text
stringlengths
28
935k
meta
stringlengths
137
139
red_pajama_subset
stringclasses
1 value
\section{Introduction} \label{sec:intro} As algorithmic predictions are increasingly employed as parts of systems that \emph{classify people}, concerns that such classfiers may be \emph{biased} or \emph{discriminatory} have increased correspondingly. These concerns are far from hypothetical; disparate treatment on the basis of \emph{sensitive features}, like race and gender, has been well-documented in diverse algorithmic application domains \cite{gendershades, wordvecs, korolovaFB}. As such, researchers across fields like computer science, machine learning, and economics have responded with many works aiming to address the serious issues of fairness and unfairness that arise in automated decision-making systems.\footnote{Moritz Hardt's lecture communicates this trend quite succinctly. \url{https://fairmlclass.github.io/1.html#/4}} While most researchers studying algorithmic fairness can agree on the high-level objectives of the field (e.g.,\ \emph{to ensure individuals are not mistreated on the basis of protected attributes; to promote social well-being and justice across populations}), there is much debate about how to translate these normative aspirations into a concrete, formal \emph{definition} of what it means for a prediction system to be fair. Indeed, as this nascent field has progressed, the efforts to promote ``fair prediction'' have grown increasingly divided, rather than coordinated. Exacerbating the problem, \cite{mitchell} identifies that each new approach to fairness makes its own set of assumptions, \emph{often implicitly}, leading to contradictory notions about the right way to approach fairness \cite{chouldechova,kmr}; these inconsistencies add to the ``serious challenge for cataloguing and comparing defintions'' \cite{mitchell}. Complicating matters further, recent works \cite{delayed,goel} have identified shortcomings of many well-established notions of fairness. At the extreme, these works argue that blindly requiring certain statistical fairness conditions may in fact \emph{harm} the communities they are meant to protect. The state of the literature makes clear that choosing an appropriate notion of fairness for prediction tasks is a challenging affair. Increasingly, fairness is viewed as a context-dependent notion \cite{selbst,fifty}, where the ``right'' notion for a given task should be informed by conversations between computational and social scientists. In the hopes of unifying some of the many directions of research in the area, we take a step back and ask whether there are guiding princples that broadly serve the high-level goals of ``fair'' prediction, without relying too strongly on any specific notion of fairness. The present work argues that understanding the ``informativeness'' of predictions needs to be part of any sociotechnical conversation about the fairness of a prediction system. Our main contribution is to provide a technical language with strong theoretical backing to discuss informational issues in the context of fair prediction. \vspace{-11pt} \paragraph{Our contributions.} Towards the goal of understanding common themes across algorithmic fairness, we investigate the role of \emph{information} in fair prediction. We study a formal notion of informativeness in predictions and demonstrate that it serves as an effective tool for understanding and improving the utility, fairness, and impact of downstream decisions. In short, we identify that many ``failures'' of requiring fairness in prediction systems can be explained by an \emph{information disparity} across subpopulations. Further, we provide algorithmic tools that aim to counteract these failures by improving informativeness. Importantly, the framework is not wedded to any specific fairness desideratum and can be applied broadly to prediction settings where discrimination may be a concern. Our main contributions can be summarized as follows: \vspace{-7pt} \begin{itemize} \item First and foremost, we identify informativeness as a key fairness desideratum. We provide information-theoretic and algorithmic tools for reasoning about how much an individual's prediction reveals about their eventual outcome. Our formulation clarifies the intuition that more informative predictions should enable fairer outcomes, across a wide array of interpretations of what it means to be ``fair.'' Notably, \emph{calibration} plays a key technical role in this reasoning; the information-theoretic framework we present relies intimately on the assumption that the underlying predictors are calibrated. Indeed, our results demonstrate a surprising application of these calibration-based methods towards improving parity-based fairness criteria, running counter to the conventional wisdom that calibration and parity are completely at odds with one another. \item In Section~\ref{sec:info}, we provide a self-contained exposition of the framework we use to study the \emph{information content} of a predictor. Information content formally quantifies the uncertainty over individuals' outcomes given their predictions. Leveraging properties of calibrated predictors, we show that the information content of a predictor is directly related to the \emph{information loss} between the \emph{true} risk distribution and the \emph{predicted} risk distribution. Therefore, in many cases, information content -- a measurable characteristic of the predicted risk distribution -- can serve as a proxy for reasoning about the information disparity across groups. To compare the information content of multiple predictors, we need a key concept called a \emph{refinement}; informally, a refinement of a predictor increases the overall information content, without losing any of the original information. Refinements provide the technical tool for reasoning about how to \emph{improve} prediction quality. \item In Section~\ref{sec:value}, we revisit the question of finding an optimal fair selection rule. For prominent parity-based fairness desiderata, we show that the optimal selection rule can be characterized as the solution to a certain linear program, based on the given predictor. We prove that improving the information content of these predictions via refinements results in a Pareto improvement of the resulting program in terms of utility, disparity, and long-term impact. As one concrete example, if we hold the selection rule's utility constant, then \emph{refining the underlying predictions causes the disparity between groups to decrease}. Additionally, we prove that at times, the \emph{cost} associated with requiring fairness should be blamed on a \emph{lack of information} about important subpopulations, not on the fairness desideratum itself. \item In Section~\ref{sec:blm}, we describe a simple algorithm, \texttt{merge}, for incorporating disparate sources of information into a single calibrated predictor. The \texttt{merge} operation can be implemented efficiently, both in terms of time and sample complexity. Along the way in our analysis, we introduce the concept of \emph{refinement distance} -- a measure of how much two predictors' knowledge ``overlaps'' -- that may be of independent interest. \end{itemize} Finally, a high-level contribution of the present work is to \emph{clarify challenges} in achieving fairness in prediction tasks. Our framework for tracking and improving information is particularly compelling because it does not requires significant technical background in information theory nor algorithms to understand. We hope the framework will facilitate interactions between computational and social scientists to further unify the literature on fair prediction, and ultimately, effect change in the fairness of real-world prediction systems. \subsection{Why information?} We motivate the study of information content in fair prediction by giving an intuitive overview of how information disparities can lead to unfair treatment and impact. We scaffold our discussion around examples from two recent works \cite{delayed,goel} that raise concerns about using broad-strokes statistical tests as the \emph{definition} of fairness. This overview will be informal, prioritizing intuition over technicality; see Section~\ref{sec:prelim} for the formal preliminaries. We consider a standard prediction setting where a decision maker, who we call the \emph{lender}, has access to a \emph{predictor} $z:\X \to [0,1]$; from the predicted risk score $z(x)$, the decison maker must choose whether to accept or reject the individual $x \in \X$, i.e.\ whether to give $x$ a loan or not. For each individual $x \in \X$, we assume there is an associated outcome $y \in \set{0,1}$ representing if they would default or repay a given loan ($0$ and $1$, respectively). Throughout, we will be focused on \emph{calibrated} predictors. Intuitively, calibration requires that a predicted score of $z(x) = p$ corresponds to the same level of risk, regardless of whether $x \in A$ or $x \in B$. More technically, this means that we can think of $z(x) = p$ as a conditional \emph{probability}; that is, amongst the individuals who receive score $z(x) = p$, a $p$-fraction of them end up having $y=1$. For simplicity, we assume there are two disjoint subpopulations $A,B \subseteq \X$. The works of \cite{delayed,goel} mainly focus on settings where there are material differences between the distribution of $y$ in the populations $A$ and $B$, arguing that these differences can lead to undesirable outcomes. We argue that even if the true risk of individuals from $A$ and $B$ are identically distributed, differences in the distribution of \emph{predicted} risk scores give rise to the same pitfalls. \vspace{-11pt} \paragraph{A caution against parity.} \cite{delayed} focuses on notions of fairness that require parity between groups. One notion they study is \emph{demographic parity}, which requires that the selection rate between groups $A$ and $B$ be equal; that is, $\Pr[x\text{ selected} \given x \in A] = \Pr[x\text{ selected} \given x \in B]$. Suppose that the majority of applicants come from group $A$ and that on-average, members of $A$ tend to have higher predictions according to $z$. In such a setting, an unconstrained utility-maximizing lender would give out loans at a higher rate in $A$ than in $B$. The argument in \cite{delayed} against requiring demographic parity goes as follows: a lender who is constrained to satisfy demographic parity must either give out fewer loans in $A$ or more in $B$; because the lender does not want to give up utility from loaning to $A$, the constrained lender will give out more loans in $B$. \cite{delayed} argue that in many reasonable settings, the lender will end up loaning to \emph{underqualified} individuals in $B$ who are unlikely to repay; thus, the default rate in $B$ will increase significantly. In their model, this increased default rate translates into \emph{negative impact} on the population $B$, whose members may go into debt and become even less creditworthy. \vspace{-11pt} \paragraph{A caution against calibration.} In general, \cite{goel} advocates for the use of calibrated score functions paired with threshold selection policies, where an individual is selected if $z(x) > \tau$ for some fixed, group-independent threshold $\tau$. Still, they caution that threshold policies paired with calibrated predictors are not sufficient to guarantee equitable treatment. In particular, suppose that the lender is willing to accept individuals if they have at least $0.7$ probability of returning the loan. But now consider a set of calibrated risk scores where the scores are much more confident about $A$ than about $B$; at the extreme, suppose that for $x \in A$, $z(x) \in \set{0,1}$ (i.e.\ perfect predictions) and for $x \in B$, $z(x)=0.5$ (i.e.\ uniform predictions). In this case, using a fixed threshold of $\tau = 0.7$ will select every qualified individual in $A$ and none of the individuals from $B$, even though, by the fact that $z$ is calibrated, half of them were qualified. Worse yet, even if we try to select more members of $B$, every member of $B$ has a $0.5$ probability of defaulting. Indeed, in this example, we cannot distinguish between the individuals in $B$ because they all receive the same score $z(x)$. In other words, we have no \emph{information} within the population $B$ even though the predictor was calibrated. These examples make clear that when there are actual differences in the risk score distributions between populations $A$ and $B$, seemingly-natural approaches to ensuring fairness -- enforcing parity amongst groups or setting a group-independent threshold -- may result in a disservice to the underrepresented population. These works echo a perspective raised by \cite{fta} that emphasizes the distinction between requiring broad-strokes demographic parity as a \emph{constraint} versus stating parity as a \emph{desideratum}. Even if we believe that groups should ideally be treated similarly, defining fairness as satisfying a set of hard constraints may have unintended consequences. Note that the arguments above relied on differences in the predicted risk scores $z(x)$ for $x \in A$ and $x \in B$, but not the true underlying risk. This observation has two immediate corollaries. On the one hand, in both of these vignettes, if the \emph{predicted} score distributions are different between population $A$ and $B$, then such approaches to fairness could still cause harm, \emph{even if the true score distributions are identically distributed}. On the other hand, just because $A$ and $B$ look different according to the predicted scores, they may not actually be different. Intuitively, the difference between the \emph{true} risk distribution and the \emph{observed} risk distribution represents a certain ``information loss.'' Optimistically, if we could somehow improve the informativeness of the predicted scores to reflect the underlying populations more accurately, then the resulting selection rule might exhibit less disparity between $A$ and $B$ in both treatment and impact. Concretely, suppose we're given a set of predicted risk scores where the scores in $A$ tend to be much more extreme (towards $0$ and $1$) than those of $B$. Differences in the risk score distributions such as these can arise for one of two reasons: either individuals from $B$ are \emph{inherently} more stochastic and unpredictable than those in $A$; or somewhere along the risk estimation pipeline, more information was lost about $B$ than about $A$. Understanding which story is true can be challenging, if not impossible. Still, in cases where we can reject the hypothesis that certain individuals are inherently less predictable than others, the fundamental question to ask is how to recover the lost information in our predictions. In this work, we provide tools to answer this question. \vspace{-11pt} \paragraph{Refinements.} Here, we give a technical highlight of the notion of a \emph{refinement} and the role refinements serve in improving fairness. In Section~\ref{sec:info}, we introduce the concept of \emph{information content}, $I(z)$ which gives a global measure of how informative a calibrated predictor $z$ is over the population of individuals; intuitively, as $I(z)$ increases, the uncertainty in a typical individual's outcome decreases. The idea that more information in predictions could lead to better utility or better fairness is not particularly surprising. Still, this intuition on its own presents some challenges. For example, suppose we're concerned about minimizing the false positive rate (the fraction of the population where $y=0$ that were selected). Because $I$ is a \emph{global} measure of uncertainty over all of $\X$, $I(z)$ could be very high due to confidence about a population $S_0 \subseteq \X$ that is very likely to have $y=0$ ($z(x)$ close to $0$), even though $z$ gives very little information ($z(x)$ far from $0$ or $1$) about the rest of $\X$, which consists of a mix of $y=0$ and $y=1$. In this case, a predictor $z'$ with less information ($I(z')$), but better certainty about even a tiny part of the population where $y=1$ ($z(x)$ close to $1$) would enable lower false positive rates (with nontrivial selection rate). As such, we need another way to reason about what it means for one set of predicted risk scores to have ``better information'' than the other. Refinements provide the key tool for comparing the information of predictors. Intuitively, a calibrated predictor $\rho:\X \to [0,1]$ is a refinement of $z$ if $\rho$ hasn't forgotten any of the information contained by $z$. Formally, we say that $\rho$ \emph{refines} $z$ if $\E_{x \sim \X}[\rho(x) \given z(x) = v] = v$; this definition is closely related to the idea of calibration in a sense that we make formal in Proposition~\ref{prop:refine}. Refinements allow us to reason about how information influences a broad range of quantities of interest in the context of fair prediction. To give a sense of this, consider the following lemma, which we use to prove our main result in Section~\ref{sec:value}, but is also independently interesting. The lemma shows that under any fixed selection rate $\beta = \Pr_{x \sim \X}[f(x) = 1]$, the true positive rates, false positive rates, and positive predictive value all improve with a nontrivial refinement. \begin{lemma*} If $\rho$ is a refinement of $z$, then for all selection rates $\beta \in [0,1]$, \begin{align*} \TPR^{\rho}(\beta)\ge \TPR^z(\beta),&& \FPR^{\rho}(\beta)\le \FPR^z(\beta),&& \PPV^{\rho}(\beta)\ge \PPV^z(\beta). \end{align*} \end{lemma*} Intuitively, the lemma shows that by improving information through refinements, mutliple key fairness quantities improve simultaneously. Leveraging this lemma and other properties of refinements and calibration, we show that for many different ways a decision-maker might choose their ``optimal'' selection rule, the ``quality'' of the selection rule improves under refinements. We highlight this lemma as one example of the broad applicability of the refinement concept in the context of fair prediction. \vspace{-11pt} \paragraph{Perspective.} Disparities in the information content of risk scores may arise for many reasons. The present work clarifies how disparities across groups at early stages of the decision-making pipeline may contribute to disparities in the downstream decisions. In particular, differences in the availability or quality of training data as well as optimization procedures that are tailored for performance in the majority population could contribute to information loss in the minority. The present work highlights the importance of auditing existing risk score predictors for information content across groups, and demonstrates that obtaining informative calibrated predictions can improve fair selection rules, even when the fairness desiderata are based on parity. \vspace{-11pt} \paragraph{Organization.} The manuscript is structured as follows: Section~\ref{sec:prelim} establishes notation and covers the necessary preliminaries; Section~\ref{sec:info} provides the technical framework for measuring information in predictors; Section~\ref{sec:value} demonstrates how improving information content improves the resulting fair selection rules; and Section~\ref{sec:blm} describes the \texttt{merge} algorithm for combining and refining multiple predictors. We conclude with a brief discussion of the context of this work and some directions for future investigation. \subsection{Related Works} The influential work of \cite{fta} provided two observations that are of particular relevance to the present work. First, \cite{fta} emphasized the pitfalls of hoping to achieve ``fairness through blindness'' by censoring sensitive information during prediction. Second, the work highlighted how enforcing broad-strokes demographic parity conditions -- even if desired or expected in fair outcomes -- is insufficient to imply fairness. Our results can be viewed as providing further evidence for these perspectives. As discussed earlier, understanding the ways in which fair \emph{treatment} can fail to provide fair \emph{outcomes} \cite{goel,delayed} provided much of the motivation for this work. For a comprehensive overview of the literature on the growing list of approaches to fairness in prediction systems, we recommend the recent encyclopedic survey of \cite{mitchell}. A few recent works have (implicitly or explicitly) touched on the relationship between information and fairness. \cite{chen} argues that discrimination may arise in prediction systems due to disparity in predictive power; they advocate for addressing discrimination through data collection. Arguably, much of the work on fairness in online prediction \cite{joseph2016fairness} can be seen as a way to gather information while maintaining fairness. Recently, issues of information and fairness were also studied in unsupervised learning tasks \cite{fairpca}. From the computational economics literature, \cite{kleinberg2018algorithmic} presents a simple planning model that draws similar qualitative conclusions to this work, demonstrating the significance of trustworthy information as a key factor in algorithmic fairness. The idea that better information improves the lender's ability to make useful and fair predictions may seem intuitive under our framing. Interestingly, different framings of prediction and informativeness can lead to qualitatively different conclusions. Specifically, the original work on delayed impact \cite{delayed} suggests that some forms of misestimation (i.e.\ loss of information) may reduce the potential for harm from applying parity-based fairness notions. In particular, if the lender's predictor $z$ is miscalibrated in a way that underestimates the quality of a group $S$, then increasing the selection rate beyond the global utility-maximizing threshold may be warranted. In our setting, because we assume that the lender's predictions are calibrated, this type of systematic bias in predictions cannot occur, and more information always improves the resulting selection rule. This discrepancy further demonstrates the importance of group calibration to our notion of information content. Other works \cite{juba1,juba2} have investigated the role of \emph{hiding} information through strategic signaling. In such settings, it may be strategic for a group to hide information about individuals in order to increase the overall selection rate for the group. These distinctions highlight the fact that understanding exactly the role of information in ``fair'' prediction is subtle and also depends on the exact environment of decision-making. We further discuss how to interpret our theorems as well as the importance of faithfully translating fairness desiderata into mathematical constraints/objectives in Section~\ref{sec:discussion}. The present work can also be viewed as further investigating the tradeoffs between calibration and parity. Inspired by investigative reporting on the ``biases'' of the COMPAS recidivism prediction system \cite{propublica}, the incompatability of calibration and parity-based notions of fairness has received lots of attention in recent years \cite{chouldechova,kmr,pleiss}. Perhaps counterintuitively, our work shows how to leverage properties of calibrated predictors to improve the disparity of the eventual decisions. At a technical level, our techniques are similar in flavor to the those of \cite{multi}, which investigates how to strengthen group-level calibration as a notion of fairness; we discuss further connections to \cite{multi} in Section~\ref{sec:discussion}. Outside the literature on fair prediction, our notions of information content and refinements are related to other notions from the fields of online forecasting and information theory. In particular, the idea of refinements was first introduced in \cite{degroot}. The concept of information content of calibrated predictions is related to ideas from the forecasting literature \cite{gneiting2007probabilistic,gneiting2007strictly}, including \emph{sharpness} and \emph{proper scoring rules} \cite{brier}. The concept of a refinement of a calibrated predictor can be seen as a special case of Blackwell's informativeness criterion \cite{blackwell,cremer,degroot}. \section{Preliminaries} \label{sec:prelim} \paragraph{Basic notation.} Let $\X$ denote the domain of individuals and $\Y = \set{0,1}$ denote the binary outcome space. We assume that individuals and their outcomes are jointly distributed according to $\D$ supported on $\X \times \Y$. Let $x,y \sim \D$ denote an independent random draw from $\D$. For a subpopulation $S \subseteq \X$, we use the shorthand $x,y \sim \D_S$ to be the data distribution conditioned on $x \in S$, and $x \sim S$ to denote a random sample from the marginal distribution over $\X$ conditioned on membership in $S$. \vspace{-11pt} \paragraph{Predictors.} A basic goal in learning is to find a \emph{classifier} $f:\X \to \set{0,1}$ that given $x \sim \X$ drawn from the marginal distribution over individuals, accurately predicts their outcome $y$. One common strategy for binary classification first maps individuals to a real-valued \emph{score} using a \emph{predictor} $z:\X \to [0,1]$ and then selects individuals on the basis of this score. We denote by $\supp(z)$ the support of $z$. We denote by $p^*:\X \to [0,1]$ the \emph{Bayes optimal predictor}, where $p^*(x) = \Pr_\D\left[y = 1 \given x\right]$ represents the inherent uncertainty in the outcome given the individual. Equivalently, for each individual $x \in \X$, their outcome $y$ is drawn independently from $\Ber(p^*(x))$, the Bernoulli distribution with expectation $p^*(x)$. While we use $[0,1]$ to denote the codomain of predictors, throughout this work, we assume that the set of individuals is finite and hence, the support of any predictor is a discrete, finite subset of the interval. \vspace{-11pt} \paragraph{Risk score distributions.} Note that there is a natural bijection between predictors and \emph{score distributions}. A predictor $z$, paired with the marginal distribution over $\X$, induces a score distribution, which we denote $\S^z$, supported on $[0,1]$, where the probability density function is given as $\S^z(v) = \Pr_{x \sim \X}\left[z(x) = v\right]$. For a subpopulation $S \subseteq \X$, we denote by $\S^z_S$ the score distribution conditioned on $x \in S$. \vspace{-11pt} \paragraph{Calibration.} A useful property of predictors is called \emph{calibration}, which implies that the scores can be interpreted meaningfully as the probability that an individual will result in a positive outcome. Calibration has been studied extensively in varied contexts, notably in forecasting and online prediction (e.g.\ \cite{fv}), and recently as a fairness desideratum \cite{kmr,pleiss,multi,goel}; the definition we use is adapted from the fairness literature. \begin{definition}[Calibration] A predictor $z:\X \to [0,1]$ is \emph{calibrated} on a subpopulation $S \subseteq \X$ if for all $v \in \supp(z)$, \begin{equation*} \Pr_{x,y \sim \D_S}\left[y = 1 \given z(x) = v\right] = v.\label{def:calibration} \end{equation*} \end{definition} For convenience when discussing calibration, we use the notation $S_{z(x)=v} = \set{x \in S : z(x) =v }$. Note that we can equivalently define \emph{calibration with respect to the Bayes optimal predictor}, where $z$ is calibrated on $S$ if for all $v \in \supp(z)$, $\E_{x \sim S_{z(x)=v}}\left[p^*(x)\right] = v$. Operationally in proofs, we end up using this definition of calibration. This formulation also makes clear that $p^*$ is calibrated on every subpopulation. \vspace{-11pt} \paragraph{Parity-based fairness.} As a notion of fairness, calibration aims to ensure similarity between predictions and the true outcome distribution. Other fairness desiderata concern disparity in prediction between subpopulations on the basis of a sensitive attribute. For simplicity, we will imagine individuals are partitioned into two subpopulations $A,B \subseteq \X$; we will overload notation and use $\set{A,B}$ to denote the names of the attributes as well. We let $\A:\X \to \set{A,B}$ map individuals to their associated attribute. The most basic notion of parity is \emph{demographic parity} (also sometimes called \emph{statistical parity} in the literature), which states that the selection rate of individuals should be independent of the sensitive attribute. \begin{definition}[Demographic parity \cite{fta}] A selection rule $f:\X \to \set{0,1}$ satisfies \emph{demographic parity} if \begin{equation*} \Pr_{x \sim \X}\left[f(x) = 1 \given \A(x) = A\right] = \Pr_{x \sim \X}\left[f(x) = 1 \given \A(x) = B\right]. \end{equation*} \end{definition} One critique of demographic parity is that the notion does not take into account the actual qualifications of groups (i.e.\ no dependence on $y$). Another popular parity-based notion, called \emph{equalized opportunity}, addresses this criticism by enforcing parity of \emph{false negative rates} across groups. \begin{definition}[Equalized opportunity \cite{hps}] A selection rule $f:\X \to \set{0,1}$ satisfies \emph{equalized opportunity} if \begin{equation*} \Pr_{x,y \sim \D}\left[f(x) = 0 \given y=1,\ \A(x) = A\right] = \Pr_{x,y \sim \D}\left[f(x) = 0 \given y=1,\ \A(x) = B\right] \end{equation*} \end{definition} In addition to these fairness concepts, the following properties of a selection rule will be useful to track. Specifically, we define the true positive rate ($\TPR$), false positive rate ($\FPR$), and positive predictive value ($\PPV$). \begin{align*} \TPR(f) &= \Pr_{x,y \sim \D}\left[f(x) = 1 \given y=1\right]\\ \FPR(f) &= \Pr_{x,y \sim \D}\left[f(x) = 1 \given y=0\right]\\ \PPV(f) &= \Pr_{x,y \sim \D}\left[y=1 \given f(x) = 1\right] \end{align*} \section{Measuring information in binary prediction} \label{sec:info} In this section, we give a self-contained exposition of a formal notion of information content in calibrated predictors. These notions have been studied extensively in the forecasting literature (see \cite{gneiting2007probabilistic,gneiting2007strictly} and references therein), but are less common in the literature on computational and statistical learning theory. Our notion of information content can be derived from the Brier scoring rule \cite{brier}. \label{sec:info:content} In the context of binary prediction, a natural way to measure the ``informativeness'' of a predictor is by the uncertainty in an individual's outcome given their score. We quantify this uncertainty using \emph{variance}.\footnote{ Alternatively, we could measure uncertainty through Shannon entropy (in fact, any function that admits a Bregman divergence). The generality of the approach is made clear in \cite{gneiting2007strictly}. In Appendix~\ref{app:entropy}, we show that notions of information that arise from Shannon entropy are effectively interchangeable with those that arise from variance. We elect to work with variance in the main body primarily because it simplifies the analysis in Section~\ref{sec:blm}.} For $p \in [0,1]$, the variance of a Bernoulli random variable with expected value $p$ is given as $\Var(\Ber(p)) = p \cdot (1-p)$. Note that variance is a strictly concave function in $p$ and is maximized at $p=1/2$ and minimized $p\in \set{0,1}$; that is, a Bernoulli trial with $p=1/2$ is maximally uncertain whereas a trial with $p=0$ or $p=1$ is perfectly certain. Consider a random draw $x,y \sim \D$. If $z$ is a calibrated predictor, then given $x$ and $z(x)$, the conditional distribution over $y$ follows a Bernoulli distribution with expectation $z(x)$. This observation suggests the following defintion. \begin{definition}[Information content] Suppose for $S \subseteq \X$, $z:\X\to[0,1]$ is calibrated on $S$. The \emph{information content} of $z$ on $S$ is given as \begin{equation*} I_S(z) = 1-4\cdot\E_{x \sim S}\left[z(x)(1-z(x))\right]. \end{equation*} \end{definition} For a calibrated $z$, we use $I(z) = I_\X(z)$ to denote the ``information content of $z$''. The factor $4$ in the definition of information content acts as a normalization factor such that $I(z) \in [0,1]$. At the extremes, a perfectly informative predictor has information content $1$, whereas a calibrated predictor that always outputs $1/2$ has $0$ information. This formulation of information content as uncertainty in a binary outcome is intuitive in the context of binary classification. In some settings, however, it may be more instructive to reason about risk score distributions directly. A conceptually different approach to measuring informativeness of a risk score distribution might track the uncertainty in the true (Bayes optimal) risk, given the predicted risk score. Consider a random variable $P^*_{z(x)=v}$ that takes value $p^*(x)$ for $x$ sampled from the individuals with score $z(x) = v$; that is, $P^*_{z(x)=v}$ equals the true risk for an individual sampled amongst those receiving predicted risk score $v$. Again, we could measure the uncertainty in this random variable by tracking its variance given $z(x) = v$; the higher the variance, the less information the risk score distribution $\S_z$ provides about the true risk score distribution $\S_{p^*}$. Recall, for a predictor $z$ that is calibrated on $S \subseteq \X$ and score $v \in [0,1]$, we let $S_{z(x)= v}= \set{x \in S : z(x)=v}$. Consider the variance in $P^*_v$ given as \begin{align*} \Var\left[P^*_{z(x)=v}\right] &= \Var_{x \sim S_{z(x) = v}}\left[p^*(x)\right]\\ &= \E_{x \sim S_{z(x)=v}}\left[\left(p^*(x) - v\right)^2\right]. \end{align*} We define the \emph{information loss} by taking an expectation of this conditional variance over the score distribution induced by $z$. \begin{definition}[Information loss] For $S \subseteq \X$, suppose a predictor $z:\X \to [0,1]$ is calibrated on $S$. The \emph{information loss} of $z$ on $S$ is given as \begin{equation*} L_S(p^*;z) = 4 \cdot \E_{\substack{v \sim \S^z_S\\x \sim S_{z(x)=v}}}\left[\left(p^*(x) - v\right)^2\right] \end{equation*} \end{definition} Again, the factor $4$ is simply to normalize the information loss into the range $L(p^*;z) \in [0,1]$. This loss is maximized when $p^*$ is a $50$:$50$ mix of $\set{0,1}$ but $z$ always predicts $1/2$; the information loss is minimized for $z = p^*$. We observe that this notion of information loss is actually proportional to the expected squared error of $z$ with respect to $p^*$; that is, \begin{align*} \E_{\substack{v \sim \S_S^z\\x \sim S_{z(x)=v}}}\left[\left(p^*(x) - v\right)^2\right] &= \sum_{v \in \supp(z)}\S_S^z(v) \cdot \E_{x \sim S_{z(x)=v}}\left[\left(p^*(x) - v\right)^2\right]\\ &= \E_{x \sim S}\left[\left(p^*(x) - z(x)\right)^2\right] \end{align*} Thus, for calibrated predictors, we can interpret the familiar squared loss between a predictor and the Bayes optimal predictor as a notion of information loss. \vspace{-11pt} \paragraph{Connecting information content and information loss.} As we defined them, information content and information loss seem like conceptually different ways to measure uncertainty in a predictor. Here, we show that they actually capture the same notion. In particular, we can express information loss of $z$ as the difference in information content of $p^*$ and that of $z$. \begin{proposition} \label{prop:infoloss} Let $p^*:\X \to [0,1]$ denote the Bayes optimal predictor. Suppose for $S \subseteq \X$, $z:\X \to [0,1]$ is calibrated on $S$. Then \begin{equation*} \label{eqn:infoloss} L_S(p^*;z) = I_S(p^*) - I_S(z). \end{equation*} \end{proposition} \begin{proof} The proof follows by expanding the information loss and rearranging so that, assuming $z$ is calibrated, terms cancel. As notational shorthand, let $S_v = S_{z(x)=v}$ and let $\bar{p} = \E_{x \sim S}[p^*(x)] = \E_{x \sim S}[z(x)]$. Thus, we can rewrite the information loss $L_S(p^*;z)$ as follows. \begin{align*} 4 \cdot \E_{x \sim S}\left[\left(p^*(x) - z(x)\right)^2\right] &= 4\cdot \E_{x \sim S}\left[p^*(x)^2 + z(x)^2 - 2p^*(x)\cdot z(x)\right]\\ &=4 \cdot \sum_{v \in \supp(z)}\S_S^z(v)\cdot \left(\E_{x \sim S_v}\left[p^*(x)^2\right] + v^2 - 2\E_{x \sim S_v}\left[p^*(x)\right]\cdot v\right)\\ &=4 \cdot \sum_{v \in \supp(z)}\S_S^z(v)\cdot \E_{x \sim S_v}\left[p^*(x)^2 - v^2\right]\label{eqn:infos:cal}\addtag\\ &=4 \cdot \E_{x \sim S}\left[p^*(x)^2 - z(x)^2\right]\\ &= \left(1 - 4 \cdot \E_{x \sim S}\left[\bar{p} - p^*(x)^2\right]\right) - \left(1 - 4 \cdot \E_{x \sim S}\left[\bar{p}-z(x)^2\right]\right)\\ &= I_S(p^*) - I_S(z) \end{align*} where (\ref{eqn:infos:cal}) follows because $\E_{x \sim S_v}\left[p^*(x)\right] = v$ under calibration. \end{proof} Because the information loss is a nonnegative quantity, Proposition~\ref{prop:infoloss} also formalizes the inutition that the Bayes optimal predictor is the most informative predictor; for $z \neq p^*$, $I(z) < I(p^*) \le 1$. Ideally, in order to evaluate the information disparity across groups, we would compare the information lost from $p^*$ to $z$ across $A$ and $B$. But because the definition of information loss depends on the true score distribution $p^*$, in general, it's impossible to directly compare the loss. Still, if we believe that $p^*(x)$ is similarly distributed across $x \sim A$ and $x \sim B$, then measuring the information contents $I_A(z)$ and $I_B(z)$ -- properties of the \emph{observed} risk scores -- allows us to directly compare the loss. \subsection{Incorporating information via refinements} \label{sec:info:refine} We have motivated the study of informativeness in prediction with the intuition that as information content improves, so too will the resulting fairness and utility of the decisions derived from the predictor. Without further assumptions, however, this line of reasoning turns out to be overly-optimistic. For instance, consider a setting where the expected utility of lending to individuals is positive if $z(x) > \tau$ for some fixed threshold $\tau$ (and negative otherwise). In this case, information about individuals whose $p^*(x)$ is significantly below $\tau$ is not especially useful. Figure~\ref{fig:pmfs} gives an example of two predictors, each calibrated to the same $p^*(x)$, where $I(z') > I(z)$, but $z$ is preferable. At a high-level, the example exploits the fact that information content $I(z)$ is a global property of $z$, whereas the quantities that affect the utility and fairness directly, like $\PPV$ or $\TPR$ are \emph{conditional} properties. Even if $I(z') > I(z)$, it could be that $z'$ has lost information about an important subpopulation compared to $z$, compensating with lots of information about the unqualified individuals. \begin{figure}[t!] \centering \vspace{-22pt} \includegraphics[width=0.3\textwidth]{zpmf}\hspace{8pt} \includegraphics[width=0.3\textwidth]{zprimepmf} \vspace{-11pt} \caption{Comparing information content directly is insufficient to compare predictors' utility. \emph{Two predictors $z,z':\X \to [0,1]$ are each calibrated to $p^*:\X \to \set{0,1}$ with $\E\left[p^*(x)\right] = 1/2$. In $z$, $\Pr[z(x) = 1/3] = 3/5$ and $\Pr[z(x) = 3/4] = 2/5$; in $z'$, $\Pr[z(x) = 0] = 1/4$ and $\Pr[z(x) = 2/3] = 3/4$. $I(z') > I(z)$, but $z$ achieves better utility than $z'$ whenever $2/3 < \tau < 3/4$.}}\label{fig:pmfs} \vspace{-11pt} \end{figure} Still, we would like to characterize ways in which more information is definitively ``better.'' Intuitively, more information is better when we don't have to give up on the information in the current predictor, but rather refine the information contained in the predictions further. The following definition, equivalent to a notion proposed in \cite{degroot}, formalizes this idea. \begin{definition}[Refinement] For $S \subseteq \X$, suppose $z,z':\X \to [0,1]$ are calibrated on $S$. $z'$ is a \emph{refinement} of $z$ on $S$ if for all $v \in \supp(z)$, \begin{equation*} \E_{x \sim S_{z(x)=v}}\left[z'(x)\right] = v. \end{equation*} \end{definition} That is, we say that $z'$ \emph{refines} $z$ if $z'$ maintains the same expectation over the level sets $S_{z(x)=v}$. To understand why this property makes sense in the context of maintaining information from $z$ to $z'$, suppose the property was violated: that is, there is some $v \in \supp(z)$ such that $\E_{x \sim S_{z(x)=v}}[z'(x)]\neq v$. This disagreement provides evidence that $z$ has some consistency with the true risk that $z'$ is lacking; because $z$ is calibrated, $\E_{x \sim S_{z(x)=v}}[z(x)] = v = \E_{x \sim S_{z(x)=v}}[p^*(x)]$. In other words, even if $z'$ has greater information content, it may not be consistent with the content of $z$. Another useful perspective on refinements is through measuring the information on each of the sets $S_{z(x)=v}$. Restricted to $S_{z(x)=v}$, $z$ has minimal information content -- its predictions are constant -- whereas $z'$ may vary. Because $z'$ is calibrated and maintains the expectation over $S_{z(x)=v}$, we can conclude that $I_{S_{z(x)=v}}(z) \le I_{S_{z(x)=v}}(z')$ for each of the partitions. This perspective highlights the importance of requiring \emph{calibration} in the definition of refinements. Indeed, because a refinement is a calibrated predictor, refinements cannot make arbitrary distinctions in predictions, so any additional distinctions on the level sets of the original predictor must represent true variability in $p^*$. We draw attention to the similarity between the definition of a refinement and the definition of calibration. In particular, if $z'$ is a refinement of $z$, then $z$ is not only calibrated with respect to $p^*$, but also with respect to $z'$; stated differently, $p^*$ is a refinement of every calibrated predictor. Indeed, one way to interpret a refinement is as a ``candidate'' Bayes optimal predictor. Carrying this intuition through, we note that the only property of $p^*$ we used in the proof of Proposition~\ref{prop:infoloss} is that it is a refinement of a calibrated $z$. Thus, we can immediately restate the proposition in terms of generic refinements. \begin{proposition}\label{prop:refine} Suppose for $S \subseteq \X$, $z,z':\X \to [0,1]$ are calibrated on $S$. If $z'$ refines $z$ on $S$, then $L_S(z';z) = I_S(z') - I_S(z)$. \end{proposition} This characterization further illustrates the notion that a refinement $z'$ could plausibly be the true risk given the information in the current predictions $z$. In particular, because $L_S(z';z)> 0$, we get $I_S(z') > I_S(z)$ for any refinement $z'\neq z$. In the context of fair prediction, we want to ensure that the information content on specific protected subpopulations does not decrease. Indeed, in this case, it may be important to ensure that the predictions are refined, not just overall, but also on the sensitive subpopulations. In Figure~\ref{fig:group:refine}, we illustrate this point by showing two predictors $z,z':\X\to[0,1]$ that are each calibrated on two subpopulations $A,B \subseteq \X$; $z'$ refines $z$ on $\X$ overall, but $z'$ loses information about the subpopulation $A$. This negative example highlights the importance of incorporating all the information available (e.g.\ group membership), not only at the time of decision-making, but also along the way when developing predictors; it serves as yet another rebuke of the approach of ``fairness through blindness'' \cite{fta}. \begin{figure}[t!] \centering \vspace{-22pt} \hspace{-22pt}\includegraphics[height=1.3in]{zcal}\hspace{-8pt}\includegraphics[height=1.3in]{zprimecal} \caption{Per-group refinement is necessary to maintain information for each group.\label{fig:group:refine} \emph{ Let $A = A_n \cup A_p$ and $B = B_n \cup B_p \cup B_0 \cup B_1$ where $r(S) = \E_{x \sim S}[p^*(x)]$ and $p(S) = \Pr_{x \sim \X}[x \in S]$. The two predictors $z,z':\X \to [0,1]$ are each calibrated on $A$ and $B$. Note that $z'$ refines $z$ overall, but has lost all information about $A$.}}\label{fig:cal} \vspace{-11pt} \end{figure} \section{The value of information in fair prediction} \label{sec:value} In this section, we argue that reasoning about the information content of calibrated predictors provides a lens into understanding how to improve the utility and fairness of predictors, even when the eventual fairness desideratum is based on parity. We discuss a prediction setting based on that of \cite{delayed} where a \emph{lender} selects individuals to give loans from a pool of \emph{applicants}. While we use the language of predicting creditworthiness, the setup is generic and can be applied to diverse prediction tasks. \cite{delayed} introduced a notion of ``delayed impact'' of selection policies, which models the potential negative impact on communities of enforcing parity-based fairness as a constraint. We revisit the question of delayed impact as part of a broader investigation of the role of information in fair prediction. We begin with an overview of the prediction setup. Then, we prove our main result: refining the underlying predictions used to choose a selection policy results in an improvement in utility, parity, or impact (or a combination of the three). \subsection{Fair prediction setup} \label{sec:value:setup} When deciding how to select qualified individuals, the lender's goal is to maximize some expected utility. Specifically, the \emph{utility function} $u:[0,1] \to [-1,1]$ specifies the lender's expected utility from an individual based on their score and a fixed threshold\footnote{Assuming such an affine utility function is equivalent to assuming that the lender receives $u_+$ from repayments, $u_-$ from defaults, and $0$ from individuals that do not receive loans. In this case, the expected utility for score $p$ is $pu_+ + (1-p)u_- = c_u \cdot u(p)$ for some constant $c_u$. A similar rationale applies to the individuals' impact function. } $\tau_u \in [0,1]$ as given in (\ref{eqn:utilityimpact}). When considering delayed impact, we will measure the expected impact per subpopulation. The \emph{impact function} $\ell:[0,1] \to [-1,1]$ specifies the expected benefit to an individual from receiving a loan based on their score and a fixed threshold $\tau_\ell$ also given in (\ref{eqn:utilityimpact}). \begin{align} \label{eqn:utilityimpact} u(p) = p - \tau_u& &\ell(p) = p - \tau_\ell \end{align} \cite{delayed} models risk-aversion of the lender by assuming that $\tau_u > \tau_\ell$; that is, by choosing accepting individuals with $z(x) \in (\tau_\ell,\tau_u)$, the impact on subpopulations may improve beyond the lender's utility-maximizing policy. In this setup, we allow the lender to pick a (randomized) group-sensitive selection policy $f:[0,1] \times \set{A,B} \to [0,1]$ that selects individuals on the basis of a predicted score and their sensitive attribute. That is, the selection policy makes decisions about individuals via their score according to some calibrated predictor $z:\X \to [0,1]$ and their sensitive attribute $\A:\X \to \set{A,B}$; for every individual $x \in \X$, the probability that $x$ is selected is given as $f(z(x),\A(x))$. We will restrict our attention to \emph{threshold policies}; that is, for sensitive attribute $A$ (resp.,\ $B$), there is some $\tau_A \in [0,1]$, such that $f(v,A)$ is given as $f(v,A) = 1$ if $v > \tau_A$, $f(v,A) = 0$ if $v < \tau_A$ and $f(v,A) = p_A$ for $v=\tau_A$, where $p_A \in [0,1]$ is a probability used to randomly break ties on the threshold. The motivation for focusing on threshold policies is their intuitiveness, widespread use, computational efficiency\footnote{Indeed, without the restriction to threshold policies, many of the \emph{information-theoretic} arguments become easier at the expense of \emph{computational cost}. As $z'$ is a refinement of $z$, we can always simulate decisions derived from $z$ given $z'$, but in general, we cannot do this efficiently.}. The restriction to threshold policies is justified formally in \cite{delayed} by the fact that the optimal decision rule in our setting can be specified as a threshold policy under both demographic parity and equalized opportunity. Given this setup, we can write the expected utility $U^z(f)$ of a policy $f$ based on a calibrated predictor $z$, that is calibrated on both subpopulations, $A$ and $B$, as follows. \begin{equation} \label{eqn:exputility} U^z(f) = \sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\sum_{v \in \supp(z)} \R^z_S(v) \cdot f(v,S) \cdot u(v)\right) \end{equation} Recall, $\S^z_S(v) = \Pr_{x \sim S}\left[z(x) = v\right]$. Similarly, the expected impact over the subpopulations $S \in \set{A,B}$ are given as \begin{equation} \label{eqn:expimpact} \mathrm{Imp}_S^z(f) =\sum_{v\in \supp(z)} {\S^z_S(v)\cdot f(v,S)\cdot \ell(v)} \end{equation} Often, it may make sense to constrain the net impact to each group as defined in (\ref{eqn:expimpact}) to be positive, ensuring that the selection policies do not do harm as in \cite{delayed}. The following quantities will be of interest to the lender when choosing a selection policy $f$ as a function of $z$. First, the lender's overall utility $U(f)$ is given as in (\ref{eqn:exputility}). In the name of fairness, the lender may also be concerned about the disparity of a number of quantities. We will show below that these quantities can be written as a linear function of the selection rule. In particular, for $S \in \set{A,B}$ demographic parity, which serve as our running example, compares the \emph{selection rates} $\beta_S = \Pr_{x \sim S}[x \text{ selected}]$, \begin{equation} \beta^z_S(f)=\sum_{v\in\supp(z)}\R^z_S(v)\cdot f(v,S). \end{equation} We may also be concerned about comparing the true positive rates (equalized opportunity) and false positive rates. Recall, $\TPR = \Pr[x \text{ selected} \given y = 1]$ and $\FPR = \Pr[x \text{ selected} \given y=0]$; in this context, we can rewrite these quantities as follows. \begin{gather} \TPR^z_S(f)=\frac{1}{r_S}\cdot\sum_{v \in \supp(z)}\R^z_S(v) \cdot f(v,S)\cdot v\\ \FPR^z_S(f)=\frac{1}{1-r_S}\cdot\sum_{v\in \supp(z)} \R^z_S(v)\cdot f(v,S)\cdot (1-v), \end{gather} where $r_S$ represents the base rate of the subpopulation $S$; that is, $r_S=\Pr_{(x,y)\sim D_S}[y=1]$. Another quantity we will track is the positive predictive value, $\PPV = \Pr[y=1 \given x \text{ selected}]$. \begin{equation} \PPV^z_S(f)=\frac{1}{\beta_S^z(f)}\cdot\left(\sum_{v\in \supp(z)}\R^z_S(v)\cdot f(v,S)\cdot v\right) \end{equation} Note that $\PPV^z_S(f)$ is not a linear function of $f(v,S)$ values, but as we never use positive predictive values directly in the optimizations for choosing a selection policy (or in a parity-based fairness definition), the optimizations are still a linear program. For notational convenience, we may drop the superscript of these quantities when $z$ is clear from the context. \subsection{Refinements in the service of fair prediction}\label{sec:improvref} Note that all of the quantities described in Section~\ref{sec:value:setup} can be written as linear functions of $f(v,S)$. Given a fixed predictor $z:\X \to [0,1]$, we can expand the quantities of interest; in particular, we note that the linear functions over $f(v,S)$ can be rewritten as linear functions over $z(x)$, where the quantities depend on $x$ only through the predictor $z$. In this section, we show how refining the predictor used for determining the selection rule can improve the utility, parity, and impact of the optimal selection rule. By the observations above, we can formulate a generic policy-selection problem as a linear program where $z$ controls many coefficients in the program. When we refine $z$, we show that the value of the program increases. Recalling that different contexts may call for different notions of fairness, we consider a number of different linear programs the lender (or regulator) might choose to optimize. At a high-level, the lender can choose to maximize utility, minimize disparity, or maximize positive impact on groups, while also maintaining some guarantees over the other quantities. We will consider selection policies given a fixed predictor $z:\X \to [0,1]$. Note that the parity-based fairness desiderata we consider are of the form $h^z_A(f)=h^z_B(f)$ for some $h\in\set{\beta,\TPR,\FPR}$; rather than requiring equality, we will consider the disparity $\card{h^z_A(f) - h^z_B(f)}$ and in some cases, constrain it to be less than some constant $\eps$. We also use $t_i,t_u$ to denote lower bounds on the desired impact and utility, respectively. For simplicity's sake, we assume that $B$ is the ``protected'' group, so we only enforce the positive impact constraint for this group; more generally, we could include an impact constraint for each group. Formally, we consider the following constrained optimizations. \begin{center} \begin{tabular}{c c c} \refstepcounter{opt}\label{opt:utility}{\bf Optimization~\theopt} & \refstepcounter{opt}\label{opt:fairness}{\bf Optimization~\theopt} & \refstepcounter{opt}\label{opt:impact}{\bf Optimization~\theopt} \\ $\max_f~U^z(f)$ &$\min_f~\card{h^z_A(f) - h^z_B(f)}$ &$\max_f~\mathrm{Imp}^z_B(f)$\\ s.t.~~$\mathrm{Imp}^z_B(f)\ge t_{i}$ & s.t.~~$\mathrm{Imp}^z_B(f)\ge t_{i}$ & s.t.~~$U^z(f)\ge t_{u}$\\ $\card{h^z_A(f)-h^z_B(f)} \le \eps$ &$U^z(f)\ge t_{u}$ &$\card{h^z_A(f)-h^z_B(f)} \le \epsilon$\\ ~~~~(\emph{Utility Maximization})~~~~ & ~~~~(\emph{Disparity minimization})~~~~ & ~~~~(\emph{Impact Maximization})~~~~ \end{tabular} \end{center} \begin{lemma} Let $h \in \set{\beta, \TPR, \FPR}$. Given a calibrated predictor $z:\X \to [0,1]$, Optimization \ref{opt:utility},\ref{opt:fairness}, and \ref{opt:impact} are linear programs in the variables $f(v,S)$ for $v \in \supp(z)$ and $S \in \set{A,B}$. Further, for each program, there is an optimal solution $f^*$ that is a threshold policy. \end{lemma} We sketch the proof of the lemma. The fact that the optimizations are linear programs follows immediately from the observations that each quantity of interest is a linear function in $f(v,S)$. The proof that there is a threshold policy $f^*$ that achieves the optimal value in each program is similar to the proof of Theorem~\ref{thm:improve} given below. Consider an arbitrary (non-threshold) selection policy $f_0$; let $h_{S,0} = h_S(f_0)$. The key observation is that for the fixed value of $h_{S,0}$, there is some other threshold policy $f$ where $h^z_S(f) = h_{S,0}$ and $U^z(f) \ge U(f_0)$ and $\mathrm{Imp}^z_S(f) \ge \mathrm{Imp}_S(f_0)$. Leveraging this observation, given any non-threshold optimal selection policy, we can construct a threshold policy, which is also optimal. We remark that our analysis applies even if considering the more general linear maximization: \begin{center} \begin{tabular}{c} \refstepcounter{opt}\label{opt:generic}{\bf Optimization~\theopt}\\ $\max_f~~ \lambda_U \cdot U^z(f) + \lambda_I\cdot \mathrm{Imp}_B^z(f) - \lambda_\beta\cdot \card{h^z_A(f)-h^z_B(f)}$ \end{tabular} \end{center} for any fixed $\lambda_U, \lambda_I, \lambda_\beta\ge 0$.\footnote{In particular, each of Optimizations~\ref{opt:utility}, \ref{opt:fairness}, and \ref{opt:impact} can be expressed as an instance of Optimization~\ref{opt:generic} by choosing $\lambda_U, \lambda_I, \lambda_\beta$ to be the optimal dual multipliers for each program. We note that the dual formulation actually gives an alternate way to derive results from \cite{delayed}. Their main result can be restated as saying that there exist distributions of scores such that the dual multiplier on the positive impact constraint in Optimization~\ref{opt:utility} is positve; that is, without this constraint, the utility-maximizing policy will do negative impact to group $B$.} In other words, the arguments hold no matter the relative weighting of the value of utility, disparity, and impact. \vspace{-11pt} \paragraph{Improving the cost of fairness.} We argue that in all of these optimizations, increasing information through refinements of the current predictor on both the subpopulations $A$ and $B$ improves this value of the program. We emphasize that this conclusion is true for all of the notions of parity-based fairness we mentioned above. Thus, independent of the exact formulation of fair selection that policy-makers deem appropriate, information content is a key factor in determining the properties of the resulting selection rule. We formalize this statement in the following theorem. \begin{theorem}\label{thm:improve} Let $z,z':\X\rightarrow[0,1]$ be two predictors that are calibrated on disjoint subpopulations $A,B \subseteq \X$. For any of the Optimization~\ref{opt:utility},~\ref{opt:fairness},~\ref{opt:impact},~\ref{opt:generic} and their corresponding fixed parameters, let $\textrm{OPT}(z)$ denote their optimal value under predictor $z$. If $z'$ refines $z$ on $A$ and $B$, then $\textrm{OPT}(z') \ge \text{OPT}(z)$ for Optimization~\ref{opt:utility},~\ref{opt:impact},~\ref{opt:generic} and $\textrm{OPT}(z') \le \text{OPT}(z)$ for Optimization~\ref{opt:fairness}. \end{theorem} One way to understand Theorem~\ref{thm:improve} is through a ``cost of fairness'' analysis. Focusing on the utility maximization setting, let $U^*$ be the maximum unconstrained utility achievable by the lender given the optimal predictions $p^*$. Let $\textrm{OPT}(z)$ be the optimal value of Optimization~\ref{opt:utility} using predictions $z$; that is, the best utility a lender can achieve under a parity-based fairness constraint ($\eps=0$) and positive impact constraint ($t_i=0$). If we take the cost of fairness to be the difference between these optimal utilities, $U^* - \textrm{OPT}(z)$, then Theorem~\ref{thm:improve} says that by refining $z$ to $z'$, \emph{the cost of fairness decreases with increasing informativeness}; that is, $U^* - \textrm{OPT}(z) \ge U^* - \textrm{OPT}(z')$. This corollary of Theorem~\ref{thm:improve} corroborates the idea that in some cases the \emph{high perceived cost} associated with requiring fairness might actually be due to the \emph{low informativeness} of the predictions in minority populations. No matter what the true $p^*$ is, this cost will decrease as we increase information content by refining subpopulations. For $S\in\{A,B\}$, we use $\TPR_S^{z}(\beta)$ to denote the true positive rate of the threshold policy with selection rate $\beta$ for the subpopulation $S$ while using the predictor $z$\footnote{Given a predictor, there is a bijection between selection rates and threshold policies.}. Similarly, $\PPV_S^z(\beta)$, $\FPR_S^z(\beta)$ are defined. The following lemma, which plays a key role in each proof, shows that refinements broadly improve selection policies across these three statistics of interest. \begin{lemma} \label{cl:improv} If $z'$ is a refinement of $z$ on subpopulations $A$ and $B$, then for $S\in\{A,B\}$, for all $\beta \in [0,1]$, \begin{align*} \TPR_S^{z'}(\beta)\ge \TPR_S^z(\beta),&& \FPR_S^{z'}(\beta)\le \FPR_S^z(\beta),&& \PPV_S^{z'}(\beta)\ge \PPV_S^z(\beta). \end{align*} \end{lemma} In particular, the proof of Theorem \ref{thm:improve} crucially uses the fact that the positive predictive values, true positive rates, and false positive rates improve for \emph{all} selection rates. Leveraging properties of refinements, the improvement across all selection rates guarantees improvement for any fixed objective. As we'll see, the proof actually tells us more: for \emph{any} selection policy using the predictor $z$, there exists a threshold selection policy that uses the refined predictor $z'$ and \emph{simultaneously} has utility, disparity, and impact that are no worse than under $z$. In this sense, increasing informativeness of predictors through refinements is an effective strategy for improving selection rules across a wide array of criteria. Still, we emphasize the importance of identifying fairness desiderata and specifying them clearly when optimizing for a selection rule. For instance, suppose the selection rule is selected by constrained utility maximization with a predictor $z$ and with a refined predictor $z'$. It is possible that the \emph{optimal} selection policy under the refinement $z'$ will have a lower quantitative impact than the optimal policy under the original predictor $z$ (while still satisfying the impact constraint). If maintaining the impact above a certain threshold is desired, then this should be specified clearly in the optimization used for determining the selection rule. We defer further discussion of these issues to Section \ref{sec:discussion}. \vspace{-11pt} \paragraph{Proofs.} Next, we prove Lemma~\ref{cl:improv} and Theorem~\ref{thm:improve}. \begin{proofof}{Lemma~\ref{cl:improv}} Note that for a fixed selection rate $\beta$, $\PPV$ is maximized by picking the top-most $\beta$ fraction of the individuals ranked according to $p^*$, i.e.\ a threshold policy that selects a $\beta$-fraction of the individuals using the Bayes optimal predictor $p^*$. Similarly, for a fixed selection rate, the $\TPR$ and $\FPR$ values are also optimized under a threshold selection policy that uses the Bayes optimal predictor $p^*$. Recall, we can interpret a refinement as a ``candidate'' Bayes optimal predictor. In particular, because $z'$ refines $z$ over $A$ and $B$, we know that $z$ is calibrated not only with respect to the true Bayes optimal predictor $p^*$, but also with respect to the refinement $z'$ on both subpopulations. Imagining a world in which $z'$ is the Bayes optimal predictor, the $\PPV$, $\TPR$, and $\FPR$ must be no worse under a threshold policy derived from $z'$ compared to that of $z$ by the initial observation. Thus, the lemma follows. \end{proofof} Using Lemma~\ref{cl:improv}, we are ready to prove Theorem~\ref{thm:improve}. \begin{proofof}{Theorem~\ref{thm:improve}} Let $f$ be any threshold selection policy under the predictor $z$. Using $f$, we will construct a selection policy $f'$ that uses the refined score distribution $z'$ such that where $U^{z'}(f') \ge U^{z}(f)$, $\mathrm{Imp}^{z'}_B(f') \ge \mathrm{Imp}^{z}_B(f)$, and $h^{z'}_A(f')=h^z_A(f)$ and $h^{z'}_B(f')=h^z_B(f)$. Here, $h\in\{\beta,\TPR,\FPR\}$ specifies the parity-based fairness definition being used. Thus, taking $f$ to be the optimal solution to any of the Optimizations~\ref{opt:utility},~\ref{opt:fairness},~\ref{opt:impact}, or~\ref{opt:generic}, we see that $f'$ is a feasible solution to the same optimization and has the same or a better objective value compared to $f$. Therefore, after optimization, objective values can only get better. In words, we are saying that refined predictors allow us to get better utility and impact as the original predictor while keeping the parity values the same (for e.g., while keeping the selection rates the same in both subpopulations). We separately construct $f'$ for each fairness definition ($h$) as follows: \begin{enumerate} \item (Demographic Parity) $h=\beta$: For $S \in \set{A,B}$, let $\beta_S = \beta^z_S(f)$ be the selection rate of $f$ in the population $S$. Let $f'$ be the threshold policy that uses the predictor $z'$ and achieves selection rates $\beta_A$ and $\beta_B$ in the subpopulations $A$ and $B$, respectively. By Lemma~\ref{cl:improv}, $\PPV_S^{z'}(\beta_S)\ge \PPV^{z}_S(\beta_S)$ for $S \in \set{A,B}$. The utility of the policy $f'$ can be written as \begin{align*} U(f')&= \sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S) \cdot v- \sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S)\cdot \tau_u\right)\\ &=\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\beta_S\cdot (\PPV^{z'}_S(\beta_S)-\tau_u)\right)\\ &\ge \sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\beta_S\cdot (\PPV^{z}_S(\beta_S)-\tau_u)\right)\\ &=U(f) \end{align*} Similarly, we can show that the impact on the subpopulation $B$ under $f'$ is at least as good as under $f$. \item (Equalized Opportunity) $h=\TPR$: Let $(\beta_A,\beta_B)$ be the selection rates of policy $f$ on the subpopulations $A$ and $B$. We know that $\TPR_S^{z'}(\beta_S)\ge \TPR^{z}_S(\beta_S)$ ($S\in\{A,B\}$) through Lemma \ref{cl:improv}. Let $f'$ be the threshold selection policy corresponding to a selection rates of $\beta_S',(S\in\{A,B\})$ such that $\TPR^{z'}_S(\beta_S')= \TPR^{z}_S(\beta_S)$ ($\le \TPR^{z'}_S(\beta_S)$). As the true positive rates increase with increasing selection rate, $\beta_S'\le \beta_S$. The utility of the policy $f'$ can be written as \begin{align*} U(f')&= \sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S) \cdot v- \sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S)\cdot \tau_u\right)\\ &=\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(r_S\cdot \TPR^{z'}_S(\beta_S')-\beta_S'\cdot \tau_u\right)\\ &\ge\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(r_S\cdot \TPR^{z}_S(\beta_S)-\beta_S\cdot \tau_u\right)\\ &=U(f) \end{align*} Similarly, we can show that the impact on the subpopulation $B$ under $f'$ is at least as good as under $f$. \item (Equalized False Positive Rate) $h=\FPR$. Let $(\beta_A,\beta_B)$ be the selection rates of policy $f$ on the subpopulations $A$ and $B$. We know that $\FPR_S^{z'}(\beta_S)\le \FPR^{z}_S(\beta_S)$ ($S\in\{A,B\}$) through Lemma \ref{cl:improv}. Let $f'$ be the threshold selection policy corresponding to a selection rates of $\beta_S',(S\in\{A,B\})$ such that $\FPR^{z'}_S(\beta_S')= \FPR^{z}_S(\beta_S)$ ($\ge \FPR_S^{z'}(\beta_S)$). As the false postive rates increase with increasing selection rate, $\beta_S'\ge \beta_S$. The utility of the policy $f'$ can be written as \begin{align*} U(f')&= \sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S) \cdot v- \sum_{v \in \supp(z')} \R^{z'}_S(v) \cdot f'(v,S)\cdot \tau_u\right)\\ &=\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\beta_S'-(1-r_S)\cdot \FPR^{z'}_S(\beta_S')-\beta_S'\cdot \tau_u\right)\\ &=\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\beta_S'\cdot (1-\tau_u)-(1-r_S)\cdot \FPR^{z'}_S(\beta_S')\right)\\ &\ge\sum_{S\in \{A,B\}}\Pr_{x \sim \X}\left[x \in S\right] \cdot \left(\beta_S\cdot (1-\tau_u)-(1-r_S)\cdot \FPR^{z}_S(\beta_S)\right)\\ &=U(f) \end{align*} Similarly, we can show that the impact on the subpopulation $B$ under $f'$ is at least as good as under $f$. \end{enumerate} This completes the proof of the theorem. \end{proofof} \section{A mechanism for refining predictors} \label{sec:blm} In this section, we outline a mechanism for obtaining refinements of predictors. We start by describing an algorithm, \texttt{merge}, which given two calibrated predictors, produces a new refined predictor that incorporates the information from both predictors (in a sense we make formal). For notational convenience, we describe how to refine a predictor over $\X$. The arguments here extend easily to refining over a partition of $\X$ by refining each part separately. We discuss the generality of the approach at the end of the section and elaborate on the possibility of refinements on overlapping subpopulations briefly in Section~\ref{sec:discussion}. Given a predictor $z$, we can evaluate the information content $I(z)$ directly; estimating the information loss $L(p^*;z)$, however, is generally impossible. Indeed, without assumptions on the structure of $p^*$ or the ability to sample every individual's outcome repeatedly (and independently), we cannot reason about information-theoretic quantities like $I(p^*)$. Still, supposing that the information loss of $z$ is sufficiently large, we would like to be able to certify this fact and ideally, bring the loss down. The most obvious way to demonstrate that a predictor $z$ can be refined would be to exhibit some calibrated $q:\X \to [0,1]$ such that $I(q) > I(z)$. That said, expecting that we could obtain such a $q$ seems to sidestep the question of how to update a predictor to improve its information content. Even if we were able to obtain some $q$ where $I(q) > I(z)$, it is not clear that $q$ would be a ``better'' predictor. In particular, $q$ might contain \emph{different} information than $z$; recall that such examples motivated the definition of a refinement in the first place. Still, intuitively, if $q$ is not a refinement of $z$ and contains very different information than $z$, then $q$ should be useful in identifying ways to improve the informativeness of $z$. Further, this intuition does not seem to rely on the fact that $I(q) > I(z)$; as long as $q$ contains information that isn't ``known'' to $z$, then incorporating the information into $z$ should reduce the information loss. To formalize this line of reasoning, first, we need to make precise what we mean when we say that $q$ is far from refining $z$. Recalling the definition of a refinement, consider the logical negation of the statement that ``$q$ refines $z$.'' \begin{equation*} \neg\left(\forall v \in \supp(z):\ \E_{x \sim \X_{z(x)=v}}\left[q(x)\right] = v\right) \iff \exists v \in \supp(z):\ \E_{x \sim \X_{z(x)=v}}\left[q(x)\right] \neq v. \end{equation*} Extending this logical formulation, we define the following divergence to capture quantitatively how far $q$ is from refining $z$. \begin{definition}[Refinement distance] Let $q,z:\X \to [0,1]$ be calibrated predictors. The \emph{refinement distance} from $z$ to $q$ is given as \begin{equation*} D_R(z;q) = \sum_{v \in \supp(z)} \R^z(v) \cdot \card{\E_{x \sim \X_{z(x)=v}}\left[q(x)\right] - v}. \end{equation*} \end{definition} Note that $D_R(z;q)$ is not symmetric; in particular, if $q$ refines $z$ and contains more information $I(q) > I(z)$, then $D_R(z;q) = 0$, but $D_R(q;z) > 0$. Intuitively, the refinement distance averages the refinement ``disagreements'' over all values in the support. We show that, under calibration, these disagreements can be reconciled to improve the overall information content. With the notion of refinement distance in place, we can state the main algorithmic result -- a simple algorithm for aggregating the information of multiple calibrated predictors into a single calibrated predictor. \begin{theorem} \label{thm:merge} Given two calibrated predictors $q,z:\X \to [0,1]$, Algorithm~\ref{alg:merge} produces a new calibrated predictor $\rho:\X \to [0,1]$ such that $\rho$ is a refinement of both $z$ and $q$. Further, $I(\rho) > \max\set{I(z) + 4\cdot D_R(q;z)^2,I(q) + 4\cdot D_R(z;q)^2}$. \end{theorem} We state the theorem generally, making no assumptions about $D_R(q;z)$ or $D_R(z;q)$. In particular, as we alluded to earlier, if $q$ already refines $z$, then $D_R(z;q) = 0$, so there will be no information gain. Algorithm~\ref{alg:merge}, which we refer to as \texttt{merge}, describes the procedure. We describe the algorithm in the statistical query model, where we assume query access to aggregate statistics about $p^*(x)$. At the end of the section, we discuss the sample complexity needed to answer such statistical queries accurately. The \texttt{merge} algorithm builds a new calibrated predictor $\rho$ from $q$ and $z$ by considering the set of individuals who receive $q(x) = u$ and $z(x) = v$ for each $u \in \supp(q)$ and $v \in \supp(z)$. For each of these sets, the merged predictor adjusts the prediction to have the correct expectation. The proof of Theorem~\ref{thm:merge} follows from a standard potential function analysis; further, the sample complexity needed to answer the statistical queries accurately is bounded. \begin{figure}[ht!] {\refstepcounter{algorithm} \label{alg:merge}{\bf Algorithm~\thealgorithm:}} \texttt{merge(z,q)} \fbox{\parbox{\textwidth}{ \vspace{4pt} {\bf Given:} $z,q:\X \to [0,1]$ calibrated predictors\\ {\bf Output:} $\rho:\X \to [0,1]$ a refinement of $z$ and $q$ \begin{itemize} \item Let $\Z = \set{\X_{z(x)=v} : v \in \supp(z)}$ \item Let $\mathcal{Q} = \set{\X_{q(x)=u} : u \in \supp(q)}$ \item For $Z_v \in \Z$ and $Q_u \in \mathcal{Q}$: \begin{itemize} \item $\X_{vu} = Z_v \cap Q_u$ \item $\rho(x) \gets \E\limits_{x \sim \X_{vu}}\left[p^*(x)\right]$ \end{itemize} \end{itemize} \vspace{-8pt} } } \end{figure} We break the proof of Theorem~\ref{thm:merge} into two lemmas. First, note that the \texttt{merge} procedure is symmetric with respect to $q$ and $z$. Thus, any statements about the output $\rho$ in terms of one of the inputs $z$ will also be true with respect to the input $q$. \begin{lemma} \label{lem:merge:refine} Let $\rho$ be the output of Algorithm~\ref{alg:merge} on two calibrated predictors $z,q:\X \to [0,1]$ as input. $\rho$ is a refinement of $z$. \end{lemma} \begin{proof} We use the notation established in Algorithm~\ref{alg:merge}. In particular, we refer to the conditional score distribution $\R^q_{Z_v}$ where $\R^q_{Z_v}(u) = \Pr_{x \sim \X}\left[q(x)=u \given z(x) = v\right]$. Consider the expectation of $\rho$ over the level sets of $z$, $\set{Z_v : v \in \supp(z)}$. \begin{align} \E_{x \sim Z_v}\left[\rho(x)\right] &=\sum_{u \in \supp(q)}\R^q_{Z_v}(u) \cdot \E_{x \sim \X_{vu}}\left[\rho(x)\right]\notag\\ &=\sum_{u \in \supp(q)}\R^q_{Z_v}(u) \cdot \E_{x \sim \X_{vu}}\left[\E_{x\sim\X_{vu}}[p^*(x)]\right]\label{eqn:lem:assign}\\ &=\sum_{u \in \supp(q)}\R^q_{Z_v}(u) \cdot \E_{x \sim Z_{v}}\left[p^*(x) \given q(x)=u\right]\label{eqn:lem:condition}\\ &=\E_{x \sim Z_v}\left[p^*(x)\right]\notag \end{align} where (\ref{eqn:lem:assign}) follows by the assignment rule of $\rho(x)$ for $x \in \X_{vu}$; and (\ref{eqn:lem:condition}) follows from exploiting $\X_{vu} = \set{x \in Z_v : q(x)=u}$. By the calibration of $z$, we see the final expression is equal to $v$. This argument is independent of $v$, so for all $v \in \supp(z)$, $\E_{x \sim Z_v}\left[\rho(x)\right] = v$; thus, by definition, $\rho$ refines $z$. \end{proof} The next lemma shows that the information of $\rho$ increases based on the refinement distance. Note that in combination Lemma~\ref{lem:merge:refine} and Lemma~\ref{lem:infogain} prove Theorem~\ref{thm:merge}. \begin{lemma} \label{lem:infogain} Let $\rho$ be the output of Algorithm~\ref{alg:merge} on two calibrated predictors $z,q:\X \to [0,1]$ as input. Then, \begin{equation*} I(\rho) \ge I(z) + 4\cdot D_R(q;z)^2. \end{equation*} \end{lemma} \begin{proof} We can lower bound the resulting information content of $\rho$ by reasoning about the difference $I(\rho)-I(z)$. Note that by Lemma~\ref{lem:merge:refine}, $\rho$ is a refinement of $z$; further, by Proposition~\ref{prop:refine}, we can express $I(\rho) - I(z)$ as $L(\rho;z)$. Expanding the information loss, we can lower bound the gain in information, which shows the lemma. \begin{align} \frac{1}{4}\cdot L(\rho;z)&= \E_{x \sim \X}\left[(\rho(x) - z(x))^2\right]\notag\\ &= \sum_{u \in \supp(q)}\R^q(u) \cdot \E_{x \sim Q_u}\left[\left(z(x) - \rho(x)\right)^2\right]\notag\\ &\ge \sum_{u \in \supp(q)}\R^q(u) \cdot \left(\E_{x \sim Q_u}\left[z(x) - \rho(x)\right]\right)^2\label{eqn:alg:jensen1}\\ &= \sum_{u \in \supp(q)}\R^q(u) \cdot \left(\E_{x \sim Q_u}\left[z(x)\right] - u\right)^2\label{eqn:alg:refine}\\ &\ge \left(\sum_{u \in \supp(q)}\R^q(u) \cdot \card{\E_{x \sim Q_u}\left[z(x)\right] - u}\right)^2\label{eqn:alg:jensen2}\\ &\ge D_R(q;z)^2\label{eqn:alg:epsfar} \end{align} where (\ref{eqn:alg:jensen1}) follows by Jensen's Inequality; (\ref{eqn:alg:refine}) notes that $\E_{x\sim Q_u}[\rho(x)] = u$ because $q$ is calibrated and $\rho$ refines $q$; (\ref{eqn:alg:jensen2}) applies Jensen's inequality again; and (\ref{eqn:alg:epsfar}) follows by the definition of refinement distance. \end{proof} One appealing consequence of Theorem~\ref{thm:merge} is that the number of times a predictor needs to be significantly updated is bounded. In particular, suppose we are merging two calibrated predictors $q,z$; for any $\eta \ge 0$, we'll say the operation is an $\eta$-merge if $\min\set{D_R(z;q),D_R(q;z)} \ge \eta$. In this case, the information content of the result predictor will increase by at least $\Omega(\eta^2)$ and any given predictor can be $\eta$-merged at most $O(1/\eta^2)$ times. In other words, as long as the information being combined is not too similar, then the number of such merge updates is bounded. \vspace{-11pt} \paragraph{Interpreting the updates.} As described, the \texttt{merge} algorithm takes two different calibrated predictors and combines them into a refinement. In settings where the lender wants to combine predictions from different sources, this algorithmic model is naturally well-motivated. Still, there are other settings where the \texttt{merge} algorithm can be applied. One natural way we can specify new information content is by giving the predictor an additional feature. Specifically, consider some a boolean feature $\phi:\X \to \set{0,1}$. We define the predictor $q_\phi:\X \to [0,1]$ to be $q_\phi(x) = \E_{x' \sim \X}\left[p^*(x') \given \phi(x') = \phi(x)\right]$. This predictor gives the expected value over the set of individuals where $\phi(x) = 1$ (resp.,\ $\phi(x) = 0$); thus, the predictor is calibrated. Merging $z$ with $q_\phi$ incorporates the information in the boolean feature $\phi$ into the predictions of $z$. In particular, the information content framework gives us a way to reason about the marginal informativeness of individual boolean features; the greater the difference between $\E_{x \sim \phi^{-1}(0)}[p^*(x)]$ and $\E_{x \sim \phi^{-1}(1)}[p^*(x)]$, the more informative. This perspective is particularly salient when we think external regulation of predictors. For example, consider some subpopulation $S \subseteq \X$. One way to provide evidence that $S$ is experiencing discrimination under $z$ would be to demonstrate that merging the predictor $q_{S}$ into $z$ significantly changes the information content. This could occur because the quality of individuals in $S$ are consistently underestimated by $z$ or because the quality of individuals in $\X\setminus S$ are consistently overestimated. \vspace{-11pt} \paragraph{Implementing the merge from samples.} While we presented the \texttt{merge} algorithm assuming access to a statistical query oracle, in practice, we want to estimate the necessary statistical queries from data. We assume that the predictions are discretized to precision $\alpha$; that is, we represent the interval $[0,1]$ as $[\alpha/2,3\alpha/2,\hdots, 1-\alpha/2]$. We argue that the number of samples needed to obtain accurate statistics in this model is bounded as follows. \begin{proposition}\label{prop:samples} Consider an execution of Algorithm~\ref{alg:merge} such that $\min_{\X_{vu}}{\Pr_{x \sim \X}\left[x \in \X_{vu}\right]} \ge \gamma$. Then from $m \ge \tilde{\Omega}\left(\frac{\log(1/\delta)}{\gamma\alpha^2}\right)$ random samples from $\D$, with probability $1-\delta$, every statistical query can be answered with some $q_{vu}$ such that $\card{q_{vu} - \E_{x \sim \X_{vu}}\left[p^*(x)\right]} < \alpha/2$. \end{proposition} \begin{proof} The argument follows by a standard uniform convergence argument. To start, note that there are at most $1/\alpha^2$ queries to answer. Suppose we have $t$ random samples $(x_i,y_i) \sim \D$ conditioned on $x_i \in \X_{vu}$ for all $i \in [t]$. Let $q_{vu}$ denote the empirical expectation of $y_i$'s on these $t$ samples over $\X_{vu}$; that is, \begin{equation*} q_{vu} \triangleq \frac{1}{t} \sum_{i=1}^t y_i. \end{equation*} By Hoeffding's inequality: \begin{equation*} \Pr\left[~\card{q_{vu} - \E_{x \sim \X_{vu}}[y \given x]} > \alpha \right] \le 2e^{2t\alpha^2}. \end{equation*} If $t \ge \Omega\left(\frac{\log(2/\delta\alpha^2)}{\alpha^2}\right)$, then the probability of failure is at most $\alpha^2\delta/2$. Union bounding over the queries, the probability of failure is at most $\delta/2$. Thus, we need to bound the sample complexity needed to hit each $\X_{vu}$ at least $t$ times. By assumption, each $\X_{vu}$ has density at least $\gamma$. Thus, for each $\X_{vu}$, the probability that a random sample from $(x,y) \sim \D$ has $x \in \X_{vu}$ is at least $\gamma$. If we take $\Omega(\log(2t/\delta)/\gamma)$ such samples, then the probability every sample misses $\X_{vu}$ is at most $\delta/2t$. Thus, if we take $\Omega(t\log(2t/\delta)/\gamma)$ samples, each $\X_{vu}$ will have at least $t$ samples with probability at least $1-\delta/2$. By union bound, the proposition follows. \end{proof} \section{Discussion} \label{sec:discussion} In this work, we identify information disparity as a potential source of discrimination in prediction tasks. We provide an introduction to key concepts of information content and loss, and show how improving the information content of predictions improves the resulting fairness of the downstream decisions. In particular, our results show when a lender does not have sufficient statistical or computational resources to learn a predictor that achieves small squared error across all significant subpopulations, issues of unfairness may arise due to differential information loss. The information content of a predictor $z$ can be significantly larger on the majority population $S$ than the minority $T$ for a number of reasons. \begin{itemize} \item Despite optimal predictions, the individuals in $S$ are inherently more predictable than those in $T$; i.e.\ $z \approx p^*$ and $I_S(p^*) > I_T(p^*)$. If this (controversial) hypothesis is true, there may be no way to improve the predictions further, and some degree of disparity may be unavoidable. Note that in general this condition cannot be verified from data. Still, the assumption that $I(z) = I(p^*)$ can be falsified by finding a way to give more informative predictions. \item Nontrivial information loss has occurred in $z$ on $T$ compared to $S$; i.e.\ $L_S(p^*;z) < L_T(p^*;z)$. Such information loss could result from purely information theoretic issues (features used for prediction are not sufficiently expressive in $T$), a mix of informational and computational issues (not enough data from the minority to learn a predictor from a sufficiently rich hypothesis class), or purely computational issues (suboptimal learning in $T$ due to optimization for $S \cup T$). Each source of information disparity has a different own solution (collecting better features, collecting more data, re-training with awareness of the population $T$, respectively), but the tools we present for reasoning about information content apply broadly. \end{itemize} As such, improving the information content of predictions may require collecting additional features or data. Once collected, the \texttt{merge} procedure provides a relatively inexpensive way of incorporating new information into the predictions while retaining certain ``quality" of the selection rule. In practice, when the sensitive group $T$ is known, it may make sense to simply retrain the prediction model with awareness of $T$. \vspace{-11pt} \paragraph{Overlapping subpopulations.} The proposed \texttt{merge} algorithm provides a simple and efficient approach for producing refinements in applications where the sensitive populations are well understood. Often, as highlighted in \cite{multi,kearns2017preventing,ftba}, the subpopulations in need of protection may be hard to anticipate. These recent works have studied notions of \emph{multi-fairness} that aim to strengthen notions of group fairness by enforcing statistical constraints not just overall, but on a rich family of subgroups. In particular, \cite{multi} introduces a notion called \emph{multicalibration}, which informally, guarantees calibration across all subpopulations specified by a given set system $\C$. We observe that the guarantees of multicalibration can be reinterpreted in the language of refinements: a predictor that is multicalibrated with respect to $\C$ is simultaneously a refinement for all $q_c:\X \to [0,1]$ where $q_c(x) = \E_{x' \sim \X}\left[p^*(x') \given c(x') = c(x)\right]$ for every $c \in \C$. In this sense, multicalibration may be an effective approach to improving information across subpopulations, when the groups that might be experiencing discrimination are unknown or overlapping. An interesting question is whether some of the analysis in the present work can be applied to understand better the connections between multicalibration and the work of \cite{kearns2017preventing} which studies the notion of rich subgroup fairness under demographic parity and equalized opportunity. \paragraph{Choosing fairness constraints.} Understanding precisely the guarantees of the specified fairness constraints is particularly important for interpreting the results of Section~\ref{sec:value}. In particular, refining predictions is guaranteed to improve the value of the \emph{stated program}. We emphasize the importance of faithfully translating fairness desiderata into mathematical requirements. For instance, suppose policy-makers want to increase representation for historically-disenfranchised populations. An appealing -- but misguided -- translation of this goal would require demographic parity; intuitively, if the lender is required to have equalized selection rates across groups, they might increase the selection rate in the minority to match that of the majority. Still, demographic parity only requires parity of selection rates which could also be achieved by reducing the selection in the majority. Further, refinements under demographic parity constraints, might cause the selection rates in the minority to \emph{decrease}. By increasing information, we might uncover that fewer individuals are actually above the tolerable risk than the previous predictions suggested; as such, fewer individuals might be deemed qualified for a loan. The framework proposed in Section~\ref{sec:value} is compatible with a variety of constraints and objectives, including explicitly lower bounding the group selection rates. Thus, increasing the selection rate in a given population can always be achieved by directly constraining the selection rule. An appealing aspect of the framework is that it allows policy-makers to experiment with constraints and objectives to understand the downstream effects of their policies, given the current set of predictions. For instance, policy-makers can evaluate how lower bounding the selection rate in a group will affect the impact of the policy on this group. Such experimentation with the programs from Section~\ref{sec:value} may help to guide future policy decisions. \vspace{-11pt} \paragraph{Changing environments.} The present work focuses on a setting where the true risk scores of the underlying population does not change; that is, we assumed that the Bayes optimal predictor $p^*$ remains fixed while producing better and better refinements. In real life, the true risk of individuals may change as their environment changes, and possibly even \emph{as a result of the prior decisions made by the lender}, as suggested by \cite{delayed}. An exciting direction for future investigation would study a setting of dynamic $p^*$, with the goal of ensuring long-term fairness and impact. A specific challenge is finding an efficient (in terms of sample and time complexity) procedure for maintaining calibration when $p^*$ changes over time. Further, we showed the importance of increasing informativeness of predictors for underrepresented populations, but required access to random samples from this population. In settings where random exploration may cause harm to uncertain populations (e.g.\ by raising the default rate) how can we improve information without causing the inherent capabilities of sensitive subpopulations to deteriorate? \vspace{-11pt} \paragraph{Conclusion.} We reiterate that the validity of every notion of fairness rests on some set of assumptions. Many approaches to fair classification assume implicitly that the predicted risk scores represent the true risk scores. Predicted risk scores are the result of an extensive pipeline of data collection and computational modeling; when data is limited for minority populations and modeling is focused on fidelity in the majority populations, the resulting predictions may not be appropriately informative in the minority. In the case that the differences arise because of suboptimal predictions, increasing information through refinements provide a simple but effective approach for improving the utility, fairness, and impact of the decision-maker's policy. \paragraph{Acknowledgments.} The authors thank Cynthia Dwork and Guy N.\ Rothblum for many helpful conversations throughout the development of this work. We thank Moritz Hardt, Gal Yona, and anonymous reviewers for feedback on earlier versions of the work. \newpage \bibliographystyle{alpha}
{'timestamp': '2019-08-02T02:19:36', 'yymm': '1904', 'arxiv_id': '1904.09942', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09942'}
arxiv
\section{Introduction} The study of precipitation in meteorology and climatology has a significant society impact. For example, drought and flood are two of the most serious meteorological disasters in China, with a direct economic loss of $177$ billion Chinese Yuan and annual average of 1256 deaths each year during the period 2001-2014~\cite{CMA2015}. Obvious seasonal and interannual variations of precipitation in China affected by Asian monsoon and complex terrain are the main reasons for the frequent drought and flood disasters. Dividing a large geographical area into more homogeneous precipitation regimes~\cite{li2009regionalization} has been shown to be useful for precipitation prediction, flood zone management, and regional extreme analysis~\cite{hosking2005regional}. Precipitation data has complex characteristics on multiple scales and typically has spatial and temporal dependence, which makes delineating precipitation regimes a non-trivial task. Motivated by this critical need, in this paper we develop a clustering approach for spatial functional data, and apply it to the precipitation data in China. Regionalization problem has been studied extensively in the meteorological literature. The empirical orthogonal function (EOF) analysis has been widely used for regionalization problems in environmental science~\cite{white1991climate},~\cite{uvo2003analysis}, which is equivalent to principal component analysis in statistics. The EOF is used in \cite{li2009regionalization} to analyze the normalized monthly mean precipitation data from 1961 to 2006 at 400 stations and obtained a precipitation regionalization focusing on seasonal and interannual variations. However, the seasonal advance and retreat of the summer monsoon rain belt in East Asia behave in a manner with a step of 10-15 days~\cite{ding2004seasonal}, which can not be accurately described using monthly data, and daily rainfall data may be more useful to describe this summer monsoon effect accrurately. Due to the limitation of EOF method, unevenly distributed stations in space can significantly affect the loading patterns. For example, the station density in the western and eastern parts of China is very different, therefore, some stations in the eastern part of China were ignored in the EOF analysis, which led to loss of information. The motivation of this research is to identify precipitation regimes in China using precipitation data. In this article, we propose a model-based approach to clustering spatial functional data by incorporating both spatial and geographic information in the procedure. In section \ref{Model}, we introduce the functional linear model for observed data and Markov model for cluster memberships with geographic covariates. In section \ref{Results}, we apply the proposed method to precipitation data. \section{Data} The data we analyze in this study is the daily precipitation data of 824 meteorological stations in the mainland China from 1951 through 2012. They were provided by the National Meteorological Information Center, China Meteorological Administration. The proportion of the missing days was $0.04\%$. Only those stations with more than 50 years' complete data are included in the analysis, so there are $722$ stations in total used in the analysis. The locations of these meteorological stations are shown in Fig \ref{location}. \begin{figure}[ht] \centering \includegraphics[width=0.5\textwidth]{locations} \caption{Spatial distribution of meteorological stations}\label{location} \end{figure} \section{Model}\label{Model} Assume $Y_{ij}$ is the precipitation data observed in station $i$ at time point $t_{ij}$, where $i=1,\ldots, n$ and $j=1,\ldots, n_{i}$. Denote $\bm{Y}_{i}=(Y_{i1},\ldots,Y_{i,n_{i}})^{T}$. Let $Z_{i}$ be the cluster membership, called latent variable, following a multinomial distribution with support $\{1,\ldots\, C\}$. Here, $C$ is the number of clusters and is a tuning parameter. $Z_{i}=k$ if $\bm{Y}_{i}$ belongs to $k$th cluster. We call $\{(\bm{Y}_{i},Z_{i}): i=1,\ldots, n\}$ the complete dataset. \subsection{Functional linear model for observed data}\label{flm} Given the cluster membership $Z_{i}$, we assume $\bm{Y}_{i}|(Z_{i}=k)$ follows a multivariate normal distribution with a functional representation: \begin{eqnarray} \bm{Y}_{i}| (Z_{i}=k)=\bm{S}_{i}(\bm{\alpha}_{k}+\bm{\gamma}_{i})+\bm{\epsilon}_{i},\\ \bm{\gamma}_{i} \sim N(0,\bm{\Gamma}), \quad \bm{\epsilon}_{i} \sim N(\bm{0},\sigma^{2}I), \end{eqnarray} where $i=1,\ldots,n, k=1,\ldots,C$. In the functional linear model, $\bm{S}_{i}=(\bm{s}(t_{i1})^{T},\ldots ,\bm{s}(t_{in_{i}})^{T})^{T}$ is the basis matrix for $i$th curve. $\bm{s}(\cdot)$ is a vector of basis functions, which can be B-spline, Fourier or functional principal component. But the row number of basis matrix can vary across different curves to allow irregularly spaced time points and slight missing of data. $\bm{\alpha}_{k}$ is the coefficient and needs to be estimated. The data in the same cluster share the same coefficient $\bm{\alpha}_{k}$. The difference of $\{\bm{\alpha}_{k}\}$ reflects the heterogeneity across clusters. We assume the independence between distinct curves given cluster memberships. However, the within-curve dependence is accounted by the random effect $\bm{\gamma}_{i}$, since $\text{cov}(Y_{ij}, Y_{ij^{'}})=$the $(j,j^{'})$ element of $\bm{S}_{i}\bm{\Gamma}\bm{S}_{i}^{T}$. $\bm{\epsilon}_{i}$ can be regarded as the measurement error or stochastic error. Note that $\bm{\gamma}_{i}$ and $\bm{\epsilon}_{i}$ are confounded. Therefore, some constraint should be imposed for identifiability~\cite{james2003clustering}. We require that \begin{equation} \bm{S}^{T}\bm{\Sigma}^{-1}\bm{S}=\bm{I}, \end{equation} where $\bm{S}$ is the basis matrix evaluated over a fine lattice of time points that covers the full range of the data and $\bm{\Sigma}=\sigma^{2}\bm{I}+\bm{S}\bm{\Gamma}\bm{S}^{T}$. \subsection{Markov model for cluster membership}\label{Markov} To fully address the joint distribution of complete data $(\bm{Y}_{i},Z_{i})$, we need to specify the distribution of $Z_{i}$. Here, we assume the cluster membership follows a Markov model in space. We assume the following probability mass function of cluster memberships in the Markov model \begin{equation}\label{gibbs} P(Z_{i}=k|\bm{Z}_{\partial i})=\frac{exp\{U_{ik}(\theta)\}}{N_{i}(\theta)}, \end{equation} where $U_{ik}(\theta)=\theta \sum_{j \in \partial i}I(Z_{j}=k)$ is called the energy function and $N_{i}(\theta)=\sum_{k=1}^{C}exp\{U_{ik}(\theta)\}$ is the normalizing constant. $\theta$ is the interaction parameter that reflects the degree of interaction among nearby sites in Markov random field. The above distribution is called the Gibbs distribution~\cite{jiang2012clustering}, which originates from statistical physics but is widely used in spatial statistics. There are several ways to incorporate geographic covariates in the Markov model. One way is to generalize the definition of distance from Euclidean distance to "geographic distance" by spatial deformation. For instance, if there is a high mountain between two sites, then the distance between them can be set to be much larger than their euclidean distance on the earth but the geometric properties of Euclidean distance are still kept. The change of the definition of distance may lead to the respective change of neighbors. This method has been introduced in many papers in spatial statistics, to name a few, \cite{sampson1992nonparametric}, \cite{anderes2008estimating}, etc. The second way is to extend the energy distribution by imposing a function $f_{i,j}(\cdot)$ on $I(Z_{j}=k)$, i.e. $\tilde{U}_{ik}(\theta)=\theta \sum_{j \in \partial i}f_{i,j}\{I(Z_{j}=k)\}$ and $\tilde{N}_{i}(\theta)=\sum_{k=1}^{C}exp\{\tilde{U}_{ik}(\theta)\}$, where $f_{i,j}\{Z_{ik}\}$ is a function affected by the geographical covariates between site $i$ and one of its neighbors, i.e. site $j$. \section{Results}\label{Results} We applied this method to identify the precipitation regimes in China. Here, we focus on the interseasonal patterns of precipitation. The extension of this method to multi-scale functional and scalar data will be addressed in the following full paper. As a consequence, the averaged daily precipitation records within a year are used in the clustering. The detailed procedure of summarizing data is that, first we get the daily precipitation in each year from 1963 to 2012, then calculate the mean of these 50 curves. Some curves are illustrated in Fig \ref{averaged daily precipitation}. We used the second approach introduced in Section \ref{Markov} to incorporate geographical covariate. If the elevation difference between two stations is larger than 1000m \cite{gerlitz2015large}, we no longer consider them to be the ``neighbors`` in the Markov random field even if they are closest in terms of distance. \begin{figure} \centering \includegraphics[width=0.49\textwidth]{dailydata} \caption{The averaged daily precipitation in some stations}\label{averaged daily precipitation} \end{figure} \begin{figure} \centering \includegraphics[width=0.49\textwidth]{clustering_map_extreme_value} \caption{Regionalization of precipitation regimes in China}\label{clustering_map} \end{figure} The final cluster assignments are shown in Fig \ref{clustering_map}. The results of clustering are consistent with the stepwise manner of East Asian monsoon. The seasonal advance and retreat of the summer monsoonal airflow and monsoon rain belt in East Asia behave in a stepwise manner (Ding, 2004). When the East Asian summer monsoon advances northward, it undergoes three standing stages (South China and northern South China Sea from mid-May to early June; 25$-$30$^{\circ}$N from mid-June to mid-July; and 40$–-$45$^{\circ}$N during the last 10 days of July to mid-August), and two stages of abrupt northward shifts (the first 10 days of June and around mid-July). In early or mid-August the rainy season of North China comes to end, with the major monsoon rain belt disappearing. From the end of August to early September the monsoon rain belt moves back to South China again. \section{Discussion} In this short paper, we develop a flexible model-based approach to cluster precipitation data which utilizes the spatial and geographical information. There are still several important aspects of this method needed to be addressed, such as the selection of cluster numbers, how to evaluate the uncertainty of clustering assignments, etc. The parameter estimation, simulation study, model selection, extension to multi-scale data and uncertainty assessment will be introduced and addressed in the following full paper. \bibliographystyle{ieeetr}
{'timestamp': '2019-04-24T02:06:51', 'yymm': '1904', 'arxiv_id': '1904.10152', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10152'}
arxiv
\section{Background} \label{sec:background} In this section, we provide some background on neural networks and robustness. \subsection{Neural Networks} A neural network is a function $\mathcal{N}:\ensuremath{\mathbb{R}}^n \to \ensuremath{\mathbb{R}}^m$ of the form $L_1 \circ \sigma_1 \circ \dots \circ \sigma_{k -1} \circ L_k$, where each $L_i$ is a differentiable {\em layer} and each $\sigma_i$ is a non-linear, almost-everywhere differentiable \emph{activation function}. While there are many types of activation functions, the most popular choice in modern neural networks is the \emph{rectified linear unit (ReLU)}, defined as $\ensuremath{\mathrm{ReLU}}(x) = \max(x,0)$. This function is applied element-wise to the output of each layer except the last. In this work, we consider feed-forward and convolutional networks, which have the additional property of being Lipschitz-continuous~\footnote{Recall that a function is Lipschitz-continuous if there exists a positive real constant $M$ such that, for all $x_1, x_2$, we have $|f(x_1) - f(x_2)| \leq M |x_1 - x_2|$}. For the purposes of this work, we think of each layer $L_i$ as an affine transformation $(W, \vec{b})$ where $W$ is a \emph{weight matrix} and $\vec{b}$ is a \emph{bias vector}. Thus, the output of the $i$'th layer is computed as $\vec{y} = W \vec{x} + \vec{b}$. We note that both \emph{fully-connected} as well as \emph{convolutional layers} can be expressed as affine transformations~\cite{ai2}. While our approach can also handle other types of layers (e.g., max pooling), we only focus on affine transformations to simplify presentation. In this work, we consider networks used for classification tasks. That is, given some input $x \in \ensuremath{\mathbb{R}}^{n}$, we wish to put $x$ into one of $m$ \emph{classes}. The output of the network $y \in \ensuremath{\mathbb{R}}^m$ is interpreted as a vector of \emph{scores}, one for each class. Then $x$ is put into the class with the highest score. More formally, given some input $x$, we say the network $\mathcal{N}$ assigns $x$ to a class $K$ if $(\mathcal{N}(x))_K > (\mathcal{N}(x))_j$ for all $j \neq K$. \begin{figure} \includegraphics[scale=0.35]{xor-new.pdf} \vspace{-0.1in} \caption{A feedforward network implementing XOR}\label{fig:xor} \vspace{-0.1in} \end{figure} \begin{example} Figure~\ref{fig:xor} shows a 2-layer feedforward neural network implementing the XOR function. To see why this network ``implements'' XOR, consider the vector $[0 \ 0]^\top$. After applying the affine transformation from the first layer, we obtain $[0 \ -1]^\top$. After applying ReLU, we get $[0 \ 0]^\top$. Finally, after applying the affine transform in the second layer, we get $[1 \ 0]^\top$. Because the output at index zero is greater than the output at index one, the network will classify $[0 \ 0]^\top$ as a zero. Similarly, this network classifies both $[0 \ 1]^\top$ and $[1 \ 0]^\top$ as $1$ and $[1 \ 1]^\top$ as $0$. \end{example} \begin{comment} which can be written as a composition of a number of \emph{layers} with an \emph{activation function} between each layer. Each layer maps a three-dimensional tensor $x \in \ensuremath{\mathbb{R}}^{p \times q \times r}$ to another three-dimensional tensor $y \in \ensuremath{\mathbb{R}}^{p' \times q' \times r'}$. The first layer, called the \emph{input layer}, must take an input of depth one (i.e., $r=1$), and the final layer, called the \emph{output layer}, must produce an output of both width and depth one (i.e., $q=r=1$). The remaining layers are called \emph{hidden layers}. For the purposes of this work, we consider three kinds of layers: fully connected, convolutional, and max pooling. \begin{figure*} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\linewidth]{fc} \caption{A fully connected layer} \label{fig:fc-layer} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=0.75\textwidth]{conv} \caption{A convolutional layer} \label{fig:conv-layer} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=0.7\textwidth]{mp} \caption{A max pooling layer} \label{fig:mp-layer} \end{subfigure} \caption{Examples of each type of layer.} \label{fig:layers} \end{figure*} A \emph{fully connected layer} serializes the elements of its input to produce a one-dimensional vector then applies an affine transformation. That is, given an input $x \in \ensuremath{\mathbb{R}}^{p \times q \times r}$, a fully connected layer first rearranges $x$ into a vector $x' \in \ensuremath{\mathbb{R}}^{pqr}$ according to a standard reshaping. Elements are ordered in $x'$ first by depth, then by column, then by row. More formally $x'_{qr(i-1)+r(j-1)+k} = x_{i,j,k}$ for $1\le i\le p$, $1\le j\le q$, and $1\le k\le r$. The fully connected layer consists of a matrix $W \in \ensuremath{\mathbb{R}}^{p'q'r' \times pqr}$ and a bias vector $b \in \ensuremath{\mathbb{R}}^{p'q'r'}$. Then the output $y$ is obtained by applying the standard reshaping in reverse to the vector $Wx'+b$. That is, $y' = Wx'+b$ and $y_{i,j,k} = y'_{q'r'(i-1)+r'(j-1)+k}$. For an example of a fully connected layer, see Figure~\ref{fig:fc-layer}. A convolutional layer consists of a number of filters which ``slide'' over the input. For an input $x \in \ensuremath{\mathbb{R}}^{p \times q \times r}$, each filter $f$ consists of a tensor $W^f \in \ensuremath{\mathbb{R}}^{s \times t \times r}$ (the \emph{kernel}) and a bias $b^f \in \ensuremath{\mathbb{R}}$. If there are $r'$ filters, $f_1,\cdots,f_{r'}$, then the output of the convolutional layer is a tensor $y \in \ensuremath{\mathbb{R}}^{p' \times q' \times r'}$, where $p' = p-s+1$, $q'=q-t+1$, and \[y_{i,j,k} = \sum_{i'=1}^s \sum_{j'=1}^t \sum_{k'=1}^r W^{f_k}_{i',j',k'} x_{(i+i'-1),(j+j'-1),(k+k'-1)} + b^{f_k}\] for $1\le i\le p'$, $1\le j\le q'$, and $1\le k\le r'$. Essentially, each index into the depth of $y$ is the output of one filter. The output of each filter is computed by ``sliding'' that filter's kernel along the input and computing its dot product of with each section of input, then adding the bias. An example of a convolutional layer with a single filter is shown in Figure~\ref{fig:conv-layer}. Finally, a max pooling layer chooses the maximum element from parts of the input. Formally, given some $s,t \in \mathbb{N}$ such that $s$ divides $p$ and $t$ divides $q$, a max pooling layer maps $x \in \ensuremath{\mathbb{R}}^{p \times q \times r}$ to $y \in \ensuremath{\mathbb{R}}^{\frac{p}{s} \times \frac{q}{t} \times r}$ such that \[y_{i,j,k} = \max_{\substack{1\le i'\le s \\ 1\le j'\le t}} x_{(s(i-1)+i'), (t(j-1)+j'),k}\] for $1\le i\le \frac{p}{s}$, $1\le j\le \frac{q}{t}$, and $1\le k\le r$. See Figure~\ref{fig:mp-layer} for an example of a max pooling layer. There are many activation functions which may be applied between layers, but for this work we focus on the rectified linear unit (ReLU), defined as $\ensuremath{\mathrm{ReLU}}(x) = \max(x,0)$. This function is applied element-wise to the output of each layer except the last. ReLU's are a popular activation function in feed-forward neural networks because they dramatically improve training time relative to other activation functions \todo{find a citation for this}. \end{comment} \begin{figure*}[t] \includegraphics[width=\textwidth]{zonotope_relu} \vspace{-0.4in} \caption{Zonotope analysis of a neural network.} \label{fig:zonotope} \end{figure*} \subsection{Robustness} (Local) robustness~\cite{BastaniILVNC16} is a key correctness property of neural networks which requires that all inputs within some region of the input space fall within the same region of the output space. Since we focus on networks designed for classification tasks, we will define ``the same region of the output space'' to mean the region which assigns the same class to the input. That is, a robustness property asserts that a small change in the input cannot change the class assigned to that input. More formally, a \emph{robustness property} is a pair $(I,K)$ with $I \subseteq \ensuremath{\mathbb{R}}^{n}$ and $0 \le K \le m-1$. Here, $I$ defines some region of the input that we are interested in and $K$ is the class into which all the inputs in $I$ should be placed. A network $\mathcal{N}$ is said to satisfy a robustness property $(I,K)$ if for all $x \in I$, we have $(\mathcal{N}(x))_K > (\mathcal{N}(x))_j$ for all $j \neq K$. \begin{comment} Intuitively, $I$ formalizes the notion of a ``small perturbation'' --- for example, we may choose a point $v$ and a limit $\epsilon$ and define $I$ to be the $\epsilon$-ball, denoted $\mathcal{B}_\epsilon(v)$ around point $v$: \begin{equation}\label{eq:input-class} I = \mathcal{B}_\epsilon(v) = \{x \in \ensuremath{\mathbb{R}}^{n } \mid \|x - v\|_\infty < \epsilon\} \end{equation} \end{comment} \begin{example} \label{ex:robust} Consider the following network with two layers, i.e., $\mathcal{N}(x) = W_2(\ensuremath{\mathrm{ReLU}}(W_1 x + b_1)) + b_2$ where: \[W_1 = \begin{bmatrix} 1 \\ 2 \end{bmatrix} \quad b_1 = \begin{bmatrix} -1 \\ 1 \end{bmatrix} \quad W_2 = \begin{bmatrix} 2 & 1 \\ -1 & 1 \end{bmatrix} \quad b_2 = \begin{bmatrix} 1 \\ 2 \end{bmatrix}\] For the input $x=0$, we have $\mathcal{N}(0) = [ 1 \ 3 ]^\top$; thus, the network outputs label 1 for input $0$. Let $I = [-1, 1]$ and $K = 1$. Then for all $x \in I$, the output of $\mathcal{N}$ is of the form $[a+1\ a+2]^T$ for some $a \in [0,3]$. Therefore, the network classifies every point in $I$ as belonging to class 1, meaning that the network is robust in $[-1,1]$. On the other hand, suppose we extend this interval to $I' = [-1,2]$. Then $\mathcal{N}(2) = [ 8 \ 6 ]^\top$, so $\mathcal{N}$ assigns input $2$ as belonging to class 0. Therefore $\mathcal{N}$ is \emph{not} robust in the input region $[-1,2]$. \end{example} \subsection{Abstract Interpretation for Neural Networks}\label{sec:ai2} In this paper, we build on the prior ${\rm AI}^2$\ work~\cite{ai2} for analyzing neural networks using the framework of \emph{abstract interpretation}~\cite{cousot77}. ${\rm AI}^2$\ allows analyzing neural networks using a variety of numeric abstract domains, including intervals (boxes)~\cite{cousot77}, polyhedra~\cite{polyhedra}, and zonotopes~\cite{zonotope}. In addition, ${\rm AI}^2$\ also supports \emph{bounded powerset domains} ~\cite{cousot77}, which essentially allow a bounded number of disjunctions in the abstraction. Since the user can specify any number of disjunctions, there are \emph{many} different abstract domains to choose from, and the precision and scalability of the analysis crucially depend on one's choice of the abstract domain. The following example illustrates a robustness property that can be verified using the bounded zonotope domain with two disjuncts but not with intervals or plain zonotopes: \begin{example} \label{ex:zonotope} Consider a network defined as: \[\mathcal{N}(x) = \begin{bmatrix} 1 & 1.1 \\ -1 & 1 \end{bmatrix} \ensuremath{\mathrm{ReLU}}\left(\begin{bmatrix} 1 & -3 \\ 0 & 3 \end{bmatrix} x + \begin{bmatrix} 1 \\ 1 \end{bmatrix}\right) + \begin{bmatrix} -3 \\ 1.2 \end{bmatrix}\] As in the previous example, the first index in the output vector corresponds to class $A$ and the second index corresponds to class $B$. Now, suppose we want to verify that for all $x \in [0,1]^2$, the network assigns class $B$ to $x$. % Let us now analyze this network using the zonotope abstract domain, which overapproximates a given region using a zonotope (i.e., center-symmetric polytope). The analysis of this network using the zonotope domain is illustrated in Figure~\ref{fig:zonotope}. At first, the initial region is propagated through the affine transformation as a single zonotope. Then, this zonotope is split into two pieces, the blue (crosshatched) one for which $x_1 \ge 0$ and the red (diagonally striped) one for which $x_1 \le 0$. The ReLU transforms the red piece into a line. (We omit the ReLU over $x_2$ because it does not change the zonotopes in this case.) After the ReLU, we show two cases: on top is the plain zonotope domain, and on the bottom is a powerset of zonotopes domain. In the plain zonotope domain, the abstraction after the ReLU is the join of the blue and red zonotopes, while in the powerset domain we keep the blue and red zonotopes separate. The final images show how the second affine transformation affects all three zonotopes. This example illustrates that the propery cannot be verified using the plain zonotope domain, but it \emph{can} be verified using the powerset of zonotopes domain. Specifically, observe that the green (vertically striped) zonotope at the top includes the point $[1.2 \ 1.2]^\top$ (marked by a dot), where the robustness specification is violated. On the other hand, the blue and red zonotopes obtained using the powerset domain do not contain any unsafe points, so the property is verified using this more precise abstraction. \end{example} \begin{comment} \todo{AI2} allows many different choices of abstract domain, including intervals, zonotopes, and polyhedra. Additionally, \emph{bounded powersets} of any of these domains may be used to increase precision. A bounded powerset of size $N$ consists of a disjunction of up to $N$ elements of the underlying abstract domain. The concretization of the powerset element is the union of the concretization of each element of the underlying abstract domain. Therefore increasing the bound $N$ increases the precision of the analysis, but also increases the amount of time it takes. Finding a good value for the powerset bound is crucial to performing an efficient analysis. \end{comment} \section{Conclusion and Future Work}\label{sec:conclusion} We have presented a novel technique for verifying robustness properties of neural networks based on synergistically combining proof search with counterexample search. This technique makes use of black-box optimization techniques in order to learn good refinement strategies in a data-driven way. We implemented our technique and showed that it significantly outperforms state-of-the-art techniques for robustness verification. Specifically, our technique is able to solve 2.6$\times$ as many benchmarks as {\sc ReluVal}\xspace and 16.6$\times$ as many as {\sc Reluplex}\xspace. Our technique is able to solve more benchmarks in general than ${\rm AI}^2$, and is able to solve them far faster. Moreover, we provide theoretical guarantees about the termination and ($\delta$-)completeness of our approach. In order to improve our tool in the future, we plan to explore a broader set of abstract domains and different black-box optimization techniques. Notably, one can view solver-based techniques as a perfectly precise abstract domain. While solver-based techniques have so far proven to be slow on many benchmarks, our method could learn when it is best to apply solvers and when to choose a less precise domain. This would allow the tool to combine solvers and traditional numerical domains in the most efficient way. Additionally, while Bayesian optimization fits our current framework well, it may be possible to modify the framework to work with different learning techniques which can explore higher-dimensional strategy spaces. In particular, reinforcement learning may be an interesting approach to explore in future work. \section{Discussion} \label{sec:disc} \subsection{Limitations} Our learned policy has two main limitations. First, since it is very expensive to train Bayesian optimization to learn a large number of parameters, we must manually identify a small set of features that best indicate how to refine and verify the input space. Second, our selection function assumes a linear combination of the learned parameters and features. However, in the optimal policy, the mapping of features to \todo{policy decisions} could be nonlinear. Both of these limitations could be addressed by a policy learned through Deep Reinforcement Learning (Deep RL). A neural network will automatically identify the most important features and learn a nonlinear mapping of those features to actions. Deep RL is a semi-supervised technique which requires a large, curated training set which may also require large manual effort. We leave this approach as interesting future work. \section{Evaluation} \label{sec:eval} To evaluate the ideas proposed in this paper, we conduct an experimental evaluation that is designed to answer the following three research questions: \begin{enumerate}[label=(RQ\arabic*)] \item How does {\sc Charon}\xspace\ compare against state-of-the-art tools for proving neural network robustness? \item How does counterexample search impact the performance of {\sc Charon}\xspace? \item What is the impact of learning a verification policy on the performance of {\sc Charon}\xspace? \end{enumerate} \paragraph{Benchmarks.} To answer these research questions, we collected a benchmark suite of 602 verification problems across 7 deep neural networks, including one convolutional network and several fully connected networks. The fully connected networks have sizes 3$\times$100, 6$\times$100, 9$\times$100, and 9$\times$200, where $N\times M$ means there are $N$ fully connected layers and each interior layer has size $M$. The convolutional network has a LeNet architecture \cite{LeNet} consisting of two convolutional layers, followed by a max pooling layer, two more convolutional layers, another max pooling layer, and finally three fully connected layers. All of these networks were trained on the MNIST \cite{LeNet} and CIFAR \cite{CIFAR} datasets. \begin{comment} The first two convolutional layers use 8 filters with a 3$\times$3 kernel, and the other two convolutional layers use 14 filters with a 3$\times$3 kernel. The max pooling layers each use a window size of 2$\times$2. The final three fully connected layers each have size 50. \end{comment} \subsection{ Comparison with ${\rm AI}^2$ \ (RQ1)}\label{sec:ai2-compare} \begin{figure*} \includegraphics[width=\textwidth]{ai2-summary} \vspace{-0.2in} \caption{Summary of results for ${\rm AI}^2$\ and {\sc Charon}\xspace.} \label{fig:ai2-summary} \vspace{-0.2in} \end{figure*} For each network, we attempt to verify around 100 robustness properties. Following prior work \cite{ai2}, the evaluated robustness properties are so-called \emph{brightening attacks} \cite{deepxplore}. For an input point $x$ and a threshold $\tau$, a brightening attack consists of the input region \[I = \left\{x' \in \ensuremath{\mathbb{R}}^n \mid \forall i. (x_i \ge \tau \wedge x_i \le x'_i \le 1) \vee x'_i = x_i\right\}.\] That is, for each pixel in the input image, if the value of that pixel is greater than $\tau$, then the corresponding pixel in the perturbed image may be anywhere between the initial value and one, and all other pixels remain unchanged. \paragraph{Set-up.} All experiments described in this section were performed on the Google Compute Engine (GCE) \cite{GCP} using an 8 vcpu instance with 10.5 GB of memory. All time measurements report the total CPU time (rather than wall clock time) in order to avoid biasing the results because of {\sc Charon}\xspace's parallel nature. For the purposes of this experiment, we set a time limit of 1000 seconds per benchmark. \begin{figure} \includegraphics[width=\columnwidth]{mnist_3_100} \vspace{-0.4in} \caption{Comparison on a 3x100 MNIST network.} \label{fig:mnist-3-100} \vspace{-0.1in} \end{figure} \begin{figure} \includegraphics[width=\columnwidth]{mnist_6_100} \vspace{-0.4in} \caption{Comparison on a 6x100 MNIST network.} \label{fig:mnist-6-100} \vspace{-0.1in} \end{figure} \begin{figure} \includegraphics[width=\columnwidth]{mnist_9_200} \vspace{-0.4in} \caption{Comparison on a 9x200 MNIST network.} \label{fig:mnist-9-200} \vspace{-0.1in} \end{figure} \begin{figure} \includegraphics[width=\columnwidth]{cifar_3_100} \vspace{-0.4in} \caption{Comparison on a 3x100 CIFAR network.} \label{fig:cifar-3-100} \vspace{-0.1in} \end{figure} In this section we compare {\sc Charon}\xspace\ with ${\rm AI}^2$~\footnote{Because we did not have access to the original ${\rm AI}^2$, we reimplemented it. However, to allow for a fair comparison, we use the same underlying abstract interpretation library, and we implement the transformers exactly as described in \cite{ai2}.}, a state-of-the-art tool for verifying network robustness~\cite{ai2}. As discussed in Section~\ref{sec:background}, ${\rm AI}^2$\ is incomplete and requires the user to specify which abstract domain to use. Following their evaluation strategy from the IEEE S\&P paper~\cite{ai2}, we instantiate ${\rm AI}^2$\ with two different domains, namely zonotopes and bounded powersets of zonotopes of size 64. We refer to these two variants as ${\rm AI}^2$-Zonotope and ${\rm AI}^2$-Bounded64. The results of this comparison are summarized in Figure~\ref{fig:ai2-summary}. This graph shows the percentage of benchmarks each tool was able to verify or falsify, as well as the percentage of benchmarks where the tool timed out and the percentage where the tool was unable to conclude either true or false. Note that, because {\sc Charon}\xspace\ is $\delta$-complete, there are no ``unknown'' results for it, and because ${\rm AI}^2$\ cannot find counterexamples, ${\rm AI}^2$\ has no ``falsified'' results. The details for each network are shown in Figures~\ref{fig:mnist-3-100} -~\ref{fig:mnist_conv}. Each chart shows the cumulative time taken on the y-axis and the number of benchmarks solved on the x-axis (so lower is better). The results for each tool include only those benchmarks that the tool could solve correctly within the time limit of 1000 seconds. Thus, a line extending further to the right indicates that the tool could solve more benchmarks. Since ${\rm AI}^2$-Bounded64 times out on every benchmark for the convolutional network, it does not appear in Figure~\ref{fig:mnist_conv}. \begin{figure} \includegraphics[width=\columnwidth]{cifar_6_100} \vspace{-0.4in} \caption{Comparison on a 6x100 CIFAR network.} \label{fig:cifar-6-100} \vspace{-0.1in} \end{figure} \begin{figure} \includegraphics[width=\columnwidth]{cifar_9_100} \vspace{-0.4in} \caption{Comparison on a 9x100 CIFAR network.} \label{fig:cifar-9-100} \vspace{-0.1in} \end{figure} \begin{figure} \includegraphics[width=\columnwidth]{mnist_conv} \vspace{-0.4in} \caption{Comparison on a convolutional network.} \label{fig:mnist_conv} \vspace{-0.2in} \end{figure} The key take-away lesson from this experiment is that {\sc Charon}\xspace\ is able to both solve more benchmarks compared to ${\rm AI}^2$-Bounded64 on most networks, and it is able to solve them much faster. In particular, {\sc Charon}\xspace solves $59.7\%$ (resp. $84.7\%$) more benchmarks compared to ${\rm AI}^2$-Bounded64 (resp. ${\rm AI}^2$-Zonotope). Furthermore, among the benchmarks that can be solved by both tools, {\sc Charon}\xspace is 6.15$\times$ (resp. 1.12$\times$ ) faster compared to ${\rm AI}^2$-Bounded64 (resp. ${\rm AI}^2$-Zonotope). Thus, we believe these results demonstrate the advantages of our approach compared to ${\rm AI}^2$. \subsection{ Comparison with Complete Tools (RQ1)}\label{sec:reluval-comp} In this section we compare {\sc Charon}\xspace\ with other complete tools for robustness analysis, namely {\sc ReluVal}\xspace~\cite{reluval} and {\sc Reluplex}\xspace~\cite{reluplex}. Among these tools, {\sc Reluplex}\xspace implements a variant of Simplex with built-in support for the ReLU activation function~\cite{reluplex}, and {\sc ReluVal}\xspace\ is an abstraction refinement approach without learning or counterexample search. \begin{comment} {\sc ReluVal}\xspace is more similar to our approach in that it is based on abstract interpretation but performs refinement over the input region to attain completeness. However, unlike our approach, {\sc ReluVal}\xspace\ does not use optimization to search for counterexamples, and it also does not use a machine-learnt verification policy to refine the abstraction. \end{comment} To perform this experiment, we evaluate all three tools on the same benchmarks from Section~\ref{sec:ai2-compare}. However, since {\sc ReluVal}\xspace\ and {\sc Reluplex}\xspace\ do not support convolutional layers, we exclude the convolutional net from this evaluation. \begin{figure} \includegraphics[width=\columnwidth]{completeTools} \vspace{-0.1in} \caption{Comparison with {\sc ReluVal}\xspace.} \label{fig:reluval} \vspace{-0.1in} \end{figure} The results of this comparison are summarized in Figure~\ref{fig:reluval}. Across all benchmarks, {\sc Charon}\xspace\ is able to solve 2.6$\times$ (resp. 16.6$\times$) more problems compared to {\sc ReluVal}\xspace (resp. {\sc Reluplex}\xspace). Furthermore, it is worth noting that the set of benchmarks that can be solved by {\sc Charon}\xspace\ is a strict superset of the benchmarks solved by {\sc ReluVal}\xspace. \begin{comment} Figure~\ref{fig:reluval} shows the number of benchmarks {\sc Charon}\xspace\ and {\sc ReluVal}\xspace\ were able to solve within the given timeout. {\sc Reluplex}\xspace\ is not shown in Figure~\ref{fig:reluval} because it timed out on every benchmark for all networks except for MNIST 3x100, where it solved 22\%. The convolutional network is not included because {\sc ReluVal}\xspace\ and {\sc Reluplex}\xspace\ do not support convolutional networks. {\sc Charon}\xspace\ is able to solve about two to three times as many benchmarks as {\sc ReluVal}\xspace\ in the same amount of time, and every benchmark which {\sc ReluVal}\xspace\ can solve, {\sc Charon}\xspace\ can also solve. \end{comment} \subsection{Impact of Counterexample Search (RQ2) } To understand the benefit of using optimization to search for counterexamples, we now compare the number of properties that can be \emph{falsified} using {\sc Charon}\xspace vs. {\sc Reluplex}\xspace and {\sc ReluVal}\xspace. (Recall that ${\rm AI}^2$\ is incomplete and cannot be used for falsification.) Among the 585 benchmarks used in the evaluation from Section~\ref{sec:reluval-comp}, {\sc Charon}\xspace\ can falsify robustness of 123 benchmarks. In contrast, {\sc Reluplex}\xspace can only falsify robustness of one benchmark, and {\sc ReluVal}\xspace cannot falsify any of them. Thus, we believe these results demonstrate the usefulness of incorporating optimization-based counterexample search into the decision procedure. \begin{comment} To evaluate the usefulness of the counterexample search in our tool, we compare our results on false benchmarks to those of {\sc ReluVal}\xspace. Since counterexample search is used to efficiently falsify properties, we expect that such false benchmarks should highlight the role the counterexample search plays in our technique. Notably, {\sc ReluVal}\xspace\ was unable to find counterexamples for any of the benchmarks in our evaluation set while we were able to find counterexamples for 123 benchmarks. Additionally, when the benchmarks were falsified, a counterexample could be found without splitting in 99 cases. \end{comment} \subsection{ Impact of Learning a Verification Policy (RQ3)} \begin{figure} \includegraphics[width=\columnwidth]{learning_comparison} \vspace{-0.1in} \caption{Comparison with {\sc ReluVal}\xspace\ on verified benchmarks.} \vspace{-0.2in} \label{fig:reluval-verified} \end{figure} Recall that a key feature of our algorithm is the use of a machine-learnt verification policy $\pi$ to choose a refinement strategy. To explore the impact of this design choice, we compare our technique against {\sc ReluVal}\xspace on the subset of the 585 benchmarks for which the robustness property holds. In particular, as mentioned earlier, {\sc ReluVal}\xspace is also based on a form of abstraction refinement but uses a static, hand-crafted strategy rather than one that is learned from data. Thus, comparing against {\sc ReluVal}\xspace on the verifiably-robust benchmarks allows us to evaluate the benefits of learning a verification policy from data.~\footnote{We compare with {\sc ReluVal}\xspace directly rather than reimplementing the {\sc ReluVal}\xspace strategy inside {\sc Charon}\xspace because our abstract interpretation engine does not support the domain used by {\sc ReluVal}\xspace. Given this, we believe the comparison to {\sc ReluVal}\xspace is the most fair available option.} The results of this comparison are shown in Figure~\ref{fig:reluval-verified}. As we can see from this figure, {\sc ReluVal}\xspace\ is still only able to solve between 35-70\% of the benchmarks that can be successfully solved by {\sc Charon}\xspace. Thus, these results demonstrate that our data-driven approach to learning verification policies is useful for verifying network robustness. \begin{comment} To evaluate the effect Bayesian optimization had on our results, we compare against {\sc ReluVal}\xspace\ on the set of benchmarks which could be verified. As metnioned in the previous section, the counterexample search is helpful when a property is false because it allows the tool to quickly find counterexamples. Therefore, by removing the false benchmarks, we can remove the effect the counterexample search has on the results and focus on the effect of learning. The results are given in Figure~\ref{fig:reluval-verified}. Note that {\sc ReluVal}\xspace\ is still only able to solve between 35 and 70\% of the benchmarks that {\sc Charon}\xspace\ can solve. \end{comment} \section{Implementation} \label{sec:impl} We have implemented the ideas proposed in this paper in a tool called {\sc Charon}\xspace, written in C++. Internally, {\sc Charon}\xspace\ uses the ELINA abstract interpretation library \cite{elina} to implement the \Call{Analyze}{} procedure from Algorithm~\ref{alg:refinement}, and it uses the BayesOpt library ~\cite{bayesopt} to perform Bayesian optimization. \paragraph{Parallelization.} Our proposed verification algorithm is easily parallelizable, as different calls to the abstract interpreter can be run on different threads. Our implementation takes advantage of this observation and utilizes as many threads as the host machine can provide by running different calls to ELINA in parallel. \paragraph{Training.} We trained our verification policy on 12 different robustness properties of a neural network used in the ACAS Xu collision avoidance system~\cite{uas}. However, since even verifying even a single benchmark can take a very long time, our implementation uses two tactics to reduce training time. First, we parallelize the training phase of the algorithm using the MPI framework \cite{MPI} and solve each benchmark at the same time. Second, we set a time limit of 700 seconds (per-process cputime) per benchmark. Contrary to what we may expect from machine learning systems, a small set of benchmarks is sufficient to learn a good strategy for our setting. We conjecture that this is because the relatively small number of features allowed by Bayesian optimization helps to regularize the learned policy. \paragraph{Featurization.} Recall that our verification policy uses a \emph{featurization function} to convert its input to a feature vector. As mentioned in Section~\ref{sec:featurization}, this featurization function should select a compact set of features so that our training is efficient and avoids overfitting our policy to the training set. These features should also capture revalant information about the network and the property so that our learned policy can generalize across networks. With this in mind, we used the following features in our implementation: \begin{itemize}[leftmargin=*] \item the distance between the center of the input region $I$ and the solution $x_*$ to the optimization problem \item the value of the objective function $\mathcal{F}$ (Eq.~\ref{eq:objective}) at $x_*$ \item the magnitude of the gradient of the network at $x_*$ \item average length of the input space along each dimension \end{itemize} \paragraph{Selection.} Recall from Section~\ref{sec:learning} that our verification policy $\pi$ uses two different selection functions $\varphi^\alpha$ and $\varphi^I$ for choosing an abstract domain and splitting plane respectively. The selection function $\varphi^I$ takes a vector of three inputs. The first two are real-valued numbers that decide which dimension to split on. Rather than considering all possible dimensions, our implementation chooses between two dimensions to make training more manageable. The first one is the longest dimension (i.e., input dimension with the largest length), and the second one is the dimension that has the largest \emph{influence} \cite{reluval} on $\mathcal{N}(x)_K$. The last input to the selection function is the offset at which to split the region. This value is clipped to $[0,1]$ and then interpreted as a ratio of the distance from the center of the input region $I$ to the solution $x_*$ of Eq.~\ref{eq:optimization}. For example, if the value is 0, the region will be bisected, and if the value is 1, then the splitting plane will intersect $x_*$. Finally, if the splitting plane is at the boundary of $I$, it is offset slightly so that the strategy satisfies Assumption~\ref{asm:split-reduces-size}. The selection function $\varphi^\alpha$ for choosing an abstract domain takes a vector of two inputs. The first controls the base abstract domain (intervals or zonotopes) and the second controls the number of disjuncts to use. In both cases, the output is extracted by first clipping the input to a fixed range and then discretizing the resulting value. \section{Introduction} \label{sec:intro} In recent years, deep neural networks (DNNs) have gained enormous popularity for a wide spectrum of applications, ranging from image recognition\cite{image-recognition-1, image-recognition-2} and malware detection \cite{malware-1,malware-2} to machine translation\cite{machine-translation}. Due to their surprising effectiveness in practice, deep learning has also found numerous applications in safety-critical systems, including self-driving cars~\cite{car-1, car-2}, unmanned aerial systems~\cite{uas}, and medical diagnosis~\cite{diagnosis}. Despite their widespread use in a broad range of application domains, it is well-known that deep neural networks are vulnerable to \emph{adversarial counterexamples}, which are small perturbations to a network's input that cause the network to output incorrect labels~\cite{adversarial-1,adversarial-2}. For instance, Figure~\ref{fig:adversarial} shows two adversarial examples in the context of speech recognition and image classification. As shown in the top half of Figure~\ref{fig:adversarial}, two sound waves that are virtually indistinguishable are recognized as ``How are you?" and ``Open the door" by a DNN-based speech recognition system~\cite{gong2018overview}. Similarly, as illustrated in the bottom half of the same figure, applying a tiny perturbation to a panda image causes a DNN to misclassify the image as that of a gibbon. It is by now well-understood that such adversarial counterexamples can pose serious security risks~\cite{advsurvey}. Prior work~\cite{BastaniILVNC16,reluplex,deepxplore,veriviz,ai2} has advocated the property of \emph{local robustness} (or \emph{robustness} for short) for protecting neural networks against attacks that exploit such adversarial examples. To understand what robustness means, consider a neural network that classifies an input $x$ as having label $y$. Then, local robustness requires that all inputs $x'$ that are ``very similar''~\footnote{For example, ``very similar'' may mean $x'$ is within some $\epsilon$ distance from $x$, where distance can be measured using different metrics such as $L^2$ norm.} to $x$ are also classified as having the same label $y$. \begin{figure}[t] \includegraphics[width=0.8\columnwidth]{adversarial.pdf} \vspace{-0.1in} \caption{ Small perturbations of the input cause the sound wave and the image to be misclassified.} \label{fig:adversarial} \vspace{-0.15in} \end{figure} Due to the growing consensus on the desirability of robust neural networks, many recent efforts have sought to algorithmically analyze robustness of networks. Of these, one category of methods seeks to discover {adversarial counterexamples} using numerical optimization techniques such as Projected Gradient Descent (PGD)~\cite{madry2017towards} and Fast Gradient Sign Method (FGSM)~\cite{GoodfellowSS14}. A second category aims to \emph{prove} network robustness using symbolic methods ranging from SMT-solving~\cite{reluplex} to abstract interpretation~\cite{ai2,reluval}. These two categories of methods have complementary advantages. Numerical counterexample search methods can quickly find violations, but are ``unsound'', in that they fail to offer certainty about a network's robustness. In contrast, proof search methods are sound, but they are either incomplete~\cite{ai2} (i.e., suffer from false positives) or do not scale well~\cite{reluplex}. In this paper, we present a new technique for robustness analysis of neural networks that combines the best of proof-based and optimization-based methods. Our approach combines formal reasoning techniques based on \emph{abstract interpretation} with continuous and black-box optimization techniques from the machine learning community. This tight coupling of optimization and abstraction has two key advantages: First, optimization-based methods can efficiently search for counterexamples that prove the violation of the robustness property, allowing efficient falsification in addition to verification. Second, optimization-based methods provide a data-driven way to automatically refine the abstraction when the property can be neither falsified nor proven. The workflow of our approach is shown schematically in Figure~\ref{fig:cegar} and consists of both a \emph{training} and a \emph{deployment} phase. During the training phase, our method uses black-box optimization techniques to learn a so-called \emph{verification policy} $\pi_\theta$ from a representative set of training problems. Then the deployment phase uses the learned verification policy to guide how gradient-based counterexample search should be coupled with proof synthesis for solving previously-unseen verification problems. \begin{figure}[h] \includegraphics[width=0.9\columnwidth]{overview-new.pdf} \vspace{-0.1in} \caption{Schematic overview of our approach.} \label{fig:cegar} \vspace{-0.15in} \end{figure} The input to the deployment phase of our algorithm consists of a neural network $\mathcal{N}$ as well as a robustness specification $(I, K)$ which states that all points in the \emph{input region} $I$ should be classified as having label $K$. Given this input, our algorithm first uses gradient-based optimization to search for an adversarial counterexample, which is a point in the input region $I$ that is classified as having label $K' \neq K$. If we can find such a counterexample, then the algorithm terminates with a witness to the violation of the property. However, even if the optimization procedure fails to find a true counterexample, the result $x_*$ of the optimization problem can still convey useful information. In particular, our method uses the learned verification policy $\pi_\theta$ to map all available information, including $x_*$, to a promising abstract domain $\mathcal{A}$ to use when attempting to verify the property. If the property can be verified using domain $\mathcal{A}$, then the algorithm successfully terminates with a robustness proof. In cases where the property is neither verified nor refuted, our algorithm uses the verification policy $\pi_\theta$ to \emph{split} the input region $I$ into two sub-regions $I_1, I_2$ such that $I = I_1 \cup I_2$ and tries to verify/falsify the robustness of each region separately. This form of refinement is useful for both the abstract interpreter as well as the counterexample finder. In particular, since gradient-based optimization methods are not guaranteed to find a global optimum, splitting the input region into smaller parts makes it more likely that the optimizer can find an adversarial counterexample. Splitting the input region is similarly useful for the abstract interpreter because the amount of imprecision introduced by the abstraction is correlated with the size of the input region. \begin{comment} However, existing efficient optimization methods are unable to guarantee that a counterexample will be found if one exists. Therefore, if we are unable to find a counterexample, we cannot immediately conclude that the region is safe, so our method tries to discover a proof of the property using abstract interpretation. If we can verify the property, the algorithm terminates with a proof. If we cannot, we iteratively {\em refine} our abstraction of the network and carry out alternating rounds of proof and counterexample search. Both the proof search and the counterexample search become easier under the increasingly refined abstraction. \end{comment} As illustrated by the discussion above, a key part of our verification algorithm is the use of a policy $\pi_\theta$ to decide (a) which abstract domain to use for verification, and (b) how to split the input region into two sub-regions. Since there is no obvious choice for either the abstract domain or the splitting strategy, our algorithm takes a \emph{data-driven approach} to learn a suitable verification policy $\pi_\theta$ during a training phase. During this training phase, we use a black-box optimization technique known as Bayesian optimization to learn values of $\theta$ that lead to strong performance on a representative set of verification problems. Once this phase is over, the algorithm can be deployed on networks and properties that have not been encountered during training. \begin{comment} A key innovation underlying our approach is in the use of {\em data-driven learning} to couple proof and counterexample search. Concretely, at the heart of our algorithm is a {\em verification policy} $\pi_\theta$, which is a parameterized function whose parameters $\theta$ can be learned using a representative set of training data. The verification policy takes as input the algorithm's state at the end of a failed verification/falsification attempt and outputs an abstraction refinement strategy, which involves (a) splitting the input region into two disjoint sub-regions to be analyzed separately, and (b) finding suitable abstract domains to use for verifying each sub-region. During the algorithm's training phase, we use a black-box optimization technique known as Bayesian optimization to learn values of $\theta$ that lead to strong performance on a representative set of verification problems. Once this phase is over, the algorithm can be deployed on networks and properties that have not been encountered during training. \end{comment} \begin{comment} The workflow of our approach is shown schematically in Figure~\ref{fig:cegar}. Given a neural network and a local robustness property, our method first tries to find a point which violates the property. If we can find such a point, then the network is provably \emph{not} robust; thus, the algorithm terminates with a witness to the violation of the property. Otherwise, our method uses an optimization procedure to find an \emph{``almost adversarial''} example, which is a point $x_*$ in the input space that comes closest to violating the specification but does not actually violate it. Since neural networks compute continuous functions of their input, our key idea is that \emph{points in the input space that are close to violating the specification should be analyzed more precisely than other parts of the input space}. Therefore, we use information about $x_*$ to choose a set of parameters $\theta$ for an abstract interpretation engine. We then attempt to verify the property using the parameters $\theta$. The second part of our refinement strategy applies when we are not able to either verify or falsify the specification. To perform refinement, our method uses the almost adversarial example computed previously. Since neural networks compute continuous functions of their input, our key idea is that \emph{regions of the input space that are near the almost-adversarial example} $x_*$ \emph{should be analyzed more precisely than other parts of the input space}. Thus, our method partitions the input region $I$ into two disjoint subsets $I^c, I^p$ such that $I = I^c \uplus I^p$ and $I^p$ contains $x_*$. \end{comment} \begin{comment} The most interesting part of our technique is the abstraction refinement engine, which is invoked when the property can be neither verified nor refuted. To perform refinement, our method obtains an \emph{``almost adversarial''} example, which is a point in the input space that comes closest to violating the property but does not actually violate it. Since neural networks compute continuous functions of their input, our key idea is that \emph{regions of the input space that are near the almost-adversarial example} $x_*$ \emph{should be analyzed more precisely than other parts of the input space}. Thus, our method partitions the input region $I$ into two disjoint subsets $I^c, I^p$ such that $I = I^c \uplus I^p$ and $I^p$ contains $x_*$. Since $I_p$ should be analyzed more precisely than $I_c$, the abstraction refinement engine also computes two different sets of parameters $\theta_c$ and $\theta_p$ and generates two new verification problems where $I^p$ (resp. $I^c$) is analyzed using $\theta^p$ (resp. $\theta^c$). \end{comment} \begin{comment} Based on the above discussion, the abstraction refinement engine needs to make two important decisions: First, given an input region $I$, network $N$, and an almost-adversarial example $x_*$, what is the ``best" way to partition the input region into two subsets? Second, given two input regions $I^c$ and $I^p$, what are the ``best'' parameters to use when proving the property for each input region? In this work, we use machine learning to automatically infer both a suitable partitioning strategy as well as the parameters of the abstract interpretation engine. However, due to the non-differentiable nature of our objective function as well as the difficulty of evaluating it, the underlying optimization problem ends up being very difficult. Our method solves this problem by using \emph{Bayesian optimization}\cite{bayesian-opt}, which has been shown to work well in exactly these kinds of settings. \end{comment} Our proposed verification algorithm has some appealing theoretical properties in that it is both sound and $\delta$-complete~\cite{delta-complete}. That is, if our method verifies the property $(I, K)$ for network $\mathcal{N}$, this means that $\mathcal{N}$ does indeed classify all points in the input region $I$ as belonging to class $K$. Furthermore, our method is $\delta$-complete in the sense that, if the property is falsified with counterexample $x_*$, this means that $x_*$ is within $\delta$ of being a true counterexample. We have implemented the proposed method in a tool called {\sc Charon}\xspace\ \footnote{\underline{C}omplete \underline{H}ybrid \underline{A}bstraction \underline{R}efinement and \underline{O}ptimization for \underline{N}eural Networks.}, and used it to analyze hundreds of robustness properties of ReLU neural networks, including both fully-connected and convolutional neural networks, trained on the MNIST~\cite{LeNet} and CIFAR~\cite{CIFAR} datasets. We have also compared our method against state-of-the-art network verification tools (namely, {\sc Reluplex}\xspace, {\sc ReluVal}\xspace, and ${\rm AI}^2$) and shown that our method outperforms all prior verification techniques, either in terms of accuracy or performance or both. In addition, our experimental results reveal the benefits of learning to couple proof search and optimization. In all, this paper makes the following key contributions: \begin{itemize}[leftmargin=*] \item We present a new sound and $\delta$-complete decision procedure that combines abstract interpretation and gradient-based counterexample search to prove robustness of deep neural networks. \item We describe a method for automatically learning verification policies that direct counterexample search and abstract interpretation steps carried out during the analysis. \item We conduct an extensive experimental evaluation on hundreds of benchmarks and show that our method significantly outperforms state-of-the-art tools for verifying neural networks. For example, our method solves $2.6\times$ and $16.6\times$ more benchmarks compared to {\sc ReluVal}\xspace\ and {\sc Reluplex}\xspace\ respectively. \end{itemize} \paragraph{Organization.} The rest of this paper is organized as follows. In Section~\ref{sec:background}, we provide necessary background on neural networks, robustness, and abstract interpretation of neural networks. In Section~\ref{sec:refinement}, we present our algorithm for checking robustness, given a verification policy (i.e., the deployment phase). Section~\ref{sec:learning} describes our data-driven approach for learning a useful verification policy from training data (i.e., the training phase), and Section~\ref{sec:theorems} discusses the theoretical properties of our algorithm. Finally, Sections~\ref{sec:impl} and ~\ref{sec:eval} describe our implementation and experimental evaluation, Section~\ref{sec:related} discusses related work, and Section~\ref{sec:conclusion} concludes. \section{Learning a Verification Policy} \label{sec:learning} As described in Section~\ref{sec:refinement}, our decision procedure for checking robustness uses a verification policy $\pi_\theta = (\pi^\domain_\theta, \pi^I_\theta)$ to choose a suitable abstract domain and an input partitioning strategy. In this section, we discuss our policy representation and how to learn values of $\theta$ that lead to good performance. \begin{comment} As described in Section~\ref{sec:refinement}, the goal of refinement is two-fold: First, given an input-region $I$, we want to split it into two regions $I_1$, $I_2$, and, second, we want to learn parameters $\theta_i$ used for analyzing region $I_i$. As mentioned in Section~\ref{sec:intro}, we address both of these problems using Bayesian optimization. \end{comment} \begin{comment} As with any machine learning approach, our refinement algorithm incorporates both an on-line and off-line phase. Specifically, during the off-line phase, we solve an optimization problem where the goal is find hyper-parameters that maximize the number of training problems that can be solved within a given time limit. These hyper-parameters are expressed as a real-valued matrix $W$. Then, during the on-line phase, we use the learned matrix $W$ to compute a plane around which the input region is split, as well as parameters that can be used to analyze each region. \end{comment} \subsection{Policy Representation}\label{sec:policy-representation} In this work, we implement verification policies $\pi^\domain_\theta$ and $\pi^I_\theta$ using a function of the following shape: \begin{equation}\label{eq:policy-rep} \varphi(\theta \, \rho(\mathcal{N}, I, K, x_* )) \end{equation} where $\rho$ is a \emph{featurization function} that extracts a feature vector from the input, $\varphi$ is a \emph{selection} function that converts a real-valued vector to a suitable output (i.e., an abstract domain for $\pi^\domain_\theta$ and the two subregions for $\pi^I_\theta$), and $\theta$ corresponds to a parameter matrix that is automatically learned from a representative set of training data. We discuss our featurization and selection functions in this sub-section and explain how to learn parameters $\theta$ in the next sub-section. \paragraph{Featurization.} \label{sec:featurization} As standard in machine learning, we need to convert the input $\iota = (\mathcal{N}, I, K, x_*)$ to a feature vector. Our choice of features is influenced by our insights about the verification problem, and we deliberately use a small number of features for two reasons: First, a large number of dimensions can lead to overfitting and poor generalization (which is especially an issue when training data is fairly small). Second, a high-dimensional feature vector leads to a more difficult learning problem, and contemporary Bayesian optimization engines only scale to a few tens of dimensions. Concretely, our featurization function considers several kinds of information, including: (a) the behavior of the network near $x_*$, (b) where $x_*$ falls in the input space, and (c) the size of the input space. Intuitively, we expect that (a) is useful because as $x_*$ comes closer to violating the specification, we should need a more precise abstraction, while (b) and (c) inform how we should split the input region during refinement. Since the precision of the analysis is correlated with how the split is performed, we found the same featurization function to work well for both policies $\pi^\domain_\theta$ and $\pi^I_\theta$. In Section~\ref{sec:impl}, we discuss the exact features used in our implementation. \begin{comment} The featurization functions $\pi_R$ and $\pi_C$ take a network $\mathcal{N}$, an input region $I$, and an almost counterexample $x_*$, and return a vector of real-valued features. The features we use include: \begin{itemize} \item The value of the objective function from Eq.~\ref{eq:objective} evaluated at $x_*$ \item The distance between the center of $I$ and $x_*$ \item The magnitude of the gradient of the network at $x_*$ \end{itemize} Intuitively, this information about the counterexample is useful because as the value of the objective function Eq.~\ref{eq:objective} decreases, we should need a more precise domain. Therefore the value of the objective function is a necessary feature. The distance between the center of $I$ and $x_*$ is relevant because if $x_*$ is close to the edge of $I$ then a very precise domain may be needed to verify the property, or it may be better to use a less precise domain, fail to verify quickly, and then split $I$. The magnitude of the gradient is a simple way to estimate the Lipschitz constant of the network in the region $I$, so we expect that as the gradient increases a more precise domain may be needed. Finally, we append a constant one to the feature vector in order to allow the learned parameters to apply a bias. \end{comment} \paragraph{Selection function.} Recall that the purpose of the selection function $\varphi$ is to convert $\theta \rho(\iota)$ to a "strategy", which is an abstract domain for $\pi^\domain$ and a hyper-plane for $\pi^I$. Since the strategies for these two functions are quite different, we use two different selection functions, denoted $\varphi_\alpha, \varphi_I$ for the domain and partition policies respectively. The selection function $\varphi_\alpha$ is quite simple and maps $\theta \rho(\iota)$ to a tuple $(d, k)$ where $d$ denotes the base abstract domain (either intervals $\mathbb{I}$ or zonotopes $\mathbb{Z}$ in our implementation) and $k$ denotes the number of disjuncts. Thus, $(\mathbb{Z}, 2)$ denotes the powerset of zonotopes abstract domain, where the maximum number of disjuncts is restricted to $2$, and $(\mathbb{I}, 1)$ corresponds to the standard interval domain. In the case of the partition policy $\pi^I$, the selection function $\varphi_I$ is also a tuple $(d, c)$ where $d$ is the dimension along which we split the input region and $c$ is the point at which to split. In other words, if $\varphi_I(\theta \rho(\iota)) = (d, c)$, this means that we split the input region $I$ using the hyperplane $x_d = c$. Our selection function $\varphi_I$ does not consider arbitrary hyperplanes of the form $c_1 x_1 + \ldots c_n x_n = c$ because splitting the input region along an arbitrary hyperplane may result in sub-regions that are not expressible in the chosen abstract domain. In particular, this is true for both the interval and zonotope domains used in our implementation. \begin{comment} The two extraction functions $\varphi_R$ and $\varphi_C$ each take a single real value $y$ as an input. The extraction function for \Call{Refine}{}, $\varphi_R$, extracts a pair of subregions $I_1,I_2$ in several steps: \begin{enumerate} \item Clip $y$ to $y' = \max(-1+\varepsilon, \min(1-\varepsilon, y))$ for some $\varepsilon$. \item Compute the dimension $n$ of the input space which has the greatest magnitude gradient. \item Scale $y'$ to a value \[c = y' * \frac{I_u(n) - I_l(n)}{2} + \frac{I_u(n) + I_l(n)}{2}\] \item Split the region $I$ around the plane $x_n = c$. \end{enumerate} The value $\varepsilon$ is some small value chosen to make sure that neither sub-region encompasses the entire original region. Because of this, we know that the algorithm makes progress in each step. Splitting around an axis-aligned plane ensures that if $I$ is an interval to begin with, then after any number of splits, any sub-region is still an interval. This means that we can always represent the input space precisely in any abstract domain. The extraction function for \Call{ChooseDomain}{}, $\varphi_C$, chooses to use either intervals or zonotopes by checking whether the input $y$ is more or less than zero. \todo{Do we want to introduce powersets earlier given that we don't actually use them. If we do we need to mention here why we don't choose a powerset size.} \end{comment} \subsection{Learning using Bayesian Optimization}\label{sec:offline} As made evident by Eq.~\ref{eq:policy-rep}, the parameter matrix $\theta$ has a huge impact on the choices made by our verification algorithm. However, manually coming up with these parameters is very difficult because the right choice of coefficients depends on both the property, the network, and the underlying abstract interpretation engine. In this work, we take a data-driven approach to solve this problem and use {\em Bayesian optimization} to learn a parameter matrix $\theta$ that leads to optimal performance by the verifier on a set of training problems. \paragraph{Background on Bayesian optimization.} Given a function $F: \ensuremath{\mathbb{R}}^n \to \ensuremath{\mathbb{R}}$, the goal of Bayesian optimization is to find a vector $\vec{x^*} \in \ensuremath{\mathbb{R}}^n$ that maximizes $F$. Importantly, Bayesian optimization does not assume that $F$ is differentiable; also, in practice, it can achieve reasonable performance without having to evaluate $F$ very many times. In our setting, the function $F$ represents the performance of a verification policy. This function is not necessarily differentiable in the parameters of the verification policy, as a small perturbation to the policy parameters can lead to the choice of a different domain. Also, evaluating the function requires an expensive round of abstract interpretation. For these reasons, Bayesian optimization is a good fit to our learning problem. At a high level, Bayesian optimization repeatedly samples inputs until a time limit is reached and returns the best input found so far. However, rather than sampling inputs {at random}, the key part of Bayesian optimization is to predict what input is useful to sample next. Towards this goal, the algorithm uses (1) a \emph{surrogate model} $\mathcal{M}$ that expresses our current belief about $F$, and (b) an \emph{acquisition function} $\mathcal{A}$ that employs $\mathcal{M}$ to decide the most promising input to sample in the next iteration. The surrogate model $\mathcal{M}$ is initialized to capture prior beliefs about $F$ and is updated based on observations on the sampled points. The acquisition function $\mathcal{A}$ is chosen to trade off exploration and exploitation where "exploration" involves sampling points with high uncertainty, and "exploitation" involves sampling points where $\mathcal{M}$ predicts a high value of $F$. Given model $\mathcal{M}$ and function $\mathcal{A}$, Bayesian optimization samples the most promising input $\vec{x}$ according to $\mathcal{A}$, evaluates $F$ at $\vec{x}$, and updates the statistical model $\mathcal{M}$ based on the observation $F(\vec{x})$. This process is repeated until a time limit is reached, and the best input sampled so far is returned as the optimum. We refer the reader to ~\cite{bayesian-opt} for a more detailed overview of Bayesian optimization. \paragraph{Using Bayesian optimization.} In order to apply Bayesian optimization to our setting, we first need to define what function we want to optimize. Intuitively, our objective function should estimate the quality of the analysis results based on decisions made by verification policy $\pi_\theta$. Towards this goal, we fix a set $S$ of representative training problems that can be used to estimate the quality of $\pi_\theta$. Then, given a parameters matrix $\theta$, our objective function $F$ calculates a score based on (a) how many benchmarks in $S$ can be successfully solved within a given time limit, and (b) how long it takes to solve the benchmarks in $S$. More specifically, our objective function $F$ is parameterized by a time limit $t \in \ensuremath{\mathbb{R}}$ and penalty $p \in \ensuremath{\mathbb{R}}$ and calculates the score for a matrix $\theta$ as follows: \[ F(\theta) = -\sum_{s \in S} \emph{cost}_\theta(s) \vspace{-0.1in} \] where: \[ \emph{cost}_\theta(s) = \left \{ \begin{array}{ll} \emph{Time}(\emph{Verify}_\theta(s)) & {\rm if} \ s \ {\rm solved} \ {\rm within} \ t \\ p \cdot t & {\rm otherwise} \end{array} \right . \] Intuitively, $p$ controls how much we want to penalize failed verification attempts -- i.e., the higher the value of $p$, the more biased the learning algorithm is towards more precise (but potentially slow) strategies. On the other hand, small values of $p$ bias learning towards strategies that yield fast results on the solved benchmarks, even if some of the benchmarks cannot be solved within the given time limit.~\footnote{In our implementation, we choose $p=2$, $t=700s$.} In order to apply Bayesian optimization to our problem, we also need to choose a suitable acquisition function and surrogate mode. Following standard practice, we adopt a \emph{Gaussian process} \cite{gaussian-process} as our surrogate model and use \emph{expected improvement} \cite{expected-improvement} for the acquisition function. \begin{comment} Intuitively, this acquisition function calculates the score of a point as the expected amount by which the value of the objective function will increase compared to any known point. More formally, suppose the best score of the objective function seen so far is $s_M$. Then the expected improvement is defined as \[EI(\theta) = E\left[\max(0, F(\theta) - s_M)\right]\] where model $\mathcal{M}$ informs expected value computation. \end{comment} \begin{comment} The most natural way to do this is to use a given strategy (determined by the weight matrix $W$) to attempt to verify some set of training properties and evaluate the strategy based on how many of these properties it is able to solve and how long it takes to do so. More specifically, we fix a set $P$ of training problems, where each problem consists of a network and a robustness property. Then for some time limit $t \in \ensuremath{\mathbb{R}}$ and penalty $p \in \ensuremath{\mathbb{R}}$ we can define a reward function $C_{t,p}(W)$ as the total amount of time needed to verify the properties in $P$, where any property on which we time out is considered to take time $pt$ to verify. Note that our cost function is not differentiable and is quite expensive to evaluate. Because of this, our optimization problem is an ideal target for Bayesian optimization. Following standard practice, we adopt a \emph{Gaussian process} \cite{gaussian-process} as our probabilistic model of the reward function. A Gaussian process models the function at each input point as a Gaussian distribution. The Gaussian process is itself parameterized by a mean function and a covariance function. Together, these two define the shape of the Gaussian distribution at each point in the domain of the function. We initialize these functions to be constant one and the well-known Mat\'{e}rn covariance function \cite{gaussian-process}. For our acquisition function, we again follow standard practice and use \emph{expected improvement} \cite{expected-improvement}. Intuitively, this function chooses points to evaluate which maximize the expected amount by which the value of the reward function will increase compared to any known point. More formally, suppose the best score of the reward function seen so far is $s_M$. Then the expected improvement is defined as \[EI(W) = E\left[\max(0, C_{t,p}(W) - s_M)\right]\] where the model $\mathcal{M}$ informs the computation of expected value. Because neural networks lack an easily interpretable structure, it is not easy to develop a refinement strategy which can efficiently verify properties by hand. Thus, it makes sense to learn a refinement strategy automatically. To do so, we first need to define the space of strategies we wish to explore in a format which is amenable to machine learning techniques. Therefore, we define a refinement strategy formally as follows: \begin{definition} \label{def:ref-strat} A \emph{refinement strategy} is a function $S$ which takes a network, an input region, and an almost adversarial example and produces the parameters for an abstract domain. Specifically, we let $S(N,I,c) = \rho(W\, \pi(N,I,c))$ where \begin{itemize} \item $\pi : Net \times \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times \ensuremath{\mathbb{R}}^{n \times m} \to \ensuremath{\mathbb{R}}^r$ extracts a set of features from a given network, input interval, and almost adversarial example. \item $W \in \ensuremath{\mathbb{R}}^{s \times r}$ is a real-valued matrix. \item $\rho : \ensuremath{\mathbb{R}}^s \to \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times O \times \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times O$ extracts the parameters of an abstract domain from a real-valued vector. \end{itemize} \end{definition} Informally, given a network, an input region, and an almost adversarial example, the strategy splits the input region into two regions and finds parameters for the abstract domain which should be used for each region. Choosing $\pi$ and $\rho$ defines a search space which can be explored by Bayesian optimization to learn an optimal strategy. For a fixed $\pi$ and $\rho$, we will define $S_W$ to be the strategy $S(N,I,c) = \rho(W\, \pi(N,I,c))$. \todo{Describe the $\pi$ and $\rho$ we end up using.} In order to choose a good strategy, we must first define what it means for a given strategy to be good. The most natural way to do this is to use the given strategy to attempt to verify some set of training properties and evaluate the strategy based on how many of these properties it is able to solve and how long it takes to do so. More formally, we fix a set $P \subseteq Net \times \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m})$ of pairs of networks and input regions. Then for some $t \in \ensuremath{\mathbb{R}}$ we can define a reward function $C_t(W)$ as the number of properties in $P$ which can be verified with strategy $S_W$ within a time limit $t$. Note that our cost function is not differentiable and is quite expensive to evaluate. Because of this, our optimization problem is an ideal target for Bayesian optimization. \end{comment} \section{Proofs} In this section we present the proofs of the theorems in Section~\ref{sec:theorems}. For convenience, the assumptions and theorem statements have been copied. \begin{repdefinition}{def:delta-complete} For a given network $\mathcal{N}$, input region $I$, target class $M$, and $\delta>0$, a $\delta$-counterexample is a point $x \in I$ such that for some $j$ with $1 \le j \le m$ and $j \neq M$, $\mathcal{N}(x)_M - \mathcal{N}(x)_j \le \delta$. \end{repdefinition} \begin{repdefinition}{def:diameter} For any set $X \subseteq \ensuremath{\mathbb{R}}^n$, its \emph{diameter} $D(X)$ is defined as \[D(X) = \sup\{\|x_1 - x_2\|_2 \mid x_1,x_2 \in X\}\] if this value exists. Otherwise the set is said to have infinite diameter. \end{repdefinition} \begin{repassumption}{asm:split-reduces-size} There exists some $\lambda \in \ensuremath{\mathbb{R}}$ with $0 < \lambda < 1$ such that for any network $\mathcal{N}$, input region $I$, and point $x_* \in I$, if $(I_1, I_2) = \Call{Refine}{N, I, x_*}$, then $D(I_1) < \lambda D(I)$ and $D(I_2) < \lambda D(I)$. \end{repassumption} \begin{repassumption}{asm:finite-overapprox} Let $\mathcal{N}^\#$ be the abstract transformer representing a network $\mathcal{N}$. Let $a$ be an element of the abstract domain representing the input region $I$. We assume there exists some $K_\mathcal{N} \in \ensuremath{\mathbb{R}}$ such that $D(\gamma(\mathcal{N}^\#(\alpha(I)))) < K_\mathcal{N} D(I)$. \end{repassumption} \begin{reptheorem}{thm:termination} Consider the variant of Algorithm~\ref{alg:refinement} where the predicate at line 3 is replaced with Eq.~\ref{eq:modification}. Then, the verification algorithm always terminates under Assumptions~\ref{asm:split-reduces-size} and~\ref{asm:finite-overapprox}. \end{reptheorem} \begin{proof} To improve readibility, we define $F(I_k) = \gamma(\mathcal{N}^\#(\alpha(I_k)))$. By Assumption~\ref{asm:split-reduces-size} there exists some $\lambda \in \ensuremath{\mathbb{R}}$ with $0 < \lambda < 1$ such that for any input region $I'$, splitting $I'$ with \Call{Refine}{} yields regions $I_1'$ and $I_2'$ with $D(I_1') < \lambda D(I')$ and $D(I_2') < \lambda D(I')$. Because there is one split for each node in the recursion tree, at a recursion depth of $k$, the region $I_k$ under consideration has diameter $D(I_k) < \lambda^k D(I)$. By Assumption~\ref{asm:finite-overapprox}, there exists some $K_\mathcal{N}$ such that $D(F(I_k)) < K_\mathcal{N} D(I_k)$. Notice that when \[k > \log_\lambda\left(\frac{\delta}{2 K_\mathcal{N} D(I)}\right)\] we must have $D(F(I_k)) < \delta / 2$. We will now show that when $k$ satisfies the preceding condition, Algorithm~\ref{alg:refinement} must terminate without recurring. In this case, suppose $x_*$ is the point returned by the call to \Call{Minimize}{} and the algorithm does not terminate. Then $\mathcal{F}(x_*)>\delta$ and in particular, $\mathcal{N}(x_*)_K-\mathcal{N}(x_*)_i > \delta$. Since \Call{Analyze}{} is sound, we must have $\mathcal{N}(x_*) \in F(I_k)$. Then since $D(F(I_k)) < \delta / 2$, we must have that for any point $y' \in F(I_k)$, $\|\mathcal{N}(x_*) - y'\|_2 < \delta / 2$. In particular, for all $i$, $|(\mathcal{N}(x_*))_i - y'_i| < \delta / 2$, so $y'_i > (\mathcal{N}(x_*))_i - \delta / 2$ and $y'_i < (\mathcal{N}(x_*))_i + \delta / 2$. Then, for all $i$, \begin{align*} y_K - y_i &> ((\mathcal{N}(x_*))_K - \delta / 2) - (\mathcal{N}(x_*))_i + \delta / 2) \\ &= ((\mathcal{N}(x_*))_K - (\mathcal{N}(x_*))_i) - \delta \\ &> 0 \end{align*} Thus, for each point $y' \in F(I_k)$, we have $y'_K > y'_i$. Since $y'$ ranges over the \emph{overapproximated} output produced by the abstract interpreter, this exactly satisfies the condition which \Call{Analyze}{} is checking, so \Call{Analyze}{} must return {\rm Verified}. Therefore, the maximum recursion depth of Algorithm~\ref{alg:refinement} is bounded, so it must terminate. \end{proof} \begin{reptheorem}{thm:completeness} Consider the variant of Algorithm~\ref{alg:refinement} where the predicate at line 3 is replaced with Eq.~\ref{eq:modification}. Then, the verification algorithm is $\delta$-complete, meaning that if the algorithm does not return ``Verified'' then the return value is a {$\delta$-counterexample} for the property. \end{reptheorem} \begin{proof} First note that by Theorem~\ref{thm:termination}, Algorithm~\ref{alg:refinement} must terminate. Therefore the algorithm must return some value, and we can prove this theorem by analyzing the possible return values. There are five places at which Algorithm~\ref{alg:refinement} can terminate: lines 4, 8, 12, 15, and 16. We only care about the case where the algorithm does not return ``Verified'' so we can ignore lines 8 and 16. The return at line 4 is only reached after checking that $x_*$ is a {$\delta$-counterexample}, so clearly if that return statement is used then the algorithm returns a {$\delta$-counterexample}. This leaves the return statements at lines 12 and 15. We suppose by induction that the recursive calls at lines 10 and 13 are $\delta$-complete. Then if $r_1$ is not {\rm Verified}, it must be a {$\delta$-counterexample}. Thus the return statement at line 12 also returns a {$\delta$-counterexample}. Similarly, if $r_2$ is not {\rm Verified}, then it is a {$\delta$-counterexample}, so line 15 returns a {$\delta$-counterexample}. \end{proof} \begin{comment} \begin{repassumption}{asm:ai2-sound} The \Call{VerifyAbstraction}{} procedure from Algorithm~\ref{alg:refinement} is sound. That is, if \Call{VerifyAbstraction}{$\mathcal{N},I,\theta,M$} returns true then the network $\mathcal{N}$ is robust in the input region $I$. \end{repassumption} \begin{reptheorem}{thm:soundness} Algorithm~\ref{alg:refinement} is sound. That is, if Algorithm~\ref{alg:refinement} terminates and does not return a counterexample, then the network $\mathcal{N}$ is robust in the input region $I$ and $\mathcal{N}$ assigns class $K$ to each $x \in I$. \end{reptheorem} \begin{proof} We proceed by (strong) induction on the maximum recursion depth. First, suppose the maximum recursion depth is one, i.e., no recursive calls are made. In this case, Algorithm~\ref{alg:refinement} must have terminated either because \Call{VerifyAbstraction}{} returned true or because a counterexample was found. By assumption, no counterexamples are found, so \Call{VerifyAbstraction}{} must have returned true. By Assumption~\ref{asm:ai2-sound}, \Call{VerifyAbstraction}{} is sound, so the network is robust in $I$. Now assume Algorithm~\ref{alg:refinement} is sound up to maximum depth $k$ and let us consider an instance where its maximum depth is $k+1$ but it does not return a counter example. We see that this can only occur if the recursive calls in lines 9 and 13 do not return counter examples. Both of these calls have depth less than or equal to $k$ so we know by our inductive hypothesis that $I_1$ and $I_2$ are robust. This means that for all $x \in I_1 \cup I_2$, the network classifies $x$ as $K$. Since the definition of a refinement strategy requires $I = I_1 \cup I_2$ the network will classify all members of $I$ as $K$. Therefore, $\mathcal{N}$ is robust in $I$ \end{proof} The following completeness theorem refers to the slightly modified definition of Algorithm~\ref{alg:refinement} discussed above. To improve readibility, we define $F(I_k) = \gamma(\mathcal{N}^\#(\alpha(I_k)))$ \begin{reptheorem}{thm:completeness} Algorithm~\ref{alg:refinement} is $\delta$-complete. That is, for a given $\delta > 0$ and input region of finite diameter, Algorithm~\ref{alg:refinement} terminates and if the property does not hold then it returns $\delta$-counterexample. \end{reptheorem} \begin{proof} By Assumption~\ref{asm:split-reduces-size} there exists some $\lambda \in \ensuremath{\mathbb{R}}$ with $0 < \lambda < 1$ such that for any input region $I'$, splitting $I'$ with \Call{Refine}{} yields regions $I_1'$ and $I_2'$ with $D(I_1') < \lambda D(I')$ and $D(I_2') < \lambda D(I')$. Because there is one split for each node in the recursion tree, at a recursion depth of $k$, the region $I_k$ under consideration has diameter $D(I_k) < \lambda^k D(I)$. By Assumption~\ref{asm:finite-overapprox}, there exists some $K_\mathcal{N}$ such that $D(F(I_k)) < K_\mathcal{N} D(I_k)$. Notice that when \[k > \log_\lambda\left(\frac{\delta}{2 K_\mathcal{N} D(I)}\right)\] we must have $D(F(I_k)) < \delta / 2$. If there are no points in $F(I_k)$ which violate the specification, then Algorithm~\ref{alg:refinement} verifies the property for the region $I_k$. Otherwise, there is a point $x \in F(I_k)$ such that $\mathcal{N}(x)_j \ge \mathcal{N}(x)_M$ for some $1 \le j \le m$ with $j \neq M$. Then for any other point $x' \in F(I_k)$, we have $\|x - x'\|_2 < \delta / 2$. Since \Call{VerifyAbstraction}{} is assumed to be sound, we know $\mathcal{N}(I_k) \subseteq F(I_k)$. Therefore for any $x' \in \mathcal{N}(I_k)$, $\|x - x'\| < \delta / 2$. But then in particular, we must have $|N(x)_i - N(x')_i| < \delta / 2$ for all $i$. Since $N(x)_K - N(x)_j \ge 0$, we have \begin{align*} N(x')_K - N(x')_j &< \left(N(x)_K + \frac{\delta}{2}\right) - \left(N(x)_j - \frac{\delta}{2}\right) \\ &= N(x)_K - N(x)_j + \delta \end{align*} Therefore any $x' \in I_k$ is a $\delta$-counterexample, and the algorithm will return this as a counterexample for the region $I_k$. Therefore, there is a finite bound on the recursion depth of Algorithm~\ref{alg:refinement}, so it must terminate. \end{proof} \end{comment} \section{Algorithm for Checking Robustness} \label{sec:refinement} In this section, we describe our algorithm for checking robustness properties of neural networks. Our algorithm interleaves optimization-based counterexample search with proof synthesis using abstraction refinement. At a high level, abstract interpretation provides an efficient way to verify properties but is subject to false positives. Conversely, optimization based techniques for finding counterexamples are efficient for finding adversarial inputs, but suffer from false negatives. Our algorithm combines the strengths of these two techniques by searching for both proofs and counterexamples at the same time and using information from the counterexample search to guide proof search. Before we describe our algorithm in detail, we need to define our optimization problem more formally. Given a network $\mathcal{N}$ and a robustness property $(I, K)$, we can view the search for an adversarial counterexample as the following optimization problem: \begin{equation}\label{eq:optimization} x_* = \argmin_{x \in I} \left( \mathcal{F}(x)\right) \end{equation} where our \emph{objective function} $\mathcal{F}$ is defined as follows: \begin{equation}\label{eq:objective} \mathcal{F}(x) = (\mathcal{N}(x))_K - \max_{j \neq K} (\mathcal{N}(x))_j \end{equation} Intuitively, the objective function $\mathcal{F}$ measures the difference between the score for class $K$ and the maximum score among classes other than $K$. Note that if the value of this objective function is not positive at some point $x$, then there exists some class which has a greater (or equal) score than the target class, so point $x$ constitutes a true adversarial counterexample. \begin{comment} \begin{theorem}\label{thm:adversarial} Let $x_*$ be the solution to the minimization problem from Eq.~\ref{eq:optimization}. Then, if $\mathcal{F}(x_*)$ is not positive, then $\mathcal{N}$ violates the robustness property $(I, K)$ and $x_*$ is an adversarial counterexample. \end{theorem} \begin{proof} If the value of the objective function is not positive, then $N(x_*)_M \le \max_{1 \le j \le m, j \neq K} \mathcal{N}(x_*)_j$, so there exists some $j \neq K$ such that $\mathcal{N}(x_*)_j \ge \mathcal{N}(x_*)_K$. Thus $x_*$ is an adversarial counterexample and since $x_* \in I$, $\mathcal{N}$ is not robust in $I$. \end{proof} \end{comment} The optimization problem from Eq.~\ref{eq:optimization} is clearly useful for searching for counterexamples to the robustness property. However, even if the solution $x_*$ is not a true counterexample (i.e., $\mathcal{F}(x_*) >0$), we can still use the result of the optimization problem to guide proof search. Based on this intuition, we now explain our decision procedure, shown in Algorithm~\ref{alg:refinement}, in more detail. The {\sc Verify} procedure takes as input a network $\mathcal{N}$, a robustness property $(I, K)$ to be verified, and a so-called \emph{verification policy} $\pi_\theta$. As mentioned in Section~\ref{sec:intro}, the verification policy is used to decide what kind of abstraction to use and how to split the input region when attempting to verify the property. In more detail, the verification policy $\pi_\theta$, parameterized by $\theta$, is a pair $(\pi^\domain_{\theta}, \pi^I_{\theta})$, where $\pi^\domain_{\theta}$ is a (parameterized) function known as the {\em domain policy} and $\pi^I_{\theta}$ is a function known as the {\em partition policy}. The domain policy is used to decide which abstract domain to use, while the partition policy determines how to split the input region $I$ into two partitions to be analyzed separately. In general, it is quite difficult to write a good verification policy by hand because there are many different parameters to tune and neural networks are quite opaque and difficult to interpret. In Section~\ref{sec:learning}, we explain how the parameters of these policy functions are learned from data. \begin{algorithm}[t] \begin{algorithmic}[1] \Procedure{Verify}{$\mathcal{N}, I, K, \pi_\theta$} \vspace{0.05in} \Statex \Input{A network $N$, robustness property $(I, K)$ and verification policy $\pi_\theta = (\pi^\domain_\theta, \pi^I_\theta)$} \Statex \Output{Counterexample if $\mathcal{N}$ is not robust, or {\rm Verified}.} \vspace{0.05in} \State $x_* \gets \Call{Minimize}{I, \mathcal{F}}$ \If{$\mathcal{F}(x_*) \le 0$} \State \textbf{return} $x_*$ \EndIf \State $\mathcal{A} \gets \pi^\domain_\theta(\mathcal{N},I,K,x_*)$ \If{$\Call{Analyze}{\mathcal{N}, I, K, \mathcal{A}} = {\rm Verified}$} \State \textbf{return} {\rm Verified} \EndIf \State $(I_1, I_2) \gets \pi^I_\theta(\mathcal{N}, I, K, x_*)$ \State $r_1 \gets \Call{Verify}{\mathcal{N}, I_1, K, \pi_\theta}$ \If{$r_1 \neq \text{Verified}$} \State \textbf{return} $r_1$ \EndIf \State \textbf{return} $\Call{Verify}{\mathcal{N}, I_2, K, \pi_\theta}$ \EndProcedure \end{algorithmic} \caption{The main algorithm} \label{alg:refinement} \end{algorithm} At a high-level, the {\sc Verify} procedure works as follows: First, we try to find a counterexample to the given robustness property by solving the optimization problem from Eq.~\ref{eq:optimization} using the well-known \emph{projected gradient descent (PGD)} technique. If $\mathcal{F}(x_*)$ is non-positive, we have found a true counterexample, so the algorithm produces $x_*$ as a witness to the violation of the property. Otherwise, we try to verify the property using abstract interpretation. As mentioned in Section~\ref{sec:background}, there are many different abstract domains that can be used to verify the property, and the choice of the abstract domain has a huge impact on the success and efficiency of verification. Thus, our approach leverages the domain policy $\pi^\domain_\theta$ to choose a sensible abstract domain to use when attempting to verify the property. Specifically, the domain policy $\pi^\domain_\theta$ takes as input the network $\mathcal{N}$, the robustness specification $(I, K)$, and the solution $x_*$ to the optimization problem and chooses an abstract domain $\mathcal{A}$ that should be used for attempting to prove the property. If the property can be verified using domain $\mathcal{A}$, the algorithm terminates with a proof of robustness. In cases where the property is neither verified nor refuted in the current iteration, the algorithm makes progress by splitting the input region $I$ into two disjoint partitions $I_1, I_2$ such that $I = I_1 \uplus I_2$. The intuition is that, even if we cannot prove robustness for the whole input region $I$, we may be able to increase analysis precision by performing a case split. That is, as long as all points in \emph{both} $I_1$ and $I_2$ are classified as having label $K$, this means that all points in $I$ are also assigned label $K$ since we have $I = I_1 \cup I_2$. In cases where the property is false, splitting the input region into two partition can similarly help adversarial counterexample search because gradient-based optimization methods do not always converge to a global optimum. Based on the above discussion, the key question is how to partition the input region $I$ into two regions $I_1, I_2$ so that each of $I_1, I_2$ has a good chance of being verified or falsified. Since this question again does not have an obvious answer, we utilize our \emph{partition policy} $\pi^I_\theta$ to make this decision. Similar to the domain policy, $\pi^I_\theta$ takes as input the network, the property, and the solution $x_*$ to the optimization problem and ``cuts'' $I$ into two sub-regions $I_1$ and $I_2$ using a hyper-plane. Then, the property is verified if and only if the recursive call to {\sc Verify} is succsessful on both regions. \begin{figure} \includegraphics[scale=0.25]{splitting} \vspace{-0.1in} \caption{The splits chosen for Example~\ref{ex:split}.} \label{fig:splitting} \vspace{-0.15in} \end{figure} \begin{example} \label{ex:split} Consider the XOR network from Figure~\ref{fig:xor} and the robustness property $([0.3,0.7]^2, 1)$. That is, for all inputs $\vec{x}$ with $0.3 \le x_1,x_2 \le 0.7$, $\vec{x}$ should be assigned to class 1 (assume classes are zero-indexed). We now illustrate how Algorithm~\ref{alg:refinement} verifies this property using the plain interval and zonotope abstract domains. The process is illustrated in Figure~\ref{fig:splitting}, which shows the splits made in each iteration as well as the domain used to analyze each region ($\mathbb{Z}$ denotes zonotopes, and $\mathbb{I}$ stands for intervals). \begin{comment} The splits can be seen as a tree structure where the children of each region are the two subregions after splitting. \end{comment} Algorithm~\ref{alg:refinement} starts by searching for an adversarial counterexample, but fails to find one since the property actually holds. Now, suppose that our domain policy $\pi^\domain_\theta$ chooses zonotopes to try to verify the property. Since the property cannot be verified using zonotopes, the call to \Call{Analyze}{} will fail. Thus, we now consult the partition policy $\pi^I_\theta$ to split this region into two pieces $I_1 = [0.3, 0.5] \times [0.3, 0.7]$ and $I_2 = [0.5, 0.7] \times [0.3, 0.7]$. Next, we recursively invoke Algorithm~\ref{alg:refinement} on both sub-regions $I_1$ and $I_2$. Again, there is no counterexample for either region, so we use the domain policy to choose an abstract domain for each of $I_1$ and $I_2$. Suppose that $\pi^\domain_\theta$ yields the zonotope domain for both $I_1$ and $I_2$. Using this domain, we can verify robustness in $I_1$ but not in $I_2$. Thus, for the second sub-problem, we again consult $\pi^I_\theta$ to obtain two sub-regions $I_{2,1} = [0.5, 0.7] \times [0.3, 0.42]$ and $I_{2,2} = [0.5, 0.7] \times [0.42, 0.7]$ and determine using $\pi^\domain_\theta$ that $I_{2,1}, I_{2,2} $ should be analyzed using intervals and zonotopes respectively. Since robustness can be verified using these domains, the algorithm successfully terminates. Notice that the three verified subregions cover the entire initial region. \end{example} \begin{comment} \begin{example} To see how Algorithm~\ref{alg:refinement} we show in Figure~\ref{fig:split} the splits which are required to verify the robustness of a region using the network defined in Figure~\ref{fig:xor}. On the top row we show the splits required by a counterexample-aware strategy, and on the bottom row are the splits needed by a simple bisection strategy. Whenever a region is verified by the abstract verifier, it is colored in gray. For any region which is not verified, the almost counterexample is indicated by a dot. In this case, the counterexample-aware strategy was able to verify the region after seven calls to the abstract verifier, while the bisection strategy required nine calls. This is because the counterexample-aware strategy was able to split closer to the point in the upper right that comes closest to violating the specification, and therefore reduces the approximation error around that point. \end{example} \begin{figure} \includegraphics[width=\columnwidth]{splits.pdf} \caption{The splits required to verify a region.} \label{fig:split} \end{figure} \begin{example} To see how Algorithm~\ref{alg:refinement} works, consider a network $\mathcal{N}(x) = W_2 (\ensuremath{\mathrm{ReLU}}(W_1 x + b_1)) + b_2$, where: \[W_1 = \begin{bmatrix} 2 & 3 \\ 0 & 3 \end{bmatrix} \quad b_1 = \begin{bmatrix} -4 \\ 1 \end{bmatrix} \quad W_2 = \begin{bmatrix} 2 & 0 \\ 0 & 0.28 \end{bmatrix} \quad b_2 = \begin{bmatrix} 0 \\ 0 \end{bmatrix}\] Suppose we wish to show that for all $x \in [0,1] \times [0,1]$, $(\mathcal{N}(x))_2 > (\mathcal{N}(x))_1$. We start with the zonotope domain to attempt to verify this property. In this case, we will fail to verify, and we will find that the point $[1 \ 1]^\top$ is an almost adversarial counterexample. This suggests that we will need more precision near that point, but we may be able to use less precision for other points. In light of that, suppose our strategy chooses to split the input region into two pieces $I_1 = [0,1] \times [0,2/3]$ and $I_2 = [0,1] \times [2/3,1]$. Additionally, because we are likely to be able to tolerate a less precise domain far away from our almost-adversarial example, suppose the strategy chooses to use the interval domain for $I_1$ and the zonotope domain for $I_2$. This split, with these domains, is sufficient to verify the property, as illustrated in Figure~\ref{fig:uneven-split}. \end{example} \begin{figure*} \includegraphics[width=\textwidth]{uneven_split} \caption{Propagating a split input region.} \label{fig:uneven-split} \end{figure*} \end{comment} \begin{comment} Now that we have defined almost adversarial examples, we can define a \emph{refinement strategy}. A refinement strategy is a function which takes a network, and input region, and an almost adversarial example, and splits the input region into two pieces. For each piece, the strategy also selects a set of parameters for the abstraction interpretation based verifier to use to attempt to verify that piece. These parameters control a bounded powerset domain by choosing an underlying abstract domain (intervals, zonotopes, etc.) and a bound for the powerset size. More formally, a refinement strategy is a function $S : Net \times \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times \ensuremath{\mathbb{R}}^{n \times m} \to \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times O \times \mathcal{P}(\ensuremath{\mathbb{R}}^{n \times m}) \times O$ (where $\mathcal{P}$ denotes the powerset operator) such that whenever $(I_1,\theta_1,I_2,\theta_2) = S(N,I,c)$, we have $I_1 \cup I_2 = I$. Here $O$ denotes a set of parameters for the abstract domain. \todo{For example, if $O = \{Zon, Itv, Ply\} \times \mathbb{N}$, then the parameters consist of a choice of either zonotopes, intervals, or polyhedra along with a number of disjuncts to use in the powerset domain.} \begin{example} \label{ex:splitting} To see how splitting the input region can be helpful, consider the network and property from Example~\ref{ex:zonotope}. Suppose instead of using a powerset of size two, we attempt to verify this property by splitting the input region into two pieces $I_1 = [0,1] \times [0,0.5]$ and $I_2 = [0,1] \times [0.5,1]$. Figure~\ref{fig:zonotope-split} shows how these two regions are propagated through the network using the zonotope domain. Note that this is sufficient to prove that the robustness property holds, even using the plain zonotope domain. \end{example} Examples~\ref{ex:zonotope} and~\ref{ex:splitting} illustrate an important concept for this work. We were able to verify the same property either by increasing the precision of our abstract domain or by splitting the input region into two pieces. This choice of how much to increase the precision of the domain versus how much to split the input region is a difficult one to make. In this work, we turn to Bayesian optimization to learn a good strategy for making this choice. \begin{figure*} \includegraphics[width=\textwidth]{zonotope_split} \caption{Propagating a split region.} \label{fig:zonotope-split} \end{figure*} \todo{$O$ currently represents some abstract notion of the set of parameters for an abstract domain. This needs to be concretized once we know exactly what parameters we're looking at.} Algorithm~\ref{alg:refinement} shows a decision procedure for checking robustness properties. The procedure starts with an input region $I$ and a set of parameters $\theta$. First, it attempts to verify that the network is robust in $I$ using some abstract technique \`{a} la $AI^2$. If that succeeds, then we are done and the property is verified. Otherwise, we search for an adversarial counterexample using standard techniques from machine learning literature. This is represented by the \Call{Minimize}{} procedure. Notice that this procedure is not guaranteed to return the actual minimizer of the objective function as this problem is intractable. The output of \Call{Minimize}{} may or may not actually be a counterexample to the robustness property, so we check. If it is a counterexample, then the property is falsified so we return it. Otherwise, the strategy $S$ uses the almost adversarial example to split $I$ into two regions $I_1$ and $I_2$ along with associated parameters $\theta_1$ and $\theta_2$. We then recursively call the verification procedure on these two subregions. \end{comment} \section{Related Work} \label{sec:related} In this section, we survey existing work on robustness analysis of neural networks and other ideas related to this paper. \vspace{-0.07in} \paragraph{Adversarial Examples and Robustness.} Szegedy et al. \cite{SzegedyZSBEGF13} first showed that neural networks are vulnerable to small perturbations on inputs. It has since been shown that such examples can be exploited to attack machine learning systems in safety-critical applications such as autonomous robotics~\cite{melis2017deep} and malware classication~\cite{grosse2017adversarial}. Bastani et al.~\cite{BastaniILVNC16} formalized the notion of local robustness in neural networks and defined metrics to evaluate the robustness of a neural network. Subsequent work has introduced other notions of robustness~\cite{reluplex,gopinath2017deepsafe}. Many recent papers have studied the construction of adversarial counterexamples \cite{KurakinAdversarialScale,LyuHL15,NguyenYC15,TabacofV16,SabourCFF15,GrossePM0M16,madry2017towards, GoodfellowSS14}. These approaches are based on various forms of gradient-based optimization, for example L-BFGS~\cite{szegedy2013intriguing}, FGSM~\cite{GoodfellowSS14} and PGD~\cite{madry2017towards}. While our implementation uses the PGD method, we could in principle also use (and benefit from advances in) alternative gradient-based optimization methods. \vspace{-0.07in} \paragraph{Verification of Neural Networks.} Scheibler et al. \cite{ScheiblerWWB15} used bounded model checking to verify safety of neural networks. Katz et al.\cite{KatzBDJK17} developed the Reluplex decision procedure extending the Simplex algorithm to verify robustness and safety properties of feedforward networks with ReLU units. Huang et al.\cite{HuangKWW16}~showed a verification framework, based on an SMT solver, which verified robustness with respect to a certain set of functions that can manipulate the input. A few recent papers~\cite{TjengMILP, DuttaMILP, LomuscioMILP} use Mixed Integer Linear Programming (MILP) solvers to verify local robustness properties of neural networks. These methods do not use abstraction and do not scale very well, but combining these techniques with abstraction is an interesting area of future work. \begin{comment} , and as demonstrated in recent work~\cite{ai2}, this can be a scalability issue. However, combining such techniques with an abstraction-refinement approach such as ours is an interesting area of future work. \end{comment} The earliest effort on neural network verification to use abstraction was by Pulina and Tacchella~\cite{PulinaT10} --- in fact, like our method, they considered an abstraction-refinement approach to solve this problem. However, their approach represents abstractions using general linear arithmetic formulas and uses a decision procedure to perform verification and counterexample search. Their approach was shown to be successful for a network with only $6$ neurons, so it does not have good scalability properties. More recently, Gehr et al. \cite{ai2} presented the AI$^2$ system for abstract interpretation of neural networks. Unlike our work, AI$^2$ is incomplete and cannot produce concrete counterexamples. The most closely related approach from prior work is {\sc ReluVal}\xspace~\cite{reluval}, which performs abstract interpretation using symbolic intervals. The two key differences between {\sc ReluVal}\xspace and our work are that {\sc Charon}\xspace couples abstract interpretation with optimization-based counterexample search and learns verification policies from data. As demonstrated in Section~\ref{sec:eval}, both of these ideas have a significant impact on our empirical results. \vspace{-0.07in} \paragraph{Learning to Verify.} The use of data-driven learning in neural network verification is, so far as we know, new. However, there are many papers~\cite{sharma2013verification,liang2011learning,garg2014ice,heo2016learning,si2018learning} on the use of such learning in traditional software verification. While most of these efforts learn proofs from execution data for specific programs, there are a few efforts that seek to learn optimal instantiations of parameterized abstract domains from a corpus of training {problems}~\cite{liang2011learning,oh2015learning}. The most relevant work in this space is by Oh et al.~\cite{oh2015learning}, who use Bayesian optimization to adapt a parameterized abstract domain. The abstract domain in that work is finite, and the Bayesian optimizer is only used to adjust the context-sensitivity and flow-sensitivity of the analysis. In contrast, our analysis of neural networks handles real-valued data and a possibly infinite space of strategies. \section{Termination and Delta Completeness} \label{sec:theorems} In this section, we discuss some theoretical properties of our verification algorithm, including soundness, termination, and completeness. To start with, it is easy to see that Algorithm~\ref{alg:refinement} is sound, as it only returns "Verified" once it establishes that \emph{every} point in the input space is classified as $K$. This is the case because every time we split the input region $I$ into two sub-regions $I_1, I_2$, we ensure that $I = I_1 \cup I_2$, and the underlying abstract interpreter is assumed to be sound. However, it is less clear whether Algorithm~\ref{alg:refinement} always terminates or whether it has any completeness guarantees. Our first observation is that the {\sc Verify} procedure, \emph{exactly} as presented in Algorithm~\ref{alg:refinement}, does {not} have termination guarantees under realistic assumptions about the optimization procedure used for finding adversarial counterexamples. Specifically, if the procedure {\sc Minimize} invoked at line 2 of Algorithm~\ref{alg:refinement} returned a \emph{global} minimum, then we could indeed guarantee termination.~\footnote{However, if we make this assumption, the optimization procedure itself would be a sound and complete decision procedure for verifying robustness!} However, since gradient-based optimization procedures do not have this property, Algorithm~\ref{alg:refinement} may not be able to find a true adversarial counterexample even as we make the input region infinitesimally small. Fortunately, we can guarantee termination and a form of completeness (known as $\delta$-completeness) by making a very small change to Algorithm~\ref{alg:refinement}. To guarantee termination of our verification algorithm, we will make the following slight change to line 3 of Algorithm~\ref{alg:refinement}: Rather than checking $ \mathcal{F}(x_*) \le 0 $ (for $\mathcal{F}$ as defined in Eq.~\ref{eq:objective}) we will instead check: \begin{equation}\label{eq:modification} \mathcal{F}(x_*) \le \delta \end{equation} While this modification can cause our verification algorithm to produce false positives under certain pathological conditions, the analysis can be made as precise as necessary by picking a value of $\delta$ that is arbitrarily close to $0$. Furthermore, under this change, we can now prove termination under some mild and realistic assumptions. In order to formally state these assumptions, we first introduce the following notion of the \emph{diameter} of a region: \begin{definition} For any set $X \subseteq \ensuremath{\mathbb{R}}^n$, its \emph{diameter} $D(X)$ is defined as $\sup\{\|x_1 - x_2\|_2 \mid x_1,x_2 \in X\}$ if this value exists. Otherwise the set is said to have infinite diameter. \label{def:diameter} \end{definition} We now use this notion of diameter to state two key assumptions that are needed to prove termination: \begin{assumption} There exists some $\lambda \in (0,1)$ such that for any network $\mathcal{N}$, input region $I$, and point $x_* \in I$, if $ \pi^I(N, I, x_*) = (I_1, I_2) $, then $D(I_1) < \lambda D(I)$ and $D(I_2) < \lambda D(I)$. \label{asm:split-reduces-size} \end{assumption} Intuitively, this assumption states that the two resulting subregions after splitting are smaller than the original region by some factor $\lambda$. It is easy to enforce this condition on any partition policy by choosing a hyper-plane $x_d = c$ where $c$ is not at the boundary of the input region. Our second assumption concerns the abstract domain: \begin{assumption} Let $\mathcal{N}^\#$ be the abstract transformer representing a network $\mathcal{N}$. For a given input region $I$, we assume there exists some $K_\mathcal{N} \in \ensuremath{\mathbb{R}}$ such that $D(\gamma(\mathcal{N}^\#(\alpha(I)))) < K_\mathcal{N} D(I)$. \label{asm:finite-overapprox} \end{assumption} This assumption asserts that the Lipschitz continuity of the network extends to its abstract behavior. Note that this assumption holds in several numerical domains including intervals, zonotopes, and powersets thereof. \begin{theorem} Consider the variant of Algorithm~\ref{alg:refinement} where the predicate at line 3 is replaced with Eq.~\ref{eq:modification}. Then, if the input region has finite diameter, the verification algorithm always terminates under Assumptions~\ref{asm:split-reduces-size} and~\ref{asm:finite-overapprox}. \label{thm:termination} \ifextended \footnote{Proofs for all theorems can be found in the appendix.} \else \footnote{Proofs for all theorems can be found in the extended version of the paper on arXiv.} \fi \end{theorem} In addition to termination, our small modification to Algorithm~\ref{alg:refinement} also ensures a property called $\delta$-completeness~\cite{delta-complete}. In the context of satisfiability over real numbers, $\delta$-completeness means that, when the algorithm returns a satisfying assignment $\sigma$, the formula is either indeed satisfiable or a $\delta$-perturbation on its numeric terms would make it satisfiable. To adapt this notion of $\delta$-completeness to our context, we introduce the folowing concept $\delta$-counterexamples: \begin{definition} For a given network $\mathcal{N}$, input region $I$, target class $K$, and $\delta>0$, a $\delta$-counterexample is a point $x \in I$ such that for some $j$ with $1 \le j \le m$ and $j \neq K$, $\mathcal{N}(x)_K - \mathcal{N}(x)_j \le \delta$. \label{def:delta-complete} \end{definition} Intuitively, a $\delta$-counterexample is a point in the input space for which the output almost violates the given specification. We can view $\delta$ as a parameter which controls how close to violating the specification a point must be to be considered ``almost'' a counterexample. \begin{theorem} Consider the variant of Algorithm~\ref{alg:refinement} where the predicate at line 3 is replaced with Eq.~\ref{eq:modification}. Then, the verification algorithm is $\delta$-complete --- i.e., if the property is not verified, it returns a {$\delta$-counterexample}. \label{thm:completeness} \end{theorem} \begin{comment} In this section, we will present several theoretical results about our algorithm. The proofs may be found in the appendix of this paper. The main results will show that our algorithm is both sound and \emph{$\delta$-complete} \cite{delta-complete}. A decision procedure for some class of properties over real numbers is $\delta$-complete if for any $\delta > 0$ it can always produce one of the following: \begin{enumerate} \item a proof that the property holds, or \item a \emph{$\delta$-counterexample} for the property. \end{enumerate} For our purposes, we will define a $\delta$-counterexample as follows. \begin{definition} For a given network $\mathcal{N}$, input region $I$, target class $M$, and $\delta>0$, a $\delta$-counterexample is a point $x \in I$ such that for some $j$ with $1 \le j \le m$ and $j \neq M$, $\mathcal{N}(x)_M - \mathcal{N}(x)_j \le \delta$. \label{def:delta-complete} \end{definition} Intuitively, a $\delta$-counterexample is a point in the input space of the network for which the output almost violates the given specification. We can view $\delta$ as a parameter which controls how close to violating the specification a point must be to be considered ``almost'' a counterexample. In order to prove that our algorithm is both sound and $\delta$-complete, we will need to have a way to talk about the size of an input region. We will use the diameter for this purpose: \begin{definition} For any set $X \subseteq \ensuremath{\mathbb{R}}^n$, its \emph{diameter} $D(X)$ is defined as \[D(X) = \sup\{\|x_1 - x_2\|_2 \mid x_1,x_2 \in X\}\] if this value exists. Otherwise the set is said to have infinite diameter. \label{def:diameter} \end{definition} We require some mild assumptions about the strategy and the abstract domain used in the algorithm: \begin{assumption} There exists some $\lambda \in \ensuremath{\mathbb{R}}$ with $0 < \lambda < 1$ such that for any network $\mathcal{N}$, input region $I$, and point $x_* \in I$, if $(I_1, I_2) = \Call{Refine}{N, I, x_*}$, then $D(I_1) < \lambda D(I)$ and $D(I_2) < \lambda D(I)$. \label{asm:split-reduces-size} \end{assumption} Intuitively, this assumption states that each time we split the input region, the two subregions it is split into are smaller than the original region. This assumption will be used to show that by repeatedly splitting the input region, we can consider arbitrarily small pieces of that region. \begin{assumption} Let $\mathcal{N}^\#$ be the abstract transformer representing a network $\mathcal{N}$. Let $a$ be an element of the abstract domain representing the input region $I$. We assume there exists some $K_\mathcal{N} \in \ensuremath{\mathbb{R}}$ such that $D(\gamma(\mathcal{N}^\#(\alpha(I)))) < K_\mathcal{N} D(I)$. \label{asm:finite-overapprox} \end{assumption} This assumption states that our abstraction can only introduce a finite overapproximation. Note that this assumption holds for the interval and zonotope domains. \begin{assumption} The \Call{VerifyAbstraction}{} procedure from Algorithm~\ref{alg:refinement} is sound. That is, if \Call{VerifyAbstraction}{$\mathcal{N},I,\theta,M$} returns true then the network $\mathcal{N}$ is robust in the input region $I$. \label{asm:ai2-sound} \end{assumption} With these assumptions stated, we can now move on to the first major theorem of this section. \begin{theorem} Algorithm~\ref{alg:refinement} is sound. That is, if Algorithm~\ref{alg:refinement} terminates and does not return a counterexample, then the network $\mathcal{N}$ is robust in the input region $I$ and $\mathcal{N}$ assigns class $K$ to each $x \in I$. \label{thm:soundness} \end{theorem} Algorithm~\ref{alg:refinement} as presented in Section~\ref{sec:refinement} does not have termination guarantees. However, there is a slight weakening of this algorithm which does allow us to prove termination. In particular, in Algorithm~\ref{alg:refinement} after searching for a counterexample $x$, we check whether there is some $j$ with $1 \le j \le m$ such that $N(x)_M - N(x)_j \le 0$. If instead we choose some positive $\delta$ and check whether $N(x)_M - N(x)_j \le \delta$, we can prove termination. This change allows the algorithm to return $\delta$-counterexamples. While this does allow the algorithm to produce false positives, the parameter $\delta$ is chosen by the user, so the algorithm can be as precise as necessary. The following completeness theorem refers to the slightly modified definition of Algorithm~\ref{alg:refinement} discussed above. To improve readibility, we define $F(I_k) = \gamma(\mathcal{N}^\#(\alpha(I_k)))$ \begin{theorem} Algorithm~\ref{alg:refinement} is $\delta$-complete. That is, for a given $\delta > 0$ and input region of finite diameter, Algorithm~\ref{alg:refinement} terminates and if the property does not hold then it returns $\delta$-counterexample. \label{thm:completeness} \end{theorem} \end{comment}
{'timestamp': '2019-05-02T02:15:50', 'yymm': '1904', 'arxiv_id': '1904.09959', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09959'}
arxiv
\section{Introduction} \input{sections/02intro} \section{Method} \input{sections/03method} \section{Quantized NAS} \input{sections/04quantized_experiments} \section{Slimmable NAS} \input{sections/05slimmable_exp} \section{Conclusion} \input{sections/06conclusion} \input{sections/07acks} \vskip 0.2in \clearpage \section{Definitions} $T_\ell$ - represents layer $\ell$ operations set, \textit{i}.\textit{e}., $T_\ell = \{ (2,2), (3,3) \}$ \\ $n_\ell$ - number of configurations for layer $\ell$. \\ $C_\ell$ - total number of filters in layer $\ell$. \\ $\configSubset{k}$ - configurations subset in iteration $k$ for gradient estimation. \\ $\bb{a}$ - denotes a network configuration. \\ $z_{\configIndices}$ - denotes network configuration arithmetic complexity. \\ $\homogeneousConfig{t}$ - denotes homogeneous configurations. \\ $\homogeneousComplexity{t}$ - denotes homogeneous configurations arithmetic complexity. \\ $\bb{\omega}$ - denotes network weights set. \\ $\networkWeights_{\configIndices}$ - denotes a specific weights set for a specific configuration $\bb{a}$. \\ $T$ - denotes the whole training data set. \\ $T_{\alpha}$ - denotes search data set, data set for $\hat{\alpha}$ optimization. \\ $T_{\networkWeights}$ - denotes data set for weights training. \\ $t_{\networkWeights}$ - denotes number of epochs for weights training. \\ $k_{\networkWeights}$ - denotes once in how many iterations to train weights. \\ $p(\bb{a} | \bb{\alpha})$ - denotes the probability to sample configuration $\bb{a}$ from distribution $\hat{\alpha}$. \\ ${\mathcal{L}}$ - denotes the loss function, \textit{i}.\textit{e}., target function we want to optimize. \\ $\hat{\alpha}$ - denotes a distribution. \\ $\Loss (\networkConfig;\networkWeights)$ - denotes the loss for configuration $\bb{a}$. \\ $\expectedValue{k}$ - denotes the expected value of distrubtion $\hat{\alpha}$ at iteration $k$. \\ $\expectedConfig{}$ - denotes the configuration of the $\hat{\alpha}$ distribution expected value. \\ $\expectedValue{} \qty\Big[ \lossConfig ]$ - loss expected value under distribution $\hat{\alpha}$. \\ $\ceLossGeneric{}$ - cross entropy loss for configuration $\bb{a}$. \\ $\ceLossInterpolation{\bb{a}}$ - the expected cross entropy loss for configuration $\bb{a}$ as the interpolation between the cross entropy loss of configurations $h_1,h_2$. \\ $\sigma \left( \cdot \right)$ - the function we apply on $z_{\configIndices}$. \\ $\Loss_{\text{com}} (\networkConfig)$ - arithmetic complexity loss for configuration $\bb{a}$. \\ $\configsSumOperator \probConfig \cdot \lossConfig$ - the target function expected value as sum of losses multiplied by their probabilities. \\ $\opAlpha{i}$ - $\alpha$ value for operation $i$ in layer $\ell$. A notation for the multinomial case. \\ $\alpha_{\ell}$ - $\alpha$ value for operation (random variable) $i$ in layer $\ell$. A notation for the binomial case, \textit{i}.\textit{e}., a single random variable in each layer. \\ $\opSample{i}$ - the number of filters in layer $\ell$ we apply operation $i$ on. A notation for the multinomial case. \\ $a_{\ell}$ - the number of filters we select in layer $\ell$. A notation for the binomial case. \\ $\opProb{i}$ - the probability to select operation $i$ in layer $\ell$. A notation for the multinomial case. \\ $\hat{\alpha}_{\ell}$ - The probability of layer $\ell$ random variable. A notation for the binomial case. \\ $\opDerivative{i}$ - $J(\bb{\alpha} ;\networkWeights)$ derivative with respect to $\opAlpha{i}$. A notation for the multinomial case. \\ $g_{\opAlphaSingle}$ - $J(\bb{\alpha} ;\networkWeights)$ derivative with respect to $\alpha_{\ell}$. A notation for the binomial case. \\ $\opDerivativeEstimator{i}$ - $\opDerivative{i}$ estimator. \\ $\opProbDetailed{i}$ - detailed probability term for operation $i$ in layer $\ell$. A notation for the multinomial case. \\ $\layerConfig{k}$ - a specific layer configuration. \\ $\layerRV{\ell}$ - random variable (multinomial or binomial) for layer $\ell$. \\ $\layerConfig{\ell} = (\opSample{1},\dots,\opSample{\abs{T_\ell}})$ - detailed version of layer $\ell$ configuration, \textit{i}.\textit{e}., number of filters assigned for each operation. A notation for the multinomial case. \\ $\layerConfig{\ell} = (\opSampleSingle)$ - detailed version of layer $\ell$ configuration, \textit{i}.\textit{e}., number of filters selected. A notation for the binomial case. \\ $b_\mathrm{w}$ - number of bits used for filter weights quantization. \\ $b_\mathrm{a}$ - number of bits used for layer output (activation) quantization. \\ $\Pr \qty( \layerRV{\ell} = \layerConfig{\ell} )$ - The probability to sample configuration $\layerConfig{\ell}$ in layer $\ell$. \begin{itemize} \item $\multinomialFrac \cdot \multinomialConfigProbFrac$ - explicit term for $\Pr \qty( \layerRV{\ell} = \layerConfig{\ell} )$ in the multinomial case. \item $\frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}}$ \item $\frac{\opSampleNumeratorMultinomialSum}{\opSampleDenominatorMultinomialWithPower}$ \item $\left( \exp \left\{ \opAlpha{k} \cdot \opSample{k} \right\} \right)$ \item $\exp \left\{ \layerOpsSumK \opAlpha{k} \cdot \opSample{k} \right\}$ \item $\sum_{j=1}^{\abs{\layerOpsSet}} \exp \left\{ \opAlpha{j} \right\}$ \item $\left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer}$ \end{itemize} $\pdv{\opAlpha{t}}$ - derivation with respect to $\opAlpha{t}$. A notation for the multinomial case. \\ $\pdv{\opAlphaSingle}$ - derivation with respect to $\alpha_{\ell}$. A notation for the binomial case. \\ $\multinomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb$ - layer $\ell$ configuration derivative with respect to $\opAlpha{t}$. \\ $\prodLayersProbLeaveOut{k}$ - The probability to choose configuration in any layer except layer $\ell$. \\ $\multinomialConfigProbDerivative{k}$ - configuration $\bb{a}$ derivative with respect to $\opAlpha{t}$. \\ $\configsSumOperator \lossConfig \cdot \multinomialConfigProbDerivative{}$ - $J(\bb{\alpha} ;\networkWeights)$ derivative with respect to $\opAlpha{t}$. \\ $\left( \nFiltersLayer-1 \right)$ - number of trials for a Binomial random variable. \\ \begin{itemize} \item $\binomialFrac \cdot \binomialConfigProbFrac$ - explicit term for $\Pr \qty( \layerRV{\ell} = \layerConfig{\ell} )$ in the binomial case. \item $\frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !}$ \item $\frac{\opProbBinomialDetailedNumeratorWithPower}{\opProbBinomialDetailedDenominatorWithPower}$ \item $\exp \left\{ \opAlphaSingle \cdot \opSampleSingle \right\}$ \item $\qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial}$ \item $\exp \left\{ \opAlphaSingle \right\}$ \item $\exp \left\{ \opAlphaSingle \right\} + 1$ \item $\frac{\exp \left\{ \opAlphaSingle \right\}}{\opProbBinomialDetailedDenominator}$ \item $\left( \opProbBinomialDetailed \right) ^{\opSampleSingle}$ \item $\nTrialsBinomial - \opSampleSingle$ \end{itemize} $\opSampleSingleConfig{}$ - number of filters sampled in layer $\ell$. \\ $\binomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb$ - layer $\ell$ configuration derivative with respect to $\alpha_{\ell}$. \\ $\binomialConfigProbDerivative{}$ - configuration $\bb{a}$ derivative with respect to $\alpha_{\ell}$. \\ $\configsSumOperator \lossConfig \cdot \binomialConfigProbDerivative{}$ - $J(\bb{\alpha} ;\networkWeights)$ derivative with respect to $\alpha_{\ell}$. \\ \section{Additional results analysis} \begin{landscape} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{figures/slimmable_heterogeneous_space_2.pdf} \caption{Slimmable validation accuracy variance exploration plot. Each point represents a different configuration. The points connected in dashed line are the homogeneous configurations. The error bar represents $0.6827$ confidence interval.} \label{fig:Slimmable_variance_ext} \end{figure} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{figures/NICE_partitions_with_errorbar_2.pdf} \caption{NICE validation accuracy variance investigation plot. Each point represents a different configuration. The points connected in dashed line are the homogeneous configurations. The error bar represents $0.6827$ confidence interval.} \label{fig:NICE_variance_ext} \end{figure} \end{landscape} \clearpage \subsection{Results} \label{app:res} \subsubsection{Quantization} \label{app:quantres} \begin{figure}[htbp] \centering \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/quant/NICE_search_1_zoom.pdf} \subcaption{Homogeneous configuration target is (3,3).} \end{subfigure} \hfill \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/quant/NICE_search_2_1_new_zoom.pdf} \subcaption{Homogeneous configuration target is (2,4).} \end{subfigure}\hfill \caption{Additional results of search in quantization case. $\lambda=1$. $T_\ell=\{(2,2),(2,4),(3,3),(8,8)\}$} \label{fig:q_results1} \end{figure} \begin{figure}[htbp] \centering \includegraphics[width=\linewidth]{figures/quant/NICE_search_3_1_new_zoom.pdf} \caption{Additional results of search in quantization case. $\lambda=1$. Homogeneous configuration target is (3,3). $T_\ell=\{(2,2),(3,3),(4,4),(8,3),(8,8)\}$.} \label{fig:q_results2} \end{figure} \begin{landscape} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{figures/quant/alphas/NICE_alphas_distribution_2.pdf} \caption{Convergence of $\bb{\alpha}$ as a function of time in quantization case} \label{fig:quant_convergence} \end{figure} \end{landscape} \clearpage \subsubsection{Pruning}\label{app:prunres} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{figures/pruning/alphas/Slimmable_alphas_distribution_1.pdf} \caption{Convergence of $\bb{\alpha}$ as a function of time in pruning case} \label{fig:prun_convergence} \end{figure} \begin{figure}[htbp] \centering \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodI/lambda_0_01_zoom.pdf} \subcaption{$\lambda=0.01,|S|=48$.} \end{subfigure} \hfill \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodI/lambda_0_001_zoom.pdf} \subcaption{$\lambda=0.001,|S|=6$.} \end{subfigure} \caption{Results of basic search.} \label{fig:pm1_results} \end{figure} \begin{figure}[htbp] \centering \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodII/lambda_0_005_zoom.pdf} \subcaption{$\lambda=0.005,k_{\networkWeights}=20$.} \end{subfigure} \hfill \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodII/lambda_0_01_zoom.pdf} \subcaption{$\lambda=0.01,k_{\networkWeights}=10$.} \end{subfigure}\hfill \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodII/lambda_0_02_zoom.pdf} \subcaption{$\lambda=0.02,k_{\networkWeights}=10$.} \end{subfigure} \caption{Results of search with $\omega$ resetting. $|S|=6$.} \label{fig:pm2_results} \end{figure} \begin{figure}[htbp] \centering \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodIII/lambda_0_005_zoom.pdf} \subcaption{$\lambda=0.005,|S|=8$} \end{subfigure} \hfill \begin{subfigure}[b]{0.48\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodIII/lambda_0_01_zoom.pdf} \subcaption{$\lambda=0.01,|S|=6$} \end{subfigure} \caption{Results of without weight sharing.} \label{fig:pm3_results} \end{figure} \begin{figure}[htbp] \centering \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodIV/lr_5E-4_probs_0_5_zoom.pdf} \subcaption{Learning rate = 5E-4. Initial distribution is 0.5, \textit{i}.\textit{e}., $\hat{\alpha}_{\ell}=0.5$.} \end{subfigure} \hfill \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodIV/lr_1E-4_probs_0_5_zoom.pdf} \subcaption{Learning rate = 1E-4. Initial distribution is 0.5, \textit{i}.\textit{e}., $\hat{\alpha}_{\ell}=0.5$.} \end{subfigure}\hfill \begin{subfigure}[b]{0.31\linewidth} \includegraphics[width=\linewidth]{figures/pruning/methodIV/lr_1E-4_probs_0_75_zoom.pdf} \subcaption{Learning rate = 1E-4. Initial distribution is 0.75, \textit{i}.\textit{e}., $\hat{\alpha}_{\ell}=0.75$.} \end{subfigure} \caption{Results of search with interpolation loss.} \label{fig:pm4_results} \end{figure} \clearpage \section{Multinomial distribution lemmas} \begin{lemma} Let \begin{itemize} \item Layer $\ell$ contains $C_\ell$ filters. \item $T_\ell$ is a set of possible operations in layer $\ell$. \item $\layerRV{\ell}$ is a random variable from a multinomial distribution, \textit{i}.\textit{e}., \begin{equation} \layerRV{\ell} \sim \text{Multinomial} \left( C_\ell,(\opProb{1},\opProb{2},...,\opProb{|T_\ell|}) \right) \end{equation} \end{itemize} The probability to sample configuration $\layerConfig{\ell} = (\opSample{1},\dots,\opSample{\abs{T_\ell}})$ is: \begin{equation} \Pr ( \layerRV{\ell} = \layerConfig{\ell} ) = \multinomialFrac \cdot \multinomialConfigProbFrac \end{equation} \begin{proof} \begin{equation} \begin{split} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \layerOpsProd{k} (\opProb{k})^{\opSample{k}} \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \layerOpsProd{k} \left( \opProbDetailed{k} \right) ^{\opSample{k}} \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \frac{\layerOpsProd{k} \left( \exp \left\{ \opAlpha{k} \cdot \opSample{k} \right\} \right)}{\layerOpsProd{k} \left( \sum_{j=1}^{\abs{\layerOpsSet}} \exp \left\{ \opAlpha{j} \right\} \right) ^{\opSample{k}}} \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \frac{\exp \left\{ \layerOpsSum{k} \opAlpha{k} \cdot \opSample{k} \right\} }{\left( \sum_{j=1}^{\abs{\layerOpsSet}} \exp \left\{ \opAlpha{j} \right\} \right) ^{\layerOpsSum{k} \opSample{k}}} \\ &= \multinomialFrac \cdot \multinomialConfigProbFrac \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} The partial derivative of the probability to sample layer configuration $\layerConfig{\ell}$ under the multinomial distribution is: \begin{equation} \pdv{\opAlpha{t}} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) = \multinomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlpha{t}} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) &= \pdv{\opAlpha{t}} \Bigg( \multinomialFrac \cdot \multinomialConfigProbFrac \Bigg) \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \pdv{\opAlpha{t}} \frac{\opSampleNumeratorMultinomialSum}{\opSampleDenominatorMultinomialWithPower} \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \frac{1}{\left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer} \cdot \left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer}} \\ & \Bigg[ \left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer} \cdot \pdv{\opAlpha{t}} \exp \left\{ \layerOpsSumK \opAlpha{k} \cdot \opSample{k} \right\} - \\ &- \exp \left\{ \layerOpsSumK \opAlpha{k} \cdot \opSample{k} \right\} \cdot \pdv{\opAlpha{t}} \left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer} \Bigg] \\ &= \frac{\nFiltersLayer !}{\layerOpsProdK \opSample{k}} \cdot \Bigg( \opSample{t} \cdot \frac{\exp \left\{ \layerOpsSumK \opAlpha{k} \cdot \opSample{k} \right\}}{\left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer}} - \\ &- C_\ell \cdot \frac{\exp \left\{ \opSample{t} \right\}}{\sum_{j=1}^{\abs{\layerOpsSet}} \exp \left\{ \opAlpha{j} \right\}} \cdot \frac{\exp \left\{ \layerOpsSumK \opAlpha{k} \cdot \opSample{k} \right\}}{\left( \opSampleDenominatorMultinomial \right) ^{\nFiltersLayer}} \Bigg) \\ &= \opSample{t} \cdot \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) - C_\ell \cdot \opProb{t} \cdot \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) \\ &= \multinomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} The partial derivative of the probability $p(\bb{a} | \bb{\alpha})$ to sample network configuration $\bb{a}$ under the multinomial distribution is: \begin{equation} \pdv{\opAlpha{t}} p(\bb{a} | \bb{\alpha}) = \multinomialConfigProbDerivative{} \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlpha{t}} p(\bb{a} | \bb{\alpha}) &= \pdv{\opAlpha{t}} \prodLayersProb{r} \\ &= \prodLayersProbLeaveOut{r} \cdot \pdv{\opAlpha{t}} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) \\ &= \prodLayersProbLeaveOut{r} \cdot \left( \multinomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \right) \\ &= \multinomialConfigDerivativeDifferencePart \cdot \prodLayersProb{r} \\ &= \multinomialConfigProbDerivative{} \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} \label{multi_loss_pdv} The partial derivative of the loss expected value $J(\bb{\alpha} ;\networkWeights)$ under the multinomial distribution is: \begin{equation} \pdv{\opAlpha{t}} J(\bb{\alpha} ;\networkWeights) = \configsSumOperator \lossConfig \cdot \multinomialConfigProbDerivative{} \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlpha{t}} J(\bb{\alpha} ;\networkWeights) &= \pdv{\opAlpha{t}} \configsSumOperator \probConfig \cdot \lossConfig \\ &= \configsSumOperator \Loss (\networkConfig;\networkWeights) \cdot \pdv{\opAlpha{t}} p(\bb{a} | \bb{\alpha}) \\ &= \configsSumOperator \lossConfig \cdot \multinomialConfigProbDerivative{} \end{split} \end{equation} \end{proof} \end{lemma} where $\opSampleConfig{}$ represents on how many filters in layer $\ell$ in configuration $\bb{a}$ we apply operation $t$. \section{Binomial distribution lemmas} \begin{lemma} Let \begin{itemize} \item Layer $\ell$ contains $C_\ell$ filters. \item $\layerRV{\ell}$ is a random variable from a binomial distribution, \textit{i}.\textit{e}., \begin{equation} \layerRV{\ell} \sim \text{Binomial} \left( C_\ell-1,\hat{\alpha}_{\ell} \right) \end{equation} \end{itemize} The probability to sample configuration $\layerConfig{\ell} = (\opSampleSingle)$ is: \begin{equation} \Pr \left( \layerRV{\ell} = \layerConfig{\ell} \right) = \binomialFrac \cdot \binomialConfigProbFrac \end{equation} \begin{proof} \begin{equation} \begin{split} \Pr \left( \layerRV{\ell} = \layerConfig{\ell} \right) &= \binom{C_\ell-1}{a_{\ell}} \cdot \left( \hat{\alpha}_{\ell} \right) ^{a_{\ell}} \cdot \left( 1-\hat{\alpha}_{\ell} \right) ^{\nTrialsBinomial - \opSampleSingle} \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \left( \opProbBinomialDetailed \right) ^{\opSampleSingle} \cdot \left( 1 - \frac{\exp \left\{ \opAlphaSingle \right\}}{\opProbBinomialDetailedDenominator} \right) ^{\nTrialsBinomial - \opSampleSingle} \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \left( \opProbBinomialDetailed \right) ^{\opSampleSingle} \cdot \left( \frac{1}{\exp \left\{ \opAlphaSingle \right\} + 1} \right) ^{\nTrialsBinomial - \opSampleSingle} \\ &= \binomialFrac \cdot \binomialConfigProbFrac \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} The partial derivative of the probability to sample layer configuration $\layerConfig{\ell}$ under the binomial distribution is: \begin{equation} \pdv{\opAlphaSingle} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) = \binomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlphaSingle} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) &= \pdv{\opAlphaSingle} \left( \binomialFrac \cdot \binomialConfigProbFrac \right) \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \pdv{\opAlphaSingle} \frac{\opProbBinomialDetailedNumeratorWithPower}{\opProbBinomialDetailedDenominatorWithPower} \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \frac{1}{\qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial} \cdot \qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial}} \\ & \Big( \qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial} \cdot \pdv{\opAlphaSingle} \exp \left\{ \opAlphaSingle \cdot \opSampleSingle \right\} \\ &- \exp \left\{ \opAlphaSingle \cdot \opSampleSingle \right\} \cdot \pdv{\opAlphaSingle} \qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial} \Big) \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \Bigg( \frac{a_{\ell} \cdot \exp \left\{ \opAlphaSingle \cdot \opSampleSingle \right\}}{\qty\big( \opProbBinomialDetailedDenominator ) ^{\nTrialsBinomial}} \\ &- \left( \nFiltersLayer-1 \right) \cdot \frac{\opProbBinomialDetailedNumeratorWithPower}{\opProbBinomialDetailedDenominatorWithPower} \cdot \frac{\exp \left\{ \opAlphaSingle \right\}}{\exp \left\{ \opAlphaSingle \right\} + 1} \Bigg) \\ &= \frac{\nTrialsBinomial !}{\opSampleSingle ! \cdot \left( \nFiltersLayer-1 - \opSampleSingle \right) !} \cdot \frac{\opProbBinomialDetailedNumeratorWithPower}{\opProbBinomialDetailedDenominatorWithPower} \cdot \binomialConfigDerivativeDifferencePart{} \\ &= \binomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} The partial derivative of the probability $p(\bb{a} | \bb{\alpha})$ to sample network configuration $\bb{a}$ under the binomial distribution is: \begin{equation} \pdv{\opAlpha{t}} p(\bb{a} | \bb{\alpha}) = \binomialConfigProbDerivative{} \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlphaSingle} p(\bb{a} | \bb{\alpha}) &= \pdv{\opAlphaSingle} \prodLayersProb{r} \\ &= \prodLayersProbLeaveOut{r} \cdot \pdv{\opAlphaSingle} \Pr \qty( \layerRV{\ell} = \layerConfig{\ell} ) \\ &= \prodLayersProbLeaveOut{r} \cdot \left( \binomialConfigDerivativeDifferencePart{} \cdot \layerConfigProb \right) \\ &= \binomialConfigDerivativeDifferencePart{} \cdot \prodLayersProb{r} \\ &= \binomialConfigProbDerivative{} \end{split} \end{equation} \end{proof} \end{lemma} \begin{lemma} \label{bi_loss_pdv} The partial derivative of the loss expected value $J(\bb{\alpha} ;\networkWeights)$ under the binomial distribution is: \begin{equation} \pdv{\opAlphaSingle} J(\bb{\alpha} ;\networkWeights) = \configsSumOperator \lossConfig \cdot \binomialConfigProbDerivative{} \end{equation} \begin{proof} \begin{equation} \begin{split} \pdv{\opAlphaSingle} J(\bb{\alpha} ;\networkWeights) &= \pdv{\opAlphaSingle} \configsSumOperator \probConfig \cdot \lossConfig \\ &= \configsSumOperator \Loss (\networkConfig;\networkWeights) \cdot \pdv{\opAlphaSingle} p(\bb{a} | \bb{\alpha}) \\ &= \configsSumOperator \lossConfig \cdot \binomialConfigProbDerivative{} \end{split} \end{equation} \end{proof} \end{lemma} where $\opSampleSingleConfig{}$ represents on how many filters in layer $\ell$ in configuration $\bb{a}$ we apply the operation. \section{Configurations} \begin{figure}[htb] \centering \includegraphics[width=0.25\linewidth]{figures/filter_wise_layer.png} \caption{Layer structure induced by sampling a configuration from a multinomial random variable. Assume $T_\ell = \{ t_1, t_2, t_3 \}$, we apply quantization with bitwidth $t_1$ on the blue filters, $t_2$ on the green filters and $t_3$ on the yellow filters.} \label{fig:multinomial_filter_wise_layer} \end{figure} \subsection{Configuration of search space} \label{app:searchspace} Similarly to \citet{ying2019bench}, we performed a grid search on a simplified search space. ResNet-20 \cite{he2016resnet} was chosen as a basic architecture. This architecture has three blocks of convolutional layers, with increasing number of filters and decreasing dimensions of features. To reduce the required resources, the number of filters was reduced to 16, 32, and 64 in each group. For the quantization search space we sampled few layer configurations. Each sampled layer configuration, denote as $\layerConfig{}$, induces a network configuration by setting each of the network layers configuration to $\layerConfig{}$. We train each network configuration 3 times under the same conditions. The stopping criteria is 150 consecutive epochs without new optimal validation accuracy. For the pruning search space we sampled blocks configurations triplets. Each triplet induces a network configuration, where each layer in a specific block has the same layer configuration as any other layer in the specific block. As we did for the quantization search space, we train each network configuration 3 times under the same conditions. The stopping criteria is also the same. \subsection{Transfer learning to ImageNet} We took 3 configurations with significant accuracy difference between them on CIFAR-10 and trained them on ImageNet. We found out that the configurations ranking on CIFAR-10 is different than their ranking on ImageNet, \textit{i}.\textit{e}., a configuration might be optimal on CIFAR-10 but average on ImageNet. \section{Search algorithms} \subsection{Quantization search algorithm} \label{app:searchalgq} \begin{algorithm} \caption{Search method} \label{alg:NICE_search_method} \begin{algorithmic}[1] \STATE{Split training set $T$ to two halves: \begin{itemize} \item $T_{\alpha}$, a set to update distribution parameters $\alpha$ \item $T_{\networkWeights}$, a set to update network weights $\bb{\omega}$. \end{itemize} } \STATE{Set bitwidth set $T_\ell$ for each layer} \STATE{Set an initial distribution $\hat{\alpha}^{0}$} \STATE{Set a configurations subset size $|\configSubset{}|$ for $J(\bb{\alpha} ;\networkWeights)$ gradient estimator} \STATE{Set $t_{\networkWeights}$, number of epochs to train network weights in each iteration} \STATE{Set a target homogeneous configuration $a_{homogeneous}$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set $\lambda$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set a function $\sigma \left( \cdot \right)$ for $\Loss_{\text{com}} (\networkConfig)$} \WHILE{not converged} \FOR{1 to $t_{\networkWeights}$} \FOR{batch $b$ in $T_{\networkWeights}$} \STATE{Sample configuration $\bb{a}$ from current distribution $\hat{\alpha}^{k}$} \STATE{Update $\bb{\omega}$ by a gradient step on $\ceLossGeneric{}$} \ENDFOR \ENDFOR \FOR{batch $b$ in $T_{\alpha}$} \STATE{Sample configurations subset $\configSubset{k}$ from current distribution $\hat{\alpha}^{k}$} \STATE{Update the distribution parameters $\alpha$ by a gradient step on $J(\bb{\alpha} ;\networkWeights)$} \ENDFOR \ENDWHILE \STATE{Sample and evaluate found configurations} \end{algorithmic} \end{algorithm} \clearpage \subsection{Basic pruning search method} \label{app:searchi} \begin{algorithm} \caption{Basic search method} \label{alg:Slimmable_search_method_I} \begin{algorithmic}[1] \STATE{Split training set $T$ to two halves: \begin{itemize} \item $T_{\alpha}$, a set to update distribution parameters $\alpha$ \item $T_{\networkWeights}$, a set to update network weights $\bb{\omega}$. \end{itemize} } \STATE{Set an initial distribution $\hat{\alpha}^{0}$} \STATE{Set a homogeneous configurations set $A$ for Slimmable method weights training} \STATE{Set a configurations subset size, $|\configSubset{}|$, for $J(\bb{\alpha} ;\networkWeights)$ gradient estimator} \STATE{Set $t_{\networkWeights}$, number of epochs to train network weights in each iteration} \STATE{Set a target homogeneous configuration $a_{homogeneous}$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set $\lambda$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set a function, $\sigma \left( \cdot \right)$, for $\Loss_{\text{com}} (\networkConfig)$} \WHILE{not converged} \STATE{Set Slimmable training method to train on $A \cup \expectedConfig{k}$} \FOR{1 to $t_{\networkWeights}$} \FOR{batch $b$ in $T_{\networkWeights}$} \STATE{Update $\bb{\omega}$ by Slimmable training method gradient step} \ENDFOR \ENDFOR \FOR{batch $b$ in $T_{\alpha}$} \STATE{Sample configurations subset $\configSubset{k}$ from current distribution $\hat{\alpha}^{k}$} \STATE{Train each configuration $\bb{a} \in \configSubset{k}$ weights for 5 epochs over $T_{\networkWeights}$} \STATE{Update the distribution parameters $\alpha$ by a gradient step on $J(\bb{\alpha} ;\networkWeights)$} \ENDFOR \ENDWHILE \STATE{Sample and evaluate found configurations} \end{algorithmic} \end{algorithm} \clearpage \subsection{Resetting the $\omega$} \label{app:searchii} \begin{algorithm} \caption{Resetting the $\omega$} \label{alg:Slimmable_search_method_II} \begin{algorithmic}[1] \STATE{Set training set $T$} \STATE{Set an initial distribution $\hat{\alpha}^{0}$} \STATE{Set a homogeneous configurations set $A$ for Slimmable method weights training} \STATE{Set a configurations subset size, $|\configSubset{}|$, for $J(\bb{\alpha} ;\networkWeights)$ gradient estimator} \STATE{Set $t_{\networkWeights}$, number of epochs to train network weights in each iteration} \STATE{Set $k_{\networkWeights}$, number of iterations between $\bb{\omega}$ update} \STATE{Set a target homogeneous configuration $a_{homogeneous}$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set $\lambda$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set a function, $\sigma \left( \cdot \right)$, for $\Loss_{\text{com}} (\networkConfig)$} \WHILE{not converged} \IF{$ \left( k_{\networkWeights} \mod k \right) == 0$} \STATE{Set Slimmable training method to train on $A \cup \expectedConfig{k}$} \STATE{Set random values to $\bb{\omega}$} \FOR{1 to $t_{\networkWeights}$} \FOR{batch $b$ in $T$} \STATE{Update $\bb{\omega}$ by Slimmable training method gradient step} \ENDFOR \ENDFOR \ENDIF \STATE{Sample configurations subset $\configSubset{k}$ from current distribution $\hat{\alpha}^{k}$} \STATE{Train each configuration $\bb{a} \in \configSubset{k}$ weights for 5 epochs over $T$} \FOR{batch $b$ in $T$} \STATE{Update the distribution parameters $\alpha$ by a gradient step on $J(\bb{\alpha} ;\networkWeights)$} \ENDFOR \ENDWHILE \STATE{Sample and evaluate found configurations} \end{algorithmic} \end{algorithm} In addition, we decided to make a few more changes: \begin{itemize} \item To optimize runtime, we decided to perform the training $\bb{\omega}$, which takes most of the time, once in $10-20$ of updating the distribution parameters $\alpha$. \item We used the whole training set both for updating $\alpha$ and $\bb{\omega}$. \item We decided to save more running time by evaluated the configurations in $\configSubset{k}$ on each batch in $T$, instead of evaluation on a single batch, which further reduced runtime. \end{itemize} \clearpage \subsection{Disabling weight-sharing} \label{app:searchiii} \begin{algorithm} \caption{Disabling weight-sharing} \label{alg:Slimmable_search_method_III} \begin{algorithmic}[1] \STATE{Set training set $T$} \STATE{Set an initial distribution $\hat{\alpha}^{0}$} \STATE{Set a configurations subset size, $|\configSubset{}|$, for $J(\bb{\alpha} ;\networkWeights)$ gradient estimator} \STATE{Set $t_{\networkWeights}$, number of epochs to train a configuration weights $\networkWeights_{\configIndices}$} \STATE{Set a target homogeneous configuration $a_{homogeneous}$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set $\lambda$ for $\Loss_{\text{com}} (\networkConfig)$} \STATE{Set a function, $\sigma \left( \cdot \right)$, for $\Loss_{\text{com}} (\networkConfig)$} \WHILE{not converged} \STATE{Sample configurations subset $\configSubset{k}$ from current distribution $\hat{\alpha}^{k}$} \FOR{configuration $\bb{a} \in \configSubset{k}$} \STATE{Set random values to $\networkWeights_{\configIndices}$} \FOR{1 to $t_{\networkWeights}$} \FOR{batch $b$ in $T$} \STATE{Update $\networkWeights_{\configIndices}$ by a gradient step on $\ceLossGeneric{1,2,\dots,L}$} \ENDFOR \ENDFOR \ENDFOR \FOR{batch $b$ in $T$} \STATE{Update the distribution parameters $\alpha$ by a gradient step on $J(\bb{\alpha} ;\networkWeights)$} \ENDFOR \ENDWHILE \STATE{Sample and evaluate found configurations} \end{algorithmic} \end{algorithm} \clearpage \subsection{Interpolation loss} \label{app:searchiv} \begin{algorithm} \caption{Interpolation loss} \label{alg:Slimmable_search_method_IV} \begin{algorithmic}[1] \STATE{Set training set $T$} \STATE{Set an initial distribution $\hat{\alpha}^{0}$} \STATE{Set a configurations subset size, $|\configSubset{}|$, for $J(\bb{\alpha} ;\networkWeights)$ gradient estimator} \STATE{Set $t_{\networkWeights}$, number of epochs to train a configuration weights $\networkWeights_{\configIndices}$} \STATE{Set a function, $\sigma \left( \cdot \right)$, for $\Loss (\networkConfig;\networkWeights)$} \WHILE{not converged} \STATE{Sample configurations subset $\configSubset{k}$ from current distribution $\hat{\alpha}^{k}$} \FOR{configuration $\bb{a} \in \configSubset{k}$} \STATE{Set random values to $\networkWeights_{\configIndices}$} \FOR{1 to $t_{\networkWeights}$} \FOR{batch $b$ in $T$} \STATE{Update $\networkWeights_{\configIndices}$ by a gradient step on $\ceLossGeneric{1,2,\dots,L}$} \ENDFOR \ENDFOR \ENDFOR \FOR{batch $b$ in $T$} \STATE{Update the distribution parameters $\alpha$ by a gradient step on $J(\bb{\alpha} ;\networkWeights)$} \ENDFOR \ENDWHILE \STATE{Sample and evaluate found configurations} \end{algorithmic} \end{algorithm} \subsubsection{The expected loss} The expected loss is calculated by the linear interpolation between any two consecutive homogeneous configurations. For a heterogeneous configuration as $\bb{a}$ with $z_{\configIndices}$ arithmetic complexity, let $\ceLossInterpolation{a}$ be an approximation of cross-entropy of homogeneous configuration of complexity $a$. Then the loss of some configuration will be: \begin{equation} \Loss (\networkConfig;\networkWeights) = \sigma \left( \ceLossGeneric{}{} - \ceLossInterpolation{\bb{a}} \right) \end{equation} for some increasing function $\sigma \left( \cdot \right)$, \textit{e}.\textit{g}., LeakyReLU, sigmoid or identity. Note there is no explicit arithmetic complexity loss term. For an approximation, we used a linear interpolation between two homogeneous configurations, $\homogeneousConfig{1}$ and $\homogeneousConfig{2}$, with the closest arithmetic complexity to $\bb{a}$, such that \begin{equation} \homogeneousComplexity{1} \leq z_{\configIndices} \leq \homogeneousComplexity{2} \end{equation} for a some predefined list of homogeneous configurations for which the average loss over 5 different training sessions is calculated before training. \clearpage \subsection{The accuracy variance problem} \label{sec:quant_var} In our experiments, we selected the set $T_\ell = \qty{ (2,2), (2,4), (3,3), (8,8) }$ for all the layers. A few configurations were trained multiple times under the same conditions. We conclude that though the search yields well-performing configurations (\cref{fig:quant_results,app:quantres}), the variance of the accuracy is high, as shown in \cref{fig:NICE_variance}. Thus, it is impossible to establish whether the configurations would be good in a different realization. \section{BOPs definition and loss derivation} \label{app:bops} Under quantization as a constraint, we use BOPs as arithmetic complexity metric. The BOPs metric quantifying the number of bit operations. Given the bitwidth of two operands, it is possible to approximate the number of bit operations required for a basic arithmetic operation such as addition and multiplication. An important phenomenon is the non-linear relation between the number of activation and weight bits and the resulting network complexity in BOPs. To quantify this effect, let us consider a single convolutional layer with $b_\mathrm{w}$-bit weights and $b_\mathrm{a}$-bit activations containing $n$ input channels, $m$ output channels, and $k \times k$ filters. The maximum value of a single output is about $2^{b_\mathrm{a}+b_\mathrm{w}} n k^2$, which sets the accumulator width in the MAC operations to $b_\mathrm{o} = b_\mathrm{a}+b_\mathrm{w} + \log_2 {nk^2}$. The complexity of a single output calculation consists therefore of $nk^2$ $b_\mathrm{a}$-wide $\times$ $b_\mathrm{w}$-wide multiplications and about the same amount of $b_\mathrm{o}$-wide additions. This yields the total layer complexity of \begin{eqnarray} \mathrm{BOPs} \, \approx \, mnk^2( b_\mathrm{a} b_\mathrm{w} + b_\mathrm{a}+b_\mathrm{w} + \log_2 {nk^2}). \end{eqnarray} Note that the reduction of the weight and activation bitwidth decreases the number of BOPs as long as the factor $b_\mathrm{a} b_\mathrm{w}$ dominates the factor $\log_2 nk^2$. Since the latter factor depends only on the layer topology, this point of diminishing return is network architecture-dependent. Another factor that must be incorporated into the BOPs calculation is the cost of fetching the parameters from an an external memory. Two assumptions are made in the approximation of this cost: firstly, we assume that each parameter is only fetched once from an external memory; secondly, the cost of fetching a $b$-bit parameter is assumed to be $b$ BOPs. Given a neural network with $n$ parameters all represented in $b$ bits, the memory access cost is simply $nb$. \subsection{BOPs loss derivation} \begin{figure*}[t] \begin{center} \includegraphics[width=.99\linewidth]{figures/conv.pdf} \end{center} \caption{Applying a $\left( b_{\omega_{n},o}, b_{a_{n},o} \right)$ filter of the $n$-th layer, \textit{i}.\textit{e}., the filter weights are quantized using $b_{\omega_{n},o}$ bits and its activation (output) uses $b_{a_{n},o}$ bits.} \label{fig:filter} \end{figure*} Since custom precision data types are used for the network weights and activations, the number of MAC operations \cite{kahan1996ieee} is not an appropriate metric to acurately estimate the computational complexity of the desired model. Recently, Baskin~\textit{et al}.\ ~\cite{baskin2018uniq} proposed \emph{Bit OPerations (BOPs)} as a metric to quantify the computational complexity of neural networks with multiple bitwidths. However, since we need to take into account filter-wise granularity, the exact expression for BOPs is slightly different. Nevertheless, the main idea is the same. We denote by $b^{\omega}_{{t}} $ and $b^{\alpha}_{{t}}$ bitwidth of weights and activations for operation type $t$. For a filter in the $n$-th convolutional layer, the filter's output is of shape $c_{n} \times H \times W$. For simplicity we assume the filter is a $k_n\times{k_n}$ square. The operation of convolution can be viewed as alternating multiplications of the input pixel by the weight and addition of the result to the accumulator, which stores the result of the convolution. While the cost of multiplication is obviously $b^{\alpha}_{{t}_1}b^{\omega}_{{t}_2} $ , the cost of addition is a bit harder to approximate. The accumulator needs to be able to store any possible result of the convolution, and thus approximate the required bitwidth with maximal value of a single filter of bitwidth $b^{\omega}_{{t}_2} $, which is a sum of maximal values of each multiplication \begin{equation} \begin{split} M_{n,{t}_2} = \sum_{{t}_{1} \in T} {a}_{n-1,o_1} 2 ^ {b^{\omega}_{{t}_2} + b^{a}_{{t}_1}} \tdu{k}{n}{2} = 2^{b^{\omega}_{{t}_2}} \tdu{k}{n}{2} \sum_{{t}_{1}=1}^m {a}_{n-1,{t}_1} 2 ^ {b^{a}_{{t}_1}}, \end{split} \end{equation} which sets the accumulator width to \begin{equation} \begin{split} b^{\text{AW}}_{n,{t}_2} = \log_{2}{M_{n,{t}_2} } \approx b^{\omega}_{{t}_2} \log_{2}{ \sum_{{t}_{1} \in T} {a}_{n-1,{t}_1} 2 ^ {b^{\alpha}_{o_1}} }. \end{split} \end{equation} Therefore, the complexity of computing the single pixel of a single filter is \begin{equation} {\mathcal{B}}_{n,{t}_2}\left(\vidx\right) = \tdu{k}{n}{2}\qty[c_{n-1}b^{\text{AW}}_{n,{t}_2} + \sum_{{t}_{1} \in T} {a}_{n-1,{t}_1} b^{\alpha}_{{t}_1} b^{\omega}_{{t}_2} ] \end{equation} This yields the total layer complexity of \begin{equation} \label{eq:complexity} {\mathcal{B}}_n\left(\vidx\right) \approx HW \sum_{{t}_{1} \in T} {\mathcal{B}}_{n,{t}_2}\left(\vidx\right) \end{equation} The proposed metric is useful when the inference is performed on a custom hardware like FPGAs or ASICs. Both are natural choices for quantized networks, due to the use of lookup tables (LUTs) and dedicated MAC (or more general DSP) units, which are efficient with custom data types.
{'timestamp': '2019-09-27T02:19:39', 'yymm': '1904', 'arxiv_id': '1904.09872', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09872'}
arxiv
\section{Introduction} Intersection types have been originally developed as an extension of simple types, but they can also be used for refining simple types. In this survey we concentrate on the latter option; more precisely, on the use of intersection types for describing quantitative properties of simply typed lambda-terms. We consider lambda-terms as generators of trees. To this end, we assume a unique ground sort\footnote{% Following the convention in this area, we use the word ``sort'' for simple types, and the word ``type'' for intersection types refining them.} $\mathsf{o}$ describing trees, and we assume some uninterpreted constants, which are functions of order at most $1$. Then, a beta-normal form of a closed lambda-term of the ground sort does not contain any lambda-binders---it is just an applicative term composed of the uninterpreted constants, and thus can be seen as a tree. In other words, in the effect of calling a function $a$ with some trees as arguments, we obtain a new tree with a root labeled by $a$, and with the arguments attached in the children of the root. Suppose now that we have a closed lambda-term $M$ of the ground sort, and we want to estimate some quantities concerning its beta-normal form $T$. As a first example of such a quantity we can take the number of appearances of some fixed constant $a$ in $T$. How can we read this number from the original lambda-term $M$? As a first approach, we can look at the number of appearances of the constant $a$ in $M$. This can be completely inappropriate, though, for two reasons. First, we can have in $M$ some appearances of the constant $a$ that will be removed during beta-reductions. Second, maybe the constant $a$ appears in $M$ only once, but it will be replicated a lot of times during beta-reductions. In order to take into account these two phenomena we design an appropriate type system; a type derivation for the lambda-term $M$ identifies the places in $M$ that are really responsible for producing some constants $a$ in the beta-normal form $T$, so that these places can be counted. The type system realizing this goal is presented in Section~\ref{sec:deterministic}. Another quantity of the tree $T$ is the largest number of appearances of some fixed constant $a$ on a single branch in $T$. While the quantity of the first kind can be called deterministic, this one is slightly more complicated, and can be called nondeterministic. The justification of such a name is that while looking locally at some fragment of $T$ we do not know whether the constants $a$ appearing in this fragment should be counted or not (i.e., whether they are located on the branch of $T$ containing the largest number of constants $a$). We thus have to non-locally (nondeterministically) choose some branch of $T$ on which the constants $a$ should be counted. A type system that allows to estimate the above quantity is presented in Section~\ref{sec:nondeterministic}. The following quantity is even more involved: what is the largest number $n$ such that the binary tree with all nodes labeled by $a$ and all branches of length $n$ embeds homeomorphically in the considered tree $T$? In a sense, this quantity combines three elements: taking the maximum, taking the minimum, and counting. Indeed, we take here the maximum over all embeddings of trees with all nodes labeled by $a$ of the minimum of lengths of paths in the chosen tree (and internally, we count the number of constants $a$ on the chosen path). Unfortunately, the presented methods do not allow to estimate this quantity; it is an open problem to construct a type system concerning this quantity. One may wonder why we want to have the aforementioned type systems, instead of just expanding the lambda-term $M$ into its beta-normal form $T$, and computing the quantity there. The answer is: compositionality. Suppose that $M$ is an application $K\,L$. If we know types derivable for $K$ and for $L$, we can determine types derivable for $K\,L$. Moreover, knowing the quantities assigned to type derivations for $K$ and for $L$ we can determine the quantity assigned to type derivations for $K\,L$. We thus have a composable abstraction of every lambda-term: a set of its types, and a tuple of numbers (with a bound on the size of this set and on the length of this tuple that depends only on the sort of the lambda-term, not on its size). Existence of such an abstraction has some interesting implications. In particular, the research presented here is motivated by applications in the area of higher-order recursion schemes. Recursion schemes, or equivalently terms of the $\lambda Y$-calculus, form an extension of the simply typed lambda-calculus by a fixed-point operator $Y$~\cite{Damm82,KNU-hopda,Ong-hoschemes,kobayashiOng2009type}. Trees generated by recursion schemes can be used to faithfully represent the control flow of programs in languages with higher-order functions~\cite{Kobayashi-types}. We remark that the same class of trees can be generated by collapsible pushdown systems~\cite{collapsible} and ordered tree-pushdown systems~\cite{DBLP:conf/fsttcs/ClementePSW15}. Intersection type systems were intensively used in the context of recursion schemes, for several purposes like model-checking~\cite{Kobayashi-types,kobayashiOng2009type,DBLP:conf/csl/BroadbentK13,DBLP:conf/popl/RamsayNO14}, pumping~\cite{koba-pumping,koba-pumping-new}, transformations of HORSes~\cite{context-sensitive-2,word2tree,downward-closure}, etc. Interestingly, constructions very similar to intersection types were used also on the side of collapsible pushdown systems; they were alternating stack automata~\cite{saturation}, and types of stacks~\cite{ho-new,Kar-Par-pumping}. The type systems are also closely connected to linear logic~\cite{linear-logic-1,linear-logic-2}. The type system of Section~\ref{sec:deterministic} is based on the type system from Parys~\cite{numbers-journal}. A similar type system was used to prove that some trees generated by recursion schemes cannot be generated by so-called safe recursion schemes~\cite{ho-new}. The type system of Section~\ref{sec:nondeterministic} comes from Parys~\cite{itrs,diagonal-types}. It implies decidability of the model-checking problem for trees generated by recursion schemes against formulae of the WMSO+U logic~\cite{wmsou-schemes}. It also allows to solve the simultaneous unboundedness problem (aka.~diagonal problem) for recursion schemes, which was first solved in a different way~\cite{downward-closure}. \section{Preliminaries} The set of \emph{sorts} is constructed from a unique basic sort $\mathsf{o}$ using a binary operation $\mathbin{\to}$. Thus $\mathsf{o}$ is a sort and if $\alpha,\beta$ are sorts, so is $(\alpha\mathbin{\to}\beta)$. The \emph{order} of a sort is defined by: $\mathit{ord}(\mathsf{o})=0$, and $\mathit{ord}(\alpha\mathbin{\to}\beta)=\max(1+\mathit{ord}(\alpha),\mathit{ord}(\beta))$; in other words, $\mathit{ord}(\alpha_1\mathbin{\to}\dots\mathbin{\to}\alpha_k\mathbin{\to}\mathsf{o})=1+\max_{i\in\{1,\dots,k\}}\mathit{ord}(\alpha_i)$ whenever $k\geq 1$. A \emph{signature} is a set of constants, that is, symbols with associated sorts. For simplicity, in this paper we use a signature consisting of three constants: $a$ of sort $\mathsf{o}\mathbin{\to}\mathsf{o}$, and $\mathit{b}$ of sort $\mathsf{o}\mathbin{\to}\mathsf{o}\mathbin{\to}\mathsf{o}$, and $e$ of sort $\mathsf{o}$ (it is easy to generalize the methods to an arbitrary signature, assuming that sorts of constants are of order at most $1$). The set of \emph{(simply typed) lambda-terms} is defined by induction as follows: \begin{compactitem} \item constants (node constructors)---a constant of sort $\alpha$ is a lambda-term of sort $\alpha$; \item variables---for each sort $\alpha$ there is a countable set of variables $x^\alpha,y^\alpha,\dots$ that are also lambda-terms of sort $\alpha$; \item lambda-binders---if $K$ is a lambda-term of sort $\beta$ and $x^\alpha$ a variable of sort $\alpha$ then $\lambda x^\alpha.K$ is a lambda-term of sort $\alpha\mathbin{\to}\beta$; \item applications---if $K$ is a lambda-term of sort $\alpha\mathbin{\to}\beta$ and $L$ is a lambda-term of sort $\alpha$ then $K\,L$ is a lambda-term of sort $\beta$. \end{compactitem} As usual, we identify lambda-terms up to alpha-conversion (renaming of bound variables). We often omit the sort annotation of variables, but please keep in mind that every variable is implicitly sorted. A term is called \emph{closed} when it does not have free variables. The \emph{order} of a lambda-term $M$, denoted $\mathit{ord}(M)$, is defined as the order of the sort of $M$, while the \emph{complexity} of $M$ is defined as the maximum of orders of subterms of $M$. A sort $\alpha_1\mathbin{\to}\dots\mathbin{\to}\alpha_k\mathbin{\to}\mathsf{o}$ is \emph{homogeneous} if $\mathit{ord}(\alpha_1)\geq\dots\geq\mathit{ord}(\alpha_k)$ and all $\alpha_1,\dots,\alpha_k$ are homogeneous (defined by induction). A lambda-term is homogeneous if all its subterms have homogeneous sorts. In order to avoid some technicalities, in this paper we only consider homogeneous lambda-terms. This is without loss of generality, since there is a simple syntactic transformation converting every closed lambda-term of sort $\mathsf{o}$ into a homogeneous lambda-term having the same beta-normal form~\cite{homogeneity}. We use the usual notion of beta-reduction: we have $M\to_\beta N$ if $N$ can be obtained from $M$ by replacing some of its subterms of the form $(\lambda x.K)\,L$ by $K[L/x]$. We recall that simply typed lambda-calculus has the properties of strong normalization and confluence, that is, every sequence of beta-reductions from a lambda-term $M$ eventually terminates in a unique lambda-term $N$ such that no more beta-reductions can be performed from $N$; the lambda-term $N$ is called the \emph{beta-normal form} of $M$. Observe that the beta-normal form of a closed lambda-term of sort $\mathsf{o}$ is an applicative term build of constants (it does not contain variables nor lambda-binders), and thus can be seen as a tree (generated by the lambda-term). In this paper we are interested in two particular reduction strategies (i.e., strategies of choosing a redex that should be reduced next). In the \emph{OI strategy}, we always reduce an \emph{outermost redex}, that is, a redex that is not located inside another redex. Notice that if $M$ is closed and of sort $\mathsf{o}$, then every outermost redex in $M$ is also closed. A redex $(\lambda x.K)\,L$ is a \emph{redex of order $m$} if $\mathit{ord}(\lambda x.K)=m$. Assuming that the lambda-term is homogeneous, we have $\mathit{ord}(\lambda x.K)=m$ if and only if $\mathit{ord}(x)=m-1$. In the \emph{RMF strategy} we always reduce a \emph{rightmost redex of the maximal order}, that is, a redex $(\lambda x.K)\,L$ of some order $m$ such that in the lambda-term there is no redex of a higher order, and in $L$ there are no redexes of order $m$,\label{pag:rmf} and the redex is not located inside $K'$ for some order-$m$ redex $(\lambda x'.K')\,L'$. In other words, whenever we see an order-$m$ redex $(\lambda x.K)\,L$, we first reduce all order-$m$ redexes in $L$, then the redex itself, and then we continue reducing the resulting lambda-term. We also write RMF$(m)$ to make it explicit that the order of the considered redex is $m$. When a closed lambda-term $M$ of sort $\mathsf{o}$ has complexity $m$ (and is not in the beta-normal form), then an RMF$(m)$ reduction always exist; thus following the RMF strategy we first reduce all redexes of order $m$ (until reaching a term of complexity $m-1$), then all redexes of order $m-1$, and so on. Moreover, for an RMF$(m)$ redex $(\lambda x.K)\,L$ in such a lambda-term, all variables appearing in $L$ are of order at most $m-2$. Suppose that we have two functions $f,g\colon X\to\mathbb{N}$, over some domain $X$. We want to define when $f$ estimates $g$. To this end, we say that $f$ is \emph{dominated} by $g$, written $f\preceq g$, if there exists a function $\eta\colon\mathbb{N}\to\mathbb{N}$ such that $f(x)\leq\eta(g(x))$ for all $x\in X$, and we say that $f$ \emph{estimates} $g$, written $f\approx g$, if $f\preceq g$ and $g\preceq f$. It is easy to see that $f$ estimates $g$ if and only if on every subset $Y$ of the domain $X$, the functions $f$ and $g$ are either both bounded or both unbounded. The above relation between functions is widely used in the area of regular cost functions (see, e.g., Colcombet~\cite{regular-cost-functions}). One may also consider infinite lambda-terms. Clearly they do not reduce to a normal form in a finite number of steps, but we can consider the (unique) normal form reached in the limit, called the \emph{B\"ohm tree}. As in the finite case, the B\"ohm tree of a closed lambda-term of sort $\mathsf{o}$ is a (potentially infinite) tree build out of constants. A \emph{recursion scheme} is a finite description of a regular (i.e., having finitely many different subterms) infinite lambda-term. \section{Deterministic Quantities}\label{sec:deterministic} In this section we present a type system that allows to estimate the number of appearances of the constant $a$ in the beta-normal form of a lambda-term. The type system should be such that a type derivation for a closed lambda-term $M$ of sort $\mathsf{o}$ identifies the places in $M$ that are responsible for producing some $a$-labeled nodes in the beta-normal form $T$ of $M$. To this end, we extend the notion of sorts by a \emph{productivity flag}, which can be ${\mathsf{pr}}$ (standing for productive) and ${\mathsf{np}}$ (standing for nonproductive). It may happen that a single lambda-term $K$ has multiple types; for example, $\lambda y.y\,(a\,e)$ is productive when the function (substituted for) $y$ uses its argument, and nonproductive otherwise. Because of that, we need intersection types (i.e., the ability of assigning multiple types to the same lambda-term). In effect, our types differ from sorts in that on the left side of $\mathbin{\to}$, instead of a single type, we have a set of pairs $(f,\tau)$, where $\tau$ is a type, and $f$ is a flag from $\{{\mathsf{pr}},{\mathsf{np}}\}$. The unique atomic type is denoted $\r$. More precisely, for each sort $\alpha$ we define the set $\mathcal{T}^\alpha$ of types of sort $\alpha$ as follows: \begin{align*} \mathcal{T}^\mathsf{o}=\{\r\},\qquad \mathcal{T}^{\alpha\mathbin{\to}\beta}=\mathcal{P}(\{{\mathsf{pr}},{\mathsf{np}}\}\times\mathcal{T}^\alpha)\times\mathcal{T}^\beta, \end{align*} where $\mathcal{P}$ denotes the powerset. A type $(T,\tau)\in\mathcal{T}^{\alpha\mathbin{\to}\beta}$ is denoted as $\bigwedge T\mathbin{\to}\tau$, or $\bigwedge_{i\in I}(f_i,\tau_i)\mathbin{\to}\tau$ when $T=\{(f_i,\tau_i)\mid i\in I\}$. The empty intersection is denoted by $\top$. To a lambda-term of sort $\alpha$ we assign not only a type $\tau\in\mathcal{T}^\alpha$, but also a flag $f\in\{{\mathsf{pr}},{\mathsf{np}}\}$ (which together form a pair $(f,\tau)$). Intuitively, a lambda-term has type $\bigwedge T\mathbin{\to}\tau$ when it can return $\tau$, while taking an argument for which we can derive all pairs (of a flag and a type) from $T$; simultaneously, while having such a type, the lambda-term is obligated to use its arguments in all ways described by type pairs from $T$. And, we assign the flag ${\mathsf{pr}}$ (productive), when this term (while being a subterm of a closed term of sort $\mathsf{o}$) increases the number of constants $a$ in the resulting tree. To be more precise, a term is productive in two cases. First, when it uses the constant $a$. Notice however that this $a$ has to be really used: there exist terms which syntactically contain $a$, but the result of this $a$ is then ignored, like in $(\lambda x.e)\,a$. Second, a term which takes a productive argument and uses it at least twice is also productive (for example, the productive argument may be a function that creates an $a$-labeled node; when a lambda-term uses such an argument twice, the lambda-term is itself responsible for increasing the number of constants $a$ in the resulting tree). A \emph{type judgment} is of the form $\Gamma\vdash M:(f,\tau)$, where we require that the type $\tau$ and the term $M$ are of the same sort. The \emph{type environment} $\Gamma$ is a set of bindings of variables of the form $x^\alpha:(f,\tau)$, where $\tau\in\mathcal{T}^\alpha$. In $\Gamma$ we may have multiple bindings for the same variable. By $\mathit{dom}(\Gamma)$ we denote the set of variables $x$ that are bound by $\Gamma$, and by $\Gamma{\restriction}_{\mathsf{pr}}$ we denote the set of those binding from $\Gamma$ that use flag ${\mathsf{pr}}$. We now gradually present rules of the type system. We begin with rules for node constructors: \begin{mathpar} \inferrule{}{\vdash a:({\mathsf{pr}},(f,\r)\mathbin{\to}\r)}\and \inferrule{}{\vdash \mathit{b}:({\mathsf{np}},(f_1,\r)\mathbin{\to}(f_2,\r)\mathbin{\to}\r)}\and \inferrule{}{\vdash e:({\mathsf{np}},\r)} \end{mathpar} Since we aim at counting constants $a$, we say here that $a$ is productive, while $\mathit{b}$ and $e$ are nonproductive. Notice that productivity of a node constructor does not depend on productivity of the argument; flags of the arguments ($f, f_1, f_2$) can be arbitrary. Then we have a rule for a variable: \begin{mathpar} \inferrule{}{x:(f,\tau)\vdash x:({\mathsf{np}},\tau)} \end{mathpar} The type of the variable is taken from the environment. The flag is always ${\mathsf{np}}$, though; by just using a variable we are not productive at all (and in the productivity flag we want to cover productivity of the lambda-term itself, not of lambda-terms that may be potentially substituted for free variables). The rule that talks about lambda-binders is very natural; it just moves type pairs from the argument to the environment: \begin{mathpar} \inferrule*[right=($\lambda$)]{\Gamma\cup\{x:(f_i,\tau_i)\mid i\in I\}\vdash K:(f,\tau)\\x\not\in \mathit{dom}(\Gamma)} {\Gamma\vdash\lambda x.K:(f,\bigwedge\nolimits_{i\in I}(f_i,\tau_i)\mathbin{\to}\tau)} \end{mathpar} Finally, we have the most complicated rule, for application: \begin{mathpar} \inferrule*[right=$(@)$]{\Gamma\vdash K:(f',\bigwedge\nolimits_{i\in I}(f_i^\bullet,\tau_i)\mathbin{\to}\tau)\\ \Gamma_i\vdash L:(f_i^\circ,\tau_i)\mbox{ for each }i\in I} {\Gamma\cup\bigcup\nolimits_{i\in I}\Gamma_i\vdash K\,L:(f,\tau)} \end{mathpar} where we assume that \begin{itemize} \item every pair $(f_i^\bullet,\tau_i)$ is different (where $i\in I$), \item for each $i\in I$, $f_i^\bullet={\mathsf{pr}}$ if and only if $f_i^\circ={\mathsf{pr}}$ or $\Gamma_i{\restriction}_{\mathsf{pr}}\neq\emptyset$, and \item $f={\mathsf{pr}}$ if and only if $f'={\mathsf{pr}}$, or $f_i^\circ={\mathsf{pr}}$ for some $i\in I$, or $|\Gamma{\restriction}_{\mathsf{pr}}|+\sum_{i\in I}|\Gamma_i{\restriction}_{\mathsf{pr}}|>|(\Gamma\cup\bigcup_{i\in I}\Gamma_i){\restriction}_{\mathsf{pr}}|$. \end{itemize} Let us explain the above conditions. The first condition is technical: we need to provide exactly one derivation for every needed type pair. The second condition says that when $K$ requires a ``productive'' argument, either we can apply an argument $L$ that is itself productive, or we can apply a nonproductive $L$ that uses a productive variable; in the latter case, after substituting something for the variable, $L$ will become productive. The third condition says that $K\,L$ is productive if $K$ is productive, or if $L$ is productive, or if some productive free variable is duplicated (i.e., used in at least two subderivations simultaneously). Notice that weakening of type environments is disallowed: $\Gamma\vdash M:(f,\tau)$ does not necessarily imply $\Gamma,x:(g,\sigma)\vdash M:(f,\tau)$; in other words, every binding $x:(g,\sigma)$ in the type environment (and thus every pair $(g,\sigma)$ assigned to an argument) has to be really used somewhere in the type derivation. This property of the type system is very expected, if we recall that we want to distinguish lambda-terms that really use their (productive) arguments from those in which the arguments are discarded. On the other hand, contraction is allowed: we may say that $\Gamma,x:(g,\sigma),x:(g,\sigma)\vdash M:(f,\tau)$ implies $\Gamma,x:(g,\sigma)\vdash M:(f,\tau)$, since a type environment is a set of type bindings. As we see in the \TirName{(\!@\!)}\xspace rule, such contractions (for productive type binding) cause productivity of lambda-terms. A \emph{derivation} is defined as usual: it is a tree labeled by type judgments, such that each node together with its children fit to one of the rules of the type system. We now define a \emph{value} of every node of a derivation, saying how much this node is productive. In a node using the rule for the constant $a$, the value is $1$. In a node using the \TirName{(\!@\!)}\xspace rule with type environments $\Gamma$ and $\Gamma_i$ for $i\in I$, the value is \begin{align*} |\Gamma{\restriction}_{\mathsf{pr}}|+\sum\nolimits_{i\in I}|\Gamma_i{\restriction}_{\mathsf{pr}}|-|(\Gamma\cup\bigcup\nolimits_{i\in I}\Gamma_i){\restriction}_{\mathsf{pr}}|\,. \end{align*} Spelling this out, the value in such a node equals the number of productive type bindings together in all the type environments $\Gamma$, $(\Gamma_i)_{i\in I}$, minus the number of such type bindings in their union. In other words, it says how many times we have to duplicate some productive type bindings before splitting them between type environments of subderivations. In all other nodes the value is $0$. For a derivation $D$, the \emph{value} of $D$, denoted $\mathit{val}(D)$, is the sum of values of all nodes in $D$. We can easily see that the value of a derivation $D$ is positive if and only if $D$ is productive (i.e., the flag in the derived type judgment is ${\mathsf{pr}}$). The main theorem says that $\mathit{val}(D)$ can be used to estimate the the number of constants $a$ in normal forms of lambda-terms. \begin{theorem}\label{thm:det} The following holds for the type system introduced above: \begin{compactenum}[(D1)] \item\label{it:d1} for every $m\in\mathbb{N}$ there is a function $\eta_m\colon\mathbb{N}\to\mathbb{N}$ such that if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$ and complexity at most $m$, and $D$ is a derivation for $\vdash M:(f,\r)$, then the number of constants $a$ in the normal form of $M$ is \begin{compactenum} \item[(D1A)]\label{it:d1a} at least $\mathit{val}(D)$, and \item[(D1B)]\label{it:d1b} at most $\eta_m(\mathit{val}(D))$; \end{compactenum} \item\label{it:d2} for every closed lambda-term $M$ of sort $\mathsf{o}$ one can derive $\vdash M:(f,\r)$ (for some $f\in\{{\mathsf{pr}},{\mathsf{np}}\}$).\footnote{% Actually, one can even prove that there is a unique derivation concerning $M$ (assuming that $M$ is closed and of sort $\mathsf{o}$).} \end{compactenum} \end{theorem} \begin{example}\label{ex:1} Observe how the type system behaves for the lambda-term $M=(\lambda y.N\,(N\,(N\,y))\,(a\,e))\,a$, where $N=\lambda y.\lambda x.y\,(y\,x)$. We start with a derivation concerning $N$, where we write $\tau_y^{\mathsf{pr}}$ for $({\mathsf{pr}},\r)\mathbin{\to}\r$: \begin{mathpar} \inferrule*[Right=$(\lambda)$,leftskip=-7.7em,rightskip=-13em]{ \inferrule*[Right=$(\lambda)$,leftskip=1.1em,rightskip=1.1em]{ \inferrule*[Right=$(@)$,leftskip=6.6em,rightskip=6.6em]{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash y:({\mathsf{np}},\tau_y^{\mathsf{pr}}) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash y:({\mathsf{np}},\tau_y^{\mathsf{pr}}) \and x:({\mathsf{pr}},\r)\vdash x:({\mathsf{np}},\r) }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}}),\,x:({\mathsf{pr}},\r)\vdash y\,x:({\mathsf{np}},\r) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}}),\,x:({\mathsf{pr}},\r)\vdash y\,(y\,x):({\mathsf{pr}},\r) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash\lambda x.y\,(y\,x):({\mathsf{pr}},\tau_y^{\mathsf{pr}}) } }{ \vdash N:({\mathsf{pr}},({\mathsf{pr}},\tau_y^{\mathsf{pr}})\mathbin{\to}\tau_y^{\mathsf{pr}}) } \end{mathpar} Notice that the type $\tau_y^{\mathsf{pr}}$ requires a productive argument, but (in both the \TirName{(\!@\!)}\xspace rules above) we apply an argument that is not productive itself. This is possible, because the type judgments for the arguments have productive type bindings in the type environments (and hence for the purposes of the \TirName{(\!@\!)}\xspace rule they are assumed to be productive). The lower use of the \TirName{(\!@\!)}\xspace rule has value $1$ (and in effect the productivity flag is set to ${\mathsf{pr}}$), because the productive type binding $y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})$ is taken to both children. Below, we have another derivation concerning $N$, where we write $\tau_y^{\mathsf{np}}$ for $({\mathsf{np}},\r)\mathbin{\to}\r$: \begin{mathpar} \inferrule*[Right=$(\lambda)$,leftskip=-5.2em,rightskip=-10.5em]{ \inferrule*[Right=$(\lambda)$,leftskip=1.1em,rightskip=1.1em]{ \inferrule*[Right=$(@)$,leftskip=4.1em,rightskip=4.1em]{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash y:({\mathsf{np}},\tau_y^{\mathsf{pr}}) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ y:({\mathsf{pr}},\tau_y^{\mathsf{np}})\vdash y:({\mathsf{np}},\tau_y^{\mathsf{np}}) \and x:({\mathsf{np}},\r)\vdash x:({\mathsf{np}},\r) }{ y:({\mathsf{pr}},\tau_y^{\mathsf{np}}),\,x:({\mathsf{np}},\r)\vdash y\,x:({\mathsf{np}},\r) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}}),\,y:({\mathsf{pr}},\tau_y^{\mathsf{np}}),\,x:({\mathsf{np}},\r)\vdash y\,(y\,x):({\mathsf{np}},\r) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}}),\,y:({\mathsf{pr}},\tau_y^{\mathsf{np}})\vdash\lambda x.y\,(y\,x):({\mathsf{np}},\tau_y^{\mathsf{np}}) } }{ \vdash N:({\mathsf{np}},({\mathsf{pr}},\tau_y^{\mathsf{pr}})\wedge({\mathsf{pr}},\tau_y^{\mathsf{np}})\mathbin{\to}\tau_y^{\mathsf{np}}) } \end{mathpar} This time the value of all nodes is $0$, because every type binding is used in exactly one place. Likewise, it is possible to derive five other type pairs for the lambda-term $N$: \begin{align*} &({\mathsf{np}},({\mathsf{pr}},\tau_y^{\mathsf{pr}})\wedge({\mathsf{np}},\tau_y^{\mathsf{pr}})\mathbin{\to}\tau_y^{\mathsf{pr}})\,,& &({\mathsf{np}},({\mathsf{np}},\tau_y^{\mathsf{pr}})\mathbin{\to}\tau_y^{\mathsf{pr}})\,,\\ &({\mathsf{np}},({\mathsf{pr}},\tau_y^{\mathsf{np}})\wedge({\mathsf{np}},\tau_y^{\mathsf{np}})\mathbin{\to}\tau_y^{\mathsf{np}})\,,& &({\mathsf{np}},({\mathsf{np}},\tau_y^{\mathsf{np}})\mathbin{\to}\tau_y^{\mathsf{np}})\,.\\ &({\mathsf{np}},({\mathsf{np}},\tau_y^{\mathsf{pr}})\wedge({\mathsf{pr}},\tau_y^{\mathsf{np}})\mathbin{\to}\tau_y^{\mathsf{np}})\,,& \end{align*} While deriving a type for $M$, we only need one type pair for $N$: the type pair $({\mathsf{pr}},({\mathsf{pr}},\tau_y^{\mathsf{pr}})\mathbin{\to}\tau_y^{\mathsf{pr}})$ derived at the beginning. But we remark that if the lambda-term was $M'=(\lambda y.N\,(N\,(N\,y))\,e)\,a$ (we have replaced here $a\,e$ by $e$, and thus the first call to $N$ receives a nonproductive argument as $x$), it would be necessary to use both the above derivations for $N$. Denoting the type $({\mathsf{pr}},\tau_y^{\mathsf{pr}})\mathbin{\to}\tau_y^{\mathsf{pr}}$ as $\tau_N$, we continue the derivation for $M$: \begin{mathpar} \inferrule*[Right=$(@)$,rightskip=-9.5em]{ \vdash N:({\mathsf{pr}},\tau_N) \and \inferrule*[Right=$(@)$,leftskip=1em,rightskip=4.2em]{ \vdash N:({\mathsf{pr}},\tau_N) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ \vdash N:({\mathsf{pr}},\tau_N) \and y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash y:({\mathsf{np}},\tau_y^{\mathsf{pr}}) }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash N\,y:({\mathsf{pr}},\tau_y^{\mathsf{pr}}) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash N\,(N\,y):({\mathsf{pr}},\tau_y^{\mathsf{pr}}) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash N\,(N\,(N\,y)):({\mathsf{pr}},\tau_y^{\mathsf{pr}}) } \and \inferrule*[right=$(@)$,leftskip=-3.5em]{ \inferrule*[right=$(\lambda)$,rightskip=1em]{ \inferrule*[Right=$(@)$,leftskip=5em,rightskip=5em]{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash N\,(N\,(N\,y)):({\mathsf{pr}},\tau_y^{\mathsf{pr}}) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.5em]{ \vdash a:({\mathsf{pr}},\tau_y^{\mathsf{np}}) \and \vdash e:({\mathsf{np}},\r) }{ \vdash a\,e:({\mathsf{pr}},\r) } }{ y:({\mathsf{pr}},\tau_y^{\mathsf{pr}})\vdash N\,(N\,(N\,y))\,(a\,e):({\mathsf{pr}},\r) } }{ \vdash\lambda y.N\,(N\,(N\,y))\,(a\,e):({\mathsf{pr}},({\mathsf{pr}},\tau^{\mathsf{pr}}_y)\mathbin{\to}\r) } \and \vdash a:({\mathsf{pr}},\tau_y^{\mathsf{pr}}) }{ \vdash M:({\mathsf{pr}},\r) } \end{mathpar} The total value of this derivation is $5$ ($2$ in the two nodes concerning $a$, and $3$ in the three subderivations concerning $N$), while the normal form of $M$ contains $9$ appearances of the constant $a$. Notice that while adding any further $N$ to the sequence $N\,(N\,(N\,y))$, we increase the value by $1$, while we almost double the number of $a$'s in the normal form. \end{example} \paragraph*{Proofs.} Let us now sketch the proof of Theorem~\ref{thm:det}. While proving Condition~\hyperref[it:d1]{(D1)}, it is convenient to consider the RMF strategy of reductions (defined on Page~\pageref{pag:rmf}). We have the following subject-reduction lemma for reductions of this kind. \begin{lemma}\label{lem:subj-red-det} If $D_0$ is a derivation for $\vdash M_0:(f,\mathsf{o})$, where $M_0$ is homogeneous, closed, and of complexity $m$ (and of sort $\mathsf{o}$), and $M_0\to_\beta M_1\to_\beta\dots\to_\beta M_n$ is a sequence of RMF$(m)$ beta-reductions, then there exists a derivation $D_n$ for $\vdash M_n:(f,\mathsf{o})$ such that $\mathit{val}(D_0)\leq\mathit{val}(D_n)$ and $\mathit{val}(D_n)\leq 2^{\mathit{val}(D_0)}$. \end{lemma} Because the maximal complexity $m$ of the lambda-term $M$ considered in Theorem~\ref{thm:det} is fixed, using Lemma~\ref{lem:subj-red-det} $m$ times (for complexities $m,m-1,\dots,1$) we obtain a derivation $D_T$ for the normal from $T$ of $M$ such that $\mathit{val}(D)\leq\mathit{val}(D_T)$ and $\mathit{val}(D_T)$ is bounded by a function of $\mathit{val}(D)$, that is, $\mathit{val}(D)$ estimates $\mathit{val}(D_T)$. It remains to notice that $\mathit{val}(D_T)$ is exactly the number of $a$-labeled nodes in the tree $T$. \begin{proof}[Proof sketch (Lemma~\ref{lem:subj-red-det})] We proceed by induction: for every $i\in\{1,\dots,n\}$ out of the derivation $D_{i-1}$ for $\vdash\nobreak M_{i-1}:(f,\mathsf{o})$ we construct a derivation $D_i$ for $\vdash M_i:(f,\mathsf{o})$. To this end, we consider every subderivation $D$ of $D_{i-1}$ starting with a type judgment $\Gamma\vdash(\lambda x.K)\,L:(g,\tau)$ concerning the redex involved in the reduction $M_{i-1}\to_\beta M_i$; we need to replace it by a derivation $D'$ for $\Gamma\vdash K[L/x]:(g,\tau)$. We obtain $D'$ by a surgery on $D$: we take the subderivation of $D$ concerning $K$, we replace every leaf deriving a type $\sigma$ for $x$ by the subderivation of $D$ deriving this type $\sigma$ for $L$, and we update type environments and productivity flags appropriately. Notice that every subderivation concerning $L$ is moved to at least one leaf concerning $x$ (nothing can disappear). The only reason why the value of the derivation can decrease is that potentially a productive type binding $x:({\mathsf{pr}},\sigma)$ was duplicated (say, $k$ times) in the derivation concerning $K$. In $D'$ this binding is no longer present (in $K[L/x]$ there is no $x$) so the value gets decreased by $k$, but in this situation the subderivation deriving $\sigma$ for $L$ becomes inserted in $k+1$ leaves. This subderivation is either productive itself, or uses a productive type binding in the environment; in both cases by creating $k$ additional copies of this subderivation we increase the value at least by $k$, compensating the loss caused by elimination of $x$. This implies that $\mathit{val}(D)\leq\mathit{val}(D')$, hence $\mathit{val}(D_{i-1})\leq\mathit{val}(D_i)$ (and, in effect, $\mathit{val}(D_0)\leq\mathit{val}(D_n)$). Conversely, the only reason why the value can grow is that some derivation concerning $L$ (that is either productive itself or uses some productive type bindings for its free variables) becomes inserted in $k+1$ leaves, for some $k\geq 1$. In the worst case, this may cause that the value (of the whole derivation for $M$) gets multiplied by $k+1$. But, simultaneously, in the subderivation concerning $K$, the productive type bindings for $x$ are removed, which decreases the value by $k$ in some nodes of this subderivation. The point is now that these nodes were never copied in the reduction sequence from $D_0$ to the considered $D_{i-1}$; this is because all the reductions are RMF$(m)$ reductions. Indeed, looking from the other side, all variables appearing in (the copied subderivation for) $L$ are of order at most $m-2$---% as observed on Page~\pageref{pag:rmf}---% but all variables involved in future order-$m$ reductions (i.e., all variables that we remove from type environments) are of order $m-1$---% because of homogeneity of the lambda-term. Thus, whenever we multiply the value of the current derivation by at most $k+1$, we subtract $k$ from the value of the original derivation $D_0$. The worst case is when $\mathit{val}(D_0)$ times we decrease the value by $1$, and $\mathit{val}(D_0)$ times we multiply it by $2$. It follows that $\mathit{val}(D_n)\leq\mathit{val}(D_0)\cdot2^{\mathit{val}(D_0)}$; a slightly more careful analysis shows that actually $\mathit{val}(D_n)\leq 2^{\mathit{val}(D_0)}$. \end{proof} In the proof of Condition~\hyperref[it:d2]{(D2)}, saying that we can derive a type for every closed lambda-term $M$ of sort $\mathsf{o}$, we proceed backwards: it is easy to derive a type for a tree (i.e., for the normal form of $M$), and thus it is enough to have a subject expansion lemma saying that out of a derivation for a lambda-term after a beta-reduction we can construct a derivation for the lambda-term before the beta-reduction. This time we follow the OI reduction strategy. Because outermost redexes are closed, it is thus enough to have the following lemma. \begin{lemma}\label{lem:subj-exp} If we can derive $\vdash K[L/x]:(g,\tau)$, then we can also derive $\vdash (\lambda x.K)\,L:(g,\tau)$. \end{lemma} \begin{proof}[Proof sketch] In the derivation $D$ for $K[L/x]$ we replace every subderivation concerning $L$ by a leaf rule for the variable $x$, and we correct type environments and productivity flags in the rest of the derivation. This way we obtain a derivation for $K$ with type environment requesting some types for $x$. Simultaneously, each of these types was derived for $L$ in some subderivation of $D$ (there may be multiple such subderivations, because $L$ may appear in many places in $K[L/x]$, but we choose only one subderivation for every type). It is not difficult to combine these derivations into a derivation concerning $(\lambda x.K)\,L$. \end{proof} We remark that by applying the above surgery to a derivation for $\Gamma\vdash K[L/x]:(g,\tau)$ (i.e., for an arbitrary redex, having some free variables) we only obtain a derivation for $\Gamma'\vdash (\lambda x.K)\,L:(g,\tau)$ with some $\Gamma'\subseteq\Gamma$, but not necessarily with $\Gamma'=\Gamma$. The reason is that we remove some subderivations concerning $L$ (we leave only one for every type), and possibly some type bindings from $\Gamma$ were used only in the removed subderivations. \paragraph*{Bibliographic Note.} As already mentioned in the introduction, the idea of the type system presented above originates from Parys~\cite{ho-new}. In that paper, a similar type system was introduced for configurations of collapsible pushdown systems. It was then used to prove that a restricted variant of these systems (systems without the so-called collapse operation) are less powerful than general collapsible pushdown systems. The type system was then transferred to the setting of lambda-terms in Parys~\cite{numbers-journal}. Their type system is slightly more complicated than ours, and allows to obtain a stronger version of Condition~\hyperref[it:d1]{(D1B)}, where the function $\eta_m$ does not depend on the complexity $m$ of considered lambda-terms. \section{Nondeterministic Quantities}\label{sec:nondeterministic} Suppose now that we want to estimate another quantity: the maximal number of appearances of the constant $a$ on a single branch in the beta-normal form $T$ of a lambda-term $M$. It seems that in order to describe this quantity, it is enough to take the type system from Section~\ref{sec:deterministic}, and replace the rule for the constant $b$ by two rules: \begin{mathpar} \inferrule{}{\vdash \mathit{b}:({\mathsf{np}},(f,\r)\mathbin{\to}\top\mathbin{\to}\r)}\and \inferrule{}{\vdash \mathit{b}:({\mathsf{np}},\top\mathbin{\to}(f,\r)\mathbin{\to}\r)} \end{mathpar} In these rules we ignore one of the arguments, and we descend only to the other one. This way, every type derivation $D$ for a tree $T$ follows one branch in $T$, and in effect $\mathit{val}(D)$ equals to the number of constants $a$ on that branch. By arguments like in the previous section we obtain the following, rather useless, properties of the modified type system: \begin{compactenum}[(N1)] \item\label{it:n1} for every $m\in\mathbb{N}$ there is a function $\eta_m\colon\mathbb{N}\to\mathbb{N}$ such that if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$ and complexity at most $m$, and $D$ is a derivation for $\vdash M:(f,\r)$, then the number of constants $a$ on some branch of the normal form of $M$ is \begin{compactenum} \item[(N1A)]\label{it:n1a} at least $\mathit{val}(D)$, and \item[(N1B)]\label{it:n1b} at most $\eta_m(\mathit{val}(D))$; \end{compactenum} \item\label{it:n2} for every closed lambda-term $M$ of sort $\mathsf{o}$ one can derive $\vdash M:(f,\r)$ (for some $f\in\{{\mathsf{pr}},{\mathsf{np}}\}$). \end{compactenum} These properties are not satisfactory for us, because they only say that there exists a branch with the number of constants $a$ estimated by $\mathit{val}(D)$, for some derivation $D$. We, however, are interested in the branch on which the number of constants $a$ is maximal. In other words: if in the beta-normal form $T$ of $M$ there are two branches, one with just a few constants $a$, and the other with a lot of them, we expect to have two derivations $D$ and $D'$, where $\mathit{val}(D)$ is small (corresponds to the first branch), and $\mathit{val}(D')$ is large (corresponds to the second branch). But Condition~\hyperref[it:n2]{(N2)} gives us only one derivation, and we do not know which one. Thus, we rather need to have the following property: \begin{compactenum} \item[(N2$'$)\!]\label{it:n2p} for every $m\in\mathbb{N}$ there is a function $\eta_m\colon\mathbb{N}\to\mathbb{N}$ such that if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$ and complexity at most $m$ and on some branch of the beta-normal form of $M$ there are $n$ appearances of the constant $a$, then there is a derivation $D$ for $\vdash M:(f,\r)$ such that $n\leq\eta_m(\mathit{val}(D))$. \end{compactenum} In the light of Condition~\hyperref[it:n2p]{(N2$'$)}, Condition~\hyperref[it:n1b]{(N1B)} becomes redundant, and thus we can restate Condition~\hyperref[it:n1a]{(N1A)} as follows: \begin{compactenum} \item[(N1$'$)\!]\label{it:n1p} if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$, and $D$ is a derivation for $\vdash M:(f,\r)$, then the number of constants $a$ on some branch of the normal form of $M$ is at least $\mathit{val}(D)$. \end{compactenum} It is, though, an open problem whether Condition~\hyperref[it:n2p]{(N2$'$)} holds. \begin{openpr} Does the modified type system satisfy Condition~\hyperref[it:n2p]{(N2$'$)}? \end{openpr} In order to prove Condition~\hyperref[it:n2p]{(N2$'$)}, we should probably proceed backward: we should start with a derivation concerning (the branch with the maximal number of constants $a$ in) the normal form of $M$, and then, successively, from a derivation for a lambda-term after a beta-reduction obtain a derivation for the lambda-term before the beta-reduction. We have a subject expansion lemma (Lemma~\ref{lem:subj-exp}) only for redexes without free variables (and it seems difficult to generalize it to arbitrary redexes, as explained at the end of the previous section); we should thus assume that we always reduce the outermost redex. In effect, in the considered sequence of beta-reductions from $M$ to its normal form we have to mix reductions concerning redexes of different orders. For such a sequence of reductions it is not clear how to estimate the value of the derivation for the beta-normal form $T$ by the value of the derivation for $M$. We remark that a modified type system, in which one allow weakening of type environments, satisfies a subject expansion lemma (like Lemma~\ref{lem:subj-exp}). But with unrestricted weakening of type environments Condition~\hyperref[it:n1p]{(N1$'$)} no longer holds. Indeed, if weakening was allowed, we could use a derivation $D$ (with an arbitrary large value) for a lambda-term $M$ as a part of a derivation for a lambda-term like $(\lambda x.e)\,M$, whose normal form contains no $a$. The reason why weakening is forbidden is exactly this: we want to have subderivations only for subterms that really participate to the normal form. The life is thus not so simple: because we want both Conditions~\hyperref[it:n1p]{(N1$'$)} and~\hyperref[it:n2p]{(N2$'$)}, we have to introduce a more complicated type system. In this type system, instead of one kind of values of nodes, we have \emph{values of order $k$} (or \emph{$k$-values}) for every $k\in\{1,\dots,m+1\}$ (where $m$ is the complexity of the considered lambda-term). We also mark some nodes as belonging to a \emph{zone of order $k$} (or \emph{$k$-zone}) for every order $k\in\{0,\dots,m\}$. Before defining the type system, let us first give some idea how Condition~\hyperref[it:n2p]{(N2$'$)} can be shown. Then, we give details of a type system motivated by this idea. Consider thus a lambda-term $M_m$ that is of complexity $m$, and reduces to a tree $M_0$. Following the RMF reduction strategy, we can find lambda-terms $M_{m-1},M_{m-2},\dots,M_1$ such that every $M_i$ is of complexity $i$ and all reductions between $M_i$ and $M_{i-1}$ are of order $i$. Our aim is to estimate the number of constants $a$ located on some branch in $M_0$. We thus mark all nodes of this branch as the $0$-zone, and we say that the order-$1$ value is $1$ in all nodes of the $0$-zone that are labeled by $a$. Next, we proceed back to $M_1$. Every node constructor in the $0$-zone in $M_0$ originates from some particular node constructor appearing already in $M_1$. We thus mark these node constructors in $M_1$ as belonging to the $0$-zone (notice that in $M_1$ they no longer form a branch); and again those of them that are $a$-labeled get $1$-value $1$. The crucial observation is that no two node constructors from the $0$-zone in $M_0$ can originate from a single node constructor of $M_1$. Indeed, all the beta-reductions between $M_1$ and $M_0$ are RMF$(1)$. In such a beta-reduction we take a whole subtree (i.e., a lambda-term of sort $\mathsf{o}$) of $M_1$, and we replace it somewhere, possibly replicating it. But since the considered nodes of $M_0$ lie on a single branch, they may belong to at most one copy of the replicated subtree. In effect, the total $1$-value in $M_1$ is the same as in $M_0$. We cannot directly repeat the same reasoning to move $1$-values from $M_1$ back to $M_2$, since now there is a problem: a single node constructor in $M_2$ may result in multiple (uncontrollably many) node constructors with a $1$-value in $M_1$. We rescue ourselves in the following way. We choose some branch of $M_1$ (included in the $0$-zone) as the $1$-zone. Then, for every node of $M_1$ with positive $1$-value, we look for the closest ancestor of this node that lies in the $1$-zone, and in this ancestor we set the $2$-value to $1$. Notice that for multiple nodes with positive $1$-value, their closest ancestor lying in the $1$-zone may be the same (and then we set its $2$-value to $1$, not to the number of these nodes). Thus, in general, the total $2$-value may be smaller than the total $1$-value. We can, however, ensure that it is smaller only logarithmically; to do so, we choose a branch forming the $1$-zone in a clever way: staring from the root, we always proceed to the subtree with the largest total $1$-value. In effect, the total $2$-value of $M_1$ estimates the total $1$-value of $M_1$. Once all nodes of $M_1$ with positive $2$-value lie on a single branch (which is chosen as the $1$-zone), we can transfer them back to $M_2$ without changing their number: because reductions between $M_2$ and $M_1$ are RMF$(2)$, every node of the $1$-zone in $M_1$ originates from a different node of $M_2$. Then in $M_2$ we again choose a branch as the $2$-zone, we assign $3$-value to some its nodes, and so on. At the end we obtain some labeling of $M_m$ by zones and values of particular orders. The goal of the type system presented below is, roughly speaking, to ensure that a labeling of $M_m$ actually is obtainable in the process as above. In fact, we do not label nodes of $M_m$ itself, but rather nodes of a type derivation for $M_m$. We now come to a formal definition of the type system. \paragraph*{Type Judgments.} For every sort $\alpha$ we define the set $\mathcal{T}^\alpha$ of \emph{types} of sort $\alpha$, and the set $\mathcal{\widehat T}}%\!\!T}^\alpha_m$ of \emph{type triples} of sort $\alpha$. This is done as follows, where $\mathcal{P}$ denotes the powerset: \begin{align*} &\mathcal{T}^{\alpha\mathbin{\to}\beta}=\mathcal{P}(\mathcal{\widehat T}}%\!\!T}_{\mathit{ord}(\alpha)}^\alpha)\times\mathcal{T}^\beta\,,\qquad \mathcal{T}^\mathsf{o}=\{\mathsf{o}\}\,,\\ &\mathcal{\widehat T}}%\!\!T}_m^\alpha= \{(Z,F,\tau)\in\{0,\dots,m\}^2\times\mathcal{T}^\alpha\mid F\leq Z+1\}\,. \end{align*} Notice that the sets $\mathcal{T}^\alpha$ and $\mathcal{\widehat T}}%\!\!T}_m^\alpha$ are finite. A type $(T,\tau)\in\mathcal{T}^{\alpha\mathbin{\to}\beta}$ is denoted as $T\mathbin{\to}\tau$. A type triple $\hat\tau=(Z,F,\tau)\in\mathcal{\widehat T}}%\!\!T}_m^\alpha$ consists of a zone order $Z$, a productivity order $F$, and a type $\tau$. In order to distinguish types from type triples, the latter are denoted by letters with a hat, like $\hat\tau$. A \emph{type judgment} is of the form $\Gamma\vdash_m M:\hat\tau$, where $\Gamma$, called a \emph{type environment}, is a set of bindings of the form $x^\alpha:\hat\sigma$ with $\hat\sigma\in\mathcal{\widehat T}}%\!\!T}^\alpha_{\mathit{ord}(\alpha)}$, and $M$ is a lambda-term, and $\hat\tau$ is a type triple of the same sort as $M$ (i.e., $\hat\tau\in\mathcal{\widehat T}}%\!\!T}^\beta_m$ when $M$ is of sort $\beta$). We assume that $M$ is homogeneous. As previously, the intuitive meaning of a type $\bigwedge T\mathbin{\to}\tau$ is that a lambda-term having this type can return a lambda-term having type $\tau$, while taking an argument for which we can derive all type triples from $T$. Moreover, in $\mathcal{T}^\mathsf{o}$ there is just one type $\mathsf{o}$, which can be assigned to every lambda-term of sort $\mathsf{o}$. Suppose that a node of a type derivation for a closed and homogeneous lambda-term $M_m$ of sort $\mathsf{o}$ is labeled by a type judgment $\Gamma\vdash_m M:\hat\tau$ with $\hat\tau=(Z,F,\tau)$. Then \begin{itemize} \item $\tau$ is the type derived for $M$; \item $\Gamma$ contains type triples that could be used for free variables of $M$ in the derivation; \item $m$ is an upper bound for the complexity of $M$ (this bound is not strict: in the proofs, it is useful to temporarily allow also lambda-terms $M$ of complexity $m+1$), and simultaneously for orders of considered zones and values; \item $Z\in\{0,\dots,m\}$ is the largest number such that for every $k\in\{0,\dots,Z\}$, the considered node of the derivation belongs to the $k$-zone; \item $F\in\{0,\dots,m\}$ is the largest number such that for every $k\in\{1,\dots,F\}$, in the imaginary lambda-term $M_k$ obtained from $M_m$ by reducing all redexes of order greater than $k$, the order-$k$ value will be positive in the subderivation starting in the considered node. \end{itemize} Notice that we always have that $Z\geq 0$, which means that every node of every derivation belongs at least to the $0$-zone. We choose zones in a derivation in such a way that for every node the set of orders $k$ of zones to which the node belongs is always of the form $\{0,\dots,Z\}$. For this reason in a type triple it is enough to have a number $Z$ (representing the set $\{0,\dots,Z\}$), instead of an arbitrary set of orders of zones. Moreover, if a node of a derivation belongs to a $k$-zone, then its parent as well; in effect, the zone order in the type triple labeling a parent cannot be smaller than in its child. Likewise, the set of orders $k$ for which the $k$-value is positive (after appropriate reductions) is always of the form $\{1,\dots,F\}$, so it is enough to remember its maximum. Moreover, if $k$-value is positive is some subderivation, then it is also positive in a larger subderivation, hence also the productivity order in the type triple labeling a parent cannot be smaller than in a child. \paragraph{Type System.} We now give the first four rules, concerning node constructors: \begin{align*} &\inferrule{}{\vdash_m \mathit{b}:(Z,0,(0,0,\r)\mathbin{\to}\top\mathbin{\to}\r)}& &\inferrule{}{\vdash_m a:(Z,\min(Z+1,m),(0,0,\r)\mathbin{\to}\r)}\\ &\inferrule{}{\vdash_m \mathit{b}:(Z,0,\top\mathbin{\to}(0,0,\r)\mathbin{\to}\r)}& &\inferrule{}{\vdash_m e:(Z,0,\r)} \end{align*} We say that the $k$-value in a node using the rule for the constant $a$ is $1$ for all $k\in\{1,\dots,Z+1\}$; for $k>Z+1$, and for the other constants the $k$-value is $0$. In the above rules we can choose $Z$ arbitrarily (from the set $\{0,\dots,m\}$), which amounts to deciding to which zones the node constructor should belong: it belongs to the $k$-zone for $k\in\{0,\dots,Z\}$. For the constant $b$ we descend only to one argument (because we want to count constants $a$ only on a single branch of the normal form). For the constant $a$ we have set the $k$-value to $1$ for all $k\in\{1,\dots,Z+1\}$, hence we set the productivity order to $Z+1$. There is an exception for $Z=m$: by definition of $\mathcal{\widehat T}}%\!\!T}_m^\alpha$, the productivity order can be at most $m$, so although the $(m+1)$-value is $1$ as well, this information is not covered by the productivity order. Notice that the type $(0,0,\r)$ assigned to arguments of node constructors is the only element of $\mathcal{\widehat T}}%\!\!T}^\mathsf{o}_{\mathit{ord}(\mathsf{o})}$; node constructors do not receive information about zones or values from their arguments. Next, we have a rule for a variable (in nodes using this rule, the $k$-value is $0$ for all $k$): \begin{mathpar} \inferrule*[right=(Var)]{(Z'=Z) \lor (Z'\geq\mathit{ord}(x)=Z)}{x:(Z,F,\tau)\vdash_m x:(Z',F,\tau)} \end{mathpar} In order to understand this rule, suppose that it labels a node of a type derivation for a closed lambda-term $M$ of sort $\mathsf{o}$. Take some $k\in\{0,\dots,m\}$, and consider the lambda-term $M_k$ obtained from our lambda-term by reducing all redexes of orders greater than $k$. According to the proof idea presented above, we create the $k$-zone as a branch of $M_k$ (and then we transfer it back to $M$). Moreover, as the productivity order we should take at least $k$ if in $M_k$ the $k$-value is positive in the subtree starting in the considered node. If $k\leq\mathit{ord}(x)$, the variable $x$ will be no longer present in $M_k$, and some lambda-term (described by the type environment) will be substituted for it. For this reason, the information about the $k$-zone and about positivity of the $k$-value is taken from the type environment. Conversely, if $k>\mathit{ord}(x)$, the node (leaf) concerning $x$ will be still present in $M_k$, and thus we can start the branch forming the $k$-zone there. But this is possible only if the node belongs to the $(k-1)$-zone; in particular for $k=\mathit{ord}(x)+1$ we need to be in the $\mathit{ord}(x)$-zone, which is the case if $Z=\mathit{ord}(x)$. Moreover, the total $k$-value in (the subtree starting in) the considered leaf is $0$, and thus the productivity order is taken from the environment (unlike in the previous type system). The rule for lambda-binders realizes a restricted variant of type weakening: we may ignore arguments that do not contain leaves of zones. This is formalized in the notion of balanced and unbalanced type triples, defined by induction on their structure. For $k\in\{0,\dots,m\}$, a type triple $(Z,F,\bigwedge T_1\mathbin{\to}\dots\mathbin{\to}\bigwedge T_n\mathbin{\to}\mathsf{o})$ is \emph{$k$-unbalanced} if $Z\geq k$ and all elements of the sets $T_1,\dots,T_n$ are $k$-balanced; otherwise, the type triple is \emph{$k$-balanced}. A type triple is \emph{unbalanced} if it is $k$-unbalanced for some $k\in\{0,\dots,m\}$; otherwise it is \emph{balanced}. Intuitively, a subderivation derives a $k$-unbalanced type triple if the unique leaf of the $k$-zone is contained either in this subderivation, or in an imaginary subderivation that will be substituted for a free variable. Indeed, the subderivation contains the leaf of the $k$-zone if it belongs to the $k$-zone, but none of the arguments provides the leaf. We can now give the rule; for nodes using this rule, the $k$-value is $0$ for all $k$. \begin{mathpar} \inferrule*[right=($\lambda$)]{ \Gamma\cup\{x:\hat\sigma\mid \hat\sigma\in T'\}\vdash_m K:(Z,F,\tau) \\ \{\hat\sigma\in T\mid \hat\sigma\mbox{ unbalanced}\}\subseteq T'\subseteq T \\ x\not\in\mathit{dom}(\Gamma) } {\Gamma\vdash_m\lambda x.K:(Z,F,\bigwedge T\mathbin{\to}\tau)} \end{mathpar} As previously, the rule for application is the most complicated one: \begin{mathpar} \inferrule*[right=$(@)$]{ \Gamma_0\vdash_m K:(Z_0,F_0,\tau_0) \\ \Gamma_i\vdash_m L:(Z_i,F_i,\tau_i)\mbox{ for each }i\in I \\ \tau_0=\bigwedge\nolimits_{i\in I}(\min(Z_i,\mathit{ord}(L)),\min(F_i,\mathit{ord}(L)),\tau_i)\mathbin{\to}\tau \and Z = \max\nolimits_{i\in\{0\}\cup I}Z_i \\ \forall k\in\{0,\dots,m\}.\,|\{i\in\{0\}\cup I\mid (Z_i,F_i,\tau_i)\mbox{ $k$-unbalanced}\}|\leq 1 } {\bigcup\nolimits_{i\in \{0\}\cup I}\Gamma_i\vdash_m K\,L:(Z,F,\tau)} \end{mathpar} where \begin{itemize} \item we assume that $0\not\in I$; \item if there is $i\in \{0\}\cup I$ such that $\mathit{ord}(L)\leq Z_i<F_i\leq Z$, then we set $F$ to $\min(Z+1,m)$, and we say that the $k$-value in the node using such a rule is $1$ for all $k\in\{F_i+1,\dots,Z+1\}$ (if there are multiple such $i$, we consider the one for which $F_i$ is the smallest); \item otherwise we set $F$ to $\max_{i\in\{0\}\cup I}F_i$, and the $k$-value to $0$ for all $k$. \end{itemize} Let us comment on the above conditions. First, notice that to the subderivation concerning $K$ we pass the information about $k$-values and $k$-zones from the subderivations concerning $L$ only for $k\leq\mathit{ord}(L)$ (i.e., we write $\min(Z_i,\mathit{ord}(L))$ and $\min(F_i,\mathit{ord}(L))$ instead of simply $Z_i$ and $F_i$). This is because, while thinking about $k$-values and about the $k$-zone, we should imagine the lambda-term $M_k$ obtained from the lambda-term under consideration by reducing all redexes of orders greater than $k$. If $k\leq\mathit{ord}(L)$, the application (for which we write the rule) is no longer present in $M_k$ (it gets reduced in some of the reductions leading to $M_k$), so we should pass the information from $L$ to $K$. Conversely, if $k>\mathit{ord}(L)$, the application is still present in $M_k$; this means $K$ and $L$ are independent subterms there, and hence the information from $L$ should not be passed to $K$. This is complementary to what we said on the \TirName{(Var)}\xspace rule. Second, we also say for every $k$ that only one child can be $k$-unbalanced. Under the intuitive meaning that a conclusion of a subderivation is $k$-unbalanced if the subderivation contains the leaf of the $k$-zone (that remains a leaf in $M_k$), this condition ensures that the $k$-zone has at most one leaf, and thus forms a branch in $M_k$. Third, observe that the $(k+1)$-value in our node is set to $1$ if, in $M_k$, it is the closest ancestor of some node with positive $k$-value that lies in the $k$-zone. Indeed, suppose that the current node is still present in $M_k$ (i.e., that $k>\mathit{ord}(L)$), and that it belongs to the $k$-zone (i.e., that $k\leq Z$). Moreover, suppose that in $M_k$ the $k$-value is positive in some node of the subderivation number $i$ (i.e., that $k\leq F_i$), where $i\in\{0\}\cup I$. If $k\leq Z_i$, then the closest ancestor being in the $k$-zone is already in the subderivation (because its root belongs to the $k$-zone). Conversely, if $k>Z_i$, the closest ancestor being in the $k$-zone is in our node. Recall that (by definition of type triples) we always have $F_i\leq Z_i+1$. All the inequalities hold when $\mathit{ord}(L)+1\leq Z_i+1=k=F_i\leq Z$, and this is exactly the situation when we set the $(k+1)$-value of the current node to $1$. If the node is also in the $(k+1)$-zone (i.e., if $k+1\leq Z$), then the closest ancestor being in the $(k+1)$-zone is in the node itself. It thus makes sense that we also set the $(k+2)$-value of the current node to $1$. Repeating this again, we should set to $1$ the values of all orders in $\{k+1,\dots,Z+1\}$. Denoting the $k$-value of a derivation $D$ by $\mathit{val}^k(D)$, we can state the desired properties of our type system. \begin{theorem}\label{thm:nondet} The following holds for the type system introduced above: \begin{compactenum}[(N1$''$)] \item\label{it:n1pp} if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$, and $D$ is a derivation for $\vdash_m M:(m,m,\r)$, then the number of constants $a$ on some branch of the normal form of $M$ is at least $\mathit{val}^{m+1}(D)$; \item\label{it:n2pp} for every $m\in\mathbb{N}$ there is a function $\eta_m\colon\mathbb{N}\to\mathbb{N}$ such that if $M$ is a homogeneous and closed lambda-term of sort $\mathsf{o}$ and complexity at most $m$, and on some branch of the beta-normal form of $M$ there are $n\geq 1$ appearances of the constant $a$, then there is a derivation $D$ for $\vdash_m M:(m,m,\r)$ such that $n\leq\eta_m(\mathit{val}^{m+1}(D))$. \end{compactenum} \end{theorem} \begin{example}\label{ex:2} Let us consider the same lambda-term as in Example~\ref{ex:1}, namely $M=(\lambda y.N\,(N\,(N\,y))\,(a\,e))\,a$ with $N=\lambda y.\lambda x.y\,(y\,x)$. As $m$ we take its complexity, that is, $2$. Notice that after performing all beta-reductions of order $2$, we obtain the lambda-term $M_1=(\lambda x.N_2\,(N_2\,x))\,(a\,e)$ with $N_2=\lambda x.N_1\,(N_1\,x)$ and $N_1=\lambda x.a\,(a\,x)$. In this term, the $1$-zone, which has to be a branch, can descend into one of the subterms $N_2$, then into one of the subterms $N_1$, and then it can finish in one of the constants $a$. In effect, while typing $M$, we need two derivations for $N$, one where the lambda-term belongs to the $1$-zone, and one where it does not. Denote $\tau_y=(0,0,\r)\mathbin{\to}\r$. Outside of the $1$-zone, we only pass (from the argument) the information that the $1$-value is positive: \begin{mathpar} \inferrule*[Right=$(\lambda)$,leftskip=-8.5em,rightskip=-13.8em]{ \inferrule*[Right=$(\lambda)$,leftskip=1.6em,rightskip=1.6em]{ \inferrule*[Right=$(@)$,leftskip=6.9em,rightskip=6.9em]{ y:(0,1,\tau_y)\vdash_2 y:(0,1,\tau_y) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ y:(0,1,\tau_y)\vdash_2 y:(0,1,\tau_y) \and x:(0,0,\r)\vdash_2 x:(0,0,\r) }{ y:(0,1,\tau_y),\,x:(0,0,\r)\vdash_2 y\,x:(0,1,\r) } }{ y:(0,1,\tau_y),\,x:(0,0,\r)\vdash_2 y\,(y\,x):(0,1,\r) } }{ y:(0,1,\tau_y)\vdash_2\lambda x.y\,(y\,x):(0,1,\tau_y) } }{ \vdash_2 N:(0,1,(0,1,\tau_y)\mathbin{\to}\tau_y) } \end{mathpar} Notice that in the second (i.e., lower) node using the \TirName{(\!@\!)}\xspace rule, the function of type $\tau_y$, that is $(0,0,\r)\mathbin{\to}\r$, accepts an argument with type triple $(0,1,\r)$. This is correct, because according to the \TirName{(\!@\!)}\xspace rule, the function receives the information only about zones and values of order not greater than the order of the argument, which is $0$ in our case, and indeed we have $(\min(0,0),\min(1,0),\r)=(0,0,\r)$. Let us now see what happens inside the $1$-zone: \begin{mathpar} \inferrule*[Right=$(\lambda)$,leftskip=-6.1em,rightskip=-11.4em]{ \inferrule*[Right=$(\lambda)$,leftskip=1.6em,rightskip=1.6em]{ \inferrule*[Right=$(@)$,leftskip=4.5em,rightskip=4.5em]{ y:(0,1,\tau_y)\vdash_2 y:(0,1,\tau_y) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ y:(1,1,\tau_y)\vdash_2 y:(1,1,\tau_y) \and x:(0,0,\r)\vdash_2 x:(0,0,\r) }{ y:(1,1,\tau_y),\,x:(0,0,\r)\vdash_2 y\,x:(1,1,\r) } }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y),\,x:(0,0,\r)\vdash_2 y\,(y\,x):(1,2,\r) } }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2\lambda x.y\,(y\,x):(1,2,\tau_y) } }{ \vdash_2 N:(1,2,(0,1,\tau_y)\wedge(1,1,\tau_y)\mathbin{\to}\tau_y) } \end{mathpar} In the second (i.e., lower) node using the \TirName{(\!@\!)}\xspace rule, the information about a positive $1$-value (coming from the left subderivation) meets the $1$-zone (coming from the right subderivation), and thus the $2$-value of this node is $1$. Denoting the type $(0,1,\tau_y)\mathbin{\to}\tau_y$ as $\tau^0_N$ and $(0,1,\tau_y)\wedge(1,1,\tau_y)\mathbin{\to}\tau_y$ as $\tau_N^1$, we continue the derivation for $M$. We choose to start the $2$-zone in a leaf concerning $y$. \begin{mathpar} \inferrule*[right=$(@)$]{ \vdash_2 N:(1,2,\tau_N^1) \and y:(0,1,\tau_y)\vdash_2 y:(0,1,\tau_y) \and y:(1,1,\tau_y)\vdash_2 y:(2,1,\tau_y) }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,y:(2,2,\tau_y) } \end{mathpar} This results in having a node with $3$-value $1$. As we want to continue in the same way with $N\,(N\,y)$ and $N\,(N\,(N\,y))$, we need to derive $(0,1,\tau_y)$ for $N\,y$ and $N\,(N\,y)$ (which describes the situation outside of the $1$-zone): \begin{mathpar} \inferrule*[Right=$(@)$,rightskip=-5.3em]{ \vdash_2 N:(0,1,\tau_N^0) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.3em]{ \vdash_2 N:(0,1,\tau_N^0) \and y:(0,1,\tau_y)\vdash_2 y:(0,1,\tau_y) }{ y:(0,1,\tau_y)\vdash_2 N\,y:(0,1,\tau_y) } }{ y:(0,1,\tau_y)\vdash_2 N\,(N\,y):(0,1,\tau_y) } \end{mathpar} We continue as follows, obtaining two more nodes with $3$-value $1$: \begin{mathpar} \inferrule*[right=$(@)$]{ \vdash_2 N:(1,2,\tau_N^1) \and y:(0,1,\tau_y)\vdash_2 N\,y:(0,1,\tau_y) \and y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,y:(2,2,\tau_y) }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,y):(2,2,\tau_y) } \and \inferrule*[right=$(@)$]{ \vdash_2 N:(1,2,\tau_N^1) \and\hspace{-10.4pt} y:(0,1,\tau_y)\vdash_2 N\,(N\,y):(0,1,\tau_y) \and\hspace{-10.4pt} y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,y):(2,2,\tau_y) }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,(N\,y)):(2,2,\tau_y) } \end{mathpar} Next we apply the argument $a\,e$, obtaining one more node with $3$-value $1$: \begin{mathpar} \inferrule*[Right=$(@)$,leftskip=0em,rightskip=-5.5em]{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,(N\,y)):(2,2,\tau_y) \and \inferrule*[right=$(@)$,leftskip=1em,rightskip=5.5em]{ \vdash_2 a:(0,1,\tau_y) \and \vdash_2 e:(0,0,\r) }{ \vdash_2 a\,e:(0,1,\r) } }{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,(N\,y))\,(a\,e):(2,2,\tau_y) } \end{mathpar} In the last part of the derivation we also have a node with $3$-value $1$: \begin{mathpar} \inferrule*[right=$(@)$]{ \inferrule*[right=$(\lambda)$,rightskip=1em]{ y:(0,1,\tau_y),\,y:(1,1,\tau_y)\vdash_2 N\,(N\,(N\,y))\,(a\,e):(2,2,\tau_y) }{ \vdash_2\lambda y.N\,(N\,(N\,y))\,(a\,e):(2,2,(0,1,\tau_y)\wedge(1,1,\tau_y)\mathbin{\to}\r) } \and \vdash_2 a:(0,1,\tau_y) \and \vdash_2 a:(1,2,\tau_y) }{ \vdash_2 M:(2,2,\r) } \end{mathpar} As in Example~\ref{ex:1}, the total $3$-value of the derivation is $5$, and by adding any further $N$ to the sequence $N\,(N\,(N\,y))$, we can increase the $3$-value by $1$. \end{example} \begin{example}\label{ex:br} Let us also illustrate on a very simple example how the rule for the constant $b$ behaves: \begin{mathpar} \inferrule*[right=$(@)$,leftskip=-5.8em,rightskip=-7.7em]{ \inferrule*[right=$(@)$,leftskip=5.8em,rightskip=7.7em]{ \vdash_2 b:(0,0,(0,0,\r)\to\top\to\r) \and \vdash_2 M:(2,2,\r) }{ \vdash_2 b\,M:(2,2,\top\to\r) } }{ \vdash_2 b\,M\,e:(2,2,\r) } \end{mathpar} We thus simply ignore one of the arguments of $b$. Notice that in the second use of the application rule does not require any subderivations for the argument. \end{example} \paragraph*{Proofs.} Let us now sketch the proof of Theorem~\ref{thm:nondet}. Condition~\hyperref[it:n1pp]{(N1$''$)} is based on the following two lemmata. \begin{lemma}\label{lem:decrease-m} Let $M$ be a closed lambda-term of sort $\mathsf{o}$ and complexity at most $m+1$. If $D_{m+1}$ is a derivation for $\vdash_{m+1} M:(m+1,m+1,\mathsf{o})$, then there exists a derivation $D_m$ for $\vdash_m M:(m,m,\mathsf{o})$ with $\mathit{val}^{m+1}(D_m)\geq\mathit{val}^{m+2}(D_{m+1})$. \end{lemma} \begin{lemma}\label{lem:s-step} Let $M$ be a homogeneous and closed lambda-term of sort $\mathsf{o}$, and let $M\to_\beta N$ be an RMF$(m+1)$ reduction. If $D$ is a derivation for $\vdash_m M:(m,m,\mathsf{o})$, then there exists a derivation $E$ for $\vdash N:(m,m,\mathsf{o})$ with the same $(m+1)$-value. \end{lemma} Condition~\hyperref[it:n2pp]{(N2$''$)} is based on two symmetric lemmata. \begin{lemma}\label{lem:c-step} Let $M$ be a homogeneous and closed lambda-term of sort $\mathsf{o}$, and let $M\to_\beta N$ be an RMF$(m+1)$ reduction. If $E$ is a derivation for $\vdash_m N:(m,m,\mathsf{o})$, then there exists a derivation $D$ for $\vdash M:(m,m,\mathsf{o})$ with the same $(m+1)$-value. \end{lemma} \begin{lemma}\label{lem:increase-m} If $D_m$ is a derivation for $\vdash_m M:(m,m,\mathsf{o})$, then there exists a derivation $D_{m+1}$ for $\vdash_{m+1} M:(m+1,m+1,\mathsf{o})$ with $\mathit{val}^{m+2}(D_{m+1})\geq\log_3(\mathit{val}^{m+1}(D_m))$. \end{lemma} Theorem~\ref{thm:nondet} is easily implied. Indeed, consider a homogeneous and closed lambda-term $M_m=M$ of sort $\mathsf{o}$ and complexity at most $m$, its normal-form $M_0$, and lambda-terms $M_{m-1},M_{m-2},\dots,M_1$ such that all reductions between $M_i$ and $M_{i-1}$ are RMF$(i)$. In Condition~\hyperref[it:n1pp]{(N1$''$)} we start with a derivation $D_m$ for $\vdash_m M_m:(m,m,\r)$. Then, repeatedly for every $i=m-1,m-2,\dots,0$ we first apply Lemma~\ref{lem:decrease-m} to $D_{i+1}$ (with conclusion $\vdash_{i+1} M_{i+1}:(i+1,i+1,\mathsf{o})$) obtaining a derivation $D_i'$ for $\vdash_i M_{i+1}:(i,i,\mathsf{o})$ with $(i+1)$-value not smaller than the $(i+2)$-value of $D_{i+1}$, and next we apply Lemma~\ref{lem:s-step} to every RMF$(i)$-reduction between $M_{i+1}$ and $M_i$, obtaining a derivation $D_i$ for $\vdash_i M_i:(i,i,\mathsf{o})$ with the same $(i+1)$-value as $D_i'$. In effect, we obtain a derivation $D_0$ for $\vdash_0 M_0:(0,0,\r)$ with $1$-value not smaller than the $(m+1)$-value of the original derivation $D_m$. We conclude by observing that $D_0$ simply follows some branch of $M_0$, and that its $1$-value equals the number of constants $a$ on that branch. Conversely, while proving Condition~\hyperref[it:n2pp]{(N2$''$)}, at the beginning we construct a derivation $D_0$ for $\vdash_0 M_0:(0,0,\r)$, following some branch of $M_0$; the $1$-value of this derivation equals the number of constants $a$ on the considered branch. Then, repeatedly for every $i\in\{0,\dots,m-1\}$ we first apply Lemma~\ref{lem:c-step} for every RMF$(i)$-reduction between $M_{i+1}$ and $M_i$, obtaining a derivation $D_i'$ for $\vdash_i M_{i+1}:(i,i,\mathsf{o})$ with the same $(i+1)$-value as $D_i$, and next we apply Lemma~\ref{lem:increase-m} to $D_i'$ obtaining a derivation $D_{i+1}$ for $\vdash_{i+1} M_{i+1}:(i+1,i+1,\mathsf{o})$ with $(i+2)$-value at most logarithmically smaller than the $(i+1)$-value of $D_i$. In effect, we obtain a derivation $D_m$ for $\vdash_m M_m:(m,m,\r)$ with $(m+1)$-value dominating the number of constants $a$ on the selected branch of the beta-normal form $M_0$. It remains to prove the lemmata. In Lemma~\ref{lem:decrease-m} we are given a derivation $D_{m+1}$ (of order $m+1$) concerning a lambda-term of complexity at most $m+1$. In such a derivation, a node has positive $(m+2)$-value (equal $1$) if it is the closest ancestor of a node with positive $(m+1)$-value that is in the $(m+1)$-zone (because all variables are of order at most $m$, the information about positive $(m+1)$-values is not passed through type environments). Of course every node has only one closest ancestor that is in the $(m+1)$-zone, thus the total $(m+2)$-value is not greater than the total $(m+1)$-value. Having this, we decrease the order of the derivation to $m$, by simply forgetting about $(m+2)$-values and about the $(m+1)$-zone; the total $(m+1)$-value remains unchanged. Lemmata~\ref{lem:s-step} and~\ref{lem:c-step} can be shown by performing appropriate surgeries on the derivations, like in Section~\ref{sec:deterministic}. One has to observe there that if a subderivation (for a lambda-term of order $m$) derives a balanced type triple, then its $(m+1)$-value is $0$, and its type environment can contain only bindings with balanced type triples. In effect, we can treat subderivations deriving balanced and unbalanced type triples differently. Namely, subderivations deriving balanced type triples can be harmlessly removed or duplicated. Indeed, on the one hand, these operations do not change the total $(m+1)$-value. On the other hand, while removing such a subderivation, only bindings with balanced type triples are removed from type environments; this does not cause problems in nodes using the \TirName{($\lambda$)}\xspace rule, because this rule allows to drop some balanced type triples. On the other hand, for every $k$ the surgery wants to move at most one subderivation deriving a $k$-unbalanced type triple, so no removal or duplication is needed for such subderivations. In Lemma~\ref{lem:increase-m}, we have to add an $(m+1)$-zone to a derivation of order $m$. Starting from the root of the derivation, we repeatedly descend to the subderivation in which the total $(m+1)$-value is the greatest (arbitrarily in the case of a tie); the branch created in this way is taken as the $(m+1)$-zone. If, while descending from some node to its child, the total $(m+1)$-value decreases (i.e., either the node itself has $(m+1)$-value $1$, or a subderivation starting in some other child also has a positive $(m+1)$-value), then the node gets positive $(m+2)$-value: it is the closest ancestor of some node with positive $(m+1)$-value that is in the $(m+2)$-zone. This can happen only in the case of the \TirName{(\!@\!)}\xspace rule. In the \TirName{(\!@\!)}\xspace rule one may observe that if a subderivation derives an $m$-balanced type triple for the argument, then its total $(m+1)$-value is $0$. We can thus have at most two subderivations (among those starting in children) with positive $(m+1)$-value: one for the operand, and one concerning an $m$-unbalanced type triple for the argument. In consequence, while descending to a subderivation, the total $(m+1)$-value decreases at most three times (with the exception that it can decrease from $1$ to $0$). It follows that the total $(m+2)$-value is at least logarithmic in the total $(m+1)$-value. \paragraph*{Extension to Recursion Schemes.} Theorem~\ref{thm:nondet} can be also stated for infinite lambda-terms (hence, in particular, for regular infinite lambda-terms represented in a finite way by recursion schemes). The assumption is that we consider there only finite type derivations, and only finite branches of the generated tree (i.e., branches ending in a leaf). Notice that a type derivation for an infinite lambda-term can be finite, because a derivation does not need to descend to every subterm of the lambda-term. We claim that, under these assumptions, Theorem~\ref{thm:nondet} is true for infinite lambda-terms. To see this, consider a new constant $\bot$ of sort $\mathsf{o}$; it differs from $e$ in that we do not have a typing rule for $\bot$. A \emph{cut} of a lambda-term $M$ is a lambda-term obtained from $M$ by replacing some its subterms with lambda-terms of the form $\lambda x_1.\cdots{}.\lambda x_k.\bot$ (the number of the variables and their sorts are chosen so that the sort of the subterm does not change). It is easy to see that there is a finite derivation for $\vdash_m M:\hat\tau$ if and only if for some its finite cut $M'$ there is a derivation for $\vdash_m M':\hat\tau$, having the same values (we can cut off subterms not involved in the derivation). Likewise, the tree generated by a closed lambda-term $M$ of sort $\mathsf{o}$ contains some finite branch $B$, if and only if the tree generated by some finite cut $M'$ of $M$ contains the same branch $B$ (the finite branch is generated after finitely many beta-reductions, concerning only a top part of $M$, and subterms located deeper in $M$ can be cut off). This way, the infinitary version of Theorem~\ref{thm:nondet} can be reduced to the original statement concerning finite lambda-terms. Because in a single infinite tree we can have branches with arbitrarily many constants $a$, it makes sense to give the following direct corollary of Theorem~\ref{thm:nondet}. \begin{corollary}\label{cor:diag} The following conditions are equivalent for a homogeneous and closed (potentially infinite) lambda-term $M$ of sort $\mathsf{o}$: \begin{compactitem} \item for every $n\in\mathbb{N}$, in the tree generated by $M$ there exists a branch with at least $n$ appearances of the constant $a$, and \item for every $n\in\mathbb{N}$, there exists a derivation for $\vdash_m M:(m,m,\r)$ with $(m+1)$-value at least $n$. \end{compactitem} \end{corollary} Because the latter condition is easily decidable for lambda-terms represented by recursion schemes, the corollary implies decidability of the former condition. \paragraph*{Bibliographic Note.} The type system presented in this section is essentially taken from Parys~\cite{itrs}; we have applied some cosmetic changes, though. In Parys~\cite{diagonal-types} the type system is extended to the task of counting multiple constants: the $(m+1)$-value is not a number, but a tuple, where each coordinate of the tuple estimates the number of appearances of a particular constant. In particular, Corollary~\ref{cor:diag} is extended there to the property ``for every $n\in\mathbb{N}$, in the tree generated by $M$ there exists a branch with at least $n$ appearances of every constant from a set $A$'', giving its decidability. Deciding this property is known under the names \emph{simultaneous unboundedness problem} (SUP) and \emph{diagonal problem} (these are two different names for the same problem). SUP for recursion schemes was first solved in Clemente, Parys, Salvati, and Walukiewicz~\cite{downward-closure}, in a different way. The advantage of solving SUP using the type system presented here is twofold. First, the solution via the type system allows to obtain the optimal complexity, while the complexity of the original solution was much worse. Second, using the type system we can obtain so-called \emph{SUP reflection}: we can solve SUP simultaneously for all subtrees of the generated tree. More precisely, out of a recursion scheme we can create a new recursion scheme that generates a tree of the same shape as the original one, but such that the label of every node contains additionally the answer to SUP in the subtree starting in that node (i.e., the information whether in that node there start branches with arbitrarily many appearances of every constant from a set $A$). SUP reflection allowed to solve the model-checking problem for trees generated by recursion schemes against formulae of the WMSO+U logic~\cite{wmsou-schemes}. This logic extends WMSO (a fragment of MSO in which one can quantify only over finite sets) by the unbounding quantifier, $\mathsf U$. A formula using this quantifier, $\mathsf U X.\,\varphi$, says that $\varphi$ holds for arbitrarily large finite sets $X$. Let us also remark that decidability of SUP implies that given a language defined by a nondeterministic recursion scheme, it is possible to compute its downward closure~\cite{Zetzsche-down-clo}, and given two such languages, it is possible to decide whether they can be separated by a piecewise testable language~\cite{Czerwinski-piecewise}. The type system presented here is also used by Asada and Kobayashi~\cite{koba-pumping-new} in their work on a pumping lemma for recursion schemes. The type system was inspired by the previous solution of SUP by Clemente et al.~\cite{downward-closure}. The idea of having balanced and unbalanced type triples, and treating them differently in type environments, comes from Asada and Kobayashi~\cite{word2tree}. \section{Branching Quantities} Finally, we shortly mention one more quantity to be considered. In this part, suppose that the constant $a$ is of sort $\mathsf{o}\mathbin{\to}\mathsf{o}\mathbin{\to}\mathsf{o}$, that is, nodes with label $a$ have two children. For $n\in\mathbb{N}$, let $A_n$ be the full binary tree of height $n$, with all internal nodes labeled by $a$, and all leaves labeled by $e$. We say that $A_n$ \emph{embeds homeomorphically} in a tree $T$ if $T$ has a subtree of the form $T=a\,T_1\,T_2$ such that $A_{n-1}$ embeds in both $T_1$ and $T_2$ (defined by induction); $A_0=e$ embeds homeomorphically in every tree having a leaf labeled by $e$. Having a tree $T$ one may want to find the maximal height $n$ of a tree $A_n$ that embeds homeomorphically in $T$. It is an open problem how to estimate this quantity using a type system (or in any other way). \begin{openpr}\label{op:2} Design a type system such that the maximal value (appropriately defined) of a type derivation for a closed lambda-term $M$ of sort $\mathsf{o}$ estimates the maximal number $n$ such that $A_n$ embeds homeomorphically in the beta-normal form of $M$. \end{openpr} Like in Section~\ref{sec:nondeterministic} (cf.\ Corollary~\ref{cor:diag}), existence of such a type system would solve the following problem concerning infinite lambda-terms represented by recursion schemes. \begin{openpr}\label{op:3} Given a recursion scheme, decide whether for every $n$ the tree $A_n$ embeds homeomorphically in the (infinite) tree generated by the scheme. \end{openpr} A naive idea is to take the type system from Section~\ref{sec:nondeterministic}, and to change the rule for a constant $a$ into $\vdash_m a:(Z,\min(Z+1,m),(0,0,\r)\mathbin{\to}(0,0,\r)\mathbin{\to}\r)$. Notice, though, that if we derive a type for a tree $T$ using such a type system, the value of the derivation counts the maximal number of constants $a$ in a tree that embeds homeomorphically in $T$. This is not what we want since, for example, if all $a$ are located on a single branch, then their number can be arbitrarily large while only $A_1$ can be embedded. In other words, we add values from the two children of an $a$-labeled node, while we should take their minimum. It seems that Open Problems~\ref{op:2} and~\ref{op:3} are closely related to the problem of computing the downward closures of languages of finite trees generated by nondeterministic recursion schemes (we remark that the downward closure of every language of finite trees is a regular language, due to the Kruskal's tree theorem). If we want to compute the downward closure of a language, we have to decide in particular whether it contains trees $A_n$ for all $n\in\mathbb{N}$, that is, whether all $A_n$ embed homeomorphically in trees from the language. Like in the case of words, downward closures are also related to the problem of deciding whether two languages can be separated by a piecewise testable language. Goubault-Larrecq and Schmitz~\cite{schmitz-kruskal} derive a general framework for solving the piecewise testable separability for languages of trees. It is highly probable that Open Problem~\ref{op:3} can be solved for a subclass of recursion schemes, called safe recursion schemes, using methods from Blumensath, Colcombet, Kuperberg, Parys, and Vanden Boom~\cite{quasi-weak}. This requires further investigation. \bibliographystyle{eptcs}
{'timestamp': '2019-04-24T02:04:42', 'yymm': '1904', 'arxiv_id': '1904.10105', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10105'}
arxiv
\section{Introduction} Termination of higher-order term rewriting systems~\cite[Chapter~11]{Terese2003} has been an active area of research for several decades. One powerful method, introduced by v.d. Pol \cite{Pol1993,pol:96}, interprets terms into \emph{weakly monotonic algebras}. In later work \cite{FuhsKop2012,Kop2012}, these algebra interpretations are specialised into \emph{higher-order polynomial interpretations}, a generalisation of the popular -- and highly automatable -- technique of polynomial interpretations for first-order term rewriting. The methods of weakly monotonic algebras and polynomial interpretation are both limited to \emph{monomorphic} systems. In this paper, we will further generalise polynomial interpretations to a higher-order formalism with full impredicative polymorphism. This goes beyond shallow (rank-1, weak) polymorphism, where type quantifiers are effectively allowed only at the top of a type: it would be relatively easy to extend the methods to a system with shallow polymorphism since shallowly polymorphic rules can be seen as defining an infinite set of monomorphic rules. While shallow polymorphism often suffices in functional programming practice, there do exist interesting examples of rewrite systems which require higher-rank impredicative polymorphism. For instance, in recent extensions of Haskell one may define a type of heterogeneous lists. \[ \begin{array}{ll} \mathtt{List} : * & \mathtt{foldl}_\sigma(f,a,\mathtt{nil}) \longrightarrow a \\ \mathtt{nil} : \mathtt{List} & \mathtt{foldl}_\sigma(f,a,\mathtt{cons}_\tau(x,l)) \longrightarrow \mathtt{foldl}_\sigma(f,f \tau a x,l) \\ \mathtt{cons} : \forall \alpha . \alpha \rightarrow \mathtt{List} \rightarrow \mathtt{List} \quad\quad \\ \multicolumn{2}{l}{\mathtt{foldl} : \forall \beta . (\forall \alpha . \beta \rightarrow \alpha \rightarrow \beta) \rightarrow \beta \rightarrow \mathtt{List} \rightarrow \beta} \end{array} \] The above states that $\mathtt{List}$ is a type ($*$), gives the types of its two constructors $\mathtt{nil}$ and $\mathtt{cons}$, and defines the corresponding fold-left function~$\mathtt{foldl}$. Each element of a heterogeneous list may have a different type. In practice, one would constrain the type variable~$\alpha$ with a type class to guarantee the existence of some operations on list elements. The function argument of~$\mathtt{foldl}$ receives the element together with its type. The $\forall$-quantifier binds type variables: a term of type $\forall \alpha . \tau$ takes a type~$\rho$ as an argument and the result is a term of type~$\tau[\subst{\alpha}{\rho}]$. Impredicativity of polymorphism means that the type itself may be substituted for its own type variable, e.g., if $\mathtt{f} : \forall \alpha . \tau$ then $f (\forall \alpha . \tau) : \tau[\subst{\alpha}{\forall\alpha.\tau}]$. Negative occurrences of impredicative type quantifiers prevent a translation into an infinite set of simply typed rules by instantiating the type variables. The above example is not directly reducible to shallow polymorphism as used in the~ML programming language. \medskip\noindent\textbf{Related work.} The term rewriting literature has various examples of higher-order term rewriting systems with some forms of polymorphism. To start, there are several studies that consider shallow polymorphic rewriting (e.g., \cite{ham:18,jou:rub:07,wah:04}), where (as in ML-like languages) systems like $\mathtt{foldl}$ above cannot be handled. Other works consider extensions of the $\lambda\Pi$-calculus \cite{cou:dow:07,dow:17} or the calculus of constructions \cite{bla:05,wal:03} with rewriting rules; only the latter includes full impredicative polymorphism. The termination techniques presented for these systems are mostly syntactic (e.g., a recursive path ordering \cite{jou:rub:07,wal:03}, or general schema \cite{bla:05}), as opposed to our more semantic method based on interpretations. An exception is \cite{dow:17}, which defines interpretations into $\Pi$-algebras; this technique bears some similarity to ours, although the methodologies are quite different. A categorical definition for a general polymorphic rewriting framework is presented in \cite{fio:ham:13}, but no termination methods are considered for it. \medskip\noindent\textbf{Our approach.} The technique we develop in this paper operates on \emph{Polymorphic Functional Systems (PFSs)}, a form of higher-order term rewriting systems with full impredicative polymorphism (Section \ref{sec_systems}), that various systems of interest can be encoded into (including the example of heterogeneous fold above). Then, our methodology follows a standard procedure: \begin{itemize} \item we define a well-ordered set $(\mathcal{I},\succ,\succeq)$ (Section \ref{sec:World}); \item we provide a general methodology to map each PFS term $s$ to a natural number $\interpret{s}$, parameterised by a core interpretation for each function symbol (Section \ref{sec_reduction_pairs}); \item we present a number of lemmas to make it easy to prove that $s \succ t$ or $s \succeq t$ whenever $s$ reduces to $t$ (Section \ref{sec_rule_removal}). \end{itemize} Due to the additional complications of full polymorphism, we have elected to only generalise higher-order polynomial interpretations, and not v.d. Pol's weakly monotonic algebras. That is, terms of base type are always interpreted to natural numbers and all functions are interpreted to combinations of addition and multiplication. We will use the system of heterogeneous fold above as a running example to demonstrate our method. However, termination of this system can be shown in other ways (e.g., an enco\-ding in System~$\mathtt{F}$). Hence, we will also study a more complex example in Section~\ref{sec:examples}: termination of a substantial fragment of~IPC2, i.e., full intuitionistic second-order propositional logic with permutative conversions. Permutative conversions~\cite[Chapter~6]{TroelstraSchwichtenberg1996} are used in proof theory to obtain ``good'' normal forms of natural deduction proofs, which satisfy e.g.~the subformula property. Termination proofs for systems with permutative conversions are notoriously tedious and difficult, with some incorrect claims in the literature and no uniform methodology. It is our goal to make such termination proofs substantially easier in the future. \onlypaper{Complete proofs for the results in this paper are available in an online appendix.~\cite{versionwithappendix}.}% \onlyarxiv{This is a pre-publication copy of a paper at FSCD 2019. In particular, it contains an appendix with complete proofs for the results in this paper.} \section{Preliminaries}\label{sec_preliminaries} In this section we recall the definition of System~$\mathtt{F}_\omega$ (see e.g.~\cite[Section~11.7]{SorensenUrzyczyn2006}), which will form a basis both of our interpretations and of a general syntactic framework for the investigated systems. In comparison to System~$\mathrm{F}$, System~$\mathtt{F}_\omega$ includes type constructors which results in a more uniform treatment. We assume familiarity with core notions of lambda calculi such as substitution and $\alpha$-conversion. \begin{defn}\label{def_types} \emph{Kinds} are defined inductively: $*$ is a kind, and if $\kappa_1,\kappa_2$ are kinds then so is $\kappa_1 \Rightarrow \kappa_2$. We assume an infinite set~$\mathcal{V}_\kappa$ of \emph{type constructor variables} of each kind~$\kappa$. Variables of kind~$*$ are \emph{type variables}. We assume a fixed set~$\Sigma^T_\kappa$ of \emph{type constructor symbols} paired with a kind~$\kappa$, denoted $c : \kappa$. % We define the set~$\mathcal{T}_\kappa$ of \emph{type constructors} of kind~$\kappa$ by the following grammar. Type constructors of kind~$*$ are \emph{types}. \[ \begin{array}{rcl} \mathcal{T}_{*} &::=& \mathcal{V}_{*} \mid \Sigma^T_{*} \mid \mathcal{T}_{\kappa\Rightarrow *}\mathcal{T}_{\kappa} \mid \forall\mathcal{V}_\kappa\mathcal{T}_* \mid \mathcal{T}_*\rightarrow\mathcal{T}_* \\ \mathcal{T}_{\kappa_1\Rightarrow\kappa_2} &::=& \mathcal{V}_{\kappa_1\Rightarrow\kappa_2} \mid \Sigma^T_{\kappa_1\Rightarrow\kappa_2} \mid \mathcal{T}_{\kappa\Rightarrow(\kappa_1\Rightarrow\kappa_2)}\mathcal{T}_{\kappa} \mid \lambda \mathcal{V}_{\kappa_1} \mathcal{T}_{\kappa_2} \end{array} \] We use the standard notations $\forall \alpha . \tau$ and $\lambda \alpha . \tau$. When $\alpha$ is of kind $\kappa$ then we use the notation $\forall \alpha : \kappa . \tau$. If not indicated otherwise, we assume~$\alpha$ to be a type variable. We treat type constructors up to $\alpha$-conversion. \begin{example} If $\Sigma^T_{*} = \{ \mathtt{List} \}$ and $\Sigma^T_{* \Rightarrow * \Rightarrow *} = \{ \mathtt{Pair} \}$, types are for instance $\mathtt{List}$ and $\forall \alpha.\mathtt{Pair}\,\alpha\,\mathtt{List}$. The expression $\mathtt{Pair}\,\mathtt{List}$ is a type constructor, but not a type. If $\Sigma^T_{(* \Rightarrow *) \Rightarrow *} = \{ \exists \}$ and $\sigma \in \mathcal{T}_{* \Rightarrow *}$, then both $\exists(\sigma)$ and $\exists (\lambda \alpha.\sigma\alpha)$ are types. \end{example} The compatible closure of the rule $(\lambda\alpha.\varphi)\psi \to \varphi[\alpha := \psi]$ defines $\beta$-reduction on type constructors. As type constructors are (essentially) simply-typed lambda-terms, their $\beta$-reduction terminates and is confluent; hence every type constructor~$\tau$ has a unique $\beta$-normal form~$\mathrm{nf}_\beta(\tau)$. A \emph{type atom} is a type in $\beta$-normal form which is neither an arrow $\tau_1\rightarrow\tau_2$ nor a quantification $\forall\alpha.\tau$. We define $\mathrm{FTV}(\varphi)$ -- the set of free type constructor variables of the type constructor~$\varphi$ -- in an obvious way by induction on~$\varphi$. A type constructor~$\varphi$ is \emph{closed} if $\mathrm{FTV}(\varphi) = \emptyset$. We assume a fixed type symbol~$\chi_* \in \Sigma^T_*$. For $\kappa=\kappa_1\Rightarrow\kappa_2$ we define $\chi_\kappa = \lambda \alpha:\kappa_1 . \chi_{\kappa_2}$. \end{defn} \begin{defn}\label{def_preterms} We assume given an infinite set $\mathcal{V}$ of variables, each paired with a type, denoted $x : \tau$. We assume given a fixed set $\Sigma$ of \emph{function symbols}, each paired with a closed type, denoted $\mathtt{f} : \tau$. Every variable~$x$ and every function symbol $\mathtt{f}$ occurs only with one type declaration. The set of \emph{preterms} consists of all expressions~$s$ such that $s : \sigma$ can be inferred for some type $\sigma$ by the following clauses: \begin{itemize} \item $x : \sigma$ for $(x : \sigma) \in \mathcal{V}$. \item $\mathtt{f} : \sigma$ for all $(\mathtt{f} : \sigma) \in \Sigma$. \item $\abs{x:\sigma}{s} : \sigma \rightarrow \tau$ if $(x : \sigma) \in \mathcal{V}$ and $s : \tau$. \item $(\tabs{\alpha:\kappa}{s}) : (\quant{\alpha:\kappa}{\sigma})$ if $s : \sigma$ and $\alpha$ does not occur free in the type of a free variable of~$s$. \item $\app{s}{t} : \tau$ if $s : \sigma \rightarrow \tau$ and $t : \sigma$ \item $\tapp{s}{\tau} : \sigma[\subst{\alpha}{\tau}]$ if $s : \quant{\alpha:\kappa}{\sigma}$ and~$\tau$ is a type constructor of kind~$\kappa$, \item $s : \tau$ if $s : \tau'$ and $\tau =_\beta \tau'$. \end{itemize} The set of free variables of a preterm~$t$, denoted $\mathrm{FV}(t)$, is defined in the expected way. Analogously, we define the set~$\mathrm{FTV}(t)$ of type constructor variables occurring free in~$t$. If $\alpha$ is a type then we use the notation $\tabs{\alpha}{t}$. We denote an occurrence of a variable~$x$ of type~$\tau$ by~$x^\tau$, e.g.~$\lambda x : \tau\rightarrow\sigma . x^{\tau\rightarrow\sigma}y^\tau$. When clear or irrelevant, we omit the type annotations, denoting the above term by~$\lambda x . x y$. Type substitution is defined in the expected way except that it needs to change the types of variables. Formally, a type substitution changes the types associated to variables in~$\mathcal{V}$. We define the equivalence relation~$\equiv$ by: $s \equiv t$ iff $s$ and $t$ are identical modulo $\beta$-conversion in types. \end{defn} Note that we present terms in orthodox Church-style, i.e., instead of using contexts each variable has a globally fixed type associated to it. \begin{lemma} If $s : \tau$ and $s \equiv t$ then $t : \tau$. \end{lemma} \begin{proof} Induction on~$s$. \end{proof} \begin{defn}\label{def_terms} The set of \emph{terms} is the set of the equivalence classes of~$\equiv$. \end{defn} Because $\beta$-reduction on types is confluent and terminating, every term has a canonical preterm representative -- the one with all types occurring in it $\beta$-normalised. We define $\mathrm{FTV}(t)$ as the value of~$\mathrm{FTV}$ on the canonical representative of~$t$. We say that $t$ is \emph{closed} if both $\mathrm{FTV}(t) = \emptyset$ and $\mathrm{FV}(t) = \emptyset$. Because typing and term formation operations (abstraction, application, \ldots) are invariant under~$\equiv$, we may denote terms by their (canonical) representatives and informally treat them interchangeably. We will often abuse notation to omit $\cdot$ and $*$. Thus, $s t$ can refer to both $\app{s}{t}$ and $\tapp{s}{t}$. This is not ambiguous due to typing. When writing $\sigma[\subst{\alpha}{\tau}]$ we implicitly assume that $\alpha$ and $\tau$ have the same kind. Analogously with $t[\subst{x}{s}]$. \begin{lemma}[Substitution lemma]\label{lem:substitution} \begin{enumerate} \item If $s : \tau$ and $x : \sigma$ and $t : \sigma$ then $s[\subst{x}{t}] : \tau$. \item If $t : \sigma$ then $t[\subst{\alpha}{\tau}] : \sigma[\subst{\alpha}{\tau}]$. \end{enumerate} \end{lemma} \begin{proof} Induction on the typing derivation. \end{proof} \begin{lemma}[Generation lemma]\label{lem:generation} If $t : \sigma$ then there is a type~$\sigma'$ such that $\sigma' =_\beta \sigma$ and $\mathrm{FTV}(\sigma') \subseteq \mathrm{FTV}(t)$ and one of the following holds. \begin{itemize} \item $t \equiv x$ is a variable with $(x : \sigma') \in \mathcal{V}$. \item $t \equiv \mathtt{f}$ is a function symbol with $\mathtt{f} : \sigma'$ in $\Sigma$. \item $t \equiv \abs{x:\tau_1}{s}$ and $\sigma'=\tau_1\rightarrow\tau_2$ and $s : \tau_2$. \item $t \equiv \tabs{\alpha:\kappa}{s}$ and $\sigma' = \quant{\alpha:\kappa}{\tau}$ and $s : \tau$ and $\alpha$ does not occur free in the type of a free variable of~$s$. \item $t \equiv \app{t_1}{t_2}$ and $t_1 : \tau \rightarrow \sigma'$ and $t_2 : \tau$ and $\mathrm{FTV}(\tau) \subseteq \mathrm{FTV}(t)$. \item $t \equiv \tapp{s}{\tau}$ and $\sigma' = \rho[\subst{\alpha}{\tau}]$ and $s : \quant{(\alpha:\kappa)}{\rho}$ and~$\tau$ is a type constructor of kind~$\kappa$. \end{itemize} \end{lemma} \begin{proof} By analysing the derivation $t : \sigma$. To ensure $\mathrm{FTV}(\sigma') \subseteq \mathrm{FTV}(t)$, note that if $\alpha \notin \mathrm{FTV}(t)$ is of kind~$\kappa$ and~$t : \sigma'$, then $t : \sigma'[\subst{\alpha}{\chi_\kappa}]$ by the substitution lemma (thus we can eliminate~$\alpha$). \end{proof} \section{Polymorphic Functional Systems}\label{sec_systems} In this section, we present a form of higher-order term rewriting systems based on $\mathtt{F}_\omega$: \emph{Polymorphic Functional Systems (PFSs)}. Systems of interest, such as logic systems like~ICP2 and higher-order TRSs with shallow or full polymorphism can be encoded into PFSs, and then proved terminating with the technique we will develop in Sections \ref{sec:World}--\ref{sec_rule_removal}. \begin{defn}\label{def_pafs_types_terms} \emph{Kinds}, \emph{type constructors} and \emph{types} are defined like in Definition~\ref{def_types}, parameterised by a fixed set~$\Sigma^T = \bigcup_{\kappa}\Sigma^T_\kappa$ of type constructor symbols. Let~$\Sigma$ be a set of function symbols such that for $\mathtt{f} : \sigma \in \Sigma$: \[ \sigma = \forall (\alpha_1 : \kappa_1) \ldots \forall (\alpha_n : \kappa_n) . \sigma_1 \rightarrow \ldots \rightarrow \sigma_k \rightarrow \tau \quad\quad (\text{with}\ \tau\ \text{a type atom}) \] We define \emph{PFS terms} as in Definition~\ref{def_terms} (based on Definition~\ref{def_preterms}), parameterised by~$\Sigma$, with the restriction that for any subterm $\app{s}{u}$ of a term~$t$, we have $s = \mathtt{f} \rho_1 \ldots \rho_n u_1 \ldots u_m$ where: \[ \mathtt{f} : \forall (\alpha_1 : \kappa_1) \ldots \forall (\alpha_n : \kappa_n) . \sigma_1 \rightarrow \ldots \rightarrow \sigma_k \rightarrow \tau \quad\quad (\text{with}\ \tau\ \text{a type atom and}\ k > m) \] \end{defn} This definition does not allow for a variable or abstraction to occur at the head of an application, nor can we have terms of the form $s \cdot t * \tau \cdot q$ (although terms of the form $s \cdot t * \tau$, or $x * \tau$ with $x$ a variable, \emph{are} allowed to occur). To stress this restriction, we will use the notation $\mathtt{f}_{\rho_1,\ldots,\rho_n}(s_1,\ldots,s_m)$ as an alternative way to denote $\mathtt{f} \rho_1 \ldots \rho_n s_1 \ldots s_m$ when $ \mathtt{f} : \forall (\alpha_1 : \kappa_1) \ldots \forall (\alpha_n : \kappa_n) . \sigma_1 \rightarrow \ldots \rightarrow \sigma_k \rightarrow \tau $ is a function symbol in~$\Sigma$ with~$\tau$ a type atom and $m \leq k$. This allows us to represent terms in a ``functional'' way, where application does not explicitly occur (only implicitly in the construction of $\mathtt{f}_{\rho_1,\ldots,\rho_n}(s_1,\ldots,s_m)$). The following result follows easily by induction on term structure: \begin{lemma} If $t,s$ are PFS terms then so is $t[\subst{x}{s}]$. \end{lemma} PFS terms will be rewritten through a reduction relation $\arr{\mathcal{R}}$ based on a (usually infinite) set of rewrite rules. To define this relation, we need two additional notions. \begin{defn}\label{def_replacement} A \emph{replacement} is a function $\delta = \gamma \circ \omega$ satisfying: \begin{enumerate} \item $\omega$ is a type constructor substitution, \item $\gamma$ is a term substitution such that $\gamma(\omega(x)) : \omega(\tau)$ for every $(x : \tau) \in \mathcal{V}$. \end{enumerate} For~$\tau$ a type constructor, we use $\delta(\tau)$ to denote $\omega(\tau)$. We use the notation $\delta[\subst{x}{t}] = \gamma[\subst{x}{t}] \circ \omega$. Note that if $t : \tau$ then $\delta(t) : \delta(\tau)$. \end{defn} \begin{defn}\label{def:context} A \emph{$\sigma$-context}~$C_\sigma$ is a PFS term with a fresh function symbol $\Box_\sigma \notin \Sigma$ of type~$\sigma$ occurring exactly once. By~$C_\sigma[t]$ we denote a PFS term obtained from~$C_\sigma$ by substituting~$t$ for~$\Box_\sigma$. We drop the $\sigma$ subscripts when clear or irrelevant. \end{defn} Now, the rewrite rules are simply a set of term pairs, whose monotonic closure generates the rewrite relation. \begin{defn}\label{def_rules} A set $\mathcal{R}$ of term pairs $(\ell,r)$ is a set of \emph{rewrite rules} if: (a) $\mathrm{FV}(r) \subseteq \mathrm{FV}(\ell)$; (b) $\ell$ and $r$ have the same type; and (c) if $(\ell,r) \in \mathcal{R}$ then $(\delta(\ell),\delta(r)) \in \mathcal{R}$ for any replacement~$\delta$. The reduction relation $\arr{\mathcal{R}}$ on PFS terms is defined by: \begin{center} $t \arr{\mathcal{R}} s$ iff $t = C[\ell]$ and $s = C[r]$ for some $(\ell,r)\in\mathcal{R}$ and context~$C$. \end{center} \end{defn} \begin{defn}\label{def_pafs} A \emph{Polymorphic Functional System (PFS)} is a triple $(\Sigma^T,\Sigma,\mathcal{R})$ where~$\Sigma^T$ is a set of type constructor symbols, $\Sigma$ a set of function symbols (restricted as in Def.~\ref{def_pafs_types_terms}), and $\mathcal{R}$ is a set of rules as in Definition~\ref{def_rules}. A term of a PFS~$A$ is referred to as an $A$-term. \end{defn} While PFS-terms are a restriction from the general terms of system $\mathtt{F}_\omega$, the reduction relation allows us to actually encode, e.g., system~$\mathtt{F}$ as a PFS: we can do so by including the symbol ${@} : \forall\alpha\forall\beta . (\alpha \rightarrow \beta) \rightarrow \alpha \rightarrow \beta$ in $\Sigma$ and adding all rules of the form $@_{\sigma,\tau}(\abs{x}{s},t) \longrightarrow s[x:=t]$. Similarly, $\beta$-reduction of type abstraction can be modelled by including a symbol $\mathtt{A} : \forall \alpha : * \Rightarrow * . \forall \beta . (\forall \gamma.\alpha \gamma) \rightarrow \alpha \beta$ and rules $\mathtt{A}_{\abs{\gamma}{\sigma},\tau}(\tabs{\gamma}{s}) \longrightarrow s[\gamma:=\tau]$.% \footnote{The use of a type constructor variable $\alpha$ of kind $* \Rightarrow *$ makes it possible to do type substitution as part of a rule. An application $s * \tau$ with $s : \quant{\gamma}{\sigma}$ is encoded as $\mathtt{A}_{\abs{\gamma}{\sigma},\tau}(s)$, so $\alpha$ is substituted with $\abs{\gamma}{\tau}$. This is well-typed because $(\abs{\gamma}{\sigma})\gamma =_\beta \sigma$ and $(\abs{\gamma}{\sigma})\tau =_\beta \sigma[\gamma:=\tau]$. } We can also use rules $(\tabs{\alpha}{s})*\tau \longrightarrow s[\alpha:=\tau]$ without the extra symbol, but to apply our method it may be convenient to use the extra symbol, as it creates more liberty in choosing an interpretation. \begin{example}[Fold on heterogenous lists]\label{ex_fold_pafs} The example from the introduction may be represented as a PFS with one type symbol $\mathtt{List} : *$, the following function symbols: \[ \begin{array}{rcl} @ & : & \forall \alpha \forall \beta . (\alpha \rightarrow \beta) \rightarrow \alpha \rightarrow \beta \\ \mathtt{A} & : & \forall \alpha : * \Rightarrow * . \forall \beta . (\forall \gamma .\alpha \gamma) \rightarrow \alpha \beta \\ \mathtt{nil} & : & \mathtt{List} \\ \mathtt{cons} & : & \forall \alpha . \alpha \rightarrow \mathtt{List} \rightarrow \mathtt{List} \\ \mathtt{foldl} & : & \forall \beta . (\forall \alpha . \beta \rightarrow \alpha \rightarrow \beta) \rightarrow \beta \rightarrow \mathtt{List} \rightarrow \beta \end{array} \] and the following rules (which formally represents an infinite set of rules: one rule for each choice of types $\sigma, \tau$ and PFS terms $s$, $t$, etc.): \[ \begin{array}{rcl} @_{\sigma,\tau}(\abs{x:\sigma}{s},t) & \longrightarrow & s[x:=t] \\ \mathtt{A}_{\abs{\alpha}{\sigma},\tau}(\tabs{\alpha}{s}) & \longrightarrow & s[\alpha:=\tau] \\ \mathtt{foldl}_\sigma(f,s,\mathtt{nil}) & \longrightarrow & s \\ \mathtt{foldl}_\sigma(f,s,\mathtt{cons}_\tau(h,t)) & \longrightarrow & \mathtt{foldl}_\sigma(f,@_{\tau,\sigma}(@_{\sigma,\tau \rightarrow\sigma}(\mathtt{A}_{\abs{\alpha}{\sigma\rightarrow\alpha\rightarrow\sigma},\tau}(f),s),h),t) \end{array} \] \end{example} \section{A well-ordered set of interpretation terms}\label{sec:World} In polynomial interpretations of first-order term rewriting~\cite[Chapter 6.2]{Terese2003}, each term $s$ is mapped to a natural number $\interpret{s}$, such that $\interpret{s} > \interpret{t}$ whenever $s \arr{\mathcal{R}} t$. In higher-order rewriting, this is not practical; instead, following \cite{pol:96}, terms are mapped to weakly monotonic functionals according to their type (i.e., terms with a $0$-order type are mapped to natural numbers, terms with a $1$-order type to weakly monotonic functions over natural numbers, terms with a $2$-order type to weakly monotonic functionals taking weakly monotonic functions as arguments, and so on). In this paper, to account for full polymorphism, we will interpret PFS terms to a set $\mathcal{I}$ of \emph{interpretation terms} in a specific extension of System~$\mathtt{F}_\omega$. This set is defined in Section \ref{subsec:I}; we provide a well-founded partial ordering $\succ$ on $\mathcal{I}$ in Section \ref{subsec:succ}. Although our world of interpretation terms is quite different from the weakly monotonic functionals of \cite{pol:96}, there are many similarities. Most pertinently, every interpretation term $\abs{x}{s}$ essentially defines a weakly monotonic function from $\mathcal{I}$ to $\mathcal{I}$. This, and the use of both addition and multiplication in the definition of $\mathcal{I}$, makes it possible to lift higher-order polynomial interpretations \cite{FuhsKop2012} to our setting. We prove weak monotonicity in Section \ref{subsec:weakmono}. \subsection{Interpretation terms}\label{subsec:I} \begin{defn}\label{def_iterms} The set~$\mathcal{Y}$ of \emph{interpretation types} is the set of types as in Definition~\ref{def_types} with $\Sigma^T = \{ \mathtt{nat} : * \}$, i.e., there is a single type constant~$\mathtt{nat}$. Then $\chi_* = \mathtt{nat}$. The set~$\mathcal{I}$ of \emph{interpretation terms} is the set of terms from Definition~\ref{def_terms} (see also Definition~\ref{def_preterms}) where as types we take the interpretation types and for the set~$\Sigma$ of function symbols we take $\Sigma = \{ n : \mathtt{nat} \mid n \in \mathbb{N} \} \cup \Sigma_f$, where $ \Sigma_f = \{ \oplus : \forall \alpha . \alpha \rightarrow \alpha \rightarrow \alpha, \otimes : \forall \alpha . \alpha \rightarrow \alpha \rightarrow \alpha, \mathtt{flatten} : \forall \alpha . \alpha \rightarrow \mathtt{nat}, \mathtt{lift} : \forall \alpha . \mathtt{nat} \rightarrow \alpha \} $. \end{defn} For easier presentation, we write $\oplus_\tau$, $\otimes_\tau$, etc., instead of $\tapp{\oplus}{\tau}$, $\tapp{\otimes}{\tau}$, etc. We will also use $\oplus$ and $\otimes$ in \emph{infix, left-associative} notation, and omit the type denotation where it is clear from context. Thus, $s \oplus t \oplus u$ should be read as $\oplus_\sigma\,(\oplus_\sigma\,s\,t)\,u$ if $s$ has type $\sigma$. Thus, our interpretation terms include natural numbers with the operations of addition and multiplication. It would not cause any fundamental problems to add more monotonic operations, e.g., exponentiation, but we refrain from doing so for the sake of simplicity. \paragraph*{Normalising interpretation terms} The set $\mathcal{I}$ of interpretation terms can be reduced through a relation $\leadsto$, that we will define below. This relation will be a powerful aid in defining the partial ordering $\succ$ in Section \ref{subsec:succ}. \begin{defn} We define the relation $\leadsto$ on interpretation terms as the smallest relation on~$\mathcal{I}$ for which the following properties are satisfied: \begin{enumerate} \item\label{arrW:mono:abs} if $s \leadsto t$ then both $\abs{x}{s} \leadsto \abs{x}{t}$ and $\tabs{\alpha}{s} \leadsto \tabs{\alpha}{t}$ \item\label{arrW:mono:right} if $s \leadsto t$ then $\app{u}{s} \leadsto \app{u}{t}$ \item\label{arrW:mono:left} if $s \leadsto t$ then both $\app{s}{u} \leadsto \app{t}{u}$ and $\tapp{s}{\sigma} \leadsto \tapp{t}{\sigma}$ \item\label{arrW:beta:abs} $\app{(\abs{x:\sigma}{s})}{t} \leadsto s[\subst{x}{t}]$ and $\tapp{(\tabs{\alpha}{s})}{\sigma} \leadsto s[\subst{\alpha}{\sigma}]$ ($\beta$-reduction) \item\label{arrW:plus:base} $\app{\app{\oplus_{\mathtt{nat}}}{n}}{m} \leadsto n+m$ and $\app{\app{\otimes_{\mathtt{nat}}}{n}}{m} \leadsto n \times m$ \item\label{arrW:circ:arrow} $\app{\app{\circ_{\sigma \rightarrow \tau}}{s}}{t} \leadsto \abs{x:\sigma}{\app{\app{\circ_\tau}{(\app{s}{x})}}{(\app{t}{x})}}$ for $\circ \in \{ \oplus, \otimes \}$ \item\label{arrW:circ:forall} $\app{\app{\circ_{\quant{\alpha}{\sigma}}}{s}}{t} \leadsto \tabs{\alpha}{\app{\app{\circ_\sigma}{(\tapp{s}{\alpha})}}{( \tapp{t}{\alpha})}}$ for $\circ \in \{ \oplus, \otimes \}$ \item $\app{\mathtt{flatten}_\mathtt{nat}}{s} \leadsto s$ \item $\app{\mathtt{flatten}_{\sigma \rightarrow \tau}}{s} \leadsto \app{\mathtt{flatten}_\tau}{(\app{s}{(\app{\mathtt{lift}_\sigma}{0})})}$ \item $\app{\mathtt{flatten}_{\quant{\alpha:\kappa}{\sigma}}}{s} \leadsto \app{\mathtt{flatten}_{\sigma[\subst{\alpha}{\chi_\kappa}]}}{(\tapp{s}{\chi_\kappa})}$ \item $\app{\mathtt{lift}_\mathtt{nat}}{s} \leadsto s$ \item $\app{\mathtt{lift}_{\sigma \rightarrow \tau}}{s} \leadsto \abs{x:\sigma}{\app{\mathtt{lift}_{\tau}}{s}}$ \item $\app{\mathtt{lift}_{\quant{\alpha}{\sigma}}}{s} \leadsto \tabs{\alpha}{\app{\mathtt{lift}_{\sigma}}{s}}$ \end{enumerate} Recall Definition~\ref{def_terms} and Definition~\ref{def_iterms} of the set of interpretation terms~$\mathcal{I}$ as the set of the equivalence classes of~$\equiv$. So, for instance, $\mathtt{lift}_\mathtt{nat}$ above denotes the equivalence class of all preterms $\mathtt{lift}_\sigma$ with $\sigma =_\beta \mathtt{nat}$. Hence, the above rules are invariant under~$\equiv$ (by confluence of $\beta$-reduction on types), and they correctly define a relation on interpretation terms. We say that $s$ is a \emph{redex} if $s$ reduces by one of the rules 4--13. A \emph{final interpretation term} is an interpretation term $s \in \mathcal{I}$ such that (a) $s$ is closed, and (b) $s$ is in normal form with respect to $\leadsto$. We let $\mathcal{I}^f$ be the set of all final interpretation terms. By~$\mathcal{I}_\tau$ ($\mathcal{I}^f_\tau$) we denote the set of all (final) interpretation terms of interpretation type~$\tau$. \end{defn} An important difference with System~$\mathtt{F}_\omega$ and related ones is that the rules for $\oplus_\tau$, $\otimes_\tau$, $\mathtt{flatten}_\tau$ and $\mathtt{lift}_\tau$ depend on the type~$\tau$. In particular, type substitution in terms may create redexes. For instance, if $\alpha$ is a type variable then $\oplus_\alpha t_1 t_2$ is not a redex, but $\oplus_{\sigma\rightarrow\tau} t_1 t_2$ is. This makes the question of termination subtle. Indeed, System~$\mathtt{F}_\omega$ is extremely sensitive to modifications which are not of a logical nature. For instance, adding a constant $\mathtt{J} : \forall \alpha \beta . \alpha \rightarrow \beta$ with a reduction rule $\mathtt{J} \tau \tau \leadsto \lambda x : \tau . x$ makes the system non-terminating~\cite{Girard1971}. This rule breaks parametricity by making it possible to compare two arbitrary types. Our rules do not allow such a definition. Moreover, the natural number constants cannot be distinguished ``inside'' the system. In other words, we could replace all natural number constants with 0 and this would not change the reduction behaviour of terms. So for the purposes of termination, the type $\mathtt{nat}$ is essentially a singleton. This implies that, while we have polymorphic functions between an arbitrary type $\alpha$ and $\mathtt{nat}$ which are not constant when seen ``from outside'' the system, they are constant for the purposes of reduction ``inside'' the system (as they would have to be in a parametric $\mathtt{F}_\omega$-like system). Intuitively, these properties of our system ensure that it stays ``close enough'' to $\mathtt{F}_\omega$ so that the standard termination proof still generalises. Now we state some properties of~$\leadsto$, including strong normalisation. Because of space limitations, most (complete) proofs are delegated to \onlypaper{\cite[Appendix~A.1]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{app_proofs_SN}}. \begin{lemma}[Subject reduction] If $t : \tau$ and $t \leadsto t'$ then $t' : \tau$. \end{lemma} \begin{proof} By induction on the definition of $t \leadsto t'$, using Lemmas \ref{lem:substitution} and \ref{lem:generation}. \end{proof} \begin{theorem}\label{thm_sn} If $t : \sigma$ then $t$ is terminating with respect to $\leadsto$. \end{theorem} \begin{proof} By an adaptation of the Tait-Girard computability method. The proof is an adaptation of chapters~6 and~14 from the book~\cite{Girard1989}, and chapters~10 and~11 from the book~\cite{SorensenUrzyczyn2006}. Details are available in \onlypaper{\cite[Appendix A.1]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{app_proofs_SN}}. \end{proof} \begin{lemma}\label{lem_unique_final} Every term $s \in \mathcal{I}$ has a unique normal form~$s\mathord{\downarrow}$. If~$s$ is closed then so is~$s\mathord{\downarrow}$. \end{lemma} \begin{proof} One easily checks that~$\leadsto$ is locally confluent. Since the relation is terminating by Theorem~\ref{thm_sn}, it is confluent by Newman's lemma. \end{proof} \begin{lemma}\label{lem_final_nat} The only final interpretation terms of type $\mathtt{nat}$ are the natural numbers. \end{lemma} \begin{example}\label{ex:arrWreduce} Let $s \in \mathcal{I}_{\mathtt{nat} \rightarrow \mathtt{nat}}$ and $t \in \mathcal{I}_\mathtt{nat}$. Then we can reduce $(s \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1)) \cdot t \leadsto (\abs{x}{s x \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1)x}) \cdot t \leadsto s t \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1)t \leadsto s t \oplus (\abs{y}{\mathtt{lift}_{\mathtt{nat}}(1)})t \leadsto s t \oplus \mathtt{lift}_\mathtt{nat}(1) \leadsto s t \oplus 1$. If $s$ and $t$ are variables, this term is in normal form. \end{example} \subsection{The ordering pair $(\succeq,\succ)$}\label{subsec:succ} With these ingredients, we are ready to define the well-founded partial ordering $\succ$ on $\mathcal{I}$. In fact, we will do more: rather than a single partial ordering, we will define an \emph{ordering pair}: a pair of a quasi-ordering $\succeq$ and a compatible well-founded ordering $\succ$. The quasi-ordering $\succeq$ often makes it easier to prove $s \succ t$, since it suffices to show that $s \succeq s' \succ t' \succeq t$ for some interpretation terms $s',t'$. Having $\succeq$ will also allow us to use rule removal (Theorem \ref{thm:ruleremove}). \begin{defn}\label{def:succ} Let $R \in \{ \succ^0,\succeq^0 \}$. For \emph{closed}~$s,t\in\mathcal{I}_\sigma$ and closed~$\sigma$ in $\beta$-normal form, the relation $s\ R_{\sigma}\ t$ is defined coinductively by the following rules. \[ \begin{array}{ccc} \infer={s\ R_\mathtt{nat}\ t}{s\mathord{\downarrow}\ R\ t\mathord{\downarrow} \text{ in }\mathbb{N}} \quad&\quad \infer={s\ R_{\sigma\rightarrow\tau}\ t}{\app{s}{q}\ R_{\tau}\ \app{t}{q} \text{ for all } q \in \mathcal{I}^f_\sigma} & \infer={s\ R_{\forall(\alpha:\kappa).\sigma}\ t}{\tapp{s}{\tau}\ R_{\mathrm{nf}_\beta(\sigma[\subst{\alpha}{\tau}])}\ \tapp{t}{\tau} \text{ for all closed } \tau \in \mathcal{T}_{\kappa}} \end{array} \] We define $s \approx_\sigma^0 t$ if both $s \succeq_\sigma^0 t$ and $t \succeq_\sigma^0 s$. We drop the type subscripts when clear or irrelevant. \end{defn} Note that in the case for~$\mathtt{nat}$ the terms~$s\mathord{\downarrow}$, $t\mathord{\downarrow}$ are natural numbers by Lemma~\ref{lem_final_nat} ($s\mathord{\downarrow},t\mathord{\downarrow}$ are closed and in normal form, so they are final interpretation terms). Intuitively, the above definition means that e.g. $s \succ^0 t$ iff there exists a possibly infinite derivation tree using the above rules. In such a derivation tree all leaves must witness $s\mathord{\downarrow} > t\mathord{\downarrow}$ in natural numbers. However, this also allows for infinite branches, which solves the problem of repeating types due to impredicative polymorphism. If e.g.~$s \succ_{\forall \alpha . \alpha}^0 t$ then $\tapp{s}{\forall\alpha.\alpha} \succ_{\forall \alpha . \alpha}^0 \tapp{t}{\forall\alpha.\alpha}$, which forces an infinite branch in the derivation tree. According to our definition, any infinite branch may essentially be ignored. Formally, the above coinductive definition of e.g.~$\succ_\sigma^0$ may be interpreted as defining the largest relation such that if $s \succ_\sigma^0 t$ then: \begin{itemize} \item $\sigma = \mathtt{nat}$ and $s\mathord{\downarrow} > t\mathord{\downarrow}$ in $\mathbb{N}$, or \item $\sigma = \tau_1\rightarrow\tau_2$ and $\app{s}{q} \succ_{\tau_2}^0 \app{t}{q}$ for all $q \in \mathcal{I}^f_{\tau_1}$, or \item $\sigma = \forall(\alpha:\kappa).\rho$ and $\tapp{s}{\tau} \succ_{\mathrm{nf}_\beta(\rho[\subst{\alpha}{\tau}])}^0 \tapp{t}{\tau}$ for all closed $\tau \in \mathcal{T}_{\kappa}$. \end{itemize} For more background on coinduction see e.g.~\cite{KozenSilva2017,Sangiorgi2012,JacobsRutten2011}. In this paper we use a few simple coinductive proofs to establish the basic properties of~$\succ$ and~$\succeq$. Later, we just use these properties and the details of the definition do not matter. \begin{defn}\label{def_closure} A \emph{closure}~$\mathcal{C} = \gamma \circ \omega$ is a replacement such that $\omega(\alpha)$ is closed for each type constructor variable~$\alpha$, and $\gamma(x)$ is closed for each term variable~$x$. % For arbitrary types~$\sigma$ and arbitrary terms $s,t \in \mathcal{I}$ we define $s \succ_\sigma t$ if for every closure~$\mathcal{C}$ we can obtain $\mathcal{C}(s) \succ_{\mathrm{nf}_\beta(\mathcal{C}(\sigma))}^c \mathcal{C}(t)$ coinductively with the above rules. The relations $\succeq_\sigma$ and $\approx_\sigma$ are defined analogously. \end{defn} Note that for closed $s,t$ and closed~$\sigma$ in $\beta$-normal form, $s \succ_\sigma t$ iff $s \succ_\sigma^0 t$ (and analogously for~$\succeq,\approx$). In this case we shall often omit the superscript~$0$. The definition of~$\succ$ and~$\succeq$ may be reformulated as follows. \begin{lemma}\label{lem_succ_explicit} $t \succeq s$ if and only if for every closure~$\mathcal{C}$ and every sequence $u_1,\ldots,u_n$ of closed terms and closed type constructors such that $\mathcal{C}(t) u_1 \ldots u_n : \mathtt{nat}$ we have $(\mathcal{C}(t) u_1 \ldots u_n)\mathord{\downarrow} \ge (\mathcal{C}(s) u_1 \ldots u_n)\mathord{\downarrow}$ in natural numbers. An analogous result holds with $\succ$ or $\approx$ instead of~$\succeq$. \end{lemma} \begin{proof} The direction from left to right follows by induction on~$n$; the other by coinduction. \end{proof} In what follows, all proofs by coinduction could be reformulated to instead use the lemma above. However, this would arguably make the proofs less perspicuous. Moreover, a coinductive definition is better suited for a formalisation -- the coinductive proofs here could be written in Coq almost verbatim. Our next task is to show that $\succeq$ and $\succ$ have the desired properties of an ordering pair; e.g., transitivity and compatibility. We first state a simple lemma that will be used implicitly. \begin{lemma} If $\tau \in \mathcal{Y}$ is closed and $\beta$-normal, then $\tau = \mathtt{nat}$ or $\tau = \tau_1\rightarrow\tau_2$ or $\tau = \forall\alpha\sigma$. \end{lemma} \begin{lemma}\label{lem_well_founded} $\succ$ is well-founded. \end{lemma} \begin{proof} It suffices to show this for closed terms and closed types in $\beta$-normal form, because any infinite sequence $t_1 \succ_\tau t_2 \succ_\tau t_3 \succ_\tau \ldots$ induces an infinite sequence $\mathcal{C}(t_1) \succ_{\mathrm{nf}_\beta(\mathcal{C}(\tau))} \mathcal{C}(t_2) \succ_{\mathrm{nf}_\beta(\mathcal{C}(\tau))} \mathcal{C}(t_3) \succ_{\mathrm{nf}_\beta(\mathcal{C}(\tau))} \ldots$ for any closure~$\mathcal{C}$. By induction on the size of a $\beta$-normal type~$\tau$ (with size measured as the number of occurrences of~$\forall$ and~$\rightarrow$) one proves that there does not exist an infinite sequence $t_1 \succ_\tau t_2 \succ_\tau t_3 \succ_\tau \ldots$ For instance, if $\alpha$ has kind~$\kappa$ and $t_1 \succ_{\forall\alpha\tau} t_2 \succ_{\forall\alpha\tau} t_3 \succ_{\forall\alpha\tau} \ldots$ then $\tapp{t_1}{\chi_\kappa} \succ_{\tau'} \tapp{t_2}{\chi_\kappa} \succ_{\tau'} \tapp{t_3}{\chi_\kappa} \succ_{\tau'} \ldots$, where $\tau'=\mathrm{nf}_\beta(\tau[\subst{\alpha}{\chi_\kappa}])$. Because $\tau$ is in $\beta$-normal form, all redexes in $\tau[\subst{\alpha}{\chi_\kappa}]$ are created by the substitution and must have the form $\chi_\kappa u$. Hence, by the definition of~$\chi_\kappa$ (see Definition~\ref{def_types}) the type~$\tau'$ is smaller than~$\tau$. This contradicts the inductive hypothesis. \end{proof} \begin{lemma}\label{lem_transitive} Both $\succ$ and $\succeq$ are transitive. \end{lemma} \begin{proof} We show this for~$\succ$, the proof for~$\succeq$ being analogous. Again, it suffices to prove this for closed terms and closed types in $\beta$-normal form. We proceed by coinduction. If $t_1 \succ_\mathtt{nat} t_2 \succ_\mathtt{nat} t_3$ then $t_1\mathord{\downarrow} > t_2\mathord{\downarrow} > t_3\mathord{\downarrow}$, so $t_1\mathord{\downarrow} > t_3\mathord{\downarrow}$. Thus $t_1 \succ_\mathtt{nat} t_3$. If $t_1 \succ_{\sigma\rightarrow\tau}t_2\succ_{\sigma\rightarrow\tau}t_3$ then $\app{t_1}{q}\succ_{\tau}\app{t_2}{q}\succ_\tau\app{t_3}{q}$ for $q \in \mathcal{I}^f_\sigma$. Hence $\app{t_1}{q}\succ_\tau\app{t_3}{q}$ for $q \in \mathcal{I}^f_\sigma$ by the coinductive hypothesis. Thus $t_1\succ_{\sigma\rightarrow\tau} t_3$. If $t_1 \succ_{\forall(\alpha:\kappa)\sigma}t_2\succ_{\forall(\alpha:\kappa)\sigma}t_3$ then $\tapp{t_1}{\tau}\succ_{\sigma'}\tapp{t_2}{\tau}\succ_{\sigma'}\tapp{t_3}{\tau}$ for any closed~$\tau$ of kind~$\kappa$, where $\sigma' = \mathrm{nf}_\beta(\sigma[\subst{\alpha}{\tau}])$. By the coinductive hypothesis $\tapp{t_1}{\tau}\succ_{\sigma'}\tapp{t_3}{\tau}$; thus $t_1\succ_{\forall\alpha\sigma}t_3$. \end{proof} \begin{lemma}\label{lem_reflexive} $\succeq$ is reflexive. \end{lemma} \begin{proof} By coinduction one shows that $\succeq_\sigma$ is reflexive on closed terms for closed $\beta$-normal~$\sigma$. The case of~$\succeq$ is then immediate from definitions. \end{proof} \begin{lemma}\label{lem:compatibility} The relations~$\succeq$ and~$\succ$ are compatible, i.e., $\succ \cdot \succeq\ \subseteq\ \succ$ and $\succeq \cdot \succ\ \subseteq\ \succ$. \end{lemma} \begin{proof} By coinduction, analogous to the transitivity proof. \end{proof} \begin{lemma}\label{lem_succ_to_succeq} If $t \succ s$ then $t \succeq s$. \end{lemma} \begin{proof} By coinduction. \end{proof} \begin{lemma}\label{lem_leadsto_to_approx} If $t \leadsto s$ then $t \approx s$. \end{lemma} \begin{proof} Follows from Lemma~\ref{lem_succ_explicit}, noting that $t \leadsto s$ implies $\mathcal{C}(t) \leadsto \mathcal{C}(s)$ for all closures~$\mathcal{C}$. \end{proof} \begin{lemma}\label{lem_succ_red} Assume $t \succ s$ (resp.~$t \succeq s$). If $t \leadsto t'$ or $t' \leadsto t$ then $t' \succ s$ (resp.~$t' \succeq s$). If $s \leadsto s'$ or $s' \leadsto s$ then $t \succ s'$ (resp.~$t \succeq s'$). \end{lemma} \begin{proof} Follows from Lemma~\ref{lem_leadsto_to_approx}, transitivity and compatibility. \end{proof} \begin{corollary}\label{cor_succ_da} For $R \in \{\succ,\succeq,\approx\}$: $s\ R\ t$ if and only if $s\downarrow\ R\ t\downarrow$. \end{corollary} \begin{example}\label{ex:plus1} We can prove that $x \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1) \succ x$: by definition, this holds if $s \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1) \succ s$ for all closed $s$, so if $(s \oplus \mathtt{lift}_{\mathtt{nat} \rightarrow \mathtt{nat}}(1))u \succ s u$ for all closed $s,u$. Following Example \ref{ex:arrWreduce} and Lemma \ref{lem_succ_red}, this holds if $s u \oplus 1 \succ s u$. By definition, this is the case if $(s u \oplus 1)\downarrow > (s u)\downarrow$ in the natural numbers, which clearly holds for any $s,u$. \end{example} \subsection{Weak monotonicity}\label{subsec:weakmono} We will now show that $s \succeq s'$ implies $t[\subst{x}{s}] \succeq t[\subst{x}{s'}]$ (weak monotonicity). For this purpose, we prove a few lemmas, many of which also apply to~$\succ$, stating the preservation of~$\succeq$ under term formation operations. We will need these results in the next section. \begin{lemma}\label{lem_app_succ} For $R \in \{\succeq,\succ\}$: if $t\:R\:s$ then $t u\:R\:s u$ with $u$ a term or type constructor. \end{lemma} \begin{proof} Follows from definitions. \end{proof} \begin{lemma}\label{lem:liftgreater} For $R \in \{\succeq,\succ\}$: if $n\:R\:m$ then $\mathtt{lift}_\sigma n\:R\:\mathtt{lift}_\sigma m$ for all types $\sigma$. \end{lemma} \begin{proof} Without loss of generality we may assume $\sigma$ closed and in $\beta$-normal form. By coinduction we show $\mathtt{lift}(n) u_1 \ldots u_k \succeq \mathtt{lift}(m) u_1 \ldots u_k$ for closed $u_1,\ldots,u_k$. First note that $(\mathtt{lift}\,t) u_1 \ldots u_k \leadsto^* \mathtt{lift}(t)$ (with a different type subscript in~$\mathtt{lift}$ on the right side, omitted for conciseness). If $\sigma = \mathtt{nat}$ then $(\mathtt{lift}(n) u_1 \ldots u_k)\mathord{\downarrow} = n \ge m = (\mathtt{lift}(m) u_1 \ldots u_k)\mathord{\downarrow}$. If $\sigma = \tau_1\rightarrow\tau_2$ then by the coinductive hypothesis $\mathtt{lift}(n) u_1 \ldots u_k q \succeq_{\tau_2} \mathtt{lift}(m) u_1 \ldots u_k q$ for any $q \in \mathcal{I}^f_{\tau_1}$, so $\mathtt{lift}(n) u_1 \ldots u_k \succeq_{\sigma} \mathtt{lift}(m) u_1 \ldots u_k$ by definition. If $\sigma = \forall(\alpha:\kappa)\tau$ then by the coinductive hypothesis $\mathtt{lift}(n) u_1 \ldots u_k \xi \succeq_{\sigma'} \mathtt{lift}(m) u_1 \ldots u_k \xi$ for any closed $\xi \in \mathcal{T}_\kappa$, where $\sigma' = \tau[\subst{\alpha}{\xi}]$. Hence $\mathtt{lift}(n) u_1 \ldots u_k \succeq_{\sigma} \mathtt{lift}(m) u_1 \ldots u_k$ by definition. \end{proof} \begin{lemma}\label{lem_flatten_succ} For $R \in \{\succeq,\succ\}$: if $t\:R_\sigma\:s$ then $\mathtt{flatten}_\sigma t\:R_\mathtt{nat}\: \mathtt{flatten}_\sigma s$ for all types $\sigma$. \end{lemma} \begin{proof} Without loss of generality we may assume~$\sigma$ is closed and in $\beta$-normal form. Using Lemma~\ref{lem_succ_red}, the lemma follows by induction on~$\sigma$. \end{proof} \begin{lemma}\label{lem_abs_succ} For $R \in \{\succeq,\succ\}$: if $t\:R\:s$ then $\abs{x}{t}\:R\:\abs{x}{s}$ and $\tabs{\alpha}{t}\:R\:\tabs{\alpha}{s}$. \end{lemma} \begin{proof} Assume $t \succeq_\tau s$ and $x : \sigma$. Let~$\mathcal{C}$ be a closure. We need to show $\mathcal{C}(\abs{x}{t}) \succeq_{\mathcal{C}(\sigma\rightarrow\tau)} \mathcal{C}(\abs{x}{s})$. Let $u \in \mathcal{I}^f_{\mathcal{C}(\sigma)}$. Then $\mathcal{C}' = \mathcal{C}[\subst{x}{u}]$ is a closure and $\mathcal{C}'(t) \succeq_{\mathcal{C}(\tau)} \mathcal{C}'(s)$. Hence $\mathcal{C}(t)[\subst{x}{u}] \succeq_{\mathcal{C}(\tau)} \mathcal{C}(s)[\subst{x}{u}]$. By Lemma~\ref{lem_succ_red} this implies $\mathcal{C}(\abs{x}{t}) u \succeq_{\mathcal{C}(\tau)} \mathcal{C}(\abs{x}{s}) u$. Therefore $\mathcal{C}(\abs{x}{t}) \succeq_{\mathcal{C}(\sigma\rightarrow\tau)} \mathcal{C}(\abs{x}{s})$. The proof for $\succ$ is analogous. \end{proof} \begin{lemma}\label{lem:plustimesmonotonic} Let $s,t,u$ be terms of type $\sigma$. \begin{enumerate} \item If $s \succeq t$ then $s \oplus_\sigma u \succeq t \oplus_\sigma u$, $u \oplus_\sigma s \succeq u \oplus_\sigma t$, $s \otimes_\sigma u \succeq t \otimes_\sigma u$, and $u \otimes_\sigma s \succeq u \otimes_\sigma t$. \item If $s \succ t$ then $s \oplus_\sigma u \succ t \oplus_\sigma u$ and $u \oplus_\sigma s \succ u \oplus_\sigma t$. Moreover, if additionally $u \succeq \mathtt{lift}_\sigma(1)$ then also $s \otimes_\sigma u \succ t \otimes_\sigma u$ and $u \otimes_\sigma s \succ u \otimes_\sigma t$. \end{enumerate} \end{lemma} \begin{proof} It suffices to prove this for closed $s,t,u$ and closed $\sigma$ in $\beta$-normal form. The proof is similar to the proof of Lemma~\ref{lem:liftgreater}. For instance, we show by coinduction that for closed $w_1,\ldots,w_n$ (denoted $\vec{w}$): if $s \vec{w} \succ t \vec{w}$ and $u \vec{w} \succeq \mathtt{lift}(1) \vec{w}$ then $(s \otimes u) \vec{w} \succ (t \otimes u) \vec{w}$. \end{proof} The following lemma depends on the lemmas above. The full proof may be found in \onlypaper{\cite[Appendix~A.2]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{sec_weakly_monotone_proof}}. The proof is actually quite complex, and uses a method similar to Girard's method of candidates for the termination proof. \begin{lemma}[Weak monotonicity]\label{lem_succeq_subst} If $s \succeq s'$ then $t[\subst{x}{s}] \succeq t[\subst{x}{s'}]$. \end{lemma} \begin{corollary}\label{cor_app_wm} If $s \succeq s'$ then $t s \succeq t s'$. \end{corollary} \section{A reduction pair for PFS terms}\label{sec_reduction_pairs} Recall that our goal is to prove termination of reduction in a PFS. To do so, in this section we will define a systematic way to generate \emph{reduction pairs}. We fix a~PFS~$A$, and define: \begin{defn} A binary relation~$R$ on $A$-terms is \emph{monotonic} if $R(s, t)$ implies $R(C[s], C[t])$ for every context~$C$ (we assume $s,t$ have the same type~$\sigma$). A \emph{reduction pair} is a pair~$(\succeq^A,\succ^A)$ of a quasi-order~$\succeq^A$ on $A$-terms and a well-founded ordering~$\succ^A$ on $A$-terms such that: (a) $\succeq^A$ and~$\succ^A$ are compatible, i.e., ${\succ^A} \cdot {\succeq^A} \subseteq {\succ^A}$ and ${\succeq^A} \cdot {\succ^A} \subseteq {\succ^A}$, and (b) $\succeq^A$ and~$\succ^A$ are both monotonic. \end{defn} If we can generate such a pair with $\ell \succ^A r$ for each rule $(\ell,r) \in \mathcal{R}$, then we easily see that the PFS $A$ is terminating. (If we merely have $\ell \succ^A r$ for \emph{some} rules and $\ell \succeq^A r$ for the rest, we can still progress with the termination proof, as we will discuss in Section \ref{sec_rule_removal}.) To generate this pair, we will define the notion of an \emph{interpretation} from the set of $A$-terms to the set $\mathcal{I}$ of interpretation terms, and thus lift the ordering pair $(\succeq,\succ)$ to $A$. In the next section, we will show how this reduction pair can be used in practice to prove termination of PFSs. One of the core ingredients of our interpretation function is a mapping to translate types: \begin{defn} A \emph{type constructor mapping} is a function $\mathcal{T\!M}$ which maps each type constructor symbol to a closed interpretation type constructor of the same kind. A fixed type constructor mapping $\mathcal{T\!M}$ is extended inductively to a function from type constructors to closed interpretation type constructors in the expected way. We denote the extended \emph{interpretation (type) mapping} by~$\typeinterpret{\sigma}$. Thus, e.g.~$\typeinterpret{\quant{\alpha}{\sigma}} = \quant{\alpha}{\typeinterpret{\sigma}}$ and $\typeinterpret{\sigma \rightarrow \tau} = \typeinterpret{\sigma} \rightarrow \typeinterpret{\tau}$. \end{defn} \begin{lemma}\label{lem:substitutioninterpret:types} $\typeinterpret{\sigma}[\alpha:=\typeinterpret{\tau}] = \typeinterpret{\sigma[\alpha:=\tau]}$ \end{lemma} \begin{proof} Induction on~$\sigma$. \end{proof} Similarly, we employ a \emph{symbol mapping} as the key ingredient to interpret PFS terms. \begin{defn} Given a fixed type constructor mapping~$\mathcal{T\!M}$, a \emph{symbol mapping} is a function $\mathcal{J}$ which assigns to each function symbol $\mathtt{f} : \rho$ a closed interpretation term $\mathcal{J}(\mathtt{f})$ of type~$\typeinterpret{\rho}$. For a fixed symbol mapping $\mathcal{J}$, we define the \emph{interpretation mapping} $\interpret{s}$ inductively: \[ \begin{array}{rclcrclcrcl} \interpret{x} & = & x &\quad& \interpret{\tabs{\alpha}{s}} & = & \tabs{\alpha}{\interpret{s}} &\quad& \interpret{\app{t_1}{t_2}} &=& \app{\interpret{t_1}}{\interpret{t_2}} \\ \interpret{\mathtt{f}} &=& \mathcal{J}(\mathtt{f}) & \quad & \interpret{\abs{x:\sigma}{s}} & = & \abs{x:\typeinterpret{\sigma}}{ \interpret{s}} & \quad & \interpret{\tapp{t}{\tau}} &=& \tapp{\interpret{t}}{\typeinterpret{\tau}} \\ \end{array} \] \end{defn} Note that $\typeinterpret{\sigma},\typeinterpret{\tau}$ above depend on~$\mathcal{T\!M}$. Essentially, $\interpret{\cdot}$ substitutes $\mathcal{T\!M}(\mathtt{c})$ for type constructor symbols $\mathtt{c}$, and $\mathcal{J}(\mathtt{f})$ for function symbols $\mathtt{f}$, thus mapping $A$-terms to interpretation terms. This translation preserves typing: \begin{lemma} If $s : \sigma$ then $\interpret{s} : \typeinterpret{\sigma}$. \end{lemma} \begin{proof} By induction on the form of $s$, using Lemma~\ref{lem:substitutioninterpret:types}. \end{proof} \begin{lemma}\label{lem:substitutioninterpret} For all $s,t,x,\alpha,\tau$: $\interpret{s}[\alpha:=\typeinterpret{\tau}] = \interpret{s[\alpha:=\tau]}$ and $\interpret{s}[x:=\interpret{t}] = \interpret{s[x:=t]}$. \end{lemma} \begin{proof} Induction on~$s$. \end{proof} \begin{defn} For a fixed type constructor mapping $\mathcal{T\!M}$ and symbol mapping $\mathcal{J}$, the \emph{interpretation pair} $(\succeq^{\Termmap},\succ^{\Termmap})$ is defined as follows: $s \succeq^{\Termmap} t$ if $\interpret{s} \succeq \interpret{t}$, and $s \succ^{\Termmap} t$ if $\interpret{s} \succ \interpret{t}$. \end{defn} \begin{remark} The polymorphic lambda-calculus has a much greater expressive power than the simply-typed lambda-calculus. Inductive data types may be encoded, along with their constructors and recursors with appropriate derived reduction rules. This makes our interpretation method easier to apply, even in the non-polymorphic setting, thanks to more sophisticated ``programming'' in the interpretations. The reader is advised to consult e.g.~\cite[Chapter~11]{Girard1989} for more background and explanations. We demonstrate the idea by presenting an encoding for the recursive type $\mathtt{List}$ and its fold-left function (see also Ex.~\ref{ex_fold_interpretation}). \end{remark} \begin{example}\label{ex:notyetmono} Towards a termination proof of Example~\ref{ex_fold_pafs}, we set $\mathcal{T\!M}(\mathtt{List}) = \forall \beta. (\forall \alpha. \beta \rightarrow \alpha \rightarrow \beta) \rightarrow \beta \rightarrow \beta$ and $\mathcal{J}(\mathtt{nil}) = \tabs{\beta}{\abs{f:\quant{\alpha}{\beta \rightarrow \alpha \rightarrow \beta}}{\abs{x:\beta}{x}}}$. If we additionally choose $\mathcal{J}(\mathtt{foldl}) = \tabs{\beta}{\abs{f}{\abs{x}{\abs{l}{l \beta f x}}} \oplus \mathtt{lift}_\beta(1)}$, we have $\interpret{\mathtt{foldl}_{\sigma}(f,s,\mathtt{nil})} = (\tabs{\beta}{ \abs{f}{\abs{x}{\abs{l}{l \beta f x}}} \oplus \mathtt{lift}_\beta(1)}) \typeinterpret{\sigma} f s (\tabs{\beta}{\abs{f}{\abs{x}{x}}}) \leadsto^* s \oplus \mathtt{lift}_{\interpret{\sigma}}(1)$ by $\beta$-reduction steps. An extension of the proof from Example~\ref{ex:plus1} shows that this term $\succ \interpret{s}$. \end{example} It is easy to see that $\succeq^{\Termmap}$ and $\succ^{\Termmap}$ have desirable properties such as transitivity, reflexivity (for $\succeq^{\Termmap}$) and well-foundedness (for $\succ^{\Termmap}$). However, $\succ^{\Termmap}$ is not necessarily monotonic. Using the interpretation from Example~\ref{ex:notyetmono}, $\interpret{\mathtt{foldl}_{\sigma}(\abs{x}{s},t,\mathtt{nil})} = \interpret{\mathtt{fold}_{\sigma}(\abs{x}{w},t,\mathtt{nil})}$ regardless of $s$ and $w$, so a reduction in $s$ would not cause a decrease in $\succ^{\Termmap}$. To obtain a reduction pair, we must impose certain conditions on $\mathcal{J}$; in particular, we will require that $\mathcal{J}$ is \emph{safe}. \begin{defn}\label{def_safe} If $s_1 \succ s_2$ implies $t[\subst{x}{s_1}] \succ t[\subst{x}{s_2}]$, then the interpretation term~$t$ is \emph{safe for~$x$}. A symbol mapping~$\mathcal{J}$ is \emph{safe} if for all $ \mathtt{f} : \forall (\alpha_1 : \kappa_1) \ldots \forall (\alpha_n : \kappa_n) . \sigma_1 \rightarrow \ldots \rightarrow \sigma_k \rightarrow \tau $ with~$\tau$ a type atom we have: $\mathcal{J}(\mathtt{f}) = \tabs{\alpha_1 \dots \alpha_n}{\abs{x_1 \dots x_k}{t}}$ with $t$ safe for each~$x_i$. \end{defn} \begin{lemma}\label{lem_safe} \begin{enumerate} \item $x u_1 \ldots u_m$ is safe for~$x$. \item If $t$ is safe for~$x$ then so are~$\mathtt{lift}(t)$ and~$\mathtt{flatten}(t)$. \item If $s_1$ is safe for~$x$ or $s_2$ is safe for~$x$ then $s_1 \oplus s_2$ is safe for~$x$. \item If either (a) $s_1$ is safe for~$x$ and $s_2 \succeq \mathtt{lift}(1)$, or (b) $s_2$ is safe for~$x$ and $s_1 \succeq \mathtt{lift}(1)$, then $s_1 \otimes s_2$ is safe for~$x$. \item If~$t$ is safe for~$x$ then so is~$\tabs{\alpha}{t}$ and~$\abs{y}{t}$ ($y \ne x$). \end{enumerate} \end{lemma} \begin{proof} Each point follows from one of the lemmas proven before, Lemma~\ref{lem_succ_to_succeq}, Lemma~\ref{lem_succeq_subst}, Lemma~\ref{lem:compatibility} and the transitivity of~$\succeq$. For instance, for the first, assume $s_1 \succ s_2$ and let $u_i^j=u_i[\subst{x}{s_j}]$. Then $(x u_1 \ldots u_m)[\subst{x}{s_1}] = s_1 u_1^1 \ldots u_m^1$. By Lemma~\ref{lem_app_succ} we have $s_1 u_1^1 \ldots u_m^1 \succ s_2 u_1^1 \ldots u_m^1$. By Lemma~\ref{lem_succ_to_succeq} and Lemma~\ref{lem_succeq_subst} we have $u_i^1 \succeq u_i^2$. By Corollary~\ref{cor_app_wm} and the transitivity of~$\succeq$ we obtain $s_2 u_1^1 \ldots u_m^1 \succeq s_2 u_1^2 \ldots u_m^2$. By Lemma~\ref{lem:compatibility} finally $(x u_1 \ldots u_m)[\subst{x}{s_1}] = s_1 u_1^1 \ldots u_m^1 \succ s_2 u_1^2 \ldots u_m^2 = (x u_1 \ldots u_m)[\subst{x}{s_2}]$. \end{proof} \begin{lemma}\label{lem_succinterpret_monotonic} If~$\mathcal{J}$ is safe then~$\succ^{\Termmap}$ is monotonic. \end{lemma} \begin{proof} Assume $s_1 \succ^{\Termmap} s_2$. By induction on a context~$C$ we show $C[s_1] \succ^{\Termmap} C[s_2]$. If $C=\Box$ then this is obvious. If $C = \abs{x}{C'}$ or $C = \tabs{\alpha}{C'}$ then $C'[s_1] \succ^{\Termmap} C'[s_2]$ by the inductive hypothesis, and thus $C[s_1] \succ^{\Termmap} C[s_2]$ follows from Lemma~\ref{lem_abs_succ} and definitions. If $C = C' t$ then $C'[s_1] \succ^{\Termmap} C'[s_2]$ by the inductive hypothesis, so $C[s_1] \succ^{\Termmap} C[s_2]$ follows from definitions. Finally, assume $C = \app{t}{C'}$. Then $t = \mathtt{f} \rho_1 \ldots \rho_n t_1 \ldots t_m$ where $ \mathtt{f} : \forall (\alpha_1 : \kappa_1) \ldots \forall (\alpha_n : \kappa_n) . \sigma_1 \rightarrow \ldots \rightarrow \sigma_k \rightarrow \tau $ with~$\tau$ a type atom, $m < k$, and $\mathcal{J}(\mathtt{f}) = \tabs{\alpha_1 \dots \alpha_n}{\abs{x_1 \dots x_k}{u}}$ with $u$ safe for each~$x_i$. Without loss of generality assume $m=k-1$. Then $\interpret{C[s_i]} \leadsto u'[\subst{x_k}{\interpret{C'[s_i]}}]$ where $u'=u[\subst{\alpha_1}{\typeinterpret{\rho_1}}]\ldots[\subst{\alpha_n}{\typeinterpret{\rho_n}}][\subst{x_1}{\interpret{t_1}}]\ldots[\subst{x_{k-1}}{\interpret{t_{k-1}}}]$. By the inductive hypothesis $\interpret{C'[s_1]} \succ \interpret{C'[s_2]}$. Hence $u'[\subst{x_k}{\interpret{C'[s_1]}}] \succ u'[\subst{x_k}{\interpret{C'[s_2]}}]$, because~$u$ is safe for~$x_k$. Thus $\interpret{C[s_1]} \succ \interpret{C[s_2]}$ by Lemma~\ref{lem_succ_red}. \end{proof} \begin{theorem}\label{thm_reduction_pair} If~$\mathcal{J}$ is safe then $(\succeq^{\Termmap},\succ^{\Termmap})$ is a reduction pair. \end{theorem} \begin{proof} By Lemmas~\ref{lem_transitive} and~\ref{lem_reflexive}, $\succeq^{\Termmap}$ is a quasi-order. Lemmas~\ref{lem_well_founded} and~\ref{lem_transitive} imply that~$\succ^{\Termmap}$ is a well-founded ordering. Compatibility follows from Lemma~\ref{lem:compatibility}. Monotonicity of~$\succeq^{\Termmap}$ follows from Lemma~\ref{lem_succeq_subst}. Monotonicity of~$\succ^{\Termmap}$ follows from Lemma~\ref{lem_succinterpret_monotonic}. \end{proof} \begin{example}\label{ex_fold_interpretation} The following is a safe interpretation for the PFS from Example~\ref{ex_fold_pafs}: \[ \begin{array}{rcll} \mathcal{T\!M}(\mathtt{List}) & = & \multicolumn{2}{l}{ \quant{\beta}{(\quant{\alpha}{\beta \rightarrow \alpha \rightarrow \beta}) \rightarrow \beta \rightarrow \beta}}\\ \mathcal{J}(\mathtt{@}) & = & \Lambda \alpha.\Lambda\beta. \lambda f.\lambda x. & f \cdot x \oplus \mathtt{lift}_\beta(\mathtt{flatten}_\alpha(x)) \\ \mathcal{J}(\mathtt{A}) & = & \Lambda \alpha.\Lambda \beta.\lambda x. & x * \beta \\ \mathcal{J}(\mathtt{nil}) & = & & \Lambda \beta.\lambda f.\abs{x}{x} \\ \mathcal{J}(\mathtt{cons}) & = & \Lambda \alpha.\lambda h.\lambda t. & \Lambda \beta.\lambda f.\lambda x. t \beta f (f \alpha x h \oplus \mathtt{lift}_\beta(\mathtt{flatten}_\beta(x)\ \oplus \\ & & & \phantom{ABCDEFGHIJKLMNOP,} \mathtt{flatten}_\alpha(h)))\ \oplus\ \\ & & & \phantom{ABCDE\ } \mathtt{lift}_\beta(\mathtt{flatten}_\beta(f\alpha x h) \oplus \mathtt{flatten}_\alpha(h) \oplus 1) \\ \mathcal{J}(\mathtt{foldl}) & = & \Lambda \beta.\lambda f. \lambda x. \lambda l. & l \beta f x \oplus \mathtt{lift}_\beta(\mathtt{flatten}_{\forall \alpha. \beta \rightarrow \alpha \rightarrow \beta}(f)\ \oplus \\ & & & \phantom{ABCDEFG\ \ } \mathtt{flatten}_\beta(x) \oplus 1) \\ \end{array} \] Note that $\mathcal{J}(\mathtt{cons})$ is \emph{not} required to be safe for $x$, since $x$ is not an argument of $\mathtt{cons}$: following its declaration, $\mathtt{cons}$ takes one type and two terms as arguments. The variable $x$ is only part of the \emph{interpretation}. Note also that the current interpretation is a mostly straightforward extension of Example~\ref{ex:notyetmono}: we retain the same \emph{core} interpretations (which, intuitively, encode $\mathtt{@}$ and $\mathtt{A}$ as forms of application and encode a list as the function that executes a fold over the list's contents), but we add a clause $\oplus \mathtt{lift}(\mathtt{flatten}(x))$ for each argument $x$ that the initial interpretation is not safe for. The only further change is that, in $\mathcal{J}(\mathtt{cons})$, the part between brackets has to be extended. This was necessitated by the change to $\mathcal{J}(\mathtt{foldl})$, in order for the rules to still be oriented (as we will do in Example \ref{ex_fold_final}). \end{example} \section{Proving termination with rule removal}\label{sec_rule_removal} A PFS $A$ is certainly terminating if its reduction relation $\arr{\mathcal{R}}$ is contained in a well-founded relation, which holds if $\ell \succ^{\Termmap} r$ for all its rules $(\ell,r)$. However, sometimes it is cumbersome to find an interpretation that orients all rules strictly. To illustrate, the interpretation of Example \ref{ex_fold_interpretation} gives $\ell \succ^{\Termmap} r$ for two of the rules and $\ell \succeq^{\Termmap} r$ for the others (as we will see in Example \ref{ex_fold_final}). In such cases, proof progress is still achieved through \emph{rule removal}. \begin{theorem}\label{thm:ruleremove} Let $\mathcal{R} = \mathcal{R}_1 \cup \mathcal{R}_2$, and suppose that $\mathcal{R}_1\subseteq{\succ^\mathcal{R}}$ and $\mathcal{R}_2\subseteq{\succeq^\mathcal{R}}$ for a reduction pair $(\succeq^\mathcal{R},\succ^\mathcal{R})$. Then $\arr{\mathcal{R}}$ is terminating if and only if $\arr{\mathcal{R}_2}$ is (so certainly if $\mathcal{R}_2 = \emptyset$). \end{theorem} \begin{proof} Monotonicity of~$\succeq^\mathcal{R}$ and~$\succ^\mathcal{R}$ implies that ${\arr{\mathcal{R}_1}}\subseteq{\succ^\mathcal{R}}$ and ${\arr{\mathcal{R}_2}}\subseteq{\succeq^\mathcal{R}}$. By well-foundedness of $\succ^\mathcal{R}$, compatibility of~$\succeq^\mathcal{R}$ and~$\succ^\mathcal{R}$, and transitivity of~$\succeq^\mathcal{R}$, every infinite $\arr{\mathcal{R}}$ sequence can contain only finitely many $\arr{\mathcal{R}_1}$ steps. \end{proof} The above theorem gives rise to the following \emph{rule removal} algorithm: \begin{enumerate} \item While $\mathcal{R}$ is non-empty: \begin{enumerate} \item Construct a reduction pair $(\succeq^\mathcal{R},\succ^\mathcal{R})$ such that all rules in $\mathcal{R}$ are oriented by $\succeq^\mathcal{R}$ or $\succ^\mathcal{R}$, and at least one of them is oriented using $\succ^\mathcal{R}$. \item Remove all rules ordered by $\succ^\mathcal{R}$ from $\mathcal{R}$. \end{enumerate} \end{enumerate} If this algorithm succeeds, we have proven termination. \medskip To use this algorithm with the pair $(\succeq^{\Termmap},\succ^{\Termmap})$ from Section~\ref{sec_reduction_pairs}, we should identify an interpretation $(\mathcal{T\!M},\mathcal{J})$ such that (a) $\mathcal{J}$ is safe, (b) all rules can be oriented with $\succeq^{\Termmap}$ or $\succ^{\Termmap}$, and (c) at least one rule is oriented with $\succ^{\Termmap}$. The first requirement guarantees that $(\succeq^{\Termmap},\succ^{\Termmap})$ is a reduction pair (by Theorem~\ref{thm_reduction_pair}). Lemma~\ref{lem_safe} provides some sufficient safety criteria. The second and third requirements have to be verified for each individual rule. \begin{example}\label{ex_fold_intermediate} We continue with our example of fold on heterogeneous lists. We prove termination by rule removal, using the symbol mapping from Example~\ref{ex_fold_interpretation}. We will show: \[ \begin{array}{rcl} @_{\sigma,\tau}(\abs{x:\sigma}{s},t) & \succeq^{\Termmap} & s[x:=t] \\ \mathtt{A}_{\abs{\alpha}{\sigma},\tau}(\tabs{\alpha}{s}) & \succeq^{\Termmap} & s[\alpha:=\tau] \\ \mathtt{foldl}_\sigma(f,s,\mathtt{nil}) & \succ^{\Termmap} & s \\ \mathtt{foldl}_\sigma(f,s,\mathtt{cons}_\tau(h,t)) & \succ^{\Termmap} & \mathtt{foldl}_\sigma(f,@_{\tau,\sigma}(@_{\sigma,\tau \rightarrow\sigma}( \mathtt{A}_{\abs{\alpha}{\sigma\rightarrow\alpha\rightarrow\sigma}, \tau}(f),s),h),t) \\ \end{array} \] Consider the first inequality; by definition it holds if $\interpret{@_{\sigma,\tau}(\abs{x:\sigma}{s},t)} \succeq \interpret{s[x:=t]}$. Since $\interpret{@_{\sigma,\tau}(\abs{x: \sigma}{s},t)} \leadsto^* \interpret{s}[x:=\interpret{t}] \oplus \mathtt{lift}_{\typeinterpret{\tau}}(\mathtt{flatten}_{\typeinterpret{\sigma}}( \interpret{t}))$, and $\interpret{s}[x:=\interpret{t}] = \interpret{s[x:=t]}$ (by Lemma~\ref{lem:substitutioninterpret}), it suffices by Lemma~\ref{lem_leadsto_to_approx} if $\interpret{s[x:=t]} \oplus \mathtt{lift}_{\typeinterpret{\tau}}(\mathtt{flatten}_{\typeinterpret{\sigma}}( \interpret{t})) \succeq \interpret{s[x:=t]}$. This is an instance of the general rule $u \oplus w \succeq u$ that we will obtain below. \end{example} To prove inequalities $s \succ t$ and $s \succeq t$, we will often use that $\succ$ and $\succeq$ are transitive and compatible with each other (Lem.~\ref{lem_transitive} and~\ref{lem:compatibility}), that $\leadsto\:\subseteq\:\approx$ (Lem.~\ref{lem_leadsto_to_approx}), that $\succeq$ is monotonic (Lem.~\ref{lem_succeq_subst}), that both $\succ$ and $\succeq$ are monotonic over $\mathtt{lift}$ and $\mathtt{flatten}$ (Lem.~\ref{lem:liftgreater} and \ref{lem_flatten_succ}) and that interpretations respect substitution (Lem.~\ref{lem:substitutioninterpret}). We will also use Lemma \ref{lem:plustimesmonotonic} which states (among other things) that $s \succ t$ implies $s \oplus u \succ t \oplus u$. In addition, we can use the calculation rules below. The proofs may be found in \onlypaper{\cite[Appendix~A.3]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{app_rule_removal}}. \begin{lemma}\label{lem:approxproperties} For all types $\sigma$ and all terms $s,t,u$ of type $\sigma$, we have: \begin{enumerate} \item\label{lem:approx:symmetry} $s \oplus_\sigma t \approx t \oplus_\sigma s$ and $s \otimes_\sigma t \approx t \otimes_\sigma s$; \item\label{lem:approx:assoc} $s \oplus_\sigma (t \oplus_\sigma u) \approx (s \oplus_\sigma t) \oplus_\sigma u$ and $s \otimes_\sigma (t \otimes_\sigma u) \approx (s \otimes_\sigma t) \otimes_\sigma u$; \item\label{lem:approx:distribution} $s \otimes_\sigma (t \oplus_\sigma u) \approx (s \otimes_\sigma t) \oplus_\sigma (s \otimes_\sigma u)$; \item\label{lem:approx:neutral} $(\mathtt{lift}_\sigma 0) \oplus_\sigma s \approx s$ and $(\mathtt{lift}_\sigma 1) \otimes_\sigma s \approx s$. \end{enumerate} \end{lemma} \begin{lemma}\label{lem_lift_approx} \begin{enumerate} \item\label{lem_lift_approx:plussplit} $\mathtt{lift}_\sigma(n+m) \approx_\sigma (\mathtt{lift}_\sigma n) \oplus_\sigma (\mathtt{lift}_\sigma m)$; \item $\mathtt{lift}_\sigma(n m) \approx_\sigma (\mathtt{lift}_\sigma n) \otimes_\sigma (\mathtt{lift}_\sigma m)$; \item $\mathtt{flatten}_\sigma(\mathtt{lift}_\sigma(n)) \approx n$. \end{enumerate} \end{lemma} \begin{lemma}\label{lem:plusparts} For all types $\sigma$, terms $s,t$ of type $\sigma$ and natural numbers $n > 0$: \begin{enumerate} \item\label{lem:plusparts:removefromsucceq} $s \oplus_{\sigma} t \succeq s$ and $s \oplus_{\sigma} t \succeq t$; \item $s \oplus_{\sigma} (\mathtt{lift}_{\sigma} n) \succ s$ and $(\mathtt{lift}_{\sigma} n) \oplus_{\sigma} t \succ t$. \end{enumerate} \end{lemma} Note that these calculation rules immediately give the inequality $x \oplus \mathtt{lift}_{nat \rightarrow \mathtt{nat}}(1) \succ x$ from Example~\ref{ex:plus1}, and also that $\mathtt{lift}_\sigma(n) \succ \mathtt{lift}_\sigma(m)$ whenever $n > m$. By Lemmas~\ref{lem:plustimesmonotonic} and~\ref{lem:plusparts} we can use \emph{absolute positiveness}: the property that (a) $s \succeq t$ if we can write $s \approx s_1 \oplus \dots \oplus s_n$ and $t \approx t_1 \oplus \dots \oplus t_k$ with $k \leq n$ and $s_i \succeq t_i$ for all $i \leq k$, and (b) if moreover $s_1 \succ t_1$ then $s \succ t$. This property is typically very useful to dispense the obligations obtained in a termination proof with polynomial interpretations. \begin{example}\label{ex_fold_final} We now have the tools to finish the example of heterogeneous lists (still using the interpretation from Example~\ref{ex_fold_interpretation}). The proof obligation from Example \ref{ex_fold_intermediate}, that $\interpret{@_{\sigma,\tau}(\abs{x:\sigma}{s},t)} \succeq \interpret{s[x:=t]}$, is completed by Lemma \ref{lem:plusparts}(\ref{lem:plusparts:removefromsucceq}). We have $\interpret{\mathtt{A}_{\abs{\alpha}{\sigma}, \tau}(\tabs{\alpha}{s})} \approx \interpret{\tabs{\alpha}{s}} * \typeinterpret{\tau} \approx \interpret{s[\alpha:=\tau]}$ by Lemma \ref{lem:substitutioninterpret}, and $\interpret{\mathtt{foldl}_\sigma(f,s,\mathtt{nil})} = \interpret{\mathtt{nil}}*\typeinterpret{\sigma} \cdot \interpret{f} \cdot \interpret{s} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\langle \text{something}\rangle\oplus 1) \approx \interpret{s} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\langle\text{something}\rangle\oplus 1) \succ \interpret{s}$ by Lemmas \ref{lem_lift_approx}(\ref{lem_lift_approx:plussplit}) and \ref{lem:plusparts}(\ref{lem:plusparts:removefromsucceq}). For the last rule note that (using only Lemmas \ref{lem_leadsto_to_approx} and \ref{lem_lift_approx}(\ref{lem_lift_approx:plussplit})): \[ \begin{array}{l} \interpret{\mathtt{foldl}_\sigma(f,s,\mathtt{cons}_\tau(h,t))} \approx \\ \interpret{\mathtt{cons}_\tau(h,t))} * \typeinterpret{\sigma} \cdot \interpret{f} \cdot \interpret{s} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}( \mathtt{flatten}(\interpret{f}) \oplus \mathtt{flatten}(\interpret{s}) \oplus 1) \approx \\ (\ \interpret{t} * \typeinterpret{\sigma} \cdot \interpret{f} \cdot (\interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h})))\ \oplus \\ \phantom{AB} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h}) \oplus \mathtt{flatten}(\interpret{h}) \oplus 1)\ )\ \oplus \\ \phantom{A} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{f}) \oplus \mathtt{flatten}(\interpret{s}) \oplus 1) \approx \\ \interpret{t} * \typeinterpret{\sigma} \cdot \interpret{f} \cdot (\ \interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h}))\ )\ \oplus \\ \phantom{A} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{f} * \typeinterpret{ \tau} \cdot \interpret{s} \cdot \interpret{h}) \oplus \mathtt{flatten}(\interpret{h}) \oplus \mathtt{flatten}(\interpret{f}) \oplus\mathtt{flatten}(\interpret{s}) \oplus 2) \\ \end{array} \] On the right-hand side of the inequality, noting that $\mathtt{lift}_{\sigma \rightarrow \tau}(u) \cdot w \leadsto^* \mathtt{lift}_{\tau}(u)$, we have: \[ \begin{array}{l} \interpret{\mathtt{foldl}_\sigma(f,@_{\tau,\sigma}(@_{\sigma,\tau \rightarrow\sigma}( \mathtt{A}_{\abs{\alpha}{\sigma\rightarrow\alpha\rightarrow\sigma}, \tau}(f),s),h),t)} \approx \\ \mathcal{J}(\mathtt{foldl})_\sigma(\interpret{f},\ \interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h})),\ \interpret{t}) \approx \\ \interpret{t} * \typeinterpret{\sigma} \cdot \interpret{f} \cdot (\ \interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h}))\ )\ \oplus \\ \phantom{A} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{f}) \oplus \mathtt{flatten}(\interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h}\ \oplus \\ \phantom{ABCDEFGHIJKLMNOPQRSt} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h}))) \oplus 1) \approx \\ \interpret{t} * \typeinterpret{\sigma} \cdot \interpret{f} \cdot (\ \interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h} \oplus \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h}))\ )\ \oplus \\ \phantom{A} \mathtt{lift}_{\typeinterpret{\sigma}}(\mathtt{flatten}(\interpret{f}) \oplus \mathtt{flatten}(\interpret{f} * \typeinterpret{\tau} \cdot \interpret{s} \cdot \interpret{h}) \oplus \mathtt{flatten}(\interpret{s}) \oplus \mathtt{flatten}(\interpret{h}) \oplus 1) \end{array} \] Now the right-hand side is the left-hand side $\oplus\ \mathtt{lift}(1)$. Clearly, the rule is oriented with $\succ$. Thus, we may remove the last two rules, and continue the rule removal algorithm with only the first two, which together define $\beta$-reduction. This is trivial, for instance with an interpretation $\mathcal{J}(@) = \Lambda \alpha.\Lambda \beta.\lambda f.\lambda x. (f \cdot x) \oplus \mathtt{lift}_\beta(\mathtt{flatten}_\alpha(x) \oplus 1)$ and $\mathcal{J}(\mathtt{A}) = \Lambda \alpha.\Lambda \beta.\lambda x. x * \beta \oplus \mathtt{lift}_{\alpha\beta}(1)$. \end{example} \section{A larger example}\label{sec:examples} System~$\mathtt{F}$ is System~$\mathtt{F}_\omega$ where no higher kinds are allowed, i.e., there are no type constructors except types. By the Curry-Howard isomorphism~$\mathtt{F}$ corresponds to the universal-implicational fragment of intuitionistic second-order propositional logic, with the types corresponding to formulas and terms to natural deduction proofs. The remaining connectives may be encoded in~$\mathtt{F}$, but the permutative conversion rules do not hold~\cite{Girard1989}. In this section we show termination of the system IPC2 (see~\cite{SorensenUrzyczyn2010}) of intuitionistic second-order propositional logic with all connectives and permutative conversions, minus a few of the permutative conversion rules for the existential quantifier. The paper~\cite{SorensenUrzyczyn2010} depends on termination of~IPC2, citing a proof from~\cite{Wojdyga2008}, which, however, later turned out to be incorrect. Termination of Curry-style~IPC2 without~$\bot$ as primitive was shown in~\cite{Tatsuta2007}. To our knowledge, termination of the full system~IPC2 remains an open problem, strictly speaking. \begin{remark} Our method builds on the work of van de Pol and Schwichtenberg, who used higher-order polynomial interpretations to prove termination of a fragment of intuitionistic first-order logic with permutative conversions~\cite{PolSchwichtenberg1995}, in the hope of providing a more perspicuous proof of this well-known result. Notably, they did not treat disjunction, as we will do. More fundamentally, their method cannot handle impredicative polymorphism necessary for second-order logic. \end{remark} The system IPC2 can be seen as a PFS with type constructors: \[ \begin{array}{c} \Sigma^T_\kappa = \{\quad \bot : *,\quad \mathtt{or} : * \Rightarrow * \Rightarrow *,\quad \mathtt{and} : * \Rightarrow * \Rightarrow *,\quad \exists : (* \Rightarrow *) \Rightarrow * \} \end{array} \] We have the following function symbols: \[ \begin{array}{rclcrcl} @ & : & \forall \alpha \forall \beta . (\alpha \rightarrow \beta) \rightarrow \alpha \rightarrow \beta & \quad & \epsilon & : & \forall \alpha . \bot \rightarrow \alpha \\ \mathtt{tapp} & : & \forall \alpha : * \Rightarrow * . \forall \beta . (\forall \beta [\alpha \beta]) \rightarrow \alpha \beta & \quad & \mathtt{pr}^1 & : & \forall \alpha \forall \beta . \mathtt{and}\, \alpha\, \beta \rightarrow \alpha \\ \mathtt{pair} & : & \forall \alpha \forall \beta . \alpha \rightarrow \beta \rightarrow \mathtt{and}\, \alpha\, \beta & \quad & \mathtt{pr}^2 & : & \forall \alpha \forall \beta . \mathtt{and}\, \alpha\, \beta \rightarrow \beta \\ \mathtt{case} & : & \forall \alpha \forall \beta \forall \gamma . \mathtt{or}\, \alpha\, \beta \rightarrow (\alpha \rightarrow \gamma) \rightarrow (\beta \rightarrow \gamma) \rightarrow \gamma & \quad & \mathtt{in}^1 & : & \forall \alpha \forall \beta . \alpha \rightarrow \mathtt{or}\, \alpha\, \beta \\ \mathtt{let} & : & \forall \alpha : * \Rightarrow * . \forall \beta . (\exists (\alpha)) \rightarrow (\forall \gamma . \alpha \gamma \rightarrow \beta) \rightarrow \beta & \quad & \mathtt{in}^2 & : & \forall \alpha \forall \beta . \beta \rightarrow \mathtt{or}\, \alpha\, \beta \\ \mathtt{ext} & : & \forall \alpha : * \Rightarrow * . \forall \beta . \alpha \beta \rightarrow \exists (\alpha) \end{array} \] The types represent formulas in intuitionistic second-order propositional logic, and the terms represent proofs. For example, a term $\mathtt{case}_{\sigma,\tau,\rho}\ s\ u\ v$ is a proof term of the formula $\rho$, built from a proof $s$ of $\mathtt{or}\ \sigma\ \tau$, a proof $u$ that $\sigma$ implies $\rho$ and a proof $v$ that $\tau$ implies $\rho$. Proof terms can be simplified using 28 reduction rules, including the following (the full set of rules is available in \onlypaper{\cite[Appendix~B]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{app_ineqs}}): \[ \begin{array}{rclrcl} @_{\sigma,\tau}(\abs{x}{s},t) & \longrightarrow & s[x:=t] & \mathtt{case}_{\sigma,\tau,\rho}(\mathtt{in}^1_{\sigma,\tau}(u), \abs{x}{s},\abs{y}{t}) & \longrightarrow & s[x:=u] \\ \mathtt{tapp}_{\abs{\alpha}{\sigma},\tau}(\tabs{\alpha}{s}) & \longrightarrow & s[\alpha:=\tau] & \mathtt{case}_{\sigma,\tau,\rho}(\mathtt{in}^2_{\sigma,\tau}(u), \abs{x}{s},\abs{y}{t}) & \longrightarrow & t[x:=u] \\ \mathtt{pr}^1_{\sigma,\tau}(\mathtt{pair}_{\sigma,\tau}(s,t)) & \longrightarrow & s & \mathtt{let}_{\varphi,\rho}(\mathtt{ext}_{\varphi,\tau}(s),\tabs{\alpha}{\abs{x}{t}}) & \longrightarrow & t[\alpha:=\tau][x:=s] \\ \mathtt{pr}^2_{\sigma,\tau}(\mathtt{pair}_{\sigma,\tau}(s,t)) & \longrightarrow & t \\ \end{array} \] \[ \begin{array}{ll} & @_{\sigma,\tau}(\epsilon_{\sigma \rightarrow \tau}(s),t) \longrightarrow \epsilon_\tau(s) \\ & \mathtt{case}_{\sigma,\tau,\rho}(\epsilon_{\mathtt{or}\,\sigma\,\tau}( u),\abs{x}{s},\abs{y}{t}) \longrightarrow \epsilon_\rho(u) \\ & \epsilon_\rho(\mathtt{case}_{\sigma,\tau,\bot}(u,\abs{x}{s}, \abs{y}{t})) \longrightarrow \mathtt{case}_{\sigma,\tau,\rho}(u,\abs{x}{\epsilon_\rho(s)}, \abs{y}{\epsilon_\rho(t)}) \\ & \mathtt{pr}^2_{\rho,\pi}(\mathtt{case}_{\sigma,\tau,\mathtt{and}\,\rho,\pi}(u, \abs{x:\sigma}{s},\abs{y:\tau}{t}))\longrightarrow \mathtt{case}_{\sigma,\tau,\pi}(u,\abs{x:\sigma}{\mathtt{pr}^2_{\rho,\pi}(s)}, \abs{y:\tau}{\mathtt{pr}^2_{\rho,\pi}(t)}) \\ & \mathtt{case}_{\rho,\pi,\xi}(\mathtt{case}_{\sigma,\tau,\mathtt{or}\, \rho\,\pi}(u,\abs{x}{s},\abs{y}{t}),\abs{z}{v}, \abs{a}{w}) \longrightarrow \\ & \phantom{AB} \mathtt{case}_{\sigma,\tau,\xi}(u,\abs{x}{\mathtt{case}_{ \rho,\pi,\xi}(s,\abs{z}{v},\abs{a}{w})}, \abs{y}{\mathtt{case}_{\rho,\pi,\xi}(t,\abs{z}{v}, \abs{a}{w})}) \\ & \mathtt{let}_{\varphi,\rho}( \mathtt{case}_{\sigma,\tau,\exists\varphi}( u,\abs{x}{s},\abs{y}{t}),v) \longrightarrow \mathtt{case}_{\sigma,\tau,\rho}(u, \abs{x}{\mathtt{let}_{\varphi,\rho}(s,v)}, \abs{y}{\mathtt{let}_{\varphi,\rho}(t,v)}) \\ \hspace{-10pt} (*) & \mathtt{let}_{\psi,\rho}(\mathtt{let}_{\varphi,\exists\psi}(s, \tabs{\alpha}{\abs{x:\varphi\alpha}{t}}),u) \longrightarrow \mathtt{let}_{\varphi,\rho}(s,\tabs{\alpha}{\abs{x: \varphi\alpha}{\mathtt{let}_{\psi,\rho}(t,u)}}) \\ \end{array} \] To define an interpretation for~IPC2, we will use the standard encoding of product and existential types (see~\cite[Chapter~11]{Girard1989} for more details). \[ \begin{array}{rclcrcl} \sigma \times \tau &=& \forall p . (\sigma \rightarrow \tau \rightarrow p) \rightarrow p & \quad & \pi^1_{\sigma,\tau}(t) &=& t \sigma (\abs{x:\sigma}{\abs{y:\tau}{x}}) \\ \pair{t_1}{t_2}_{\sigma,\tau} &=& \tabs{p}{\abs{x:\sigma\rightarrow\tau\rightarrow p}{x t_1 t_2}} & & \pi^2_{\sigma,\tau}(t) &=& t \tau (\abs{x:\sigma}{\abs{y:\tau}{y}}) \\ \Sigma \alpha . \sigma &=& \forall p . (\forall \alpha . \sigma \rightarrow p) \rightarrow p & \quad & \phantom{ABCD} \expair{\tau}{t}_{\Sigma\alpha.\sigma} &=& \tabs{p}{\abs{x:\forall\alpha.\sigma\rightarrow p}{x \tau t}} \\ & & \multicolumn{3}{r}{ \xlet{\rho}{t}{\alpha,x:\sigma}{s}} &=& t \rho (\tabs{\alpha}{\abs{x:\sigma}{s}}) \\ \end{array} \] We do not currently have an algorithmic method to find a suitable interpretation. Instead, we used the following manual process. We start by noting the minimal requirements given by the first set of rules (e.g., that $\mathtt{pr}^1_{\sigma,\tau}(\mathtt{pair}_{\sigma,\tau}(s, t)) \succeq s$); to orient these inequalities, it would be good to for instance have $\interpret{\mathtt{pair}_{\sigma,\tau}(s,t)} \succeq \pair{\interpret{s}}{\interpret{t}}_{\typeinterpret{\sigma}, \typeinterpret{\tau}}$ and $\interpret{\mathtt{pr}^i_{\sigma,\tau}(s)} = \pi^i_{\typeinterpret{\sigma},\typeinterpret{\tau}}(\interpret{s})$. To make the interpretation safe, we additionally include clauses $\mathtt{lift}(\mathtt{flatten}(x))$ for any unsafe arguments $x$; to make the rules \emph{strictly} oriented, we include clauses $\mathtt{lift}(1)$. Unfortunately, this approach does not suffice to orient the rules where some terms are duplicated, such as the second- and third-last rules. To handle these rules, we \emph{multiply} the first argument of several symbols with the second (and possibly third). Some further tweaking gives the following safe interpretation, which orients most of the rules: \[ \begin{array}{rclcrcl} \mathcal{T\!M}(\bot) & = & \mathtt{nat} & \quad & \mathcal{T\!M}(\mathtt{and}) & = & \lambda\alpha_1\lambda\alpha_2 . \alpha_1\times\alpha_2 \\ \mathcal{T\!M}(\exists) & = & \lambda(\alpha : * \Rightarrow *) . \Sigma \gamma . \alpha \gamma & \quad & \mathcal{T\!M}(\mathtt{or}) & = & \lambda\alpha_1\lambda\alpha_2 . \alpha_1\times\alpha_2 \\ \end{array} \] \[ \begin{array}{rcll} \mathcal{J}(\epsilon) & = & \Lambda \alpha:* . \lambda x:\mathtt{nat}. & \mathtt{lift}_\alpha(2 \otimes x \oplus 1) \\ \mathcal{J}(@) & = & \Lambda\alpha\Lambda\beta\lambda x: \alpha \rightarrow \beta . \lambda y : \alpha . \quad & \mathtt{lift}_\beta(2) \otimes (x \cdot y) \oplus \mathtt{lift}_\beta(\mathtt{flatten}_\alpha(y)\ \oplus \\ & & & \phantom{AB}\mathtt{flatten}_{\alpha \rightarrow \beta}(x) \otimes \mathtt{flatten}_\beta(y) \oplus 1) \\ \mathcal{J}(\mathtt{tapp}) & = & \Lambda \alpha : * \Rightarrow * . \Lambda \beta . \lambda x : \quant{\gamma}{\alpha\gamma} . \quad & \mathtt{lift}_{\alpha\beta}(2) \otimes (x * \beta) \oplus \mathtt{lift}_{\alpha\beta}(1) \\ \mathcal{J}(\mathtt{ext}) & = & \Lambda \alpha : * \Rightarrow * . \Lambda \beta : * . \lambda x:\alpha\beta . & \expair{\beta}{x} \oplus \mathtt{lift}_{\Sigma\gamma.\beta\gamma}( \mathtt{flatten}_{\alpha\gamma}(x)) \\ \mathcal{J}(\mathtt{pair}) & = & \Lambda \alpha \Lambda \beta \lambda x : \alpha, y : \beta.\quad & \pair{x}{y} \oplus \mathtt{lift}_{ \alpha \times \beta}(\mathtt{flatten}_\alpha(x) \oplus \mathtt{flatten}_{\beta}(y)) \\ \mathcal{J}(\mathtt{pr}^1) & = & \Lambda \alpha \Lambda \beta \lambda x : \alpha \times \beta . \quad & \mathtt{lift}_\alpha(2) \otimes \pi^1(x) \oplus \mathtt{lift}_{\alpha}(1) \\ \mathcal{J}(\mathtt{pr}^2) & = & \Lambda \alpha \Lambda \beta \lambda x : \alpha\times\beta.\quad & \mathtt{lift}_\beta(2) \otimes \pi^2(x) \oplus \mathtt{lift}_{\beta}(1) \\ \mathcal{J}(\mathtt{in}^1) & = & \Lambda \alpha \Lambda \beta \lambda x : \alpha.\quad & \pair{x}{\mathtt{lift}_\beta(1)} \oplus \mathtt{lift}_{\alpha \times \beta}(\mathtt{flatten}_{\alpha}(x)) \\ \mathcal{J}(\mathtt{in}^2) & = & \Lambda \alpha \Lambda \beta \lambda x : \beta.\quad & \pair{\mathtt{lift}_\alpha(1)}{x} \oplus \mathtt{lift}_{\alpha \times \beta}(\mathtt{flatten}_{\beta}(x)) \\ \end{array} \] \[ \begin{array}{rcl} \mathcal{J}(\mathtt{let}) & = & \Lambda \alpha : * \Rightarrow * . \Lambda \beta : * . \lambda x : \Sigma \xi . \alpha\xi, y : \quant{\xi}{\alpha\xi \rightarrow \beta}. \\ & & \mathtt{lift}_\beta(1) \oplus \mathtt{lift}_\beta(2) \otimes (\xlet{\beta}{x}{\xi,z}{y\xi z})\ \oplus \\ & & \mathtt{lift}_\beta(\mathtt{flatten}_{\Sigma\gamma.\alpha\gamma}(x) \oplus 1) \otimes (y * \mathtt{nat} \cdot \mathtt{lift}_{\alpha\mathtt{nat}}(0)) \\ \mathcal{J}(\mathtt{case}) & = & \Lambda \alpha,\beta,\xi . \lambda x : \alpha \times \beta, y : (\alpha \rightarrow \xi), z : (\beta \rightarrow \xi). \\ & & \quad \mathtt{lift}_\xi(2) \oplus \mathtt{lift}_\xi(3 \otimes \mathtt{flatten}_{\alpha \times \beta}(x)) \oplus \\ & & \quad\phantom{ABCDE} \mathtt{lift}_\xi(\mathtt{flatten}_{\alpha \times \beta}(x) \oplus 1) \otimes (y \cdot \pi^1(x) \oplus z \cdot \pi^2(x)) \\ \end{array} \] Above, $\otimes$ binds stronger than~$\oplus$. The derivations to orient rules with these interpretations are also given in \onlypaper{\cite[Appendix~B]{versionwithappendix}}% \onlyarxiv{Appendix~\ref{app_ineqs}}. The only rules that are not oriented with this interpretation -- not with~$\succeq$ either -- are the ones of the form $f(\mathtt{let}(s,t), \dots) \longrightarrow \mathtt{let}(s,f(t,\dots))$, like the rule marked (*) above. Nonetheless, this is already a significant step towards a systematic, extensible methodology of termination proofs for IPC2 and similar systems of higher-order logic. Verifying the orientations is still tedious, but our method raises hope for at least partial automation, as was done with polynomial interpretations for non-polymorphic higher-order rewriting~\cite{FuhsKop2012}. \section{Conclusions and future work} We introduced a powerful and systematic methodology to prove termination of higher-order rewriting with full impredicative polymorphism. To use the method one just needs to invent safe interpretations and verify the orientation of the rules with the calculation rules. As the method is tedious to apply manually for larger systems, a natural direction for future work is to look into automation: both for automatic verification that a given interpretation suffices and -- building on existing termination provers for first- and higher-order term rewriting -- for automatically finding a suitable interpretation. In addition, it would be worth exploring improvements of the method that would allow us to handle the remaining rules of IPC2, or extending other techniques for higher-order termination such as orderings (see, e.g., \cite{jou:rub:07}) or dependency pairs (e.g.,~\cite{kop:raa:12,suz:kus:bla:11}). \addcontentsline{toc}{section}{References}
{'timestamp': '2019-04-23T02:25:55', 'yymm': '1904', 'arxiv_id': '1904.09859', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09859'}
arxiv
\section{Introduction} \label{sec:Intro} The replicability crisis---the phenomenon that conclusions from many scientific studies are unable to be verified in follow-up studies---was dramatically brought to the forefront when researchers at the biotech company Amgen attempted to replicate 53 well-regarded pre-clinical studies only to find that just 6 supported the original conclusions~\citep{begley2012raise}. Failures to replicate have been shown to occur across all scientific domains~\citep{begley2015reproducibility}. A survey of Nature readers found that about 70$\%$ of scientists have failed to replicate other researchers' experimental results, and more than 50$\%$ have failed to replicate results of their own studies~\citep{baker2016there}. The \citet{NAP25303} define \textit{replicability} as ``obtaining consistent results across studies aimed at answering the same scientific question, each of which has obtained its own data,'' and recently addressed the replicability crisis from the point of view of science in general. The statistics community came out with a special issue of The American Statistician to deal with statistical issues~\citep{ronspaper}. Much of the literature has pointed to familiar culprits behind the replicability crisis: $p$-hacking, insufficient power, inappropriate analyses given the data, variability of $p$-values, overstated evidence, and so on~\citep{ioannidis2009repeatability,boos2011p,allison2018reproducibility, bello2018invited, gibson2020role}. Concerns about replicability have led to an overall distrust of $p$-values and claims of statistical significance. It has progressed to the point where practitioners have recommended removing such terms and phrases completely~\citep{woolston2015psychology,ronspaper}. While the aforementioned violations of recommended statistical practice are common reasons why an experiment cannot be replicated, we shed light on another concern, namely the \textit{research environment} and its effect on the treatments and outcomes. The research environment encompasses the totality of conditions under which an experiment is done. This includes the population, if any, the protocol, personnel, and the prevailing conditions such as the weather, location, equipment, and time of day or year. It also includes unrecognized random factors that could systematically bias outcomes in unknown ways. The research environment is unique to each experiment; it changes when the experiment is repeated. The magnitude of the change may be small, as in a tightly controlled laboratory experiment or large, as in an agricultural field trial. Furthermore, if there is environment by treatment interaction, which appears to be common in research~\citep{berliner2002comment, Kafkafi:2005, kafkafi2017addressing, kafkafi2018reproducibility, snape2007dissecting}, treatments with large effects in one environment could have small effects in another; moreover, such discrepancies are not the result of misuse of statistical methods but occur because of inherent difficulties in doing an experiment exactly the same way twice. The effect of a changing research environment on replicability may be inferred by performing the same experiment in several randomly selected environments and applying a mixed model analysis to assess treatment effects. Such mixed-model analysis has been a staple of fields including agriculture, biology, and psychology~\citep{littell1996sas, milliken2009analysis, Kafkafi:2005, cronbach1963theory, cronbach1972dependability, shavelson1989generalizability}. However, this approach is limited because it is often impractical to do a study more than once due to costs, time, or lack of incentives for carrying out replication studies~(\citetalias[p.~137--138]{NAP25303},~\citealt{koole2012rewarding, lundwall2019changing}). Meta-analysis may be appropriate when the same treatments are studied in several environments, usually with non-identical experiments, and the desire is to come up with estimates of treatment effects that are better than one could get with a single experiment~\citep{lipsey2001practical, borenstein2011introduction}. Typically, measures of replicability do not account for a changing environment. For example, \citet{goodman1992comment} proposed the ``probability of repeating a significant result in the same direction.'' It is computed after an initial experiment is done and assumes that the follow-up experiment, if it were to be done, would be done under the identical conditions of the initial experiment. \citet{trafimow2018priori} computed a “probability of replication” based on a criterion of closeness of sample means to population means in the initial and follow-up experiments. It can be computed before any experimentation is done, but it also does not account for random environmental effects except for sampling error. In practice, replicability is often just an assumption based on the scientific tenet that experiments done the same way will produce the same results. However, the replicability crisis has brought this assumption into question. Thus, it would be desirable to have probability-based inferences that can assess whether an assumption of replicabilty is reasonable in light of potential changes in the research environment that may occur in future experiments. \citet{kafkafi2017addressing} dealt with this problem in the context of single-laboratory genetic experiments. They assumed that observations from a single laboratory are governed by the same mixed model that would apply to multiple-laboratory experiments. They estimated genotype-by-laboratory interaction from previous studies and combined this information with the data from the present experiment to adjust the variance of the difference of means. They used the $t$-statistic with Satterthwaite’s approximation for degrees of freedom to obtain $p$-values and confidence intervals that are "adjusted" for changing environments. We propose a conceptual framework for thinking about replicability that makes it possible to pose and answer a broader array of questions than could be addressed with just a single number such as ``probability of replicability.'' Replicability in our framework is about the consistency of the properties of inferential procedures as they are applied to initial and follow-up experiments. The initial experiment is where the data are taken; the follow-up experiment is a hypothetical construct that enables us to ask and answer ``what if'' questions about replicability in a changing research environment. For instance, if the initial experiment has a desirable power for a given pre-specified effect size, how would the power be affected by the change in environment in a follow-up experiment? Couching replicability in terms of properties of inferential procedures rather than experimental outcomes is implicit in the popular recommendation to use large $n$ and small $p$ as a means to deal with replicability problems~\citep{singh2017big}. Here, the properties that are assumed to be replicable are small probabilities of Type I and Type II errors. Ironically, we are able to use our conceptualization to show serious flaws in this recommendation (see Section~\ref{subsec:ex2}). We measure the size of the environmental effect with a dimensionless parameter that we call the environmental effect ratio EER, which is the ratio of the standard deviations of environment-by-treatment interaction and the experimental error. We obtain exact distributions of the statistical quantities of interest by assuming that EER is known. We further assume that information is available that would enable the researcher to place reasonable bounds on EER and therefore to be able to place reasonable bounds on quantities that depend on it. Additionally, we show that by varying EER, it is possible to examine the sensitivity of methods to a changing research environment. We apply this approach to power, sample size selection, $p$-values, and confidence levels. In so doing we are able to determine conditions that are favorable for replicability and those that are not. In addition to EER, these conditions depend on sample size, effect size, and in the case of hypothesis testing, nominal significance levels. Section 2 has the mathematical model and exact distributional properties of the t-statistic under the mixed model. Section 3 considers the effect of the research environment on power, relative efficiency, and sample size selection. In Section 4 we derive broad-inference p-values and confidence intervals, which are functions of EER, and show how these can be used to help researchers make inferences across multiple environments from data taken from just one environment. Section 5 gives plausible values of EER from data that have been taken in multi-environment experiments. Section 6 has summary and conclusions. \section{Model} \label{sec:Model} We consider an experiment with two treatment conditions $r \in (1,2)$. Observations from the initial experiment are assumed to follow the model \begin{equation} \label{eq:initialmodel} Y_{rj} = \mu_r + \epsilon_{rj},\;\;\ r = 1,2, \;j = 1,\ldots, n_r \end{equation} where $\mu_r$ is the mean of the $r$th treatment in the environment in which the initial experiment is run, $n_r$ is the number of units assigned to treatment $r$, and the $\epsilon_{rj}$'s are independent and identically distributed (iid) $N(0, \sigma^2_e)$ random variables. We are interested in inferences for $\mu_1 - \mu_2$. In a follow-up experiment, the changing research environment is assumed to affect the responses all in the same way or in ways unique to each treatment. We express this with the mixed model \begin{equation} \label{eq:followupmodel} Y_{rj} = \mu_r + \theta + \delta_r + \epsilon_{rj},\;\;\ r = 1,2, \;j = 1,\ldots, n_r. \end{equation} The $\mu_{r}$'s are the same as in the model~\eqref{eq:initialmodel} and the $\epsilon_{rj}$'s follow the assumptions of model~\eqref{eq:initialmodel}. The term $\theta$ represents a random source of variability common to all observations. The $\delta_r$'s, which are the interaction terms, represent random sources of variability unique to each treatment. For instance, in comparing two varieties of wheat, both may respond favorably in going from a drier to moister environment as expressed by the common effect $\theta$, but one variety may respond better than another as expressed through the $\delta_r$'s. The greatest danger to inferring replicability in a changing research environment lies not in those factors that we recognize as having an effect. They often can be accounted for in the model. Rather it is those unknown or unexpected sources of variability that can systematically affect outcomes in unexpected ways. Those are the factors whose effects are captured by the random environmental terms. The $\delta_r$'s are assumed to be distributed as iid $N(0, \sigma^2_\delta)$, and $\theta$ is assumed to be distributed as $N(0, \sigma^2_{\theta})$ although its distribution does not figure into the discussion except in Section~\ref{sec:realeer}. The random terms in model~\eqref{eq:followupmodel} are assumed to be mutually independent. For brevity, we may use M1 to refer to model~\eqref{eq:initialmodel} and M2 to refer to model~\eqref{eq:followupmodel}. \subsection{Test Statistic and Distribution} Let us consider testing $H_0\!: \mu_1 - \mu_2 = 0$ against $H_a\!: \mu_1 - \mu_2 \neq 0$. Let $n_h$ denote the harmonic mean of the observations \begin{equation} \label{eq:defineharmonicmean} n_h = \frac{2}{1/n_1 + 1/n_2}. \end{equation} The test statistic is \begin{equation} \label{eq:defineteststatistic} T = \frac{\overline Y_1 - \overline Y_2}{S_e\sqrt{2/n_h}} \end{equation} where $\bar Y_r$ the sample mean of the responses for treatment $r$ and $S_e$ is the pooled standard deviation of experimental error. The treatment effect size (TES), denoted $\Delta$, is defined by \begin{equation} \label{eq:definetes} \Delta = \frac{\mu_1 - \mu_2}{\sigma_e\sqrt{2}}. \end{equation} A variant of TES used in the social sciences excludes the $\sqrt{2}$ factor in the denominator, the sample version of which is Cohen's $d$~\citep{cohen1988statistical}. We include the $\sqrt{2}$ because it simplifies some of the mathematical expressions given below. It is also the standard deviation of the difference between two observations, one from each treatment. The environmental effect ratio (EER), denoted $\omega$, is \begin{equation} \label{eq:defineeer} \omega = \frac{\sigma_\delta}{\sigma_e}. \end{equation} Both $\Delta$ and $\omega$ are dimensionless quantities that can be interpreted without reference to the scale of measurement of the responses or indeed to the area of application. The EER also has a connection with Cohen's $d$. Under M2, the variance of the difference between sample means is approximately $2\sigma^2_\delta$ when sample sizes are large. If we divide this by the error variance $\sigma^2_e$ , this quantity is $\tau^2$, the variance of Cohen’s population effect size~\citep{higgins2002quantifying}. That is, $2\omega^2 = \tau^2$ under M2. Under M2, it can be shown that $T/\sqrt{1 + n_h\omega^2}$ has a noncentral t-distribution with degrees of freedom $df = n_1 + n_2 - 2$ and noncentrality parameter \begin{equation} \label{eq:noncentralityparameter} \frac{\Delta\sqrt{n_h}}{\sqrt{1 + n_h\omega^2}}. \end{equation} We denote the cumulative distribution function (cdf) of this noncentral $t$-distribution as $G_\Delta(t)$. The cdf of $T$ under model (2) is given by \begin{equation} \label{eq:definecdft} P(T \leq t~|~\text{M2} ) = G_\Delta\left(\frac{t}{\sqrt{1+n_h\omega^2}} \right). \end{equation} The distribution of $T$ under M1 is obtained by setting $\omega = 0$, and under the null hypothesis $H_0\!: \mu_1 -\mu_2 = 0$, by setting $\Delta = 0$. When $\Delta = 0$, $G_\Delta(t)$ is the cdf of the (central) t-distribution with $df = n_1 + n_2 - 2$, which we denote as $G_0(t)$. For large samples, the distribution of $T$ can be approximated by a normal distribution with mean $\Delta \sqrt{n_h}$ and variance $1 + n_h\omega^2$. \section{Replicability Power} \label{sec:probofrep} Suppose the researcher plans the two-sample experiment so that the test achieves a sufficiently large power for a pre-specified treatment effect size $\Delta$ and significance level $\alpha$. For the two-sided test the sample size computation does not depend on the direction of the effect, either positive or negative. However, the direction becomes important because of what can happen in the follow-up experiment. While the probability of rejection in the wrong direction, e.g. lower-tail rejection when $\mu_1 > \mu_2$, is less than $ \alpha/2$ in the initial experiment, it can be as large as $1/2$ in the follow-up experiment as we discuss below. Thus, in considering the power of the follow-up experiment, we must not only consider the magnitude of the effect but also its direction. Intuitively, \textit{replicability power} is the probability of detecting an effect of a pre-specified magnitude and direction computed under model~\eqref{eq:followupmodel}. This discussion would be unnecessary if we were to do one-sided tests with one-sided power functions, but in doing so, we would fail to consider an important measure of what can go wrong with inferences in a follow-up experiment, namely, the probability of getting significance in the wrong direction in a two-sided test. We assume that $\mu_1 > \mu_2$ in testing $H_0\!: \mu_1 - \mu_2 = 0$ against $H_a\!: \mu_1 - \mu_2 \neq 0$. Let $t_{\alpha/2}$ denote the $1-\alpha/2$ quantile of the $t$-distribution with $df = n_1 + n_2 - 2$. With $T \geq t_{\alpha/2}$ being the right direction for rejection in the initial experiment, we obtain from~\eqref{eq:definecdft} that the replicability power, denoted by $p_{rep}$, is \begin{equation} \label{eq:probofrep} p_{rep} = P(T \geq t_{\alpha/2}~|~\text{M2}) = 1-G_\Delta\left(t_{\alpha/2}/\sqrt{1+n_h\omega^2}\right), \end{equation} and for large $n_1, n_2 $ \begin{equation} \label{eq:asympprobofrep} p_{rep}\approx 1 - \Phi\left(\frac{z_{\alpha/2} - \Delta\sqrt{n_h}}{\sqrt{1+n_h\omega^2}} \right) \end{equation} where $\Phi$ is the cdf of the standard normal distribution and $z_{\alpha/2}$ is the $1-\alpha/2$ quantile of the standard normal distribution. From expressions~\eqref{eq:definecdft},~\eqref{eq:probofrep}, and~\eqref{eq:asympprobofrep}, we can see that $p_{rep} \rightarrow 1/2$ and $P(T \leq -t_{\alpha/2}) \rightarrow 1/2$ as $\omega \rightarrow \infty$. That is, the replicability power can be as small as 1/2 for large EER regardless of the level of significance and power of the initial experiment, and the probability of an inference in the wrong direction can be as large as 1/2. \subsection{The Effect of EER on Replicability Power} The examples below demonstrate how EER affects replicability power both in small and large samples and for varying effect sizes and significance levels. \subsubsection{Example 1: Small \texorpdfstring{$n$}{n} and Traditional \texorpdfstring{$\alpha$}{alpha} \label{subsec:ex1}} \citet{snedecor1980statistical} illustrate the independent sample $t$-test with data from a study to compare the comb weights of male chicks given one of two hormone treatments. The sample sizes are $n_1 = n_2 =11$, the sample means are $97$ and $56$, and the pooled standard deviation is $12.14$. A test for differences of means gives $p = .003$ for a two-sided test. The observed treatment effect size is 1.02, and a 95\% confidence interval for the true TES is $(.32, 1.72)$~\citep{kadel2012sas}. To illustrate the sensitivity of the replicability power to EER, suppose that follow-up experiment like this one is planned in which $n_1 = n_2 = 11$, $\alpha = .05$, and true treatment effect size that is of importance is $\Delta = 1.0$. The $.975$ quantile of the $t$-distribution with $df = 20$ is $2.086$, so the replicability power is $p_{rep} = P(T \geq 2.086 ~|~ \text {M2})$. Figure~\ref{figure1} shows plots of $p_{rep}$, probability of significance in the wrong direction, and probability of non-significance as functions of EER. If the EER $\omega = 0$, then $p_{rep}$ is $.88$ which is the same as the power of the initial test for $\Delta = 1.0$. Small values of EER ensure that $p_{rep}$ is large in the follow-up experiment. However, as EER increases, $p_{rep}$ decreases. For instance, if EER= .5, then $p_{rep} = .74$ and the probability of non-significance increases to $.26$. The probability of significance in the wrong direction is negligible in this instance but increases with increasing EER. \begin{figure}[ht \centering \includegraphics[width = \textwidth]{nfigure1.pdf} \caption{Replicability power, probability of significance in the wrong direction, and probability of non-significance vs.~the environmental effect ratio (EER). Here, the treatment effect size $\Delta = 1.0$, $n_1 = n_2 = 11$, and $\alpha = .05$. The power of the initial study is $.88$, but the power of follow-up studies may be significantly lower when EER is large.} \label{figure1} \end{figure} \subsubsection{Example 2: Large \texorpdfstring{$n$}{n} and Small \texorpdfstring{$\alpha$}{alpha}\label{subsec:ex2}} An initial experiment with a large sample size and small significance level has a low probability of a false positive and a high probability of detecting a treatment effect size of practical importance. Thus, large $n$ and small $p$ are often recommended as a prescription for solving replicability problems as discussed in~\citet{singh2017big}. However, this can fail in the face of a changing research environment. Table~\ref{tab:largen} gives an example in which $n_1 = n_2 = 300$, $\alpha =.005$, and $\Delta = .25$ or $1.0$. The power of the initial test is $.94$ when $\Delta = .25$, but in a follow-up experiment with the same TES in which EER = .5, the replicability power is just $.57$, and the probabilities of finding a non-significant result and significance in the wrong direction are $.22$ and $.21$, respectively. On the other hand, if $\Delta = 1.0$, the replicability power is $.95$, and the probabilities of finding non-significance and significance in the wrong direction are negligible. \begin{table} \begin{center} \begin{tabular}{|l| c| c|}\cline{2-3} \multicolumn{1}{c|}{}& $\Delta = 0.25$ & $\Delta = 1.00$ \\ \hline Power of initial test: Model~\eqref{eq:initialmodel} & 0.93 & 1.00 \\ Replicability power: Model~\eqref{eq:followupmodel} & 0.57 & 0.95 \\ Prob. significant in wrong direction & 0.21 & 0.01 \\ Prob. non-significant & 0.22 & 0.04\\ \hline \end{tabular} \end{center} \caption{Replicability power for treatment effect size $\Delta = .25, 1.0$. Probabilities are computed setting the environmental effect ratio $\omega = 0.5$, $n_1 = n_2 = 300$, and $\alpha = .005$.} \label{tab:largen} \end{table} Additional insight can be gained by looking at the limiting case as $n_1, n_2 \rightarrow \infty$. Under the initial model M1, the power approaches 1 as $n_r \rightarrow \infty$ for any non-zero TES,but this is not the case for the replicability power under model M2. Because the distribution of the sample means depends on the $\epsilon_{rj}$'s through the standard error $\sigma_e/\sqrt{n_r}$, which is negligible for large samples, the distribution of $T$ in the limit depends only on the distribution of the $\delta_r$'s and is independent of the level of significance. Expressed in terms of $\Delta/\omega$ , the replicability power in the limit is given by \begin{equation} \label{eq:probreplim} \lim_{n_h\to \infty} P(T \geq t_{\alpha/2} ~|~ \text{M2}) = \Phi(\Delta/\omega), \end{equation} and the probability of significance in the wrong direction is $1-\Phi(\Delta/\omega)$. For instance, if $\Delta = .25$ and $\omega = .5$, the limit is $.69$, which is the largest that the replicability power can be as a function of sample size for these values of $\Delta$ and $\omega$, and the probability of significance in the wrong direction is $.31$. However, if $\Delta = 1$, these limiting values are .98 for power and .02 for probability of significance in the wrong direction. Thus, as expected, larger values of TES help mitigate the negative effects of EER on replicability power. This is further is illustrated in Figure~\ref{figure2} which has plots of the limiting replicability power in~\eqref{eq:probreplim} and probability of significance in the wrong direction vs EER for $\Delta = .25$ and $1.0$. \begin{figure}[ht \centering \includegraphics[width = \textwidth]{nfigure2.pdf} \caption{Limiting replicability power and significance in the wrong direction vs.~the environmental effect ratio (EER) $\omega$ for treatment effect size (TES) $\Delta = .25$ and $1.0.$. Replicability power deviates from 1.0 quickly as the ratio $\Delta/\omega$ decreases. } \label{figure2} \end{figure} \subsection{Relative Efficiency of the Initial and Follow-up Experiments} If two tests that are performed at the same level of significance have the same power for a given effect size, then the ratio of their respective sample sizes is a measure of the relative efficiency of the two tests. We adapt this idea to obtain the relative efficiency of the $t$-test when applied to the initial and follow-up experiments. Suppose $\mu_1 > \mu_2$ as before and suppose, for a given $\Delta$ and $\alpha$, we would like the replicability power to be the same as the power of the initial test. Let $n_I$ and $n_F$ be sample sizes per treatment in the initial and follow-up experiments, respectively, so that the initial and replicability powers are the same. The relative efficiency of the follow-up experiment to the initial experiment is $n_I/n_F$. For simplicity, we use the normal approximation in~\eqref{eq:asympprobofrep}. The sample size $n_I$ necessary for the initial experiment to have power $1-\beta$ for treatment effect size $\Delta$ is $n_I = (z_{\alpha/2} + z_{\beta})^2/\Delta^2$. For the follow-up experiment, $n_F$ can be found by setting the replicability power~\eqref{eq:asympprobofrep} to $1 - \beta$ and solving for $n_F$. This is equivalent to solving for $n_F$ in the formula \begin{equation} \label{eq:findnmodel2} z_{\alpha/2} + z_\beta\sqrt{1+n_F\omega^2} = \Delta \sqrt{n_F}. \end{equation} It is possible that there is no value of $n_F$ that will satisfy~\eqref{eq:findnmodel2}, in which case, the relative efficiency is $0$. \begin{figure}[ht \centering \includegraphics[width = \textwidth]{nfigure3.pdf} \caption{Relative efficiency in sample sizes between the initial and follow up experiments vs.~environmental effect ratio (EER) $\omega$ for varying treatment effect sizes (TES) $\Delta$. Here, $\alpha = .05$ and $1-\beta = .8$. Relative efficiency decreases rapidly as the ratio $\Delta/\omega$ decreases.} \label{figure3} \end{figure} Figure~\ref{figure3} shows plots of the relative efficiencies against EER for values of the TES $\Delta = .25$ and $.5$ given level of significance $\alpha = .05$ and power of the initial experiment set at $.8$. If $\Delta = .25$ and $\omega = .2$, the sample sizes are $n_I = 126$ and $n_F = 626$ with relative efficiency of only $.20$ (computed sample sizes are rounded up to the nearest integer). Relative efficiency increases with increasing $\Delta$. For instance, if $\Delta = .5$ when $\omega$ = .2, the sample sizes are $n_I = 32$ and $n_F = 46$, giving a relative efficiency of .70. A researcher who wishes to have the results of the initial experiment confirmed by a follow-up experiment is at a disadvantage if the follow-up experiment is done at the same sample size as the initial experiment. The loss of efficiency in the follow-up experiment can be substantial. One may be able to compensate by adjusting the sample size of the follow-up experiment to put it on an equal footing with the initial experiment, although this is not always possible. As with all sample size determinations, prior knowledge of the size of the variance components is required to determine the sample size for the follow-up experiment. \section{Assessing Replicability through Varying EER} \label{sec:adjpval} We now discuss the sensitivity of inferences to changes in environment through evaluating inferential quantities across a range of hypothetical values for the EER. We first derive, what we call, \textit{broad-inference} $p$-values and confidence levels that take into account the environmental variability present in the follow-up experiment. These inferential quantities are functions of the data and the unknown EER parameter $\omega$. We then demonstrate how evaluating these quantities across a spectrum of hypothetical EER values can aid researchers in assessing the replicability of an experiment, and in particular, help determine how much environmental variability may be tolerated before results can no longer expect to be replicated. This analysis can be performed graphically through EER \textit{profile plots}. The process is similar to the sensitivity analysis approach popularized by~\citet{rosenbaum2002overt}, except results are evaluated under differing magnitudes of unobserved across-experiment variability rather than unobserved confounding. \subsection{Broad-Inference \texorpdfstring{$p$}{p}-Values and Confidence Levels} We now derive the broad-inference $p$-values and confidence intervals. Our derivation is similar to that in~\citet{kafkafi2017addressing} except we write expressions in terms of the unobserved EER $\omega$. Suppose that a follow-up experiment is performed in a randomly selected environment. Consider the conditional distribution of $T$ in that environment given $\delta_1 = \delta^*_1$ and $\delta_2 = \delta^*_2$. This distribution depends on $\mu_1 - \mu_2 + \delta^*_1 - \delta^*_2$ instead of only $\mu_1 - \mu_2$ as in M1. Thus, an observed value of $T$ that may be judged “extreme” under M1 and $H_0\!: \mu_1 - \mu_2 = 0$ may be either more extreme or less extreme under the follow-up model M2 depending on the size of the (unobserved) $\delta^*_1 - \delta^*_2$. Also, the conditional confidence interval in the follow-up experiment is centered on $\mu_1 - \mu_2 + \delta^*_1 - \delta^*_2$ not $\mu_1 - \mu_2$, so the stated level of confidence for capturing $\mu_1 - \mu_2$ in the interval is smaller under M2 than under M1. The broad-inference values are conceptually computed by averaging the conditional $p$-values and confidence levels across the environments, i.e. with respect to the distribution of $\delta_1 - \delta_2$. However, we performed the actual computations directly from~\eqref{eq:definecdft}. \subsubsection{Broad-Inference \texorpdfstring{$p$}{p}-Value} The observed effect size computed from the initial experiment is defined to be \begin{equation} \label{eq:defineobseffsize} \Delta^* = \frac{\bar y_1 - \bar y_2}{\sqrt 2 s_e}, \end{equation} where the lower-case letters denote observed values from the two treatments. We assume $\Delta^* > 0$ consistent with our assumption that $\mu_1 > \mu_2$. Because the distribution of $T$ under M2 is given by~\eqref{eq:probofrep} with $\mu_1 - \mu_2 = 0$ and $df = n_1 + n_2 -2$, the broad-inference two-sided $p$-value for the effect size $\Delta^*$ in a follow-up experiment is \begin{equation} \label{eq:adjpvalue} P\left(|T| > \Delta^*\sqrt{n_h} ~|~ \text{M2}, \mu_1 - \mu_2 = 0\right) = 2\left(1- G_0\left(\frac{\Delta^*\sqrt{n_h}}{\sqrt{1+ n_h\omega^2}}\right)\right). \end{equation} The limit of~\eqref{eq:adjpvalue} as $n_h \to \infty$ is the \textit{asymptotic} broad-inference $p$-value, which is \begin{equation} \label{eq:asymtpvalue} 2(1-\Phi(\Delta^*/\omega)). \end{equation} Note that~\eqref{eq:adjpvalue} decreases as $n_h$ increases so that the asymptotic broad-inference $p$-value is also the minimum. For the asymptotic broad-inference $p$-value to be $\alpha$, we must have $\Delta^* = z_{\alpha/2}\omega$. If $\Delta^*$ is less than this, the broad-inference $p$-value cannot attain a level of significance $\alpha$ regardless of sample size. \subsubsection{Broad-Inference Level of Confidence and Confidence Intervals} Confidence intervals may be preferred to hypothesis tests because they provide more information, but whether one uses confidence intervals or hypothesis tests, the problems posed by the random factors in the follow-up model do not go away. The confidence interval $(\bar y_1 - \bar y_2) \pm t_{\alpha/2}s_e\sqrt{2/n_h}$, while having level of confidence $1-\alpha$ for $\mu_1 - \mu_2$ in the initial experiment, has a smaller broad-inference level of confidence. The derivation of the confidence level begins with the distribution of the statistic \begin{equation} \label{eq:defineteststatisticc} T_\mu = \frac{\overline Y_1 - \overline Y_2-(\mu_1 - \mu_2)}{S_e\sqrt{2/n_h}} \end{equation} under M2. It can be seen that $T_\mu /\sqrt{1+n_h\omega^2}$ has a t-distribution with $df = n_1 + n_2 - 2$. Thus, the broad-inference confidence level is the probability that the confidence interval contains $\mu_1 - \mu_2$ which can be shown to be \begin{equation} \label{eq:adjconflevel} 2 G_0\left( \frac{t_{\alpha/2}}{\sqrt{1+n_h\omega^2}} \right) - 1. \end{equation} If $\omega > 0$, the broad-inference level of confidence approaches 0 as $n_h\to \infty$. Thus, for large $n_h$, the traditional confidence interval in a follow-up experiment almost certainly will not contain $\mu_1 - \mu_2$. Additionally, we can manipulate the above equation to find an broad-inference confidence interval for a given significance level $\alpha$. A \textit{broad-inference} $1-\alpha$ confidence interval is \begin{equation} \label{eq:adjconfint} (\bar y_1 - \bar y_2) \pm t_{\alpha/2}s_e\sqrt{2/n_h + 2\omega^2}. \end{equation} Of note, as $n_h\rightarrow \infty$, the length of the confidence interval for a fixed confidence level $1-\alpha$ approaches $\omega\sqrt{2}$. That is, when accounting for the presence of the EER, the confidence interval in~\eqref{eq:adjconfint} no longer is expected to converge to the true value of the difference in means. \subsection{Assessing Replicability through EER Profile Plots for Example 1} We now use EER profile plots to assess the replicability of the experiment performed by~\citet{snedecor1980statistical} on the use of in Example 1 in Section~\ref{subsec:ex1}. These are obtained by taking the quantities in~\eqref{eq:adjpvalue} and~\eqref{eq:adjconflevel} and plotting these values against varying hypothetical values of the EER $\omega$. These plots allow for analysis on how sensitive results are to environmental variability. Figure~\ref{figure4} gives these profile plots. Conventional analysis yields a difference in hormone treatments ($p = .003$) that would typically be indicative of strong statistical significance. However, this $p$-value only holds under the environment in which the experiment was conducted. Indeed, if $\omega$ is quite small, inferences made using broad-inference $p$-values will be the same as those from traditional statistical tests. However, if $\omega > .38$, which seems to be a reasonable value of the environmental variability (see Section~\ref{sec:realeer}), the broad-inference $p$-value would no longer indicate significance at the $5\%$ level and the broad-inference level of confidence would fall below $.8$ from an initial value of $.95$. If $\omega > .65$, which is plausible for experiments that have environments that are difficult to regulate, the broad-inference $p$-value is $p = .178$, for which only the most unscrupulous of practitioners would claim any kind of significance (for examples, see~\citet{hankins2013still}). That is, despite seemingly strong statistical significance of treatment under conventional analysis, there seems to be weak evidence that the result is actually due to treatment efficacy rather than the variability that may exist across different experimental environments. A researcher interested in performing a follow-up study to this experiment should not be shocked if the original result failed to replicate. \begin{figure}[ht \centering \includegraphics[width = \textwidth]{nfigure4.pdf} \caption{Profile plot of broad-inference (BI) $p$-values and confidence levels vs.~environmental effect ratio (EER) for observed treatment effect size $\Delta^{*}=1.0$ and $n_1 = n_2 = 11$. The dotted gray line at the bottom denotes $p=.05$ and at the top denotes the initial confidence level $1-\alpha = .95$. The initial $p$-value of the study (when EER $\omega = 0$) is $p = .003$.} \label{figure4} \end{figure} \section{Plausible values of EER} \label{sec:realeer} Estimates of EER from multi-environment experiments in four different areas of application were obtained to show plausible values of EER in practice. With such information from prior data or experiences, a researcher can place plausible bounds on EER from which bounds can be placed on replicability power, sample sizes in replicability studies, broad-inference $p$-values, and confidence levels, and help interpret and make conclusions from EER profile plots. \subsection{Example 3: Genetics} \label{subsec:ex3esteer} \citet{Kafkafi:2005} used a mixed model to decompose the total variance of 17 endpoints in a multi-laboratory experiment into the following components: between-genotype, between-laboratory, genotype by laboratory interaction, and within-laboratory. We calculated EER for these endpoints from the proportions of total variance for interaction and error presented in graphical form in \citet{Kafkafi:2005} and in table form in a supplement to their paper. Results are shown in Table~\ref{Table.2}. Values of $\omega$ range from 0 to .63 with a median of .34. \begin{table}[ht] \centering \begin{tabular}{|c| c| l| c| } \hline \multicolumn{4}{|c|}{EER for different endpoints \citep{Kafkafi:2005}} \\ \hline \multicolumn{1}{|l|}{Endpoint(Response)} &{EER}&{Endpoint(Response)} & {EER}\\ \hline \multicolumn{1}{|l|}{lingering time} &{0.63}&{distance traveled} &{0.57}\\ \hline \multicolumn{1}{|l|}{segment max speed} &{0.40}&{excursions} &{0.37}\\ \hline \multicolumn{1}{|l|}{time for tum} &{0.13}&{radius of tum} &{0.34}\\ \hline \multicolumn{1}{|l|}{segment length} &{0.51}&{center time} &{0.40}\\ \hline \multicolumn{1}{|l|}{progression segments} &{0.14}&{segment acceleration} &{0.38}\\ \hline \multicolumn{1}{|l|}{homebase occupancy} &{0.0}&{lingering mean speed} &{0.35}\\ \hline \multicolumn{1}{|l|}{diversity} &{0.0}&{stops per excursion} &{0.18}\\ \hline \multicolumn{1}{|l|}{lingering spatial spread} &{0.19}&{relative activity decrease} &{0.03}\\ \hline \multicolumn{1}{|l|}{latency to half max speed} &{0.0}&{} &{}\\ \hline \end{tabular} \caption{Estimated environmental effect ratios (EER) for a multi-lab experiment.} \label{Table.2} \end{table} \subsection{Example 4: RCB in Agriculture} In agriculture experimentation, there is often non-homogeneity in the environment that is accounted for by blocking in the design of the experiment. If the treatments appear more than once in each block, then the usual RCB analysis with fixed effect ``treatment'' and random effects ``block'' and ``block$\times$treatment'' would give us an estimate of the component of variance $\sigma^2_\delta$ for the random interaction of blocks and treatments. If we regard the block itself as an ``environment,'' then the estimate of the ratio $\sigma_\delta/\sigma_e$ will suggest a plausible value for EER. We analyzed data from~\citet[p.~267]{snedecor1980statistical} using a randomized block design in which there are 3 treatments measured each of 4 times in each of 5 blocks. The data are the number of wireworms in soil samples treated with either one of two fumigants or a control. We obtained the estimates of the components of variance as shown in Table~\ref{tab:ex3ests} and computed the estimate of $\omega$ to be $.65$. Note that the ``block$\times$treatment''mean square is the error mean square for testing treatment effects, not the residual. If data were taken from only one block, the residual would be the wrong error term for making inferences across blocks. \begin{table} \begin{center} \begin{tabular}{|l| c| c| c | c | }\hline Source of Var. & Estimate & SE & $Z$-Value & $Pr > Z$ \\ \hline blk & $1.1052$ & $2.4502$ & $0.45$ & $0.326$ \\ blk$\times$trt $(=\sigma^2_\delta)$ & $3.8559$ & $3.1035$ & $1.24$ & $0.107$ \\ Residual $(= \sigma^2_e)$ & $9.1056$ & $1.9196$ & $4.74$ & $<0.0001$\\ $\text{EER} = \sigma_\delta/\sigma_e$ & 0.6507 & & &\\ \hline \end{tabular} \end{center} \caption{Variance component estimates for Example 4.} \label{tab:ex3ests} \end{table} \subsection{Example 5: EER via Intraclass Correlation, Horticulture and Education } We may relate EER to the \textit{intraclass correlation} from which a bound may be placed on EER. If we randomly select an environment then take observations according to M2, the observations within treatment are correlated because of the random term $\theta + \delta_i$ which is common to all the observations within the treatment. The intraclass correlation is given by \begin{equation} \label{eq:deficc} \rho = \frac{\sigma^2_\theta + \sigma^2_\delta}{\sigma^2_\theta + \sigma^2_\delta + \sigma^2_e} . \end{equation} This quantity is smallest when $\sigma^2_\theta = 0$, so $\rho > \sigma^2_\delta/(\sigma^2_\delta + \sigma^2_e)$. It follows that \begin{equation} \label{eq:boundomega} \omega < \sqrt{\rho/(1-\rho)} . \end{equation}We use this method of bounding EER in data taken from horticulture and education. The value of $\rho$ was estimated in~\citet{perrett2006method} for eight cultivars inoculated with spider mites in 4 greenhouses which are the environments for this example. The values of estimated $\rho$ ranged from $0$ to $.30$ with a median of $.12$. If $\rho = .30$, then $\omega < .65$, and if $\rho = .12$, then $\omega < .37$. We also compute bounds on EER from data obtained by~\citet{perrett2004using}. Here, the intraclass correlation was for 14 multi-section university courses using data from the fall and spring semesters of the years 2001-2003 for a total of 43 course-semester combinations. The data were grades based on a 4 point scale. The largest value of $\rho$ was .34 ($\omega < .72$). However, the remaining 42 values of $\rho$ were .23 or less ($\omega < .55$) and the median was .07 ($\omega < .27$). \section{Summary and Conclusions \label{sec:conclude}} It would be foolhardy to perform an experiment at a research facility if it were believed that the results would apply only to that facility at the time the research is done and under the conditions that prevail at that time. Yet the methods that we teach, the software that we use, and the consulting advice that we provide often allow for formal statistical inferences to be made only under those circumstances. While the replicability crisis has led to extensive commentary on the improper application of statistical methods, in particular, the uncritical use of ``$p < .05$,'' problems of replicability cannot be fully addressed without considering the effect that the research environment has on outcomes and inferences. This is true whether the inferences are frequentist or Bayesian and whether we use $p < .05$ or abandon significance tests altogether. By using a mixed model and EER as a measure of the size of the environmental effect for a follow-up experiment, one can quantitatively assess the effect that the research environment has on power, sample size selection, $p$-values, and confidence levels. The usual $p$-values and confidence levels can be misleading in answering questions of replicability if EER $\omega > 0$. Broad-inference $p$-values and confidence levels are more conservative and more appropriate for this purpose because they account for potential changes in the research environment when an experiment is redone. A large treatment effect size, which like EER is dimensionless, can help mitigate the negative effects of environmental factors, but small treatment effect sizes, even if statistically significant, should be viewed with caution. For instance, a treatment effect size less than $.7$ (Cohen’s d less than .5) could not attain a broad-inference $p$-value less than .05 regardless of sample size when EER is greater than $.36$, which is a plausible value for EER in practice. In areas where the effects of the research environment are difficult to control or the effect sizes tend to be small, the only recourse the researcher will have to separate treatment effects from random error would be to do the experiment in several, perhaps many, randomly selected environments. EER profile plots of broad-inference $p$-values and broad-inference confidence levels across hypothetical values of EER and plots of replicability power against EER can be used to judge the sensitivity of results to changing environments and to assist in making judgments about the replicability of experimental outcomes. This is especially helpful when it is impractical to redo an experiment or when one wants to assess likely replicability before an experiment can be redone. In planning a follow-up experiment, the replicability power will be less than that of the initial experiment for the same sample size if the initial power is greater than $1/2$ and $\omega > 0$. Thus, the sample size must be greater in the follow-up experiment for the two experiments to be on an equal footing. Large $n$ alone cannot control replicability power which can be as small as $1/2$ when EER is large relative to treatment effect size. Similarly, the probability of obtaining significance in the wrong direction can be as large as $1/2$ again depending on the size of EER. There are implications for teaching as well. For instance, in teaching the two-sample $t$-test in introductory statistical methods courses, we dutifully note that the observations are randomly selected from normally distributed populations and caution students that inferences only apply to these populations. What may be ignored or given only slight attention is the fact that inferences are also limited by the conditions that prevail at the time the data are taken. If the objective of statistics is ``better scientific investigation'' as~\citet{box1990commentary} asserted, then it is incumbent upon the teacher to give prominence to this point. The limitations on inferences imposed by the research environment should be as much of a concern as the distributional assumptions of the methods used to analyze data. Greater effort needs to be made to get estimates of components of variance due to environmental effects and in particular EER which plays a key role in replicability. Where available, these should be reported along with means, standard errors, and effect sizes in research results. With greater knowledge of EER in various contexts, it will become possible to make more informed judgments about the potential replicability of results from a single experiment. \bibliographystyle{agsm}
{'timestamp': '2020-09-01T02:14:12', 'yymm': '1904', 'arxiv_id': '1904.10036', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10036'}
arxiv
\section{Introduction}\label{ooo} Agile software development has become an extremely popular way of managing projects, and there have also been studies showing the effectiveness of such approaches \cite{serrador}. Many different measurement models for agility have been proposed but according to \cite{ozcan} Sidky's Agile Adoption Framework \cite{sidkyphd} is the most complete to date. Many companies have implemented an agile approach but lack a way to evaluate the level of implementation, and need contextually specific tools \cite{xp20141}. However, getting some quantitative feedback from the teams could be a useful indication of agility that can be used to study (and improve) agile teams and also to compare them. This paper presents preliminary results from such a tool. Sidky's \cite{sidkyphd} framework assesses the level of agility an organization is ready to implement and recommends what methods these should be. There are two main differences between Sidky's \cite{sidkyphd} tool and how we use it here. First, we measure the present level of agility and not agile potential. In order to measure agility level, the items were altered in time in our tool so they ask about the current situation. Second, it lets the group members fill out the survey and allows a statistical confidence interval to the result. One validation study has been conducted testing the tool in such a way \cite{grenjss}. The authors report that the feedback was considered useful by the team participating in the pretest, but that the measurement itself shows problems with validity. Despite that, and since the tool was considered useful by the team itself in the focus group, we believe our tool can be used to guide improvement efforts. Sidky \cite{sidkyphd}, also validated the content in the tool by letting practitioners evaluate the items and their connection to what they think agility is. Sidky's framework is divided into ``agile levels'', ``principles'', ``practices and concepts'', and ``items or indicators''. To assess the results the Agile Adoption Framework includes 4 steps: First, calculating a weight for each item (the weight of 1 is divided by the number of items if all items are considered equally important), second, computing weighted intervals. These intervals are created by taking the answer of each item and calculating a pessimistic and optimistic result for each one, and the Likert scale is then divided into a percentage. To clarify, this means that the practices ``Reflect and tune process'', ``Collaborative planning'', ``Collaborative teams'', ``Empowered and motivated teams'', ``Working standards\slash procedures'', ``Knowledge sharing tools'', ``Task volunteering'', and ``Customer commitment'' are assessed in the tool. The actual items (or indicators) are published in \cite{grenjss}. The tool consists of one survey for managers and one survey for developers. To assess an agile practice the analysis method proposed uses answers from both surveys. Some of the items are also used to assess more than one practice. Below is the description of what the agile characteristics set out to determine. This list is needed to find what the different scores mean in the feedback table presented later. \begin{table* \centering \caption{The Result for Team A (the ``notes below table'' can be found in Section~\ref{ooo} of this paper).} \label{fig:Company A} \includegraphics[scale=0.35]{seaa2016.pdf} \end{table*} \begin{framed} \scriptsize (1) Whether or not a collaborative or a command-control relation exists between managers and subordinates. The management style is an indication of whether or not management trusts the developers and vice versa. (2) Whether or not management is supportive of or resistive to having a collaborative environment. (3) Whether or not management can be open with customers and developers, i.e., no politics and secrets. (4) Whether or not people are intimidated\slash afraid to give honest feedback and participation in the presence of their managers. (5) Whether or not the developers are willing to plan in a collaborative environment. (6) Whether or not the organization does basic planning for its projects. (7) Whether or not any levels of interaction exist between people thus laying a foundation for more team work. (8) Whether or not people believe in group work and helping others or are just concerned about themselves. (9) Whether or not people are willing to work in teams. (10) Whether or not people recognize that their input is valuable in group work. (11) Whether or not the developers see the benefit and are willing to apply coding standards. (12) Whether or not developers believe in and can see the benefits of having project information communicated to the whole team. (13) Whether or not managers believe in and can see the benefits of having project information communicated to the whole team. (14) Whether or not management will be willing to buy into and can see benefits from employees volunteering for tasks instead of being assigned. (15) Whether or not developers are willing to see the benefits from volunteering for tasks. (16) Whether or not management empowers teams with decision making authority. (17) Whether or not people are treated in a way that motivates them. (18) Whether or not managers trust and believe in the technical team in order to truly empower them. (19) Whether or not developers are willing to commit to reflecting about and tuning the process after each iteration or release. (20) Whether or not management is willing to commit to reflecting about and tuning the process after each iteration or release. (21) Whether or not the organization can handle process change in the middle of the project. \end{framed} \section{Feedback to Companies}\label{sub:feedback} So far, we have tested the tool on seven teams in three multinational companies consisting of two US-based and one European-based. Below is the result and recommendations that were given to each team based on the survey result. Only one result and feedback from the one team at Company A is shown in this paper as an example, but all teams were given feedback the same way. \paragraph{Results and Recommendations for Company A --- One team} Company A could focus on the following aspects to improve their agility (they are explained in more detail below): (1) Collaborative Planning with regard to the Power Distance between management and group members. (2) Task volunteering. (3) Management's buy-in of reflecting and tuning the process after each iteration or release. Table~\ref{fig:Company A} shows the results for the team. Collaborative planning and its aspect of power distance got a lower score, which means the teams would benefit from having a flatter and less hierarchical organizational structure when planning projects. Having management plan and set up the projects without participation from team members, will result in less accurate and suboptimal goals. The team members are experts on how much work the team can do under a given period of time. At Team A, ``task volunteering'' got a lower score from both mangers and developers. Task volunteering is also a key to success, since developers need to take full responsibility for their current chores and deliverables together with the team as a whole. Team members are often also better at knowing their capability and making time estimates on tasks. The last aspect of Team A concerned manager's buy-in of ``Reflect and Tune Process''. This means that the management is not willing to reflect and tune the process after each iteration or release. Continuous improvement is a key to achieving as high performance as possible. Management of Team A would benefit from having a workshop on how agile principles are supposed to work in teams, especially how the process needs fine-tuning and adaptation to each team/or context. A practice that works well in one team might need to be adapted to a new context but with the reason behind it kept. I.e. the agile principle behind an implementation can be kept, but the actual implementation must be tuned to, and reflected on, in the new context. Hopefully this will guide them into accepting and seeing the benefits of reflecting and tuning the processes and task volunteering. \section{Conclusions and Future Work}\label{sec:conclusions_and_future_work} This paper has presented how the Agile Adoption Framework can be used to assess agility and pinpoint focus areas for companies that want to improve. Management found it useful in general to get data on possible focus points for improvement. Agility implies a set of principles that need to be followed in order to have the proposed responsiveness to change. We believe our tool could be useful as one step in the agile process assessment. \nocite{ex1,ex2} \bibliographystyle{latex8}
{'timestamp': '2019-04-23T02:28:56', 'yymm': '1904', 'arxiv_id': '1904.09972', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09972'}
arxiv
\section{Introduction} Though sales of electric vehicles (EVs) are increasing rapidly, there are still barriers to their wide-spread adoption. A survey by AAA found that ``not enough places to charge" was cited by 63\% of consumers unwilling or unsure about purchasing an electric car, making it the most common reason cited \cite{newsroom}. While 80\% of charging currently occurs at home, in many areas (like densely populated urban areas) the availability of at home charging may not be feasible. It is thus important to study ways of making more charging infrastructure available to the general public. Federal and state governments have been pursuing multiple strategies to increase charging infrastructure. One method of increasing availability of charging is by inducing private firms to install charging stations at parking spots. For example, the city of Seattle is working with two private firms to install EV charging stations throughout the city in order to induce more EV drivers \cite{seattlemag}. Given that these decisions affect not only the EV market but also the market for ICE cars (who are excluded from using designated charging spots), the potential effects of such policies warrants investigation. As far as we know, this is one of the first attempts to explicitly do so. A variety of work has focused on optimizing EV charging, both in a competitive market and when system operator is looking at global welfare \cite{lee2015electric,mehar2013optimization,luo2017placement,alizadeh2016optimal,liu2013optimal}. In \cite{lee2015electric} the authors analyze the competition between charging stations (not necessary in a parking context) with renewable generation. The effect of EVs on the power grid and road system is studied in \cite{alizadeh2016optimal}, which offers ways system planners can optimize for this. Our work differs from \cite{lee2015electric} by analyzing how firm's investment in parking affects the market for EVs and ICEs and from \cite{alizadeh2016optimal} by focusing on parking rather than travel decisions of EV drivers along road networks. A key feature of parking is that it is a congestible resource, i.e., the more users that park in a given location, the less desirable it is (on average) for the next user who parks there. Commonly this effect is modeled with a congestion cost term that is increasing in the number of users parking in a given location \cite{arnott2006integrated}. We follow this approach here and adopt a model similar to those used in the literature on competition with congestible resources, e.g. \cite{nguyen2016cost,acemoglu2007competition,gibbens2000internet,acemoglu2006price,kelly1998rate,fan2011distributed,johari2010congestible}. In particular \cite{nguyen2016cost} most closely resembles our model, as it looks at wireless service providers pricing unlicensed and licensed spectrum where consumers suffer congestion when other consumers use the same band. We will similarly look at a case where two classes of a market (parking for EV and ICE drivers) are priced and where consumers suffer congestion costs with other consumers of the same class, but differ as each class of service can only serve one type of consumer. There is a rich literature on examining the effect of prices and competition on parking decisions by consumers and the resulting welfare effects \cite{glazer2001parking,arnott1991temporal,qian2013optimal,shoup2006cruising,shoup1999trouble,ayala2012pricing,arnott1995modeling,lindsey2000traffic,arnott2006integrated}. The interaction of parking and road usage congestion is examined in \cite{glazer2001parking}, which shows a road-usage fee in addition to a parking fee is needed to maximize welfare. The work in \cite{arnott1991temporal} builds upon Vickrey's classic bottleneck road congestion model to examine how different pricing options can help maximize welfare by reducing or eliminating congestion. The effect of setting a minimum amount of parking for urban land use, and how this reduces welfare compared to allowing the market to decide the provision of spots is studied in \cite{shoup1999trouble}. However, none of this work looks at situations where both EV and ICE cars interact. This paper focuses on the effect of government policy in two cases: in the first incumbent private owners of parking spaces are installing parking spots with charging stations and in the second a monopolist owns all spots but has uncertainty over the size of the EV market. In the first case we consider how two policies affect these firms: namely introducing subsidies for constructing EV charging spots and setting a minimum proportion of spots that should have chargers installed. This portion is built upon our earlier work \cite{badia2018price}. We compare the electiveness of these policies under different assumptions on how firms compete and the relative market sizes of the EV and ICE markets. In the second case, we study the impact of stochasticity in the more valuable market (the EV market) on construction decisions by a monopolist. We assume a monopolist holds a mass of parking spots in an area with many ICE drivers. Due to the potential difficulties in forecasting the size of the future EV market, they have some uncertainty on how large the EV market may be. We will show both the monopolist's expectation and government policy can have a large impact on outcomes. The rest of the paper is organized as follows. Section \ref{sec:competitivemodel} defines the model for the competitive market; Section \ref{sec:sequentialspotallocation} analyzes the game as defined by this model; Section \ref{sec:competitiveresults} summarizes the results from this model; Section \ref{sec:competitivenumericalcasestudy} analyzes a specific case study; Section \ref{sec:monopolistmodel} defines the model for the monopolist; Section \ref{sec:monopolistpricing} examines the pricing structure in this model; Section \ref{sec:stochasticarrivalcapacity} examines the impact capacity decisions have on the optimal operating point; Section \ref{sec:monopolistnumerical} studies a numerical case study for this model; Section \ref{sec:conclusion} concludes and looks at potential future work. \section{Competitive Market: Model} \label{sec:competitivemodel} \noindent In this section we present our model for firms competing over servicing EV and ICE drivers. \subsection{Consumers} We assume there is a mass of two classes of consumers: drivers who use EVs and those who use ICE. Consumers of both classes are assumed to be non-atomic. There will be two types of parking spots: regular parking spots for ICE drivers and spots equipped for charging EVs. We assume each class of driver only parks in a spot designated for them. This is true in practice for ICE drivers as there are regulations against parking in spots with chargers, while we assume all EV drivers require charge for their cars and so would only consider parking in a spot with a charger equipped. As is standard in parking models we model the congestion as a function of the proportion of occupied spots \cite{arnott2006integrated}. This reflects that with higher occupancy each driver has to spend more time on average to find a vacant spot. We assume firms cluster spots of the same type together (i.e., those with charging and those without) and so consumers at each firm's parking location suffer congestion due to drivers of the same class but not due to other class of drivers, nor with any at the other firm. In general we want a congestion function for each marginal consumer that is increasing in the quantity of consumers already parked, decreasing in the number of spots, and convex in the volume-capacity ratio \cite{arnott2006integrated}. For simplicity we will use a linear congestion function, which will be the same for both classes of consumers, i.e., \begin{equation} \label{eq:congestion} S(q,N) = \epsilon \frac{q}{N}, \end{equation} \noindent where $q$ is the quantity of that class of consumers already parked, $N$ is the number of spots allocated for that class of driver, and $\epsilon > 0$ is a constant term that represents the congestion cost if all spots are filled. Note, we have not put any constraints on $q$ and thus allow $q > N$. In this case it would mean on average not only are all spots taken but there are consumers cruising around for spots. We do not model differences in the length of time a consumer may want to park; they simply want access to the ability to park (and will all pay the same price at a given firm to do so as discussed in the firm section below). One can think of this as a mass of drivers going to work, where they all work the same amount of time. Each consumer therefore purchases the same good, which is the ability to park during the work day. We will assume for both classes that there is a linear downward inverse demand curve for parking determined by the valuation and size of each market, which we define for EV drivers ($P_e(q_e)$) and ICE drivers ($P_d(q_d)$) as \begin{equation} \label{eq:inversedemandEV} P_e(q_e) = W_e(1-\alpha q_e), \end{equation} \begin{equation} \label{eq:inversedemandICE} P_d(q_d) = W_d(1-\beta q_d). \end{equation} The $y$-intercept of the ICE inverse demand curve is $W_d > 0$, and the slope is $\beta > 0$; while the $y$-intercept for the mass of EV drivers is $W_e > 0$, and the slope is $\alpha > 0$. Instead of modeling explicitly the demand EV drivers have for a certain amount of charge, for simplicity we assume that access to charging results in a fixed additional utility over parking. We capture this by assuming $W_e > W_d$, where $W_e$ captures both demand for the parking and the ability to charge at the parking spot. \subsection{Firms} We assume there are two firms (i.e., parking garage owners) that already own a mass of parking spots suitable for ICE drivers. We normalize the number of total spots to be 1 and the number of spots firm $i$ has as $N_i$. Specifically, we define the proportion of spots that firm 1 owns as $N_1 = \delta$, where $0 \leq \delta \leq 1$. This means firm 2 owns $N_2 = 1 - \delta$ spots. Firms are unable to construct new spots, but either due to government policy or their own choice they are able to convert a portion of their spots to include an EV charger at cost $p$. We will call the number of spots designated for EVs at firm $i$ as $N_{ei}$ and the remaining spots as $N_{di}$. We assume the firms are close together so on average consumers have no preference for one firm over the other. The model could be extended to assume all consumers are attempting to get to a common location (for example a central business district) where one firm may be closer and thus preferred as in \cite{qian2013optimal}. We define the value of parking for a marginal driver of each class at each firm $i$ when the firm sets a price $m_i$ ($c_i$) for ICE cars (EVs) and $q_{di}$ ($q_{ei}$) ICE (EV) drivers are parked at firm $i$ as follows: \begin{multline} \label{eq:utilityEV} U_{ei}(q_{e1},q_{e2},N_{ei},c_i) = W_e(1-\alpha (q_{e1} + q_{e2})) \\ - \epsilon \frac{q_{ei}}{N_{ei}} - c_i, \end{multline} \begin{multline} \label{eq:utilityICE} U_{di}(q_{d1},q_{d2},N_{di},m_i) = W_d(1-\beta (q_{d1} + q_{d2})) \\ - \epsilon \frac{q_{di}}{N_{di}} - m_i. \end{multline} Here, the first terms reflect the inverse demands in \eqref{eq:inversedemandEV} and \eqref{eq:inversedemandICE}. The quantity of each class of driver at firm $i$ is a function of the number of spots available for that driver and the price set for them both by firm $i$ and the opposing firm $j$. The number of consumers at each firm in equilibrium is defined using the notion of a Wardrop equilibrium \cite{wardrop1952some}. A Wardrop equilibrium here means that when drivers are parking at both firms, the following two conditions hold: the marginal utilities of the consumers at each garage have to be equated ($U_{ei} = U_{ej}$, $U_{di} = U_{dj}$) and the marginal utilities have be 0 ($U_{ei} = 0$, $U_{ej} = 0$, $U_{di} = 0$, $U_{dj} = 0$). This means that consumers park until the marginal user would gain negative utility from doing so, and sort themselves at the garage at which they get the highest utility. Let $N^{\epsilon}_{ei} =\frac{N_{ei}}{\epsilon}$, $N^{\epsilon}_{di} =\frac{N_{di}}{\epsilon}$, $\mathbf{N_e} = \{N_{e1},N_{e2}\}$, $\mathbf{N_d} = \{N_{d1},N_{d2}\}$, $\mathbf{m} = \{m_1,m_2\}$ and $\mathbf{c} = \{c_1,c_2\}$. Solving the system of equations given by the Wardrop Equilibrium, we get the following closed-form solution for the quantities serviced at firm $i$ given the actions of firm $i$ and the opposing firm $j$ when they both set a price such that $q_{ei} > 0 $ and $q_{ej} > 0$: \begin{equation} \label{eq:wardropEV} q_{ei}(\mathbf{N_e},\mathbf{c}) = \frac{W_e(1+\alpha N_{ej}^{\epsilon}(c_j-c_i) ) - c_i}{\alpha W_e(1+\frac{N_{ej}}{N_{ei}}) + \frac{1}{N_{ei}^{\epsilon}}}, \end{equation} \begin{equation} \label{eq:wardropICE} q_{di}(\mathbf{N_d},\mathbf{m}) = \frac{W_d(1+\beta N_{dj}^{\epsilon}(m_j-m_i) ) - m_i}{\beta W_d(1+\frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}}. \end{equation} These equations were derived by assuming that there exist a $q_{ei} \geq 0$ and $q_{ej} \geq 0$ such that the marginal utilities at each firm are 0, which may not always be the case. In particular this will not be true in two scenarios. First, if one firm sets the number of spots for a given type of user to be $0$, as this leads to an infinite amount of congestion for that type of user. If this happens to one firm and not the other, the above solutions lead to one firm with non-zero capacity acting as a monopolist and the other firm servicing a quantity of $0$ for that class of driver as should occur. If they both set the number of spots to be $0$ then both quantities are 0 as is expected. The second scenario is where a firm sets too high a price so that the marginal utility of any driver parking there in equilibrium is negative. We show in Appendix 10.1, that in any unilateral deviation away from the above equilibrium, no firm would ever have such a price and so there is no problem with ignoring this possibility. We can therefore specify the general problem faced by each firm $i$: \begin{multline} \label{eq:firmoptimization} \underset{N_{ei},N_{di},m_i,c_i}{\text{max}} \Pi_i = m_iq_{di}(\mathbf{N_d},\mathbf{m}) + c_iq_{ei}(\mathbf{N_e},\mathbf{c}) - pN_{ei} \\ \text{s.t.} \ \ \ \ \ \ N_{ei} + N_{di} = N_i, \ N_{di} \geq 0, \ N_{ei} \geq 0. \end{multline} Note that each firm seeks to solve such a problem, and that their decisions are coupled through the resulting Wardrop equilbrium quantities. Also note that we set no constraint for prices. This is because any negative price will result in negative profit, while a price that is too large (for example, $m_i > W_d$) will result in no profit. These choices are therefore dominated by setting the price to be $0$ and so there is an inferred constraint due to the nature of the optimization problem. By not explicitly stating this constraint we will be able to evaluate first-order conditions without having to check for corner solutions. \subsection{Government} We assume the government wants to induce more charging infrastructure to be constructed by firms. We will examine two methods of doing so: issuing a mandate and subsidizing construction. These are policies being currently explored and implemented. For the mandate, we define the proportion of spots mandated for EV charging as $r$ and incorporate this into \eqref{eq:firmoptimization} by adding an additional constraint \begin{equation} \label{eq:governmentmandate} N_{ei} \geq r N_i. \end{equation} For the subsidy, we will allow the government to set a subsidy $s$ such that the cost of constructing EV spots for firms as a function of the intrinsic cost $t$ is \begin{equation} \label{eq:governmensubsidy} p = t - s. \end{equation} \subsection{Consumer Surplus and Total Welfare} Given that consumers are non-atomic, then the consumer surplus for each class of consumer is given by integrating \eqref{eq:utilityEV} and \eqref{eq:utilityICE} over the quantity serviced at both firms, i.e., \begin{multline} \label{eq:consumerwelfareEV} CS_{EV} = \int_{0}^{q_{e1} + q_{e2}} W_e(1-\alpha q) dq \ - \\ \int_{0}^{q_{e1}}(\epsilon \frac{q}{N_{e1}} + c_1)dq - \int_{0}^{q_{e2}}(\epsilon \frac{q}{N_{e2}} + c_2)dq, \end{multline} \begin{multline} \label{eq:consumerwelfareICE} CS_{ICE} = \int_{0}^{q_{d1} + q_{d2}} W_d(1-\beta q) dq \ - \\ \int_{0}^{q_{d1}}(\epsilon \frac{q}{N_{d1}} + m_1)dq - \int_{0}^{q_{d2}}(\epsilon \frac{q}{N_{d2}} + m_2)dq. \end{multline} Note here we are assuming that drivers park sequentially so that early drivers incur a lower congestion cost than later drivers\footnote{Alternatively, we could assume that all drivers park in ``steady-state" in which case all drivers would see the same congestion cost.}. Each firm's welfare will simply be the total profit they receive given by the objective function in \eqref{eq:firmoptimization}. The government has to pay for any subsidies they offer firms. We define the cost of subsidies as \begin{equation*} G(N_{e1},N_{e2},s) = s(N_{e1} + N_{e2}). \end{equation*} We therefore define the total welfare as the sum of consumer surpluses, the firm profits, and the government's cost to provide subsidies, i.e., \begin{equation} \label{eq:welfare} W_{total} = CS_{EV} + CS_{ICE} + \Pi_1 + \Pi_2 - G(N_{e1},N_{e2},s) . \end{equation} \section{Competitive Market: Sequential Spot Allocation and Pricing Game} \label{sec:sequentialspotallocation} We model the overall market interactions as a one shot, two-stage game. In the first stage, the firms simultaneously set the number of parking spots they will convert to have chargers. In the second stage they set prices having committed to the number of installations they made in the first stage. We will solve this game using backward induction, so we first examine the second stage (where parking spot quantities have already been set). \subsection{Second stage: Price competition} We will consider three different ways in which firms may set prices given fixed quantities of parking spaces. These will differ in the degree to which firms price discriminate and anticipate the impact of EV parking. We begin with a ``two pricing case" in which firms discriminate in the prices that they charge EV and ICE drivers accounting fully for the different preferences of these two classes. However, around 50\% of public chargers are free and thus it seems many private owners of charging stations do not specifically set a price to use that service \cite{plugincarschargenetworks}. We analyze two different scenarios where this might occur. The first is where they set a single price for both classes of drivers, but optimize that price understanding EV drivers' valuations. We call this the ``optimal single price case". In the second case, we assume that the garages had in the past (before constructing EV spots) set prices to compete over only ICE drivers and then maintain this price even after charging stations are added to parking spots. We call this the ``Naive" single price case. Each of these pricing schemes could also arise in part due to regulation that limits the prices that can be charged. We look at each case separately. A summary of the cases is shown in Table \ref{tab:firmpricedecisions} below. \\ \begin{table}[h!] \begin{center} \begin{tabular}{ |c|c| } \hline Case & Constraint on Prices ($c_i$, $m_i$) \\ \hline Two Price & None \\ \hline Optimal single price & $c_i = m_i$ \\ \hline ``Naive" single price & set assuming $N_{e1} = N_{e2} =0$. \\ \hline \end{tabular} \caption{Firm Price Decisions} \label{tab:firmpricedecisions} \end{center} \end{table} \subsubsection{Two price case} In this case we assume that the firms each set two separate prices: one for EV spots ($c$) and one for the ICE drivers ($m$). The price for EVs can be thought of as the plug-in price on top of the price of parking (so $c = m + e$, where $e$ is this plug-in price). In principle $t$ could vary with the amount of electricity an EV consumes while parked (and could also vary with the underlying cost of electricity in a real-time market). Here, we do not model such considerations and simply view each EV as incurring the same additional cost $t$ (or equivalently we could view this as the average cost per EV). We also do not explicitly model the length of stay for each driver, so all drivers of the same class pay the same cost at each firm's location. Each firm in this stage seeks to choose prices to maximize revenue. Note that in this stage the cost of building parking spaces is sunk and so we can ignore this when optimizing revenue. Also, once the spaces are allocated the pricing decision for the two classes de-couple and thus a firm's optimal prices in response to the price of its opponent are given by: \begin{equation*} c_i^{BR} = \underset{c_i}{\textrm{argmax}} \ c_iq_{ei}(N_{e1},N_{e2},c_1,c_2), \end{equation*} \begin{equation*} m_i^{BR} = \underset{m_i}{\textrm{argmax}} \ m_iq_{di}(N_{d1},N_{d2},m_1,m_2). \end{equation*} It can be shown that the objective in these optimization problems is concave in the prices and so the solution can be found by evaluating the first order optimality conditions which yields: \begin{equation*} c_i^{BR}(N_{ej},c_j) = \frac{W_e(1+\alpha N_{ej}^{\epsilon}c_j)}{2(\alpha W_eN_{ej}^{\epsilon} + 1)}, \end{equation*} \begin{equation*} m_i^{BR}(N_{dj},m_j) = \frac{W_d(1+\beta N_{dj}^{\epsilon}m_j)}{2(\beta W_dN_{dj}^{\epsilon} + 1)}. \end{equation*} Hence, by solving for the fixed point of the best responses we get the following expressions for the unique equilibrium prices in the second stage: \begin{align} \label{eq:optimalEVpricetwoprice} c_i^{*}(\mathbf{N_e}) = \frac{2\alpha W_e^2 N_{ei}^{\epsilon} + \alpha W_e^2 N_{ej}^{\epsilon} + 2W_e}{3\alpha^2W_e^2 N_{ei}^{\epsilon} N_{ej}^{\epsilon} + 4\alpha W_e(N_{ei}^{\epsilon} + N_{ej}^{\epsilon}) + 4}, \end{align} \begin{equation} \label{eq:optimalICEpricetwoprice} m_i^{*}(\mathbf{N_d}) = \frac{2\beta W_d^2 N_{di}^{\epsilon} + \beta W_d^2 N_{dj}^{\epsilon} + 2W_d}{3\beta^2W_d^2 N_{ei}^{\epsilon} N_{dj}^{\epsilon} + 4\beta W_d(N_{di}^{\epsilon} + N_{dj}^{\epsilon}) + 4}. \end{equation} \subsubsection{Optimal single pricing case} In this case we assume that each firm only sets one price that both EV drivers and ICE drivers pay to park (i.e., the plug-in price is always 0). Each firm in this stage seeks to choose a single price $m$ to maximize revenue. Note again that in this stage the cost of building parking spaces is sunk and so we can ignore this when optimizing revenue. Thus a firm's optimal price in response to the price of its opponent are given by: \begin{equation*} m_i^{BR} = \underset{m_i}{\textrm{argmax}} \ m_i[q_{ei}(\mathbf{N_e},\mathbf{m}) + q_{di}(\mathbf{N_d},\mathbf{m})]. \end{equation*} \noindent Again this objective can be shown to be concave in price, and therefore we can find the solution by examining the first order optimality conditions. Define \begin{multline*} g^m_i(\mathbf{N_e},\mathbf{N_d},m_j)= W_e \left[\beta W_d ( 1 + \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}} \right] ( 1 + \\ \alpha N_{ej}^{\epsilon} m_j ) + W_d\left[ \alpha W_e (1 + \frac{N_{ej}}{N_{ei}}) + \frac{1}{N_{ei}^{\epsilon}} \right] (1 +\beta N_{dj}^{\epsilon} m_j), \end{multline*} \begin{multline*} h^m_i(\mathbf{N_e},\mathbf{N_d},m_j) = (\alpha W_e N_{ej}^{\epsilon} + 1)(\beta W_d \left(1 + \right. \\ \left. \frac{N_{dj}^{\epsilon}}{N_{di}^{\epsilon}} \right) + \frac{1}{N_{di}^{\epsilon}}) + (\beta W_d N_{dj}^{\epsilon} + 1)(\alpha W_e \left(1 + \frac{N_{ej}}{N_{ei}} \right) + \frac{1}{N_{ei}^{\epsilon}}). \end{multline*} Using these, the best response price for each firm is: \begin{equation} \label{eq:priceoptimalsingleprice} m_i^{BR}(\mathbf{N_e},\mathbf{N_d},m_j) = \frac{g_i^m(\mathbf{N_e},\mathbf{N_d},m_j)}{2h_i^m(\mathbf{N_e},\mathbf{N_d},m_j)}. \end{equation} As before we can solve for the fixed point of these best responses to get an expression for the equilibrium prices as a function of the number of parking spots for each class of driver ($m_i^{*}(\mathbf{N_e},\mathbf{N_d})$). The expression contains many terms and so is excluded from this write-up for clarity. \subsubsection{``Naive" single pricing case} In this case we also assume firms charge one price for parking. However firms are ``naive" about the entry of EVs into the market and so maintain the parking prices they had set before they had constructed EV chargers. Thus the best response function for the single price they charge is \begin{equation*} m_i^{BR} = \underset{m_i}{\textrm{argmax}} \ m_iq_{di}(N_{d1} = \delta,N_{d2} = 1- \delta,m_1,m_2). \end{equation*} Note in this case the price is independent of any decision made in the first stage of the game as the objective function assumes $N_{d1} = \delta$, $N_{d2} = 1- \delta$. Again, we can solve this using the first-order optimality conditions to derive the best responses and then solve for the fixed point. Defining $N_i^{\epsilon} = \frac{N_i}{\epsilon}$, this yields \begin{equation} \label{eq:pricenaivesingleprice} m_i^{*} = \frac{2\beta W_d^2 N_i^{\epsilon} + \beta W_d^2 N_j^{\epsilon} + 2W_d}{3\beta^2W_d^2 N_i^{\epsilon} N_j^{\epsilon} + 4\beta W_dN_i^{\epsilon} + 4\beta W_dN_j^{\epsilon} + 4}. \end{equation} \subsection{First stage: Capacity competition} Next, we turn to the first stage in which firms decide on how many EV spaces to construct accounting for the resulting price equilibrium in the second stage. We will look at two scenarios of how firms may respond to the government mandate in this stage. In the pricing stage, we assumed in some cases firms did not fully internalize their ability to charge EV drivers a different price than ICE drivers. We will do something similar in this stage. In one case we assume firms ``naively" follow the mandate while in the other they will more intelligently choose the number of spaces to optimize their objective function in \eqref{eq:firmoptimization}. In the first scenario, the firms simply meet the mandate (i.e., adding $N_{ei} = rN_i$ as a constraint in \eqref{eq:firmoptimization}). In the second scenario, both firms optimize over the number of EV spots taking the mandate as a lower bound (adding \eqref{eq:governmentmandate} as a constraint in \eqref{eq:firmoptimization}). Table \ref{tab:firmcapacitydecisions} summarizes these two scenarios. \begin{table}[h!] \begin{center} \begin{tabular}{ |c|c| } \hline Case & Capacity constraint \\ \hline ``Naive" mandate fulfillment & $N_{ei} = rN_i$ \\ \hline Optimal Capacity & \eqref{eq:governmentmandate} \\ \hline \end{tabular} \caption{Firm Capacity Decisions} \label{tab:firmcapacitydecisions} \end{center} \end{table} \begin{figure*}[t!] \centering \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_Average_EV_Price}.pdf} \caption{Average EV price vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_Total_Rev}.pdf} \caption{Total Firm revenue vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_Total_Welfare}.pdf} \caption{Total Welfare vs r} \end{subfigure} \end{minipage} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_Total_Congestion}.pdf} \caption{Total Congestion vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_Reg_Herfindahl_Index}.pdf} \caption{Herfindahl index ICE market vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_5_1_1_1_0.6_EV_Herfindahl_Index}.pdf} \caption{Herfindahl index EV market vs r} \end{subfigure} \end{minipage} \caption{Plots for $\alpha = 5$} \end{figure*} \section{Competitive Market: Results} \label{sec:competitiveresults} We now summarize the main results from analyzing the overall equilibrium under the different scenarios. \\ \begin{prop} \label{prop:equilibriumexistence} For the ``naive" mandate fulfillment case, a sub-game perfect Nash equilibrium exists and is unique for all pricing schemes. In the optimal capacity case, a sub-game perfect Nash equilibrium exists if $\alpha W_e \leq 1$ , $\beta W_d \leq 1$ and $\epsilon = 1$ for the two price case and for any values in the ``naive" single price case. \end{prop} This proposition shows that under certain scenarios a unique sub-game perfect Nash equilibrium exists. In general a closed form expression for this equilibrium appears to be difficult to obtain. In Section 5 we will instead numerically analyze properties of these equilibria. The uniqueness of the equilibria given in this theorem provides a guarantee that our results will not depend on the algorithm used to numerically find equilibria. The proof for this is provided in the appendix. \begin{prop} \label{prop:maxquantitydriver} If the total number of spots across both firms for a class of driver is fixed, then the quantity of that class of driver serviced is maximized if when these spots are divided equally across the firms. \end{prop} This makes intuitive sense. If there is a fixed number of spots for a given class of driver, the price will be lowest when firms have equal market power and thus compete the most. As a direct corollary to this we have: \begin{corollary} \label{cor:competitivewelfaremax} Consumer welfare is maximized when each firm has the same initial endowment ($\delta = 0.5$) and there is a unique equilibria. \end{corollary} This follows from Proposition \ref{prop:maxquantitydriver}. When $\delta = 0.5$, it can be shown in all cases where equilibria are unique that each firm chooses the same number of spots for EVs and ICE drivers. This cannot happen if $\delta \neq 0.5$ as in this case the same number of spots cannot be constructed for both classes of drivers: at best this can only occur for one class. Again this result is intuitive, as consumer welfare is maximized when no firm has market power over another. \begin{prop} \label{prop:bestresponseslopde} The best response prices in either market for the two price case is decreasing as the slope of demand in that market increases (i.e. as $\alpha$ or $\beta$ increases). The best response price in the ``naive" single price case increases as $\beta$ increases. \end{prop} \begin{proof} We prove this by showing that in the two price case the derivative of best response price for EV drivers is negative with respect to $\alpha$, $\forall \alpha \geq 0 $ and the derivative of best response price for ICE drivers is negative with respect to $\beta$, $\forall \beta \geq 0 $. \begin{multline*} \frac{\delta c^{*}_i}{\delta \alpha}(\mathbf{Ne}) = -(\frac{3\alpha W_e^3 Ne_i Ne_j}{\epsilon^2}) \times \\ \frac{(\frac{2\alpha W_eN_{ei}}{\epsilon} +\frac{\beta W_eN_{ej}}{\epsilon} + 4)}{(3\alpha^2W_e^2 N_{ei}^{\epsilon} N_{ej}^{\epsilon} + 4\alpha W_e(N_{ei}^{\epsilon} + N_{ej}^{\epsilon}) + 4)^2} \leq 0, \end{multline*} \begin{multline*} \frac{\delta m^{*}_i}{\delta \beta}(\mathbf{Nd}) = -(\frac{3\beta W_d^3 Nd_i Nd_j}{\epsilon^2}) \times \\ \frac{(\frac{2\beta W_dN_{di}}{\epsilon} +\frac{\beta W_dN_{dj}}{\epsilon} + 4)}{(3\beta^2W_d^2 N_{di}^{\epsilon} N_{dj}^{\epsilon} + 4\beta W_d(N_{di}^{\epsilon} + N_{dj}^{\epsilon}) + 4)^2} \leq 0. \end{multline*} The ``Naive" pricing case's best response price function is equivalent to the ICE best price function of the two price case but with quantities of firm $i$ fixed as $N_i$ and firm $j$ fixed as $N_j$. \end{proof} This means that the smaller the market, the more each firm has an incentive to compete by lowering price. In the most extreme case where $\alpha = 0$ or $\beta = 0$, the firms do not compete at all (as there are an infinite number of consumers with the same valuation) and set the same price as a monopoly servicing that market. \begin{figure*}[t!] \centering \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_Average_EV_Price}.pdf} \caption{Average EV price vs r} \label{fig:evPrice5} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_Total_Rev}.pdf} \caption{Total Firm revenue vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_Total_Welfare}.pdf} \caption{Total Welfare vs r} \end{subfigure} \end{minipage} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_Total_Congestion}.pdf} \caption{Total Congestion vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_Reg_Herfindahl_Index}.pdf} \caption{Herfindahl index ICE market vs r} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{1.25_2_1_1_1_0.6_EV_Herfindahl_Index}.pdf} \caption{Herfindahl index EV market vs r} \end{subfigure} \end{minipage} \caption{Plots for $\alpha = 2$} \end{figure*} \section{Competitive Market: Numerical Case Study} \label{sec:competitivenumericalcasestudy} Next we present a numerical case study to see how differing levels of government mandate impact the market. We first define some values of interest. The first is the average price consumers of each class pay in equilibrium. For given prices $a_i$ the average price is defined as: \begin{equation*} a_{ave} = \sum_{i=1}^{2}\frac{q_{i}a_i}{q_{e1} + q_{e2}}. \end{equation*} \noindent We are also interested in how competitive each market is. One way to measure this is the Herfindahl Index, a widely used measure of market concentration \cite{herfindahl1950concentration}. Given the quantity serviced $q_i$ at each firm $i$, this is defined as \begin{equation*} H = \sum_{i=1}^{2}(\frac{q_{i}}{q_{1} + q_{2}})^2, \end{equation*} \noindent where larger values of $H$ indicate a less competitive market. \subsection{``Naive" mandate fulfillment} In our first set of numerical results, we look at all three pricing approaches in the ``Naive" mandate fulfillment case. For all plots we set $W_d = 1$, $\beta = 1$, $W_e = 1.25$, $\alpha = 5$, $\epsilon = 1$, $p = 0$, $t=0$, and $\delta = 0.6$. In this case we have a large ICE market and a relatively small EV market, although the EV users have a larger utility for parking. We assume one of the garages is larger than the other (controlling 60\% of the parking spots). We then use the same values except set $\alpha = 2$. This can be viewed as the EV market expanding (the slope of demand decreases) while all other market conditions stay the same. We plot the average EV price, total firm profits, total welfare, total congestion (sum of congestion at all firms) and the Herfindahl index of both markets as a function of the government mandate ($r$). The plots for $\alpha = 5$ are shown in Figure 1 and the plots for $\alpha = 2$ are in Figure 2. The values are plotted for all three pricing cases that were described above. We note some interesting features. First, the average EV price can be lower for the two price case than in any of the single price cases if the EV mandate is high enough when $\alpha = 5$ (the smaller EV market). However, when the EV market is larger ($\alpha = 2$), the average EV price in the two price case is never lower than in the naive single price case but can still be slightly lower than the optimal single price case when $r$ is large. Also, for $\alpha = 5$ the optimal single price can be lower than the naive price when $r$ is large but not for $\alpha = 2$. Intuitively, when the EV market is small and a large number of spots are allocated to EV's the parking owners need to lower prices. We can also see that total firm profits can be larger in the naive pricing case than in any other case when $\alpha = 5$ and the EV mandate is large enough, though this is not the case for $\alpha = 2$. The intuition here is that although individually each firm would rather set two prices, fixing the price to that of the market before EVs enter reduces the ability of firms to compete with each other, which can increase aggregate profits. Note in both cases the optimal total welfare occurs approximately when the mandate is equal to the size of the EV market ($\frac{1}{\alpha}$). At this value, naive single pricing maximizes welfare even though it generates lower firm profits. Apparently, the increased consumer surplus from lower prices makes up for the loss of profits, yielding improved welfare. Lastly, we note that the competitiveness of the regular market is lower in the two prices case than with the naive pricing when the EV mandate is set to the size of the EV market ($\frac{1}{\alpha}$) for both $\alpha =2$ and $\alpha = 5$. This is capturing the trade-off of inducing EV parking spots: if firms start competing on EVs, they may compete less over regular drivers and thus make the market less competitive for this class of consumers. \subsection{Optimal Capacity} We now examine the case where firms choose both $N_e$ and prices. We restrict ourselves to the ``two price" case where we have shown an equilibrium exists. We will assume the intrinsic cost of constructing spots is $t$, and the cost firms pay to construct them $p$ is a function of $t$ and government subsidies. This will impact aggregate welfare. We set $We = 1$, $\alpha = 1$, $W_d = 0.9$, $\beta = 0.33$, $\epsilon = 1$, $t = 0.1$, while varying $\delta$ between $0.5$ to $0.9$. We examine the effect of two government policies: one where they set a slightly lower mandate $r=0.33$ but fully subsidize construction, so $p=0$. We plot the welfare in Figure 3 as a function of $\delta$ with the four possible combinations of government policy as defined in Table \ref{tab:plotcaseesoptimalquantity}. \begin{table}[h!] \begin{center} \begin{tabular}{ |c|c|c| } \hline & No Subsidy & Subsidy \\ \hline No Mandate & (a) & (b)\\ \hline Mandate & (c) & (d)\\ \hline \end{tabular} \caption{Optimal capacity results} \label{tab:plotcaseesoptimalquantity} \end{center} \end{table} While aggregate welfare is decreased only slightly for all values of $\delta$ when any government action is taken, we see a large decrease in ICE consumer surplus (almost a $50\%$ drop-off) in all cases of government actions, but with a large increase in EV welfare (up to an almost $400\%$ increase) for all values of $\delta$. Effectively the government is only somewhat inefficiently trading off ICE welfare for EV welfare by either forcing or inducing (through subsidies) construction of EV chargers. Having both a large subsidy and relatively large mandate does not have much more impact beyond using just one policy given: they both produce similar effects independently and together. However, subsidies lead to government welfare loss and increases both firm profits at all levels of $\delta$, while mandates lead to lower firm profits and no cost to the government. \begin{figure*}[t!] \label{fig:optimalcapacity} \centering \begin{minipage}[t]{3.2cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.28]{{welfare_plot_optimal_capacity_nogovt}.pdf} \caption{Welfare, no government action} \label{fig:welfarenogovt} \end{subfigure} \end{minipage} \hspace{0.9cm} \begin{minipage}[t]{3.2cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.28]{{welfare_plot_optimal_capacity_subsidy}.pdf} \caption{Welfare, full subsidy} \label{fig:welfaresubsidy} \end{subfigure} \end{minipage} \hspace{0.9cm} \begin{minipage}[t]{3.2cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.28]{{welfare_plot_optimal_capacity_mandate}.pdf} \caption{Welfare, government mandate} \label{fig:welfaremandate} \end{subfigure} \end{minipage} \hspace{0.8cm} \begin{minipage}[t]{3.2cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.28]{{welfare_plot_optimal_capacity_subsidyandmandate}.pdf} \caption{Welfare, mandate and subsidy} \label{fig:welfaremandateandsubsidy} \end{subfigure} \end{minipage} \caption{Plots for Optimal Capacity} \end{figure*} \section{Monopolist with Stochastic Demand: Model} \label{sec:monopolistmodel} \noindent We now turn to our second model in which there is uncertainty in the demand for EV drivers. We consider a similar model as in Section II, with two changes. First, we consider a monopolist instead of a competitive market. Second, the demand function of both types of drivers will change. \subsection{Consumers} We will assume there is a mass of regular drivers all with the same valuation for parking, $W_d$. This mass is sufficiently large (essentially unbounded) such that at any positive price, the monopolist can fill up its parking spots until the marginal value is zero. For the EV market, we similarly assume all drivers have the same valuation for parking, $W_e > W_d$, but there are only $q_{max}$ EV consumers, where $q_{max}$ depends on the state of the world. Specifically, we define a probability distribution $\mathbf{\pi} = \{\pi_1,\pi_2,\ldots,\pi_n\}$ over a set $\mathbf{q} = \{q_1, q_2,\ldots,q_n\}$, so that $q_{max} = q_i$ with probability $\pi_i$. The monopolist sets both the capacity ($N_e$) and prices for ICE and EV drivers ($m$ and $c$, respectively) before this distribution is realized. We can therefore write the marginal utility of EV drivers (as a function of $q_{max}$) and ICE drivers as \begin{equation*} \label{eq:utilityICEmonopolist} U_d(q_d,N_e,m) = W_d - \epsilon \frac{q_d}{1 - N_e}- m, \end{equation*} \begin{align*} \label{eq:utilityEVmonopolist} U_e(q_e,N_e,c,q_{max}) &= W_e - \epsilon \frac{q_e}{N_e} - c. \\ \text{s.t.} \ \ \ & q_e \leq q_{max} \end{align*} \subsection{Monopolist} We assume there exists a monopolist who already owns a mass of parking spots suitable for ICE drivers. Like in the previous model, we normalize this number of spots to be 1. This monopolist cannot construct new parking spots, but is able to convert a portion of their spots to include an EV charger at cost $p$. This means choosing a number of EV spots $ 0 \leq N_e \leq 1$, leaving $1 - N_e$ spots for ICE drivers. The monopolist then chooses a price $c$ for EV drivers and $m$ for ICE drivers (i.e., we are only examining the ``Two Price'' case as described in the competitive model). They do this before realizing what state of the world they are in (i.e., before the size of the EV market is realized). Assuming $m \leq W_d$ and $c \leq W_e$, the demand for ICE drivers and EV drivers (as a function of the realization $q_{max}$), respectively, is \begin{equation*} D_d(N_e,m) = (1 - N_e)\frac{W_d - m}{\epsilon}, \end{equation*} \begin{equation} \label{eq:EVdemandstochastic} D_e(N_e,c,q_{max}) = \min \left\{ N_e \frac{W_e - c}{\epsilon},q_{max} \right\}. \end{equation} The monopolist is risk neutral and wants to maximize their expected profit from the ICE market and EV market, which will we define, respectively, as \begin{equation} \label{eq:ICErevenuemonopolist} \Pi^d(m,N_e) = mD_d(N_e,m), \end{equation} \begin{equation} \label{eq:EVrevenuemonopolist} E[\Pi^e(c,N_e)] = \sum_{i = 1}^{i = n} c\pi_i D_{e}(N_e,c,q_i). \end{equation} Combining \eqref{eq:ICErevenuemonopolist} and \eqref{eq:EVrevenuemonopolist} as well as the cost of constructing spots, the overall profit maximization problem of the monopolist is: \begin{equation} \label{eq:monopolistoptimization} \begin{aligned} & \underset{N_e,m,c}{\text{maximize}} & & \Pi_d(m,N_e) + E[\Pi_e(c,N_e)] - pN_{e} \\ & \text{subject to} & & 0 \leq N_e \leq 1. \end{aligned} \end{equation} Similar to the competitive model, we analyze this problem by viewing the monopolist's decision in two stages: first choosing $N_e$ and then choosing prices $m$ and $c$. \section{Monopolist with Stochastic Demand: Pricing} \label{sec:monopolistpricing} In this section, we analyze the prices the monopolist chooses as a function of $N_e$. We note that once the proportion of EV spots is chosen, the decisions to price EV and ICE drivers are independent as they cause no congestion to each other and the cost of the spots is sunk, and so we examine each separately. \subsection{ICE driver Pricing} We can find the optimal ICE price by solving \begin{equation*} \begin{aligned} & \underset{m}{\text{maximize}} & & \Pi^d(m) = m(1-N_e)\frac{W_d - m}{\epsilon}. \\ \end{aligned} \end{equation*} This problem is concave in $m$ and so we can find the solution by examining the first order optimality conditions which gives \begin{equation} \label{eq:optmonopolistICEprice} m^{*}(N_e) = \frac{W_d}{2}. \end{equation} We can plug \eqref{eq:optmonopolistICEprice} back into the optimization problem to get an expression for ICE revenue as a function of $N_e$ \begin{equation} \label{eq:ICErevmonopolist} \Pi^d(N_e) = \frac{(1 - N_e)W_d^2}{4\epsilon}. \end{equation} \noindent We can see this is simply a linear function in $N_e$, which increases in the ICE driver's utility ($W_d$) and decreases in $\epsilon$. \subsection{EV driver Pricing} Note that fixing $N_e$, we can break down the EV quantities serviced in each realization into three broad cases based on the EV price ($c$) the monopolist sets. We will define each case by what quantity of EV drivers $q_e$ they service for a given $q_{max} \ \in \mathbf{q}$. The first two cases are uniquely defined by a target realization $q_t \ \in \ \mathbf{q}$. Case 1 occurs when the monopolist sets a price such that $q_{e} = q_{max}$ in realizations where $q_{max} \leq q_t$ while $q_{e} = q_t$ when $q_{max} > q_t$. In other words the monopolist sets an EV price such that they exactly service the target quantity when there is a large enough demand for it, and fully service all realizations smaller than the target. Case 2 occurs when the monopolist sets a price such that $q_{e} = q_{max}$ when $q_{max} \leq q_t$ and $q_{e} = q_{r}$ for some $q_t < q_{r} < q_{t+1}$. This means the monopolist serves exactly $q_{max}$ for any realization where $q_{max} \leq q_t$, but serves some amount between the target realization and the next highest realization in all states of the world such that $q_{max} > q_t$. Finally the monopolist can set a price such that $q_e < q_1$ in all realizations of $q_{max}$, which we can call Case 3. These cases are summarized in Table \ref{tab:EVpricingcasesgeneraldist} . \begin{table}[h!] \begin{center} \begin{tabular}{ |c|c| } \hline Case & EV quantity serviced \\ \hline Case 1 & $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_t$ \\ \hline Case 2 & $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_r$ ($ q_t < q_r < q_{t+1}$) \\ \hline Case 3 & $q_{e} < q_1 \ \forall q_{max} $ \\ \hline \end{tabular} \caption{Monopolist quantity strategies.} \label{tab:EVpricingcasesgeneraldist} \end{center} \end{table} For a given number of possible realization $n$ the possible cases can be ordered as follows (which is increasing in the size of the maximum number of EVs served over all realizations). \\ [Case 3, Case 1 ($t=1$), Case 2 ($t=1$), Case 1 ($t=2$), ... , Case 2 ($t=n-1$), Case 1 ($t=n$)]. \\ This allows us to describe any feasible set of quantities the monopolist serves with $n$ target quantities of Case 1 ($t = [1,2,...,n]$, i.e., the monopolist can seek to at most service any given realization) and $n - 1$ target quantities for Case 2 ($t = [1,2,...,n-1]$ as the monopolist cannot service more than the largest realization). Given the threshold structure of EV demand in \eqref{eq:EVdemandstochastic}, note that for any realization where $q_{e} \leq q_{max}$, the monopolist will serve the same $q_{e}$ in any realization with a larger quantity of EV drivers. We now analyze the pricing in each of these cases (with a given target realization $q_t$ where applicable) for a fixed $N_e$. \\ \subsubsection*{Case 1: $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_t$} In this case, for a given target quantity $q_t$, the monopolist sets the price such that they get exactly $q_t$ in any realization where the number of arrivals is greater than or equal to $q_t$. By setting \eqref{eq:EVdemandstochastic} equal to $q_t$ and solving for $c$, we find the price is \begin{equation} \label{eq:pricecase1} c_1^{*}(N_e,t) = W_e - \epsilon\frac{q_t}{N_e}. \end{equation} \subsubsection*{Case 2: $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_r$ ($ q_t < q_r < q_{t+1}$)} In this case the monopolist wants to set the optimal price which is low enough to get a quantity $>q_t$ while large enough to get some amount $<q_{k+1}$. This can be expressed as the following optimization problem \begin{equation} \label{eq:case2twostageoptimization} \begin{aligned} & \underset{c}{\text{max}} & & \Pi^{e}_3(c) = c(\sum_{i = 1}^{i = t}\pi_i q_i + \sum_{j = t+1}^{j = n}\pi_j N_e\frac{W_e - c}{\epsilon}) \\ & \text{subject to} & & W_e - \epsilon \frac{q_t}{N_e} < c < W_e - \epsilon \frac{q_{t+1}}{N_e}. \end{aligned} \end{equation} Again we can make the constraint set closed by relaxing it to be $W_e - \epsilon \frac{q_t}{N_e} \leq c \leq W_e - \epsilon \frac{q_{k+1}}{N_e}$. If any constraint is tight, then this case is not optimal for the given setting. If the constraints are not tight, we can find the optimal price by examining the first order optimality conditions , which gives us \begin{equation} \label{eq:pricecase2} c_2^{*}(N_e,t) = \frac{W_e}{2} + \frac{\epsilon \sum_{i=1}^{t}\pi_iq_i}{2\sum_{j=t+1}^{n}\pi_j N_e}. \end{equation} This price can be viewed as the price if there was no constraint on the size of the EV market ($\frac{W_e}{2}$) (see Case 3) which is decreasing in the target $t$. \\ \subsubsection*{Case 3: $q_{e} < q_1 \ \forall q_{max} $} In this case, the monopolist sets the optimal price as a function of $N_e$ such that they get $q_e < q_1$ in any realization. For this case to be feasible, the monopolist has to set a high enough price such that $D_e(N_e,c,q_i) < q_1$. Hence the pricing scheme in this case is equivalent to the following optimization problem \begin{equation} \label{eq:case3optimization} \begin{aligned} & \underset{c}{\text{maximize}} & & \Pi^{e}_1(c) = cN_e\frac{W_e - c}{\epsilon} \\ & \text{subject to} & & c > W_e - \epsilon \frac{q_1}{N_e}. \end{aligned} \end{equation} Again we can relax the constraint to be $c \geq W_e - \epsilon \frac{q_1}{N_e}$, and note that if this constraint is ever tight we are not in this case. If this occurs we will say that this case is no longer feasible, as case 2 is strictly superior. When the constraint is not tight, we find the optimal price is \begin{equation} \label{eq:optmonopolistEVpricecasea} c_3^{*}(N_e,t) = \frac{W_e}{2}. \end{equation} This is the same pricing scheme as for the ICE drivers (a constant price independent of $N_e$). This makes sense as assuming ex ante the monopolist sets a price such that they serves $q_e < q_1$ EV drivers is the same as being unconstrained by the size of the EV market. \section{Monopolist with Stochastic Demand: Capacity} \label{sec:stochasticarrivalcapacity} Next, we turn to the Monopolist's optimal choice of $N_e$. Using the results of the previous section, we can now formulate this as \begin{align} \label{eq:firststagemonopolist} \underset{N_e}{\text{maximize}} & \ \ m^{*}(N_e)D_d(N_e,m^{*})\ + \\ & c^{*}(N_e,t)\sum_{r = 1}^{r = n} \pi_r D_{e}(N_e,c^{*}(N_e,t),q_r) - pN_{e} \nonumber \\ \text{subject to} & \ \ 0 \leq N_e \leq 1. \nonumber \end{align} At each value of $N_e$, the optimal EV price $c^{*}(N_e,k)$ is defined by whichever pricing case and target quantity pair leads to the highest profit (at a given $N_e$, any given case could lead to this). The optimal ICE price $m^{*}(N_e)$ is defined by \eqref{eq:optmonopolistICEprice} regardless of case (and in fact is also independent of $N_e$). The overall optimal profit of the monopolist is defined by the best choice of EV spots $N_e^*$ that solves this problem. This choice also solves \eqref{eq:monopolistoptimization} (where the optimal $m$ and $c$ are determined by this choice $N_e^*$). We now examine an important property of $N_e^{*}$. \begin{theorem} \label{thm:stochasticdemand} Assume $\frac{W_e}{2} > \epsilon q_1$ and $\frac{4}{\epsilon}(W_e^2 - W_d^2) > p$. Any optimal pricing strategy for the monopolist is to set a price $c$ such that for some $t$, $1 \leq t \leq n$, the monopolist services exactly $q_t$ for every realization of the distribution such that $q_e \geq q_t$, and exactly $q_i$ for any realization where the quantity of EV drivers is $q_i < q_t$. \end{theorem} In other words, this shows that under the assumptions in this theorem the optimal price is always in Case 1. Hence, to determine the optimal $N_e$, we only need to consider the $n$ prices corresponding to Case 1. We can prove this by examining the structure of \eqref{eq:firststagemonopolist} given how $c^{*}(N_e)$ is defined in each case. The proof for this is found in the appendix. \begin{figure*}[t!] \label{fig:stochasticdemand} \centering \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_a}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.3]$, $\boldsymbol{\pi} = [0.4,0.33,0.27]$, $p=0.01$} \label{fig:stochastic_plot_a} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_b}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.3]$, $\boldsymbol{\pi} = [0.31,0.33,0.36]$, $p=0.01$} \label{fig:stochastic_plot_b} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_c}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.5]$, $\boldsymbol{\pi} = [0.31,0.33,0.36]$, $p=0.01$} \label{fig:stochastic_plot_c} \end{subfigure} \end{minipage} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_d}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.5]$, $\boldsymbol{\pi} = [0.2,0.1,0.7]$, $p=0.01$} \label{fig:stochastic_plot_d} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_e}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.5]$, $\boldsymbol{\pi} = [0.2,0.15,0.65]$, $p=0.01$} \label{fig:stochastic_plot_e} \end{subfigure} \end{minipage} \hspace{1.1cm} \begin{minipage}[t]{4cm} \begin{subfigure}[t]{1\textwidth} \centering \includegraphics[scale=0.35]{{plot_f}.pdf} \caption{$\mathbf{q} = [0.1,0.15,0.5]$, $\boldsymbol{\pi} = [0.2,0.15,0.65]$, $p=0$} \label{fig:stochastic_plot_f} \end{subfigure} \end{minipage} \caption{Plots for stochastic demand} \end{figure*} \section{Monopolist with Stochastic Demand: Case Study} \label{sec:monopolistnumerical} We now examine how changes in the monopolist's belief about the EV market can affect the capacity they can add. In Figure 4 we plot the optimal revenue function for the monopolist as a function of $N_e$ with $W_e = 1.25$, $W_d = 1$, $\epsilon = 1$, $n=3$, $t = 0.01$ and $p=0.01$. We divide the pricing into the cases defined by different k values as described before. The overall optimal $N_e^*$ in each plot is marked by a vertical blue line. In each plot, we vary the distribution of EV arrivals as noted below. As indicated in Theorem \ref{thm:stochasticdemand}, in each plot the optimal number of spots is in a Case 1 pricing regime, but the target quantity $k$ is different and noted. In plot (a), we set $\mathbf{q} = [0.1,0.15,0.3]$ and $\boldsymbol{\pi} = [0.4,0.33,0.27]$ and find $N_e^* = 0.196$ with $k = 1$. In plot (b), we set $\mathbf{q} = [0.1,0.15,0.3]$ and $\boldsymbol{\pi} = [0.31,0.33,0.36]$, and find that the optimal exists at $N_e^* = 0.279$ with $k = 2$. This is the same as plot (a) but with a small change in the arrival distribution (a $0.06$ decrease in $\pi_1$ and a corresponding increase in $\pi_3$). This small change leads to an almost $50\%$ increase in the number of EV spots constructed. In plot (c), we set $\mathbf{q} = [0.1,0.15,0.5]$ and $\boldsymbol{\pi} = [0.31,0.33,0.36]$ and find $N_e^* = 0.278$ for k=2 again. This is the same as plot (b) but with $q_3$ increasing by $0.2$. We can see that even though there is now a possible realization where many more EV drivers enter the market than in plot (b), the monopolist optimally does not plan any differently as $N_e^*$ is independent of $q_3$. In plot (d), we set $\mathbf{q} = [0.1,0.15,0.5]$ and $\boldsymbol{\pi} = [0.2,0.1,0.7]$ and find $N_e^* = 0.860$ with k=3. A change in the distribution of EV arrivals (not the quantities in each state) leads to a large change in the number of spots constructed. In plot (e), we set $\mathbf{q} = [0.1,0.15,0.5]$ and $\boldsymbol{\pi} = [0.2,0.15,0.65]$ and find $N_e^* = 0.284$ with $k=2$. This is a small change from plot d (the same quantity distribution but with $\pi_2$ $0.05$ higher and $pi_3$ correspondingly smaller). A small change in the distribution of arrivals in this case leads to more than a 3 times larger number of EV spots constructed. Lastly, in plot (f) we have the government subsidize the construction of EV spots ($p = 0.0$) with no change in the distribution of arrivals and find $N_e^* =0.857$ with k=3. We see that government subsidies can have a large impact on equilibrium behavior as it can shift which case is optimal for the monopolist. It also affects the number of spots within cases as we can see from \eqref{eq:optimalNecase1stochastic}. This makes it a tool that always increases the number of EV spots created, unlike the distributions of arrivals (which as we saw may not impact the number of spots constructed). \section{Conclusions} \label{sec:conclusion} We proposed a model where EV drivers and ICE drivers utilize the same fixed quantity of a resource (parking) and EV drivers have a higher valuation due to the need to charge. However, to serve EV drivers, operators require additional investment leading to these spots only being available to ECs. We have used this model to examine a case where there is competition or another where there is uncertainty in future EV demand. The right set of policies (subsidies and mandates) and the correct levels are dependent on how competitive the market is when firms are more cognizant of the ability to add capacity and price these two concurrent markets (EV and ICE drivers). With a single monopolist, we showed that errors in forecasting the EV demand can have significant impact on the charging capacity installed, suggesting that techniques for improving such forecasts are worth considering in future work. This also suggests that risk neutrality may not be the best way to optimize over this uncertainty, as a different objective function could lead to a capacity that targets for multiple sizes of the EV market instead of the one target as in our work. One key element in the EV market we did not model is the cost of electricity (we assumed charging costs were low enough to be considered 0); adding such costs as well as options to help lower these (like investing in renewable generation) is another possible future direction. \section*{Appendix} \subsection{Justification of Wardrop equilibrium expressions} In \eqref{eq:wardropEV} and \eqref{eq:wardropICE}, we gave the Wardrop equilibrium quantities by assuming that both firms always served each type of user. In particular we ignored the case where one firms prices for a given class was large enough compared to the other firms so that it did not serve any customers. In this section we show that in terms of determining the Wardrop equilibrium, there is no loss in doing this. In particular, we show that given an equilibrium as in Section \ref{sec:competitivemodel}, a firm would never benefit by unilaterally lowering its price to the point where our given expressions no longer hold. We show this by contradiction. We analyze the EV market, but the same results hold for the ICE one. Without loss of generality, we will fix the price of firm 2 and look at firm 1's incentives to deviate. We note that the expression for quantity in \eqref{eq:wardropEV} we have implies \begin{equation*} c_1 + \epsilon \frac{q_{e1}}{Ne_{e1}} = c_2 + \epsilon \frac{q_{e2}}{Ne_{e2}}. \end{equation*} Assume that firm 1 deviates from this point and sets a price that leads to no consumers optimally parking at firm 2. This implies two conditions hold \begin{equation} \label{eq:wardropcondition1} c_1 + \epsilon \frac{q_{e1}}{Ne_{e1}} = W_e - \alpha W_e q_{e1} \end{equation} \begin{equation} \label{eq:wardropcondition2} c_2 > W_e - \alpha W_e q_{e1}. \end{equation} Rearranging equation \eqref{eq:wardropcondition1}, the revenue function for firm 1 is \begin{equation*} \max_{c_1} c_1(\frac{W_e - c_1}{\alpha W_e + \frac{\epsilon}{N_{e1}}}). \end{equation*} This is a concave function in $c_1$. Evaluating the first-order optimality conditions, the optimal price that firm 1 chooses in this case is \begin{equation*} c_1^* = \frac{W_e}{2}. \end{equation*} In order for condition \eqref{eq:wardropcondition2} to hold given this price, it must be that: \begin{equation*} c_2 > W_e - \alpha W_e q_{e1} = c_1 + \epsilon \frac{q_{e1}}{N_{e1}} = \frac{W_e}{2} + \epsilon \frac{q_{e1}}{N_{e1}}. \end{equation*} As $\frac{W_e}{2}$ is the monopolist price, this can never occur. Therefore, firm 1 will never best respond to firm 2 such that firm 2 would serve no consumers (unless firm 2's capacity was 0). \subsection{Proof of Proposition \ref{prop:equilibriumexistence}} \subsubsection{Quantity case 1: Exactly follow mandate} In this case the first stage of the game is simply $Ne_i = rN_i$. Thus to prove this result we only need to verify that the second stage equilibrium is unique. To do this we first evaluate the second derivative of the revenue function from serving ICE drivers as follows (as quantity is assumed to be fixed in the first stage): \\ \begin{gather*} \Pi^{ICE}_i = m_iq_{di} = \frac{(W_d+\beta W_d N_{dj}^{\epsilon}m_j)m_i}{\beta W_d(1+ \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}} \\ - \frac{(W_d \beta N_{dj}^{\epsilon} + 1)m_i^2}{\beta W_d(1+ \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}} \\ \frac{\delta \Pi^{ICE}_i }{\delta m_i} = \frac{(W_d+\beta W_d N_{dj}^{\epsilon}m_j) - 2(W_d \beta N_{dj}^{\epsilon} + 1)m_i}{\beta W_d(1+ \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}} \\ \frac{\delta^2 \Pi^{ICE}_i }{\delta m_i^2} = \frac{ - 2(W_d \beta N_{dj}^{\epsilon} + 1)}{\beta W_d(1+ \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}} \leq 0 . \end{gather*} Given the second derivative is always negative with respect to the firm's strategy we have the existence of a Nash Equilibria. Uniqueness then follows from comparing this to the off-diagonal terms in the Hessian matrix for $\Pi_i$, i.e., \\ \begin{equation*} \frac{\delta^2 \Pi_i }{\delta m_i m_j} = \frac{W_d \beta N_{dj}^{\epsilon} }{\beta W_d(1+ \frac{N_{dj}}{N_{di}}) + \frac{1}{N_{di}^{\epsilon}}} \leq |\frac{\delta^2 \Pi_i }{\delta m_i^2}|. \end{equation*} The same can be done with the revenue function of servicing EV drivers. This implies dominance solvability of the overall revenue function (as the Hessian of the payoff functions are negative semi-definite), which from Moulin (1984) proves there exists a unique Nash equilibrium \cite{moulin1984dominance} \cite{rosen1965existence}. \\ \subsubsection{Quantity case 2: Mandate forms lower bound} For length purposes, the proof for this can be found in the version of the paper located at \cite{dropbox}. \subsection{Proof of Proposition \ref{prop:maxquantitydriver}} We assume $N_{e1} + N_{e2} = K$, and so can define $N_{e1} = K - N_{e2}$. We will prove this by showing the function $\frac{\delta q_{e}(K-N_{e2},N_{e2})}{\delta N_{e2}} \leq 0$ for $N_{e2} \geq \frac{K}{2}$. Using \ref{eq:wardropEV} and the expressions for $c_i^{BR}(N_{ei},c_j)$ we can express $q_ei$ as follows: \begin{equation*} q_{e1}(K-N_{e2},N_{e2}) = \frac{W_e + \frac{\alpha W_e N_{e2}}{\epsilon}c^{BR}_2(K-N{e2},N_{e2})}{2(\alpha W_e K + \epsilon)(\frac{1}{N_{e2}})}, \end{equation*} \begin{equation*} q_{e2(K-N_{e2},N_{e2})} = \frac{W_e + \frac{\alpha W_e (K - N_{e2})}{\epsilon}c^{BR}_1(K-N{e2},N_{e2})}{2(\alpha W_e K + \epsilon)(\frac{1}{K - N_{e2}})}. \end{equation*} Let $q_e(K-N_{e2},N_{e2}) = q_{e1}(K-N_{e2},N_{e2}) + q_{e2}(K-N_{e2},N_{e2})$ and \begin{multline*} q_e(K-N_{e2},N_{e2}) =\frac{\alpha W_e(KN_{e2}-N^2_{e2})}{\epsilon}[ \\ c^{BR}_1(K-N{e2},N_{e2}) + c^{BR}_2(K-N{e2},N_{e2})]. \end{multline*} Using the expressions for $c^{BR}_1(K-N{e2},N_{e2})$ and $c^{BR}_2(K-N{e2},N_{e2})$ we find \begin{multline*} q_e(K-N_{e2},N_{e2}) = \frac{(\frac{\alpha W_e(KN_{e2}-N^2_{e2})}{\epsilon})(\frac{3\alpha W_e^2 K}{\epsilon} + 4W_e)}{\frac{3\alpha^2 W_e^2 (KN_{e2} - N_{e2}^2)}{\epsilon^2} + \frac{4 \alpha W_e K}{\epsilon} + 4}. \end{multline*} Using the quotient rule, we can express the derivative with respect to $N_{e2}$ as: \begin{multline}\label{eq:derivativequantity} \frac{\delta q_e(K-N_{e2},N_{e2})}{\delta N_{e2}} = \frac{(\frac{\alpha W_e(K-2N_{e2})}{\epsilon})(\frac{3\alpha W_e^2 K}{\epsilon} + 4W_e)}{\frac{3\alpha^2 W_e^2 (KN_{e2} - N_{e2}^2)}{\epsilon^2} + \frac{4 \alpha W_e K}{\epsilon} + 4} \\ + \frac{(\frac{\alpha W_e(KN_{e2}-N^2_{e2})}{\epsilon})(\frac{3\alpha W_e^2 K}{\epsilon} + 4W_e)(\frac{3\alpha^2 W_e^2 (K - 2N_{e2})}{\epsilon^2})}{(\frac{3\alpha^2 W_e^2 (KN_{e2} - N_{e2}^2)}{\epsilon^2} + \frac{4 \alpha W_e K}{\epsilon} + 4)^2}. \end{multline} For any $N_{e2} \in [\frac{K}{2},K]$, $(K-2N_{e2}) \leq 0$ but $(KN_{e2}-N_{e2}^2) \geq 0$. Therefore, both terms in the above equation are $\leq 0$ for any $N_{e2}$ between $\frac{K}{2}$ and $K$, and so the total EV quantity serviced decreases as $N_{e2}$ increases from $\frac{K}{2}$ to $K$. Therefore, the quantity is maximized when $N_{e2} = \frac{K}{2}$. We note this same proof holds for ICE pricing. \subsection{Proof of Theorem \ref{thm:stochasticdemand}} We show that the monopolist can never choose $N_e^{*}$ such that they are in Case 2 or Case 3 (for any target $q_t$), but can do so when in Case 1. We examine each case separately to demonstrate this. \begin{proof} \begin{proofpart} Case 1: $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_t$ \normalfont We can note using $c_1^{*}(N_e,t)$ as defined in \eqref{eq:pricecase1} in \eqref{eq:firststagemonopolist} leads to the revenue function in Case 1 as a function of the target $k$ as \begin{multline*} \Pi_{1}(N_e,k) =(W_e - \epsilon \frac{q_t}{N_e})(\sum_{i = 1}^{i = t}\pi_i q_i + \sum_{j = t+1}^{j = n}\pi_j q_t)\\ + \frac{(1-N_e)W_d^2}{4\epsilon} - pN_e. \end{multline*} \normalfont This is a concave problem in $N_e$. We find the optimal $N_e^*$ for this case given a target quantity $q_t$ is \begin{equation} \label{eq:optimalNecase1stochastic} N_e^*(k) = \max\{\sqrt{\frac{\epsilon q_t(\sum_{i = 1}^{i = k}\pi_i q_i + \sum_{j = k+1}^{j = n}\pi_j q_t)}{\frac{W_d^2}{4\epsilon} + p}},1\}. \end{equation} \end{proofpart} \begin{proofpart} Case 2: $q_{e} = q_i$ if $q_{max} \leq q_t$, else $q_{e} = q_r$ ($ q_t < q_r < q_{t+1}$) \normalfont Substituting $c_2^{*}(N_e)$ as defined in \eqref{eq:pricecase2} into \eqref{eq:firststagemonopolist}, we can examine the revenue as a function of $N_e$ in Case 2 for a given $k$ as \begin{multline*} \Pi_{2}(N_e,k) = (\frac{W_e}{2} + \frac{\epsilon \sum_{i=1}^{k}\pi_iq_i}{2\sum_{j=k+1}^{n}\pi_j N_e})(\sum_{i = 1}^{i = k}\pi_i q_i + \\ \sum_{j = k+1}^{j = n}\pi_j N_e\frac{W_e - \frac{\epsilon \sum_{i=1}^{k}\pi_iq_i}{\sum_{j=k+1}^{n}\pi_j N_e}}{2\epsilon}) + \frac{(1-N_e)W_d^2}{4\epsilon}. \end{multline*} \normalfont This problem is twice differentiable in $N_e$, and examining the second derivative we can see that \begin{equation*} \frac{\delta^2 \Pi_{3}(N_e,k)}{\delta N_e^2} = \frac{\epsilon(\sum_{i=1}^{k}\pi_iq_i)^2}{2\sum_{j=k+1}^{n}\pi_j N_e^3} > 0.\\ \end{equation*} \normalfont Therefore this problem is strictly convex in $N_e$ for any $k$. This means the revenue will be maximized within this case when one side of the constraint of \eqref{eq:case2twostageoptimization} is tight, which leads to Case 2 pricing no longer being feasible for the target quantity. \end{proofpart} \begin{proofpart} Case 3: $q_{e} < q_1 \ \forall q_{max} $ \normalfont We can show the monopolist never optimally prices in this case by first noting the optimal price $c_3^{*}(N_e)$ defined in \eqref{eq:optmonopolistEVpricecasea} leads to an EV demand with $q_{max} = q_1$ as a function of $N_e$ equal to \begin{equation*} D_e(N_e,c_3^{*}(N_e),q_1) = \min\{N_e \frac{W_e}{2\epsilon},q_1\}. \end{equation*} \normalfont We have assumed $\frac{W_e}{2} > \epsilon q_1$, which is equivalent to $D_e(N_e = 1,c = \frac{W_e}{2},q_{max}=q_1)$. This implies $\exists N_e^{'} < 1$. such that $N_e^{'} \frac{W_e}{2\epsilon} = q_1$ and thus at this level of $N_e^{'}$ the monopolist is pricing in Case 1 with $q_t = q_1$. \normalfont Secondly, we can substitute \eqref{eq:optmonopolistEVpricecasea} into \eqref{eq:firststagemonopolist} to get the revenue as a function of $N_e$ when they price in Case 3 \begin{equation} \label{eq:revcase3} \Pi_3(N_e) = \frac{N_eW_e^2}{4\epsilon} + \frac{(1 - N_e)W_d^2}{4\epsilon} - pN_e. \end{equation} \normalfont We can show that at any $N_e < N_e^{'}$ (where the firm is still pricing in Case 3), $\Pi_1(N_e) < \Pi_1(N_e^{'})$ by examining the first derivative of \eqref{eq:revcase3}, which is \begin{equation*} \frac{\delta \Pi_1(N_e)}{\delta N_e} = \frac{4}{\epsilon}(W_e^2 - W_d^2) - p > 0 \end{equation*} \noindent \normalfont as in our assumption $\frac{4}{\epsilon}(W_e^2 - W_d^2) > p$. Therefore, at any level $N_e$ such that the constraint in \eqref{eq:case3optimization} is satisfied the monopolist would increase profit by increasing $N_e$, and at any level where the constraint is violated they would gain more profit from pricing in Case 1. \end{proofpart} \end{proof} \begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{ErminWei.pdf}}]{Ermin Wei} received the Undergraduate triple degree in computer engineering, finance and mathematics with a minor in German from the University of Maryland, College Park, MD, USA, the M.S. degree from the Massachusetts Institute of Technology (MIT), Cambridge, MA, USA, and the Ph.D. degree in electrical engineering and computer science, advised by Prof. A. Ozdaglar, from MIT in 2014. She is currently an Assistant Professor with the Department of Electrical Engineering and Computer Science, Northwestern University, Evanston, IL, USA. Her research interests include distributed optimization methods, convex optimization and analysis, smart grid, communication systems and energy networks, and market economic analysis. She was the recipient of many awards, including the Graduate Women of Excellence Award, second place prize in Ernst A. Guillemen Thesis Award, and Alpha Lambda Delta National Academic Honor Society Betty Jo Budson Fellowship. \end{IEEEbiography} \begin{IEEEbiography} [{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{RandallBerry.pdf}}]{Randall A. Berry} Randall A. Berry is the Lorraine Morton Professor in the Department of Electrical Engineering and Computer Science at Northwestern University. His current research interests span topics in network economics, wireless communication, computer networking and information theory. Dr. Berry received the MS and PhD degrees from the Massachusetts Institute of Technology in 1996 and 2000, respectively. He is the recipient of a 2003 CAREER award from the National Science Foundation and is a fellow of the IEEE. He served as an editor for the IEEE Transactions on Wireless Communications (2006- 2009) and the IEEE Transactions on Information Theory (2008-2012) as well as a guest editor for special issues of the IEEE Journal on Selected Areas in Communications (2017), the IEEE Journal on Selected Topics in Signal Processing (2008) and the IEEE Transactions on Information Theory (2007). Dr. Berry has also served on the program and organizing committees of numerous conferences including serving as co- chair of the 2012 IEEE Communication Theory Workshop, co-chair of 2010 IEEE ICC Wireless Networking Symposium. and TPC co-chair for the 2018 ACM MobiHoc conference. \end{IEEEbiography} \begin{IEEEbiography} [{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio, angle=360]{BrendanBadia.pdf}}]{Brendan Badia} is a PhD candidate in Electrical Engineering at Northwestern. He received the BS in Electrical and Computer Engineering and Economics at Carnegie Mellon, Pittsburgh, PA. \end{IEEEbiography} \bibliographystyle{ieeetr}
{'timestamp': '2019-04-23T02:28:49', 'yymm': '1904', 'arxiv_id': '1904.09967', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09967'}
arxiv
\section{Completeness of $\mathsf{Ldm}$}\label{Completeness_Proof_ldm} We give the definitions and lemmas sufficient to prove the completeness of $\mathsf{Ldm}$ relative to $\mathsf{Tstit}$ frames \cite{Lor13,BerLyo19}. We make use of the canonical model of $\mathsf{Ldm}$ (obtained by standard means \cite{BlaRijVen01,BalHerTro08}) to construct a $\mathsf{Tstit}$ model. A truth-lemma is then given relative to this model, from which, completeness follows as a corollary. \begin{definition}[$\mathsf{Ldm}$-CS, $\mathsf{Ldm}$-MCS] A set $\Theta \subset \mathcal{L}_{\mathsf{Ldm}}$ is a \emph{$\mathsf{Ldm}$ consistent set ($\mathsf{Ldm}$-CS)} iff $\Theta \not\vdash_{\mathsf{Ldm}} \bot$. We call a set $\Theta \subset \mathcal{L}_{\mathsf{Ldm}}$ a \emph{$\mathsf{Ldm}$ maximally consistent set ($\mathsf{Ldm}$-MCS)} iff $\Theta$ is a $\mathsf{Ldm}$-CS and for any set $\Theta'$ such that $\Theta \subset \Theta'$, $\Theta' \vdash_{\mathsf{Ldm}} \bot$. \end{definition} \begin{lemma}[Lindenbaum's Lemma \cite{BlaRijVen01}]\label{Lindenbaum} Every $\mathsf{Ldm}$-CS can be extended to a $\mathsf{Ldm}$-MCS. \end{lemma} \begin{definition}[Present and Future Pre-Canonical $\mathsf{Tstit}$ Model] The \emph{present pre-canonical $\mathsf{Tstit}$ model} is the tuple $M^{\mathsf{pres}} = (W^{\mathsf{pres}}, \mathcal{R}^{\mathsf{pres}}_{\Box},$ $\{\mathcal{R}^{\mathsf{pres}}_{i}|i \in Ag\}, V^{\mathsf{pres}})$ defined below left, and the \emph{future pre-canonical $\mathsf{Tstit}$ model} is the tuple $M^{\mathsf{fut}} = (W^{\mathsf{fut}}, \mathcal{R}^{\mathsf{fut}}_{\Box}, \{\mathcal{R}^{\mathsf{fut}}_{i}|i \in Ag\}, V^{\mathsf{fut}})$ defined below right: \begin{center} \begin{multicols}{2} \begin{center} \begin{itemize} \item $W^{\mathsf{pres}}$ is the set of all $\mathsf{Ldm}$-MCSs; \item $\mathcal{R}^{\mathsf{pres}}_{\Box}wu$ iff for all $\Box \phi \in w$, $\phi \in u$; \item $\mathcal{R}^{\mathsf{pres}}_{i}wu$ iff for all $[i] \phi \in w$, $\phi \in u$; \item $V^{\mathsf{pres}}(p) = \{w \in W| p \in w\}$. \end{itemize} \end{center} \begin{center} \begin{itemize} \item $W^{\mathsf{fut}} = W^{\mathsf{pres}}$; \item $\mathcal{R}^{\mathsf{fut}}_{\Box}(w) = \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(w)$; \item $\mathcal{R}^{\mathsf{fut}}_{i}(w) = \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(w)$; \item $V^{\mathsf{fut}}(p) = V^{\mathsf{pres}}(p)$. \end{itemize} \end{center} \end{multicols} \end{center} \end{definition} \begin{definition}[Canonical Temporal Kripke STIT Model] We define the \emph{canonical temporal Kripke STIT model} to be the tuple $M^{\mathsf{Ldm}} = (W^{\mathsf{Ldm}}, \mathcal{R}^{\mathsf{Ldm}}_{\Box}, $ $\{R^{\mathsf{Ldm}}_{i} | i \in Ag\}, \mathcal{R}^{\mathsf{Ldm}}_{Ag}, \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}, \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{H}},$ $V^{\mathsf{Ldm}})$ such that: \begin{itemize} \item $W^{\mathsf{Ldm}} = W^{\mathsf{pres}} \times \mathbb{N}$\footnote{Note that we choose to write each world $(w,j) \in W^{\mathsf{Ldm}}$ as $w^{j}$ to simplify notation. Moreover, we write $\phi \in w^{j}$ to mean that the formula $\phi$ is in the $\mathsf{Ldm}$-MCS $w$ associated with $j$.}; \item $\mathcal{R}^{\mathsf{Ldm}}_{\Box}w^{j}u^{j}$ iff (i) $\mathcal{R}^{\mathsf{pres}}_{\Box}wu$ and $j = 0$, or (ii) $\mathcal{R}^{\mathsf{fut}}_{\Box}wu$ and $j > 0$; \item $\mathcal{R}^{\mathsf{Ldm}}_{i}w^{j}u^{j}$ iff (i) $\mathcal{R}^{\mathsf{pres}}_{i}wu$ and $j = 0$, or (ii) $\mathcal{R}^{\mathsf{fut}}_{i}wu$ and $j > 0$; \item $\mathcal{R}^{\mathsf{Ldm}}_{Ag}(w^{j}) = \bigcap_{1 \leq i \leq n} \mathcal{R}^{\mathsf{Ldm}}_{i}(w^{j})$; \item $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}} = \{(w^{j},w^{k})| w^{j}, w^{k} \in W^{\mathsf{Ldm}} \text{ and } j < k \}$; \item $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{H}} = \{(u^{i},w^{i})| (w^{i},u^{i}) \in \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}\}$; \item $V^{\mathsf{Ldm}}(p) = \{w^{j} \in W^{\mathsf{Ldm}}| w \in V^{\mathsf{pres}}(p)\}$. \end{itemize} \end{definition} \begin{lemma}\label{Relate_only_same_level} For all $\alpha \in \{\Box, Ag\} \cup Ag$, if $\mathcal{R}^{\mathsf{Ldm}}_{\alpha}w^{j}u^{k}$ for $j,k \in \mathbb{N}$, then $j = k$. \end{lemma} \begin{proof} Follows by definition of the canonical $\mathsf{Tstit}$ model. \end{proof} \begin{lemma}\label{AG_Rel_Same_All_Levels} For all $j \in \mathbb{N}$ with $k \geq 1$, $(w^{j},u^{j}) \in \mathcal{R}^{\mathsf{Ldm}}_{Ag}$ iff $(w^{j+k},u^{j+k}) \in \mathcal{R}^{\mathsf{Ldm}}_{Ag}$. \end{lemma} \begin{proof} This follows from the fact that $u^{0} \in \mathcal{R}^{\mathsf{Ldm}}_{Ag}(w^{0})$ iff $u \in \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(w)$ iff $u \in \mathcal{R}^{\mathsf{fut}}_{i}(w)$ for each $i \in Ag$ iff $u \in \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{fut}}_{i}(w)$ iff $u^{k} \in \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{Ldm}}_{i}(w^{k})$ for any $k > 0$. \end{proof} \begin{lemma}[\cite{BlaRijVen01}]\label{Relations_Diamonds} (i) For all $\mathsf{x} \in\{\mathsf{pres}, \mathsf{fut}, \mathsf{Ldm}\}$, $\mathcal{R}^{\mathsf{x}}_{\Box}wu$ iff for all $\phi$, if $\phi \in u$, then $\Diamond \phi \in w$. (ii) For all $\mathsf{x} \in\{\mathsf{pres}, \mathsf{fut}, \mathsf{Ldm}\}$, $\mathcal{R}^{\mathsf{x}}_{i}wu$ iff for all $\phi$, if $\phi \in u$, then $\langle i \rangle \phi \in w$. \end{lemma} \begin{lemma}[Existence Lemma \cite{BlaRijVen01}]\label{Existence_Lemma} (i) For any world $w^{j} \in W^{\mathsf{Ldm}}$, if $\Diamond \phi \in w^{j}$, then there exists a world $u^{j} \in W^{\mathsf{Ldm}}$ such that $\mathcal{R}^{\mathsf{Ldm}}_{\Box}w^{j}u^{j}$ and $\phi \in u^{j}$. (ii) For any world $w^{j} \in W^{\mathsf{Ldm}}$, if $\langle i \rangle \phi \in w^{j}$, then there exists a world $u^{j} \in W^{\mathsf{Ldm}}$ such that $\mathcal{R}^{\mathsf{Ldm}}_{i}w^{j}u^{j}$ and $\phi \in u^{j}$. \end{lemma} \begin{lemma}\label{Canonical_is_TTKSTIT_Model} The Canonical Model is a temporal Kripke STIT model. \end{lemma} \begin{proof} We prove that $M^{\mathsf{Ldm}}$ has all the properties of a $\mathsf{Tstit}$ model: \begin{itemize} \item By lemma \ref{Lindenbaum}, the $\mathsf{Ldm}$ consistent set $\{p\}$ can be extended to a $\mathsf{Ldm}$-MCS, and therefore $W^{\mathsf{pres}}$ is non-empty. Since $\mathbb{N}$ is non-empty as well, $W^{\mathsf{pres}} \times \mathbb{N} = W^{\mathsf{Ldm}}$ is a non-empty set of worlds. \item We argue that $\mathcal{R}^{\mathsf{Ldm}}_{\Box}$ is an equivalence relation between worlds of $W^{\mathsf{Ldm}}$, and omit the arguments for $\mathcal{R}^{\mathsf{Ldm}}_{i}$ and $\mathcal{R}^{\mathsf{Ldm}}_{Ag}$, which are similar. Suppose that $w^{j} \in W^{\mathsf{Ldm}}$. We have two cases to consider: (i) $j = 0$, and (ii) $j > 0$. \textbf{(i)} Standard canonical model arguments apply and $\mathcal{R}^{\mathsf{Ldm}}_{\Box}$ is an equivalence relation between all worlds of the form $w^{0} \in W^{\mathsf{Ldm}}$ (See \cite{BlaRijVen01} for details). \textbf{(ii)} If we fix a $j >0$, then $\mathcal{R}^{\mathsf{Ldm}}_{\Box}$ will be an equivalence relation for all worlds of the form $w^{j} \in W^{\mathsf{Ldm}}$ since the intersection of equivalence relations produces another equivalence relation. Last, since $\mathcal{R}^{\mathsf{Ldm}}_{\Box}$ is an equivalence relation for each fixed $j \in \mathbb{N}$, and because each $W^{\mathsf{pres}} \times \{j\} \subset W^{\mathsf{Ldm}}$ is disjoint from each $W^{\mathsf{pres}} \times \{j'\} \subset W^{\mathsf{Ldm}}$ for $j \neq j'$, we know that the union all such equivalence relations will be an equivalence relation. \item[{\rm \textbf{(C1)}}] Let $i$ be in $Ag$ and assume that $(w^{j},u^{j}) \in \mathcal{R}^{\mathsf{Ldm}}_{i}$. We split the proof into two cases: (i) $j = 0$, or (ii) $j > 0$. \textbf{(i)} Assume that $\Box \phi \in w^{0}$. Since $w$ is a $\mathsf{Ldm}$-MCS, it contains the axiom $\Box \phi \rightarrow [i] \phi$, and so, $[i] \phi \in w$ as well. Since $(w,u) \in \mathcal{R}^{\mathsf{pres}}_{i}$ (because $j = 0$), we know that $\phi \in u$ by the definition of the relation; therefore, $(w,u) \in \mathcal{R}^{\mathsf{pres}}_{\Box}$, which implies that $(w^{0},u^{0}) \in \mathcal{R}^{\mathsf{Ldm}}_{\Box}$ by definition. \textbf{(ii)} The assumption that $j >0$ implies that $u \in \mathcal{R}^{\mathsf{fut}}_{i} (w) $ $= \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(w) = \mathcal{R}^{\mathsf{fut}}_{\Box}(w)$ by definition, which implies that $(w^{j},u^{j}) \in \mathcal{R}^{\mathsf{Ldm}}_{\Box}$. \item[{\rm \textbf{(C2)}}] Let $u^{j}_{1}, ..., u^{j}_{n} \in W^{\mathsf{Ldm}}$ and assume that $\mathcal{R}^{\mathsf{Ldm}}_{\Box}u^{j}_{i}u^{j}_{k}$ for all $i,k \in \{1,...,n\}$. We split the proof into two cases: (i) $j = 0$, or (ii) $j > 0$. \textbf{(i)} We want to show that there exists a world $w^{j} \in W^{\mathsf{Ldm}}$ such that $w^{j} \in \bigcap_{1 \leq i \leq n} \mathcal{R}^{\mathsf{Ldm}}_{i}(u^{j}_{i})$. Let $\hat{w}^{j} = \bigcup_{1 \leq i \leq n} \{\phi | [i] \phi \in u^{j}_{i} \}$. Suppose that $\hat{w}^{j}$ is inconsistent to derive a contradiction. Then, there are $\psi_{1}$,...,$\psi_{k}$ such that $\vdash_{\mathsf{Ldm}} \bigwedge_{1 \leq l \leq k} \psi_{i} \rightarrow \bot$. For each $i \in Ag$, we define $\Phi_{i} = \{\psi_{l}|[i] \psi_{l} \in u^{j}_{i}\} \subseteq \{\psi_{1},...,\psi_{k}\}$. Observe that for each $i \in Ag$, $[i] \bigwedge \Phi_{i} \in u^{j}_{i}$ because $\bigwedge [i] \Phi_{i} \in u^{j}_{i}$ and $\vdash_{\mathsf{Ldm}} \bigwedge [i] \Phi_{i} \rightarrow [i] \bigwedge \Phi_{i}$. Since by assumption $\mathcal{R}^{\mathsf{Ldm}}_{\Box}u^{j}_{i}u^{j}_{k}$ for all $i,k \in \{1,...,n\}$, this means that for any $u^{j}_{m}$ we pick (with $1 \leq m \leq n$), $\Diamond [i] \bigwedge \Phi_{i} \in u^{j}_{m}$ for each $i \in Ag$ by lemma \ref{Relations_Diamonds}; hence, $\bigwedge_{i \in Ag} \Diamond [i] \bigwedge \Phi_{i} \in u^{j}_{m}$. By the $(\mathsf{IOA})$ axiom, this implies that $\Diamond \bigwedge_{i \in Ag} [i] (\bigwedge \Phi_{i}) \in u^{j}_{m}$. By lemma \ref{Existence_Lemma}, there must exist a world $v^{j}$ such that $\mathcal{R}^{\mathsf{Ldm}}_{\Box}u^{j}_{m}v^{j}$ and $\bigwedge_{i \in Ag} [i] (\bigwedge \Phi_{i}) \in v^{j}$. But then, since $\vdash_{\mathsf{Ldm}} [i] (\bigwedge \Phi_{i}) \rightarrow \bigwedge \Phi_{i}$ by reflexivity, $\vdash_{\mathsf{Ldm}} \bigwedge_{i \in Ag} (\bigwedge \Phi_{i}) \leftrightarrow \bigwedge_{1 \leq i \leq k} \psi_{i}$, and $\vdash_{\mathsf{Ldm}} \bigwedge_{1 \leq i \leq k} \psi_{i} \rightarrow \bot$, it follows that $\bot \in v^{j}$, which is a contradiction since $v^{j}$ is a $\mathsf{Ldm}$-MCS. Therefore, $\hat{w}^{j}$ must be consistent and by lemma \ref{Lindenbaum}, it may be extended to a $\mathsf{Ldm}$-MCS $w^{j}$. Since for each $[i] \phi \in u^{j}_{i}$, $\phi \in w^{j}$, we have that $w \in \mathcal{R}^{\mathsf{pres}}_{i}(u_{i})$ for each $i \in Ag$. Hence, $w \in \bigcap_{1 \leq i \leq n} \mathcal{R}^{\mathsf{pres}}_{i}(u_{i})$, and so, $w^{j} \in \bigcap_{1 \leq i \leq n} \mathcal{R}^{\mathsf{Ldm}}_{i}(u^{j}_{i})$. \textbf{(ii)} Suppose that $j > 0$, so that $t^{j} \in \mathcal{R}^{\mathsf{Ldm}}_{\Box}(s^{j})$ iff $t \in \mathcal{R}^{\mathsf{fut}}_{\Box}(s)$ = $\bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(s)$. By assumption then, $u^{j}_{m} \in \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(u^{j}_{k}) = \mathcal{R}^{\mathsf{fut}}_{i}(u^{j}_{k})$ for all $k,m \in \{1,...,n\}$ and each $i \in Ag$. Hence, $u^{j}_{m} \in \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{fut}}_{i}(u^{j}_{k})$ for all $k,m \in \{1,...,n\}$. If we therefore pick any $u^{j}_{k}$, it follows that $u^{j}_{k} \in \bigcap_{i \in Ag}\mathcal{R}^{\mathsf{fut}}_{i} (u^{j}_{i})$, meaning that the intersection $\bigcap_{1 \leq i \leq n} \mathcal{R}^{\mathsf{Ldm}}_{i}(u^{j}_{i})$ is non-empty. \item[{\rm \textbf{(C3)}}] Follows by definition. \item $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$ is a transitive and serial by definition, and $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{H}}$ is the converse of $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$ by definition as well. \item[{\rm \textbf{(C4)}}] For all $u^{j}, u^{k}, u^{l} \in W^{\mathsf{Ldm}}$, suppose that $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}u^{j}u^{k}$ and $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}u^{j}u^{l}$. Then, $j < k$ and $j < l$, and since $\mathbb{N}$ is linearly ordered, we have that $k < l$, $k = l$, or $k> l$, implying that $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}u^{k}u^{l}$, $u^{k} = u^{l}$, or $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}u^{l}u^{k}$. \item[{\rm \textbf{(C5)}}] Similar to previous case. \item[{\rm \textbf{(C6)}}] Suppose that $(u^{j},v^{j+k}) \in \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}} \circ \mathcal{R}^{\mathsf{Ldm}}_{\Box}$ with $k \geq 1$. By definition of $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$, $u^{j+k}$ is the only element in $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}(u^{j})$ associated with $j+k$, and so, $(u^{j+k},v^{j+k}) \in \mathcal{R}^{\mathsf{Ldm}}_{\Box}$ (By lemma \ref{Relate_only_same_level} no other $u^{j+k'}$ with $k' \neq k$ can relate to $v^{j+k}$ in $\mathcal{R}^{\mathsf{Ldm}}_{\Box}$.). Since $k \geq 1$, $v^{j+k} \in \mathcal{R}^{\mathsf{Ldm}}_{\Box}(u^{j+k})$ iff $v \in \mathcal{R}^{\mathsf{fut}}_{\Box}(u) = \bigcap_{i \in Ag} \mathcal{R}^{\mathsf{pres}}_{i}(u)$ iff $v^{0} \in \mathcal{R}^{\mathsf{Ldm}}_{Ag}(u^{0})$. By lemma \ref{AG_Rel_Same_All_Levels}, $(u^{j},v^{j}) \in \mathcal{R}^{\mathsf{Ldm}}_{Ag}$. This implies that, and since $(v^{j},v^{j+k}) \in \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$ by definition, we have that $(u^{j},v^{j+k}) \in \mathcal{R}^{\mathsf{Ldm}}_{Ag} \circ \mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$. \item[{\rm \textbf{(C7)}}] Follows from the definition of the $\mathcal{R}^{\mathsf{Ldm}}_{\mathsf{G}}$ relation. \item Last, it is easy to see that the valuation function $V^{\mathsf{Ldm}}$ is indeed a valuation function. \end{itemize} \end{proof} \begin{lemma}[Truth-Lemma]\label{Truth_Lemma} For any formula $\phi$, $M^{\mathsf{Ldm}}, w^{0} \models \phi$ iff $\phi \in w^{0}$. \end{lemma} \begin{proof} Shown by induction on the complexity of $\phi$ (See \cite{BlaRijVen01}). \end{proof} \iffalse \section{Completeness of $\mathsf{G3Tstit}$}\label{G3TSTIT_Completeness} \textbf{\emph{Proof of lemma \ref{Provable_or_Counter}.}} We construct the \textit{Reduction Tree} (\textbf{RT}) of a given sequent $\Gamma$, following the method of \cite{Neg09}. If \textbf{RT} is finite, all leaves are initial sequents that are conclusions of $(\mathsf{id})$ or $(\mathsf{comp}_{\mathsf{G} 1})$. If \textbf{RT} is infinite, by K\"onig's lemma, there exists an infinite branch: $\Gamma_{0}$, $\Gamma_{1}$, ..., $\Gamma_{n}$,... (with $\Gamma_{0} {=}\Gamma$). Let $\mathbf{\Gamma}$ = $\bigcup \Gamma_{i}$. We define a $\mathsf{Tstit}$-model $M^{\ast} {=} (W, \mathcal{R}_{\Box}, \{R_{i} | i \in Ag\}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}, V)$ as follows: Let $x \thicksim_{\mathbf{\Gamma}} y$ iff $x {=} y \in \mathbf{\Gamma}$. (Usage of the rules ($\mathsf{ref}_{=}$) and ($\mathsf{eucl}_{=}$) in the infinite branch ensure $\thicksim_{\mathbf{\Gamma}}$ is an equivalence relation.) Define $W$ to consist of all equivalence classes $[x]$ of labels in $\mathbf{\Gamma}$ under $\thicksim_{\mathbf{\Gamma}}$. For each $\mathcal{R}_{\alpha} xy \in \mathbf{\Gamma}$ let $([x]_{\thicksim_{\mathbf{\Gamma}}},[y]_{\thicksim_{\mathbf{\Gamma}}})\in \mathcal{R}_{\alpha}$ (with $\mathcal{R}_{\alpha} {\in} \{\mathcal{R}_{\Box}, \mathcal{R}_{i}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \breve{\mathcal{R}}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}\}$), and for each labelled propositional atom $x : p \in \mathbf{\Gamma}$, let $[x]_{\thicksim_{\mathbf{\Gamma}}} \not\in V(p)$. It is a routine task to show that all relations and the valuation are well-defined. Last, let the interpretation $I {:} L {\mapsto} W$ map each label $x$ to the class of labels $[x]_{\thicksim_{\mathbf{\Gamma}}}$ containing $x$, and suppose $I$ maps all other labels arbitrarily. We show that: \textbf{(i)} $M^{\ast}$ is a $\mathsf{Tstit}$ model, and \textbf{(ii)} $M^{\ast}$ is a counter-model for $\Gamma$. \ \ \textbf{(i)} First, we may assume w.l.g. that $\Gamma {\neq} \emptyset$ since the empty sequent is not satisfied on any model. Therefore, there must exist at least one label in $\Gamma$, and hence $W {\neq} \emptyset$. \ \ We argue that $\mathcal{R}_{\Box}$ is an equivalence relation and omit the analogues proofs showing that $\mathcal{R}_{i}$ and $\mathcal{R}_{Ag}$ are equivalence relations. Suppose, for some $\Gamma_{n}$ in the infinite branch there occurs a label $x$ but $\mathcal{R}_{\Box}xx \not\in \Gamma_{n}$. By definition of \textbf{RT}, at some later stage $\Gamma_{n+k}$ the rule $(\mathsf{refl}_{\Box})$ will be applied; hence, $\mathcal{R}_{\Box}xx \in \mathbf{\Gamma}$. The argument is similar for the $(\mathsf{eucl}_{\Box})$ rule. Properties {\rm \textbf{(C1)}} and {\rm \textbf{(C2)}} follow from the rules $(\mathsf{br}_{[i]})$ and $(\mathsf{IOA})$, respectively. Regarding {\rm \textbf{(C3)}}, we only obtain $\mathcal{R}_{Ag} \subseteq \bigcap_{i \in Ag} \mathcal{R}_{i}$ in $M^{\ast}$ via the $(\mathsf{agd})$ rule. Using lemma 9 of \cite{Lor13}, we can transform $M^{\ast}$ into a model where (i) $\mathcal{R}_{Ag} {=} \bigcap_{i \in Ag} \mathcal{R}_{i}$ and where (ii) the model satisfies the same formulae. \ \ We obtain that $\mathcal{R}_{\mathsf{G}}$ is transitive and serial due to the $(\mathsf{trans}_{\mathsf{G}})$ and $(\mathsf{ser}_{\mathsf{G}})$ rules. $\mathcal{R}_{\mathsf{H}}$ is the converse of $\mathcal{R}_{\mathsf{G}}$ by the rules $(\mathsf{conv}_{\mathsf{G}})$ and $(\mathsf{conv}_{\mathsf{H}})$. The properties {\rm \textbf{(C4)}}, {\rm \textbf{(C5)}} and {\rm \textbf{(C6)}} follow from the rules $(\mathsf{conn}_{\mathsf{G}})$, $(\mathsf{conn}_{\mathsf{H}})$ and $(\mathsf{ncuh})$, respectively. \ \ {\rm \textbf{(C7)}} follows from $(\mathsf{irr}_{\mathsf{G}})$, $(\mathsf{comp}_{\mathsf{G} 1})$, and the equality rules: these rules ensure that ($\ast$) if $[u]_{\thicksim_{\mathbf{\Gamma}}} \in \mathcal{R}_{\Box}([w]_{\thicksim_{\mathbf{\Gamma}}})$, then $[u]_{\thicksim_{\mathbf{\Gamma}}} \not\in \mathcal{R}_{\mathsf{G}}([w]_{\thicksim_{\mathbf{\Gamma}}})$. In what follows, we abuse notation and use $[w]$ to denote equivocally the label $w$, as well as any other label $v$ for which a chain of equalities between $w$ and $v$ occurs in the sequent. The claim ($\ast$) is obtained accordingly: if both $\mathcal{R}_{\Box}[w][u]$ and $\mathcal{R}_{\mathsf{G}}[w][u]$ appear together in some sequent $\Gamma_{i}$, then higher up in the infinite branch, the equality rules will introduce relational atoms of the form $\mathcal{R}_{\Box}w'u'$ and $\mathcal{R}_{\mathsf{G}}w'u'$. Eventually, the $(\mathsf{irr}_{\mathsf{G}})$ rule will be applied as well and the rule $(\mathsf{comp}_{\mathsf{G} 1})$ will ensure that the reduction tree procedure halts for the given branch. Moreover, if $\mathcal{R}_{\mathsf{G}}[w][w]$ occurs in a sequent $\Gamma_{i}$ of \textbf{RT}, then higher up in the branch the equality rules will introduce a relational atom of the form $\mathcal{R}_{\mathsf{G}}w'w'$. Eventually, $(\mathsf{refl}_{\Box})$ will be applied which adds $\mathcal{R}_{\Box}w'w'$ to the branch containing $\Gamma_{i}$. Lastly, $(\mathsf{irr}_{\mathsf{G}})$ will be applied even higher up this branch, adding $\breve{\mathcal{R}}_{\mathsf{G}}w'w'$, which by $(\mathsf{comp}_{\mathsf{G} 1})$ will halt the \textbf{RT}-procedure for that branch. Thus we may conclude: for any infinite branch of \textbf{RT} $\mathcal{R}_{\mathsf{G}}ww$ will not occur for any label $w$; meaning that not only will $M^{\ast}$ satisfy {\rm \textbf{(C7)}}, its relation $\mathcal{R}_{\mathsf{G}}$ will be irreflexive. Additionally, note that $(\mathsf{comp}_{\mathsf{G} 2})$ will ensure that $\breve{\mathcal{R}}_{\mathsf{G}}$ is the complement of $\mathcal{R}_{\mathsf{G}}$. \ \ Lastly, as long as $[x]_{\thicksim_{\mathbf{\Gamma}}} \not\in V(p)$ when $x : p \in \mathbf{\Gamma}$, all other labels can be mapped by $V$ in any arbitrary manner. Thus, $V$ is a valid valuation function. \ \ \textbf{(ii)} By construction, $M^{\ast}$ satisfies each relational atom in $\mathbf{\Gamma}$, and therefore, satisfies each relational atom in $\Gamma$. By induction on the complexity of $\phi$ it is shown that for any formula $x : \phi \in \mathbf{\Gamma}$ we have $M^{\ast}, [x]_{\thicksim_{\mathbf{\Gamma}}} \not\models \phi$ (See \cite{Neg09} for details). Hence, $\Gamma$ is falsified on $M^{\ast}$ with $I$. \fi \section{$\mathsf{G3Xstit}$ Derivation of IOA$^x$ Axiom}\label{XSTIT_IOA} We make use of the system of rules $(\mathsf{IOA_X})$, to derive the $\mathsf{Xstit}$ IOA axiom in $\mathsf{G3Xstit}$. \\ \begin{small} \begin{tabular}{@{\hskip -4em} c} \AxiomC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, R_{A}w_{2}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{5}: \phi, w_{5}: \overline{\phi}$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, R_{A}w_{2}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{5}: \phi$} \RightLabel{($\mathsf{IOA-U_{1}})$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ... \ \ $ w_{5}: \phi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{4}: [A]^x\phi$} \UnaryInfC{$D_1$} \DisplayProof \end{tabular} \ \\ \begin{tabular}{@{\hskip -4em} c} \AxiomC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, R_{B}w_{3}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ....\ \ $ w_{6}: \psi, w_{6} : \overline{\psi}$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, R_{B}w_{3}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{6}: \psi$} \RightLabel{($\mathsf{IOA-U_{2}})$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{6}: \psi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{4}: [B]^x\psi$} \UnaryInfC{$D_2$} \DisplayProof \end{tabular} \ \\ \begin{tabular}{@{\hskip -4em} c} \AxiomC{$D_1\quad\quad\quad$ \AxiomC{$\quad\quad\quad D_2$ \BinaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi), w_{4}: [A]^x\phi\land [B]^x\psi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \RightLabel{($\mathsf{IOA-E}$)} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \UnaryInfC{$w_{1}: \Box \langle A \rangle^x \overline{\phi}, w_{1}:\Box \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \UnaryInfC{$w_{1}: \Box \langle A \rangle^x \overline{\phi} \lor \Box \langle B \rangle^x \overline{\psi} \lor \Diamond ([A]^x\phi\land [B]^x\psi)$} \DisplayProof \end{tabular} \end{small} \section{Introduction} \input{finalintro2.tex} \section{The Logic $\mathsf{Ldm}$}\label{LDM_Section} \input{Section-1.tex} \section{The Logic $\mathsf{Tstit}$}\label{TSTIT_Section} \input{Section-2.tex} \section{The Logic $\mathsf{Xstit}$}\label{XSTIT_Section} \input{Section-3.tex} \section{Conclusion and Future Work}\label{Conclusion} \input{Conclusion.tex} \bibliographystyle{splncs04} \subsection{Axioms and Relational Semantics for $\mathsf{Ldm}$} The basic STIT logic $\mathsf{Ldm}$ offers a framework for reasoning about individual agents realizing propositions via the choices available to them at particular moments in time. In the semantics of $\mathsf{Ldm}$, each \textit{moment} can be formalized as an equivalence class of \textit{worlds}, where each world sits in a linear chain (referred to as a \emph{history}) extending to the future and (possibly to) the past. Therefore, each world contained in a particular moment can be thought of as an alternative state of affairs that evolves along a different timeline. Moreover, for each agent, moments are further partitioned into equivalence classes, where each class represents a possible choice available to the agent for realizing a set of potential outcome . Hence, if a proposition $\phi$ holds true in every world of a particular choice for an agent $i$, then we claim that ``$i$ sees to it that $\phi$" (written formally as $[i]\phi$) at each world of that choice; \textit{i.e.} $i$'s committal to the choice ensures $\phi$ regardless of which world in the choice set is actual. The above STIT operator $[i]$ is referred to as the \emph{Chellas}-STIT (i.e. \emph{cstit}) \cite{BelPerXu01}. It is often distinguished from the \emph{deliberative} STIT (i.e. \emph{dstit}) which consists of \textit{cstit} together with a negative condition: we say that ``agent $i$ deliberatively sees to it that $\phi$'' (written formally as $[i]^{d}$) when (i) ``$i$ sees to it that $\phi$'' and (ii) ``$\phi$ is currently not settled true'' \cite{BelHor95,Hor01}. The second condition ensures that the realization of $\phi$ \textit{depends} on the choice made by the agent; \textit{i.e.} $\phi$ might not have been case had the agent chosen to act differently. By making use of the \emph{settledness} operator $\Box$, which is prefixed to a formula when the formula holds true at every world in a moment, \textit{cstit} and \textit{dstit} become inter-definable: namely, $[i]^{d}\phi$ \textit{iff} $[i] \phi \wedge \neg \Box \phi$. As an example of a STIT formula, the formula $\Diamond [i]^d\phi$ must be interpreted as follows: at the current moment, agent $i$ has a possible choice available that allows $i$ to see to it that $\phi$ is guaranteed, and there is an alternative choice present to $i$ that does not guarantee $\phi$. In this paper, we introduce $\Box$ and $[i]$ as primitive and take $[i]^d$ as defined. In this section, we make all of the aforementioned notions formally precise and provide a relational semantics for $\mathsf{Ldm}$ along with a corresponding cut-free labelled calculus. In section \ref{TSTIT_Section}, we will extend $\mathsf{Ldm}$ with temporal operators, obtaining the logic $\mathsf{Tstit}$. Since both logics rely on the same semantics, we introduce their languages and semantics simultaneously, avoiding unnecessary repetition. Lastly, in what follows we give all formulae of the associated logics in negation normal form. This reduces the number of rules in the associated calculi and offers a simpler presentation of the proof theory. The languages for $\mathsf{Ldm}$ and $\mathsf{Tstit}$ are given below: \begin{definition}[The Languages $\mathcal{L}_{\mathsf{Ldm}}$ and $\mathcal{L}_{\mathsf{Tstit}}$]\label{ldmtlanguage} Let $Ag = \{1,2,...,n\}$ be a finite set of agent labels and let $Var =\{p_1,p_2,p_3...\}$ be a countable set of propositional variables. The language $\mathcal{L}_{\mathsf{Ldm}}$ is given by the following BNF grammar: {\small $$\phi ::= p \ | \ \overline{p} \ | \ \phi \wedge \phi \ | \ \phi\vee \phi \ | \ \Box \phi \ | \ \Diamond \phi \ | \ [i] \phi \ | \ \langle i \rangle \phi$$} The language $\mathcal{L}_{\mathsf{Tstit}}$ is defined accordingly: {\small $$\phi ::= p \ | \ \overline{p} \ | \ \phi \wedge \phi \ | \ \phi\vee \phi \ | \ \Box \phi \ | \ \Diamond \phi \ | \ [i] \phi \ | \ \langle i \rangle \phi \ | \ [Ag] \phi \ | \ \langle Ag \rangle \phi \ | \ \mathsf{G} \phi \ | \ \mathsf{F} \phi \ | \ \mathsf{H} \phi \ | \ \mathsf{P} \phi$$} where $i\in Ag$ and $p \in Var$. \end{definition} \noindent The language $\mathcal{L}_{\mathsf{Tstit}}$ extends $\mathcal{L}_{\mathsf{Ldm}}$ through the incorporation of the tense modalities $\mathsf{G}$, $\mathsf{F}$, $\mathsf{H}$, and $\mathsf{P}$ and the modalities $[Ag]$ and $\langle Ag \rangle$ for the grand coalition $Ag$ of agents. $\mathsf{G}$ and $\mathsf{F}$ are duals and read, respectively, as `always will be in the future' and `somewhere in the future'. $\mathsf{H}$ are $\mathsf{P}$ are also dual and are interpreted, respectively, as `always has been in the past' and `somewhere in the past' (cf. \cite{Lor13,Pri67}). The operator $[Ag]$ captures the notion that `the grand coalition of agents sees to it that'. Note that the negation of a formula $\phi$, written $\overline{\phi}$, is obtained in the usual way by replacing each operator with its dual, each positive propositional atom $p$ with its negation $\overline{p}$, and each negative propositional atom $\overline{p}$ with its positive version $p$. We may therefore define $\phi \rightarrow \psi$ as $\overline{\phi} \vee \psi$, $\phi \leftrightarrow \psi$ as $\phi \rightarrow \psi \wedge \psi \rightarrow \phi$, $\top$ as $p \vee \overline{p}$, and $\bot$ as $p \wedge \overline{p}$. We will use these abbreviations throughout the paper. At present, we are principally interested in $\mathsf{Ldm}$ and temporal frames: in particular, since $\mathsf{Tstit}$ will be introduced as the temporal extension of $\mathsf{Ldm}$ and, more generally, because the logic of STIT has an implicit temporal intuition underlying choice-making (\textit{cf.} original branching-time frames employed for $\mathsf{Ldm}$ \cite{BelPerXu01,BelHor95,Hor01}). We will prove that $\mathsf{Ldm}$ is strongly complete with respect to these more elaborate \textit{irreflexive} Temporal Kripke STIT frames. \begin{definition}[Relational $\mathsf{Tstit}$ Frames and Models \cite{Lor13}]\label{models_tkstit} Let $\mathcal{R}_{\alpha}(w) := \{v\in W | (w,v)\in R_{\alpha}\}$ for $\alpha \in \{\Box, Ag, \mathsf{G}, \mathsf{H} \} \cup Ag$. A relational \emph{Temporal STIT frame ($\mathsf{Tstit}$-frame)} is defined as a tuple $F = (W, \mathcal{R}_{\Box}, \{\mathcal{R}_{i} | i \in Ag\}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}})$ where $W$ is a non-empty set of worlds $w,v,u...$ and: \begin{itemize} \item For all $i\in Ag$, $\mathcal{R}_{\Box}$, $\mathcal{R}_{i}$, $\mathcal{R}_{Ag} \subseteq W\times W$ are equivalence relations where: \item[{\rm \textbf{(C1)}}] For each $i$, $\mathcal{R}_{i} \subseteq \mathcal{R}_{\Box}$; \item[{\rm \textbf{(C2)}}] For all $u_{1},...,u_{n} \in W$, if $\mathcal{R}_{\Box}u_{i}u_{j}$ for all $1 \leq i,j \leq n$, then $\bigcap_{i} \mathcal{R}_{i}(u_{i}) \neq \emptyset$; \item[{\rm \textbf{(C3)}}] For all $w \in W$, $\mathcal{R}_{Ag}(w) = \bigcap_{i \in Ag} \mathcal{R}_{i}(w)$; \item $\mathcal{R}_{\mathsf{G}}\subseteq W\times W$ is a transitive and serial binary relation and $\mathcal{R}_{\mathsf{H}}$ is the converse of $\mathcal{R}_{\mathsf{G}}$, and the following conditions hold: \item[{\rm \textbf{(C4)}}] For all $w, u, v \in W$, if $\mathcal{R}_{\mathsf{G}}wu$ and $\mathcal{R}_{\mathsf{G}}wv$, then $\mathcal{R}_{\mathsf{G}}uv$, $u = v$, or $\mathcal{R}_{\mathsf{G}}vu$; \item[{\rm \textbf{(C5)}}] For all $w, u, v \in W$, if $\mathcal{R}_{\mathsf{H}}wu$ and $\mathcal{R}_{\mathsf{H}}wv$, then $\mathcal{R}_{\mathsf{H}}uv$, $u = v$, or $\mathcal{R}_{\mathsf{H}}vu$; \item[{\rm \textbf{(C6)}}] $\mathcal{R}_{\mathsf{G}} \circ \mathcal{R}_{\Box} \subseteq \mathcal{R}_{Ag} \circ \mathcal{R}_{\mathsf{G}}$; (Relation composition $\circ$ is defined as usual.) \item[{\rm \textbf{(C7)}}] For all $w,u \in W$, if $u \in \mathcal{R}_{\Box}(w)$, then $u \not\in \mathcal{R}_{\mathsf{G}}(w)$; \end{itemize} A $\mathsf{Tstit}$-model is defined as a tuple $M = (F,V)$ where $F$ is a $\mathsf{Tstit}$-frame and $V$ is a valuation function assigning propositional variables to subsets of $W$; that is, $V{:}\ Var \mapsto \mathcal{P}(W)$. \end{definition} The property expressed in C2 corresponds to the familiar \textit{independence of agents} principle of STIT logic, which states that if it is currently possible for each distinct agent to make a certain choice, then it is possible for all such choices to be made simultaneously. Condition C6 captures the STIT principle of \textit{no choice between undivided histories}, which ensures that if two time-lines remain undivided at some future moment, then no agent can currently make a choice realizing one time-line without the other. (This principle is inexpressible in the atemporal language of the base logic $\mathsf{Ldm}$.) For a philosophical discussion of these principles see \cite{BelPerXu01}. Last, condition C7 ensures that the temporal frames under consideration are \textit{irreflexive}, which means that the future is a strict future (excluding the present). For a discussion of the other frame properties we refer to \cite{Lor13}. \begin{definition}[Semantics for $\mathcal{L}_{\mathsf{Ldm}}$ and $\mathcal{L}_{\mathsf{Tstit}} ]\label{Semantics_ldm_tstit} Let $M$ be a $\mathsf{Tstit}$-model and let $w$ be a world in its domain $W$. The \emph{satisfaction} of a formula $\phi$ on $M$ at $w$ is inductively defined as follows (in clauses 1-14 we omit explicit mention of $M$): \begin{small} \begin{multicols}{2} \begin{itemize} \item[1.] $ w \models p$ iff $w \in V(p)$ \item[2.] $ w \models \overline{p}$ iff $w \not\in V(p)$ \item[3.] $ w \models \phi \wedge \psi$ iff $ w \models \phi$ and $ w \models \psi$ \item[4.] $ w \models \phi \vee \psi$ iff $ w \models \phi$ or $ w \models \psi$ \item[5.] $ w \models \Box \phi$ iff $\forall u \in \mathcal{R}_{\Box}(w)$, $ u \models \phi$ \item[6.] $ w \models \Diamond \phi$ iff $\exists u \in \mathcal{R}_{\Box}(w)$, $ u \models \phi$ \item[7.] $ w \models [i] \phi$ iff $\forall u \in \mathcal{R}_{i}(w)$, $ u \models \phi$ \end{itemize} \columnbreak \begin{itemize} \item[8.] $ w \models \langle i \rangle \phi$ iff $\exists u \in \mathcal{R}_{i}(w)$, $ u \models \phi$ \item[9.] $ w \models [Ag] \phi$ iff $\forall u \in \mathcal{R}_{Ag}(w)$, $ u \models \phi$ \item[10.] $ w \models \langle Ag \rangle \phi$ iff $\exists u \in \mathcal{R}_{Ag}(w)$, $ u \models \phi$ \item[11.] $ w \models \mathsf{G} \phi$ iff $\forall u \in \mathcal{R}_{\mathsf{G}}(w)$, $ u \models \phi$ \item[12.] $ w \models \mathsf{F} \phi$ iff $\exists u \in \mathcal{R}_{\mathsf{G}}(w)$, $ u \models \phi$ \item[13.] $ w \models \mathsf{H} \phi$ iff $\forall u \in \mathcal{R}_{\mathsf{H}}(w)$, $ u \models \phi$ \item[14.] $ w \models \mathsf{P} \phi$ iff $\exists u \in \mathcal{R}_{\mathsf{H}}(w)$, $ u \models \phi$ \end{itemize} \end{multicols} \end{small} \noindent A formula $\phi$ is \emph{globally true} on $M$ (\textit{i.e.} $M {\models} \phi$) iff it is satisfied at every world $w$ in the domain $W$ of $M$. A formula $\phi$ is \emph{valid} (\textit{i.e.} ${\models} \phi$) iff it is globally true on every $\mathsf{Tstit}$-model. \end{definition} \begin{definition}[The Logic $\mathsf{Ldm}$~\cite{BelPerXu01}] The Hilbert system of $\mathsf{Ldm}$ consists of the following axioms and inference rules: \begin{small} \begin{center} \begin{tabular}{c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c} $\phi \rightarrow (\psi \rightarrow \phi)$ & $(\overline{\psi} \rightarrow \overline{\phi}) \rightarrow (\phi \rightarrow \psi)$ & $(\phi \rightarrow (\psi \rightarrow \chi)) \rightarrow ((\phi \rightarrow \psi) \rightarrow (\phi \rightarrow \chi))$ \end{tabular} \ \\ \begin{tabular}{c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c} $\Box \phi \rightarrow \phi$ & $\Diamond \phi \rightarrow \Box \Diamond \phi$ & $\Box (\phi \rightarrow \psi) \rightarrow (\Box \phi \rightarrow \Box \psi)$ & $[i]{} \phi \rightarrow \phi$ & $\langle i \rangle \phi \rightarrow [i]{} \langle i \rangle \phi$ \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c} $\Box \phi \vee \Diamond \overline{\phi}$ & $[i] \phi \vee \langle i \rangle \overline{\phi}$ & $\bigwedge_{i \in Ag} \Diamond [i] \phi_{i} \rightarrow \Diamond ( \bigwedge_{i \in Ag}[i] \phi_{i})$ \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c @{\hskip 1em} c} $[i]{} (\phi \rightarrow \psi) \rightarrow ([i]{} \phi \rightarrow [i]{} \psi)$ & $\Box \phi \rightarrow [i] \phi$ & \AxiomC{$\phi$} \UnaryInfC{$\Box \phi$} \DisplayProof & \AxiomC{$\phi$} \AxiomC{$\phi \rightarrow \psi$} \BinaryInfC{$\psi$} \DisplayProof \end{tabular} \end{center} \end{small} A derivation of $\phi$ in $\mathsf{Ldm}$ from a set of premises $\Theta$, is written as $\Theta \vdash_{\mathsf{Ldm}} \phi$. When $\Theta$ is the empty set, we refer to $\phi$ as a \emph{theorem} and write $\vdash_{\mathsf{Ldm}} \phi$. \end{definition} The axiomatization contains duality-axioms $\Box \phi \vee \Diamond \overline{\phi}$ and $[i] \phi \vee \langle i \rangle \overline{\phi}$ which ensure the usual interaction between the box and diamond modalities. Furthermore, the axiom $\bigwedge_{i \in Ag} \Diamond [i] \phi_{i} \rightarrow \Diamond ( \bigwedge_{i \in Ag}[i] \phi_{i})$ is the \textit{independence of agents} (\emph{IOA}) axiom. % \begin{theorem}[Soundness~\cite{Lor13}] For any formula $\phi$, if $ \vdash_{\mathsf{Ldm}} \phi$, then $ {\models} \phi$. \end{theorem} \noindent Observe that all axioms of $\mathsf{Ldm}$ are within the Sahlqvist class. Therefore, we know that $\mathsf{Ldm}$ is already strongly complete relative to the simpler class of frames defined by the first-order properties corresponding to its axioms \cite{BlaRijVen01} (\textit{cf.} \cite{BalHerTro08,HerSch08} for alternative completeness proofs of $\mathsf{Ldm}$ relative to this class of relational frames). As mentioned previously, we are interested in $\mathsf{Ldm}$ relative to the more involved \textit{temporal} frames. The usual canonical model construction from \cite{BlaRijVen01} cannot be applied to obtain completeness of $\mathsf{Ldm}$ in relation to $\mathsf{Tstit}$-frames. This follows from the fact that the axioms of $\mathsf{Ldm}$ do not impose any temporal structure on the canonical model of $\mathsf{Ldm}$, and hence, we are not ensured that the resulting model qualifies as a $\mathsf{Tstit}$-model. Theorem \ref{compl_ldm} is therefore proved via an alternative canonical model construction, which can be found in appendix \ref{Completeness_Proof_ldm}. \begin{theorem}[Completeness]\label{compl_ldm} Any consistent set $\Sigma \subset \mathcal{L}_{\mathsf{Ldm}}$ is satisfiable. \end{theorem} \subsection{A Cut-free Labelled Calculus for $\mathsf{Ldm}$}\label{cutfreeldm} We now provide a cut-free labelled calculus for $\mathsf{Ldm}$, which can be seen as a simplification of the tableaux calculus in \cite{Wan06}. Labelled sequents $\Gamma$ are defined through the following BNF grammar: $$\Gamma ::= x:\phi \ | \ \Gamma, \Gamma \ | \ \mathcal{R}_{\alpha}xy, \Gamma$$ where $x$ is from a countable set of labels $L = \{ x, y, z, ... \}$, $\alpha \in \{\Box\} \cup Ag$, and $\phi \in \mathcal{L}_{\mathsf{Ldm}}$. Note that commas are used equivocally in the interpretation of a labelled sequent: representing (i) a conjunction when occurring between relational atoms, (ii) a disjunction when occurring between labelled formulae, and (iii) an implication when binding the multiset of relational atoms to the multiset of labelled formulae, which comprise a sequent. Last, we use the notation $\vdash_{G3\mathsf{X}} x:\phi$ (for $\mathsf{X} \in \{\mathsf{Ldm}, \mathsf{Tstit}, \mathsf{Xstit}\}$) to denote here and later that the labelled formula $x:\phi$ is derivable in the calculus $\mathsf{G3X}$. The first order correspondents of all $\mathsf{Ldm}$ axioms are \textit{geometric axioms}: that is, axioms of the form $\forall x_{1} ... x_{n} ((\phi_{1} \wedge ... \wedge \phi_{m}) \rightarrow \exists y_{1}...y_{k} (\psi_{1} \vee ... \vee \psi_{l}))$ where each $\phi_{i}$ is atomic and does not contain free occurrences of $y_{j}$ (for $1 \leq j \leq k$), and each $\psi_{i}$ is a conjunction $\chi_{1} \wedge ... \wedge \chi_{r}$ of atomic formulae. The calculus $\mathsf{G3Ldm}$ is obtained by transforming all such correspondents into rules; \textit{i.e.} \textit{geometric rules}. (For further discussion on extracting rules from axioms, we refer to \cite{Neg05,Neg16}.) Last, since our formulae are in negation normal form, we provide a one-sided version of the calculi introduced in \cite{Neg05}. This allows for a simpler formalism with fewer rules, but which is equivalent in expressivity. \begin{definition}[The Calculus $\mathsf{G3Ldm}$]\label{sequentldml} \begin{small} \begin{center} \begin{tabular}{c c c c} \AxiomC{ } \RightLabel{$(\mathsf{id})$} \UnaryInfC{$\Gamma, w:p, w:\overline{p} $} \DisplayProof & \AxiomC{$\Gamma, w: \phi$} \AxiomC{$\Gamma, w: \psi$} \RightLabel{$(\wedge)$} \BinaryInfC{$\Gamma, w: \phi \wedge \psi$} \DisplayProof & \AxiomC{$\Gamma, w: \phi, w : \psi$} \RightLabel{$(\vee)$} \UnaryInfC{$\Gamma, w: \phi \vee \psi$} \DisplayProof & \AxiomC{$\Gamma, \mathcal{R}_{\Box}wv, v: \phi$} \RightLabel{$(\Box)^{*}$} \UnaryInfC{$\Gamma, w: \Box \phi$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1 em} c @{\hskip 1 em} c} \AxiomC{$\Gamma, \mathcal{R}_{\Box}wu, w: \Diamond \phi, u: \phi$} \RightLabel{$(\Diamond)$} \UnaryInfC{$\Gamma, \mathcal{R}_{\Box}wu, w: \Diamond \phi$} \DisplayProof & \AxiomC{$\Gamma, \mathcal{R}_{i}wv, v: \phi$} \RightLabel{$([i]{})^{*}$} \UnaryInfC{$\Gamma, w: [i] \phi$} \DisplayProof & \AxiomC{$\Gamma, \mathcal{R}_{i}wu, w: \langle i \rangle \phi, u: \phi$} \RightLabel{$(\langle i \rangle)$} \UnaryInfC{$\Gamma, \mathcal{R}_{i}wu, w: \langle i \rangle \phi$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c} \AxiomC{$\mathcal{R}_{\Box}ww, \Gamma$} \RightLabel{$(\mathsf{refl}_{\Box})$} \UnaryInfC{$\Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{i}ww, \Gamma$} \RightLabel{$(\mathsf{refl}_{[i]{}})$} \UnaryInfC{$\Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{\Box}wu_{1}, ..., \mathcal{R}_{\Box}wu_{n}, \mathcal{R}_{1}u_{1}v, ..., \mathcal{R}_{n}u_{n}v, \Gamma$} \RightLabel{$(\mathsf{IOA})^{*}$} \UnaryInfC{$\mathcal{R}_{\Box}wu_{1}, ..., \mathcal{R}_{\Box}wu_{n},\Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c} \AxiomC{$\mathcal{R}_{\Box}wu, \mathcal{R}_{\Box}wv, \mathcal{R}_{\Box}uv, \Gamma$} \RightLabel{$(\mathsf{eucl}_{\Box})$} \UnaryInfC{$\mathcal{R}_{\Box}wu, \mathcal{R}_{\Box}wv, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{\Box}wu, \mathcal{R}_{i}wu, \Gamma$} \RightLabel{$(\mathsf{br}_{[i]})$} \UnaryInfC{$\mathcal{R}_{i}wu, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{i}wu, \mathcal{R}_{i}wv, \mathcal{R}_{i}uv, \Gamma$} \RightLabel{$(\mathsf{eucl}_{[i]{}})$} \UnaryInfC{$\mathcal{R}_{i}wu, \mathcal{R}_{i}wv, \Gamma$} \DisplayProof \end{tabular} \end{center} The `$\ast$' on the labels $(\Box)$, $([i]{})$, and $(\mathsf{IOA})$ indicates an eigenvariable condition for this rule: \textit{i.e.} the label $v$ occurring in the premise of the rule cannot occur in the conclusion. \end{small} \end{definition} \noindent The rule $(\mathsf{id})$ is an initial sequent and the rules $(\wedge)$, $(\vee)$, $(\Box)$, $(\Diamond)$, $([i]{})$ and $(\langle i \rangle)$ allow us to decompose connectives. Furthermore, as indicated by the relational atoms, the rules $(\mathsf{refl}_{\Box}), (\mathsf{refl}_{[i]{}}), (\mathsf{eucl}_{\Box}),(\mathsf{eucl}_{[i]{}}),(\mathsf{br}_{[i]})$ capture the behavior of the corresponding modal operators, and the rule $(\mathsf{IOA})$ secures independence of agents in $\mathsf{G3Ldm}$. In order to establish the intended soundness and completeness results, we need to formally interpret a labelled sequent relative to a given model. For the sake of brevity, we provide the semantics uniformly for all labelled sequent languages appearing in this paper: \begin{definition}[Interpretation, Satisfiability, Validity] Let $\mathsf{X}\in \{\mathsf{Ldm},\mathsf{Tstit},$ $\mathsf{Xstit}\}$. Let $M$ be a model for $\mathsf{X}$ with domain $W$, $L$ the set of labels used in the labelled sequent language of $\mathsf{G3X}$, $\Gamma$ a sequent in $\mathsf{G3X}$ and let $\mathcal{R}_{\alpha}$ be a relation of $M$. (We have $\mathcal{R}_{\alpha} \in \{\mathcal{R}_{\Box}, \mathcal{R}_{i}\}$ for $\mathsf{X} = \mathsf{Ldm}$, $\mathcal{R}_{\alpha} \in \{\mathcal{R}_{\Box}, \mathcal{R}_{i}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \breve{\mathcal{R}}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}\}$ for $\mathsf{X} = \mathsf{Tstit}$, and $\mathcal{R}_{\alpha} \in \{\mathcal{R}_{\Box}, \mathcal{R}_{X}, \mathcal{R}_{A}\}$, for all $A \subseteq Ag$, when $\mathsf{X} = \mathsf{Xstit}$. We take $\breve{\mathcal{R}}_{\mathsf{G}}$ as the complement of the relation $\mathcal{R}_{\mathsf{G}}$ ) Last, let $I$ be an \emph{interpretation function} of $L$ on $M$ that maps labels to worlds; \textit{i.e.} $I{:} \ L \mapsto W$. We say that, \begin{itemize} \item[] a sequent $\Gamma$ is \emph{satisfied} in $M$ with $I$ iff for all relational atoms $\mathcal{R}_{\alpha} xy$ and equalities $x {=} y$ in $\Gamma$, if $\mathcal{R}_{\alpha} x^{I}y^{I}$ holds in $M$, then there must exist some $z : \phi$ in $\Gamma$ such that $M, z^{I} {\models} \phi$. \end{itemize} A sequent $\Gamma$ is \emph{valid} iff it is satisfiable in any model $M$ with any $I$ of $L$ on $M$. \end{definition} \begin{theorem}[Soundness]\label{Soundness_G3LDM} Every sequent derivable in $\mathsf{G3Ldm}$ is valid. \end{theorem} \begin{proof} By induction on the height of the given $\mathsf{G3Ldm}$ derivation. For initial sequents of the form $\Gamma, w{:}p, w {:} \overline{p}$ the claim is clear. The inductive step is argued by showing that each inference rule preserves validity (cf. theorem 5.3 in \cite{Neg09}). \end{proof} \begin{lemma}\label{sequent_ldm} For all $\phi\in \mathcal{L}_{\mathsf{Ldm}}$, if $\vdash_{\mathsf{Ldm}} \phi$, then $\vdash_{\mathsf{G3Ldm}} x : \phi$. \end{lemma} \begin{proof} The derivation of each axiom and inference rule of $\mathsf{Ldm}$, except for the IOA-axiom, is straightforward (See \cite{Neg05,Negvon01}). For readability, we only present the derivation of the IOA-axiom for two agents; the general case is similar:\\ \begin{small} \begin{tabular}{@{\hskip -4em} c} \AxiomC{$\mathcal{R}_{1}vu,\mathcal{R}_{1}yv, \mathcal{R}_{1}yu, ..., y : \langle 1 \rangle \overline{\phi}_{1}, u : \overline{\phi}_{1}, u : \phi_{1}$} \UnaryInfC{$\mathcal{R}_{1}vu,\mathcal{R}_{1}yv, \mathcal{R}_{i}yu, ..., y : \langle 1 \rangle \overline{\phi}_{1}, u : \phi_{1}$} \dashedLine \UnaryInfC{$\mathcal{R}_{1}vu,\mathcal{R}_{1}yv, ..., y : \langle 1 \rangle \overline{\phi}_{1}, u : \phi_{1}$} \UnaryInfC{$\mathcal{R}_{1}yv, ..., y : \langle 1 \rangle \overline{\phi}_{1}, v: [1] \phi_{1}$} \AxiomC{$\mathcal{R}_{2}vu,\mathcal{R}_{2}zv, \mathcal{R}_{i}zw, ..., z : \langle 2 \rangle \overline{\phi}_{2}, w : \overline{\phi}_{2}, w : \phi_{2}$} \UnaryInfC{$\mathcal{R}_{2}vw,\mathcal{R}_{2}zv, \mathcal{R}_{2}zw, ..., z : \langle 2 \rangle \overline{\phi}_{2}, w : \phi_{2}$} \dashedLine \UnaryInfC{$\mathcal{R}_{2}vw,\mathcal{R}_{2}zv, ..., z : \langle 2 \rangle \overline{\phi}_{2}, w : \phi_{2}$} \UnaryInfC{$\mathcal{R}_{2}zv, ..., z : \langle 2 \rangle \overline{\phi}_{2}, v: [2] \phi_{2}$} \BinaryInfC{$\mathcal{R}_{1}yv, \mathcal{R}_{2}zv,\mathcal{R}_{\Box}xy, \mathcal{R}_{\Box}yv, \mathcal{R}_{\Box}xv, \mathcal{R}_{\Box}xz, y : \langle 1 \rangle \overline{\phi}_{1}, z: \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2}), v: [1] \phi_{1} \wedge [2] \phi_{2}$} \UnaryInfC{$\mathcal{R}_{1}yv, \mathcal{R}_{2}zv,\mathcal{R}_{\Box}xy, \mathcal{R}_{\Box}yv, \mathcal{R}_{\Box}xv, \mathcal{R}_{\Box}xz, y : \langle 1 \rangle \overline{\phi}_{1}, z: \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \dashedLine \UnaryInfC{$\mathcal{R}_{1}yv, \mathcal{R}_{2}zv,\mathcal{R}_{\Box}xy, \mathcal{R}_{\Box}yv, \mathcal{R}_{\Box}xz, y : \langle 1 \rangle \overline{\phi}_{1}, z: \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \UnaryInfC{$\mathcal{R}_{1}yv, \mathcal{R}_{2}zv,\mathcal{R}_{\Box}xy, \mathcal{R}_{\Box}xz, y : \langle 1 \rangle \overline{\phi}_{1}, z: \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \UnaryInfC{$\mathcal{R}_{\Box}xy, \mathcal{R}_{\Box}xz, y : \langle 1 \rangle \overline{\phi}_{1}, z: \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \UnaryInfC{$x : \Box \langle 1 \rangle \overline{\phi}_{1}, x: \Box \langle 2 \rangle \overline{\phi}_{2}, x: \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \UnaryInfC{$x : \Box \langle 1 \rangle \overline{\phi}_{1} \vee \Box \langle 2 \rangle \overline{\phi}_{2} \vee \Diamond ([1] \phi_{1} \wedge [2] \phi_{2})$} \DisplayProof \end{tabular} \end{small} \vspace{0.3cm} \noindent The dashed lines in the above proof indicate the use of transitivity rules, which are derivable from the $(\mathsf{refl}_{[i]{}})$, $(\mathsf{eucl}_{[i]{}})$, $(\mathsf{refl}_{\Box})$, and $(\mathsf{eucl}_{\Box})$ rules (see \cite{Neg05}). \end{proof} \begin{theorem}[Completeness]\label{Compeleteness_G3ldm} For all $\phi \in \mathcal{L}_{\mathsf{Ldm}}$, if $\models \phi$, then $\vdash_{\mathsf{G3Ldm}} x: \phi$. \end{theorem} \begin{proof} Follows from theorem \ref{compl_ldm} and lemma \ref{sequent_ldm}. \end{proof} Due to the fact that all labelled sequent calculi given in this paper fit within the scheme presented in \cite{Neg05,Neg16}, we obtain the subsequent theorem specifying their proof-theoretic properties: \begin{theorem}\label{Properties_of_Calc} Each calculus $\mathsf{G3X}$ with $\mathsf{X} \in \{\mathsf{Ldm}, \mathsf{Tstit}, \mathsf{Xstit} \}$ has the following properties: \begin{enumerate} \item All sequents of the form $\Gamma, x : \phi, x: \overline{\phi}$ are derivable in $\mathsf{G3X}$ with $\phi$ in the language $\mathcal{L}_{\mathsf{X}}$; \item All inference rules of $\mathsf{G3X}$ are height-preserving invertible; \item Weakening, contraction, and variable-substitution are height-preserving admissible; \item Cut is admissible. \end{enumerate} \end{theorem} \begin{proof} See \cite{Neg05} and \cite{Neg16} for details. \end{proof} In order to maintain the admissibility of contraction, our calculi must satisfy the \emph{closure condition} \cite{Neg05,Neg16}. That is, the calculi $\mathsf{G3Ldm},\mathsf{G3Tstit}$ and $\mathsf{G3Xstit}$ adhere to the following condition: For any \textit{generalized geometric rule} in which a substitution of variables produces a duplication of relational atoms or equalities active in the rule, the instance of the rule with such duplicates contracted is added to the calculus. Since variable substitutions can only bring about a finite number of rule instances possessing duplications, the closure condition adds at most finitely many rules and is hence unproblematic. (Generalized geometric rules extend the class of geometric rules and can be extracted from generalized geometric axioms. In short, these are formulae of the form $GA_{n} = \forall x_{1} ... x_{n} ((\phi_{1} \wedge ... \wedge \phi_{m}) \rightarrow (\exists y_{1} \bigwedge GA_{k_{1}} \vee ... \vee \exists y_{m} \bigwedge GA_{k_{m}}))$, where each $\bigwedge GA_{k_{j}}$ (for $0 {\leq} k_{1}, \cdots\!, k_{m} {<} n$) stands for a conjunction of generalized geometric axioms, inductively constructed up to $k_j$-depth with the base case $GA_{0}$ being a geometric axiom. For a formal treatment of these axioms and rules see \cite{Neg16}.) \subsection{Axiomatization for $\mathsf{Tstit}$} The logic $\mathsf{Tstit}$ extends the logic $\mathsf{Ldm}$ through the incorporation of tense modalities and the modality for the grand coalition of agents (see definition \ref{ldmtlanguage}). This additional expressivity allows for the application of $\mathsf{Tstit}$ in settings where one wishes to reason about the joint action of all agents, or the consequences of choices over time. The logic was originally proposed in \cite{Lor13} as a Hilbert system, in this section we provide a corresponding cut-free calculus. \begin{definition}[The Logic $\mathsf{Tstit}$ \cite{Lor13}]\label{TSTIT_Def} The Hilbert system for the logic $\mathsf{Tstit}$ is defined as the logic $\mathsf{Ldm}$ \emph{extended} with the following axioms and inference rules: \begin{small} \begin{center} \begin{tabular}{c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c} $[Ag] \phi \rightarrow \phi$ & $\langle Ag \rangle \phi \rightarrow [Ag] \langle Ag \rangle \phi$ & $\bigwedge_{1 \leq i \leq n} [i] \phi_{i} \rightarrow [Ag] \bigwedge_{1 \leq i \leq n} \phi_{i}$ & $\phi \rightarrow \mathsf{G} \mathsf{P} \phi$ \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c} $\phi \rightarrow \mathsf{H} \mathsf{F} \phi$ & $\mathsf{G} \phi \rightarrow \mathsf{F} \phi$ & $\mathsf{F} \mathsf{F} \phi \rightarrow \mathsf{F} \phi$ & $\mathsf{F} \mathsf{P} \phi \rightarrow \mathsf{P} \phi \vee \phi \vee \mathsf{F} \phi$ & $\mathsf{P} \mathsf{F} \phi \rightarrow \mathsf{P} \phi \vee \phi \vee \mathsf{F} \phi$ \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1.2em} c @{\hskip 1.2em} c @{\hskip 1.4em} c} $\mathsf{G} \phi \vee \mathsf{F} \overline{\phi}$ & $\mathsf{H} \phi \vee \mathsf{P} \overline{\phi}$ & $[Ag] \phi \vee \langle Ag \rangle \overline{\phi}$ & $\alpha (\phi \rightarrow \psi)\rightarrow (\alpha \phi\rightarrow \alpha\psi)$ for $\alpha\in\{\mathsf{G},\mathsf{H},[Ag]\}$ \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 2em} c @{\hskip 2em} c @{\hskip 2em} c } $\mathsf{F} \Diamond \phi \rightarrow \langle Ag \rangle \mathsf{F} \phi$ & \AxiomC{$\phi$} \UnaryInfC{$\mathsf{G} \phi$} \DisplayProof & \AxiomC{$\phi$} \UnaryInfC{$\mathsf{H} \phi$} \DisplayProof & \AxiomC{$(\Box \neg p \wedge \Box (\mathsf{G} p \wedge \mathsf{H} p)) \rightarrow \phi$} \RightLabel{\text{ with $p \not\in \phi$}} \UnaryInfC{$\phi$} \DisplayProof \end{tabular} \end{center} \end{small} A derivation of $\phi$ in $\mathsf{Tstit}$ from a set of premises $\Theta$, is written as $\Theta \vdash_{\mathsf{Tstit}} \phi$. When $\Theta$ is the empty set, we refer to $\phi$ as a \emph{theorem} and write $\vdash_{\mathsf{Tstit}} \phi$. \end{definition} \noindent Note that the axiom $\mathsf{F} \Diamond \phi \rightarrow \langle Ag \rangle \mathsf{F} \phi$ characterizes the \emph{no choice between undivided histories} property definition \ref{models_tkstit}, C6). Furthermore, the last inference rule, a variation of Gabbay's irreflexivity rule \cite{Gab81}, characterizes the property of $\mathcal{R}_{\mathsf{G}}$-irreflexivity definition \ref{models_tkstit}, C7). For a discussion of all axioms and rules see \cite{Lor13}. \begin{theorem}[Soundness and Completeness~\cite{Lor13}]\label{Soundness_Completeness_T-STIT} For any formula $\phi \in \mathcal{L}_{\mathsf{Tstit}}$, $\vdash_{\mathsf{Tstit}} \phi$ iff $ \models \phi$. \end{theorem} \subsection{A Cut-free Labelled Calculus for $\mathsf{Tstit}$} Let $L=\{ x, y, z, ... \}$ be a countable set of labels. The language of $\mathsf{G3Tstit}$ is defined as follows: $$\Gamma ::= x:\phi \ | \ \Gamma, \Gamma \ | \ \mathcal{R}_{\alpha} xy, \Gamma$$ where $x\in L$, $\phi\in\mathcal{L}_{\mathsf{Tstit}}$, and $\mathcal{R}_{\alpha} \in \{\mathcal{R}_{\Box}, \mathcal{R}_{i}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \breve{\mathcal{R}}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}\}$. On the basis of this language, we construct the calculus $\mathsf{G3Tstit}$ as an extension of $\mathsf{G3Ldm}$. \begin{definition}[The Calculus $\mathsf{G3Tstit}$]\label{sequentldmtl} The labelled calculus $\mathsf{G3Tstit}$ consists of all the rules of $\mathsf{G3Ldm}$ extended with the following set of rules: \begin{small} \begin{center} \begin{tabular}{c c c c} \AxiomC{$\mathcal{R}_{\mathsf{H}}wu, \mathcal{R}_{\mathsf{G}}uw, \Gamma$} \RightLabel{$(\mathsf{conv}_{\mathsf{H}})$} \UnaryInfC{$\mathcal{R}_{\mathsf{H}}wu, \Gamma$} \DisplayProof & \AxiomC{$ \Gamma, \mathcal{R}_{\mathsf{H}}wu, w: \mathsf{P} \phi, u : \phi$} \RightLabel{$(\mathsf{P})$} \UnaryInfC{$\Gamma, \mathcal{R}_{\mathsf{H}}wu, w: \mathsf{P} \phi$} \DisplayProof & \AxiomC{ } \RightLabel{$(\mathsf{comp}_{\mathsf{G} 1})$} \UnaryInfC{$\mathcal{R}_{\mathsf{G}}wu, \breve{\mathcal{R}}_{\mathsf{G}}wu, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c c} \AxiomC{$\Gamma, \mathcal{R}_{\mathsf{G}}wv, v: \phi$} \RightLabel{$(\mathsf{G})^{*}$} \UnaryInfC{$\Gamma, w: \mathsf{G} \phi$} \DisplayProof & \AxiomC{$\Gamma, \mathcal{R}_{\mathsf{G}}wu, w: \mathsf{F} \phi, u : \phi$} \RightLabel{$(\mathsf{F})$} \UnaryInfC{$\Gamma, \mathcal{R}_{\mathsf{G}}wu, w: \mathsf{F} \phi$} \DisplayProof & \AxiomC{$ \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{H}}uw, \Gamma$} \RightLabel{$(\mathsf{conv}_{\mathsf{G}})$} \UnaryInfC{$ \mathcal{R}_{\mathsf{G}}wu, \Gamma$} \DisplayProof & \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c c} \AxiomC{$ \Gamma, \mathcal{R}_{Ag}wu, w: \langle Ag \rangle \phi, u : \phi$} \RightLabel{$(\mathsf{\langle Ag \rangle})$} \UnaryInfC{$\Gamma, \mathcal{R}_{Ag}wu, w: \langle Ag \rangle \phi$} \DisplayProof & \AxiomC{$\mathcal{R}_{Ag}ww, \Gamma$} \RightLabel{$(\mathsf{refl}_{Ag})$} \UnaryInfC{$\Gamma$} \DisplayProof & \AxiomC{$w = w, \Gamma$} \RightLabel{$(\mathsf{refl_{=}})$} \UnaryInfC{$\Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c} \AxiomC{$\mathcal{R}_{\mathsf{G}}uv, \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \AxiomC{$u = v, \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \AxiomC{$\mathcal{R}_{\mathsf{G}}vu, \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \RightLabel{$(\mathsf{conn}_{\mathsf{G}})$} \TrinaryInfC{$\mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c} \AxiomC{$\mathcal{R}_{\mathsf{H}}uv, \mathcal{R}_{\mathsf{H}}wu, \mathcal{R}_{\mathsf{H}}wv, \Gamma$} \AxiomC{$u = v, \mathcal{R}_{\mathsf{H}}wu, \mathcal{R}_{\mathsf{H}}wv, \Gamma$} \AxiomC{$\mathcal{R}_{\mathsf{H}}vu, \mathcal{R}_{\mathsf{H}}wu, \mathcal{R}_{\mathsf{H}}wv, \Gamma$} \RightLabel{$(\mathsf{conn}_{\mathsf{H}})$} \TrinaryInfC{$\mathcal{R}_{\mathsf{H}}wu, \mathcal{R}_{\mathsf{H}}wv, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c} \AxiomC{$ \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\Box}uz, \mathcal{R}_{Ag}wv, \mathcal{R}_{\mathsf{G}}vz, \Gamma$} \RightLabel{$(\mathsf{ncuh})^{*}$} \UnaryInfC{$ \mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\Box}uz, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{\mathsf{G}}wu, \Gamma$} \AxiomC{$\breve{\mathcal{R}}_{\mathsf{G}}wu, \Gamma$} \RightLabel{$(\mathsf{comp}_{\mathsf{G} 2})$} \BinaryInfC{$\Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c} \AxiomC{$\mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}uv, \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \RightLabel{$(\mathsf{trans}_{\mathsf{G}})$} \UnaryInfC{$\mathcal{R}_{\mathsf{G}}wu, \mathcal{R}_{\mathsf{G}}uv, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{Ag}wu, \mathcal{R}_{i}wu, \Gamma$} \RightLabel{$(\mathsf{agd})$} \UnaryInfC{$\mathcal{R}_{Ag}wu, \Gamma$} \DisplayProof & \AxiomC{$ \Gamma, \mathcal{R}_{\mathsf{H}}wv, v: \phi$} \RightLabel{$(\mathsf{H})^{*}$} \UnaryInfC{$ \Gamma, w: \mathsf{H} \phi$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c} \AxiomC{$ \mathcal{R}_{\mathsf{G}}wv, \Gamma$} \RightLabel{$(\mathsf{ser}_{\mathsf{G}})^{*}$} \UnaryInfC{$ \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{Ag}wu, \mathcal{R}_{Ag}wv, \mathcal{R}_{Ag}uv, \Gamma$} \RightLabel{$(\mathsf{eucl}_{Ag})$} \UnaryInfC{$\mathcal{R}_{Ag}wu, \mathcal{R}_{Ag}wv, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{\Box}wu, \breve{\mathcal{R}}_{\mathsf{G}}wu, \Gamma$} \RightLabel{$(\mathsf{irr}_{\mathsf{G}})$} \UnaryInfC{$\mathcal{R}_{\Box}wu, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c c} \AxiomC{$w = u, \Delta[w], \Delta[u], \Gamma$} \RightLabel{$(\mathsf{sub_{=}})$} \UnaryInfC{$w = u, \Delta[w], \Gamma$} \DisplayProof & \AxiomC{$w = u, w = v, u = v, \Gamma$} \RightLabel{$(\mathsf{eucl_{=}})$} \UnaryInfC{$w = u, w = v, \Gamma$} \DisplayProof & \AxiomC{$ \Gamma, \mathcal{R}_{Ag}wv, v: A$} \RightLabel{$(\mathsf{[Ag]})^{*}$} \UnaryInfC{$ \Gamma, w: [Ag] A$} \DisplayProof \end{tabular} \end{center} For $(\mathsf{H})$, $(\mathsf{[Ag]})$, $(\mathsf{G})$, $(\mathsf{ncuh})$, and $(\mathsf{ser}_{\mathsf{G}})$ the `$\ast$' states that $v$ must be an eigenvariable. \end{small} \end{definition} \noindent We note that the rules $(\mathsf{conv}_{\mathsf{G}})$ and $(\mathsf{conv}_{\mathsf{H}})$ express the converse relation between $\mathcal{R}_{\mathsf{G}}$ and $\mathcal{R}_{\mathsf{H}}$, and the rules $(\mathsf{agd})$, $(\mathsf{conn}_{\mathsf{G}})$, $(\mathsf{conn}_{\mathsf{H}})$, $(\mathsf{ncuh})$ and $\{(\mathsf{irr}_{\mathsf{G}}),(\mathsf{comp}_{\mathsf{G} 1}),$ $(\mathsf{comp}_{\mathsf{G} 2}) \}$ correspond to conditions {\rm \textbf{(C3)}}-{\rm \textbf{(C7)}} of definition \ref{models_tkstit}, respectively. Furthermore, the notation $\Delta[u]$ in the substitution rule $(\mathsf{sub_{=}})$ is used to express a collection of relational atoms and labelled formulae where all occurrences of the label $w$ in $\Delta[w]$ have been replaced by occurrences of $u$. This notation uniformly captures all of the substitution rules given in \cite{Neg05}. \begin{theorem}[Soundness]\label{Soundness_G3Tstit} Every sequent derivable in $\mathsf{G3Tstit}$ is valid. \end{theorem} \begin{proof} Similar to theorem \ref{Soundness_G3LDM}. \end{proof} \noindent Unfortunately, with respect $\mathsf{G3Tstit}$ completeness, we cannot use the relatively simple strategy applied in proving $\mathsf{G3Ldm}$ completeness. This is because the irreflexivity rule (def. \ref{TSTIT_Def}) does not readily lend itself to derivation in $\mathsf{G3Tstit}$. Here we prove $\mathsf{G3Tstit}$ completeness relative to irreflexive $\mathsf{Tstit}$-frames by leveraging the methods presented in \cite{Neg09}. (NB. For this reason, we introduced $\breve{\mathcal{R}}_{\mathsf{G}}$--the complement of $\mathcal{R}_{\mathsf{G}}$- directly into the language of the proof system. \begin{lemma}\label{Provable_or_Counter} Let $\Gamma$ be a $\mathsf{G3Tstit}$-sequent. Either, $\Gamma$ is $\mathsf{G3Tstit}$-derivable, or it has a $\mathsf{Tstit}$-countermodel. \end{lemma} \begin{proof} We construct the \textit{Reduction Tree} (\textbf{RT}) of a given sequent $\Gamma$, following the method of \cite{Neg09}. If \textbf{RT} is finite, all leaves are initial sequents that are conclusions of $(\mathsf{id})$ or $(\mathsf{comp}_{\mathsf{G} 1})$. If \textbf{RT} is infinite, by K\"onig's lemma, there exists an infinite branch: $\Gamma_{0}$, $\Gamma_{1}$, ..., $\Gamma_{n}$,... (with $\Gamma_{0} {=}\Gamma$). Let $\mathbf{\Gamma}$ = $\bigcup \Gamma_{i}$. We define a $\mathsf{Tstit}$-model $M^{\ast} {=} (W, \mathcal{R}_{\Box}, \{R_{i} | i \in Ag\}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}, V)$ as follows: Let $x \thicksim_{\mathbf{\Gamma}} y$ \textit{iff} $x {=} y \in \mathbf{\Gamma}$. (Usage of the rules ($\mathsf{ref}_{=}$) and ($\mathsf{eucl}_{=}$) in the infinite branch ensure $\thicksim_{\mathbf{\Gamma}}$ is an equivalence relation.) Define $W$ to consist of all equivalence classes $[x]$ of labels in $\mathbf{\Gamma}$ under $\thicksim_{\mathbf{\Gamma}}$. For each $\mathcal{R}_{\alpha} xy \in \mathbf{\Gamma}$ let $([x]_{\thicksim_{\mathbf{\Gamma}}},[y]_{\thicksim_{\mathbf{\Gamma}}})\in \mathcal{R}_{\alpha}$ (with $\mathcal{R}_{\alpha} {\in} \{\mathcal{R}_{\Box}, \mathcal{R}_{i}, \mathcal{R}_{Ag}, \mathcal{R}_{\mathsf{G}}, \breve{\mathcal{R}}_{\mathsf{G}}, \mathcal{R}_{\mathsf{H}}\}$), and for each labelled propositional atom $x : p \in \mathbf{\Gamma}$, let $[x]_{\thicksim_{\mathbf{\Gamma}}} \not\in V(p)$. It is a routine task to show that all relations and the valuation are well-defined. Last, let the interpretation $I {:} L {\mapsto} W$ map each label $x$ to the class of labels $[x]_{\thicksim_{\mathbf{\Gamma}}}$ containing $x$, and suppose $I$ maps all other labels not in ${\mathbf{\Gamma}}$ arbitrarily. We show that: \textbf{(i)} $M^{\ast}$ is a $\mathsf{Tstit}$ model, and \textbf{(ii)} $M^{\ast}$ is a counter-model for $\Gamma$. \ \ \textbf{(i)} First, we assume w.l.o.g. that $\Gamma {\neq} \emptyset$ because the empty sequent is not satisfied on any model. Thus, there must exist at least one label in $\Gamma$; i.e. $W {\neq} \emptyset$. \ \ We argue that $\mathcal{R}_{\Box}$ is an equivalence relation and omit the analogues proofs showing that $\mathcal{R}_{i}$ and $\mathcal{R}_{Ag}$ are equivalence relations. Suppose, for some $\Gamma_{n}$ in the infinite branch there occurs a label $x$ but $\mathcal{R}_{\Box}xx \not\in \Gamma_{n}$. By definition of \textbf{RT}, at some later stage $\Gamma_{n+k}$ the rule $(\mathsf{refl}_{\Box})$ will be applied; hence, $\mathcal{R}_{\Box}xx \in \mathbf{\Gamma}$. The argument is similar for the $(\mathsf{eucl}_{\Box})$ rule. Properties {\rm \textbf{(C1)}} and {\rm \textbf{(C2)}} follow from the rules $(\mathsf{br}_{[i]})$ and $(\mathsf{IOA})$, respectively. Regarding {\rm \textbf{(C3)}}, we only obtain $\mathcal{R}_{Ag} \subseteq \bigcap_{i \in Ag} \mathcal{R}_{i}$ in $M^{\ast}$ via the $(\mathsf{agd})$ rule. Using lemma 9 of \cite{Lor13}, we can transform $M^{\ast}$ into a model where (i) $\mathcal{R}_{Ag} {=} \bigcap_{i \in Ag} \mathcal{R}_{i}$ and where (ii) the model satisfies the same formulae. \ \ We obtain that $\mathcal{R}_{\mathsf{G}}$ is transitive and serial due to the $(\mathsf{trans}_{\mathsf{G}})$ and $(\mathsf{ser}_{\mathsf{G}})$ rules. $\mathcal{R}_{\mathsf{H}}$ is the converse of $\mathcal{R}_{\mathsf{G}}$ by $(\mathsf{conv}_{\mathsf{G}})$ and $(\mathsf{conv}_{\mathsf{H}})$. The properties {\rm \textbf{(C4)}}, {\rm \textbf{(C5)}} and {\rm \textbf{(C6)}} follow from the rules $(\mathsf{conn}_{\mathsf{G}})$, $(\mathsf{conn}_{\mathsf{H}})$ and $(\mathsf{ncuh}) , respectively. \ \ {\rm \textbf{(C7)}} follows from $(\mathsf{irr}_{\mathsf{G}})$, $(\mathsf{comp}_{\mathsf{G} 1})$, and the equality rules: these rules ensure that ($\ast$) if $[u]_{\thicksim_{\mathbf{\Gamma}}} \in \mathcal{R}_{\Box}([w]_{\thicksim_{\mathbf{\Gamma}}})$, then $[u]_{\thicksim_{\mathbf{\Gamma}}} \not\in \mathcal{R}_{\mathsf{G}}([w]_{\thicksim_{\mathbf{\Gamma}}})$. In what follows, we abuse notation and use $[w]$ to denote equivocally the label $w$, as well as any other label $v$ for which a chain of equalities between $w$ and $v$ occurs in the sequent. The claim ($\ast$) is obtained accordingly: if both $\mathcal{R}_{\Box}[w][u]$ and $\mathcal{R}_{\mathsf{G}}[w][u]$ appear together in some sequent $\Gamma_{i}$, then higher up in the infinite branch, the equality rules will introduce relational atoms of the form $\mathcal{R}_{\Box}w'u'$ and $\mathcal{R}_{\mathsf{G}}w'u'$. Eventually, the rule $(\mathsf{irr}_{\mathsf{G}})$ will also be applied and, subsequently, the rule $(\mathsf{comp}_{\mathsf{G} 1})$ will ensure that the reduction tree procedure halts for the given branch. Moreover, if $\mathcal{R}_{\mathsf{G}}[w][w]$ occurs in a sequent $\Gamma_{i}$ of \textbf{RT}, then higher up in the branch the equality rules will introduce a relational atom of the form $\mathcal{R}_{\mathsf{G}}w'w'$. Eventually, $(\mathsf{refl}_{\Box})$ will be applied which adds $\mathcal{R}_{\Box}w'w'$ to the branch containing $\Gamma_{i}$. Lastly, $(\mathsf{irr}_{\mathsf{G}})$ will be applied even higher up this branch, adding $\breve{\mathcal{R}}_{\mathsf{G}}w'w'$, which by $(\mathsf{comp}_{\mathsf{G} 1})$ will halt the \textbf{RT}-procedure for that branch. Thus we may conclude: for any infinite branch of \textbf{RT} $\mathcal{R}_{\mathsf{G}}ww$ will not occur for any label $w$; meaning that not only will $M^{\ast}$ satisfy {\rm \textbf{(C7)}}, its relation $\mathcal{R}_{\mathsf{G}}$ will be irreflexive. Additionally, note that $(\mathsf{comp}_{\mathsf{G} 2})$ will ensure that $\breve{\mathcal{R}}_{\mathsf{G}}$ is the complement of $\mathcal{R}_{\mathsf{G}}$. \ \ Lastly, as long as $[x]_{\thicksim_{\mathbf{\Gamma}}} \not\in V(p)$ when $x : p \in \mathbf{\Gamma}$, all other labels can be mapped by $V$ in any arbitrary manner. Thus, $V$ is a valid valuation function. \ \ \textbf{(ii)} By construction, $M^{\ast}$ satisfies each relational atom in $\mathbf{\Gamma}$, and therefore, satisfies each relational atom in $\Gamma$. By induction on the complexity of $\phi$ it is shown that for any formula $x : \phi \in \mathbf{\Gamma}$ we have $M^{\ast}, [x]_{\thicksim_{\mathbf{\Gamma}}} \not\models \phi$ (See \cite{Neg09} for details). Hence, $\Gamma$ is falsified on $M^{\ast}$ with $I$. \end{proof} \begin{theorem}[Completeness]\label{Completeness_G3Tstit} Every valid sequent is derivable in $\mathsf{G3Tstit}$. \end{theorem} \begin{proof} Follows from lemma \ref{Provable_or_Counter}. \end{proof} \subsection{Axioms and Relational Semantics for $\mathsf{Xstit}$} A common feature of the \textit{cstit}- and \textit{dstit}-operator is that they do not internally employ temporal structures. In this section, we consider the logic of $\mathsf{Xstit}$ which contains a non-instantaneous STIT-operator explicitly affecting next states. This logic, introduced in \cite{Bro11,Bro11b}, has been motivated by the observation that affecting next states is a central aspect of agency in computer science. Moreover, extensions of the logic $\mathsf{Xstit}$ have been employed to investigate the concepts of purposeful and voluntary acts and their relation to different levels of legal culpability \cite{Bro11}. The logic was originally proposed for a two-dimensional semantics making reference to both states and histories; the latter defined as maximally linear ordered paths on a frame. In this section, we provide a semantics for $\mathsf{Xstit}$ that relies on relational frames, avoiding the use of complex two-dimensional indices (the possibility of which was already noted in \cite{Bro11}). We provide a labelled calculus $\mathsf{G3Xstit}$ for this logic and prove that it is sound and complete with respect to its relational characterization. Furthermore, by showing a correspondence between the original Hilbert system $\mathsf{Xstit}$ and the calculus $\mathsf{G3Xstit}$ we show that the language of $\mathsf{Xstit}$ does not allow us to distinguish between the two available semantics. \begin{definition}[The Language $\mathcal{L}_{\mathsf{Xstit}}$]\label{language_xstit} Let $Ag {=} \{1,2,...,n\}$ be a finite set of agent labels and let $Var {=}\{p_1,p_2,p_3...\}$ be a countable set of propositional variables. $\mathcal{L}_{\mathsf{Xstit}}$ is defined as follows {\small $$\phi ::= p \ | \ \overline{p} \ | \ \phi \wedge \phi \ | \ \phi \vee \phi \ | \ \Box \phi \ | \ \Diamond \phi \ | \ [A]^x\phi \ | \ \langle A\rangle^x \phi \ | \ [X] \phi \ | \ \langle X\rangle \phi $$} where $p \in Var$; and $A\subseteq Ag$ (with special cases $\emptyset$ and $Ag$). \end{definition} \noindent The language uses the settledness operator $\Box$, a group-stit operator $[A]^{x}$, and the operator $[X]$ referring to the next state. Formulae of the form $[A]^{x}\phi$ must be read as `group $A$ effectively sees to it that in the next state $\phi$ holds'. As mentioned previously, we provide a semantics for the logic $\mathsf{Xstit}$ based on relational frames. The conditions on these frames are obtained through a simple transformation of the two-dimensional frame properties presented in \cite{Bro11}. \begin{definition}[Relational $\mathsf{Xstit}$ Frames and Models]\label{models_xstit} An $\mathsf{Xstit}$-frame is defined to be a tuple $F = ( W, \mathcal{R}_{\Box}, \mathcal{R}_X, \{\mathcal{R}_A | A\subseteq Ag\})$ such that $W \neq \emptyset$ and: \begin{itemize} \item[{\rm \textbf{(D1)}}] $\mathcal{R}_{\Box}\subseteq W{\times}W$ is an equivalence relation; \item[{\rm \textbf{(D2)}}] $\mathcal{R}_X\subseteq W{\times}W$ is serial and deterministic; \item[{\rm \textbf{(D3)}}] $\mathcal{R}_A \subseteq W{\times}W$ such that, \begin{itemize} \item[(i)] $\mathcal{R}_{\emptyset} = \mathcal{R}_{\Box} \circ \mathcal{R}_X$; \item[(ii)] $\mathcal{R}_{Ag} = \mathcal{R}_X \circ \mathcal{R}_{\Box}$; \item[(iii)] $\mathcal{R}_A\subseteq \mathcal{R}_B$ for $\emptyset \subseteq B\subseteq A\subseteq Ag$; \item[(iv)] For any $B,A\subseteq Ag$ (s.t. $B\cap A=\emptyset$) and $\forall w_1,w_2,w_3,w_5,w_6\in W$ we have: $(\mathcal{R}_{\Box} w_1w_2\land \mathcal{R}_{\Box}w_1w_3) \rightarrow \exists w_4 (\mathcal{R}_{\Box}w_1w_4 \land (\mathcal{R}_A w_4w_5 \rightarrow \mathcal{R}_Aw_2w_5)\land (\mathcal{R}_B w_4w_6 \rightarrow \mathcal{R}_Bw_3w_6))$ \end{itemize} \end{itemize} \noindent A relational $\mathsf{Xstit}$-model is a tuple $M = ( F,V )$ where $F$ is an $\mathsf{Xstit}$-frame and $V$ a valuation function mapping propositional variables $p_i\in Var$ to subsets of $W$; i.e. $V: Var\mapsto \mathcal{P}(W)$. \end{definition} \noindent Condition (D3)-(iv) expresses the \textit{independence of agents} principle for $\mathsf{Xstit}$. From condition (D3)-(ii) we obtain that $\mathcal{R}_{Ag} \subseteq \mathcal{R}_X \circ \mathcal{R}_{\Box}$, which ensures the principle of \textit{no choice between undivided histories} (\textit{cf}. definition \ref{models_tkstit}, C6). Furthermore, we stress that, following \cite{Bro11}, the relation $\mathcal{R}_X$ is not explicitly defined as a \textit{strict} next-relation; that is, the frame construction allows for reflexive worlds. For a discussion of all the frame properties we refer the reader to \cite{Bro11}. \begin{definition}[Semantics of $\mathcal{L}_\mathsf{Xstit}$] To define the \emph{satisfaction} of a formula $\phi\in\mathcal{L}_{\mathsf{Xstit}}$ on $M$ at $w$, we make use of clauses (1)-(6) from definition \ref{Semantics_ldm_tstit}, taking $M$ to be an $\mathsf{Xstit}$-model (but omitting explicit mention of $M$ in the clauses), along with the following clauses (global truth and validity are defined as usual): \begin{center} \begin{small} \begin{multicols}{2} \begin{itemize} \item[7.] $w \models [A]^x \phi$ iff $\forall u \in \mathcal{R}_{A}(w)$, $u \models \phi$; \item[8.] $w \models \langle A\rangle^x \phi$ iff $\exists u \in \mathcal{R}_{A}(w)$, $u \models \phi$; \end{itemize} \columnbreak \begin{itemize} \item[9.] $w \models [X] \phi$ iff $\forall u \in \mathcal{R}_{X}(w)$, $u \models \phi$; \item[10.] $w \models \langle X\rangle \phi$ iff $\exists u \in \mathcal{R}_{X}(w)$, $u \models \phi$. \end{itemize} \end{multicols} \end{small} \end{center} \end{definition} \begin{definition}[The Logic $\mathsf{Xstit}$ \cite{Bro11}]\label{axioms_xstit} The Hilbert system for $\mathsf{Xstit}$ consists of the axioms and rules below, where $\phi, \psi\in\mathcal{L}_{\mathsf{Xstit}}$, $A\subseteq Ag$ and $\alpha \in \{\Box,[A]^x,[X]\}$: \begin{small} \begin{center} \begin{tabular}{c @{\hskip 2em} c @{\hskip 2em} c} $\phi\rightarrow (\psi \rightarrow \phi)$ & $(\overline{\psi} \rightarrow \overline{\phi}) \rightarrow (\phi \rightarrow \psi)$ & $(\phi \rightarrow (\psi \rightarrow \chi)) \rightarrow ((\phi \rightarrow \psi) \rightarrow (\phi \rightarrow \chi))$ \end{tabular} \ \\ \begin{tabular}{c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c } $\alpha (\phi\rightarrow \psi)\rightarrow (\alpha \phi\rightarrow \alpha \psi)$ & $\Box \phi \rightarrow \phi$ & $\Diamond \phi \rightarrow \Box \Diamond \phi$ & $[A]^x\phi \rightarrow \langle A\rangle^x \phi$ & $\diamx \phi \rightarrow [X] \phi$ \end{tabular} \ \\ \begin{tabular}{ c @{\hskip 1.5em} c @{\hskip 1.5em} c@{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c} $\Box [X]\phi \leftrightarrow [\emptyset]^x \phi$ & $[Ag]^x \phi \leftrightarrow [X]\Box\phi$ & $[A]^x \phi \rightarrow [B]^x \phi^{(\dag)}$ & $\Box \phi \vee \Diamond \overline{\phi}$ & $[A]^x \phi \vee \langle A\rangle^x \overline{\phi}$ \end{tabular} \ \\ \begin{tabular}{c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c @{\hskip 1.5em} c } $\Diamond [A]^x \phi \land \Diamond [B]^x \psi \rightarrow \Diamond ([A]^x \phi \land [B]^x \psi)^{(\dag\dag)}$ & $[X] \phi \vee \langle X\rangle \overline{\phi}$ & \AxiomC{$\phi$} \AxiomC{$\phi \rightarrow \psi$} \BinaryInfC{$\psi$} \DisplayProof & \AxiomC{$\phi$} \UnaryInfC{$\alpha \phi$} \DisplayProof \end{tabular} \end{center} \noindent where $(\dag) A\subseteq B\subseteq Ag$; and $(\dag\dag) A \cap B =\emptyset$. \end{small} \\ \\ \noindent A derivation of $\phi$ in $\mathsf{Xstit}$ from $\Theta$ is written as $\Theta \vdash_{\mathsf{Xstit}} \phi$. When $\Theta$ is the empty set, we refer to $\phi$ as a \emph{theorem} and write $\vdash_{\mathsf{Xstit}} \phi$. \end{definition} We refer to $\Diamond [A]^x \phi \land \Diamond [B]^x \psi \rightarrow \Diamond ([A]^x \phi \land [B]^x \psi)$ as the IOA$^x$-axiom. In contrast with the standard IOA-axiom, observe that IOA$^x$-axiom refers to the independence of isolated \textit{groups} of agents with respect to \textit{successor} states. For a natural language interpretation of the other axioms of $\mathsf{Xstit}$ we refer to \cite{Bro11}. Instead of proving completeness for the intended sequent calculus directly, we prove it first for the Hilbert calculus. This enables us to eventually conclude the equivalence of these two calculi with respect to the logic $\mathsf{Xstit}$. \begin{theorem}[Completeness of $\mathsf{Xstit}$]\label{xstitcomp} For all $\phi\in\mathcal{L}_{\mathsf{Xstit}}$, if $\models \phi$, then $\vdash_{\mathsf{Xstit}} \phi$. \end{theorem} \begin{proof} As observed in \cite{Bro11}, all axioms of $\mathsf{Xstit}$ are Sahlqvist formula . Furthermore, the first-order correspondents of the $\mathsf{Xstit}$ axioms taken together define the class of frames from definition \ref{models_xstit}. Applying Theorem 4.42 of \cite{BlaRijVen01}, we obtain that the logic $\mathsf{Xstit}$ is complete relative to this class of frames. \end{proof} \subsection{A Cut-free Labelled Calculus for $\mathsf{Xstit}$} We provide a labelled calculus $\mathsf{G3Xstit}$ that is sound and complete relative to the relational frames of definition \ref{models_xstit}. In order to convert the $\mathsf{Xstit}$ axiomatization into rules for the intended calculus, we first observe that every axiom of $\mathsf{Xstit}$ is a \textit{geometric formula} with the exception of the IOA$^x$ axiom. For the geometric formulae we can find corresponding geometric rules, following \cite{Neg05}. The first-order frame condition $\mathrm{(D3)}(iv)$ for IOA$^x$ (def. \ref{models_xstit}) is not a geometric formula; however, we observe that its components $\mathcal{R}_{A}w_{4}w_{5} {\rightarrow} \mathcal{R}_{A}w_{2}w_{5}$ and $\mathcal{R}_{B}w_{4}w_{6} {\rightarrow} \mathcal{R}_{B}w_{3}w_{6}$ in fact are. The IOA$^x$-condition is, thus, a \textit{generalized geometric axiom} of type $GA_1$ and we may therefore find an equivalent system of rules, following \cite{Neg16}. We refer to the following system of rules $\langle (\mathsf{IOA{-}E}), \{(\mathsf{IOA{-}U_1}),(\mathsf{IOA{-}U_{2}})\}\rangle$ as the `independence of agents' rule $(\mathsf{IOA_X})$. We may use the rule ($\mathsf{IOA{-}E}$) wherever throughout the course of a derivation, but if we use either ($\mathsf{IOA{-}U_1}$) or ($\mathsf{IOA{-}U_2}$), then we must (i) use the other ($\mathsf{IOA{-}U}_{i}$) rule (for $i \in \{1,2\}$) in a separate branch of the derivation and (ii) use the ($\mathsf{IOA{-}E}$) rule below both instances of ($\mathsf{IOA{-}U}_{i}$); \textit{i.e.} the derivation is of the form represented below: \begin{small} \begin{center} \AxiomC{$R_{A}w_{4}w_{5}, R_{A}w_{2}w_{5}, \Gamma$} \RightLabel{($\mathsf{IOA-U_{1}})$} \UnaryInfC{$R_{A}w_{4}w_{5}, \Gamma$} \UnaryInfC{$\vdots$} \AxiomC{$R_{B}w_{4}w_{6}, R_{B}w_{3}w_{6}, \Gamma'$} \RightLabel{($\mathsf{IOA-U_{2}})$} \UnaryInfC{$R_{B}w_{4}w_{6}, \Gamma'$} \UnaryInfC{$\vdots$} \BinaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, \Gamma''$} \RightLabel{($\mathsf{IOA-E})^{*}$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3},\Gamma''$} \DisplayProof \end{center} \ \\ \noindent where (*) $w_{4}$ is an eigenvariable in the ($\mathsf{IOA-E}$) rule. \end{small} \begin{definition}[The Calculus $\mathsf{G3Xstit}$]\label{sequentxstitl} The labeled calculus $\mathsf{G3Xstit}$ consists of the rules $(\mathsf{id})$, $(\wedge)$, $(\vee)$, $(\mathsf{refl}_=)$, $(\mathsf{eucl_=})$, $(\mathsf{sub_=})$, $(\Box)$, $(\Diamond)$, $(\mathsf{refl}_{\Box})$, and $(\mathsf{eucl}_{\Box})$ from definitions \ref{sequentldml} and \ref{sequentldmtl} extended with the $(\mathsf{IOA_X})$-rule and the following: \begin{small} \begin{center} \begin{tabular}{c @{\hskip 1 em} c @{\hskip 1 em} c @{\hskip 1 em} c} \AxiomC{$\Gamma, \mathcal{R}_A wv, v: \phi$} \RightLabel{$(\mathsf{[A]}^x)^{*}$} \UnaryInfC{$\Gamma, w: [A]^x \phi$} \DisplayProof & \AxiomC{$\Gamma, \mathcal{R}_Awu, w: \langle A \rangle^x \phi, u: \phi$} \RightLabel{$(\mathsf{\langle A\rangle}^x)$} \UnaryInfC{$\Gamma, \mathcal{R}_A wu, w: \langle A \rangle^x \phi$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c c} \AxiomC{$ \Gamma, \mathcal{R}_X wv, w: \diamx \phi, v: \phi$} \RightLabel{$(\langle\mathsf{X}\rangle)$} \UnaryInfC{$\Gamma, \mathcal{R}_X wv w: \langle X\rangle \phi$} \DisplayProof & \AxiomC{$\mathcal{R}_{\Box}wv, \mathcal{R}_X vu, \mathcal{R}_{\emptyset} wu, \Gamma$} \RightLabel{$(\mathsf{Eff}{\emptyset})$} \UnaryInfC{$\mathcal{R}_{\Box}wv, \mathcal{R}_X vu, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{ c @{\hskip 1em} c @{\hskip 1em} c } \AxiomC{$\mathcal{R}_A wv, \mathcal{R}_B wv, \Gamma$} \RightLabel{$(\mathsf{C{-}Mon})^{\dag}$ \UnaryInfC{$\mathcal{R}_A wv, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_X wv, \Gamma$} \RightLabel{$(\mathsf{ser_X})^{\ast}$} \UnaryInfC{$\Gamma$} \DisplayProof & \AxiomC{$v = u, \mathcal{R}_X wv, \mathcal{R}_X wu, \Gamma$} \RightLabel{$(\mathsf{det_X})$} \UnaryInfC{$\mathcal{R}_X wv,\mathcal{R}_X wu, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 1em} c @{\hskip 1em} c } \AxiomC{$ \Gamma, \mathcal{R}_X wv, v: \phi$} \RightLabel{$([\mathsf{X}])^{\ast}$} \UnaryInfC{$\Gamma, w: [X] \phi$} \DisplayProof & \AxiomC{$\mathcal{R}_{\Box}wv, \mathcal{R}_X vu, \mathcal{R}_{\emptyset} wu, \Gamma$} \RightLabel{$({\emptyset}\mathsf{Eff}) ^{\ast}$ \UnaryInfC{$\mathcal{R}_{\emptyset} wu, \Gamma$} \DisplayProof \end{tabular} \end{center} \begin{center} \begin{tabular}{c @{\hskip 2.5em} c } \AxiomC{$\mathcal{R}_{Ag}wu, \mathcal{R}_X wv, \mathcal{R}_{\Box}vu, \Gamma$} \RightLabel{$(\mathsf{EffAg})$} \UnaryInfC{$\mathcal{R}_X wv, \mathcal{R}_{\Box}vu, \Gamma$} \DisplayProof & \AxiomC{$\mathcal{R}_{Ag}wu, \mathcal{R}_X wv, \mathcal{R}_{\Box}vu, \Gamma$} \RightLabel{$(\mathsf{AgEff})^{\ast}$ \UnaryInfC{$\mathcal{R}_{Ag}wu, \Gamma$} \DisplayProof \end{tabular} \end{center} \noindent where $(\ast)$ $v$ is an eigenvariable; and $(\dag)$ $B\subseteq A\subseteq Ag$. \end{small} \end{definition} \noindent Observe that the rules $\{({\emptyset}\mathsf{Eff}),(\mathsf{Eff}{\emptyset})\}, \{(\mathsf{AgEff}),(\mathsf{EffAg})\}, (\mathsf{C{-}Mon})$ and $(\mathsf{IOA_X})$ of the labelled calculus $\mathsf{G3Xstit}$ capture the frame conditions $\mathrm{(D3)}(i){-}(iv)$ of definition \ref{models_xstit}, respectively.\footnote{In \cite{Neg16} it is shown that every generalized geometric formula can be captured through (a system of) rules, allowing for the construction of \textit{analytic} calculi for the minimal modal logic $\mathsf{K}$ extended with any axioms from the Sahlqvist class. Since all axioms of $\mathsf{Ldm}$ and $\mathsf{Xstit}$ are Sahlqvist formulae, the results also apply to these logics.} \begin{theorem}[Soundness]\label{xstitsound} Every sequent derivable in $\mathsf{G3Xstit}$ is valid. \end{theorem} \begin{proof} Similar to theorem \ref{Soundness_G3LDM}. Since all rules of $\mathsf{G3Xstit}$ are generalized geometric rules, we can apply the general soundness results of Theorem 6.3 of \cite{Neg16} \end{proof} \noindent In order to prove completeness of $\mathsf{G3Xstit}$ relative to the logic $\mathsf{Xstit}$, we employ the same strategy as for $\mathsf{G3Ldm}$, by first proving that every formula derivable in $\mathsf{Xstit}$ is derivable in $\mathsf{G3Xstit}$. \begin{lemma}\label{xstitsequent} For all $\phi \in \mathcal{L}_{\mathsf{Xstit}}$, if $\vdash_{\mathsf{Xstit}} \phi$, then $\vdash_{\mathsf{G3Xstit}} x : \phi$. \end{lemma} \begin{proof} The derivation of each axiom and inference rule is straightforward (See \cite{Neg05}). The $\mathsf{G3Xstit}$-derivation of the IOA$^x$-axiom can be obtained by applying the rule system $(\mathsf{IOA_X})$ (see appendix \ref{XSTIT_IOA}). \end{proof} \iffalse \begin{proof} The derivation of each geometric axiom and inference rule of $\mathsf{Xstit}$ is similar to lemma \ref{sequent_ldm}. The derivation of the generalized geometric IOA-axiom can be found in the Appendix \ref{LDM_IOA}. \end{proof} \begin{small} \begin{figure}\label{ioaxderivation} \begin{tabular} c} \AxiomC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, R_{A}w_{2}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{5}: \phi, w_{5}: \overline{\phi}$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, R_{A}w_{2}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{5}: \phi$} \RightLabel{($\mathsf{IOA-U_{1}})$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{A}w_{4}w_{5}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ... \ \ $ w_{5}: \phi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{4}: [A]^x\phi$} \UnaryInfC{$D_1$} \DisplayProof \end{tabular} \ \\ \begin{tabular} c} \AxiomC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, R_{B}w_{3}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ....\ \ $ w_{6}: \psi, w_{6} : \overline{\psi}$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, R_{B}w_{3}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{6}: \psi$} \RightLabel{($\mathsf{IOA-U_{2}})$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, R_{B}w_{4}w_{6}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{6}: \psi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, ...\ \ $ w_{4}: [B]^x\psi$} \UnaryInfC{$D_2$} \DisplayProof \end{tabular} \ \\ \begin{tabular} c} \AxiomC{$D_1\quad\quad\quad$ \AxiomC{$\quad\quad\quad D_2$ \BinaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi), w_{4}: [A]^x\phi\land [B]^x\psi$} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, R_{\Box}w_{1}w_{4}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \RightLabel{($\mathsf{IOA-E}$)} \UnaryInfC{$R_{\Box}w_{1}w_{2}, R_{\Box}w_{1}w_{3}, w_{2}: \langle A \rangle^x \overline{\phi}, w_{3}: \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \UnaryInfC{$w_{1}: \Box \langle A \rangle^x \overline{\phi}, w_{1}:\Box \langle B \rangle^x \overline{\psi}, w_{1}: \Diamond ([A]^x\phi\land [B]^x\psi)$} \UnaryInfC{$w_{1}: \Box \langle A \rangle^x \overline{\phi} \lor \Box \langle B \rangle^x \overline{\psi} \lor \Diamond ([A]^x\phi\land [B]^x\psi)$} \DisplayProof \end{tabular} \caption{Derivation of the IOA axiom in $\mathsf{G3Xstit}$.} \end{figure} \end{small} \fi \begin{corollary}[Completeness]\label{xstitlcomp} For all $\phi\in\mathcal{L}_{\mathsf{Xstit}}$, if $\models \phi$, then $\vdash_{\mathsf{G3Xstit}} x : \phi$ \end{corollary} \begin{proof} Follows from theorem \ref{xstitcomp} and lemma \ref{xstitsequent}. \end{proof} As another consequence, we obtain that the logic $\mathsf{Xstit}$ can be characterized without using two-dimensional frames employing histories, as applied in \cite{Bro11}.
{'timestamp': '2019-04-23T02:26:50', 'yymm': '1904', 'arxiv_id': '1904.09899', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09899'}
arxiv
\section{Introduction} \label{sec:intro} The group testing problem consists of determining a small subset of defective items within a larger set of items, based on a tests performed on groups of items, and corresponding outcomes that indicate whether the group contains at least one defective item. This problem has a history in medical testing \cite{Dor43}, and has regained significant attention following new applications in areas such as communication protocols \cite{Ant11}, pattern matching \cite{Cli10}, and database systems \cite{Cor05}, and connections with compressive sensing \cite{Gil08,Gil07}. The design and analysis of group testing algorithms remains an active ongoing area of research; see \cite{Du93,Ald19} for comprehensive surveys. {Some of the key defining features of the group testing problem are outlined as follows: \begin{itemize} \item {\bf Combinatorial vs.~probabilistic.} In {\em combinatorial group testing} \cite{Du93}, one seeks to construct a testing procedure that guarantees the recovery of {\em all} defective sets up to a certain size. In contrast, in {\em probabilistic group testing} \cite{Ald19}, the test design may be randomized, and the algorithm is allowed some non-zero probability of error. Combinatorial group testing is also known as the {\em for-all model} or the {\em zero-error recovery criterion}, and probabilistic group testing is also known as the {\em for-each model} or the {\em small-error recovery criterion}. \item {\bf Adaptive vs.~non-adaptive.} In the {\em adaptive} setting, each test may be designed based on all previous outcomes, whereas in the {\em non-adaptive setting}, all tests must be chosen prior to observing any outcomes. The non-adaptive setting is often preferable in practice, as it permits the tests to be performed in parallel. \item {\bf Noiseless vs.~noisy.} In the {\em noiseless} setting, the test outcomes are perfectly reliable, whereas in {\em noisy settings}, some tests may be flipped according to some probabilistic or adversarial noise model. \end{itemize} Our focus is on non-adaptive probabilistic group testing; we formally introduce the noiseless model below, and turn to the noisy setting in Section \ref{sec:noisy}. } \subsection{Problem Setup} \label{sec:setup} The group testing problem consists of $n$ items labeled $\{1,\dotsc,n\}$, a subset $\Kc$ of which are {\em defective}. We seek to identify $\Kc$ via a series of suitably-chosen tests. Except where stated otherwise, we consider the noiseless setting, in which each test takes the form \begin{equation} Y = \bigvee_{j \in \Kc} X_j, \label{eq:gt_noiseless_model} \end{equation} where the test vector $X = (X_1,\dotsc,X_n) \in \{0,1\}^n$ indicates which items are included in the test, and $Y \in \{0,1\}$ is the resulting test outcome. That is, the output indicates whether at least one defective item is included in the test. The goal is to design a sequence of tests $X^{(1)},\dotsc,X^{(t)}$, with $t$ ideally as small as possible, such that the outcomes can be used to reliably recover the defective set $\Kc$. We focus on {\em non-adaptive} test designs, in which all tests must be chosen prior to observing any outcomes. Accordingly, the tests $X^{(1)},\dotsc,X^{(t)}$ are represented by a {\em test matrix} $\Xv \in \{0,1\}^{t \times n}$ whose $i$-th column is $X^{(i)} \in \{0,1\}^t$. The corresponding test outcomes are denoted by $\Yv = (Y^{(1)},\dotsc,Y^{(t)})$, with $Y^{(i)} \in \{0,1\}$ generated from $X^{(i)}$ according to the model \eqref{eq:gt_noiseless_model}. Given the tests and their outcomes, a \emph{decoder} forms an estimate $\Kchat$ of $\Kc$. We consider the exact recovery criterion, in which the error probability is given by \begin{equation} \pe := \PP[\Kchat \ne \Kc]. \label{eq:pe} \end{equation} We assume that $|\Kc| \le k$ for some $k$ that is known to the group testing algorithm. That is, the algorithm knows an upper bound on $|\Kc|$ is known but not necessarily the exact value. {This is a standard assumption in the literature, and an assumption of this kind is necessary in the non-adaptive setting -- without an upper bound on $|\Kc|$, one would need to account for scenarios such as $|\Kc| \ge \frac{n}{2}$ that require $n$ tests \cite{Ald18}.} Our analysis will hold for an arbitrary {\em fixed} defective set $\Kc$ with cardinality at most $k$, meaning that the probability in \eqref{eq:pe} is only with respect to our randomized test design $\Xv$. However, we can alternatively view our results as certifying the existence of a fixed matrix $\Xv$ yielding small $\pe$ with respect a randomly generated $\Kc$ whose distribution is {\em independent of $\Xv$} and satisfies $|\Kc| \le k$ almost surely. {Throughout the paper, we use the standard asymptotic notation $O(\cdot)$, $o(\cdot)$, $\Theta(\cdot)$, $\Omega(\cdot)$ and $\omega(\cdot)$.} \subsection{Summary of Results} \label{sec:contr} {The vast majority of the group testing literature has sought to develop test designs with as few tests as possible, and decoding algorithms whose runtime is linear or polynomial in the number of items. Recently, however, a line of works has developed test designs and decoding algorithms that permit more efficient $\poly(k \log n)$ decoding time when there are $n$ items and $k$ defectives, thereby considerably reducing the dependence on $n$. This was first done in the combinatorial setting \cite{Che09,Ind10,Ngo11} and more recently in the probabilistic setting \cite{Cai13,Lee15a,Ina19}; see Section \ref{sec:related} for details. } {In this paper, we introduce a non-adaptive probabilistic group testing procedure termed {\em bit mixing coding} (BMC) that attains asymptotically vanishing error probability as $n \to \infty$ with $O(k \log n)$ tests and $O(k^2 \cdot \log k \cdot \log n)$ decoding time. The $O(k \log n)$ number of tests is known to be order-optimal whenever $k \le O(n^{1-\epsilon})$ for some $\epsilon > 0$. BMC is the first algorithm to achieve such optimal number of tests together with $\poly(k \log n)$ decoding time, resolving an open problem recently posed in \cite{Ina19}. As we will see in Section \ref{sec:related}, the best known previous approach with $\poly(k \log n)$ decoding time needed to use $O(k \cdot \log k \cdot \log n)$ tests \cite{Cai13,Lee15a}. In the terminology of \cite{Bal13,Ald14a,Ald19}, order-optimality in the number of tests amounts to attaining a {\em positive rate}: The number of bits learned per test is $\Theta(1)$, whereas existing algorithms that use $O(k \cdot \log k \cdot \log n)$ tests \cite{Cai13,Lee15a} only learn $O\big( \frac{1}{\log k} \big)$ bits per test. Finally, we note that the $O(k^2 \cdot \log k \cdot \log n)$ decoding time of BMC falls short of the $O(k \cdot \log k \cdot \log n)$ decoding time achieved using $O(k \cdot \log k \cdot \log n)$ tests \cite{Cai13,Lee15a}, which leaves open the possibility of reducing our runtime further while maintaining order-optimality in the number of tests. BMC has a few additional salient features. While BMC uses a randomized test design, along the way we provide sufficient conditions for success that hold with high probability and can be verified in time $\poly(k \log n)$. BMC also can naturally incorporate mechanisms for combating noise in the test outcomes: In Section \ref{sec:noisy}, we describe straightforward modifications to the test design and decoding algorithm to permit randomly flipped test outcomes while preserving the guarantees on the number of tests and decoding time.} \section{Related Work} \label{sec:related} In this section, we provide a detailed overview of the most related existing works, first focusing on the theoretical results and then discussing the corresponding algorithmic ideas. \subsection{Overview of Existing Group Testing Results} \label{sec:ex_gt} {The existing literature on non-adaptive group testing most related to this work is summarized in Table \ref{tbl:summary}. Along with the distinction between the combinatorial and probabilistic settings, we highlight the following features of the test designs and recovery algorithms: \begin{itemize} \item {\bf Explicit vs.~randomized.} Many of the tightest bounds in the literature are based on {\em randomized} test designs. In contrast, an efficient deterministic procedure for constructing a test design is said to be {\em explicit}. There are various notions of how efficient the procedure should be to warrant this terminology \cite{Por11}; to facilitate our discussion, we only consider the most lenient notion in the literature, requiring the test matrix $\Xv \in \{0,1\}^{t \times n}$ can be deterministically constructed in time polynomial in $t$ and $n$. \item {\bf Decoding efficiency.} The majority of the group testing literature considers algorithms with $\Omega(n)$ runtime, e.g., as a result of traversing the entire matrix $\Xv \in \{0,1\}^{t \times n}$. Our focus, however, is on decoding algorithms with a significantly lower runtime of the form $\poly(k \log n)$ decoding time, ideally with a low polynomial power. Such algorithms attain {\em sublinear-time decoding} (i.e., decoding time scaling as $o(n)$) when $k$ grows sufficiently slowly with respect to $n$. \item {\bf Recovery criteria.} Except where stated otherwise, all results that we overview correspond to the exact recovery criterion, requiring that $\Kchat = \Kc$ (see \eqref{eq:pe}). However, we also briefly mention two other recovery criteria appearing in Table \ref{tbl:summary}: (i) The {\em list decoding} criterion \cite{Deb05,Dya83,Ras90,Che09,Ind10,Ngo11} only requires identifying a superset of the defective set, typically constrained to be of size $O(k)$; (ii) The {\em approximate recovery} criterion \cite{Lee15a,Sca17} only requires identifying a fraction $1-\epsilon$ of the defectives, for some constant $\epsilon > 0$. \end{itemize} We proceed by discussing the results in Table \ref{tbl:summary} in more detail; the most relevant algorithmic ideas used in attaining these results will be discussed in Section \ref{sec:techniques}. {\bf Combinatorial group testing.} The combinatorial setting poses a strictly harder problem than the probabilistic setting, in the sense of requiring $t = \Omega\big( \min\big\{ k^2 \frac{\log n}{\log k}, n \big\} \big)$ tests \cite{Dya82} as opposed to $O(k \log n)$ \cite{Ald14a}. The best-known $O(k^2 \log n)$ upper bound on the number of tests was originally attained with $\Omega(n)$ decoding time, first using random coding methods \cite{Dya82} and then using explicit designs \cite{Por11}. See \cite{Kau64,Dya83,Dya00,Kim04} and the references therein for further related works. More recently, algorithms were developed that attain ${\rm poly}(t)$ decoding time \cite{Che09,Ind10,Ngo11}, with Cheragchi \cite{Che09} focusing on list decoding, and Indyk {\em et al.}~\cite{Ind10} and Ngo {\em et al.}~\cite{Ngo11} considering exact recovery. In particular, the latter works showed that the decoding time can be reduced to ${\rm poly}(t)$ while maintaining the $t = O(k^2 \log n)$ scaling of \cite{Por11}. To achieve this, \cite{Ind10} used a randomized design, and \cite{Ngo11} presented an explicit construction. A more recent work provided an explicit construction attaining $t = O(k^2 \log^2 n)$ with $O(k^3 \log^2 n)$ decoding time \cite{Che19}. The main feature highlighted in \cite{Che19} is the simplicity of the construction, but a drawback is an additional $\log n$ factor in the number of tests. \begin{table} \begin{center} \begin{tabular}{|>{\centering}m{2.8cm}|>{\centering}m{2.35cm}|>{\centering}m{2.9cm}|>{\centering}m{3.0cm}|>{\centering}m{3.5cm}|} \hline \textbf{References} & \textbf{Guarantee} & \textbf{Number of tests $t$} & \textbf{Runtime} & \textbf{Construction}\tabularnewline \hline \hline {\em Lower Bound} \cite{Dya82} & Combinatorial & $\Omega\big(\min\big\{k^2 \frac{\log n}{\log k},n\big\}\big)$ & - & -\tabularnewline \hline D'yachkov-Rykov \cite{Dya83} & Combinatorial & $O(k^{2}\log n)$ & $\Omega(n)$ & Randomized\tabularnewline \hline Kautz-Singleton \cite{Kau64} & Combinatorial & $O\big(k^{2}\frac{\log^2 n}{\log^2 k}\big)$ & $\Omega(n)$ & Explicit\tabularnewline \hline Porat-Rothschild \cite{Por11} & Combinatorial & $O(k^{2}\log n)$ & $\Omega(n)$ & Explicit\tabularnewline \hline Cheragchi \cite{Che09} & Combinatorial {\bf (list decoding only)} & $O(k\cdot2^{\log^{3}\log n})$ & ${\rm poly(t)}$ & Explicit\tabularnewline \hline Indyk \emph{et al.}~\cite{Ind10} & Combinatorial & $O(k^{2}\log n)$ & ${\rm poly}(k)t\log^{2}(t)+O(t^{2})$ & Randomized {\footnotesize (Explicit if $k = O\big(\frac{\log n}{\log \log n}\big)$)}\tabularnewline \hline Ngo \emph{et al.}~\cite{Ngo11} & Combinatorial & $O(k^{2}\log n)$ & ${\rm poly(t)}$ & Explicit\tabularnewline \hline Cheraghchi-Ribeiro~\cite{Che19} & Combinatorial & $O(k^{2}\log^2 n)$ & $O(k^3 \log^2 n)$ & Explicit\tabularnewline \hline \hline {\em Lower Bound} \cite{Mal78} & Probabilistic & $\Omega\big( k \log \frac{n}{k} \big)$ & - & -\tabularnewline \hline Various \cite{Cha11,Che11,Mal13,Ald14a,Sca15b,Sca17b,Coj19,Coj19a} & Probabilistic & $O(k \log n)$ & $\Omega(n)$ & Randomized\tabularnewline \hline Mazumdar~\cite{Maz16} & Probabilistic & $O\big(k \frac{\log^2 n}{\log k}\big)$ & $\Omega(n)$ & Explicit\tabularnewline \hline Inan \emph{et al.}~\cite{Ina19} & Probabilistic & $O(k \log n)$ & $\Omega(n)$ & Explicit\tabularnewline \hline GROTESQUE~\cite{Cai13} & Probabilistic & $O(k\cdot\log k\cdot\log n)$ & $O(k\cdot\log k\cdot\log n)$ & Randomized\tabularnewline \hline SAFFRON \cite{Lee15a} & Probabilistic & $O(k\cdot\log k\cdot\log n)$ & $O(k\cdot\log k\cdot\log n)$ & Randomized\tabularnewline \hline SAFFRON \cite{Lee15a} & Probabilistic {\bf (approximate recovery only)} & $O(k \log n)$ & $O(k \log n)$ & Randomized\tabularnewline \hline Inan \emph{et al.}~\cite{Ina19} & Probabilistic & $O\big(k\cdot\log n\cdot\log\frac{\log n}{\log k}\big)$ & $\ensuremath{O\big(k^{3}\cdot\log n\cdot\log\frac{\log n}{\log k}\big)}$ & Explicit\tabularnewline \hline \textbf{This paper} & Probabilistic & \textbf{$O(k\log n)$} & \textbf{$O(k^2 \cdot\log k\cdot\log n)$} & Randomized\footnotemark\tabularnewline \hline \end{tabular} \par\end{center} \caption{{Overview of existing non-adaptive group testing results, with $n$ items, $k$ defectives, and $t$ tests. Two of the works listed above attain a reduced number of tests and/or runtime by considering a less stringent recovery criterion than exact recovery: (i) In \cite{Che09}, a list $\Lc$ of size $O(k)$ is returned, and it is only required that $\Kc \subseteq \Lc$; (ii) In \cite{Lee15a}, a set of size $k$ is returned, but it is only required to contain a fraction $1-\epsilon$ of the defectives for some $\epsilon > 0$, and the scaling laws shown do not apply in the limit as $\epsilon \to 0$.}\label{tbl:summary}} \end{table} {\bf Probabilistic group testing.} In the probabilistic setting, the $\Omega\big( k \log\frac{n}{k}\big)$ lower bound \cite{Mal78} on the number $t$ of tests indicates that the scaling of $t = O(k \log n)$ is optimal whenever $k \le O(n^{1-\epsilon})$ for some constant $\epsilon > 0$. Under a randomized test design and with $\Omega(n)$ decoding time, numerous results attaining asymptotically vanishing error probability with $t = O(k \log n)$ have been obtained \cite{Cha11,Che11,Mal13,Ald14a,Sca15b,Sca17b,Coj19,Coj19a}. In addition, Inan {\em et al.}~\cite{Ina19} attain $t = O(k \log n)$ with $\Omega(n)$ decoding time using an explicit design, improving on an earlier $t = O\big( k \frac{\log^2 n}{\log k} \big)$ bound due to Mazumdar \cite{Maz16}. \footnotetext{{Despite being randomized, we also provide sufficient conditions that hold with high probability, that ensure success, and that can be verified in time $\poly(k \log n)$; see the discussion following Lemma \ref{lem:lcs}.}} The most relevant existing works to this paper are those attaining $\poly(k \log n)$ decoding time in the probabilistic setting, particularly GROTESQUE \cite{Cai13}, SAFFRON \cite{Lee15}, and the study of the Kautz-Singleton construction by Inan {\em et al.}~\cite{Ina19}. GROTESQUE and SAFFRON attain $O(k \cdot \log k \cdot \log n)$ for both the number of tests and runtime using randomized designs, whereas \cite{Ina19} attains $t = O\big(k \cdot \log n \cdot \log \frac{\log n}{\log k}\big)$ with $O\big(k^3 \cdot \log n \cdot \log \frac{\log n}{\log k}\big)$ decoding time using an explicit design. SAFFRON additionally improves the $O(k \cdot \log k \cdot \log n)$ scaling to $O( C(\epsilon) k \log n)$ (for some $C(\epsilon) > 0$) under an approximate recovery criterion that only requires $(1-\epsilon) k$ defectives to be identified. But an inspection of the proof reveals that $C(\epsilon) \to \infty$ as $\epsilon \to 0$, precluding exact recovery with an order-optimal number of tests. We note that if $k = \Theta(n^{\alpha})$ for some constant $\alpha \in (0,1)$ and one merely requires $t = O(k \log n)$ and $\poly(k \log n)$ decoding time, then there exist several algorithms achieving this goal as a result of having $O(n t)$ decoding time \cite{Cha11,Che11,Ald14a,Sca17b}, or $O(k^3 \cdot \log n)$ runtime in the case of \cite{Ina19}. We therefore contend that the regime of primary interest for seeking $\poly(k \log n)$ decoding time is the sparser regime in which $k = o(n^{\alpha})$ for any constant $\alpha > 0$. {\bf Comparison with our results.} As outlined above, our main contribution is to bring the number of tests down to the optimal $t = O(k \log n)$ scaling while maintaining efficient decoding time (namely, $O(k^2 \log k \cdot \log n)$), and imposing no restrictions on $k$. } \subsection{Overview of Existing Group Testing Techniques} \label{sec:techniques} { The above-outlined group testing algorithms with efficient decoding are predominantly either based on {\em code concatenation}, or utilize the idea of {\em encoding item indices} into the test matrix. While these are two fundamentally different techniques, they in fact share a common high-level structure, depicted in Figure \ref{fig:concat_mask}. Initially, a matrix is formed with $n$ rows, denoted by $\cv_1,\dotsc,\cv_n$. The final (transpose of the) test matrix is formed by expanding each entry of each $\cv_i$ to a longer binary sequence: \begin{itemize} \item In the concatenated coding approach, the ``codewords'' $\cv_1,\dotsc,\cv_n$ form a non-binary {\em outer code}, and each codeword symbol is mapped to a block in the final test matrix via an {\em inner code}. For instance, the Kautz-Singleton construction \cite{Kau64} employs a trivial inner code (along with a Reed-Solomon outer code) that maps to a vector with one in a single entry indexing the corresponding non-binary symbol, and zeros elsewhere. \item In the alternative approach that encodes item indices, the entries of $\cv_1,\dotsc,\cv_n$ are binary. Any zero entry is trivially mapped to a block of zeros, whereas the entries equaling one in $\cv_i$ are mapped to a binary vector describing the item's index, $i \in \{1,\dotsc,n\}$. A standard binary description would require exactly $\lceil \log_2 n \rceil$ bits, but a longer length may be used to facilitate fast decoding \cite{Lee15a} and/or improve robustness to noise \cite{Cai13}. \end{itemize} We proceed by discussing each of these in more detail. (In Section \ref{sec:cs}, we also discuss the origins of the latter approach in the context of compressive sensing.) \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{concat_mask} \caption{{High-level illustration of the (transpose of the) group testing matrices formed by code concatenation or techniques that directly encode the items' indices; the details of the two techniques differ, and are given in the text.}} \label{fig:concat_mask} \end{figure} {\bf Code concatenation.} Early uses of concatenated codes in combinatorial group testing incurred $\Omega(n)$ decoding time \cite{Kau64,Por11}. To achieve $\poly(k \log n)$ time decoding, the main idea employed in \cite{Ind10,Ngo11} is {\em list decoding}: An {inner code} of length $O(k \log n)$ is used that in itself would suffice the attain the above-mentioned list decoding criterion, and an {outer code} of rate $O\big( \frac{1}{k} \big)$ is used to efficiently resolve the remaining uncertainty in the list (e.g., a Reed-Solomon code suffices), leading to $O(k^2 \log n)$ tests in total. In addition, \cite{Ngo11} proposed a novel recursive construction that allows the decoder to recover a ${\rm poly}(k)$-size superset of the defective set, after which a standard decoding strategy for disjunct matrices can be used to resolve the remaining uncertainty. The recent work of Inan {\em et al.}~\cite{Ina19} follows the Kautz-Singleton construction \cite{Kau64} (i.e., a Reed-Solomon outer code and trivial inner code), but varies its parameters (e.g., the code length) to better suit the probabilistic group testing setting, as opposed to the combinatorial setting considered in \cite{Kau64}. {\bf Techniques that encode item indices.} Existing group testing techniques that encode the items' indices into the test matrix have focused predominantly on the probabilistic setting, rather than the combinatorial setting.\footnote{An exception is \cite{Che19}, which will briefly be discussed in Section \ref{sec:cs}.} In particular, we highlight the GROTESQUE \cite{Cai13} and SAFFRON \cite{Lee15a} algorithms, both of which use random binary strings $\cv_1,\dotsc,\cv_n$ in Figure \ref{fig:concat_mask} drawn from a suitably-designed distribution. This distribution is chosen such that, with high probability, each defective item $i \in \Kc$ is {\em isolated}: There exists an index $j$ for which the $j$-th entry of $\cv_i$ is $1$, but the $j$-th entry of each string in $\{\cv_{i'}\}_{i' \in \Kc \setminus \{i\}}$ is $0$.\footnote{This discussion is based on the ``singleton-only'' version of SAFFRON. The general version also makes use of blocks with two defectives, which are useful after one of them has already been identified. However, both versions yield the same scaling laws in the number of tests and decoding time.} When this property holds, each test outcome in the corresponding block (see the right of Figure \ref{fig:concat_mask}) is positive if and only if item $i$ is included in the test. The two algorithms primarily differ in (i) how to locate the blocks corresponding to isolated defectives, and (ii) how to decode the defective items' indices: \begin{itemize} \item In SAFFRON, the two are done simultaneously by using blocks of length $2 \lceil\log_2 n\rceil$ to encode each item's index and its complement. Then, it is shown that each block corresponds to an isolated defective if and only if the corresponding outcomes contain exactly $\lceil \log_2 n \rceil$ ones. In addition, when this is the case, the item index can be directly read from the first $\lceil \log_2 n \rceil$ outcomes. \item GROTESQUE uses a procedure termed {\em multiplicity testing}, in which items are randomly tested, and the cases ``no defectives'' vs.~``one defective'' vs.~``two or more defectives'' can be distinguished by simply counting the number of $1$'s in the outcomes. To ensure the reliable recovery of the item's index in the case that the answer is ``one defective'', the index is encoded in each block using an expander code to combat possible noise, though a trivial length-$\lceil \log _2 n\rceil$ code would also suffice in the noiseless setting. \end{itemize} In both algorithms, the vectors $\cv_1,\dotsc,\cv_n$ in Figure \ref{fig:concat_mask} are chosen to have length $O(k \log k)$. Since it is unknown in advance which blocks of tests will correspond to isolated defectives, every block in the final test matrix must incur $O(\log n)$ tests, for a total of $t = O(k \cdot \log k \cdot \log n)$. {\bf Comparison with our techniques.} Our group testing strategy, BMC, is outlined in Section \ref{sec:overview}, but at this point we can already highlight some of the key differences to the techniques described above: \begin{itemize} \item While the strings $\cv_1,\dotsc,\cv_n$ are mutually independent in \cite{Cai13,Lee15a}, this is far from being true in BMC. Instead, we independently generate a {\em much smaller} number of strings, and then let each $\cv_i$ equal one of these strings selected uniformly at random. Hence, there are a large number of {\em repeated strings}; we only seek to ensure that there are no repetitions {\em among the defectives}. \item The first step of our decoding algorithm is to {\em identify the strings associated with defectives}, whereas in \cite{Cai13,Lee15a} the goal is to {\em identify the blocks corresponding to isolated defectives}. These are distinct goals, and are solved using different techniques: In contrast with the above-outlined approaches used by GROTESQUE and SAFFRON, we can achieve our goal by performing a simple one-by-one check on the small set of strings mentioned in the previous dot point. \item We not only seek for each defective item $i \in \Kc$ to have a single isolated index in $\cv_i$, but rather, $O(\log n)$ of them. This may sound like a more restrictive condition that potentially {\em increases} the number of tests, but it is made up for by the following crucial observation: We do {\em not} blow up the number of tests by a factor of $O(\log n)$ in order to ensure $O(\log n)$ ``collision-free'' tests for each defective item. Instead, we treat any collisions as erasures, and control for them using erasure-correcting coding.\footnote{GROTESQUE \cite{Cai13} employs expander codes to combat {\em random noise}, but this is a distinct notion to our idea of using erasure-correction to combat collisions, and the former technique does not transfer readily to the latter.} Hence, instead of seeking $O(\log n)$ specific collision-free tests, we allow the defectives to {\em share the damage of collisions} in a controlled manner. \end{itemize} We also briefly contrast BMC with the list-decoding approach \cite{Deb05,Ngo11}, which first finds a ``small enough'' superset of $\Kc$ (e.g., of size $O(k)$ or $O({\rm poly}(k))$), and uses further tests to resolve the false positives. The first decoding step of BMC finds up to $k$ masking strings, and the union of sets of items associated with those masking strings is a superset of $\Kc$ with high probability. However, the number of items assigned to each masking string is in fact very large, leading to this superset having size $O\big( \frac{n}{k \log k} \big)$. In sparse settings (e.g., $k = O({\rm poly}(\log n))$), this size far exceeds ${\rm poly}(k)$, indicating that BMC is fundamentally different to list decoding.} \subsection{Related Techniques for Compressive Sensing} \label{sec:cs} {While we focused on the most related group testing works when discussing the idea of encoding items' indices into $\Xv$, closely-related techniques appeared prior to those works in the context of {\em compressive sensing} (CS) \cite{Cor06,Gil06,Gil07,Ber08a,Che17,Che19}. In this problem, the goal is to design a (real-valued) measurement matrix $\Xv \in \RR^{t \times n}$ that permits the recovery of $k$-sparse vectors $\beta \in \RR^n$ via linear measurements of the form $\yv = \Xv\beta$ (or similarly with noise added). Group testing can be viewed as a Boolean counterpart to CS \cite{Gil08,Ati12}, but there are also important differences between the two. In particular, in contrast with CS, group testing is inherently non-linear due to the ``OR'' operation. As a result, several decoding techniques used in compressive sensing cannot be used in group testing , notably including the idea of ``subtracting off'' previously-found values in the sparse vector. Due to these differences, CS results often differ significantly from group testing. For instance, it is possible to attain the ``for-all'' guarantee in CS with $t = O(k \log n)$ measurements \cite{Can08}, in stark contrast with the $\Omega\big(\min\big\{k^2 \frac{\log n}{\log k},n\big\}\big)$ lower bound for combinatorial group testing \cite{Dya82}. An early CS work of Cormode and Muthukrishnan \cite{Cor06} followed the structure of Figure \ref{fig:concat_mask}, utilizing a disjunct matrix in the first step. This approach could readily be applied to group testing, but would not be suited to the probabilistic setting, due to the $\Omega\big(\min\big\{k^2 \frac{\log n}{\log k},n\big\}\big)$ number of rows required for a disjunct matrix. The number of tests was subsequently reduced using test designs based on random selection \cite{Gil06,Gil07}, an idea also used the above-outlined group testing works \cite{Cai13,Lee15a}. In fact, the CS designs in \cite{Gil06,Gil07} use more sophisticated random selection techniques based on random binning with variable bin sizes, but these appear to be less suited to group testing due to them strongly exploiting the linearity of the measurements as discussed above. More recent CS works utilized alternative constructions based on expanders and extractors \cite{Ber08a,Che17,Che19}. In addition, \cite{Che19} showed that constructions of this kind can also be applied to combinatorial group testing, though we are not aware of any similar attempts for probabilistic group testing. Despite these advances in the context of compressive sensing, we are not aware of any construction that can be adapted to provide a probabilistic group testing algorithm with $O(k \log n)$ tests and $\poly(k \log n)$ decoding time. Essentially, each of these works appears to exhibit one or both of the following roadblocks: (i) the number of tests is inherently limited to behave as $\Omega(k \cdot \log k \cdot \log n)$ or higher, thus failing to improve on \cite{Cai13,Lee15a}; (ii) the decoding procedure crucially exploits the linearity in the compressive sensing model. Finally, to our knowledge, none of the existing CS works include the unique aspects of BMC highlighted at the end of Section \ref{sec:techniques}, namely, the notion of assigning non-unique strings to indices in $\{1,\dotsc,n\}$, the initial decoding step of identifying strings associated with non-zero entries, or the method of controlling for collisions via erasure-correction coding. } \section{Bit Mixing Coding: Test Design and Decoding} \label{sec:bmc} In this section, we provide the details of BMC, as well as formally stating the guarantees on the number of tests and decoding time. The main subsequent notation is shown in Table \ref{tbl:notation} \begin{table} \centering \caption{Notation used throughout the paper. \label{tbl:notation}} \begin{tabular}{|c|l|} \hline $n$ & Number of items \\ \hline $k$ & Maximum number of defective items (known to the algorithm) \\ \hline $k'$ & Actual number of defective items (not known to the algorithm) \\ \hline $t$ & Total number of tests \\ \hline $\Kc$ & Defective set \\ \hline $\Kchat$ & Estimate of the defective set decoded in the second batch \\ \hline $w$ & Weight of a masking string / block length of a codeword \\ \hline $\sv,\svtil$ & Masking strings \\ \hline $\delta$ & Parameter controlling the error probability \\ \hline $t_1$, $t_2$ & Number of tests in the first and second batches \\ \hline $\Sc$ & Low collision set \\ \hline $\Lc$ & Set of masking strings decoded in first batch \\ \hline $\Cc$ & Codebook (possibly non-binary) with block length $w$ \\ \hline $\Ac$ & Symbol alphabet for the codebook $\Cc$ \\ \hline $\ell$ & Number of bits to represent a symbol in $\Ac$, i.e., $\ell = \log_2|\Ac|$ \\ \hline \end{tabular} \end{table} \subsection{Overview of Bit Mixing Coding} \label{sec:overview} Here we provide a brief overview of our test design and decoding strategy. Given integers $t_1$, $t_2$, and $w$, the testing is done in two batches, described below (we use the terminology {\em batches} instead of {\em stages} to highlight that the testing remains entirely non-adaptive). A rough illustration of these batches is shown in Figure \ref{fig:bmc1}. Subsequently, the function $\log(\cdot)$ has base $e$. In the first batch, each item is assigned a binary string of length $t_1$ and weight $w$, chosen uniformly at random with replacement from a carefully designed set $\Sc \subseteq \{0,1\}^{t_1}$. We refer to these strings as {\em masking strings} (see Section \ref{sec:masking}). The number of strings in $\Sc$ is typically much smaller than the number of items, implying that a given item's string is unlikely to be unique. However, we do seek uniqueness {\em among the defective items}. The testing sub-matrix $\Xv_1 \in \{0,1\}^{t_1 \times n}$ simply arranges the items' strings in columns (or rows in Figure \ref{fig:bmc1}, which shows $\Xv^T$). Given the resulting $t_1$ test outcomes, the decoder searches through the strings in $\Sc$ and seeks to determine which ones were assigned to {\em some} defective item, but without attempting to identify the index of that item. In the second batch, the testing sub-matrix $\Xv_2 \in \{0,1\}^{t_2 \times n}$ has a similar structure to $\Xv_1$, but with each bit replaced by a constant number $\ell$ of bits; hence, $t_2 = \ell t_1$. Any entry that was zero in $\Xv_1$ is simply replaced by a string of $\ell$ zeros. On the other hand, for any given column, each of the $w$ entries equal to one is replaced by the binary description of a symbol from a codeword. Specifically, each item has a {\em unique} codeword of length $w$ on an alphabet $\Ac$ of size $2^{\ell}$, and that codeword is an erasure-coded representation of the item's index. \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{BMC} \caption{Illustration of the BMC-based (transpose of the) group testing matrix. In the first batch, each item is assigned a constant-weight masking string with weight $w = 4$, and in the second batch, the same structure is repeated in length-$\ell$ segments corresponding to symbols on a larger alphabet. {For compactness, we consider only $n = 8$ items and $k = 2$ defectives, and each masking string has length $t_1 = 16$ even though the choice in our mathematical analysis would correspond to $t_1 = 4kw = 32$.} The $k=2$ rows corresponding to defective items are highlighted, and we observe that their masking strings collide in the third segment of length $4$. } \label{fig:bmc1} \end{figure} The idea of the decoding procedure is as follows. Suppose that we have designed $\Sc$ such that with high probability, (i) the first batch of tests allows the decoder to successfully identify which $k$ (or fewer) masking strings were assigned to defective items; and (ii) any one of these strings collides (i.e., overlaps in the indices equaling $1$) with the union of the $k-1$ other strings in at most $\frac{w}{2}$ indices.\footnote{We will introduce these as key properties of {\em low collision sets} in Section \ref{sec:masking}.} These properties ensure that from the second batch of tests, the decoder can perfectly recover the symbols (with values in $\Ac$) corresponding to the $\frac{w}{2}$ (or more) non-colliding locations of $1$'s in each defective item's masking string, while marking the symbols in the other $\frac{w}{2}$ (or fewer) locations as erasures. Any length-$w$ code on $\Ac$ capable of correcting the worst-case erasure of half the codeword symbols can therefore recover this defective item's codeword, and hence also the index of the item. In the following, we focus on the case that $k \to \infty$ as $n \to \infty$. The case $k = O(1)$ is in fact much simpler, but also more convenient to handle separately, so it is deferred to Appendix \ref{sec:fixed_k}. \subsection{Masking Strings and Low Collision Sets} \label{sec:masking} A key technical challenge in our analysis is proving the existence of the set $\Sc \subseteq \{0,1\}^{t_1}$ satisfying the properties overviewed in Section \ref{sec:overview}. We proceed by presenting the relevant definitions and results towards achieving this goal. We begin with the formal definition of a masking string. This definition depends on the maximum number of defectives $k$ and a length parameter $w$, and leads to a number of tests in the first batch given by $t_1 = 4kw$. \begin{defn} \label{def:masking} We say that $\sv \in \{0,1\}^{t_1}$ is a {\em $(k,w)$ masking string} if it is the concatenation of $w$ (typically different) binary substrings of length $4k$, with each substring having a Hamming weight of $1$. \end{defn} We use the simplified terminology {\em masking string} when the parameters $k$ and $w$ are clear from the context. Clearly, any $(k,w)$ masking string has length $t_1 = 4kw$ and weight $w$. Our group testing design will rely crucially on a subset $\Sc$ of masking strings that are sufficiently ``well-separated on average''. Specifically, when we assign masking strings from $\Sc$ to items uniformly at random with replacement, we seek to ensure that (i) upon observing the bitwise ``OR'' of the $k' \le k$ masking strings assigned to defective items, the decoder can identify the corresponding $k'$ (or fewer) individual strings in $\Sc$; and (ii) each of these $k'$ masking strings has at most half of its $1$'s in common with the union of the other $k'-1$. The following definition formally introduces sufficient requirements for this purpose. \begin{defn} \label{def:lcs} A set $\Sc \subseteq \{0,1\}^{t_1}$ of $(k,w)$ masking strings is a {\em $(k,w,\delta)$ low collision set} (LCS) if it satisfies the following property for any given integer $k' \le k$ and any given index $i \in \{1,\dotsc,k'\}$: If we choose $k'$ strings $\svtil_1,\dotsc,\svtil_{k'}$ from $\Sc$ uniformly at random with replacement, then the following conditions hold with probability at least $1-\delta$: \begin{enumerate} \item The multi-set $\Sctil = \{\svtil_1,\ldots, \svtil_{k'}\}$ is such that all $\svtil \in \Sc \setminus \Sctil$ satisfy $\sum_{j=1}^{k'} \svtil^T \svtil_j \le \frac{w}{2}$; \item The multi-set $\Sctil^{(-i)} = \{\svtil_1, \ldots, \svtil_{i-1}, \svtil_{i+1}, \ldots, \svtil_{k'}\}$ is such that $\sum_{1 \le j \le k' \,:\, j \ne i} \svtil_i^T \svtil_j \le \frac{w}{2}$. \end{enumerate} \end{defn} The bulk of our technical analysis is devoted to proving the following lemma, establishing the existence of an LCS with certain requirements on the size $|\Sc|$ and parameters $(k,w,\delta)$. To simplify the analysis, we state the result in an asymptotic form, but non-asymptotic variants can easily be deduced from the proof. In addition, we make no effort to optimize the constant factors, which could also be improved by refining our analysis. \begin{lem} \label{lem:lcs} Consider any sequence of $(k,\delta)$ pairs such that $k \to \infty$, $\delta \to 0$, and $\delta \ge \frac{1}{k^2}$. If $w$ satisfies \begin{equation} w \ge 70\, \log \frac{k}{\delta}, \label{eq:choice_w} \end{equation} then for sufficiently large $k$ there exists a $(k,w,\delta)$ low collision set (LCS) $\Sc$ with cardinality $|\Sc| = \frac{2k}{\delta}$. \end{lem} \begin{proof} See Section \ref{sec:lcs}. \end{proof} While the construction used to prove Lemma \ref{lem:lcs} is randomized, the proof provides sufficient conditions for being an LCS that hold with high probability, {and that can be verified in time $O\big( |\Sc|^2 \cdot w \big)$. We will later set $w = O(\log n)$ and $\delta = \frac{1}{k \log k}$, in which case substituting $|\Sc| = \frac{2k}{\delta}$ gives verification time $O(k^4 (\log k)^4 \log n) = \poly(k \log n)$.} In contrast, given a set $\Sc$ of masking strings, it appears to be difficult to directly verify whether the set is an LCS in an efficient manner. \subsection{Encoding and Decoding: First Batch of Tests} \label{sec:batch1} \begin{algorithm} \caption{\label{alg:masking} Test design (encoding) and masking string identification (decoding) for the first batch of tests. } \small \begin{algorithmic}[1] \Statex \hspace*{-6mm} {\em Global parameters:} Number of items $n$, triplet $(k,w,\delta)$, low collision set $\Sc$ of size $\frac{2k}{\delta}$ \Statex \Statex \hspace*{-6mm} {\em Test design} \State {\bf foreach} $i = 1,\dotsc,n$ {\bf do} \State \hspace*{4mm} Let the $i$-th column of $\Xv_1$ be a uniformly random element from the set $\Sc$ \State {\bf endfor} \Statex \setcounter{ALG@line}{0} \Statex \hspace*{-6mm} {\em Masking string identification} ({\bf input:} A received binary string $\yv_1$ of $4kw$ bits; {\bf output:} A list $\Lc$ of masking strings) \State {\bf foreach} $\sv \in \Sc$ {\bf do} \State \hspace*{4mm} {\bf if} {$\sv^T \yv_1 = w$} {\bf then} include $\sv$ in the output list $\Lc$ \label{line:decision} \State {\bf endfor} \end{algorithmic} \normalsize \end{algorithm} The test design and decoding procedure associated with the first batch of tests are depicted in Algorithm \ref{alg:masking}. The test design simply assigns a masking string to each item uniformly at random from $\Sc$ with replacement, and arranges these in columns to form $\Xv_1$. Given the resulting test outcome vector $\yv_1 \in \{0,1\}^{t_1}$, the decoder constructs a list $\Lc \subseteq \Sc$ of masking strings believed to correspond to defective items by adding only the strings having sufficient overlap with $\yv_1$ in the locations of $1$'s. The following lemma provides a formal statement of successful masking string identification. \begin{lem} \label{lem:batch1} Suppose that there are $k' \le k$ defective items, and their associated masking strings $\{\svtil_1,\dotsc,\svtil_{k'}\}$ satisfy the first condition of Definition \ref{def:lcs}. Then, the test design and masking string identification procedure in Algorithm \ref{alg:masking} lead to an estimate $\Lc$ containing $\{\svtil_1,\dotsc,\svtil_{k'}\}$ and no other elements of $\Sc$. \end{lem} \begin{proof} It is trivial that any masking string $\svtil_i$ assigned to a defective item will be included in $\Lc$: Any index where its masking string is $1$ will lead to a positive test, yielding $\svtil_i^T \yv_1 = w$ since the weight of each masking string is $w$. On the other hand, if $\svtil \in \Sc$ is not assigned to any defective item, then the first property of Definition \ref{def:lcs} ensures that the sum of overlaps between $\svtil$ and the elements of $\{\svtil_1,\dotsc,\svtil_{k'}\}$ is at most $\frac{w}{2}$. Since $\yv_1$ is the bit-wise ``OR'' of $\{\svtil_1,\dotsc,\svtil_{k'}\}$, this implies that $\svtil^T \yv_1 \le \frac{w}{2}$. \end{proof} \subsection{Encoding and Decoding: Second Batch of Tests} \label{sec:batch2} \begin{algorithm} \caption{\label{alg:data} Test design (encoding) and item identification (decoding) for the second batch of tests.} \small \begin{algorithmic}[1] \Statex \hspace*{-6mm} {\em Global parameters:} Number of items $n$, triplet $(k,w,\delta)$, multi-set $\{\sv_1,\dotsc,\sv_n\}$ of masking strings assigned to items in first batch, parameter $\ell$ and alphabet $\Ac$ of size $2^{\ell}$, codebook $\Cc = \{\cv_1,\dotsc,\cv_n\}$ with $n$ codewords in $\Ac^w$. \Statex \Statex \hspace*{-6mm} {\em Test design} \State {\bf foreach} $i = 1,\dotsc,n$ {\bf do} \State \hspace*{4mm} Initialize $\xv$ to be the empty string \State \hspace*{4mm} Let $\sv = (s_1,\dotsc,s_{4kw})$ be the masking string assigned to item $i$ in the first batch \State \hspace*{4mm} {\bf foreach} $j = 1,\dotsc,4kw$ {\bf do} \State \hspace*{4mm} \hspace*{4mm} {\bf if} $s_j = 0$ {\bf then} append $\ell$ zeros to $\xv$ \State \hspace*{4mm} \hspace*{4mm} {\bf else} Append length-$\ell$ binary representation of the next symbol of $\cv_i$ to $\xv$ \State \hspace*{4mm} {\bf endfor} \State \hspace*{4mm} Fill in the $i$-th column of $\Xv_2$ with the entries of $\xv$ \State {\bf endfor} \Statex \setcounter{ALG@line}{0} \Statex \hspace*{-6mm} {\em Item identification} ({\bf input:} Received string $\yv_2$ of length $4kw\ell$, list $\Lc$ of decoded masking strings returned by Algorithm~\ref{alg:masking}; {\bf output:} Estimate $\Kchat$ of the defective set) \State Construct $\yvtil \in \Ac^{4kw}$ by converting $\yv_2 \in \{0,1\}^{4kw\ell}$ from binary to the alphabet $\Ac$ \State {\bf foreach} $\sv \in \Lc$ {\bf do} \State \hspace*{4mm} Initialize $\uv$ to be the empty string \State \hspace*{4mm} {\bf foreach} $i=1,\dotsc,4kw$ {\bf do} \State \hspace*{4mm}\hspace*{4mm} {\bf if} ($s_i = 1$) and (there exists no $\svtil \in \Lc$ such that $\svtil \ne \sv$ and $\stil_i = 1$) {\bf then} \State \hspace*{4mm}\hspace*{4mm}\hspace*{4mm} Append the $i$-th symbol of $\yvtil$ to $\uv$; \State \hspace*{4mm}\hspace*{4mm} {\bf else if} ($s_i = 1$) {\bf then} \State \hspace*{4mm}\hspace*{4mm}\hspace*{4mm} Append the erasure symbol to $\uv$; \State \hspace*{4mm} {\bf endfor} \State \hspace*{4mm} $\Ic \leftarrow $ decoder for $\Cc$ applied to $\uv$ to return an index in $\{1,\dotsc,n\}$ \State \hspace*{4mm} Include $\Ic$ in the output set $\Kchat$ \State {\bf endfor} \end{algorithmic} \normalsize \end{algorithm} The test design and decoding procedure associated with the second batch of tests are depicted in Algorithm \ref{alg:data}. As discussed in Section \ref{sec:overview}, the idea is to copy the structure of $\Xv_1$, but replace each bit by a sequence of $\ell$ bits. Any ``$0$'' bit is trivially mapped to a string of $\ell$ zeros, whereas any ``$1$'' bit is replaced by the binary representation of a codeword symbol. The codeword has length $w$ and alphabet $\Ac$, whose size is $|\Ac| = 2^{\ell}$, and the corresponding codebook $\Cc = \{\cv_1,\dotsc,\cv_n\}$ is chosen to have good worst-case erasure correction guarantees (see Section \ref{sec:erasure}). For item $i$, the codeword $\cv_i$ is used. For item identification, any collisions between masking strings in $\Lc$ (returned from the first batch) are treated as erasures, whereas in the absence of a collision, the corresponding length-$\ell$ binary string from the test outcome vector $\yv_2$ is mapped to a symbol from $\Ac$. For each $\sv \in \Lc$, if there are sufficiently few erasures, then we can recover the corresponding codeword $\cv_i$ via erasure-correcting decoding, and hence identify the defective item index $i \in \{1,\dotsc,n\}$. The following lemma formally states the requirements on $\Cc$, along with sufficient conditions under which the decoding succeeds. \begin{lem} \label{lem:batch2} Suppose that there are $k' \le k$ defective items, and their associated masking strings $\{\svtil_1,\dotsc,\svtil_{k'}\}$ satisfy the second condition of Definition \ref{def:lcs}. If the first batch successfully produces $\Lc = \{\svtil_1,\dotsc,\svtil_{k'}\}$, and the decoder of $\Cc$ is able to correct an arbitrary pattern of $\frac{w}{2}$ erasures, then the test design and item identification procedure in Algorithm \ref{alg:data} lead to successful recovery, i.e., $\Kchat = \Kc$. \end{lem} \begin{proof} The second condition of Definition \ref{def:lcs} implies that $\Lc = \{\svtil_1,\dotsc,\svtil_{k'}\}$ contains no duplicates, and also that for any such $\svtil_i \in \Lc$, at most $\frac{w}{2}$ of the indices of $1$'s collide with those of {\em any} of the other strings in $\Lc$. Hence, when $\svtil_i$ is processed in the outer loop of item identification in Algorithm \ref{alg:data}, we have the following: \begin{itemize} \item Whenever there is a collision, an erasure symbol is added to $\uv$, and this occurs at most $\frac{w}{2}$ times; \item Whenever there is no collision, the correct codeword symbol from $\cv_i$ is added to $\uv$. \end{itemize} Hence, $\uv$ equals the desired length-$w$ codeword $\cv_i$ with at most $\frac{w}{2}$ entries replaced by the erasure symbol, and by our assumption on the decoder of $\Cc$, the correct codeword $\cv_i$ (or equivalently, the correct index $i$) is identified. \end{proof} \subsection{Choice of Erasure-Correcting Code} \label{sec:erasure} The problem of decoding in the presence of worst-case erasures has been extensively studied in coding theory. There are many erasure-correcting codes that we could use in Algorithm \ref{alg:data}, with various trade-offs in the subsequent mathematical analysis and decoding time. For instance: \begin{itemize} \item In a preliminary version of this work \cite{Bon19}, we used Reed-Solomon codes, which have the convenient feature of being maximum Maximum Distance Separable (MDS). However, when applied to group testing, their large alphabet size (i.e., increasing in the block length) leads to an $O(k \cdot \log k \cdot \log\log k)$ term in the number of tests.\footnote{In \cite{Bon19} the logarithmic factors were also not optimized, so the analysis therein actually would actually lead to an $O(k \cdot \log^2 k \cdot \log\log k)$ term.} This suffices for attaining the optimal $t = O(k \log n)$ scaling in sufficiently sparse regimes, but here we prefer to adopt an approach that does so in both sparser and denser regimes. \item In Section \ref{sec:noisy}, we discuss the use of binary codes (i.e., $\Ac = \{0,1\}$), which makes Algorithm \ref{alg:data} conceptually simpler, and can be useful in noisy scenarios. However, this requires several of the constants to be modified to less favorable values throughout the analysis. For instance, the length $t_1 = 4kw$ may be increased to a value such as $10kw$, and the proportion of erasures permitted may decrease from $\frac{1}{2}$ to a smaller value such as $\frac{1}{10}$. \item We ideally seek linear decoding time in the block length, though polynomial decoding time is also acceptable given that the code length is only $w = O(\log n)$. \end{itemize} As a suitable trade-off of these various aspects, we found the following code construction from \cite{Alo96} to be convenient, providing near-MDS erasure correction with a {\em bounded} alphabet size. The code construction is based on expanders. \begin{lem} \label{lem:erasure} {\em \cite[Thm.~1]{Alo96}} For any $r \in (0,1)$ and arbitrarily small $\epsilon > 0$, there exists an alphabet $\Ac$ whose size is a constant depending only on $\epsilon$, and a codebook $\Cc$ (with codeword symbols on $\Ac$) and associated encoder/decoder pair, such that the following properties hold: \begin{itemize} \item $\Cc$ has rate $r$, i.e., the number of codewords is $|\Ac|^{wr}$, where $w$ is the block length; \item The decoder corrects any (worst-case) fraction $1-r-\epsilon$ of erasures; \item The encoding and decoding time are linear in the block length. \end{itemize} \end{lem} In our analysis, we will not require $\epsilon$ to be arbitrarily small, and instead simply take $r = \frac{1}{3}$ and $\epsilon = \frac{1}{6}$, so that a fraction $\frac{1}{2}$ of erasures is tolerated. \subsection{Statement of Main Result} \label{sec:main} We are now ready to state our main theorem. For simplicity, we set the relevant parameters to ensure $\pe \le \frac{1}{\log k}$, but with simple modifications to the constant factors (here and in the auxiliary results), we can improve this to $\pe \le \frac{1}{k^c}$ for any fixed $c > 0$. However, it is worth noting that the decoding time has a $\frac{1}{\pe}$ dependence on $\pe$, which is why we choose a logarithmic dependence on $k$. We also re-iterate that we have made no effort to optimize constant factors, and we recall that despite the assumption $k \to \infty$ here, the case $k = O(1)$ is in fact much simpler, and is handled in Appendix \ref{sec:fixed_k}. \begin{thm} \label{the:main} Under the choices $w = \max\big\{ \frac{3}{\ell} \log_2 n, 70 \log \frac{k}{\delta} \big\}$ and $\delta = \frac{1}{k \log k}$, and a code $\Cc$ chosen suitably according to Lemma \ref{lem:erasure}, the BMC group testing procedure described in Algorithms \ref{alg:masking} and \ref{alg:data} with an LCS constructed according to Lemma \ref{lem:lcs} yields $\pe \le \frac{1}{\log k}$ for any $k \to \infty$, and the resulting number of tests used satisfies \begin{equation} t \le 12 k \max\bigg\{ \frac{\ell+1}{\ell} \log_2 n, ~ 50\, (\ell+1) \log k \bigg\} (1+o(1)), \label{eq:t_final} \end{equation} where $\ell \ge 2$ is a constant (not depending on $n$ or $k$) corresponding to $\log_2|\Ac|$ in Lemma \ref{lem:erasure}. In addition, with probability at least $1 - \frac{1}{\log k}$, the decoding time is $O(k^2 \cdot \log k \cdot \log n)$. \end{thm} \begin{proof} By Lemma \ref{lem:lcs}, there exists an LCS with $\delta = \frac{1}{k \log k}$ as long as $w \ge 70\, \log \frac{k}{\delta}$. The choice of $w$ in the theorem statement ensures that this condition is true. Then, since the high-probability event in Definition \ref{def:lcs} holds with probability at least $1-\delta$ for each defective item $i$, it holds simultaneously for all defective items with probability at least $1-k\delta = 1-\frac{1}{\log k}$. Under this high-probability event, assuming the codebook $\Cc$ in Algorithm \ref{alg:data} corrects $\frac{w}{2}$ worst-case erasures, we deduce from Lemmas \ref{lem:batch1} and \ref{lem:batch2} that the final estimate of the defective set is indeed correct. It remains to choose the parameters to ensure that $w \ge 70\, \log \frac{k}{\delta}$, and to characterize the total number of tests and runtime. Suppose that, as stated following Lemma \ref{lem:erasure}, we use a code of rate $\frac{1}{3}$. Since identifying an item requires $\frac{1}{\ell} \log_2 n$ symbols from $\Ac$ (with alphabet size $2^{\ell}$), a rate-$\frac{1}{3}$ code yields $w = \frac{3}{\ell} \log_2 n$.\footnote{Here and subsequently, we ignore rounding issues, as these do not impact the final result.} This is consistent with the condition $w \ge 70\, \log \frac{k}{\delta}$ whenever $k \le \delta n^{\frac{3}{70 \ell \cdot \log 2}}$. Alternatively, if this condition on $k$ fails to hold, we can simply replace the rate-$\frac{1}{3}$ code by a (potentially much) lower rate code such that $w = 70 \log \frac{k}{\delta}$; by Lemma \ref{lem:erasure}, such a code still exists with the required erasure-correcting properties. Combining these two cases, we obtain \begin{equation} w = \max\bigg\{ \frac{3}{\ell} \log_2 n, 70 \log \frac{k}{\delta} \bigg\}. \end{equation} The number of tests is equal to $t_1 = 4kw$ in the first batch, and $t_2 = 4kw\ell$ in the second batch, yielding a total number of tests equal to \begin{align} t &= 4 kw(\ell + 1) \\ &= 4 k \max\bigg\{ \frac{3(\ell + 1)}{\ell} \log_2 n, 70 (\ell + 1) \log \frac{k}{\delta} \bigg\} \end{align} Substituting $\delta = \frac{1}{k \log k}$, taking a factor of $3$ out the front, and writing $\frac{2 \times 70}{3} \le 50$, we obtain \eqref{eq:t_final}. {\bf Decoding time.} For decoding in Algorithm 1, we need to compute an inner product between $\yv_1$ and every $\sv \in \Sc$. To do so, we use the $w$ positions of the ``1'' bits in $\sv$ to index the required entries of $\yv_1$. This leads to $O(w) = O( \log n )$ complexity for each $\sv$, or $O(|\Sc| \cdot \log n) = O(k^2 \cdot \log k \cdot \log n)$ for all $\sv \in \Sc$ (since $|\Sc| = \frac{2k}{\delta}$). The decoding in Algorithm 2 has a total of $|\Lc|$ iterations. In each iteration, it constructs a sequence $\uv$ while incurring $O(w|\Lc|) = O(|\Lc| \log n)$ complexity,\footnote{The loop from $i=1,\dotsc,4kw$ need not be done explicitly; instead, this can be thought of as a loop over $w$ locations of $1$'s.} and then invokes decoding on $\uv$, whose time is linear in the length $w = O(\log n)$ (see Lemma \ref{lem:erasure}). Hence, the total decoding time for Algorithm 2 is $O( |\Lc|^2 \log n )$. By Lemma \ref{lem:batch1} and our choice of $\delta$, we know that with probability at least $1-\frac{1}{\log k}$, we have $|\Lc|\le k$. It is then easy to see that the decoding time is dominated by Algorithm \ref{alg:masking}, and the overall complexity is $O(k^2 \cdot \log k \cdot \log n)$. \end{proof} \subsection{Limitations of BMC} \label{sec:limitations} {The most immediate limitation of BMC is that it has a higher decoding time than certain existing algorithms (notably including GROTEQUE \cite{Cai13} and SAFFRON \cite{Lee15a}) by a factor of $k$. Hence, it remains an open problem as to whether one can further reduce the decoding time while still maintaining $t = O(k \log n)$. Another important limitation is the dependence on the error probability. We focused on the goal of attaining asymptotically vanishing error probability, and accordingly only targeted $\pe \le \frac{1}{\log k}$ in our main result with $k \to \infty$. However, in finite-size systems, the speed of convergence to zero can be important, and faster convergence such as $\pe \le k^{-\tau}$ (with $\tau > 0$) is preferable. While our algorithm and analysis can be adapted to achieve this stricter requirement, the decoding time increases to $k^{2+\tau} \log n$. In contrast, SAFFRON and GROTESQUE can attain $\pe \le k^{-\tau}$ while only affecting the constant factors in the runtime. Finally, we re-iterate that the constants factors in Theorem \ref{the:main} are fairly high, since our focus in this paper is on the scaling laws. } \section{Proof of Lemma \ref{lem:lcs} (Finding a Low Collision Set)} \label{sec:lcs} Algorithm \ref{alg:masking} takes as input an LCS, whose properties play a crucial role in proving our main result, Theorem \ref{the:main}. In this section, we prove the existence of an LCS under suitable parameters, as stated in Lemma \ref{lem:lcs}. Specifically, we show that if we construct a multi-set in a certain randomized way, then with probability close to $1$, this multi-set will satisfy some {\em sufficient conditions} for being an LCS. In addition, these sufficient conditions will be verifiable in polynomial time, which is beneficial from a practical point of view. We emphasize that the LCS is constructed ``offline'' prior to forming the test matrix, and needs to be done only once. \subsection{A Random Construction} \label{sec:construct} We will analyze a randomized construction of masking strings (see Definition \ref{def:masking}). To construct a {\em single} masking string of length $t_1 = 4kw$, for each $4k$-bit segment of the string, we set a uniformly random bit in the segment to be ``1'' and all remaining bits to be ``0''. To construct a multi-set $\Sc$ containing $|\Sc| = \frac{2k}{\delta}$ random masking strings, we simply repeat this procedure independently $\frac{2k}{\delta}$ times. This means that $\Sc$ may contain duplicates; however, we will later prove that with high probability, there are no duplicates, so that $\Sc$ is a set. \subsection{Overview of the Proof} We will show that with probability approaching one (as $k \to \infty$), the multi-set returned by the above construction is an LCS. Despite the simplicity of the construction, the reasoning is rather complex because there are two sources of randomness involved: The construction is random, while the definition of LCS (Definition~\ref{def:lcs}) also involves its own randomness in the form of random selections from $\Sc$. To decouple these two forms of randomness, we will introduce the concept of a {\em promising set} (see Section~\ref{sec:promisingset}). In contrast with LCS, the definition of a promising set does not contain any probability terms. In addition, we will be able to verify deterministically in polynomial time whether a set is a promising set or not {(see Section \ref{sec:promisingset} for details)}, whereas it is unclear how to check (in polynomial time) whether a set is an LCS. We will then prove the following: (i) With probability approaching one, the multi-set returned by the random construction in Section~\ref{sec:construct} is a promising set (see Lemma~\ref{lem:promisingexist} below); (ii) A promising set must be an LCS (see Lemma~\ref{lem:promising2low} below) --- namely, being a promising set is a {\em sufficient condition} for being an LCS. We will prove these claims for $w \ge 70\, \log \frac{k}{\delta}$, $k \to \infty$, $\delta \to 0$, and $\delta \ge \frac{1}{k^2}$, as stated in Lemma \ref{lem:lcs}. In fact, the latter condition can be improved to $\delta \ge \frac{1}{k^c}$ for any constant $c > 0$, by suitably adjusting certain other constants. In addition to the assumption $w \ge 70\, \log\frac{k}{\delta}$, we can further restrict our attention to $w = C\, \log\frac{k}{\delta}$ for some constant $C = \Theta(1)$ with $C \ge 70$. Once this is established, we can easily get an LCS for larger $w$ values (e.g., $C \to \infty$ as $k \to \infty$) by repeating each masking string; this is formally stated as follows. \begin{lem} \label{lem:extend} Given any $(k, w, \delta)$ low collision set $\Sc$ and any positive integer $c$, we can construct a $(k, cw, \delta)$ low collision set $\Sc^c$. \end{lem} \begin{proof} For compactness, throughout this proof we use the terminology that a $(k,w)$ masking string $\svtil$ is {\em $w$-compatible} with a multi-set $\{\sv_1,\dotsc,\sv_m\}$ if $\sum_{i=1}^m \svtil^T \sv_i \le \frac{w}{2}$. Let $\Sc^c = \{\sv^c \,\,|\,\, \sv\in \Sc \}$, where $\sv^c$ denotes the concatenation of $c$ copies of $\sv$. For all $\sv$ and $\svtil$, we trivially have $(\sv^c)^T \svtil^c = c\times (\sv^T \svtil )$. Fix an integer $m$ and a multi-set $\{\svtil^c_1, \ldots, \svtil^c_m\} \subseteq \Sc^c$. It is easy to verify that: (i) $\Sctil^c = \{\svtil_1^c, \ldots, \svtil_m^c\}$ is $(cw)$-compatible with all $\sv^c \in \Sc^c\setminus \Sctil^c$ if and only if $\Sctil = \{\svtil_1, \ldots, \svtil_m\}$ is $w$-compatible with all $\sv \in \Sc\setminus \Sctil$, and (ii) for all $i=1,\dotsc,m$, $(\Sctil^{(-i)})^c = \{\svtil_1^c, \ldots, \svtil_{i-1}^c, \svtil_{i+1}^c, \ldots, \svtil_m^c\}$ is $(cw)$-compatible with $\svtil_i^c$ if and only if $\Sctil^{(-i)} = \{\svtil_1, \ldots, \svtil_{i-1}, \svtil_{i+1}, \ldots, \svtil_m\}$ is $w$-compatible with $\svtil_i$. From Definition \ref{def:lcs}, we deduce that since $\Sc$ is a $(k,w,\delta)$ LCS, $\Sc^c$ is a $(k,cw,\delta)$ LCS. \end{proof} Hence, we proceed by assuming that $w = C\, \log\frac{k}{\delta}$ with $C = \Theta(1)$ and $C \ge 70$. In particular, we will use the fact that $\frac{w}{k} \to 0$, obtained by combining this assumption with $k \to \infty$ and $\delta \ge \frac{1}{k^2}$. \subsection{The Concept of a Promising Set} \label{sec:promisingset} Given a set $\Sc$ of masking strings and any $\svtil\in \Sc$, we define \begin{equation} \mu(\svtil, \Sc) = \frac{1}{|\Sc|-1} \sum_{\sv\in \Sc \setminus \{\svtil\}} \svtil^T \sv. \label{eq:def_mu} \end{equation} In the following, we define the concept of a {\em promising set}, which will provide a stepping stone to establishing the existence of an LCS. \begin{defn} \label{def:promising} A set $\Sc$ of $(k,w)$ masking strings is a {\em $(k,w,\delta)$ promising set} if the following equations hold for all $\svtil \in \Sc$: \begin{align} \label{eqn:proof1} \Big|\mu(\svtil,\Sc) - \frac{w}{4k}\Big| &\le \frac{0.04w}{4k} \\ \label{eqn:proof2} \max_{\sv \in \Sc \setminus \{\svtil\}} |\svtil^T\sv - \mu(\svtil,\Sc)| &\le 6.1 \\ \label{eqn:proof3} \sum_{\sv \in \Sc \setminus \{\svtil\}} (\svtil^T\sv - \mu(\svtil,\Sc))^2 &\le (|\Sc|-1) \frac{w}{2k}. \end{align} \end{defn} To gain some intuition behind this definition, note that $\mu(\svtil,\Sc)$ is the average number of collisions between $\svtil$ and other masking strings in $\Sc$. Hence, \eqref{eqn:proof1} requires the average to be close to $\frac{w}{4k}$. Similarly, \eqref{eqn:proof2} requires the maximum number of collisions to be close to this average, and \eqref{eqn:proof3} bounds the ``variance'' of the number of collisions between $\svtil$ and other masking strings in $\Sc$. The values on the right-hand side of the three equations are carefully chosen such that (i) the random construction in Section \ref{sec:construct} returns a promising set with high probability, and (ii) a promising set must be an LCS. {As we stated previously, the conditions in Definition \ref{def:promising} can be verified in a computationally efficient manner. Computing the inner product between two masking strings can be done in $O(w)$ time, since each has only $w$ non-zero entries. Then, each mean value $\mu(\svtil, \Sc)$ (for $\sv \in \Sc$) can be computed in time $O(|\Sc| \cdot w)$, for a total of $O(|\Sc|^2 \cdot w)$ time. Finally, once all such values have been computed, conditions \eqref{eqn:proof1}--\eqref{eqn:proof3} can similarly be directly checked for all $\svtil \in \Sc$ in time $O(|\Sc|^2 \cdot w)$.} \subsection{Probability of Being a Promising Set} \label{sec:claim1} The following lemma proves that the random construction in Section~\ref{sec:construct} yields a promising set with high probability. \begin{lem} \label{lem:promisingexist} Consider any sequence of triplets $(k,w,\delta)$ such that $k \to \infty$, $\delta \to 0$, $\delta \ge \frac{1}{k^2}$, and $w = C \log\frac{k}{\delta}$ with $C = \Theta(1)$ and $C \ge 70$. For sufficiently large $k$, with probability\footnote{The probability is with respect to the randomness in the construction in Section \ref{sec:construct}.} approaching one as $k \to \infty$ the multi-set $\Sc$ is a $(k, w, \delta)$ promising set of size $\frac{2k}{\delta}$. \end{lem} \begin{proof} Let $\Sc = \{\sv_1, \sv_2, \ldots, \sv_{\frac{2k}{\delta}}\}$ be the multi-set constructed in Section~\ref{sec:construct}. With a slight abuse of notation, for any $i$, we define $\mu(\sv_i, \Sc) = \frac{1}{|\Sc|-1}\sum_{j\,:\,j\ne i} \sv_i^T \sv_j$. We will prove that, with probability approaching one, the following conditions hold simultaneously for all $i$: \begin{align} \label{eqn:proof4} \Big|\mu(\sv_i, \Sc) - \frac{w}{4k}\Big| &\le \frac{0.04w}{4k} \\ \label{eqn:substitute} \max_{j \,:\, j\ne i} \Big|\sv_i^T \sv_j - \frac{w}{4k}\Big| &\le 6.05 \\ \label{eqn:substitute2} \sum_{j\,:\,j\ne i}\Big(\sv_i^T \sv_j-\frac{w}{4k}\Big)^2 &\le (|\Sc|-1) \frac{w}{2k}. \end{align} Note that \eqref{eqn:substitute} implies that $\Sc$ is a set (i.e., there are no duplicates): If there existed $i$ and $j$ such that $i\ne j$ and $\sv_i = \sv_j$, then we would have $\max_{j \,:\, j\ne i} |\sv_i^T \sv_j - \frac{w}{4k}| = w - \frac{w}{4k} = w(1+o(1))$, violating \eqref{eqn:substitute}. Given that $\Sc$ is a set, \eqref{eqn:proof4} becomes equivalent to \eqref{eqn:proof1}. Then, combining \eqref{eqn:proof4} and \eqref{eqn:substitute} leads to \eqref{eqn:proof2}, since \begin{align} \max_{\sv\in \Sc \setminus \{\svtil\}} |\svtil^T\sv - \mu(\svtil,\Sc)| &= \max_{j\,:\,j\ne i} |\sv_i^T \sv_j - \mu(\sv_i,\Sc)| \\ &\le \Big|\mu(\sv_i, \Sc) - \frac{w}{4k}\Big| + \max_{j\,:\,j\ne i} \Big|\sv_i^T \sv_j - \frac{w}{4k}\Big| \\ & \le \frac{0.04w}{4k} + 6.05 \\ &\le 6.1, \label{eq:final6} \end{align} where \eqref{eq:final6} holds for sufficiently large $k$ since $\frac{w}{k} \to 0$. Finally, using the standard fact that an expectation $\EE[(Z - a)^2]$ is always smallest when $a = \EE[Z]$, and noting that $\mu(\sv_i,\Sc)$ is the average of the $\sv_i^T \sv_j$ values for $j \ne i$, we deduce that $\sum_{j\,:\,j\ne i}(\sv_i^T \sv_j -\mu(\sv_i, \Sc))^2 \le \sum_{j\,:\,j\ne i}(\sv_i^T \sv_j-a)^2$ for any $a \in \RR$. Taking $a = \frac{w}{4k}$, we find that \eqref{eqn:substitute2} implies \eqref{eqn:proof3}. To complete the proof, we show that \eqref{eqn:proof4}, \eqref{eqn:substitute}, and \eqref{eqn:substitute2} each hold (simultaneously for all $i$) with probability approaching one as $k \to \infty$. A trivial union bound then shows that the three hold simultaneously with probability approaching one. For \eqref{eqn:proof4}, consider any fixed $i$ and fixed $\sv_i$, and view the remaining masking strings in $\Sc$ as random variables (according to the randomness in the construction). The quantity $\sum_{j\,:\,j\ne i} \sv_i^T \sv_j$ follows a binomial distribution with parameters $(|\Sc|-1)w$ and $\frac{1}{4k}$. By the Chernoff bound (see Appendix \ref{sec:conc}), we have \begin{align} \PP\bigg[\Big|\mu(\sv_i, \Sc) - \frac{w}{4k}\Big| \ge \frac{0.04w}{4k}\bigg] &= \PP\bigg[\Big|\sum_{j\,:\,j\ne i} \sv_i^T \sv_j - (|\Sc|-1)\frac{w}{4k}\Big| \ge (|\Sc|-1)\frac{0.04w}{4k}\bigg] \label{eq:cond1_1} \\ &\le 2 \exp\bigg(-\frac{1}{3} \cdot (0.04^2) \cdot (|\Sc|-1)\frac{w}{4k}\bigg) \\ &\le 2 \exp\bigg(- \frac{70\cdot(0.04^2)}{12 \delta} \log\frac{k}{\delta}\bigg) \label{eq:cond1_2} \\ &= \Big(\frac{\delta}{k}\Big)^{\omega(1)}, \label{eq:cond1_3} \end{align} where \eqref{eq:cond1_2} uses $|\Sc|-1 = \frac{2k}{\delta} - 1 \ge \frac{k}{\delta}$ and $w \ge 70 \log \frac{k}{\delta}$, and \eqref{eq:cond1_3} uses $\delta \to 0$. By a union bound across all $\frac{2k}{\delta}$ values of $i$, we deduce that \eqref{eqn:proof4} holds with probability approaching one. For \eqref{eqn:substitute}, first observe that trivially $\sv_i^T \sv_j \ge \frac{w}{4k} - 6.05$ for sufficiently large $k$, since $\frac{w}{k} \to 0$ and $\sv_i^T \sv_j \ge 0$. To establish the other direction $\sv_i^T \sv_j \le \frac{w}{4k} + 6.05$, consider any fixed $i$ and fixed $\sv_i$, and view $\sv_j$ as a random variable. The quantity $\sv_i^T \sv_j$ follows a binomial distribution with parameters $w$ and $\frac{1}{4k}$, so its mean is $\frac{w}{4k}$. By the Chernoff bound (see Appendix \ref{sec:conc}), we have for any $\eta > 0$ that \begin{align} \PP\Big[\sv_i^T \sv_j \ge \frac{w}{4k} (1+\eta)\Big] &\le \exp\bigg( - \frac{w}{4k} \big( (1+\eta) \log(1+\eta) - \eta \big) \bigg). \label{eqn:proof7} \end{align} Recalling that $w = C\log\frac{k}{\delta}$ with $C = \Theta(1)$, we set $\eta = \frac{24.2}{C}\cdot \frac{k}{\log \frac{k}{\delta}}$, so that the event in the probability \eqref{eqn:proof7} is indeed the complement of the event $\sv_i^T \sv_j < \frac{w}{4k} + 6.05$. This choice satisfies $\eta \to \infty$, and hence $ (1+\eta) \log(1+\eta) - \eta = (\eta \log \eta)(1+o(1))$. Also noting that $\log \eta = (\log k)(1+o(1))$, we find that \eqref{eqn:proof7} simplifies to \begin{align} \PP\Big[\sv_i^T \sv_j \ge \frac{w}{4k} (1+\eta)\Big] &\le \exp\bigg( - \frac{C \log \frac{k}{\delta}}{4k} \cdot \frac{24.2}{C}\cdot \frac{k}{\log \frac{k}{\delta}} \cdot (\log k)(1+o(1)) \bigg) \\ &= \exp\Big( - \big( 6.05 \log k \big) (1+o(1)) \Big) \\ &= k^{-6.05(1+o(1))}. \label{eq:cond2_end} \end{align} There are a total of ${|\Sc| \choose 2} \le (\frac{2k}{\delta})^2$ possible combinations of $i$ and $j$, which we can further upper bound by $4k^6$ since $\delta \ge \frac{1}{k^2}$. Taking a union bound over all such combinations, we deduce that \eqref{eqn:substitute} holds for all $i$ with probability approaching one. Finally, for \eqref{eqn:substitute2}, consider any fixed $i$ and $\sv_i$, and view the remaining masking strings in $\Sc$ as random variables. Under the given $i$ and $\sv_i$, define the random variable $Z_j= \frac{(\sv_i^T \sv_j-\frac{w}{4k})^2}{(6.05^2)}$ for $j\ne i$. The quantity $\sv_i^T \sv_j$ is a binomial random variable with parameters $w$ and $\frac{1}{4k}$, and hence \begin{align} \EE[Z_j] &= \frac{\EE[(\sv_i^T \sv_j-\frac{w}{4k})^2]}{(6.05^2)} = \frac{\mbox{Var}[\sv_i^T \sv_j]}{(6.05^2)} = \frac{w\cdot \frac{1}{4k} \cdot (1-\frac{1}{4k})}{(6.05^2)}, \end{align} which implies \begin{equation} \EE\Big[\sum_{j\,:\,j\ne i}Z_j\Big] \le \frac{w(1-\frac{1}{4k})}{4k} \cdot \frac{|\Sc|-1}{(6.05^2)}. \label{eq:mean_sum_Z} \end{equation} By \eqref{eq:cond2_end} and the union bound, we know that with probability at least $1-k^{-3.05(1+o(1))}$, it holds that $|\sv_i^T \sv_j -\frac{w}{4k}|< 6.05$ for all $j \ne i$, and hence $Z_j \le 1$. It will be useful to condition on the corresponding event $\Bc = \bigcap_{j\,:\,j \ne i} \{Z_j \le 1\}$. Since $\{Z_j\}$ are independent random variables, they remain independent after this conditioning. {In addition, \eqref{eq:mean_sum_Z} implies that \begin{equation} \EE\Big[\sum_{j\,:\,j\ne i}Z_j \,\Big|\, \Bc\Big] \le \frac{w(1-\frac{1}{4k})}{4k} \cdot \frac{|\Sc|-1}{(6.05^2)}, \label{eq:mean_sum_Z2} \end{equation} since the conditioning on $\Bc$ does not increase the average (we are conditioning on each $Z_j$ taking smaller values compared to its full range).} Conditioned on $\Bc$, we invoke the Chernoff bound (see Appendix \ref{sec:conc}) and get \begin{align} &\PP\Big[\sum_{j\,:\,j\ne i}\Big(\sv_i^T \sv_j-\frac{w}{4k}\Big)^2 \ge (|\Sc|-1) \frac{w}{2k} \,\Big|\, \Bc \Big] \\ &\qquad= \PP\Big[\sum_{j\,:\,j\ne i} Z_j \ge \frac{|\Sc|-1}{(6.05^2)} \frac{w}{2k} \,\Big|\, \Bc \Big] \\ &\qquad\le \exp\Big(-\frac{1}{3} \frac{|\Sc|-1}{(6.05^2)} \frac{w(1-\frac{1}{4k})}{4k}\Big) \label{eq:cond3_6} \\ &\qquad\le \exp\Big(-\frac{70}{3 (6.05^2)} \cdot \frac{k(1-\frac{1}{4k})\log \frac{k}{\delta}}{4k\delta} \Big) \label{eq:cond3_7} \\ &\qquad= \Big(\frac{\delta}{k}\Big)^{\omega(1)}, \label{eq:cond3_8} \end{align} where the application of the Chernoff bound in \eqref{eq:cond3_6} also uses \eqref{eq:mean_sum_Z2}, \eqref{eq:cond3_7} uses $|\Sc| -1 = \frac{2k}{\delta} - 1 \ge \frac{k}{\delta}$ and $w \ge 70 \log\frac{k}{\delta}$, and \eqref{eq:cond3_8} uses $\delta = o(1)$. Using $\PP[\Bc] \ge 1-k^{-3.05(1+o(1))}$ and taking a union bound across all values of $i$, we deduce that \eqref{eqn:substitute2} holds with probability approaching one. \end{proof} \subsection{A Promising Set Must Be an LCS} \label{sec:claim2} The following lemma establishes that any promising set is an LCS. \begin{lem} \label{lem:promising2low} Consider any sequence of triplets $(k,w,\delta)$ such that $k \to \infty$, $\delta \to 0$, $\delta \ge \frac{1}{k^2}$, and $w \ge 70 \log\frac{k}{\delta}$. For sufficiently large $k$, a $(k, w, \delta)$ promising set $\Sc$ of size $\frac{2k}{\delta}$ must be a $(k, w, \delta)$ LCS. \end{lem} \begin{proof} In accordance with Definition \ref{def:lcs}, fix $k' \le k$, and select $k'$ strings $\svtil_1,\dotsc,\svtil_{k'}$ from $\Sc$ uniformly at random with replacement to form the multi-set $\Sctil = \{\svtil_1, \ldots, \svtil_{k'}\}$. Note that here $\Sc$ is already fixed --- only $\svtil_1,\dotsc,\svtil_{k'}$ are random variables. We first prove that $\Sc$ satisfies the first requirement of LCS. Specifically, we will show that with probability at least $1-\frac{\delta}{4}$, we have $\sum_{i=1}^{k'} \svtil^T \svtil_i \le \frac{w}{2}$ for all $\svtil\in \Sc \setminus \Sctil$. We consider a binary matrix whose $|\Sc|^{k'}$ columns correspond to all the possible $\Sctil$, and whose $|\Sc|$ rows correspond to all the possible $\svtil\in \Sc$. We say that a matrix entry corresponding to a given $\Sctil$ and $\svtil$ is {\em bad} if $\sum_{i=1}^{k'} \svtil^T \svtil_i > \frac{w}{2}$ and $\svtil\in \Sc \setminus \Sctil$. To prove the desired claim, it suffices to show that at least $|\Sc|^{k'}\times (1-\frac{\delta}{4})$ columns contain no bad entries. Directly proving this appears to be challenging, so we instead prove that for each row, at most a $\frac{\delta}{4|\Sc|}$ fraction of the entries are bad. This will then imply that the total number of bad entries in the matrix is at most $|\Sc|^{k'} \times |\Sc| \times \frac{\delta}{4|\Sc|} = |\Sc|^{k'} \times \frac{\delta}{4}$, and hence there can be at most $|\Sc|^{k'} \times \frac{\delta}{4}$ columns containing bad entries. To prove that each row has at most $\frac{\delta}{4 |\Sc|}$ fraction of its entries being bad, it suffices to prove that for any given $\svtil$, when we choose $\svtil_1$ through $\svtil_{k'}$ from $\Sc\setminus \{\svtil\}$ uniformly at random with replacement, we have \begin{align} \label{eqn:proof8} \PP\Big[\sum_{i=1}^{k'} \svtil^T \svtil_i \ge \frac{w}{2}\Big] &\le \frac{\delta}{4|\Sc|}. \end{align} To prove \eqref{eqn:proof8}, define $Z_i= \svtil^T \svtil_i-\mu(\svtil,\Sc)$ for $i=1,\dotsc,k'$, where $\mu(\svtil,\Sc)$ is defined in \eqref{eq:def_mu}. Hence, we have $\EE[Z_i]=0$. (Note, however, that $\svtil^T \svtil_i$ does {\em not} follow a binomial distribution.) Since $\Sc$ is a promising set, \eqref{eqn:proof1} yields \begin{equation} \sum_{i=1}^{k'}\svtil^T \svtil_i = \sum_{i=1}^{k'}(Z_i+\mu(\svtil,\Sc)) = k'\cdot \mu(\svtil,\Sc) + \sum_{i=1}^{k'} Z_i \le \frac{1.04w}{4} + \sum_{i=1}^{k'} Z_i. \label{eq:sum_mean} \end{equation} In addition, for all $i=1,\dotsc,k'$, \eqref{eqn:proof2} and \eqref{eqn:proof3} tell us that $|Z_i| \le 6.1$ and $\EE[Z_i^2] \le \frac{w}{2k}$. Hence, by Bernstein's inequality (see Appendix \ref{sec:conc}), we have \begin{align} \PP\Big[\sum_{i=1}^{k'} Z_i>\frac{0.96w}{4}\Big] &\le \exp\bigg(-\frac{\frac{(0.96w)^2}{16}}{2k' \cdot \frac{w}{2k} + \frac{2}{3} \cdot 6.1 \cdot \frac{0.96w}{4}}\bigg) \label{eq:pro1_2} \\ &\le \exp\Big(-\frac{\frac{0.96^2}{16}w}{1 + \frac{2}{3} \cdot 6.1 \cdot \frac{0.96}{4}}\Big) \label{eq:pro1_3} \\ &\le \exp\Big(-\frac{w}{35} \Big) \label{eq:pro1_4} \\ &\le \Big(\frac{\delta}{k}\Big)^{2} \label{eq:pro1_5} \\ &\le \frac{\delta}{4|\Sc|}, \label{eq:pro1_6} \end{align} where \eqref{eq:pro1_3} uses $k' \le k$, \eqref{eq:pro1_4} uses a numerical calculation, \eqref{eq:pro1_5} uses $w \ge 70 \log \frac{k}{\delta}$, and \eqref{eq:pro1_6} holds since $|\Sc| = \frac{2k}{\delta}$ and $k \to \infty$. In turn, for any given $\svtil\in \Sc$, \eqref{eqn:proof8} follows since \begin{equation} \PP\bigg[\sum_{i=1}^{k'} \svtil^T \svtil_i \ge \frac{w}{2}\bigg] \le \PP\bigg[\sum_{i=1}^{k'} Z_i>\frac{0.96w}{4}\bigg] \le \frac{\delta}{4|\Sc|}, \end{equation} where the first inequality uses \eqref{eq:sum_mean}. Next, we prove that $\Sc$ satisfies the second requirement for an LCS. Specifically, we show that for any given $i \in \{1,\dotsc,k'\}$, with probability at least $1-0.6\, \delta$, the multi-set $\{\svtil_1, \ldots, \svtil_{i-1}, \svtil_{i+1}, \ldots, \svtil_{k'}\}$ and $\svtil_i$ satisfy $\sum_{j \,:\, j \ne i} \svtil_i^T \svtil_j \le \frac{w}{2}$. We clearly only need to prove this for $k' \ge 2$. In addition, since all the $\svtil_i$'s are generated in a symmetric manner, we can assume without loss of generality that $i = k'$. Define $\Sctil^{(-k')} = \{\svtil_1, \svtil_2, \ldots, \svtil_{k'-1}\}$. We claim that with probability at least $1-0.5\delta$, $\svtil_{k'}\notin \Sctil^{(-k')}$. To see this, note that $\svtil_1,\dotsc,\svtil_{k'-1}$ correspond to at most $k'-1$ distinct elements form $\Sc$, and hence $\PP[\svtil_{k'}\in \Sctil^{(-k')}] \le \frac{k-1}{|\Sc|} \le 0.5\delta$. Conditioned on $\svtil_{k'}\notin \Sctil^{(-k')}$, each $\svtil_j$ for $1\le j\le k'-1$ is a uniformly random string in $\Sc\setminus \{\svtil_{k'}\}$. As a result, one can apply the same analysis as that for \eqref{eqn:proof8} (after replacing $k'$ by $k'-1$), and deduce that \begin{equation} \PP\bigg[\sum_{j=1}^{k'-1} (\svtil_{k'}^T \svtil_j) \ge \frac{w}{2}\bigg] \le \frac{\delta}{4|\Sc|} = o(\delta), \end{equation} where we used the fact that $|\Sc| = \frac{2k}{\delta} \to \infty$. Hence, we know that with probability at least $(1-0.5\delta)\cdot (1-o(\delta)) \ge 1-0.6\delta$ (for sufficiently large $k$), the multi-set $\Sctil^{(-k')}$ and $\svtil_{k'}$ satisfy $\sum_{1 \le j \le k'-1} \svtil_{k'}^T \svtil_j \le \frac{w}{2}$. Finally, a union bound over the two requirements shows that the requirements hold simultaneously with probability at least $1-\delta$, meaning that $\Sc$ is an LCS. \end{proof} \section{Extension to the Noisy Setting} \label{sec:noisy} While the noiseless group testing model is in itself of significant interest, there is also substantial motivation to develop algorithms with low decoding time in the presence of noise. For combinatorial group testing, it is common to assume a bounded number of {\em worst case} errors (e.g., see \cite{Che09}), whereas for probabilistic group testing, it is more common to assume that tests are subject to {\em random} noise (e.g., see \cite{Cai13,Lee15a,Ina19}). We focus on the latter, and then briefly discuss the former. Specifically, we outline a natural extension of BMC (i.e., Algorithms \ref{alg:masking} and \ref{alg:data}) and Theorem \ref{the:main} to the noisy setting. Generalizing \eqref{eq:gt_noiseless_model}, we consider the following widely-adopted symmetric noise model: \begin{equation} Y = \bigg( \bigvee_{j \in \Kc} X_j \bigg) \oplus Z, \label{eq:gt_symm_model} \end{equation} where $Z \sim \Bernoulli(\xi)$ for some constant $\xi \in \big[0,\frac{1}{2}\big)$, and $\oplus$ denotes modulo-2 addition. We assume that the noise is independent between tests, i.e., we have i.i.d.~bit flips. In Sections \ref{sec:bmc} and \ref{sec:lcs}, we used masking strings with length $t_1 = 4kw$, and showed that this leads to at most $\frac{w}{2}$ collisions in each defective item's masking string, with high probability. In the following, we make use of the following more general statement: For masking strings of length $t_1 = c_1kw$ constructed by concatenating $w$ unit-weight substrings of length $c_1 k$ for some constant $c_1 \ge 4$, we have \begin{equation} t_1 = c_1 k w \implies \text{At most }\frac{2w}{c_1}\text{ collisions} \label{eq:c1} \end{equation} in each defective item's masking string, with high probability. This follows from straightforward modifications of our previous analysis, including its associated constant factors. {For the first batch of tests, we can modify the decision step (Line \ref{line:decision} of the second part of Algorithm \ref{alg:masking}) to the following for improved robustness: \begin{equation} \text{if $\sv^T\yv_1 \ge \frac{3w}{4}$ then include $\sv$ in the output list $\Lc$.} \label{eq:thresh} \end{equation}} As seen in the proof of Lemma \ref{lem:batch1} the values of $\sv^T\yv_1$ that we obtain in the absence of noise are exactly $w$ for masking strings of defective items, and at most $\frac{w}{2}$ for the other masking strings. Hence, as long as fewer than $\frac{w}{4}$ bit flips occur in the entries of $\yv_1$ corresponding to ones in $\svtil$, the correct decision is still made. Under the above model of i.i.d.~bit flips, we can simply use the Chernoff bound for an i.i.d.~sum of $w$ random variables (see Appendix \ref{sec:conc}), and deduce that if $\xi < \frac{1}{4}$, then the mis-classification event resulting from Algorithm \ref{alg:masking} has probability $O(n^{-c})$, where $c$ can be set to an arbitrary value by choosing the implied constant in $w = \Theta(\log n)$ large enough. Choosing $c$ large enough, the error probability remains small even after a union bound over the $\frac{2k}{\delta}$ masking strings. In the case that $\xi \in \big[\frac{1}{4},\frac{1}{2}\big)$, we can increase the value of $c_1 \ge 4$ and use \eqref{eq:c1}, so that $\svtil^T \yv_1$ reduces from $\frac{w}{2}$ to $\frac{2w}{c_1}$ (or less) for masking strings not assigned to defective items. Upon changing the threshold from $\frac{3w}{4}$ to $\frac{1}{2}\big( \frac{2w}{c_1} + w \big)$ in \eqref{eq:thresh}, the preceding argument generalizes easily to this case, permitting any noise level $\xi \in \big [0,\frac{1}{2}\big)$ as long as $c_1$ is large enough. For the second batch of tests, when noise is present, we can no longer assume that the symbols at any non-collided locations are received perfectly. However, since this part is based on erasure-correcting coding, we can easily generalize to {\em erasure and error correcting coding} to achieve tolerance to noise. In the presence of noise, the use of non-binary codes with symbols mapped directly to $\ell > 1$ bits (see Algorithm \ref{alg:data}) may not be ideal, since even a single flip among these $\ell$ bits will cause the symbol to be changed. We therefore favor the use of a binary code $\Cc$ in the noisy setting, along with a suitable modification of the constants. In this case, we again use the more general statement in \eqref{eq:c1} with $c_1 \ge 4$, ensuring at most $\frac{2w}{c_1}$ erasures with high probability. While a code with minimum distance exceeding $\frac{2w}{c_1}$ would suffice for correcting these erasures alone, here we further increase the target minimum distance beyond $\frac{2w}{c_1}$ in order to account for the bit flips. To give a specific example of a binary code with good distance properties, we note that \cite{Gur05} provides a code with linear encoding/decoding time achieving the Blokh-Zyablov bound \cite[Fig.~1]{Dum98}, with example rate/distance pairs $(R,d_{\min})$ satisfying (i) $R > \frac{1}{5}$ and $d_{\min} > \frac{w}{10}$; (ii) $R > 0.04$ and $d_{\min} > \frac{w}{4}$. In particular, the rate of the code remains positive as long as $\frac{d_{\min}}{w}$ is a constant strictly less than $\frac{1}{2}$. To simplify the discussion, suppose that we naively replace all erasures by arbitrary bit values ($0$ or $1$), so that we only have bit flips; this allows us to use the fact that the codes from \cite{Gur05} that permit efficiently decoding any number of worst-case bit flips less than half the minimum distance. Since the bit flips are i.i.d., we can characterize the number of flips using a concentration argument: With a low enough code rate to make the code length long enough (i.e., a large enough implied constant in $w = O(\log n)$), the number of bit flips is at most $(\xi + \eta) w$ with probability $O(n^{-c})$ for any target $c > 0$, where $\eta > 0$ is any (small) constant. With at most $(\xi + \eta) w$ bit flips coming from the noise, and at most $\frac{2w}{c_1}$ bit flips coming from the collisions in the first batch, we find that the errors can be corrected as long as $\big( \xi + \eta + \frac{2}{c_1} \big) w < \frac{d_{\min}}{2}$. Since $d_{\min}$ can be arbitrarily close to $\frac{w}{2}$, this condition can always be satisfied for sufficiently large $c_1$ and a sufficiently low code rate as long as $\xi < \frac{1}{4}$. In addition, the case $\xi \in \big[ \frac{1}{4}, \frac{1}{2}\big)$ can be handled similarly as long as one has access to an efficiently decodable constant-rate code that can simultaneously correct $\frac{2w}{c_1}$ worst-case erasures and probability-$\xi$ i.i.d.~bit flips; the condition $\xi < \frac{1}{4}$ above only arose due to using a worst-case error correcting code to correct i.i.d.~bit flips. In summary, under i.i.d.~noise of the form \eqref{eq:gt_symm_model}, by modifying only the constant factors and the code $\Cc$ used, we can achieve the same scaling laws as Theorem \ref{the:main} in terms of both tests and runtime (at least when $\xi < \frac{1}{4}$). To avoid repetition with the noiseless case, we omit a formal statement and derivation of this fact. Finally, we briefly mention that BMC only has limited robustness to {\em adversarial} bit flips, since $O(w) = O(\log n)$ worst-case flips suffice to cause incorrect decisions from either the first or second batch of tests. \section{Conclusion} \label{sec:conclusion} We have introduced a novel scheme for sublinear-time non-adaptive group testing, and established that it attains asymptotically vanishing error probability with $t = O(k \log n)$ tests and $O(k^2 \cdot \log k \cdot \log n)$ runtime. Our algorithm and analysis use coding-based subroutines that permit straightforward extensions to the noisy setting. An important remaining open problem is whether the runtime can further be reduced to $k \cdot \poly(\log n)$, or better yet, to $O(k \log n)$, while still attaining $t = O(k \log n)$. In addition, since we did not attempt to optimize constant factors, it is also of interest to sharpen the analysis (and/or modify the algorithm itself) to attain constant factors competitive with those of slower decoding techniques \cite[Ch.~2]{Ald19}. \appendices \section{Concentration Inequalities} \label{sec:conc} Throughout the paper, we make use of several standard concentration bounds for sums of independent random variables, e.g., see \cite[Sec.~4.1]{Mot10} and \cite[Ch.~2]{Bou13}. For clarity, in this section we summarize the specific bounds used. Letting $Z_1,\dotsc,Z_n$ be a sequence of independent and identically distributed random variables, we have the following: \begin{itemize} \item (Chernoff bound) Suppose that $Z_i \in [0,1]$ almost surely, and $\EE[Z_i] = \mu$. Then, for any $\alpha > 0$, we have \begin{equation} \PP\bigg[ \sum_{i=1}^n Z_i \ge (1+\alpha)n \mu \bigg] \le \exp\Big( -\mu n \big( (1+\alpha)\log(1+\alpha) - \alpha \big) \Big), \label{eq:strong_chernoff_1} \end{equation} and for any $\alpha \in (0,1]$, we have \begin{equation} \PP\bigg[ \sum_{i=1}^n Z_i \le (1-\alpha)n \mu \bigg] \le \exp\Big( -\mu n \big( (1-\alpha)\log(1-\alpha) + \alpha \big) \Big). \end{equation} \item (Weakened Chernoff bound) Suppose that $Z_i \in [0,1]$ almost surely, and $\EE[Z_i] = \mu$. Then, {for any $\alpha \in (0,1]$, we have \begin{gather} \PP\bigg[ \sum_{i=1}^n Z_i \ge (1+\alpha)n \mu \bigg] \le \exp\Big( -\frac{1}{3} \alpha^2 \mu n \Big), \label{eq:weak_chernoff_1} \\ \PP\bigg[ \sum_{i=1}^n Z_i \le (1-\alpha)n \mu \bigg] \le \exp\Big( -\frac{1}{3} \alpha^2 \mu n \Big). \end{gather}} \item (Bernstein's inequality) Suppose that $|Z_i| \le M$ almost surely, and that $\EE[Z_i] = 0$ and $\EE[Z_i^2] \le V$. Then, for any $\delta > 0$, we have \begin{equation} \PP\bigg[ \sum_{i=1}^n Z_i \ge t \bigg] \le \exp\bigg( - \frac{t^2}{ 2\big( n V + \frac{1}{3} M t \big) } \bigg). \end{equation} \end{itemize} \section{The Very Sparse Regime $k = O(1)$} \label{sec:fixed_k} In our main result (Theorem \ref{the:main}), we assumed that $k \to \infty$ as $n \to \infty$. Here we describe how to use BMC to attain $\pe \to 0$ as $n \to \infty$ in the case that $k = O(1)$, while using $t = O(\log n)$ tests and $O((\log n)^2)$ decoding time. We again use Definition \ref{def:masking}, letting each masking string contain $w = \log n$ segments of length $4k$ and weight one, so that the total length is $t_1 = 4 k \log n$. Similarly to Section \ref{sec:masking}, we consider the random construction of a multi-set $\Sc$ of such masking strings, with each non-zero entry of each length-$4k$ segment being independently chosen uniformly at random. We let the size of this multi-set be $|\Sc| = \log n$. For two such random masking strings $\sv$ and $\sv'$, the average number of collisions (i.e., $1$'s in common) follows a binomial distribution with parameters $\log n$ and $\frac{1}{4k}$, so the mean is $\frac{\log n}{4 k}$. Hence, by the Chernoff bound (see Appendix \ref{sec:conc}), the probability of the number of collisions exceeding $\frac{\log n}{2k}$ is $O(n^{-c})$ for some $c > 0$ (here $c$ depends on $k$, but is still $\Omega(1)$ since $k = O(1)$). By a union bound over $O( \log^2 n )$ pairs, we deduce that the probability of {\em any} two $\sv,\sv' \in \Sc$ having more than $\frac{\log n}{2k}$ collisions tends to zero as $n \to \infty$. We henceforth condition on the (high-probability) complement of this event. Due to this conditioning, we find that {\em any} $\sv \in \Sc$ collides with {\em any} subset $\Sctil \subseteq \Sc \setminus \{\sv\}$ of cardinality $k$ (or less) in at most $k \times \frac{\log n}{2k} = \frac{1}{2} \log n = \frac{w}{2}$ positions. Hence, the two conditions in Definition \ref{def:lcs} hold for {\em any} $k' \le k$ distinct strings $\svtil_1,\dotsc,\svtil_{k'}$ from $\Sc$. As a result, when we assign strings from $\Sc$ to the $n$ items uniformly at random with replacement, the only case that causes excessive collisions is that in which two defective items are assigned the same masking string. Since $|\Sc| = \log n$ and $k = O(1)$, this occurs with probability $O\big( \frac{1}{\log n} \big)$. Given $\Sc$ satisfying the preceding properties, the proof of Theorem \ref{the:main} goes through essentially unchanged with $w = O(\log n)$. The number of tests is $O(w) = O(\log n)$, and the decoding time is dominated by the $O(|\Sc| \cdot \log n) = O((\log n)^2)$ term in the first batch. \section*{Acknowledgment} We thank Rui Zhang for helpful discussions, Sidharth Jaggi for helpful comments regarding the sublinear-time group testing literature, and Mahdi Cheragchi for helpful suggestions regarding efficient erasure-correcting codes. This work is partly supported by the research grant MOE2017-T2-2-031 from Singapore Ministry of Education Academic Research Fund Tier-2. Binbin Chen is supported by the National Research Foundation, Prime Minister's Office, Singapore, partly under the Energy Programme administrated by the Energy Market Authority (EP Award No. NRF2017EWT-EP003-047) and partly under the Campus for Research Excellence and Technological Enterprise (CREATE) programme. Jonathan Scarlett is supported by an NUS Early Career Research Award. \bibliographystyle{IEEEtran}
{'timestamp': '2020-01-27T02:04:07', 'yymm': '1904', 'arxiv_id': '1904.10102', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10102'}
arxiv
\section{Introduction} Independent component analysis (ICA) aims at estimating unknown \textit{sources} that have been mixed together into an \textit{observation}. The usual assumptions are that the sources are statistically independent and no more than one is Gaussian \cite{jutten2003advances}. The now-cemented metaphor is one of a cocktail party problem: several people (sources) are speaking simultaneously and their speech has been mixed together in a recording (observation). The task is to unmix the recording such that all dialogues can be listened to clearly. In linear ICA, we have a data matrix $S$ whose rows are drawn from statistically independent distributions, a mixing matrix A, and an observation matrix $X$: $$X = AS$$ \noindent and we want to find an unmixing matrix $U$ of $A$ that recovers the sources up to a permutation and scaling: $$ Y = UX $$ The general non-linear ICA problem is ill-posed \cite{hyvarinen1999nonlinear, darmois1953analyse} as there is an infinite number of solutions if the space of mixing functions is unconstrained. However, post-linear \cite{taleb1999source} (PNL) ICA is solvable. This is a particular case of non-linear ICA where the observations take the form $$X = f(AS)$$ \noindent where $f$ operates componentwise, i.e. $X_{i, t} = f_i \left( \sum_n^N A_{i, n}S_{n, t}\right) $. The problem is solved efficiently if $f$ is at least approximately invertible \cite{ziehe2003blind} and there are approaches to optimize the problem for non-invertible $f$ as well \cite{ilin2004post}. For signals with time-structure, however, the problem is not ill-posed even though it is for i.i.d. samples \cite{blaschke2007independent, sprekeler2014extension}. To frame ICA as an optimization problem, we must find a way to measure the statistical independence of the output components and minimize this quantity. There are two main ways to approach this: either minimize the mutual information between the sources \cite{amari1996new, bell1995non, cardoso1997infomax}, or maximize the sources' non-Gaussianity \cite{hyvarinen2000independent, blaschke2004cubica}. There has been a recent interest in combining deep learning with the principles of ICA, usually in an adversarial framework, for example Deep InfoMax (DIM) \cite{hjelm2018learning}, Graph Deep InfoMax \cite{velivckovic2018deep} and Generative adversarial networks \cite{goodfellow2014generative}, which utilize the work of Brakel et al. \cite{brakel2017learning}. Our work is distinct from theirs as we do not rely on adversarial training. \section{Method} We train an encoder $E$ to generate an output $\left(z_1, z_2, \dots, z_M\right)$ such that any one of the output components is statistically independent of the union of the others, i.e. $P(z_i, \boldsymbol{z_{-i}}) = P(z_i)P(\boldsymbol{z_{-i}})$, where $$\boldsymbol{z_{-i}} := \left(z_1, \dots, z_{i-1}, z_{i+1}, \dots, z_M\right)$$ The statistical independence of $z_i$ and $\boldsymbol{z_{-i}}$ can be maximized by minimizing their mutual information \begin{equation} \label{mi_definition} I\left(Z_i; \boldsymbol{Z_{-i}} \right) = \int_{z} \int_{\boldsymbol{z_{-i}}} p(z_i, \boldsymbol{z_{-i}}) \log \left( \frac{p(z_i, \boldsymbol{z_{-i}})}{p(z_i)p(\boldsymbol{z_{-i}})} \right) dz_i d\boldsymbol{z_{-i}} \end{equation} This quantity is hard to estimate, particularly for high-dimensional data. We therefore estimate the lower bound of Eq.\ (\ref{mi_definition}) using a mutual information neural estimation (MINE) network $M$ \cite{belghazi2018mine}: \begin{equation} \label{mine_objective} I\left(Z_i; \boldsymbol{Z_{-i}} \right) \geq L_i = \mathbb{E}_{\mathbb{J}} \left[M \left( z_i, \boldsymbol{z_{-i}} \right) \right] - \log \left( \mathbb{E}_{\mathbb{M}} \left[ e^{M \left( z_i, \boldsymbol{z_{-i}} \right) } \right] \right) \end{equation} \noindent where $\mathbb{J}$ indicates that the expected value is taken over the joint and similarly $\mathbb{M}$ for the product of marginals. The networks $E$ and $M$ are parameterized by $\theta_E$ and $\theta_M$. The encoder takes the observations as input and the MINE network takes the output of the encoder as an input. The E network minimizes $L := \sum_i L_i$ in order for the outputs to have low mutual information and therefore be statistically independent. In order to get a faithful estimation of the lower bound of the mutual information, the M network maximizes $L$. Thus, in a push-pull fashion the system as a whole converges to independent output components of the encoder network E. In practice, rather than training the E and M networks simultaneously it proved useful to train M from scratch for a few iterations after each iteration of training E, since the loss functions of E and M are at odds with each other. When the encoder is trained, the MINE network's parameters are frozen and \textit{vice versa.} \begin{figure}[h!] \centering \captionsetup{width=.8\linewidth} \resizebox*{0.99 \textwidth}{!}{\includegraphics {info_test.pdf}} \caption{The system learns statistically independent outputs by alternate optimization of an encoder E and a MINE network M parameterized by $\theta_E$ and $\theta_M$. The MINE objective (Eq.\ \ref{mine_objective}) is minimized with respect to $\theta_E$ for weight updates of the encoder but it is \textit{maximized} with respect to $\theta_M$ for weight updates of the MINE network.} \label{our_method} \end{figure} \section{Results} We validate the method\footnote{Full code for the results is available at \url{github.com/wiskott-lab/gradient-based-ica/blob/master/bss3.ipynb}} for linear noisy ICA example \cite{sklearn}. Three independent, noisy sources --- sine wave, square wave and sawtooth signal (Fig.\ \ref{sources}) --- are mixed linearly (Fig.\ \ref{mixed}): $$ Y = \begin{bmatrix} 1 & 1 & 1 \\ 0.5 & 2 & 1\\ 1.5 & 1 & 2 \end{bmatrix} S$$ \\ The encoder is a single layer neural network with linear activation with a differentiable whitening layer \cite{schuler2018gradient} before the output. The whitening layer is a key component for performing successful blind source separation for our method. Statistically independent random variables are necessarily uncorrelated, so whitening the output by construction beforehand simplifies the optimization problem significantly. The MINE network M is a seven-layer neural network. Each layer but the last one has 64 units with a rectified linear activation function. Each training epoch of the encoder is followed by seven training epochs of M. Estimating the exact mutual information is not essential, so few iterations suffice for a good gradient direction. Since the MINE network is applied to each component individually, to estimate mutual information (Eq.\ \ref{mine_objective}), we need to pass each sample through the MINE network $N$ times --- once for each component. Equivalently, one could conceptualize this as having $N$ copies of the MINE network and feeding the samples to it in parallel, with different components singled out. Thus, for sample $(z_1, z_2, \dots, z_N)$ we feed in $(z_i ; z_{-i})$, for each $i$. Both networks are optimized using Nesterov momentum ADAM \cite{dozat2016incorporating} with a learning rate of $0.005$. For this simple example, our method (Fig.\ \ref{ours_bss}) is equivalently good at unmixing the signals as FastICA (Fig.\ \ref{fastica_bss}), albeit slower. Note that, in general, the sources can only be recovered up to permutation and scaling. \begin{figure} \centering \captionsetup{width=.88\linewidth} \begin{subfigure}[b]{.45\linewidth} \includegraphics[width=\linewidth]{source.png} \caption{The original sources.}\label{sources} \end{subfigure} \begin{subfigure}[b]{.45\linewidth} \includegraphics[width=\linewidth]{obs.png} \caption{Linear mixture of sources.}\label{mixed} \end{subfigure} \begin{subfigure}[b]{.45\linewidth} \includegraphics[width=\linewidth]{step2000.png} \caption{Sources recovered by our method.}\label{ours_bss} \end{subfigure} \begin{subfigure}[b]{.45\linewidth} \includegraphics[width=\linewidth]{ica.png} \caption{Sources recovered by FastICA.}\label{fastica_bss} \end{subfigure} \caption{Three independent, noisy sources (a) are mixed linearly (b). Our method recovers them (c) to the same extent as FastICA (d).} \label{fig:animals} \end{figure} \section{Summary} We've introduced a proof-of-concept implementation for training a differentiable function for performing ICA. The method consists of alternating the optimization of an encoder and a neural mutual-information neural estimation (MINE) network. The mutual information estimate between each encoder output and the union of the others is minimized with respect to the encoder's parameters. Although this work is in a very preliminary stage, further investigation into the method is warranted. The general nonlinear ICA problem is ill-posed, but it is an interesting question whether this method can work for non-linear problems with low complexity. We can constrain the expresiveness of our encoder by limiting for example the number of layers or number of hidden units in the neural network, thus constraining the solution space of the method. The method is also trivially extended for over- or undercomplete ICA by changing the number of output units. Higher dimensional and real-world data can also be tested. As this method can be used for general neural network training, it should be investigated whether useful representations can be learned while solving the ICA task. This method blends nicely into deep learning architectures and the MINE loss term can be added as a regularizer to other loss functions. We imagine that this can be helpful for methods such as deep sparse coding to enforce independence between features and disentangle factors of variation.
{'timestamp': '2019-04-23T02:25:55', 'yymm': '1904', 'arxiv_id': '1904.09858', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09858'}
arxiv
\section{Appendix A} In this Appendix, we give some bounds that are used in the paper \begin{lemma}\label{Markov} {\bf Markov's Bound}. Let $X\ge 0$ be a random variable with finite expected value $\mu=\E[X]$. Then for any real numbers $\kappa,K > 0$, \begin{eqnarray} \Pr(X\ge \kappa)\leq {\frac {\E[X]}{\kappa}}.\label{Markov1}\\ \Pr(X\ge K\E[X])\leq {\frac {1}{K}}.\label{Markov2} \end{eqnarray} \end{lemma} \begin{lemma}\label{Chebyshev} {\bf Chebyshev's Bound}. Let $X$ be a random variable with finite expected value $\mu=\E[X]$ and finite non-zero variance $\Var[X]=\E[X^2]-\E[X]^2$. Then for any real numbers $\kappa,K > 0$, \begin{eqnarray} \Pr(|X-\mu |\geq \kappa\sqrt{\Var[X]} )\leq {\frac {1}{\kappa^{2}}}.\label{Chebyshev1}\\ \Pr(|X-\mu |\geq K)\leq {\frac {\Var[X]}{K^{2}}}.\label{Chebyshev2} \end{eqnarray} \end{lemma} \begin{lemma}\label{Chernoff}{\bf Chernoff's Bound}. Let $X_1,\ldots, X_m$ are independent random variables taking values in $\{0, 1\}$. Let $X=\sum_{i=1}^mX_i$ denote their sum and let $\mu = \E[X]$ denote the sum's expected value. Then \begin{eqnarray}\Pr[X>(1+\lambda)\mu]\le \left(\frac{e^{\lambda}}{(1+\lambda)^{(1+\lambda)}}\right)^{\mu}\le e^{-\frac{\lambda^2\mu}{2+\lambda}}\le \begin{cases} e^{-\frac{\lambda^2\mu}{3}} &\mbox{if\ } 0< \lambda\le 1 \\ e^{-\frac{\lambda \mu}{3}} & \mbox{if\ } \lambda>1 \end{cases} .\label{Chernoff1} \end{eqnarray} For $0\le \lambda\le 1$ we have \begin{eqnarray} \Pr[X<(1-\lambda)\mu]\le \left(\frac{e^{-\lambda}}{(1-\lambda)^{(1-\lambda)}}\right)^{\mu}\le e^{-\frac{\lambda^2\mu}{2}}.\label{Chernoff2} \end{eqnarray} \end{lemma} \begin{lemma}\label{Hoeffding}{\bf Hoeffding's Bound}. Let $X_1,\ldots, X_m$ are independent random variables taking values in $\{0, 1\}$. Let $X=\sum_{i=1}^mX_i$ denote their sum and let $\mu = \E[X]$ denote the sum's expected value. Then for $0\le \lambda\le 1$ we have \begin{eqnarray}\Pr[X>\mu+\lambda m]\le e^{-{2\lambda^2m}} \end{eqnarray} and \begin{eqnarray} \Pr[X<\mu-\lambda m]\le e^{-{2\lambda^2m}} \end{eqnarray} \end{lemma} \section{Inroduction} Property testing of Boolean function was first considered in the seminal works of Blum, Luby and Rubinfeld~\cite{BlumLR93} and Rubinfeld and Sudan~\cite{RubinfeldS96} and has recently become a very active research area. See for example,~\cite{AlonKKLR05,BaleshzarMPR16,BelovsB16,BhattacharyyaKSSZ10,BlaisBM11,BlaisK12,Bshouty19,ChakrabartyS13,ChakrabartyS16a,ChakrabortyGM11,ChenDST15,ChenST14,ChenWX17,ChenWX17b,DiakonikolasLMORSW07,FischerKRSS02, GoldreichGLRS00,GopalanOSSW11,KhotMS15,KhotS16,MatulefORS10,MatulefORS09,ParnasRS02,Saglam18} and other works referenced in the surveys~\cite{GoldreichSurvey10,Ron08,Ron09}. A Boolean function $f:\{0,1\}^n\to \{0,1\}$ is said to be $k$-junta if it depends on at most $k$ coordinates. The class $k$-Junta is the class of all $k$-juntas. The class $k$-Junta has been of particular interest to the computational learning theory community~\cite{Blum03,BlumL97,BshoutyC18,Damaschke00,GuijarroTT98,LiptonMMV05,MosselOS04}. A problem closely related to learning $k$-Junta is the problem of learning and testing subclasses $C$ of $k$-Junta and classes $C$ of Boolean functions that can be approximated by $k$-juntas~\cite{BlaisK12,BlumL97,DiakonikolasLMSW11,ChakrabortyGM11,DiakonikolasLMORSW07,GoldreichGR98,GopalanOSSW11,ParnasRS02}: Given black-box query access to a Boolean function $f$. In learning, for $f\in C$, we need to learn, with high probability, a hypothesis $h$ that is $\epsilon$-close to $f$. In testing, for any Boolean function $f$, we need to distinguish, with high probability, the case that $f$ is in $C$ versus the case that $f$ is $\epsilon$-far from every function in $C$. In the {\it uniform-distribution property testing} (and learning) the distance between Boolean functions is measured with respect to the uniform distribution. In the {\it distribution-free property testing},~\cite{GoldreichGR98}, (and learning~\cite{Valiant84}) the distance between Boolean functions is measured with respect to an arbitrary and unknown distribution~${\cal D}$ over $\{0,1\}^n$. In the distribution-free model, the testing (and learning) algorithm is allowed (in addition to making black-box queries) to draw random $x\in\{0,1\}^n$ according to the distribution~${\cal D}$. This model is studied in~\cite{Bshouty19,ChenX16,DolevR11,GlasnerS09,HalevyK07,LiuCSSX18}. \subsection{Results} We give improved and almost optimal testers for several classes of Boolean functions on $n$ inputs that have concise representation in the uniform and distribution-free models. The classes studied here are $k$-Junta, $k$-Linear Functions, $k$-Term, $s$-Term DNF, $s$-Term Monotone DNF, $s$-Term Monotone $r$-DNF, $r$-DNF, Decision List, Length-$k$ Decision List, $r$-Decision List, size-$s$ Decision Tree, size-$s$ Branching Programs, size-$s$ Boolean Formula, size-$s$-Boolean Circuit, $s$-Sparse Polynomials over the binary field, $s$-Sparse Polynomials of Degree $d$ and functions with Fourier Degree at most $d$. In Table~\ref{TABLE}, we list all the previous results and our results in this paper. In the table, $\tilde O(T)$ stands for $O(T\cdot poly(\log T))$, $U$ and $D$ stand for uniform and distribution-free model, and Exp and Poly stand for exponential and polynomial time. It follows from the lower bounds of Saglam,~\cite{Saglam18}, that our query complexity is almost optimal (with log-factor) for the classes $k$-Junta, $k$-Linear, $k$-Term, $s$-Term DNF, $s$-Term Monotone DNF, $r$-DNF ($r$ constant), Decision List, $r$-Decision List ($r$ constant), size-$s$ Decision Tree, size-$s$ Branching Programs and size-$s$ Boolean Formula. For more details on the previous results and the results in this paper see Table~\ref{TABLE} and Sections~\ref{result1}, \ref{result2} and~\ref{result3}. \begin{figure}[h!] \begin{center} \begin{tabular}{|c|c|c|c|c|} \hline {\bf Class of Functions}& {\bf Model} & {\bf $\#$Queries} & {\bf Time}&{\bf Reference}\\ \hline \hline $s$-Term Monotone DNF & U & $\tilde O(s^2/\epsilon)$ &Poly. &\cite{ParnasRS02}\\ \cline{2-5} $s$-Term Unate DNF & U & $\tilde O(s/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} & U & $\tilde O(s/\epsilon)$ &Poly. &This Paper\\ \hline $s$-Term Monotone $r$-DNF & U & $\tilde O(s/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} $s$-Term Unate $r$-DNF & U & $\tilde O(s/\epsilon)$ &Poly. &This Paper\\ \cline{2-5} & D & $\tilde O(s^2r/\epsilon)$ &Poly. &This Paper\\ \hline $s$-Term DNF & U & $\tilde O(s^2/\epsilon)$ &Exp. &\cite{DiakonikolasLMORSW07}\\ \cline{2-5} & U & $\tilde O(s/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} & U & $\tilde O(s/\epsilon)$ &Exp. &This Paper\\ \hline $r$-DNF (Constant $r$)& U & $\tilde O(1/\epsilon)$ &Poly. &This Paper\\ \hline Decision List & U & $\tilde O(1/\epsilon^2)$ &Poly. &\cite{DiakonikolasLMORSW07}\\ \cline{2-5} & U & $\tilde O(1/\epsilon)$ &Poly. &This Paper\\ \hline Length-$k$ Decision List & D & $\tilde O(k^2/\epsilon)$ &Poly. &This Paper\\ \hline $r$-DL (Constant $r$)& U & $\tilde O(1/\epsilon)$ &Poly. &This Paper\\ \hline $k$-Linear & U & $\tilde O(k/\epsilon)$ &Poly. &\cite{Blais09,BlumLR93}\\ \cline{2-5} & D & $\tilde O(k/\epsilon)$ &Poly. &This Paper\\ \hline $k$-Term & U & $ O(1/\epsilon)$ &Poly. &\cite{ParnasRS02}\\ \cline{2-5} & U & $\tilde O(1/\epsilon)$ &Poly. &This Paper\\ \cline{2-5} & D & $\tilde O(k/\epsilon)$ &Poly. &This Paper\\ \hline size-$s$ Decision Trees and& U & $\tilde O(s/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} size-$s$ Branching Programs & U & $\tilde O(s/\epsilon)$ &Exp. &This Paper\\ \cline{2-5} & D & $\tilde O(s^2/\epsilon)$ &Exp. &This Paper\\ \hline size-$s$ Boolean Formulas &U &$\tilde O(s/\epsilon^2)$ &Exp.&\cite{ChakrabortyGM11}\\ \cline{2-5} & U & $\tilde O(s/\epsilon)$ &Exp. &This Paper\\ \hline size-$s$ Boolean Circuit & U & $\tilde O(s^2/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} & U & $\tilde O(s^2/\epsilon)$ &Exp. &This Paper\\ \hline Functions with & U & $\tilde O(2^{2d}/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} Fourier Degree $\le d$&D & $\tilde O(2^d/\epsilon+2^{2d})$ &Poly. &This Paper\\ \hline $s$-Sparse Polynomial & U & $poly(s/\epsilon)+\tilde O(2^{2d})$ &Poly. &\cite{AlonKKLR03,DiakonikolasLMSW11}\\ \cline{2-5} over $F_2$ of Degree $d$ & U & $\tilde O(s^2/\epsilon+2^{2d})$ &Poly. &This Paper+\cite{AlonKKLR03}\\ \cline{2-5} &U & $\tilde O(s/\epsilon+s2^d)$ &Poly. &This Paper\\ \cline{2-5} &D & $\tilde O(s^2/\epsilon+s2^d)$ &Poly. &This Paper\\ \hline $s$-Sparse Polynomial & U & $\tilde O(s/\epsilon^2)$ &Exp. &\cite{ChakrabortyGM11}\\ \cline{2-5} over $F_2$&U & $Poly(s/\epsilon)$ &Poly. &\cite{DiakonikolasLMSW11}\\ \cline{2-5} &U & $\tilde O(s^2/\epsilon)$ &Poly. &This Paper\\ \hline \end{tabular} \end{center} \caption{A table of the results. In the table, $\tilde O(T)$ stands for $O(T\cdot poly(\log T))$, $U$ and $D$ stand for uniform and distribution-free model, and Exp and Poly stand for exponential and polynomial time.} \label{TABLE} \end{figure} \subsection{Notations} \color{black} In this subsection, we give some notations that we use throughout the paper. Denote $[n]=\{1,2,\ldots,n\}$. For $S\subseteq [n]$ and $x=(x_1,\ldots,x_n)$ we denote $x(S)=\{x_i|i\in S\}$. For $X\subset [n]$ we denote by $\{0,1\}^X$ the set of all binary strings of length $|X|$ with coordinates indexed by $i\in X$. For $x\in \{0,1\}^n$ and $X\subseteq [n]$ we write $x_X\in\{0,1\}^{X}$ to denote the projection of $x$ over coordinates in $X$. We denote by $1_X$ and $0_X$ the all-one and all-zero strings in $\{0,1\}^{X}$, respectively. When we write $x_I=0$ we mean $x_I=0_I$. For $X_1,X_2\subseteq [n]$ where $X_1\cap X_2=\emptyset$ and $x\in \{0,1\}^{X_1}, y\in \{0,1\}^{X_2}$ we write $x\circ y$ to denote their concatenation, i.e., the string in $\{0,1\}^{X_1\cup X_2}$ that agrees with $x$ over coordinates in $X_1$ and agrees with $y$ over coordinates in~$X_2$. Notice that $x\circ y=y\circ x$. When we write $u=\circ_{w\in W}w$ we mean that $u$ is the concatenation of all the strings in $W$. For $X\subseteq [n]$ we denote $\overline{X}=[n]\backslash X=\{x\in [n]|x\not\in X\}$. We say that two strings $x$ and $y$ are {\it equal on $I$} if $x_I=y_I$. Given $f,g:\{0,1\}^n\to \{0,1\}$ and a probability distribution $\D$ over $\{0,1\}^n$, we say that $f$ is $\epsilon$-{\it close to $g$ with respect to} $\D$ if $\Pr_{x\in\D}[f(x)\not=g(x)]\le \epsilon$, where $x\in \D$ means $x$ is chosen from $\{0,1\}^n$ according to the distribution $\D$. We say that $f$ is $\epsilon$-{\it far from $g$ with respect to} $\D$ if $\Pr_{x\in\D}[f(x)\not=g(x)]\ge \epsilon$. For a class of Boolean functions $C$, we say that $f$ is $\epsilon$-{\it far from every function in $C$ with respect to} $\D$ if for every $g\in C$, $f$ is $\epsilon$-far from $g$ with respect to $\D$. We will use $U$ to denote the uniform distribution over $\{0,1\}^n$ or over $\{0,1\}^X$ when $X$ in clear from the context. For a Boolean function $f$ and $X\subset [n]$, we say that $X$ is a {\it relevant set} of $f$ if there are $a,b\in \{0,1\}^n$ such that $f(a)\not= f(b_X\circ a_{\overline X})$. We call the pair $(a,b)$ (or just $a$ when $b=0$) a {\it witness} of $f$ for the relevant set $X$. When $X=\{i\}$ then we say that $x_i$ is a {\it relevant variable} of $f$ and $a$ is {\it a witness} of $f$ for $x_i$. Obviously, if $X$ is relevant set of $f$ then $x(X)$ contains at least one relevant variable of $f$. We say that the Boolean function $f:\{0,1\}^n\to \{0,1\}$ is a literal if $f\in \{x_1,\ldots,x_n,\overline{x_1},\ldots,\overline{x_n}\}$ where $\overline{x}$ is the negation of $x$. Let $C$ be a class of Boolean functions $f:\{0,1\}^n\to \{0,1\}$. We say that $C$ is {\it closed under variable projection} if for every {\it projection} $\pi:[n]\to [n]$ and every $f\in C$, we have $f(x(\pi))\in C$ where $x(\pi):=(x_{\pi(1)},\cdots,x_{\pi(n)})$. We say that $C$ is {\it closed under zero projection} (resp. {\it closed under one projection}) if for every $f\in C$ and every $i\in [n]$, $f(0_{\{i\}}\circ x_{\overline{\{i\}}})$ (resp. $f(1_{\{i\}}\circ x_{\overline{\{i\}}})\in C$). We say it is closed under zero-one projection if is closed under zero and one projection. Throughout the paper, we assume that the class $C$ is closed under variable and zero projection. After section~3, we assume that it is also closed under one projection. \subsection{The Model} In this subsection, we define the testing and learning models. In the testing model, we consider the problem of testing a class of Boolean function $C$ in the uniform and distribution-free testing models. In the distribution-free testing model (resp. uniform model), the algorithm has access to a Boolean function $f$ via a black-box that returns $f(x)$ when a string $x$ is queried. We call this query {\it membership query} (MQ$_f$ or just MQ). The algorithm also has access to unknown distribution $\D$ (resp. uniform distribution) via an oracle that returns $x\in\{0,1\}^n$ chosen randomly according to the distribution $\D$ (resp. according to the uniform distribution). We call this query {\it example query} (ExQ$_\D$ (resp. ExQ)). A {\it distribution-free testing algorithm},~\cite{GoldreichGR98}, (resp. {\it testing algorithm}) ${\cal A}$ for $C$ is an algorithm that, given as input a distance parameter $\epsilon$ and the above two oracles to a Boolean function $f$, \begin{enumerate} \item if $f\in C$ then ${\cal A}$ outputs ``accept'' with probability at least $2/3$. \item if $f$ is $\epsilon$-far from every $g\in C$ with respect to the distribution $\D$ (resp. uniform distribution) then ${\cal A}$ outputs ``reject'' with probability at least $2/3$. \end{enumerate} We will also call ${\cal A}$ {\it a tester (or $\epsilon$-tester) for the class $C$} and an algorithm for {\it $\epsilon$-testing $C$}. We say that ${\cal A}$ is {\it one-sided} if it always accepts when $f\in C$; otherwise, it is called {\it two-sided} algorithm. The {\it query complexity of ${\cal A}$} is the maximum number of queries ${\cal A}$ makes on any Boolean function~$f$. In the learning models, $C$ is a class of representations of Boolean functions rather than a class of Boolean functions. Therefore, we may have two different representations in $C$ that are logically equivalent. In this paper, we assume that this representation is verifiable, that is, given a representation $g$, one can decide in polynomial time on the length of this representation if $g\in C$. A {\it distribution-free proper learning algorithm} (resp. proper learning algorithm under the uniform distribution) ${\cal A}$ for $C$ is an algorithm that, given as input an accuracy parameter $\epsilon$, a confidence parameter $\delta$ and an access to both MQ$_f$ for the {\it target function} $f\in C$ and ExQ$_\D$, with unknown $\D$, (resp. ExQ or ExQ$_U$), with probability at least $1-\delta$, ${\cal A}$ returns $h\in C$ that is $\epsilon$-close to $f$ with respect to $\D$ (resp. with respect to the uniform distribution). This model is also called {\it proper PAC-learning with membership queries} under any distribution (resp. under the uniform distribution)~\cite{Ang88,Valiant84}. A {\it proper exact learning algorithm}~\cite{Ang88} for $C$ is an algorithm that given as input a confidence parameter $\delta$ and an access to MQ$_f$ for $f\in C$, with probability at least $1-\delta$, returns $h\in C$ that is equivalent to $f$. The {\it query complexity of ${\cal A}$} is the maximum number of queries ${\cal A}$ makes on any Boolean function~$f\in C$. \subsection{Our Techniques} In this section, we give a detailed overview of our techniques. \subsubsection{Testing Subclasses of $k$-Junta} For testing a subclass $C$ of $k$-Junta that is closed under variable and zero projections, we use {\bf Tester$C$} in Figure~\ref{Tester1}. We first note that {\bf Tester$C$} rejects if any procedure that it calls rejects. First, {\bf Tester$C$} calls the procedure {\bf ApproxTarget}, in Figure~\ref{A31}. {\bf ApproxTarget} partitions the (indices of the) variables $[n]$ into $r=O(k^2)$ disjoint sets $X_1,\ldots,X_r$. Since $C\subseteq k-$Junta it follows that, with high probability (whp), if $f\in C$ then different relevant variables of $f$ fall into different sets. Therefore, if $f\in C$, whp, every $X_i$ contains at most one relevant variable of $f$. The procedure then binary searches for enough relevant sets $\{X_i\}_{i\in I}$ such that, whp, for $X=\cup_{i\in I} X_i$, $h=f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-close to $f$ with respect to $\D$. If the procedure finds more than $k$ relevant sets of $f$ then there are more than $k$ relevant variables in $f$ and it rejects. If $f\in C$ then the procedure does not reject and, since $C$ is closed under zero projection, $h\in C$. Since, whp, $h$ is $(\epsilon/3)$-close to $f$ with respect to $\D$, it is enough to distinguish whether $h$ is in $C$ or $(2\epsilon/3)$-far from every function in $C$ with respect to $\D$. {\bf ApproxTarget} also finds, for each relevant set $X_i$, $i\in I$, a witness $v^{(i)}\in \{0,1\}^{n}$ of $h$ for $X_i$. That is, for every $i\in I$, $h(v^{(i)})\not=h(0_{X_i}\circ v^{(i)}_{\overline{X_i}})$. If $f\in C$, then $h\in C$ and, whp, for each $i\in I$, $h(x_{X_i}\circ v^{(i)}_{\overline{X_i}})$ is a literal. {\bf ApproxTarget} makes $\tilde O(k/\epsilon)$ queries. In the second stage, the tester calls the procedure {\bf TestSets}, in Figure~\ref{A32}. {\bf TestSets} verifies, whp, that for every $i\in I$, $h(x_{X_i}\circ v^{(i)}_{\overline{X_i}})$ is $(1/30)$-close to some literal in $\{x_{\tau(i)},\overline{x_{\tau(i)}}\}$ for some $\tau(i)\in X_i$, with respect to the uniform distribution. If $f\in C$, then $h\in C$ and, whp, for each $i\in I$, $h(x_{X_i}\circ v^{(i)}_{\overline{X_i}})$ is a literal and therefore {\bf TestSets} does not reject. Notice that if $f\in C$, then, whp, $\Gamma:=\{x_{\tau(i)}\}_{i\in I}$ are the relevant variables of $h$. This test does not give $\tau(i)$ but the fact that $h(x_{X_i}\circ v^{(i)}_{\overline{X_i}})$ is close to $x_{\tau(i)}$ or $\overline{x_{\tau(i)}}$ can be used to find the value of $u_{\tau(i)}$ in every assignment $u \in \{0,1\}^{n}$ without knowing $\tau(i)$. The latter is done, whp, by the procedure {\bf RelVarValues}. See Figure~\ref{A3}. Both procedures make $\tilde O(k)$ queries. Recall that for $\xi\in\{0,1\}$, $\xi_X$ is the all $\xi$ vector in $\{0,1\}^X$. Then the tester defines the Boolean function $F=h(0_{\overline{X}}\circ\circ_{i\in I}(x_{\tau(i)})_{X_i})$ on the variables $\{x_{\tau(j)}\}_{j\in I}$, that is, the function $F$ is obtained by substituting in $h$ for every $i\in I$ and every $x_j\in x(X_i)$ the variable $x_{\tau(i)}$. Since $C\subseteq k$-Junta and $C$ is closed under variable and zero projections, $\tau(i)\in X_i$ and, whp, $\Gamma=\{x_{\tau(i)}\}_{i\in I}$ are the relevant variables of $h$ we have: \begin{itemize} \item If the function $f$ is in $C$ then, whp, $F=h\in C$ and $F$ depends on all the variables in $\Gamma=\{x_{\tau(j)}\}_{j\in I}$. \end{itemize} If $h$ is $(2\epsilon/3)$-far from every function in $C$ with respect to $\D$ then either $h$ is $(\epsilon/3)$-far from $F$ with respect to $\D$ or $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to $\D$ where $C(\Gamma)$ is the set of all functions in $C$ that depends on all the variables in $\Gamma$. Therefore, \begin{itemize} \item If the function $f$ is $\epsilon$-far from every function in $C$ then, whp, either \begin{enumerate} \item $h$ is $(\epsilon/3)$-far from $F$ with respect to $\D$ or \item $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to $\D$. \end{enumerate} \end{itemize} Therefore, it remains to do two tests. The first is testing whether $h =F$ given that $h$ is either $(\epsilon/3)$-far from $F$ with respect to $\D$ or $h=F$. The second is testing whether $F\in C$ given that $F$ is either $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to~$\D$ or $f\in C(\Gamma)$. The former test, $h=F$, can be done, whp, by choosing $O(1/\epsilon)$ strings $u\in\{0,1\}^n$ according to the distribution $\D$ and testing whether $F(u)=h(u)$. To compute $F(u)$ we need to find $\{u_{\tau(i)}\}_{i\in I}$, which can be done by the procedure {\bf RelVarValues}. Therefore, each query to $F$ requires one call to the procedure {\bf RelVarValues} that uses $\tilde O(k)$ queries to $f$. Thus, the first test can be done using $\tilde O(k/\epsilon)$ queries. This is done in the procedure {\bf Close$fF$} in Figure~\ref{Close01}. Notice that, thus far, all the above procedures run in polynomial time and make $\tilde O(k/\epsilon)$ queries. Testing whether $F\in C$ can be done, whp, by choosing $O((\log |C(\Gamma)|)/\epsilon)$ strings $u\in\{0,1\}^n$ according to the distribution $\D$ and testing whether $F(u)=g(u)$ for every $g\in C(\Gamma)$. Notice here that the time complexity is $poly(|C(\Gamma)|)$ which is polynomial only when $C(\Gamma)$ contains polynomial number of functions. If the distribution is uniform, we do not need to use {\bf RelVarValues} to find $\{u_{\tau(i)}\}_{i\in I}$ because when the distribution of $u$ is uniform the distribution of $\{u_{\tau(i)}\}_{i\in I}$ is also uniform. Therefore we can just test whether $F(u)=g(u)$ for every $g\in C(\Gamma)$ for uniform $\{u_{\tau(i)}\}_{i\in I}$. Then computing $F(u)$ for random uniform string $u$ can be done in one query to $h$. Thus, for the uniform distribution, the algorithm makes $\tilde O((\log |C(\Gamma)|)/\epsilon)$ queries to $f$. This is the procedure {\bf Close$FCU$} in Figure~\ref{Close02}. If the distribution is unknown then each computation of $F(u)$ for a random string $u$ according to the distribution $\D$ requires choosing $u$ according to the distribution $\D$, then extracting $\{u_{\tau(i)}\}_{i\in I}$ from $u$ and then substituting the values $\{u_{\tau(i)}\}_{i\in I}$ in $F$. This can be done by the procedure {\bf RelVarValues} using $\tilde O(k)$ queries to $h$. Therefore, for unknown distribution the algorithm makes $\tilde O((k\log |C(\Gamma)|)/\epsilon)$ queries to $f$. This is the procedures {\bf Close$FCD$} in Figure~\ref{Close02}. As we mentioned before the time complexity of {\bf Close$FCU$} and {\bf Close$FCD$} is polynomial only if $|C(\Gamma)|$ is polynomial. When $|C(\Gamma)|$ is exponential, we solve the problem via learning theory. We find a proper learning algorithm ${\cal A}$ for $C(\Gamma)$. We run ${\cal A}$ to learn $F$. If the algorithm fails, runs more time than it should, asks more queries than it should or outputs a hypothesis $g\not\in C$ then we know that, whp, $F\not\in C(\Gamma)$. Otherwise, it outputs a function $g\in C(\Gamma)$ and then, as above, we test whether $g=F$ given that $g$ is $(\epsilon/3)$-far from $F$ or $g=F$. Therefore, for the uniform distribution, if the proper learning algorithm for $C$ makes $m$ MQs and $q$ ExQs then the tester makes $m+q+O(1/\epsilon)$ queries. If the distribution is unknown, then the tester makes $m+\tilde O(kq+k/\epsilon)$ queries. \subsubsection{Testing Classes that are Close to $k$-Junta} To understand the intuition behind the second technique, we demonstrate it for testing $s$-term DNF. The tester first runs the procedure {\bf Approx$C$} in Figure~\ref{A3f}. This procedure is similar to the procedure {\bf ApproxTarget}. It randomly uniformly partitions the variables to $r=4c^2(c+1)s\log(s/\epsilon)$ disjoint sets $X_1,\ldots,X_r$ and finds relevant sets $\{X_i\}_{i\in I}$. Here $c$ is a large constant. To find a new relevant set, it chooses two random uniform strings $u,v\in \{0,1\}^n$ and verifies if $f(u_X\circ v_{\overline{X}})\not=f(u)$ where $X$ is the union of the relevant sets that it has found thus far. If $f(u_X\circ v_{\overline{X}})\not=f(u)$ then the binary search finds a new relevant set. In the binary search for a new relevant set, the procedure defines a set $X'$ that is equal to the union of half of the sets in $\{X_i\}_{i\not\in I}$. Then either $f(u_{X\cup X'} \circ v_{\overline{X'}})\not=f(u)$ or $f(u_{X\cup X'} \circ v_{\overline{X'}})\not= f(u_X\circ v_{\overline{X}})$. Then it recursively does the above until it finds a new relevant set $X_\ell$. It is easy to show that if $f$ is $s$-term DNF then, whp, for all the terms $T$ in $f$ of size at least $c^2\log(s/\epsilon)$, for all the random uniform strings $u,v$ chosen in the algorithm and for all the strings $w$ generated in the binary search, $T(u_X\circ v_{\overline{X}})=T(u)=T(w)=0$. Therefore, when $f$ is $s$-term DNF, the procedure, whp, runs as if there are no terms of size greater than $c^2\log(s/\epsilon)$ in $f$. This shows that, whp, each relevant set that the procedure finds contains at least one variable that belongs to a term of size at most $c^2\log(s/\epsilon)$ in $f$. Therefore, if $f$ is $s$-term DNF, the procedure, whp, does not generate more than $c^2s\log(s/\epsilon)$ relevant sets. If the procedure finds more than $c^2s\log(s/\epsilon)$ relevant sets then, whp, $f$ is not $s$-term DNF and therefore it rejects. Let $R$ be the set of all the variables that belong to the terms in $f$ of size at most $c^2\log(s/\epsilon)$. The procedure returns $h=f(x_X\circ w_{\overline{X}})$ for random uniform $w$ where $X$ is the union of the relevant sets $X=\cup_{i\in I}X_i$ that is found by the procedure. If $f$ is $s$-term DNF then since $r=4c^2(c+1)s\log(s/\epsilon)$ and the number of relevant sets is at most $c^2s\log(s/\epsilon)$, whp, at least $(1/2)c\log(s/\epsilon)$ variables in each term of $f$ that contains at least $c\log(s/\epsilon)$ variables not in $R$ falls outside $X$ in the partition of $[n]$. Therefore, for random uniform $w$, whp, terms $T$ in $f$ that contains at least $c\log(s/\epsilon)$ variables not in $R$ satisfies $T(x_X\circ w_{\overline{X}})=0$ and therefore, whp, are vanished in $h=f(x_X\circ w_{\overline{X}})$. Thus, whp, $h$ contains all the terms that contains variables in $R$ and at most $cs\log(s/\epsilon)$ variables not in $R$. Therefore, whp, $h$ contains at most $c(c+1)s\log(s/\epsilon)$ relevant variables. From this, and using similar arguments as for the procedure {\bf ApproxTarget} in the previous subsection, we prove that, {\bf Approx$C$} makes at most $\tilde O(s/\epsilon)$ queries and \begin{enumerate} \item If $f$ is $s$-term DNF then, whp, the procedure outputs $X$ and $w$ such that \begin{itemize} \item $h=f(x_X\circ w_{\overline{X}})$ is $s$-term DNF. \item The number of relevant variables in $h=f(x_X\circ w_{\overline{X}})$ is at most $O(s\log(s/\epsilon))$. \end{itemize} \item If $f$ is $\epsilon$-far from every $s$-term DNF then the procedure either rejects or outputs $X$ and $w$ such that, whp, $h=f(x_X\circ w_{\overline{X}})$ is $(3\epsilon/4)$-far from every $s$-term DNF. \end{enumerate} We can now run {\bf Tester$C$} (with $3\epsilon/4$) on $h$ from the previous subsection for testing $C^*$ where $C^*$ is the set of $s$-term DNF with $k=O(s\log(s/\epsilon))$ relevant variables. All the procedures makes $\tilde O(s/\epsilon)$ queries except {\bf Close$FCU$} that makes $\tilde O(s^2/\epsilon)$ queries. This is because that the size of the class $C^*(\Gamma)$ is $2^{\tilde O(s^2)}$ and therefore {\bf Close$FCU$} makes $\tilde O(s^2/\epsilon)$ queries. This gives a tester that makes $\tilde O(s^2/\epsilon)$ queries which is not optimal. Instead, we consider the class $C'$ of $s$-term DNF with $O(s\log(s/\epsilon))$ variables and terms of size at most $c\log(s/\epsilon)$ and show that, in {\bf Close$FCU$}, whp, all the terms $T$ of size greater than $c\log(s/\epsilon)$ and all the random strings $u$ chosen in the procedure satisfies $T(u)=0$ and therefore it runs as if the target function $h$ has only terms of size at most $c\log(s/\epsilon)$. This gives a tester that makes $\tilde O(s/\epsilon)$ queries. As in the previous section, all the procedures run in polynomial time except {\bf Close$FCU$}. For some classes, we replace {\bf Close$FCU$} with polynomial time learning algorithms and obtains polynomial time testers. \color{black} \section{Preparing the Target for Accessing the Relevant Variables} In this Section we give the three procedures {\bf ApproxTarget}, {\bf TestSets} and {\bf RelVarValues}. \subsection{Preliminaries} In this subsection, we give some known results that will be used in the sequel. The following lemma is straightforward \begin{lemma}\label{trivial01} If $\{X_i\}_{i\in [r]}$ is a partition of $[n]$ then for any Boolean function $f$ the number of relevant sets $X_i$ of $f$ is at most the number of relevant variables of $f$. \end{lemma} We will use the following folklore result that is formally proved in~\cite{LiuCSSX18}. \begin{lemma}\label{BiSe} Let $\{X_i\}_{i\in [r]}$ be a partition of $[n]$. Let $f$ be a Boolean function and $u,w\in \{0,1\}^n$. If $f(u)\not= f(w)$ then a relevant set $X_\ell$ of $f$ with a string $v\in \{0,1\}^n$ that satisfies $f(v)\not=f(w_{X_\ell}\circ v_{\overline{X_\ell}})$ can be found using $\lceil \log_2 r\rceil$ queries. \end{lemma} The following is from \cite{Blais09} \begin{lemma}\label{OneSide} There exists a one-sided adaptive algorithm, {\bf UniformJunta}$(f , k, \epsilon,\delta)$, for $\epsilon$-testing $k$-junta that makes $O(((k/\epsilon) + k \log k)\log(1/\delta))$ queries and rejects $f$ with probability at least $1-\delta$ when it is $\epsilon$-far from every $k$-junta with respect to the uniform distribution. Moreover, it rejects only when it has found $k+1$ pairwise disjoint relevant sets and a witness of $f$ for each one. \end{lemma} \subsection{Approximating the Target} In this subsection we give the procedure {\bf ApproxTarget} that returns $(X=\cup_{i\in I}X_i,V=\{v^{(i)}\}_{i\in I},I)$, $X\subseteq [n]$, $V\subseteq \{0,1\}^n$ and $I\subseteq [r]$ where, whp, each $x(X_i)$, $i\in I$, contains at least one relevant variable of $h:=f(x_X\circ 0_{\overline{X}})$ and exactly one if $f$ is $k$-junta. Each $v^{(i)}$, $i\in I$, is a witness of $f(x_{X}\circ 0_{\overline{X}})$ for the relevant set $X_i$. Also, whp, $f(x_{X}\circ 0_{\overline{X}})$ is $(\epsilon/c)$-close to the target with respect to the distribution $\D$. \newcounter{ALC} \setcounter{ALC}{0} \newcommand{\step}{\stepcounter{ALC}$\arabic{ALC}.\ $\>} \newcommand{\steplabel}[1]{\addtocounter{ALC}{-1}\refstepcounter{ALC}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf ApproxTarget}$(f,\D,\epsilon,c)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ and \\ \>\>an oracle that draws $x\in \{0,1\}^n$ according to the distribution $\D$. \\ {\it Output}: Either ``reject'' or $(X,V,I)$\\ \\ {\bf Partition $[n]$ into $r$ sets}\\ \step\steplabel{par11} Set $r = 2k^2$.\\ \step\steplabel{par21} Choose uniformly at random a partition $X_1,X_2,\ldots,X_r$ of $[n]$\\ \\ {\bf Find a close function and relevant sets} \\ \step\steplabel{Sett1} Set $X=\emptyset$; $I=\emptyset$; $V=\emptyset$; $t(X)=0$.\\ \step\steplabel{two1} Repeat $M=ck\ln(15k)/\epsilon$ times\\ \step\steplabel{Cho1} \> Choose $u\in {\cal D}$. \\ \step \> $t(X)\gets t(X)+1$\\ \step\steplabel{con11} \> If $f(u_X\circ 0_{\overline{X}})\not=f(u)$ then\\ \step\steplabel{Wempty}\>\>\> $W\gets \emptyset$. \\ \step\steplabel{Find1} \>\>\> Binary Search to find a new relevant set from $(u,u_X\circ 0_{\overline{X}})\to \ell$;\\ \step\steplabel{Finddd1} \>\>\>\> and a string $w^{(\ell)}\in\{0,1\}^n$ such that $f(w^{(\ell)})\not= f(w^{(\ell)}_{\overline{X_\ell}}\circ 0_{X_\ell})$;\\ \step\steplabel{Xadd}\>\>\> $X\gets X\cup X_\ell$; $I\gets I\cup \{\ell\}$.\\ \step\steplabel{Rej1} \>\>\> If $|I|>k$ then Output(``reject'').\\ \step\>\>\> $W=W\cup\{w^{(\ell)}\}$.\\ \step\>\>\>\steplabel{ccch}Choose $w^{(r)}\in W$.\\ \step\>\>\>\steplabel{Tr}If $f(w^{(r)}_X\circ 0_{\overline{X}})\not=f(w^{(r)}_{X\backslash X_r}\circ 0_{\overline{X}\cup X_r})$ then \\ \>\>\>\>\> $W\gets W\backslash\{w^{(r)}\}; v^{(r)}\gets w^{(r)}_X\circ 0_{\overline{X}}; V\gets V\cup\{v^{(r)}\};$\\ \>\>\>\>\> If $W\not=\emptyset$ then Goto~\ref{ccch}\\ \step\>\>\>\steplabel{Fir01} Else If $f(w^{(r)}_X\circ 0_{\overline{X}})\not=f(w^{(r)})$ then $u\gets w^{(r)}$; Goto~\ref{Find1} \\ \step \>\>\>\steplabel{Fir02} Else $u\gets w^{(r)}_{\overline{X_r}}\circ 0_{X_r}$; Goto~\ref{Find1}\\ \step\steplabel{tx01} \>\>\> $t(X)=0$.\\ \step\steplabel{EndRep1} \> If $t(X)=c\ln(15k)/\epsilon$ then Output($X,V,I$). \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that finds relevant sets $\{X_i\}_{i\in I}$ of $f$ and a witness $v^{(i)}$ for each relevant set~$X_i$ for $h:=f(x_X\circ 0_{\overline{X}})$ where $X=\cup_{i\in I}X_i$. Also, whp, $h$ is $(\epsilon/c)$-close to the target.} \label{A31} \end{figure} Consider the procedure {\bf ApproxTarget} in Figure~\ref{A31}. In steps~\ref{par11}-\ref{par21} the procedure partitions the set $[n]$ into $r=2k^2$ disjoint sets $X_1,X_2,\ldots,X_r$. In step~\ref{Sett1} it defines the variables $X,I,V$ and $t(X)$. At each iteration of the procedure, $I$ contains the indices of some relevant sets of $f(x_X\circ 0_{\overline{X}})$ where $X=\cup_{i\in I}X_i$, i.e., each $X_i$, $i\in I$ is relevant set of $f(x_X\circ 0_{\overline{X}})$. The set $V$ contains, for each $i\in I$, a string $v^{(i)}\in \{0,1\}^n$ that satisfies $f(v^{(i)}_X\circ 0_{\overline{X}})\not=f(v^{(i)}_{X\backslash X_i}\circ 0_{X_i}\circ 0_{\overline{X}})$. That is, a witness of $f(x_X\circ 0_{\overline{X}})$ for the relevant set $X_i$, $i\in I$. The procedure in steps~\ref{two1}-\ref{EndRep1} tests if $f(u_X\circ 0_{\overline{X}})=f(u)$ for at least $c\ln(15/k)/\epsilon$, independently and at random, chosen $u$ according to the distribution $\D$. The variable $t(X)$ counts the number of such $u$. If this happens then, whp, $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/c)$-close to $f$ with respect to $\D$ and the procedure returns $(X,V,I)$. If not then $f(u_X\circ 0_{\overline{X}})\not=f(u)$ for some $u$ and then a new relevant set is found. If the number of relevant sets is greater than $k$, it rejects. This is done in steps~\ref{Wempty}-\ref{tx01}. In steps~\ref{Find1}-\ref{Finddd1}, the procedure uses Lemma~\ref{BiSe} to (binary) searches for a new relevant set. The search gives an index $\ell$ of the new relevant set $X_\ell$ and a witness $w^{(\ell)}$ that satisfies $f(w^{(\ell)})\not= f(0_{X_\ell}\circ w^{(\ell)}_{\overline{X_\ell}})$. Then $\ell$ is added to $I$ and $X$ is extended to $X\cup X_\ell$. The binary search gives a witness that $X_\ell$ is relevant set of $f$, but not a witness that it is relevant set of $f(x_X\circ 0_{\overline{X}})$. This is why we need steps~\ref{ccch}-\ref{Fir02}. In those steps the procedure adds $w^{(\ell)}$ to $W$. Then for each $w^{(r)}\in W$ (at the beginning $r=\ell$) it checks if $w^{(r)}$ is a witness of $f(x_X\circ 0_{\overline{X}})$ for $X_r$. If it is then it adds it to $V$. If it isn't then we show in the discussion below that a new relevant set can be found. The procedure rejects when it finds more than $k$ relevant sets. If the procedure does not reject then it outputs $(X,V,I)$ where $I$ contains the indices of some relevant sets of $f(x_{X}\circ 0_{\overline{X}})$, $X=\cup_{i\in I}X_i$ and the set $V$ contains for each $i\in I$ a string $v^{(i)}\in \{0,1\}^n$ that is a witness of $f(x_{X}\circ 0_{\overline{X}})$ for $X_i$, i.e., $f(v^{(i)}_X\circ 0_{\overline{X}})\not=f(v^{(i)}_{X\backslash X_i}\circ 0_{X_i}\circ 0_{\overline{X}})$. We will also show in Lemma~\ref{cloose} that, whp, $\Pr_\D[f(x_X\circ 0_{\overline{X}})\not=f(x)]\le \epsilon/c$. \color{black} We first prove \begin{lemma}\label{dist} Consider steps~\ref{par11}-\ref{par21} in the {\bf ApproxTarget}. If $f$ is a $k$-junta then, with probability at least $2/3$, for each $i\in [r]$, the set $x(X_i)=\{x_j|j\in X_i\}$ contains at most one relevant variable of $f$. \end{lemma} \begin{proof} Let $x_{i_1}$ and $x_{i_2}$ be two relevant variables in $f$. The probability that $x_{i_1}$ and $x_{i_2}$ are in the same set is equal to $1/r$. By the union bound, it follows that the probability that some relevant variables $x_{i_1}$ and $x_{i_2}$, $i_1\not=i_2$, in $f$ are in the same set is at most ${k\choose 2}/r\le 1/3$. \end{proof} \begin{figure}[h!] \begin{center} \begin{tabular}{l | c | c || c | c |} & \multicolumn{2}{|c||}{$X^{(j)}=\bigcup_{i=1}^jX_{\ell_i}$}&\multicolumn{2}{|c|}{$\overline{X^{(j)}}$} \\ \cline{2-5} &$X^{(j)}\backslash X_r$ &$X_r$&$\bigcup_{i=j+1}^{q^{\ } }X_{\ell_i}$&$\overline{\overline{X^{(q)}}}$\\ \hline $v^{(r)}$& *********** & ***** & 00000000000 & 000000\\ \hline $w^{(r)}$& *********** & ***** & *********** & ******\\ \hline $w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}}=v^{(r)}$& *********** & ***** & 00000000000 & 000000\\ \hline $w^{(r)}_{\overline{X_r}}\circ 0_{X_r}$&*********** & 00000 & *********** & ******\\ \hline $w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r}$& *********** & 00000 & 00000000000 & 000000\\ \hline \end{tabular} \end{center} \caption{The value of $v^{(r)}$, $w^{(r)}$, $w^{(r)}_{X^{(j)}}\circ0_{\overline{X^{(j)}}}$, $w^{(r)}_{\overline{X_r}}\circ 0_{X_r}$ and $w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r}$ where * indicates any value.} \label{ValTable} \end{figure} Recall that after the binary search in step~\ref{Find1} the procedure has a witness $w^{(\ell)}$ that satisfies $f(w^{(\ell)})\not= f(w^{(\ell)}_{\overline{X_\ell}}\circ 0_{X_\ell})$ that is not necessarily a witness of $f(x_X\circ 0_{\overline X})$ for $X_\ell$, i.e., does not necessarily satisfies $f(w^{(\ell)}_X\circ 0_{\overline{X}})\not= f(w^{(\ell)}_{X\backslash X_\ell}\circ 0_{X_\ell}\circ 0_{\overline{X}})$. This is why we first add $w^{(\ell)}$ to $W$ and not to $V$. We next will show that an element $w^{(r)}$ in $W$ is either a witness of $f(x_X\circ 0_{\overline X})$ for $X_\ell$, in which case we add it to $V$ and remove it from $W$, or, this element generates another new relevant set and then another witness of $f$ is added to $W$. Suppose the variable $\ell$ in the procedure takes the values ${\ell_1},\ldots,{\ell_q}$. Then $X_\ell$ takes the values $X_{\ell_1},\ldots,X_{\ell_q}$ and $X$ takes the values $X^{(i)}$ where $X^{(i)}=X^{(i-1)}\cup X_{\ell_i}$ and $X^{(0)}=\emptyset$. Notice that $X^{(0)}\subset X^{(1)} \subset \cdots \subset X^{(q)}$. Suppose, at some iteration, the procedure chooses, in step \ref{ccch}, $w^{(r)}\in W$ where $r=\ell_i$. By step~\ref{Finddd1}, $f(w^{(r)})\not= f(w^{(r)}_{\overline{X_r}}\circ 0_{X_r})$. Suppose at this iteration $X=X^{(j)}$. Then $r\le j$, $X_{\ell_1},\ldots,X_{\ell_j}$ are the relevant sets that are discovered so far and $X_{\ell_{j+1}},\ldots,X_{\ell_q}\subseteq \overline{X^{(j)}}$. Since $w^{(r)}\in W$, by step~\ref{Xadd}, $X_r\subseteq X^{(j)}$. See the table in Figure~\ref{ValTable}. If in step~\ref{Tr}, $f(w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})\not=f(w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r})$ then $v^{(r)}= w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}}$ is added to the set $V$. This is the only step that adds an element to $V$. Since $v^{(r)}= w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}}$ and $X^{(j)}\subseteq X^{(q)}$ we have $v^{(r)}_{\overline{X^{(q)}}}=0$ and $f(v^{(r)})=f(w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})\not=f(w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r})=f(v^{(r)}_{\overline{X_r}} \circ 0_{X_r}).$ Therefore \begin{lemma}\label{Witf0} If the procedure outputs $(X^{(q)},V,I)$ then for every $v^{(\ell)}\in V$ we have $v^{(\ell)}_{\overline{X^{(q)}}}=0$ and $f(v^{(\ell)})\not=f( v^{(\ell)}_{\overline{X_\ell}}\circ 0_{X_\ell})$. That is, $v^{(\ell)}\in V$ is a witness of $f(x_{X^{(q)}}\circ 0_{\overline{X^{(q)}}})$ for $X_\ell$. \end{lemma} We now show that if, in step~\ref{Tr}, $f(w^{(r)}_X\circ 0_{\overline{X}})=f(w^{(r)}_{X\backslash X_r}\circ 0_{\overline{X}\cup X_r})$ then the procedure finds a new relevant set. \begin{lemma} Consider step~\ref{Tr} in the procedure in the iteration where $X=X^{(j)}$. If $w^{(r)}$ is not a witness of $f(x_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})$ for $X_r$, i.e., $f(w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})=f(w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r})$, then a new relevant set is found. \end{lemma} \begin{proof} See the table in Figure~\ref{ValTable} throughout the proof. Since by step ~\ref{Finddd1}, $f(w^{(r)})\not= f(w^{(r)}_{\overline{X_r}}\circ0_{X_r})$, then either $f(w^{(r)})\not=f(w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})$ or $f(w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r})\not= f(w^{(r)}_{\overline{X_r}}\circ0_{X_r})$. If $f(w^{(r)})\not=f(w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}})$ then the procedure in step~\ref{Fir01} assign $u=w^{(r)}$ and goes to step~\ref{Find1} to find a relevant set in $\overline{X^{(j)}}$. Step~\ref{Find1} finds a new relevant set because $w^{(r)}$ and $w^{(r)}_{X^{(j)}}\circ 0_{\overline{X^{(j)}}}$ are equal on $X^{(j)}$. If $f(w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r})\not= f(w^{(r)}_{\overline{X_r}}\circ 0_{X_r})$ then the procedure in step~\ref{Fir02} assign $u=w^{(r)}_{\overline{X_r}}\circ0_{X_r}$ and goes to step~\ref{Find1} to find a relevant set in $\overline{X^{(j)}}$. Step~\ref{Find1} finds a new relevant set because $w^{(r)}_{X^{(j)}\backslash X_r}\circ 0_{\overline{X^{(j)}}\cup X_r}$ and $w^{(r)}_{\overline{X_r}}\circ 0_{X_r}$ are equal on $X^{(j)}$. \end{proof} Therefore, for every $w^{(r)}\in W$ the procedure either finds $v^{(r)}$ that satisfies the condition in Lemma~\ref{Witf0} or finds a new relevant set. If the number of relevant sets is greater than $k$, then the procedure rejects. This is because each relevant set contains a relevant variable, and the relevant sets are disjoint. So the function, in this case, is not $k$-junta and therefore not in $C$. If the number of relevant sets is less than or equal to $k$, then the algorithm eventually finds, for each $\ell\in I$, a witness $v^{(\ell)}$ of $f(x_X\circ 0_{\overline{X}})$ for $X_{i_\ell}$. This implies \begin{lemma}\label{lklk} If {\bf ApproxTarget} does not reject then it outputs $(X=X^{(q)},V=\{v^{(\ell_1)}, \ldots,v^{(\ell_q)}\},I=\{\ell_1,\ldots,\ell_q\})$ that satisfies \begin{enumerate} \item\label{lklk1} $q=|I|\le k$. \item\label{lklk2} For every $\ell\in I$, $v^{(\ell)}_{\overline{X}}=0$ and $f(v^{(\ell)})\not=f(0_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$. That is, $v^{(\ell)}\in V$ is a witness of $f(x_{X}\circ 0_{\overline{X}})$ for $X_\ell$ . \item\label{lklk3} Each $x(X_\ell)$, $\ell\in I$, contains at least one relevant variable of $f(x_X\circ 0_{\overline{X}})$. \end{enumerate} \end{lemma} \begin{lemma}\label{kjun} If $f$ is $k$-junta and each $x(X_i)$ contains at most one relevant variable of $f$ then \begin{enumerate} \item {\bf ApproxTarget} outputs $(X,V,I)$. \item Each $x(X_\ell)$, $\ell\in I$, contains exactly one relevant variable in $f(x_X\circ 0_{\overline{X}})$. \item For every $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is a literal. \end{enumerate} \end{lemma} \begin{proof} By {\it \ref{lklk3}} in Lemma~\ref{lklk}, $x(X_\ell)$, $\ell\in I$, contains exactly one relevant variable. Thus, for every $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is a literal. Since $f$ contains at most $k$ relevant variables, by Lemma~\ref{trivial01}, the number of relevant sets $|I|$ is at most $k$. Therefore, {\bf ApproxTarget} does not halt in step~\ref{Rej1}. \end{proof} The following lemma shows that \begin{lemma}\label{cloose} If {\bf ApproxTarget} outputs $(X,V,I)$ then $|I|\le k$ and with probability at least $14/15$ $$\Pr_{u\in {\cal D}}[f(u_X\circ 0_{\overline{X}})\not= f(u)]\le \epsilon/c.$$ \end{lemma} \begin{proof} If $|I|>k$ then, from step~\ref{Rej1}, {\bf ApproxTarget} outputs ``reject''. Therefore, the probability that {\bf ApproxTarget} fails to output $(X,V,I)$ with $\Pr_{u\in {\cal D}}[f(u_X\circ 0_{\overline{X}})\not= f(u)]\le \epsilon/c$ is the probability that for some $X^{(\ell)}$, $\Pr_{u\in {\cal D}}[f(x_{X^{(\ell)}}\circ 0_{\overline{X^{(\ell)}}})\not= f(x)]> \epsilon/c$ and $f(u_{X^{(\ell)}}\circ 0_{\overline{X^{(\ell)}}})= f(u)$ for $c\ln(15k)/\epsilon$ strings $u$ chosen independently at random according to the distribution $\D$. This probability is at most $$k\left(1-\frac{c}{\epsilon}\right)^{c\ln(15k)/\epsilon}\le \frac{1}{15}.$$ \end{proof} We now give the query complexity \begin{lemma}\label{Query01} The procedure {\bf ApproxTarget} makes $O((k\log k)/\epsilon)$ queries. \end{lemma} \begin{proof} The condition in step~\ref{con11} requires two queries and is executed at most $M=ck\ln(15k)/\epsilon$ times. This is $2M=O((k\log k)/\epsilon)$ queries. Steps~\ref{Find1}-\ref{Fir02} are executed at most $k+1$ times. This is because each time it is executed, the value of $|I|$ is increased by one, and when $|I|=k+1$ the procedure rejects. By Lemma~\ref{BiSe}, to find a new relevant set the procedure makes $O(\log r)=O(\log k)$ queries. This gives another $O(k\log k)$ queries. Therefore, the query complexity is $O((k\log k)/\epsilon)$. \end{proof} \color{black} \subsection{Testing the Relevant Sets} In this subsection we give the procedure {\bf TestSets} that takes as an input $(X,V=\{v^{(\ell_1)}, \ldots,v^{(\ell_q)}\},I=\{\ell_1,\ldots,\ell_q\})$ and tests if for all $\ell\in I$, $f(x_{X_\ell} \circ v^{(\ell)}_{\overline{X_\ell}})$ is $(1/30)$-close to some literal with respect to the uniform distribution. \newcounter{ALC2} \setcounter{ALC2}{0} \newcommand{\stepb}{\stepcounter{ALC2}$\arabic{ALC2}.\ $\>} \newcommand{\steplabelb}[1]{\addtocounter{ALC2}{-1}\refstepcounter{ALC2}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf TestSets}$(X,V,I)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ and $(X,V,I)$. \\ {\it Output}: Either ``reject'' or ``OK''\\ \\ \stepb\steplabelb{LitT1} For every $\ell\in I$ do\\ \stepb\steplabelb{Uni1} \> If {\bf UniformJunta}$(f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}}),1,1/30,1/15)$=``reject'' \\ \stepb\steplabelb{Rej211} \>\>\>then Output(``reject'')\\ \stepb\steplabelb{ConB1} \> Choose $b\in U$\\ \stepb\steplabelb{ConE11} \> If $f(b_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})=f(\overline{b_{X_\ell}}\circ v^{(\ell)}_{\overline{X_\ell}})$ then Output(``reject'')\\ \stepb\ Return ``OK'' \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that tests if for all $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $(1/30)$-close to some literal with respect to the uniform distribution.} \label{A32} \end{figure} We first prove \begin{lemma}\label{kjun1} If $f$ is $k$-junta and each $x(X_i)$ contains at most one relevant variable of $f$ then {\bf TestSets} returns ``OK''. \end{lemma} \begin{proof} By Lemma~\ref{kjun}, for every $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is a literal. If {\bf TestSets} rejects in step~\ref{Rej211} then, by Lemma~\ref{OneSide}, for some $X_\ell$, $\ell\in I$, $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is not $1$-Junta (literal or constant function) and therefore $x(X_\ell)$ contains at least two relevant variables. If it rejects in step~\ref{ConE11}, then $f(b_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})=f(\overline{b_{X_\ell}}\circ v^{(\ell)}_{\overline{X_\ell}})$ and then $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is not a literal. In all cases we get a contradiction. \end{proof} In the following lemma we show that if {\bf TestSets} returns ``OK'' then, whp, each $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is close to a literal with respect to the uniform distribution. \begin{lemma}\label{closelit} If for some $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $(1/30)$-far from every literal with respect to the uniform distribution then, with probability at least $1-(1/15)$, {\bf TestSets} rejects. \end{lemma} \begin{proof} If $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $(1/30)$-far from every literal with respect to the uniform distribution then it is either (case 1) $(1/30)$-far from every $1$-Junta (literal or constant) or (case 2) $(1/30)$-far from every literal and $(1/30)$-close to $0$-Junta. In case 1, by Lemma~\ref{OneSide}, with probability at least $1-(1/15)$, ${\bf UniformJunta}$ $(f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)}),1,1/30,1/15)$ $=$ ``reject'' and then the procedure rejects. In case 2, if $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $(1/30)$-close to some $0$-Junta then it is either $(1/30)$-close to~$0$ or $(1/30)$-close to~$1$. Suppose it is $(1/30)$-close to $0$. Let $b$ be a random uniform string chosen in steps~\ref{ConB1}. Then $\overline{b}$ is random uniform and for $g(x)=f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ we have \begin{eqnarray*} \Pr[\mbox{The procedure does not reject}]&=& \Pr\left[g(b)\not=g(\overline{b})\right]\\ &=&\Pr[g(b)=1\wedge g(\overline{b})=0]+\Pr[g(b)=0\wedge g(\overline{b})=1]\\ &\le&\Pr[g(b)=1]+\Pr[g(\overline{b})=1]\\ &\le&\frac{1}{15}. \end{eqnarray*} \end{proof} \begin{lemma}\label{Query02} The procedure {\bf TestSets} makes $O(k)$ queries. \end{lemma} \begin{proof} Steps~\ref{Uni1} and \ref{ConE11} are executed $|I|\le k$ times, and by Lemma~\ref{OneSide}, the total number of queries made is $O(1/(1/30)\log(15))k+2k=O(k)$. \end{proof} \subsection{Determining the Values of the Relevant Variables} \newcounter{ALC3} \setcounter{ALC3}{0} \newcommand{\stepc}{\stepcounter{ALC3}$\arabic{ALC3}.\ $\>} \newcommand{\steplabelc}[1]{\addtocounter{ALC3}{-1}\refstepcounter{ALC3}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf RelVarValues}$(w,X,V,I,\delta)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$, $(X,V,I)$ and $w\in\{0,1\}^n$. \\ {\it Output}: Either ``reject'' or for every $\ell\in I$, the value, $z_\ell=w_{\tau(\ell)}$ where $x_{\tau(\ell)}$ is one of the\\ \>\> relevant variables of $f(x_X\circ 0_{\overline{X}})$ in $x(X_\ell)$\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepc\steplabelc{feld01} For every $\ell\in I$ do\\ \stepc \>\> For $\xi\in\{0,1\}$ set $Y_{\ell,\xi}=\{j\in X_\ell | w_j=\xi\}$.\\ \stepc \>\> Set $G_{\ell,0}=G_{\ell,1}=0$;\\ \stepc\steplabelc{feld02} \>\> Repeat $h=\ln(k/\delta)/\ln(4/3)$ times\\ \stepc\steplabelc{feld03} \>\>\> Choose $b\in U$; \\ \stepc\steplabelc{qqq1}\>\>\>\> If $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})\not= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ then $G_{\ell,0}\gets G_{\ell,0}+1$\\ \stepc\steplabelc{qqq2}\>\>\>\> If $f(b_{Y_{\ell,1}}\circ b_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})\not= f(\overline{b_{Y_{\ell,1}}}\circ b_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})$ then $G_{\ell,1}\gets G_{\ell,1}+1$\\ \stepc\steplabelc{GGG5} \>\>If ($\{G_{\ell,0},G_{\ell,1}\}\not=\{0,h\}$) then Output(``reject'')\\ \stepc\steplabelc{Gl} \>\> If $G_{\ell,0}=h$ then $z_\ell \gets 0$ else $z_\ell \gets 1$\\ \stepc Output(``$\{z_\ell\}_{\ell\in I}$'') \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that takes as input $(X,V,I)$ and a string $w\in\{0,1\}^n$ and, with probability at least $1-\delta$, returns the values of $w_{\tau(i)}$, $i\in I$, where $f(x_{X_i}\circ v_{\overline{X_i}}^{(i)})$ is $(1/30)$-close to one of the literals in $\{x_{\tau(i)},\overline{x_{\tau(i)}}\}$ with respect to the uniform distribution.} \label{A3} \end{figure} \color{black} In this subsection we give a procedure {\bf RelVarValue} that for an input $(w\in\{0,1\}^n,X,V,I,\delta)$ where $(X,V,I)$ satisfies all the properties in the previous two subsections, the procedure, with probability at least $1-\delta$, returns the values of $w_{\tau(i)}$, $i\in I$, where $f(x_{X_i}\circ v_{\overline{X_i}}^{(i)})$ is $(1/30)$-close to one of the literals in $\{x_{\tau(i)},\overline{x_{\tau(i)}}\}$ with respect to the uniform distribution. When $f$ is $k$-junta and each $x(X_i)$ contains at most one relevant variable then $\{x_{\tau(i)}\}_{i\in I}$ is the set of the relevant variables of $f(x_X\circ 0_{\overline{X}})$ and $w_{\tau(i)}$, $i\in I$ are the values of the relevant variables. The procedure is in Figure~\ref{A3}. We first prove \begin{lemma}\label{kjun2} If $f$ is $k$-Junta and each $x(X_i)$ contains at most one relevant variable of $f$ then {\bf RelVarValues} outputs $z$ such that $z_\ell=w_{\tau(\ell)}$ where $f(x_{X_\ell}\circ 0_{\overline{X_\ell}})\in \{x_{\tau(\ell)},\overline{x_{\tau(\ell)}}\}$. \end{lemma} \begin{proof} Since $Y_{\ell,0}, Y_{\ell,1}$ is a partition of $X_\ell$, $\ell\in I$ and, by Lemma~\ref{kjun}, $x(X_\ell)$ contains exactly one relevant variable $x_{\tau(\ell)}$ of $f(x_X\circ 0_{\overline{X}})$, this variable is either in $x(Y_{\ell,0})$ or in $x(Y_{\ell,1})$ but not in both. Suppose w.l.o.g. it is in $x(Y_{\ell,0})$ and not in $x(Y_{\ell,1})$. Then $w_{\tau(\ell)}=0$, $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is a literal and $f(x_{Y_{\ell,1}}\circ b_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is a constant function. This implies that for any $b$, $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})\not= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ and $f(b_{Y_{\ell,1}}\circ b_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})= f(\overline{b_{Y_{\ell,1}}}\circ b_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})$. Therefore, by steps~\ref{qqq1}-\ref{qqq2} in the procedure, $G_{\ell,0}=h$ and $G_{\ell,1}=0$ and the procedure does not output reject in step~\ref{GGG5}. Thus, by step~\ref{Gl}, $z_\ell=w_{\tau(\ell)}$. \end{proof} We now prove \begin{lemma}\label{FinTest} If for every $\ell\in I$ the function $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(1/30)$-close to a literal in $\{x_{\tau(\ell)},\bar{x}_{\tau(\ell)}\}$ with respect to the uniform distribution, where $\tau(\ell)\in X_\ell$, and in {\bf RelVarValues}, for every $\ell\in I$, $\{G_{\ell,0},G_{\ell,1}\}=\{0,h\}$ then, with probability at least $1-\delta$, we have: For every $\ell\in I$, $z_\ell=w_{\tau(\ell)}$. \end{lemma} \begin{proof} Fix some $\ell$. Suppose $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(1/30)$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution. The case when it is $(1/30)$-close to $\overline{{x}_{\tau(\ell)}}$ is similar. Since $X_\ell=Y_{\ell,0}\cup Y_{\ell,1}$ and $Y_{\ell,0}\cap Y_{\ell,1}=\emptyset$ we have that $\tau(\ell)\in Y_{\ell,0}$ or $\tau(\ell)\in Y_{\ell,1}$, but not both. Suppose $\tau(\ell)\in Y_{\ell,0}$. The case where $\tau(\ell)\in Y_{\ell,1}$ is similar. Define the random variable $Z(x_{X_\ell})=1$ if $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})\not=x_{\tau(\ell)}$ and $Z(x_{X_\ell})=0$ otherwise. Then $$\E_{x_{X_\ell}\in U}[Z(x_{X_\ell})]\le \frac{1}{30}.$$ Therefore $$\E_{x_{Y_{\ell,1}}\in U}\E_{x_{Y_{\ell,0}}\in U}[Z(x_{Y_{\ell,0}}\circ x_{Y_{\ell,1}})]\le \frac{1}{30}$$ and by Markov's bound $$\Pr_{x_{Y_{\ell,1}}\in U}\left[ \E_{x_{Y_{\ell,0}}\in U}[Z(x_{Y_{\ell,0}}\circ x_{Y_{\ell,1}})]\ge \frac{2}{15}\right]\le \frac{1}{4}.$$ That is, for a random uniform string $b\in \{0,1\}^n$, with probability at least $3/4$, $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(2/15)$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution. Now, given that $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(2/15)$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution the probability that $G_{\ell,0}=0$ is the probability that $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ for $h$ random uniform strings $b\in \{0,1\}^n$. Let $b^{(1)},\ldots,b^{(h)}$ be $h$ random uniform strings in $\{0,1\}^n$, $V(b)$ be the event $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ and $A$ the event that $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(2/15)$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution. Let $g(x_{Y_{\ell,0}})=f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$. Then \begin{eqnarray*} \Pr[V(b)|A]&=& \Pr[g(b_{Y_{\ell,0}})=g(\overline{b_{Y_{\ell,0}}})|A]\\ &=&\Pr[(g(b_{Y_{\ell,0}})=b_{\tau(\ell)}\wedge g(\overline{b_{Y_{\ell,0}}})=b_{\tau(\ell)}) \vee (g(b_{Y_{\ell,0}})=\overline{b_{\tau(\ell)}}\wedge g(\overline{b_{Y_{\ell,0}}})=\overline{b_{\tau(\ell)}})|A]\\ &\le& \Pr[g(\overline{b_{Y_{\ell,0}}})\not=\overline{b_{\tau(\ell)}} \vee g({b_{Y_{\ell,0}}})\not={b_{\tau(\ell)}})|A]\\ &\le& \Pr[g(\overline{b_{Y_{\ell,0}}})\not=\overline{b_{\tau(\ell)}}|A] +\Pr[g({b_{Y_{\ell,0}}})\not={b_{\tau(\ell)}})|A]\le \frac{4}{15}. \end{eqnarray*} Since $\tau(\ell)\in Y_{\ell,0}$, we have $w_{\tau(\ell)}=0$. Therefore, by step~\ref{Gl} and since $\tau(\ell)\in X_\ell$, \begin{eqnarray*} \Pr[z_\ell\not= w_{\tau(\ell)}]&=&\Pr[z_{\ell}=1]\\ &=&\Pr[G_{\ell,0}=0\wedge G_{\ell,1}=h]\\ &\le&\Pr[G_{\ell,0}=0]=\Pr[(\forall j\in[h]) V(b^{(j)})]\\ &=& (\Pr[V(b)])^h \le \left( \Pr[V(b)|A]+\Pr[\overline{A}]\right)^h \le (4/15+1/4)^h\le (3/4)^h \end{eqnarray*} Therefore, the probability that $z_{\ell}\not =w_{\tau(\ell)}$ for some $\ell\in I$ is at most $k(3/4)^h\le \delta$. \end{proof} The following is obvious \begin{lemma}\label{kkkkkk} The procedure {\bf RelVarValues} makes $O(k\log(k/\delta))$ queries. \end{lemma} \section{Testing Subclasses of $k$-Junta} In this section, we give testers for subclasses of $k$-Junta that are closed under variable and zero projections. Our tester will start by running the two procedures {\bf ApproxTarget} and {\bf TestSets} and therefore, by Lemmas~\ref{dist}, \ref{kjun} and~\ref{kjun1}, if $f\in C$ (and therefore is $k$-junta) then, with probability at least $2/3$, both procedures do not reject and item {\it \ref{f01}} in the following Assumption happens. By Lemmas~\ref{lklk}, \ref{cloose}, and \ref{closelit}, if $f$ is $\epsilon$-far from every function in $C$ and both procedures do not reject then, with probability at least $13/15$, item {\it \ref{f02}} in the following Assumption happens. Obviously, the above two probabilities can be changed to $1-\delta$ for any constant $\delta$ without changing the asymptotic query complexity. \begin{assm}\label{assmp} Throughout this section we assume that there are $X$, $q\le k$, $I=\{\ell_1,\ldots,\ell_q\}$ and $V=\{v^{(\ell_1)},\ldots,v^{(\ell_q)}\}$ such that: For every $\ell\in I$, $v^{(\ell)}_{\overline{X}}=0$ and $f(v^{(\ell)})\not=f(0_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$. That is, $v^{(\ell)}\in V$ is a witness of $f(x_{X}\circ 0_{\overline{X}})$ for $X_\ell$ and \begin{enumerate} \item\label{f01} If $f\in C$ (and therefore is $k$-junta) \begin{itemize} \item $f(x_X\circ 0_{\overline{X}})\in C$. \item Each $x(X_\ell)$, $\ell\in I$ contains exactly one relevant variable. \item For every $\ell\in I$, $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is a literal in $\{x_{\tau(\ell)},\overline{x_{\tau(\ell)}}\}$. \end{itemize} \item\label{f02} If $f$ is $\epsilon$-far from every function in $C$ then \begin{itemize} \item $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-close to $f$ with respect to $\D$ and therefore $f(x_X\circ 0_{\overline{X}})$ is $(2\epsilon/3)$-far from every function in $C$ with respect to $\D$. \item For every $\ell\in I$, $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $(1/30)$-close to a literal in $\{x_{\tau(\ell)},\bar{x}_{\tau(\ell)}\}$ with respect to the uniform distribution. \end{itemize} \end{enumerate} We will also use the set of indices $\Gamma:=\{\tau(\ell_1),\ldots,\tau(\ell_q)\}$. Notice that if $f$ is $k$-junta then $x(\Gamma)$ are the relevant variables of $f$. \end{assm} We remind the reader that for a projection $\pi:X\to X$ the string $x(\pi)$ is defined as $x(\pi)_j=x_{\pi(j)}$ for every $j\in X$. Define the projection $\pi_{f,I}:X\to X$ that satisfies: For every $\ell\in I$ and every $j\in X_\ell$, $\pi_{f,I}(j)=\tau(\ell)$. Define the function $F(x_\Gamma)=F(x_{\tau(\ell_1)},\ldots,x_{\tau(\ell_q)}):=f(x(\pi_{f,I})\circ 0_{\overline{X}})$. That is, $F$ is the function that results from substituting in $f(x_X\circ 0_{\overline{X}})$ for every $\ell\in I$ and every $x_i$, $i\in X_\ell$, the variable $x_{\tau(\ell)}$. Note here that the tester does not know $\tau(\ell_1),\ldots,\tau(\ell_q)$. We now show how to query $F$ by querying $f$ \begin{lemma}\label{SimulateF} For the function $F$ we have \begin{enumerate} \item \label{Compp1}Given $(y_1,\ldots,y_q)$, computing $F(y_1,\ldots,y_q)$ can be done with one query to $f$. \item \label{Compp3}Given $x\in\{0,1\}^n$ and $\delta$, there is an algorithm that makes $O(k\log (k/\delta))$ queries and, with probability at least $1-\delta$, either discovers that some $X_i$, $i\in I$ contains at least two relevant variables in $f$ (and therefore, whp, $f$ is not $k$-junta) and then rejects or computes $z=(x_{\tau(\ell_1)},\ldots,x_{\tau(\ell_q)})$ and $F(z)$. \end{enumerate} \end{lemma} \begin{proof} {\it \ref{Compp1}} is immediate. To prove {\it \ref{Compp3}} we use Lemma~\ref{FinTest}. We run {\bf RelVarValues}$(x,X,V,I,\delta)$. If it rejects then $\{G_{\ell,0},G_{\ell,1}\}\not= \{0,h\}$ for some $\ell\in I$ and therefore $G_{\ell,0},G_{\ell,1}>0$. This implies that for some $b,b'\in\{0,1\}^n$, $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})\not= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ and $f(b'_{Y_{\ell,1}}\circ b'_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})\not= f(\overline{b'_{Y_{\ell,1}}}\circ b'_{Y_{\ell,0}}\circ v^{(\ell)}_{\overline{X_\ell}})$. Since $X_\ell=Y_{\ell,0}\cup Y_{\ell,1}$ and $Y_{\ell,0}\cap Y_{\ell,1}=\emptyset$, the set $x(X_\ell)$ contains at least two relevant variables in $f$. If for every $\ell$ we have $\{G_{\ell,0},G_{\ell,1}\}= \{0,h\}$ then, by Lemma~\ref{FinTest}, with probability at least $1-\delta$, the procedure outputs $z$ where for every $\ell$, $z_\ell=x_{\tau(\ell)}$. Then using {\it \ref{Compp1}} we compute $F(z)$. Since by Lemma~\ref{kkkkkk}, {\bf RelVarValue} makes $O(k\log (k/\delta))$ queries, the result follows. \end{proof} We now give the key lemma for the first tester \begin{lemma}\label{kLem} Let $C\subseteq k-$Junta be a class that is closed under variable and zero projections and $f$ be any Boolean function. Let $F(x_\Gamma)=f(x(\pi_{f,I})\circ 0_{\overline{X}})$ where $\Gamma=\{\tau(\ell)|\ell\in I\}$ and $C(\Gamma)$ be the set of all functions in $C$ that their relevant variables are $x(\Gamma)$. If Assumption~\ref{assmp} is true, then \begin{enumerate} \item\label{proj01} If $f\in C$ then $f(x_X\circ 0_{\overline{X}})=F\in C(\Gamma)$. \item\label{proj02} If $f$ is $\epsilon$-far from every function in $C$ with respect to ${\cal D}$ then either \begin{enumerate} \item\label{proj02a} $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to ${\cal D}$, or \item\label{proj02b} $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$. \end{enumerate} \end{enumerate} \end{lemma} \begin{proof} We first prove {\it \ref{proj01}}. If $f\in C$, then since $C$ is closed under variable and zero projection $f(x_X\circ 0_{\overline{X}})\in C$. We have $f(x_X\circ 0_{\overline{X}})=f(\circ_{\ell\in I}x_{X_\ell}\circ 0_{\overline{X}})$ and, by Assumption~\ref{assmp}, every $x(X_\ell)$, $\ell\in I$, contains exactly one relevant variable $x_{\tau(\ell)}$ of $f(x_X\circ 0_{\overline{X}})$. Therefore, $f(x_X\circ 0_{\overline{X}})$ is a function that depends only on the variables $x_{\tau(\ell)}$, $\ell\in I$. By the definition of $x(\pi_{f,{I}})$ and since $\tau(\ell)\in X_\ell$ we have $x(\pi_{f,{I}})_{\tau(\ell)}=x_{\tau(\ell)}$ and therefore $f(x_X\circ 0_{\overline{X}})=f(x(\pi_{f,{I}})\circ 0_{\overline{X}})=F$. We now prove~{\it\ref{proj02}}. Suppose, for the contrary, $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-close to $F$ with respect to $\D$ and $F$ is $(\epsilon/3)$-close to some function $g\in C(\Gamma)$ with respect to $\D$. Then $f(x_X\circ 0_{\overline{X}})$ is $(2\epsilon/3)$-close to $g$ with respect to $\D$. Since, by Assumption~\ref{assmp}, $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-close to $f$ with respect to $\D$ we get that $f$ is $\epsilon$-close to $g\in C$ with respect to $\D$. A contradiction. \end{proof} In the following two subsections we discuss how to test the closeness of $f(x_X\circ 0_{\overline{X}})$ to $F$ and $F$ to $C(\Gamma)$. We will assume all the procedures in the following subsections have access to $X,V,I$ that satisfies Assumption~\ref{assmp}. \subsection{Testing the Closeness of $f(x_X\circ 0_{\overline{X}})$ to $F$} \newcounter{ALCc1} \setcounter{ALCc1}{0} \newcommand{\stepco}{\stepcounter{ALCc1}$\arabic{ALCc1}.\ $\>} \newcommand{\steplabelco}[1]{\addtocounter{ALCc1}{-1}\refstepcounter{ALCc1}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf Close$fF$}$(f,\D,\epsilon,\delta)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ and $\D$. \\ {\it Output}: Either ``reject'' or ``OK''\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepco Define $F\equiv f(x(\pi_{f,I})\circ 0_{\overline{X}})$.\\ \stepco\steplabelco{co01} Repeat $t=(3/\epsilon)\ln(2/\delta)$ times \\ \stepco\steplabelco{co02}\> Choose $u\in \D$.\\ \stepco\steplabelco{co03}\> $z\gets${\bf RelVarValue}$(u,X,V,I,\delta/(2t))$ .\\ \stepco\steplabelco{co04}\> If $f(u_X\circ 0_{\overline{X}})\not=F(z)$ then Output(``reject'')\\ \stepco\steplabelco{co05} Return ``OK''. \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that tests whether $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to ${\cal D}$.} \label{Close01} \end{figure} We now give the procedure {\bf Close$fF$} that tests whether $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to ${\cal D}$. See Figure~\ref{Close01}. \begin{lemma}\label{FirstApp} For any $\epsilon$, a constant $\delta$, and $(X,V,I)$ that satisfies Assumption~\ref{assmp}, procedure {\bf Close$fF$} makes $O((k/\epsilon)\log (k/\epsilon))$ queries and \begin{enumerate} \item\label{FirstApp1} If $f\in C$ then {\bf Close$fF$} returns OK. \item\label{FirstApp2} If $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to $\D$ then, with probability at least $1-\delta$, {\bf Close$fF$} rejects. \end{enumerate} \end{lemma} \begin{proof} {\bf Close$fF$} draws $t=(3/\epsilon)\ln(2/\delta)$ random $u^{(i)}\in\{0,1\}^n$, $i=1,\ldots,t$ according to the distribution~${\cal D}$. It finds $z^{(i)}=u^{(i)}_\Gamma$ and if $F(u^{(i)}_\Gamma)=f(u^{(i)}_X\circ 0_{\overline{X}})$ for all $i$ then it returns ``OK''. Otherwise it rejects. If $f\in C$ then, by {\it \ref{proj01}} in Lemma~\ref{kLem}, $F(u^{(i)}_\Gamma)=f(u^{(i)}_X\circ 0_{\overline{X}})$ for every $i$. By Lemma~\ref{kjun2} and Assumption~\ref{assmp}, $z^{(i)}= u^{(i)}_\Gamma$ for all $i$, and therefore {\bf Close$fF$} returns OK. Suppose now $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to $\D$. By {\it\ref{Compp3}} in Lemma~\ref{SimulateF}, {\bf RelVarValue} makes $O(k\log((kt)/\delta))$ queries and computes $F(u_\Gamma^{(i)})$, $i=1,\ldots,t$, with failure probability at most $\delta/2$. Then the probability that it fails to reject is at most $(1-\epsilon/3)^t\le \delta/2$. This gives the result. Therefore, {\bf Close$fF$} makes $O((k/\epsilon)\log(k/\epsilon))$ queries and satisfies~{\it \ref{FirstApp1}} and~{\it \ref{FirstApp2}}. \end{proof} \subsection{Testing the Closeness of $F$ to $C(\Gamma)$} \newcounter{ALC8} \setcounter{ALC8}{0} \newcommand{\steps}{\stepcounter{ALC8}$\arabic{ALC8}.\ $\>} \newcommand{\steplabels}[1]{\addtocounter{ALC8}{-1}\refstepcounter{ALC8}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf Close$FC\D$}$(f,\D,\epsilon,\delta)$}\\ {\it Input}: Oracles that access a Boolean function $f$ and $\D$. \\ {\it Output}: Either ``reject'' or ``OK''\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \steps\steplabels{FFs07}$C^*\gets C(\Gamma)$\\ \steps\steplabels{FFs08}Repeat $\tau=(12/\epsilon)\ln(2|C^*|/\delta)$ times\\ \steps\steplabels{FFs09}\> Choose $u\in \D$.\\ \steps\steplabels{FFs10}\> $z\gets${\bf RelVarValue}$(u,X,V,I,1/2)$ .\\ \steps\steplabels{FFs11}\> For every $g\in C^*$\\ \steps\steplabels{FFs12}\>\>If $g(z)\not=F(z)$ then $C^*\gets C^*\backslash \{g\}$.\\ \steps\steplabels{FFs13}\>If $C^*=\emptyset$ then Output(``Reject'')\\ \steps\steplabels{FFs14} Return ``OK''\\ \addtocounter{ALC8}{-8} ----------------------------------------------------------------------\\ {{\bf Close$FCU$}$(f,\epsilon,\delta)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$. \\ {\it Output}: Either ``reject'' or ``OK''\\ \\ \steps\steplabels{FFss07}$C^*\gets C(\Gamma)$\\ \steps\steplabels{FFs15}Repeat $\tau=(3/\epsilon)\ln(2|C^*|/\delta))$ times\\ \steps\steplabels{FFs16}\> Choose $(z_1,\ldots,z_q)\in U$.\\ \steps\steplabels{FFs17}\> For every $g\in C^*$\\ \steps\steplabels{FFs18}\>\>If $g(z)\not=F(z)$ then $C^*\gets C^*\backslash \{g\}$.\\ \steps\steplabels{FFs19}\>If $C^*=\emptyset$ then Output(``Reject'')\\ \steps\steplabels{FFs20} Return ``OK'' \end{tabbing} \end{minipage}}} \end{center} \caption{Two procedures that test whether $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ and the uniform distribution, respectively.} \label{Close02} \end{figure} In this section, we give the procedures {\bf Close$FC\D$} and {\bf Close$FCU$} that test whether $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ and the uniform distribution, respectively. We prove \begin{lemma}\label{clooo} For any $\epsilon$ and any constant $\delta$ and $(X,V,I)$ that satisfies Assumption~\ref{assmp}, the procedures {\bf Close$FC\D$} and {\bf Close$FCU$} make $O((k\log|C(\Gamma)|)/\epsilon)$ and $O((\log|C(\Gamma)|)/\epsilon)$ queries to $f$, respectively, and \begin{enumerate} \item If $f\in C$ then {\bf Close$FC\D$} and {\bf Close$FCU$} output OK. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ then, with probability at least $1-\delta$, {\bf Close$FC\D$} rejects. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to the uniform distribution, then with probability at least $1-\delta$, {\bf Close$FCU$} rejects. \end{enumerate} Both procedures run in time $poly(n,|C(\Gamma)|,1/\epsilon)$. \end{lemma} \begin{proof} The proof for {\bf Close$FCU$} is similar to the proof of Lemma~\ref{FirstApp} with union bound. For {\bf Close$FC\D$}, notice that it calls {\bf RelVarValue}$(u,X,V,I,1/2)$, and therefore at each iteration, with probability $1/2$, $z=u_\Gamma$. By Chernoff's bound ((\ref{Chernoff2}) in Lemma~\ref{Chernoff}), with probability at least $1-\delta/2$, $(3/\epsilon)\ln(2|C^*|/\delta)$ of the chosen $u$s in the procedures satisfy $z=u_\Gamma$. Then again, by union bound, the result follows. \end{proof} \subsection{Testing the Closeness of $F$ to $C(\Gamma)$ via Learning $C(\Gamma)$} In this subsection, we show how proper learning implies testing the closeness of $F$ to $C(\Gamma)$. The proofs are similar to the proof of Proposition 3.1.1 in~\cite{GoldreichGR98}. Let $(X,V,I)$ be as in~Assumption~\ref{assmp} and $q=|I|\le k$. Let $Y=\{y_1,\ldots,y_q\}$ be a set of Boolean variables and $C(Y)$ be the set of all functions in $C$ that depend on all the variables of $Y$. Notice that instead of using $C(Y)$ we could have used $C(\{x_1,\ldots,x_q\})$ but here we use the new Boolean variables $y_i$ to avoid confusion with the variables $x_i$ of $f$. \begin{remark}\label{remark} In all the lemmas in this subsection and the following one, in addition to the fact that $F$ depends on all the variables of $Y$, the learning algorithms can also make use of $(X,V,I)$ that satisfies Assumption~\ref{assmp}. This may help for some classes. For example\footnote{See the definition of unate in Subsection~\ref{TMDD}}, if the target function is a unate monotone function, then from the witnesses in $V$, we can know if $F$ is positive or negative unate in $y_i$, for each variable $y_i$. \end{remark} The following is an immediate result that follows from the two procedures {\bf Close$FC\D$} and {\bf Close$FCU$} in the previous subsection \begin{lemma}\label{LtoTTriv} If there is a polynomial time algorithm that given a set $${\cal Y}=\{(y^{(1)},\xi_1),\ldots,(y^{(t)},\xi_t)\}\subseteq \{0,1\}^q\times \{0,1\}$$ decides whether there is a function $F\in C(Y)$ that is consistent with ${\cal Y}$, i.e., $F(y^{(i)})=\xi_i$ for all $i=1,\ldots,t$, then there is a polynomial time algorithm ${\cal B}_\D$ (resp. ${\cal B}_U$) that makes $O((k\log|C(\Gamma)|)/\epsilon)$ queries (resp. $O((\log|C(\Gamma)|)/\epsilon)$ queries) to $f$ and \begin{enumerate} \item If $f\in C$ then ${\cal B}_\D$ and ${\cal B}_U$ output OK. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ then, with probability at least $1-\delta$, ${\cal B}_\D$ rejects. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to the uniform distribution then, with probability at least $1-\delta$, ${\cal B}_U$ rejects. \end{enumerate} \end{lemma} We now give the reduction from exact learning \begin{lemma}\label{LtoT01} If there is a polynomial time algorithm ${\cal A}$ that, given as an input any constant $\delta$, properly exactly learns $ C(Y)$ with confidence parameter $\delta$ and makes $M(\delta)$ membership queries to $F$ then there is a polynomial time algorithm ${\cal B}$ that, given as an input $\epsilon$, any constant $\delta$, makes $M(\delta/3)+O((k/\epsilon)\log(1/\epsilon))$ (resp. $M(\delta/3)+O(1/\epsilon)$) queries to $f$ and \begin{enumerate} \item If $f\in C$ then, with probability at least $1-\delta$, ${\cal B}$ outputs OK. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ (resp. with respect to the uniform distribution) then, with probability at least $1-\delta$, ${\cal B}$ rejects. \end{enumerate} \end{lemma} \begin{proof} Algorithm ${\cal B}$ runs ${\cal A}$ with confidence parameter $\delta/3$ to learn $F(y_1,\ldots,y_q)$. By Lemma~\ref{SimulateF}, each membership query to $F$ can be simulated by one membership query to $f$. If algorithm ${\cal A}$ runs more than it should, asks more than $M(\delta/3)$ membership queries or outputs $h\not\in C(Y)$ then ${\cal B}$ rejects. If ${\cal A}$ outputs $h\in C(Y)$ then the algorithm needs to distinguish whether $h(x_\Gamma)$ is equal to $F(x_\Gamma)$ or $(\epsilon/3)$-far from $F(x_\Gamma)$ with respect to the distribution $\D$ (resp. uniform distribution). When the distribution is uniform, the algorithm chooses $t=(3/\epsilon)\ln(3/\delta)$ strings $v^{(1)},\ldots,v^{(t)}\in \{0,1\}^q$ and if $F(v^{(i)})=h(v^{(i)})$ for all $i$ then it outputs ``OK''; otherwise it rejects. In the distribution-free model, ${\cal B}$ chooses $t=(12/\epsilon)\ln(2/\delta)$ strings $u^{(i)}\in \{0,1\}^n$ according to the distribution $\D$. Then runs {\bf RelValValue}$(u^{(i)},X,V,I,1/2)$ to find, with probability $1/2$ the value of $u^{(i)}_\Gamma$, $i=1,\ldots,t$. If $F(u^{(i)}_\Gamma)=h(u^{(i)}_\Gamma)$ for all $i$, then it outputs ``OK''; otherwise it rejects. The analysis and correctness of the algorithm are the same as in the above proofs and Proposition~3.1.1 in~\cite{GoldreichGR98}. \end{proof} We now give the reduction from learning from MQ and ExQ$_\D$ \begin{lemma}\label{LtoT02} If there is a polynomial time algorithm ${\cal A}$ that, given as an input a constant $\delta$, any $\epsilon$, learns $C(Y)$ with respect to the distribution $\D$ (resp. uniform distribution), with confident $\delta$, accuracy $\epsilon$, makes $M(\epsilon,\delta)$ $MQ$ to $F$ and $Q(\epsilon,\delta)$ ExQ$_\D$ (resp. ExQ$_U$) queries to $F$ then there is a polynomial time algorithm ${\cal B}_\D$ (resp. ${\cal B}_U$) that asks $$O\left(M(\epsilon/12,\delta/3)+kQ(\epsilon/12,\delta/3)\log ({kQ(\epsilon/12,\delta/3)})+\frac{k}{\epsilon}\log\frac{1}{\epsilon}\right)$$ queries (resp. $$O\left(M(\epsilon/12,\delta/3)+Q(\epsilon/12,\delta/3)+\frac{1}{\epsilon}\right)$$ queries) to $f$ and \begin{enumerate} \item If $f\in C$ then with probability at least $1-\delta$, ${\cal B}_\D$ and ${\cal B}_U$ output OK. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ then, with probability at least $1-\delta$, ${\cal B}_\D$ rejects. \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to the uniform distribution then, with probability at least $1-\delta$, ${\cal B}_U$ rejects. \end{enumerate} \end{lemma} \begin{proof} Algorithm ${\cal B}$ runs ${\cal A}$ with confidence parameter $\delta/3$ and accuracy $\epsilon/12$. By Lemma~\ref{SimulateF}, every membership query to $F(y)$ can be simulated with one membership query to $f$. Every ExQ$_{\D'}$ (resp. ExQ) for the induced distribution $\D'$ of $\D$ on the coordinates $\Gamma$, can be simulated with one ExQ$_{\D}$ and $k \log(3kQ(\epsilon/12,\delta/3)/\delta)$ membership queries (resp. one ExQ) with failure probability $\delta/(3Q(\epsilon/12,\delta/3))$, and therefore, with failure probability $\delta/3$ for all the ExQ$_{\D'}$ queries asked in the learning algorithm. If algorithm ${\cal A}$ runs more than it should, asks more than $Q(\epsilon/12,\delta/3)$ ExQ$_{\D'}$, asks more than $M(\epsilon/12,\delta/3)$ MQ or outputs $h\not\in C(Y)$ then ${\cal B}_\D$ rejects. If ${\cal A}$ outputs $h\in C(Y)$ then, with probability at least $1-(2\delta/3)$, \begin{enumerate} \item If $F\in C(\Gamma)$ then $F$ is $(\epsilon/12)$-close to $h$ \item If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ then $F$ is $(\epsilon/4)$-far from $h$. \end{enumerate} Now, using Chernoff's bound in Lemma~\ref{Chernoff}, algorithm ${\cal B}$, can estimate the distance between $F$ and $h$ with accuracy $\epsilon/24$ and confidence $\delta/6$ using $O((\log(1/\delta))/\epsilon)$ strings chosen according to the distribution $\D'$. This can be done using $O((\log(1/\delta))/\epsilon)$ queries in the uniform model and $O((k/\epsilon)(\log (1/\delta)\log(1/(\epsilon\delta)))$ with confidence $\delta/6$ in the distribution-free model. \end{proof} Define the oracle WExQ$_{\D}$ (Weak ExQ$_{\D}$) that returns with probability $1/2$ a $x\in\{0,1\}^n$ according to the distribution $\D$ and with probability $1/2$ an arbitrary $x\in\{0,1\}^n$. In some of the learning algorithms given in the sequel, the algorithms still work if we replace the oracle ExQ$_\D$ with WExQ$_{\D}$. In that case, we can save the factor of $\log(3kQ(\epsilon/12,\delta/3)/\delta)$ in the query complexity of Lemma~\ref{LtoT02} in the distribution-free setting. We will discuss this in Section~\ref{IFR}. \subsection{The First Tester} We are now ready to give the first tester. Consider the tester {\bf Tester$C$} in Figure~\ref{Tester1}. Note that the tester rejects if any one of the procedures called by the tester rejects. We prove \newcounter{ALC4} \setcounter{ALC4}{0} \newcommand{\stepd}{\stepcounter{ALC4}$\arabic{ALC4}.\ $\>} \newcommand{\steplabeld}[1]{\addtocounter{ALC4}{-1}\refstepcounter{ALC4}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf Tester$C$}$(f,\D,\epsilon)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ and $\D$. \\ {\it Output}: If any one of the procedures reject \\ \>\>then ``reject'' or ``accept''\\ \\ \stepd\steplabeld{FF01} $(X,V,I)\gets ${\bf ApproxTarget}$(f,\D,\epsilon,1/3)$. \\ \stepd\steplabeld{FF02} {\bf TestSets}$(X,V,I)$.\\ \stepd\steplabeld{FF04} Define $F\equiv f(x(\pi_{f,I})\circ 0_{\overline{X}})$\\ \stepd\steplabeld{FF03} {{\bf Close$fF$}$(f,\D,\epsilon,1/15)$} \\ \\ \ {\bf For any distribution}\\ \stepd\steplabeld{FF08}{{\bf Close$FC\D$}$(f,\D,\epsilon,1/15)$}\\ \stepd\steplabeld{FF14} Return ``accept''\\ \\ \addtocounter{ALC4}{-2} {\bf For the uniform distribution}\\ \stepd\steplabeld{FF19}{{\bf Close$FCU$}$(f,\epsilon,1/15)$}\\ \stepd\steplabeld{FF20} Return ``accept'' \end{tabbing} \end{minipage}}} \end{center} \caption{A tester for subclasses $C$ of $k$-Junta} \label{Tester1} \end{figure} \begin{theorem}\label{FirstTester} Let $C\subseteq k-$Junta that is closed under zero and variable projections. Then \begin{enumerate} \item There is a $poly(|C(\Gamma)|,n,1/\epsilon)$ time two-sided adaptive algorithm, {\bf Tester$C$}, for $\epsilon$-testing $C$ that makes $\tilde O((1/\epsilon)(k+\log|C(\Gamma)|))$ queries. That is \begin{enumerate} \item If $f\in C$ then, with probability at least $2/3$, {\bf Tester$C$} accepts. \item If $f$ is $\epsilon$-far from every function in $C$ with respect to the uniform distribution then, with probability at least $2/3$, {\bf Tester$C$} rejects. \end{enumerate} \item There is a $poly(|C(\Gamma)|,n,1/\epsilon)$ time two-sided distribution-free adaptive algorithm, {\bf Tester$C$}, for $\epsilon$-testing $C$ that makes $\tilde O((k/\epsilon)\log (2|C(\Gamma)|))$ queries. That is \begin{enumerate} \item If $f\in C$ then, with probability at least $2/3$, {\bf Tester$C$} accepts. \item If $f$ is $\epsilon$-far from every function in $C$ with respect to the distribution $\D$ then, with probability at least $2/3$, {\bf Tester$C$} rejects. \end{enumerate} \end{enumerate} \end{theorem} \begin{proof} We prove~{\it 1a} and {\it 2a}. Let $f\in C$. Consider step~\ref{FF01} in {\bf Tester$C$}. By Lemma~\ref{dist} and \ref{kjun}, with probability at least $2/3$, {\bf ApproxTarget} outputs $(X,V,I)$ that satisfies Assumption~\ref{assmp}. Now with this assumption we have: By Lemma~\ref{kjun1}, {\bf TestSets} in step~\ref{FF02} does not reject. By Lemma~\ref{FirstApp}, {\bf Close$fF$} in step~\ref{FF03} does not reject. By Lemma~\ref{clooo}, {\bf Close$FC\D$} and {\bf Close$FCU$} in step~\ref{FF08} do not reject. Therefore, with probability at least $2/3$ the tester accepts. We now prove~{\it 1b} and {\it 2b}. Suppose $f$ is $\epsilon$-far from every function in $C$ with respect to $\D$. The proof for the uniform distribution is similar. If in step~\ref{FF01} {\bf ApproxTarget} outputs $(X,V,I)$ then by Lemma~\ref{cloose}, with probability at least $14/15$, $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-close to $f$. If in step~\ref{FF02} {\bf TestSets} does not reject then, by Lemma~\ref{closelit}, with probability at least $14/15$, for all $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $(1/30)$-close to a literal $\{x_{\tau(\ell)},\overline{x_{\tau(\ell)}}\}$. Therefore with probability at least $13/15$, Assumption~\ref{assmp} is true. Then by Lemma~\ref{kLem}, either $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to ${\cal D}$, or $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$. If $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to $\D$ then by Lemma~\ref{FirstApp}, with probability at least $14/15$, {\bf Close$fF$} rejects. If $F$ is $(\epsilon/3)$-far from every function in $C(\Gamma)$ with respect to ${\cal D}$ then by Lemma~\ref{clooo}, with probability at least $14/15$, {\bf Close$FC$} rejects. By the union bound the probability that the tester rejects is at least $2/3$. The query complexity follows from Lemmas~\ref{Query01}, \ref{Query02}, \ref{FirstApp} and \ref{clooo}. \end{proof} If we replace {\bf Close$FC\D$} and {\bf Close$FCU$} with the testers in Lemma~\ref{LtoTTriv}, \ref{LtoT01} and \ref{LtoT02}, we get the following results \begin{theorem}\label{LtoTTriv2} If there is a polynomial time algorithm that given a set $${\cal Y}=\{(y^{(1)},\xi_1),\ldots,(y^{(t)},\xi_t)\}\subseteq \{0,1\}^q\times \{0,1\}$$ decides whether there is a function $F\in C(Y)$ that is consistent with ${\cal Y}$, then \begin{enumerate} \item There is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $C$ that makes $\tilde O((1/\epsilon)(k+\log|C(\Gamma)|))$ queries. \item There is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $C$ that makes $\tilde O((k/\epsilon)\log (2|C(\Gamma)|))$ queries. \end{enumerate} \end{theorem} \begin{theorem}\label{TesterL01} If there is a polynomial time algorithm ${\cal A}$ that, given as an input any constant $\delta$, properly exactly learns $ C(Y)$ with confidence parameter $\delta$ and makes $M(\delta)$ membership queries then \begin{enumerate} \item There is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $C$ that makes $M(1/24)+\tilde O(k/\epsilon)$ queries. \item There is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $C$ that makes $M(1/24)+\tilde O(k/\epsilon)$ queries. \end{enumerate} \end{theorem} \begin{theorem}\label{TesterL02} If there is a polynomial time algorithm ${\cal A}$ that, given as an input a constant $\delta$ and any $\epsilon$, learns $C(Y)$, with confident $\delta$, accuracy $\epsilon$, makes $M(\epsilon,\delta)$ $MQ$ and $Q(\epsilon,\delta)$ ExQ$_U$ (resp. ExQ$_\D$) then \begin{enumerate} \item There is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $C$ that makes $$\tilde O\left(M(\epsilon/12,1/24)+Q(\epsilon/12,\delta/3)+\frac{k}{\epsilon}\right)$$ queries. \item There is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $C$ that makes $$\tilde O\left(M(\epsilon/12,1/24)+kQ(\epsilon/12,1/24)+\frac{k}{\epsilon}\right)$$ queries. \end{enumerate} \end{theorem} Finally, one trivial but useful result is \begin{theorem}\label{ThTriv} If there is a polynomial time algorithm ${\cal A}$ that, given as an input any constant $\delta$ and any $\epsilon$ makes $M(\epsilon,\delta)$ MQs and $Q(\epsilon,\delta)$ ExQ$_U$ (resp. ExD$_\D$) and distinguish between $F\in C(Y)$ and $F$ $\epsilon$-far from every function in $C(Y)$ with respect to the uniform distribution (resp. with respect to the distribution $\D$) then \begin{enumerate} \item There is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $C$ that makes $$\tilde O\left(M(\epsilon/12,1/24)+Q(\epsilon/12,1/24)+\frac{k}{\epsilon}\right)$$ queries. \item There is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $C$ that makes $$\tilde O\left(M(\epsilon/12,1/24)+kQ(\epsilon/12,1/24)+\frac{k}{\epsilon}\right)$$ queries. \end{enumerate} \end{theorem} \section{Results}\label{result1} In this section we define the classes and give the results for the classes $k$-Junta, $k$-Linear, $k$-Term, $s$-Term Monotone $r$-DNF, size-$s$ Decision Tree, size-$s$ Branching Program, Functions with Fourier Degree at most $d$, Length-$k$ Decision List and $s$-Sparse Polynomial of Degree $d$. We will use words that are capitalized for classes and non-capitalized words for functions. For example, $k$-Junta is the class of all $k$-juntas. \subsection{Testing $k$-Junta} For $k$-Junta in uniform distribution framework, Ficher et al.~\cite{FischerKRSS02} introduced the junta testing problem and gave a non-adaptive algorithm that makes $\tilde O(k^2)/\epsilon$ queries. Blais in~\cite{Blais08} gave a non-adaptive algorithm that makes $\tilde{O}(k^{3/2})/\epsilon$ queries and in~\cite{Blais09} an adaptive algorithm that makes $O(k\log k+k/\epsilon)$ queries. On the lower bounds side, Fisher et al.~\cite{FischerKRSS02} gave an $\Omega(\sqrt{k})$ lower bound for non-adaptive testing. Chockler and Gutfreund~\cite{ChocklerG04} gave an $\Omega(k)$ lower bound for adaptive testing and, recently, Sa\u{g}lam in~ \cite{Saglam18} improved this lower bound to $\Omega(k\log k)$. For the non-adaptive testing Chen et al.~\cite{ChenSTWX17} gave the lower bound $\tilde{\Omega}(k^{3/2})/\epsilon$. For testing $k$-junta in the distribution-free model, Chen et al.~\cite{LiuCSSX18} gave a one-sided adaptive algorithm that makes $\tilde{O}(k^{2})/\epsilon$ queries and proved a lower bound $\Omega(2^{k/3})$ for any non-adaptive algorithm. The result of Halevy and Kushilevitz in~\cite{HalevyK07} gives a one-sided non-adaptive algorithm that makes $O(2^k/\epsilon)$ queries. The adaptive $\Omega(k\log k)$ uniform-distribution lower bound from~\cite{Saglam18} trivially extends to the distribution-free model. Bshouty~\cite{Bshouty19} gave a two-sided adaptive algorithm that makes $\tilde O(1/\epsilon)k\log k$ queries. Our algorithm in this paper gives \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $k$-Junta that makes $\tilde O(k/\epsilon)$ queries. \end{theorem} \begin{proof} We use Theorem~\ref{ThTriv}. Since every $F(Y)$ is in $k$-Junta$(Y)$, the algorithm ${\cal A}$ always accepts. Therefore, we have $M=Q=0$, and the algorithm makes $\tilde O(k/\epsilon)$ queries. \end{proof} \subsection{Testing $k$-Linear} The function is linear if it is a sum (over the binary field $F_2$) of variables. The class Linear is the class of all linear functions. The class $k$-Linear is Linear$\cap k$-Junta. That is, the class of functions that are the sum of at most $k$ variables. Blum et al. \cite{BlumLR93} showed that there is an algorithm for testing Linear under the uniform distribution that makes $O(1/\epsilon)$ queries. For testing $k$-Linear under the uniform distribution, Fisher, et al.~\cite{FischerKRSS02} gave a tester that makes $O(k^2/\epsilon)$ queries. They also gave the lower bound $\Omega(\sqrt{k})$ for non-adaptive algorithms. Goldreich~\cite{Goldreich10}, proved the lower bound $\Omega(k)$ for non-adaptive algorithms and $\Omega(\sqrt{k})$ for adaptive algorithms. Then Blais et al.~\cite{BlaisBM11} proved the lower bound $\Omega(k)$ for adaptive algorithms. Blais and Kane, in~\cite{BlaisK12}, gave the lower bound $k-o(k)$ for adaptive algorithms and $2k-o(k)$ for non-adaptive algorithms. Testing $k$-Linear can be done by first testing if the function is $k$-Junta and then testing if it is Linear. Therefore, there is an adaptive algorithm for $\epsilon$-testing $k$-Linear under the uniform distribution that makes $\tilde O(k/\epsilon)$ queries. In this paper we prove \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $k$-Linear that makes $\tilde O(k/\epsilon)$ queries. \end{theorem} \begin{proof} We use Theorem~\ref{TesterL02}. Here $C(Y)=\{y_1+\cdots+y_q\}$ contains one function and therefore the learning algorithm just outputs $y_1+\cdots+y_q$. Therefore $M=Q=0$ and the result follows. \end{proof} \subsection{Testing $k$-Term} A {\it term} (or {\it monomial}) is a conjunction of literals and {\it Term} is the class of all terms. A {\it $k$-term} is a term with at most $k$ literals and {\it $k$-Term} is the class of all $k$-terms. In the uniform distribution model, Pernas et al.~\cite{ParnasRS02}, gave a tester for $k$-terms that makes $O(1/\epsilon)$ queries in the uniform model. We give the same result in the next section. In this paper we prove the following result for the distribution-free model. When $k=n$, better results can be found in~\cite{GlasnerS09,DolevR11}. \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $k$-Term that makes $\tilde O(k/\epsilon)$ queries. \end{theorem} \begin{proof} Recall that $x_i^0=x_i$ and $x_i^1=\overline{x_i}$. Here $C(Y)=\{y_1^{\xi_1}\wedge\cdots\wedge y_q^{\xi_q}|\xi\in\{0,1\}^q\}$ contains $2^q$ functions. We use Theorem~\ref{TesterL02} with Remark~\ref{remark}. Since $V$ contains witnesses for each variable it follows that $\xi_i$ are known. Just take any string $a$ that satisfies $F(a)=1$ and then $\xi_i=\overline{a_i}$. Therefore $M=Q=0$ and the result follows. \end{proof} \subsection{Testing $s$-Term Monotone $r$-DNF}\label{TMDD} A {\it DNF} is a disjunction of terms. An {\it $r$-DNF} is a disjunction of $r$-terms. The class {\it $s$-Term $r$-DNF} is the class of all $r$-DNFs with at most $s$ terms. The class {\it $s$-Term Monotone $r$-DNF} is the class of all $r$-DNFs with at most $s$ terms with no negated variables. A DNF $f$ is called {\it unate DNF} if there is $\xi\in \{0,1\}^n$ such that $f(x_1^{\xi_1},\ldots,x_n^{\xi_n})$ is monotone DNF. If $\xi_i=0$ then we say that $f$ {\it is positive unate in $x_i$}; otherwise we say that $f$ {\it is negative unate in $x_i$}. Similarly, one can define the classes Unate DNF, Unate $s$-DNF etc. We first give a learning algorithm for $s$-Term Monotone $r$-DNF. The algorithm is in Figure~\ref{MDNFL}. In the algorithm, we use $P_{1/r}$ for the probability distribution over the strings $b\in \{0,1\}^n$ where each coordinate $b_i$ is chosen randomly and independently to be $1$ with probability $1-1/r$ and $0$ with probability $1/r$. For two strings $x,y\in \{0,1\}^n$ we denote $x*y=(x_1y_1,\ldots,x_ny_n)$ where $x_iy_i=x_i\wedge y_i$. The procedure {\bf FindMinterm}$(f,a)$ flips bits that are one in $a$ to zero as long as $f(a)=1$. \newcounter{ALCM} \setcounter{ALCM}{0} \newcommand{\stepM}{\stepcounter{ALCM}$\arabic{ALCM}.\ $\>} \newcommand{\steplabelM}[1]{\addtocounter{ALCM}{-1}\refstepcounter{ALCM}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf LearnMonotone}$(f,\D,\epsilon,\delta,s,r)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$\\ \>\> that is $s$-term monotone $r$-DNF and $\D$. \\ {\it Output}: $h$ that is $s$-term monotone $r$-DNF\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepM\steplabelM{MDNF00} $h\gets 0$. \\ \stepM\steplabelM{MDNF01} Repeat $4(s/\epsilon)\log(1/\delta)$ times. \\ \stepM\steplabelM{MDNF02}\> Choose $a\in \D$.\\ \stepM\steplabelM{MDNF03}\> If $f(a)=1$ and $h(a)=0$ then \\ \stepM\steplabelM{MDNF04}\>\> $t\gets 0$\\ \stepM\steplabelM{MDNF04b}\>\> While $t\le \alpha:=4r\ln(2ns/\delta)$ and $wt(a)>r$ do\\ \stepM\steplabelM{MDNF05a}\>\>\> $t\gets t+1;$ If $t=\alpha+1$ Output ``fail''\\ \stepM\steplabelM{MDNF05}\>\>\> Choose $y\in P_{1/r}$\\ \stepM\steplabelM{MDNF06}\>\>\> If $f(a*y)=1$ then $a\gets a*y$\\ \stepM\steplabelM{MDNF07a}\>\> $a\gets${\bf FindMinterm}$(f,a)$\\ \stepM\steplabelM{MDNF07}\>\> $h\gets h\vee \prod_{a_i=1}x_i$\\ \stepM\steplabelM{MDNF08} Output $h$ \end{tabbing} \end{minipage}}} \end{center} \caption{A learning algorithm for $s$-Term Monotone $r$-DNF} \label{MDNFL} \end{figure} We now show \begin{lemma}\label{LearnMDNF} If the target function $f$ is $s$-term monotone $r$-DNF then for any constant $\delta$, algorithm {\bf LearnMonotone} asks $O(s/\epsilon)$ ExQ$_D$ and $O(sr\log(ns))$ MQ and, with probability at least $1-\delta$, learns an $s$-term monotone $r$-DNF, $h$, that satisfies $\Pr_\D[h\not =f]\le \epsilon$. \end{lemma} \begin{proof} We first show that if in the $m$th iteration of the algorithm (steps \ref{MDNF02}-\ref{MDNF07}) the function $h$ contains $\ell$ terms of $f$ and $f(a)=1$ and $h(a)=0$ then, with probability at least $1-\delta/(2s)$, steps \ref{MDNF04} to \ref{MDNF07} adds to $h$ a new term of~$f$. This implies that in the $(m+1)$th iteration $h$ contains $\ell+1$ terms of $f$. Then, since the number of terms of $f$ is at most $s$, with probability at least $1-\delta/2$, all the terms in $h$ are terms in $f$. We then show that, with probability at least $1-\delta/2$, the procedure outputs $h$ that satisfies $\Pr_\D[h\not =f]\le \epsilon$. First notice that if $f(a)=1$ and $h(a)=0$ then for every $y\in\{0,1\}^n$, $h(a*y)=0$. This follows from the fact that $h$ is monotone and $a*y\le a$. Therefore if $a$ receives the values $a^{(1)},\ldots,a^{(\tau)}$ in the While loop then $f(a^{(i)})=1$ and $h(a^{(i)})=0$ for all $i=1,\ldots,\tau$. We also have $a^{(i+1)}=a^{(i)}$ if $f(a^{(i)}*y)=0$ and $a^{(i+1)}=a^{(i)}*y$ if $f(a^{(i)}*y)=1$. Consider the random variable $W_i=wt(a^{(i)})-r$. We will now compute $\E[W_{i+1}|W_i]$. Since $f(a^{(i)})=1$ and $h(a^{(i)})=0$, there is a term $T$ in $f$ that is not in $h$ that satisfies $T(a^{(i)})=1$. Suppose $T=x_{j_1}x_{j_2}\cdots x_{j_{r'}}$, $r'\le r$. Then $a^{(i)}_{j_1}=\cdots=a^{(i)}_{j_{r'}}=1$. Consider another $r-r'$ entries in $a^{(i)}$ that are equal to $1$, $a^{(i)}_{j_{r'+1}}=\cdots=a^{(i)}_{j_r}=1$. Such entries exist because of the condition $wt(a)>r$ of the While command. Note that $wt(a^{(i)})=W_i+r$. Let $j_{r+1},\ldots,j_{r+W_i}$ be the other entries of $a^{(i)}$ that are equal to $1$. Let $A$ be the event that, for the $y\in P_{1/r}$ chosen at this stage, $y_{j_1}=\cdots=y_{j_r}=1$. Notice that if event $A$ happens then $T(a^{(i+1)})=f(a^{(i+1)})=1$ and $a^{(i+1)}=a^{(i)}*y$. Then \begin{eqnarray} \E[W_{i+1}|W_i]&=&\E[W_{i+1}|W_i,A]\Pr[A]+\E[W_{i+1}|W_i,\bar A]\Pr[\bar A]\nonumber\\ &\le &\E[W_{i+1}|W_i,A]\left(1-\frac{1}{r}\right)^r+W_i\left(1-\left(1-\frac{1}{r}\right)^r\right)\label{pr01}\\ &= & W_i\left(1-\frac{1}{r}\right)^{r+1}+W_i\left(1-\left(1-\frac{1}{r}\right)^r\right)\label{pr02}\\ &=& W_i\left(1-\frac{1}{r}\left(1-\frac{1}{r}\right)^r\right)\le W_i\left(1-\frac{1}{4r}\right).\nonumber \end{eqnarray} The inequality in (\ref{pr01}) follows from the fact that $W_{i+1}\le W_i$ and (\ref{pr02}) follows from the fact that the expected number of ones in $y_{j_{r+1}}a_{j_{r+1}},\ldots,y_{j_{r+W_i}}a_{j_{r+W_i}}$ is $(1-1/r)W_i$. Therefore $\E[W_i]\le n(1-1/(4r))^i$. The probability that the algorithm fails is the probability that $t= 4r\ln(2ns/\delta)$. By Markov's Bound, Lemma~\ref{Markov}, this is bounded by $$\Pr[wt(a^{(t)})>r]=\Pr[W_t>1]\le \E[W_t]\le n\left(1-\frac{1}{4r}\right)^t\le \frac{\delta}{2s}.$$ This completes the first part of the proof. Now we show that, with probability at least $1-\delta/2$, the procedure outputs $h$ that satisfies $\Pr_\D[f\not= h]\le \epsilon$. Let $h^{(i)}$ be the function $h$ at iteration $i=1,2,\ldots,w$. Since $h^{(1)}\implies h^{(2)}\implies \cdots \implies h^{(w)}=h\implies f$, if $\Pr_\D[f\not= h]> \epsilon$ then $\Pr_\D[f\not= h^{(i)}]> \epsilon$ for all $i$. Therefore, the probability that $\Pr_\D[f\not= h]> \epsilon$ is less than the probability that for $v=4s\log(1/\delta)/\epsilon$ strings $a^{(1)},\ldots,a^{(v)}$ chosen independently at random according to the distribution $\D$, less than $s$ of them satisfies $g_i(a^{(i)})\not=f(a^{(i)})$ for Boolean functions $g_i$ that satisfy $\Pr_\D[g_i\not=f]\ge \epsilon$. By Chernoff's bound, Lemma \ref{Chernoff}, this probability is less than $\delta/2$. The algorithm asks at most $4s\log(1/\delta)/\epsilon=O(s/\epsilon)$ ExQ$_\D$ and at most $s\cdot 4r\ln(2ns/\delta)=O(sr\log (ns))$ MQ. \end{proof} Now we show \begin{theorem}\label{ThMon} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $s$-Term Monotone $r$-DNF that makes $\tilde O(rs^2/\epsilon)$ queries. \end{theorem} \begin{proof} The number of relevant variables in any $s$-term monotone $r$-DNF is at most $q\le k=sr$. By Lemma~\ref{LearnMDNF}, $C(Y)$ can be learned with constant confidence $\delta$ and accuracy $\epsilon$ in $M=\tilde O(sr\log(qs))=\tilde O(sr)$ MQ and $O(s/\epsilon)$ ExQ$_\D$. By Theorem~\ref{TesterL02}, there is a distribution-free tester for $s$-Term Monotone $r$-DNF that makes $\tilde O(s^2r/\epsilon)$ queries. \end{proof} \begin{theorem}\label{MUnate} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing $s$-Term Unate $r$-DNF that makes $\tilde O(rs^2/\epsilon)$ queries. \end{theorem} \begin{proof} The set of witnesses tells us, for every variable $x_i$, if $f$ is positive unate in $x_i$ or negative unate. If $f(v^{(\ell)})=1$, $f(0_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})=0$ then $f$ is positive unate in $x_{\tau(\ell)}$ and if $f(v^{(\ell)})=0$, $f(0_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})=1$ then $f$ is negative unate in $x_{\tau(\ell)}$. Then the result immediately follows from Theorem~\ref{ThMon}. \end{proof} \subsection{Testing Size-$s$ Decision Tree and Size $s$ Branching Program} A {\it decision tree} is a rooted binary tree in which each internal node is labeled with a variable $x_i$ and has two children. Each leaf is labeled with an output from $\{0,1\}$. A decision tree computes a Boolean function in an obvious way: given an input $x\in \{0,1\}^n$, the value of the function on $x$ is the output in the leaf reached by starting at the root and going left or right at each internal node according to whether the variable's value in $x$ is $0$ or $1$, respectively. The {\it size} of a decision tree is the number of leaves of the tree. The class size-$s$ Decision Tree is the class of all decision trees of size $s$. A {\it branching program} is a rooted directed acyclic graph with two sink nodes labeled $0$ and $1$. As in the decision tree, each internal node is labeled with a variable $x_i$ and has two children. The two edges to the children are labeled with $0$ and $1$. Given an input $x$, the value of the branching program on $x$ is the label of the sink node that is reached as described above. The {\it size} of a branching program is the number of nodes in the graph. The class size-$s$ Branching Program is the class of all Branching Program of size $s$. Diakonikolas et al.~\cite{DiakonikolasLMORSW07}, gave a tester for size-$s$ Decision Tree and size $s$ Branching Program under the uniform distribution that makes $\tilde O(s^4/\epsilon^2)$ queries. Chakraborty et al.~\cite{ChakrabortyGM11} improved the query complexity to $\tilde O(s/\epsilon^2)$. In this paper we prove \begin{theorem} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing size-$s$ Decision Tree and size-$s$ Branching Program that makes $\tilde O(s/\epsilon)$ queries. There is a two-sided distribution-free adaptive algorithm for $\epsilon$-testing size-$s$ Decision Tree and size $s$ Branching Program that makes $\tilde O(s^2/\epsilon)$ queries. \end{theorem} \begin{proof} For decision tree, $C(Y)$ contains the decision trees with $q=|Y|\le k=s$ relevant variables. It is shown in~\cite{DiakonikolasLMORSW07} that $|C(Y)|\le (8s)^s$. For branching programs $|C(Y)|\le (s+1)^{3s}$. Now by Theorem~\ref{FirstTester} the result follows. \end{proof} \subsection{Functions with Fourier Degree at most $d$} For convenience here we take the Boolean functions to be $f:\{-1,1\}^n\to \{-1,1\}$. Then every Boolean function has a unique Fourier representation $f(x)=\sum_{S\subseteq [n]} \hat f_S\prod_{i\in S}x_i$ where $\hat f_S$ are the {\it Fourier coefficients} of $f$. The {\it Fourier degree} of $f$ is the largest $d=|S|$ with $\hat f_S\not=0$. Let $C$ be the class of all Boolean functions over $\{-1,1\}^n$ with Fourier degree at most $d$. Nisan and Szegedy, \cite{NisanS92}, proved that any Boolean function with Fourier degree $d$ must have at most $k:=d2^d$ relevant variables. Diakinikolas et al.~\cite{DiakonikolasLMORSW07}, show that every nonzero Fourier coefficient of $f\in C$ is an integer multiple of $1/2^{d-1}$. Since $\sum_{S\subseteq [n]} \hat f_S^2=1$, there are at most $2^{2d-2}$ nonzero Fourier coefficients in $f\in C$. Diakonikolas et al.~\cite{DiakonikolasLMORSW07}, gave an exponential time tester for Boolean functions with Fourier degree at most $d$ under the uniform distribution that makes $\tilde O(2^{6d}/\epsilon^2)$ queries. Chakraborty et al.~\cite{ChakrabortyGM11} improved the query complexity to $\tilde O(2^{2d}/\epsilon^2)$. In this paper we prove \begin{theorem} For any $\epsilon>0$, there is a $poly(2^d,n)$ time two-sided distribution-free adaptive algorithm for $\epsilon$-testing for the class of Boolean functions with Fourier degree at most $d$ that makes $\tilde O(2^{2d}+2^d/\epsilon)$ queries. \end{theorem} \begin{proof} Bshouty gives in~\cite{Bshouty18} an exact learning algorithm for such class\footnote{The class in~\cite{Bshouty18} is the class of decision trees of depth $d$ but the analysis is the same for the class of functions with Fourier degree at most $d$} that asks $M=\tilde O(2^{2d}\log n)$ membership queries for any constant confidence parameter $\delta$. Now since $q=|Y|\le k=d2^d$, by Theorem~\ref{TesterL01} the result follows. \end{proof} \subsection{Testing Length $k$ Decision List} A decision list is a sequence $f=(x_{i_1},\xi_1,a_1),\ldots,(x_{i_s},\xi_s,a_s)$ for any $s$ where $\xi_i,a_i\in\{0,1\}$. This sequence represents the following function: $f(x):=$ If $x_{i_1}=\xi_1$ then output$(a_1)$ else if $x_{i_2}=\xi_2$ then output$(a_2)$ else if $\cdots$ else if $x_{i_s}=\xi_s$ then output$(a_s)$. Length-$k$ decision list is a decision list with $s\le k$. The class Decision List is the class of all decision lists and the class Length-$k$ Decision List is the class of all length-$k$ decision lists. It is known that this class is learnable under any distribution with $O((k\log n+\log (1/\delta))/\epsilon)$ ExQ$_D$,~\cite{BlumerEHW87,Rivest87}. This implies \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided distribution-free adaptive algorithm for $\epsilon$-testing Length-$k$ Decision List that makes $\tilde O(k^2/\epsilon)$ queries. \end{theorem} \begin{proof} The result follows from Theorem~\ref{TesterL02}. \end{proof} \subsection{Testing $s$-Sparse Polynomial of Degree $d$} A polynomial (over the field $F_2$) is a sum (in the binary field $F_2$) of monotone terms. An $s$-sparse polynomial is a sum of at most $s$ monotone terms. We say that the polynomial $f$ is of degree $d$ if its terms are monotone $d$-terms. The class $s$-Sparse Polynomial of Degree $d$ is the class of all $s$-sparse polynomials of degree~$d$. The class Polynomial of Degree~$d$ is the class of all polynomials of degree~$d$. In the uniform distribution model, Diakonikolas et al.~\cite{DiakonikolasLMORSW07}, gave the first testing algorithm for the class $s$-Sparse Polynomial that runs in exponential time and makes $\tilde O(s^4/\epsilon^2)$ queries. Chakraborty et al.~\cite{ChakrabortyGM11} improved the query complexity to $\tilde O(s/\epsilon^2)$. Diakonikolas et al. gave in~\cite{DiakonikolasLMSW11} the first polynomial time testing algorithm that makes $poly(s,1/\epsilon)$ queries. In~\cite{AlonKKLR03}, Alon et al. gave a testing algorithm for Polynomial of Degree $d$ that makes $O(1/\epsilon+d2^{2d})$ queries. They also show the lower bound $\Omega(1/\epsilon+2^d)$ for the number of queries. Combining those results we get a polynomial time testing algorithm for $s$-Sparse Polynomial of Degree $d$ that makes $poly(s,1/\epsilon)+\tilde O(2^{2d})$ queries. Just run the Alon et al. algorithm in~\cite{AlonKKLR03} and then run Diakonikolas et al. algorithm in~\cite{DiakonikolasLMSW11} and accept if both algorithms accept. Here we prove the following Theorem. \begin{theorem}\label{ThSpa} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing $s$-Sparse Polynomial of Degree $d$ that makes $\tilde O(s/\epsilon+s2^d)$ queries. For any $\epsilon>0$, there is a two-sided distribution-free adaptive algorithm for $\epsilon$-testing $s$-Sparse Polynomial of Degree $d$ that makes $\tilde O(s^2/\epsilon+s 2^d)$ queries. \end{theorem} We first give a learning algorithm {\bf LearnPolynomial} for $s$-sparse polynomial of degree $d$. See Figure~\ref{PFL}. \newcounter{ALCMP} \setcounter{ALCMP}{0} \newcommand{\stepMP}{\stepcounter{ALCMP}$\arabic{ALCMP}.\ $\>} \newcommand{\steplabelMP}[1]{\addtocounter{ALCMP}{-1}\refstepcounter{ALCMP}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf LearnPolynomial}$(f,\D,\epsilon,\delta,s,d)$}\\ {\it Input}: Oracle that accesses an $s$-sparse polynomial $f$\\ \>\> of degree $d$ and $\D$. \\ {\it Output}: An $s$-sparse polynomial of degree $d$, $h$, or ``fail''\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepMP\steplabelMP{nPF00} $h\gets 0$, $t(h)\gets 0$. \\ \stepMP\steplabelMP{nPF01} Repeat $(s/\epsilon)\ln(3s/\delta)$ times. \\ \stepMP\steplabelMP{nPF02}\> Choose $a\in \D$.\\ \stepMP\steplabelMP{nPF02b}\> $t(h)\gets t(h)+1$.\\ \stepMP\steplabelMP{nPF03}\> If $(f+h)(a)=1$ then \\ \stepMP\steplabelMP{nPF04}\>\> $m\gets 0$;\\ \stepMP\steplabelMP{nPF04b}\>\> While $m\le \alpha:=16\cdot 2^d(2\ln(s/\delta)+\ln n)$ and $wt(a)>d$ do\\ \stepMP\steplabelMP{nPF05a}\>\>\> $m\gets m+1;$ \\ \stepMP\steplabelMP{nPF05}\>\>\> Choose $y\in U$\\ \stepMP\steplabelMP{nPF06}\>\>\> If $(f+h)(a*y)=1$ then $a\gets a*y$\\ \stepMP\steplabelMP{nPF07x}\>\> If $wt(a)>d$ then ``fail''\\ \stepMP\steplabelMP{nPF07a}\>\> $M\gets$ Find a monotone term in $(f+h)(a*x)$\\ \stepMP\steplabelMP{nPF07}\>\> $h\gets h+ M$\\ \stepMP\steplabelMP{nPF07b}\>\> $t(h)\gets 0$.\\ \stepMP\steplabelMP{nPF08}\> If $t(h)=(1/\epsilon)\ln(3s/\delta)$ then Output $h$ \end{tabbing} \end{minipage}}} \end{center} \caption{A learning algorithm for $s$-sparse polynomial of degree $d$} \label{PFL} \end{figure} \begin{lemma}\label{LearnPolynomial} Let $f$ be an $s$-sparse polynomial of degree $d$. For any constant $\delta$, algorithm {\bf LearnPolynomial} asks $O((s/\epsilon)\log s)$ ExQ$_\D$ and $O(s 2^d$ $\log(ns))$ MQ and, with probability at least $1-\delta$, learns an $s$-sparse polynomial of degree $d$, $h$, that satisfies $\Pr_\D[h\not =f]\le \epsilon$. \end{lemma} \begin{proof} Suppose $f=\sum_{M\in F}M$, where $F$ are the set of monotone $d$-terms of $f$ and $|F|=s'\le s$. Suppose, at some stage of the algorithm $h=\sum_{M\in F'} M$ where $F'\subset F$. Then $f+h=\sum_{M\in F\backslash F'}M$. Notice that $F'$ is the set of terms of $f$ that is found by the algorithm up to this stage and $F\backslash F'$ is the set of terms that is yet to be found. Since the number of terms of $f$ is at most $s$, all we need to show is that: \begin{enumerate} \item Each time the algorithm executes steps~\ref{nPF04}-\ref{nPF07b}, with probability at least~$1-\delta/(2s)$, it finds a term of $f+h$, and therefore, a new term of $f$. \item Assuming 1., the algorithm, with probability at least $1-\delta/2$, outputs an $s$-sparse polynomial of degree $d$, $h$ that satisfies $\Pr_D[f\not=h]\le \epsilon$. \end{enumerate} Then, by the union bound, the success probability of the algorithm is at least $1-\delta$ and the result follows. We first prove 1. Let $g=f+h$. Suppose that the algorithm finds a string $a$ such that $g(a)=1$. Then $a$ satisfies at least one term in $g$. Let $M'\in F\backslash F'$ be one of them and let $d'\le d$ be the degree of $M'$ . Then $g(a*x)=\sum_{M\in F\backslash F', M(a)=1}M$ contains $M'$ and therefore $g(a*x)$ is not zero. We first show that the probability that after $\alpha_1:=16\cdot 2^d\ln(sn/\delta)$ iterations of steps~\ref{nPF04b}-\ref{nPF06}, the weight of $a$ does not drop below $24d$ is less than $\delta/(4s)$. Then we show that, if the weight of $a$ is less than or equal to $24d$ then the probability that after $\alpha_2:=\alpha-\alpha_1$ more iterations of steps~\ref{nPF04b}-\ref{nPF06} the weight of $a$ does not drop below $d+1$ is less than $\delta/(4s)$. If these two facts are true then after the algorithm finishes executing the While command, with probability at least $1-\delta/(2s)$, the weight of $a$ is less than $d+1$. It is known that for any non-zero polynomial $H$ of degree at most $d$, $\Pr_U[H(x)=1]\ge 1/2^d$,~\cite{BshoutyM02}. Since $g(a*x)$ is of degree at most $d$, for a random uniform string $y$ we get $\Pr[g(a*y)=1]\ge 1/2^d$. Now suppose $wt(a)\ge 24d$. By Chernoff's bound, Lemma~\ref{Chernoff}, the probability that $wt(a*y)>(3/4)wt(a)$ is at most $e^{-wt(a)/24}\le 2^{-d-1}$. Therefore, by the union bound, \begin{eqnarray} \Pr[g(a*y)=1 \mbox{\ and\ } wt(a*y)\le (3/4)wt(a)]\ge 1-\left(1-\frac{1}{2^d}+\frac{1}{2^{d+1}}\right)\ge \frac{1}{2^{d+1}}.\label{cO} \end{eqnarray} The probability that after $\alpha_1=16\cdot 2^d\ln(sn/\delta)$ iterations of steps~\ref{nPF04b}-\ref{nPF06}, the weight of $a$ does not drop below $24d$ is less than the probability that for $\alpha_1=16\cdot 2^d\ln(sn/\delta)$ random uniform strings~$y$, less than $\log(n)/\log(4/3)$ of them satisfies $g(a*y)=1$ and $wt(a*y)\le (3/4)wt(a)$ given that $a$ satisfies $wt(a)\ge 24d$ and $g(a*x)\not=0$. By (\ref{cO}) and Chernoff's bound this probability is less than $\delta/(4s)$. We now show that if $wt(a)<24d$, then after $\alpha_2=\alpha-\alpha_1=16\cdot 2^d\ln(s/\delta)$ iterations of steps~\ref{nPF04b}-\ref{nPF06}, with probability at least $1-\delta/(4s)$, the weight of $a$ drops below $d+1$. Take $a$ that satisfies $d+1\le wt(a)<24d$. Then \begin{eqnarray*} \Pr[g(a*y)=1\mbox{\ and\ }wt(a*y)< wt(a)]&\ge& \Pr[g(a*y)=1]-\Pr[wt(a*y)=wt(a)]\\ &\ge& \frac{1}{2^d}-\frac{1}{2^{d+1}}=\frac{1}{2^{d+1}}. \end{eqnarray*} Then as before, with an additional $\alpha_2$ iterations of steps~\ref{nPF04b}-\ref{nPF06}, with probability at least $1-\delta/(4s)$, the weight of $a$ drops below $d+1$. Once the weight of $a$ is less or equal to $d$, the algorithm finds in step~\ref{nPF07a} a monotone term in $g(a*x)$ by building a truth table of $g(a*x)$ using at most $2^d$ queries and learning one of its terms. This term is in $g$ because all the terms of $g(a*x)$ are terms of $g(x)$. The proof that the algorithm, with probability at least $1-\delta/2$, outputs $h$ such that $\Pr_D[f\not=h]\le \epsilon$ is identical to the proof in Lemma~\ref{cloose} for the output of {\bf ApproxTarget}. \end{proof} We are now ready to prove Theorem~\ref{ThSpa}. \begin{proof} By Lemma~\ref{LearnPolynomial}, Theorem~\ref{TesterL02} and since $n=|Y|=sd$, $Q=(s/\epsilon)\log s$ and $M=s2^d\log(sd)$ the result follows. \end{proof} \section{Testing Classes that are Close to $k$-Junta} In this section, we show the result for $s$-term DNF in the uniform distribution model. Then in the following section, we show how to extend it to other classes. The main idea is the following. We first run the procedure {\bf Approx$C$} in Figure~\ref{A3f} that finds $X\subset [n]$ and $w\in\{0,1\}^n$ such that, with high probability, \begin{enumerate} \item\label{pp01} The projection $x_X\circ w_{\overline{X}}$ removes variables from $f$ that appear only in terms of $f$ of size at least $c\log(s/\epsilon)$ for some large constant $c$. \item\label{pp02} $h=f(x_X\circ w_{\overline{X}})$ is $(\epsilon/8)$-close to $f$. \end{enumerate} From~(\ref{pp01}) we conclude that the terms of size at most $c\log(s/\epsilon)$ in $f$ contain all the variables of~$h$. Since the number of terms in $f$ is at most $s$ the number of variables that remain in $h$ is at most $k:=cs\log(s/\epsilon)$. From~(\ref{pp02}) we conclude that if $f$ is $\epsilon$-far from every $s$-term DNF then $h$ is $(7\epsilon/8)$-far from every $s$-term DNF and therefore $h$ is $(7\epsilon/8)$-far from every $s$-term DNF with at most $k$ variables. Therefore, it is enough to distinguish whether $h$ is an $s$-term DNF with at most $k$ variables or $(7\epsilon/8)$-far from every $s$-term DNF with at most $k$ variables. This can be done by the algorithm {\bf Tester$C$} in the previous section Note that removing variables that only appears in large size terms does not necessarily remove large terms in $f$. Therefore, $h$ may still contain large terms even after running {\bf ApproxTarget} in {\bf Tester$C$}. To handle large terms, we can use any learning algorithm that learns $h$ with accuracy $\epsilon/12$ and use Theorem~\ref{TesterL02}. This gives a tester for $s$-term DNF that makes $\tilde O(s^2/\epsilon)$ queries, which is not optimal. This is because the number of $s$-term DNF with at most $k$ variables is $m:=2^{O(ks)}$ (and therefore the number of queries in~{\bf Tester$C$} is at least $O((\log m)/\epsilon)=\tilde O(s^2/\epsilon)$). To get an optimal query tester, we do the following. We build a tester that uses only random uniform queries for the class $s$-term DNF with at most $k$ variables and terms of size at most $r=c'\log(s/\epsilon)$ where $c'$ is a large constant and show that this tester, with high probability, works well for $h$. The reason for that is that when the algorithm uses random uniform queries, with high probability, all the terms of $h$ that are of size greater than $r$ are zero for every query. Since the number of $s$-term DNF with at most $k$ variables and terms of size at most $r$ is at most $m=2^{O(rs\log k)}$ the number of queries in~{\bf Tester$C$} is at most $O(k/\epsilon+(\log m)/\epsilon)=\tilde O(s/\epsilon)$. In the next subsection, we give the procedure {\bf Approx$C$} that removes variables that only appear in large size terms, and in Subsection~\ref{RVAST}, we give the tester for $s$-Term DNF. Then in Section~\ref{result2}, we extend the above to other classes. \subsection{Removing Variables that only Appears in Large Size Terms} \newcounter{ALCf} \setcounter{ALCf}{0} \newcommand{\stepf}{\stepcounter{ALCf}$\arabic{ALCf}.\ $\>} \newcommand{\steplabelf}[1]{\addtocounter{ALCf}{-1}\refstepcounter{ALCf}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {\bf Algorithm Approx$C(f,\epsilon,\lambda)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ and \\ {\it Output}: Either ``$X\subseteq [n],w\in\{0,1\}^n$'' or ``reject''\\ \\ {\bf Partition $[n]$ into $r$ sets}\\ \stepf\steplabelf{par1f} Set $m=c\log(s/\epsilon)$; $r=8ms$.\\ \stepf\steplabelf{par2f} Choose uniformly at random a partition $X_1,X_2,\ldots,X_r$ of $[n]$\\ \\ {\bf Find a close function and relevant sets} \\ \stepf\steplabelf{Settf} Set $X=\emptyset$; $I=\emptyset$; $t(X)=0$; $k=3ms$\\ \stepf\steplabelf{twof} Repeat $M=100\lambda k\ln(100k)/\epsilon$ times\\ \stepf\steplabelf{Chof} \> Choose $u,v\in U$. \\ \stepf \> $t(X)\gets t(X)+1$\\ \stepf\steplabelf{con1f} \> If $f(u_X\circ v_{\overline{X}})\not=f(u)$ then\\ \stepf\steplabelf{Findf} \>\>\> Binary Search to find a new relevant set $X_\ell$; $X\gets X\cup X_\ell$; $I\gets I\cup \{\ell\}$.\\ \stepf\steplabelf{Rejf} \>\>\> If $|I|>k$ then output ``reject'' and halt.\\ \stepf\steplabelf{tx0f} \>\>\> $t(X)=0$.\\ \stepf\steplabelf{EndRepf} \> If $t(X)=100\lambda\ln(100k)/\epsilon$ then \\ \stepf\>\>\>\> Choose a random uniform $w$; \\ \stepf\>\>\>\> Output$(X,w,f(x_X\circ w_{\overline{X}}))$. \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that removes variables from $f$ that only appears in large size terms.} \label{A3f} \end{figure} We explain our technique by proving the result for $s$-term DNF. We remind the reader that for a term $T$, the size of $T$ is the number of variables that are in it. For a variable $x$ and $\xi\in\{0,1\}$, $x^\xi=x$ if $\xi=0$ and $x^\xi=\overline{x}$ if $\xi=1$. For a term $T=x_{i_1}^{c_1}\wedge \cdots\wedge x_{i_v}^{c_v}$ we denote by $\Va(T)=\{x_{i_1},\ldots,x_{i_v}\}$, the set of variables that appears in $T$. For a set of terms $\T$ we denote $\Va(\T)=\cup_{T\in\T}\Va(T)$. Here $\lambda > 1$ is any constant and we use $c = O(\log \lambda)$ to denote a large constant. Consider the procedure {\bf Approx$C$} in Figure~\ref{A3f}. We will prove the following two Lemmas \begin{lemma}\label{DNF1} Let $f$ be an $s$-term DNF. {\bf Approx$C$} makes $\tilde O(s/\epsilon)$ queries and, with probability at least $9/10$, outputs $X$ and $w$ such that \begin{enumerate} \item $f(x_X\circ w_{\overline{X}})$ is $s$-term DNF. \item The number of relevant variables in $f(x_X\circ w_{\overline{X}})$ is at most $3cs\log(s/\epsilon)=O(s\log(s/\epsilon))$. \end{enumerate} \end{lemma} \begin{lemma}\label{DNF2} Let $f$ be $\epsilon$-far from every $s$-term DNF. {\bf Approx$C$} makes $\tilde O(s/\epsilon)$ queries and either rejects, or with probability at least $9/10$, outputs $X$ and $w$ such that $f(x_X\circ w_{\overline{X}})$ is $(1-1/\lambda)\epsilon$-far from every $s$-term DNF. \end{lemma} We first prove Lemma~\ref{DNF1} \begin{proof} Consider an $s$-term DNF, $f=T_1\vee T_2\vee \cdots\vee T_{s'}$, where $s'\le s$. Let $\T=\{T_1,\ldots,T_{s'}\}$. Let $\T_1=\{T\in {\cal T} : |\Va(T)|\le m\}$ be the set of terms in $\T$ of size at most $m:=c\log(s/\epsilon)$ and let $R_1=\Va(\T_1)$ be the set of variables that appear in the terms in $\T_1$. Let $\T_2=\{T\in \T\ :\ |\Va(T)\backslash R_1|\le m\}$ be the set of terms $T\in\T$ that contain at most $m$ variables not in $R_1$. Let $R_2=R_1\cup \Va(\T_2)$ be the variables in $R_1$ and of the terms in $\T_2$. Let $\T_3=\{T\in \T\ :\ |\Va(T)\backslash R_1|> m\}$ be the set terms $T\in \T$ that contain more than $m$ variables that are not in $R_1$. Let $\T_4=\{T\in \T\ :\ |\Va(T)\backslash R_2|\ge m\}$ be the set of terms in $T\in \T$ that contain at least $m$ variables not in $R_2$. Let $R_3=R_2\cup \Va(\T_3\backslash \T_4)$ be the set of variables in $R_2$ and of the terms in $\T_3\backslash \T_4$. Then $$|R_1|\le ms,|R_2|\le 2ms, |R_3|\le 3ms \mbox{\ and\ } \T_4\subseteq \T_3.$$ In steps~\ref{par1f}-\ref{par2f}, procedure {\bf Approx$C$} uniformly at random partitions $[n]$ into $r=8ms$ sets $X_1,\ldots,X_r$. Suppose that the variables in $R_2$ are distributed to the sets $X_{j_1},\ldots,X_{j_q}$, $q\le |R_2|\le 2ms$. For each $T\in \T_4$, the expected number of variables in $\Va(T)\backslash R_2$ that are not distributed to one of the sets $X_{j_1},\ldots,X_{j_q}$ is greater or equal to $\left(1-{q}/{r}\right)m = (3/4)m$. By Hoeffding's bound, Lemma~\ref{Hoeffding}, and the union bound, the probability that it is greater than $m/2$ in every term $T\in \T_4$ is at least $1-s \cdot exp(-m/8)\ge 99/100$. In steps~\ref{Chof}-\ref{con1f} procedure {\bf Approx$C$} are repeated $M$ times and it finds relevant sets using two random uniform strings $u$ and $v$. If $f(u_X\circ v_{\overline{X}})\not=f(u)$ then a new relevant set is found. Consider any $T\in \T_3$. The size of $T$ is at least $m$. Suppose $T=x_{a_1}^{\xi_1}\wedge \cdots \wedge x_{a_{m'}}^{\xi_{m'}}$, $m'\ge m$. For random uniform $u,v\in\{0,1\}^n$, the probability that there is no $j\in[m']$ such that $u_{a_j}= (u_X\circ v_{\overline{X}})_{a_j}=\xi_j$ is at most $(3/4)^{m}$. The probability that this happens for at least one $T\in \T_3$ and at least one of the $M$ randomly uniformly chosen $u$ and $v$ in the procedure is at most $(3/4)^{m}sM\le 1/100$. Notice that if $u_{a_j}= (u_X\circ v_{\overline{X}})_{a_j}=\xi_j$ then $T(u)=T(u_X\circ v_{\overline{X}})=0$ and $T(w)=0$ for every string $w$ in the binary search that is made to find a new relevant set. Therefore, with probability at least $99/100$, the procedure runs as if $f$ contains no terms in $\T_3$. Let $f'=\vee_{T\in\T\backslash \T_3}T$. With probability at least $99/100$ the procedure runs as if $f=f'$. The number of relevant variables in $f'$ is at most $|R_2|\le 2ms$ and all those variables are distributed to $X_{j_1},\ldots,X_{j_q}$. Therefore, with probability at least $99/100$, the procedure generates at most $2ms<k$ relevant sets and therefore, by step~\ref{Rejf}, it does not reject and those relevant sets are from $X_{j_1},\ldots,X_{j_q}$. The output of the procedure is $X\subseteq X_{j_1}\cup\cdots\cup X_{j_q}$ and a random uniform $w$. We now show that with high probability $f(x_X\circ w_{\overline{X}})$ contains at most $k=3ms$ relevant variables. We have shown above that with probability at least $99/100$ every term $T\in \T_4$ contains at least $m/2$ variables that are not distributed to $X_{j_1},\ldots,X_{j_q}$. Therefore, for a fixed term $T\in\T_4$ and for a random uniform $w$, the probability that $T(x_X\circ w_{\overline{X}})=0$ is at least $1-(1/2)^{m/2}$. The probability that $T(x_X\circ w_{\overline{X}})=0$ for every $T\in \T_4$ is at least $1-s(1/2)^{m/2}\ge 99/100$. Therefore, when we randomly uniformly choose $w\in \{0,1\}^n$, with probability at least $99/100$, the function $f(x_X\circ w_{\overline{X}})$ does not contain terms from $\T_4$. Thus, with probability at least $99/100$, $f(x_X\circ w_{\overline{X}})$ contains at most $|R_3|\le 3ms$ variables. Now as in the proof of Lemma~\ref{Query01}, the query complexity is $2M+k\log r=\tilde O(s/\epsilon)$. \end{proof} We now prove Lemma~\ref{DNF2}. \begin{proof} As in the proof of Lemma~\ref{cloose}, the probability that the algorithm fails to output $X$ that satisfies $\Pr_{x,y\in U}[f(x_X\circ y_{\overline{X}})=f(x)]\le \epsilon/(100\lambda)$ is at most $$k\left(1-\frac{\epsilon}{100\lambda}\right)^{(100\lambda\ln(100/k))/\epsilon}=\frac{1}{100}.$$ If $\Pr_{x,y\in U}[f(x_X\circ y_{\overline{X}})=f(x)]\le \epsilon/(100\lambda)$ then, by Markov's inequality, Lemma~\ref{Markov}, for a random uniform $w$, with probability at least $99/100$, $\Pr_{x\in U}[f(x_X\circ w_{\overline{X}})=f(x)]\le \epsilon/\lambda$. Now as in the proof of Lemma~\ref{Query01}, the query complexity is $2M+k\log r=\tilde O(s/\epsilon)$. \end{proof} In the next subsection, we give the result for $s$-term DNF, and then we show how to use the above technique to other classes. \subsection{Testing $s$-term DNF}\label{RVAST} We have shown in Lemma~\ref{DNF1} and \ref{DNF2} that, using $\tilde O(s/\epsilon)$ queries, the problem of testing $s$-Term DNF can be reduced to the problem of testing $s$-Term DNF with $k=O(s\log(s/\epsilon))$ relevant variables. We then can use {\bf Tester$C$} for the latter problem. This gives a tester for $s$-term DNF that makes $\tilde O(s^2/\epsilon)$. This is because the number of $s$-term DNF with $k=O(s\log (s/\epsilon))$ relevant variables is $2^{\tilde O(s^2)}$. We will now show how to slightly change the tester {\bf Tester$C$} and get one that makes $\tilde O(s/\epsilon)$ queries. In {\bf Tester$C$} the procedures {\bf ApproxTarget}, {\bf TestSet} and {\bf Close$fF$} make $O(k\log k)$, $O(k)$ and $O((k/\epsilon)\log (k/\epsilon))$ queries, respectively. This is $\tilde O(s/\epsilon)$ queries. Therefore, the only procedure that makes $\tilde O(s^2/\epsilon)$ queries in {\bf Tester$C$} is {\bf Close$FCU$}. So we will change this procedure. Let $h$ be an $s$-term DNF. Notice that in step \ref{FFs16} in {\bf Close$FCU$}, for a random uniform $z=(z_1,\ldots,z_q)\in\{0,1\}^q$, the probability that $z$ satisfies a term $T$ in $h$ of size at least $c\log (s/\epsilon)$ (i.e., $T(z)=1$), is at most $(\epsilon/s)^c$. Therefore, if in {\bf Close$FCU$} we define $C^*$ to be the class of all $s$-term DNF with terms of size at most $c\log (s/\epsilon)$, then the probability that for at least one of the $\tau=(3/\epsilon)\log(|C^*|/\delta)$ random uniform $z=(z_1,\ldots,z_q)$ and at least one of the terms $T$ in $h$ of size at least $c\log (s/\epsilon)$, $T$ satisfies $z$, is at most $s\tau (\epsilon/s)^c\le 1/100$. Therefore, with probability at least $99/100$ the algorithm runs as if $h$ is $s$-term DNF with terms of size at most $c\log (s/\epsilon)$ and then accept. Since $\log|C^*|=\tilde O(s)$ we get \begin{theorem} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing $s$-Term DNF that makes $\tilde O(s/\epsilon)$ queries. \end{theorem} For completeness we wrote the tester. See {\bf TesterApprox$C$} in Figure~\ref{yTester}. In the tester $C(\{y_1,\ldots,y_q\},c\log(s/\epsilon))$ is the class of all $s$-term DNFs with terms of size at most $c\log(s/\epsilon)$ over $q$ variables. \section{Results}\label{result2} In this section, we extend the technique used in the previous section to other classes. \newcounter{yALC4} \setcounter{yALC4}{0} \newcommand{\ystepd}{\stepcounter{yALC4}$\arabic{yALC4}.\ $\>} \newcommand{\ysteplabeld}[1]{\addtocounter{yALC4}{-1}\refstepcounter{yALC4}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf TesterApprox$C$}$(f,\D,\epsilon)$}\\ {\it Input}: Oracle that access a Boolean function $f$ and $\D$. \\ {\it Output}: Either ``reject'' or ``accept''\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \ystepd\ysteplabeld{yFF001} $(X,w)\gets ${\bf Approx$C$}$(f,\epsilon,1/6)$. \\ \ystepd\ysteplabeld{yFF002} $h:= f(x_X\circ w_{\overline{X}})$.\\ \ystepd\ysteplabeld{yFF01} $(X,V,I)\gets ${\bf ApproxTarget}$(h,U,\epsilon,1/6)$. \\ \ystepd\ysteplabeld{yFF02} {\bf TestSets}$(X,V,I)$.\\ \ystepd {\bf Close$fF$}$(f,U,\epsilon,1/15)$\\ \ystepd\ysteplabeld{yFF07}$C^*\gets C(\{y_1,\ldots,y_q\},c\log(s/\epsilon))$ where $q=|V|$\\ {\bf Test closeness to $C^*$}\\ \ystepd\ysteplabeld{yFF15}Repeat $\tau=(3/\epsilon)\log(30|C^*|)$ times\\ \ystepd\ysteplabeld{yFF16}\> Choose $(z_1,\ldots,z_q)\in U$.\\ \ystepd\ysteplabeld{yFF17}\> For every $g\in C^*$\\ \ystepd\ysteplabeld{yFF18}\>\>If $g(z)\not=F(z)$ then $C^*\gets C^*\backslash \{g\}$.\\ \ystepd\ysteplabeld{yFF19}\>\>If $C^*=\emptyset$ then ``reject''\\ \ystepd\ysteplabeld{yFF20} Return ``accept'' \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure for testing $s$-Term DNF} \label{yTester} \end{figure} \subsection{Testing $s$-Term Monotone DNF} We first use the algorithm {\bf LearnMonotone} in Figure~\ref{MDNFL} to show \begin{lemma}\label{LearnMDNF2} Let $f:\{0,1\}^n\to \{0,1\}$ be an $s$-term Monotone DNF. For constant $\delta$, algorithm {\bf LearnMonotone}$(f,U,\epsilon/2,\delta/2,s,2(\log (s/\epsilon)+\log(1/\delta)))$ asks $O(s/\epsilon)$ ExQ$_U$ and $O(s(\log n+\log s)\cdot$ $\log (s/\epsilon))$ MQ and, with probability at least $1-\delta$, learns an $s$-term monotone DNF $h$ that satisfies $\Pr_U[h\not =f]\le \epsilon$. \end{lemma} \begin{proof} Let $\hat f$ be the function $f$ without the terms of size greater than $2(\log(s/\epsilon)+\log(1/\delta))$. Then $$\Pr_U[f\not=\hat f]\le s2^{-2(\log(s/\epsilon)+\log(1/\delta)))}\le \frac{\epsilon}{2}.$$ In the algorithm {\bf LearnMonotone} the probability that one of the assignments in step~\ref{MDNF02} (that is, $a$ where $a\in U$) satisfies one of the terms in $f$ of size greater than $2(\log(s/\epsilon)+\log(1/\delta))$ is less than $$(4s/\epsilon)(\log(1/\delta))s2^{-2(\log(s/\epsilon)+\log(1/\delta))}\le \frac{\delta}{2}.$$ Also for a monotone term $T$, if $T(a)=0$ then for any $y$, $T(a*y)=0$. Therefore, with probability at least $1-\delta/2$, the algorithm runs as if $f$ is $\hat f$ (which is $s$-term monotone $(2(\log(s/\epsilon)+\log(1/\delta)))$-DNF). By Lemma~\ref{LearnMDNF}, if the target is $\hat f$ then, with probability at least $1-\delta/2$, {\bf LearnMonotone} outputs $h$ that is $(\epsilon/2)$-close to $\hat f$. Since $\hat f$ is $(\epsilon/2)$-close to $f$ and $h$ is $(\epsilon/2)$-close to $\hat f$ we have that $h$ is $\epsilon$-close to $f$. This happens with probability at least $1-\delta$. The number of queries follows from Lemma~\ref{LearnMDNF}. \end{proof} We now prove \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $s$-Term Monotone DNF that makes $\tilde O(s/\epsilon)$ queries. \end{theorem} \begin{proof} We first run {\bf Approx$C$} and get an $s$-term monotone DNF $h$ with $O(s\log(s/\epsilon))$ variables that is $(\epsilon/6)$-close to $f$. We then use Theorem~\ref{TesterL02} with Lemma~\ref{LearnMDNF2}. \end{proof} We also have \begin{theorem} For any $\epsilon>0$, there is a polynomial time two-sided adaptive algorithm for $\epsilon$-testing $s$-Term Unate DNF that makes $\tilde O(s/\epsilon)$ queries. \end{theorem} \begin{proof} The proof is similar to the proof of Theorem~\ref{MUnate}.\end{proof} \subsection{Testing Size-$s$ Boolean Formula and Size-$s$ Boolean Circuit} A Boolean formula is a rooted tree in which each internal node has arbitrarily many children and is labeled with AND or OR. Each leaf is labeled with a Boolean variable $x_i$ or its negation $\bar x_i$. The size of a Boolean formula is the number of AND/OR gates it contains. The class size-$s$ Boolean Formula is the class of all Boolean formulas of size at most $s$. A Boolean circuit is a rooted directed acyclic graph with internal nodes labeled with an AND, OR or NOT gate. Each AND/OR gate is allowed to have arbitrarily many descendants. Each directed path from the root ends in one of the nodes $x_1,x_2,\ldots,x_n,0,1$. The same analysis that we did for $s$-term DNF also applies to size-$s$ Boolean formulas and size-$s$ Boolean circuit. Analogous to the size of terms, we take the number of distinct literals a gate has. If the gate is labeled with AND (respectively, OR) and the number of distinct literals it has is more than $c\log(s/\epsilon)$, then we replace the gate with a node labeled with $0$ (respectively, $1$) and remove all the edges to its children. Therefore we have \begin{lemma} Lemma~\ref{DNF1} and \ref{DNF2} are also true for size-$s$ Boolean formulas and size-$s$ Boolean circuit. \end{lemma} We now prove \begin{theorem} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing size-$s$ Boolean Formula that makes $\tilde O(s/\epsilon)$ queries. \end{theorem} \begin{proof} Similar to testing $s$-term DNF, we can ignore gates that have more than $c\log (s/\epsilon)$ distinct literals. Just replace it with $0$ if its label is AND and with $1$ if it is OR. The number of Boolean formulas of size $s$ that have at most $c\log (s/\epsilon)$ distinct literal in each gate and at most $k=O(s\log (s/\epsilon))$ variables is $2^{\tilde O(s)}$,~\cite{DiakonikolasLMORSW07}. The rest of the proof goes along with the proof of testing $s$-term DNF. \end{proof} The number of Boolean circuits of size $s$ that have at most $c\log (s/\epsilon)$ distinct literals in each gate and at most $k=O(s\log (s/\epsilon))$ variables is $2^{\tilde O(s^2)}$,~\cite{DiakonikolasLMORSW07}. Then similar to the above proof one can show \begin{theorem} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing size-$s$ Boolean Circuit that makes $\tilde O(s^2/\epsilon)$ queries. \end{theorem} \subsection{Testing $s$-Sparse Polynomial} In the literature, the first testing algorithm for the class $s$-Sparse Polynomial runs in exponential time~\cite{DiakonikolasLMORSW07} and makes $\tilde O(s^4/\epsilon^2)$ queries. Chakraborty et al., \cite{ChakrabortyGM11}, then gave another exponential time algorithm that makes $\tilde O(s/\epsilon^2)$ queries. Diakonikolas et al. gave in~\cite{DiakonikolasLMSW11} the first polynomial time testing algorithm that makes $poly(s,1/\epsilon)$ queries. Here we prove \begin{theorem} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing $s$-Sparse Polynomial that makes $\tilde O(s^2/\epsilon)$ queries. \end{theorem} \newcounter{ALCMp} \setcounter{ALCMp}{0} \newcommand{\stepMp}{\stepcounter{ALCMp}$\arabic{ALCMp}.\ $\>} \newcommand{\steplabelMp}[1]{\addtocounter{ALCMp}{-1}\refstepcounter{ALCMp}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf LearnPolyUnif}$(f,\epsilon,\delta,s)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$ that is $s$-sparse polynomial. \\ {\it Output}: $h$ that is $s$-sparse polynomial\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepMp\steplabelMp{pF00} $h\gets 0$, $t(h)\gets 0$, $w\gets 0$. \\ \stepMp\steplabelMp{pF01} Repeat $(s/\epsilon)\ln(3s/\delta)\log(3s/\delta)$ times. \\ \stepMp\steplabelMp{pF02}\> Choose $a\in U$.\\ \stepMp\steplabelMp{pF02b}\> $t(h)\gets t(h)+1$.\\ \stepMp\steplabelMp{pF03}\> If $(f+h)(a)=1$ then \\ \stepMp\steplabelMp{pF04}\>\> $m\gets 0$, $w\gets w+1$\\ \stepMp\steplabelMp{pF04x}\>\> If $w=\log(3s/\delta)$ then Output $h$\\ \stepMp\steplabelMp{pF04b}\>\> While $m\le \alpha:=16\cdot (8s/\epsilon)(2\ln(s/\delta)+\ln n)$ and $wt(a)>\log(s/\epsilon)+3$ do\\ \stepMp\steplabelMp{pF05a}\>\>\> $m\gets m+1;$ \\ \stepMp\steplabelMp{PF05}\>\>\> Choose $y\in U$\\ \stepMp\steplabelMp{PF06}\>\>\> If $(f+h)(a*y)=1$ then $a\gets a*y$\\ \stepMp\steplabelMp{PF07x}\>\> If $wt(a)>\log(s/\epsilon)+3$ then Goto~\ref{PF07b}\\ \stepMp\steplabelMp{PF07y}\>\> $w\gets 0$.\\ \stepMp\steplabelMp{PF07a}\>\> $a\gets$ Find a monotone term in $(f+h)(a*x)$\\ \stepMp\steplabelMp{PF07}\>\> $h\gets h+ \prod_{a_i=1}x_i$\\ \stepMp\steplabelMp{PF07b}\>\> $t(h)\gets 0$.\\ \stepMp\steplabelMp{PF08}\> If $t(h)=(1/\epsilon)\ln(3s/\delta)$ then Output $h$ \end{tabbing} \end{minipage}}} \end{center} \caption{A learning algorithm for $s$-sparse polynomial under the uniform distribution} \label{pFL} \end{figure} We have shown in Lemma~\ref{DNF1} and \ref{DNF2} that the problem of testing $s$-Term DNF can be reduced to the problem of testing $s$-Term DNF with $k=O(s\log(s/\epsilon))$ relevant variables. The same reduction and analysis show that the problem of testing $s$-sparse polynomials can be reduced to the problem of testing $s$-sparse polynomials with $k=O(s\log(s/\epsilon))$ relevant variables. The reduction makes $\tilde O(s/\epsilon)$ queries. Thus \begin{lemma} Lemma~\ref{DNF1} and \ref{DNF2} are also true for $s$-Sparse Polynomials. \end{lemma} We can then use {\bf Tester$C$} for the latter problem. Therefore, all we need to do in this section is to find a learning algorithm for the class of $s$-sparse polynomials with $k=O(s\log(s/\epsilon))$ relevant variables. Consider the algorithm {\bf LearnPolyUnif} in Figure~\ref{pFL}. We prove \begin{lemma}\label{LearnPolyUnif} Let $f$ be a $s$-sparse polynomial with $n$ variables. For constant $\delta$, algorithm {\bf LearnPolyUnif} asks $\tilde O(s/\epsilon)$ ExQ$_U$ and $\tilde O((s^2/\epsilon)\log n)$ MQ and, with probability at least $1-\delta$, learns an $s$-sparse polynomial $h$ that satisfies $\Pr_U[h\not =f]\le \epsilon$. \end{lemma} \begin{proof} Let $f=M_1+M_2+\cdots+M_{s'}$, $s'\le s$, where $deg(M_1)\le \cdots\le \deg(M_{s''})\le \log(s/\epsilon)+3 < deg(M_{s''+1})\le \cdots \le deg(M_{s'})$. Let $f_1=M_1+\cdots+M_{s''}$ and $f_2=M_{s''+1}+\cdots+M_{s'}$. Then $f=f_1+f_2$ and $\Pr_U[f_2=1]\le s2^{-\log(s/\epsilon)-3}=\epsilon/8$. If $f(a)\not=f_1(a)$ then $f_2(a)=1$ and therefore $\Pr_U[f\not=f_1]\le \Pr_U[f_2=1]\le \epsilon/8$ and $\Pr_U[f=f_1]\ge 1-\epsilon/8$. In fact, if $A(x)$ is the event that $T_i(x)=0$ for all $i>s''$ then $\Pr_U[A]\ge 1-\epsilon/8$. The algorithm {\bf LearnPolyUnif} is similar to the algorithm {\bf LearnPolynomial} with $d=\log(s/\epsilon)+3$ with the changes that is described below. First notice that in the algorithm the hypothesis $h$ contains only terms from $f_1$, that is, terms of size at most $\log(s/\epsilon)+3$. This is because in step~\ref{PF07x} the algorithm skips the command that adds a term to $h$ when $wt(a)\ge \log(s/\epsilon)+3$. Suppose at some stage of the algorithm, $h=\sum_{i\in B\subseteq [s'']}M_i$ contains some terms of $f_1$ and let $g=f+h=\sum_{i\in [s']\backslash B}M_i$. Suppose $\Pr_U[f\not=h]\ge \epsilon$. Then $\Pr_U[g=1]\ge \epsilon$. We want to compute the probability that the algorithm finds a term in $f_1+h=\sum_{i\in [s'']\backslash B}M_i$ and not in $f_2$. That is, the probability that it finds a term of $f$ of degree at most $\log(s/\epsilon)+3$. We first have \begin{eqnarray*} \Pr_{a\in U}[(f_1+h)(a)=1\wedge A |(f+h)(a)=1]&=&\Pr_{a\in U}[g(a)=1\wedge A |g(a)=1]\\ &=&\frac{\Pr_{a\in U}[g(a)=1\wedge A]}{\Pr_{a\in U}[g(a)=1]}\\ &\ge& \frac{\Pr_{a\in U}[g(a)=1]-\Pr_{a\in U}[\overline{A}]}{\Pr_{a\in U}[g(a)=1]}\\ &\ge& 1-\frac{\epsilon/8}{\epsilon}\ge \frac{7}{8}. \end{eqnarray*} That is, if $\Pr_U[f\not=h]\ge \epsilon$ and $(f+h)(a)=1$ then with probability at least $7/8$, $(f_1+h)(a)=1$ and for every term $T$ in $f_2$, $T(a)=0$. If the event $A(a)$ happens then for any $y$ and for every term $T$ in $f_2$, $T(a*y)=0$, and therefore, for such $a$, the algorithm runs as if the target is $f_1$. When the algorithm reaches step~\ref{pF03} and finds a string $a\in\{0,1\}^n$ such that $(f+h)(a)=1$, we have three cases: \begin{enumerate} \item The event $B\equiv [\ ((f_1+h)(a)=1$ and $A(a)]$ happens. \item $\Pr_U[f\not=h]\ge \epsilon$ and $\overline{B}$. \item $\Pr_U[f\not=h]< \epsilon$ and $\overline{B}$. \end{enumerate} {\bf Case 1.} Notice that steps~\ref{pF04b}-\ref{PF06} are identical to steps~\ref{nPF04b}-\ref{nPF06} in {\bf LearnPolynomial} in Figure~\ref{PFL} with $d=\log(s/\epsilon)+3$. Therefore, as in the proof of Lemma~\ref{LearnPolynomial}, with probability at least $1-\delta/3$ every assignment $a$ that satisfies $B$ gives a term in $f_1$ that is not in $h$. \noindent {\bf Case 2.} This case can happen with probability at most $1/8$. So the probability that it happens $\log(3s/\delta)$ consecutive times is at most $\delta/(3s)$. The probability that it does happen for some of the at most $s$ different hypothesis $h$ generated in the algorithm is at most $\delta/3$. Notice that $w$ counts the number of consecutive times that this case happens and step~\ref{pF04x} outputs $h$ when it does happen $\log(3s/\delta)$ consecutive times. Therefore, with probability at most $\delta/3$ the algorithm halts in step~\ref{pF04x} and output $h$ that satisfies $\Pr[f\not=h]\ge \epsilon$. This is also the reason that the algorithm repeats the search for $a$ in step~\ref{pF01}, $(s/\epsilon)\ln(3s/\delta)\log(3s/\delta)$ times which is $\log(3s/\delta)$ times more than in algorithm {\bf LearnPolynomial}. When this case happens, the algorithm either ends up with a string $a$ of weight that is greater than $\ell:=\log(s/\epsilon)+3$ and then it ignores this string, or, it ends up with a string of weight less than or equal to $\ell$ and then, Step~\ref{PF07a} finds a new term in $f_1$. This is because that a string of weight less than or equal to $\ell$ cannot satisfy a term of degree more than $\ell$. \noindent {\bf Case 3.} This case cannot happen more than $\log(3s/\delta)$ consecutive times because if it does step~\ref{pF04x} outputs $h$ which is a good hypothesis. \end{proof} \section{A General Method for Other Testers}\label{result3} In this section, we generalize the method we have used in the previous section and then prove some more results \newcounter{ALCG} \setcounter{ALCG}{0} \newcommand{\stepG}{\stepcounter{ALCG}$\arabic{ALCG}.\ $\>} \newcommand{\steplabelG}[1]{\addtocounter{ALCG}{-1}\refstepcounter{ALCG}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {\bf Algorithm ApproxGeneral$C$$(f,\epsilon,\delta)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$\\ {\it Output}: Either ``$X\subseteq [n],w\in\{0,1\}^n$'' or ``reject''\\ \\ {\bf Partition $[n]$ into $r$ sets}\\ \stepG\steplabelG{par1G} Set $r=k^{c+1}$.\\ \stepG\steplabelG{par2G} Choose uniformly at random a partition $X_1,X_2,\ldots,X_r$ of $[n]$\\ \\ {\bf Find a close function and relevant sets} \\ \stepG\steplabelG{SettG} Set $X=\emptyset$; $I=\emptyset$; $t(X)=0$\\ \stepG\steplabelG{twoG} Repeat $M=(4c_1k/(\delta\epsilon))\ln(4k/\delta)$ times\\ \stepG\steplabelG{ChoG} \> Choose $u,v\in U$. \\ \stepG \> $t(X)\gets t(X)+1$\\ \stepG\steplabelG{con1G} \> If $f(u_X\circ v_{\overline{X}})\not=f(u)$ then\\ \stepG\steplabelG{FindG} \>\>\> Find a new relevant set $X_\ell$; $X\gets X\cup X_\ell$; $I\gets I\cup \{\ell\}$.\\ \stepG\steplabelG{RejG} \>\>\> If $|I|>k$ then Output ``reject''\\ \stepG\steplabelG{tx0G} \>\>\> $t(X)=0$.\\ \stepG\steplabelG{EndRepG} \> If $t(X)=(4c_1/(\delta\epsilon))\ln(4k/\delta)$ then \\ \stepG\>\>\> Choose a random uniform $w$; \\ \stepG\>\>\> Output$(X,w)$. \end{tabbing} \end{minipage}}} \end{center} \caption{An algorithm that removes variables from $f$ that have a small influence.} \label{A3G} \end{figure} We define the distribution $\D[p]$ to be over $\prod_{i=1}^n\{0,1,x_i\}$ where each coordinate $i$ is chosen to be $x_i$ with probability $p$, $0$ with probability $(1-p)/2$ and $1$ with probability $(1-p)/2$. We will denote by $|f|$ the {\it size} of $f$ in $C$ which is the length of the representation of the function $f$ in $C$. Consider the algorithm {\bf ApproxGeneral$C$} in Figure~\ref{A3G}. We start with the following result \begin{lemma}\label{General} Let $\delta<1/2$, $c_1\ge 1,\lambda>1$ and $c\ge 1$ be any constants, $k:=k(\epsilon,\delta,|f|)$ be an integer and $M=(4c_1k/(\delta\epsilon))\ln(4k/\delta)$. Let $C$ be a class of functions where for every $f\in C$ there is $h\in (C\cap k$-Junta$)$ with relevant variables $x(Y)=\{x_i|x\in Y\}$, $Y\subseteq [n]$, and $h'\in (C\cap (\lambda k)$-Junta$)$ that satisfy the following: \begin{enumerate} \item\label{ConG1} $\Pr_{z\in \D[1/2]}[f(z)\not=h(z)]\le \delta/(4M)$. \item\label{ConG2} $\Pr_{y\in \D[1/k^c]}[f(x_Y\circ y_{\overline{Y}})\not= h'(y)]\le \delta/4$. \end{enumerate} The algorithm {\bf ApproxGeneral$C$} makes $\tilde O(k/\epsilon)$ queries and, \begin{enumerate} \item If $f\in C$ then, with probability at least $1-\delta$, the algorithm does not reject and outputs $X$ and $w$ such that $f(x_X\circ w_{\overline{X}})\in C$ has at most $\lambda k$ relevant variables. \item For any $f$, if the algorithm does not reject then, with probability at least $1-\delta$, $\Pr[f(x)\not =f(x_X\circ w_{\overline{X}})]\le \epsilon/c_1$. \end{enumerate} \end{lemma} \begin{proof} Let $f\in C$. Let $h\in C\cap k-$Junta and $h'\in (C\cap (\lambda k)$-Junta$)$ be functions that satisfies \ref{ConG1} and~\ref{ConG2}. The algorithm in step~\ref{ChoG} chooses two random uniform strings $u$ and $v$. Define $z=(z_1,\ldots,z_n)$ such that $z_i=0$ if $u_i=v_i=0$, $z_i=1$ if $u_i=v_i=1$, and $z_i=x_i$ if $u_i\not=v_i$. Since $u$ and $v$ are chosen uniformly at random we have that $z\in \D[1/2]$ and therefore, with probability at least $1-\delta/(4M)$, $f(z)=h(z)$. If $f(z)=h(z)$ then $f(u)=h(u)$ and $f(u_X\circ v_{\overline{X}})=h(u_X\circ v_{\overline{X}})$ for any $X\subseteq [n]$. In Step~\ref{FindG} {\bf ApproxGeneral} does a binary search to find a new relevant set. In the binary search it queries strings $a$ that satisfy $a_i=z_i=u_i=v_i$ for all $i$ that satisfies $z_i\in\{0,1\}$. Therefore, $f(a)=h(a)$ for all the strings $a$ generated in the binary search for finding a relevant set. Therefore, with probability at least $1-\delta/(4M)$, $f(a)=h(a)$ for all the queries used in one iteration and, with probability at least $1-\delta/4$, $f(a)=h(a)$ for all the queries used in the algorithm. That is, with probability at least $1-\delta/4$, the algorithm runs as if the target is $h$. Therefore, if $f\in C$, then with probability at least $1-\delta/4$, each one of the relevant sets discovered in the algorithm contains at least one relevant variable of $h$. Then since $h\in k$-Junta, the algorithm does not reject in Step~\ref{RejG}, that is, $|I|\le k$. Now we show that, if $f\in C$ then with probability at least $1-\delta/4$, $f(x_X\circ w_{\overline{X}})$ contains at most $\lambda k$ relevant variables. Consider the partition in steps~\ref{par1G}-\ref{par2G} in the algorithm and let $X_{i_1},\ldots,X_{i_{k'}}$, $k'\le k$, be the sets where the indices of the relevant variables $x(Y)$ of $h$ are distributed. Let $X'=X_{i_1}\cup \cdots \cup X_{i_{k'}}$. Notice that for a random uniform $w\in\{0,1\}^n$, $(x_{X'}\circ w_{\overline{X'}})=(x_Y\circ y_{\overline{Y}})$ where $y\in \D[k'/k^{c+1}]$. That is, given that the relevant variables of $h$ are distributed to $k'$ different sets that their union is $X'$, the probability distributions of $(x_{X'}\circ w_{\overline{X'}})$ and of $(x_Y\circ y_{\overline{Y}})$ are identical. Choosing a string in $\D[k'/k^{c+1}]$ can be done by first choosing a string $b$ in $\D[1/k^c]$ and then substitute in each variable $x_i$, $i\not\in Y$, in $b$, $0$, $1$ or $x_i$ with probability $1/2-k'/(2k)$, $1/2-k'/(2k)$ or $k'/k$, respectively. Therefore, since $\Pr_{y\in \D[1/k^c]}[f(x_Y\circ y_{\overline{Y}})\not= h'(y)]\le \delta/4$, we have $\Pr_{y\in \D[k'/k^{c+1}]}[f(x_Y\circ y_{\overline{Y}})\not= h'(y)]\le \delta/4$ and, thus, with probability at least $1-\delta/4$, we have that $f(x_{X'}\circ w_{\overline{X'}})=h'(x)$. In particular, with probability at least $1-\delta/4$, $f(x_{X'}\circ w_{\overline{X'}})$ has at most $\lambda k$ relevant variables. Since $X\subseteq X'$ we also have with the same probability $f(x_{X}\circ w_{\overline{X}})$ has at most $\lambda k$ relevant variables. This completes the proof of {\it 1.} Now let $f$ be any boolean function. If the algorithm does not reject then $|I|\le k$. Since for the final $X$, $f(u_X\circ v_{\overline{X}})\not=f(u)$ for $(4c_1/(\delta\epsilon))\ln(4k/\delta)$ random uniform $u$ and $v$, we have that the probability that the algorithm fails to output $X$ that satisfies $\Pr_{x,y\in U}[f(x_X\circ y_{\overline{X}})\not=f(x)]\le \delta\epsilon/(4c_1)$ is at most $$k\left(1-\frac{\delta\epsilon}{4c_1}\right)^{(4c_1/(\delta\epsilon))\ln(4k/\delta)}=\frac{\delta}{4}.$$ If $\Pr_{x,y\in U}[f(x_X\circ y_{\overline{X}})\not=f(x)]\le \delta\epsilon/(4c_1)$ then, by Markov's inequality, for a random uniform $w$, with probability at least $1-\delta/4$, $\Pr_{x\in U}[f(x_X\circ w_{\overline{X}})\not=f(x)]\le \epsilon/c_1$. This completes the proof of~{\it 2.} \end{proof} In the next subsections, we give some results that follow from Lemma~\ref{General}. \subsection{Testing Decision List} In \cite{DiakonikolasLMORSW07}, Diakonikolas et al. gave a polynomial time tester for Decision List that makes $\tilde O(1/\epsilon^2)$ queries. In this paper, we give a polynomial time tester that makes $\tilde O(1/\epsilon)$ queries. We show \begin{theorem}\label{kdl} For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing Decision List that makes $\tilde O(1/\epsilon)$ queries. \end{theorem} \begin{proof} Let $f=(x_{i_1},\xi_1,a_1),\ldots,(x_{i_s},\xi_s,a_s)$ be any decision list. We first use Lemma~\ref{General}. Define $k=\min(s,c'\log(1/(\epsilon\delta)))$ for some large constant $c'$ and $h=(x_{i_1},\xi_1,a_1),\ldots,(x_{i_k},\xi_k,a_k)$. For the distribution $\D[1/2]$, the probability that $f(z)=h(z)$ is $1$ when $k=s$ and at least $1-(3/4)^k\ge 1-1/(3M)$ where $M=(4c_1k/(\delta\epsilon))\ln(4k/\delta)$. For the distribution $\D[1/k^2]$ and $Y=\{i_1,\ldots,i_k\}$, the probability that $f(x_Y\circ y_{\overline{Y}})$ has more than $2 k$ relevant variables is less than $(3/4)^{k}\le \delta/3$. The query complexity of {\bf ApproxGeneral} is $\tilde O(k/\epsilon)=\tilde O(1/\epsilon)$. Therefore all we need to do to get the result is to give a tester for decision list of size $k=O(\log(1/\epsilon))$ that makes $\tilde O(1/\epsilon)$ queries. The learnability of this class with $\tilde O(1/\epsilon)$ ExQs follows from~\cite{Rivest87,BlumerEHW87}. \end{proof} \subsection{Testing $r$-DNF and $r$-Decision List for Constant $r$} An $r$-decision list is a sequence $f=(T_{1},\xi_1,a_1),\ldots,(T_{s},\xi_s,a_s)$ for any $s$ where $\xi_i,a_i\in\{0,1\}$ and $T_i$ are $r$-terms. This sequence represents the following function: $f(x):=$``If $T_{1}=\xi_1$ then output$(a_1)$ else if $T_{2}=\xi_2$ then output$(a_2)$ else if $\cdots$ else if $T_{s}=\xi_s$ then output$(a_s)$''. The class $r$-Decision List is the class of all $r$-decision lists and the class of Length-$s$ $r$-Decision List is the class of all $r$-decision lists $f=(T_{1},\xi_1,a_1),\ldots,(T_{m},\xi_m,a_m)$ with $m\le s$. In this subsection, we show \begin{theorem} Let $r$ be any constant. For any $\epsilon>0$, there is a two-sided adaptive algorithm for $\epsilon$-testing $r$-Decision List and $r$-DNF that makes $\tilde O(1/\epsilon)$ queries. \end{theorem} It is known that the class Length-$s$ $r$-Decision List is learnable under any distribution in time $O(n^r)$ using $O((sr\log n+\log (1/\delta))/\epsilon)$ ExQ$_D$,~\cite{BlumerEHW87,Rivest87}. Also we may assume that $T_1,\ldots ,T_s$ are distinct and therefore $s$ is less than $\sum_{i=1}^r{n\choose i}2^i$ , the number of terms of size at most $r$. Thus, for constant $r$, it is enough to prove that $r$-Decision List and $r$-DNF satisfies \ref{ConG1} and \ref{ConG2} in Lemma~\ref{General} with $k=poly(\log(1/\epsilon))$. We now prove the result for $r$-Decision List when $r$ is constant. The same analysis shows that the result is also true for $r$-DNF. Consider an $r$-decision list $f=(T_1,\xi_1,a_1)\cdots (T_s,\xi_s,a_s)$. If $\xi_i=0$ then we change $(T_i,0,a_i)$ to the equivalent expression $(x_{i_1}^{{1-c_{i_1}}},1,a_i)\cdots (x_{i_\ell}^{{1-c_{i_\ell}}},1,a_i)$ where $T_i=x_{i_1}^{c_1}\cdots x_{i_\ell}^{c_\ell}$. Therefore we may assume that $\xi_j=1$ for all $j$. In that case we just write $f=(T_1,a_1)\cdots (T_s,a_s)$. For an $r$-decision list $f=(T_1,a_1)\cdots (T_s,a_s)$, a {\it sublist of $f$} is an $r$-decision list $g=(T_{i_1},a_{i_1})\cdots $ $(T_{i_\ell},a_{i_\ell})$ such that $1\le i_1<i_2<\cdots<i_\ell\le s$. We first prove \begin{lemma} Let $r$ be a constant. For any $r$-decision list $f$ there is a $k_r:=O(\log^r(1/\epsilon))$-length $r$-decision list $h$ that is a sublist of $f$ and satisfies \ref{ConG1} and \ref{ConG2} in Lemma~\ref{General}. \end{lemma} \begin{proof} We show that it satisfies \ref{ConG1} in Lemma~\ref{General}. The proof that it also satisfies~\ref{ConG2} is similar. We give a stronger result as long as $r$ is constant. We prove by induction that for any $r$-decision list $f$ there is a $k_r=O(\log^{r}(1/\epsilon))$-length $r$-decision list $h$ that is a sublist of $f$ and satisfies $\Pr_{z\in \D[1/2]}[f(z)\not=h(z)]\le poly(\epsilon)$. The proof is by induction on $r$. For $r=1$, the result follows from the proof of Theorem~\ref{kdl} in the previous subsection. Assume the result is true for $r$-decision list. We now show the result for $(r+1)$-decision list. Let $c$ be a large constant. Let $f=(T_1,a_1)\cdots (T_s,a_s)$ be $(r+1)$-decision list. Let $s_1=1$ and $T_{s_1},\ldots,T_{s_w}$ be a sequence of terms such that $s_1<s_2<\cdots<s_w\le s$ and for every $i$, $s_i$ is the minimal integer that is greater than $s_{i-1}$ such that the variables in $T_{s_i}$ do not appear in any one of the terms $T_{s_1},T_{s_2},\ldots,T_{s_{i-1}}$. Define $h_0=(T_1,a_1)(T_2,a_2)\cdots (T_{s_{w'}},a_{s_{w'}})$ if $w':=c2^{r+1}\ln(1/\epsilon)\le w$ and $h_0=f$ if $w'>w$. Then \begin{eqnarray*} \Pr_{z\in \D[1/2]}[f(z)\not=h_0(z)]&\le&\Pr[T_{1}(z)=0\wedge T_{2}(z)=0\wedge \cdots\wedge T_{s_{w'}}(z)=0]\\\\ &\le&\Pr[T_{s_1}(z)=0\wedge T_{s_2}(z)=0\wedge \cdots\wedge T_{s_{w'}}(z)=0]\\ &\le& \left(1-\frac{1}{2^{r+1}}\right)^{w'}\le poly(\epsilon). \end{eqnarray*} Let $S=\{x_{j_1},\ldots,x_{j_t}\}$ be the set of the variables in $T_{s_1},\ldots,T_{s_{w'}}$. Then $t\le (r+1)w'=c(r+1)2^{r+1}\ln(1/\epsilon)$ and every term $T_i$ in $h_0$ contains at least one variable in $S$. Consider all the terms that contains the variable $x_{j_1}$, $T_{i_1}=x_{j_1}T_{i_1}',T_{i_2}=x_{j_1}T_{i_2}',\ldots,T_{i_\ell}=x_{j_1}T_{i_\ell}'$, $i_1<i_2<\cdots<i_\ell$. Consider the $r$-decision list $g:=(T'_{i_1},a_1)(T'_{i_2},a_2)\cdots(T'_{i_\ell},a_\ell)$. By the induction hypothesis there is an $r$-decision list $g'$ that is a sublist of $g$ of length at most $k_{r}=O(\log^{r}(1/\epsilon))$ such that $\Pr_{z\in \D[1/2]}[g(z)\not=g'(z)]\le poly(\epsilon)$. Let $h_1$ be $h_0$ without all the terms $(T_{i_w},a_{i_w})$ that correspond to the terms $(T_{i_w}',a_{i_w})$ that do not occur in $g'$. It is easy to see that $\Pr_{z\in \D[1/2]}[h_0(z)\not=h_1(z)]\le poly(\epsilon)$. We do the same for all the other variables $x_{j_2},\ldots,x_{j_t}$ of $S$ and get a sequence of $r$-decision lists $h_2,h_3,\ldots,h_t$ that satisfies $\Pr_{z\in \D[1/2]}[h_w(z)\not=h_{w+1}(z)]\le poly(\epsilon)$. Therefore $\Pr_{z\in \D[1/2]}[f(z)\not=h_{t}(z)]\le t \cdot poly(\epsilon)=poly(\epsilon)$ and the length of $h_t$ is at most $tk_{r}=O(\log^{r+1}(1/\epsilon))=k_{r+1}$. \end{proof} \section{Improvements and Further Results}\label{IFR} In this section, we go over the previous results and show how some modifications can give improved results. The improvements are in the logarithmic part of the query complexity. We concentrate on the first tester that test subclasses of $k$-Junta. Similar improvements can also be made for the second and third testers. \subsection{Improved {\it ApproxTarget} Procedure}\label{AppN} The procedure {\bf ApproxTarget} makes $O((k\log k)/\epsilon)$ queries. We show that the number of queries can be reduced to $O(k/\epsilon+k\log k)$. We call the new procedure {\bf IApproxTarget} The procedure {\bf IApproxTarget} repeats steps~\ref{Cho1}-\ref{tx01} in {\bf ApproxTarget} $M=16ck/\epsilon$ times and does not have step~\ref{EndRep1}, and therefore does not need the variable $t(X)$. It also saves all the values of $X$. Suppose it does not reject and $X$ takes the values $X^{(1)},X^{(2)},\ldots, X^{(k')}$ where $k'\le k$ and let $h^{(i)}=f(x_{X^{(i)}}\circ 0_{\overline{X^{(i)}}})$ for $i\in[k']$. In the case where the procedure does not reject we add another procedure that estimates $\Pr_{x\in\D}[h^{(i)}(x)\not=f(x)]$ for all $i\in [k']$, with constant multiplicative error and outputs $h^{(i)}$ with the least estimated value. This can be done with $N=(96c/\epsilon)\ln(60k)$ queries to ExQ$_\D$. We first prove that, with probability at least $29/30$, there is $i\in [k']$ such that $\Pr_{x\in\D}[h^{(i)}(x)\not=f(x)]\le \epsilon/(2c)$. For suppose there is no such $i$: Then all the functions $h^{(i)}$ are $(\epsilon/(2c))$-far from $f(x)$ and for $M=16ck/\epsilon$ random $u\in\D$ only $k'\le k$ of them witness that $h^{(i)}(x)\not=f(x)$ for some~$i$. By Chernoff's bound this can happen with probability at most $e^{-(7/8)^2\cdot 8k/2}\le e^{-3k}\le 1/30$. Now to distinguish between those that are $(\epsilon/(2c))$-close to $f$ and those that are $(\epsilon/c)$-far from $f$, by Chernoff's bound, we need to estimate all $\Pr_{x\in\D}[h^{(i)}(x)\not=f(x)]$, $i\in [k']$, with confidence probability $29/30$ and accuracy $\epsilon/(4c)$. For this we need $N\le (96c/\epsilon)\ln(60k)$ queries to ExQ$_\D$. We've proved \begin{lemma}\label{IApproxTarget} The {\bf IApproxTarget} makes $O(k/\epsilon+k\log k)$ queries. \end{lemma} Obviously, if the $h^{(\ell)}$ gets the least estimated value then the procedure removes from $V$ (and $I$) all the witnesses of $X^{(i)}$, $i>\ell$ and returns $(X^{(\ell)},V,I)$. \subsection{A General {\it TestSets} Procedure} In this subsection, we give a small change in the procedure {\bf TestSets} and show in the sequel how this change improves the query complexity. The general TestSets {\bf GTestSet} has another parameter $\beta<1/30$ as an input and calls {\bf UniformJunta}$(f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)}),1,\beta,1/15)$ in step~\ref{Uni1}. The other commands are the same. The value of $\beta$ will depend on the class being learned. The same proofs as for {\bf TestSet} give \begin{lemma}\label{TSG} Let $\beta<1/30$. The procedure {\bf GTestSet} satisfies \begin{enumerate} \item If for some $\ell\in I$, $f(x_{X_\ell}\circ v_{\overline{X_\ell}}^{(\ell)})$ is $\beta$-far from every literal with respect to the uniform distribution then, with probability at least $14/15$, {\bf GTestSet} rejects. \item {\bf GTestSet} makes $O(k/\beta)$ queries. \end{enumerate} \end{lemma} \subsection{A General {\it RelVarValue} Procedure} In this, subsection we give a small change in the procedure {\bf RelVarValue} and show in the sequel how this change improves the query complexity. The general RelVarValue {\bf GRelVarValue}$(w,X,V,I,\delta,\beta)$, that has another parameter $\beta<1/30$ as an input, repeats steps~\ref{feld03}-\ref{qqq2} $$h=\max(1,(\log(k/\delta))/\log(1/(3\sqrt{\beta})))$$ times. The other commands are the same. The value of $\beta$ will depend on the class being learned. We give the proof of the following \begin{lemma}\label{FinTest2} If for every $\ell\in I$ the function $f(x_{X_\ell}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $\beta$-close to a literal in $\{x_{\tau(\ell)},\bar{x}_{\tau(\ell)}\}$ with respect to the uniform distribution, where $\tau(\ell)\in X_\ell$, and $\{G_{\ell,0},G_{\ell,1}\}=\{0,h\}$ then, with probability at least $1-\delta$, we have: For every $\ell\in I$, $z_\ell=w_{\tau(\ell)}$. \end{lemma} \begin{proof} We follow the proof of Lemma~\ref{FinTest} with the same notations and the following changes in the proof. We have $$\E_{x_{X_\ell}\in U}[Z(x_{X_\ell})]\le \beta.$$ Therefore $$\E_{x_{Y_{\ell,1}}\in U}\E_{x_{Y_{\ell,0}}\in U}[Z(x_{Y_{\ell,0}}\circ x_{Y_{\ell,1}})]\le \beta$$ and by Markov's bound $$\Pr_{x_{Y_{\ell,1}}\in U}\left[ \E_{x_{Y_{\ell,0}}\in U}[Z(x_{Y_{\ell,0}}\circ x_{Y_{\ell,1}})]\ge \sqrt{\beta}\right]\le \sqrt{\beta}.$$ That is, for a random uniform string $b\in \{0,1\}^n$, with probability at least $1-\sqrt{\beta}$, $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $\sqrt{\beta}$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution. Now, given that $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $\sqrt{\beta}$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution the probability that $G_{\ell,0}=0$ is the probability that $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ for $h$ random uniform strings $b\in \{0,1\}^n$. Let $b^{(1)},\ldots,b^{(h)}$ be $h$ random uniform strings in $\{0,1\}^n$, $V(b)$ be the event $f(b_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})= f(\overline{b_{Y_{\ell,0}}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ and $A$ the event that $f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$ is $\sqrt{\beta}$-close to $x_{\tau(\ell)}$ with respect to the uniform distribution. Let $g(x_{Y_{\ell,0}})=f(x_{Y_{\ell,0}}\circ b_{Y_{\ell,1}}\circ v^{(\ell)}_{\overline{X_\ell}})$. Then \begin{eqnarray*} \Pr[V(b)|A] \le \Pr[g(\overline{b_{Y_{\ell,0}}})\not=\overline{b_{\tau(\ell)}}|A] +\Pr[g({b_{Y_{\ell,0}}})\not={b_{\tau(\ell)}})|A]\le 2\sqrt{\beta}. \end{eqnarray*} Since $\tau(\ell)\in Y_{\ell,0}$, we have $w_{\tau(\ell)}=0$. Therefore, by step~\ref{Gl} and since $\tau(\ell)\in X_\ell$, \begin{eqnarray*} \Pr[z_\ell\not=w_{\tau(\ell)}] \le \left( \Pr[V(b)|A]+\Pr[\overline{A}]\right)^h \le (3\sqrt{\beta})^h \end{eqnarray*} Therefore, the probability that $z_{\ell}\not =w_{\tau(\ell)}$ for some $\ell\in I$ is at most $k(3\sqrt{\beta})^h\le \delta$. \end{proof} The following is obvious \begin{lemma}\label{GRVV} The procedure {\bf GRelVarValues} makes $O(k+k(\log(k/\delta))/\log(1/\beta)))$ queries. \end{lemma} \subsection{Improved {\it Close$fF$} Procedure} \newcommand{\Var}{{\bf Var}} The procedure {\bf Close$fF$} makes $O((k/\epsilon)\log(k/\epsilon))$ queries. We show that the number of queries can be reduced to $O((k/\epsilon)+(k/\epsilon)\log(k/\epsilon)/\log(1/\beta))$ queries in the distribution-free model and $$O(k\log(1/\epsilon)+k\log(1/\epsilon)\log (k\log(1/\epsilon))/\log(1/\beta)+1/\epsilon)$$ queries in the uniform distribution model. We call the new procedures {\bf IClose$fF$} and {\bf IUClose$fF$}. Notice that if you choose $\beta=\epsilon$, the query complexity of {\bf TestSets} is $O(k/\epsilon)$ and the query complexity of {\bf Close$fF$} is $O((k/\epsilon)(1+(\log k)/\log(1/\epsilon)))$ queries in the distribution-free model and $O(k\log k+k\log\log(1/\epsilon)+1/\epsilon)$ queries in the uniform distribution model. The former complexity is $O(k/\epsilon)$ when $\epsilon=1/k^{\Omega(1)}$. For {\bf IClose$fF$} we just take the procedure {\bf Close$fF$} and instead of calling {\bf RelVarValue} it calls {\bf GRelVarValues} with the parameter $\beta$. \begin{lemma}\label{IClauseQQ} For any constant $\delta$, procedure {\bf IClose$fF$} makes $O((k/\epsilon)+(k/\epsilon)(\log(k/\epsilon))/\log(1/\beta))$ queries. \end{lemma} When the distribution is uniform, rather than choosing random uniform and independent strings $u$ we choose random uniform pairwise independent strings. We choose $t=O(\log(1/\epsilon))$ random uniform and independent strings $W=\{w^{(1)},\ldots,w^{(t)}\}$ and generate random uniform pairwise independent strings from the linear space that are spanned by $W$. It is enough to run {\bf GRelVarValues} for the strings in $W$ to find $w^{(1)}_\Gamma,\ldots,w^{(t)}_\Gamma$ because for any other string $u=\sum_{i=1}^t \eta_i w^{(i)}$ in the linear space we have $u_\Gamma=\sum_{i=1}^t \eta_i w^{(i)}_\Gamma$. The algorithm is in Figure~\ref{CloseI}. \newcounter{ALCI} \setcounter{ALCI}{0} \newcommand{\stepI}{\stepcounter{ALCI}$\arabic{ALCI}.\ $\>} \newcommand{\steplabelI}[1]{\addtocounter{ALCI}{-1}\refstepcounter{ALCI}\label{#1}} \begin{figure}[h!] \begin{center} \fbox{\fbox{\begin{minipage}{28em} \begin{tabbing} xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill {{\bf IUClose$fF$}$(f,\epsilon,\delta,\beta)$}\\ {\it Input}: Oracle that accesses a Boolean function $f$. \\ {\it Output}: Either ``reject'' or ``OK''\\ \\ xxx\=xxxx\=xxxx\=xxxx\=xxxx\=xxxx\= \kill \stepI\steplabelI{co00I} Define $F\equiv f(x(\pi_{f,I})\circ 0_{\overline{X}})$.\\ \stepI\steplabelI{co01I} Choose $t=\log(12/(\epsilon\delta))$ i.i.d. strings $w^{(1)},\ldots,w^{(t)}\in U$ \\ \stepI\steplabelI{co02I} For $i=1$ to $t$.\\ \stepI\steplabelI{co03I}\> $\zeta^{(i)}\gets${\bf GRelVarValue}$(w^{(i)},X,V,I,\delta/(2t),\beta)$ .\\ \stepI\steplabelI{co03NI}Choose arbitrary $m=6/(\epsilon\delta)$ non-zero strings $\xi^{(1)},\ldots,\xi^{(m)}\in \{0,1\}^t$ \\ \stepI\steplabelI{co04I} For $i=1$ to $m$.\\ \stepI\steplabelI{co05I}\> Set $u\gets \sum_{j=1}^t\xi^{(i)}_jw^{(j)}; z\gets \sum_{j=1}^t\xi^{(i)}_j\zeta^{(j)}$; \\ \stepI\steplabelI{co05I}\> If $f(u_X\circ 0_{\overline{X}})\not=F(z)$ then ``reject''\\ \stepI\steplabelI{co06I} Return ``OK'' \end{tabbing} \end{minipage}}} \end{center} \caption{A procedure that tests whether $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ with respect to the uniform distribution.} \label{CloseI} \end{figure} \begin{lemma}\label{FirstAppUI} For any constant $\delta$ and $(X,V,I)$ that satisfies Assumption~\ref{assmp}, procedure {\bf IUClose$fF$} makes $O(k\log(1/\epsilon)+(k\log(1/\epsilon)\log (k\log(1/\epsilon))/\log(1/\beta)+1/\epsilon)$ queries and \begin{enumerate} \item\label{FirstAppUI1} If $f\in C$ then {\bf IUClose$fF$} outputs OK. \item\label{FirstAppUI2} If $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ then, with probability at least $1-\delta$, {\bf IUClose$fF$} rejects. \end{enumerate} \end{lemma} \begin{proof} The proof of~{\it \ref{FirstAppUI1}} is the same as in the proof of Lemma~\ref{FirstApp}. We now prove~{\it \ref{FirstAppUI2}}. Let $u^{(i)}= \sum_{j=1}^t\xi^{(i)}_jw^{(j)}$ and $z^{(i)}= \sum_{j=1}^t\xi^{(i)}_j\zeta^{(j)}$ for $i\in [m]$. By Lemma~\ref{FinTest2} and \ref{GRVV}, with probability at least $1-\delta/2$, $\zeta^{(i)}=w^{(i)}_\Gamma$ for all $i\in [t]$ . The map $x\to x_\Gamma$ is a linear map and therefore, with probability at least $1-\delta/2$, $u^{(i)}_\Gamma=z^{(i)}$ for all $i\in [m]$. Define, for $i\in [m]$, the event $A_i=1$ if $f(u^{(i)}_X\circ 0_{\overline{X}})\not=F(z^{(i)})$ and $0$ otherwise. Let $A=\sum_{i\in [m]}A_i$. Then $\epsilon':=\E[A_i]\ge \epsilon/3$, $\mu:=\E[A]= \sum_{i\in[m]} \epsilon'=\epsilon'm\ge \epsilon m/3=2/\delta$ and $\Var[A_i]=\epsilon'-\epsilon'^2$. Since $A_i$ are pairwise independent, $\Var[A]=\sum_{i\in [m]}\Var[A_i]=\mu(1-\epsilon').$ By (\ref{Chebyshev2}) in Lemma~\ref{Chebyshev} we have $$\Pr[\mbox{Algorithm outputs ``OK''}]=\Pr[A=0]\le \Pr[|A-\mu|\ge \mu]\le \frac{\Var[A]}{\mu^2}\le \frac{1}{\mu}\le \frac{\delta}{2}.$$ Therefore, if $f(x_X\circ 0_{\overline{X}})$ is $(\epsilon/3)$-far from $F$ then, with probability at least $1-\delta$, {\bf IUClose$fF$} rejects. The query complexity follows from Lemma~\ref{GRVV}. \end{proof} \subsection{A Weaker ExQ$_\D$} In this subsection, we define a weak ExQ$_\D$, WExQ$_\D$, and show that learning with WExQ$_\D$ and MQ gives a tester for $F(y)$ using a better query complexity. We then show that in many of the learning algorithms in this paper, ExQ$_\D$ can be replaced with WExQ$_\D$. We define the WExQ$_\D$ that returns with probability $1/2$ a string drawn according to distribution $\D$ and with probability $1/2$ an arbitrary string (chosen by an adversary). We now show that in some of the learning algorithms in this paper one can replace ExQ$_\D$ with WExQ$_\D$ We first show \begin{lemma}\label{LearnMDNF3} For constant $\delta$, there is a polynomial time learning algorithm for $s$-Term Monotone $r$-DNF that makes $O(s/\epsilon)$ WExQ$_D$ and $O(sr\log(ns))$ MQ and, with probability at least $1-\delta$, learns an $s$-term monotone $r$-DNF $h$ that satisfies $\Pr_\D[h\not =f]\le \epsilon$. \end{lemma} \begin{proof} Consider the algorithm {\bf LearnMonotone} in Figure~\ref{MDNFL} with WExQ$_\D$. If steps~\ref{MDNF01}-\ref{MDNF07} are repeated $16(s/\epsilon)\log(1/\delta)$ times then with probability at least $1-\delta$, more than $4(s/\epsilon)\log(1/\delta)$ of the examples received by the WExQ$_\D$ are according to the distribution $\D$. The rest of the proof follows directly from the proof of Lemma~\ref{LearnMDNF}. \end{proof} Consider now algorithm {\bf LearnPolynomial} in Figure~\ref{PFL} that learns $s$-sparse polynomial over $F_2$ of Degree $d$. We can use the technique in Subsection~\ref{AppN}, to get an algorithm that learns this class with $O(s/\epsilon)$ ExQ$_\D$ and $O(2^d\log(ns))$ MQ. Then as in the proof of Lemma~\ref{LearnMDNF2} the ExQ$_\D$ can be replaced with WExQ$_\D$. Therefore \begin{lemma}\label{LearnPolynomial2} For constant $\delta$, there is a polynomial time learning algorithm for $s$-Sparse Polynomial of Degree $d$ that makes $O(s/\epsilon)$ WExQ$_\D$ and $O(2^ds\log(ns))$ MQ and, with probability at least $1-\delta$, learns an $s$-sparse polynomial of degree $d$, $h$, that satisfies $\Pr_\D[h\not =f]\le \epsilon$. \end{lemma} \subsection{An Improved Query Complexity} We first show \begin{theorem}\label{ThTriv2} Let $C\subseteq k$-Junta. If there is a polynomial time algorithm ${\cal A}$ that, given as an input a constant $\delta$, any $\epsilon$ and $(X,V,I)$ that satisfies Assumption~\ref{assmp}, learns $C(Y)$ with respect the distribution $\D$ (resp. uniform distribution), with confident $\delta$, accuracy $\epsilon$, makes $M(\epsilon,\delta)$ $MQ$ to $F$ and $Q(\epsilon,\delta)$ ExQ$_\D$ (resp. WExD$_\D$, ExD$_U$) queries to $F$ then there is a polynomial time tester ${\cal T}_\D$ (resp. ${\cal T}_{W\D}$, ${\cal T}_U$) for $C$ that makes $$O\left(\frac{k}{\epsilon}+k\log k+M'+kQ'+k\cdot\frac{\frac{1}{\epsilon}\log k+Q'\log(kQ')}{\log\frac{1}{\epsilon}+\log\log k+\log Q'}\right)$$ queries (resp. $$O\left(\frac{k}{\epsilon}+k\log k+M'+kQ'+k\log k\cdot \frac{\frac{1}{\epsilon}+Q'}{\log\frac{1}{\epsilon}+\log\log k+\log Q'}\right),$$ $$O\left(\frac{k}{\epsilon}+k\log k+M'+Q'\right)$$ queries) where $Q'=Q(\epsilon/12,1/24)$, $M'=M(\epsilon/12,1/24)$ and \begin{enumerate} \item If $f\in C$ then, with probability at least $2/3$, ${\cal T}_\D$, ${\cal T}_{W\D}$ and ${\cal T}_U$ accepts. \item If $f$ is $\epsilon$-far from every function in $C$ with respect to ${\cal D}$ then, with probability at least $2/3$, ${\cal T}_\D$ (resp. ${\cal T}_{W\D}$) rejects. \item If $f$ is $\epsilon$-far from every function in $C$ with respect to the uniform distribution then, with probability at least $2/3$, ${\cal T}_U$ rejects. \end{enumerate} \end{theorem} \begin{proof} We run {{\bf Tester$C$}$(f,\D,\epsilon)$} in Figure~\ref{Tester1} with the following changes: In step~\ref{FF01} we run the procedure {\bf IApproxTarget}$(f,\D,\epsilon,1/3)$. By Lemma~\ref{IApproxTarget}, it uses $O(k/\epsilon+k\log k)$ queries. In step~\ref{FF02} we run the procedure {\bf GTestSet}$(X,V,I,\beta)$. By Lemma~\ref{TSG}, it uses $k/\beta$ queries. The value of $\beta$ will be determined later. In step~\ref{FF03}, we will run the procedure {{\bf IClose$fF$}$(f,\D,\epsilon,1/15,\beta)$} for any distribution $\D$ and {{\bf IUClose$fF$}$(f,\epsilon,1/15,\beta)$} for the uniform distribution. By Lemma~\ref{IClauseQQ}, {\bf IClose$fF$} makes $O(k/\epsilon+(k/\epsilon)(\log(k/\epsilon))/\log(1/\beta))$ queries. By Lemma~\ref{FirstAppUI}, {\bf IUClose$fF$} makes $$O(k\log(1/\epsilon)+k\log(1/\epsilon)\log (k\log(1/\epsilon))/\log(1/\beta)+1/\epsilon)$$ queries. By Lemma~\ref{LtoT01} and~\ref{GRVV}, to distinguish between $F\in C(Y)$ and $F$ $\epsilon$-far from every function in $C(Y)$ we need to ask $M'$ MQ and $Q''=Q'+ O(1/\epsilon)$ ExQ$_\D$ queries to $f$. For that we need to run {\bf GRelVarValue}$(w,X,V,I,1/(24Q''),\beta)$, $Q''$ times. This takes $O(kQ''+kQ''(\log(kQ''))/\log(1/\beta))$ queries. To make $Q''$ WExQ$_\D$, by Lemma~\ref{GRVV}, we need to run {\bf GRelVarValue}$(w,X,V,I,1/2,\beta)$, $Q''$ times. This takes $O(kQ'+kQ'(\log k)/\log(1/\beta))$ queries. For the uniform distribution we just need $Q'$ queries. For MQ we need $M'$ queries. Now for the distribution-free model we choose (resp. with WExQ$_\D$) $$\beta=\frac{\log^2\left(\frac{1}{\epsilon}\log\frac{k}{\epsilon}+Q''\log(kQ'')\right)}{\frac{1}{\epsilon}\log \frac{k}{\epsilon}+Q''\log(kQ'')}$$ (resp. $$\beta=\frac{\log^2\left(\frac{1}{\epsilon}\log\frac{k}{\epsilon}+Q'\log k\right)}{\frac{1}{\epsilon}\log \frac{k}{\epsilon}+Q'\log k}$$) and get the result. For the uniform distribution model we choose $\beta=\epsilon$ and get the result. \end{proof} We note here that when $Q'=0$ then we define $\log 0=0$. \subsection{Some Improved Results} \begin{figure}[h!] \begin{center} \begin{tabular}{|c|c|c|} \hline & {\bf Distri-} & {\bf $\#$Queries} \\ {\bf Class of Functions} & {\bf bution} & {\bf Complexity} $O(\cdot)$ \\ \hline \hline $s$-Term Monotone $r$-DNF & U & $\frac{sr}{\epsilon}+sr\log(sr)$ \\ \cline{2-3} $s$-Term Unate $r$-DNF & D & $sr\log r+\frac{s^2r}{\epsilon}+\frac{s^2r}{\epsilon}\frac{\log r}{\log s+\log\log r+\log\frac{1}{\epsilon}}$ \\ \hline $k$-Junta, $k$-Term & U & $\frac{k}{\epsilon}+k\log k$ \\ \cline{2-3} and $k$-Linear & D & $ \frac{k}{\epsilon}+k\log k+\frac{\frac{k}{\epsilon}\log k}{\log\frac{1}{\epsilon}+\log\log k}$ \\ \hline Length $k$ Decision List & U & $\frac{k\log k}{\epsilon}$ \\ \cline{2-3} & D & $\frac{k^2\log k}{\epsilon}$ \\ \hline size-$s$ Decision Trees and& U & $\frac{s\log s}{\epsilon}$ \\ \cline{2-3} size-$s$ Branching Programs & D & $\frac{s^2\log s}{\epsilon}$ \\ \hline F. With Fourier Degree $\le d$& D & $\frac{d2^d}{\epsilon}+d^52^{2d}$\\ \hline \end{tabular} \end{center} \caption{A table of the results. In the table, $U$ and $D$ stand for uniform and distribution-free model.} \label{TABLE2} \end{figure} In this subsection, we give some of the results. See the Table in Figure~\ref{TABLE2}. For $k$-Junta we have $M'=Q'=0$ and then by Theorem~\ref{ThTriv2}, we get the query complexity $O(k/\epsilon+k\log k)$ for the uniform model and $$ O\left(\frac{k}{\epsilon}+k\log k+\frac{\frac{k}{\epsilon}\log k}{\log\frac{1}{\epsilon}+\log\log k}\right)$$ for the distribution-free model. Notice that, the latter query complexity is $O(k/\epsilon+k\log k)$ when $1/\epsilon=O(\log\log k)$ or $1/\epsilon=k^{\Omega(1)}$. The same result follows for the classes $k$-Linear and $k$-Term. For $s$-Term Monotone $r$-DNF and $s$-Unate $r$-DNF, by Lemma~\ref{LearnMDNF2}, there is an algorithm that learns $F\in C(Y)$ with $k=sr$ variables with $M'=O(sr\log(sr))$ MQ and $Q'=O(s/\epsilon)$ WExQ$_\D$. This gives the result in the Table. For Length-$k$ Decision List, $M'=0$ MQ and $Q'=O((k/\epsilon)\log k)$ WExQ$_\D$. By Theorem~\ref{ThTriv2}, we get the query complexity $O(k(\log k)/\epsilon)$ for the uniform model and $O(k^2(\log k)/\epsilon)$ for the distribution-free model. It is an open problem whether the class of Length-$k$ Decision List is learnable with $O(k/\epsilon)$ ExQ$_\D$. If it is, then the query complexity can be reduced to $O(k/\epsilon+k\log k)$ for the uniform model $O(k^2/\epsilon)$ for the distribution-free model. For Functions with Fourier Degree $\le d$, it is known from~\cite{Bshouty18}, Lemma 21, that this class is learnable with $O(d^32^{2d}\log^2n)$ queries. Therefore, $k=d2^d$, $M'=O(d^52^{2d})$ and $Q'=0$. By Theorem~\ref{ThTriv2}, we get a query complexity $O(d2^d/\epsilon+d^52^{2d})$ in the distribution-free model.
{'timestamp': '2019-11-11T02:11:34', 'yymm': '1904', 'arxiv_id': '1904.09958', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09958'}
arxiv
\section{Introduction} Few international institutions are as ubiquitous as military alliances. With far reaching consequences, interstate military alliances influence almost every aspect of international politics. Even the foundational theory of international relations, balance of power theory, is a theory about when states should aggregate their capabilities through alliances. However, for a concept so integral to so many international processes and research areas in international relations, little attempt has been made to empirically examine variation in why states form alliances. Since the foundation of international relations, alliances have been considered a means of promoting state security through deterring attack, balancing competitors, or preparing for an inevitable conflict \citep{carr1939twenty, hans1948politics, waltz1979theory, mearsheimer2001tragedy, johnson2017external}. Empirical approaches have largely mirrored this understanding \citep{lai2000democracy, leeds2002alliance, leeds2003alliance, gibler2006alliances}, while a variety of theoretically-motivated studies have pushed back, recognizing the variety of motives states may have for forming alliances \citep{morrow1991alliances, schroeder1994historical, schroeder1996transformation, kim2016supply, henke2017politics}. Recent empirical work has highlighted that alliances may vary in their design \citep{leeds2002alliance}, but the initial conditions motivating their formation are thought to be relatively homogenous. While theoretically-motivated scholars have been increasingly interested in empirically considering variation \citep{kim2016supply, henke2017politics}, it has been largely been limited to particular case studies. The previous discussion highlights two distinct approaches dominating the study of military alliances. The peace science approach is empirically-driven and uses systematic and rigorous data to uncover meaningful empirical insights about the causes and consequences of alliances. The security studies approach is more theoretically motivated, using context and diplomatic history to provide a rich and nuanced conceptualization of alliances. Unfortunately, these approaches rarely engage with one another, and within the strength of one lays the weakness of the other. While the peace science approach yields tractable empirical insights, it does so by invoking a flat and non-comprehensive view of alliances. This view emphasizes the Capability Aggregation Model (CAM) which holds that states, motivated by an external security threat, form alliances to aggregate capabilities and consolidate their security. Many security studies scholars have long voiced their opposition, arguing that alliances are complex institutions, and states form alliances for a variety of motives. While the security studies approach provides a means of understanding this nuance, generating inferences is difficult as empirically assessing and generalizing this variation is difficult. In this manuscript, I unify these perspectives, answering several questions: \textit{Are alliances only formed to respond to external threats? Do contextual factors influence states' motives for forming alliances? How do we synthesize the parsimonious Capability Aggregation Model with contextual factors? How do the objectives motivating alliance formation differ from one another, and how would we measure these differences? Is this desire to differentiate alliances analytically useful?} Synthesizing the peace science and security studies approach, I introduce a new role-based framework for considering variation in alliance design and objective. This role-based framework holds that states adopt roles within the alliance network that vary across systemic context, and design their local alliance network to accomplish role-motivated objectives. These roles are thought to vary across two dimensions -- whether they are order pursuing/preserving or narrowly utilitarian, and whether the aggregation of capabilities is the chief means to accomplish their objectives or if institutional means are essential. States may adopt the role of Balancer (Ordering, Capability Aggregating), Aggregator (Narrowly Utilitarian, Capability Aggregating), Reformer (Ordering, Institutional), or Consolidator (Narrowly Utilitarian, Institutional), each possessing its own logic and objectives motivating local alliance network design. These roles are uncovered using the ego-Temporal Exponential Random Graph Model (ego-TERGM), a novel statistical innovation that allows analysts to sort ``ego-networks" (e.g. a state and their allies) into a finite number of clusters according to similarity. This model allows for both the generation of data on roles and an assessment of the generative process for these roles. By synthesizing the richness of the security studies approach with the rigor of the peace science approach, I find that the Capability Aggregation Model of alliances is inadequate and that scholars should empirically consider the heterogeneous and non-security motives driving states to form military alliances. While security-based roles are detected, states are frequently found to form alliances to consolidate economic or political relationships and to promote domestic reforms. The roles uncovered are also found to vary according to historical context. This novel approach has far reaching implications for how IR scholars consider alliance formation and evolution, and the consequences of different alliance types. \section{State Objectives Influencing Alliance Design} The literatures on alliance formation and maintenance span two schools with two distinct approaches: peace science and security studies. The conventional wisdom in peace science, and international relations broadly, is embodied by the parsimonious and generalizable Capability Aggregation Model (CAM). The CAM holds that states form and maintain alliances to balance peer competitors, deter potential attack, improve bargaining power, or prepare for what is perceived to be an inevitable conflict \citep{johnson2017external}. This perspective has dominated the empirical literature on alliances as its parsimonious logic makes modeling alliance behavior simple and tractable using existing data sources. While such motivations inform many alliances, there remain cases that this logic cannot explain, including the enlargement of the North Atlantic Treaty Organization (NATO) \citep{waltz2000structural}, the post-Cold War evolution of the Organization of American States (OAS) \citep{pevehouse2005democracy, therien2012changing}, or the formation of the Economic Community of West African States (ECOWAS) \citep{ukeje2005economic}. Security studies and diplomatic history, on the other hand, offers nuanced explanations for why particular alliances form and evolve without emphasizing generalizable or empirically-oriented logics capable of detecting such patterns. In other words, within the \textit{strength} of one approach lies the \textit{weakness} of the other. While international relations and peace science possesses a generalizable and parsimonious model of alliances that travels to many cases and makes empirical modeling easy, it fails in explaining a great many important alliances. While security studies and diplomatic history can offer nuance and explain the contexts driving particular alliances, it lacks a general framework capable of detecting consistent logics. In this manuscript I argue that a synthesis of these approaches is necessary to further theoretical and empirical innovation. \subsection{Alliances as Responses to External Threats} The peace science approach, the dominant perspective within international relations, holds that states, motivated by some common external threat aggregate their capabilities to increase their security, bargaining power, and/or war-fighting capabilities beyond what they would be in the absence of a formal obligation alone \citep{morrow2000alliances, johnson2017external}. This perspective is attractive for empirical modeling as it allows the analyst to assume there is a homogenous data generating process.\footnote{This perspective was certainly not created by peace scientists, nor is it only adopted by peace scientists or the only perspective within peace science. Regardless, I label this perspective the peace science approach as it is the modal perspective in peace science, which is one of the most active literatures and most empirically-oriented literatures on alliances.} This view was propagated by early Realists and has dominated international relations since its founding. In his call for a scientific study of international politics, \citet{carr1939twenty} critiqued Interwar foreign policymaking which prioritized ideals to a pursuit of the national interest. This view, formalized by \citet{hans1948politics}, identifies national power as the chief motive of states. Implicit to this logic is that states seek power to secure their sovereignty from external threats, and that at times, alliances may be necessary to ensure security. While many have debated the precise conditions necessitating such power politics and alliance decisions \citep{waltz1979theory, walt1990origins, mearsheimer2001tragedy}, the consequence is the same: states form alliances to secure their survival against external threats. Once these threats are removed, their corresponding alliances should dissolve \citep[904]{morrow1991alliances}. With the quantitative shift in international relations and the rise of peace science, the empirical work on alliances has largely adopted these parsimonious assumptions. Invoking this assumption makes modeling challenges much more tractable as analysts can assume there is a homogenous data generating process that is easily measurable. Early quantitative work on alliances emerged from the Correlates of War (COW) Project which coded alliances according to whether the alliance was a defense pact, a neutrality and non-aggression pact, or an entente \citep{singer1966formal}. These data have been used to examine many questions, including the factors influencing alliance formation \citep{lai2000democracy} and whether alliances deter or provoke conflict \citep{singer1966formal, smith1995alliance, gibler2006alliances}. Building upon this dataset, \citet{leeds2002alliance} introduced the Alliance Treaty Obligations and Provisions (ATOP) dataset which included additional data on aspects of alliance design. These data represent the state of the art and have allowed for a more rigorous examination of the factors underlying alliance formation \citep{leeds2002alliance, cranmer2012toward, cranmer2012complex}, and its effects on conflict \citep{leeds2003alliances}, trade \citep{long2006trading, fordham2010trade} and more \citep{benson2016assessing}.\footnote{There are many other well known and widely cited articles I would like to mention here, but journals have word limits.} It is not the COW or ATOP coding decisions that are problematic, but rather an analyst's comfortability in assuming a homogenous data generating process, treating alliances as varying only in commitment and not objective. There are several challenges to this approach. First, Diplomatic Historians have long noted that the empirical record challenges the ``no functional differentiation" assumption, arguing that states perform highly specialized functions \citep{schroeder1994historical}. Consider the OAS, an alliance formed to counter Soviet expansion into the Western Hemisphere, only to update its primary mission following the Cold War -- to accomplish a series of non-security goals including political and economic liberalization \citep{pevehouse2005democracy, therien2012changing}. Second, world politics reflects a highly dynamic system where a variety of time varying material and immaterial forces influence state behavior. Failing to model alliances as a function of this dynamic system may produce flawed inferences, as noted by \citet{jenke2016theme}. As such, treating alliances and their formational logic as time invariant may produce flawed inferences. Unit and temporal heterogeneity in alliance decision-making has certainly been explored by IR scholars, but never in a systematic way that posits a framework capable of competing with the CAM, leaving much of the work on alliance heterogeneity to diplomatic history and security studies. \citet{holsti1970national} enumerated the foreign policy roles states adopted during the Cold War, which almost certainly influenced their motives for forming alliances. An early piece by Russett used factor analysis to cluster alliances on a variety of background and output variables to produce an alliance typology based upon an alliance's distribution of capabilities \citep{russett1971empirical}. In a recent study \citet{benson2016assessing} consider variation in the commitments enshrined in treaties, but does not consider the motivations for distinct commitments. The effect of alliances on conflict are also thought to differ before and after the advent of nuclear weapons \citep{kenwick2015alliances}. Existing understandings of alliance heterogeneity have failed to articulate a theoretical or empirical framework capable of explaining why alliances are formed or evolve to accomplish objectives beyond those outlined by the CAM. \subsection{Alliances as Heterogenous Institutions} While diplomatic historians have certainly championed balance of power theory \citep{taylor1954struggle}, the modal approach holds that alliances possess a great degree of specialization and are used to accomplish many objectives \citep{schroeder1994historical, kissinger1994diplomacy, schroeder1996transformation, bridge2014great}. In his well known retort to \citet{waltz1979theory}, \citet{schroeder1994historical} argues that states have unique logics of political survival and have sought survival through performing specialized roles (125). This call for nuance in treating alliances as institutions formed for a variety of reasons, while largely falling on deaf ears within mainstream international relations, has been recently heralded by security studies scholars. States have different logics of political survival and have different instruments for achieving them. This functional differentiation in the roles adopted and performed by states has significant consequences for how and why states form alliances. The objective of the United States following World War II was to contain the Soviet Union through establishing alliances in any area at risk of communist infiltration \citep{holsti1970national, kissinger1994diplomacy}. The \textit{Chief Balancer} role ascribed to and adopted by the United States was well understood and certainly transformed the US' incentive structure, driving it to design its local alliance network to be consistent with this role. Following the Cold War, the US is widely thought to adopt the new role as \textit{Hegemon}, a promoter of a global order based upon liberal institutions \citep{ikenberry2012liberal}. The US and its allies adjusted their existing alliance network accordingly, bringing former Soviet satellites into NATO and establishing a new mission for the OAS. This nuanced view is standard within diplomatic history and security studies, with scholars offering rich and sophisticated narratives for the historical context of each state, and how the position ascribed to them informs how they design alliances \citep{schroeder1994historical, schroeder1996transformation, ikenberry2012liberal, bridge2014great, kim2016supply, henke2017politics}. While many mainstream IR scholars or peace scientists might argue that the alliance system constructed by Metternich following the Concert of Vienna was an attempt to aggregate Russian, Prussian, and Austrian capabilities to prevent the return of Napoleon or to counter a very dominant United Kingdom \citep{jervis1992political}, many diplomatic historians are quick to recognize that the Holy Alliance was a pact among autocrats to protect sovereigns against rising nationalism and to promote a new order based upon cooperation \citep{schroeder1992did}. Within security studies, theoretically-motivated work has explored variation in why states contract alliances. In criticizing the CAM and its inability to explain alliances formed between great powers and weak powers, \citet{morrow1991alliances} introduced the Security-Autonomy Tradeoff Model which sought to explain the asymmetric gains of states forming alliances. Relatedly, \citet{kim2016supply} has introduced a market theory of alliances, viewing alliances as a good exchanged between states wherein security may be exchanged for concessions in other areas. Additionally, \citet{henke2017politics} explores how a variety of non-military factors influence a state's admittance to a multilateral military coalition. While these are just examples from a much broader literature, a common thread has been the development of sophisticated and rich understandings and theories of alliances. Unfortunately, diplomatic historians and security studies scholars often lack parsimonious and generalizable frameworks for considering alliances or detecting patterns of alliance behavior. They bring rich nuance to the study of alliances, often at the cost of producing systematic or rigorous empirical insights or predictions. As \citet{jervis1992political} notes, one large attraction of the IR approach to considering alliances is that it is relatively straightforward, parsimonious, and with a few simple assumptions it can explain a ``great deal of behavior that has taken place over tens of centuries under widely differing circumstances." This generalizability, a strength of the IR approach, is certainly a significant weakness of the diplomatic history approach to studying alliances. How might one synthesize these rich and context-based understandings of alliances with the generalizable models that interest IR scholars and peace scientists? In the following section I attempt to answer this question by introducing a new role-based framework for considering military alliances, combining the richness of diplomatic history and security studies with the empirically-motivated peace science tradition. \section{The Role Framework of Alliance Politics}\label{theory} In this section a role-based framework for considering alliances is presented. The intention is not to explicitly theorize about why states adopt certain roles or to be exhaustive in enumerating the innumerable specialized roles a state may adopt. Instead, the focus is to discuss what a ``role" is within the context of the alliance network, what these functionally differentiable roles might look like, what general patterns in roles might be detected, how they might be differentiated, and how they may vary as a function of time and system features. It is worth mentioning that the roles that actors adopt are undeniably dynamic and informed by systemic factors. A broader discussion of this temporal heterogeneity and system-based expectation is included in the Supplementary Information (SI) Appendix. I explicitly model this heterogeneity when later assessing this framework. \subsection{Roles and the Alliance Network} Within international relations and political science broadly, the dominant understanding of roles stems from \citet{wendt1999social}. For Wendt, a role is the cultural position an actor performs by occupying a place within a social structure and observing behavioral norms towards Others who perform a counter-role \citep[227]{wendt1999social}. Roles, as they are discussed in this manuscript, differ from Wendt's understanding. Social roles, as discussed here, refer to cultural objects that are widely accepted and understood within a given community and used to accomplish certain objectives \citep{campbell2017detecting}. This definition is similar to Wendt's in that roles are attributes of a broader system and are rooted in certain repeated and emergent practices. While both understand roles as structural features, Wendt views them as mutually constitutive while I view them as purpose-based. In other words, I believe that states have more agency in making these decisions. In addition, role need not necessarily precede behavior, in some cases role may be adopted to conform to current behavior. Within the context of the alliance network, a network defined by states related to one another through the presence of shared alliance treaties, states may adopt whatever roles their alters and the broader system will allow them to. This view of states stands in contrast to the strong assumption often invoked that states are not functionally differentiable, that they only differ with respect to relative capabilities \citep{waltz1979theory, schroeder1994historical}. If states behave differently based upon observable roles, then the theoretical underpinnings for much of modern international relations theory must be reevaluated. In the following section I give cause for such concern. \subsection{Roles and Objectives for Alliance Formation} As previously noted, and discussed in \citet{holsti1970national}, the CAM holds that states only form alliances to further objectives consistent with one of three roles: Balancer, Aggressor, or Defender. It is undeniable that across time and space, this capability-aggregation function of alliances is a constant. The stated role of the US and other NATO members as both Balancers and Defenders during the Cold War is clear \citep{holsti1970national}. What is less clear is whether one can say that these roles persist when the supposed Aggressor, the USSR, dissolves. Without a clear threat or motive, the CAM cannot make sense of NATO's post-Cold War expansion \citep{morrow1991alliances, waltz2000structural}. To make sense of this puzzle, I introduce a role-based framework for considering alliances. This approach differs from the much narrower CAM by positing that states may have motives for adopting roles that are not simply motivated by countering external threats. The framework presented here holds that there are four ``types" of states in the alliance network that are characterized by the role adopted and their expected behavior. These roles are sorted according to two characteristics, forming the configuration presented in Table \ref{2by2}. The first significant dimension that may sort alliances is whether the alliance is formed for some order-based objective or whether the alliance should be considered narrowly utilitarian \citep{lake2009regional, schweller2011after, ikenberry2012liberal, ikenberry2014power}. When considering order, one must consider the role of ideology which certainly informs an actor's preferences with respect to ideal orders. Within this context, the international orders pursued by states ``represent sets of governing arrangements, rules, and norms designed to secure the constituent units against external threat, at the cost of limiting their autonomy," \citep{braumoeller2019}. The particular set of arrangement, rues, and norms are often an outcome reached through bargaining among states \citep{lake2009hierarchy}. Alternatively, alliances may be pursued for narrowly utilitarian reasons, as is usually thought. These motives span beyond the pursue of some ideal international order into a variety of other considerations such as deterrence, conflict preparation, or even the non-security externalities associated with alliances. The second dimension that alliances may be thought to vary along is the function of capability aggregation in accomplishing the alliance's objectives. Some alliances may have underlying objectives that are predicated upon the aggregation of resources, such as balancing alliances, while others may not and may emphasize alliances as non-security institutions, such as consolidating alliances \citep{morrow1991alliances, weitsman2004dangerous}. In peacetime, alliances may become an institutional means of promoting policy coordination and accomplishing non-security objectives \citep{giberTaking2018}. One interesting question is why states may use military alliances over other forms of international institutions when seeking to consolidate, expand, or pursue relationships. Alliances are often the institution most frequently associated with high-level dialogue between between influential civil and military leaders, empowering them to accomplish these institutionalizing pursuits better than other forms of institutions, such as economic institutions \citep{pevehouse2005democracy, cranmerWorkingIndirect}. When these two dimensions are combined, much can be learned about alliance roles. The first role, Balancer, is reflective of conventional balance of power logic wherein capabilities are aggregated to achieve order-based goals. The second role, Aggregator, refers to a state that aggregates its capabilities by allying with others to counter a geopolitical threat and/or prepare for an inevitable conflict. These motives are agnostic to the broader international order. The third, Reformer, is representative of a process where alliances are a means to promote internal reform within a state. These reforms are promoted through institutional means, not necessarily security-based means, to pursue order-based motivations. The fourth and final role breaks from conventional wisdom, Consolidators may form alliances to consolidate economic or political ties through institutionalized arrangements. Often these ties may be formed without paying close attention to broader international orders or capability aggregation. It is worth noting that these four roles may not be the only roles adopted within the alliance network or the only type of alliances formed. Alliances can be formed to serve a variety of purposes, as illustrated in Figure \ref{type} which shows the tree of alliance types and general levels of abstraction. These roles, however, are consistent with general patterns that are expected to be the most prominent. \begin{table}[] \centering \begin{tabular}{l|l|l|} & \textbf{Ordering} & \textbf{Narrowly Utilitarian} \\ \hline \textbf{Capability Aggregating} & Balancers & Aggregators \\ \hline \textbf{Institutional} & Reformers & Consolidators \\ \hline \end{tabular} \caption{\textbf{Dimensions Sorting Alliance Roles.} Alliances can be thought to vary according to whether they are ordering or narrowly utilitarian, and whether this is accomplished through capability aggregation or institutional mechanisms.} \label{2by2} \end{table} \begin{figure}[t!] \centering \includegraphics[height=5cm]{AllianceTypeTree.png} \caption{\textbf{Alliance Typology Tree.} Tree ascends in increasing order of abstraction. All types of alliances belong to particular roles, which belong to particular models, which broadly capture all alliances. } \label{type} \end{figure} It is worth clarifying what I mean when I refer to alliances within this conceptual framework. Alliances, for the purposes outlined here, are defined in a way consistent with the ATOP project: ``Alliances are written agreements, signed by official representatives of at least two independent states, that include promises to aid a partner in the event of military conflict, to remain neutral in the event of conflict, to refrain from military conflict with one another, or to consult/cooperate in the event of international crises that create a potential for military conflict," \citep[238]{leeds2002alliance}. Here, alliances are not defined with respect to their motive of aggregating power but rather as a treaty that contains provisions relating to security politics. While these provisions may be important to the alliance, the alliance need not be formed solely for these provisions. In fact, an institutionalist view of alliances may view such provisions as tertiary to the objective of forming a broader institution designed to accomplish other objectives. \subsubsection{Balancer} It is conventionally thought that a state's primary foreign policy objective is to ensure its security, often through countering the rise of a revisionist state or peer competitor, or preserving an ideal international order. Balancers aggregate resources to promote an ideal international order or preserve an existing international order. Capability aggregation occurs through the formation of alliances with like-minded states intended to maintain the balance of power \citep{waltz1979theory, walt1990origins, mearsheimer2001tragedy}. The aforementioned example of the US forming NATO following World War II exemplifies a state adopting the role of Balancer \citep{holsti1970national}. With a liberal order in mind, NATO was formed to aggregate capability to encircle the Soviet Union. It may be argued that for states to be Balancers, they need not have common interests. This is certainly true, in the case presented here, however, these states are aggregating capabilities for narrowly utilitarian objectives, and as such, may be thought of as Aggregators. The alliance behavior of both the state being balanced and the target of balancing, however, may often resemble one another. For example, during the Cold War the alliance behavior of both the US and the USSR are relatively similar. In other words, even if a state is the target of balancing attempts, they too may adopt the role of Balancer to serve as a counterweight to the new balancing coalition. The local alliance network of Balancers may have four observable features. Recent research has indicated that when constructing balancing coalitions, states create a larger coalition that includes many states as it lends legitimacy to their cause and the order they are attempting to preserve or establish \citep{keohane1974transgovernmental, adler2008spread, adler2009security, ikenberry2014power}. This tendency can be measured through two network features. First, the local alliance network of Balancers should show a tendency towards many ``high-degree" nodes. Figure \ref{2star} presents the topographical representation of preferential attachment, often measured through $k$-stars wherein a node $i$ is connected to $j$ and $k$ but $j$ and $k$ are not connected. Second, these local alliance networks should be tightly knit and marked by a tendency towards triadic closure, illustrated in Figure \ref{triad}. This tight clustering would be an indication of similar preferences and a costly signal of the coalition's cohesiveness \citep{keohane1974transgovernmental, cranmer2012complex, cranmer2012toward}. \begin{figure}[t!] \centering \begin{subfigure}[]{0.48\textwidth} \centering \includegraphics[height=5cm]{2star.png} \caption{K-Stars or Preferential Attachment} \label{2star} \end{subfigure} \begin{subfigure}[]{0.48\textwidth} \centering \includegraphics[height=5cm]{triangle.png} \caption{Triadic Closure} \label{triad} \end{subfigure} \caption{\textbf{Triadic Configurations.} K-stars may be reflective of a tendency towards preferential attachment, triangles measure triadic closure.} \label{triadconfig} \end{figure} Third, as Balancers may be forming alliances to uphold a particular order, it seems likely that they would form alliances with states of similar regime types. States with similar regime types often have similar international preferences and are more likely to have similar foreign policy objectives \citep{gartzke1998kant, gartzke2000preferences}. The Holy Alliance following the Congress of Vienna seems to be a strong case of states of the same regime type having domestic incentives to uphold a conservative international order. Forth and finally, as states attempt to increase the strength of their balancing and order-preserving coalitions, or to aggregate resources, it may seem possible that stronger states may have to form alliances with weaker states, contrary to the expectations of the CAM \citep{morrow1991alliances}. While there are increased autonomy costs for adding additional states \citep{morrow1991alliances, morrow2000alliances}, adding even weaker states will still marginally increase the overall size, strength, and perceived legitimacy of a coalition. As such, one counter-intuitive expectation of this framework may be a tendency towards asymmetric alliances (with respect to capabilities) within the local alliance network of Balancers. As previously mentioned, Balancing coalitions can also be engineered by revisionist states so it does not seem obvious that the local alliance network of Balancers should be truly marked by a tendency towards forming alliances with revisionist/non-revisionist states. \subsubsection{Aggregator} An Aggregator attempts to aggregate capabilities to prepare for conflict, a motive that is agnostic to the broader international order. This role is fairly consistent with the logic of the CAM. Balancers form alliances as a means of pooling resources for creating or maintaining an international order, which may manifest through a desire to constrain a peer competitor and/or promoting a balance of power. Aggregators, however, form alliances to pool resources to prepare for what is perceived to be an inevitable conflict. Consider the case of Brazil, Argentina, and Uruguay in the Triple Alliance which marks a clear example of states coming together to prepare for a conflict, in this case, the Paraguayan War (1864-1870). Aggregators' alliance networks should be marked by several characteristics. First and foremost, Aggregators pay greater attention to the capabilities of their allies than Balancers. Given that Aggregators form alliances based upon the expectation of an inevitable conflict, alliance-based autonomy costs and the security gains are much more salient \citep{morrow1991alliances, snyder1997alliance, morrow2000alliances}. However, forming alliances with equally strong states may be difficult as there are constraints on available allies and sub-optimal alliances may exist. As such, while it is expected that Aggregators do not form asymmetric alliances, they may not be able to form perfectly symmetric ones either. Second, if Aggregators believe that a conflict is inevitable, they may seek out many alliance partners and downplay autonomy costs. As such, it might be expected to find a tendency similar to that of Balancers wherein the local network of Aggregators is constituted by many high-degree nodes. This is measured through $k$-stars or a degree term, illustrated through Figure \ref{2star}. Third, similar to Balancers, Aggregators may be more likely to form tightly knit alliance networks marked by a tendency towards triadic closure, illustrated in Figure \ref{triad}. As \citet{cranmer2012toward} note, this may help bolster states' security through providing synergetic gains. Fourth, and finally, states are said to make decisions about alliance reliability based upon attributes of potential partners \citep{crescenzi2012reliability}. \citet{lai2000democracy} finds that democracies can more credibly commit their reliability as allies to one another. In addition, autocracies may be more trusting of one another as they may have similar preferences \citep{gartzke2000preferences}. As such, regime type homophily is expected to be a common feature of an Aggregator's local alliance network. As Aggregator's alliances may be fleeting alliances of convenience and include strange bedfellows, a tendency towards including revisionist or non-revisionist states does not seem likely. \subsubsection{Reformer} The Reformer role is associated with states forming alliances as a means to push or be pushed by others to adopt internal reforms, likely economic or political liberalization, or influence policy. The effect of alliances on political reforms or policy change is well documented \citep{pevehouse2005democracy, gibler2006alliances, giberTaking2018}, but typically considered as a positive externality as opposed to a chief motivation for alliance formation. Consider the revised mission of the OAS following the Cold War. Initially formed to expel Soviet influence in Latin America, the OAS was reorganized around a renewed set of principles, including a regionalist cooperative security order and respect for human rights, economic freedom, and liberal democracy \citep{pevehouse2005democracy, therien2012changing}. These new principles were consistent with the broader liberal internationalist order pursued by the West \citep{ikenberry2012liberal}. Reformers are likely to have ego-networks that mirror the structure of Consolidators. Similar to the prior alliance roles, Reformers should have ego-networks constituted by many high-degree nodes. As the institutions designed to push reforms are typically very large and designed to form regional institutions, it seems inevitable that there would be many reform pushers and many reform pushees that are all interacting within a very large community. Second, given that these institutions largely work through socialization \citep{pevehouse2005democracy}, a series of tightly knit alliance clusters seems to be essential to success. If particular states were excluded from the community, then their socializing effects may not be as successful. Third, Reformers' alliance networks are more likely to be constituted by many asymmetric alliances. Within asymmetric dyads, stronger states may be able to exercise a greater degree of influence over weaker states in pushing their preferred policy outcomes, in this case, domestic reform \citep{morrow1991alliances}. Fourth, initially, the alliance networks formed by Reformers should be constituted by regime heterophily, only to eventually be marked by regime homophily as reforms become successfully implemented. When used as a vector for the diffusion of democracy, it is expected that reformers would be democracies forming alliances with autocratic reformees. This dynamic is well documented, the US is often known to use alliances like the OAS to promote democratization abroad \citep{pevehouse2005democracy, therien2012changing}. \subsubsection{Consolidator} Finally, Consolidators form alliances to institutionalize existing economic or political ties or coordinate policy action. This role has become more prevalent as it is increasingly common for states to use alliances to facilitate and institutionalize economic, political, or cultural exchange \citep{long2006trading, lake2009regional, fordham2010trade}. These peacetime alliances may be be particularly useful in coordinating policy action \citep{giberTaking2018}. In these cases the states may be agnostic to the broader order to capability aggregation and see the alliance as a useful institutional mechanism to consolidate a relationship \citep{powers2004regional}. In the post-Napoleonic system, the German kingdoms, Prussia, and Austria formed alliances to pave way for the German Confederation and eventually, German Unification \citep{hartshorne1950franco, craig1995force}. Consolidators' ego-networks are likely to mirror those of Balancers and Aggregators with respect to network topology. First, Consolidators are likely to have alliance networks constituted by many high-degree nodes. Once states decide to adopt this role, they turn towards creating institutional arrangements with many states. German Unification highlights this point clearly -- many kingdoms like Bavaria or Hanover formed many dyadic alliances with other kingdoms in an effort to bring many into the fold. Second, there is likely to be a tendency towards triadic closure as these states seek to form tightly knit communities to assist consolidation. In the case of German Unification, it would make little sense for some kingdoms to exclude others if the goal is to create a truly pan-Germanic community. Consolidators are likely to form alliances with states of disparate capabilities and regime types. Consolidators' alliance ties may be more likely to emerge between states of disparate national capabilities as there is greater potential for heterophilous gains. If two states have an interest in forming a firm relationship and seek heterophilous gains from one another, alliances may be an optimal institution allowing for such concessions and side payments \citep{morrow1991alliances, fordham2010trade}. For example, a stronger state may seek trade concessions from a weaker state, but to give such concessions, the weaker state may demand defense. These asymmetric alliances may provide a means to consolidate such ties. Fourth, and finally, alliances may provide a means of bringing states of disparate regime types together. Alliances are often considered a trust building mechanism \citep{kydd2001trust} and their effect in promoting preference conference is well known \citep{bearce2007intergovernmental}. \section{Empirical Strategy} This section introduces an empirical strategy for evaluating the previously introduced role-based framework. It begins by introducing the ego-Temporal Exponential Random Graph Model (ego-TERGM), a model capable of identifying the previously discussed roles. The following subsection then discusses details of each model estimated, including the time periods used, the number of roles estimated, and the covariates used. It is worth noting that some states may enter analyses for certain periods, this occurs as states may form or dissolve, or not achieve the minimum number of alliances needed for any year within a period. \subsection{Inferring Alliance Roles Using the ego-TERGM} To assess this role-based framework a novel statistical approach, the ego-Temporal Exponential Random Graph Model (ego-TERGM), is used. This approach, outlined by \citet{campbell2017detecting}, decomposes a longitudinal network (such as the alliance treaty network) into its component ego-networks and clusters them according to similarity or difference across a variety of user-specified nodal, dyadic, temporal, or network variables. In other words, if one views the interstate alliance network as constituted by a set of states and their allies, one may infer the roles states serve in the alliance network through examining patterns of how and why states form alliances. Previous work has indicated that the ego-TERGM, and its equivalent for cross-sectional networks, the ego-Exponential Random Graph Model (ego-ERGM), is useful for uncovering interesting properties of a network \citep{salter2015role, box2017role, campbell2017detecting}. \citet{box2017role} used the ego-ERGM to examine the roles that interest groups adopt within the environmental lobbying coalition. In examining a canonical social network, \citet{campbell2017detecting} uncovers a set of roles reflecting a unique aspect of labor negotiations and collective action in non-union shops. In simple terms, the ego-TERGM clusters a set of nodes and their local networks (ego-networks) within a broader longitudinal network into a user-defined number of time-invariant classes (clusters or roles) according to the similarity of these ego-networks (TERGM model parameters). In more formal language, the ego-TERGM is a finite mixture model that attempts to assess mixtures of data generating processes (DGPs) for bootstrapped Temporal Exponential Random Graph Models (TERGMs) \citep{cranmer2010inferential, campbell2017detecting}. This is accomplished through assigning each actor's longitudinal ego-network to a cluster according to the similarity in each network's TERGM parameters, which characterize the generating process for the network. This model is an unsupervised and finite latent class model based upon the clustering of TERGM parameters, meaning that cluster memberships are determined entirely by estimated parameters. For additional detail on the ego-TERGM, including its likelihood function, assumptions, estimation routine, and goodness of fit measures, the reader is referred to \citet{campbell2017detecting} and/or the SI Appendix. The requirement that the analyst assign labels and meaning to each cluster is a limitation to any study that uses unsupervised machine learning to measure otherwise immeasurable phenomena. Nevertheless, the alternatives to this relatively inductive approach are much worse. Analysts either treat all alliances as capability aggregation by assumption, or they take the historian's approach of being inductive about every case such that there is no structure. I mitigate the issue of inductive or \textit{ex post} label assignment through developing a theoretical framework that provides \textit{a priori} expectations about which roles or clusters should exist and which states should be assigned to these roles, and deductive observable implications that may be captured via ego-network structure. In other words, while my approach may be inductive, I am principled and systematic in how I interpret raw historical data and cluster assignments, similar to how Bueno de Mesquita and co-authors use history in a systematic empirical basis \citep{de1985forecasting, bueno2011new}. In this model the user must specify a set of parameters. This includes the minimum size an ego-network must achieve to be included in the analysis, the order of alters to include, the (T)ERG-based terms that roles are thought to sort on, and the number of roles that the model is allowed to fit. For the models presented here, a state must have at least five allies to be included in the model. This parameter value is chosen to increase the number of states considered for role assignments while also achieving a minimum size necessary to allow for model identifiability. Only first order alters are examined as the allies of allies may not be thought to inform a state's role assignment. In the following section the terms used to sort states are discussed. Finally, in allowing the data to speak to the number of roles present, model BIC is allowed to inform the role assignment. It is worth noting that in some cases theoretically-motivated constraints are imposed to prevent the model from selecting role cluster values that may be unacceptable, in this case, in excess of four total clusters of roles. \subsection{Data to Distinguish Alliance Roles} This section discusses the model terms used to distinguish between role assignments, how they are measured, where they are sourced, and what constitutes the longitudinally observed network(s). The analysis starts from a dyad-year dataset of all alliance treaties coded by the Alliance Treaty Obligations and Provisions dataset from 1816 to 2002 \citep{leeds2002alliance}. These dyad-years are transformed into an undirected longitudinal network observed over 187 annually measured time steps. A tie is present within this network when any two states are member to a treaty containing an offensive, defensive, neutrality, or non-aggression commitment. The broader network of all treaties is preferred to the narrower network of particular commitments for two reasons. First, for non-CAM roles, commitment may be independent of the role adopted. For example, Consolidators and Reformers focus more upon the treaty and less upon the particular commitment when forming an institution. Second, the presence of certain commitments over others may assist in distinguishing between particular roles. While there are no strong \textit{a priori} reasons to suspect some roles would prioritize some commitments to others, including covariates for particular commitments allows the ego-TERGM to leverage additional information in producing role assignments. These networks are then partitioned into six historical time periods that are each analyzed distinctly. These time periods are chosen to reflect the dynamic nature of state motives and the means through which distinct international systems or orders may influence the roles states adopt within the alliance network For a further discussion of these periods and the roles expected during them, the reader is referred to the SI Appendix. During each of these periods, I search the parameter space of models that are identifiable and produce the best fitting number of roles (or clusters) according to BIC while constraining the value to ensure parsimony. When constraints are imposed they are done in a theoretically-motivated fashion to induce parsimonious assignments. Table \ref{modelFitInformation} presents information on the models estimated on each of these time-periods. To distinguish between the roles adopted during this time I employ a variety of covariates that are used to distinguish each longitudinally observed ego-network.\footnote{The distributions of these covariates, their coding rules, and original data sources are discussed further in the SI Appendix.} First, a simple edges term is used to distinguish between networks as one might expect roles to sort on the relative density of actors' ego-networks. In other words, this model would be used to detect the number of dyadic alliances present in an ego-network. Second, a measure for the number of $k$-stars within the network is used. Some roles may sort on $k$-stars as actors similar to Bismarck attempt to create dominant and expedient coalitions without becoming fully embedded, or attempt to form alliances with many different states. Alternating $k$-stars is chosen to assist in model estimation. Third, a homophily term for regime type is used. This term captures the tendency of a state to form alliance with states of a similar or different regime type and can capture the formation of ideological communities. Data for this variable is taken from the Polity IV project \citep{marshall2002polity}, where a democracy is coded as any state with a regime score greater than 6 and a non-democracy is coded as any state with a regime score less than 7.\footnote{It is possible that states may seek out or seek to avoid autocratic regimes of a particular type when forming alliances \citep{weeks2008autocratic}. Democracies may be more likely to push for domestic reforms in autocratic military regimes. Accounting for variation in autocracy poses a tremendous modeling challenge as some autocratic types may not exist during some years, and as such, create model identifiability issues. As such, a broader understanding of autocracy is adopted here.} In addition, two ``difference" variables are used to capture the tendency of two nodes to have disparate values on a variable. The fourth term included measures the tendency for states to form alliances with either stronger or weaker states. It is measured by the absolute difference in CINC scores for a dyad, with data sourced from the Correlates of War Project \citep{singer1972capability}. The fifth term included accounts for the absolute difference in binary indicators for whether a state is labeled as a revisionist state in a militarized dispute in that year. Data for this variable is also taken from the Correlates of War Project \citep{jones1996militarized}. Four attributes of the alliance are also used to distinguish between roles \citep{leeds2002alliance}. The sixth, seventh, and eights terms included are whether an alliance formed contains a defensive, offensive, and/or secret commitment respectively. Many alliance roles may sort on these covariates as states engineer and design their alliances to accomplish goals consistent with their role. It is worth noting that when including these commitment-based covariates, the baseline category for treaties becomes the presence of a non-aggression or neutrality pact. The last attribute is the number of years a dyad has had an alliance treaty. This variable is designed to capture the temporal dependence that may exist between alliance years.\footnote{While the inclusion squared and cubed functions of alliance years may be ideal \citep{carter2010back}, their inclusion creates model identifiability problems.} It is worth noting that the choice of some covariates is constrained by whether there is variability for each dyad within an ego-network with respect to certain covariates. For example, in some periods there is no variability in a state's ego-network with respect to offensive commitments. This invariability prevents the ego-TERGM from being identifiable for the broader network as initial parameter values cannot be estimated for all states. For example, edge covariates for whether the alliance developed established institutions or was formed to counter common enemies were not included as they created identification problems. The inclusion of a term for the number of triangles in a network also created problems as alliance ego-networks often reflect fully connected networks, and as such, also do not vary in dyadic change statistics.\footnote{It should be noted that the terms discussed here and used for the ego-TERGM differ from those later used to detect commonalities in ego-network structure among states of the same role.} \begin{table}[] \centering \scalebox{0.8}{ \begin{tabular}{llll} \hline \textbf{System or Period} & \textbf{Time Span} & \textbf{Num. Roles Fit} & \textbf{Covariates Used} \\ \hline \rowcolor{Gray} Congress of Vienna & 1816-1848 & 3 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily, \\ CINC Difference, Revisionist Difference, \\ Defensive Commitments, Alliance Years\end{tabular} \\ Nationalism and Bismarckian & 1849-1890 & 4 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily, \\ CINC Difference, Revisionist Difference,\\ Defensive Commitments, Alliance Years\end{tabular} \\ \rowcolor{Gray} Pre-WW1 & 1891-1918 & 2 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily,\\ CINC Difference, Revisionist Difference,\\ Defensive Commitments, Offensive Commitments,\\ Secret Provisions, Alliance Years\end{tabular} \\ Interwar & 1919-1945 & 1 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily,\\ CINC Difference, Revisionist Difference,\\ Defensive Commitments, Offensive Commitments,\\ Alliance Years\end{tabular} \\ \rowcolor{Gray} Containment and Bipolar & 1946-1991 & 4 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily,\\ CINC Difference, Revisionist Difference,\\ Alliance Years\end{tabular} \\ Liberal International & 1992-2002 & 4 & \begin{tabular}[c]{@{}l@{}}Edges, Alternating K-Stars (0.5), Regime Homophily,\\ CINC Difference, Revisionist Difference,\\ Alliance Years\end{tabular} \\ \hline \end{tabular} } \caption{\textbf{Model Fit Details:} Each row represents the model estimated and presented for each time period and the information relevant to its estimation.} \label{modelFitInformation} \end{table} \section{Results and Discussion} The results for my analyses uncover a role-structure consistent with the previously introduced role framework of alliances.\footnote{Models were validated using a combination of within-sample validation based on BIC for the number of roles fit parameter and external validation based upon historical expectation. Given that labels and roles are not known \textit{a priori} cross validation of role assignments is not possible. A broader discussion of model validation is provided in the SI Appendix.} Alliances, it appears, are formed for a variety of purposes beyond those expected by the Capability Aggregation Model. In particular, across time states form alliances to adopt non-security aggregating roles, including Consolidator and Reformer. The results for each period are discussed in turn.\footnote{When discussing the roles states adopt within each period, it is important to note that these results are based upon general patterns of behavior consistent across all states included. There may occasionally be country-to-country differences in how these roles are performed, which may be nuances too subtle to be teased out.} This section will discuss each period and the roles uncovered, in turn, and conclude by discussing the generative structure for each role. \subsection{Period Roles} \subsubsection{Vienna System Roles} In the years following the Napoleonic Wars, the victors established a principled order designed to promote stability, prevent conflict, and uphold autocratic rule \citep{taylor1954struggle, jervis1985balance, schroeder1996transformation}. The German kingdoms also moved to promote unification through consolidating relationships and creating a pan-Germanic confederation \citep[599-606]{schroeder1996transformation}. While the order was designed to prevent conflict, force was occasionally seen as necessary to prolong the post-Napoleonic order \citep[736-740]{schroeder1996transformation}. As such, states would be expected to adopt the role of Balancer, Consolidator, or occasionally, Aggregator. During the Vienna System, the period spanning 1816 to 1848, a role-structure consisting of three roles, Consolidators, Balancers, and Aggregators, is uncovered and found to produce superior model fit according to BIC. Table \ref{modelFitInformation} presents the parameters used for this (and all other) ego-TERGM(s) fit. Overall, the \textit{a priori} expectation is confirmed: states appear to either adopt the role of Consolidator, Balancer, or a variation of Aggregator. Results for this period are presented in Figure \ref{Vienna}.\footnote{To understand the relative contribution of each model term, a sensitivity-based approach is utilized. This routine and its results for each period are discussed in the Si Appendix.} \begin{figure}[t!] \centering \includegraphics[height=15cm]{AH_Cong_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Vienna System.} Darker cells show higher probabilities of assignment to a particular role. Country labels refer to their Correlates of War System Membership Data name which may include legacy names for latter periods.} \label{Vienna} \end{figure} First, one set of roles were adopted by the smaller kingdoms that were member to the German Confederation. The German Confederation, made up of kingdoms like Bavaria and Hanover, as well as powers like Austria and Prussia, was a means of promoting economic and regional stability \citep{schroeder1996transformation}.\footnote{Note that the names discussed here are their historical names while the names presented in in the role assignment figures contain their Correlates of War System Membership Data legacy names. For example, Correlates of War labels Prussia as its later legacy Germany, and labels the Ottoman Empire as its later legacy Turkey. This naming is preserved to ensure consistency throughout the manuscript.} The model's selection of these states to include in the same cluster, and not the powerful German Confederation members like Prussia or Austria, is indication that these states may have formed a series of alliances to consolidate and bring order to existing economic and political ties. This is consistent with the previously discussed Consolidator role and the expectation of diplomatic history \citep{schroeder1996transformation}. Second, the powers of the German Confederation, Austria and Prussia, are found to adopt a role distinct from their German Confederation co-members that closely resembles the Balancers role. These two states are partners to the well known Holy Alliance (and later the Quadruple and Quintuple Alliances) formed to maintain the Vienna System and its set of norms. Initially this alliance was formed between Austria, Prussia, and Russia to make the world safe for monarchs, but was expanded to include the United Kingdom and France as to maintain norms against violence and ensure an adequate balance of power by creating a dominant order-preserving coalition \citep{taylor1954struggle, jervis1985balance, schroeder1996transformation, bridge2014great}. This is in contrast to the expectations of \citet{schroeder1992did,schroeder1996transformation} who argued that the Vienna System did not rest upon a balance of power, and that during this time the powers did not view power aggregation as essential to sustaining the system. France, Great Britain, and Russia are not included in the analysis for this period as they never ally with at least five other states. This logic, and the motivation for the alliances formed by Austria and Prussia at this time, is consistent with the Balancers role discussed in Section \ref{theory}. The third and final role identified is solely constituted by the Ottoman Empire (modernly, Turkey). During the Vienna System, the Ottoman Empire found itself party to a multi-state alliance for several months in 1840. This alliance alliance was formed to ensure Egypt would accept a peaceful negotiated settlement to the Second Egyptian-Ottoman War (1839-1841). This case reflects a particularly odd dynamic rarely considered -- alliances formed as a means of promoting dispute resolution through resource aggregation. This alliance was not formed prior to the conduct of conflict and as such does not cleanly match the logic of the Aggregators role. Instead it represents a variation on this logic, resources aggregated after conflict to incentivize a winning party's acceptance of a negotiated settlement, as opposed to continue executing the conflict for additional gains. This version of the Aggregators role, however, is consistent with historical intuition per \citet[736-740]{schroeder1996transformation} as the Ottoman multi-state alliance was ultimately formed in an effort to prevent the collapse of the Vienna System. It is worth noting that Russia, France, and the United Kingdom are conspicuously omitted from my analyses. The reasons are a result of model identifiability -- during no period do the local alliance networks of any of these countries contain enough states to allow a model to be estimated. For example, during this time the UK typically only has three alliances, having four alliances with Prussia, Austria-Hungary, Russia, and the Ottoman Empire in 1840. An ego-network of this size often provides insufficient variation or evidence to allow for a model to be estimated. This is not ideal from a historical perspective, but it is not obvious what alternative would be suitable and allow for these states' inclusion. \subsubsection{Bismarckian System Roles} The Bismarckian System, which spans 1849 to 1890, begins as a series of revolutions spread across Europe. These revolutions make it likely that Reformers will emerge in an effort to nudge states either towards or away from democracy \citep{craig1995force}. In addition, many conflicts, most notably the Austro-Prussian War, occur that might lead states to adopt the Aggregators role \citep{craig1995force}. Under Bismarck, German unification escalates, the German kingdoms would likely continue to adopt the role of Consolidator as they attempt to transition to a Unified Germany with Bismarck at the helm \citep{hartshorne1950franco}. During the Bismarckian System, four distinct roles are detected and $G$ and found to produce the best fitting model according to BIC. The role assignments for this period, presented in Figure \ref{Bismarckian}, demonstrate a great degree of variation that is mostly consistent with theoretical and historical intuition. \begin{figure}[t!] \centering \includegraphics[height=15cm]{AH_Nat_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Bismarckian System.}} \label{Bismarckian} \end{figure} Similar to the prior period, many German kingdoms find themselves clustered in the same role with a relatively high degree of certainty. The inclusion of Prussia and Austria within this role alongside many smaller German kingdoms indicates two significant legacies of Bismarck's foreign policy. During this time, Bismarck used many of the alliances with the German kingdoms as a means of consolidating existing relationships in an effort to further promote German Unification \citep{hartshorne1950franco}. However, it is quite clear that Bismarck also saw his chief role as a Balancer and through a thoughtfully engineered alliance system which included Italy, Austria-Hungary, and Russia, he sought to promote stability \citep{craig1995force, snyder1997alliance}. As such Prussia and Austria appear to be mixture of Consolidators and Balancers. On the outside of Bismarck's alliance system often laid France, whom this League of the Three Emperors with Austria and Russia was designed to exclude. Intuitively then France is in a separate role with the United Kingdom and Ottoman Empire. This clustering make sense as the Ottoman Empire and England often found themselves at odds with the League of the Three Emperors \citep{taylor1954struggle, snyder1997alliance}. These states, on the outside of Bismarck's core, do not appear to reflect any of the roles discussed in Section \ref{theory} and appear to be on the outside of a core-periphery system. As a counter-weight to Bismarck's order-preserving and balancing coalition, France, the Ottoman Empire, and England too appeared to have adopted the Balancers role. The third role is solely constituted by Ecuador with very low-level probabilities of assignment from Germany and Austria. As there are no other countries in Latin America, little alone the Western Hemisphere, who have at least five alliances at this time, they appear to be the most active state with respect to alliance politics. During this period Ecuador collaborated with many other countries, including Peru, Chile, and Bolivia against Spain in the Chincha Islands War. They are also engaged in three other conflicts during this period, which seems to indicate that they adopted a role most consistent with the Aggregators role as they seemed to be constantly engaged in conflict and as such, behooved to find wartime partners. The low-level probabilities of assignment for Austria and Prussia also make sense as for a brief time they prepared for and engaged in the Austro-Prussian war. The final role reflects the Reformers role, and is constituted largely by Italy with all Consolidators having a low-level probability of assignment. Following 1848, revolution spread across Europe, dramatically changing its geopolitical landscape \citep{taylor1954struggle, schroeder1996transformation, bridge2014great}. In particular, these revolutions shaped the foreign policy trajectories of Italy, Austria, and Germany. In particular, the revolts in Italy had geopolitical implications that ultimately unraveled the European Order and brought France and Austria to battle over Italian independence in 1859 and Italy and Austria to fight in 1866. With each conflict, Austria's hold on Italy weakened and a path for Italian unification was paved. As Italy became increasingly independent, France and England used their clout and alliance ties with Italy to push for Italian independence and democratization. As such, Italy can be described as a Reformer. \subsubsection{Pre-World War I System Roles} The Pre-World War 1 period, spanning 1891 to 1918, represents a tumultuous time wherein Bismarck's sophisticated alliance system was handed to a set of diplomats that many considered to be professionally incompetent \citep{taylor1954struggle, kissinger1994diplomacy}. During this period the lasting effects of Bismarck's \textit{realpolitik} system are felt and as competition between states increased, there were increased pressures for states to arm and aggregate power. This system appears to be a much simpler role system than the prior periods, as two role are detected and found to produce optimal model fit according to BIC. Results presented in Figure \ref{preww1} show support for historical expectation as Balancers and Aggregators are both dominant. Overall, the the theoretical intuition is corroborated to some degree, although the prediction that Aggregators would be more prevalent than Balancers is not confirmed. \begin{figure}[t!] \centering \includegraphics[height=15cm]{AH_WW1_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Pre-World War 1 System.}} \label{preww1} \end{figure} The first role is solely composed of Russia, who during the lead up to World War I would go on to be a member of the Triple Entente with Great Britain and France. Russia was particularly unique from its Triple Entente counterparts, however, in that they increasingly expansionist and turned their eye on the Far East \citep{kissinger1994diplomacy}. Nicholas II was of the opinion, among many others, that being a great power required territorial expansion \citep{kissinger1994diplomacy}. This expansion made it clear that Russia was accruing alliances for the purpose of aggregating its power and expanding its influence. As such, Russia appears to have adopted the Aggregators role. The second role is composed by the remaining states who have at least five allies during this time: United Kingdom, France, Germany, Austria-Hungary, Italy, and Romania. Many of the states adopting this role are members of either the Triple Entente or the Triple Alliance which are alliances thought to be formed to balance other great powers \citep{taylor1954struggle}. The Triple Alliance, for example, was designed to balance against France and to prevent attack on Italy or Germany. The Triple Entente was mostly formed as a counterweight to the Triple Alliance. As such, I would refer to these states as Balancers. \subsubsection{Interwar System Roles} After World War I, the role structure of world politics became much more complicated \citep{carr1939twenty, siverson1982alliances, kissinger1994diplomacy}. While attempts were made to consolidate relationships through the failed League of Nations or to promote liberal reforms, there are were many salient cases of state competition \citep{carr1939twenty}. As such, it is unclear what the role structuring principles of this period were. Given this expected heterogeneity \citep{siverson1982alliances}, it is interesting that a homogenous role system consisting of only one role is found to produce superior model fit. Results from the model are presented in Figure \ref{interwar}. While theoretical expectation would expect to find some combination of roles, only Consolidators were detected \begin{figure}[t!] \centering \includegraphics[height=9cm]{AH_Interwar_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Interwar System.}} \label{interwar} \end{figure} The estimation of any model with $G > 1$ produces a more poorly fitting model when accounting for the penalization of additional roles through BIC. This indicates that the ego-network for all states included in the model appear similar, at least with respect to the covariates specified. During this time the post-WW1 order was created and states began to focus upon the consolidation of political and economic relationships to maintain the broader international order established in Versailles \citep{carr1939twenty, kissinger1994diplomacy, craig1995force}. This is not precisely consistent with theoretical logic, as it may be expected that states also form alliances in an effort to aggregate power to counter a rising Germany or to prepare for conflict \citep{siverson1982alliances, kissinger1994diplomacy}. \subsubsection{Bipolar System Roles} This bipolar system emerges in 1946 and lasts until the dissolution of the Soviet Union in 1991. Following the resolution of World War II international politics began to organize along two distinct alliance blocs: NATO and the Warsaw Pact. With that being said, however, it does not seem clear that states within each of these blocs form alliances for distinct reasons as they are members of coalitions balancing each other. As previously discussed, this period should be dominated by Aggregators, Balancers, and Consolidators. Four roles are detected and found to produce the best fitting model according to BIC. Of these roles, 133 different states are assigned to three different roles. Intriguingly, in addition to the roles expected, adding an additional role is found to improve model fit. However, no state has a probability of assignment to this role greater than 0.00001. We refer to this as the Reformers role, which while likely to be rare at this point, may still exist in generality. This model is estimated according to the parameters discussed in Table \ref{modelFitInformation}. We will discuss these four roles, highlighting particularly powerful states that adopt these roles. Results from this model are presented in Figure \ref{containment} and largely consistent with prior expectation. \begin{figure}[t!] \centering \includegraphics[height=12cm]{AH_Containment_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Bipolar System.}} \label{containment} \end{figure} The first role contains the most number of states and is reflective of the Balancers role. Among these members are prominent early NATO countries, including the United States, the United Kingdom, Canada, Belgium, and France, but also late comers such as Turkey and Spain. Additionally, all Warsaw Pact countries excluding Albania are included in this role. During this period these two alliance blocs commonly formed alliances as a means of containing and balancing the influence of the other \citep{waltz1993emerging, kissinger1994diplomacy}. The second role is predominantly constituted by smaller states that do not directly participate in either of these alliance blocs (except Albania). Many of these countries are early and late coming members of the OAS, such as Brazil, Argentina, and St. Lucia, while others are members of the Arab League, such as Algeria or Tunisia. During this time many of these alliances were formed to consolidate existing ties through promoting coordination and cooperation \citep{lebow1994long}. These motives are consistent with the Consolidators role as states formed alliances to institutionalize existing ties. While the United States may have been using the OAS as an opportunity to balance Soviet influence and promote western-style modernization, it appear that many of its OAS allies may have had different motives, viewing the alliance as an opportunity to consolidate their relationship with each other and with the hegemon \citep{weeks1991beyond, mikoyan2018russia}. This may be useful as a regime's support from the United States may have predicted the United States' support for the regime and thus its survival. \citep{slater2008geopolitics, stodden2016interests} In such cases, participation within the OAS may have been useful for consolidating economic and political relationships, producing a series of positive externalities, but such participation may not have been totally voluntary \citep{weeks1991beyond, slater2008geopolitics, stodden2016interests}.\footnote{There has been a great amount of highlighting that many of the asymmetric relationships during this time were coercive and marred by the use of colonial and imperial power \citep{slater2008geopolitics}. As such, one might view the hegemon as exercising power over the subaltern to ensure that the subaltern participates in alliances in an effort to consolidate the asymmetric relationship and bolster the perceived legitimacy of the American-promoted liberal internationalist order \citep{slater2008geopolitics}.} The last role discovered, adopted by Benin, Burkina Faso, Gambia, Guinea-Bissau, Ivory Coast, Liberia, Nigeria, Sierra Leone, and Togo, appears to be a variation of the Aggregators role wherein states form a larger institution to aggregate power in an effort to bring order to a region and respond to internal threats. Many of these states are party to the Defense Pact of the African and Malagasy Union or the Economic Community of West African States (ECOWAS), both institutions designed to uphold norms against territorial aggression and military confrontation in Africa through aggregating capabilities and deterring armed conflict \citep{ukeje2005economic}. \subsubsection{Liberal International System Roles} The final role system considered is that of the Liberal International System that emerges following the dissolution of the Soviet Union in 1991 and is considered until 2002, the last year collected in ATOP. During this time the US has its ``unipolar moment" which radically transformed international politics and created a new order based upon liberal international norms \citep{ikenberry2012liberal, ikenberry2014power}. New constraints on competitive behavior has lead states to use alliances to accomplish nonconventional objectives consistent with the Reformer or Consolidator roles \citep{pevehouse2005democracy}. During this period a model is estimated according to the parameters in Table \ref{modelFitInformation}. A role structure consisting of four roles is detected and found to produce optimal model fit according to BIC. As is with the prior case, 158 countries are assigned to three different roles even though four roles are fit. Results from the ego-TERGM fit on this period are presented in Figure \ref{unipolarity}, which present results that are largely in line with theoretical expectation. \begin{figure}[t!] \centering \includegraphics[height=12cm]{AH_Unipolarity_Heatmap_01302018.pdf} \caption{\textbf{Ego-TERGM Role Assignment Probabilities by Country, Liberal International System.}} \label{unipolarity} \end{figure} The first role is constituted by the most countries and is reflective of a process where many states view military alliances as an opportunity to promote some broader order through institution building. This is representative of the Reformers role. This primarily includes countries within the OAS which are party to its renewed mission and effort to promote a regional security community based upon respect for democracy, free trade, and cooperative security \citep{therien2012changing}. During this time, many of the democracies within the OAS pushing autocracies to liberalize through the Unit for the Promotion of Democracy (UPD), such as the democratic United States and Mexico tied to autocracies like Venezuela, Guatemala, Haiti, and Nicaragua \citep{pevehouse2005democracy, slater2008geopolitics, therien2012changing}. Parallel narratives also emerge within NATO and ECOWAS, wherein former security institutions adopt a renewed mission of assisting states in pursuing reforms and promoting a regional security community or order \citep{adler2008spread}. The second role is constituted by many other peripheral states that are active outside of NATO (while including some NATO member countries). Many of these states, like France and Russia, have at times resisted the liberal international order promoted by the United States. As such, it does not seem clear that these states adopt the Reformers role, and at the same time, do not appear to cleanly fit into any other roles. Many of these states may be more reflective of an unexpected Aggregators role as many participate in conflict during this time. The third and final role closely resembles the Consolidators role and is constituted by a set of African, Asian and Middle Eastern countries who have formed alliance-based institutions like the Arab League or the Shanghai Cooperation Organization. These institutions are largely means to prevent aggression and provide an institutional means to consolidate existing economic, political, or cultural relationships and promote cooperation. \subsection{Assessing the Role Generative Structure} To assess the generative structure of the roles uncovered by the ego-TERGM, four bootstrapped pseudolikelihood TERGMs are fit on all ego-networks associated with each role for each systemic period. This routine, introduced by \citet{campbell2017detecting}, allows analysts to understand the network features that are prevalent or not for all networks associated with a role.\footnote{For additional discussion of the TERGM estimated through bootstrapped pseudolikelihood, I refer the reader to \citet{cranmer2010inferential}.} The models presented here are the best fitting identifiable models associated with each role.\footnote{In the SI Appendix, TERGMs fit on each role for each time period are introduced and discussed. For additional detail on the covariates used for these TERGMs that are not used for the ego-TERGM, the reader is referred to the SI Appendix.} Results for this routine are presented in Table \ref{roleTERGMs}.\footnote{Goodness of fit diagnostics for these models are presented in the SI Appendix.} Overall, the results illustrate that the observed role-generating processes pretty closely mirrors the expected role-generating processes. The pooled TERGM fit on all Balancer ego-networks finds a tendency towards high-degree nodes, marked by a positive and robust effect for GW Degree, and triadic closure, found by a positive and robust effect for the Triangles term. This makes sense as Balancers may create large and tightly knit coalitions to legitimize their ideal international order \citep{adler2008spread, adler2009security, ikenberry2014power}. In addition, the model also discovers a tendency towards regime homophily and capability heterophily, marked by positive and robust effects for both the Regime Homophily and CINC Difference terms respectively. Balancers may be more likely to bring in weaker states to further illustrate the breadth of support for their ideal order, but this desire for a breadth of support may be constrained by foreign policy preferences that stem from regime type \citep{gartzke1998kant, gartzke2000preferences}. The Aggregators model also uncovers results consistent with theoretical expectation. Aggregators' ego-networks have a tendency towards both triadic closure and high-degree nodes, indicating fairly large and tightly knit alliance clusters that would produce synergetic gains to state security \citep{cranmer2012toward, cranmer2012complex}. In addition, it also appears that Aggregators are more likely to form alliances with states of similar regime types. This makes sense as Aggregators must form alliances with states they can trust given the potential security costs of ally renegement \citep{lai2000democracy, gartzke2000preferences}. Finally, Aggregators do not illustrate a strong tendency to form symmetric alliances over asymmetric alliances. Theoretical expectation would hold that Aggregators would be more likely to seek allies with similar capabilities \citep{morrow1991alliances}. However, as noted, a null effect may also be expected as alliance choices are constrained by the allies willing to collaborate with the state in an inevitable conflict. The estimated role generating process for Consolidators' ego-networks shows a tendency towards high-degree nodes and triadic closure. This is consistent with \textit{a priori} expectation as Consolidators may use alliances to create communities for the purpose of easing political or economic tie consolidation among all members. The pooled TERGMs also reveal a tendency towards regime type heterophily within these ego-networks, which makes sense as alliances are often used to build trust \citep{kydd2001trust} or produce converging interests through socialization \citep{bearce2007intergovernmental}. Existing theory may also expect that asymmetric alliances provide a means of producing concessions between states of disparate capabilities through allowing both states to extract distinct gains through side payments \citep{morrow1991alliances, fordham2010trade}. We find support for this function, as it appears that Consolidators' ego-networks have a tendency towards alliances formed between states of disparate national capabilities. Finally, a pooled TERGM is fit on all ego-networks associated with the Reformers role. Results from this model are largely consistent with the preceding discussion. These ego-networks show a tendency towards high-degree nodes and triadic closure. This would indicate support for the proposition that Reformers seek to include many states in a tightly knit institution, which may assist in socializing member states \citep{pevehouse2005democracy}. In addition, it is expected that the alliances constituting Reformers' ego-networks are more likely to be asymmetric with respect to capabilities. This is because stronger states may be more able to effectively exercise influence over weaker states when pushing for domestic reforms \citep{morrow1991alliances}. Finally, it would be expected that the alliances formed by Reformers are between states of different regimes. Democracies may more effectively socialize autocratic peers as they'd be seen as more legitimate \citep{pevehouse2005democracy}. In this case, the positive effect for regime homophily is not consistent with theoretical expectation. One potential explanation is that reforms have already been implemented, and the model is observing the post-reform tendency for these institutions to persist even after reforms have been made. \begin{table} \begin{center} \begin{tabular}{l c c c c } \hline & Balancers & Aggregators & Consolidators & Reformers \\ \hline Edges & $\mathbf{-5.95}^{*}$ & $\mathbf{-5.93}^{*}$ & $\mathbf{-1.91}^{*}$ & $\mathbf{-6.22}^{*}$ \\ & $[-6.31;\ -5.63]$ & $[-6.69;\ -4.87]$ & $[-2.18;\ -1.64]$ & $[-6.82;\ -5.64]$ \\ Triangles & $\mathbf{0.97}^{*}$ & $\mathbf{0.60}^{*}$ & $\mathbf{0.40}^{*}$ & $\mathbf{0.53}^{*}$ \\ & $[0.88;\ 1.08]$ & $[0.45;\ 0.76]$ & $[0.35;\ 0.50]$ & $[0.42;\ 0.61]$ \\ GW Degree (0.1) & $\mathbf{7.86}^{*}$ & $\mathbf{3.71}^{*}$ & $\mathbf{3.31}^{*}$ & $\mathbf{19.18}^{*}$ \\ & $[7.19;\ 8.89]$ & $[0.34;\ 6.45]$ & $[2.86;\ 3.96]$ & $[14.65;\ 24.27]$ \\ CINC Difference & $\mathbf{13.24}^{*}$ & $2.42$ & $\mathbf{8.52}^{*}$ & $\mathbf{15.93}^{*}$ \\ & $[12.20;\ 14.30]$ & $[-41.46;\ 13.85]$ & $[6.81;\ 10.25]$ & $[13.67;\ 18.44]$ \\ Revisionism Difference & $\mathbf{0.13}^{*}$ & $\mathbf{-0.37}^{*}$ & $\mathbf{-0.23}^{*}$ & $-0.02$ \\ & $[0.03;\ 0.22]$ & $[-0.68;\ -0.08]$ & $[-0.34;\ -0.13]$ & $[-0.18;\ 0.14]$ \\ Regime Homophily & $\mathbf{0.72}^{*}$ & $\mathbf{0.54}^{*}$ & $\mathbf{-0.60}^{*}$ & $\mathbf{0.71}^{*}$ \\ & $[0.62;\ 0.81]$ & $[0.43;\ 0.65]$ & $[-0.76;\ -0.44]$ & $[0.53;\ 0.89]$ \\ Defensive Commitments & $\mathbf{1.34}^{*}$ & $\mathbf{1.31}^{*}$ & $\mathbf{2.11}^{*}$ & $\mathbf{2.79}^{*}$ \\ & $[1.14;\ 1.55]$ & $[0.57;\ 1.94]$ & $[1.82;\ 2.39]$ & $[2.43;\ 3.23]$ \\ Offensive Commitments & $\mathbf{1.12}^{*}$ & $\mathbf{2.59}^{*}$ & & \\ & $[0.90;\ 1.36]$ & $[1.06;\ 19.87]$ & & \\ Secret Provisions & $\mathbf{0.76}^{*}$ & & & \\ & $[0.53;\ 0.95]$ & & & \\ Degree of Institutionalization & $0.30$ & $-3.16$ & $0.01$ & $-0.32$ \\ & $[-0.10;\ 0.67]$ & $[-4.21;\ 4.96]$ & $[-0.29;\ 0.22]$ & $[-1.23;\ 0.43]$ \\ Alliance Years & $\mathbf{0.06}^{*}$ & $\mathbf{1.24}^{*}$ & $\mathbf{0.02}^{*}$ & $\mathbf{0.06}^{*}$ \\ & $[0.04;\ 0.07]$ & $[0.77;\ 1.99]$ & $[0.01;\ 0.03]$ & $[0.03;\ 0.10]$ \\ \hline Num. obs. & 463658 & 612609 & 127956 & 269440 \\ \hline \multicolumn{5}{l}{\scriptsize{$^*$ 0 outside the 95\% bootstrapped confidence interval}} \end{tabular} \caption{\textbf{Pooled TERGM Results for Role Generative Structure, All Periods.} 95\% confidence intervals estimated through bootstrapped pseudolikelihood. 500 replications.} \label{roleTERGMs} \end{center} \end{table} \section{Concluding Thoughts} In this manuscript a novel role-based approach to considering alliances is introduced. This framework breaks with the restrictive and conventional assumption that alliances are homogenous institutions formed in response to external threats. It also provides a logic necessary to empirically evaluate the rich, nuanced based view of alliances championed by diplomatic historians and security studies scholars. My framework recognizes that states have a variety of objectives that they consider when forming interstate military institutions. Results indicate that there are many roles made available to states in the alliance network. These roles, which are informed by contextual factors, influence how and why states form alliances. This framework and its roles, inferred by the flexible and novel ego-TERGM, offers analysts a new take on perhaps the most foundational concept in IR. The roles uncovered across distinct historical periods indicate that there is great heterogeneity in the generative model of alliances, and that the motives driving states to form alliances vary across states, space, and time. The roles detected by this routine confirm that our initial understanding of military alliances has long been flawed. This may indicate that many of our theories and empirical models of alliances have been misspecified because they have failed to account for why the alliances were formed in the first place. Consider any study on alliances, whether it be on the effect of alliances on trade, conflict, or democratization. By assuming that alliances are formed for the same purpose, empirical models have problematically pooled alliances formed by Balancers or Aggregators with those formed by Reformers or Consolidators and assumed that their effects are constant. This misspecification plagues both theoretical and empirical work by failing to properly specify the necessary scope conditions about the types of alliances that may be relevant. This new framework offers a fresh take on many old and important questions. Instead of just thinking about the dynamics of different commitments, IR scholars may now empirically consider the dynamics associated with different alliance roles. In other words, this new framework allows us to ask a variety of new questions: \textit{Are alliances formed by Balancers to restrain peer competitors successful? When Aggregators form alliances to prepare for conflict, do they deter it, or produce it? Are Consolidators successful in using alliances to consolidate economic or political ties? When Reformers use alliances to promote economic or political liberalization, do their allies liberalize? How heterogeneous is the international system? How does a state's engagement with world politics evolve?} \clearpage \clearpage \bibliographystyle{IO_bibstyle.bst}
{'timestamp': '2019-04-23T02:26:30', 'yymm': '1904', 'arxiv_id': '1904.09883', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09883'}
arxiv
\section{Introduction} Consider $n$ data points in $\mathbb{R}^d$. When $d \gg n$, PCA has inconsistence issue in estimating the $m$ leading eigenvectors $\mathbf{W}\in\mathbb{R}^{d\times m}$ of population covariance matrix $\mathbf{A} \in \mathbb{R}^{d\times d}$ \citep{johnstone2009consistency}, which can be addressed by assuming the sparsity in the principal components. Prior work has been done in methodology design \citep{zou2006sparse,shen2008sparse,d2007direct,vu2013fantope,papailiopoulos2013sparse,yang2015streaming,kundu2017recovering} and theoretical understanding \citep{vu2013minimax,lei2015sparsistency,yang2016rate,zhang2018optimal}. The principal subspace estimation problem is directly connected to dimension reduction and is important when there are more than one principal component of interest. Indeed, typical applications of PCA use the projection onto the principal subspace to facilitate exploration and inference of important features of the data. As the authors of \citep{vu2013minimax} point out, dimension reduction by PCA should emphasize subspaces rather than eigenvectors. The sparsity level in sparse principal subspace estimation is defined as follows \citep{vu2013minimax,wang2014tighten,yang2015streaming}. \begin{definition}[Subspace sparsity, \citep{vu2013minimax}]\label{def:sparsespace} For the $m$-dimensional principal subspace $\textnormal{span}(\mathbf{W})$ of the covariance $\mathbf{A}$, the subspace sparsity level $k$, which should be rotation invariant since the top $m$ eigenvalues of $\mathbf{A}$ might be not distinct, is defined by \[ k = \textnormal{card}(\textnormal{supp}[\textnormal{diag}(\mathbf{\Pi})]) = \|\mathbf{W}\|_{2,0}, \] where $\mathbf{\Pi} = \mathbf{WW}^\top$ is the projection matrix onto $\textnormal{span}(\mathbf{W})$. \end{definition} This paper considers the principal subspace estimation problem with the feature subspace sparsity constraint, termed Feature Sparse PCA (Problem \eqref{eq:fspca} ). Some approaches have been proposed to solve the FSPCA problem \citep{wang2014tighten,yang2015streaming,magdon2016optimal}. Yet, there are some drawbacks in the existing methods. (1) Most of the existing analysis only holds in high probability when specific data generation assumptions hold, e.g., \citet{yang2015streaming} requires data generated from the spike model, \citet{wang2014tighten} requires data generated from the Gaussian distribution. Otherwise, they only guarantee convergence when the initial solution is near the global optimum. (2) Existing iterative schemes are not ascent guaranteed. (3) Some methods make the spike model assumption, in which the covariance is instinctively low-rank, but existing methods cannot make full use of the low-rank structure in the covariance. \begin{figure} \centering \includegraphics{nm_fig.pdf}% \caption{Element-wise Sparse PCA $\mathbf{W}_{\text{(a)}}$ versus Feature Sparse PCA $\mathbf{W}_{\text{(b)}}$.}% \label{fig:matrix}% \end{figure} In this paper, we provide two optimization strategies to estimate the leading sparse principal subspace with provable guarantees. The first strategy (Algorithm \ref{alg:kISc}) solves the feature sparse PCA problem globally when the covariance matrix is low-rank, while the second strategy (Algorithm \ref{alg:generalFSPCA}) solves the feature sparse PCA for general covariance matrix iteratively with its convergence guaranteed. \paragraph{Contributions.} More precisely, we make the following contributions: \begin{enumerate} \item We show that, for a low-rank covariance matrix, the FSPCA problem can be solved globally with the newly proposed algorithm (Algorithm \ref{alg:kISc}). For the general high-rank case, we report an iterative algorithm (Algorithm \ref{alg:generalFSPCA}) by building a carefully designed proxy covariance. \item We prove theoretical guarantees on approximation and convergence for the proposed optimization strategies. Computational complexities analysis of both algorithms are provided. \item We conduct experiments on both synthetic and real-world data to evaluate the new algorithms. The experimental results demonstrate the promising performance of the newly proposed algorithms compared with the state-of-the-art methods. \end{enumerate} \paragraph{Notations.} Throughout this paper, scalars, vectors and matrices are denoted by lowercase letters, boldface lowercase letters and boldface uppercase letters, respectively; for a matrix $\mathbf{A} \in \mathbb{R}^{d \times d}$, $\mathbf{A}^\top$ denotes the transpose of $\mathbf{A}$, $\textnormal{Tr}(\mathbf{A}) = \sum_{i=1}^d a_{ii}$, $\| \mathbf{A} \|_F^2 = \textnormal{Tr}(\mathbf{A}^\top\mathbf{A})$; $\mathbb{1}_n\in\mathbb{R}^n$ denotes vector with all ones; $\|\mathbf{x}\|_0$ denotes the number of non-zero elements;$\|\mathbf{A}\|_{p,q} = ( \sum_{i=1}^d \|\mathbf{a}_i\|_p^q )^{1/q}$; $\Ind{n} \in \mathbb{R}^{n\times n}$ denotes the identity matrix; $\mathbf{H}_n = \Ind{n} - \frac{1}{n}\mathbb{1}_n\mathbb{1}_n^\top$ is the centralization matrix; $\mathcal{I}(1:k)$ is the first $k$ elements in indices $\mathcal{I}$; $\mathbf{A}^\dagger$ denotes the Moore–Penrose inverse; $\mathbf{A}_m$ is the best rank-$m$ approximation of $\mathbf{A}$ in Frobenius norm; card$(\mathcal{I})$ is the cardinality of $\mathcal{I}$; $\mathbb{1}$\{condition\} is the indicator of the condition. \section{Prior Work}\label{sec:prior} \paragraph{Sparse Principal Components.} Most existing methods in the literature to solve the sparse PCA problem only estimate the first leading eigenvector with the element-wise sparsity constraint. To estimate the $m$ leading eigenvectors, one has to build a new covariance matrix with the deflation technique \citep{mackey2009deflation} and solve the leading eigenvector again. The main drawback of this scheme is that, for example, the indices of non-zero elements in the first eigenvector might not be the same as that of the second eigenvector. As shown in \Cref{fig:matrix}, the sparsity pattern is inconsistent among the $m$ leading eigenvectors. Moreover, as pointed out by \cite{wang2014tighten}, the deflation has identifiability and orthogonality issues when the top $m$ eigenvalues are not distinct. \citep{asteris2014nonnegative,papailiopoulos2013sparse} propose methods for the leading eigenvector with approximation guarantee but their guarantee only applies to the first component, not to further iterates. \paragraph{Sparse Principal Subspace.} \citet{vu2013minimax} consider a different setting that the estimated subspace is subspace sparsity constrained (\Cref{def:sparsespace}), in which the sparsity pattern is forced consistent among rows. They show this problem has nice statistical properties \citep{vu2013minimax}, that is, the optimum is minimax optimal. But there is a gap between the computational method and statistical theory. To close this gap, \citep{wang2014tighten,yang2015streaming,magdon2016optimal} proposed algorithms to solve the subspace sparsity constrained problem. However, existing methods require data distribution assumptions and are lack of global convergence guarantee. \paragraph{Sparse Regression.} Another line of research \citep{pang2018efficient,du2018exploiting,cai2013exact} considers solving the sparse regression problem with the $\ell_{2,0}$ constraint. The main technical difference between the $\ell_{2,0}$ constrained sparse regression and FSPCA is the semi-orthogonal constraint on $\mathbf{W}$. Without the semi-orthogonal constraint, the FSPCA problem is not bound from above. Existing techniques to solve the $\ell_{2,0}$ constrained sparse regression problem, e.g., the projected gradient scheme in \cite{pang2018efficient}, cannot be used to solve our problem because, to our knowledge, there is no method to solve the projection subproblem with the semi-orthogonal constraint. Thus, the FSPCA problem is substantially more difficult than that of $\ell_{2,0}$-constrained sparse regression. \section{Problem Setup}\label{sec:FSPCA} Formally, we propose algorithms to solve the following general problem \begin{equation}\label{eq:fspca} \mathop{\textnormal{maximize}}_{\mathbf{W}\in\mathbb{R}^{d\times m}} \textnormal{Tr}\left( \mathbf{W}^\top \mathbf{A} \mathbf{W} \right) \quad\textnormal{subject to}\quad \mathbf{W}^\top\mathbf{W} = \Ind{m},\|\mathbf{W}\|_{2,0}\leq k, \end{equation} where $m \leq k \leq d$ and matrix $\mathbf{A} \in \mathbb{R}^{d\times d}$ is positive semi-definite. This problem is NP-hard to solve globally even for $m = 1$ \citep{moghaddam2006spectral} and sadly NP-hard to solve $(1-\varepsilon)$-approximately for small $\varepsilon > 0$ \citep{chan2016approximability}. Several techniques have been proposed \citep{wang2014tighten,yang2015streaming} to solve this challenging problem. However, they only report high-probability analysis and none of them provides deterministic guarantee on both approximation and global convergence. \begin{remark} As shown in \citet{vu2013minimax}, the optimal $\mathbf{W}$ of Problem \eqref{eq:fspca} achieves the optimal minimax error for row sparse subspace estimation. Besides, the FSPCA problem can be viewed as performing unsupervised feature selection and PCA simultaneously. The key point is the $\ell_{2,0}$ norm constraint forces the sparsity pattern consistence among different eigenvectors, while the vanilla element-wise sparse PCA model cannot keep this consistence as shown in \Cref{fig:matrix}. One might use only the leading eigenvector for feature selection \citep{luss2010clustering,naikal2011informative} but this leads to suboptimal solution when there are more than one principal component of interest. \end{remark} \section{Optimization Strategies}\label{sec:optimization} In this section, we provide new optimization strategies to solve the FSPCA model in Problem \eqref{eq:fspca}. We first consider the case when rank$(\mathbf{A}) \leq m$, for which a non-iterative strategy (Algorithm \ref{alg:kISc}) is provided to solve the problem globally. Then we consider the general case when rank$(\mathbf{A}) > m$, for which we provide an iterative algorithm (Algorithm \ref{alg:generalFSPCA}) by approximating $\mathbf{A}$ with a carefully designed low-rank proxy covariance $\mathbf{P}$ and solve the proxy subproblem with the Algorithm \ref{alg:kISc}. \subsection{GO: Finding the Global Optimum for rank$(\mathbf{A}) \leq m$} We make the following notion for ease of notations. \begin{definition}[Row selection matrix map] We define $(d, k)$-row selection matrix map $\mathbb{S}_{d,k}(\mathcal{I})$ to build row selection matrix $\mathbf{S}\in\mathbb{R}^{d\times k}$ according to given indices $\mathcal{I}$ such that $\mathbb{S}_{d,k}(\mathcal{I})=\mathbf{S}$. One can left multiply the row selection matrix $\mathbf{S}$ to select specific $k$ rows from $d$ inputs. Specifically, \[ s_{ij}= \left\{ \begin{array}{rcl} 1 & \mbox{for} & i = \mathcal{I}(j) \\ 0 & \mbox{for} & otherwise. \end{array} \right. \] \end{definition} The algorithm to solve Problem \eqref{eq:fspca} is summarized in the following Algorithm \ref{alg:kISc}. \begin{algorithm}[H] \caption{Solve Problem \eqref{eq:fspca} with $\textnormal{rank}(\mathbf{A}) \leq m$} \label{alg:kISc} \begin{algorithmic}[1] \Procedure{Go}{$\mathbf{A},m,k,d$} \Comment{require $\mathbf{A}\succcurlyeq \mathbb{0}$, rank$(\mathbf{A}) \leq m$, and $m\leq k \leq d$.} \State $\mathcal{I} \leftarrow$ \texttt{Sort}($\text{diag}(\mathbf{A})$, \texttt{\textquotesingle{}descending\textquotesingle}, \texttt{\textquotesingle{}output indices\textquotesingle}); \Comment{$O(d\log d)$.} \State $\mathbf{S} \leftarrow \mathbb{S}_{d,k}(\texttt{Sort}(\mathcal{I}(1:k), \texttt{\textquotesingle{}ascending\textquotesingle}))$; \Comment{build selection matrix $\mathbf{S}$ from $\mathcal{I}$. $O(k \log k)$.} \State $\mathbf{V} \leftarrow$ \texttt{Eigenvectors}($\mathbf{S}^\top\mathbf{AS}$, \texttt{\textquotesingle{}output $m$ leading eigenvectors\textquotesingle}); \Comment{$O(k^3)$.} \State \Return $\mathbf{W} \leftarrow \mathbf{SV}$; \Comment{$O(km)$.} \EndProcedure \end{algorithmic} \end{algorithm} The following theorem justifies the \textbf{global optimality} of the output of Algorithm \ref{alg:kISc}: \begin{restatable}{theorem}{globaloptimality}\label{thm:globaloptimality} Suppose $\mathbf{A}\succcurlyeq \mathbb{0}$ and rank$(\mathbf{A}) \leq m$. Let $\mathbf{W}=\textsc{Go}(\mathbf{A},m,k,d)$ with $m\leq k \leq d$. Then, $\mathbf{W}$ is a globally optimal solution of Problem \eqref{eq:fspca}. \end{restatable}% \begin{remark}\label{rem:lowRankApp} \Cref{thm:globaloptimality} guarantees the global optimality of Algorithm \ref{alg:kISc} for a low-rank $\mathbf{A}$. It is interesting to see that, though the Problem \eqref{eq:fspca} is NP-hard to solve in general, it is globally solvable for a low-rank covariance $\mathbf{A}$. A natural idea then comes out that we can try to solve the general Problem \eqref{eq:fspca} by running Algorithm \ref{alg:kISc} with the best rank-$m$ approximation $\mathbf{A}_m$. In \Cref{thm:approx} and \Cref{sec:exps}, we will justify this idea theoretically and empirically. \end{remark} \begin{remark}\label{rem:addEyeIsOK} If there exists $\sigma$ such that $\textnormal{rank}(\mathbf{A}+\sigma\Ind{d}) \leq m$, which is the covariance in spike model, then the Algorithm \ref{alg:kISc} still outputs a globally optimal solution with $\mathbf{A} + \sigma\Ind{d}$ as input, since $ \textnormal{Tr}\left(\mathbf{W}^\top (\mathbf{A}+\sigma \Ind{d}) \mathbf{W} \right) = \textnormal{Tr}\left(\mathbf{W}^\top \mathbf{A} \mathbf{W} \right) + \sigma m. $ $\textnormal{rank}(\mathbf{A}) \leq m$ is a special case when $\sigma=0$. \end{remark} \subsection{IPU: Iteratively Proxy Update for rank$(\mathbf{A}) > m$} In this subsection, we consider the general case, that is, rank$(\mathbf{A}) > m$. The main idea is that we try to build a proxy covariance, say $\mathbf{P}$, of original $\mathbf{A}$ such that $\textnormal{rank}(\mathbf{P}) \leq m, \mathbf{P} \succcurlyeq \mathbb{0}$. Then we can run Algorithm \ref{alg:kISc} with the low-rank proxy $\mathbf{P}$ to solve the original problem iteratively. \textbf{Proxy Construction.} With careful design, given the estimate $\mathbf{W}_t$ from the $t$th iterative step, we define the matrix \[ \mathbf{P}_t = \mathbf{A}\mathbf{W}_{t}(\mathbf{W}_t^\top \mathbf{A}\mathbf{W}_t)^{\dagger}\mathbf{W}_t^\top\mathbf{A} \] as the low-rank proxy matrix of original $\mathbf{A}$. Then, We solve Problem \ref{eq:fspca} with the proxy $\mathbf{P}_t$ rather than $\mathbf{A}$. Following claim verifies the sufficient conditions for $\mathbf{P}_t$ to be solvable with Algorithm \ref{alg:kISc}. \begin{restatable}{claim}{proxyclaim}\label{chaim:PisSolvable} For each $t\geq 1$, $\mathbf{W}_t^\top\mathbf{W}_t = \Ind{m}$, it holds $\textnormal{rank}(\mathbf{P}_t) \leq m$, and $ \mathbf{P}_t \succcurlyeq \mathbb{0}.$ \end{restatable} \textbf{Indices Selection.} With the proxy matrix $\mathbf{P}_t$ in hand, a natural idea is to iteratively update $\mathbf{W}$ by solving the following problem with Algorithm \ref{alg:kISc}: \begin{equation}\label{eq:WwtDEF} \widetilde{\mathbf{W}}_{t+1} \leftarrow \textsc{Go}(\mathbf{P}_t, m, k,d). \end{equation} But we can further refine the $\widetilde{\mathbf{W}}_{t+1}$ by performing eigenvalue decomposition on original $\mathbf{A}$ rather than on the proxy covariance $\mathbf{P}_t$, which will accelerate the convergence. \textbf{Eigenvectors Refinement.} Note that $\widetilde{\mathbf{W}}_{t+1}$ can be written as $\widetilde{\mathbf{W}}_{t+1} = \mathbf{S}_{t+1}\widetilde{\mathbf{V}}_{t+1}$, where $\mathbf{S}_{t+1}$ is the selection matrix and $\widetilde{\mathbf{V}}_{t+1}$ is the eigenvectors in the row support of $\widetilde{\mathbf{W}}_{t+1}$. Then, $\widetilde{\mathbf{W}}_{t+1}$ can be further refined by fixing the selection matrix $\mathbf{S}_{t+1}$ and updating the eigenvectors $\mathbf{V}_{t+1}$ with \begin{equation}\label{eq:solveVclever} \mathbf{V}_{t+1} \leftarrow \mathop{\arg\mathop{\textnormal{maximize}}}_{\mathbf{V}^\top\mathbf{V}=\Ind{m}} \textnormal{Tr}(\mathbf{V}^\top\mathbf{S}_{t+1}^\top\mathbf{A}\mathbf{S}_{t+1}\mathbf{V}). \end{equation} And finally, the refined $\mathbf{W}_{t+1}$ can be computed by \mathbf{W}_{t+1} \leftarrow \mathbf{S}_{t+1}\mathbf{V}_{t+1}. $ Compared with updating with Problem \eqref{eq:WwtDEF}, updating with the refinement makes larger progress thus it is more aggressive. In summary, we collect the proposed procedure to solve FSPCA when $\textnormal{rank}(\mathbf{A}) > m$ in Algorithm \ref{alg:generalFSPCA}. \begin{algorithm}[H] \caption{Solve Problem \eqref{eq:fspca} with $\textnormal{rank}(\mathbf{A}) > m$} \label{alg:generalFSPCA} \begin{algorithmic}[1] \Procedure{Ipu}{$\mathbf{A},m,k,d, \mathbf{W}_0$} \Comment{require $\mathbf{A}\succcurlyeq \mathbb{0}$ and $m\leq k \leq d$.} \Repeat \State $\mathbf{P}_t \leftarrow \mathbf{A}\mathbf{W}_t(\mathbf{W}_t^\top \mathbf{A}\mathbf{W}_t )^{\dagger}\mathbf{W}_t^\top \mathbf{A}$; \Comment{$O(m^2d)$.} \State $\mathcal{I}_t \leftarrow$ \texttt{Sort}($\text{diag}(\mathbf{P}_t)$, \texttt{\textquotesingle{}descending\textquotesingle{}}, \texttt{\textquotesingle{}output indices\textquotesingle{}}); \Comment{$O(d\log d)$.} \State $\mathbf{S}_t \leftarrow \mathbb{S}_{d,k}(\texttt{Sort}(\mathcal{I}_t(1:k), \texttt{\textquotesingle{}ascending\textquotesingle}))$; \Comment{$O(k\log k)$.} \State $\mathbf{V}_t \leftarrow$ \texttt{Eigenvectors}($\mathbf{S}^\top\mathbf{AS}$, \texttt{\textquotesingle{}output $m$ leading eigenvectors\textquotesingle{}}); \Comment{$O(k^3)$.} \State $ \mathbf{W}_{t+1} \leftarrow \mathbf{S}_{t}\mathbf{V}_{t} $; $\quad t \leftarrow t+1$; \label{alg_line:defW} \Comment{$O(km)$. \Until{$\mathcal{I}_{t-1} = \mathcal{I}_{t-2}$} \State \Return{$\mathbf{W}_t$;} \EndProcedure \end{algorithmic} \end{algorithm} \section{Theoretical Justification}\label{sec:analysis} In this section, we provide the theoretical analysis for Algorithm \ref{alg:kISc} and \ref{alg:generalFSPCA}. In detail, we prove approximation and convergence guarantees for the new algorithms. Then, we report the computational complexities and compare them with these of methods in the literature. \subsection{Approximation Guarantee}\label{sec:approx} First, we define constants related to the eigenvalues decay of $\mathbf{A}$. Let $r=\min\{\textnormal{rank}(\mathbf{A}), 2m\}$, and \[\textstyle G_1 = \frac{\sum_{i=m+1}^{r}\lambda_i(\mathbf{A})}{\sum_{i=1}^m \lambda_i(\mathbf{A})},\qquad\qquad G_2 = \frac{\sum_{i=m+1}^{r}\lambda_i(\mathbf{A})}{\sum_{i=1}^d \lambda_i(\mathbf{A})}. \] The main approximation result can be stated as follows. \begin{restatable}{theorem}{approxgua}\label{thm:approx} Suppose $\mathbf{A}\succcurlyeq \mathbb{0}, m\leq k \leq d$. Let $\mathbf{W}_m = \text{Go}(\mathbf{A}_m, m, k, d)$, and $\mathbf{W}_*$ be a globally optimal solution of Problem \ref{eq:fspca}. Then, we have $ (1-\varepsilon) \leq \frac{\textnormal{Tr}(\mathbf{W}_m^\top\mathbf{A}\mathbf{W}_m) }{\textnormal{Tr}(\mathbf{W}_*^\top\mathbf{A}\mathbf{W}_*)} \leq 1 $ with $\varepsilon \leq \min\left\{ \frac{dG_1}{k},\frac{dG_2}{m} \right\}$. \end{restatable} \begin{remark} \Cref{thm:approx} says that, for sufficiently large $m$ or $k$, $\text{Go}(\mathbf{A}_m, m, k, d)$ gives a $(1-\varepsilon)$-approximate solution of Problem \ref{eq:fspca}. Also note that, when the eigenvalues of the covariance $\mathbf{A}$ decay fast enough, a small $m$ or $k$ is sufficient to guarantee $(1-\varepsilon)$-approximation. It is notable that, when $\textnormal{rank}(\mathbf{A}) \leq m$, we have $G_1 = G_2 = 0, \mathbf{A}=\mathbf{A}_m$, which implies $\varepsilon=0$ and the output of the Algorithm \ref{alg:kISc} is a globally optimal solution. This cross-verifies the correctness of \Cref{thm:globaloptimality}. \end{remark} It has been observed by \citet{breslau1999web,faloutsos1999power,mihail2002eigenvalue} that many phenomena approximately follow Zipf-like spectrum, e.g., Web caching, Internet topology, and city population. Specifically, the $i$th eigenvalue of the Zipf-like spectrum is $ci^{-t}$ with constants $c>0,t>1$. We have following corollary from \Cref{thm:approx} for Zipf-like distributed eigenvalues. \begin{restatable}[Zipf-like distribution]{corollary}{coroPower}\label{coro:power} Suppose $\mathbf{A}\succcurlyeq \mathbb{0}, m\leq k \leq d$, and $\lambda_i(\mathbf{A})=ci^{-t}$ with $t > 1, c > 0$ for each $i=1,\dots,2m$. Let $\mathbf{W}_m = \text{Go}(\mathbf{A}_m, m, k, d)$, and $\mathbf{W}_*$ be an optimal solution of Problem \ref{eq:fspca}. If the sparsity satisfies $k=\Omega\left(\frac{d}{\varepsilon m^{t-1}}\right)$, then we have $(1-\varepsilon) \leq \frac{\textnormal{Tr}(\mathbf{W}_m^\top\mathbf{A}\mathbf{W}_m)}{\textnormal{Tr}(\mathbf{W}_*^\top\mathbf{A}\mathbf{W}_*)} \leq 1$. \end{restatable} \subsection{Convergence Guarantee} In this section, we show the iterative scheme proposed in Algorithm \ref{alg:generalFSPCA} increases the objective function value in every iterative step, which directly indicates the convergence of the iterative scheme. \begin{restatable}{theorem}{ascentthm}\label{thm:ascent} Suppose $\mathbf{A}\succcurlyeq \mathbb{0}, m\leq k \leq d$. Let $\mathbf{W}_{t+1}=\mathbf{S}_t\mathbf{V}_t$ be the variable defined in \Cref{alg_line:defW} of Algorithm \ref{alg:generalFSPCA}. Then, it holds that $ \textnormal{Tr}(\mathbf{W}_{t}^\top\mathbf{A}\mathbf{W}_{t})\leq \textnormal{Tr}(\mathbf{W}_{t+1}^\top\mathbf{A}\mathbf{W}_{t+1}). $ \end{restatable} \begin{remark}\label{rem:ascent} \Cref{thm:ascent} shows that the newly proposed Algorithm \ref{alg:generalFSPCA} is an ascent method, that is $\{\textnormal{Tr}(\mathbf{W}_t^\top \mathbf{A}\mathbf{W}_t)\}_{t=1}^T$ is an increasing sequence, which is important since most of the existing algorithms for solving Problem \eqref{eq:fspca} are not ascent. That is to say, they cannot guarantee the output is better than the initialization. Combining with the fact that the objective function is bounded from above by finite $\textnormal{Tr}(\mathbf{A})$, the convergence of Algorithm \ref{alg:generalFSPCA} can be obtained. \end{remark} Leveraging the ascent property, we have following the approximation guarantee for Algorithm \ref{alg:generalFSPCA}. \begin{corollary}\label{coro:approxIPU} Suppose $\mathbf{A}\succcurlyeq \mathbb{0}$. Let $\widehat{\mathbf{W}} = \text{IPU}(\mathbf{A}, m, k, d, \text{Go}(\mathbf{A}_m, m, k, d))$, and $\mathbf{W}_*$ be an optimal solution of Problem \ref{eq:fspca}. Then, we have $ (1-\varepsilon) \leq \frac{\textnormal{Tr}(\widehat{\mathbf{W}}^\top\mathbf{A}\widehat{\mathbf{W}}) }{\textnormal{Tr}(\mathbf{W}_*^\top\mathbf{A}\mathbf{W}_*)} \leq 1 $ with $\varepsilon \leq \min\left\{ \frac{dG_1}{k},\frac{dG_2}{m} \right\}$. \end{corollary} \subsection{Computational Complexity} \textbf{Algorithm \ref{alg:kISc}.} It is easy to see the overall complexity is $O( \mathop{\textnormal{maximize}}\{d\log d, k^3\})$ since $O(d\log d)$ for indices selection, $O(k^3)$ for eigenvalue decomposition, and $O(km)$ for building the output $\mathbf{W}$. \textbf{Algorithm \ref{alg:generalFSPCA}.} The overall computational complexity is $O( \mathop{\textnormal{maximize}}\{d\log d, k^3, dkm\}T)$, where $T$ is the number of iterative steps used to coverage. In \Cref{sec:toydata}, we will see the number of iterative steps $T$ is usually less than $20$ empirically. For proxy covariance construction and indices selection, we need $O(\mathop{\textnormal{maximize}}\{dm^2, d\log d\})$ for naively building $\mathbf{P}_t$ and running Algorithm \ref{alg:kISc}. But note that we only need the diagonal elements in $\mathbf{P}_t$ for sorting and selecting. Thus, we only compute the diagonal elements of $\mathbf{P}_t$ and sort it for the indices selection, that is $O(\mathop{\textnormal{maximize}}\{dkm, d\log d\})$. Then, performing eigenvectors refinement and updating $\mathbf{W}_{t+1}$ costs $O(k^3)$. Also note that, the computational complexity of SOAP proposed in \citep{wang2014tighten} is $O(d^2m)$ for every iterative step. Ours computational complexity is strictly less than that of SOAP. For SRT in \citep{yang2015streaming}, the computational complexity is $O(dm \min\{m, k \log d\}) $. When $k=O(m)$, our complexity matches that of SRT. \section{Discussion}\label{sec:discuss} In this section, we provide discussion to show that the newly proposed algorithm fits into the MM optimization framework and discuss the invertibility issue of $\mathbf{W}_t^\top\mathbf{A}\mathbf{W}_t$. \subsection{MM Framework} Lots of classical algorithms can be framed into the MM framework, e.g., EM Algorithm \citep{dempster1977maximum}, Proximal Algorithms \citep{bertsekas1994partial,parikh2014proximal}, Concave-Convex Procedure (CCCP) \citep{yuille2002concave,lipp2016variations}. Please refer to \citep{sun2017majorization} for further discussion. It is notable that the newly proposed Algorithm \ref{alg:generalFSPCA} can also be viewed as a special case of the general MM optimization framework with the auxiliary function defined by $ g(\mathbf{W};\mathbf{W}_t) = \textnormal{Tr}(\mathbf{W}^\top \mathbf{A}\mathbf{W}_{t}(\mathbf{W}_t^\top \mathbf{A}\mathbf{W}_t)^{\dagger}\mathbf{W}_t^\top\mathbf{A} \mathbf{W}) \leq \textnormal{Tr}(\mathbf{W}^\top \mathbf{A} \mathbf{W}). $ Meanwhile, it is easy to check that $g(\mathbf{W};\mathbf{W}_t)$ satisfies $ g(\mathbf{W}_t;\mathbf{W}_t) = \textnormal{Tr}(\mathbf{W}_t^\top \mathbf{A} \mathbf{W}_t). $ \subsection{On the Invertibility of $\mathbf{W}_t^\top\mathbf{A}\mathbf{W}_t$} In the definition of the proxy matrix $\mathbf{P}_t$, there is a Moore–Penrose inverse term $(\mathbf{W}_t^\top\mathbf{A}\mathbf{W}_t)^\dagger$. In this subsection we provide a condition under which this matrix is always invertible thus the Moore–Penrose inverse can be replaced with the matrix inverse. The reason why we care about the invertibility is that when $\mathbf{W}_t^\top\mathbf{A}\mathbf{W}_t$ is not invertible, it is rank deficient. Thus it might not be a good approximation to the high-rank covariance $\mathbf{A}$. \begin{restatable}{claim}{invertclaim}\label{claim:invert} If \textnormal{rank}$(\mathbf{A}) \geq d - k + m$, then, for all $t$, $\mathbf{W}_t^\top\mathbf{A}\mathbf{W}_t$ in Algorithm \ref{alg:generalFSPCA} is always invertible. \end{restatable} \begin{remark} \label{rem:invert} Note that the condition shown in \Cref{claim:invert} is easy to be satisfied. Indeed, we can solve Problem \eqref{eq:fspca} with $\mathbf{A}_\varepsilon = \mathbf{A} + \varepsilon\cdot\Ind{d}$. Thus, $\textnormal{rank}(\mathbf{A}_\varepsilon) = d \geq d-k+m$. Note that this small $\varepsilon$ perturbation on $\mathbf{A}$ does not change the optimal $\mathbf{W}$ because $ \textnormal{Tr}\left(\mathbf{W}^\top \mathbf{A}_\varepsilon \mathbf{W} \right) = \textnormal{Tr}\left(\mathbf{W}^\top \mathbf{A} \mathbf{W} \right) + \varepsilon m, $ which is only a constant $\varepsilon m$ added to the original objective function. Thus, the optimal $\mathbf{W}$ remains unchanged. In practice, we recommend using $\mathbf{A}_\varepsilon$ with a small $\varepsilon > 0$ to keep safe. \end{remark} \begin{table}[t] \centering \caption{Synthetic Data Description} \label{tab:my-table} \begin{tabularx}{\textwidth}{@{}clXl@{}} \toprule No. & \multicolumn{1}{c}{Description} & & \multicolumn{1}{c}{Note} \\ \midrule A & $\mathbf{\lambda}(\mathbf{A})=\{100,100,4,1,\dots,1\}$ & & Setting in \citep{wang2014tighten} \\ B & $\mathbf{\lambda}(\mathbf{A})=\{300,180,60,1,\dots,1\}$ & & Setting in \citep{wang2014tighten} \\ C & $\mathbf{\lambda}(\mathbf{A})=\{300,180,60,0,\dots,0\}$ & & To justify \Cref{thm:globaloptimality} \\ D & $\mathbf{\lambda}(\mathbf{A})=\{160,80, 40, 20, 10, 5, 2,1,\dots,1\}$ & & For all $\sigma$, rank$(\mathbf{A+\sigma\Ind{d}}) > m$ \\ E & $\mathbf{X}$ is \emph{iid} sampled from $\mathcal{U}[0, 1]$ and $\mathbf{A}=\mathbf{XX}^\top$ & & Uniform Distribution \\ F & $\mathbf{X}$ is \emph{iid} sampled from $\mathcal{N}(0, 1)$ and $\mathbf{A}=\mathbf{XX}^\top$ & & Gaussian Distribution \\ \bottomrule \end{tabularx} \end{table} \section{Experiments}\label{sec:exps} In this section, we provide experimental results to validate the effectiveness of the proposed Go and IPU on both synthetic and real-world data. In our experiments, we always use $\mathbf{A}_\varepsilon$ with $\varepsilon=0.1$ to keep safe (\Cref{rem:invert}), except in the No. C synthetic data where we require $\textnormal{rank}(\mathbf{A}) \leq m$. \begin{table}[t] \centering \caption{Synthetic Data Results. [mean $($std. err.$)$; $\uparrow$: larger is better; $\downarrow$: smaller is better]} \label{tab:toy} \resizebox{\textwidth}{!}{% \begin{tabular}{@{}ccccccccccccc@{}} \toprule & & \multicolumn{3}{c}{Random Subspace} & & \multicolumn{3}{c}{Convex Relaxation} & & \multicolumn{3}{c}{Low Rank Approx.} \\ \cmidrule(lr){3-5} \cmidrule(lr){7-9} \cmidrule(l){11-13} & & IR $\uparrow$ & RE $\downarrow$ & HF $\uparrow$ & & IR $\uparrow$ & RE $\downarrow$ & HF $\uparrow$ & & IR $\uparrow$ & RE $\downarrow$ & HF $\uparrow$ \\ \midrule \multirow{5}{*}{A} & SOAP & 0.73 (0.09) & 0.03 (0.02) & 0.18 (0.15) & & 0.71 (0.12) & 0.08 (0.04) & 0.01 (0.01) & & 0.84 (0.12) & 0.03 (0.03) & 0.22 (0.17) \\ & SRT & 0.77 (0.19) & 0.01 (0.02) & 0.70 (0.21) & & 0.92 (0.12) & 0.01 (0.02) & 0.62 (0.24) & & 0.88 (0.16) & 0.02 (0.04) & 0.50 (0.25) \\ & CSSP & 0.63 (0.13) & 0.88 (0.05) & 0.00 (0.00) & & 0.62 (0.12) & 0.87 (0.06) & 0.00 (0.00) & & 0.62 (0.12) & 0.87 (0.06) & 0.00 (0.00) \\ & Go & 0.92 (0.12) & 0.01 (0.03) & 0.74 (0.19) & & 0.93 (0.12) & 0.01 (0.03) & 0.67 (0.22) & & 0.93 (0.12) & 0.01 (0.03) & 0.66 (0.22) \\ & IPU & \textbf{0.97 (0.04)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{0.99 (0.04)} & \textbf{0.00 (0.00)} & \textbf{0.97 (0.03)} & \textbf{} & \textbf{0.98 (0.05)} & \textbf{0.00 (0.00)} & \textbf{0.91 (0.08)} \\ \midrule \multirow{5}{*}{B} & SOAP & 0.76 (0.12) & 0.03 (0.03) & 0.14 (0.12) & & 0.78 (0.11) & 0.04 (0.03) & 0.09 (0.08) & & 0.77 (0.12) & 0.04 (0.03) & 0.05 (0.05) \\ & SRT & 0.59 (0.08) & 0.03 (0.03) & 0.28 (0.20) & & 0.79 (0.14) & 0.04 (0.04) & 0.15 (0.13) & & 0.80 (0.16) & 0.04 (0.05) & 0.30 (0.21) \\ & CSSP & 0.77 (0.10) & 0.90 (0.05) & 0.00 (0.00) & & 0.76 (0.12) & 0.90 (0.05) & 0.00 (0.00) & & 0.76 (0.12) & 0.91 (0.05) & 0.00 (0.00) \\ & Go & \textbf{0.99 (0.02)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{0.99 (0.02)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{0.99 (0.01)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} \\ & IPU & 0.97 (0.03) & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{0.99 (0.01)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{0.99 (0.01)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} \\ \midrule \multirow{5}{*}{C} & SOAP & 0.77 (0.12) & 0.04 (0.03) & 0.11 (0.10) & & 0.77 (0.12) & 0.04 (0.03) & 0.08 (0.07) & & 0.76 (0.12) & 0.04 (0.03) & 0.05 (0.05) \\ & SRT & 0.59 (0.08) & 0.03 (0.04) & 0.20 (0.16) & & 0.76 (0.16) & 0.05 (0.05) & 0.12 (0.11) & & 0.80 (0.17) & 0.05 (0.06) & 0.26 (0.19) \\ & CSSP & 0.77 (0.11) & 0.94 (0.03) & 0.00 (0.00) & & 0.76 (0.12) & 0.94 (0.03) & 0.00 (0.00) & & 0.76 (0.12) & 0.94 (0.03) & 0.00 (0.00) \\ & Go & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} \\ & IPU & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} & \textbf{} & \textbf{1.00 (0.00)} & \textbf{0.00 (0.00)} & \textbf{1.00 (0.00)} \\ \midrule \multirow{5}{*}{D} & SOAP & 0.79 (0.08) & 0.01 (0.01) & 0.43 (0.25) & & 0.80 (0.13) & 0.02 (0.02) & 0.15 (0.13) & & 0.84 (0.11) & 0.01 (0.01) & 0.22 (0.17) \\ & SRT & 0.57 (0.07) & 0.02 (0.02) & 0.14 (0.12) & & 0.77 (0.15) & 0.04 (0.04) & 0.12 (0.11) & & 0.83 (0.14) & 0.02 (0.03) & 0.27 (0.20) \\ & CSSP & 0.76 (0.12) & 0.80 (0.07) & 0.00 (0.00) & & 0.77 (0.12) & 0.82 (0.08) & 0.00 (0.00) & & 0.77 (0.12) & 0.82 (0.08) & 0.00 (0.00) \\ & Go & \textbf{0.91 (0.10)} & \textbf{0.00 (0.01)} & 0.52 (0.25) & & 0.92 (0.10) & \textbf{0.00 (0.01)} & 0.59 (0.24) & & \textbf{0.92 (0.09)} & \textbf{0.00 (0.01)} & 0.56 (0.25) \\ & IPU & 0.83 (0.07) & \textbf{0.00 (0.00)} & \textbf{0.97 (0.03)} & \textbf{} & \textbf{0.93 (0.10)} & \textbf{0.00 (0.01)} & \textbf{0.65 (0.23)} & \textbf{} & \textbf{0.92 (0.10)} & \textbf{0.00 (0.01)} & \textbf{0.60 (0.24)} \\ \midrule \multirow{5}{*}{E} & SOAP & 0.43 (0.07) & 0.06 (0.03) & 0.01 (0.01) & & 0.46 (0.16) & 0.12 (0.05) & 0.00 (0.00) & & 0.73 (0.16) & 0.04 (0.04) & 0.12 (0.11) \\ & SRT & 0.86 (0.07) & \textbf{0.00 (0.00)} & 0.72 (0.20) & & 0.88 (0.11) & 0.01 (0.01) & 0.40 (0.24) & & \textbf{0.90 (0.09)} & \textbf{0.01 (0.01)} & \textbf{0.52 (0.25)} \\ & CSSP & 0.43 (0.16) & 0.82 (0.06) & 0.00 (0.00) & & 0.43 (0.16) & 0.83 (0.06) & 0.00 (0.00) & & 0.44 (0.16) & 0.83 (0.06) & 0.00 (0.00) \\ & Go & \textbf{0.89 (0.09)} & \textbf{0.00 (0.01)} & 0.48 (0.25) & & \textbf{0.90 (0.09)} & \textbf{0.00 (0.01)} & \textbf{0.46 (0.25)} & & 0.88 (0.10) & \textbf{0.01(0.01)} & 0.41 (0.24) \\ & IPU & 0.83 (0.06) & \textbf{0.00 (0.00)} & \textbf{0.89 (0.10)} & & 0.87 (0.10) & 0.01 (0.01) & 0.37 (0.23) & & 0.88 (0.10) & \textbf{0.01(0.01)} & 0.42 (0.24) \\ \midrule \multirow{5}{*}{F} & SOAP & 0.61 (0.07) & \textbf{0.01 (0.01)} & 0.36 (0.23) & & 0.79 (0.14) & \textbf{0.03 (0.03)} & 0.16 (0.13) & & 0.81 (0.12) & \textbf{0.03 (0.02)} & 0.16 (0.13) \\ & SRT & 0.62 (0.08) & \textbf{0.01 (0.01)} & 0.37 (0.23) & & \textbf{0.82 (0.12)} & \textbf{0.03 (0.02)} & \textbf{0.20 (0.16)} & & \textbf{0.82 (0.12)} & \textbf{0.03 (0.02)} & \textbf{0.17 (0.14)} \\ & CSSP & 0.79 (0.13) & 0.52 (0.08) & 0.00 (0.00) & & 0.77 (0.14) & 0.54 (0.08) & 0.00 (0.00) & & 0.77 (0.14) & 0.54 (0.08) & 0.00 (0.00) \\ & Go & \textbf{0.83 (0.12)} & 0.02 (0.03) & 0.21 (0.17) & & 0.81 (0.12) & \textbf{0.03 (0.03)} & 0.16 (0.13) & & 0.81 (0.12) & \textbf{0.03 (0.03)} & 0.16 (0.13) \\ & IPU & 0.62 (0.07) & \textbf{0.01 (0.01)} & \textbf{0.44 (0.25)} & & \textbf{0.82 (0.12)} & \textbf{0.03 (0.02)} & 0.18 (0.15) & & \textbf{0.82 (0.12)} & \textbf{0.03 (0.02)} & \textbf{0.17 (0.14)} \\ \bottomrule \end{tabular}% } \end{table} \subsection{Synthetic Data}\label{sec:toydata} To show the effectiveness of the proposed method, we build a series of small-scale synthetic datasets, whose global optimum can be obtained by brute-force searching. Then we compare our methods with several state-of-the-art methods with optimal indices and objective value in hand. \paragraph{Experiments Setup.} We compare the newly proposed \textsc{Go} (Algorithm \ref{alg:kISc}) and \textsc{Ipu} (Algorithm \ref{alg:generalFSPCA}) with SOAP \citep{wang2014tighten}, SRT \citep{yang2015streaming}, and CSSP \citep{magdon2016optimal}. For the synthetic data, we fix $m=3,k=7,$and $d=20$. We cannot afford large-scale setting since the brute-force searching space grows exponentially. We consider three different initialization methods: Random Subspace; Convex Relaxation proposed in \citep{vu2013fantope} and used in \citep{wang2014tighten}; Low Rank Approx. with \textsc{Go}$(\mathbf{A}_m, m, k, d)$. We consider $6$ different synthetic data in our experiments. The descriptions of these schemes are summarized in \Cref{tab:my-table}. For A--D, we fix the eigenvalues and generate the eigenspace randomly. Every scheme is independently run for 100 times and we report the mean and standard error. For the Random Subspace setting, every realization $\mathbf{A}$ is repeated run 20 times with different random initialization. Thus, in the random initialization setting, we run all algorithms $20\times 100=2000$ times. The overall mean and standard error are reported. \paragraph{Performance Measures.} Intersection Ratio (IR): $ \frac{\text{card}\left( \{\text{estimated indices}\} \cap \{\text{optimal indices} \} \right)}{\text{\# sparsity }k}. $ Relative Error (RE): $ \frac{\textnormal{Tr}\left(\mathbf{W}^\top\mathbf{A}\mathbf{W}\right) - \textnormal{Tr}\left(\mathbf{W}_*^{\top}\mathbf{A}\mathbf{W}_*\right)}{\textnormal{Tr}\left(\mathbf{W}_*^{\top}\mathbf{A}\mathbf{W}_*\right)}. $ Hit Frequency (HF): $ \frac{1}{N} \sum_{i=1}^N \mathbb{1}\{ \text{Relative Error} \leq 10^{-3}\}, $% where $N$ is the number of repeated running. The motivation to use these measures is deferred to \Cref{sec:expDetail}. \paragraph{Results.} Experimental results are reported in \Cref{tab:toy}, and we get the following insights: (1) From No. C, Algorithm \ref{alg:kISc} gives a globally optimal solution when the covariance $\mathbf{A}$ is low-rank. (2) Both the performance of Go and IPU outperform or match other state-of-the-art methods, especially when the numerical rank of covariance is small. (3) CSSP does not perform well in HF and RE, which is consistent with results reported in \citep{magdon2016optimal}, since the objective of CSSP is a regression-type minimization rather than variance maximization. (4) When the Low Rank Approx. strategy (with Go) is used as initialization, all methods have match or even better explained variance than initialization with Convex Relaxation, while the computational complexity of Low Rank Approx. (with SVD) is seriously smaller than that of Convex Relaxation (with ADMM or SDP). Meanwhile, initialization with Random Space has better performance than both Convex Relaxation and Low Rank Approx., which is not surprising since the reported results for Random Subspace are the maximal objective value among 20 random initialization. This strategy is widely used in practice, e.g., run $k$-means multiple times with different initialization and pick the one with the smallest loss. \subsection{Real-world Data} \begin{figure}[t!] \centering \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=\textwidth]{real_L.pdf}% \end{subfigure}% ~ \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=\textwidth]{real_N.pdf}% \end{subfigure} ~ \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=\textwidth]{real_H.pdf}% \end{subfigure} \caption{Real-world Data Results.} \label{fig:real} \end{figure} \paragraph{Experiment Setup.} We consider real-world datasets, including Lymphoma (biology) \citep{yuan2013truncated}, NUS-WIDE (web images) \citep{nus-wide-civr09}, and Numerical Numbers (handwritten numbers) \citep{asuncion2007uci}. We compare Go and IPU with SOAP, SRT, TPower (G) and report the results of TPower (D) as a baseline. TPower (G) selects the sparsity pattern with the leading eigenvector Greedily and TPower (D) uses the Deflation scheme, which cannot produce consistent sparsity pattern among rows. We follow \citep{wang2014tighten} to use Convex Relaxation as the initialization. Following \citep{wang2014tighten,yang2015streaming}, we use the Normalized Explained Variance as the performance measure. The Normalized Explained Variance is defined as $ \textnormal{Tr}(\widehat{\mathbf{W}}^\top \mathbf{A}\widehat{\mathbf{W}}) / \textnormal{Tr}(\mathbf{A}_m), $ where the $\widehat{\mathbf{W}}$ is the subspace estimation returned by algorithms. \paragraph{Results.} The experimental results are reported in \Cref{fig:real}, from which we get the following insights: (1) For all three real-world datasets, the new algorithms, Go and IPU, consistently perform better than other state-of-the-art methods that solve FSPCA; (2) For NN dataset, the performance of all methods except SOAP and TPower (D) are tied. It is of interest to see whether the reason for this phenomenon is the dataset is too difficult or too easy. Therefore, we plot the approximation bound in \Cref{thm:approx}, which reveals that these methods achieve almost optimal performance; (3) While TPower (D) achieves the highest NEV, it cannot be used for either feature selection or sparse subspace estimation (see \Cref{def:sparsespace}), due to the sparsity inconsistent issue of one-by-one eigenvectors estimation (see \Cref{fig:matrix}). Strictly speaking, TPower (D) actually solves a less constrained problem. \begin{wrapfigure}{r}{0.33\textwidth} \vspace{-1.em} \centering \includegraphics[width=0.33\textwidth]{converge_fig.pdf \caption{Convergence.}% \label{fig:convergence}% \vspace{-2em} \end{wrapfigure}% \paragraph{Convergence.} In \Cref{thm:ascent}, we prove the monotonic ascent property of IPU (Algorithm \ref{alg:generalFSPCA}) and in \Cref{rem:ascent}, we claim that existing iterative schemes are not monotonic ascent guaranteed. Here we provide numerical evidence to support this claim. We run Go, IPU, SOAP, SRT on Lymphoma dataset with $m=10,k=100,d=500$. We use the same convex relaxation initialization for all methods with row truncation. We record the objective value in every iterative step for all methods. The results are plotted in \Cref{fig:convergence}, from which we can see both SOAP and SRT are not ascent methods and both Go and IPU achieve better Explained Variance than SOAP and SRT with the same initialization. Besides, IPU takes less than 20 steps to converge, which is the case we keep seeing in all our experiments. \section{Conclusion} \label{sec:conclusion} In this paper, we present algorithms to directly estimate the row sparsity constrained leading $m$ eigenvectors. We propose Algorithm \ref{alg:kISc} to solve FSPCA for low-rank covariance globally. For general high-rank covariance, we propose Algorithm \ref{alg:generalFSPCA} to solve FSPCA by iteratively building a carefully designed low-rank proxy covariance matrix. We prove theoretical guarantees for both algorithms on approximation and convergence. Experimental results show the promising performance of the new algorithms compared with the state-of-the-art methods.
{'timestamp': '2019-05-28T02:15:32', 'yymm': '1904', 'arxiv_id': '1904.10155', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10155'}
arxiv
\section{Introduction}\label{sec1} Visual tracking is an important research problem in the field of computer vision. It estimates the position of an arbitrary target object in a video sequence, as long as the target object is specified with a bounding box in the first frame. Especially, high-performance visual tracking approaches with real-time speed are widely pursued in numerous applications, including video surveillance, autonomous driving, pose estimation, and human-computer interfaces. Although considerable progress has been made by many tracking approaches in the last decade, visual tracking is still a challenging problem due to multiple negative scenarios such as occlusions, fast motions, scale variations, and background clutters~\cite{survey2006,survey2011,survey2014,survey2018}. Most recent tracking approaches are developed based on two successful frameworks. The first one is the discriminative correlation filter (DCF). Thanks to the circular shifting of training samples and fast learning correlation filters in the Fourier frequency domain, DCF demonstrates superior computational efficiency and fairly good tracking accuracy and has attracted increasing attention since MOSSE~\cite{mosse}first exploited it. Later, in order to overcome different kinds of challenges and achieve competitive tracking performance, the advancement in DCF-based tracking is focused on the use of kernel functions~\cite{ecs}, motion information~\cite{flowtrack,csot}, multi-dimensional features~\cite{cnt,kcf}, multi-scale estimation~\cite{dsst,samf}, boundary effects alleviation~\cite{srdcf,bacf}, deep convolutional features~\cite{eco,ccot}, and ensemble combination~\cite{cact,mlcft,mfcmt}. However, most DCF-based trackers employ offline pre-trained convolutional neural networks (CNN) for feature extraction and do not perform stochastic gradient descent (SGD) to online fine-tune the parameters. So that DCF-based trackers benefit very little from end-to-end trainable networks. In recent years, another popular visual tracking framework occurs, i.e., fully-convolutional Siamese network (SiamNet), which has shown remarkable potential for high-performance visual tracking. These SiamNet-based trackers use a Siamese convolutional network to compare an exemplar image with candidate images of the same size, and hence bypass the online fine-tuning problem~\cite{sint,siamfc,cfnet,cfcf,lcsnt}. Several recent extensions~\cite{siamrpn,dasiamrpn} exploit a SiamNet for feature extraction, and a Region Proposal Networks (RPN)~\cite{fastrcnn,fasterrcnn} for classification and detection, have yielded excellent results on various benchmark datasets. Unfortunately, the visual tracking community is still plagued by several problems. First, existing backbone networks~\cite{alexnet,vgg,resnet} applied in visual tracking are always pre-trained for other different tasks such as ImageNet object classification and detection~\cite{imagenet}, which are not adequate for effective tracking. In these networks, feature maps extracted from high-level convolutional layers always have low resolutions, which are not sufficient for accurate localization. In contrast, high-resolution feature maps extracted from lower layers are ineffective to distinguish targets with different attributes or categories. Moreover, these pre-trained networks are not lightweight enough for real-world applications. Existing lightweight networks, such as MobileNet~\cite{mobilenet}, SqueezeNet~\cite{squeezenet}, and Xception~\cite{xception}, have demonstrated fast and effective performance with slightly accuracy degradation on object classification and detection tasks compared to popular networks. Still, they cannot fully take advantage of the benefits of deeper and wider architectures to enhance capabilities for target object representation in visual tracking~\cite{cir}. Therefore, how to effectively make trade-off between computational complexityand strong representation capability of the backbone network is critical for visual tracking. Second, it is well known that intermediate relationships of different convolutional layers demonstrate the true potential for improving the representation and generalization capability~\cite{senet,cbam}, but only a few approaches~\cite{flowtrack,rasnet,lsart,rar} efficiently take full use of these relationships in visual tracking. Third, in order to obtain more accurate tracking results, recent trackers~\cite{siamrpn,dasiamrpn} employ RPN for proposing target candidates. However, RPN always requires a large number of anchor boxes~\cite{fastrcnn,fasterrcnn} with redundant hyperparameters, i.e., the number, scales, and aspect-ratios of the candidate proposals, which incur computational and memory storage overload and make these approaches not efficient both in the training and testing stages. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig1.pdf} \end{center} \caption{Visualization of heatmaps of SATIN. Tracking result on the $200^{th}$ frame of the sequence \emph{David3} is presented, with the top-left corner point, the centroid point and the bottom-right corner point marked.} \label{fig:heatmaps} \end{figure} To address the above issues, we develop the \emph{Siamese Attentional Keypoint Network}, dubbed SATIN, for high-performance visual tracking in an end-to-end fashion. It consists of three components, i.e., a Siamese lightweight hourglass network for feature extraction, a cross-attentional module for adaptive feature refinement, and a keypoints detection module for object detection and localization. As the backbone network of SATIN, the Siamese lightweight hourglass network is symmetric, consisting of (a) a series of convolutional layers for feature map resolution reductions, (b) a series of upsampling layers to raise the low-resolution feature maps to the original resolution and (c) a set of skip layers to bring back original information. We also shrink the network by reducing the number of hyperparameters to make it simple and fast~\cite{mobilenet}. Therefore, our backbone network takes advantage of the benefits of the repeated bottom-up and top-down framework and captures more contextual information at multiple scales on the input images. Moreover, to boost the representation power of SATIN, we investigate the impact of spatial and channel-wise attention mechanisms. It is well known that visual attention plays the most critical role in many computer vision tasks. We align our motivation to the new convolutional block attention module (CBAM)~\cite{cbam} and develop a novel cross-attentional module consisting of a multi-layer perceptron and a single-layer perceptron to highlight informative representations and suppress the background noises. Since low-level geometric information is effective for target object localization, and high-level semantic information is sufficient for target object discrimination, the spatial and channel-wise attention maps can be computed separately on different level information. Further, motivated by CornerNet~\cite{cornernet}, we propose a unified detection architecture, which traces the target object using a set of keypoints, as shown in Fig.~\ref{fig:heatmaps}. It detects the top-left corner point, the centroid point, and the bottom-right corner point of the target bounding box using three separate detection module. The centroid point detection module is similar to SiamFC~\cite{siamfc}. Each corner point detection module has a localization branch and an offset prediction branch, starting with its corresponding pooling layer, namely, \emph{corner pooling}~\cite{cornernet}, to overcome the limitation of the receptive field, and enhance the capability to localize corner points of the bounding box. These corner points are determined by searching for the highest scores on the heatmaps, and their locations are adjusted by the offsets. Compared with recent RPN methods, our keypoints detection module is simple, which eliminates the need for designing anchor boxes, and therefore significantly reduces computational and memory storage overhead. Our main contributions can be summarized as three folds. (a) We design a Siamese lightweight hourglass network as the backbone, which can capture more contextual information at multiple scales on the input images. (b) We develop a novel cross-attentional module to selectively highlight meaningful information, and to boost the representation power of feature maps. (c) We trace the target object by detecting the top-left corner, the centroid, and the bottom-right corner of the target bounding box to avoid designing anchor boxes or multi-scale pyramids. Finally, our proposed approach achieves consummate performance both in terms of accuracy and robustness on several recent benchmark datasets~\cite{otb2013,otb2015,vot2016,vot2017,vot2018}. To the best of our knowledge, we are the first to formulate visual tracking as a keypoint detection task. The rest of the paper is organized as follows. Section~\ref{sec:2} briefly reviews related works. Section~\ref{sec:3} illustrates the proposed SATIN tracker. Section~\ref{sec:4} details experiments and discusses results. Finally, Section~\ref{sec:5} concludes this paper with final remarks. \section{Related works}\label{sec:2} In this section, we give a brief review of three aspects related to our work: backbone networks, attentional mechanisms, and detection components. \subsection{Backbone networks}\label{sec:21} In recent years, CNNs have made significant progress in a wide range of computer vision applications due to their impressive representation abilities. Because of their surprisingly good performance of CNN on object classification and detection, researchers are encouraged to either combine existing CNNs with DCF, or design deep networks in the Siamese framework for high-performance visual tracking. The most popular backbone networks utilized in recent trackers~\cite{ccot,csot,hcf,siamfc,siamrpn,lmsco} are AlexNet~\cite{alexnet}, VGGNet~\cite{vgg}, and ResNet~\cite{resnet}. AlexNet~\cite{alexnet} consists of several convolutional and pooling layers, and it was the first large-scale CNN that had won the ImageNet Large Scale Visual Recognition Challenge (ILSVRC)~\cite{imagenet}. VGGNet~\cite{vgg} stacks numerous small convolutional kernels without using pooling operations, which increases the representation power of the network while reducing the number of parameters. ResNet~\cite{resnet} introduces the skip connection to learn residual information, which makes it more efficient and simple to design deeper architectures. Moreover, there are some efficient backbone networks introduced by other vision tasks, such as hourglass networks~\cite{hourglass} and FlowNet~\cite{flownet}. However, these networks sometimes are computational and memory expensive for practical computer vision applications. Meanwhile, some lightweight networks~\cite{mobilenet,squeezenet,xception} focus on designing a more efficient architecture to reduce network computation while maintaining excellent performance. Unfortunately, these networks mentioned above are always pre-trained for object classification and detection. Trackers that employ these networks may obtain suboptimal tracking results. The recent trend in visual tracking~\cite{mdnet,cfnet,siamfc} is to design suitable networks for learning object- or category-specific representations and enhance the generalization power to new video sequences. Different from these tracking methods, we aim to design a lightweight CNN as the backbone network, which can learn more contextual features at multiple scales with a simple architecture and small model size. \subsection{Attentional mechanisms}\label{sec:22} Attentional mechanisms have been widely utilized in many computer vision tasks, such as image classification~\cite{senet}, object detection~\cite{cbam}, and image semantic segmentation~\cite{panet}. The recent advance of tracking approaches has achieved great success by integrating attentional mechanisms. CSRDCF~\cite{csrdcf} introduces a channel weighted block by constructing a unique spatial reliability map in an online constrained optimization. LSART~\cite{lsart} proposes a cross-patch similarity kernel to encode the similarity scores of all pairs of patches between two samples, and a spatial regularized constraint method to enforce each filter kernel to focus on a specific region of the target. Both RASNet~\cite{rasnet} and FlowTrack~\cite{flowtrack} adopt a squeeze-and-excitation network (SENet)~\cite{senet} to enhance the representation capability of their backbone networks. In these modules, global average-pooling operations are utilized to compute channel-wise attention, and to re-weight the original feature maps based on the pooled features. In contrast to those attentional mechanisms, we design a cross-attentional module in an end-to-end offline learning framework to investigate both spatial and channel-wise relationship between shallow and deep convolutional features, especially their geometric and semantic contributions to global contextual information. \subsection{Detection components}\label{sec:23} Most state-of-the-art tracking approaches follow the tracking-by-detection paradigm~\cite{lowrank,dsst,csot,siamrpn}, which treats visual tracking as detection problems. DCF-based trackers~\cite{kcf,dsst} and some SiamNet-based trackers~\cite{cfnet} detect objects by searching the peak value on similarity score maps, which come from the correlation of the candidate feature maps with correlation filters trained on the exemplar feature maps. While other SiamNet-based trackers~\cite{siamfc} straightforwardly cross-correlate exemplar and candidate feature maps. To achieve more accurate tracking in scale variation scenarios, most existing tracking approaches utilize multi-scale pyramids as DSST~\cite{dsst} and SAMF~\cite{samf}. But these improvements in accuracy are gained at the expensive cost in tracking speed. SiamRPN~\cite{siamrpn} and DaSiamRPN~\cite{dasiamrpn} combine RPN~\cite{fasterrcnn} with AlexNet in the Siamese framework to formulate the multiple scale object tracking as proposal classification and bounding box regression problem on correlation feature maps. However, these trackers always require a large number of anchor boxes, and many extra hyperparameters have to be set in advance to generate more suitable proposals. Unlike these detection methods, and motivated by object detection approach in CornerNet~\cite{cornernet}, we trace target object as a set of keypoints, i.e., the top-left corner point, the centroid point and the bottom-right corner point of the target bounding box, therefore mitigate the drawbacks of the above-mentioned detection components. \section{The proposed approach}\label{sec:3} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig2.pdf} \end{center} \caption{The overall framework of our proposed approach. For the sake of clarity, we only show pipelines of the top-left corner (bottom-right corner) point and the centroid point detection.} \label{fig:arch} \end{figure} \subsection{Algorithm overview}\label{sec:31} In this section, we describe our proposed SATIN in detail. Fig.~\ref{fig:arch} shows the overall framework of SATIN, which consists of three portions: a backbone network for deep feature extraction, a cross-attentional module for representation capability improvement, and a keypoints detection module for keypoints prediction. Given an exemplar image patch $\mathbf{z}$ centered on the target object and a larger candidate image patch $\mathbf{x}$ centered on the previous target location, these two images are fed into a backbone network consisting of two lightweight hourglass networks. Each lightweight hourglass network is designed with a symmetric topology that captures and consolidates both global and local information at multiple scales of the input image through repeated bottom-up and top-down processing. The architecture of our backbone network will be presented in Section~\ref{sec:32}. The backbone network is followed by a cross-attentional module, which is consisted of a multi-layer perceptron and a single-layer perceptron to highlight meaningful information along spatial and channel-wise dimensions, respectively. The spatial attention map is inferred from the low-level geometric features before being fed into the second stage lightweight hourglass network. While the channel-wise attention map is obtained from the high-level semantic feature map, which is the output of the second stage lightweight hourglass network. Both spatial and channel-wise attention maps are then multiplied with the output of the backbone network, therefore taking full advantage of essential attention during tracking. We will illustrate the details of our cross-attentional module in Section~\ref{sec:33}. After that, we exploit the keypoints detection module to trace target objects, which detects the top-left corner point, the centroid point, and the bottom-right corner point of the bounding box simultaneously. Each corner point detection module has its corner pooling strategy and correlates the candidate feature map with the exemplar feature map to obtain a heatmap for corner location prediction and a set of offsets for corner location refinement. The bottom-right corner and the top-left corner are detected similarly. The centroid point is detected as similar to SiamFC~\cite{siamfc}. For the sake of clarity, Fig.~\ref{fig:arch} demonstrates the processes of top-left corner point detection and centroid point detections. We will describe the implementation of the keypoint detection module in Section~\ref{sec:34}. \subsection{Lightweight hourglass network}\label{sec:32} It is well acknowledged that powerful target object representations are crucial for accurate and robust visual tracking~\cite{winsty,csot}. Deep features extracted from the off-the-shelf CNNs pre-trained for other visual tasks may be suboptimal for visual tracking, there is still a considerable gap to achieve state-of-the-art tracking performance. Different from CNNs employed in most existing tracking approaches~\cite{siamfc,siamrpn,csot}, we employ a Siamese lightweight hourglass network as the backbone network of SATIN, which is technically designed for visual tracking. The hourglass network was first introduced into the computer vision community for human pose prediction~\cite{hourglass}. In the original hourglass network, several \emph{hourglass modules} are stacked to preserve low-level geometric representation and high-level semantic information across different resolutions in the repeated bottom-up (from fine to coarse) and top-down (from coarse to fine) processing. Each hourglass module consists of several \emph{residual blocks}, which are the minimal units in the network. The hourglass module first downsamples input features to coarse resolution using a series of convolutional and max-pooling layers to extract semantic information. The pooled features are then upsampled back to the original input resolution through a series of convolutional and upsampling layers. However, some useful fine-grained object-specific details may be lost during bottom-up processing. To solve this problem, a series of convolutional and skipping layers~\cite{resnet} are utilized to bring the lost details back to the upsampled features. The upsampled features and lost details are combined across multiple scales as the inputs of the next module. The hourglass network takes advantage of both global and local contextual information throughout the repeated bottom-up and top-down processing. It is an ideal backbone network for deep feature extraction for visual tracking. In our approach, two hourglass networks are stacked in the backbone network. In order to extract more powerful deep features, more hourglass modules are nested to make a deeper hourglass network. However, as the hourglass network going deeper, it becomes more complicated and not practical for real-world applications due to limited computational resources. Inspired by the recent implementation of efficient and lightweight networks, we exploit the compression method to make some critical modifications to the original hourglass network and design the architecture of a lightweight hourglass network. Instead of using the $3\times 3$ standard convolution layer to filter and consolidate input features simultaneously, we follow the depthwise separable convolutional unit described in MobileNet~\cite{mobilenet} and factorize the $3\times 3$ standard convolution into a $3\times 3$ depthwise convolution for filtering and a $1\times 1$ pointwise convolution for consolidating. In the residual block, we use a depthwise separable convolutional unit followed by a depthwise convolutional layer to extract deep features, and another pointwise convolutional layer is used to bring the original information back to the output features. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig3.pdf} \end{center} \caption{Illustration of a single residual block. In the figure, \emph{BN} means the batch normalization, \emph{ReLU} means a rectified linear unit and \emph{Conv$\ast$} means a convolutional layer. The first number in the bracket indicates the input channel and the second one indicates the output channel. The parameters \emph{k$\ast$}, \emph{p$\ast$} and \emph{s$\ast$} represent the filter size, padding size and stride of the corresponding convolutional layer, respectively. The parameter \emph{s} indicates the stride of Conv1 and Conv4, which is preset according to the hourglass module.} \label{fig:res} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig4.pdf} \end{center} \caption{Illustration of a single hourglass module. In the figure, \emph{M$\ast$} means a residual block, \emph{UP} means a upsampling layer. The first number in the bracket indicates the input channel and the second one indicates the output channel. The parameter \emph{s} represents the stride of Conv1 and Conv4 in each residual block.} \label{fig:hour} \end{figure} In the hourglass module, three residual blocks are followed by an upsampling layer as the principal propagation, and another residual block works as the skipping connection. It is worth noting that the second residual block M$2$ can be nested by an hourglass module, and thus the network can do repeated bottom-up and top-down processing. Four lightweight hourglass modules are nested with output channel numbers of $(256, 512, 512, 256)$ respectively in each hourglass network. Another noteworthy modification is to reduce input feature resolution, we apply stride of 2 instead of max-pooling operation in the first residual block of each hourglass module. A simple nearest neighbor upsampling method is used to restore output feature maps to the original input resolution. After that, the upsampled features and lost details are merged directly by element-wise addition. Besides, before the first stage lightweight hourglass network, we apply an $11\times 11$ convolutional layer with stride of 2 and output channel 128 and a $5\times 5$ convolutional layer with stride 2 and output channel 256 to increase the number of input channels and reduce the input resolution. Fig.~\ref{fig:res} and Fig.~\ref{fig:hour} show implementations of our residual block and hourglass module, respectively. \subsection{Cross-attentional module}\label{sec:33} The backbone network as designed in Section~\ref{sec:32} is used to generate contextual representations of both the exemplar image \textbf{z} and candidate image \textbf{x}. However, those contextual representations may not be sufficient enough for tracking performance improvement because they treat every channel and region equally. Some informative channels and attentive regions of the output are more crucial for target object discrimination and localization than others, as they may involve more semantic attributes and visual patterns of different objects. In order to highlight meaningful information and to enhance the representation power of output features, an effective cross-attentional module in our approach is exploited as follows. Without loss of generality, the input and output feature maps of the second stage lightweight hourglass network are respectively denoted as $\mathbf{F}^i\in \mathbb{R}^{W\times H \times C}$ and $\mathbf{F}^o\in \mathbb{R}^{W\times H \times C}$, where $W$, $H$ and $C$ indicate the width, height and channel number of feature maps, respectively. Since low-level geometric representations contribute more in target object localization, and the high-level semantic information is sufficient for distinguishing the target object from the background surroundings, we utilize a single-layer perceptron on $\mathbf{F}^i$ and a multi-layer perceptron on $\mathbf{F}^o$, therefore encode those regions and channels to be emphasized or suppressed, respectively. The structure of the cross-attentional module is shown in Fig.~\ref{fig:att}. \textbf{Spatial attention.} We utilize spatial attention to highlight informative regions that adequately represent the current target object. Given the input feature map $\mathbf{F}^i\in \mathbb{R}^{W\times H \times C}$, we first apply global average-pooling and max-pooling operations along the channel axis to construct two 2D spatial feature descriptors, denoted as $\mathbf{F}^i_{avg}\in \mathbb{R}^{W\times H \times 1}$ and $\mathbf{F}^i_{max}\in \mathbb{R}^{W\times H \times 1}$. Spatial feature descriptors are then concatenated and fed into a single-layer perceptron with a sigmoid activation, where a 2D spatial attention map $\mathbf{M}_s\in \mathbb{R}^{W\times H\times 1}$ is created over the size of $W\times H$, \begin{equation} \mathbf{M}_s = \sigma\big(\verb"SLP"([\mathbf{F}^i_{avg};\mathbf{F}^i_{max}])\big) \end{equation} where $\sigma$ indicates the sigmoid function, and $[\mathbf{F}^i_{avg};\mathbf{F}^i_{max}]\in \mathbb{R}^{W\times H \times 2}$ denotes the concatenation of global average-pooled and max-pooled feature descriptors. $\verb"SLP"$ means the single-layer perceptron consisting of a $7\times 7$ convolutional layer with padding 3, stride 1, input channel 2 and output channel 1. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig5.pdf} \end{center} \caption{The structure of the cross-attentional module. The concatenation of max-pooled and average-pooled input feature maps are supplied into a single-layer perceptron to infer a 2D spatial attention map. Both max-pooled and average-pooled output feature maps are fed into a shared multi-layer perceptron to generate a 1D channel-wise attention map. Finally, the output feature map is weighted with both channel-wise and spatial attention by broadcasting element-wise multiplication.} \label{fig:att} \end{figure} \textbf{Channel-wise attention.} The channel-wise attention is employed to select useful channels which facilitate the current tracking task adaptively. Given the output feature map $\mathbf{F}^o\in \mathbb{R}^{W\times H \times C}$, global average-pooling and max-pooling operations are applied along the spatial axis to generate two 1D channel-wise feature descriptors denoted as $\mathbf{F}^o_{avg}\in \mathbb{R}^{1\times 1 \times C}$ and $\mathbf{F}^o_{max}\in \mathbb{R}^{1\times 1 \times C}$, respectively. Different from the spatial-wise attention, a multi-layer perceptron is applied on each pooled feature descriptor to create a 1D channel attention map $\mathbf{M}_c\in \mathbb{R}^{1\times 1\times C}$ over $C$ channels, \begin{equation} \begin{aligned} \mathbf{M}_c &= \sigma\big(\verb"MLP"(\mathbf{F}^o_{avg})\oplus \verb"MLP"(\mathbf{F}^o_{max})\big) \\ &= \sigma\Big(W_u\big(W_d(\mathbf{F}^o_{avg})\big)\oplus W_u\big(W_d(\mathbf{F}^o_{max})\big)\Big) \end{aligned} \end{equation} where $\sigma$ indicates the sigmoid function, $\oplus$ denotes the element-wise addition, and $\verb"MLP"$ means the multi-layer perceptron. Moreover, the multi-layer perceptron is composed of a channel reduction layer with weight $W_d\in\mathbb{R}^{\frac{C}{r}\times C}$ and a ReLU activation, and a channel-increasing layer with weight $W_u\in\mathbb{R}^{C\times \frac{C}{r}}$ and a sigmoid activation, where $r$ (set to 4) is a channel reduction ratio~\cite{cbam} to reduce the computational burden. It is worth noting that the weights $W_d$ and $W_u$ of the multi-layer perceptron are shared for both global average-pooled and max-pooled feature descriptors. The attention-refined feature map $\mathbf{F}^a\in \mathbb{R}^{W\times H \times C}$ weighted with both the channel-wise and spatial attention can be calculated sequentially as, \begin{equation} \mathbf{F}^a=\mathbf{F}^o\oplus (\mathbf{F}^o\otimes \mathbf{M}_s\otimes \mathbf{M}_c) \end{equation} where $\otimes$ and $\oplus$ indicate multiplication and element-wise addition, respectively. Another noteworthy issue is that the spatial attention map $\mathbf{M}_s$ and the channel attention map $\mathbf{M}_c$ are broadcasted along the channel and the spatial axes, respectively, during element-wise multiplication. The original output information is brought back to the attention-refined feature map in the cross-attentional module. In our approach, the cross-attentional module is only applied to the exemplar image. Before the keypoints detection process, we reduce the resolution of $\mathbf{F}^a(\mathbf{z})$ and $\mathbf{F}^o(\mathbf{x})$ by two times using $3\times 3$ convolutional layers, both with stride 2 and padding 1. For convenience, final feature maps of the exemplar image $\mathbf{z}$ and the candidate image $\mathbf{x}$ are denoted as $\mathbf{F}(\mathbf{z})$ and $\mathbf{F}(\mathbf{x})$, respectively. \subsection{Keypoint detection}\label{sec:34} We now show how those three keypoint detection modules work, i.e., the top-left corner point, the centroid point, and the bottom-right corner point detection module. \textbf{Corner point detection.} The corner point detection modules are inspired by CornerNet~\cite{cornernet}, which detects the target object as a pair of bounding box corner points to eliminate the need for designing anchor boxes or multi-scale pyramids. There are two corner point detection modules in SATIN, one for the top-left corner point detection and the other for the bottom-right corner point detection. However, because of the limitation of the receptive field and the lack of local visual pattern of corner points, it is difficult to detect the corner point outside the target object directly, as shown in Fig.~\ref{fig:heatmaps}. To address this problem, we adopt a new type of pooling layer, namely, corner pooling~\cite{cornernet}, to translate meaningful object-specific information to locations outside of the target object based on explicit prior knowledge. We use an example to illustrate our idea. Suppose we are going to detect the top-left corner point, as shown in Fig.~\ref{fig:corp}, the max-pooling operation is applied on the feature map horizontally from the rightmost boundary to the left, and vertically from the bottommost boundary to the top. For convenience, let $\mathbf{F}\in \mathbb{R}^{W\times H \times C}$ denote either $\mathbf{F}(\mathbf{z})$ or $\mathbf{F}(\mathbf{x})$, where $W$, $H$ and $C$ indicate the width, height and channel number of $\mathbf{F}$, respectively. The top-left corner point detection module first generates two corner-oriented feature maps $\mathbf{F}_t\in \mathbb{R}^{W\times H \times C}$ and $\mathbf{F}_l\in \mathbb{R}^{W\times H \times C}$ using two independent $3\times 3$ convolutional layers with stride 1 and padding 1, respectively. Then, we apply max-pooling operation between coordinate $(m,n)$ and $(m,H)$ on $\mathbf{F}_t$ to obtain a vertical maximum pattern $t_{(m,n)}$, where $m\in\{1,\ldots,W\}$ and $n\in\{1,\ldots,H\}$. Similarly, the same operation is applied between $(m,n)$ and $(W,n)$ on $\mathbf{F}_l$ to obtain a maximum horizontal pattern $l_{(m,n)}$. The top-left feature pattern $tl_{(m,n)}$ at location $(m,n)$ in the top-left corner-pooled feature map $\mathbf{F}_{tlc}$ is calculated by adding $t_{(m,n)}$ and $l_{(m,n)}$ together. The process is depicted as, \begin{equation}\label{eq:5} \begin{aligned} t_{(m,n)} &= \left\{\begin{array}{ll} \max(\mathbf{F}_{t_{(m,n)}},t_{(m,n+1)}) & \textrm{if $n<H$}\\ F_{t_{(m,H)}} & \textrm{otherwise} \end{array}\right.\\ l_{(m,n)} &= \left\{\begin{array}{ll} \max(\mathbf{F}_{l_{(m,n)}},l_{(m+1,n)}) & \textrm{if $m<W$}\\ F_{l_{(W,n)}} & \textrm{otherwise} \end{array}\right.\\ tl_{(m,n)} &= t_{(m,n)}+l_{(m,n)} \end{aligned} \end{equation} where $\mathbf{F}_{t_{(m,n)}}$ (or $\mathbf{F}_{l_{(m,n)}}$) denote oriented feature patterns at the location $(m,n)$ in $\mathbf{F}_t$ (or $\mathbf{F}_l$). To obtain the top-left corner-specific feature map $\mathbf{F}_{tl}$, the top-left corner-pooled feature map $\mathbf{F}_{tlc}$ is then fed into a $3\times 3$ convolutional layer, and add back the residual feature map $\mathbf{F}_{tlr}$ obtained by applying a $1\times 1$ convolution to the input feature map $\mathbf{F}$. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig6.pdf} \end{center} \caption{An illustration of the corner-pooling operation in the top-left corner point detection module.} \label{fig:corp} \end{figure} Each corner detection module is utilized to detect only one corner point. Hence, it only outputs a single-channel heatmap for prediction and a double-channel offset map for refinement. To suppress the effect of redundant information, the top-left quarter of $\mathbf{F}_{tl}(\mathbf{z})$ is then cropped and denoted as $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]$. Therefore, two separate $3\times 3$ convolutional layers are applied to keep and double the channels of $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]$, generating $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{s}$ (with the same number of channels) and $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{o}$ (with doubled number of channels), respectively. Meanwhile, $\mathbf{F}_{tl}(\mathbf{x})$ is also divided into two branches $[\mathbf{F}_{tl}(\mathbf{x})]_{s}$ and $[\mathbf{F}_{tl}(\mathbf{x})]_{o}$ by two separate $3\times 3$ convolutional layers, but the channels are kept unchanged. The heatmap $\mathbf{S}_{lt}$ and offset $\mathbf{O}_{lt}$ are computed as, \begin{equation}\label{eq:corner} \begin{aligned} \mathbf{S}_{lt} &= \big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{s} \ast [\mathbf{F}_{tl}(\mathbf{x})]_{s} \\ \mathbf{O}_{lt} &= \big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{o} \ast [\mathbf{F}_{tl}(\mathbf{x})]_{o} \end{aligned} \end{equation} where $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{s}$ and $\big[\verb"crop"_{tl}\big(\mathbf{F}_{tl}(\mathbf{z})\big)\big]_{o}$ are served as correlation kernels, and $\ast$ denotes the cross-correlation operation. Each score in $\mathbf{S}_{lt}$ represents the probability of being the top-left corner point at the location $(m,n)$. After upsampling $\mathbf{S}_{lt}$ to the resolution of $\mathbf{x}$, the location of the maximum score relative to the top-left corner point of the bounding box. Due to a series of downsampling operations involved in the previous modules, the top-left corner point $(m_{lt},n_{lt})$ in $\mathbf{x}$ is mapped to the location $\big(\big\lfloor\frac{m_{lt}}{\alpha}\big\rfloor,\big\lfloor\frac{n_{lt}}{\alpha}\big\rfloor\big)$ in $\mathbf{S}_{lt}$, where $\big\lfloor\cdot\big\rfloor$ denotes the round down operation, and $\alpha$ is the downsampling factor. However, if we remap the location $\big(\big\lfloor\frac{m_{lt}}{\alpha}\big\rfloor,\big\lfloor\frac{n_{lt}}{\alpha}\big\rfloor\big)$ from $\mathbf{S}_{lt}$ to $\mathbf{x}$ by multiplying $\alpha$ directly, we may not obtain its corresponding location $(m_{lt},n_{lt})$, which significantly affects the tracking accuracy, especially when tracking small objects. To address this issue, we exploit the offset map $\mathbf{O}_{lt}$ to adjust the score locations before remapping them to the candidate image, \begin{equation}\label{eq:offset} (m_{lt},\,n_{lt}) = \alpha\cdot\bigg(\Big\lfloor\frac{m_{lt}}{\alpha}\Big\rfloor + \mathbf{O}_{lt}^1,\,\Big\lfloor\frac{n_{lt}}{\alpha}\Big\rfloor + \mathbf{O}_{lt}^2\bigg) \end{equation} where $\mathbf{O}_{lt}^a$ indicates the $a$-th channel of $\mathbf{O}_{lt}$. A similar procedure can be extended to the bottom-right corner point detection, but along the topmost boundary to the bottom and the leftmost boundary to the right. Two corner-oriented feature maps $\mathbf{F}_b$ and $\mathbf{F}_r$ are first generated respectively by applying two separate $3\times 3$ convolutional layers on the feature map $\mathbf{F}$. The bottom-right corner pooling operation is then applied to create the feature map $\mathbf{F}_{br}$. Both the heatmap $\mathbf{S}_{br}$ and the offset map $\mathbf{O}_{br}$ are computed with a formulation like Eq.~\ref{eq:corner}. \textbf{Centroid detection.} The centroid point detection module is just a variant of the corner point detection module, but with the corner pooling operation removed. To detect the centroid point of the bounding box, only a quarter around the center of the exemplar feature map $\mathbf{F}(\mathbf{z})$ is cropped to reduce the effect of background information, as illustrated in Fig.~\ref{fig:arch}. After that, the heatmap $\mathbf{S}_{c}$ and the offset map $\mathbf{O}_{c}$ are created using similar correlation operations as described in Eq.~\ref{eq:corner}. \subsection{Loss function}\label{sec:35} During training, it is conventional to assign a binary label $y\in\{0,1\}$ for each pixel $(m,n)$ in the candidate image $\mathbf{x}$ to indicate whether it is a keypoint or not. Instead of doing this, a soft label is exploited to penalize negative locations smoothly within a radius of the ground-truth keypoint. This is because, for each keypoint, there is only one positive location, while all other locations are negative. However, false keypoints sometimes detected close to their respective positive locations, but the detected bounding box can still satisfactorily overlap the ground-truth bounding box (region of interests). To ensure those three keypoints are detected correctly, it is required that the detected bounding box must have an Intersection-over-Union (IoU) overlap higher than $0.7$ with the ground-truth bounding box, and the radius is thus determined by the size of the ground-truth bounding box. For convenience, let $(m_1,n_1)$, $(m_2,n_2)$ and $(m_3,n_3)$ indicate coordinates for the top-left corner point, the centroid point and the bottom-right corner point of the detected bounding box, respectively. $(\hat{m}_1,\hat{n}_1)$, $(\hat{m}_2,\hat{n}_2)$ and $(\hat{m}_3,\hat{n}_3)$ are those of the ground-truth bounding box. The soft labels corresponding to the pixel $(m,n)$ are defined by an unnormalized Gaussian function, \begin{equation}\label{eq:label} y_{(m,n),i}=\exp\bigg(-\frac{(m-\hat{m_i})^2+(n-\hat{n_i})^2}{2\sigma^2}\bigg),\;\; i\in\{1,2,3\} \end{equation} where $i$ is the index of a keypoint as mentioned above, and $\sigma$ is $1/3$ of the radius. The soft labels $y_{(m,n),i}$ is centered at their corresponding ground-truth keypoints $(\hat{m}_i,\hat{n}_i)$ and smoothly reduces to 0 for the locations outside the radius. Although we increase the number of positive locations by labeling the negative locations within a radius of the ground-truth location with soft labels, there remains an imbalance problem between the limited positive locations within the radius and a substantial amount of negative locations outside the radius. These easy negative locations will take over the majority of training losses and dominate the gradient. To solve this problem, we investigate the relationship between the soft labels $y_{(m,n),i}$ and the probability scores $s_{(m,n),i}$ corresponding to the location $(m,n)$, and propose a location-sensitive loss function $\mathcal{L}_{hm}$ of the keypoint heatmap, \begin{equation}\label{eq:loss1} \mathcal{L}_{hm} = -\sum_{i=1}^{3}\sum_{m=1}^{W}\sum_{n=1}^{H}y_{(m,n),i}(1-s_{(m,n),i})\log(s_{(m,n),i})+s_{(m,n),i}(1-y_{(m,n),i})\log(1-s_{(m,n),i}) \end{equation} where $s_{(m,n),i}$ is the score value at location $(m,n)$ associated with the $i$-th keypoint heatmap obtained in Section~\ref{sec:34}. With the ground-truth keypoints $(\hat{m}_{i},\hat{n}_{i})$, the precision loss caused by the downsampling operations can be written as below, \begin{equation}\label{eq:offset} \mathbf{\hat{O}}_{i} = \bigg(\frac{\hat{m}_{i}}{\alpha}-\Big\lfloor\frac{\hat{m}_{i}}{\alpha}\Big\rfloor,\,\frac{\hat{n}_{i}}{\alpha}-\Big\lfloor\frac{\hat{n}_{i}}{\alpha}\Big\rfloor\bigg) ,\;\; i\in\{1,2,3\} \end{equation} where $\alpha$ is the downsampling factor. Then the offset loss $\mathcal{L}_{os}$ can be formulated as, \begin{equation}\label{eq:loss2} \mathcal{L}_{os} = \sum_{i=1}^{3}\sum_{k=1}^{2}smooth_{L1}\Big(\mathbf{O}_i^k-\mathbf{\hat{O}}_i^k\Big) \end{equation} where $\mathbf{O}_i$ is the offset map predicted in Section~\ref{sec:34}, and $smooth_{L1}$ is a robust loss function~\cite{fastrcnn} defined as, \begin{equation}\label{eq:smooth} smooth_{L1}(x)=\left\{\begin{array}{ll} 0.5x^2 & \textrm{if $|x|<1$}\\ |x|-0.5 & \textrm{otherwise} \end{array}\right.\\ \end{equation} Since the top-left corner point and the bottom-right corner point should be symmetric around the centroid point, the relative distance between the top-left corner point and the centroid point must be equal to that between the bottom-right corner point and the centroid point. Hence, the symmetry loss is defined as, \begin{equation}\label{eq:loss3} \mathcal{L}_{st}=\big((m_2-m_1)-(m_3-m_2)\big)+\big((n_2-n_1)-(n_3-n_2)\big) \end{equation} Finally, our SATIN is trained by minimizing the combination loss $\mathcal{L}$ of the heatmap loss $\mathcal{L}_{hm}$, the offset loss $\mathcal{L}_{os}$, and the symmetry loss $\mathcal{L}_{st}$ as, \begin{equation}\label{eq:loss} \mathcal{L} = \mathcal{L}_{hm}+\lambda_1\mathcal{L}_{os}+\lambda_2\mathcal{L}_{st} \end{equation} where $\lambda_1$ and $\lambda_2$ are trade-off factors to balance the three loss. \section{Experiments}\label{sec:4} In this section, implementation details are introduced first. Then extensive experiments on OTB and VOT benchmark datasets are conducted to evaluate our proposed approach. Finally, ablation studies are carried out on OTB benchmark datasets to investigate how each component contributes to improving performance. \subsection{Implementation details} We apply stochastic gradient descent (SGD) with the momentum of $0.9$ and the weight decay of $0.005$ to train SATIN offline from scratch using Image-VID~\cite{imagenet} and YouTube-VOS~\cite{youtube}. Totally $50$ epochs are performed with learning rate decreased in a logarithmic manner from $10^{-3}$ to $10^{-5}$. Frame pairs are collected with interval less than $100$ from the same video sequence, and exemplar images and candidate images are then cropped from frames pairs around their corresponding ground-truth bounding box with $2\times$ and $4\times$ padding respectively. Random translations are performed up to $\pm12$ pixels, and the range of rescaling varies from $2^{-1/4}$ to $2^{1/4}$. If the cropped image extends exceed the size of the frame, the missing portion is filled with the mean background RGB value. After that, exemplar and candidate images are resized to the size of $127\times 127 \times 3$ and $255\times 255\times 3$, respectively. The trade-off factors in Eq.~\ref{eq:loss} are set as $\lambda_1=1$ and $\lambda_2=10$. Before we train the full approach, the backbone network is pre-trained individually on ImageNet-DET~\cite{imagenet} and COCO~\cite{coco} for warm-up to enhance both generalization and representation capabilities. Similar to~\cite{hourglass}and~\cite{cornernet}, we add intermediate supervision in training without adding the intermediate predictions back to the network. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig7.pdf} \end{center} \caption{Success and precision performance on the OTB-2013 benchmark~\cite{otb2013}. The first number in the legend indicates the AUC score while the second denotes DP score at error threshold of 20 pixels. The best trackers are located at the top-right corner.} \label{fig:otb2013} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig8.pdf} \end{center} \caption{Success and precision performance on the OTB-2015 benchmark~\cite{otb2015}. The first number in the legend indicates the AUC score while the second denotes DP score at error threshold of 20 pixels. The best trackers are located at the top-right corner.} \label{fig:otb2015} \end{figure} Our approach is implemented using MXNet~\cite{mxnet}, trained on an Amazon EC2 instance with $16$ Intel$^\circledR$ Xeon$^\circledR$ E5-2686 v4 @ 2.3GHz CPU with 732GB RAM, and 16 NVIDIA$^\circledR$ Tesla$^\circledR$ K80 GPU with $192$GB VRAM. Experiments are conducted on an Amazon EC2 instance with an Intel$^\circledR$ Xeon$^\circledR$ E5-2686 v4 @ 2.3GHz CPU with 61GB RAM, and an NVIDIA$^\circledR$ Tesla$^\circledR$ K80 GPU with 12GB VRAM. All the parameters are fixed across experiments and datasets. The average tracking speed of our proposed tracker is $27$ frames per second (fps), which exceeds the real-time bound of $15$ fps~\cite{survey2011} by a large margin. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig9.pdf} \end{center} \caption{Success performance on the OTB-2015 benchmark with 11 attributes~\cite{otb2015}. Best viewed in color.} \label{fig:attauc} \end{figure} \subsection{Experiments on OTB} We compare SATIN with nine state-of-the-art trackers, including ACFN~\cite{acfn}, CREST~\cite{crest}, DSST~\cite{dsst}, SiamTri~\cite{siamtri}, SiamRPN~\cite{siamrpn}, SiamFC~\cite{siamfc}, DeepLMCF~\cite{lmcf}, DLSSVM~\cite{dlssvm} and KCF~\cite{kcf}, on the OTB benchmark datasets~\cite{otb2013,otb2015}. Among the participants, we treat SiamFC and SiamRPN as our baseline. Two widely-used metrics: distance precision (DP) and overlap success (OS) are employed to evaluate tracking performance. DP is the percentage of frames in the video where the Euclidean distance between the detected object location and the ground-truth object location is smaller than a fixed threshold of $20$ pixels. OS is the percentage of frames in the video where the overlap ratio between the detected bounding box and the ground-truth bounding box exceeds a preset threshold of $0.5$. All the trackers are initialized with the ground-truth bounding box in the first frame. For better performance measurement, we utilize the area-under-curve (AUC) to present the OS score within the threshold range of $[0,1]$~\cite{otb2013}. Fig.~\ref{fig:otb2013} illustrates the \emph{precision and success performance} under one-pass evaluation (OPE) over the $51$ fully-annotated video sequences in the OTB-2013 benchmark dataset~\cite{otb2013}. SATIN achieves the second-best AUC score of $66.9\%$ and the third-best DP score of $89.3\%$, respectively. The residual tracker CREST~\cite{crest} performs favorably against all compared trackers, slightly outperforming SATIN by gains of $0.4\%$ and $1.5\%$ in AUC and DP scores, respectively. Although both DeepLMCF~\cite{lmcf} and DLSSVM~\cite{dlssvm} employ support vector machines (SVM) as classifiers to distinguish the target object from the surrounding background, their performance is still left far behind by SATIN. Compared with the pioneering Siamese approach SiamFC~\cite{siamfc} with an AUC score of $60.9\%$ and a DP score of $80.9\%$, SATIN obtains significant improvements by $6.0\%$ and $8.4\%$, respectively. SiamRPN~\cite{siamrpn} exploits the Siamese region proposal network to get more accurate bounding boxes. It provides an AUC score of $65.8\%$ and a DP score of $88.4\%$. Compared with SiamRPN, SATIN surpasses it by absolute gains of $1.6\%$ and $1.1\%$ in AUC and DP scores, respectively. Overall, the evaluation results on the OTB-2013 benchmark dataset demonstrate that our proposed SATIN tracker performs well against state-of-the-art trackers over the $51$ challenging video sequences. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig10.pdf} \end{center} \caption{Precision performance on the OTB-2015 benchmark with 11 attributes~\cite{otb2015}. Best viewed in color.} \label{fig:atterror} \end{figure} Fig.~\ref{fig:otb2015} illustrates the \emph{precision and success performance} under OPE over the $100$ fully-annotated video sequences in the OTB-2015 benchmark dataset~\cite{otb2015}. SATIN achieves the best AUC score and the third-best DP score, respectively. Compared with SiamFC, SATIN improves the AUC score from $57.8\%$ to $64.1\%$, and the DP score from $76.7\%$ to $84.4\%$. CREST has provided the best performance on the OTB-2013 benchmark dataset, but SATIN outperforms it by amazing improvements of $1.8\%$ and $0.6\%$ on the AUC and DP scores after extending the dataset to $100$ video sequences. In particular, SATIN is superior to the baseline SiamRPN tracker in the AUC score with an absolute gain of $1.0\%$. However, SiamRPN achieves a DP score of $85.1\%$, which provides an absolute gain of $0.7\%$ compared to SATIN. Our approach performs better than the triplet loss tracker SiamTri and gets $5.1\%$ and $6.3\%$ absolute gains in terms of AUC and DP scores. Although DeepLMCF obtains the best DP performance of $85.9\%$, its AUC score of $61.6\%$ is much inferior to SATIN. Besides, SATIN achieves absolute AUC/DP gains of $16.4\%$/$15.1\%$, $12.1\%$/$16.4\%$, $10.0\%$/$7.7\%$ and $6.8\%$/$4.5\%$ over KCF, DSST, DLSSVM and ACFN, respectively. The excellent tracking performance of SATIN can be primarily attributed to two aspects. First, the specially designed backbone network and the cross-attentional module are utilized to enhance the representation and generalization capabilities of SATIN. Second, SATIN tracks target objects by regressing keypoints of the bounding boxes to soft labels instead of generating redundant region proposals or designing complicated scale pyramids, which are robust to target object appearance variations and scale changes. \begin{figure}[t] \begin{center} \begin{minipage}[b]{\linewidth}\centerline{\includegraphics[width=\textwidth]{fig11a.pdf}}\end{minipage} \vfill \begin{minipage}[b]{0.85\linewidth}\centerline{\includegraphics[width=\textwidth]{fig11b.pdf}}\end{minipage} \end{center} \caption{Example tracking results of STAIN with the comparison to state-of-the-are trackers including ACFN~\cite{acfn}, SiamFC~\cite{siamfc}, SiamRPN~\cite{siamrpn} and CREST~\cite{crest} on four challenging sequences (from top to down: \emph{carScale}, \emph{Skating2-2}, \emph{Human6} and \emph{ironman}). The ground-truth are illustrated with green bounding boxes. Best viewed in color.} \label{fig:otb} \end{figure} For comprehensive evaluation and analysis on the effectiveness of our approach, we compare SATIN with five state-of-the-art trackers, including SiamRPN~\cite{siamrpn}, CREST~\cite{crest}, SiamTri~\cite{siamtri}, ACFN~\cite{acfn}, and SiamFC~\cite{siamfc} in different attributes on the OTB-2015 benchmark. Each sequence in the OTB-2015 benchmark dataset is categorized with 11 attributes. Among all the 100 fully-annotated video sequences, there are 38 sequences with illumination variation (IV), 63 sequences with out-of-plane rotation (OPR), 64 sequences with scale variation (SV), 49 sequences with occlusion (OCC), 44 sequences with deformation (DEF), 29 sequences with motion blur (MB), 39 sequences with fast motion (FM), 51 sequences with in-plane rotation (IPR), 14 sequences with out of view (OV), 31 sequences with background clutter (BC) and 9 sequences with low resolution (LR). The results of overlap success and distance precision are shown in Fig.~\ref{fig:attauc} and Fig.~\ref{fig:atterror}, respectively. It is clear that the proposed SATIN obtains the best performance under $8$ of $11$ attributes. However, SATIN is slightly worse than SiamRPN on the attributes of in-plane rotation and low resolution. The main reason is that our backbone network may lose some fine-grained information through the repeated bottom-up and top-down framework. Besides, SATIN performs more accurate and robust under occlusion and background clutter with the help of attentional feature refinement, which can emphasize the informative feature regions and channels and reduce the effect of background noise to facilitate tracking tasks. Fig.~\ref{fig:otb} shows comparison results of SATIN with ACFN, SiamFC, SiamRPN, and CREST on OTB benchmark datasets. SATIN performs well on all the presented video sequences including \emph{carScale} (with attributes of SV, OCC, FM, IPR, and OPR), \emph{Skating2-2} (with attributes of SV, OCC, DEF, FM, and OPR), \emph{Human6} (with attributes of SV, OCC, DEF, FM, OPR, and OV) and \emph{ironman} (with attributes of IV, SV, OCC, MB, FM, IPR, OPR, OV, BC, and LR). All the results clearly demonstrate the excellent performance of SATIN. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig12.pdf} \end{center} \caption{Expected average overlap curve on the VOT-2016 challenge dataset~\cite{vot2016}. For presentation clarity, only the top 16 trackers with respect to the EAO score are shown in the plot.} \label{fig:vot2016graph} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig13.pdf} \end{center} \caption{Expected average overlap graph with trackers ranked on the VOT-2016 challenge dataset~\cite{vot2016}. For presentation clarity, only the top 16 trackers with respect to the EAO score are shown in the plot. The better trackers are located at the right.} \label{fig:vot2016} \end{figure} \begin{table}[t] \begin{center} \caption{Comparisons between STAIN and 15 state-of-the-art trackers on the VOT-2016 challenge dataset. The results are presented in terms of expected average overlap (EAO), accuracy (A), robustness (R), and equivalent filter operations (EFO). The first, second and third best values are highlighted in \textbf{\textcolor[rgb]{1.00,0.00,0.00}{red}}, \textbf{\textcolor[rgb]{0.00,0.00,1.00}{blue}} and \textbf{\textcolor[rgb]{0.00,1.00,0.00}{green}} fonts, respectively.} \label{table:vot2016} \begin{tabular}{p{2.5cm}p{2cm}<{\centering}p{2cm}<{\centering}p{2cm}<{\centering}p{2cm}<{\centering}} \toprule \textbf{Tracker} & \textbf{EAO} $\uparrow$ & \textbf{A} $\uparrow$ & \textbf{R} $\downarrow$ & \textbf{EFO} $\uparrow$ \\ \midrule CCOT~\cite{ccot} & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{0.331}} & 0.539 & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{0.850}} & 0.507 \\ TCNN~\cite{tcnn} & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{0.325}} & 0.554 & 0.959 & 1.049 \\ SSAT~\cite{vot2016} & 0.321 & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{0.577}} & 1.041 & 0.475 \\ MLDF~\cite{vot2016} & 0.311 & 0.490 & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{0.833}} & 1.483 \\ Staple~\cite{staple} & 0.295 & 0.544 & 1.350 & 11.114 \\ DDC~\cite{vot2016} & 0.293 & 0.541 & 1.233 & 0.198 \\ EBT~\cite{ebtt} & 0.291 & 0.465 & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{0.900}} & 3.011 \\ SRBT~\cite{vot2016} & 0.290 & 0.496 & 1.250 & 3.688 \\ STAPLEp~\cite{vot2016} & 0.286 & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{0.557}} & 1.317 & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{44.765}} \\ DNT~\cite{dnt} & 0.278 & 0.515 & 1.176 & 1.127 \\ SSKCF~\cite{vot2016} & 0.277 & 0.547 & 1.333 & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{29.153}} \\ SiamFC~\cite{siamfc} & 0.277 & 0.549 & 1.367 & 5.444 \\ DeepSRDCF~\cite{deepsrdcf} & 0.276 & 0.528 & 1.167 & 0.380 \\ SHCT~\cite{vot2016} & 0.266 & 0.547 & 1.417 & 0.711 \\ MDNet\_N~\cite{mdnet} & 0.257 & 0.541 & 1.204 & 0.534 \\ \midrule SATIN & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{0.324}} & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{0.561}} & 1.136 & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{11.688}} \\ \bottomrule \end{tabular} \end{center} \end{table} \subsection{Experiments on VOT} The VOT challenge~\cite{vot} is the most significant annual competition in the field of visual tracking. Each of VOT-2016, VOT-2017, and VOT-2018 benchmark datasets~\cite{vot2016,vot2017,vot2018} contains 60 video sequences. We use them to evaluate our proposed approach. In the experiments, the performance is assessed in three metrics: Accuracy, Robustness, and Expected Average Overlap (EAO). Accuracy is defined as the average overlap between the detected bounding box and the ground truth bounding box during successful tracking periods. Robustness is defined as how many times tracking failures occur. EAO represents the average overlap with no re-initialization following a failure. For fair comparisons, we use the original results provided by the VOT challenge committee~\footnote{\url{http://www.votchallenge.net/}}. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig14.pdf} \end{center} \caption{Expected average overlap graph with trackers ranked on the VOT-2017 challenge dataset~\cite{vot2017}. For presentation clarity, only the top 16 trackers with respect to the EAO score are shown in the plot. The better trackers are located at the right.} \label{fig:vot2017} \end{figure} We compared SATIN with $70$ other state-of-the-art trackers on the VOT-2016 challenge dataset, and report EAO curves and graph of the top $16$ participants in Fig.~\ref{fig:vot2016}. Among all the trackers, CCOT~\cite{ccot} achieves the best EAO score of $0.331$, which exploits continuous convolution operators on multi-level feature maps. It is clear that SATIN is superior to most of the state-of-the-art, and obtains the third-best EAO score of $0.324$, which is only $0.001$ lower than the second-best tracker TCNN~\cite{tcnn}. However, there is still a gap compared with the top performer CCOT~\cite{ccot}. Compared with SiamFC~\cite{siamfc} and DeepSRDCF~\cite{srdcf}, SATIN achieves absolute gains of $4.7\%$ and $4.8\%$ in EAO, respectively. Table~\ref{table:vot2016} reports the detailed comparison of SATIN with other tops 15 approaches in VOT-2016~\cite{vot2016} with respect to EAO, Accuracy, Robustness, and EFO is used to measure tracking speed. Among these 16 state-of-the-art trackers, SATIN achieves the second-best accuracy score of $0.561$ and the sixth-best robustness score of $1.136$, respectively. Compared with the baseline SiamFC~\cite{siamfc} which has an EAO score of $0.277$, SATIN substantially obtains a substantial gain of $17.0\%$ in EAO and demonstrates the superiority in terms of accuracy and robustness. Besides, compared to the top-performing tracker, i.e., CCOT, SATIN is $20\times$ faster than it with respect to the EFO score. All the above experiments show that our proposed approach performs well compared with other state-of-the-art trackers in the VOT-2016 challenge dataset. For the evaluation on the VOT-2017 challenge dataset, Fig.~\ref{fig:vot2017} reports the EAO score of ours in comparison with $15$ other state-of-the-art trackers. It is worth noting that although the VOT-2017 challenge dataset replaces ten videos in the VOT-2016 challenge dataset with $10$ complicated sequences. Compared with the top-ranked tracker in the VOT-2016 challenge, i.e., CCOT, the proposed approach improves the EAO score from $0.267$ to $0.291$, obtaining an absolute gain of $2.4\%$. Compared with SiamDCF, which performs correlation analysis on multi-level feature maps, SATIN obtains a significant EAO gain of $4.2\%$. This is mainly attributed to our tracker takes advantages of the benefits of both global and local contextual representations across multiple scales.% \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig15.pdf} \end{center} \caption{Expected average overlap graph for the baseline experiment on the VOT-2018 challenge dataset~\cite{vot2018}. For presentation clarity, only the top 22 trackers with respect to the EAO score are shown in the plot. The better trackers are located at the right.} \label{fig:vot2018base} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{fig16.pdf} \end{center} \caption{Expected average overlap graph for the real-time experiment on the VOT-2018 challenge dataset~\cite{vot2018}.} \label{fig:vot2018rt} \end{figure} For comprehensive evaluations, we further validate the tracking performance and efficiency of SATIN on the available VOT-2018 challenge dataset~\cite{vot2018}, which contains the same $60$ video sequences as the VOT-2017 challenge dataset. Two different experiments are conducted: a baseline experiment and a real-time experiment. The baseline experiment is as same as the standard experiments in the VOT-2016 and VOT-2017 challenge datasets. While in the real-time experiment, if a tracker cannot estimate the tracking results in 40 ms, the previous estimated target object position and size will be considered as the current results straightforwardly. Fig.~\ref{fig:vot2018base} and Fig.~\ref{fig:vot2018rt} report the results of ours against 21 state-of-the-arts with respect to the EAO score in baseline and real-time experiments, respectively. Trackers whose EAO scores exceed 0.282 will be considered as state-of-the-arts~\cite{vot2018}. Although SATIN ranks the 15th with an EAO score of 0.294 in the baseline experiment, it achieves a third-best performance with the EAO score of 0.289 in the real-time experiment. Compared with the LADCF tracker~\cite{ladcf}, which delivers the best EAO score of 0.389 in the baseline experiment, SATIN outperforms it by $22.3\%$ in the real-time experiment. SiamRPN~\cite{siamrpn} obtains the best EAO score of 0.383 in the real-time experiment~\footnote{This is a particular optimized version of SiamRPN for VOT evaluations. The original version (which is exploited in the OTB evaluations as mentioned earlier) achieves an EAO score of 0.244 in both baseline and real-time experiments.}. However, it has more redundant hyperparameters, which cost much memory storage overhead~\cite{fasterrcnn,cornernet} when compared to SATIN. Overall, all the baseline and real-time results demonstrate the proposed approach has comparable performance and efficiency. \subsection{Ablation studies} \begin{table}[t] \centering \caption{Ablation studies of several variations of our tracker on OTB benchmarks using AUC and Precision metrics. The first, second and third best values are highlighted in \textbf{\textcolor[rgb]{1.00,0.00,0.00}{red}}, \textbf{\textcolor[rgb]{0.00,0.00,1.00}{blue}} and \textbf{\textcolor[rgb]{0.00,1.00,0.00}{green}}, respectively.} \label{table:abla} \begin{tabular}{p{2.2cm}p{2cm}<{\centering}p{2cm}<{\centering}p{0.1cm}<{\centering}p{2cm}<{\centering}p{2cm}<{\centering}} \toprule \multirow{2}{*}{Trackers} & \multicolumn{2}{c}{OTB-2015} & & \multicolumn{2}{c}{OTB-2013} \\ \cline{2-3}\cline{5-6} & \multicolumn{1}{c}{AUC~(\%)} & \multicolumn{1}{c}{Precision~(\%)} & & \multicolumn{1}{c}{AUC~(\%)} & \multicolumn{1}{c}{Precision~(\%)} \\ \midrule SiamFC~\cite{siamfc} & 57.8 & 76.7 & & 60.9 & 80.9 \\ \midrule SATIN$_{NAA}$ & 60.8 & 81.2 & & 62.4 & 84.3 \\ SATIN$_{SENet}$ & 61.1 & 82.4 & & 63.2 & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{87.1}} \\ SATIN$_{NSA}$ & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{62.6}} & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{83.4}} & & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{64.5}} & \textbf{\textcolor[rgb]{0.00,0.00,1.00}{87.6}} \\ SATIN$_{NCA}$ & 61.5 & 82.2 & & 63.7 &86.5 \\ SATIN$_{NCP}$ & 57.2 & 79.1 & & 59.7 & 82.5 \\ SATIN$_{VGG}$ & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{61.9}} & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{82.7}} & & \textbf{\textcolor[rgb]{0.00,1.00,0.00}{64.3}} & 86.4 \\ SATIN$_{MobN}$ & 59.3 & 80.5 & & 61.6 & 82.2 \\ \midrule \textbf{SATIN} & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{64.1}} & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{84.4}} & & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{66.9}} & \textbf{\textcolor[rgb]{1.00,0.00,0.00}{89.3}} \\ \bottomrule \end{tabular} \end{table} To validate our tracker and analyze the effectiveness of each component, several ablative variants of SATIN, as well as the baseline tracker SiamFC~\cite{siamfc}, are evaluated on OTB benchmarks. The detailed evaluation results are illustrated in Table~\ref{table:abla}. Our full tracking approach (SATIN) outperforms all other variants. The effectiveness of the cross-attentional module is evaluated by comparison with three alternative variants, i.e., SATIN$_{NAA}$ (SATIN without all attention), SATIN$_{NSA}$ (SATIN without the spatial attention), and SATIN$_{NCA}$ (SATIN without the channel-wise attention). In addition, we implement a variant SATIN$_{SENet}$ that incorporates the recent SENet~\cite{senet} to learn channel-wise attention. SATIN$_{NSA}$ obtains absolute AUC and DP gains of $1.5\%$ and $1.0\%$ compared with SATIN$_{SENet}$. This is mainly attributed to the different pooling strategies of these two variants. Compared with SATIN$_{NAA}$, after integrating both channel-wise and spatial attentional information in the full approach, both robustness and accuracy are dramatically improved, with gains of almost $3.3\%$ and $3.2\%$ in AUC and DP scores, respectively. Without corner pooling operation (SATIN$_{NCP}$), inaccurate corner point detections significantly deteriorate the tracking results. This fact demonstrates that the corner pooling operations is more critical for detecting corner points. Specifically, we observe that the AUC score of SATIN$_{NCP}$ is inferior to that of the baseline SiamFC with a $1.2\%$ drop. But the DP score is around $2.4\%$ higher than that of SiamFC owing to that centroid point detection does not need corner pooling operation. To investigate how the proposed lightweight hourglass network contributes to SATIN, we first implement the variant SATIN$_{VGG}$, which stacks two VGG-M~\cite{vgg} as the backbone network. Compared with the full SATIN tracker, the performance of SATIN$_{VGG}$ drops more than $2.6\%$ and $2.9\%$ in terms of AUC and DP scores on the OTB-2015 benchmark dataset. We also construct another variant named SATIN$_{MobN}$ by replacing the lightweight hourglass networks with two MobileNets~\cite{mobilenet}. However, this replacement causes a significant performance drop of $5.3\%$ from $66.9\%$ to $61.6\%$ in the AUC score on the OTB-2015 benchmark dataset. These results~\footnote{For comprehensive and fair evaluations, we also add some convolutional and upsampling layers following each original VGG-M and MobileNet to make the output feature maps at the desired resolution in SATIN$_{VGG}$ and SATIN$_{MobN}$, respectively.} prove that our backbone network can learn more contextual representations than the off-the-shelf and lightweight networks. For comprehensive studies on the effectiveness of the proposed lightweight hourglass network, we further compare it with the original hourglass network~\cite{hourglass} and the MobileNet~\cite{mobilenet}. Table~\ref{table:para} summarizes the experimental results. We observe that using deeper backbone networks for feature extraction may lead to further performance improvement but also with the extra computational burden. Although the original hourglass network slightly outperforms the proposed lightweight hourglass network on both OTB-2015 and VOT-2017 datasets, it is much larger and complicated than the latter. Specifically, compared with the single-stage original hourglass network ($\times$1), the \#Params and \#GFLOPs of the single-stage lightweight hourglass network ($\times1$) are much lower and less than $35\%$ while the speed is $15\times$ fast. It is worth noting that adding another lightweight hourglass network in the backbone, i.e., the two-stage lightweight hourglass network ($\times2$), significantly improves performance. The AUC score on the OTB-2015 benchmark dataset is enhanced by $3.0\%$ from 0.611 to 0.641, and the EAO score on the VOT-2017 challenge dataset is improved by $3.2\%$ from 0.262 to 0.294, respectively, at the costs of $174\%$ \#Params and $161\%$ \#GFLOPs. Moreover, the two-stage lightweight hourglass network ($\times2$) performs better than the single-stage original hourglass network ($\times1$) while significantly being $2.9\times$ smaller and $2.4\times$ less computational cost, which evidences reasonable complexity and performance tradeoff is critical for visual tracking. These results indicate that each component brings individual improvement, and all of them work together to achieve surprisingly excellent tracking performance. \begin{table}[t] \centering\footnotesize \caption{Effect on the depth of backbone networks in SATIN.} \label{table:para} \begin{tabular}{rcccccc} \toprule \# \begin{tabular}[c]{@{}r@{}}Backbone Networks\end{tabular} & \begin{tabular}[c]{@{}c@{}}MobileNet\\($\times$1)\end{tabular} & \begin{tabular}[c]{@{}c@{}}MobileNet\\($\times$2)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Original\\Hourglass\\($\times$1)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Original\\ Hourglass\\ ($\times$2)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Lightweight \\Hourglass\\ ($\times$1)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Lightweight \\Hourglass\\ ($\times$2)\end{tabular} \\%& \midrule AUC on OTB-2015 &0.577&0.593&0.632&0.650&0.611&0.641\\ EAO on VOT-2017 &0.252&0.270&0.287&0.302&0.262&0.294\\ Speed (fps) &93&77&9&$\sim$2&41&27\\ \# Params (M) &5.3&9.8&32.2&57.8&11.3&19.7\\ \# GFLOPs &0.87&1.43&36.2&66.5&15.4&24.8\\ \bottomrule \end{tabular} \end{table} \section{Conclusions}\label{sec:5} In this paper, we propose a new deep architecture named SATIN for high-performance visual tracking. It utilizes a Siamese lightweight hourglass network as the backbone network, which can extract more global and local contextual representations at multiple scales in a repeated bottom-up and top-down manner. We model generic visual tracking as a set of keypoint detection tasks, i.e., SATIN tracks any target object by detecting three keypoints of its bounding box, including the top-left corner point, the centroid point, and the bottom-right corner point. Thus, our approach eliminates the need for designing anchor boxes or multi-scale pyramids. Meanwhile, a cross-attentional module is employed to heuristically learn where to emphasize or suppress along channel-wise and spatial dimensions on object representations, therefore the tracking performance is promoted further. Without bells and whistles, our approach achieves state-of-the-art results on four popular benchmark datasets. Furthermore, SATIN runs at $27$ fps, which is far above real-time frame rate. \section*{Acknowledgments} \label{sec:ack} This work was supported by the National Natural Science Foundation of China under Grant No.~31701187, the Science and Technology Planning Program of Guangdong Province under Grant No.~2016B090918047, and Promotional Credit from Amazon Web Service, Inc. The authors would like to thank all the anonymous reviewers for their insightful comments and suggestions that have helped to significantly improve the quality of this paper.
{'timestamp': '2020-01-01T02:08:35', 'yymm': '1904', 'arxiv_id': '1904.10128', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10128'}
arxiv
\section{Introduction}\label{sec1} {Statistical classification methods are widely used in various fields such as economics, computer science, meteorology, and medicine. Specifically, in medicine, diagnostic tests are employed as effective ``classifiers" to discriminate diseased individuals from the non-diseased. Over the recent decades, many research articles recommended combining multiple test results in order to increase the overall diagnostic accuracy. Common approaches to combine multiple test results include the logistic regression (LR), the linear discriminant analysis (LDA) and other model-based approaches. Some authors (\cite{su1993liu}, \cite{pepe2000thompson}, \cite{pepe2006cai}) directly focused on the maximization of the Area Under the Receiver Operating Characteristic (ROC) Curve (AUC) to combine multiple test results. However, to the best of our knowledge, there is only limited development for finding the optimal linear combination of diagnostic tests in case of multivariate classification problems.} {For binary classification, earlier works considered maximizing various non-parametric estimates of AUC to obtain the best linear combination of the biomarkers (\cite{pepe2000thompson}, \cite{ma2005}, \cite{ma2006}, \cite{ma2007huang}, \cite{liu2011min}, among others). In particular, \cite{pepe2006cai} proposed to maximize an empirical estimate of AUC in the form of a Mann-Whitney U-statistic for obtaining the best solution. However, maximization of the empirical AUC remains computationally challenging since the objective function is discontinuous and non-differentiable. To reduce the computational complexity, \cite{ma2007huang} considered maximizing a smooth consistent approximation of the empirical AUC using the sigmoid function to estimate the optimal coefficient parameters for the binary classification scenario. For multivariate classification problems, \cite{liu2011min} proposed a min-max method where only the biomarkers with the minimum and the maximum values are considered for each subject, and then they are combined linearly by maximizing the empirical AUC. Thus, irrespective of the number of biomarkers, min-max method estimates only one coefficient at a time which is computationally less expensive.} When a disease outcome involves more than two categories, Hyper-volume Under the ROC Manifold (HUM) is commonly used as a multi-category extension of AUC (\cite{li2008fine}). In such problems, the goal is to find the optimal combination of biomarkers that maximizes the diagnostic accuracy measure HUM. For a three-category outcome, HUM is also known as the Volume under ROC Surface (VUS), and has also been considered in the context of some real applications (\cite{scurfield1996}, \cite{mossman1999}, \cite{nakas2004yiannoutsos}). To evaluate the HUM values for single marker or multiple markers under existing learning methods, one may adopt R packages {\tt HUM} \cite{novo2013} and {\tt mcca} \cite{li2019}, respectively. \cite{zhang2011li} maximized the empirical estimate of VUS to combine multiple biomarkers. Due to non-differentiability of the objective function, maximization of empirical VUS requires derivative-free optimization methods which are computationally expensive, especially when the number of biomarkers is large. To overcome this problem, under normality assumption, \cite{kang2013} used a penalized and scaled stochastic distance method to combine multiple biomarkers, which was computationally less demanding. However, violation of the normality assumption of biomarkers may lead to poor estimation performance. \cite{hsu2016chen} constructed upper and lower bounds of the HUM using Fr\'echet inequality and showed that these bounds are functions of AUCs of all possible pairwise adjacent categories. Then they maximized the empirical estimates of such upper and lower bounds to obtain the optimal linear combination. This technique reduces the computational complexity. However, such approximations do not perform well for small sample sizes and/or non-normal distributions (as is observed in our simulation study). {In this article, we propose to maximize the distribution-free Smooth approximation of empirical HUM (SHUM) to combine multiple biomarkers in an effective way. In particular, the sigmoid function and the normal cumulative distribution functions (CDF) are used to approximate the non-differentiable indicator functions embedded in the definition of HUM. We show that the proposed method yields consistent estimates of the optimal coefficients and they are asymptotically normal. A major advantage with the proposed method stems from the fact that SHUM is a continuous and differentiable function; this feature of SHUM allows one to adopt a variety of gradient-based optimization algorithms. Maximizing empirical HUM with derivative-free optimization techniques, such as Nelder-Mead simplex method, genetic algorithm (GA), and simulating annealing (SA), are computationally expensive. However, gradient-based optimization techniques like Newton-Raphson and Quasi-Newton methods can be applied to maximize the SHUM function; these nonlinear solvers are much more stable with nice convergence properties. In addition to the theoretical developments, we also carry out extensive simulations to examine our methods and compare their performance with other existing methods, e.g., the min-max method (\cite{liu2011min}), the lower and upper bound methods (\cite{hsu2016chen}), the empirical method (\cite{zhang2011li}) and the parametric method with normal distribution (\cite{zhang2010thesis}).} {As a motivating application, we consider data from the {\bf E}ffect of {\bf R}emote {\bf I}schemic Preconditioning on {\bf C}linical Outcomes in Patient Undergoing {\bf C}oronary {\bf A}rtery Bypass Graft Surgery (ERICCA) trial where a group of patients participated in a cardiovascular surgery and were followed for one year after the surgery (\cite{hausenloy2015}). During the study period, patients might have developed Acute Kidney Injury (AKI) which was recorded as a multi-category ordinal outcome with 4 severity levels. In another application, we consider data on Alzheimer's disease from the Alzheimer’s Disease Research Center (ADRC) at the University of Washington. There, based on the level of disease severity, the patients were divided into 3 groups and data on 14 biomarkers were collected. For both the datasets, we apply our proposed methods to combine the biomarkers and compare the results with the competing methods.} The rest of the article is organized as follows. In Section 2, HUM and SHUM are defined along with discussion on the large sample properties of the estimated combination coefficients. In Section 3, existing methods are summarized in an overview. In Section 4, we provide a discussion on computational issues. In section 5, we present results from the simulation studies. Section 6 describes the results and findings from two real data analyses. Section 7 contains discussion and concluding remarks. All the proofs of theoretical results can be found in the Appendix. \section{Methods} In this section, we introduce the HUM and SHUM methods for combining multiple markers to improve the multi-category classification accuracy. \subsection{{Hyper-volume Under ROC Manifold (HUM)}} Consider a study where there are $M$ multiple diagnostic/disease categories which are assumed to be ordered in nature without loss of generality. We provide some practical suggestion later for unordered classes. Suppose $\mathbf{X}_{1}, \mathbf{X}_{2}, \cdots, \mathbf{X}_{M}$ are $d$-dimensional random selected vectors representing the values of $d$ biomarkers for $M$ diagnostic/disease categories where $\mathbf{X}_{j} = (X_{j1}, X_{j2},\cdots, X_{jd})^{T}$ and $X_{jk}$ denotes the value of the $k$-th biomarker from the $j$-th category, $k=1,2,\cdots,d$ and $j=1,2,\cdots,M$. Suppose $\mathbf{X}_{j}$ follows multivariate continuous distribution $F_{j}$. Consider a linear combination of these biomarkers as $$ \boldsymbol{\beta}^{T}\mathbf{X}_{j}=\displaystyle\sum_{k=1}^{d}\beta_{j}X_{jk}, \; j=1,2,\cdots, M, $$ where $\boldsymbol{\beta}=(\beta_{1}, \beta_{2}, \cdots, \beta_{d})^{T}$ is a $d$-dimensional vector of parameters. Under the assumption that the larger value of the above combination corresponds to more severe disease category, a diagnostic accuracy measure can be defined by the following probability $$D(\boldsymbol{\beta}) = P(\boldsymbol{\beta}^{T}\mathbf{X}_{M}>\boldsymbol{\beta}^{T}\mathbf{X}_{(M-1)}>\cdots>\boldsymbol{\beta}^{T}\mathbf{X}_{1}),$$ which is known as hyper-volume under the ROC manifolds (HUM) (\cite{scurfield1996}, \cite{li2008fine}). For multi-category ordinal outcome, HUM can be considered as an extension of the AUC which is widely used for binary diagnostic accuracy studies. Our objective is to find the best possible value of $\beta$ for which $D(\boldsymbol{\beta})$ is maximized. Ideally, if there exist a $\beta$ for which $D(\boldsymbol{\beta}) = 1$, using such a combination the diagnostic categories would be perfectly separated. Let $\boldsymbol{\beta}_{0}$ denote the optimal coefficient parameter that maximizes $D(\boldsymbol{\beta})$ over a restricted parametric space $B$, $$\boldsymbol{\beta}_{0} = \arg \max_{\boldsymbol{\beta} \in B} D(\boldsymbol{\beta}),$$ where the restricted space $B = \{\boldsymbol{\beta}\in \mathbb{R}^{d}: \beta_{d} = 1\}$ is considered to avoid the identifiability problem. Denote $\boldsymbol{\theta} = (\beta_{1}, \beta_{2}, \cdots, \beta_{d-1})^T$ to be the first $d-1$ components of $\boldsymbol{\beta}$ which are the actual coefficient parameters free to vary in the $d-1$ dimensional Euclidean space. Hereafter, for the simplicity of presentation, we use $\boldsymbol{\beta}$ in place of $\boldsymbol{\beta}(\boldsymbol{\theta})=(\boldsymbol{\theta}^{T}, 1)^T$. If the biomarkers are non-informative in predicting the disease categories then $D(\boldsymbol{\beta})$ will be close to the probability of a random sorting $\frac{1}{M!}$. Under the assumption that $\mathbf{X}_{1}, \mathbf{X}_{2}, \cdots, \mathbf{X}_{M}$ are generated from multivariate normal distribution, a unique solution for $\boldsymbol{\beta}_{0}$ can be derived under some regularity conditions, (\cite{su1993liu}). However, in general for non-normal data, there does not exist such closed form expression of $\boldsymbol{\beta}_{0}$ and numerical optimizer must be utilized. \subsection{{Empirical HUM}}\label{sec_EHUM} {Now let us consider the problem of estimating $\boldsymbol{\beta}_{0}$ given an empirical sample. Let $\{\mathbf{X}_{ji_j}; \; i_j=1,2,\cdots,n_{j}, \; j=1,2,\cdots,M\}$ be a sample of size $n=\sum_{j=1}^{M}n_{i}$ observations where $j=1,\ldots,M$ denote diagnostic categories and $i_{j}=1,2,\cdots,n_{j}$ denote the samples in the $j$-th category. Then, for a fixed $\boldsymbol{\beta}$, the empirical HUM is given by \begin{eqnarray}\label{eqn-hum-empirical} {D}_{E}(\boldsymbol{\beta}) &=& \dfrac{1}{n_{1}n_{2} \cdots n_{M}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}} \cdots \displaystyle\sum_{i_{M}=1}^{n_{M}}I(\boldsymbol{\beta}^{T}\mathbf{X}_{Mi_{M}}>\boldsymbol{\beta}^{T}\mathbf{X}_{(M-1)i_{(M-1)}}>\cdots>\boldsymbol{\beta}^{T}\mathbf{X}_{1i_{1}}) \nonumber \\ &=& \dfrac{1}{\displaystyle\prod_{i=1}^{M}n_{i}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}} \cdots \displaystyle\sum_{i_{M}=1}^{n_{M}} I(\boldsymbol{\beta}^{T}\mathbf{X}_{Mi_{M}}>\boldsymbol{\beta}^{T}\mathbf{X}_{(M-1)i_{(M-1)}}) \cdots I(\boldsymbol{\beta}^{T}\mathbf{X}_{2i_{2}}>\boldsymbol{\beta}^{T}\mathbf{X}_{1i_{1}}) \nonumber \\ \end{eqnarray} where $I(\cdot)$ denotes the indicator function. When sample size is large, $D_E(\boldsymbol{\beta})$ is a very close approximation to $D(\boldsymbol{\beta})$. Therefore an optimal coefficient parameter can be estimated by $$ \widehat{\boldsymbol{\beta}}_{E} = \arg \max_{\boldsymbol{\beta} \in B} {D}_{E}(\boldsymbol{\beta}).$$ When the number of disease categories is 2 (i.e., $M=2$), the empirical HUM reduces to the empirical estimate of AUC given by $$D_{E}(\boldsymbol{\beta}) = \dfrac{1}{n_{1}n_{2}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}} I(\boldsymbol{\beta}^{T}\mathbf{X}_{2i_{2}}>\boldsymbol{\beta}^{T}\mathbf{X}_{1i_{1}}),$$ and when $M=3$, it reduces to the empirical VUS given by {\begin{align} D_{E}(\boldsymbol{\beta}) = \dfrac{1}{n_{1}n_{2}n_{3}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}}\displaystyle\sum_{i_{3}=1}^{n_{3}} I(\boldsymbol{\beta}^{T}\mathbf{X}_{3i_{3}}>\boldsymbol{\beta}^{T}\mathbf{X}_{2i_{2}}>\boldsymbol{\beta}^{T}\mathbf{X}_{1i_{1}}). \label{EVUS} \end{align}} Under some regularity conditions, \cite{zhang2011li} established the consistency and asymptotic normality of $\widehat{\boldsymbol{\beta}}_{E}$ for three-category outcome. Following their argument, the consistency and asymptotic normality of $\widehat{\boldsymbol{\beta}}_{E}$ for more than three categories can be similarly established. However, upon close examination, we notice that ${D}_{E}(\boldsymbol{\beta})$ is discontinuous and not differentiable w.r.t. $\boldsymbol{\beta}$, and hence faster gradient-based algorithms are not useful to this optimization problem. On the other hand, although derivative-free algorithms can be used for small number of categories, say $M=2$ or $3$, with the increase in the number of categories derivative-free algorithms become computationally prohibitive and instable. To address this issue, in the next section, we propose a new method based on smooth approximation.} \subsection{{Smooth Approximation of empirical HUM}} In order to alleviate the computational burden of maximizing the sample version HUM, as an alternative we propose to maximize a class of smooth approximations of the empirical HUM. The basic idea is to approximate the non-differentiable indicator function $I(x>0)$. We focus on the class of all continuous distribution functions $g(x)$ with support over $(-\infty,\infty)$, satisfying $g(x)+g(-x)=1$ and $g^{''}(x)$ is continuous. Having $g^{''}(x)$ continuous and replacing all indicator functions with this kind of approximation function makes the approximate objective function solvable with gradient-based optimization algorithms such as the Newton-Raphson methods and the Quasi-Newton methods. In this paper, we consider two smooth candidates which are the sigmoid function $s(x) = \frac{1}{1+\exp(-x)}$, and the standard normal CDF denoted by $\Phi(x)=P(\chi \leq x)$ where $\chi$ follows a normal distribution with mean 0 and variance 1. Under the binary classification scenario, \cite{ma2007huang} proposed the sigmoid approximation of the empirical AUC to seek $\boldsymbol{\beta}_{0}$. However this approach has never been extended for multi-category classification scenario to the best of our knowledge. As the value of $x$ goes away from 0, $s(x)$ tends to get closer to $I(x)$. When $x$ is close to 0, the absolute difference between $s(x)$ and $I(x)$ is the highest. This also holds true for $\Phi(x)$. Therefore, in order to improve the approximation of these functions, a tuning parameter $\lambda_{n}$ is introduced and we approximate $I(x)$ by $s_{n}(x)=s(\frac{x}{\lambda_{n}})=\frac{1}{1+\exp(-x/\lambda_{n})}$ and $\Phi_{n}(x) = \Phi(x/\lambda_{n})$ where $\lambda_{n}$ satisfies $\lim_{n \rightarrow \infty} \lambda_{n} = 0$. The choice of $\lambda_{n}$ is very crucial in the performance of the smoothed HUM function. When $\lambda_{n}$ is close to 0, the proposed SHUM estimator behaves similarly to the empirical HUM with a very large value of derivative across a very small interval around zero. This induces a greater variability on the resulting estimators. On the other hand, if $\lambda_{n}$ is chosen to be one, it suffers from biased approximation. Therefore, we need to choose an optimal $\lambda_{n}$ between 0 and 1 to strike a balance between the bias and the variance issues. To illustrate the role of $\lambda_{n}$, a graphical representation is displayed in Figure \ref{fig-lambda-n} where we consider a few selected values of $\lambda_n$. We can see that as $\lambda_{n}$ decreases to zero the approximation becomes closer to the indicator function $I(x)$. As a rule of thumb, \cite{gammerman1996} and \cite{ma2007huang} recommended $\lambda_{n}$ should be chosen ensuring that $|\boldsymbol{\beta}^{T}(\mathbf{X}_{1i_1} - \mathbf{X}_{2i_2})/ \lambda_{n}| > 5$ is satisfied for most of the pairs ($i_1$, $i_2$). In this paper after experimenting with different possible values of $\lambda_{n}$, we set $\lambda_{n}=\frac{1}{\sqrt{n}}$ for our simulation studies and real data analysis, which satisfies the empirical condition. \begin{figure}[t] \centering \includegraphics[scale=0.6]{choose_lambda_n_normal_cdf} \caption{Sigmoid and normal CDF functions for different choices of tuning parameter $\lambda_n$} \label{fig-lambda-n} \end{figure} {Although the smoothing approximation can be done through either $g_{n}=s_n$ or $g_n=\Phi_n$, hereafter we only present the results for the sigmoid smoothing approximation to save the space. Applying this proposed function approximation to ${D}_{E}(\boldsymbol{\beta})$, the proposed sigmoid smooth approximation function for multi-categorical problem is given by \begin{equation}\label{eqn-hum-sigmoid} {D}_{s_{n}}(\boldsymbol{\beta}) = \dfrac{1}{n_{1}n_{2}\cdots n_{M}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}} \cdots \displaystyle\sum_{i_{M}=1}^{n_{M}} s_{n}(\boldsymbol{\beta}^{T}(\mathbf{X}_{Mi_{M}}-\mathbf{X}_{(M-1)i_{(M-1)}})) \cdots s_{n}(\boldsymbol{\beta}^{T}(\mathbf{X}_{2i_{2}}-\mathbf{X}_{1i_{1}})). \end{equation} We propose to maximize ${D}_{s_{n}}(\boldsymbol{\beta})$ in order to estimate the optimal coefficient vector. The optimal vector of combination is estimated by $$\widehat{\boldsymbol{\beta}}_{s_{n}} = \arg \max_{\boldsymbol{\beta} \in B} {D}_{s_{n}}(\boldsymbol{\beta}).$$ We denote the optimal coefficient estimate obtained using the sigmoid smooth approximation of the empirical HUM (SSHUM) as $\widehat{\boldsymbol{\beta}}_{s_{n}}$ and using the normal smooth approximation of the empirical HUM (NSHUM) by $\widehat{\boldsymbol{\beta}}_{\Phi_{n}}$. \subsection{Consistency and Asymptotic Normality of SSHUM} Under some regularity conditions, we establish the consistency and asymptotic normality of $\widehat{\boldsymbol{\beta}}_{s_{n}}$. We list the set of necessary regularity conditions as follows. \begin{itemize} \item[A1.] The support space of $\mathbf{X}_{ji_j}$ is not contained in any proper linear subspace of $\mathbb{R}^{d}$. \item[A2.] There exist at least one component of $\mathbf{X}_{ji_j}$ which has positive density everywhere conditional on the other components, almost surely. \item[A3.] The true parameter value $\boldsymbol{\beta}_{0}$ is an interior point of $B$ which is a compact subset of $\mathbb{R}^{d}$. \end{itemize} \begin{theorem}[Consistency]\label{theo_cons} Suppose that assumptions (A1)-(A3) hold, then $$\widehat{\boldsymbol{\beta}}_{s_n} \overset{p}{\longrightarrow} \boldsymbol{\beta}_{0}$$ as $n \rightarrow \infty$, where $``{\overset{p}{\longrightarrow}}"$ denotes {\it convergence in probability}. \end{theorem} The detailed proof of Theorem \ref{theo_cons} is provided in section A1 in the appendix. {In order to prove the asymptotic normality of $\widehat{\boldsymbol{\beta}}_{s_n}$, we assume additional set of regularity conditions. Denote $\Psi(\mathbf{X}_{1i_1}, \mathbf{X}_{2i_2}, \mathbf{X}_{Mi_M}; \boldsymbol{\beta})=\dfrac{\partial}{\partial\boldsymbol{\theta}} \left[s_{n}(\boldsymbol{\beta}^{T}(\mathbf{X}_{Mi_{M}}-\mathbf{X}_{(M-1)i_{(M-1)}})) \cdots s_{n}(\boldsymbol{\beta}^{T}(\mathbf{X}_{2i_{2}}-\mathbf{X}_{1i_{1}})) \right]$. Then assume the following: \begin{itemize} \item[A4.] $\mathbf{A}(\boldsymbol{\beta}_{0}) = E\left(-\dfrac{\partial}{\partial\boldsymbol{\theta}^{T}}\Psi(\mathbf{X}_{1i_1}, \mathbf{X}_{2i_2}, \mathbf{X}_{Mi_M}; \boldsymbol{\beta}_{0})\right)<\infty$ and is invertible. \item[A5.] $\tilde{\Psi}_{m1}(\mathbf{X}_{m1}; \boldsymbol{\beta}_{0}) = E\left(\dfrac{\partial}{\partial\boldsymbol{\theta}}\Psi(\mathbf{X}_{11}, \mathbf{X}_{21}, \mathbf{X}_{M1}; \boldsymbol{\beta}_{0})|\mathbf{X}_{m1}\right)$ is having the finite variance-covariance matrix, i.e., $\Sigma_{\psi_{m}} = Var(\tilde{\Psi}_{m1}(\mathbf{X}_{m1}; \boldsymbol{\beta}_{0})) <\infty$ for all $m=1,2,\cdots,M$. \item[A6.] $\lim_{n \rightarrow \infty}\dfrac{n}{n_{m}}=\rho_{m}^{2} < \infty$ for all $1\le m \le M$. \end{itemize} Assumptions (A4)-(A6) ensure that the asymptotic variance exits and is finite.} \begin{theorem}[Asymptotic normality]\label{theo_normality} Suppose that the regularity conditions (A1)-(A6) hold, then $$\sqrt{n}(\widehat{\boldsymbol{\beta}}_{s_n} - \boldsymbol{\beta}_{0}) \overset{D}{\longrightarrow} (W^{T},0)^{T}$$ as $n \longrightarrow \infty$ where $``{\overset{D}{\longrightarrow}}"$ denotes {\it convergence in distribution} and $W$ is a $(d-1)$-variate normal distribution $N(\mathbf{0}, \mathbf{A}^{-1}(\boldsymbol{\beta}_{0})\mathbf{B}(\boldsymbol{\beta}_{0})\{\mathbf{A}^{-1}(\boldsymbol{\beta}_{0})\}^{T})$, where \begin{eqnarray*} \mathbf{B}(\boldsymbol{\beta}_{0}) &=& \displaystyle\sum_{m=1}^{M}\rho_{m}^{2}\Sigma_{\psi_{m}}. \end{eqnarray*} \end{theorem} {Remark: Computation of variance of $\widehat{\boldsymbol{\beta}}_{s_n}$ using the asymptotic variance formula given in Theorem 2 is very tedious and challenging, especially because of the choice of the kernel function $\mathbf{g}$ given in equation \eqref{eqn-g}. Furthermore, it is noticed that the U-statistic based asymptotic variance formula are not generally reliable for small sample size for the direct maximization of the empirical HUM (see \cite{li2008fine}). In such cases, bootstrap technique is usually employed to compute the variances of the coefficient estimators of ${\boldsymbol{\beta}}_{s_n}$.} \section{Existing Methods}\label{sec-existing} {In this section, we provide a brief summary of the existing methods which can be used to obtain the optimal coefficient vector for biomarker combinations. In the simulation study section, we shall compare the proposed methods with these methods.} \subsection{Parametric Method with Normality Assumption (Parametric)} \cite {zhang2010thesis} proposed the parametric method with normality assumption of the biomarkers in order to obtain the optimal linear combination of biomarkers. This approach assumes that $F_j$, the distribution of biomarkers from the $j$th category $\boldsymbol{X}_{j} $, is a multivariate normal distribution with mean vector $\boldsymbol{\mu}_{j}$ and variance-covariance matrix $\Sigma_{j}$, $j=1,2,\cdots,M$. Then, the linear combination of biomarkers $\boldsymbol{X}_{j}$ for the $j$-th category, denoted by $V_{j} = \boldsymbol{\beta}^{T}\boldsymbol{X}_{j}$, follows a univariate normal distribution with mean $\boldsymbol{\beta}^{T}\boldsymbol{\mu}_{j}$ and variance $\boldsymbol{\beta}^{T}\Sigma_{j}\boldsymbol{\beta}$, i.e., $V_{j} \sim N(\boldsymbol{\beta}^{T}\boldsymbol{\mu}_{j}, \boldsymbol{\beta}^{T}\Sigma_{j}\boldsymbol{\beta})$ $j=1,2,\cdots,M$. Let $\phi$ and $\Phi$ denote the density function and cumulative distribution function of the standard normal distribution $N(0,1)$. For $M=3$, the HUM $D(\boldsymbol{\beta})$ can be shown to be equal to \begin{eqnarray} D_{N}(\boldsymbol{\beta}) &=& \int_{-\infty}^{\infty} \Phi\left(\dfrac{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{2}\boldsymbol{\beta}}}{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{1}\boldsymbol{\beta}}} u + \dfrac{\boldsymbol{\beta}^{T}(\boldsymbol{\mu}_{2} - \boldsymbol{\mu}_{1})}{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{1}\boldsymbol{\beta}}} \right) \Phi\left(- \dfrac{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{2}\boldsymbol{\beta}}}{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{3}\boldsymbol{\beta}}} u + \dfrac{\boldsymbol{\beta}^{T}(\boldsymbol{\mu}_{3} - \boldsymbol{\mu}_{2})}{\sqrt{\boldsymbol{\beta}^{T}\Sigma_{3}\boldsymbol{\beta}}} \right) \phi(u) \; du. \nonumber \\ \end{eqnarray}\label{eqn-normal-hum} Maximizing $D_{N}(\boldsymbol{\beta})$ with respect to $\boldsymbol{\beta}$, we obtain the optimal coefficient estimates as $$\boldsymbol{\beta}_{N} = \arg \max_{\boldsymbol{\beta} \in B} D_{N}(\boldsymbol{\beta}).$$ Following the results of \cite{su1993liu}, it can be shown that if $\mathbf{X}_{1}, \mathbf{X}_{2}, \cdots, \mathbf{X}_{M}$ are multivariate normally distributed with mean vectors $\boldsymbol{\mu}_{1}$, $\boldsymbol{\mu}_{2}$, $\cdots$, $\boldsymbol{\mu}_{M}$, respectively and common variance-covariance matrix $\Sigma$ satisfying \begin{eqnarray}\label{eqn-normal-cond} \boldsymbol{\mu}_{2}-\boldsymbol{\mu}_{1}=\boldsymbol{\mu}_{3}-\boldsymbol{\mu}_{2}= \cdots = \boldsymbol{\mu}_{M}-\boldsymbol{\mu}_{M-1} =\boldsymbol{\delta}, \end{eqnarray} the optimal coefficient parameters $\widehat{\boldsymbol{\beta}}_{N}$ will be proportional to $\Sigma^{-1}\boldsymbol{\delta}$, i.e., $\widehat{\boldsymbol{\beta}}_{N} \propto \Sigma^{-1}\boldsymbol{\delta}$. Once we have the sample estimates for the mean and covariance parameters, we can plug-in them into the formula of $\widehat{\boldsymbol{\beta}}_{N}$ to obtain the coefficient estimates. {A major advantage of using normality assumption is that it is computationally very easy, especially when \eqref{eqn-normal-cond} holds true. However, the method fully depends on the normality assumption. Violation of the normality assumption may result in poor estimate of $\boldsymbol{\beta}_{0}$.} \subsection{Min-Max Method (Min-Max)} The Min-Max {(MM)} method is a more simplified non-parametric approach to combine the multiple biomarkers. It was originally proposed by \cite{liu2011min} in the context of binary outcome. Instead of considering all the biomarkers, this method considers the empirical AUC based on the linear combination of two extreme biomarkers for each subject in the study. In this paper, to facilitate a comparative study, we define the empirical HUM based on the combination of the minimum and maximum biomarkers for each subject. {Let $X_{ji_j,max} = \max_{1\le k \le d} X_{ji_j,k}$ and $X_{ji_j,min} = \min_{1\le k \le d} X_{ji_j, k}$ and define the linear combination of these two extreme observations as $ V_{ji_j} = \beta_{max} X_{ji_j,max} + \beta_{min} X_{ji_j,min}$, $i=1,2,\cdots,n_j$, $j=1,2,\cdots,M$. Then the objective function to be maximized to obtain the optimal coefficient vector is given by \begin{eqnarray}\label{eqn-minmax-hum} D_{MM}(\boldsymbol{\beta}) &=& \dfrac{1}{\displaystyle\prod_{j=1}^{M}n_{j}} \displaystyle\sum_{i_{1}=1}^{n_{1}}\displaystyle\sum_{i_{2}=1}^{n_{2}} \cdots \displaystyle\sum_{i_{M}=1}^{n_{M}}I(V_{Mi_M} > V_{(M-1)i_{M-1}} > \cdots > V_{1i_{1}}). \end{eqnarray} The optimal coefficient estimates by maximizing the above quantity can be written as $$ \widehat{\boldsymbol{\beta}}_{MM} = \arg \max_{\boldsymbol{\beta}\in B} {D}_{MM}(\boldsymbol{\beta}).$$} {A major advantage of this method is that it involves the optimization of a single parameter as opposed to other competing methods, and hence computationally it is very efficient. Furthermore, it does not need to assume any distributional assumption of the data and hence is more robust against the parametric methods. So far, the method is studied only in the context of binary disease outcome and it is observed that the method can achieve higher sensitivity over a certain range of specificity. In other words, when someone is interested in partial AUC, this methods works better. However a major limitation of this method is that a major portion of the informations on the biomarkers are not utilized since only maximum and minimum biomarkers’ values are used.} \subsection{{Upper and Lower Bound Approach using Fr\'echet inequality (Fr\'echet)} } To reduce computational burden of maximizing the empirical HUM in case of higher number of disease categories and/or number of biomarkers, \cite{hsu2016chen} proposed the upper and lower bounds of HUM which are given by $$\max\{0, (M-1)P_{A}(\boldsymbol{\beta}) - (M-2)\} \le D(\boldsymbol{\beta}) \le P_{M}(\boldsymbol{\beta}),$$ where $P_{A}(\boldsymbol{\beta})$ and $P_{M}(\boldsymbol{\beta})$ are defined as follows $$P_{A}(\boldsymbol{\beta}) = \displaystyle\sum_{j=1}^{M-1}P(\boldsymbol{\beta}^{T}\mathbf{X}_{j+1}>\boldsymbol{\beta}^{T}\mathbf{X}_{j})/(M-1),$$ and $$ P_{M}(\boldsymbol{\beta}) = \min_{1 \le j \le M-1} P(\boldsymbol{\beta}^{T}\mathbf{X}_{j+1}>\boldsymbol{\beta}^{T}\mathbf{X}_{j}).$$ Instead of maximizing HUM, they proposed to maximize $P_{A}(\boldsymbol{\beta})$ or $P_{M}(\boldsymbol{\beta})$ in order to obtain the optimal combination. For example, maximizing $P_{M}(\boldsymbol{\beta})$ with respect to $\boldsymbol{\beta}$ we obtain $\widehat{\boldsymbol{\beta}}_{Frechet} = \arg \max_{\boldsymbol{\beta} \in B} P_{M}(\boldsymbol{\beta})$ which can be considered as an optimal coefficient vector. The above method is computationally efficient against the direct maximization of HUM as it only considers pairs from the adjacent categories, i.e., binary outcomes. The above method is computationally less time consuming than the HUM when the number of disease categories is more than two. However, when pairwise discrimination among the disease categories are not relevant to the overall discrimination, this method might perform poorly. \section{Step-down Algorithm for Optimization} Step-down algorithm was originally proposed by \cite{pepe2006cai} to combine multiple biomarkers in the context of binary diagnostic outcomes. {The main motivation of using step-down algorithm is its ability to optimize the elements of the $\boldsymbol{\beta}$ vector sequentially one at a time instead of attempting to optimize them simultaneously. \cite{kang2013} formalized the step-down algorithm in the context of three-category diagnostic outcomes. Recently \cite{hsu2016chen} used this algorithm to maximize upper or lower bound of HUM and obtained an optimal linear coefficient estimates. The algorithm to maximize a criteria function (e.g., SHUM) goes as follows:} \begin{itemize} \item[{\bf Step 1.}] Compute the SHUM for each individual $d$ biomarkers {using one at a time} and {arrange covariates in decreasing order} with respect to the computed SHUM values {such that $X_{(1)}$ and $X_{(d)}$ have the highest and the lowest individual SHUM values respectively.}. \item[{\bf Step 2.}] {Choose the first two biomarkers with the highest SHUM values and combine them as $V_2=X_{(1)} + \lambda_2 X_{(2)}$.} \item[{\bf Step 3.}] {Maximize the SHUM for the combined marker $V_2$ w.r.t. $\lambda_2$ and obtain $\widehat{V}_2 = X_{(1)} + \widehat{\lambda}_2 X_{(2)}$.} \item[{\bf Step 4.}] {For $i = 3,\ldots,d$ construct $V_i = \widehat{V}_{i-1}+\lambda_i X_{(i)}$ and maximize $V_i$ w.r.t. $\lambda_i$ and obtain $\widehat{\lambda}_i$.} \end{itemize} Thus at the end of step 4, the estimated optimal combination $\widehat{V}_d = X_{(1)} + \widehat{\lambda}_2 X_{(2)} + \cdots + \widehat{\lambda}_d X_{(d)}$ is obtained. Although this algorithm has been widely used to maximize empirical HUM for binary and three-category cases, here we mainly use a gradient-decent based algorithm, namely quasi-Newton method to maximize all the stepwise SHUM values. We implement the numerical method using the in-built function {\tt optim} in the {\tt R} software freely available in {\tt www.cran.org}. \section{Simulation Study} To compare the performance of the proposed method with the existing methods, we perform experiments based on various simulation scenarios. We consider three biomarkers and three-category ordinal outcome $Y \in \{0, 1, 2\}$, such that higher values of biomarkers represent higher disease category. To explore the performance of the methods under different case scenarios, we consider three examples based on normal distribution (with different correlation structure) and one based on Weibull distribution to represent the non-normal and skewed family. {\bf Scenario 1 :} For the $i$-th category, the values of the biomarkers are simulated from three dimensional normal distributions with mean vector $\boldsymbol{\mu}_{i}$, and common variance covariance matrix as identity $\Sigma=\mathbf{I}$; $i=0,1,2$. We set the parameter values as $\boldsymbol{\mu}_{0}=(0, 0, 0)^{T}$, $\boldsymbol{\mu}_{1}=(1.0, 1.1, 1.2)^{T}$, and $\boldsymbol{\mu}_{2}=(2.0, 2.2, 2.4)^{T}$ for categories $i=0,1,2$, respectively. Since the correlation matrix is considered to be identity with normal distributions, the biomarkers are independent to each other. {\bf Scenario 2 :} In the second scenario, the mean vectors are same as in Scenario 1, however the covariance matrix $\Sigma=((\sigma_{st}))$ is such that all the diagonal elements are 1, i.e, $\sigma_{ss}=1$; and all the off-diagonal elements are 0.2, i.e., $\sigma_{st} = 0.2, s\ne t$; $s,t=1,2,3$. This variance covariance matrix is an example of exchangeable matrix. Since all the off-diagonal elements are non-zero and equal, therefore the biomarkers are correlated. {\bf Scenario 3 :} In the third scenario, the mean vectors are same as the previous scenarios. The covariance matrix has an AR(1) form, i.e., all the diagonal elements are 1; and the off-diagonal elements are set as $\sigma_{st} = 0.2^{|s-t|},\; s\ne t$; $s,t=1,2,3$. Here all the mutual correlations are non-zero but it fades as the distance between two biomarkers increases. {\bf Scenario 4 :} In the fourth scenario, values of the biomarkers are simulated from Weibull distribution. Specifically, the $j$-th biomarker from the $i$-th disease category follows a Weibull distribution with shape parameter $k_j$ and scale parameter $\lambda_i$ and the probability density function is given by \begin{eqnarray*} f(x; k_j, \lambda_i) &=& \begin{cases} \dfrac{k_i}{\lambda_i} \left(\dfrac{x}{\lambda_i}\right)^{k_j-1} \exp(-(\frac{x}{\lambda_j})^{k_j}) & \qquad x>0, \\ 0 & \qquad x \le 0, \end{cases} \end{eqnarray*} $i=0,1,2$ and $j=1,2, 3$. Values of the shape parameter $k$ and scale parameter $\lambda$ are set as $(k_1, k_2, k_3)=(0.5,1,1.5)$ and $(\lambda_1, \lambda_2, \lambda_3)=(1,2,3)$, respectively. Here, we assume that biomarkers are independently distributed. This case corresponds to non-normal and skewed distribution. \subsection{Performance Evaluation} For each of the above-mentioned scenarios, we considered three sample sizes $n=60, 90, 120$. Performance of the proposed SSHUM and NSHUM methods are compared with the existing methods, namely the empirical method (\cite{zhang2011li}), the Frechet bounds method (\cite{hsu2016chen}), the parametric method (\cite{zhang2010thesis}) and the Min-Max method (\cite{liu2011min}). Using all these methods, we first estimated the optimal coefficient vector $\boldsymbol{\beta}$ and then calculated the maximized HUM values at those solutions. The above procedure was repeated for 500 times to obtain the mean and standard error of the optimal solutions of $\boldsymbol{\beta}$ and the corresponding HUM $D_{E}(\boldsymbol{\beta})$. The mean and standard errors of HUM for different methods are reported in Table \ref{tab-simu-hum}, whereas those values for the coefficient vector are reported in Table \ref{tab-simu-beta}. Under all the above scenarios, the proposed SSHUM and NSHUM methods outperform the other existing approximation methods. Under the first three scenarios where biomarkers' values are generated from normal distributions, the SSHUM and NSHUM methods performs as good as the parametric method in Section 3.1 and outperform the Frechet bounds method and Min-Max method. In Scenario 4 where biomarkers' values are non-normally distributed, the parametric method with normality assumption performs poorly than the proposed methods. However, there is no observable difference in the accuracy measure between the SSHUM and NSHUM methods, suggesting both the sigmoid and the normal CDF approximations perform equally good for non-normal distributions. \begin{table}[ht] \caption{Means and standard errors (in parenthesis) of obtained EHUM values at the optimal coefficient vector estimated using the methods: the Empirical method (\cite{zhang2011li}), the Fr\'echet bounds method (\cite{hsu2016chen}), the parametric method (\cite{zhang2010thesis}), the Min-Max method, SSHUM and NSHUM for simulation Scenarios 1, 2, 3, 4 with sample sizes $(60,60,60), (90,90,90), (120,120,120)$, based on 1000 repetitions. } \centering \scalebox{0.8}{ \begin{tabular}{l c c c c c c} \hline \hline ($n_1$, $n_2$, $n_3$) & Empirical & Min-Max & Parametric & Fr\'echet & SSHUM & NHSUM \\ \hline \multicolumn{7}{c}{{\bf Scenario} 1 (True HUM=0.833)} \\ \hline (60, 60, 60) & 0.824 (0.032) & 0.804 (0.035) & 0.826 (0.032) & 0.813 (0.034) & 0.828 (0.033) & 0.828 (0.033) \\ (90, 90, 90) & 0.825 (0.026) & 0.805 (0.028) & 0.827 (0.027) & 0.815 (0.026) & 0.827 (0.026) & 0.827 (0.026) \\ (120, 120, 120) & 0.824 (0.022) & 0.804 (0.023) & 0.825 (0.022) & 0.813 (0.022) & 0.825 (0.022) & 0.825 (0.022) \\ \hline \multicolumn{7}{c}{{\bf Scenario} 2 (True HUM=0.720)} \\ \hline (60, 60, 60) & 0.747 (0.039) & 0.734 (0.039) & 0.752 (0.039) & 0.744 (0.039) & 0.754 (0.039) & 0.754 (0.039) \\ (90, 90, 90) & 0.748 (0.032) & 0.735 (0.032) & 0.750 (0.031) & 0.744 (0.032) & 0.752 (0.031) & 0.752 (0.031) \\ (120, 120, 120) & 0.749 (0.026) & 0.736 (0.027) & 0.751 (0.026) & 0.745 (0.027) & 0.752 (0.026) & 0.752 (0.026) \\ \hline \multicolumn{7}{c}{{\bf Scenario} 3 (True HUM=0.770)} \\ \hline (60, 60, 60) & 0.766 (0.037) & 0.752 (0.038) & 0.770 (0.037) & 0.756 (0.039) & 0.773 (0.037) & 0.773 (0.037) \\ (90, 90, 90) & 0.767 (0.030) & 0.753 (0.031) & 0.769 (0.031) & 0.756 (0.031) & 0.771 (0.030) & 0.771 (0.030) \\ (120, 120, 120) & 0.769 (0.026) & 0.754 (0.026) & 0.770 (0.026) & 0.758 (0.026) & 0.771 (0.026) & 0.772 (0.026) \\ \hline \multicolumn{7}{c}{{\bf Scenario} 4 (True HUM=0.514)} \\ \hline (60, 60, 60) & 0.452 (0.059) & 0.412 (0.044) & 0.436 (0.057) & 0.391 (0.043) & 0.521 (0.045) & 0.521 (0.046) \\ (90, 90, 90) & 0.474 (0.051) & 0.412 (0.036) & 0.425 (0.058) & 0.391 (0.038) & 0.515 (0.036) & 0.515 (0.036) \\ (120, 120, 120) & 0.484 (0.046) & 0.411 (0.031) & 0.420 (0.047) & 0.392 (0.033) & 0.512 (0.031) & 0.512 (0.031) \\ \hline \hline \end{tabular}\label{tab-simu-hum} } \end{table} \begin{table}[htb] \caption{Means (biases and standard errors) of $(\beta_{1}, \beta_{2})^{T}$ (based on 1000 replications) by different methods for {Scenario} 1. All the methods were maximized using Quasi-Newton method.} \centering \scalebox{0.65}{ \begin{tabular}{lc cc c c c } \hline \hline Sample size & $(\beta_{1}, \beta_{2})^{T}$ & Empirical & Parametric & Fr\'echet & SSHUM & NSHUM \\ \hline \multicolumn{7}{c}{{\bf Scenario} 1} \\ \hline $n=(60,60,60)$ & 1.2 & 1.045 (-0.155, 0.179) & 1.230 (0.030, 0.294) & 1.995 (0.795, 0.067) & 1.275 (0.075, 0.367) & 1.308 (0.108, 0.377) \\ & 1.1 & 1.018 (-0.082, 0.170) & 1.124 (0.024, 0.284) & 1.990 (0.890, 0.070) & 1.182 (0.082, 0.382) & 1.215 (0.115, 0.384) \\ \hline $n=(90,90,90)$ & 1.2 & 1.050 (-0.15, 0.125) &1.230 (0.030, 0.229) &1.998 (0.798, 0.062) &1.274 (0.074, 0.297) &1.282 (0.082, 0.311)\\ & 1.1 & 1.010 (-0.09, 0.113) &1.125 (0.025, 0.219) &1.990 (0.890, 0.062) &1.175 (0.075, 0.289) &1.178 (0.078, 0.299)\\ \hline $n=(120,120,120)$ & 1.2 &1.074 (-0.126, 0.135) &1.219 (0.019, 0.200) &1.994 (0.794, 0.059) &1.256 (0.056, 0.238) &1.258 (0.058, 0.246)\\ & 1.1 &1.013 (-0.087, 0.114) &1.117 (0.017, 0.184) &1.973 (0.873, 0.092) &1.144 (0.044, 0.215) &1.148 (0.048, 0.224)\\ \hline \hline \multicolumn{7}{c}{{\bf Scenario} 2} \\ \hline $n=(60,60,60)$ & 1.378 &1.059 (-0.320, 0.180) &1.502 (0.124, 0.557) &2.000 (0.622, 0.066) &1.628 (0.25, 0.657) &1.670 (0.292, 0.658) \\ & 1.189 &1.006 (-0.183, 0.139) &1.291 (0.102, 0.503) &1.994 (0.805, 0.068) &1.399 (0.21, 0.616) &1.446 (0.257, 0.598) \\ \hline $n=(90,90,90)$ & 1.378 &1.086 (-0.293, 0.218) &1.457 (0.079, 0.447) &2.003 (0.625, 0.087) &1.546 (0.168, 0.549) &1.577 (0.198, 0.526) \\ & 1.189 &1.019 (-0.170, 0.174) &1.259 (0.070, 0.395) &1.986 (0.797, 0.081) &1.337 (0.148, 0.484) &1.369 (0.180, 0.479) \\ \hline $n=(120,120,120)$ & 1.378 &1.111 (-0.267, 0.237) &1.414 (0.036, 0.338) &2.006 (0.628, 0.102) &1.474 (0.096, 0.411) &1.485 (0.107, 0.409) \\ & 1.189 &1.025 (-0.164, 0.185) &1.216 (0.027, 0.307) &1.977 (0.788, 0.132) &1.272 (0.082, 0.381) &1.282 (0.093, 0.382) \\ \hline \hline \multicolumn{7}{c}{{\bf Scenario} 3} \\ \hline $n=(60,60,60)$ & 1.256 &1.058 (-0.199, 0.167) & 1.299 (0.042, 0.345) &2.011 (0.754, 0.246) &1.400 (0.144, 0.490) &1.446 (0.189, 0.515) \\ & 0.903 &0.964 ( 0.062, 0.137) & 0.947 (0.044, 0.323) &1.983 (1.081, 0.068) &1.032 (0.130, 0.435) &1.086 (0.183, 0.471) \\ \hline $n=(90,90,90)$ & 1.256 &1.102 (-0.154, 0.255) & 1.292 (0.036, 0.284) &2.003 (0.746, 0.073) &1.338 (0.082, 0.350) &1.362 (0.106, 0.370) \\ & 0.903 &0.957 ( 0.054, 0.206) & 0.932 (0.029, 0.253) &1.977 (1.075, 0.086) &0.974 (0.071, 0.318) &0.993 (0.091, 0.346) \\ \hline $n=(120,120,120)$ & 1.256 &1.122 (-0.135, 0.189) & 1.284 (0.028, 0.240) &2.005 (0.748, 0.089) &1.324 (0.067, 0.301) &1.328 (0.071, 0.319) \\ & 0.903 &0.940 ( 0.038, 0.144) & 0.917 (0.015, 0.224) &1.965 (1.062, 0.105) &0.948 (0.045, 0.277) &0.951 (0.048, 0.291) \\ \hline \hline \multicolumn{7}{c}{{\bf Scenario} 4} \\ \hline $n=(60,60,60)$ & 0.047 & 0.695 (0.648, 0.368) & 0.964 (0.917, 0.927) & 1.960 (1.913, 0.233) & 0.089 (0.042, 0.091) & 0.100 (0.053, 0.130) \\ & 0.456 & 1.028 (0.571, 0.538) & 3.237 (2.781, 4.707) & 3.894 (3.437, 41.735) & 0.530 (0.074, 0.225) & 0.563 (0.107, 0.276) \\ \hline $n=(90,90,90)$ & 0.047 & 0.440 (0.393, 0.387) & 1.031 (0.984, 0.817) & 1.641 (1.594, 8.895) & 0.079 (0.032, 0.055) & 0.080 (0.033, 0.061) \\ & 0.456 & 0.925 (0.469, 0.359) & 2.450 (1.993, 1.572) & 2.324 (1.868, 8.906) & 0.505 (0.049, 0.159) & 0.513 (0.056, 0.171) \\ \hline $n=(120,120,120)$ & 0.047 & 0.306 (0.259, 0.345) & 1.173 (1.126, 1.059) & 1.888 (1.841, 0.308) & 0.073 (0.025, 0.046) & 0.073 (0.026, 0.046) \\ & 0.456 & 0.838 (0.382, 0.344) & 2.548 (2.091, 1.893) & 2.020 (1.564, 0.406) & 0.492 (0.036, 0.140) & 0.494 (0.037, 0.144) \\ \hline \hline \end{tabular}\label{tab-simu-beta} } \end{table} \section{Real Data Analysis} \subsection{{The Alzheimer's Disease Data Analysis}} The first data set that we analyzed here for illustration is a subset of the longitudinal cohort data on Alzheimer's Disease (AD) from Alzheimer's Disease Research Center (ADRC) at Washington University. The dataset is available in the R package \texttt{DiagTest3Grp} ({\it https://www.cran.org}). In this data set, measurements of 14 neuro-psychological markers were collected from 118 independent individuals of age 75 among which 44 individuals were non-demented, 43 were very mildly demented, and 21 individuals were mildly demented. It is now commonly accepted that treatment for Alzheimer's disease is a rather complicated issue and more clinically useful strategy is to apply appropriate interventions for earlier stage patients with relatively mild conditions (\cite{Dubois2014},\cite{Dubois2016}). Therefore it is meaningful to differentiate three or even more categories of patients with ascending disease severity and subsequently offer category-specific treatments. Due to some missing observations, we deleted 10 individuals from the data set for our analysis. Note that values of these fourteen biomarkers can be negative. Furthermore, as we can see from the boxplot in Figure \ref{fig-boxplot-AL} and density plot in \ref{fig-density-AL}, there is a clear decreasing trend in the distributions of all the fourteen neuro-psychological markers across the dementia status. This shows the potential discrimination power of these individual markers. This observation was further evident by their individual discrimination power in terms of EHUM values where \textit{factor1}, \textit{ktemp} and \textit{zpsy004} have the highest individual EHUM values ranging from 0.70 to 0.78. Even the lowest EHUM values for the individual markers lie above 0.3, clearly much larger than the lowest EHUM value for random guess which is 0.17 in this case. To see the improvement in discrimination accuracy by combing these individual markers over the individual markers and to facilitate comparison, we employed all the six combining methods discussed in Section 3. The estimated EHUM values with their respective standard errors using all the six methods are reported in Table \ref{tab-AL3} along with the coefficient parameter estimates and their respective bootstrap standard errors. We note that the empirical method has the highest EHUM value of 0.832 which is a substantive improvement than the highest individual biomarker's EHUM value of 0.784. The SSHUM method has the second largest EHUM value of 0.828, also a substantive improvement over the individual biomarkers. However, as we can see the Min-Max and Naive method (where we assumed equal weight for each individual biomarkers) have the lowest EHUM values of 0.80 and 0.792, respectively. National Institute of Aging-Alzheimer's Association (NIA-AA) published research criteria for AD diagnosis in 2011 using biomarkers information. In addition to dementia due to AD, other stages of interest include prodromal AD (mild cognitive impairment) and preclinical AD (individuals with normal condition with AD pathology). The markers evaluated in our analysis may also offer useful insight for such mutli-stage diagnosis. \begin{figure}[ht] \centering \includegraphics[scale=0.5]{boxplot_AL} \caption{Boxplot for individual and combined biomarkers for Alzheimer data set.} \label{fig-boxplot-AL} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.5]{densityplot_AL} \caption{Density plot for individual and combined biomarkers for Alzheimer data set.} \label{fig-density-AL} \end{figure} \begin{table}[ht] \caption{Empirical HUM values (with bootstrap standard errors) for the individual biomarkers for the AKI and Alzheimer data sets.} \centering \scalebox{0.7}{ \begin{tabular}{cc | cc} \hline \multicolumn{2}{c}{Alzheimer data} & \multicolumn{2}{c}{ERICCA data} \\ \hline Individual biomarkers & HUM (se) & Individual biomarkers & HUM (se) \\ \hline FACTOR1 & 0.774 (0.056) & NGAL 0 hours & 0.179 (0.029) \\ ktemp & 0.784 (0.055) & NGAL 6 hours & 0.222 (0.034) \\ kpar & 0.600 (0.065) & NGAL 12 hours & 0.273 (0.040) \\ kfront & 0.654 (0.059) & NGAL 24 hours & 0.315 (0.042) \\ zpsy004 & 0.718 (0.058) & & \\ zpsy005 & 0.316 (0.064) & & \\ zpsy006 & 0.442 (0.069) & & \\ zinfo & 0.643 (0.065) & & \\ zbentc & 0.506 (0.060) & & \\ zbentd & 0.144 (0.047) & & \\ zboston & 0.590 (0.066) & & \\ zmentcon & 0.367 (0.065) & & \\ zworflu & 0.561 (0.066) & & \\ zassc & 0.648 (0.066) & & \\ \hline \end{tabular}\label{tab-AL1} } \end{table} \begin{table}[htb] \caption{{Estimated coefficients and the HUM values (with standard errors in parenthesis) for the Alzheimer's disease data using Naive method, Empirical, SSHUM, NSHUM, Fr\'echet, Parametric and Min-max methods based on 100 repetitions.}} \centering \scalebox{0.6}{ \begin{tabular}{c c c c c c c c} \hline \hline Biomarkers& $\beta_{Naive}$ & $\beta_{Empirical}$ & $\beta_{SSHUM}$ & $\beta_{NSHUM}$ & $\beta_{Frechet}$ & $\beta_{Parametric}$ & $\beta_{Min-Max}$ \\ \hline FACTOR1 & 0.267 & 0.437 (0.2056) & -0.092 (0.2457) & 0.431 (0.2235) & 0.192 (0.2064) & -0.032 (0.2235) & - \\ ktemp & 0.267 & 0.117 (0.1613) & 0.233 (0.1332) & 0.155 (0.1218) & 0.192 (0.1564) & 0.203 (0.1774) & - \\ kpar & 0.267 & 0.154 (0.1379) & 0.261 (0.1278) & 0.229 (0.1389) & 0.161 (0.1526) & 0.019 (0.2000) & - \\ kfront & 0.267 & -0.005 (0.1590) & -0.006 (0.1577) & -0.030 (0.1628) & 0.343 (0.1713) & 0.232 (0.1860) & - \\ zpsy004 & 0.267 & 0.685 (0.1953) & 0.447 (0.0986) & 0.433 (0.0911) & 0.667 (0.2171) & 0.495 (0.2301) & - \\ zpsy005 & 0.267 & 0.173 (0.1604) & 0.063 (0.1683) & 0.071 (0.1381) & 0.192 (0.1909) & 0.082 (0.2191) & - \\ zpsy006 & 0.267 & 0.180 (0.1841) & 0.402 (0.1270) & 0.318 (0.1263) & 0.192 (0.1915) & 0.423 (0.2071) & - \\ zinfo & 0.267 & -0.283 (0.2664) & -0.447 (0.1730) & -0.433 (0.2389) & -0.073 (0.2699) & -0.244 (0.2657) & - \\ zbentc & 0.267 & -0.043 (0.1905) & 0.268 (0.1697) & 0.063 (0.1599) & -0.262 (0.2033) & 0.249 (0.2205) & - \\ zbentd & 0.267 & 0.007 (0.2093) & -0.401 (0.2179) & -0.291 (0.2478) & 0.001 (0.2293) & -0.067 (0.2403) & - \\ zboston & 0.267 & 0.173 (0.1983) & -0.128 (0.1641) & 0.183 (0.1662) & 0.000 (0.2045) & 0.303 (0.2149) & - \\ zmentcon & 0.267 & 0.235 (0.2564) & 0.139 (0.1466) & 0.288 (0.1462) & -0.196 (0.2704) & -0.377 (0.2172) & - \\ zworflu & 0.267 & -0.192 (0.2175) & -0.138 (0.1899) & 0.021 (0.1797) & -0.065 (0.2387) & 0.326 (0.2352) & - \\ zassc & 0.267 & -0.189 (0.2580) & -0.125 (0.2503) & -0.222 (0.2379) & 0.384 (0.2838) & -0.079 (0.2395) & - \\ \hline HUM & 0.792 & 0.832 (0.0545) & 0.874 (0.0179) & 0.849 (0.0177) & 0.812 (0.0614) & 0.817 (0.0584) & 0.800 (0.0509) \\ \hline \end{tabular}\label{tab-AL3} } \end{table} \subsection{The ERICCA data analysis} Here we analyze an acute kidney injury dataset following a heart surgery to illustrate our proposed method. We consider the data from the {\bf E}ffect of {\bf R}emote {\bf I}schemic Preconditioning on {\bf C}linical Outcomes in Patient Undergoing {\bf C}oronary {\bf A}rtery Bypass Graft Surgery (ERICCA) trial where a group of 1612 patients participated in a cardiovascular surgery and were observed for one year after the surgery (\cite{hausenloy2012,hausenloy2015}). All the patients were randomized to two different methods of surgeries namely Remote Ischemic Conditioning (RIC) or Sham Preconditioning. During the study period, some patients developed a disease called Acute Kidney Injury (AKI) along with few other diseases post-surgery. The AKI was recorded as a multi-category ordinal outcome with four levels based on the severity level. The data also includes cardiovascular death and all-cause mortality at 1 year (binary), non-fatal Myocardial Infarction (MI) (binary) and coronary revascularization or stroke at 1 year (binary). In literature, studies on prediction of AKI after cardiac surgery has been performed in several occasions. Assuming AKI as a binary outcome, \cite{heeraj2017} found that the serum Neutrophil Gelatinase Associated Lipocalin (NGAL) measurements taken at 0 (before surgery), 6, 12 and 24 hours after surgery are significant influential biomarkers in the development of AKI. In addition, they showed that for the risk-stratification of patients prior to cardiac surgery for AKI may be improved by adding pre-oprative levels of NGAL to existing risk scores where existing risk score was calculated based on age, gender, diabetes mellitus, hypertension, peripheral vascular disease, previous Coronary Artery Bypass Graft type of surgery planned, use of intra-aortic ballon pump and few other baseline covariates. However, the main limitation of their study is that they did not consider the multiple categories of the AKI outcome. Instead, they converted it to binary outcome where level 0 stands for no AKI and level 1 stands for any of the 1,2,3 levels of AKI in the data. To illustrate the proposed method, we consider the AKI within 72 hours of surgery as our multi-category outcome which are leveled as 0 (none), 1, 2, 3 as per the international Kidney Disease: Improving Global Outcomes classification (KDIGO) criteria on serum creatinine. Since level 3 has only a few observations, we combine the levels 2 and 3 into a single category denoted as the highest risk group. Therefore, in the following analysis, the AKI has three levels/categories. Our biomarkers of interest in predicting AKI are individual NGAL at 0 (before surgery), 6, 12 and 24 hours after surgery and their different combinations using different methods. In a previous analysis, \cite{heeraj2017} observed that there is a significant increase in AKI as the individual's pre-operative NGAL increases from the first to the third tertile ($>$220 ng/L). Hence they considered only the individuals from the third tertile and concluded that the pre-operative NGAL is a significant predictor in predicting binary AKI. There are 305 individuals in our sample after discarding all the missing observations. Among these subjects, 172 patients did not develop AKI within the 72 hours of surgery (AKI=0), 99 patients developed level 1 AKI, and 34 developed level 2 (i.e., combined levels 2 and 3 in original scale) AKI. {Note that larger values of the NGAL measurements indicate the higher level of severity of AKI. Since the NGAL measurements are highly skewed-distributed and large in number, so we transformed them into the logarithm scale to scale down those high numbers and make the distributions close to normal distributions. Considering logarithmic transformation of the biomarkers is a common strategy for this type of data analysis (see e.g., \cite{pepe2000thompson}). To see the visual discrimination power of these individual log of NGAL measurements, the box plots and the density plots are shown in Figures \ref{fig-boxplot-ericca} and \ref{fig-density-ericca}, respectively. The estimated empirical HUM values for the individual NGAL at four different time points are 0.179 (at 0 hours), 0.222 (at 6 hours), 0.273 (at 12 hours), and 0.315 (at 24 hours). These values are also reported in Table \ref{tab-AL1}, along with their respective standard error. Recall that for random guess the HUM value is 1/6=0.1667 when the disease outcome variable has three possible outcomes. That is to say HUM value for any biomarker less that 0.1667 indicates that the biomarker is weaker in predicting the disease outcome and should be avoided from the prediction model. In this case, all the NGAL measurements can be included in the prediction model. Further, it is noticed that as the time of NGAL measurement increases from 0 hours to 24 hours, the HUM value increases to almost two times that of the 0 hours. It indicates the strong discrimination power of the NGAL biomarker in predicting AKI as time progresses after surgery. } \begin{figure}[ht] \centering \includegraphics[scale=0.5]{boxplot_ericca} \caption{{Boxplot for individual and combined NGALs for ERICCA data set. The top 4 plots represents the NGAL levels at 0, 6, 12 and 24 hours after the surgery for 3 levels of AKI. Bottom left diagram shows the boxplots for Naive method (i.e., linear combination of covariates with equal positive coefficients) and the bottom right diagram shows the boxplots for SSHUM method.}} \label{fig-boxplot-ericca} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.5]{densityplot_ericca} \caption{Density plot for individual and combined NGALs for ERICCA data set.} \label{fig-density-ericca} \end{figure} Further, we treat the four NGAL measurements as four biomarkers and apply our proposed SSHUM method to combine these markers. As comparison, a naive linear combination approach with equal weights on the four markers is also constructed. The distributions of these combined markers are also displayed in Figures \ref{fig-boxplot-ericca} and \ref{fig-density-ericca}. It is noted that SSHUM separates the three class in the most effective way. Further, we obtain the HUM values for other existing methods along with their respective optimal linear combination estimates. The estimates along with their bootstrap standard errors are reported in Table \ref{tab-AL2}. We note that all the linear combining methods yield larger HUM values than that of the individual biomarkers and the naive equal weight method. The proposed sigmoid approximation yields the highest HUM value compared to the other existing methods. Although the proposed method combines the time-varying NGAL measurements in a more effective way than the others, still further studies may be required to support the effectiveness of such NGAL measurements and their combining factor in predicting AKI. \begin{table}[htb] \caption{{Estimated optimal coefficients and the HUM values (with standard errors in parenthesis) for the ERICCA dataset using naive method, empirical method, SSHUM, NSHUM, Fr\'echet, parametric and Min-Max methods based on 100 repetitions.}} \centering \scalebox{0.6}{ \begin{tabular}{c c c c c c c c} \hline \hline Biomarkers& ${naive}$ & ${Empirical}$ & ${SSHUM}$ & ${NSHUM}$ & ${Frechet}$ & ${Parametric}$ & ${Min-Max}$ \\ \hline NGAL 0 hours & 0.5 & 0.412 (0.2869) & -0.208 (0.3078) & -0.097 (0.3142) & 0.234 (0.0798) & 0.236 (0.3636) & -\\ NGAL 6 hours & 0.5 & -0.050 (0.4074) & -0.660 (0.3201) & -0.387 (0.3196) & -0.382 (0.1083) & 0.593 (0.3659) & - \\ NGAL 12 hours & 0.5 & 0.594 (0.2098) & 0.360 (0.3320) & 0.176 (0.3377) & 0.566 (0.0426) & 0.590 (0.2563) & - \\ NGAL 24 hours & 0.5 & 0.688 (0.1917) & 1.508 (0.2570) & 0.900 (0.2665) & 0.692 (0.0462) & 0.494 (0.1762) & - \\ \hline HUM & 0.281 & 0.317 (0.0154) & 0.326 (0.0140) & 0.325 (0.0135) & 0.312 (0.0054) & 0.287 (0.0182) & 0.303 (0.0079) \\ \hline \end{tabular}\label{tab-AL2} } \end{table} \section{Discussion} Improving diagnostic accuracy by combining multiple biomarkers have been studied both for binary and multi-category outcomes. In this article, we have extended the idea of direct maximization of empirical hyper-volume under manifolds, specifically volume under surface (VUS) proposed by \cite{zhang2011li}, to a smoothing approximation of it using a class of smooth CDFs which is controlled by a tuning parameter. In particular, we have used the logistic CDF (sigmoid function) and normal CDF to operationalize our proposed method. We have also discussed about the choice of the tuning parameter. Consistency and asymptotic normality of the coefficient estimators using the proposed method have been established. Furthermore, through simulation studies we observe that the proposed method is computationally less challenging than the direct maximization of the EHUM, which is non-smooth and non-differentiable. We also note that the performance of the proposed method heavily depends on the choice of the tuning parameter $\lambda$, with lower values of $\lambda$ leading to results very similar to the empirical method with less bias but large variability. This is a problem of bias-variance trade-off which we have discussed in considerable detail in Section 2.3. Results from our simulation study and the two real medical data analyses have shown that shown that in general, the proposed method outperforms other methods including the empirical method. To obtain the estimated coefficient vectors maximizing SHUM, we considered the step-down algorithm. However, in future, coming up with advanced computational aids and fast global optimization algorithms for simultaneous estimation of the whole coefficient vector (instead of estimating one at a time using step-down algorithm) maximizing SHUM might further improve the solutions. \section*{Acknowledgements} We thank Jon Wellner, Palash Ghosh and Heerajnarain Bulluck for helpful discussions. The work was partially supported by grants R-155-000-205-114, R-155-000-195-114, R-155-000-197-112, R-155-000-197-113 and MOE2015-T2-2-056 from the Ministry of Education in Singapore, as well as the start-up grant of Bibhas Chakraborty from Duke-NUS Medical School. \bibliographystyle{wileyj}
{'timestamp': '2019-04-24T02:02:13', 'yymm': '1904', 'arxiv_id': '1904.10046', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10046'}
arxiv
\section{Introduction} There are many situations where a group of autonomous actors---which may be software processes, physical devices, and/or people operating via a platform like a smart-phone---need to interact with each other over the Internet. The members of such a group, who may not trust each other, may be required to interact subject to a given protocol. Such a protocol may represent a contract that binds these actors, or it may be necessary for the actors to collaborate effectively on some common goal, or to compete safely over the use of some resources. We call a group of actors that comply with a given protocol P, a \emph{P-community}, or simply a community. It is sometimes possible to establish a given protocol P over a community by relying on voluntary compliance with it, by all the members of this community. Voluntary compliance can be effective when a community is homogeneous, or when it is relatively small and its members trust each other, or when its members are well managed. But otherwise, for voluntary compliance with a given protocol P to be effective it needs to satisfy the following two conditions, as argued in \cite{min03-7}: (a) it must be the vested interest of every member of the community to comply with P; and (b) a failure to comply with P, by anybody, should not cause any serious harm to anybody else in the given community. And if any one of these conditions is not satisfied, then the given protocol may need to be \emph{enforced}. The enforcement of protocols is the subject of this paper. And we call a mechanism used for enforcing protocols a \emph{protocol enforcement mechanism} or PEM. We start in \secRef{quality} by introducing the set of qualities of a PEM that we consider essential. We continue in \secRef{art} by reviewing two existing realizations of PEM: (a) the currently popular blockchain-based smart-contract mechanism, and (b) the older law-governed interaction (LGI) mechanism introduced by the 1st author---evaluating them in terms of these qualities. We find that each of these mechanisms fails to satisfy some of these qualities. We obtain a PEM that satisfies all these qualities, by extending LGI into what we call \emph{Cop}. Before introducing Cop we outline, in \secRef{LGI}, the LGI mechanism itself, and describe its shortcoming---which we attempt to resolve. The LGI-based Cop mechanism is introduced in \secRef{Cop}, and discussed further in subsequent sections. We conclude in \secRef{conclusion}, and with an appendix in \secRef{append}. \paragraph{A Terminological Comment} In the computer-science literature the concept of protocol is sometimes referred to as a contract, and sometimes as a law. All three terms are being used here in the following way: We use the term ``protocol'' as a general term, when not discussing any particular enforcement mechanism; we use the term ``contract'' when discussing blockchain-based smart-contracts; and we use the term ``law'' when discussing LGI and Cop. \section{The Essential Qualities of Protocol-Enforcement Mechanisms}\label{quality} There is a wide range of types of applications that may benefit from the enforcement of protocols. Such applications differ along several dimensions. Some are small, others may be very large. Some are simple enough to be handled as a single community operating subject to a single protocol, others consist of multiple communities, operating subject to different protocols, which may need to inter-operate in various ways. Some applications are lax about the speed of protocol enforcement, others are time-critical. The actors involved in such applications may include software processes, people, and physical devices (i.e., devices that belong to IoT). One would like to have a single protocol-enforcement mechanism (PEM) which is sufficiently broad-spectrum to support a wide range of potential applications. We identify below four qualities that a PEM should satisfy to be sufficiently broad-spectrum. \begin{enumerate} \item \emph{Sufficiently short latency}: By latency we mean, the time it takes for a PEM to resolve a given transaction\footnote{We use the term ``transaction'' to mean any interactive operation by one of the actors in a given community.}. The maximal latency that a given application may require varies widely. It may, for example, be of the order of a few minutes for many commercial and financial systems. But it may be of the order of milliseconds or less for the so-called \emph{time-critical} applications---such as a collection of interacting physical machines operating in an industrial plant, or the components of an airborne control system interacting with each other. \item \emph{Scalability:} By scalability we mean here that the latency is virtually independent of the volume and frequency of transactions in a given system. Scalability is a challenge to large systems, such as enterprise systems, and to infrastructures such as air-traffic control systems. It is also a challenge to financial systems such as the one described in \cite{bla18-1}, where "a reasonable estimate of [its] peak figure may be in the region of several thousand transactions per second." \item \emph{Interoperability:} By interoperability we mean: the ability of communities that operate subject to different protocols to interact with each other. Of course, such an ability needs to be subject to regulation. That is, there needs to be a way to control which communities can interact with each other, and how. Interoperability is required, in many situations. In particular, when different small businesses, each operating under its own protocol, need to interact with each other. Moreover, complex systems, such as enterprise systems, cannot be governed by a single protocol. Rather, different communities of actors that belong to the same system, but engaged in different types of activities, would be required to operate subject to different protocols. And such communities often need to interact with each other. Therefore, a PEM needs to support multi-community systems, where different communities, operating under different protocols, need to be able to interact, subject to some constraints. Moreover, as we have shown \cite{min18-1}, effective modularity of the set of protocols, that thus govern a complex system, can be achieved by organizing them into the so-called \emph{conformance hierarchies}. \item \emph{Dependability and Security}: By this we mean the degree to which a PEM can defend itself against failures and programming errors (dependability) and against attacks (security). Dependability and security are, of course, critical for many applications. \end{enumerate} \noindent It is worth pointing out that the satisfaction of any of these qualities is not a zero/one predicate, so our objective is a \emph{substantial} satisfaction of these qualities. \section{On the State-of-the-Art of Protocol Enforcement Mechanisms}\label{art} In the following two sub-sections we consider two existing protocol-enforcement mechanisms mentioned in the introduction, evaluating them in terms of the qualities described above, and finding both of them wanting. \subsection{The Blockchain-based Smart-Contract Mechanism} This type of mechanisms---which was inspired by a 1997 paper \cite{sza97-1} by Nick Szabo---became very popular recently, mostly for financial and commercial applications (see \cite{pet16-1}). The main characteristic of smart-contracts is that the enforcement of contracts is carried out over a \emph{blockchain}, which provides this mechanism with a high level of security. But smart-contracts do not satisfy well the other three qualities listed above. First, the latency of a smart-contract cannot be shorter than the time in takes to reach consensus---a fundamental element of blockchains. And this latency is quite substantial--it is currently of the order of a few minutes under the various implementations of smart-contract, and it probably cannot be made much shorter than a few seconds. This means that smart-contracts \emph{cannot be used for many time-critical applications}. Second, the smart-contract mechanism is not scalable, as is frequently admitted by many researchers and developers of such systems. And although many, like \cite{vuk17-1}, are working on reducing the level of unscalability, the lack of scalability is inherent in the blockchain-based smart-contract mechanisms. This is because, despite the distributed nature of the consensus, regarding which block to admit to the various copies of the blockchain, the enforcement itself is essentially centralized, and linear, for the following reason: A new block cannot be admitted to the blockchains, without sacrificing security, before the previous block is resolved. Now suppose that it takes $T$ seconds to select a block (via a distributed consensus mechanism), to be admitted into the distributed blockchain, and to be resolved according to the contract at hand; and suppose that the average number of transaction that can be included in a block is $B$. Now, if more than $B$ new transactions arrive, on average, to the blockchain in $T$ seconds, then the length of the queue of transactions waiting to be processed will increase linearly in time. And the latency will increase, proportionally with the length of the queue. So, such a mechanism is inherently unscalable. Third, blockchain-based smart-contracts cannot handle really complex systems, such as federated enterprises, supply chain, and health-care systems. Such systems are composed of many different communities operating under different interdependent contracts which often need to inter-operate. But despite some recent attempts to make blockchains interoperate, such as by the Cosmos project, none of them provides a practical and general solution to this problem. The Cosmos project, in particular, features a hub blockchain involved in all interoperations. And it seems to us that the use of such a hub would decrease the scalability and the security of smart-contracts. \subsection{The Law-Governed Interaction (LGI) Mechanism:} This mechanism, which is discussed in some detail in \secRef{LGI}, satisfies most of the qualities we required in \secRef{quality}. This includes very short latency, high level of scalability, and a very general concept of controllable interoperability. But although LGI is reasonably secure---arguably more secure than the centralized access control mechanisms---LGI has a serious security weakness described in \secRef{heel}, which this paper aims to resolve. We sometime refer to this weakness of the security of LGI as its \emph{Achilles heel}. \section{An Outline of LGI, and its \emph{Achilles Heel}}\label{LGI} This section is an outline of the LGI mechanism, which should suffice for the understanding of the rest of this paper. But for a deeper and more detailed description of LGI, we propose two, somewhat dated, sources: (a) a Journal paper \cite{min99-5}; and (b) the manual of LGI \cite{min05-8}. We confine ourselves here to the treatment of a single community of actors that are supposed to interact with each other subject to a common LGI-law \EL---such a community is called an \EL-community, and we occasionally refer to it as $C$. The enforcement of an LGI-law is strictly \emph{decentralized}, as follows: Each member $a$ of $C$ interacts with other members of $C$ via a private surrogate (called a \emph{controller}) that enforces law \EL\ over the interactive activities of $a$. Such an enforcement is done \emph{locally}, with no knowledge of, or dependency on, anything that happens simultaneously at the surrogates of other members of $C$. (This locality is the consequence of the nature of laws, as we shall see below). So, the enforcement of a law \EL\ over the interactive activities of members of the \EL-community is done in a decentralized manner, and thus in parallel, by the various surrogates of the members of $C$. This enforcement is very efficient, and inherently scalable. The rest of this section is organized as follows: \secRef{cos} describes the service that provides actors with the controllers that can serve as their surrogates; \secRef{creation} describes how a given actor can become a member of the \EL-community, for a given law \EL; \secRef{law} outlines the structure of LGI-laws; \secRef{examples} introduces two simple examples of laws; \secRef{beyond} points out that LGI can handle far more complex systems than is implied by the single community discussed so far. Finally, \secRef{heel} discusses the security vulnerability of LGI, which is what this paper is intended to relieve. \subsection{A Trustworthy Controller-Service (CoS)}\label{cos} LGI require the availability of a set of authentic generic controllers that are trusted to operate as surrogates of arbitrary actors, subject to any well formed LGI-law selected by them. Such a generic controller is denoted by $T$, which suggests that it needs to be trusted to enforce correctly any LGI-law loaded into it. A controller operating under a given law \EL\ is called an \EL-controller, and is denoted by \Tla{L}{}. There are several ways for supplying such generic controllers. One of this is to create a \emph{controller service} (CoS) that maintains set of authentic controllers, and leases them to its customers, presumably for a fee. The CoS can use various techniques for guarding against corruption of controllers. In particular it can use the TPM (Trusted Platform Module) technology, or some more recent variant of it. This is particularly easy to do because all generic controllers have identical codes, which would have a single and stable hash. To be trustworthy, a CoS must be managed by a highly reputable organization, which can vouch for the authenticity of its controllers. Moreover, the CoS should provide each of its controllers with a digital certificate signed by the CoS itself. This certificate is used by the controllers to authenticate themselves as genuine LGI-controllers. The CoS is the trusted computing base (TCB) of LGI. \subsection{The Concept of an \EL-Agent, and the Formation of an \EL-Community}\label{creation} \subsubsection{An \EL-agent and its formation} Any actor $a$ can attempt to operate under a given law \EL, thus joining the \EL-community. It can do so by performing the following two steps: (i) acquiring a generic controller $T$ from the CoS; and (ii) adopting this controller to be its surrogate, subject to law \EL. If the adoption of a controller $T$ subject to law \EL\ is successful, then this controller would be denoted by \Tla{L}{a}, which means that $T$ now operates as the surrogate of $a$, subject to law \EL. Now, the pair $ \langle a, T^{\mathcal{L}}_{a} \rangle,$ is called an \EL-\emph{agent}, which is denoted by $\overline{a}$. The mediator \Tla{L}{a} is called the \emph{private controller} (or simply the controller) of agent $a$, and the actor $a$, whose internal structure is irrelevant to this model, is said to \emph{animate} agent $\overline{a}$. But note that the attempt of $a$ to form an \EL-agent may fail, because law \EL\ may refuse to allow $a$ to do so. For example, law \EL\ may require a password, or a certificate, to be submitted by $a$ in its adoption command. This would prevent any actor that cannot authenticate itself in the manner required by law \EL\ from operating as a member of the \EL-community. \begin{figure} \leavevmode \epsfysize=1.0 in \epsfxsize=4.5 in \centerline{\epsffile{agent1.eps}} \caption{\emph{A pair of interacting agents, operating under possible different laws} } \label{fig-agent} \end{figure} \subsubsection{The Dual Mediation of Communication Under LGI}\label{ss-dual} One of the significant aspects of LGI is that it involves dual mediation of every exchange of messages between LGI-agents: one on the side of the sender of a message, and one on the side of its receiver. Specifically, the passage of a message from an actor $A_x$ of an \EL-agent $x$ to an actor $A_y$ of an \CAL{L'}-agent $y$, must be mediated first by the controller \Tla{L}{x} associated with $A_x$, and then by the controller \Tla{L'}{y}, associated with $A_y$, as is illustrated in Figure~\ref{fig-agent}. This is a direct consequence of the locality of LGI-laws, which requires both the sender and receiver to individually comply with the law under which each of them operates. The dual mediation under LGI has several important implications, not the least of which is that it facilitates interoperability by providing flexible control over cross-interaction between agents operating under different laws, as is further discussed in \secRef{beyond}. Moreover, as has been shown in \cite{min99-5}, the dual control turns out to be more efficient than centralized control, in many circumstances. A simple illustration of the nature of dual mediation, and some of its consequences, is provided by the example laws on \secRef{examples}. \subsubsection{On the Formation of an \EL-Community} An \EL-community is created simply by the creation of the first \EL-agent by some actor $a$. No special initialization of an \EL-community is required. And the membership of such a community evolves incrementally, by the creation or destruction of \EL-agents. The structure and dynamic behavior of such a community, which depends on the nature of its law, is explored in \cite{min00-3}. \subsection{The Concept of Law Under LGI}\label{law} An LGI-\emph{law} \EL\ is formulated in terms of three elements, defined with respect to a given \EL-controller $x$. The following is an incomplete description of these elements: (1) A set $E$ of \emph{regulated events} (or, simply, \emph{events}) that may occur at $x$. $E$ includes, among others: (a) the \emph{adoption} of this controller, under a given law \EL---which is the first event that occurs at $x$. (b) The arrival of a message at $x$, and the sending of a message by it. Note that a message may arrive at $x$ mostly from three sources: (i) from another controller; (ii) from the actor that adopted $x$; and (iii) as a result from some \emph{exception-condition}, which is reported to $x$ via a message. And (3) an event called \emph{obligationDue} that has to do with the pro-active capability if LGI. This type of events discussed in \secRef{oblig}. (2) The \emph{state} $S_x$ of controller $x$, which is distinct from the internal state of the actors that uses $x$ as its surrogate---of which the law is oblivious. The state $S_x$ is an unbounded (but often small) set of terms, whose structure is left unspecified here. (3) A set $O$ of \emph{operations} that can be mandated by a law, to be carried out by the controller $x$ upon the occurrence of a regulated events at it. The set $O$ includes, among others: (a) replacing the state $S_x$ of $x$ with another state (or, if you will, changing the state $S_x$); and (b) sending some messages, to anybody on the Internet. (Note that the sending of a message by $x$, as mandated by the law, would constitute a new event at $x$.) Now, the role of a law is to decide what should be done in response to the occurrence of any regulated event at a controller operating under it. This decision, with respect to controller $x$, is formally defined by the following mapping: \begin{equation} E \times S_x \rightarrow (O)^* \times S_x \label{eq-law-2} \end{equation} Using a less formal notation: the law, when applies to a given controller $x$, is a function \begin{equation} law: (e,s) \rightarrow (m,ns) \label{eq-law-3} \end{equation} \noindent that maps any a given pair $(e,s)$, into a \emph{ruling} $(m,ns)$. Here $e$ is an event that occurred at controller $x$, and $s$ is the state of $x$ at the time of occurrence of this event. And the ruling that $x$ is to carry out, consists of: (a) a (possibly empty) list $m$ of \emph{operations} that $x$ must execute (which are, most often, messages to be sent); and (b) a new state $ns$ that is to replace the current state of $x$. This definition makes it clear that the law is strictly \emph{local}. Indeed, the event that occurs at the controller and its state are local. And the ruling is to be carried out locally. Of course, if the ruling calls for some message to be sent to another controller, then this message would eventually have a non-local effect. But the decision to send such a message is local. It should be pointing out that while Formula~\ref{eq-law-2} is a definition of the semantics of laws\footnote{Modulo the fact that the sets $E$ of events and $O$ of operations have not been fully spelled out here.}, it does not specify a language for writing them. In fact, the current implementation of LGI supports several \emph{law-languages}, one of which is JavaScript. The choice of a law-language has no effect on the semantics of LGI, as long as the chosen language is sufficiently powerful to specify all possible mappings defined by Formula~\ref{eq-law-2}. \subsubsection{Additional Observations about LGI-Laws and their Enforcement}\label{more-observations} \paragraph{Non-Deterministic Laws} A law may be \emph{non-deterministic} in that its rulings may include random numbers. Such laws are useful, in particular, for the protocols involving randomness and tie-breaking. The implementation of non-determinism under Cop is discussed in \cite{ccong}. \paragraph{On the Interplay Between the Fixed Law and the Changing State of a Controller $x$} On one hand, the ruling of the law may depend on the current state of $x$, on the other hand the evolution of the state is regulated by the law---although it is driven by the various event that occur at $x$, most of them coming from other controllers in a given community. \paragraph{About the Enforcement of Laws} A controller $x$ deals with events occurring at it sequentially, and if several events occur at $x$ at the same time, they will be handles in an arbitrary order. Also, the ruling of an event $e$ is carried out atomically, before handling any subsequent event. \subsection{Two Examples of Laws}\label{examples} We introduce here two very simple examples of LGI-laws, called \emph{money transfer law} (\CAL{MT}) and \emph{monitoring law} (\CAL{MO}). The formar law is stated formally in one of the law-languages currently supported by LGI, and the latter law is described informally. We will return to these laws in \secRef{heel}, and also in \secRef{Cop}. \textbf{A Money Transfer Law (\CAL{MT}):} This law provides an initial budget of \$1000 to every \CAL{MT}-agent (this is done upon the adoption of a controller with law \CAL{MT}). And then, this law enables every \CAL{MT}-agent to transfer to others any amount of money smaller than or equal to its current budget. A formal statement of this law---written in the the law-language based on CoffeeScript (a semantically equivalent variant of JavaScript)---is spelled out in Box \ref{law:MT}. This law has three rules, each of them contains comments (lines starting with \#) that explain its effect. \textbf{A Monitoring (\CAL{MO}) Law:} The following informally stated law, called \CAL{MO}, establishes a systematic monitoring scheme for all communication within a given community. \begin{enumerate} \em \item When any new \CAL{MO}-agent is created---by an actor adopting a controller after inserting law \CAL{MO} into it---the controller of the newborn agent would send a message to the designated monitor, essentially recording its own birth. \item Whenever an \CAL{MO}-message is sent, a copy of it, along with the addresses of the sender and its target, is sent to the monitor. \end{enumerate} \begin{lawscript}{Money Transfer Law}{law:MT}\label{MT} Name: MT LawScript: CoffeeScript # (R1) When the controller is adopted, # initialize the agent's budget to 1000. UPON "adopted", -> DO "set", key: "budget", value: 1000 return true # (R2) An agent can send any positive amount of money # to another agent provided that the amount # is not greater than its budget, # then the amount will be deducted from its budget. UPON "sent", -> if @message > 0 and @message <= CS("budget") DO "set", key: "budget", value: CS("budget") - @message DO "forward" return true # (R3) When an agent receives a positive amount of money, # the amount will be deposited to its budget. UPON "arrived", -> if @message > 0 DO "set", key: "budget", value: CS("budget") + @message DO "deliver" return true \end{lawscript} \subsection{Beyond Singleton Communities}\label{beyond} So far we have discussed the case of an singleton \EL-community, whose members interact with each other subject to a common law. But LGI is far more general than that, in the following ways, in particular: First, LGI can handle any number of communities, operating under different laws. Second, LGI can enable members of different such communities, say $C1$ and $C2$---each operating under its own law---to interact with each other in a regulated manner. This can be done by having the laws of each of these community specify the condition under which its members can interact with each other. And third, LGI enables the organization of a set of laws that collectively governs a single system, into a coherent ensemble called a \emph{conformance hierarchy} $H$. $H$ is a tree of laws rooted by a law called \law{R}. And every law in $H$, except of \law{R} itself, conforms transitively to its superior law. Moreover the conformance relation between laws in $H$ is inherent in the manner in which $H$ is constructed, requiring no extra validation. For a formal definition of such an hierarchy of laws see \cite{min03-6}, and for a recent application of it to complex systems see \cite{min18-1}. \subsection{The Security Vulnerability of LGI}\label{heel} Even if the CoS of LGI does its utmost to maintain and protect authentic controllers there is, of course, no way to ensure that controllers cannot be corrupted and would violate the the law under which they are supposed to operate. Such a corruption may be the result of an attack on a controller, either by an insider of the CoS, or by an outsider who discovered some vulnerability in the code of controllers. We are concerned here mostly about the resulting \emph{Byzantine behavior} of controllers, and not about their fail-stop type of failure, which can be handled effectively by LGI The possible failure of individual controllers may be considered an acceptable risk in distributed computing, as it poses a smaller risk than that of the corruption of a central reference monitor commonly used in access control. Indeed, the corruption of a central reference monitor can endanger an entire system, while the corruption of a few controllers usually have a more local effect. Yet, in some cases a Byzantine failure of even a single controller may cause a serious damage to the community at large. A case in point is the money-transfer law presented in \secRef{examples}. If a single controller has been corrupted, it may be able to distribute a large amount of fake money among other members of the \CAL{MT}-community, without raising any suspicion, at least for a while. The \emph{Achilles heel} of LGI is that it provide no general means for even detecting corrupt controllers. Our approach for resolving this \emph{Achilles heel}, thus protecting a system from the misbehaviors of its controllers, is the following: We provide a general mechanism that detects quickly and reliably any failed controller, right after it first failed to satisfy the law under which it operates; and then to recover from such a failure. This mechanism, called \emph{detection \& recovery} (or $D\&R$), is the subject of the rest of this paper. But first, we should make the following observation: There is, of course, a very general technique for handling Byzantine failures, see \cite{cas00-1} for example. In principle, this techniques can be applied to every controllers of LGI. But this would be prohibitively too inefficient and expensive for most potential applications of LGI. \section{The LGI-Based Cop Mechanism}\label{Cop} Cop carries out two complementary functions in enforcing a given law \EL\ over an \EL-community $C$. One function is the enforcement, \emph{per se}, of law \EL\ over the interactive activities of the members of $C$. The other function is the speedy detection of any failure of an \EL-controller to enforce law \EL, followed immediately by the recovery from this failure, which includes the repair of the failed controller, and by the resumption of its operation. These dual functions are carried out by two disjoint processes that operate in concert. One process is the enforcement of law \EL\ over the \EL-community, which is done by means of the LGI mechanism, outlined in \secRef{LGI}\footnote{There is just one difference between the LGI version used in Cop, and the older LGI---it is the implementation of the concept of \emph{enforced obligation}}, which provides LGI with an important proactive capability (cf. \cite{ccong}). The other process, which operates off-line of the enforcement mechanism, is the detection of any misbehaving (or failed) controllers, and the recovery from such failures. This is done by a mechanism called D\&R, for “Detection and Recovery”. The D\&R part of Cop is the main subject of the rest of this paper. It should be noted that---for simplicity---most of our description of Cop involves the treatment of a single isolated \EL-community, whose members interact only with each other subject to law \EL. But as we shall see, Cop can handle any number of such communities. Moreover, as explained in \secRef{interop}, Cop is not limited to dealing with isolated communities. Rather, like LGI itself, Cop can govern complex systems constituted of many interacting communities, inter-operating with each other subject to a conformance-hierarchy of laws. We conclude this section with a description of the main components of Cop, and of the roles they play. The operations of the D\&R mechanism, is discussed in \secRef{detection}. \subsection{The Components of the Cop Mechanism}\label{structure} The Cop mechanism is composed of three types of components that operate in concert. \begin{enumerate} \item The \emph{controller provider} (CP), which is a variant of the CoS of LGI. Besides the maintenance of generic controllers, as does the CoS, the CP participates actively in the operations of the D\&R mechanism. \item The \emph{ledger} $D_L$ that maintains a record of the interactive behavior of all \EL-controllers---i.e., the controllers that serve the \EL-community. \item The \emph{inspector} $I_L$, which performs the inspection of the interactive behavior of all \EL-controllers in order to detect any failure of any one of them, and to initiate the recovery of such failures. \end{enumerate} \noindent Note that while the Cop mechanism has just one CP, which can handle any number of communities, each active \EL-community is served by its own pair ($D_L$, $I_L$) of ledger and inspector, respectively. Note also, that the various ledgers and inspectors are to operate on different hosts, then the hosts used by CP. These three types of components are described in details in the following three subsections. \subsubsection{\textbf{The Controller Provider (CP)}}\label{CP} The CP plays two kinds of roles. First, like the controller-service (CoS) of LGI, CP maintains generic controllers, and provides them to its clients. In that, CP is a more reliable version of the CoS, as argued below. Second, CP plays an important role in the operation of the D\&R mechanism. These two roles are discussed in the following two paragraphs. \paragraph{The Maintenance of Generic Controllers} The main structural difference between the CP and the CoS, in this respect, is that under the CP, controllers are encapsulated in Linux \emph{containers} \cite{mer14-1}, hosted by a group of servers we call \emph{CPnodes}, which are managed by the CP. The CP can maintain any number of CPnodes, and each CPnode can host several hundreds of generic controllers, depending on the applications using them. And the controllers residing on any given CPnode may end up operating under different laws, and thus serving different communities. All the controllers resident in a given CPnode are managed by a \emph{local manager} running on this CPnode---some of the functions of the local manager will be discussed in due course. The CP as a whole is managed by a \emph{global manager} running on a distinguished CPnode of the CP. (And it would be useful, and quite elegant although not entirely necessary, for all these managers to interact with each other, subject to suitable \emph{management-law} under LGI---this is not done in present prototype of Cop.) The encapsulation of controllers in containers has several advantages. In particular, this architecture enables the imposition of limits on the use of various resources---such as CPU, memory and communication---by individual controllers. Such limits can be imposed by the local manager of the CPnode and dynamically adjusted by it. The ability to impose such limits would make controllers more robust because it can help to prevent an individual controller from hogging resources, thus preventing others from operating effectively, or at all. \paragraph{The Role that CP Plays in the Operations of the D\&R Mechanism} The CP carries out two functions that are essential to the D\&R mechanism, as follows: \emph{(b.1) Supplying the ledger $D_L$ with the information it needs:} As we shall see later, the detection of the failure of controllers by D\&R requires that all the events that occur at every \EL-controller, and all the operations carried out by it, be logged correctly on the ledger $D_L$ (cf. \secRef{ledger}). Unfortunately, we cannot trust the controllers themselves to log their own events and operations, because anyone of them may be corrupted. So, such logging is to be done by the local manager of every CPnode, by intercepting all the messages sent or received by every controllers that resides on the CPnode in question. And note that the sending or receiving of a message by a given controller corresponds to some event that occurred in it, and/or some operation carried out by it. The events and operations thus logged in ledgers are time-stamped, using the local time of the CPnode on which the controller resides; and they identify the controller in question. Finally, it is important to point out that controllers operating subject to a given law \EL, thus serving actors belonging to the \EL-community, may reside on different CPnodes. The managers of these CPnodes would log events that occur of \EL-controllers on the $D_L$ ledger. Conversely, the manager of a given CPnode, which may host controllers operating under different laws, would have to log events on different ledgers. \emph{(b.2) Repairing failed controllers:} As discussed in \secRef{recon}, the reconstruction of a failed \EL-controller is carried out by the CP---following an instruction by the inspector $I_L$. \subsubsection{\textbf{The Ledger}}\label{ledger} As has already been pointed out, there is one ledger $D_L$ per an \EL-community, which is designed to maintain entries representing two kind of items: (a) the \emph{events} that occurred at any given \EL-controller $z$, which represent messages obtained by $z$ from various sources; and (b) the \emph{operations} carried out by $z$, most of which represent messages sent by it to various targets. These entries are supplied to the ledger by the CP, as pointed out above. Such a ledger can have various architectures, providing different level of security and efficiency to Cop. It can, in particular, be some form of blockchain, such as under Ethereum \cite{pet16-1} or under HyperLedger \cite{vuk17-1}. Or it can be just a file, perhaps replicated, which a given organization maintains as part of its TCB. We will not discuss here the pros and cons of the various implementations of the ledger. \subsubsection{\textbf{The Inspector}}\label{inspect} The objective of an inspector $I_L$, associated with a given \EL-community, is twofold: (a) to inspect the interactive behavior of all the \EL-controllers, in order to detect any failure of any of them; and (b) to initiate the recovery measures for failed controllers. It is clear that the detection of a corrupt controller, and its recovery, needs to be done as quickly as possible---because the longer a corrupt controller is allowed to operate, the more damage it can do---damage that may be hard to reverse. The manner in which the inspector operates is discussed in \secRef{detection}. \begin{figure} \leavevmode \epsfysize=4 in \epsfxsize=3.7 in \centerline{\epsffile{fig-cop.eps}} \caption{A Schematic Depiction of the Operation of CoP \label{fig-cop}} \end{figure} \subsubsection{The Architecture of Cop}\label{arch} Figure~\ref{fig-cop} provides a schematic depiction of the overall architecture and behavior of Cop. This figure depicts the treatment under Cop of the interaction between two actors operating under a law denoted by $L$, via a pair of controllers residing in a given controller-provider (CP). The various events and operation generated by this interaction are intercepted by the the CP and sent to the L-ledger, which is inspected by the L-inspector. \section{Inspection: The Process of Detection and Recovery of Failed Controllers} \label{detection} This section starts with some introductory observations about the inspection process. Then, \secRef{single} discusses the inspection of a single \EL-controller, \secRef{scaling} discusses the inspection of all the controllers serving a given \EL-community, and \secRef{recovery} focuses on the recovery from the failures of controllers. \subsection{Introductory Observations}\label{observations} \subsubsection{Locality: the Key to Effective Detection of Failed Controllers}\label{locality} The detection of the failure of controllers, by inspecting their interactive behavior, may seem to be a daunting and time consuming process, because the behavior of each controller depends on its interaction with others. This seems to suggest the need for global analysis of the process of interaction between all controllers for detecting any violation of the law by any of them. Fortunately, no such global analysis is required, due to the inherently local nature of the laws of LGI (cf. \secRef{LGI}). This aspect of laws under LGI is what enables it to enforce its laws locally, and thus efficiently and scalably. And since the enforcement is local, it follows that non-compliance with the law can also be dealt with locally---at each controller, independently of all other controllers. This simplifies the process of inspection enormously, and makes it very efficient and scalable. Thus, the locality of laws is the key for effective detection of the failure of controllers \subsubsection{An Invariant of the Inspection Process} The inspector $I_L$ maintains a variable called $CSV_x$---which stands for \emph{Controller State-Variable} of $x$---for every \EL-controller $x$ being inspected. $CSV_x$ is computed, by the inspector, such that the following invariant is maintained: \begin{quote} The value of $CSV_x$ is the \emph{correct} state of the controller $x$ associated with the current event that occurs at $x$. \end{quote} \noindent By ``correct state of the controller'' we mean the state that a good controller $x$ would have associated with the event that occurs at it. Of course, a failed, Byzantine, controller may have an arbitrary state, whose value cannot be predicted. We will see later how this invariant is maintained by the inspector. \subsubsection{The Initialization of an \EL-community Under Cop}\label{init} We described in \secRef{LGI} the process of the creation and incremental development of an \EL-community under LGI, which require no formal initialization. But under Cop, this process needs to be prefaced with the following initialization steps: (a) the formation of law \EL; (b) the creation of an empty ledger $D_L$; and (c) the creation of inspector $I_L$, which is given the law under which it is to operate. Note that initially this community has no members, and no activity to be recorded on the ledger $D_L$. The inspector $I_L$ starts examining the ledger, but doing nothing else until it finds some entries on the ledger to be inspected. \subsection{The Inspection of a single \EL-Controller}\label{single} Broadly speaking, the process of inspection of a controller $x$ by the inspector $I_L$ starts when $x$ becomes an \EL-controller. This happens when $x$ is adopted by some actor $a$, to operate subject to a law \EL. This action by actor $a$ triggers the so-called \emph{adopted} event at $x$, which is the first event in its lifetime. When this event is intercepted by the CP and stored in the ledger $D_L$, it is observed by the inspector $I_L$ and inspected, as described in \secRef{inspection-1} below. After this initial inspection of $x$, its inspection continues recursively in response to consecutive events at $x$ until $x$ quits---as described in \secRef{inspection-2}. For the detailed discussion of this process it would be helpful to recall the description of an LGI law provided by Formula~\ref{eq-law-3}, namely: a law is a function \begin{equation} law: (e,s) \rightarrow (m,ns) \end{equation} \noindent that maps any a given pair $(e,s)$, into a \emph{ruling} $(m,ns)$. Here $e$ is an event that occurred in controller $x$, $s$ is the state of $x$ at the time of occurrence of this event. And the ruling that $x$ is to carry out consists of: (a) a (possibly empty) list $m$ of \emph{operations} that $x$ is to perform (which are, most often, messages to be sent); and (b) a new state $ns$ that is to replace the current state $s$ of $x$. \subsubsection{The initial Inspection of $x$}\label{inspection-1} This inspection starts when the inspector $I_L$---which continuously scans the ledger $D_L$ for new entries---notices the \emph{adopted} event at $x$ on the ledger, which prompts it to carry out the following sequence of steps. (i) The inspector creates the variable $CSV_x$ of $x$, whose value, in general, is to be the correct state of the controller $x$ associated with any given event that occurs at $x$. The initial value of $CSV_x$ is set to be an empty set, because, as stated in \secRef{creation}, this is the state of every newly formed controller, before its \emph{adopted} event is evaluated. (ii) The inspector computes the ruling of law \EL\ for the pair $(e,s)$, where the event $e$ is the adopted event and the state $s$ is the current value of $CSV_x$, which is the empty state, as pointed up above. The ruling $(m,ns)$ defines what a good $x$ is expected to carry out, atomically. (iii) Getting this ruling, the inspector changes the value of $CSV_x$ to $ns$, which is clearly the correct state of $x$ at this point, because it is mandated by the law. (iv) The inspector will now verify if the controller $x$ carried out the required list of operations in $m$---no more then in $m$ and no less than in it. To do this, the inspector needs to compare $m$ to the list $m'$ of operations found on the ledger between the adopted event of $x$ and its next event. (This must be the place for these operations, because the ruling of the law must be carried out atomically, and thus before the occurrence of next event at $x$.) Now, the inspector has two possibility to consider: First, if $m'$ equals to $m$, then the inspector concludes that $x$ operates correctly. Second, if $m'$ differs from $m$, the inspector concludes that $x$ just failed, and it will commence the appropriate recovery procedure, as described in \secRef{recovery}. \subsubsection{The Recursive Inspection of $x$}\label{inspection-2} Suppose that inspector $I_L$ inspected a sequence of events $(e_1, e_2, ..., e_n)$ that occurred at $x$, without detecting any failure---where $e_1$ is the very first event that occurred at $x$, namely the \emph{adopted} event discussed above. The inspection will continue, recursively, to the next event, if any, as follows: (i) $I_L$ will compute the ruling of the law for the pair $(e_{n+1},s_n)$, where $e_{n+1}$ is the new event at $x$ found on the ledger, and $s_n$ is the current value of $CSV_x$ which is obtained during the previous step of this recursion. Suppose now that the ruling of the law for the pair $(e_{n+1},s_n)$ is the pair $(m_{n+1},ns_{n+1})$, whose structure was described before. (ii) Getting this ruling, the inspector plants $ns_{n+1}$ as the new value of $CSV_x$. (iii) The inspector will now check if $x$ carried out the required list of operations $m_{n+1}$. To do this it needs compare this list to the list $m'$ of operations found on the ledger immediately after the $e_{n+1}$ event of $x$, and before the next event that occurred at $x$, if any. Now, the inspector has, again, two possibility to consider, in a direct analogy to the two possibilities it had in the very first inspection of $x$: First, if $m'$ is equals to $m_{n+1}$, then the inspector concludes that $x$ operates correctly. And second, if $m'$ differs from $m_{n+1}$, then the inspector concludes that $x$ just failed, and it will commence the recovery procedure from this failure, as described in \secRef{recovery}. It is worth pointing out, again, that the correctness of the value of $CSV_x$ as the true state of the controller which should be used for the evaluation of the law, is an \emph{invariant} of this recursive inspection. \subsection{The Scalable Process of Inspecting of all \EL-Controllers}\label{scaling} A single inspector can, in principle, inspect all the the \EL-controllers that serve a given \EL-community. Such an inspector would maintain the CSV of all active \EL-controllers, in a single address space. And it would inspect all these controller virtually in parallel. But there is a potential problem with this modus operandi of inspection. Namely, when the size of the community increases, the latency between the failure of a controller and the detection of this failure grows, roughly linearly. In other words, such inspection is unscalable with respect to this latency. And the longer the latency is, the more opportunity a failed controller would have to send illegal messages that can cause serious damages to the system, and which may be very hard to recover from. Fortunately, it is very easy to make the process of inspection scalable, as follows: If the set of \EL-controllers in a given community is considered too large, in the sense that it produces overly large latency, one can divide this set to any number of subgroups that can be handled by different, but identical, copies of inspector that operate in parallel. Such division can be done dynamically, while the inspector operates. \subsection{Recovery from the Failures of Controllers}\label{recovery} We consider here two complementary kinds of recoveries. The first is the resumption of the proper operation of a failed controller by its reconstruction. The second deals with the affect of the failed controller on other parts of the system. \subsubsection{The Reconstruction of a Failed \EL-Controller}\label{recon} The reconstruction of a failed controller $x$ is prompted by the inspector, and carried out by the local manager of the CPnode that host $x$. The reconstruction is carried out by the following sequence of steps: (i) Controller $x$ is replaced---without changing its address---with an authentic generic-controller provided by the CP. (ii) Law \EL\ is planted into $x$, making it into an \EL-controller. (iii) The latest value of $CSV_x$ is planted into $x$. And, (iv) the reconstructed controller $x$ is reactivated. \subsubsection{Regarding the Affect of a Failed Controller on Other Parts of the System} Note that an \EL-controller is recognized by the inspector as failing, after it operated illegally, relative to law \EL. Such an illegal operation needs to be corrected. Now, the ruling of a law is a list of zero or more operations that are to be carried out by the controller. The failure to carry out a given ruling consists of one or more instances of two types of illegality: (a) an \emph{illegal inaction}, namely, the failure to carry out one of the operations in the ruling of law \EL; and (b) an \emph{illegal action}, namely, carrying out an operation not in the ruling of law \EL. These two types of illegalities require different handling, discussed below: \paragraph{The Handling of Illegal Inaction} What one needs to do to recover from this kind of illegality is to carry out the operation required by the ruling. The Inspector does that right after discovering a failing controller, for every one of its illegal inactions, if any. \paragraph{The Handling of Illegal Action} An illegal action means that the failing controller $x$ sent some message to some controller $y$---an operation not mandated by the law. Such a message cannot be stopped, and its affect on $y$, and possibly on other members of the \EL-community can be quite complex and possible serious---as exemplified by the discussion of law \CAL{MD} in \secRef{heel}. The recovery from such a an illegal action may depend on the nature of the message sent, on the law, and on the application at hand, and is not a simple matter. But Cop can help in recovering from such an illegal action, by having the inspector notify some designated manager---one associated with the \EL-community---which can analyze the situation and decide how to rectify the problem. The operation of such a manager is beyond the scope of this paper. But it is worth pointing out that such a manager may need to examine parts of the $D_L$ ledger, to determine the extent of the affect of the illegal message. \section{Additional Aspects of Cop}\label{aspects} \subsection{The Controllable Interoperability Under Cop}\label{interop} As explained in \secRef{beyond}, the LGI part of Cop---which is the part that enforces laws---provides for a sophisticated kind of interoperability. This capability of LGI extends to D\&R, and thus to Cop. Consequently, Cop can be used to govern the interaction between the the members of disjoint communities. Moreover, can be used for governing very complex systems, such as federated enterprises, which comprises of a collection of communities operating under different laws that inter-operate with each other. Furthermore, it is possible to organize such inter-operating laws in a \emph{conformance hierarchy}, which provides a way to control which communities can inter-operate with each other, and how. This provides Cop with considerable generality. \subsection{The LGI's Concept of Enforced Obligation, and its Treatment under Cop}\label{oblig} The concept of \emph{enforced obligation} (or ``obligation'' for short) provides LGI with an important \emph{pro-active capabilities}, invaluable for security and for fault tolerance. This concept can be used, for example, to ensure that resources will not stay locked indefinitely, or to penalize book borrowers that do not return a book in the appointed time. Informally speaking, an obligation \emph{incurred} by a given controller, serves as a kind of \emph{motive force}, which ensures that a certain action (called \emph{sanction}) is carried out by this controller, at a specified time in the future (the deadline), when the obligation is said to \emph{come due}---provided that certain conditions on the state of the controller are satisfied at that time. This mechanism is governed by the law in question. Specifically, a controller $x$ incurs an obligation by the execution, as part of the ruling of some event, of an operation \textbf{imposeObligation(oName,dt)}, where \TT{oName} is the name of the obligation and \TT{dt} is the time period after which the obligation is to come due. When this obligation comes due, after \TT{dt} seconds, the event \textbf{obligationDue(oName)} would occur at controller $x$. The occurrence of this event would cause the controller to evaluate the ruling of the law for this event, and to carry out its ruling. The ruling of the law about an \TT{obligationDue(oName)} event is, thus, the \emph{sanction} for obligation \TT{oName}. But this concept of LGI, as is, cannot be supported under Cop. Because it relies on the controller itself to determine when the \TT{obligationDue(oName)} event occurs. And our D\&R mechanism does not, and cannot, rely on the controllers themselves. So, we implement the concept of obligation under Cop by making two changes to the obligation mechanism of LGI, without changing its semantics. First, the operation \textbf{imposeObligation(oName,dt)} causes a message with this text to be sent to an \emph{obligation-server} implemented in the CPnode where the control $x$ in question resides. When the deadline for this obligation arrives, the obligation-server is programmed to send the message \textbf{obligationDue(oName)} to $x$. Second, the \textbf{obligationDue(oName)} message sent by the obligation-server, is viewed by the receiving controller as an event that would be handled just as the internal event \textbf{obligationDue(oName)} is handled by the original LGI. That is, the controller would evaluate the ruling of the law for this event, and then carry out its ruling---thus preserving the original semantics of the enforced obligation under LGI. It should be pointed out that this is the only change in LGI we make in order to incorporate it in Cop. \subsection{An Implementation of a Prototype of Cop, and its Testing}\label{testing} We have implemented a fully functional prototype of Cop, and tested it. The following is a summary of the results of this testing of the correctness and the performance of the D\&R mechanism of Cop. (The correctness and performance of the LGI part of Cop has been tested many times in the past, and these measures did not change under Cop.) To test the correctness of D\&R---which is, in a sense, the test of the security of Cop---we've applied this prototype to multiple types of test cases, with different laws. We found \emph{no false negatives}, i.e., all failed controllers were discovered. And we found \emph{no false positive}, i.e., no correct controller were reported as a failed. Moreover, after the recovery of failed controllers, they all behaved correctly. We have also measured the performance of the prototype of the D\&R mechanism. We found (a) the latency of discovering a failed controller to be 6 seconds, on the average; and (b) the latency of the recovery of failed controllers to be 2 seconds, on the average. But these performance measures have a limited value. First, because it is just a prototype which we tested, whose code is not optimized, in particular, it is written in Python 3---a scripting language with relatively low performance. And second, because our experiments were done on a relatively weak hardware, which did not allow us to experiment with large communities. We expect that our latency result would be reduced by an order of magnitude, with optimized code, run on a stronger hardware. \subsection{On the Trustworthiness and Security of the D\&R Mechanism}\label{security} The D\&R mechanism has been designed for protecting against the possible failure of controllers---which we call the Achilles heel of LGI. But this protection can be effective only if the D\&R Mechanism itself---consisting of the CP, the ledgers, and the Inspectors---is secure. That is, these three components must constitute the trusted computing base (TCB) of D\&R. We believe that our current design of these components of D\&R of makes these components reasonably secure. And their security can be enhanced via various traditional means, including TPM and related technologies. Such security enhancements are beyond the scope of this work. \section{Conclusion}\label{conclusion} This paper introduces a scalable and secure protocol-enforcement mechanism, called Cop, which fulfills important qualities for such mechanisms, including low latency, high scalability, general interoperability and security. It is thus applicable to a wide range of applications, including small and large systems, time-critical systems, and systems-of-systems. Cop enforces protocols via the existing Law-Governed Interaction (LGI) mechanism, coupled with a new protective layer called D\&R that discovers any failed LGI-controller and repairs it---which is done soon after the failure occurs. The D\&R layer of Cop operates off-line relative to the enforcement by LGI, and it significantly enhances the dependability and security of the enforcement. We have implemented a fully functional prototype of Cop, and verified experimentally its correctness. But the evaluation of the performance and security of Cop, particularly when it is applied to large scale systems, would require an optimized implementation of Cop, and a sufficiently powerful hardware for it to run on.
{'timestamp': '2019-04-23T02:28:13', 'yymm': '1904', 'arxiv_id': '1904.09940', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09940'}
arxiv
\section{Introduction} Bayesian Networks (BN) have been widely used in machine learning applications~\citep{glymour1999computation,ott2004finding}. The structure of a BN takes the form of a directed acyclic graph (DAG) and plays a vital part in causal inference~\citep{pearl88} with many applications in medicine, genetics, economics, and epidemics. Its structure learning problem is however NP-hard~\citep{chickering2004large} and stimulates a proliferation of literature. Score-based methods generally formulate the structure learning problem as optimizing a certain score function with respect to the unknown (weighted) adjacency matrix $A$ and the observed data samples, with a combinatorial constraint stating that the graph must be acyclic. The intractable search space (with a complexity superexponential in the number of graph nodes) poses substantial challenges for optimization. Hence, for practical problems in a scale beyond small, approximate search often needs to be employed with additional structure assumption~\citep{nie2014advances,chow1968approximating,scanagatta2015learning,chen2016learning}. Recently, \citet{Zheng2018} formulate an equivalent acyclicity constraint by using a continuous function of the adjacency matrix (specifically, the matrix exponential of $A\circ A$). This approach drastically changes the combinatorial nature of the problem to a continuous optimization, which may be efficiently solved by using maturely developed blackbox solvers. The optimization problem is nevertheless nonlinear, thus these solvers generally return only a stationary-point solution rather than the global optimum. Nevertheless, the authors show that empirically such local solutions are highly comparable to the global ones obtained through expensive combinatorial search. With the inspiring reformulation of the constraint, we revisit the objective function. The score-based objective functions generally make assumptions of the variables and the model class. For example, \citet{Zheng2018} demonstrate on the linear structural equation model (SEM) with a least-squares loss. While convenient, such assumptions are often restricted and they may not correctly reflect the actual distribution of real-life data. Hence, motivated by the remarkable success of deep neural networks, which are arguably universal approximators, in this work we develop a graph-based deep generative model aiming at better capturing the sampling distribution faithful to the DAG. To this end, we employ the machinery of variational inference and parameterize a pair of encoder/decoder with specially designed graph neural networks (GNN). The objective function (the score), then, is the evidence lower bound. Different from the current flourishing designs of GNNs~\citep{Bruna2014,Defferrard2016,Li2016,Kipf2017,Hamilton2017,Gilmer2017,Chen2018,Velickovic2018}, the proposed ones are generalized from linear SEM, so that the new model performs at least as well as linear SEM when the data is linear. Our proposal has the following distinct features and advantages. First, the work is built on the widespread use of deep generative models (specifically, variational autoencoders, VAE~\citep{Kingma2014}) that are able to capture complex distributions of data and to sample from them. Under the graph setting, the weighted adjacency matrix is an explicit parameter, rather than a latent structure, learnable together with other neural network parameters. The proposed network architecture has not been used before. Second, the framework of VAE naturally handles various data types, notably not only continuous but also discrete ones. All one needs to do is to model the likelihood distribution (decoder output) consistent with the nature of the variables. Third, owing to the use of graph neural networks for parameterization, each variable (node) can be not only scalar-valued but also vector-valued. These variables are considered node features input to/output of the GNNs. Fourth, we propose a variant of the acyclicity constraint more suitable for implementation under current deep learning platforms. The matrix exponential suggested by~\citet{Zheng2018}, while mathematically elegant, may not be implemented or supported with automatic differentiation in all popular platforms. We propose a polynomial alternative more practically convenient and as numerically stable as the exponential. We demonstrate the effectiveness of the proposed method on synthetic data generated from linear and nonlinear SEMs, benchmark data sets with discrete variables, and data sets from applications. For synthetic data, the proposed DAG-GNN outperforms DAG-NOTEARS, the algorithm proposed by~\citet{Zheng2018} based on linear SEM. For benchmark data, our learned graphs compare favorably with those obtained through optimizing the Bayesian information criterion by using combinatorial search. \section{Background and Related Work} A DAG $G$ and a joint distribution $\mathcal{P}$ are \emph{faithful} to each other if all and only the conditional independencies true in $\mathcal{P}$ are entailed by $G$~\citep{pearl88}. The faithfulness condition enables one to recover $G$ from $\mathcal{P}$. Given independent and iid samples $D$ from an unknown distribution corresponding to a faithful but unknown DAG, \emph{structure learning} refers to recovering the DAG from $D$. Many exact and approximate algorithms for learning DAG from data have been developed, including score-based and constraint-based approaches~\citep{PCalgorithm,chickering02,koivisto2004exact,silander06,jaakkola2010,cussens11,Yuan13learning}. Score-based methods generally use a score to measure the goodness of fit of different graphs over data; and then use a search procedure---such as hill-climbing~\citep{heckerman1995learning,MMPCcor,HCimap}, forward-backward search~\citep{chickering02}, dynamic programming~\citep{smDP,silander06}, A$^*$~\citep{Yuan13learning}, or integer programming~\citep{jaakkola2010,cussens11,cussens2016polyhedral}---in order to find the best graph. Commonly used Bayesian score criteria, such as BDeu and Bayesian information criterion (BIC), are decomposable, consistent, locally consistent~\citep{chickering02}, and score equivalent~\citep{heckerman1995learning}. To make the DAG search space tractable, approximate methods make additional assumptions such as bounded tree-width~\citep{nie2014advances}, tree-like structures~\citep{chow1968approximating}, approximation~\citep{scanagatta2015learning}, and other constraints about the DAG~\citep{chen2016learning}. Many bootstrap~\citep{friedman1999data} and sampling-based structure learning algorithms~\citep{madigan1995bayesian,friedman2003being,eaton2012bayesian,grzegorczyk2008improving,niinimaki2013annealed,niinimaki2012partial,he2016structure} are also proposed to tackle the expensive search problem. Constraint-based methods, in contrast, use (conditional) independence tests to test the existence of edges between each pair of variables. Popular algorithms include SGS~\citep{spirtes2000causation}, PC~\citep{spirtes2000causation}, IC~\citep{pearl2003causality}, and FCI~\citep{spirtes1995causal,zhang2008completeness}. Recently, there appears a suite of hybrid algorithms that combine score-based and constraint-based methods, such as MMHC~\citep{Tsamardinos03}, and apply constraint-based methods to multiple environments~\citep{mooij2016joint}. Due to the NP-hardness, traditional DAG learning methods usually deal with discrete variables, as discussed above, or jointly Gaussian variables~\citep{mohan2012structured,mohammadi2015bayesian}. Recently, a new continuous optimization approach is proposed~\citep{Zheng2018}, which transforms the discrete search procedure into an equality constraint. This approach enables a suite of continuous optimization techniques such as gradient descent to be used. The approach achieves good structure recovery results, although it is applied to only linear SEM for ease of exposition. Neural-network approaches started to surface only very recently. \citet{Kalainathan2018} propose a GAN-style (generative adversarial network) method, whereby a separate generative model is applied to each variable and a discriminator is used to distinguish between the joint distributions of real and generated samples. The approach appears to scale well but acyclicity is not enforced. \section{Neural DAG Structure Learning} Our method learns the weighted adjacency matrix of a DAG by using a deep generative model that generalizes linear SEM, with which we start the journey. \subsection{Linear Structural Equation Model} Let $A\in\mathbb{R}^{m\times m}$ be the weighted adjacency matrix of the DAG with $m$ nodes and $X\in\mathbb{R}^{m\times d}$ be a sample of a joint distribution of $m$ variables, where each row corresponds to one variable. In the literature, a variable is typically a scalar, but it can be trivially generalized to a $d$-dimensional vector under the current setting. The linear SEM model reads \begin{equation}\label{eqn:linear.sem} X = A^TX + Z, \end{equation} where $Z\in\mathbb{R}^{m\times d}$ is the noise matrix. When the graph nodes are sorted in the topological order, the matrix $A$ is strictly upper triangular. Hence, ancestral sampling from the DAG is equivalent to generating a random noise $Z$ followed by a triangular solve \begin{equation}\label{eqn:linear.sem.sampling} X=(I-A^T)^{-1}Z. \end{equation} \subsection{Proposed Graph Neural Network Model} Equation~\eqref{eqn:linear.sem.sampling} may be written as $X=f_A(Z)$, a general form recognized by the deep learning community as an abstraction of parameterized graph neural networks that take node features $Z$ as input and return $X$ as high level representations. Nearly all graph neural networks~\citep{Bruna2014,Defferrard2016,Li2016,Kipf2017,Hamilton2017,Gilmer2017,Chen2018,Velickovic2018} can be written in this form. For example, the popular GCN~\citep{Kipf2017} architecture reads \[ X = \widehat{A}\cdot\relu(\widehat{A}ZW^1)\cdot W^2, \] where $\widehat{A}$ is a normalization of $A$ and $W^1$ and $W^2$ are parameter matrices. Owing to the special structure~\eqref{eqn:linear.sem.sampling}, we propose a new graph neural network architecture \begin{equation}\label{eqn:decoder} X=f_2((I-A^T)^{-1}f_1(Z)). \end{equation} The parameterized functions $f_1$ and $f_2$ effectively perform (possibly nonlinear) transforms on $Z$ and $X$, respectively. If $f_2$ is invertible, then~\eqref{eqn:decoder} is equivalent to $f_2^{-1}(X) = A^Tf_2^{-1}(X) + f_1(Z)$, a generalized version of the linear SEM~\eqref{eqn:linear.sem}. We will defer the instantiation of these functions in a later subsection. One of the reasons is that the activation in $f_2$ must match the type of the variable $X$, a subject to be discussed together with discrete variables. \subsection{Model Learning with Variational Autoencoder} Given a specification of the distribution of $Z$ and samples $X^1,\ldots,X^n$, one may learn the generative model~\eqref{eqn:decoder} through maximizing the log-evidence \[ \frac{1}{n}\sum_{k=1}^n\log p(X^k)=\frac{1}{n}\sum_{k=1}^n\log\int p(X^k|Z)p(Z)\,dZ, \] which, unfortunately, is generally intractable. Hence, we appeal to variational Bayes. To this end, we use a variational posterior $q(Z|X)$ to approximate the actual posterior $p(Z|X)$. The net result is the evidence lower bound (ELBO) \[ L_{\text{ELBO}}=\frac{1}{n}\sum_{k=1}^nL_{\text{ELBO}}^k, \] with \begin{multline}\label{eqn:elbo.i} L_{\text{ELBO}}^k \equiv -D_{\text{KL}}\Big(q(Z|X^k) \,||\, p(Z)\Big) \\ +\mean_{q(Z|X^k)}\Big[\log p(X^k|Z)\Big]. \end{multline} Each individual term $L_{\text{ELBO}}^k$ departs from the log-evidence by $D_{\text{KL}}\Big(q(Z|X^k) \,||\, p(Z|X^k)\Big)\ge0$, the KL-divergence between the variational posterior and the actual one. The ELBO lends itself to a variational autoencoder (VAE)~\citep{Kingma2014}, where given a sample $X^k$, the encoder (inference model) encodes it into a latent variable $Z$ with density $q(Z|X^k)$; and the decoder (generative model) tries to reconstruct $X^k$ from $Z$ with density $p(X^k|Z)$. Both densities may be parameterized by using neural networks. Modulo the probability specification to be completed later, the generative model~\eqref{eqn:decoder} discussed in the preceding subsection plays the role of the decoder. Then, we propose the corresponding encoder \begin{equation}\label{eqn:encoder} Z = f_4((I-A^T)f_3(X)), \end{equation} where$f_3$ and $f_4$ are parameterized functions that conceptually play the inverse role of $f_2$ and $f_1$, respectively. \begin{figure*}[ht] \centering \includegraphics[width=.98\linewidth]{architecture-crop} \caption{Architecture (for continuous variables). In the case of discrete variables, the decoder output is changed from $M_X,S_X$ to $P_X$.} \label{fig:architecture} \end{figure*} \subsection{Architecture and Loss Function} To complete the VAE, one must specify the distributions in~\eqref{eqn:elbo.i}. Recall that for now both $X^k$ and $Z$ are $m\times d$ matrices. For simplicity, the prior is typically modeled as the standard matrix normal $p(Z) = \mathcal{MN}_{m\times d}(0,I,I)$. For the inference model, we let $f_3$ be a multilayer perceptron (MLP) and $f_4$ be the identity mapping. Then, the variational posterior $q(Z|X)$ is a factored Gaussian with mean $M_Z\in\mathbb{R}^{m\times d}$ and standard deviation $S_Z\in\mathbb{R}^{m\times d}$, computed from the encoder \begin{equation}\label{eqn:encoder.p} [M_Z | \log S_Z] = (I-A^T)\mlp(X, W^1, W^2), \end{equation} where $\mlp(X, W^1, W^2) := \relu(XW^1)W^2$, and $W^1$ and $W^2$ are parameter matrices. For the generative model, we let $f_1$ be the identity mapping and $f_2$ be an MLP. Then, the likelihood $p(X|Z)$ is a factored Gaussian with mean $M_X\in\mathbb{R}^{m\times d}$ and standard deviation $S_X\in\mathbb{R}^{m\times d}$, computed from the decoder \begin{equation}\label{eqn:decoder.p} [M_X | \log S_X] = \mlp((I-A^T)^{-1}Z, W^3, W^4), \end{equation} where $W^3$ and $W^4$ are parameter matrices. One may switch the MLP and the identity mapping inside each of the encoder/decoder, but we find that the performance is less competitive. One possible reason is that the current design~\eqref{eqn:decoder.p} places an emphasis on the nonlinear transform of a sample $(I-A^T)^{-1}Z$ from linear SEM, which better captures nonlinearity. Based on~\eqref{eqn:encoder.p} and~\eqref{eqn:decoder.p}, the KL-divergence term in the ELBO~\eqref{eqn:elbo.i} admits a closed form \begin{multline}\label{eqn:loss.kl} D_{\text{KL}}\Big(q(Z|X) \,||\, p(Z)\Big) = \\ \frac{1}{2}\sum_{i=1}^m\sum_{j=1}^d (S_Z)_{ij}^2 + (M_Z)_{ij}^2 - 2\log(S_Z)_{ij} - 1, \end{multline} and the reconstruction accuracy term may be computed with Monte Carlo approximation \begin{multline}\label{eqn:loss.recons} \mean_{q(Z|X)}\Big[\log p(X|Z)\Big] \approx \\ \frac{1}{L}\sum_{l=1}^L\sum_{i=1}^m\sum_{j=1}^d -\frac{(X_{ij}-(M_X^{(l)})_{ij})^2}{2(S_X^{(l)})_{ij}^2} - \log (S_X^{(l)})_{ij} - c, \end{multline} where $c$ is a constant and $M_X^{(l)}$ and $S_X^{(l)}$ are the outputs of the decoder~\eqref{eqn:decoder.p} by taking as input Monte Carlo samples $Z^{(l)}\sim q(Z|X)$, for $l=1,\ldots,L$. Note that under the autoencoder framework, $Z$ is considered latent (rather than the noise in linear SEM). Hence, the column dimension of $Z$ may be different from $d$. From the neural network point of view, changing the column dimension of $Z$ affects only the sizes of the parameter matrices $W^2$ and $W^3$. Sometimes, one may want to use a smaller number than $d$ if he/she observes that the data has a smaller intrinsic dimension. An illustration of the architecture is shown in Figure~\ref{fig:architecture}. \subsection{Discrete Variables} One advantage of the proposed method is that it naturally handles discrete variables. We assume that each variable has a finite support of cardinality $d$. Hence, we let each row of $X$ be a one-hot vector, where the ``on'' location indicates the value of the corresponding variable. We still use standard matrix normal to model the prior and factored Gaussian to model the variational posterior, with~\eqref{eqn:encoder.p} being the encoder. On the other hand, we need to slightly modify the likelihood to cope with the discrete nature of the variables. Specifically, we let $p(X|Z)$ be a factored categorical distribution with probability matrix $P_X$, where each row is a probability vector for the corresponding categorical variable. To achieve so, we change $f_2$ from the identity mapping to a row-wise softmax and modify the decoder~\eqref{eqn:decoder.p} to \begin{equation}\label{eqn:decoder.p.discrete} P_X = \softmax(\mlp((I-A^T)^{-1}Z, W^3, W^4)). \end{equation} Correspondingly for the ELBO, the KL term~\eqref{eqn:loss.kl} remains the same, but the reconstruction term~\eqref{eqn:loss.recons} needs be modified to \begin{equation}\label{eqn:loss.recons.discrete} \mean_{q(Z|X)}\Big[\log p(X|Z)\Big] \approx \\ \frac{1}{L}\sum_{l=1}^L\sum_{i=1}^m\sum_{j=1}^d X_{ij}\log (P_X^{(l)})_{ij}, \end{equation} where $P_X^{(l)}$ is the output of the decoder~\eqref{eqn:decoder.p.discrete} by taking as input Monte Carlo samples $Z^{(l)}\sim q(Z|X)$, for $l=1,\ldots,L$. \subsection{Connection to Linear SEM} One has seen from the forgoing discussions how the proposed model is developed from linear SEM: We apply nonlinearality to the sampling procedure~\eqref{eqn:linear.sem.sampling} of SEM, treat the resulting generative model as a decoder, and pair with it a variational encoder for tractable learning. Compared with a plain autoencoder, the variational version allows a modeling of the latent space, from which samples are generated. We now proceed, in a reverse thought flow, to establish the connection between the loss function of the linear SEM considered in~\citet{Zheng2018} and that of ours. We first strip off the variational component of the autoencoder. This plain version uses~\eqref{eqn:encoder} as the encoder and~\eqref{eqn:decoder} as the decoder. For notational clarity, let us write $\widehat{X}$ as the output of the decoder, to distinguish it from the encoder input $X$. A typical sample loss to minimize is \[ \frac{1}{2}\sum_{i=1}^m\sum_{j=1}^d(X_{ij}-\widehat{X}_{ij})^2 + \frac{1}{2}\sum_{i=1}^m\sum_{j=1}^d Z_{ij}^2, \] where the first term is the reconstruction error and the second term is a regularization of the latent space. One recognizes that the reconstruction error is the same as the negative reconstruction accuracy~\eqref{eqn:loss.recons} in the ELBO, up to a constant, if the standard deviation $S_X$ is $1$, the mean $M_X$ is taken as $\widehat{X}$, and only one Monte Carlo sample is drawn from the variational posterior. Moreover, the regularization term is the same as the KL-divergence~\eqref{eqn:loss.kl} in the ELBO if the standard deviation $S_Z$ is $1$ and the mean $M_Z$ is taken as $Z$. If we further strip off the (possibly nonlinear) mappings $f_1$ to $f_4$, then the encoder~\eqref{eqn:encoder} and decoder~\eqref{eqn:decoder} read, respectively, $Z=(I-A^T)X$ and $\widehat{X}=(I-A^T)^{-1}Z$. This pair results in perfect reconstruction, and hence the sample loss reduces to \begin{equation}\label{eqn:loss.ls} \frac{1}{2}\sum_{i=1}^m\sum_{j=1}^d Z_{ij}^2 = \frac{1}{2}\|(I-A^T)X\|_F^2, \end{equation} which is the least-squares loss used and justified by~\citet{Zheng2018}. \subsection{Acyclicity Constraint} Neither maximizing the ELBO~\eqref{eqn:elbo.i} nor minimizing the least-squares loss~\eqref{eqn:loss.ls} guarantees that the corresponding graph of the resulting $A$ is acyclic. \citet{Zheng2018} pair the loss function with an equality constraint, whose satisfaction ensures acyclicity. The idea is based on the fact that the positivity of the $(i,j)$ element of the $k$-th power of a nonnegative adjacency matrix $B$ indicates the existence of a length-$k$ path between nodes $i$ and $j$. Hence, the positivity of the diagonal of $B^k$ reveals cycles. The authors leverage the trick that the matrix exponential admits a Taylor series (because it is analytic on the complex plane), which is nothing but a weighted sum of all nonnegative integer powers of the matrix. The coefficient of the zeorth power (the identity matrix $I_{m\times m}$) is $1$, and hence the trace of the exponential of $B$ must be exactly $m$ for a DAG. To satisfy nonnegativity, one may let $B$ be the elementwise square of $A$; that is, $B=A\circ A$. Whereas the formulation of this acyclicity constraint is mathematically elegant, support of the matrix exponential may not be available in all deep learning platforms. To ease the coding effort, we propose an alternative constraint that is practically convenient. \begin{theorem}\label{thm:tr} Let $A\in\mathbb{R}^{m\times m}$ be the (possibly negatively) weighted adjacency matrix of a directed graph. For any $\alpha>0$, the graph is acyclic if and only if \begin{equation}\label{eqn:dag.constraint} \tr[(I + \alpha A\circ A)^m] - m = 0. \end{equation} \end{theorem} We use~\eqref{eqn:dag.constraint} as the equality constraint when maximizing the ELBO. The computations of both $(I+\alpha B)^m$ and $\exp(B)$ may meet numerical difficulty when the eigenvalues of $B$ have a large magnitude. However, the former is less severe than the latter with a judicious choice of $\alpha$. \begin{theorem}\label{thm:exp} Let $\alpha=c/m>0$ for some $c$ . Then for any complex $\lambda$, we have $(1+\alpha|\lambda|)^m \le e^{c|\lambda|}$. \end{theorem} In practice, $\alpha$ may be treated as a hyperparameter and its setting depends on an estimation of the largest eigenvalue of $B$ in magnitude. This value is the spectral radius of $B$, and because of nonnegativity, it is bounded by the maximum row sum according to the Perron--Frobenius theorem. \subsection{Training} Based on the foregoing, the learning problem is \begin{align*} \min_{A,\theta} \quad& f(A,\theta) \equiv -L_{\text{ELBO}} \\ \text{s.t.} \quad& h(A) \equiv \tr[(I + \alpha A\circ A)^m] - m = 0, \end{align*} where the unknowns include the matrix $A$ and all the parameters $\theta$ of the VAE (currently we have $\theta=\{W^1,W^2,W^3,W^4\}$). Nonlinear equality-constrained problems are well studied and we use the augmented Lagrangian approach to solve it. For completeness, we summarize the algorithm here; the reader is referred to standard textbooks such as Section 4.2 of~\citet{Bertsekas1999} for details and convergence analysis. Define the augmented Lagrangian \[ L_c(A,\theta,\lambda)=f(A,\theta)+\lambda h(A)+\frac{c}{2}|h(A)|^2, \] where $\lambda$ is the Lagrange multiplier and $c$ is the penalty parameter. When $c=+\infty$, the minimizer of $L_c(A,\theta,\lambda)$ must satisfy $h(A)=0$, in which case $L_c(A,\theta,\lambda)$ is equal to the objective function $f(A,\theta)$. Hence, the strategy is to progressively increase $c$, for each of which minimize the unconstrained augmented Lagrangian. The Lagrange multiplier $\lambda$ is correspondingly updated so that it converges to the one under the optimality condition. There exist a few variants for updating $\lambda$ and increasing $c$, but a typical effective rule reads: \begin{align} (A^k,\theta^k) &= \argmin_{A,\theta} L_{c^k}(A,\theta,\lambda^k), \label{eqn:sub}\\ \lambda^{k+1} &= \lambda^k+c^kh(A^k),\\ c^{k+1} &= \begin{cases} \eta c^k, & \text{if } |h(A^k)|>\gamma|h(A^{k-1})|, \\ c^k, & \text{otherwise}, \end{cases} \end{align} where $\eta>1$ and $\gamma<1$ are tuning parameters. We find that often $\eta=10$ and $\gamma=1/4$ work well. The subproblem~\eqref{eqn:sub} may be solved by using blackbox stochastic optimization solvers, by noting that the ELBO is defined on a set of samples. \section{Experiments} In this section, we present a comprehensive set of experiments to demonstrate the effectiveness of the proposed method DAG-GNN. In Section~\ref{sec:data1}, we compare with DAG-NOTEARS, the method proposed by~\citet{Zheng2018} based on linear SEM, on synthetic data sets generated by sampling generalized linear models, with an emphasis on nonlinear data and vector-valued data ($d>1$). In Section~\ref{sec:data2}, we showcase the capability of our model with discrete data, often seen in benchmark data sets with ground truths for assessing quality. To further illustrate the usefulness of the proposed method, in Section~\ref{sec:data3} we apply DAG-GNN on a protein data set for the discovery of consensus protein signaling network, as well as a knowledge base data set for learning causal relations. Our implementation is based on PyTorch~\citep{paszke2017automatic}. We use Adam~\citep{Kingma2015} to solve the subproblems~\eqref{eqn:sub}. To avoid overparameterization, we parameterize the variational posterior $q(Z|X)$ as a factored Gaussian with constant unit variance, and similarly for the likelihood $p(X|Z)$. When extracting the DAG, we use a thresholding value $0.3$, following the recommendation of~\citet{Zheng2018}. For benchmark and application data sets, we include a Huber-norm regularization of $A$ in the objective function to encourage more rapid convergence. \subsection{Synthetic Data Sets}\label{sec:data1} The synthetic data sets are generated in the following manner. We first generate a random DAG by using the Erd\H{o}s--R\'{e}nyi model with expected node degree 3, then assign uniformly random weights for the edges to obtain the weighted adjacency matrix $A$. A sample $X$ is generated by sampling the (generalized) linear model $X=g(A^TX)+Z$ with some function $g$ elaborated soon. The noise $Z$ follows standard matrix normal. When the dimension $d=1$, we use lowercase letters to denote vectors; that is, $x=g(A^Tx)+z$. We compare DAG-GNN with DAG-NOTEARS and report the structural Hamming distance (SHD) and false discovery rate (FDR), each averaged over five random repetitions. With sample size $n=5000$, we run experiments on four graph sizes $m\in\{10,20,50,100\}$. In Sections~\ref{sec:lineardata} and~\ref{sec:nonlineardata} we consider scalar-valued variables ($d=1)$ and in Section~\ref{sec:multiddata} vector-valued variables ($d>1$). \subsubsection{Linear Case}\label{sec:lineardata} This case is the linear SEM model, with $g$ being the identity mapping. The SHD and FDR are plotted in Figure~\ref{fig:linear}. One sees that the graphs learned by the proposed method are substantially more accurate than those by DAG-NOTEARS when the graphs are large. \begin{figure}[!ht] \centering \subfigure{\scalebox{0.38}[0.35]{\includegraphics{./linear_shdfdr-eps-converted-to.pdf}}} \caption{Structure discovery in terms of SHD and FDR to the true graph, on synthetic data set generated by $x=A^Tx+z$.} \label{fig:linear} \end{figure} \subsubsection{Nonlinear Case}\label{sec:nonlineardata} We now consider data generated by the following model \[ x = A^Th(x)+z, \] for some nonlinear function $h$. Taking first-order approximation $h(x)\approx h(0)\textbf{1}+h'(0)x$ (ignoring higher-order terms of $x$), one obtains an amendatory approximation of the graph adjacency matrix, $h'(0)A$. This approximate ground truth maintains the DAG structure, with only a scaling on the edge weights. We take $h(x)=\cos(x+\mathbf{1})$ and plot the SHD and FDR in Figure~\ref{fig:cos}. one observes that DAG-GNN slightly improves over DAG-NOTEARS in terms of SHD. Further, FDR is substantially improved, by approximately a factor of three, which indicates that DAG-GNN tends to be more accurate on selecting correct edges. This observation is consistent with the parameter estimates shown in Figure~\ref{fig:cosG}, where the ground truth is set as $-\sin(1)A$. The heat map confirms that DAG-GNN results in fewer ``false alarms'' and recovers a relatively sparser matrix. \begin{figure}[!ht] \centering \subfigure{\scalebox{0.38}[0.35]{\includegraphics{./cos_shdfdr-eps-converted-to.pdf}}} \caption{Structure discovery in terms of SHD and FDR to the true graph, on synthetic data set generated by $x=A^T\cos(x+\mathbf{1})+z$.} \label{fig:cos} \end{figure} \begin{figure}[!ht] \centering \subfigure{\scalebox{0.22}[0.22]{\includegraphics{./compare10W1-eps-converted-to.pdf}}} \caption{Parameter estimates (before thresholding) of the graph on synthetic data set generated by $x=A^T\cos(x+\mathbf{1})+z$.} \label{fig:cosG} \end{figure} We further experiment with a more complex nonlinear generation model, where the nonlinearity occurs after the linear combination of the variables, as opposed to the preceding case where nonlinearity is applied to the variables before linear combination. Specifically, we consider \begin{displaymath} x=2\sin(A^T(x+0.5\cdot\mathbf{1}))+A^T(x+0.5\cdot\mathbf{1})+z, \end{displaymath} and plot the results in Figure~\ref{fig:newsin}. One sees that with higher nonlinearity, the proposed method results in significantly better SHD and FDR than does DAG-NOTEARS. \begin{figure}[!ht] \centering \subfigure{\scalebox{0.38}[0.35]{\includegraphics{./newsin_shdfdr-eps-converted-to.pdf}}} \caption{Structure discovery in terms of SHD and FDR to the true graph, on synthetic data set generated by $x=2\sin(A^T(x+0.5\cdot\mathbf{1}))+A^T(x+0.5\cdot\mathbf{1})+z$.} \label{fig:newsin} \end{figure} \subsubsection{Vector-Valued Case}\label{sec:multiddata} The proposed method offers a modeling benefit that the variables can be vector-valued with $d>1$. Moreover, since $Z$ resides in the latent space of the autoencoder and is not interpreted as noise as in linear SEM, one may take a smaller column dimension $d_Z<d$ if he/she believes that the variables have a lower intrinsic dimension. To demonstrate this capability, we construct a data set where the different dimensions come from a randomly scaled and perturbed sample from linear SEM. Specifically, given a graph adjacency matrix $A$, we first construct a sample $\tilde{x}\in\mathbb{R}^{m\times1}$ from the linear SEM $\tilde{x}=A^T\tilde{x}+\tilde{z}$, and then generate for the $k$-th dimension $x^k=u^k\tilde{x}+v^k+z^k$, where $u^k$ and $v^k$ are random scalars from standard normal and $z^k$ is a standard normal vector. The eventual sample is $X=[x^1|x^2|\cdots|x^d]$. We let $d=5$ and $d_Z=1$ and compare DAG-GNN with DAG-NOTEARS. The SHD and FDR are plotted in Figure~\ref{fig:multid}. The figure clearly shows the significantly better performance of the proposed method. Moreover, the parameter estimates are shown in Figure~\ref{fig:multidG}, compared against the ground-truth $A$. One sees that the estimated graph from DAG-GNN successfully captures all the ground truth edges and that the estimated weights are also similar. On the other hand, DAG-NOTEARS barely learns the graph. \begin{figure}[!ht] \centering \subfigure{\scalebox{0.38}[0.35]{\includegraphics{./multid_shdfdr-eps-converted-to.pdf}}} \caption{Structure discovery in terms of SHD and FDR to the true graph, on synthetic vector-valued data set.} \label{fig:multid} \end{figure} \begin{figure}[!ht] \centering \subfigure{\scalebox{0.22}[0.22]{\includegraphics{./compare10W_multid-eps-converted-to.pdf}}} \caption{Parameter estimates (before thresholding) of the graph on synthetic vector-valued data set.} \label{fig:multidG} \end{figure} \vspace{-0.3cm} \subsection{Benchmark Data Sets}\label{sec:data2} A benefit of the proposed method is that it naturally handles discrete variables, a case precluded by linear SEM. We demonstrate the use of DAG-GNN on three discrete benchmark data sets: Child, Alarm, and Pigs~\citep{MMPCcor}. For comparison is the state-of-the-art exact DAG solver GOPNILP~\citep{cussens2016polyhedral}, which is based on a constrained integer programming formulation. We use 1000 samples for learning. One sees from Table~\ref{Table:discrete} that our results are reasonably close to the ground truth, whereas not surprisingly the results of GOPNILP are nearly optimal. The BIC score gap exhibits by DAG-GNN may be caused by the relatively simple autoencoder architecture, which is less successful in approximating multinomial distributions. Nevertheless, it is encouraging that the proposed method as a unified framework can handle discrete variables with only slight changes in the network architecture. \begin{table}[!ht] \centering \caption{BIC scores on benchmark datasets of discrete variables.} \label{Table:discrete} \vskip 0.1in \small \begin{tabular}{ccccc} \hline Dataset& $m$ &Groundtruth&GOPNILP&DAG-GNN\\ \hline Child & 20 & \texttt{-1.27e+4} & \texttt{-1.27e+4} & \texttt{-1.38e+4}\\ Alarm & 37 & \texttt{-1.07e+4} & \texttt{-1.12e+4} & \texttt{-1.28e+4}\\ Pigs & 441 & \texttt{-3.48e+5} & \texttt{-3.50e+5} & \texttt{-3.69e+5}\\ \hline \end{tabular} \end{table} \subsection{Applications}\label{sec:data3} We consider a bioinformatics data set~\citep{sachs2005causal} for the discovery of a protein signaling network based on expression levels of proteins and phospholipids. This is a widely used data set for research on graphical models, with experimental annotations accepted by the biological research community. The data set offers continuous measurements of expression levels of multiple phosphorylated proteins and phospholipid components in human immune system cells, and the modeled network provides the ordering of the connections between pathway components. Based on $n=7466$ samples of $m=11$ cell types, \citet{sachs2005causal} estimate 20 edges in the graph. In Table~\ref{Table:protein}, we compare DAG-GNN with DAG-NOTEARS as well as FSG, the fast greedy search method proposed by~\citet{ramsey2017million}, against the ground truth offered by~\citet{sachs2005causal}. The proposed method achieves the lowest SHD. We further show in Figure~\ref{fig:protein} our estimated graph. One observes that it is acyclic. Our method successfully learns 8 out of 20 ground-truth edges (as marked by red arrows), and predicts 5 indirectly connected edges (blue dashed arrows) as well as 3 reverse edges (yellow arrows). \begin{table}[!ht] \centering \caption{Results on protein signaling network: comparison of the predicted graphs with respect to the ground truth.} \label{Table:protein} \vskip 0.1in \begin{tabular}{ccc} \hline Method& SHD & \# Predicted edges\\ \hline FGS&22&17\\ NOTEARS&22&16\\ DAG-GNN&19&18\\ \hline \end{tabular} \end{table} \begin{figure}[!ht] \centering \subfigure{\scalebox{0.6}[0.55]{\includegraphics{./proteinresults-eps-converted-to.pdf}}} \caption{Estimate protein signaling network.} \label{fig:protein} \end{figure} For another application, we develop a new causal inference task over relations defined in a knowledge base (KB) schema. The task aims at learning a BN, the nodes of which are relations and the edges indicate whether one relation suggests another. For example, the relation person/Nationality may imply person/Language, because the spoken language of a person naturally associates with his/her nationality. This task has a practical value, because most existing KBs are constructed by hand. The success of this task helps suggest meaningful relations for new entities and reduce human efforts. We construct a data set from FB15K-237~\citep{toutanova2015representing} and list in Table~\ref{tab:kb} a few extracted causal relations. Because of space limitation, we defer the details and more results in the supplementary material. One sees that these results are quite intuitive. We plan a comprehensive study with field experts to systematically evaluate the extraction results. \begin{table}[!ht] \centering \caption{Examples of extracted edges with high confidence } \label{tab:kb} \vskip 0.1in \small \begin{tabular}{rcl} \toprule[0.8pt] film/ProducedBy &$\Rightarrow$ &film/Country \\ film/ProductionCompanies & $\Rightarrow$ &film/Country \\ \midrule person/Nationality& $\Rightarrow$& person/Languages \\ person/PlaceOfBirth& $\Rightarrow$& person/Languages \\ \midrule person/PlaceOfBirth& $\Rightarrow$& person/Nationality \\ person/PlaceLivedLocation& $\Rightarrow$& person/Nationality\\ \toprule[0.8pt] \end{tabular} \vspace{-0.3cm} \end{table} \section{Conclusion} DAG structure learning is a challenging problem that has long been pursued in the literature of graphical models. The difficulty, in a large part, is owing to the NP-hardness incurred in the combinatorial formulation. \citet{Zheng2018} propose an equivalent continuous constraint that opens the opportunity of using well developed continuous optimization techniques for solving the problem. In this context, we explore the power of neural networks as functional approximators and develop a deep generative model to capture the complex data distribution, aiming at better recovering the underlying DAG with a different design of the objective function. In particular, we employ the machinery of variational autoencoders and parameterize them with new graph neural network architectures. The proposed method handles not only data generated by parametric models beyond linear, but also variables in general forms, including scalar/vector values and continuous/discrete types. We have performed extensive experiments on synthetic, benchmark, and application data and demonstrated the practical competitiveness of the proposal.
{'timestamp': '2019-04-24T02:04:24', 'yymm': '1904', 'arxiv_id': '1904.10098', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10098'}
arxiv
\section{Introduction} This paper is motivated by solving the following convex-concave problem: \begin{align}\label{eqn:main} \min_{x\in X}\max_{y\in \text{dom}(\phi^*)}y^{\top}\ell(x) - \phi^*(y) + g(x) \end{align} where $X\subseteq\mathbb{R}^d$ is a closed convex set, $\ell(x) = (\ell_1(x), \ldots, \ell_n(x))^{\top}: X\rightarrow\mathbb{R}^n$ is a lower-semicontinuous mapping whose component function $\ell_i(\mathbf{x})$ is lower-semicontinuous and convex, $\phi^*(y): \text{dom}(\phi^*)\rightarrow\mathbb{R}$ is a convex function whose convex conjugate is denoted by $\phi$, and $g(\mathbf{x}):X\rightarrow\mathbb{R}$ is a lower-semicontinuous convex function. To ensure the convexity of the problem, it is assumed that $\text{dom}(\phi^*)\subseteq\mathbb{R}_+^n$ if $\ell(x)$ is not an affine function. By using the convex conjugate $\phi^*$, the problem~(\ref{eqn:main}) is equivalent to the following convex minimization problem: \begin{align}\label{eqn:primal} \min_{x\in X}P(x): = \phi(\ell(x)) + g(x). \end{align} A particular family of min-max problem~(\ref{eqn:main}) and its minimization form~(\ref{eqn:primal}) that has been considered extensively in the literature~\citep{DBLP:conf/icml/ZhangL15,DBLP:journals/corr/YuLY15,DBLP:conf/nips/TanZML18,citeulike:11703902,DBLP:conf/nips/LinLX14} is that $\ell(x) = Ax + b$ is an affine function and $\phi(s)= \sum_{i=1}^n \phi_i(s_i)$ for $s\in\mathbb{R}^n$ is decomposable. In this case, the problem~(\ref{eqn:primal}) is known as (regularized) {empirical risk minimization} problem in machine learning: \begin{align}\label{eqn:p} \min_{x \in X} \frac{1}{n} \sum_{i=1}^{n} \phi_{i}( a_i^{\top}x + b_i ) + g(x) , \end{align} where $a_i$ is the $i$-th row of $A$ and $b_i$ is the i-th element of $b$. However, stochastic optimization algorithms with fast convergence rates are still under-explored for a more challenging family of problems of~(\ref{eqn:main}) and~(\ref{eqn:primal}) where $\ell(x)$ is not necessarily an affine or smooth function and $\phi$ is not necessarily decomposable. It is our goal to design new stochastic primal-dual algorithms for solving these problems with a fast convergence rate. A key motivating example of the considered problem is to solve a distributionally robust optimization problem: \begin{align}\label{eqn:dro} \min_{x\in X}\max_{y\in \Delta_n}\sum_{i=1}^ny_i \ell_i(x) - V(y, y_0) + g(x), \end{align} where $\Delta_n = \{y\in\mathbb{R}^n; y_i\geq 0, \sum_iy_i = 1\}$ is a simplex, and $V(y, y_0)$ denotes a divergence measure (e.g., $\phi$-divergence) between two sets of probabilities $y$ and $y_0$. In machine learning with $\ell_i(x)$ denoting the loss of a model $x$ on the $i$-th example, the above problem corresponds to {\bf robust risk minimization paradigm}, which can achieve variance-based regularization for learning a predictive model from $n$ examples~\citep{DBLP:conf/nips/NamkoongD17}. Other examples of the considered challenging problems can be found in robust learning from multiple perturbed distributions~\citep{NIPS2017_7056} in which $\ell_i(x)$ corresponds to the loss from the $i$-th perturbed distribution, and minimizing non-decomposable loss functions~\citep{DBLP:conf/nips/FanLYH17,DBLP:conf/nips/DekelS06}. With stochastic (sub)-gradients computed for $x$ and $y$, one can employ the conventional primal-dual stochastic gradient method or its variant~\citep{Nemirovski:2009:RSA:1654243.1654247,juditsky2011} for solving the problem~(\ref{eqn:main}). Under appropriate basic assumptions, one can derive the standard $O(1/\sqrt{T})$ convergence rate with $T$ being the number of stochastic updates. However, the convergence rate $O(1/\sqrt{T})$ is known as a slow convergence rate. It is always desirable to design optimization algorithms with a faster convergence. Nonetheless, to the best of our knowledge stochastic primal-dual algorithms with a fast convergence rate of $O(1/T)$ in terms of minimizing $P(x)$ remain unknown in general, even under the strong convexity of $\phi^*$ and $g$. In contrast, if $\phi$ is decomposable and $P$ is strongly convex, the standard stochastic gradient method for solving~(\ref{eqn:primal}) with an appropriate scheme of step size has a convergence rate of $O(1/T)$~\citep{DBLP:journals/ml/HazanAK07,DBLP:journals/jmlr/HazanK11a}. A direct extension of algorithms and analysis for stochastic strongly convex minimization to the stochastic concave-concave optimization does not give a satisfactory $O(1/T)$ convergence rate~\footnote{One may obtain a dimensionality dependent convergence rate of $O(n/T)$ by following conventional analysis, but it is not the standard dimensionality independent rate that we aim to achieve. }. It is still {\bf an open problem} that whether there exists a stochastic primal-dual algorithm by solving the convex-concave problem~(\ref{eqn:main}) that enjoys a fast rate of $O(1/T)$ in terms of minimizing $P(x)$. {\bf The major contribution} of this paper is to fill this gap by developing stochastic primal-dual algorithms for solving~(\ref{eqn:main}) such that they enjoy a faster convergence than $O(1/\sqrt{T})$ in terms of the primal objective gap. In particular, under the assumptions that $\nabla\phi$ is Lipschitz continuous, $\ell_i(x)$ are Lipschitz continuous and the minimization problem~(\ref{eqn:primal}) satisfies the strong convexity condition, the proposed algorithms enjoy an iteration complexity of $O(1/\epsilon)$ for finding a solution $x$ such that $\mathrm{E}[P(x) - \min_{x\in X}P(x)]\leq \epsilon$, which corresponds to a faster convergence rate of $O(1/T)$. The key difference of the proposed algorithms from the traditional stochastic primal-dual algorithm is that it is required to compute a logarithmic number of deterministic updates for $y$ in the following form: \begin{align} \mathcal A(x) = \arg\max_{y\in\text{dom}(\phi^*)}y^\top\ell(x) - \phi^*(y), \end{align} which can be usually solved in $O(n)$ time complexity. It would be worth noting that $\mathcal A(x) = \nabla \phi(\ell(x))$ (See Appendix \ref{app:sec:regarding_A}). When $n$ is a moderate number, the proposed algorithms could converge faster than the traditional primal-dual stochastic gradient method. It is also important to note that we do not assume the proximal mapping of $\phi^*$ and $g$ can be easily computed. Instead, our algorithms only require (stochastic) sub-gradients of $\phi^*$ and $g$, which make them applicable and efficient for solving more challenging problems where $g$ is an empirical sum of individual functions. In addition, the proposed algorithms and theories can be easily extended to the case that $\nabla\phi$ is H\"older~ continuous and the minimization problem~(\ref{eqn:primal}) satisfies a more general local error bound condition as defined later, with intermediate faster rates established. \section{Related Work}\label{sec:rw} Stochastic primal-dual gradient method and its variant were first analyzed by~\citep{Nemirovski:2009:RSA:1654243.1654247} for solving a more general problem $\min_{x\in X}\max_{y\in Y}\mathrm{E}_{\xi}[f(x, y; \xi)]$. Under the standard bounded stochastic (sub)-gradient assumption, a convergence rate of $O(1/\sqrt{T})$ was established for a primal-dual gap, which implies a convergence rate of $O(1/\sqrt{T})$ for minimizing the primal objective $P(x) = \max_{y\in Y}\mathrm{E}_{\xi}[f(x, y; \xi)]$. Later, there are couple of studies that aim to strengthen this convergence rate by leveraging the smoothness of $f(x, y; \xi)$ or the involved function when there is a special structure of the objective function~\citep{juditsky2011,doi:10.1137/130919362,Chen2017}. However, the worst-case convergence rate of these later algorithms is still dominated by $O(1/\sqrt{T})$. Without smoothness assumption on $\ell(\mathbf{x})$ or a bilinear structure, these later algorithms are not directly applicable to solving~(\ref{eqn:main}). In addition, Frank Wolfe algorithms are analyzed for saddle point problems in~\citep{gidel2016frank}, which could also achieve a convergence rate of $O(1/\sqrt{T})$ in terms of primal-dual gap under the smoothness condition. Recently, there emerge several algorithms with faster convergence for solving~(\ref{eqn:main}) by leveraging the bilinear structure and strong convexity of $\phi^*$ and $g$. For example, \citet{DBLP:conf/icml/ZhangL15} proposed a stochastic primal-dual coordinate (SPDC) method for solving~(\ref{eqn:p}) under the condition that $\ell(x) = Ax$ is of bilinear structure and $\phi^*$ is strongly convex. When $g$ is also a strongly convex function, SPDC enjoys a linear convergence for the primal-dual gap. Other variants of SPDC have been considered in~\citep{DBLP:journals/corr/YuLY15,DBLP:conf/nips/TanZML18} for solving~(\ref{eqn:main}) with bilinear structure. \citet{DBLP:conf/nips/PalaniappanB16} proposed stochastic variance reduction methods for solving a family of saddle-point problems. When applied to~(\ref{eqn:main}), they require $\ell(\mathbf{x})$ is either an affine function or a smooth mapping. If additionally $g$ and $\phi^*$ are strongly convex, their algorithms also enjoy a linear convergence for finding a solution that is $\epsilon$-close to the optimal solution in squared Euclidean distance. \citet{DBLP:journals/corr/abs-1802-01504} established a similar linear convergence of a primal-dual SVRG algorithm for solving~(\ref{eqn:main}) when $\ell = Ax$ is an affine function with a full column rank for $A$, $g$ is smooth, and $\phi^*$ is smooth and strongly convex, which are stronger assumptions than ours. All of these algorithms except \citep{DBLP:journals/corr/abs-1802-01504} also need to compute the proximal mapping of $\phi_i^*$ and $g$ at each iteration. In contrast, the present work is complementary to these studies aiming to solve a more challenging family of problems. In particular, the proposed algorithms do not require the bilinear structure or the smoothness of $\ell$, and the smoothness and strong convexity of $\phi^*$ and $g$ are also not necessary. In addition, we do not assume that $g$ and $\phi^*$ have an efficient proximal mapping. Several recent studies have been devoted to stochastic AUC optimization based on a min-max formulation that has a bilinear structure~\citep{fastAUC18,DBLP:conf/icml/NatoleYL18}, aiming to derive a faster convergence rate of $O(1/T)$. The differences from the present work is that (i) \citep{fastAUC18}'s analysis is restricted to the online setting for AUC optimization; (ii) \citep{DBLP:conf/icml/NatoleYL18} only proves a convergence rate of $O(1/T)$ in term of squared distance of found primal solution to the optimal solution under the strong convexity of the regularizer on the primal variable, which is weaker than our results on the convergence of the primal objective gap. To the best of our knowledge, the present work is the first one that establishes a convergence rate of $O(1/T)$ in terms of minimizing $P(x)$ for the proposed stochastic primal-dual methods by solving a general convex-concave problem~(\ref{eqn:main}) without bilinear structure or smoothness assumption on $\ell(\mathbf{x})$ under (weakly local) strong convexity. Restart schemes are recently considered to get improved convergence rate under some conditions. In~\citep{roulet2017sharpness}, restart scheme is analyzed for smooth convex problems under the sharpness and H\"older~ continuity condition. In~\citep{dvurechensky2018generalized}, a universal algorithm is proposed for variational inequalities under H\"older~ conituity condition where the H\"older~ parameters are unknown. Stochastic algorithms are proposed for strongly convex stochastic composite problems in \citep{ghadimi2012optimal,ghadimi2013optimal}. Finally, we would like to mention that our algorithms and techniques share many similarities to that proposed in~\citep{ICMLASSG} for solving stochastic convex minimization problems under the local error bound condition. However, their algorithms are not directly applicable to the convex-concave problem~(\ref{eqn:main}) or the problem~(\ref{eqn:primal}) with non-decomposable function $\phi$. The novelty of this work is the design and analysis of new algorithms that can leverage the weak local strong convexity or more general local error bound condition of the primal minimzation problem~(\ref{eqn:primal}) through solving the convex-concave problem~(\ref{eqn:main}) for enjoying a faster convergence. \section{Preliminaries}\label{sec:prel} Recall that the problem of interest: \begin{align}\label{eq:primal_dual_problem} \min_{x\in X}\bigg\{P(x) =& \phi( \ell( x ) ) + g(x) \nonumber\\ = &\max_{y\in Y} \underbrace{y^{\top} \ell ( x ) - \phi^*(y) + g(x)}\limits_{f(x,y)}\bigg\}, \end{align} where $Y= \text{dom}(\phi^*)$. Let $X^*$ denote the optimal set of the primal variable for the above problem, $P^{*}$ denote the optimal primal objective value and $x^* = \arg\min_{z \in X^*} ||x - z||$ is the optimal solution closest to $x$, where $\|\cdot\|$ denotes the Euclidean norm. Let $\Pi_{\Omega}[\cdot]$ denote the projection onto the set $\Omega$. Denote by $\mathcal{S}_{\epsilon} := \{ x \in X: P(x) - P^* \leq \epsilon \}$ and $\mathcal{L}_{\epsilon} := \{ x \in X: P(x) - P^* =\epsilon \}$ denote the $\epsilon$-level set and $\epsilon$-sublevel set of the primal problem, respectively. A function $f(x): X\rightarrow\mathbb{R}$ is $L$-smooth if it is differentiable and its gradient is $L$-Lipchitz continuous, i.e., $\|\nabla f(x_1) - \nabla f(x_2)\|\leq L\|x_1 - x_2\|, \forall x_1, x_2\in X$. A differentiable function $f$ is said to have an $(L,v)$-H\"{o}lder continuous gradient with $v\in(0,1]$ iff $\|\nabla f(x_1) - \nabla f(x_2)\|\leq L\|x_1 - x_2\|^v$. When $v=1$, H\"{o}lder continuous gradient reduces to Lipchitz continuous gradient. A function $f$ is called $\lambda$-strongly convex if for any $x_1, x_2\in X$ there exists $\lambda>0$ such that \begin{align*} f(x_1) \geq f(x_2) + \partial f(x_2)^{\top}(x_1 - x_2) + \frac{\lambda}{2}\|x_1 - x_2\|^2, \end{align*} where $\partial f(\mathbf{x})$ denotes any subgradient of $f$ at $x$. A more general definition is the uniform convexity. $f$ is uniformly convex with degree $p\geq 2$ if for any $x_1,x_2\in X$ there exists $\lambda>0$ such that \begin{align*} f(x_1) \geq f(x_2) + \partial f(x_2)^{\top}(x_1 - x_2) + \frac{\lambda}{2}\|x_1 - x_2\|^p. \end{align*} For analysis of the proposed algorithms, we need a few basic notions about convex conjugate. For an extended real-valued convex function $h: \mathbb{R}^d\rightarrow \mathbb{R}\cup\{\infty, -\infty\}$, the convex conjugate of $h$ is defined as \begin{align*} h^*(y) = \max_{x}y^{\top}x - h(x). \end{align*} The convex conjugate of $h^*$ is $h$. Due to the convex duality, if $h^*$ is $\lambda$-strongly convex then $h$ is differentiable and is $(1/\lambda)$-smooth. More generally, if $h^*$ is $p$-uniformly convex then $h$ is differentiable and its gradient is $(L, v)$-H\"{o}lder continuous where $v = \frac{1}{p-1}$, $L = (\frac{1}{\lambda})^{v}$~\citep{Nesterov2015}. One of the conditions that allows us to derive a fast rate of $O(1/T)$ for a stochastic algorithm is that both $g$ and $\phi^*$ are strongly convex, which implies that $f(x, y)$ is strongly convex in terms of $x$ and strongly concave in terms of $y$. One might regard this as a trivial task given the $O(1/T)$ result for stochastic strongly convex minimization where a stochastic gradient is available for the objective function to be minimized~\citep{DBLP:journals/ml/HazanAK07,DBLP:journals/jmlr/HazanK11a}. However, the analysis for stochastic strongly convex minimization is not directly applicable to stochastic primal-dual algorithms, as briefly explained later as we present our results. Moreover, the strong convexity of $g$ can be relaxed to a weak strong convexity of $P$ to derive a similar order of convergence rate, i.e., for any $x\in X$, we have \begin{align*} dist(x, X^{*}) \leq c(P(x) - P^{*} )^{1/2}, \end{align*} where $dist(x, X^{*}) =\min_{z\in X^*}\|z-x\|_2$ is the distance between $x$ and the optimal set $X^*$. More generally, we can consider a setting in which $P$ satisfies a local error bound (or local growth) condition as defined below. \begin{defi} A function $P(x)$ is said to be satisfied local error bound (LEB) condition if for any $x\in \mathcal{S}_{\epsilon}$, \begin{align}\label{eq:leb_condition} dist(x, X^{*}) \leq c ( P(x) - P^{*} )^{\theta}, \end{align} \noindent where $c>0$ is a constant, and $\theta \in [0, 1]$ is a parameter. \end{defi} This condition was recently studied in~\citep{yang2018rsg} for developing a faster subgradient method than the standard subgradient method, and was laster considered in~\citep{ICMLASSG} for stochastic convex optimization. A global version of the above condition (known as the global error bound condition) has a long history in mathematical programming~\citep{Pang:1997}. However, exploiting this condition for developing stochastic primal-dual algorithms seems to be new. When $\theta=1/2$, the above condition is also referred to as weakly local strong convexity. When $\theta=0$, it can capture general convex functions as long as $\text{dist}(x, X^*)$ is upper bounded for $x\in \mathcal S_\epsilon$, which is true if $X^*$ is compact or $X$ is compact. In parallel with the relaxed condition on $P$, we can also relax the smoothness condition on $\phi$ or strong convexity condition on $\phi^*$ to H\"{o}lder continuous gradient condition on $\phi$ or a uniformly convexity condition on $\phi^*$. Under the local error bound condition of $P$ and the H\"{o}lder continuous gradient condition of $\phi$, we are able to develop stochastic primal-dual algorithms with intermediate complexity depending on $\theta$ and $\nu$, which varies from $O(1/\epsilon^2)$ to $O(\log(1/\epsilon))$. Formally, we will develop stochastic primal-dual algorithms for solving~(\ref{eq:primal_dual_problem}) under the following assumptions. \begin{ass}\label{assumption:general} For Problem~(\ref{eq:primal_dual_problem}), we assume \begin{enumerate} \item[(1)] There exist $x_{0} \in X$ and $\epsilon_{0} > 0$ such that $P(x_{0}) - P^{*} \leq \epsilon_{0}$; \item[(2)] Let $\nabla_{x} f(x,y;\xi)$ and $\nabla_{y} f(x,y;\xi)$ denote the stochastic subgradient of $f(x,y)$ w.r.t. $x$ and $y$, respectively. There exists constants $M\geq 0$ and $B\geq 0$ such that $|| \nabla_{x} f(x,y;\xi) || \leq M$ and $|| \nabla_{y} f(x,y;\xi) || \leq B$. \item[(3)] $\phi^*(\cdot)$ is $p$-uniformly convex with $\lambda_\phi>0$ such that $\phi$ has $(L,v)$-H\"older~ continuous gradient where $v = \frac{1}{p-1}$ and $L=(1/\lambda_\phi)^v$. \item[(4)] $\ell(x)$ is $G$-Lipchitz continuous for $x\in X$. \item[(5)] One of the following conditions hold: (i) $P(x)$ is $\mu$-strongly convex; (ii) $P(x)$ satisfies the LEB condition for $c>0$ and $\theta\in(0,1]$. \end{enumerate} \end{ass} {\bf Remark.} Assumption~\ref{assumption:general} (1) assumes that there is a lower bound of $P^{*}$, which is usually satisfied in machine learning problems. Assumption~\ref{assumption:general} (2) is a common assumption usually made in existing stochastic-based methods. Note that we do not assume $g$ and $\phi^*$ have efficient proximal mapping. Instead, we only require a stochastic subgradient of $g$ and $\phi^*$. Assumption~\ref{assumption:general} (3) is a general condition which unifies both smooth and non-smooth assumptions on $\phi$. When $v = 1$, $\phi(\cdot)$ satisfies the classical smooth condition with parameter $L$. When $v = 0$, it is the classical non-smooth assumption on the boundness of the subgradients. We will state our convergence results in terms of $v$ and $L$ instead of $p$ and $\lambda_\phi$. Assumption~\ref{assumption:general} (4) on the Lipschitz continuity of $\ell(x)$ is more general than assuming a bilinear form $\ell(x) = Ax + b$. Finally, we note that assuming the strong convexity of $P(x)$ allows us to develop a stochastic primal-dual algorithm with simpler updates. \section{Main Results}\label{sec:main} In this section, we will present our main results for solving~(\ref{eq:primal_dual_problem}). Our development is divided into three parts. First, we present a stochastic primal-dual algorithm and its convergence result when the primal objective function $P(x)$ is strongly convex and $\phi^*$ is also strongly convex. Then we extend the result into a more general case, i.e., $P(x)$ satisfying LEB condition and $\phi^*$ is uniformly convex. Lastly, we propose an adaptive variant with the same order of convergence result when the value of parameter $c$ in LEB condition is unknown, which is also useful for tackling problems without knowing the value of $\theta$. For both cases, we assume $P(x_0) - P^* \leq \epsilon_0$. \subsection{Restarted Stochastic Primal-Dual Algorithm for Strongly Convex $P$} \setlength{\textfloatsep}{5pt \begin{algorithm}[t] \caption{Restarted Stochastic Primal-Dual algorithm for strongly convex $P$: RSPD$^\text{sc}$($x_{0}, S, T, \epsilon_0$)} \label{alg:RSPDsc} \begin{algorithmic}[1] \STATE Initialization: $x_{0}^{(1)} = x_0 \in X$, $y_{0}^{(1)} = \mathcal A(x_{0}^{(1)})$, $ \eta_{x,1} = \frac{2\epsilon_{0}}{45 M^{2} }$, $\eta_{y,1} = \frac{2\epsilon_{0}}{45 B^{2} }$. \FOR{$s = 1, 2, ..., S$} \FOR{$t = 0, 1, 2, ..., T_s-1$} \label{alg1:line:pd_sa_inner_loop_start} \STATE $x_{t+1}^{(s)} = \Pi_{X} (x_{t}^{(s)} - \eta_{x,s} \nabla_{x} f (x_{t}^{(s)}, y_{t}^{(s)}; \xi_{t}^{s})) $ \label{alg1:line:pd_sa_update_x} \STATE $y_{t+1}^{(s)} = \Pi_{Y} (y_{t}^{(s)} + \eta_{y,s} \nabla_{y} f (x_{t}^{(s)}, y_{t}^{(s)}; \xi_{t}^{s})) $ \label{alg1:line:pd_sa_update_y} \ENDFOR \label{alg1:line:pd_sa_inner_loop_end} \STATE $x_{0}^{(s+1)} = {\bar{x}}_{s} = \frac{1}{T} \sum_{t=0}^{T-1} x_{t}^{(s)}$ \label{line:pd_sa_update_x_initial} \STATE $y_{0}^{(s+1)} =\mathcal A(x_{0}^{(s+1)})$ \label{line:pd_sa_update_y_initial} \STATE $\eta_{x,s+1} = \frac{\eta_{x,s} }{2}$ and $\eta_{y,s+1} = \frac{\eta_{y,s} }{2}$, $T_{s+1} = 2T_s$ \label{alg1:line:pd_update_R} \ENDFOR \STATE Return ${\bar{x}}_{S}.$ \end{algorithmic} \end{algorithm} The detailed updates of the proposed stochastic algorithm for strongly convex $P$ are presented in Algorithm~\ref{alg:RSPDsc}, to which we refer as restarted stochastic primal-dual algorithm or RSPD$^\text{sc}$ for short. The algorithm is based on a restarting idea that have been used widely in existing studies~\citep{hazan-20110-beyond,ghadimi2013optimal,ICMLASSG,yang2018rsg}. It runs in epoch-wise and it has two loops. The steps 3-7 are the standard updates of stochastic primal-dual subgradient method~\citep{Nemirovski:2009:RSA:1654243.1654247}. However, the key difference from these previous studies is that the restarted solution for the dual variable $y$ for the next epoch $s+1$ is computed based on the averaged primal variable for the $s$-th epoch. It is this step that explores the strong convexity of $\phi^*$, which together with the restarting scheme allows us exploring the strong convexity of $P$ to derive a fast convergence rate of $O(1/T)$ with $T$ being the total number of iterations. Below, we will briefly discuss the path for proving the fast convergence rate of RSPD. We first show that why the standard analysis for strongly convex minimization can not be generalized to the stochastic convex-concave problem to derive the fast convergence rate of $O(1/T)$. Let $\nabla_{x,t} = \nabla_{x} f (x_{t}, y_{t}; \xi_{t})$ and similarly for $\nabla_{y,t}$. A standard convergence analysis for the inner loop (steps 3-6) of Algorithm~\ref{alg:RSPDsc} usually starts from the following inequalities. \begin{lem} For the updates in Step 4 and 5 omitting the subscript $s$, the following holds for any $x\in X, y\in Y$ \begin{align} & \nabla_{x,t}^{\top}(x_t - x)\leq \frac{\|x_t - x\|^2 -\|x_{t+1} - x\|^2}{2\eta_{x}} + \frac{\eta_{x} M^2}{2}\label{eqn:bprimal}\\ & \nabla_{y,t}^{\top}(y - y_t)\leq \frac{\|y_t - y\|^2 -\|y_{t+1} - y\|^2}{2\eta_{y}} + \frac{\eta_{y} B^2}{2}\label{eqn:bdual}. \end{align} \end{lem} For stochastic strongly convex minimization problems in which $y$ is absent in the above inequalities, one can take expectation over~(\ref{eqn:bprimal}) and then apply the $\lambda$-strong convexity of $f(x)$ to get the following inequality \begin{align*} \mathrm{E}[f(x_t) - f(x)]\leq& \frac{\|x_t - x\|^2 -\|x_{t+1} - x\|^2}{2\eta_{x}} + \frac{\eta_{x} M^2}{2} - \frac{\lambda\|x_t - x\|^2}{2}. \end{align*} Based on the above inequalities for all $t=1,\ldots, T$, one can design a particular scheme of step size $\eta_{x,t} = 1/(\lambda t)$ that allows us to derive $\widetilde O(1/T)$ convergence rate. However, such analysis cannot be extended to the primal-dual case. A naive approach would be taking expectation for both~(\ref{eqn:bprimal}) and~(\ref{eqn:bdual}) for a fixed $x, y$ and applying the $\lambda_x$-strong convexity (resp. $\lambda_y$-strong concavity) of $f(x, y)$ in terms of $x$ (resp. $y$), which yields the following inequalities \begin{align*} \mathrm{E}[f(x_t, y_t) - f(x, y_t)]\leq& \frac{\|x_t - x\|^2 -\|x_{t+1} - x\|^2}{2\eta_{x}} + \frac{\eta_{x} M^2}{2} - \frac{\lambda_x\|x_t - x\|^2}{2}. \end{align*} \begin{align*} \mathrm{E}[f(x_t, y) - f(x_t, y_t)]\leq& \frac{\|y_t - y\|^2 -\|y_{t+1} - y\|^2}{2\eta_{y}} + \frac{\eta_{y} B^2}{2} - \frac{\lambda_y\|y_t - y\|^2}{2}. \end{align*} It is notable that in deriving the above inequalities, $x$ and $y$ have to be independent of $\xi_1, \ldots, \xi_T$. By adding the above inequalities together and applying the same analysis for the R.H.S with $\eta_{x, t} = 1/(\lambda_x t)$ and $\eta_{y,t} = 1/(\lambda_{y}t)$, we can obtain the following inequalities for any fixed $y\in Y$ and $x\in X$ independent of $\xi_1, \ldots, \xi_T$: \begin{align}\label{eqn:naive} \mathrm{E}\left[(f(\hat x_T, y) - f(x, \hat y_T))\right]\leq& O\left(\frac{\log T}{T}\right), \end{align} where $\hat x_T = \sum_{t=0}^{T-1}x_t/T$ and $\hat y_T = \sum_{t=0}^{T-1} y_t/T$. However, the above inequality does not imply the convergence for the standard definition of primal-dual gap of $\max_{x\in X, y\in Y}(f(\hat x_T, y) - f(x, \hat y_T))$ or even the primal objective gap $P(\hat x_T) - \min_{x\in X}P(x)$. The main obstacle is that we cannot set $y = \arg\max_{y\in Y}f(\hat x_T, y)$ which will make $y$ depend on $\xi_1, \ldots, \xi_T$ and hence make the expectional analysis fail. It would be worth noting that following \citep{gidel2016frank}, one could derive the upper bound of primal-dual gap of $(\hat{x}_{T}, \hat{y}_{T})$ by $\max_{y \in Y} f(\hat{x}_{T}, y) - \min_{x \in X} f(x, \hat{y}_{T}) \leq \sqrt{2} P_{\mathcal{L}} \sqrt{f(\hat{x}_{T}, y^*) - f(x^*, \hat{y}_{T})}$ (see Equation (5), (13) and (14) therein), where $P_{\mathcal{L}}$ can be upper bounded by a constant and $y^* \in \arg\max_{y \in Y} f(x^*, y^*)$. Even if one sets $x = x^*$ and $y = y^*$ in (\ref{eqn:naive}), the convergence rate of primal-dual gap is only of $O(\sqrt{\log(T) / T})$, which is not what we pursue. Another approach that gets around of the issue introduced by taking the expectation is by using high probability analysis. To this end, one can use concentration inequalities to bound the martingale difference sequence $\sum_{t=1}^T(\nabla_{x} f (x_{t}, y_{t}; \xi_{t}) - \nabla_{x} f (x_{t}, y_{t}))^{\top}(x_t - x) $ and $\sum_{t=1}^T(\nabla_{y} f (x_{t}, y_{t}; \xi_{t}) - \nabla_{y} f (x_{t}, y_{t}))^{\top}(y - y_t) $ for a fixed $x$ and $y$~\citep{DBLP:conf/nips/KakadeT08}. However, in order to prove the primal objective gap $P(\hat x_T) - P^*$ one has to bound the later martingale difference sequence for any possible $y\in Y$ so that one can get $P(\hat x_t)$ from $\max_{y\in Y}f(\hat x_T, y)$. A standard approach for achieving this high probability bound is by using a covering number argument for the set $Y$. However, this will inevitably introduce dependence on the dimensionality of $y$. For example, an $\epsilon$-cover of a bounded ball of radius $R$ in $\mathbb{R}^n$ has cardinality of $O((R/\epsilon)^n)$, and of a simplex in $\mathbb{R}^n$ has cardinality of $O((1/\epsilon)^{n-1})$. To tackle the aforementioned challenges for both exceptional analysis and high probability analysis, we develop a different analysis for the proposed RSPD algorithm in order to achieve a faster convergence rate of $O(1/T)$ without explicit dependence on the dimensionality of $y$. In this subsection, we will focus on expectional convergence result, which will be extended to high probability convergence in next subsection. Our expectional analysis is build on the following lemma that is used to derive $O(1/\sqrt{T})$ convergence rate in the literature~\citep{Nemirovski:2009:RSA:1654243.1654247}. \begin{lem}\label{lemma:convergence_RSPDsc_per_stage} Let the Lines 4 and 5 of Algorithm~\ref{alg:RSPDsc} run for $T$ iterations with a fixed step size $\eta_x$ and $\eta_y$. Then \begin{align} \label{eq1:convergence_per_stage} \mathrm{E}[\max_{y\in Y} f(\bar x_T, y) - f(x^*, \bar y_T)] \leq & \frac{\mathrm{E}[|| x^* - x_{0} ||^{2}] }{\eta_x T } + \frac{\mathrm{E}[ || \hat y_T - y_{0} ||^{2}] }{\eta_y T }+ \frac{5\eta_x M^2}{2} + \frac{5\eta_y B^2}{2}, \end{align} where $\bar x_T = \sum_{t=0}^{T-1} x_{t}/T$, $\bar y_T = \sum_{t=0}^{T-1} y_{t}/T$, $\hat y_T = \arg\max_{y\in Y}f(\bar x_T, y)$ and $x^*\in X^*$. \end{lem} {\bf Remark:} A nice property of the above result is that the max over $y$ in the L.H.S is taken before expectation. Nevertheless, a simple approach for setting the step size as $O(1/\sqrt{T})$ still yields a convergence rate of $O(1/\sqrt{T})$ by assuming the size of $Y$ is bounded~\citep{Nemirovski:2009:RSA:1654243.1654247}. The proposed RSPD algorithm has the special design of computing the restarted solutions and setting the step sizes, which together allows us to achieve $O(1/T)$ convergence rate as stated in the following theorem. The key idea is that by using $y_0^{(s+1)}=\mathcal A(x_0^{(s+1)})$ as a restarted point for the dual variable, we are able to connect $\|\hat y_T - y_0\|$ to $P(x_0^{(s)}) - P^*$ by using the strong convexity of $P$ and of $\phi^*$. The convergence result of RSPD$^\text{sc}$ is presented below. \begin{thm}\label{thm:RSPDsc} Suppose that Assumption~\ref{assumption:general} holds with $v=1$ and $P(x)$ being $\mu$-strongly convex. By setting $S = \lceil \log(\frac{\epsilon_{0}}{\epsilon}) \rceil$ and $T_1 = \frac{\max \{ 405M^2, 810 L^2G^2B^2 \}}{\mu\epsilon_{0}}$, then Algorithm~\ref{alg:RSPDsc} guarantees that $\mathrm{E}[P({\bar{x}}_{S}) - P^{*} ]\leq \epsilon$. The total number of iterations is $ O( \frac{1}{\mu\epsilon})$. \end{thm} {\bf Remark.} The equivalent convergence rate of the above result is $O(1/(\mu T))$ given a total number of iterations $T$. This matches the state-of-the-art convergence result for stochastic strongly convex minimization~\citep{hazan-20110-beyond}. Our algorithm can be applied to solving~(\ref{eqn:primal}) for non-decomposable $\phi$. In contrast to the standard stochastic primal-dual subgradient method, the additional computational overhead in RSPD$^\text{sc}$ is introduced by computing the restarted points $y_0^{s+1} = \mathcal A(x_0^{(s+1)})$. However, such computation only happens for a logarithmic number of times in the order of $O(\log(1/\epsilon))$. We defer the discussion on the total time complexity of RSPD to the next section for some particular applications. \begin{proof To prove Theorem~\ref{thm:RSPDsc}, we first need Lemma~\ref{lemma:convergence_RSPDsc_per_stage}. Its proof will be given in Appendix \ref{app:sec:proof:lem:convergence_RSPDsc_per_stage}. \yancomment{ To prove Theorem~\ref{thm:RSPDsc}, we first need the following lemma, whose proof will be given in Appendix. \begin{lem}\label{lemma:3} Let the Lines 4 and 5 of Algorithm~\ref{alg:RSPDsc} run for $T$ iterations by fixed step size $\eta_x$ and $\eta_y$. Then \begin{align} \label{eq1:convergence_per_stage} & \mathrm{E}[\max_{y\in Y} f(\bar x_T, y) - f(x^*, \bar y_T)]\leq \frac{\mathrm{E}[|| x^* - x_{0} ||^{2}] }{\eta_x T }+ \frac{\mathrm{E}[ || \hat y_T - y_{0} ||^{2}] }{\eta_y T }+ \frac{5\eta_x M^2}{2} + \frac{5\eta_y B^2}{2}, \end{align} where $\bar x_T = \sum_{t=0}^{T-1} x_{t}/T$, $\bar y_T = \sum_{t=0}^{T-1} y_{t}/T$, $\hat y_T = \arg\max_{y\in Y}f(\bar x_T, y)$ and $x^*\in X^*$. \end{lem} } Let $\epsilon_{s} = \frac{\epsilon_{s-1}}{2}$, by the setting of Algorithm~\ref{alg:RSPDsc}, we know $\eta_{x, s+1} = \frac{ 2 \epsilon_{s}}{45 M^2}$, $\eta_{y, s+1} = \frac{ 2 \epsilon_{s}}{45 B^2}$, and $x_{0}^{(s+1)} = {\bar{x}}_{s} = \frac{1}{T_{s}} \sum_{t=1}^{T_s} x_{t}^{(s)}$ for $s = 0, 1, \dots$. We will show $\mathrm{E}[P(x_{0}^{(s+1)})] - P^* \leq \epsilon_{s}$ by induction for $s = 0, 1, \dots$. It is easy to verify $ \mathrm{E}[P(x_{0}^{(1)})] - P^* \leq \epsilon_{0} $ for a sufficiently large $\epsilon_{0}$ according to Assumption~\ref{assumption:general}. Next, we need to show that conditional on $\mathrm{E}[P(x_{0}^{(s)}) ]- P^* \leq \epsilon_{s-1} $, then we have $$ \mathrm{E}[P(x_{0}^{(s+1)})] - P^*\leq \epsilon_{s}. $$ Consider the update of $s$-th stage. By Lemma~\ref{lemma:convergence_RSPDsc_per_stage} for the update of $s$-the stage, we have \begin{align* \mathrm{E}[f({\bar{x}}_{s}, \hat{y}({\bar{x}}_{s})) - f(x^*, {\bar{y}}_s)] \leq \frac{\mathrm{E}[|| x^* - x_{0}^{(s)} ||^{2}] }{\eta_{x,s} T_s } + \frac{\mathrm{E}[|| \hat{y}({\bar{x}}_{s}) - y_{0}^{(s)} ||^{2}]}{\eta_{y,s} T_s } + \frac{5 \eta_{x,s} M^{2} }{ 2 } + \frac{5 \eta_{y, s} B^{2}}{2}. \end{align*} Since $P({\bar{x}}_{s}) = f({\bar{x}}_{s}, \hat{y}({\bar{x}}_{s}))$ and $ P(x^*) = \max_{y \in Y} f(x^*, y) \geq f(x^*, {\bar{y}}_s)$, we have \begin{align}\label{eq1:convergence_induction} \mathrm{E}[P({\bar{x}}_{s}) - P^*] \leq & \frac{\mathrm{E}[|| x^* - x_{0}^{(s)} ||^{2}] }{\eta_{x,s} T_s } + \frac{\mathrm{E}[|| \hat{y}({\bar{x}}_{s}) - y_{0}^{(s)} ||^{2}]}{\eta_{y,s} T_s } + \frac{5 \eta_{x,s} M^{2} }{ 2 } + \frac{5 \eta_{y, s} B^{2}}{2}. \end{align} For the first term on the RHS of (\ref{eq1:convergence_induction}), by the strong convexity of $P(x)$ and the condition $\mathrm{E}[P(x_{0}^{(s)}) ]- P^* \leq \epsilon_{s-1} $ we have \begin{align*} \mathrm{E}[|| x^* - x_{0}^{(s)} || ^2] \leq \mathrm{E}\bigg[ \frac{2 }{\mu} ( P(x_{0}^{(s)}) - P^*)\bigg] \nonumber \leq \frac{2\epsilon_{s-1} }{\mu}. \end{align*} For the second term on the RHS of (\ref{eq1:convergence_induction}), \begin{align*} || \hat{y}({\bar{x}}_{s}) - y_{0}^{(s)} ||^{2} = & || \nabla \phi(\ell({\bar{x}}_{s})) - \nabla \phi(\ell(x_{0}^{(s)})) ||^{2} \\ \leq & L^{2} || \ell({\bar{x}}_{s}) - \ell(x_{0}^{(s)}) ||^{2v} \\ = & L^{2} || \ell({\bar{x}}_{s}) - \ell(x_{0}^{(s)}) ||^{2} \\ = & L^{2} G^{2} || {\bar{x}}_{s} - x_{0}^{(s)} ||^{2}, \end{align*} where the first equality is due to the set up of the algorithm and Lemma~\ref{lemma:supp:1}, the second equality is due to $\phi(\cdot)$ is smooth ($v=1$). Since $P(x)$ is strongly convex with parameter $\mu>0$, its optimal solution $x_*$ is unique, then we have \begin{align*} \mathrm{E}[ || \hat{y}({\bar{x}}_{s}) - y_{0}^{(s)} ||^{2}] \leq & 2L^{2} G^{2}( \mathrm{E}[|| {\bar{x}}_{s} - x_* ||^{2}] + \mathrm{E}[|| x_* - x_{0}^{(s)} ||^{2}])\\ \leq & \frac{4L^{2} G^{2}}{\mu}( \mathrm{E}[P({\bar{x}}_{s}) - P^* ] + \mathrm{E}[ P(x_{0}^{(s)}) - P^*]) \\ \leq & \frac{4L^{2} G^{2}}{\mu}( \mathrm{E}[P({\bar{x}}_{s}) - P^* ] + \epsilon_{s-1} ]). \end{align*} Then the inequality (\ref{eq1:convergence_induction}) becomes \begin{align* \mathrm{E}[P({\bar{x}}_{s}) - P^*] \leq & \frac{ 2\epsilon_{s-1} }{\mu \eta_{x,s} T_s } + \frac{\frac{4L^{2} G^{2}}{\mu}( \mathrm{E}[P({\bar{x}}_{s}) - P^* ] + \epsilon_{s-1} ])}{\eta_{y,s} T_s } + \frac{5 \eta_{x,s} M^{2} }{ 2 } + \frac{5 \eta_{y, s} B^{2}}{2}. \end{align*} By the setting of $ \eta_{x,s} = \frac{2\epsilon_{s-1}}{45 M^{2} }$, $\eta_{y,s} = \frac{2\epsilon_{s-1}}{45 B^{2} }$ and $T_s = \frac{\max \{ 405M^2, 810 L^2G^2B^2 \}}{\mu\epsilon_{s-1}}$, we know $\frac{\frac{4L^{2} G^{2}}{\mu}}{\eta_{y,s} T } \leq \frac{1}{9}$, then \begin{align*} \mathrm{E}[P({\bar{x}}_{s}) - P^*] \leq & \frac{9 \epsilon_{s-1}}{4 \eta_{x,s} \mu T_s } + \frac{ \epsilon_{s-1} }{8} + \frac{45 \eta_{x,s} M^{2} }{ 16 } + \frac{45 \eta_{y, s} B^{2}}{16} \leq \frac{\epsilon_{s-1}}{2} = \epsilon_s. \end{align*} Therefore, by induction, after running $S = \lceil \log(\frac{\epsilon_{0}}{\epsilon}) \rceil$ stages, we have $$ \mathrm{E}[P({\bar{x}}_{S}) - P^*] \leq \epsilon_{S} = \epsilon. $$ The total iteration complexity is $ \sum_{s=1}^{S} T_s = O (\frac{1}{\epsilon})$. \end{proof} \subsection{RSPD Algorithm under the LEB condition} In the previous subsection, we introduce the RSPD$^\text{sc}$ algorithm for solving problem~(\ref{eqn:main}) when the objective function $P(x)$ is strongly convex and $\phi(\cdot)$ is $L$-smooth. However, these conditions are sometimes too strong for many machine learning problems. In this subsection, we will relax these strong conditions by assuming that $P(x)$ satisfies the LEB condition (\ref{eq:leb_condition}) and $\phi(\cdot)$ has $(L,v)$-H\"older~ continuous gradient with $v\in[0,1]$. We will develop a different variant of RSPD that also has high probability convergence guarantee. Denote by $ \mathcal{B}_x(x_{0}, R) = \{x\in X: \|x - x_0\|\leq R\}$ a ball centered at $x_0$ with a radius $R$ intersected with $X$, and similarly by $ \mathcal{B}_y(y_{0}, R) = \{y\in Y: \|y - y_0\|\leq R\}$ a ball centered at $y_0$ with a radius $R$ intersected with $Y$. The second variant of the RSPD algorithm for solving problem~(\ref{eqn:main}) is summarized in Algorithm~\ref{alg:restart_primal_dual_algorithm_sa}, which is similar to the RSPD$^\text{sc}$ algorithm except that the iterates are projected to bounded balls centered at the initial solutions of each epoch. This complication on the updates is introduced for the purpose of high-probability analysis, which also allows us to tackle problems that satisfies the LEB condition with $\theta>1/2$. After each epoch, the proposed RSPD algorithm reduces the radius of the Euclidean ball. It is notable that this ball shrinkage technique is not new and has already used in Epoch-SGD method~\citep{hazan-20110-beyond} for high probability bound analysis. We set the same value of initial radius for primal variable $x$ and dual variable $y$ in RSPD algorithm for the convenience of analysis. However, one can use different values but the same order of convergence result will be obtained by changing the analysis slightly. Another feature of RSPD that is different from RSPD$^\text{sc}$ is that RSPD uses a constant number of iterations in the inner loop in order to accommodate the local error bound condition. \begin{algorithm}[t] \caption{RSPD($x_{0}, S, T, R_{x, 1}, \epsilon_0$)} \label{alg:restart_primal_dual_algorithm_sa} \begin{algorithmic}[1] \STATE Initialization: $x_{0}^{(1)} = x_0 \in X$, $y_{0}^{(1)} \in \mathcal A(x_{0}^{(1)})$, $R_{x, 1} \geq \frac{c \epsilon_{0}}{\epsilon^{1 - \theta}}$, $R_{y, 1} = L G^v R_{x, 1}^v$, $\eta_{x,1} = \frac{\epsilon_{0}}{40 M^{2} }$, $\eta_{y,1} = \frac{\epsilon_{0}}{40 B^{2} }$. \FOR{$s = 1, 2, ..., S$} \FOR{$t = 0, 1, 2, ..., T-1$} \label{alg:line:pd_sa_inner_loop_start} \STATE Compute $\mathcal G_{x, t} = \nabla_{x} f (x_{t}^{(s)}, y_{t}^{(s)}; \xi_{t}^{s})$ and $\mathcal G_y = \nabla_{y, t} f (x_{t}^{(s)}, y_{t}^{(s)}; \xi_{t}^{s})$ \STATE $x_{t+1}^{(s)} = \Pi_{\mathcal{B}_x(x_{0}^{(s)}, R_{x, s})} (x_{t}^{(s)} - \eta_{x,s} \mathcal G_{x, t} )$ \STATE $y_{t+1}^{(s)} = \Pi_{\mathcal{B}_y(y_{0}^{(s)}, R_{y, s})} (y_{t}^{(s)} + \eta_{y,s} \mathcal G_{x, t} )$ \label{alg2:line:pd_sa_update_y} \ENDFOR \label{alg:line:pd_sa_inner_loop_end} \STATE $x_{0}^{(s+1)} = {\bar{x}}_{s} = \frac{1}{T} \sum_{t=0}^{T-1} x_{t}^{(s)}$ \STATE $y_{0}^{(s+1)} =\mathcal A(x_{0}^{(s+1)})$ \label{alg2:line:pd_sa_update_x} \STATE $R_{x, s+1} = \frac{R_{x, s}}{2}$, $R_{y, s+1} = \frac{R_{y, s}}{2^v}$, $\eta_{x,s+1} = \frac{\eta_{x,s} }{2}$ and $\eta_{y,s+1} = \frac{\eta_{y,s} }{2}$ \label{alg:line:pd_update_R} \ENDFOR \STATE Return ${\bar{x}}_{S}.$ \end{algorithmic} \end{algorithm} We summarize the theoretical result of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa} with a high probability bound in the following theorem. \begin{thm}\label{theorem:convergence_rspd} Suppose that Assumption~\ref{assumption:general} holds and $P(x)$ obeys the LEB condition (\ref{eq:leb_condition}). Given $\delta \in (0, 1)$, let $S = \lceil \log(\frac{\epsilon_{0}}{\epsilon}) \rceil$, $\tilde{\delta} = \delta / S$, $R_{1} = O ( \frac{c\epsilon_{0}}{\epsilon^{1 - \theta}} )$ and \begin{align*} T \geq & \max \bigg\{ \frac{ 320 M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 } , \frac{ 320 B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } , \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 } , \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } \bigg\} . \end{align*} Algorithm~\ref{alg:restart_primal_dual_algorithm_sa} guarantees that $P({\bar{x}}_{S}) - P^{*} \leq 2 \epsilon$ with at least probability $1 - \delta$. The total number of iterations is $\widetilde O( \frac{1}{\epsilon^{2(1 - v\theta)}})$, where $\widetilde O$ suppresses a logarithmic factor. \end{thm} {\bf Remark.} When $v\theta>0$, RSPD enjoys the improved iteration complexity than $O(1/\sqrt{T})$. When $v=1$ (i.e., $\phi(\cdot)$ is smooth), if $\theta = \frac{1}{2}$ (e.g., $P(x)$ is (weakly) strongly convex), then RSPD enjoys the iteration complexity of $ O(\log(1/\epsilon)/\epsilon)$, which is only worse by a logarithmic factor than the expectional convergence result in Theorem~\ref{thm:RSPDsc} for strongly convex $P$. When $v=0$ or $\theta=0$ (i.e., $\phi$ is non-differentiable with no H\"{o}lder continuous gradient or $P$ does not obey the error bound condition), the convergence rate reduces to the standard $\widetilde O(1/\sqrt{T})$. \begin{proof} To prove Theorem~\ref{theorem:convergence_rspd}, we first present the following two lemmes. The first one presents Azuma's inequality which handles martingale difference sequence. The second one analyzes the behaviour of the update within a stage of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa}. Proof of Lemma \ref{lemma:convergence_rspd_per_stage} is in Appendix \ref{app:sec:proof:lem:convergence_rspd_per_stage}. \begin{lem}\label{lemma:azuma} (Azuma's inequality) Let $X_{1}, ..., X_{T}$ be the martingale difference sequence. Suppose that $| X_{t} | \leq b$. Then for $\delta > 0$ we have $$ \Pr \bigg( \sum_{t=1}^{T} X_{t} \geq b \sqrt{2 T \log \frac{1}{\delta}} \bigg) \leq \delta . $$ \end{lem} \begin{lem}\label{lemma:convergence_rspd_per_stage} Let the Lines 4, 5, and 6 of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa} run for $T$ iterations by fixed step size $\eta_x$ and $\eta_y$ starting from $x_0$ and $y_0$. Then with the probability at least $1 - \tilde{\delta}$ where $\tilde{\delta} \in (0, 1)$, we have \begin{align} \label{eq1:convergence_per_stage} \max_{y \in Y \cap \mathcal{B}(y_0, R_y)} f(\bar x_T, y) - f(x, \bar y_T) \leq & \frac{|| x - x_{0} ||^{2} }{\eta_x T } + \frac{|| \hat y_T - y_{0} ||^{2} }{\eta_y T } + \frac{5\eta_x M^2}{2} + \frac{5\eta_y B^2}{2} \nonumber\\ & + \frac{ 4 ( M R_x + B R_y ) \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{ \sqrt{T} } , \end{align} where $\bar x_T = \sum_{t=0}^{T-1} x_{t}/T$, $\bar y_T = \sum_{t=0}^{T-1} y_{t}/T$, $\hat y_T = \arg\max_{y \in Y \cap \mathcal{B}(y_0, R_y)} f(\bar x_T, y)$ and any fixed $x \in X \cap \mathcal{B}(x_0, R_x)$. \end{lem} Now we proceed to proof of Theorem~\ref{theorem:convergence_rspd}. Let $\epsilon_{s} = \frac{\epsilon_{s-1}}{2}$, by the setting of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa}, we know $R_{s+1} = \frac{R_1}{2^{s}}\geq \frac{c\epsilon_{s}}{\epsilon^{1-\theta}}$, $\eta_{x, s+1} = \frac{\epsilon_{s}}{40M^2}$, $\eta_{y, s+1} = \frac{\epsilon_{s}}{40B^2}$, and $x_{0}^{(s+1)} = {\bar{x}}_{s} = \frac{1}{T} \sum_{t=1}^{T} x_{t}^{(s)}$ for $s = 0, 1, \dots$. We will show $P(x_{0}^{(s+1)}) - P^* \leq \epsilon_{s} + \epsilon$ by induction for $s = 0, 1, \dots$ with a high probability. It is easy to verify $ P(x_{0}^{(1)}) - P^* \leq \epsilon_{0} + \epsilon $ for a sufficiently large $\epsilon_{0}$ according to Assumption~\ref{assumption:general}. Next, we need to show that conditional on $P(x_{0}^{(s)}) - P^* \leq \epsilon_{s-1} + \epsilon$, we have $$ P(x_{0}^{(s+1)}) - P_*\leq \epsilon_{s} + \epsilon $$ with a high probability. Consider the update of the $s$-th stage. Define $\hat{y}({\bar{x}}_{s}) = \arg\max_{y \in Y } f({\bar{x}}_{s}, y)$ and $x_{0, \epsilon}^{(s), \dagger} = \arg\min_{ x \in \mathcal{S}_{\epsilon} } \| x - x_0^{(s)} \|$. We would like to show that both $\| x_{0, \epsilon}^{(s), \dagger} - x_{0}^{(s)} \| \leq R_x$ and $\| \hat{y}({\bar{x}}_{s}) - y_0^{(s)} \| \leq R_y$ always hold, so that we are able to plug $x = x_{0, \epsilon}^{(s), \dagger}$ and $y = \hat{y}({\bar{x}}_{s})$ into (\ref{eq1:convergence_per_stage}) in Lemma~\ref{lemma:convergence_rspd_per_stage}. To this end, we have for $x_{0, \epsilon}^{(s), \dagger}$, \begin{align* || x_{0, \epsilon}^{(s), \dagger} - x_{0}^{(s)} || \leq & \frac{dist( x_{0, \epsilon}^{(s), \dagger}, X^* ) }{\epsilon} ( P(x_{0}^{(s)}) - P(x_{0, \epsilon}^{(s), \dagger}) ) \nonumber\\ \leq & \frac{ c ( P( x_{0, \epsilon}^{(s), \dagger} ) - P^* )^{\theta} }{\epsilon} \epsilon_{s-1} \nonumber\\ \leq & \frac{c \epsilon_{s-1} }{\epsilon^{1 - \theta}} \leq R_{x, s}, \end{align*} where the first inequality is due to Lemma 4 in~\citep{yang2018rsg}, the second inequality is due to~(\ref{eq:leb_condition}) and the third inequality is due to $x_{0, \epsilon}^{(s), \dagger} \in \mathcal{S}_\epsilon$. For $\hat{y}({\bar{x}}_{s})$, we have \begin{align*} || \hat{y}({\bar{x}}_{s}) - y_{0} || = & || \nabla \phi(\ell({\bar{x}}_{s})) - \nabla \phi(\ell(x_{0})) || \\ \leq & L || \ell({\bar{x}}_{s}) - \ell(x_{0}) ||^v \\ \leq & L G^v || {\bar{x}}_{s} - x_{0} ||^v \leq L G^v R_{x, s}^v = R_{y, s}, \end{align*} where the first equality is due to the set up of the algorithm and Lemma~\ref{lemma:supp:1}, the first inequality is due to the $(L, v)$-H\"older~ continuous gradients of $\phi$ (Assumption \ref{assumption:general} (3)), the second inequality is due to $G$-Lipschitz continuity of $\ell$ (Assumption \ref{assumption:general} (4)), and the last equality is due to the setting of $R_{y, s} = L G^v R_{x, s}^v$. By showing that $\| x_{0, \epsilon}^{(s), \dagger} - x_{0}^{(s)} \| \leq R_x$ and $\| \hat{y}({\bar{x}}_{s}) - y_0^{(s)} \| \leq R_y$, we then plug in $x = x_{0, \epsilon}^{(s), \dagger}$ and $y = \hat{y}({\bar{x}}_{s})$ into (\ref{eq1:convergence_per_stage}) in Lemma~\ref{lemma:convergence_rspd_per_stage} as follows \begin{align}\label{eq:convergence_induction} & P(\bar x_s) - P(x_{0, \epsilon}^{(s), \dagger}) \leq f({\bar{x}}_{s}, \hat{y}({\bar{x}}_{s})) - f(x_{0, \epsilon}^{(s), \dagger}, {\bar{y}}_s) \nonumber\\ \leq & \frac{ R_{x, s}^2 }{ \eta_{x,s} T } + \frac{ R_{y, s}^2 }{ \eta_{y,s} T } + \frac{5 \eta_{x,s} M^{2} }{ 2 } + \frac{5 \eta_{y, s} B^{2}}{ 2 } + \frac{ 4 ( M R_{x, s} + B R_{y, s} ) \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{\sqrt{T }} \nonumber\\ = & \underbrace{ \frac{ R_{x, s}^2 }{ \eta_{x,s} T } }_{(a)} + \underbrace{ \frac{ L^2 G^{2v} R_{x, s}^{2v} }{ \eta_{y,s} T } }_{(b)} + \underbrace{ \frac{ 5 \eta_{x, s} M^{2} }{ 2 } }_{(c)} + \underbrace{ \frac{ 5 \eta_{y, s} B^{2} }{ 2 } }_{(d)} + \underbrace{ \frac{ 4 M R_{x, s} \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{ \sqrt{ T } } }_{(e)} + \underbrace{ \frac{ 4 B L G^v R_{x, s}^v \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{ \sqrt{ T } } }_{(f)} . \end{align} Finally, we would like to show $P(\bar x_s) - P(x_{0, \epsilon}^{(s), \dagger}) \leq \epsilon_{s} = \frac{\epsilon_{s-1}}{2}$ by properly setting the values of $T$, $\eta_{x, s}$, $\eta_{y, s}$, $R_{x, s}$ and $R_{y, s}$. First, to make $\frac{5 \eta_{x, s} M^{2} }{ 2 } = \frac{\epsilon_{s-1}}{16}$ in term $(c)$ and $\frac{5 \eta_{y, s} B^{2} }{ 2 } = \frac{\epsilon_{s-1}}{16}$ in term $(d)$, we have $\eta_{x, s} = \frac{\epsilon_{s-1}}{40M^2}$ and $\eta_{y, s} = \frac{\epsilon_{s-1}}{40B^2}$, respectively. Recalling that $\epsilon_{s} = \frac{\epsilon_{s-1}}{2}$, this requires $\eta_{x, s+1} = \frac{ \eta_{x, s} }{2}$ and $\eta_{y, s+1} = \frac{ \eta_{y, s} }{2}$, as in Line 5 and 6 of Algorithm \ref{alg:restart_primal_dual_algorithm_sa}. Next, we can plug $\eta_{x, s}$ and $\eta_{y, s}$ into term $(a)$ and $(b)$. By setting $T \geq \max \{ \frac{ 320 M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 } , \frac{ 320 B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } \}$, we have \begin{align*} \frac{ R_{x, s}^2 }{ \eta_{x,s} T } \leq \frac{ \epsilon_{s-1} }{ 8 } , \text{~and~} \frac{ L^2 G^{2v} R_{x, s}^{2v} }{ \eta_{y,s} T } \leq \frac{ \epsilon_{s-1} }{ 8 } . \end{align*} Then, for $(e)$, by setting $T \geq \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 }$, we have $\frac{ 4 M R_{x, s} \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{ \sqrt{ T } } \leq \frac{\epsilon_{s-1}}{16}$. Last, for $(f)$, by setting $T \geq \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 }$, we have $\frac{ 4 B L G^v R_{x, s}^v \sqrt{2 \log\frac{1}{\tilde{\delta}}} }{ \sqrt{ T } } \leq \frac{\epsilon_{s-1}}{16}$. Therefore, we have \begin{align*} P({\bar{x}}_{0}^{s+1}) - P(x_{0, \epsilon}^{(s), \dagger}) = P({\bar{x}}_{s}) - P(x_{0, \epsilon}^{(s), \dagger}) \leq \frac{\epsilon_{s-1}}{2} = \epsilon_s, \end{align*} i.e., \begin{align*} P({\bar{x}}_{0}^{s+1}) - P^* \leq \epsilon_s + \epsilon, \end{align*} By induction, after running $S = \lceil \log(\frac{\epsilon_{0}}{\epsilon}) \rceil$ stages, with probability $(1 - \tilde{\delta})^{S} \geq 1 - S \tilde{\delta}$, we have $$ P({\bar{x}}_{S}) - P^* \leq \epsilon_{S} + \epsilon \leq 2 \epsilon, $$ where we set $\tilde{\delta} = \delta/S$. Considering the requirements from (\ref{eq:convergence_induction}), for $T$, we have \begin{align*} T \geq & \max \bigg\{ \frac{ 320 M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 } , \frac{ 320 B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } , \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) M^2 R_{x, s}^2 }{ \epsilon_{s-1}^2 } , \frac{ 8192 \log(\frac{1}{\tilde{\delta}}) B^2 L^2 G^{2v} R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } \bigg\} . \end{align*} Recall that $v \in [0,1]$, $R_{x, 1} \geq \frac{c \epsilon_{0}}{\epsilon^{1-\theta}}$, $R_{x, s} = \frac{ R_{x, 1} }{ 2^{s-1} }$ and $\epsilon_{ s-1 } = \frac{ \epsilon_0 }{ 2^{s-1} }$. On one hand, we have $$ \frac{R_{x, s}^2}{ \epsilon_{s-1}^2 } = \frac{R_{x, 1}^2}{ \epsilon_0^2 } . $$ On the other hand, for $s \leq \lfloor \log( \frac{ \epsilon_0 }{ \epsilon } ) \rfloor$, we have $$ \frac{R_{x, s}^{2v} }{ \epsilon_{s-1}^2 } = \frac{ R_{x, 1}^{2v} }{ \epsilon_0^2 } \cdot ( 2^{s-1} )^{ 2(1-v) } \leq \frac{ R_{x, 1}^{2v} }{ \epsilon_0^2 } \cdot ( 2^{ \log( \frac{ \epsilon_0 }{ \epsilon } ) } )^{ 2(1-v) } \\ = \frac{ R_{x, 1}^{2v} }{ \epsilon_0^2 } \cdot ( \frac{ \epsilon_0 }{ \epsilon } )^{ 2(1-v) } = \frac{ R_{x, 1}^{2v} }{ \epsilon_0^{2v} \epsilon^{ 2 ( 1 - v ) } } . $$ The above terms show that $T$ would not change as $s$ changes. Provided $R_{x, 1} = O(\frac{c \epsilon_0}{ \epsilon^{ 1 - \theta } })$ and $R_{x, 1} \geq \frac{c \epsilon_0}{ \epsilon^{ 1 - \theta } }$, we have the total number of iterations is at most $ ST = O\bigg(\frac{\lceil \log(\frac{\epsilon_{0}}{\epsilon}) \rceil \lceil \log ({S}/{\delta}) \rceil }{\epsilon^{2(1 - v\theta)}}\bigg) = \widetilde O \bigg(\frac{1}{\epsilon^{2(1 - v\theta)}}\bigg)$. \end{proof} \subsection{Adaptive Variants of RSPD} When setting the initial value of radius $R_{1}$ (as well as the value of $T$) in Algorithm~\ref{alg:restart_primal_dual_algorithm_sa}, one requires to know $c$, $\theta$ and $\epsilon$ (setting $R_{1} \geq \frac{c \epsilon_{0}}{\epsilon^{1 - \theta}}$), which may not be feasible in practice. Below, we introduce an adaptive variant of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa} to find the $\epsilon$-optimal solution without knowing either $c$ or $\theta$ and $\epsilon$ to initiate the algorithm under that $v=1$. The developments in this section are mostly direct extension of techniques introduced~\citep{ICMLASSG,yang2018rsg}. The idea of tackling unknown $c$ is similar to the grid search: starting from a guess of $c$ for setting $R_1, T$ to run RSPD and then restarting RSPD using a larger $c$ (increased by a constant factor) or equivalently a larger $R_1, T$. However, in order to not waste the updates for using a smaller $c$ and also remove the dependence on $\epsilon$ for setting $R_1, T$, we equivalently increase $R_1$ and $T$ in a way that depends on $\theta$ such that a similar convergence rate can be still established. The details are presented in Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c}. The following theorem gives convergence result of Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c}. Its proof is in Appendix \ref{app:sec:proof:thm:convergence_rspd_adaptive}. \begin{thm}\label{theorem:convergence_rspd_adaptive_c} Suppose that Assumption~\ref{assumption:general} holds with $v=1$, and there exists ${\hat{\epsilon}}_1\in(\epsilon, \epsilon_0/2]$ such that the initial value $R_1^{(1)}$ satisfies $R_1^{(1)} = \frac{c\epsilon_{0}}{{\hat{\epsilon}}_{1}^{1 - \theta}}$ and the error bound condition holds on $\mathcal S_{{\hat{\epsilon}}_1}$ with $c>0, \theta\in(0,1)$. For any $\delta \in (0, 1)$, $\epsilon\leq \epsilon_0/4$, let $\hat\delta = \frac{\delta}{S(S+1)}, S = \lceil \log_2(\frac{\epsilon_0}{\epsilon})\rceil$, $\kappa = 1$, and $ T_1 = \max \bigg\{ 320 M^2, 320 B^2 L^2 G^2, 8192 \log(\frac{1}{\tilde{\delta}}) M^2, 8192 \log(\frac{1}{\tilde{\delta}}) B^2 L^2 G^2 \bigg\} \cdot \frac{(R_1^{(1)})^2}{\epsilon_0^2} . $ After at most $K = \lceil \log(\frac{\hat{\epsilon}_{1}}{\epsilon}) \rceil+1$ calls of RSPD, Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c} guarantees that $P(x^{(K)}) - P(x^{*}) \leq 2 \epsilon$ with probability $1 - \delta$ with an iteration complextiy of $\widetilde O(\log(1/\delta)/\epsilon^{2(1-\theta)})$ . \end{thm} {\bf Remark:} The requirement on the local error bound condition of the above theorem seems slightly stronger than that holds on $\mathcal{S}_\epsilon$. However, for a convex function it has been shown that a local error bound condition implies an error bound condition on any compact set with the same $\theta$ but possibly different $c$~\citep{arxiv:1510.08234}. The above theorem and Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c} do not cover the case $\theta=1$. But this can be easily resolved by setting $R_1 = \hat c_1\epsilon_0$ according to an initial guess of $c$, and then increasing $\hat c_1$ or $R_1$ by two times and rerun RSPD. It is easy to see that after $\log(c/\hat c_1)$ times the estimated value of $c$ will become larger than the true $c$ and the convergence theory in previous subsection will apply. As a result the total iteration complexity is only amplified by a factor of $\log(c/\hat c_1)$. \begin{algorithm}[t] \caption{Adaptive RSPD (ARSPD)} \label{alg:restart_primal_dual_algorithm_sa_adaptive_c} \begin{algorithmic}[1] \STATE Initialization: $x^{(0)} \in X$, $S$, $T_1$, $\epsilon_{0}$, $R_{1}^{(1)}$ and $\kappa\in(0,1]$. \STATE Set: $\epsilon^{(1)}_0 = \epsilon_0$, $\eta_{x,1} = \frac{\epsilon_{0}}{40 M^{2} }$, $\eta_{y,1} = \frac{\epsilon_{0}}{40 B^{2} }$ \FOR{$k = 1, 2, ..., K$} \STATE $x^{(k)} =$ RSPD($x^{(k-1)}, S, T_k, R^{(k)}_{1}, \epsilon^{(k)}_0$) ~\label{alg3:line:pd_sa_update_x} \STATE $R_1^{(k+1)} = R_1^{(k)} \cdot 2^{1- \theta}$, $T_{k+1} = T_{k} \cdot 2^{2(1 - \theta)}$ and $\epsilon_0^{(k+1)} = \epsilon_0^{(k)} \cdot \kappa$. \label{alg:line:update_radius_and_t} \ENDFOR \STATE Return $x^{(K)}$ \end{algorithmic} \end{algorithm} Finally, we can show that even if $\theta$ is unknown, by setting $\theta=0$ in Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c}, we can still prove an improved convergence. Let $B_{\epsilon} = \max_{v \in \mathcal{L}_{\epsilon}} \min_{z \in X^*} || v - z ||$ be the maximum distance between the points in the $\epsilon$-level set $\mathcal{L}_{\epsilon}$ and the optimal set $X^*$. Proof of the following theorem is similar to the one of Theorem \ref{theorem:convergence_rspd_adaptive_c} (in Appendix \ref{app:sec:proof:thm:convergence_rspd_adaptive}) with slight modification. \begin{thm}\label{theorem:convergence_rspd_adaptive_theta} Suppose that Assumption~\ref{assumption:general} (1$\sim$4) holds with $v=1$, and $R^{(1)}_{1}$ is sufficiently large such that there exists ${\hat{\epsilon}}_{1} \in [ \epsilon, \frac{\epsilon_{0}}{2}]$ and $R^{(1)}_{1}= \frac{ B_{{\hat{\epsilon}}_{1}} \epsilon_{0}}{{\hat{\epsilon}}_{1} }$. Given $\delta \in (0, 1)$, let $\theta=0$, $\hat\delta = \frac{\delta}{S(S+1)}$, $S = \lceil \log_2(\frac{\epsilon_0}{\epsilon})\rceil$, $ T_1 = \max \bigg\{ 320 M^2, 320 B^2 L^2 G^2, 8192 \log(\frac{1}{\tilde{\delta}}) M^2, 8192 \log(\frac{1}{\tilde{\delta}}) B^2 L^2 G^2 \bigg\} \cdot \frac{(R_1^{(1)})^2}{\epsilon_0^2} , $ and $\kappa = 1$. After at most $K = \lceil \log(\frac{\hat{\epsilon}_{1}}{\epsilon}) \rceil+1$ calls of RSPD, Algorithm~\ref{alg:restart_primal_dual_algorithm_sa_adaptive_c} guarantees that $P(x^{(K)}) - P(x^{*}) \leq 2 \epsilon$ with probability $1 - \delta$ with an iteration complexity of $\widetilde O( \log(\frac{1}{\delta}) B_{{\hat{\epsilon}}_{1}}^{2} /\epsilon^{2} )$. \end{thm} {\bf Remark:} This iteration complexity is still an improved one compared with that in~\citep{Nemirovski:2009:RSA:1654243.1654247}, reducing the dependence on the size of $X$ and $Y$ to the $B_{{\hat{\epsilon}}_1}$. \section{Applications and Experiments}\label{sec:app} \begin{table}[t] \centering \caption{Data statistics.} \label{tab:data_stats} \begin{tabular}{c|c|c} \hline Datasets & \#Examples & \#Features \\\hline w8a & 49,749 & 300 \\ rcv1 & 20,242 & 47,236 \\ a9a & 32,561 & 123 \\ real-sim & 72,309 & 20,958 \\ covtype & 581,012 & 54 \\ URL & 2,396,130 & 3,231,961 \\ \hline \end{tabular} \end{table} In this section, we investigate the effectiveness of our algorithms on two applications, i.e., distributionally robust optimization (DRO) and area under receiver operating characteristic curve (AUC) maximization. We perform DRO experiments on four benchmark datasets, a9a, real-sim, rcv1 and w8a. AUC experiments are performed on a9a, real-sim, covtype and URL. Table~\ref{tab:data_stats} shows the statistics of the used six datasets. \begin{figure*}[h] \centering \hspace{-0.25in} {\includegraphics[scale=.215]{fig4_DR_hinge_a9a-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig2_DR_hinge_realsim-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig1_DR_hinge_rcv1-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig3_DR_hinge_w8a-eps-converted-to.pdf}} \hspace{-0.25in} \caption{Results for Distributionally Robust Optimization} \label{fig:dro_n_grad} \end{figure*} \begin{figure*}[h] \centering \hspace{-0.25in} {\includegraphics[scale=.215]{fig4_DR_hinge_a9a_time-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig2_DR_hinge_realsim_time-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig1_DR_hinge_rcv1_time-eps-converted-to.pdf}} \hspace{-0.25in} {\includegraphics[scale=.215]{fig3_DR_hinge_w8a_time-eps-converted-to.pdf}} \hspace{-0.25in} \caption{Results for Distributionally Robust Optimization by CPU time} \label{fig:dro_cpu_time} \end{figure*} {\bf DRO.} First, we consider solving the DRO~(\ref{eqn:dro}) for binary classification as mentioned in the Introduction. We use the square distance for $V$ that was studied in~\citep{DBLP:conf/nips/NamkoongD17}, i.e., $V(y, \mathbf 1/n) = \frac{\lambda_1}{2} \| ny - \mathbf{1}\|_2^2$. For the loss function, we consider the non-smooth hinge loss $\ell_i(x)=\max\{0,1 -b_i x^\top a_i\}$, where $a_i\in\mathbb{R}^d$ denotes the feature vector and $b_i\in\{1, -1\}$ denotes the label. We also include a regularizer $g(x)$ on the model parameter $x$. Using different regularizers will give different properties for the primal objective function. For example, if $g(x) = \frac{\lambda_2}{2}\|x\|_2^2$, then the primal objective function $P(x)$ is obviously a strongly convex function. If $g(x) = \lambda_2\|x\|_1$, then we can prove that the primal objective function $P(x)$ is a piecewise quadratic convex function, which satisfies the LEB condition with $\theta=1/2$. The proof is given in Appendix~\ref{app:sec:proof:piecewise_quadratic}. We report the result of RSPD$^{\text{sc}}$ for solving the problem with $g(x) = \frac{\lambda_2}{2}\|x\|_2^2$ here. We compare with the baseline called Bandit Mirror Descent (BMD) algorithm considered in~\citep{DBLP:conf/nips/NamkoongD16}, which has a convergence rate of $O(1/\sqrt{T})$. The stochastic gradients are computed in the same way as in~\citep{DBLP:conf/nips/NamkoongD16}. Computing the restarted dual solution $y^{(s+1)}_0= \mathcal A(x^{(s+1)}_0)$ takes $O(nd)$ time complexity, and each update for the primal variable and the dual variable takes $O(d)$ and $O(n)$, respectively. Therefore, the total time complexity of RSPD for finding an $\epsilon$-optimal solution is $O(nd\log(1/\epsilon) +\frac{n+d}{\epsilon})$. In contrast, the time complexity of BMD is $O((n+d)/\epsilon^2)$. We conduct experiments on four datasets from libsvm website using $\ell_2$ regularization for $g(x)$. The regularizer parameters are set to be $\lambda_1 = \lambda_2 = \frac{1}{n}$ for all datasets. The initial step sizes of all algorithms are tuned in the range of $\{10^{-5:1:3}\}$. All algorithms start with the same initial solutions with $y_0 = \frac{\textbf{1}}{n}$ and $x_0 = \mathbf{0}$. In implementing RSPD$^{\text{sc}}$, we start with an initial $T=10^4$ increased by a factor of $2$ at each epoch. The results of objective gap against the number of gradients and against CPU time are shown in Figure~\ref{fig:dro_n_grad} and Figure~\ref{fig:dro_cpu_time}, respectively. It is clear that the proposed algorithm converge much faster than the baseline algorithm BMD. \yancomment{ Let $f(x) = \max_{p} \sum_{i=1}^{n} p^{T} \ell( x ) - \sigma(p)$. By Proposition 2.3 in~\citep{rockafellar1987linear} and the assumption that $\ell(x)$ is piecewise linear, the above function is piecewise linear-quadratic in $x$, and thus obeys the LEB condition. } \begin{figure*}[t] \centering \hspace{-0.1in} {\includegraphics[scale=.2125]{a9a_n_grad_point151_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{real-sim_n_grad_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{covtype_n_grad_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{url_combined_n_grad_point151_crop.pdf}} \hspace{-0.1in} \caption{Results for AUC Maximization (with L2 ball constraint)} \label{fig:auc_n_grad} \end{figure*} \begin{figure*}[t] \centering \hspace{-0.1in} {\includegraphics[scale=.2125]{a9a_cputime_point151_no_svrg_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{real-sim_cputime_point251_crop.pdf}} \hspace{-0.15in} {\includegraphics[scale=.2125]{covtype_cputime_point251_crop.pdf}} \hspace{-0.09in} {\includegraphics[scale=.2125]{url_combined_cputime_point151_crop.pdf}} \hspace{-0.1in} \caption{Results for AUC Maximization by CPU time (with L2 ball constraint)} \label{figure:auc_cputime} \end{figure*} {\bf AUC Maximization.} Next, we consider empirical AUC maximization by solving the min-max saddle-point formulation proposed by~\citep{DBLP:conf/nips/YingWL16}: \[ \min_{\mathbf{w} , a, b } \max_{\alpha} \frac{1}{n}\sum_{i=1}^{n} F(\mathbf{w}, a, b, \alpha; (\mathbf{x}_i, z_i) ), \] where $\mathbf{x}_i\in\mathbb{R}^d, z_i\in\{1,-1\}$ denote the feature-label pairs of a training example, $ F(\mathbf{w}, a, b, \alpha; (\mathbf{x}, z) ) = (1 - p) (\mathbf{w}^{\top} \mathbf{x} - a)^{2} I_{[z=1]} + p(\mathbf{w}^{\top} \mathbf{x} - b)^{2} I_{[z=-1]} - p(1-p)\alpha^2 + 2(1+\alpha) (p \mathbf{w}^{\top}\mathbf{x} I_{[z=-1]} - (1-p) \mathbf{w}^{\top}\mathbf{x} I_{[z=1]})$, $p$ is the percentage of positive example, and $I_{[\cdot]}$ is the indicator function. Let ${\bf{v}} = [\mathbf{w}^{\top}, a, b]^{\top} \in \mathbb{R}^{d+2}$. In order to achieve good AUC performance, we add a ball constraint on $\mathbf{w}$. Bounds on $(a, b)$ can be derived similarly to~\citep{DBLP:conf/nips/YingWL16}. If we use $\ell_1$ ball $\|\mathbf{v}\|_1\leq B$, it was shown in~\citep{fastAUC18} that the primal objective function satisfies the LEB with $\theta=1/2$. If we use $\ell_2$ ball constraint $\|\mathbf{v}\|_2\leq B$, under a mild condition that $\min_{\mathbf{v}\in\mathbb{R}^{d+2}}P(\mathbf{v})<\min_{\|\mathbf{v}\|_2\leq B}P(\mathbf{v})$ it was shown that a LEB with $\theta=1/2$ is satisfied~\citep{DBLP:conf/nips/LiuZZRY18}. Then the iteration complexity of RSPD is given by $\widetilde O(1/\epsilon)$. Since the dual variable is one-dimensional, computing the restarted dual solution $y^{(s+1)}_0$ takes $O(d)$ complexity given the averaged feature vectors for the positive and negative examples are precomputed. Hence, when LEB with $\theta=1/2$ is satisfied, the total time complexity of RSPD or ARSPD is $\widetilde O(d\log(1/\epsilon) + d/\epsilon)$. We also note that SPDC~\citep{DBLP:conf/icml/ZhangL15} is applicable in the AUC task, but it does not give a linear rate for the considered AUC problem, because there is no strong convexity for primal variable as required for achieving a linear rate. Adding a small strongly convex regularizer on the primal variable, its total time complexity is $O(nd^2 + d^2/\sqrt{\epsilon})$ since every iteration needs to solve a linear system (i.e., the proximal mapping of the quadratic part of the primal variable), where $n$ is sample size. Here, we report the results of the proposed adaptive algorithm for the problem with an $\ell_2$ ball constraint and an $\ell_{1}$ ball, respectively. \begin{figure*}[t] \centering \hspace{-0.1in} {\includegraphics[scale=.2125]{a9a_l1_n_grad_point151_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{real-sim_l1_n_grad_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{covtype_l1_n_grad_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{url_l1_n_grad_point151_crop.pdf}} \caption{Results for AUC Maximization (with L1 ball constraint)} \label{figure:auc_n_grad_l1} \end{figure*} \begin{figure*}[t] \centering \hspace{-0.1in} {\includegraphics[scale=.2125]{a9a_l1_cputime_point151_no_svrg_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{real-sim_l1_cputime_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{covtype_l1_cputime_point251_crop.pdf}} \hspace{-0.1in} {\includegraphics[scale=.2125]{url_l1_cputime_point151_crop.pdf}} \caption{Results for AUC Maximization by CPU time (with L1 ball constraint)} \label{figure:auc_cputime_l1} \end{figure*} Since the function $F$ is smooth in terms of $\mathbf{v}$ and $\alpha$, we include more applicable baselines for comparison. In particular, we compare with four algorithms, i.e., PDSG~\citep{Nemirovski:2009:RSA:1654243.1654247}, SPAM~\citep{DBLP:conf/icml/NatoleYL18}, SMP~\citep{juditsky2011} and primal-dual SVRG~\citep{DBLP:conf/nips/PalaniappanB16}. For primal-dua SVRG, we directly use the formulation of AUC proposed in the paper and conduct the experiment using the code provided by the authors \footnote{Code derived at \url{https://sites.google.com/site/pbalamuru/home/sagsaddle-code}}. SPAM is an algorithm proposed particularly for the stochastic AUC maximization. SMP and SVRG utilize the smoothness of the objective function. The complexity of PDSG and SMP for finding an $\epsilon$-stationary solution is given by $O(d/\epsilon^2)$. Note that both SPAM and SVRG require a strong convexity of the objective function on the primal variable. To this end, we add an $\ell_{2}$ regularizer, i.e., $\frac{\lambda}{2}||\mathbf{w}||_{2}^{2}$ with a small value of $\lambda = \Theta(\epsilon)$. These two algorithms have a total time complexity for finding a solution $\mathbf{v}$ such that $\|\mathbf{v}- \mathbf{v}_*\|^2\leq \epsilon$ given by $\widetilde O(d/\epsilon^2)$ and $\widetilde O(nd + nd/\epsilon)$, respectively. We can see that all baseline algorithms have worse time complexity than RSPD, especially the primal dual SVRG algorithm. In the $\ell_{2}$ ball setting, we fix $B=10$ and $\lambda = 10^{-4}$ on all datasets. In the $\ell_{1}$ ball setting, we set $B = 100$ on a9a, covtype and URL, and $B = 1000$ on real-sim. The initial step sizes of all algorithms are tuned in the range of $\{ 10^{-5:1:3} \}$. For ARSPD, we set $S=5$ and simply set $\theta = 0$ pretending that we do not know the value of true $\theta$ and tune $\kappa = \{ 0.25, 0.5, 0.75, 1 \}$. The initial solution of all algorithms are set to $\mathbf{0}$. For the $\ell_{2}$ ball setting, the convergence curves of AUC on four data sets against the number of gradients and CPU time are shown in Figure~\ref{fig:auc_n_grad} and Figure~\ref{figure:auc_cputime}, including two large-scale datasets covtype and URL, on which SVRG is too slow to be plotted. For the $\ell_{1}$ ball setting, the convergence curves of AUC against the number of gradients and CPU time are shown in Figure~\ref{figure:auc_n_grad_l1} and Figure{\ref{figure:auc_cputime_l1}}. We can see that the overall performance of ARSPD is the best among all algorithms. \section{Conclusion}\label{sec:conc} In this paper, we have proposed novel stochastic primal-dual algorithms for solving convex-concave problems with no bilinear structure assumed, which employ a mixture of stochastic gradient updates and deterministic dual updates. A fast convergence rate of $O(1/T)$ was achieved under strong convexity on the primal and dual variables. In addition, we design variants for more general problems without strong convexity achiving adaptive rates. Empirical results verify the effectiveness of our algorithms.
{'timestamp': '2019-12-20T02:03:18', 'yymm': '1904', 'arxiv_id': '1904.10112', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10112'}
arxiv
\section{Introduction} \label{I} The rapidly increasing need of very high data rate communications made free space optical (FSO) communication very popular during the past few years. FSO communication offers a great potential due to the ease of deployment, unregulated frequency band and the enormous available bandwidth \cite{ghassemlooy2012optical}. FSO communication has observed great scientific developments and engineering improvements that make it usable for various commercial, industrial, military, environmental, and sensor network applications \cite{Dr_khalighi_survay,dabiri2017performance}. However, atmospheric turbulence-induced fading, geometrical spread and channel loss, which are distance-dependent, significantly decrease the FSO link performance \cite{safari2012multi,anees2015performance,dabiri2017fso}. To overcome this limitation, relaying techniques to divide a long link into multiple short links, has been advocated for FSO transceivers as a mean to cover large distances and improve the performance of FSO systems \cite{boluda2015impact}. Research studies on relay-assisted FSO systems was initially focused on electrical relaying where electrical-optical and optical-electrical conversions was performed at relays \cite{safari2008relay,kashani2013optimal,boluda2016miso}. However, it is well known that the efficiency of electrical relaying is limited due to the requirement of high-speed electrons and optoelectronic hardware. Moreover, by developing tracking systems using acousto-optic devices that especially applicable to the fast moving unmanned aerial vehicles (UAVs) for compensating the pointing losses, UAV-based FSO communication systems are employed for high data transmission between moving UAVs \cite{dabiriJSAC}. However, due to the power, size and weight constraints of UAV systems, in practice, all-optical relaying is preferred to relying optical signals between UAVs \cite{vu2018performance}. To avoid the inherent complexities associated with electrical-optical and optical-electrical conversions in electrical relays, a new setup of relay-assisted FSO system referred to as all-optical relaying was recently proposed in the context of FSO communication where all processing are done in the optical domain \cite{yang2014performance,trinh2015alll,trinh2015all,nor2016comparison,nor2015performance,nor2017experimental,kazemlou2011all,bayaki2012,SAFARI_ALL_OPTIC_2012,IET2014,dabiri2017performance2}. In particular, in \cite{kazemlou2011all}, optical amplify and optical regenerate techniques were developed and bit error rate (BER) performance was investigated by using Monte-Carlo (M-C) simulations. However, the latter work does not consider the effect of amplified spontaneous emission (ASE) noise. In \cite{bayaki2012}, the outage probability for a dual-hop FSO relay system was investigated in which ASE noise of optical amplifier was considered. However, in \cite{bayaki2012}, the authors have not considered the effect of the optical degree-of-freedom (DoF). In \cite{SAFARI_ALL_OPTIC_2012} and \cite{IET2014}, the outage probability of a dual-hop and parallel all-optical relaying was studied in which the effects of both ASE noise and optical DoF was considered. However, performance analysis performed in \cite{SAFARI_ALL_OPTIC_2012,IET2014}, is based on the assumption that the effects of the background and thermal noises are negligible compared to the effect of the ASE noise. Recently, in \cite{dabiri2017performance2} a comprehensive signal model for a more precise analysis of dual-hop all-optical relaying FSO systems is studied in the presence of all main noise sources. In \cite{dabiri2017performance2} the authors shown that due to the presence of background and ASE noise, the optimal location of the relay node is not placed at half distance of transceiver. In this paper, we extend the results of \cite{dabiri2017performance2} and investigate the performance of triple-hop all-optical FSO system relaying. Particularly, using full CSI\footnote{Notice that this is a practical assumption due to the slow fading property of FSO links \cite{dabiri2017generalized,dabiri2017glrt,WCL2018}} relaying, we derive the exact expressions for the noise variance at the destination in the presence of all main source noises including background, thermal and ASE noise by taking into account the presence of DoF. Then, in order to simplify the analytical expressions of full CSI relaying, we also propose and investigate the validity of different approximations over noise variance at the destination. The motivation of this paper is answering to this question: what is the relationship between relay locations and noise sources. For this aim numerical results are plotted in term of ergodic capacity versus different values of source-to-relay, relay-to-relay and relay-to-destination. Simulation results revealed that the optimal relay locations strongly depend on noise sources. The rest of this paper is organized as follows. In Section II, we describe the triple-hop FSO system model along with our main assumptions. In this Section, we derive the noise variance at the destination. we propose some approximations over noise variance at the destination. In Section III, we study the performance of considered system in term of ergodic capacity throw numerical results. Finally in Section IV, we draw our conclusions. \section{System Model} \begin{figure*} \begin{center} \includegraphics[width=5 in ]{Triple_relay2.eps} \caption{ All-optical triple-hop FSO system model.} \label{system_Model} \end{center} \end{figure*} In this paper, we consider a relay-assisted intensity modulation-direct detection (IM-DD) FSO system, where the information at the source is transmitted to the destination through two all-optical AF relay network, i.e., the process of reception, amplification and retransmission are done in the optical domain. The source-to-destination (SD) link length is $d_{sd}=d_{sr}+d_{rr}+d_{rd}$, where $d_{sr}$, $d_{rr}$ and $d_{rd}$ are source-to-relay (SR), relay-to-relay (RR) and relay-to-destination (RD) link length. As depicted in Fig. \ref{system_Model}, the considered system model includes the following main parts: transmitter, turbulence channel, all-optical relays and receiver. In the sequel, we analyze these four parts with more details to obtain the mathematical models for the signals and noises at the destination in the context of all-optical relaying system. \subsubsection{Transmitter} It is assumed that the transmitter is equipped with a laser diode operating at wavelength $\lambda=$ 1550 nm. Notice that the 1550 nm band is compatible with erbium-doped fiber amplifier (EDFA) technology, which is useful for long range FSO links to improve their performance \cite{razavi_2005}. The mean photon counts of the transmitted pulses is $m_t = P_t T_s / h_p\nu$, where $P_t$, $T_s$, $\nu$ and $h_p$ are the transmitted power, chip duration, optical frequency and Plank's constant, respectively. For convenience, we use the notations $m_s$, $m_{r1}$ and $m_{r2}$ to denote the mean of transmitted photon counts at source, first and second relay, respectively. \subsubsection{FSO Channel} We assume that the transmitted power is attenuated by two factors: the path loss $h_l$ and the atmospheric turbulence $h_a$. Hence, the channel gain $h$ can be formulated as $h=h_l h_a$. The path loss $h_l$ is a function of the optical wavelength $\lambda$, divergence angle $\theta_{\rm div}$ and link length $d$, and can be expressed as \cite{loss_1} \begin{align} \label{jh1} h_l = \frac{A_a}{\left(\theta_{\rm div} d/2\right)^2} h_l'~, \end{align} where $A_a$ is the receiver aperture area and $h_l'$ is the atmospheric attenuation which is modeled by the exponential Beers-Lambert Law as $h_l'=\exp\left(-d\xi\right)$ and $\xi$ is the scattering coefficient \cite{loss_1}. For clear and foggy weather conditions, the scattering coefficient is a function of the visibility $\mathcal{V}$, and can be written as \cite{loss_1} \begin{align} \label{st1} \xi = \frac{3.91}{\mathcal{V}} \left( \frac{\lambda}{550}\right)^{-q}, \end{align} where $q$ is equal to 1.6, 1.3 and 0.585$\mathcal{V}^{1/3}$ for $\mathcal{V}>50$ Km, 50 Km$>\mathcal{V}>6$ Km and $\mathcal{V}<6$ Km, respectively. We model the turbulence-induced fading $h_a$ by a log-normal distribution, i.e., $\ln\mathcal{N} (h_a;\mu_{l,h_a}, \sigma_{l,h_a}^2)$, which is emerged as a useful model for a weak atmospheric turbulence regime \cite{jurado2007efficient}. The probability density function (PDF) of the log-normal model is given by \begin{align} \label{ch1} f_{h_a}(h_a)=\frac{1}{h_a\sigma_{l,h_a}\sqrt{2\pi}} \exp\left( -\frac{\left(\ln h_a-\mu_{l,h_a}\right)^2}{2\sigma^2_{l,h_a}}\right). \end{align} To ensure that fading does not attenuate or amplify the average power, we normalize the fading coefficients such that $\mu_{h_a}=1$. Doing so requires the choice of $\mu_{l,h_a}=-\sigma^2_{l,h_a}/2$. Notice that $\sigma^2_{l,h_a}\simeq \sigma^2_{R}/4$ where $ \sigma^2_{R}$ is the Rytov variance and can be measured directly from atmospheric parameters as \cite{ghassemlooy2012optical} \begin{align} \label{ch2} \sigma^2_{R} = 1.23 C_n^2 \kappa^{7/6} d^{11/6}, \end{align} where $\kappa=2\pi/\lambda$ and $C_n^2$ is the refractive index structure constant. In this paper, we assume that the transceivers are perfectly aligned. Since, the channel gain is modeled as $h=h_l h_a$, hence, $h$ is distributed according to the log-normal distribution $\ln\mathcal{N} (h;\mu_{l,h}, \sigma_{l,h}^2)$ where $\mu_{l,h}=-\sigma^2_{R}/8+\ln(h_l)$ and $\sigma_{l,h}^2=\sigma^2_{R}/4$. For convenience, we use the notations $h_{sr}$, $h_{rr}$ and $h_{rd}$ to denote the SR, RR and RD channel gains, respectively. \subsubsection{EDFA-Based Relays} At the relay nodes, the incoming optical light is guided into the optical fiber by a converging lens. However, in addition to the desired optical signal, the undesired background light due to the scattered sunlight is also collected by the receiver. The collected optical light is then amplified by an EDFA to compensate the channel loss. An EDFA is characterized by the noise factor $K=n_{sp}(G-1)$, the number of spontaneous mode\footnote{The number of spontaneous mode $D$ is the product of spatial and temporal modes and is obtained as $D = B_0 D_p T_s$, where $B_0$ is the bandwidth of optical filter that follows the preamplifier in Hz and $D_p$ is number of polarization modes \cite{EFA_book}.} $D$, and gain $G$ where, $n_{sp}$ is the amplifier spontaneous emission factor. Assuming that the ASE noise is modeled by an additive noise (similar to the background noise), the photon count $n$, at the output of first relay is Laguerre distributed as \cite{EFA_book,razavi_2005} \begin{align} \label{j2d3} f_{n,r_1}(n) = Lag\left\{ n, G_1 m_s h_{sr}, G_1 (m_{br_1} + n_{sp}) , D \right\}, \end{align} where $m_{br_1}=P_{br_1}T_s/h_p\nu$ and $P_{br_1}$ is the filtered background power at first relay. The distribution of Laguerre (also known as the non-central negative-binomial) is given in \cite[Eq. (5)]{razavi_2005}. Moreover, the mean and the variance of $Lag\{n,a,b,D\}$ are respectively derived in \cite[Eq. (7)]{razavi_2005} as \begin{align} \label{lag1} &m_{{\rm Lag}}(a, b, D) = a + Db, \nonumber \\ {\it Var}_{{\rm Lag}}&(a, b, D) = a+D(b+b^2)+2ab. \end{align} Similar to the approach followed by most of existing work in the context of dual-hop FSO communications \cite{bayaki2012,IET2014,SAFARI_ALL_OPTIC_2012}, in this paper, full CSI relaying (variable gain) is considered. Note that, for FSO channels, CSI can be easily obtained over a sequence of received bits \cite{dabiri2017generalized,dabiri2017glrt}. In full CSI relaying, the instantaneous CSI of the SR and RR links are assumed to be known at the relays. First and second relays set the amplifier gains based on the instantaneous fading of the SR and RR links $h_{sr}$ and $h_{rr}$, respectively, in such a way that the relay output powers $P_{r_1}$ and $P_{r_2}$, are kept constant at all time-slots. Due to the high gain of EDFAs (i.e., $G\gg 1$), in this paper, we approximate the noise factor as $K\simeq n_{sp}G$. The amplifier gains of both first and second relays are calculated as \cite{SAFARI_ALL_OPTIC_2012} \begin{align} \label{fcsi} G_1 =& \frac{m_{r_1}}{m_s h_{sr} + D(m_{br_1}+n_{sp})}, \\ \label{djh} G_2 =& \frac{m_{r_2}}{m_{r_1} h_{rr} + D(m_{br_2}+n_{sp})}, \end{align} where $m_{r_1}=P_{r_1} T_s / h_p\nu$ and $m_{r_2}=P_{r_2} T_s / h_p\nu$ are the average transmitted photons by first and second relays, respectively. According to \eqref{j2d3}, the photon count $n$, at the output of second relay is distributed as \begin{align} \label{42d3} f_{n,r_2}(n) = Lag\Big\{ &n, G_1G_2 m_s h_{sr} h_{rr}, G_1G_2 (m_{br_1} + n_{sp})h_{rr} \nonumber \\ &+G_2 (m_{br_2} + n_{sp}) , D \Big\}, \end{align} where $m_{br_2}=P_{br_2}T_s/h_p\nu$ and $P_{br_2}$ is the filtered background power at second relay. \subsubsection{Signal Model at Destination} The amplified optical signal is forwarded to the destination via a transmitting lens. At destination, the received optical signal, including the background radiation, is collected and focused on the surface of a photo-detector. Based on \eqref{42d3}, the photon count $n$, at the input of photo-detector has also a Laguerre distribution as \begin{align} \label{43d3} f_{n,d}(n) =& Lag\Big\{ n, G_1G_2 m_s h_{sr} h_{rr}h_{rd}, G_1G_2 (m_{br_1}+ n_{sp}) \nonumber \\ & \times h_{rr}h_{rd} + G_2 (m_{br_2} + n_{sp})h_{rd} + m_{bd} , D \Big\}, \end{align} where $m_{bd}=P_{bd}T_s/h_p\nu$ and $P_{bd}$ is the filtered background power at destination. At the destination, the collected optical signal is converted to an electrical one by a photo-detector (PD). The Laguerre distribution has the property that it preserves its form after photo-detection and $Lag(n,a,b,D)$ is converted to $Lag\{n,\eta a, \eta b, D\}$ by a photo-detector with quantum efficiency $\eta$ \cite{razavi_2005}. Hence, the photon count distribution at destination, without considering the effect of thermal noise, is derived as \begin{align} \label{laf5} f'_{n,d}(n) =& Lag\Big\{ n, \eta G_1G_2 m_s h_{sr} h_{rr}h_{rd}, \eta G_1G_2 (m_{br_1} + n_{sp}) \nonumber \\ & \times h_{rr}h_{rd} + \eta G_2 (m_{br_2} + n_{sp})h_{rd} + \eta m_{bd} , D \Big\}. \end{align} By substituting \eqref{laf5} in \eqref{lag1} and without considering the effect of thermal noise after photo-detection process, the mean and variance of photon count at destination are respectively derived as \begin{align} \label{lmw1} m'_d &= \eta G_1G_2 m_s h_{sr} h_{rr}h_{rd} \nonumber \\ &~~~ + \eta D G_1G_2 (m_{br_1} + n_{sp}) h_{rr}h_{rd} \nonumber \\ &~~~+ \eta D G_2 (m_{br_2} + n_{sp})h_{rd} +\eta D m_{bd}, \end{align} and \begin{align} \label{lmw2} \sigma'^2_d=& \eta G_1G_2 m_s\big(1+ 2\eta m_{bd}\big) h_{sr} h_{rr}h_{rd} \nonumber \\ & + \eta D G_1G_2 (m_{br_1} + n_{sp})\big(1+2\eta m_{bd} \big)h_{rr}h_{rd} \nonumber \\ &+ \eta D G_2 (m_{br_2} + n_{sp})\big(1+ 2\eta m_{bd}\big)h_{rd} \nonumber \\ &+ D\big(\eta G_1G_2 (m_{br_1} + n_{sp})\big)^2 h_{rr}^2 h_{rd}^2 \nonumber \\ &+ D\big(\eta G_2 (m_{br_2} + n_{sp})\big)^2 h_{rd}^2 \nonumber \\ &+ 2\eta^2 G_1G_2^2 (m_{br_1} + n_{sp}) (m_{br_2} + n_{sp})h_{rr}h_{rd}^2 \nonumber \\ &+ 2\eta^2 G_1^2G_2^2 m_s(m_{br_1} + n_{sp}) h_{sr} h_{rr}^2h_{rd}^2 \nonumber \\ &+ 2\eta^2 G_1 G_2^2 m_s(m_{br_2} + n_{sp}) h_{sr} h_{rr} h_{rd}^2 \nonumber \\ &+ \eta D \big( m_{bd} + m_{bd}^2\big). \end{align} Because of the large number of photons after optical amplification, the mean and the variance of the received photon count at the destination can be approximated closely by a Gaussian \cite{razavi_2005}. Moreover, the thermal noise is generated independently from the received optical signal and has a zero-mean Gaussian distribution with variance due to the resistive element \begin{align} \label{therm_1} \sigma^2_{th} = \frac{2 K_B T_R T_s}{R_L e^2}, \end{align} where $K_B$ is the Boltzmann constant, $T_R$ and $R_L$ are the receiver’s equivalent temperature and load, and $e$ denotes the electron charge. While dark current noise can practically be neglected, the photo-electron count at the destination can accurately be modeled by a Gaussian distribution with mean $m_d = m'_d$ and variance \begin{align} \label{sigma2d} \sigma_d^2 = \sigma'^2_d + \sigma_{th}^2. \end{align} Finally, the electrical SNR at destination is expressed as \begin{align} \label{pj_1} \gamma = \left(\eta G_1G_2 m_s h_{sr} h_{rr} h_{rd}\right)^2/\sigma_d^2. \end{align} As we observe from \eqref{lmw2} and \eqref{sigma2d}, the variance of noise at the destination is very complex. In order to simplify, in the sequel, we propose two approximations over noise variance and then, in the Section III we investigate the accuracy of these approximations. First, we consider the practical case where the amount of background power is low. At this condition, the noise variance at the destination can be approximated as \begin{align} \label{lmw6} \sigma^2_d\simeq&~2\eta^2 G_1^2G_2^2 m_s(m_{br_1} + n_{sp}) h_{sr} h_{rr}^2h_{rd}^2 \nonumber \\ &+ 2\eta^2 G_1 G_2^2 m_s(m_{br_2} + n_{sp}) h_{sr} h_{rr} h_{rd}^2 + \sigma_{th}^2. \end{align} To study the effect thermal noise has on the performance of the considered dual hop FSO system, we assume that the SNR at the destination is limited by thermal noise. According this assumption, noise variance at the destination is simplified as \begin{align} \label{h1} \sigma_d^2 \simeq \sigma^2_{th}. \end{align} \section{Numerical Results and Discussions} We now present numerical and analytical results to evaluate the performance of the considered triple-hop FSO system over log-normal turbulence channel. Different system parameters used throughout performance evaluation are provided in Table \ref{par2}. To facilitate numerical analysis, we consider a similar condition for SR, RR and RD links, i.e., parameters such as visibility $\mathcal{V}$, refractive index structure constant $C_n^2$, background power $P_{br1}=P_{br1}=P_{bd}=P_b$, and divergence angle $\theta_{div}$, are set equal in both channels. In this paper, we analyze the performance of considered system in term of ergodic or average capacity. As we observe from \eqref{pj_1}, electrical SNR at the destination is a function of $h_{sr}$, $h_{rr}$ and $h_{rd}$. Hence, for considered system, ergodic capacity can be obtained as \begin{align} \label{ko2} \mathcal{C}_{\rm erg}=& \int_0^\infty \!\!\int_0^\infty\!\! \int_0^\infty \log\Big(1+\gamma(h_{sr},h_{rr}, h_{rd}) \Big)dh_{sr}dh_{rr}dh_{rd}. \end{align} \begin{table} \caption{System Parameters Used for Simulations} \centering \begin{tabular}{l c c} \hline\hline \\[-1.2ex] {\bf Description} & {\bf Parameter} & {\bf Setting} \\ [.5ex] \hline\hline \\[-1.2ex] Wavelength &$ \lambda $ &$ 1550$ nm \\[1ex] Source-to-destination length &$d_{sd}$& 5 km \\[1ex] Visibility &$\mathcal{V}$& 1.5 km \\[1ex] Refractive index &$C_n^2$& $10^{-15}$ \\[1ex] Aperture area & $ A_a $ & $\pi (0.1)^2$ \\[1ex] Divergence angle & $ \theta_{div} $ &$ 1 $ mrad \\[1ex] Plank\textquotesingle s Constant&$ h_{p} $ &$ 6.6 \times 10^{-34} $ \\[1ex] Boltzmann\textquotesingle s Constant&$ K_{B} $ & $ 1.38 \times 10^{-23} $ \\[1ex] Receiver Load &$ R_{L} $ & $ 100~\Omega $ \\[1ex] Receiver Temperature &$ T_{R} $ & $ 300\degree~K$ \\[1ex] Transfer Rate & $R_s$ & 2 Gbit/s \\[1ex] Symbol Duration &$ T_{s} $ & $1/R_s$ s\\[1ex] Spontaneous emission parameter &$ n_s $ & 1\\[1ex] DoF &$ D $ & 100\\[1ex] Quantum efficiency & $ \eta $ & 0.8 \\[1ex] Average transmit power of source & $ P_s $ & 5 dBm W \\[1ex] Average transmit power of relays & $ P_{r_1}\&P_{r_2} $ & 5 dBm W \\[1ex] \hline\hline \end{tabular} \label{par2} \end{table} \begin{figure} \begin{center} \includegraphics[width=3.3 in ]{ergodic_3D_Pb_5_9.eps} \caption{ Average capacity of FSO relaying system versus SR link length $d_{sr}$, and RR link length $d_{rr}$ for a fixed SD link length $d_{sd}=5$ km and $P_b=5\times10^{-9}$.} \label{1} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.3 in ]{ergodic_3D_Pb_9.eps} \caption{ Average capacity of FSO relaying system versus SR link length $d_{sr}$, and RR link length $d_{rr}$ for a fixed SD link length $d_{sd}=5$ km and $P_b=10^{-9}$.} \label{2} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.3 in ]{ergodic_2D.eps} \caption{ Average capacity of FSO relaying system versus RD link length $d_{rd}$ for a fixed SD link length $d_{sd}=5$ km and different values of $P_b$.} \label{3} \end{center} \end{figure} To demonstrate the effects of optimum relay location on the performance of the considered triple-hop FSO system, in Figs. \ref{1} and \ref{2}, we have plotted the ergodic capacity versus SR link length $d_{sr}$, and RR link length $d_{rr}$ for a fixed SD link length $d_{sd}=5$ km. Figure \ref{1} is depicted for $P_b=5\times10^{-9}$ and Fig. \ref{2} is depicted for $P_b=10^{-9}$. There are three important observations which can be drawn from these figures. First, the performance strongly depends on the relay locations and as we observe, by changing relay locations the ergodic capacity changes, significantly. Second, the optimum location of relays (the location with higher ergodic capacity) depends on the background noise level. For instance, for $P_b=5\times10^{-9}$, the optimum location of relays are achieved at $d_{sr}=1850$, $d_{rr}=1800$ and $d_{rd}=1350$ m and for $P_b=10^{-9}$, the optimum location of relays are achieved at $d_{sr}=1900$, $d_{rr}=1850$ and $d_{rd}=1250$ m. Third, at the optimum location of relays, SR link length is approximately equal to RR link length and they are bigger than that RD link length. Now we want to investigate the validity of approximations on \eqref{lmw2} which are characterized by \eqref{lmw6} and \eqref{h1}. To this aim, in Fig. \ref{3}, we have plotted the ergodic capacity versus $d_{rd}$ for different values of $P_b$ where $d_{sr}=d_{rr}$. In addition to the conclusions drawn form the simulation results proposed in the previous section, from Fig. \ref{3} we can draw the conclusions that at low values of $P_b$, our proposed approximation in \eqref{lmw2} for the noise variance at the destination is valid for all of possible relay locations, while the thermal noise limited approximation proposed in \eqref{h1} is valid for locations close to the source. \section{Conclusion} In this paper, we proposed a comprehensive signal model of triple-hop all-optical relaying FSO systems in the presence of all main noise sources including background, thermal and ASE noise by considering at the same time the effect of the DoF. Using full CSI relaying, we derived the exact expressions for the noise variance at the destination. Then, in order to simplify the analytical expressions of full CSI relaying, we also proposed and investigated the validity of different approximations over noise variance at the destination. Numerical results were provided in term of ergodic capacity and they confirmed that for low values of the background power, the proposed approximation regarding SNR at the destination is valid for all of possible relay locations. For thermal noise limited, it was shown that the considered approximation is valid when the relay is close to the source. \balance
{'timestamp': '2018-10-05T02:10:45', 'yymm': '1810', 'arxiv_id': '1810.02171', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02171'}
arxiv
\section{Introduction} During the past decade, deep neural networks (DNNs) have demonstrated an amazing performance in solving many complex artificial intelligence tasks such as object recognition and identification, text understanding and translation, question answering, and more \cite{goodfellow2016deep}. The capacity of {\it unregularized} fully connected DNNs, as a function of the network size and depth, is fairly well understood \cite{anthony2009neural,bartlett1998sample,shalev2014understanding}. By bounding the $L_2$ norm of the incoming weights of each unit, \cite{salimans2016weight} is able to accelerate the convergence of stochastic gradient descent optimization across applications in supervised image recognition, generative modeling, and deep reinforcement learning. However, theoretical investigations on such networks are less explored in the literature, and a few exceptions are \cite{bartlett1998sample,bartlett2017spectrally,pmlr-v75-golowich18a,neyshabur2018a,neyshabur2015norm,sun2016depth}. There is a central question waiting for an answer: Can we bound the capacity of fully connected DNNs with bias neurons by weight normalization alone, which has the least dependence on the architecture? In this paper, we focus on networks with rectified linear units (ReLU) and study a more general weight normalized deep neural network (WN-DNN), which includes all layer-wise $L_{p,q}$ weight normalizations. In addition, these networks have a bias neuron per hidden layer, while prior studies \cite{bartlett1998sample,bartlett2017spectrally,pmlr-v75-golowich18a,neyshabur2018a,neyshabur2015norm,sun2016depth} either exclude the bias neuron, or only include the bias neuron in the input layer, which differs from the practical application. We establish the upper bound on the Rademacher complexities of this family and study the theoretical properties of WN-DNNs in terms of the approximation error. We first examine how the $L_{p,q}$ WN-DNN architecture influences their generalization properties. Specifically, for $L_{p,q}$ normalization where $q\le p^*$ and $1/p+1/p^{*}=1$, we obtain a complexity bound that is independent of width and only has a square root dependence on the depth. To the best of our knowledge, this is the first theoretical result for the fully connected DNNs including a bias neuron for each hidden layer in terms of generalization. We will demonstrate later that it is nontrivial to extend the existing results to the DNNs with bias neurons. Even excluding the bias neurons, existing generalization bounds for DNNs depend on either width or depth logarithmically \cite{bartlett2017spectrally}, polynomially\cite{pmlr-v75-golowich18a,neyshabur2018a}, or even exponentially \cite{neyshabur2015norm,sun2016depth}. Even for \cite{bartlett2017spectrally}, the logarithmic dependency is not always guaranteed, as the margin bound is \[O\left(\log (\max{\mbox{\boldmath $d$}})/\sqrt{n}\prod\limits_{i=1}^k \norm{\mbox{$\mathbf W$}_i}_{\mbox{$\sigma$}} \left(\sum\limits_{i=1}^k \norm{\mbox{$\mathbf W$}^T_i-\mbox{$\mathbf M$}^T_i}^{2/3}_{2,1}/\norm{\mbox{$\mathbf W$}_i}_{\mbox{$\sigma$}}^{2/3}\right)^{3/2} \right),\] where $\norm{\cdot}_{\mbox{$\sigma$}}$ is the spectral norm, and $\mbox{$\mathbf M$}_i$ is a collection of predetermined reference matrix. The bound will worsen, when the $\mbox{$\mathbf W$}_i$ moves farther from $\mbox{$\mathbf M$}_i$. For example, if \[\norm{\mbox{$\mathbf W$}^T_i-\mbox{$\mathbf M$}^T_i}_{2,1}/\norm{\mbox{$\mathbf W$}_i}_{\mbox{$\sigma$}}\ge A_0\] for some constant $A_0$, then the above bound will rely on the network size by $O\left(\log (\max{\mbox{\boldmath $d$}})k^{3/2} \right)$. We also examine the approximation error of WN-DNNs. It is shown that the $L_{1,\infty}$ WN-DNN is able to approximate any Lipschitz continuous function arbitrarily well by increasing the norm of its output layer and growing its size. Early work on neural network approximation theory includes the universal approximation theorem \cite{cybenko1989approximation,hornik1991approximation,pinkus1999approximation}, indicating that a fully connected network with a single hidden layer can approximate any continuous functions. More recent work expands the result of shallow networks to deep networks with an increased interest in the expressive power of deep networks especially for some families of "hard" functions \cite{arora2018understanding,Eldan2016ThePO, liang2016deep,pmlr-v70-safran17a,pmlr-v49-telgarsky16,yarotsky2017error}. For instance, \cite{pmlr-v49-telgarsky16} shows that for any positive integer $l$, there exist neural networks with $\Theta(l^3)$ layers and $\Theta(1)$ nodes per layer, which can not be approximated by networks with $\Theta(l)$ layers unless they possess $\Omega(2^l)$ nodes. These results on the other hand request for an artificial neural network of which the generalization bounds grow slowly with depth and even avoid explicit dependence on depth. The contributions of this paper are summarized as follows. \begin{enumerate} \item We extend the $L_{2,\infty}$ weight normalization \cite{salimans2016weight} to the more general $L_{p,q}$ WN-DNNs and relate these classes to those represented by unregularized DNNs. \item We include a bias node not only in the input layer but also in every hidden layer. As discussed in Claim \ref{claim:1}, it is nontrivial to extend prior research to study this case. \item We study the Rademacher complexities of WN-DNNs. Especially, with any $L_{p,q}$ normalization satisfying that $q\le p^*$, we have a capacity control that is independent of the width and depends on the depth by $O(\sqrt{k})$. \item We analyze the approximation property of $L_{p,q}$ WN-DNNs and further show the theoretical advantage of $L_{1,\infty}$ WN-DNNs. \end{enumerate} The paper is organized as follows. In Section 2, we define the $L_{p,q}$ WN-DNNs and analyze the corresponding function class. Section 3 gives the Rademacher complexities. In Section 4, we provide the error bounds for the approximation error of Lipschitz continuous functions. \section{Preliminaries}\label{sec:prelim} In this section, we define the WN-DNNs, of which the weights and biases for all layers are scaled by some norm up to a normalization constant $c$. Furthermore, we demonstrate how it surpasses unregularized DNNs theoretically. A neural network on $\mbox{$\mathbb R$}^{d_0}\to\mbox{$\mathbb R$}^{d_{k+1}}$ with $k$ hidden layers is defined by a set of $k+1$ affine transformations $T_1: \mbox{$\mathbb R$}^{d_0}\to\mbox{$\mathbb R$}^{d_1}, T_2: \mbox{$\mathbb R$}^{d_1}\to\mbox{$\mathbb R$}^{d_2},\cdots, T_{k+1}: \mbox{$\mathbb R$}^{d_k}\to\mbox{$\mathbb R$}^{d_{k+1}}$ and the ReLU activation $\sigma(u)=(u)_{+}=u I\{u>0\}$. The affine transformations are parameterized by $T_i(\mbox{$\mathbf u$})=\mbox{\boldmath $W$}_i^T\mbox{$\mathbf u$}+\mbox{$\mathbf B$}_i$, where $\mbox{\boldmath $W$}_{i}\in \mbox{$\mathbb R$}^{d_{i-1}\times d_i},\mbox{$\mathbf B$}_i\in \mbox{$\mathbb R$}^{d_i}$ for $i=1,\cdots,k+1$. The function represented by this neural network is \[ f(x)=T_{k+1}\circ\mbox{$\sigma$}\circ T_{k}\circ\cdots\circ\mbox{$\sigma$}\circ T_{1}\circ\mbox{\boldmath $x$} \] Before introducing $L_{p,q}$ WN-DNNs, we build an augmented layer for each hidden layer by appending the bias neuron $1$ to the original layer, then combine the weight matrix and the bias vector as a new matrix. Define $f^{*}_0(\mbox{\boldmath $x$})=(1,\mbox{\boldmath $x$}^T)^T$. Then the first hidden layer \[f_1(\mbox{\boldmath $x$})= T_{1}\circ\mbox{\boldmath $x$}\triangleq \tilde{\mbox{$\mathbf V$}}_1^Tf_0^*(\mbox{\boldmath $x$}),\] where $\tilde{\mbox{$\mathbf V$}}_1=(\mbox{$\mathbf B$}_1,\mbox{\boldmath $W$}_1^T)^T\in \mbox{$\mathbb R$}^{(d_0+1)\times d_1}$. Define the augmented first hidden layer as \[f^{*}_1(\mbox{\boldmath $x$})=(1,(f_1(\mbox{\boldmath $x$}))^T)^T\in \mbox{$\mathbb R$}^{d_1+1}.\] Then $f^{*}_1(\mbox{\boldmath $x$})\triangleq\mbox{$\mathbf V$}_1^Tf_0^{*}(\mbox{\boldmath $x$})$, where $\mbox{$\mathbf V$}_1=(\mbox{\boldmath $e$}_{10},\tilde{\mbox{$\mathbf V$}}_1)\in \mbox{$\mathbb R$}^{(d_0+1)\times (d_1+1)}$ and $\mbox{\boldmath $e$}_{10}=(1,0,\cdots,0)^T\in \mbox{$\mathbb R$}^{d_0+1}$. Sequentially for $i=2,\cdots,k$, define the $i$th hidden layer as \begin{equation}\label{eqn:def:f} f_i(\mbox{\boldmath $x$})= T_{i}\circ \mbox{$\sigma$}\circ f_{i-1}(\mbox{\boldmath $x$})\triangleq \dotprod{\tilde{\mbox{$\mathbf V$}}_i}{\mbox{$\sigma$}\circ f^{*}_{i-1}(\mbox{\boldmath $x$})}, \end{equation} where $ \tilde{\mbox{$\mathbf V$}}_i=(\mbox{$\mathbf B$}_i,\mbox{\boldmath $W$}_i^T)^T\in \mbox{$\mathbb R$}^{(d_{i-1}+1)\times d_i}$. Note that $\mbox{$\sigma$}(1)=1$, thus $(1,\mbox{$\sigma$}\circ f_{i-1}(\mbox{\boldmath $x$}))=\mbox{$\sigma$}\circ f^{*}_{i-1}(\mbox{\boldmath $x$})$. The augmented $i$th hidden layer is \begin{equation}\label{eqn:aughiddenlayer} f_i^{*}(\mbox{\boldmath $x$})=(1,(f_i(\mbox{\boldmath $x$}))^T)^T\in \mbox{$\mathbb R$}^{d_i+1}, \end{equation} and $f^{*}_i(\mbox{\boldmath $x$})\triangleq \dotprod{\mbox{$\mathbf V$}_i}{\mbox{$\sigma$}\circ f^{*}_{i-1}(\mbox{\boldmath $x$})}$, where \begin{equation}\label{eqn:def:V} \mbox{$\mathbf V$}_i=(\mbox{\boldmath $e$}_{1i},\tilde{\mbox{$\mathbf V$}}_i)\in \mbox{$\mathbb R$}^{(d_{i-1}+1)\times (d_i+1)}, \end{equation} and $\mbox{\boldmath $e$}_{1i}=(1,0,\cdots,0)^T\in \mbox{$\mathbb R$}^{d_{i-1}+1}$. The output layer is \begin{equation} f(\mbox{\boldmath $x$})=T_{k+1} \circ \mbox{$\sigma$} \circ f^{*}_{k}(\mbox{\boldmath $x$})\triangleq \dotprod{\tilde{\mbox{$\mathbf V$}}_{k+1}}{\mbox{$\sigma$}\circ f^{*}_{k}(\mbox{\boldmath $x$})}, \end{equation} where $ \tilde{\mbox{$\mathbf V$}}_{k+1}=(\mbox{$\mathbf B$}_{k+1},\mbox{\boldmath $W$}_{k+1}^T)^T\in \mbox{$\mathbb R$}^{(d_{k}+1)\times d_{k+1}}$. \paragraph{The $L{p,q}$ Norm.} The $L{p,q}$ norm of a $s_1\times s_2$ matrix $A$ is defined as \[\norm{A}_{p,q}=\left( \sum\limits_{j=1}^{s_2} \left( \sum\limits_{i=1}^{s_1}|a_{ij}|^p\right)^{q/p}\right)^{1/q},\] where $1\le p <\infty$ and $1\le q \le \infty$. When $q=\infty$, $\norm{A}_{p,\infty}= \sup_{j} \left( \sum\limits_{i=1}^{s_1}|a_{ij}|^p\right)^{1/p}$. When $p=q=2$, the $L_{p,q}$ is the Frobenius norm. We motivate our introduction of WN-DNNs with a negative result when directly applying existing studies on fully connected DNNs with bias neurons. \paragraph{A Motivating Example.} As shown in Figure \ref{fig:1}, define $f=T_2\circ\mbox{$\sigma$}\circ T_1:\mbox{$\mathbb R$}\to\mbox{$\mathbb R$}$, where $T_1(x)=(-x+1,-x-1)\triangleq \tilde{\mbox{$\mathbf V$}}_1^T(1,x)^T$ and $T_2(\mbox{$\mathbf u$})=1-u_1-u_2\triangleq\tilde{\mbox{$\mathbf V$}}_2^T(1,u_1,u_2)^T$. Consider $f^{'}=100T_2\circ\mbox{$\sigma$}\circ \frac{1}{100}T_1$, as shown in Figure \ref{fig:2} . Then \[f^{'}(x)=100-\mbox{$\sigma$}(-x+1)-\mbox{$\sigma$}(-x-1)=99+f(x)\] Note that the product of the norms of all layers for $f^{'}$ remains the same as that for $f$: \[\norm{100T_2}_**\norm{\frac{T_1}{100}}_*=\norm{T_2}_**\norm{T_1}_*,\] where the norm of the affine transformation $\norm{T_i}_*$ is defined as the norm of its corresponding linear transformation matrix $\norm{\tilde{\mbox{$\mathbf V$}}_i}_*$ for $i=1,2$. Using a similar trick, we could replace the 100 in this example with any positive number. This on the other hand suggests an unbounded output even when the product of the norms of all layers is small. \begin{figure}[h] \centering \begin{subfigure}{0.45\textwidth} \centering \includegraphics[scale=0.7]{3.pdf} \caption{Visualization of $f$.} \label{fig:1} \end{subfigure} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[scale=0.7]{4.pdf} \caption{Visualization of $f^{'}$.} \label{fig:2} \end{subfigure} \caption{The motivating example.} \end{figure} Furthermore, a negative result will be presented in terms of Rademacher complexity in the following claim. \begin{claim}\label{claim:1} Define $\mathcal{N}_{\gamma_{*}\le \gamma}^{k,\mbox{\boldmath $d$}}$ as a function class that contains all functions representable by some neural network of depth $k+1$ and widths $\mbox{\boldmath $d$}$: $f=T_{k+1}\circ\mbox{$\sigma$}\circ T_{k}\circ\cdots\circ\mbox{$\sigma$}\circ T_{1}\circ\mbox{\boldmath $x$}$, where $\mbox{\boldmath $d$}=(m_1,d_1,\cdots,d_k,1),$ $\norm{\cdot}_*$ is an arbitrary norm, and $T_i(\mbox{$\mathbf u$}): \mbox{$\mathbb R$}^{d_{i-1}}\to\mbox{$\mathbb R$}^{d_{i}}=\tilde{\mbox{$\mathbf V$}}_i^T(1,\mbox{$\mathbf u$}^T)^T$, for $i=1,\cdots,k+1$, such that \[\gamma_*=\prod\limits_{i=1}^{k+1}\norm{\tilde{\mbox{$\mathbf V$}}_i}_{*}\le \gamma.\] Then for a fixed n and any sample $S=\{\mbox{\boldmath $x$}_1,\cdots,\mbox{\boldmath $x$}_n\}\subseteq \mbox{$\mathbb R$}^{m_1}$, \[\widehat{\Rademacher}_S(\mathcal{N}_{\gamma_{*}\le \gamma}^{k,\mbox{\boldmath $d$}})=\infty.\] \end{claim} Claim \ref{claim:1} shows the failure of current norm-based constraints on fully connected neural networks with the bias neuron in each hidden layer. Prior studies \cite{bartlett1998sample,bartlett2017spectrally,pmlr-v75-golowich18a,neyshabur2018a,neyshabur2015norm,sun2016depth} included the bias neuron only in the input layer and considered layered networks parameterized by a sequence of weight matrices only, that is $\mbox{$\mathbf B$}_i=\mbox{\boldmath $0$}$ for all $i=1, \cdots, k+1$. While fixing the architecture of neural networks, these works imply that $\prod\limits_{i=1}^{k+1}\norm{\mbox{$\mathbf W$}_i}_*$ is sufficient to control the Rademacher complexity of the function class represented by these DNNs, where $\norm{\cdot}_{*}$ is the spectral norm in \cite{bartlett2017spectrally,neyshabur2018a}, the $L_{1,\infty}$ norm in \cite{bartlett1998sample,sun2016depth}, the $L_{1,\infty}/L_{2,2}$ norm in \cite{pmlr-v75-golowich18a}, and the $L_{p,q}$ norm in \cite{neyshabur2015norm} for any $p\in[1,\infty)$, $q\in[1,\infty]$. However, this kind of control fails once the bias neuron is added to each hidden layer, demonstrating the necessity to use WN-DNNs instead. \paragraph{The $L_{p,q}$ WN-DNNs. } An $L_{p,q}$ WN-DNN by a normalization constant $c\ge 1$ with $k$ hidden layers is defined by a set of $k+1$ affine transformations $T_1: \mbox{$\mathbb R$}^{d_0}\to\mbox{$\mathbb R$}^{d_1}, T_2: \mbox{$\mathbb R$}^{d_1}\to\mbox{$\mathbb R$}^{d_2},\cdots, T_{k+1}: \mbox{$\mathbb R$}^{d_k}\to\mbox{$\mathbb R$}^{d_{k+1}}$ and the ReLU activation, where $T_i(\mbox{$\mathbf u$})=\tilde{\mbox{$\mathbf V$}}_i^T(1,\mbox{$\mathbf u$}^T)^T$, $\tilde{\mbox{$\mathbf V$}}_i\in\mbox{$\mathbb R$}^{(d_{i-1}+1)\times d_i}$ and $\norm{T_i}_{p,q}\triangleq\norm{\tilde{\mbox{$\mathbf V$}}_i}_{p,q}$, for $i=1,\cdots,k+1$. In addition, $\norm{T_i}_{p,q}\equiv c$ for $i=1,\cdots,k$. Define $\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$ as the collection of all functions that could be represented by an $L_{p,q}$ WN-DNN with the normalization constant $c$ satisfying: \begin{enumerate \item[(a)] The number of neurons in the $i$th hidden layer is $d_i$ for $i=1,2,\cdots, k$. The dimension of input is $d_0$, and output $d_{k+1}$; \item[(b)] It has $k$ hidden layers; \item[(c)] $\norm{T_i}_{p,q}\equiv c$ for $i=1,\cdots,k$; \item[(d)] $\norm{T_{k+1}}_{p,q}\le c_o$. \end{enumerate} The following theorem provides some useful observations regarding $\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$. \begin{theorem}\label{thm:nn:prop} Let $c,c_o,c_1,c_2,c_o^1,c_o^2>0$, $p\in[1,\infty)$, $q\in[1,\infty]$, $k,k_1,k_2\in \mathbb{N}$, $\mbox{\boldmath $d$}=(d_0, d_1\cdots,d_{k+1})\in\mathbb{N}_+^{k+2}$, $\mbox{\boldmath $d$}^1=(d^1_0, d^1_1\cdots,d^1_{k_1+1})\in\mathbb{N}_+^{k_1+2}$, and $\mbox{\boldmath $d$}^2=(d^2_0, d^2_1\cdots,d^2_{k_2+1})\in\mathbb{N}_+^{k_2+2}$. \begin{enumerate}[label=(\alph*)] \item \label{nn:prop:1} A function $f:\mbox{$\mathbb R$}^{d_0}\to\mbox{$\mathbb R$}^{d_{k+1}}=T_{k+1}\circ\mbox{$\sigma$}\circ T_{k}\circ\cdots\circ\mbox{$\sigma$}\circ T_{1}\circ\mbox{\boldmath $x$}$, where $T_i(\mbox{$\mathbf u$})=\mbox{\boldmath $W$}_i^T\mbox{$\mathbf u$}+\mbox{$\mathbf B$}_i:\mbox{$\mathbb R$}^{d_{i-1}}\to\mbox{$\mathbb R$}^{d_i}$. Then $f\in \mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$, as long as $\norm{T_i}_{p,q}\le c$ for $i=1,\cdots,k$ and $\norm{T_{k+1}}_{p,q}\le c_o$. \item \label{nn:prop:2}$ \mathcal{N}_{p,q,c_1,c_o}^{k,\mbox{\boldmath $d$}}\subseteq \mathcal{N}_{p,q,c_2,c_o}^{k,\mbox{\boldmath $d$}}$ if $c_1\le c_2$. $ \mathcal{N}_{p,q,c,c^1_o}^{k,\mbox{\boldmath $d$}}\subseteq \mathcal{N}_{p,q,c,c^2_o}^{k,\mbox{\boldmath $d$}}$ if $c^1_o\le c^2_o$. If $g\in \mathcal{N}_{p,q,c,1}^{k,\mbox{\boldmath $d$}}$, then $c_og\in\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$. \item \label{nn:prop:norm} $ \mathcal{N}_{p_1,q,c,c_o}^{k,\mbox{\boldmath $d$}}\subseteq \mathcal{N}_{p_2,q,c,c_o}^{k,\mbox{\boldmath $d$}}$ if $1\le p_1\le p_2<\infty$. $ \mathcal{N}_{p,q_1,c,c_o}^{k,\mbox{\boldmath $d$}}\subseteq \mathcal{N}_{p,q_2,c,c_o}^{k,\mbox{\boldmath $d$}}$ if $1\le q_1\le q_2\le \infty$. $ \mathcal{N}_{p,\infty,c,c_o}^{k,\mbox{\boldmath $d$}}\subseteq \mathcal{N}_{p,q,\tilde{c},\tilde{c}_o}^{k,\mbox{\boldmath $d$}}$, where $\tilde{c}=c\max^{\frac{1}{q}}\{d_1,d_2\cdots,d_{k}\}$ and $\tilde{c}_o=d_{k+1}^{\frac{1}{q}}c_o$. Especially, when $d_{k+1}=1$, $\tilde{c}_o=c_o$. \item \label{nn:prop:widendeepen}$ \mathcal{N}_{p,q,c,c_o}^{k_1,\mbox{\boldmath $d$}^1}\subseteq \mathcal{N}_{p,q,c,c_o}^{k_2,\mbox{\boldmath $d$}^2}$ if $c\ge1$, $k_1\le k_2$, $d_0^2=d_0^1$, $d_i^2\ge d_i^1$ for $i=1,\cdots,k_1$, $ d_i^2\ge d_{k_1+1}^1$ for $i>k_1$, and $d_{k_2+1}^2=d_{k_1+1}^1=1$. \end{enumerate} \end{theorem} In particular, Part (a) connects normalized neural networks to unregularized DNNs. Part (b) shows the increased expressive power of neural networks by increasing the normalization constant or the output layer norm constraint. Part (c) discusses the influence of the choice of $L_{p,q}$ normalization on its representation capacity. Part (d) describes the gain in representation power by either widening or deepening the neural networks. \section{Estimating the Rademacher Complexities of $\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$}\label{sec:rader} In this section, we bound the Rademacher complexities of $\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$, where $d_0=m_1$ and $d_{k+1}=1$. Without loss of generality, assume the input space $\mathcal{X}= [-1,1]^{m_1}$ in the following sections. Further define $p^*$ by $1/p+1/p^{*}=1$. \begin{proposition}\label{prop:RCp1} Fix $q \ge 1, k \ge 0, c, c_o>0, d_i\in\mathbb{N}_+$ for $i=1,\cdots,k$, then for any set $S=\{\mbox{\boldmath $x$}_1,\cdots,\mbox{\boldmath $x$}_n\}\subseteq \mathcal{X}$ , we have \begin{align*} \widehat{\Rademacher}_S(\mathcal{N}_{1,q,c,c_o}^{k,\mbox{\boldmath $d$}})&\le\frac{c_o}{\sqrt{n}}\min\left( 2\max(1,c^k)\sqrt{k+2+\log(m_1+1)},\right.\\&\left.\sqrt{k\log 16}\sum\limits_{i=0}^kc^i+c^k(\sqrt{2\log(2m_1)}+\sqrt{k\log 16})\right).\end{align*} \end{proposition} \begin{proof}[Proof sketch] As $\mbox{$\sigma$}(1)=1$, we could treat the bias neuron in the $i$th hidden layer as a hidden neuron computed from the $(i-1)$th hidden layer by \[\mbox{$\sigma$}(\mbox{\boldmath $e$}_{1i}^Tf^*_{i-1}(\mbox{\boldmath $x$}))=1,\] where $\mbox{\boldmath $e$}_{1i}=(1,0,\cdots,0)^T\in \mbox{$\mathbb R$}^{d_{i-1}+1}$, and $f^*_{i-1}$ is the augmented $(i-1)$th hidden layer as defined in Equation \eqref{eqn:aughiddenlayer}. Therefore, the new affine transformation could be parameterized by $\mbox{$\mathbf V$}_i$ defined in Equation \eqref{eqn:def:V}, such that $\norm{\mbox{$\mathbf V$}_i}_{1,\infty}=\max(1,c)$. Then the result is the minimum of the bound of \cite[Theorem 2]{pmlr-v75-golowich18a} on DNNs without bias neurons and that of Proposition \ref{prop:RCp2} when $p=1$. \end{proof} \begin{proposition}\label{prop:RCp2} Fix $p, q \ge 1, k \ge 0, c, c_o>0, d_i\in\mathbb{N}_+$ for $i=1,\cdots,k$, then for any set $S=\{\mbox{\boldmath $x$}_1,\cdots,\mbox{\boldmath $x$}_n\}\subseteq \mathcal{X}$ , we have \begin{enumerate}[label=(\alph*)] \item for $p\in (1,2]$, \begin{equation}\label{eqn:prop2:1} \begin{split} \widehat{\Rademacher}_S(\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}})&\le c_o\sqrt{\frac{(k+1)\log 16}{n}}\left(\sum\limits_{i=1}^{k+1}c^{k-i+1}\prod\limits_{l=i}^kd_l^{[\frac{1}{p^*}-\frac{1}{q}]_+}\right)+\\&\frac{c_oc^{k}}{\sqrt{n}}\prod\limits_{i=1}^kd_i^{[\frac{1}{p^*}-\frac{1}{q}]_+}m_1^{\frac{1}{p^{*}}}\left[\min\left((\sqrt{p^{*}-1}, \sqrt{2\log(2m_1)} \right)+\sqrt{(k+1)\log 16}\right], \end{split} \end{equation} \item for $p\in 1\cup(2,\infty)$, \begin{equation}\label{eqn:prop2:2} \begin{split} \widehat{\Rademacher}_S(\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}})&\le c_o\sqrt{\frac{(k+1)\log 16}{n}}\left(\sum\limits_{i=1}^{k+1}c^{k-i+1}\prod\limits_{l=i}^kd_l^{[\frac{1}{p^*}-\frac{1}{q}]_+}\right)+\\&\frac{1}{\sqrt{n}}c_oc^{k}\prod\limits_{i=1}^kd_i^{[\frac{1}{p^*}-\frac{1}{q}]_+}m_1^{\frac{1}{p^{*}}}\left(\sqrt{2\log(2m_1)}+\sqrt{(k+1)\log 16}\right). \end{split} \end{equation} \end{enumerate} \end{proposition} \begin{proof}[Proof sketch] The proof consists of two steps. In the first step, following the notations in Section 2, we define a series of random variables \[Z_{j}=\sup_{f\in\mathcal{N}^{k,\mbox{\boldmath $d$}}_{p,q,c,c_o}}\norm{\sum\limits_{i=1}^n\epsilon_i\mbox{$\sigma$}\circ f_j(\mbox{\boldmath $x$}_i)}_{p^*},\] where $\{\epsilon_1,\cdots,\epsilon_n\}$ are $n$ i.i.d Rademacher random variables, and $f_j$ is the $j$th hidden layer of the neural network $f$. We prove by induction that for any $t\in\mbox{$\mathbb R$}$, \[ \mathbb{E}_\epsilon\exp(tZ_j)\le4^{j} \exp\left(\frac{t^2ns^2_j}{2}+tc^j\prod\limits_{i=1}^jd_i^{[\frac{1}{p^*}-\frac{1}{q}]_+}A_{m_1,S}^{p}\right),\] where \[s_j=\sum\limits_{i=2}^jc^{j-i+1}\prod\limits_{l=i}^jd_l^{[\frac{1}{p^*}-\frac{1}{q}]_+}+(m_1^{1/p^*}+1)c^j\prod\limits_{l=1}^jd_l^{[\frac{1}{p^*}-\frac{1}{q}]_+},\] and $A_{m_1,S}^{p}$ is some constant only depends on the sample. In addition, we relies on H\"older's inequality with an optimal parameter to separate the bias neuron. Step 2 is motivated by the idea of \cite{pmlr-v75-golowich18a}. By Jensen's inequality \[ n\widehat{\Rademacher}_S(\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}})\le \frac{1}{\lambda}\log \mathbb{E}_\epsilon \exp\left(\lambda\sup_{f \in \mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}}{\left( \sum_{i=1}^n{\epsilon_i f(\mbox{\boldmath $x$}_i)}\right)}\right).\] Finally we get the desired result by choosing the optimal $\lambda$. \end{proof} When $\mbox{\boldmath $d$}=d \mbox{\boldmath $1$}$, the upper bound of Rademacher complexity depends on the width by $O(d^{k[ \frac{1}{p^*}-\frac{1}{q} ]_+})$, which is similar to the case without bias neurons \cite{neyshabur2015norm}. Furthermore, the dependence on widths disappears as long as $q\in[1,p^*]$. In order to investigate the tightness of the bound given in Proposition \ref{prop:RCp2}, we consider the binary classification as a specific case, indicating that when $\frac{1}{p} + \frac{1}{q} < 1$, the dependence on width is unavoidable. \begin{proposition}\cite[Theorem 3]{neyshabur2015norm} \label{prop:lower} For any $p,q\ge 1$, $\mbox{\boldmath $d$}=d \mbox{\boldmath $1$}$ and any $k\ge 2$, $n$ $\{-1,+1\}$ points could be shattered with unit margin by $\mathcal{N}_{p,q,c,c_o}^{k,\mbox{\boldmath $d$}}$, with \[c^kc_o\le (\log_2n)^{\frac{1}{p }} n^{(\frac{1}{p}+\frac{1}{q})}d^{-(k-2)[ \frac{1}{p^*}-\frac{1}{q} ]_+}.\] \end{proposition} \paragraph{Issues on Bias Neurons.} $L_{p,q}$ norm-constrained fully connected DNNs with no bias neuron were investigated in prior studies \cite{bartlett1998sample,pmlr-v75-golowich18a,neyshabur2015norm,sun2016depth}. First of all, the generalization bounds given by \cite{bartlett1998sample,neyshabur2015norm,sun2016depth} have explicit exponential dependence on the depth, thus it is not meaningful to compare these results with ours. Secondly, \cite{pmlr-v75-golowich18a} provides the up-to-date Rademacher complexity bounds of both $L_{1,\infty}$ and $L_{2,2}$ norm-constrained fully connected DNNs without bias neurons. However, it is not straightforward to extend their results to fully connected DNNs with a bias neuron in each hidden layer. For example, consider the $L_{2,2}$ WN-DNNs with $c=1$. If we simply treat each bias neuron as a hidden neuron, as in the proof for Proposition \ref{prop:RCp1}, the complexity bounds \cite{pmlr-v75-golowich18a} grows exponentially with respect to the depth by $O(\sqrt{k}2^{\frac{k}{2}})$, while our Proposition \ref{prop:RCp2} gives a much tighter bound $O(k^{\frac{3}{2}})$. \paragraph{Comparison with \cite{pmlr-v75-golowich18a} on the Rademacher compexity bounds of $L_{1,\infty}$ and $L_{2,2}$ WN-DNNs.} \cite{pmlr-v75-golowich18a} is the most recent work on the Rademacher complexities of the $L_{1,\infty}$ and $L_{2,2}$ norm-constrained fully connected DNNs without bias neurons. Consider a specific case when $\log(m_1)$ is small and $c_o=1$ to shed light on the possible influence of the bias neurons on the generalization properties. \begin{table}[h] \centering \begin{tabular}{c|cc} \hline &With Bias Neurons & Without Bias Neurons \cite{pmlr-v75-golowich18a} \\ \hline $c<1$&$O(\frac{\sqrt{k}(1-c^{k+1})}{(1-c)\sqrt{n}})$ &$O(\frac{\sqrt{k}c^k}{\sqrt{n}})$ \\\hline $c=1,L_{1,\infty}$&$O(\frac{\sqrt{k}}{\sqrt{n}})$&$O(\frac{\sqrt{k}}{\sqrt{n}})$\\\hline $c=1,L_{2,2}$&$O(\frac{k^{3/2}}{\sqrt{n}})$&$O(\frac{\sqrt{k}}{\sqrt{n}})$\\\hline $c>1, L_{1,\infty}$&$O(\frac{\sqrt{k}c^{k}}{\sqrt{n}})$&$O(\frac{\sqrt{k}c^k}{\sqrt{n}})$ \\ \hline $c>1,L_{2,2}$&$O(\frac{\sqrt{k}(c^{k+1}-1)}{\sqrt{n}})$&$O(\frac{\sqrt{k}c^k}{\sqrt{n}})$ \\ \hline \end{tabular} \caption{Rademacher complexity bounds for $L_{1,\infty}$/$L_{2,2}$ WN-DNNs with/without bias neurons. } \label{tab:1} \end{table} As summarized in Table \ref{tab:1}, these comparisons suggest that the inclusion of a bias neuron in each hidden layer might lead to extra dependence of generalization bounds on the depth especially when $c$ is small. Note that, when $c<1$, $\sqrt{k}(1-c^{k+1})/(1-c)\to \infty$, while $\sqrt{k}c^k\to 0$, as $k\to \infty$. For $L_{2,2}$ WN-DNNs, when $c=1$, the bounds are $O(\frac{k^{\frac{3}{2}}}{\sqrt{n}})$ if with bias neurons and $O(\frac{\sqrt{k}}{\sqrt{n}})$ without bias neurons. For $L_{2,2}$ WN-DNNs, when $c>1$, the bounds are $O(\frac{\sqrt{k}(c^{k+1}-1)}{\sqrt{n}})$ if including bias neurons and $O(\frac{\sqrt{k}c^k}{\sqrt{n}})$ if excluding bias neurons. Another interesting observation is that the complexity bounds remain the same no matter whether bias neurons are included or not, when $c>1$ for $L_{1,\infty}$ WNN-DNNs. \section{Approximation Properties }\label{sec:approx} In this section, we analyze the approximation properties of $L_{p,q}$ WN-DNNs and show the theoretical advantage of $L_{1,\infty}$ WN-DNN. We first introduce a technical lemma, demonstrating that any wide one-hidden-layer neural network could be exactly represented by a deep but narrow normalized neural network. In addition, Lemma \ref{lemma:approx:con:deep} indicates that $\mathcal{N}_{1,\infty,\cdot,c_o}^{1,(m_1,r,1)}\subseteq \mathcal{N}_{p,\infty,1,2c_o}^{k,(m_1,([r/k]+2m_1+3){\bf1}_k,1)}$ for any $r>1$, $k\in \mathcal{N}$, and $c_o>0$, where $[x]$ is the smallest integer which is greater than or equal to $x$, and ${\bf1}_k=(1,\cdots,1)\in\mbox{$\mathbb R$}^k$. \begin{lemma}\label{lemma:approx:con:deep} Assume that a function \[g(\mbox{\boldmath $x$}):\mbox{$\mathbb R$}^{m_1}\to\mbox{$\mathbb R$}=\sum\limits_{i=1}^rc_i\mbox{$\sigma$} (\mbox{\boldmath $w$}_i^T\mbox{\boldmath $x$}+b_i)\] satisfies that $\sum\limits_{i=1}^r |c_i|\le c_o$ and $\norm{(b_i,\mbox{\boldmath $w$}_i^T)}_1=1$. Then for any integer $k\in[1,r]$, \[g\in\mathcal{N}_{p,q,wid_k^{1/q},2c_o}^{k,\mbox{\boldmath $d$}^k},\] where $wid_k=[r/k]+2m_1+3$, $d^k_0=m_1$, $d^k_i=wid_k$ for $i=1,\cdots,k$, and $d^k_{k+1}=1$. \end{lemma} \begin{proof}[Proof sketch] Note that the shallow neural network $g$ could be decomposed as \[\sum\limits_{i=1}^{r_1}c_i^+\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+\right)-\sum\limits_{i=1}^{r_2}c_i^-\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^-)^T\mbox{\boldmath $x$}+b_i^-\right), \] where $c_i^+, c_i^->0$ and $r_1+r_2=r$. We consider a simplified case when $g(\mbox{\boldmath $x$})=\sum\limits_{i=1}^{r_1}c_i^+\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+\right)$ to illustrate the main idea of our proof. Without loss of generality, assume that $\norm{(b_i,2\mbox{\boldmath $w$}_{i}^T)}_1=1$. First create a set \[\mathcal{C}=\{\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+\right),i=1,\cdots,r_1\}.\] In order to build a $k+1$-layer WN-DNN to represent $g$, we partition $\mathcal{C}$ into $k$ equally sized subsets: $\mathcal{C}_1,\cdots,\mathcal{C}_k$. The key idea is to get all elements of $\mathcal{C}_j$ in the $j$th hidden layer for $j=1,\cdots,k$, while keeping both $\mbox{$\sigma$}\circ\mbox{\boldmath $x$}$, and $\mbox{$\sigma$}\circ-\mbox{\boldmath $x$}$. In addition, the normalized cumulative sum $S_j$ of $\cup_{i\le j}\mathcal{C}_i$ is computed in the $j+1$th hidden layer. More specifically, \[S_j=\frac{\sum\limits_{i=1}^{jr_1/k}c_i^+\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+\right)}{\sum\limits_{i=1}^{jr_1/k}c_i^+}.\] Note that \[(\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+=(\mbox{\boldmath $w$}_i^+)^T\mbox{$\sigma$}\circ\mbox{\boldmath $x$}-(\mbox{\boldmath $w$}_i^+)^T\mbox{$\sigma$}\circ(-\mbox{\boldmath $x$})+b_i^+,\] and \[S_j=\frac{\sum\limits_{i=1}^{(j-1)r_1/k}c_i^+}{\sum\limits_{i=1}^{jr_1/k}c_i^+}\mbox{$\sigma$}(S_{j-1})+\sum\limits_{i=(j-1)r_1/k+1}^{jr_1/k}\frac{c_i^+}{{\sum\limits_{i=1}^{jr_1/k}c_i^+}}\mbox{$\sigma$}\left((\mbox{\boldmath $w$}_i^+)^T\mbox{\boldmath $x$}+b_i^+\right).\] Thus the $L_{1,\infty}$ norm of the corresponding transformation still $\le 1$. \end{proof} Based on Lemma \ref{lemma:approx:con:deep}, we establish that a WN-DNN is able to approximate any Lipschitz-continuous function arbitrarily well by loosing the constraint for the norm of the output layer and either widening or deepening the neural network at the same time. Especially, for $L_{p,\infty}$ WN-DNNs, the approximation error could be purely controlled by the norm of the output layer, while the $L_{p,\infty}$ norm of each hidden layer is fixed to be 1. \begin{theorem}\label{thm:approx} $f:\mathcal{X}\to\mbox{$\mathbb R$}$, satisfying that $\norm{f}_\infty\le L$, and $\lvert f(x)-f(y)\rvert\le L\norm{x-y}_\infty$. Then for any $p\in[1,\infty)$, $q\in[1,\infty]$, and any integer $k\in[1,C_r(m_1)(\log \frac{c_o}{L})^{-2(m_1+1)/(m_1+4)}\left(\frac{c_o}{L}\right)^{2(m_1+3)/(m_1+4)}] $, if $c_o$ greater than a constant depending only on $m_1$, there exists a function $h \in\mathcal{N}_{p,q,wid_k^{1/q},2c_o}^{k,\mbox{\boldmath $d$}^k}$, where \[wid_k=[ k^{-1}C_r(m_1)(\log \frac{c_o}{L})^{-\frac{2(m_1+1)}{m_1+4}}\left(\frac{c_o}{L}\right)^{\frac{2(m_1+3)}{m_1+4}}]+2m_1+3,\] $\mbox{\boldmath $d$}^k=(m_1,wid_k,\cdots,wid_k,1)$, such that \[\sup\limits_{\norm{\mbox{\boldmath $x$}}_\infty\le 1}\vert f(\mbox{\boldmath $x$})-h(\mbox{\boldmath $x$})\rvert\le C(m_1)L(\frac{c_o}{L})^{-\frac{2}{m_1+1}}\log\frac{c_o}{L}, \] where $C_r(m_1)$ and $C(m_1)$ denotes some constant that depends only on $m_1$. \end{theorem} Theorem \ref{thm:approx} shows that the approximation bounds could be controlled by $c_o$ given a sufficiently deep or wide $L_{p,q}$ WN-DNN. Assume that the loss function is 1-Lipschitz continuous, then the dependence of the corresponding generalization bound on the architecture for each $\mathcal{N}_{p,q,wid_k^{1/q},2c_o}^{k,\mbox{\boldmath $d$}^k}$ defined above are summarized as follows: \begin{enumerate} \item[(a)] $p=1, q=\infty$: $O\left(\sqrt{k}c_o\right)$;\\ \item[(b)] $p=1, q<\infty$: $O\left(\sqrt{k}c_owid_k^{\frac{k}{q}}\right)$;\\ \item[(c)] $p>1, q\in(p^*,\infty]$: $O\left(\sqrt{k}c_o[(1+wid_k)^{\frac{1}{p^*}}]^k\right)$;\\ \item[(d)] $p>1, q\in[1,p^*]$: $O\left(\sqrt{k}c_o[(1+wid_k)^{\frac{1}{q}}]^k\right)$. \end{enumerate} \section{Concluding Remarks} We present a general framework for capacity control on WN-DNNs. In particular, we provide a satisfying answer for the central question: we obtain the generalization bounds for $L_{1,\infty}$ WN-DNNs that grows with depth by a square root term while getting the approximation error controlled. It will be interesting to extend this work to mullticlass classification. However, if handling via Radermacher complexity analysis, the generalization bound will depend on the square root of the number of classes \cite{zhang2004statistical}. Besides the extension to convolutional neural networks, we are also working on the design of effective algorithms for $L_{1,\infty}$ WN-DNNs. \subsubsection*{Acknowledgments} We thank the anonymous reviewers for their careful reading of our manuscript and their insightful comments that have greatly improved the paper.
{'timestamp': '2018-11-29T02:05:22', 'yymm': '1810', 'arxiv_id': '1810.01877', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01877'}
arxiv
\section{Introduction} \label{sec:intro} \vspace{-0.1cm} The state-of-art performances in visual recognition obtained by Convolutional Neural Networks (CNNs) are subject to the availability of a large set of annotated training data to learn the model. Since it is rarely the case for many practical tasks of interest (\textit{target-tasks}), one usually adopts a transfer-learning approach~\cite{oquab2014learning,razavianASC14,popescu15arxiv} which relies on a CNN pre-trained on a \textit{source task} with sufficient annotated data (often ImageNet~\cite{russakovsky2014imagenet}) then further truncated to provide the representations of the samples of target-task. Then, even with few annotated data, this last can usually be learned with a linear classifier. Such approaches raise the question of the similarity of the \textit{source-task} on which the representation has been learned and the target-task on which it is used. Although this similarity is not easy to formalize, one has the intuition that the closer the both tasks the better the representation will be adapted to the target-task. This consideration leads to several methods that tend to obtain more \textit{universal} representations~\cite{bilen2017universal,conneau2017supervised,kokkinos2017ubernet,rebuffi2017learning,tamaazousti2017mucale_net,tamaazousti2018universal}, that is to say that are more adapted to a large set of diverse target-tasks, in a transfer-learning scenario. The general idea of these methods is to diversify the classification problem of the source-task in order to obtain more features, able to adequately represent new target-datasets, from more domains, in a larger context. All these approaches vary the problem by creating new categories having an existing label. However, most of them studied the effect of adding categories extracted from ImageNet, either \textit{generic} categories~\cite{krizhevsky2012imagenet,mettesicmr16,tamaazousti2017mucale_net, tamaazousti2018universal} or \textit{specific} ones~\cite{zhou2014learning,azizpour2015generic,bilen2017universal,rebuffi2017learning}, that are at the bottom of a hierarchy such as ImageNet, except~\cite{joulin2015learning,vo15cbmi,vo2017harnessing} that use web annotations with noisy labels. In general, the usage of specific categories tends to provide better performances than generic ones~\cite{bilen2017universal,rebuffi2017learning}, although combining them can significantly boost the universalizing capacity of the CNN~\cite{tamaazousti2017mucale_net,tamaazousti2018universal}. Yet, even for the most specific categories, it is plausible that it exists a variety of semantics within the class that is not explored (\textit{e.g.}, one could imagine to split the object-class according to the different poses of the object). Clearly, the limiting point is the availability of such finest annotation (\textit{e.g.}, poses, contexts, attributes) for existing specific classes. In this article, we argue that exploring \textit{finer} classes than the most \textit{specific} existing ones, can significantly increase the diversity of the problem, therefore improve the universality of the representation learned in the internal layers of the CNN. The main difficulty is the lack of annotation below the most specific levels. We propose to rely on unsupervised learning (clustering) to determine these finer categories within each specific category. Our contribution is three-fold. First, we show that the use of finer categories rather than the most specific ones to learn CNNs, improves the universality of the resulting representation, even when the finer classes are determined \textit{randomly} within each specific class. Second, the usage of a K-means based approach leads to slightly better results although the resulting clusters are strongly imbalanced. To fix this, our core contribution splits and merges the specific categories to automatically determine better balanced finer classes, leading to better results. Last, we show that CNNs learned with our approach provide a better complementary to standard CNN representations than those learned on generic categories. Let note that if the target-task has enough data, the representation can be adapted to the target-task by fine-tuning. This is nevertheless out of the scope of this work, because it is a \textit{complementary} process to the transfer-learning in itself, that will always improve the performances, and especially, because fine-tuning modifies the representations, which leads to a bias that \textit{hides the real ability} of a universalizing method~\cite{huh2016makes}. Hence, in this paper, we are only interested into studying the universality of the representations, independently of many possible refinements of a full adaptation method on each target-task. Previous works~\cite{dong2013subcategory,dong2015looking,xiang2017subcategory,chen2017s} exploited sub-categories in the context of visual recognition. In~\cite{dong2013subcategory,dong2015looking}, an object instance affinity graph is computed from intra-class similarities and inter-class ambiguities then the visual subcategories are detected by the graph shift algorithm. The process is nevertheless quite computationally demanding and applied to object detection on small target datasets only. In~\cite{xiang2017subcategory,chen2017s}, subcategories that are learned from extrapolated feature maps and fine-tuned on a target-dataset, are used within a CNN to improve region proposal for object detection. To the best of our knowledge, our paper is the first to propose the usage of subcategories determined by unsupervised learning on a source-task, in order to improve universality of representations. More related to universality, \cite{bilen2017universal,rebuffi2017learning,rebuffi2018efficient} added annotated data from more domains as well as domain-specific neurons to an initial set of domain-agnostic ones. Contrary to them, our method only modifies the source-problem at zero cost of annotation. Our work is closer to the approach of~\cite{tamaazousti2017mucale_net,tamaazousti2018universal} that proposes to relabel specific categories into generic ones (that match the upper categorical-levels), to learn an additive CNN with the same architecture. Nevertheless, our approach is interested into the ``opposite way'', that is, creating finer classes than those at the bottom of a hierarchy (ImageNet), for which no annotation exists and thus their method can not be applied. We evaluated our proposal on the problem of universality, that is, in a transfer-learning scheme using multiple target-tasks (\textit{i.e.}, ten classification benchmarks from multiple domains, including actions, food, scenes, birds, aircrafts, etc.). In particular, in comparable settings (using ILSVRC as source-task and two architectures, AlexNet~\cite{krizhevsky2012imagenet} and DarkNet~\cite{redmon2017yolo9000}), we showed that our method outperforms state-of-the-art ones. \section{Proposed Method} \vspace{-0.2cm} We propose a new universalizing method that consists in training a network on a set of categories that are \textit{finer} than those of the \textit{finest}-level of a hierarchy (\textit{e.g.}, ImageNet hierarchy or any set of categories). In Sec.~\ref{sec:finet_splitting_random_clustering}, we start by describing its general principle as well as two baselines that splits them either randomly or by clustering their features. With such baseline, the number of finer classes must be a priori fixed, thus we propose a ``bottom-up clustering-based merging'' approach that determines a better splitting automatically (Sec.~\ref{sec:bucbam}). Furthermore, we propose to combine the features learned on the specific categories and those learned on the finer ones to get an even more universal representation (Sec.~\ref{sec:spefinet}). \begin{figure*}[tb!] \begin{center} \includegraphics[width=12.0cm]{images/finer_level.png} \end{center} \vspace{-0.5cm} \caption{ Illustration of our splitting principle that determines a \textit{finer}-level $\ell$+1 containing $n_{\ell +1}$ \textit{finer}-classes (blue nodes in \textbf{A}) from the \textit{finest}-level $\ell$ of a hierarchy (here, ImageNet), containing $n_{\ell}$ \textit{specific} categories that the leaf gray nodes in \textbf{(A)}. Each finer-class $c_i^{\ell +1}$ ($i \in [n_{\ell +1}]$) is related to a specific-class $c_j^{\ell}$ ($j \in [n_{\ell}]$) through ``is-a'' relations, since the $c_i^{\ell +1}$ classes are obtained from \textit{each} $c_j^{\ell}$ class. In \textbf{(B)}, we focus on the particular specific class $c_{n_l}^{\ell}$ (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/class_gray.png}) and its image-representations (\protect \includegraphics[width=1.5ex,height=1.5ex]{legends/circle.png}), to determine the finer-classes $\{c_{n_l-3}^{\ell +1}, c_{n_l-2}^{\ell +1}, c_{n_l-1}^{\ell +1}, c_{n_l}^{\ell +1}\}$. In (b), it is splitted into $K$ (here $K$$=$$4$) groups (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/bucbam_clusters_blue.png}) corresponding to the finer-classes $c_j^{\ell +1}$. } \vspace{-0.3cm} \label{fig:finer-level_finer-classes} \end{figure*} \subsection{FiNet: Network Trained on Finer-Classes} \label{sec:finet_splitting_random_clustering} \vspace{-0.2cm} The leaf nodes of the ImageNet hierarchy represents the \textit{finest} or most \textit{specific} categories that are annotated. More generally, this is the case for the set of categories of any classification dataset. To go towards our goal of automatically obtaining finer categories (without annotations) from the finest ones, a baseline approach consists in using a random partitioning of the specific categories or a simple clustering-based approach of their image-features. The first baseline, randomly assigns every image of a specific category to one of $K_i$ clusters. The second one, first, learns a CNN (noted \textbf{SpeNet}) on the specific categories, uses one of its layer as features-extractor for every image, then determines $K_i$ clusters using K-means on these vectors. A more sophisticated way is our final method that is presented in Sec.~\ref{sec:bucbam}. Note that, in all cases, the splitting is performed on specific categories, that already contains quite similar samples/vectors. Once the finer classes obtained, we train another network (denoted \textbf{FiNet}) on the \textit{same} images used to train SpeNet, but labeled among the obtained \textit{finer}-classes. The whole set of finer-classes forms the new finest-level of the hierarchy. Our general principle is illustrated in Fig.~\ref{fig:finer-level_finer-classes} and presented more formally below. Let us consider a semantic hierarchy with hyponymy relations, that is to say a set of categories organized according to ``is-a'' relations (\textit{e.g.}, ImageNet~\cite{deng09imagenet} hierarchy). This hierarchy denoted $\mathcal{H}_{\ell}=(\mathcal{C}_{\ell},E)$ is a directed acyclic graph of $\ell$ levels of nodes, with $\mathcal{C}_{\ell}$ being all the nodes and $E$ the set of directed edges between the nodes. Each node $c_i^{\ell}\in \mathcal{C}_{\ell}$ corresponds to the $i$-th category at level $\ell$ in $\mathcal{H}_{\ell}$ and $n_{\ell}$ is the number of categories at level $\ell$. A hierarchy-edge $(c_i^{\ell},c_j^{\ell +1})\in E$ indicates that class $c_i^{\ell}$ subsumes class $c_j^{\ell +1}$. Let us also consider an initial dataset $\mathcal{D}_{N}^{\ell}$ containing a set of $N$ images labeled among the categories at level $\ell $ and let us denote $N_{i}^{\ell}$ the number of images labeled among the $i$-th category at level $\ell$. Note that, $N = \sum_{i=1}^{n_l} N_i^{\ell}$. Each image $\textbf{I}_i^j\in \mathcal{D}_N^{\ell}$ of the dataset, is associated to a given category $c_j^{\ell}$ for $j\in [n_{\ell}]$\footnote{Let $[n]$ denotes $\llbracket1 ,n \rrbracket$, in all the paper.}. Let us denote $\textbf{X}_i^{\ell, L}\in \mathbb{R}^{d_{\ell}}$ the representation of an image $\textbf{I}_i$ extracted from layer $L$ of the network trained on $\mathcal{D}_N^{\ell}$ (\textit{i.e.}, SpeNet). Let also $\mathcal{X}_i^{\ell} = \{ \textbf{X}_j^{\ell,L}\}_{j=1}^{N_i^{\ell}}$ being the set of features extracted from all the images belonging to the category $c_i^{\ell}$. In order to construct the $K_i$ finer-categories $\{c_j^{\ell +1}\}_{j=1}^{ n^{\ell+1}}$ of \textit{each} category of the previous level $c_i^{\ell}$, we apply a clustering algorithm (\textit{e.g.}, K-means, MeanShift or BUCBAM presented in Sec.~\ref{sec:bucbam}) on $\mathcal{X}_i^{\ell}$ (that builds $K_i$ centroids) where the feature vector $\textbf{X}_j^{\ell,L}$ of each image $\textbf{I}_j$ ($j\in [N_i^{\ell}]$) is assigned to the nearest centroid (hard-coding~\cite{liu2011defense}), which forms the $K_i$ finer classes. This process is applied for all $i\in [n_{\ell}]$ which gives the $n_{\ell +1}=K_i\times n_{\ell}$ finer classes, that forms the nodes of the finer level $\ell +1$. This latter results in a new dataset $\mathcal{D}_N^{\ell +1}$, for which each image $\textbf{I}_i^j\in \mathcal{D}_N^{\ell +1}$ is associated to a given category $c_j^{\ell +1}$ for $j\in [n_{\ell +1}]$. Note that by construction, every $c_i^{\ell}$ subsumes all its finer-categories $\{c_{j}^{\ell +1}\}_{j=1}^{K_i}$, thus we have ($c_i^{\ell}, c_{j}^{\ell +1})_{(i,j)\in [n_{\ell}]\times[K_i]}$. The whole process results in a new hierarchical level $\ell +1$ that forms the new hierarchy $\mathcal{H}_{\ell+1}=(\mathcal{C}_{\ell+1},E')$ with $\mathcal{C}_{\ell+1} = \mathcal{C}_{\ell}\cup \{ c_{j, j\in[K_i]}^{\ell +1} \}_{i\in [n_{\ell}]}$. $E'$ corresponds to the union of $E$ and the edges that connect each category $c_i^{\ell}$ to its $K_i$ finer ones $c_j^{\ell +1}$. It is important to point out that, depending on the clustering algorithm, $K_i$ will depend on $c_i^{\ell}$ or be the \textit{same} for all categories. This is discussed in the next section. The new dataset $\mathcal{D}_{N}^{\ell+1}$ is used to train (softmax cross-entropy loss minimized by SGD) the FiNet network, which has $n_{\ell +1}$ neurons on its last layer. FiNet is then used as features-extractors for the images $\textbf{I}_i$ of the target-tasks: $\textbf{X}_i^{\ell +1, L}=\Phi^{\ell +1}_L(\textbf{I}_i)$. \begin{figure*}[tb!] \begin{center} \includegraphics[width=9.0cm]{images/bottom_up_clustering_based_merging.png} \end{center} \vspace{-0.5cm} \caption{ On the left, given image-representations (\protect \includegraphics[width=1.5ex,height=1.5ex]{legends/circle.png}) labeled among a specific class (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/class.png}), BUCBAM first performs a clustering with many clusters (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/many_clusters.png}), then attaches small clusters to bigger closest ones (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/small_clusters.png}) and lastly, merges similar ones (\protect \includegraphics[width=2.0ex,height=1.5ex]{legends/bucbam_clusters.png}), w.r.t certain strategies. On the right, we describe the latter merging strategies. Given the similarity matrix $\textbf{M}_j$ (high values: blue, low: white) for one specific class $c_j^{\ell}$, BUCBAM-SS merges \textit{only} clusters that are reciprocally highly similar to each other, respecting constraint (a) with high scoring values in $(\textbf{M}_j)_{k,l}$ and $(\textbf{M}_j)_{l,k}$). BUCBAM-AS \textit{also} merges asymmetrically similar clusters (those that respect constraints (a), (b) and (c)). In both cases, dissimilar clusters (d) are let disjoint. } \vspace{-0.5cm} \label{fig:bottom_up_clustering_based_merging} \end{figure*} \subsection{Bottom-Up Clustering-Based Merging} \label{sec:bucbam} \vspace{-0.2cm} We empirically observed (see Fig.~\ref{fig:results}) that clustering approaches with a fixed $K_i$ for each category (\textit{e.g.}, Kmeans) usually leads to a FiNet that gives better universality results than approaches that adapt $K_i$ to each category (\textit{e.g.}, Affinity-Propagation). Indeed, this latter tends to provide a set of finer classes with many clusters containing few images and a couple of clusters containing a large number of images, leading to an undesirable imbalanced dataset that penalizes the network training. Even if the use of fixed-$K_i$ clustering methods leads to more balanced data, it remains sub-optimal since it sets the \textit{same} amount of clusters for all specific categories ($\forall i \in [n_{\ell}], K_i = K$), while this may depend on the content of each category. Furthermore, in fixed-$K_i$ clustering methods, the $K$ value is an hyper-parameter that is cross-validated on the target-tasks, which are not accessible during the learning on the source-task, in the context of universality~\cite{tamaazousti2018universal}. Hence, the cross-validation of $K$ should be performed \textit{only} with the \textit{source}-task, which is not trivial (optimal $K$ on the source-task not necessary optimal one for the target-tasks). To overcome the drawbacks of fixed and adapted-$K_i$ clustering methods, we proposed an hybrid one called ``Bottom-Up Clustering-BAsed Merging'' (\textbf{BUCBAM}). It roughly starts with the clusters obtained by a fixed-$K_i$ clustering and \textit{automatically} sets the amount of clusters for \textit{each} specific category by enforcing a more balanced resulting set of finer-classes. Specifically, it consists in three main steps (illustrated on the left of Fig.~\ref{fig:bottom_up_clustering_based_merging}): (i) splitting the specific categories into $K$ clusters (with a large $K$); (ii) attaching small clusters to the closest bigger ones (to avoid imbalanced data); and (iii) merging the most similar ones, with respect to a proposed similarity criteria. Formally, BUCBAM starts with a \textit{large} amount of $K$ finer-classes per category $c_{j}$ with $j \in [n_{\ell}]^{\ell}$ and $K$ being the \textit{same} for all $c_j^{\ell}$. Let us assume we have $K(\in \mathbb{N}^*)$ finer-categories $\{c_i^{\ell +1}\}_{i\in [K_j]}$ obtained from the category $c_j^{\ell}$ of the previous level through a fixed-$Kçi$ clustering method. Let denote $\mathcal{X}_i^{\ell +1} = \{ \textbf{X}_i^{\ell,L}\}_{i\in [N_i^{\ell +1}]}$ the whole set of features extracted from the images of a given category $c_i^{\ell +1}$ through the SpeNet $\Phi^{\ell}_L$. Note that, $N_i^{\ell +1}$ corresponds to the amount of images in each $c_i^{\ell +1}$\footnote{For simplicity, we omit the power indices $\ell$, $\ell +1$ and $L$ in the following.}. The goal of BUCBAM is to get an amount of clusters $K_j$ depending on the images of \textit{each} category $c_j^{\ell}$. To do so, it first prunes out the \textit{small} clusters (\textit{i.e.}, all the $c_i$ such that $\forall i\in [K_j]$, $\card(c_i) < S\in \mathbb{N}^*$, with $S \ll N_i$), by re-assigning their samples $\textbf{I}_{k, k\in[N_i]}$ (that were assigned to $c_i$) to the category of the closest feature vector $\textbf{X}_{l, l \in [N_i]}^i = \mathcal{N}(\textbf{X}_{k, k\in [N_m]}^m)$, with $m \neq i$ and $\mathcal{N}(\cdot)$ being a function that provides the closest vector (\textit{e.g.}, k-NN algorithm with Euclidean distance) in the set of features $\{\mathcal{X}_j\}$ belonging to the \textit{other} and \textit{large} clusters (\textit{i.e.}, all $c_m$ with $\card(c_m) \geqslant S$). Pruning small clusters for all categories $c_j^{\ell}$, results in a set of $K_j^{\mathcal{P}}$ finer-classes $\{c_i\}_{i\in K_j^{\mathcal{P}}}$ per class $c_j^{\ell}$. The last step of BUCBAM is to merge the similar clusters. To do that, a classifier $\Psi_i$ is trained for each cluster $c_i$ -- using features of $c_i$ samples as positives and same amount of samples from a \textit{diverse} class $c_{d}$ as negatives -- and evaluated on the images of all other clusters. The diverse category $c_{d}$ is created by randomly picking elements equiprobably from all the categories $\{c_i^{\ell}\}_{i \in [n_{\ell}]}$. The evaluation of the classifiers provides a similarity matrix $\textbf{M}_j \in [0,1]^{K_i^{\mathcal{P}} \times K_i^{\mathcal{P}} }$ for each category $c_i^{\ell}$. This last is used to merge similar clusters and let dissimilar ones disjoint. More precisely, a first strategy is to consider clusters $c_i$ and $c_m$ \textit{symmetrically similar} (BUCBAM-SS) if: $\Psi_i(\textbf{X}_{k, k\in [N_m]}^m) > S_H$ and $\Psi_m(\textbf{X}_{k, k\in [N_i]}^i) > S_H$, with $m \neq i$ and $S_H \in [0,1]$ a \textit{high} score (close to 1). Another strategy is to consider, clusters \textit{asymmetrically similar} (BUCBAM-AS) if only one constraint is respected and the other is greater than $S_M$, with $S_M = S_H/2$ a \textit{medium} score. In both cases (that are illustrated in Fig.~\ref{fig:bottom_up_clustering_based_merging}), dissimilar clusters are desirably let disjoint. Merging similar clusters for all classes $c_j^{\ell}$, results in a set of $K_j^{\mathcal{M}}$ finer-classes $\{c_i\}_{i\in K_j^{\mathcal{M}}}$ per category $c_j$. \vspace{-0.2cm} \subsection{SpeFiNet: Combining Specific and Finer Features} \label{sec:spefinet} \vspace{-0.2cm} Following the approach of~\cite{tamaazousti2018universal} -- which roughly consists in training initial features on an initial set of categories, then learning new features on new set of categories and finally combining initial and new features --, we propose to learn the new features with our FiNet (rather than a network trained on \textit{generic} categories~\cite{tamaazousti2017mucale_net,tamaazousti2018universal}) and combine them with the features of the initial SpeNet to get a representation even more universal. This method is denoted \textbf{SpeFiNet} in the following. Formally, the final SpeFiNet representation combines specific and finer features and is computed for an image $I_i$ of a target-task as: $ \textbf{X}_{i} = \mathcal{F}\big( \{\mathcal{Z}( \textbf{X}^{\ell}_{i}), \mathcal{Z}( \textbf{X}^{\ell +1}_{i})\} \big)$, where $\mathcal{F}$ is a fusion operator, and $\mathcal{Z}$ is a normalization function. In practice for the normalization and fusion, we respectively choose the L-infinite norm ($L$-$\infty$) and the concatenation. To the best of our knowledge, we are the first to propose to combine a SpeNet (trained on \textit{specific} categories) and a FiNet (trained on \textit{finer} categories) to get more universal representations. \vspace{-0.2cm} \section{Experimental Results} \label{sec:settings} \vspace{-0.2cm} \textbf{Universality}\\ Universalizing methods are evaluated in a transfer-learning scheme on multiple target-tasks~\cite{cer2018universal,conneau2017supervised,tamaazousti2018universal}. More precisely, a source-task is used to train a network that acts as a representation extractor on the data of the target-tasks. Each target-task is trained with a simple predictor on top of the representations extracted from the samples of the target-task. Note that, fine-tuning the representations on the target-tasks could always improve performances but induces a bias avoiding correct evaluation of universality~\cite{conneau2018senteval,huh2016makes,subramanian2018learning,tamaazousti2018universal}. Hence, following the literature, simple predictors that do not modify the representations learned on the source-task are used. In particular, here for the target-tasks, we used a classification task with datasets from multiple visual domains (presented below) and for the predictor, we used a one-versus-all SVM classifier for each class. Even if~\cite{conneau2018senteval,rebuffi2017learning,tamaazousti2018universal} initiated a work around universality evaluation, it seems to remain an open problem. Hence here, since we only have benchmarks that are evaluated in terms of accuracy and precision, we evaluate universalizing methods in terms of average of their performances on the multiple benchmarks.\\ \noindent\textbf{Datasets}\\ For the source-task, we used ILSVRC~\cite{russakovsky2014imagenet} and ILSVRC* (half of the former, detailed in~\cite{tamaazousti2017mucale_net}). For the target-tasks, we used ten datasets from multiple domains, including general objects (VOC07~\cite{everingham2010pascal}, NWO~\cite{nus-wide-civr09}, CA101~\cite{fei2006one}, CA256~\cite{griffin2007caltech}), scenes (MIT67~\cite{quattoni2009recognizing}), actions (stACT~\cite{yao2011human}), birds (CUB~\cite{wahCUB_200_2011}), plants (FLO~\cite{nilsback2008automated}), food (FOOD~\cite{bossard14}) and airplanes (AIRC~\cite{maji13fine-grained}). The characteristics of all the datasets are detailed in supplementary material.\\ \noindent\textbf{Implementation Details}\\ Our method consists in the combination of a SpeNet and FiNet. For both networks, we used two architectures, namely the classical AlexNet~\cite{krizhevsky2012imagenet} and the deeper DarkNet~\cite{redmon2017yolo9000}. They are respectively trained on the images of ILSVRC* and ILSVRC. SpeNet is thus respectively trained to recognize $C=483$ and $C=1,000$ \textit{specific} categories. In contrast, FiNet is trained to recognize a set of $K_i\times C$ \textit{finer}-classes ($K_i$ depends on the splitting method), for which we used four variants: (i) random splitting with $K_i\in\{2,4,8,16\}$ fixed, denoted \textbf{Random-K} (ii) K-means clustering with $K_i\in\{2,4,8,16\}$ fixed, denoted \textbf{Cluster-K} (iii) BUCBAM splitting with \textit{asymmetrically similar} clusters merging, denoted \textbf{BUCBAM-AS} and (iv) BUCBAM splitting with \textit{symmetrically similar} clusters merging, denoted \textbf{BUCBAM-SS}. Note that, the BUCBAM methods leads to a $K_i$ depending on the content of each category. In Sec.~\ref{sec:analysis}, we provides some statistics of the resulting dataset of each method, including the total amount of finer-classes. In Cluster-K and BUCBAM methods, we extract features from the penultimate layer to represent the samples of each class, which results in features of 4096 dimensions for AlexNet and 1000 for DarkNet. Specific to BUCBAM, the $K$, $S$ and $S_H$ parameters are respectively set to 32, 15 and 0.8. Indeed, $K$ has to be large, and we found that as long as $K$ is larger than 20 our method provides the same splitting result. $S=15$ ensures to train a network with at least 15 images per class. We obtained similar results with $S=50$. The parameters $S_H$ is not critical since similar clusters generally provides very high (close to 1.0) classification scores. \vspace{-0.2cm} \begin{table*}[tb!] \centering \bgroup \def1.2{1.2} \resizebox{\textwidth}{!}{ \begin{tabular}{|l c c c c c c c c || c |} \hline \multirow{2}{*}{\textbf{Method}} & \textbf{VOC07} & \textbf{CA101} & \textbf{CA256} & \textbf{NWO} & \textbf{MIT67} & \textbf{stACT} & \textbf{CUB} & \textbf{FLO} & \multirow{2}{*}{\textbf{Avg}} \\ & mAP & Acc. & Acc. & mAP & Acc. & Acc. & Acc. & Acc. & \\ \hline \hline \textbf{SpeNet (REFERENCE)} & 66.8 & 71.1 & 53.2 & 52.5 & 36.0 & 44.3 & 36.1 & 50.5 & 51.3 \\ \textbf{SPV$_{\mathbf{A}}^{\mathbf{spe}}$}~\cite{azizpour2015generic} & 66.6 & 74.7 & 54.7 & 53.2 & 37.4 & 45.1 & 36.0 & 51.9 & 52.4 \\ \textbf{SPV$_{\mathbf{G}}^{\mathbf{gen}}$}~\cite{mettesicmr16,tamaazousti2017vision} & 67.7 & 73.0 & 54.3 & 50.5 & 37.1 & 44.9 & 36.8 & 50.3 & 51.8 \\ \textbf{AMECON}~\cite{chami2017amecon} & 61.1 & 58.7 & 40.6 & 45.8 & 24.3 & 32.7 & 26.1 & 36.4 & 44.5 \\ \textbf{WhatMakes}~\cite{huh2016makes} & 64.0 & 69.4 & 50.1 & 45.6 & 33.7 & 41.9 & 15.0 & 42.8 & 45.3 \\ \textbf{ISM}~\cite{wu2016ism} & 62.5 & 68.8 & 50.7 & 28.5 & 37.9 & 42.6 & 34.0 & 50.0 & 46.9 \\ \textbf{GrowingBrain-RWA}~\cite{wang2017growing} & 69.1 & 74.8 & 55.9 & 50.4 & 40.0 & 48.4 & 38.6 & 56.1 & 54.2 \\ \textbf{FSFT}~\cite{tamaazousti2018universal} & 67.5 & 73.9 & 55.0 & 44.6 & 40.4 & 47.1 & 38.7 & 56.8 & 53.0 \\ \textbf{MuCaLe-Net}~\cite{tamaazousti2017mucale_net} & \underline{69.5} & 76.0 & 56.8 & \textbf{54.7} & 41.3 & 48.5 & 35.6 & 54.8 & 54.6 \\ \textbf{MulDiP-Net}~\cite{tamaazousti2018universal} & \textbf{69.8} & 77.5 & \underline{58.3} & 47.9 & \textbf{43.7} & 50.2 & 37.4 & 59.7 & 55.6 \\ \hline \textbf{FiNet, Random$\dagger$} & 66.4 & 72.4 & 53.2& 51.0 & 39.7 & 46.9 & 35.7 & 55.9 & 52.6 \\ \textbf{FiNet, Cluster$\dagger$} & 66.0 & 73.2 & 54.6 & 50.9 & 40.7 & 47.2 & 36.4 & 55.6 & 53.1 \\ \textbf{FiNet, BUCBAM} & 65.3 & 75.4 & 56.0 & 48.6 & 41.6 & 49.4 & 37.8 & 59.8 & 54.2 \\ \textbf{SpeFiNet, Random$\dagger$} & \textbf{69.8} & 75.7 & 57.5 & \underline{54.6} & 41.2 & 50.0 & 39.8 & 58.3 & 55.9 \\ \textbf{SpeFiNet, Cluster$\dagger$} & 68.6 & \underline{77.9} & 58.1 & 53.9 & 41.3 & \underline{50.5} & \underline{40.8} & \underline{60.1} & \underline{56.4} \\ \textbf{SpeFiNet, BUCBAM} & 69.1 & \textbf{78.3} & \textbf{59.3} & 54.0 & \underline{42.7} & \textbf{52.0} & \textbf{41.8} & \textbf{61.7} & \textbf{57.4} \\ \hline \end{tabular} } \vspace{-0.3cm} \caption{ Comparison of our methods (bottom) to the state-of-the-art (top). All the methods are trained on the data of ILSVRC* with an AlexNet network and compared in terms of average (Avg) performance on the set of eight target-tasks used in~\cite{tamaazousti2018universal}. For each benchmark, we highlight the best score in bold and the second is underlined. Methods marked with $\dagger$ are obtained with a parameter cross-validated (on the target-tasks), while our BUCBAM method automatically set this parameter on the source-task. Note that MuCaLe-Net, MulDiP-Net and SpeFiNets use representations which dimension is twice other method's. } \vspace{-0.3cm} \label{tab:results_sota} \egroup \end{table*} \begin{table*}[tb!] \centering \bgroup \def1.2{1.2} \resizebox{\textwidth}{!}{ \begin{tabular}{|l c c c c c c c c c c || c |} \hline \multirow{2}{*}{\textbf{Method}} & \textbf{VOC07} & \textbf{CA101} & \textbf{CA256} & \textbf{NWO} & \textbf{MIT67} & \textbf{stACT} & \textbf{CUB} & \textbf{FLO} & \textbf{AIRC} & \textbf{FOOD} & \multirow{2}{*}{\textbf{Avg.}} \\ & mAP & Acc. & Acc. & mAP & Acc. & Acc. & Acc. & Acc. & Acc. & Acc. & \\ \hline \hline \textbf{SpeNet (REF.)} & 82.7& 91.0 & 78.4 & 70.5 & 64.8 & 72.2 & 59.5 & 80.0 & 49.2 & 47.6 & 69.6 \\ \textbf{GenNet}~\cite{tamaazousti2017mucale_net} & 83.2 & 91.5 & 78.1 & \underline{73.2} & 64.4 & 72.6 & 52.5 & 78.9 & 48.5 & 46.2 & 68.9 \\ \textbf{MulDiP-Net}~\cite{tamaazousti2018universal} & \textbf{84.1} & \textbf{92.7} & \textbf{80.1} & \textbf{73.9} & 66.4 & \underline{74.5} & 61.2 & 82.1 & 53.5 & 49.3 & \underline{71.8} \\ \hline \textbf{FiNet, Cluster$\dagger$} & 82.5 & 91.8 & 78.8 & 70.0 & 65.8 & 73.2 & 60.9 & 81.9 & 51.9 & 47.8 & 70.5 \\ \textbf{FiNet, Cluster$ (K=16)$} & 81.4 & 91.5 & 77.4 & 69.5 & 64.6 & 72.2 & 58.6 & 81.5 & 52.3 & 47.5 & 69.6 \\ \textbf{FiNet, BUCBAM} & 81.3 & 91.0 & 77.0 & 69.7 & 64.3 & 72.2 & 59.1 & 81.6 & 52.9 & 48.9 & 69.8 \\ \textbf{SpeFiNet, Cluster$\dagger$} & \underline{83.7} & \underline{92.5} & \underline{79.8} & 71.9 & \textbf{66.7} & \textbf{74.8} & \textbf{63.6} & \underline{83.1} & 54.5 & 49.5 & \textbf{72.0} \\ \textbf{SpeFiNet, Cluster$ (K=16)$} & 83.3 & 92.2 & 79.6 & 71.9 & \underline{66.6} & 74.1 & 62.5 & 83.0 & \underline{55.1} & \underline{49.8} & \underline{71.8} \\ \textbf{SpeFiNet, BUCBAM} & 83.2 & 92.2 & 79.6 & 71.7 & \underline{66.6} & \underline{74.5} & \underline{62.7} & \textbf{83.4} & \textbf{56.1} & \textbf{50.0} & \textbf{72.0} \\ \hline \end{tabular} } \vspace{-0.3cm} \caption{ Comparison of our methods (bottom) to the state-of-the-art (top). All the methods are trained on the data of \textit{full} ILSVRC with a DarkNet network and compared in terms of average performance (Avg) on the set of \textit{ten} target-tasks presented in Sec~\ref{sec:settings}. For each benchmark, we highlight the best score in bold and the second is underlined. Methods marked with $\dagger$ are obtained with a parameter cross-validated on the target-tasks. BUCBAM automatically set this parameter on the source-task. } \vspace{-0.5cm} \label{tab:results_sota_deep_large} \egroup \end{table*} \subsection{Comparison to the State-of-the-Art} \label{sec:comparison_sota} \vspace{-0.1cm} We compare the results obtained by our method with those of the literature, in particular, all the methods re-implemented and reported in~\cite{tamaazousti2018universal}. For fair comparisons, we followed their training configuration, and trained our method with an AlexNet network and ILSVRC* as source-task. Moreover, instead of using our more diverse set of ten target-datasets, we used the eight ones used in their paper. The results are reported on Table~\ref{tab:results_sota}. We first observe that our methods are always better than the reference method used in~\cite{tamaazousti2017mucale_net,tamaazousti2018universal,bilen2017universal,rebuffi2017learning,rebuffi2018efficient}, namely SpeNet. In particular our best method (BUCBAM) exhibits a boost of 6 points on average, compared to SpeNet. Let also note that SpeFiNet is always better than FiNet, itself better than SpeNet, regardless the splitting method. More precisely, the BUCBAM splitting method is significantly better than the best Cluster one, without the high cost of cross-validation of the $K$ parameter. Compared to state-of-the-art methods, ours achieves the best performances, that is, almost 2 points of improvement compared to the most competitive MulDiP-Net method~\cite{tamaazousti2018universal}, while it surpasses all other methods by more than 3 points. A last salient result is the fact that a SpeFiNet (whatever the splitting method) is significantly better than MuCaLe-Net~\cite{tamaazousti2017mucale_net} which has been trained on the best generic categories (manually obtained from categorical-levels~\cite{tamaazousti2016diverse,tamaazousti2017mucale_net}). This latter clearly demonstrates than combining features trained on specific categories with those trained on \textit{finer} categories is better than combining them with those trained on \textit{generic} categories. Furthermore, since~\cite{tamaazousti2018universal} reported better results with a deeper network (DarkNet) trained on the full ILSVRC, we also implemented our method in the same configuration. Since MulDiP-Net provides the best results of the literature on the problem of universality, we only compare to them for this setting. The results are reported on Table~\ref{tab:results_sota_deep_large}. While the improvement is only slightly better, our method still beats the competitive MulDiP-Net. Moreover, a salient observation is that our method tend to be much better than theirs on the fine-grained classification benchmarks, which are more challenging. As in the previous setting, SpeFiNet is better than FiNet which is itself better than SpeNet. We also compared to the GenNet (which is the generic sub-component of MulDiP-Net~\cite{tamaazousti2018universal}) and we observe that FiNet-BUCBAM is better by 0.9 points. \begin{figure*}[tb!] \begin{center} \includegraphics[width=13.0cm]{images/results.png} \end{center} \vspace{-0.6cm} \caption{ Comparison of our methods to multiple splitting baselines. On the left, we illustrate the average results of each method on the ten target-tasks, were for each splitting method, we illustrate the FiNet in dark color and SpeFiNet in light color. On the right, we plot a diagram for the SpeFiNet-BUCBAM, FiNet-BUCBAM and SpeNet methods, their performances on each target-task. Best view in color } \label{fig:results} \end{figure*} \subsection{Analysis and Comparison to Baselines} \label{sec:analysis} In this section, we perform an in-depth analysis of our method through an ablation study, a comparison to baselines and visualization of some statistics. In particular, in supplementary we compared our method to multiple clustering baselines, namely Spectral Clustering and Affinity propagation. The former provides a fixed set of clusters per category, while the latter leads to a dynamic set of clusters. A summary of results is presented on the left of Fig.~\ref{fig:results}, where we plot, a bar for each method, that represents its average performance on the set of 10 benchmarks described in Sec~\ref{sec:settings}. We also tested the Mean-Shift algorithm with many different bandwidth values, but it always led to many clusters with one or two images, and one cluster containing all the remaining images. This setting providing very low results, we did not report them. From these results, we observe that our BUCBAM method is better than all the baselines including other existing algorithms. Rather than the average performances, in the diagram on the right of Fig.~\ref{fig:results}, we illustrated the \textit{detailed} results (on the ten benchmarks) of the SpeFiNet-BUCBAM, FiNet-BUCBAM and SpeNet methods. We clearly observe that the diagram of our SpeFiNet-BUCBAM overlaps FiNet-BUCBAM, which itself overlaps the reference SpeNet method. In addition, we provide in supplementary material the detailed results of all the methods on all the target-tasks. In Figure~\ref{fig:clusters_vizualisation}, we visualize some of the clusters obtained by each splitting method (random, clustering and BUCBAM). To do so, we highlight three clusters for two specific categories (two blocks of three rows of five images). On the left, the clusters are determined from a random distribution within the full specific category, leading to clusters that contain its full diversity. On the contrary, with the K-means clustering (middle), the clusters exhibits a more coherent aspect. For example, for the \textit{goldfish} category, the $c_3^1$ cluster report close-up views of fish that are rather seen on their profile. We have a similar behaviour for the \textit{banjo} category with cluster $c_1^3$ and $c_2^3$. With the proposed BUCBAM method (right), the clusters are even more specific than in the K-means case. For instance, for the \textit{goldfish} category, we clearly identify a cluster that represents ``many golfishes'' ($c_1^1$), ``on goldfish in a close-up view'' ($c_2^1$) and some images on which the fish tank is visible ($c_3^1$). Also for the \textit{banjo} class, we also clearly observe that our method identified a cluster that represents ``person playing banjo'' $c_1^3$ and even ``person playing banjo in a concert'' $c_3^3$. Importantly, while the clustering method tend to results in duplicate clusters (\textit{e.g.}, $c^1_2$ with $c^1_3$; $c_1^3$ with $c_2^3$; etc.), ours tend to provide only dissimilar results, thank to our merging process. In supplementary material, we also provided some statistics of our method and baselines (\textit{i.e.}, histograms of average amount of clusters per category, histograms of intra-class variance of the clusters) and more visualizations of the obtained clusters, through the visualization of some images in some clusters and the features of each image of the clusters in a 2D dimensional space, after performing a PCA on their full features. This highlights the clear interest of our method, in terms of cluster relevancy and the balance of resulting data, compared to the random and clustering baselines. \begin{figure}[tb!] \includegraphics[width=13.0cm]{images/clusters_vizualisation_small.png} \vspace{-0.6cm} \caption{ Illustration of some finer categories obtained from two specific categories (two row blocks) with the different methods: random split (left), Kmeans clustering with K=16 (middle) and our BUCBAM proposal (right). In every block, a line (from the three) shows the five most representative images of a cluster at the new finest-level. Best view in PDF. } \label{fig:clusters_vizualisation} \end{figure} \section{Conclusions} \vspace{-0.1cm} In this paper, we tackled the problem of universality of representations with a new method relying on categories that are finer than the most specific ones of the ImageNet hierarchy. These last being the finest that are annotated, we proposed a method that automatically add a hierarchical-level to the ImageNet hierarchy. A network trained on the categories of such finer-level provides a more universal representation than with the upper levels. In practice, it leads to significantly better results in a transfer-learning scheme, on 10 publicly available datasets from diverse domains. We also showed that a K-means and, surprisingly, a random partitioning of the leaf nodes of ImageNet already gives interesting results, although below than the proposed approach. It nevertheless suggests that the general principle highlighted in this article could be fruitful to design new CNN-based representations that are more universal in a transfer-learning context. Furthermore, it should be noted that our principle is neither limited to the ImageNet hierarchy nor to the classification task. Indeed, it could be applied to any hierarchy or dataset and on other tasks, such as detection, segmentation or keypoint estimation, as considered in~\cite{wang2018more}.
{'timestamp': '2018-10-05T02:09:42', 'yymm': '1810', 'arxiv_id': '1810.02126', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02126'}
arxiv
\section{Introduction} A prototypical example of categorial grammar is Lambek grammars \cite{Lambek}. These are based on logical {\it Lambek calculus}, which is, speaking in modern terms, a noncommutative variant of (intuitionistic) linear logic \cite{Girard}. It is well known that Lambek grammars generate exactly the same class of languages as context-free grammars \cite{Pentus}. However, it is agreed that context-free grammar are, in general, not sufficient for modeling natural language. Therefore linguists consider various more expressive formalisms. Lambek calculus is extended to different complicated {\it multimodal}, {\it mixed commutative} and {\it mixed nonassociative} systems, see \cite{Moortgat}. Many grammars operate with more complex constituents than just words. For example {\it displacement grammars} \cite{Morrill_Displacement}, extending Lambek grammars, operate on discontinuous tuples of words. Especially interesting (in the author's point of view) are {\it abstract categorial grammars (ACG)} \cite{deGroote}. Unlike Lambek grammars, these are based on a more intuitive and familiar {\it commutative} logic, namely, the implicational fragment of linear logic. Yet their expressive power is much stronger \cite{YoshinakaKanazawa}. This, however, comes with a certain drawback. The constituents are, basically, just linear $\lambda$-terms. It is not so easy to identify them with any elements of language. We should add also that there exist {\it hybrid type logical grammars} \cite{KubotaLevine}, which extend ACG, mixing them with Lambek grammars. Finally, we note, that, although the list of existing grammars seems sufficiently long, there exists a very interesting unifying approach of \cite{Moot_comparing}. It turns out that many grammatical formalisms can be faithfully represented as fragments of first order multiplicative intuitionistic linear logic {\bf MILL1}. This provides some common ground on which different systems can be compared. From the author's point of view it is quite remarkable that a unifying logic is, again, commutative. In this work we propose one more categorial grammar based on a commutative system, namely on classical linear logic. {\it Linear logic grammars (LLG)} of this paper can be seen as an extension of ACG to full multiplicative fragment. Although, as we just noted, the list of different formalisms is already sufficiently long, we think that our work deserves some interest at least for two reasons. First, unlike the case of ACG, constituents of LLG are very simple. They are tuples of words with labeled endpoints, we call them {\it multiwords}. Multiwords are directly identified as basic elements of language, and apparently they are somewhat easier to deal with than abstract $\lambda$-terms. ACG embed into LLG, so at least we give a concrete and intuitive {\it representation} of ACG. (We don't know if LLG have stronger expressive power as ACG, or just the same.) Second, we identify on the class of multiwords a fundamental algebraic structure. This structure is a {\it category} (in the mathematical, rather than linguistic sense of the word), which is {\it symmetric monoidal closed} and {\it compact closed}. It is this categorical structure that allows us representing linear $\lambda$-calculus and ACG, as well as classical linear logic. And, apparently, at least some other formalisms can be represented in this setting as well. Possibly, this can give some common reference for different systems. We now discuss it in a greater detail. \subsection{Algebraic considerations} The algebraic structure underlying linguistic interpretations of Lambek calculus is that of a monoid. Indeed, the set of words over a given alphabet is a free monoid under concatenation, and Lambek calculus can be interpreted as a logic of the poset of this monoid subsets (i.e. of formal languages). Typically, the sequent $$X_1,\ldots,X_n\vdash X$$ is interpreted as subset inclusion: the concatenation of languages $X_1,\ldots,X_n$ is a sublanguage of $X$. When constituents of a grammar are more complicated, such as word tuples, there is no unique concatenation, since tuples can be glued together in many ways. Thus the algebra is more complex. We consider tuples of words with labeled endpoints, we call them {\it multiwords}. Multiwords can be conveniently represented as very simple directed graphs with labeled edges and vertices. They are glued together along matching labels on vertices. For example, we have a multiword with two components $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](3,0) -- (5,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (3,0) circle [radius=0.05]; \node[above]at (1,0){John}; \node[above]at (4,0){Mary}; \node[below left] at (0,0){$\alpha$}; \node[below ]at (2,0){$\beta$}; \node[below left]at (3,0){$\gamma$}; \node[below ]at (5,0){$\delta$}; } $$ and another multiword with one component. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw [fill] (0,0) circle [radius=0.05]; \node[above]at (1,0){likes}; \node[below left] at (0,0){$\beta$}; \node[below ]at (2,0){$\gamma$}; } $$ These glue together and yield the following. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (4,0); \draw [fill] (0,0) circle [radius=0.05]; \node[above]at (2,0){John likes Mary}; \node[below left] at (0,0){$\alpha$}; \node[below ]at (4,0){$\delta$}; } $$ The same multiword can be obtained by gluing a three-component multiword $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](3,0) -- (5,0); \draw[thick,->](6,0) -- (8,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (3,0) circle [radius=0.05]; \draw [fill] (6,0) circle [radius=0.05]; \node[above]at (1,0){John}; \node[above]at (4,0){likes}; \node[above]at (7,0){Mary}; \node[below left] at (0,0){$\alpha$}; \node[below ]at (2,0){$\beta$}; \node[below left]at (3,0){$\gamma$}; \node[below ]at (5,0){$\mu$}; \node[below left]at (6,0){$\nu$}; \node[below ]at (8,0){$\delta$}; } $$ with another multiword $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](3,0) -- (5,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (3,0) circle [radius=0.05]; \node[below left] at (0,0){$\beta$}; \node[below ]at (2,0){$\gamma$}; \node[below left]at (3,0){$\mu$}; \node[below ]at (5,0){$\nu$}; } $$ whose all components are empty. Unfortunately, nothing precludes us from gluing words cyclically, and thus obtaining cyclic sequences of letters with no endpoints. Consider gluing a word $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw [fill] (0,0) circle [radius=0.05]; \node[above]at (1,0){x}; \node[below left] at (0,0){$\alpha$}; \node[below ]at (2,0){$\beta$}; } $$ with a ``wrongly oriented'' one. $$ \tikz[xscale=.7]{ \draw[thick,->](0,-0.5) -- (2,-0.5); \draw [fill] (0,-.5) circle [radius=0.05]; \node[above]at (1,-.5){y}; \node[below left] at (0,-0.5){$\beta$}; \node[below ]at (2,-0.5){$\alpha$}; } $$ For consistency we have to allow also such {\it cyclic} or {\it singular} multiwords, which can be represented as closed loops. Multiwords can be organized in a {\it monoidal category}, very similar to the category of {\it topological cobordisms} (see \cite{Baez}). Its objects, {\it boundaries}, are sets of vertex labels, and morphisms, {\it word cobordisms}, are (equivalence classes of) multiwords, composed by gluing. Monoidal structure, ``tensor product'' is just disjoint union. Thus, we shift from a non-commutative monoid of words to a symmetric monoidal category of word cobordisms. (We find it amusing to abbreviate the latter term as {\it cowordism}.) \subsection{Adding logic} The category of cowordisms (over a given alphabet) is not only symmetric monoidal, but also {\it compact closed}, just as the category of cobordisms. This makes it a model of classical multiplicative linear logic \cite{Seely}. When interpreting logic in such a setting, logical consequence does no longer correspond to subset inclusion. A sequent $$X_1\ldots,X_n\vdash X$$ given {\it together with its derivation}, is now a particular cowordism of type $$X_1\otimes\ldots\otimes X_n\to X,$$ which can be explicitly computed from the derivation. Adding a {\it lexicon}, which is a finite set of non-logical axioms, i.e. cowordisms together with their typing specifications, we obtain a {\it linear logic grammar} (LLG). Syntactic derivations from the lexicon directly translate to cowordisms, (which are just tuples of words). This gives us a {\it linear logic grammar}; its language consists of all words that can be written as compositions of cowordisms in the lexicon and ``natural'' cowordisms coming from linear logic proofs. Speaking more generally, with an LLG we get a subcategory of {\it cowordism types} generated by the grammar. This is, in general, no longer compact. It is, however, a categorical model of linear logic and linear $\lambda$-calculus. Comparing with Lambek calculus, we shift from a {\it poset} of formal languages to a {\it category} of cowordism types. \subsection{Some wishful thinking on categorical semantics} LLG are at least as expressive as abstract categorial grammars (on the string signature). Indeed, ACG are based on a conservative fragment of classical linear logic, so they have direct translation to our setting. Thus, cowordisms and LLG provide a {\it concrete categorical model} of abstract categorial grammar. In fact, cowordisms are essentially proof-nets, and passage from ACG to LLG is basically, a passage, from $\lambda$-terms to proof-nets. Now, forgetting about LLG, it seems reasonable that any formalism admitting some version of proof-nets has a representation in the category of cowordisms. (It does not necessarily mean that such a representation is useful.) Possibly, this might provide some common, syntax-independent ground, i.e. a model, for different systems. This might be compared with representation of different systems in {\bf MILL1} in \cite{Moot_comparing}. One of the main features making categorial grammars interesting is that they allow a bridge between language syntax and language semantics (see \cite{MootRetore}). Semantics is often modeled by means of a commutative logic, most notably, linear logic as in \cite{Dalrymple}. But the category of cowordisms itself is a symmetric monoidal category of language elements, which is independent of any grammar. It might prove helpful for understanding this bridge. An interesting approach is that of {\it categorical compositional distributional models of meaning (DisCoCat)}) \cite{CoeckeSadrzadehClark}, \cite{Coecke_Lmabek_vs_Lambek}. In DisCoCat it is proposed to model and analyze language semantics by a functorial mapping (``quantization'') of syntactic derivations in a categorial grammar to the (symmetric) compact closed category {\bf FDVec} of finite-dimensional vector spaces. The approach has been developed so far mainly on the base of Lambek grammars or pregroup grammars (see \cite{Lambek_pregroups}), which are, from the category-theoretical point of view, {\it non-symmetric monoidal closed}. On the other hand, the cowordism category is symmetric and compact closed, and in this sense it is a better mirror of {\bf FDVec}. Thus it seems a more natural candidate for quantization. Possibly, cowordism representation may help to apply ideas of DisCoCat to LLG or ACG, thus going beyond context-free languages. \subsection{Structure of the paper} The paper is reasonably self-contained. We assume, however, that the reader has some basic acquaintance with categories, in particular, with monoidal categories, see \cite{MacLane} for background. In the first section we define the category of word cobordisms (cowordisms). In the second section we discuss monoidal closed categories in general, and monoidal closed structures of cowordism categories in particular. Section 3 introduces linear logic, its categorical semantics and, finally, linear logic grammars. In Section 4, as an example, we show that multiple context-free grammars encode in LLG, and that every LLG with a {\it $\otimes$-free lexicon} generates a multiple context-free language. This result is similar to the known result that all second order ACG generate multiple context-free languages \cite{Salvati}. The fifth section is the encoding of ACG to LLG. Finally, in the last section we show how LLG generates an NP-complete language. The purpose of this last piece is mainly illustrative. We try to convince the reader that the geometric language of cowordisms is indeed intuitive and convenient for analysing language generation. \section{Word cobordisms} \subsection{Multiwords} Let $T$ be a finite alphabet. We denote the set of all finite words in $T$ as $T^*$. For consistency of definitions we will also have to consider cyclic words. We say that two words in $T^*$ are {\it cyclically equivalent} if they differ by a cyclic permutation of letters. A {\it cyclic word} over $T$ is an equivalence class of cyclically equivalent words in $T^*$. For $w\in T^*$ we denote the corresponding cyclic word as $[w]$. Observe that there exists a perfectly well-defined {\it empty cyclic word}. \bd A {\bf regular multiword} $M$ over an alphabet $T$ is a finite directed graph with edges labelled by words in $T^*$, such that each vertex is adjacent to exactly one edge (so that it is a perfect matching). \ed The {\it left}, respectively, {\it right boundary} of a multiword $M$ is the set of vertices of the underlying graph that are heads, respectively, tails of some edges. We denote the left boundary of $M$ as $\d_lM$ and the right boundary, as $\d_rM$. The {\it boundary} $\d M$ of $M$ is the set $\partial M=\d_lM\cup\d_rM$. \bd A {\bf multiword} $M$ over the alphabet $T$ is a pair $M=(M_0,M_c)$, where $M_0$, the {\bf regular} part, is a regular multiword over $T$, and $M_c$, the {\bf singular} or {\bf cyclic} part, is a finite multiset of cyclic words over $T$. \ed The boundaries $\d M$, $\d_l M$, $\d_r M$ of a multiword $M$ are defined as corresponding boundaries of its regular part $M_0$. The multiword is {\it acyclic} or {\it regular} if its singular part is empty. Otherwise it is {\it singular}. A multiword $M$ can be pictured geometrically as the edge-labelled graph $M_0$ and a bunch of isolated loops labelled by elements of $M_c$. The underlying geometric object is no longer a graph, but it is a topological space. It is even a manifold with boundary. In fact, we can equivalently define a multiword as a 1-dimensional compact oriented manifold with boundary (up to a boundary fixing homeomorphism), whose connected components are labelled by cyclic words, if they are closed, and by ordinary words otherwise. \subsubsection{Gluing} It should be clear from a geometric representation how to glue multiwords. We now give a boring accurate definition. First, we define the {\it disjoint union} of multiwords in the most obvious way. If $M=(M_0,M_c)$, $M'=(M_0',M_c')$ are multiwords then we define the disjoint union $M\sqcup M'$ as the multiword $$M\sqcup M'=(M_0\sqcup M_0',M_c\sqcup M_c').$$ Next we define {\it contraction}, which corresponds to elementary gluing. Let $M$ be a multiword and $x\in\partial_lM$, $y\in \partial_rM$. The {\it contraction} $M/\{x=y\}$ of $x$ and $y$ in $M$ is obtained by identifying $x$ with $y$ in the underlying graph and gluing the corresponding edges into one. The words labeling the edges are also glued, i.e. concatenated. This means the following. If vertices $x$, $y$ are not connected by an edge in $M_0$, then let $t$ be the tail of the unique edge adjacent to $x$ and $z$ be the head of the unique edge adjacent to $y$. Let $u$ be the word labeling $(x,t)$ and $v$ be the word labeling $(z,y)$. We construct a new edge-labelled graph $M_0'$ by removing $x$ and $y$ together with their adjacent edges from $M_0$ and drawing an edge from $(z,t)$. The new edge is labelled by the concatenation $vu$. We put $M/\{x=y\}=(M_0',M_c)$. If $x$ and $y$ are connected by an edge, let $w$ be its label. We remove $x$, $y$ and $(x,y)$ from $M_0$, which gives us the new edge-labelled graph $M_0'$, and we add to $M_c$ the cyclic word $[w]$, which gives us the new multiset $M_c'$. We put $M/\{x=y\}=(M_0',M_c')$. \smallskip Note that iterated contractions commute. \nb\label{associativity of contraction} Let $M$ be a multiword, and $x_1,x_2\in \d_lM$, $y_1,y_2\in \d_rM$. Then $$((M/\{x_1=y_1\})/\{x_2=y_2\}=((M/\{x_2=y_2\})/\{x_1=y_1\}.\quad \Box $$ \nbe \smallskip In view of the above we can define {\it multiple contractions}. \bd Let $M$ be a multiword. Let $$X\subseteq \d_lM,\quad Y\subseteq \d_rM,$$ and let $\phi:X\to Y$ be a bijection. The {\bf contraction} $M/\{X\stackrel{}{\cong} Y\}$ of $X$ and $Y$ along $\phi$ in $M$ is defined by $$M/\{X\stackrel{}{\cong}Y\}=(\ldots(M/\{x_1=\phi(x_1)\})\ldots)/\{x_n=\phi(x_n)\},$$ where $\{x_1,\ldots,x_n\}$ is any enumeration of elements of $X$. \ed (We omit the bijection $\phi$ from notation, because it will be clear from the context.) Now let two multiwords $M$, $M'$ be given. Assume that we have subsets $$X_l\subseteq\d_l M,\quad X_r\subseteq\d_r M,$$ $$X_l'\subseteq\d_l M',\quad X_r'\subseteq\d_r M',$$ and two bijections $$\phi:X_l\to X_r',\quad\phi':X_l'\to X_r.$$ Let $X, X'$ be the disjoint unions $X=X_l\sqcup X_r$, $X'=X_l'\sqcup X_r'$. The {\it gluing} $M\sqcup_{X\cong X'}M'$ of $M$ and $M'$ along $X$ and $X'$ is defined as the multiple contraction $$M\sqcup_{X,X'}M'=((M\sqcup M')/\{X_l\cong X_r'\})/\{X_l'\cong X_r\}.$$ \subsection{Category of word cobordisms} \subsubsection{Cowordisms} We remarked above that multiwords can be represented geometrically as very simple manifolds with boundary. Manifolds with boundary give rise to the category of {\it cobordisms}, see \cite{Baez}. We are now going to define a similar category of {\it word cobordisms}. We find it amusing to abbreviate the latter term as {\it cowordism}, and we will do so. \bd A {\bf boundary} is a finite set $X$ equipped with a partition $X=X_l\cup X_r$ into two disjoint subsets. \ed Now, we want to look at a multiword $M$ as a morphism between boundaries. For that, we need to understand which part of $\d M$ is the input, and which is the output. This leads to the following definition. \bd Let $X$, $Y$ be boundaries. A {\bf cowordism} $$\sigma:X\to Y$$ over an alphabet $T$ from $X$ to $Y$ is a triple $$\sigma=(M,\phi_l,\phi_r),$$ where $M$ is a multiword over $T$ together with two bijective {\bf labeling functions} $$\phi_l:Y_l\sqcup X_r\to\d_lM,\quad\phi_r:Y_r\sqcup X_l \to\d_rM.$$ \ed A cowordism is {\it regular} if its underlying multiword is regular. Otherwise the cowordism is {\it singular}. For our purposed it is necessary to identify cowordisms that differ by inessential relabeling of boundaries. Therefor we supply our definition of a cowordism with a definition of {\it cowordism equality}. \bd Two cowordisms $\sigma=(M,\phi_l,\phi_r)$ and $\sigma'=(M',\phi_l',\phi_r')$ are {\bf equal}, if their singular part coincide, $$M_c=M_c',$$ and there is a pair of bijections $$\psi_l:\d_lM\to\d_lM',\mbox{ }\psi_r:\d_rM\to\d_rM'$$ inducing an edge-labeled graph isomorphism of the regular parts, such that $$\phi_l'=\psi_l\circ\phi_l,\mbox{ }\phi_r'=\psi_r\circ\phi_r.$$ \ed In the sequel we will systematically abuse notation and denote a cowordism and its underlying multiword with the same letter. Note, however, that, generally speaking, a cowordism and a multiword are two different structures. In particular, we can have two different non-equal multiwords representing the same cowordism (see the definition of cowordism equality above). We are going to organise cowordisms into a compact closed category (to be discussed below). Since cowordisms, by definition, have geometric representation, it is natural to adapt the {\it pictorial language} (see \cite{Selinger}) used for such categories. We can depict an abstract cowordism $\sigma:X\to Y$ schematically as a box with incoming and outgoing wires, like the following. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1.5);\node at(1,.75){$\sigma$}; \draw[thick,-](2,.5)--(3,.5); \node[above] at(3,1.2) {$Y_r$}; \draw[thick,->](2,1.2)--(3,1.2); \node[below] at(3,.5) {$Y_l$}; \node[below ] at(-1,.5) {$X_l$}; \node[above ] at(-1,1.2) {$X_r$}; \draw [fill] (-1,1.2) circle [radius=0.05]; \draw [fill] (3,.5) circle [radius=0.05]; \draw[thick](-1,1.2)--(0,1.2); \draw[thick,<-](-1,.5)--(0,.5); }.$$ Or, using fewer labels on the wires, like the following. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1);\node at(1,.5){$\sigma$}; \draw[thick,-](2,.25)--(3,.25); \draw[thick,->](2,.75)--(3,.75); \node [right] at(3,.5) {$Y$}; \node[left ] at(-1,.5) {$X$}; \draw [fill] (-1,.75) circle [radius=0.05]; \draw [fill] (3,.25) circle [radius=0.05]; \draw[thick](-1,.75)--(0,.75); \draw[thick,<-](-1,.25)--(0,.25); }.$$ (Of course for a concrete $\sigma$ there are as many wires as there are points in the boundaries $X$, $Y$.) \subsubsection{Composition} Cowordisms are composed simply by gluing multiwords along matching boundary parts. In the pictorial language of boxes and wires, given two cowordisms $$\sigma:X\to Y,\quad\tau:Y\to Z,$$ the composition $\tau\circ\sigma$ is represented in a most natural way. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1);\node at(1,.5){$\sigma$}; \draw[thick,-](2,.25)--(3,.25); \draw[thick,-](2,.75)--(3,.75); \node[left ] at(-1,.5) {$X$}; \draw [fill] (-1,.75) circle [radius=0.05]; \draw[thick](-1,.75)--(0,.75); \draw[thick,<-](-1,.25)--(0,.25); \draw[draw=black,fill=gray!10](4,0)rectangle++(2,1);\node at(5,.5){$\tau$}; \draw[thick,-](6,.25)--(7,.25); \draw[thick,->](6,.75)--(7,.75); \node[right] at(7,.5) {$Z$}; \draw [fill] (7,.25) circle [radius=0.05]; \draw[thick](3,.75)--(4,.75); \draw[thick,-](3,.25)--(4,.25); }.$$ An accurate definition is as follows. Let $X$, $Y$, $Z$ be boundaries, and $$\sigma=(\sigma,\phi_l,\phi_r),\quad \tau=(\tau,\psi_l,\psi_r)$$ be cowordisms from $X$ to $Y$ and from $Y$ to $Z$ respectively. Let $\rho=\sigma\sqcup\tau$. We have the injective maps $$\xi_l:Y_l\sqcup Y_r\to \d_l\rho,\mbox{ }\xi_r: Y_r\sqcup Y_l\to \d_r\rho$$ obtained from restrictions of $\phi_l\sqcup\psi_l$, $\psi_r\sqcup\phi_r$ respectively. Denote the image of $\xi_l$ as $I_l$ and the image of $\xi_r$ as $I_r$. The {\it composition} $\tau\circ\sigma$ is defined as the gluing of $\tau$ and $\sigma$ along $I_l$ identified with $I_r$ by means of bijection $\xi_r^{-1}\circ\xi_l:I_l\cong I_r$, i.e. $$\tau\circ\sigma= (\sigma\sqcup\tau)/\{I_l\stackrel{}{\cong}I_r\}.$$ Restrictions of $\psi_l\sqcup\phi_l$ to $Z_l\sqcup X_r$ and of $\psi_r\sqcup\phi_r$ to $Z_r\sqcup X_l$ provide necessary bijections $$Z_l\sqcup X_r\cong \d_l(\tau\circ\sigma),\mbox{ }Z_r\sqcup X_l\cong\d_r(\tau\circ\sigma),$$ which makes the constructed multiword a cowordism from $X$ to $Z$. It follows from Note \ref{associativity of contraction} and definition of cowordism equality that composition is associative. \subsubsection{Identities} In order to construct a category we only need to find identities. Let $X$ be a boundary. The {\it identity cowordism} $\id_X$ is constructed as follows. Take two copies of $X$ and then draw a directed edge from each point of $X_r$ in the first copy to its image in the second copy and from each point of $X_l$ in the second copy to its image in the first copy. Label every constructed edge with the empty word. This gives us an acyclic multiword with the left and right boundaries isomorphic to $X_r\sqcup X_l$. In the pictorial language, $\id_X$ looks as follows. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,<-](0,-0.5) -- (2,-0.5); \node[left] at (0,-0.25) {$X$}; \node[right] at (2,-0.25) {$X$}; \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (2,-0.5) circle [radius=0.05]; }$$ \smallskip It is immediate now that the following is well defined. \bd The category ${\bf Cow}_T$ of cowordisms over the alphabet $T$ has boundaries as objects and cowordisms over $T$ as morphisms. \ed \subsection{Over the empty alphabet} Note that even when the alphabet is empty, the category of cowordisms is nontrivial. In fact, it becomes literally the category of oriented 1-dimensional cobordisms. In the sequel we will use the term {\it cobordism} for a cowordism over the empty alphabet, and denote $${\bf Cow_\emptyset}={\bf Cob}.$$ Given two boundaries $X,Y$ and a cowordism $\sigma:X\to Y$ over some alphabet $T$, we define the {\it pattern} of $\sigma$ as the cobordism from $X$ to $Y$ obtained by erasing from $\sigma$ all letters. \section{Cowordisms and monoidal closed categories} \subsection{Structure of cowordisms category} The category of cowordisms has a rich structure (which it inherits, in fact, from the underlying category of cobordisms). It is a {\it symmetric monoidal closed, $*$-autonomous}, and {\it compact closed category}, which makes it a model of linear $\lambda$-calculus and of classical multiplicative linear logic. \subsubsection{Monoidal structure} First, the operation of disjoint union makes this category {\it monoidal}. The {\it tensor product} $\otimes$ on ${\bf Cow}_T$ is defined both on objects and morphisms as the disjoint union. The {\it monoidal unit} ${\bf 1}$ is the empty boundary, $${\bf 1}={\bf 1}_r={\bf 1}_l=\emptyset.$$ Obviously, tensor product of cowordisms is associative up to a natural transformation. In order to avoid very cumbersome notations we will, as is quite customary in literature, treat the category of cowordisms as {\it strict monoidal}. That is we will write $X\otimes Y \otimes Z$ without brackets, as if the associativity isomorphisms were strict equalities. Similarly, we will usually identify ${\bf 1}\otimes X$ and $X\otimes {\bf 1}$ with $X$. This is legitimate, because any monoidal category is equivalent to a strict monoidal category, see \cite{MacLane}, Chapter VII for details. In the pictorial language, given two cowordisms $$\sigma:X\to Y,\quad\tau:Z\to T,$$ we depict the tensor product $\sigma\otimes \tau$ as two disjoint boxes. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1);\node at(1,.5){$\sigma$}; \draw[thick,-](2,.25)--(3,.25); \node[right] at(3,.5) {$Y$}; \draw[thick,->](2,.75)--(3,.75); \node[left ] at(-1,.5) {$X$}; \draw [fill] (-1,.75) circle [radius=0.05]; \draw [fill] (3,.25) circle [radius=0.05]; \draw[thick](-1,.75)--(0,.75); \draw[thick,<-](-1,.25)--(0,.25); \node at(1,-.5){$\otimes$}; \draw[draw=black,fill=gray!10](0,-2.)rectangle++(2,1.);\node at(1,-1.5){$\tau$}; \draw[thick,->](2,-1.25)--(3,-1.25); \node[right] at(3,-1.5) {$T$}; \draw[thick,-](2,-1.75)--(3,-1.75); \node[left ] at(-1,-1.5) {$Z$}; \draw [fill] (-1,-1.25) circle [radius=0.05]; \draw [fill] (3,-1.75) circle [radius=0.05]; \draw[thick,<-](-1,-1.75)--(0,-1.75); \draw[thick](-1,-1.25)--(0,-1.25); }.$$ For an abstract cowordism $\sigma$ of the form $$\sigma:X_1\otimes\ldots\otimes X_n\to Y_1\otimes\ldots\otimes Y_m, $$ it is convenient to depict $\sigma$ as a box with different slots for different tensor factors, as follows. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,-2)rectangle++(2,3);\node at(1,-.5){$\sigma$}; \draw[thick,-](2,.25)--(3,.25); \node[right] at(3,.5) {$Y_1$}; \draw[thick,->](2,.75)--(3,.75); \node[left ] at(-1,.5) {$X_1$}; \node[left ] at(-1,-.1) {$\otimes$}; \node[right ] at(3,-.1) {$\otimes$}; \draw [fill] (-1,.75) circle [radius=0.05]; \draw [fill] (3,.25) circle [radius=0.05]; \draw[thick](-1,.75)--(0,.75); \draw[thick,<-](-1,.25)--(0,.25); \node [left] at(-1,-.5){$\ldots$}; \node [right] at(3,-.5){$\ldots$}; \draw[thick,->](2,-1.25)--(3,-1.25); \node[right] at(3,-1.5) {$Y_m$}; \draw[thick,-](2,-1.75)--(3,-1.75); \node[left ] at(-1,-.9) {$\otimes$}; \node[right ] at(3,-.9) {$\otimes$}; \node[left ] at(-1,-1.5) {$X_n$}; \draw [fill] (-1,-1.25) circle [radius=0.05]; \draw [fill] (3,-1.75) circle [radius=0.05]; \draw[thick,<-](-1,-1.75)--(0,-1.75); \draw[thick](-1,-1.25)--(0,-1.25); }.$$ When the cowordism $\sigma$ is of the form $$\sigma:{\bf 1}\to X_1\otimes\ldots\otimes X_n$$ It is natural to represent it without wires on the left as follows. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,-2)rectangle++(2,3);\node at(1,-.5){$\sigma$}; \draw[thick,-](2,.25)--(3,.25); \node[right] at(3,.5) {$X_1$}; \draw[thick,->](2,.75)--(3,.75); \node[right ] at(3,-.1) {$\otimes$}; \draw [fill] (3,.25) circle [radius=0.05]; \node [right] at(3,-.5){$\ldots$}; \draw[thick,->](2,-1.25)--(3,-1.25); \node[right] at(3,-1.5) {$X_m$}; \draw[thick,-](2,-1.75)--(3,-1.75); \node[right ] at(3,-.9) {$\otimes$}; \draw [fill] (3,-1.75) circle [radius=0.05]; }.$$ \subsubsection{Symmetry} The above monoidal structure is also symmetric. The {\it symmetry transformation} $$s_{X,Y}:X\otimes Y\to Y\otimes X$$ is given for any boundaries $X$, $Y$ by the following cowordism. Take a copy of $X\sqcup Y$ and a copy of $Y\sqcup X$. For each $x\in X_r$ draw a directed edge from the image of $x$ in $X\sqcup Y$ to the image of $x$ in $Y\sqcup X$, similarly for each $y\in Y_r$. Then for each $x\in X_l$ draw a directed edge from the image of $x$ in $Y\sqcup X$ to the image of $x$ in $X\sqcup Y$, similarly for each $y\in Y_l$. Label each constructed edge with the empty word. This gives an acyclic multiword, which is a cowordism from $X\otimes Y$ to $Y\otimes X$ in the obvious way. In the pictorial language symmetry is the following. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,-1.5); \draw[thick,<-](0,-.5) -- (2,-2); \draw[thick,->](0,-1.5) -- (2,0); \draw[thick,<-](0,-2.) -- (2,-.5); \node[right] at (2,-1) {$\otimes$}; \node[left] at (0,-1) {$\otimes$}; \node[right] at (2,-.25) {$Y$}; \node[right] at (2,-1.75) {$X$}; \node[left] at (0,-.25) {$X$}; \node[left] at (0,-1.75) {$Y$}; \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (2,-.5) circle [radius=0.05]; \draw [fill] (0,-1.5) circle [radius=0.05]; \draw [fill] (2,-2.) circle [radius=0.05]; }$$ \nb The above defined tensor product, monoidal unit and symmetry make ${\bf Cow}_T$ a symmetric monoidal category. $\Box$ \nbe \subsubsection{Duality and internal homs} The category of cowordisms also has a well-behaved {\it contravariant duality} $(.)^\bot$, defined by switching left and right. Let $X=X_r\cup X_l$ be a boundary. The {\it dual} $X^\bot$ of $X$ is defined by $$X^\bot=X,\quad (X^\bot)_r=X_l,\quad(X^\bot)_l=X_r.$$ On morphisms, duality amounts to relabeling boundary points. Let $\sigma:X\to Y$ be a cowordism. By definition $\sigma$ is a multiword $\sigma$ together with two labeling functions $$\phi_l:Y_l\sqcup X_r\to\d_l\sigma,\quad\phi_r:Y_r\sqcup X_l \to\d_r\sigma.$$ Let $$s_{r,l}:X_r\sqcup Y_l\to Y_l\sqcup X_r,\quad s_{l,r}:X_l\sqcup Y_r\to Y_r\sqcup X_l$$ be the natural bijections. Then the triple $$\sigma^\bot=(\sigma,\phi_r\circ s_{l,r},\phi_l\circ s_{r,l})$$ is a cowordism from $Y^\bot$ to $X^\bot$. In the pictorial language, given a cowordism $\sigma:X\to Y$, the dual cowordism $\sigma^\bot$ looks as follows. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1.5);\node at(1,.75){$\sigma$}; \draw [fill] (4,1.7) circle [radius=0.05]; \draw [fill] (-2,-.5) circle [radius=0.05]; \draw[thick,-](2,.5) to [out=0,in=90] (3,.2) to [out=-90,in=0] (-2,-.5); \draw[thick,->](2,1.2) to [out=0,in=90] (4,.2) to [out=-90,in=0] (-2,-1.2); \draw[thick,-](4,1.7) to [out=180,in=90] (-.75,1.3) to [out=-90,in=180] (0,1.2); \draw[thick,<-](4,2.4) to [out=180,in=90] (-2,1.4) to [out=-90,in=-180] (0,.5); \node []at (4,2.05) {$X^\bot$}; \node []at (-2,-.85) {$Y^\bot$}; }.$$ \nb The above defined duality is a contravariant functor commuting with the tensor product: $(X\otimes Y)^\bot\cong X^\bot\otimes Y^\bot$. $\Box$ \nbe \smallskip Tensor and duality equip ${\bf Cow}_T$ with a very rich categorical structure that we discuss in the next section. \subsection{Zoo of monoidal closed categories} \bd {\bf Monoidal closed category} ${\bf C}$ is a symmetric monoidal category ${\bf C}$ equipped with a bifunctor $\multimap$, contravariant in the first entry and covariant in the second entry, such that there exists a natural bijection \be\label{monoidal closure} Hom(X\otimes Y, Z)\cong Hom(X,Y\multimap Z). \ee \ed The functor $\multimap$ in the above definition is called {\it internal homs functor}. \bd \cite{Barr} {\bf $*$-Autonomous category} ${\bf C}$ is a symmetric monoidal category ${\bf C}$ equipped with a contravariant functor $(.)^\bot$, such that there is a natural isomorphism $$A^{\bot\bot}\cong A$$ and a natural bijection $$ Hom(X\otimes Y, Z)\cong Hom(X,(Y\otimes Z^\bot)^\bot. $$ \ed Duality $(.)^\bot$ equips a $*$-autonomous category with a second monoidal structure. The {\it cotensor product} $\wp$ is defined by $$X\wp Y=(X^\bot\otimes ^\bot)^\bot.$$ The neutral object for the cotensor product is $$\bot={\bf 1}^\bot.$$ Any $*$-autonomous category is monoidal closed. The internal homs functor is defined by $$X\multimap Y=X^\bot\wp Y.$$ Note that we have a natural isomorphism \be\label{duality as implication} X^\bot\cong X\multimap\bot. \ee \bd\cite{KellyLaplaza} A {\bf compact closed} or, simply, {\bf compact category} is a $*$-autonomous category for which duality commutes with tensor, i.e. such that $$X\wp Y\cong X\otimes Y,\quad {\bf 1}\cong \bot.$$ \ed For compact categories it is convenient to define internal homs by\be\label{internal homs in compacts} X\multimap Y=X^\bot\otimes Y, \ee A prototypical example of a compact category is the category of finite-dimensional vector spaces with the usual tensor product and algebraic duality. Note, however, that in this case, and, in general, in the algebraic setting, duality is denoted as a star $(.)^*$. Another example of a compact category widely used in mathematics and important for our discussion is the category of cobordisms. \nb The category of cowordisms is compact closed (hence monoidal closed and $*$-autonomous). \nbe {\bf Proof} exercise. $\Box$ \smallskip Compact structure provides a lot of important maps and constructions. A short and readable introduction into the subject can be found, for example, in \cite{AbramskyCoecke}. We pick some necessary bits in the next section. \subsubsection{Names} Let ${\bf C}$ be a monoidal closed category. For any morphism $$\sigma:A\to B$$ correspondence (\ref{monoidal closure}) together with the isomorphism $$A\cong{\bf 1}\otimes A$$ yields the morphism $$\ulcorner\sigma\urcorner:{\bf 1}\to A\multimap B,$$ sometimes called the {\it name} of $\sigma$. In the case of cowordisms, the name $\ulcorner\sigma\urcorner:{\bf 1}\to A\multimap B\cong A^\bot\otimes B$ of a cowordism $\sigma:A\multimap B$ can be depicted as follows. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle(2,1.5);\node at(1,.75){$\sigma$}; \draw [fill] (4,1.7) circle [radius=0.05]; \draw [fill] (4,.5) circle [radius=0.05]; \draw[thick,-](2,.5) --(4,.5); \draw[thick,->](2,1.2)--(4,1.2); \draw[thick,-](4,1.7) to [out=180,in=90] (-.75,1.3) to [out=-90,in=180] (0,1.2); \draw[thick,<-](4,2.4) to [out=180,in=90] (-2,1.4) to [out=-90,in=-180] (0,.5); \node [right]at (4,2.05) {$A^\bot$}; \node [right]at (4,.85) {$B$}; \node [right]at (4,1.45) {$\otimes$}; }.$$ \subsubsection{Applications} As before, let ${\bf C}$ be a monoidal closed category. For any two objects $A,B$, correspondence (\ref{monoidal closure}) composed with symmetry applied to $\id_{A\multimap B}$ yields the {\it evaluation} morphism $$\ev_{A,B}:A\otimes(A\multimap B)\to B.$$ In a compact closed case, where we have identifications (\ref{internal homs in compacts}), evaluation is especially simple. We have the natural {\it pairing map} $$\epsilon_{A}:A\otimes A^\bot\to{\bf 1},$$ usually called {\it counit}, and evaluation can be computed as $$\ev_{A,B}=\epsilon_A\otimes\id_B.$$ In the case of cowordisms the pairing $\epsilon_A$ has the following shape (remember that $A^\bot_r=A_l$ and $A^\bot_l=A_r$). $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) to [out=0,in=90] (3,-1.) to [out=-90,in=0] (0,-2); \node[below left ] at (0,0){$A$}; \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (0,-1.5) circle [radius=0.05]; \draw[thick,<-](0,-0.5) to [out=0,in=90] (2,-1) to [out=-90,in=0] (0,-1.5); \node [below left]at (0,-1.5) {$A^\bot$}; \node[left] at(0,-1) {$\otimes$}; }$$ The evaluation $\ev_{A,B}$, accordingly, is pictured as follows. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) to [out=0,in=90] (3,-1.) to [out=-90,in=0] (0,-2); \node[below left ] at (0,0){$A$}; \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (0,-1.5) circle [radius=0.05]; \draw[thick,<-](0,-0.5) to [out=0,in=90] (2,-1) to [out=-90,in=0] (0,-1.5); \node [below left]at (0,-1.5) {$A^\bot$}; \node[left] at(0,-1) {$\otimes$}; \node[left] at(0,-2.5) {$\otimes$}; \draw[thick,->] (0,-3)--(2,-3); \draw[thick,<-] (0,-3.5)--(2,-3.5); \node [below left]at (0,-3) {$B$}; \node [below right]at (2,-3) {$B$}; \draw [fill] (0,-3) circle [radius=0.05]; \draw [fill] (2,-3.5) circle [radius=0.05]; }$$ Now given two morphisms $$\tau:{\bf 1}\to A,\quad\sigma:{\bf 1}\to A\multimap B,$$ we can define the {\it application} $$(\sigma\cdot\tau)_A:{\bf 1}\to B$$ of $\sigma$ to $\tau$ as $$(\sigma\cdot\tau)_A=\ev_{A,B}\circ(\tau\otimes\sigma).$$ The following property holds for any monoidal closed category. \nb\label{application} For any two morphisms $$\tau:{\bf 1}\to A,\quad \sigma: A\to B,$$ it holds that $$\ulcorner\sigma\urcorner\cdot\tau=\sigma\circ\tau.\mbox{ } \Box$$ \nbe \smallskip In the case of cowordisms, the property is evident from geometric representation. \subsubsection{Partial pairing} Now let ${\bf C}$ be a $*$-autonomous category. For any objects $A,B, C,D$ there is a natural {\it linear distributivity} morphism \cite{CocketSeely} \be\label{linear distributivity} \delta_{A,B,C,D}:(A\wp B)\otimes (C\wp D)\to A\wp (B\otimes C)\wp D. \ee In a compact closed case, where cotensor and tensor can be identified, linear distributivity is just associativity of tensor product. Using linear distributivity, for any two morphisms $$\tau:{\bf 1}\to A\wp U,\quad\sigma:{\bf 1}\to U^\bot\wp B,$$ we can define the {\it partial pairing} $$\langle\tau,\sigma\rangle_U:{\bf 1}\to A\wp B$$ of $\tau$ and $\sigma$ over $U$ by $$ \langle\tau,\sigma\rangle_U=(\id_A\wp \epsilon_{U}\wp\id_B)\circ\delta_{A,U,U^\bot,B}\circ(\tau\otimes\sigma). $$ In the case of cowordisms, given two cowordisms $$\sigma:{\bf 1}\to A\otimes U,\quad\tau:{\bf 1}\to U^\bot\otimes B,$$ the partial pairing $\langle\tau,\sigma\rangle_U$ has the following shape. $$ \tikz[xscale=.7]{ \draw[draw=black,fill=gray!10](0,0)rectangle++(2,2);\node at(1,1){$\sigma$}; \draw[thick,-](2,1.25)--(5,1.25); \node[right] at(5,1.5) {$A$}; \draw[thick,->](2,1.75)--(5,1.75); \draw[thick,->](2,.75) to [out=0,in=90] (4,-.625) to [out=-90,in=0] (2,-1.75); \draw[thick,<-](2,.25) to [out=0,in=90] (3,-.625) to [out=-90,in=0] (2,-1.25); \draw [fill] (5,1.25) circle [radius=0.05]; \draw[draw=black,fill=gray!10](0,-3.)rectangle++(2,2);\node at(1,-2){$\tau$}; \draw[thick,->](2,-2.25)--(5,-2.25); \draw[thick,-](2,-2.75)--(5,-2.75); \node[right] at(5,-2.5) {$B$}; \node[right] at(5,-.625) {$\otimes$}; \draw [fill] (5,-2.75) circle [radius=0.05]; }.$$ Partial pairing can be understood as a symmetrized composition, as the following observation shows. \nb\label{partial pairing} For all morphisms $$\tau:A\to B,\quad\sigma:B\to C$$ it holds that $$\ulcorner\sigma\circ\tau\urcorner=\langle\ulcorner\tau\urcorner,\ulcorner\sigma\urcorner\rangle_{B}. \quad\Box$$ \nbe \subsection{Categories of cowordism types} We know discuss subcategories of ${\bf Cow}_T$, which are no longer compact, but are monoidal closed. They will be helpful for understanding categorial grammars considered in this paper. \bd Given a boundary $X$, a {\bf cowordism type} over an alphabet $T$ or, simply, a {\bf type} on the boundary $X$ is a set of cowordisms over $T$ from ${\bf 1}$ to $X$. A set of cowordisms over the alphabet $T$ is a {\bf cowordism type} or, simply, a {\bf type}, if it is a type on some boundary. \ed Given a type $A$, we denote the corresponding boundary as $\d A$. \bd Given two cowordism types $A,B$ over the same alphabet, a cowordism $$\sigma:\d A\to \d B$$ is a {\bf morphism of types} $$\sigma:A\to B$$ if for any $\tau\in A$ it holds that $\sigma\circ \tau\in B$. \ed Obviously, morphisms of types compose, and identity cowordisms are morphisms of types. So, types over an alphabet $T$ form a category. We denote it as ${\bf Types}_T$. Categories of types inherit symmetrical monoidal, and even monoidal closed structure of ${\bf Cow}_T$. For two types $A,B$ we define the {\it tensor product type} $A\otimes B$ as the type on the tensor product of boundaries, $$\d(A\otimes B)=\d A \otimes \d B,$$ given by $$A\otimes B=\{\sigma\otimes \tau|\mbox{ }\sigma\in A,\tau\in B\}.$$ We define the {\it internal homs type} $A\multimap B$ as the type on the boundary $$\d(A\multimap B)=\d A\multimap\d B=(\d A)^\bot\otimes\d B$$ given by $$A\multimap B=\{\sigma|\mbox{ }\forall\tau\in A\mbox{ }\sigma\cdot\tau\in B\}.$$ Elements of $A\multimap B$ are precisely all names of cowordisms which are morphisms of types $A$ and $B$. The {\it unit type} ${\bf 1}$ is the type on the empty boundary that contains only the empty cowordism $\emptyset$. \nb The category ${\bf Types}_T$ of cowordism types is symmetric monoidal closed. The forgetful functor $${\bf Types}_T\to {\bf Cow}_T$$ which send each type $A$ to the boundary $\d A$ and is identity on morphisms preserves monoidal closed structure. $\Box$ \nbe \subsubsection{Cowordisms of a formal language}\label{cowordism of lang} Let $L$ be a formal language in the alphabet $T$. Without loss of generality we assume that the symbol $\star$ is not in $T$. Let $$T'=T\cup\{\star\}.$$ We define the type $\bot$ over $T'$ on the empty boundary as the set of cyclic words $$\bot=\{[w\star]\mbox{ }|w\in L\},$$ where each cyclic word is seen as a singular cowordism. Now for any type $A$ over $T'$ we define the {\it dual} $A^\bot$ of $A$ (with respect to $L$) as the type $$A^\bot=A\multimap\bot.$$ We say that the type $A$ is a {\it closed type (of the language $L$)} if $A=A^{\bot\bot}$ (using the identification $(\d A)^{\bot\bot}\cong\d A$ on the level of boundaries). Closed types of $L$ form a (full) subcategory of ${\bf Types}_{T'}$, which we denote as ${\bf CTypes}_L$. The category ${\bf CTypes}_L$ is, in fact, $*$-autonomous. It is easy to see that for all closed types $A$, $B$, the type $A\multimap B$ is closed. Also the types $\bot$, ${\bf 1}$ are closed with $${\bf 1}=\bot^\bot.$$ In general, we have the following. \nb A type $A$ is closed iff $A\cong B^\bot$ for some type $B$ on the boundary $(\d A)^\bot$. There is a contravariant functor $$(.)^\bot:{\bf Types}_T\to {\bf CTypes}_L$$ sending a type $A$ to the type $A^\bot$ and a cowordism $\sigma$, to the cowordism $\sigma^\bot$. $\Box$ \nbe \smallskip In particular, if $A$ is a type, then we can complete it to the type $Cl(A)$ on the same boundary $\d A$, defined as $$Cl(A)=A^{\bot\bot}$$ with the usual identification \be\label{bidal identification} \d A\cong(\d A)^{\bot\bot}. \ee We say that $Cl(A)$ is the {\it closure} of $A$ (with respect to $L$). Then the preceding Note implies the following. \bc\label{pretypes2types} Let $A$, $B\in {\bf Types}_T$. Any cowordism $\sigma$ which is a morphism of types $$\sigma: A\to B$$ is also a morphism of closed types $$\sigma: Cl(A)\to Cl(B)B.$$ \ec {\bf Proof} By the preceding Note, we have a {\it covariant} functor $$(.)^{\bot\bot}:{\bf Types}_T\to{\bf CTypes}_L.$$ But, under identification (\ref{bidal identification}), it sends any type to its closure and is identity on morphisms. $\Box$ \smallskip For closed types $A$, $B$ we define the {\it closed tensor product type} $A\otimes B$ as the closure of the tensor product type, $$A\otimes B=Cl(\{\sigma\otimes \tau|\mbox{ }\sigma\in A,\tau\in B\}).$$ \nb With the above defined tensor product and duality $(.)^\bot$, the category ${\bf CTypes}_L$ is $*$-autonomous. The forgetful functor $${\bf CTypes}_L\to {\bf Cow}_T,$$ which sends type $A$ to the boundary $\d A$ and is identity on morphisms, preserves $*$-autonomous structure. $\Box$ \nbe \smallskip It is useful to observe that the original language $L$ can be represented as a closed type of $L$. Indeed, let $X$ be some boundary with $|X_l|=|X_r|=1$. Any regular cowordism from ${\bf 1}$ to $X$, seen as a graph consists of a single edge. Define ${\bf star} $ as the type on $X$ consisting of the single regular cowordism whose only edge is labeled with $\star$. Then the closed type $S={\bf star}^\bot$ consists of all regular cowordisms whose only edge is labeled with an element of $L$. It seems natural to identify $S$ with the language $L$. \section{Linear logic grammars} \subsection{Linear logic} Strictly speaking, the system discussed below is {\it multiplicative linear logic}, a fragment of full linear logic. However, since we do not consider other fragments, the prefix ``multiplicative'' will be omitted. A more detailed introduction to linear logic can be found in \cite{Girard}, \cite{Girard2}. Given a set $N$ of {\it positive literals}, we define the set $N^\bot$ of {\it negative literals} as $$N^\bot=\{X^\bot|\mbox{ }X\in N\}.$$ Elements of $N\cup N^\bot$ will be called {\it literals}. The set $Fm(N)$ of ${\bf LL}$ formulas (over the alphabet $N$) is defined by the following induction. \begin{itemize} \item Any $X\in N\cup N^\bot$ is a formula; \item if $X$, $Y$ are formulas, then $X\wp Y$ and $X\otimes Y$ are formulas; \end{itemize} Connectives $\otimes$ and $\wp$ are called respectively {\it times} (also {\it tensor}) and {\it par} (also {\it cotensor}). {\it Linear negation} $A^\bot$ of a formula $A$ is defined inductively as $$(P^\bot)^\bot=P,\mbox{ for }P\in N,$$ $$(A\otimes B)^\bot=A^\bot\wp B^\bot,\quad (A\wp B)^\bot=A^\bot\otimes B^\bot.$$ {\it Linear implication} is defined as \be\label{linear implication} A\multimap B=A^\bot\wp B. \ee An ${\bf LL}$ sequent is an expression of the form $\vdash\Gamma$, where $\Gamma$ is s finite sequence of ${\bf LL}$ formulas. The {\it sequent calculus} for ${\bf LL}$ is given by the following rules: $$\vdash X^\bot,X\mbox{ } (Identity),\quad \frac{\vdash \Gamma,X\quad\vdash X^\bot,\Delta}{\vdash\Gamma,\Delta} \mbox{ }(Cut),$$ $$\frac{\vdash X_1,\ldots,X_n}{\vdash X_{\pi(1)},\ldots,X_{\pi(n)}}, \pi\in S_n \mbox{ }(Exchange),$$ $$\frac{\vdash \Gamma,X,Y} {\vdash\Gamma,X\wp Y}\mbox{ } (\wp)\quad\frac{\vdash\Gamma, X \quad\vdash Y,\Delta}{\vdash\Gamma,X\otimes Y,\Delta}\mbox{ } (\otimes).$$ \smallskip Linear logic enjoys the fundamental property of {\it cut-elimination}. Any sequent derivable in ${\bf LL}$ is derivable also in the {\it cut-free} system, i.e., without use of the Cut rule. Moreover, any proof has an essentially unique, up to some permutation of rules, {\it cut-free form}, which can be found algorithmically. This allows computational and categorical interpretations in the {\it proofs-as-programs} or {\it proofs-as-functions} paradigm. \subsection{Semantics} Categorical interpretation of proof theory is based on the idea that formulas should be understood as objects and proofs, as morphisms in a category, while composition of morphisms corresponds to cut-elimination. In a two-sided sequent calculus, formulas are interpreted as objects in a monoidal category, and a proof of the sequent $$X_1,\ldots, X_n\vdash X$$ is interpreted as a morphism of type $$X_1\otimes\ldots\otimes X_n\to X.$$ This includes the case $n=0$, with the usual convention that the tensor of the empty collection of objects is the monoidal unit ${\bf 1}$. Then the Cut rule corresponds to composition. A crucial requirement is that the interpretation should be invariant with respect to cut-elimination; a proof and its cut-free form are interpreted the same. In the case of linear logic, whose sequents are one-sided, the appropriate setting for categorical interpretation is {\it $*$-autonomous categories} \cite{Seely}, \cite{Mellies_categorical_semantics}. In this setting, a proof of the sequent $$ \vdash X_1,\ldots, X_n$$ is interpreted as a morphism of type $${\bf 1}\to X_1\wp\ldots\wp X_n.$$ The Cut rule corresponds to partial pairing, which can be understood as a symmetrized composition. A special case of $*$-autonomous categories are compact categories, and, in particular, categories of cowordisms. Given a $*$-autonomous category ${\bf C}$ and an alphabet $N$ of positive literals, an interpretation of ${\bf LL}$ in ${\bf C}$ consists in assigning to any positive literal $A$ an object $[A]$ of $\bf C$. The assignment of objects extends to all formulas in $Fm(N)$ by the obvious induction $$[A\otimes B]=[A]\otimes [B],\quad [A^\bot]=[A]^\bot.$$ It is quite customary in literature to omit square brackets and denote a formula and its interpretation by the same expression, and we will follow this practice when convenient. Given interpretation of formulas, proofs are interpreted by induction on the rules. The axiom $\vdash A^\bot,A$ is interpreted as the name $$\ulcorner \id_{[ A]}\urcorner:{\bf 1}\to [ A]^\bot\wp [ A]$$ of the identity. The Cut rule corresponds to partial pairing, as stated above. The Exchange rule corresponds to a symmetry transformation. The $(\wp)$ rule does nothing. The $(\otimes)$ rule is linear distributivity (\ref{linear distributivity}). In the case of a compact category, in particular the category of cowordisms, the $(\otimes)$ rule just tensors two morphisms together (up to associativity of tensor product). Two proofs are {\it equivalent}, if they get the same interpretation for any interpretation in any $*$-autonomous category. When the category ${\bf C}$ is a compact category of cowordisms (over some alphabet), and formulas are interpreted as boundaries, we denote the interpretation of a formula $A$ as $\d A$ and use the convention $$(\d A)_l=\d_lA,\quad (\d A)_r=\d_r A.$$ Observe that in this, interpretations of proofs do not depend on the alphabet at all. So it would be more honest to say that this is an interpretation in the category ${\bf Cob}$ of {\it cobordisms}. The alphabet comes into play if we add new axioms to the logic, which gives us a {\it logic grammar}. \subsection{Adding lexicon} An ${\bf LL}$ grammar is an interpretation of ${\bf LL}$ in a category of cowordisms supplied with a set of axioms together with cowordisms representing their ``proofs''. Here is an accurate definition \bd {\bf Linear logic grammar (LLG)} $G$ is a tuple $G=(N,T,Lex,S)$, where \begin{itemize} \item $N$ is a finite set of positive literals together with an interpretation $A\mapsto \d A$ of elements of $N$ as boundaries; \item $T$ is a finite alphabet; \item $Lex$, the {\bf lexicon}, is a finite set of expressions of the form $\sigma:F$, where $F$ is an ${\bf LL}$ formula, and $$\sigma:{\bf 1}\to \d F$$ is a cowordism; \item $S\in N$, the {\bf standard type}, is interpreted as a boundary with $|\d_lS|=|\d_rS|=1$. \end{itemize} \ed Elements of the lexicon $Lex$ will be often called {\it axioms}, and elements of $N$ will be called {\it atomic types}. Now let $A$ be an ${\bf LL}$ formula, and let $\rho:{\bf 1}\to \d A$ be a cowordism. We say that $G$ {\it generates the cowordism $\rho$ of type $A$}, if there exists axioms $$\tau_1: A_1,\ldots,\tau_k: A_n\in Lex$$ for some $k\geq 0$ and a cowordism $$\sigma:{\bf 1}\to \d A_1^\bot\otimes\ldots\otimes \d A_n^\bot\otimes \d A$$ arising as the interpretation of some ${\bf LL}$ proof of the sequent $$\vdash A_1^\bot,\ldots,A_n^\bot, A,$$ such that, $$\rho=\langle\tau_1\otimes\ldots\otimes\tau_n,\sigma\rangle_{\d A_1\otimes\ldots\otimes \d A_n}.$$ The {\it cowordism type} $A$ {\it generated by $G$}, or, simply, the {\it cowordism type $A$ of $G$}, is the set of all cowordisms of type $A$ generated by $G$. Now any regular cowordism of the standard type $S$ is an edge-labeled graph containing a single edge. Thus the set of type $S$ regular cowordisms can be identified with a set of words. The {\it language $L(G)$ generated by $G$} is the set of type $S$ regular cowordisms generated by $G$. \section{Encoding multiple context-free grammars} In this section, as an example, we establish a relationship between LLG and {\it multiple context-free grammars}. \subsection{Multiple context-free grammars} Multiple context-free grammars were introduced in \cite{Seki}. We follow (with minor variations in notation) the presentation in \cite{Kanazawa}. \bd\label{MCFG def} A {\bf multiple context free grammar (MCFG)} $G$ is a tuple $G=(N,T,S,P)$ where \begin{itemize} \item $N$ is a finite alphabet of nonzero arity predicate symbols called {\bf nonterminal symbols} or {\bf nonterminals}; \item $T$ is a finite alphabet of {\bf terminal symbols} or {\bf terminals}; \item $S\in N$, the {\bf start symbol}, is unary; \item $P$ is a finite set of sequents, called {\bf productions} of the form \be\label{production} B_1(x^1_1,\ldots,x^1_{k_1}),\ldots,B_n(x^n_1,\ldots,x^n_{k_n})\vdash A(s_1,\ldots,s_k), \ee where \begin{enumerate}[(i)] \item $n\geq0$ and $A,B_1,\ldots, B_n$ are nonterminals with arities $k,k_1,\ldots,k_n$ respectively; \item $\{x^j_i\}$ are pairwise distinct variables not from $T$; \item $s_1,\ldots, s_k$ are words built of terminals and $\{x_i^j\}$; \item each of the variables $x^j_i$ occurs exactly once in exactly one of the words $s_1,\ldots s_k$. \end{enumerate} \end{itemize} \ed \smallskip {\bf Remark} Productions are often written in the opposite order in literature; with $A$ on the left and $B_1,\ldots,B_n$ on the right. Also, our ``non-erasing'' condition (iv) in the definition of a MCFG, namely, that all $x_i^j$ occurring on the left occur exactly once on the right, is too strong compared with original definitions in \cite{Seki}, \cite{Kanazawa}. Usually it is required only that each $x_i^j$ should occur at most once on the right. However, it is known \cite{Seki} that adding the non-erasing condition does not change the expressive power of MCFG, in the sense that the class of generated languages (see below) remains the same. \bd The set of {\bf predicate formulas derivable in $G$} is the smallest set satisfying the following. . \begin{enumerate}[(i)] \item { If a production $$\vdash A(s_1,\ldots,s_k)$$ is in $P$, then $A(s_1,\ldots,s_k)$ is derivable. } \item { For every production {\bf(\ref{production})} in $P$, if \begin{itemize} \item $B_1(s^1_1,\ldots,s^1_{k_1}),\ldots,B_n(s^n_1,\ldots,s^n_{k_n})$ are derivable, \item $t_m$ is the result of substituting the word $s^j_i$ for every variable $x^j_i$ in $s_m$, for $m=1,\ldots,k$, \end{itemize} then the formula $A(t_1,\ldots,t_k)$ is derivable. } \end{enumerate} \ed \bd The {\bf language generated } by an MCFG $G$ is the set of words $s$ for which $S(s)$ is derivable in $G$. {\bf Multiple context-free language} is a language generated by some MCFG. \ed When all predicate symbols in $N$ are unary, the above definition reduces to the more familiar case of a {\it context free grammar} (CFG). \subsection{MCFG productions as cowordisms}\label{MCFG -> cowordisms} Assume that we are given alphabets $N$ and $T$ of nonterminals and terminals respectively, as in Definition \ref{MCFG def}. For each $A\in N$ with arity $k$ introduce {\it left vertices} $$l^A_{1},\ldots,l^A_{k}$$ and {\it right vertices} $$r^A_{1},\ldots,r^A_{k}.$$ Denote the set of left vertices as $\d_lA$, and the set of right vertices, as $\d_r A$. Define the boundary $\d A$ as $\d A=\d_l A\cup \d_r A$. Now for any production $p$ of the form $$ B_1(x_1^1,\ldots,x^1_{k_1}),\ldots,B_n(x^n_1,\ldots,x^n_{k_n})\vdash A(s_1,\ldots,s_k)$$ we construct a cowordism $graph(p)$ over the alphabet $T$ of the type $$graph(p):\d B_1\otimes\ldots\otimes \d B_n\to \d A,$$ if $n>0$, or $$graph(p):{\bf 1}\to \d A$$ otherwise. In order to get $graph(p)$ it is sufficient to construct a multiword with the left boundary $$\d_r A\sqcup (\d_l B_1)\sqcup\ldots \sqcup (\d_l B_n)$$ and the right boundary $$\d_l A\sqcup (\d_r B_1)\sqcup\ldots \sqcup (\d_r B_n).$$ The multiword is constructed as follows. Let $V$ be the set of all variables $x_i^j$ occurring in $p$. For each $y=x_i^j\in V$ let $$h(y)=l^{B_j}_i,\quad t(y)=r^{B_j}_i.$$ Now each word $s_m$, $m=1,\ldots,k$, on the righthand side of $p$ is a concatenation of the form $$s_m=w^0_my^1_mw^1_m\ldots y^{\alpha_m}_mw^{\alpha_m}_m,$$ where all $$w^0_m,\ldots,w^{\alpha_m}_m$$ are words in the alphabet $T$ (possibly empty), and $$y^1_m,\ldots,y^{\alpha_m}_m$$ are variables from $V$. (With the convention that $\alpha_m$ may equal zero, in which case $s_m=w^0_m$.) We represent $p$ as the following multiword $graph(p)$. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](5,0) -- (7,0); \draw[thick,->](10,0) -- (12,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (5,0) circle [radius=0.05]; \draw [fill] (10,0) circle [radius=0.05]; \node at (8.5,0){$\cdots$}; \node[above]at (1,0){$w_1^0$}; \node[above]at (6,0){$w_1^1$}; \node[above]at (11,0){$w_1^{\alpha_1}$}; \node[below left] at (0,0){$l^{A}_1$}; \node[below ] at (2,0){$h(y_1^1)$}; \node[below left]at (5,0){$t(y^1_1)$}; \node[below ]at (7,0){$h(y_1^2)$}; \node[below ]at (10,0){$t(y^{\alpha_1}_1)$}; \node[below right]at (12,0){$r^A_1$}; \node[right] at(0,-1) {$\cdots$}; \node[left] at(12,-1) {$\cdots$}; \draw[thick,->](0,-2) -- (2,-2); \draw[thick,->](5,-2) -- (7,-2); \draw[thick,->](10,-2) -- (12,-2); \draw [fill] (0,-2) circle [radius=0.05]; \draw [fill] (5,-2) circle [radius=0.05]; \draw [fill] (10,-2) circle [radius=0.05]; \node at (8.5,-2){$\cdots$}; \node[above]at (1,-2){$w_k^0$}; \node[above]at (6,-2){$w_k^1$}; \node[above]at (11,-2){$w_k^{\alpha_k}$}; \node[below left] at (0,-2){$l^{A}_k$}; \node[below ] at (2,-2){$h(y_k^1)$}; \node[below left]at (5,-2){$t(y^1_k)$}; \node[below ]at (7,-2){$h(y_k^2)$}; \node[below ]at (10,-2){$t(y^{\alpha_k}_k)$}; \node[below right]at (12,-2){$r^A_k$}; } $$ In a verbal language, the multiword $graph(p)$ is defined as follows. For each $m=1,\ldots,k$, if $\alpha_m=0$ draw a directed edge from $l^A_m$ to $r^A_m$ and label it with $s_m$. Otherwise \begin{itemize} \item draw a directed edge from $l^A_m$ to $h(y^1_m)$ and label it with $w^0_m$, \item draw a directed edge from $t(y^{\alpha_m}_m)$ to $r^A_m$ and label it with $w^{\alpha_m}_m$, \item for each $\beta=1,\alpha_m-1$ draw a directed edge from $t(y^\beta_m)$ to $h(y^{\beta+1}_m)$ and label it with $w^\beta_m$. \end{itemize} Since each element of $V$ occurs on the left side of $p$ exactly once, it follows that the obtained edge-labeled graph is a perfect matching, hence a (regular) multiword, and its boundary satisfies the desired specification. \smallskip The constructed cowordism $graph(p)$ represents the production $p$ is a very direct sense. Let us construct, for every nonterminal $C\in N$ of arity $\alpha$, an oriented graph on the vertex set $\d C$ by drawing for each $m=1,\ldots,\alpha$ a directed edge from $l^{C}_m$ to $r^{C}_m$ as depicted below. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](5,0) -- (7,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (5,0) circle [radius=0.05]; \node at (3.5,0){$\cdots$}; \node[below left] at (0,0){$l^{C}_1$}; \node[below right] at (2,0){$r^{C}_1$}; \node[below left]at (5,0){$l^{C}_\alpha$}; \node[below right]at (7,0){$r^{C}_\alpha$}; } $$ This graph is a perfect matching. We call it the {\it pattern } of $C$ and denote as $Pat(C)$. We will represent a predicate formula \be\label{just a formula} C(s_1,\ldots,s_\alpha), \ee where $s_1,\ldots,s_\alpha$ are words, as a multiword whose underlying graph is $Pat(C)$ in the following obvious way. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (2,0); \draw[thick,->](5,0) -- (7,0); \draw [fill] (0,0) circle [radius=0.05]; \draw [fill] (5,0) circle [radius=0.05]; \node at (3.5,0){$\cdots$}; \node[above]at (1,0){$s_1$}; \node[above]at (6,0){$s_\alpha$}; \node[below left] at (0,0){$l^{C}_1$}; \node[below right] at (2,0){$r^{C}_1$}; \node[below left]at (5,0){$l^{C}_\alpha$}; \node[below right]at (7,0){$r^{C}_\alpha$}; } $$ We say that the above multiword {\it represents} formula (\ref{just a formula}). Then the following holds. \nb\label{production is a cowordism} Let $\sigma_1,\ldots,\sigma_n$ be cowordisms, $$\sigma_j:{\bf 1}\to \d B_j,\mbox{ }j=1,\ldots,n,$$ such that, seen as multiwords, they represent formulas $$ B(s_1^1,\ldots,s_1^{k_1}),\ldots,B(s_n^1,\ldots,s_n^{k_n}) $$ respectively, where $k_j$ is the arity of $B_j$, $j=1,\ldots,n$. Let $t_m$ be the result of substituting the word $s^j_i$ for every variable $x^j_i$ in $s_m$, for $m=1,\ldots,k$, Then the composition $$graph(p)\circ(\sigma_1\otimes\ldots\otimes\sigma_n):{\bf 1}\to \d A$$ gives the multiword representing the formula $$A(t_1,\ldots,t_k).\mbox{ }\Box$$ \nbe \subsection{From MCFG to LLG}\label{encoding MCFG} Any MCFG $G=(N,T,P,S)$ gives rise to an LLG by means of the translation described in Section \ref{MCFG -> cowordisms}. We treat each nonterminal $A$ as a positive literal and assign to it the boundary $\d A$ as in Section \ref{MCFG -> cowordisms}. This gives us a set $ N$ of positive literals and an interpretation $ A\mapsto \d A$ in the category of cowordisms. Then, to any production $p\in P$ of form (\ref{production}) we assign the axiom $$\ulcorner{graph(p)}\urcorner:\d B_1\otimes\ldots\otimes \d B_n\multimap \d A,$$ and this gives us the lexicon $Graph(P)$. The LLG $G'$ is defined as the tuple $G'=(N,T,Graph( P), S)$. From Note \ref{production is a cowordism} (using Note \ref{partial pairing} on the properties of partial pairing of cowordisms) it is immediate that the language generated by $G$ identifies with a subset of the language generated by $ G'$ . Let us prove the opposite inclusion. Let $L(G)$ be the language generated by $G$. Consider the category ${\bf CTypes}_{L(G)}$ of closed types of $L(G)$. For any $A\in N$ of arity $k$ we define the type $ \tilde A$ as the type on $\d A$ consisting of all multiwords representing formulas $$A(s_1,\ldots,s_k)$$ derivable in $G$. We then define the closed type $A\in{\bf Types}_{L(G)}$ as the closure $$ A=Cl(\tilde A).$$ (We deliberately abuse notation using the same symbol for an atomic type of $G'$ and the corresponding closed cowordism type.) Now we refine the interpretation of ${\bf LL}$ in ${\bf Cow}_T$ to an interpretation in ${\bf CTypes}_{L(G)}$. We assign to each literal $A\in N$ the corresponding cowordism type $A\in{\bf CTypes}_{L(G)}$ and extend the assignment to all formulas in $Fm(N)$ by induction. Since the category ${\bf CTypes}_{L(G)}$ is $*$-autonomous this gives us also a sound interpretation of proofs as morphisms of closed types. Since the forgetful functor $${\bf CTypes}_{L(G)}\to {\bf Cow}_T$$ preserves $*$-autonomous structure, the two interpretations (in ${\bf CTypes}_{L(G)}$ and in ${\bf Cow}_T$) coincide on the level of cowordisms. In particular, if $\pi$ is a proof of a sequent $$\vdash A_1,\ldots, A_n,$$ then its interpretation, the cowordism $$[\pi]:{\bf 1}\to \d A_1\otimes\ldots\otimes \d A_n$$ is in the type $A_1\wp\ldots\wp A_n$. Now we have the following. \nb Elements of the type $S\in {\bf CTypes}_{L(G)}$ are all regular cowordisms whose single edge is labeled with a word of $L$. \nbe {\bf Proof} repeats the discussion in the end of Section \ref{cowordism of lang}. $\Box$ \nb For any axiom $\sigma: F$ in the lexicon $Graph(P)$, the cowordism $\sigma$ belongs to the corresponding cowordism type $F\in {\bf CTypes}_{L(G)}$. \nbe {\bf Proof} We have that $\sigma=\ulcorner graph(p)\urcorner$ is the name of a cowordism representing some production $p\in P$ of form (\ref{production}), and $$F=B_1\otimes\ldots\otimes B_n\multimap A.$$ By Note \ref{production is a cowordism}, the cowordism $graph(p)$ is a morphism of types $$graph(p):\widetilde {B_1}\otimes\ldots\otimes \widetilde B_n\to \widetilde A.$$ By Note \ref{pretypes2types}, it remains a morphism of closed types $$graph(p): {B_1}\otimes\ldots\otimes B_n\to A.$$ It follows that the name $\sigma$ of $graph(p)$ is in the closed type $F$ of $L(G)$. $\Box$ \smallskip It follows that $G'$ generates the language $L(G)$. Thus we have the following. \bt Any multiple context-free language is generated by an ${\bf LL}$ grammar. $\Box$ \et \subsection{From LLG to MCFG} Note that LLG constructed from MCFG in the preceding section have particularly simple lexicons: formulas occurring in such lexicons do not contain $\otimes$ connective. We call such lexicons {\it $\otimes$-free}. We are going to prove the converse of the preceding theorem: any LLG with a $\otimes$-free lexicon generates a multiple context-free language. \subsubsection{Extended MCFG grammars} It will be convenient to reformulate (and slightly generalize) MCFG in a more category-theoretic language. \bd An {\bf extended MCFG grammar} $G$ is a tuple $G=(N,T,P,S)$, where \begin{itemize} \item $N$ is a finite set of {\bf types} together with an interpretation $A\mapsto \d A$ of elements of $N$ as boundaries; \item $T$ is a finite alphabet of {\bf terminal symbols}; \item $P$, is a finite set of rules of the form \be\label{cowordism produxtion def} \sigma:\d A_1\otimes\ldots\otimes \d A_n\to \d A, \ee Where $A_1,\ldots,A_n,A$ are elements of $N$, and $$\sigma:\d A_1\otimes\ldots\otimes \d A_n\to \d A.$$ is a cowordism; \item $S\in N$, the {\bf standard type}, is interpreted a boundary with $|\d_lS|=|\d_rS|=1$. \end{itemize} \ed Elements of $P$ are called {\it cowordism productions}. Now, for any type $A\in N$, we will define a cowordism type on $\d A$, called the {\it cowordism type $A$ generated by $G$}, or, simply, the {\it cowordism type $A$ of} $G$. We will write $G\vdash\sigma:A$ to express that $\sigma $ is in the cowordism type $A$ of $G$. The set is defined by induction. \begin{itemize} \item If a cowordism production $\sigma:{\bf 1}\to A$ is in $P$, then $G\vdash\sigma:A$. \item If a cowordism production $$\sigma:A_1\otimes\ldots\otimes A_n\to A$$ is in $P$, and $$G\vdash\tau_i:A_i,\quad i=1,\ldots,n,$$ then $G\vdash\sigma\circ(\tau_1\otimes\ldots\otimes\tau_n):A$. \end{itemize} The set of regular cowordisms of type $S$ is called the {\it language generated by the extended MCFG} $G$. \subsubsection{From extended MCFG to ordinary MCFG} Let $G=(N,T,P,S)$ be an extended MCFG. For each $A\in N$ and regular cowordism $\sigma:{\bf 1}\to \d A$ such that $G\vdash\sigma:A$ let $Pat(\sigma)$ be the pattern of $\sigma$. We say that $Pat(\sigma)$ is a {\it possible pattern} of $A$. We denote the set of possible patterns of $A$ as $Patt(A)$. Note that this set is finite. \bd The extended MCFG $G$ is {\bf simple}, if for any type $A\in N$ the set $Patt(A)$ contains at most one element. \ed \smallskip Quite obviously, any ordinary MCFG, can be seen as a simple extended MCFG. \bl If a language is generated by a simple extended MCFG, then it is also generated by an ordinary MCFG. \el {\bf Proof} Let $P_0\subseteq P$ be the set of regular cowordism productions that participate in generation of $L(G)$. For each element $p\in P_0$ we easily write an MCFG production as the inverse of the ``$graph$ map'' (see Section \ref{MCFG -> cowordisms}). This is left as an exercise to the reader. $\Box$ \smallskip Now we generalise the above to arbitrary extended MCFG $G$. Since the empty language is obviously multiple context-free, we may assume that $L(G)$ is nonempty, otherwise there is nothing to prove. We construct a new extended MCFG $G'$ as follows. For any type $A$ of $G$ and any possible pattern $\pi$ of $A$ we introduce a new symbol $(A,\pi)$. We define the set $N'$ of types of $G'$ as $$N'=\{(A,\pi)|\mbox{ }A\in N,\pi\in Patt(X)\}.$$ Interpretation of types as boundaries is given by $$\d (A,\pi)=\d A.$$ For any cowordism production $$\sigma:A_1\otimes\ldots\otimes A_n\to A$$ of $G$ we consider all possible cowordism productions of the form \be\label{new lexicon} \sigma':(A_1,\pi_1)\otimes\ldots\otimes(A_n,\pi_n)\to(A,\pi), \ee where $$\pi_i\in Patt(A_i),\mbox{ } i=1,\ldots, n,$$ and $\pi\in Patt(A)$ is constructed as the composition $$\tau=Pat(\sigma)\circ(\pi_1\otimes\ldots\otimes\pi_n).$$ The set $P'$ of productions for $G'$ consists of all cowordism productions of form (\ref{new lexicon}). Again, there are only finitely many of them. Since the set $L(G)$ is assumed nonempty, the set $Patt(S)$ is a singleton. We denote $S'=(S,e)$, where $e$ is the only element of $Patt(S)$. We define $G'$ as $G'=(N',T,L',S')$. It is immediate that $G'$ is simple and generates the same extended language as $G$. Combining the above with the preceding lemma, we obtain the following. \bl\label{MCFG=cowordisms} A language is generated by an MCFG iff it is generated by an extended MCFG. $\Box$ \el \subsubsection{From $\otimes$-free lexicon to extended MCFG } We start with some simple technical developments. For a sequent $\Theta$ of the form \be\label{tensor of ids} \Theta= A,A^\bot\otimes B^\bot,B, \ee we have a proof $$\frac{\vdash A,A^\bot\quad\vdash B^\bot,B}{\vdash\Theta}(\otimes).$$ We call this proof the {\it standard proof} of $\Theta$. Now let $\Phi$ be a finite set of $\otimes$-free ${\bf LL}$ formulas, which is closed under subformulas. Let $\Phi^\bot$ be the set $$\Phi^\bot=\{F^\bot|\mbox{ }F\in\Phi\}.$$ Let $\Pi_0(\Phi)$ be the set of all standard proofs of sequents of form (\ref{tensor of ids}) where $A^\bot,B^\bot,A\wp B\in \Phi$. Let $\Pi(\Phi)$ be the closure of $\Pi_0(\Phi)$ under the Exchange rule. \bl\label{main} Let $\Gamma$ be a sequent all whose formulas are in $\Phi^\bot$. Then any proof of $\Gamma$ is equivalent to a proof obtained from elements of $\Pi(\Phi)$ using only axioms and the Cut rule. \el {\bf Proof} by induction on a cut-free proof. $\Box$ \smallskip Now let $G=(N,T,Lex,S)$ be an LLG with a $\otimes$-free lexicon. We construct a cowordism grammar $G'$ using Lemma \ref{main} as follows. Let $\Phi$ be the set of all subformulas occurring in $L$. For every formula $F$ in $\Phi\cup\Phi^\bot$ we introduce a fresh symbol $[F]$ and assign to $[F]$ the same interpretation as to $F$, $$\d[F]=\d F.$$ We put $$N'=\{[F]\mbox{ }|\mbox{ }F\in\Phi\cup\Phi^\bot\},\quad S'=[S].$$ Now in order to define an extended MCFG we only need productions. Let $P_0$ be the set of all cowordism productions of the form $$\sigma:[F_1]\otimes[F_2]\to[F],$$ where $\sigma$ is the interpretation of some proof in $\Pi(\Phi)$ having the sequent $$\vdash F_1^\bot,F_2^\bot,F$$ as the conclusion. Let $P_1$ be the set of all cowordism productions $$\sigma:{\bf 1}\to[F]$$ where $\sigma:F\in Lex$. We define the set of productions $P'$ as $P'=P_0\cup P_1'$. The extended MCFG $G'$ is defined as $G'=(N',T,P',S')$. Lemma \ref{main} easily yields the following. \nb For any formula $F\in \Phi^\bot$ the cowordism type $[F]$ generated by $G'$ coincides with the cowordism type $F$ generated by $G$. \nbe {\bf Proof} Exercise. $\Box$ \smallskip We leave it as an exercise to the reader to prove that if $G$ generates a nonempty language then $S^\bot$ occurs as a subformula in $Lex$, hence $S\in \Phi^\bot$. Then the above Note implies that the language of $G'$ coincides with the language of $G$. We summarize in the following. \bl\label{LL->cowordisms lemma} For any LLG $G$ with a $\otimes$-free lexicon there exists a cowordism grammar $G'$ generating the same extended language. $\Box$ \el \smallskip Putting Lemmas \ref{LL->cowordisms lemma} and \ref{MCFG=cowordisms} together we obtain the following. \bt\label{tens. free lex is MCFG} A language is multiple context-free iff it is generated by an LLG with a $\otimes$-free lexicon. $\Box$ \et \section{Encoding abstract categorial grammars} Abstract categorial grammars (ACG) were introduced in \cite{deGroote}. They are based on the purely implicational fragment of linear logic, and {\bf LL} grammars of this paper can be seen as a representation and extension of ACG (over string signature). In this section we assume that the reader is familiar with basic notions of $\lambda$-calculus, see \cite{Barendregt} for a reference. \subsection{Linear $\lambda$-calculus} Linear $\lambda$-terms are $\lambda$-terms where each variable occurs exactly once. More accurately, given a set $X$ of {\it variables} and a set $C$ of {\it constants}, with $C\cap X=\emptyset$, the set $\Lambda(X,C)$ of {\it linear $\lambda$-terms} is defined by the following. \begin{itemize} \item Any $a\in X\cup C$ is in $\Lambda(X,C)$; \item if $t,s\in\Lambda(X,C)$ are linear $\lambda$-terms whose sets of free variables are disjoint then $(ts)\in\Lambda(X,C)$; \item if $t\in\Lambda(X,C)$, and $x\in X$ occurs freely in $t$ exactly once then $(\lambda x.t)\in \Lambda(X,C)$. \end{itemize} We type linear terms using {\it linear implicational types}. Given a set $N$ of {\it atomic types}, the set $Tp(N)$ of { linear implicational types} is defined by induction. \begin{itemize} \item Any $A\in N$ is in $Tp(N)$; \item if $A,B\in Tp(N)$, then $(A\multimap B)\in Tp(N)$. \end{itemize} \bd A {\bf higher order linear signature}, or, simply, a {\bf signature}, $\Sigma$ is a triple $\Sigma=(N,C,\tau)$, where $N$ is a finite set of atomic types, $C$ is a finite set of constants and $\tau$ is a function assigning to each constant a linear implicational type. \ed Given a signature $\Sigma=(N,C,\tau)$ and a countable set $X$ of variables, a {\it typing judgement} is a sequent of the form $$x_1:A_1,\ldots,x_n:A_n\vdash_\Sigma t:A,$$ where $x_1,\ldots x_n\in X$ are pairwise distinct ($n$ may be zero), $t\in\Lambda(X,C)$, and $A_1,\ldots,A_n,A\in Tp(N)$. Typing judgements are derived from the following type inference rules. $$\frac{}{\vdash_\Sigma c:\tau(c)},\mbox{ for }c\in C\quad(\mbox{const}), \quad\frac{}{x:A\vdash_\Sigma x:A}\quad(\mbox{var}),$$ $$\frac{\Gamma\vdash_\Sigma s:A\quad\Delta\vdash_\Sigma t:A\multimap B}{\Gamma,\Delta\vdash_\Sigma (ts):B}\quad(\mbox{app}), \quad\frac{\Gamma,x:A,\Delta\vdash_\Sigma t:B}{\Gamma,\Delta\vdash_\Sigma (\lambda x.t):A\multimap B}\quad(\mbox{abstr}).$$ We say that a term $t$ is {\it typeable} in $\Sigma$ if there is a type $A$ such that $\vdash_\Sigma t:A$. In this case we say that $A$ is the {\it type of $t$ in $\Sigma$}. \subsubsection{Semantics} Let ${\bf C}$ be a symmetric monoidal category, and $\Sigma=(N,C,\tau)$ a signature. An interpretation of signature $\Sigma$ types in ${\bf C}$ consists in assigning to each atomic type $A\in N$ an object $[A]\in{\bf C}$. This is extended to all types in $Tp(N)$ by the obvious induction: $$[A\multimap B]=[A]\multimap [B].$$ In the following we omit square brackets and denote a type $A\in Tp(N)$ and its interpretation the same. An interpretation of $\Sigma$ in ${\bf C}$ consists of an interpretation of types and a function $c\mapsto[c]$ assigning to each constant $c\in C$ a morphism $$[c]:{\bf 1}\to \tau(c).$$ The interpretation extends to all typeable terms and derivable typing judgements. To each derivable typing judgement $\sigma$ of the form $$x_1:A_1,\ldots,x_n;A_m\vdash_\Sigma A$$ we assign a ${\bf C}$-morphism $$[\sigma]: A_1\otimes\ldots\otimes A_n\to A,$$ if $n>0$, or $$[\sigma]:{\bf 1}\to A,$$ if $n=0$, by induction on type inference rules. If the judgement $\sigma$ is $\vdash_\Sigma c:\tau(c)$ obtained by the (const) rule, then $[\sigma]=[c]$. If $\sigma$ is $x:A\vdash_\Sigma x:A$ obtained by the (var) rule, then $[\sigma]=\id_{A}$. If $\sigma$ is obtained from a derivable judgement $\sigma'$ by the (abstr) rule, then $[\sigma]$ is obtained from $[\sigma']$ using symmetry and correspondence (\ref{monoidal closure}). If $\sigma$ is obtained from derivable judgements $$\sigma_1=\Gamma_1\vdash_\Sigma s:A,\quad \sigma_2=\Gamma_2\vdash_\Sigma t:A\multimap B$$ by the (app) rule, then $$[\sigma]=\ev_{A,B}\circ([\sigma_1]\otimes[\sigma_2]).$$ Finally, for a typeable term $t$ of type $A$ we have a derivable typing judgement $\vdash_\Sigma t:A$, and we put $[t]=[\sigma]$. \bl\cite{HylandDePaiva} With notation as above we have: \begin{itemize} \item if typeable terms $t,s$ are $\beta\eta$-equivalent, then $[t]=[s]$; \item if $\vdash_\Sigma s:A$, $\vdash_\Sigma t:A\multimap B$, then $[ts]=[t]\cdot[s]$. \end{itemize} \el {\bf Proof} Exercise or see \cite{HylandDePaiva}. $\Box$ \subsubsection{String signature} Let $T$ be a finite alphabet. The {\it string signature} $Str_T$ {\it over} $T$ has a single atomic type $O$, the alphabet $T$ as the set of constants and a typing assignment $$\tau(c)=O\multimap O\mbox{ }\forall c\in T.$$ We denote the type $O\multimap O$ as $str$. Terms typeable in $Str_T$ with the type $str$ are called {\it string terms}. Any word $a_1\ldots a_n$ in the alphabet $T$ can be represented as the string term $$/a_1\ldots a_n/=(\lambda x.a_1(\ldots(a_n(x))\ldots)).$$ It is not hard to see that, if we identify $\beta\eta$-equivalent terms, the map $w\mapsto/w/$ has an inverse. \nb Any $\beta$-normal term $t$ typeable in $Str_T$ with the type $str$ is $\beta\eta$-equivalent to the term $/w/$ for some $w\in T^*$. \nbe {\bf Proof} \begin{enumerate}[(i)] \item There is no typeable term of type $O$ (for example, because any derivable typing judgement has an even number of $O$ occurrences). \item Using (i), we prove by induction on type inference that any $\beta$-normal term $t$ typeable in $Str_T$ is either a constant $t\in T$, or an abstraction, $t=(\lambda x.t')$ for some variable $x$ and term $t'$. \item Using (ii), we prove by induction on type inference that for any derivable typing judgement $x:O\vdash_{Str_T}t:O$, where $t$ is a $\beta$-normal term, it holds that $t=c_1(\ldots(c_n(t))\ldots)$ for some constants $c_1,\ldots,c_n\in T$. \end{enumerate} Now if $\vdash_{Str_T}t:O\multimap O $, then either $t$ is a constant, hence $\beta\eta$-equivalent to $/t/$, or its typing was obtained by the (abstr) rule. In the latter case the claim follows from (iii). $\Box$ \smallskip Thus we have a map from typeable string terms to words over $T$. It turns out that this map extends to all typeable terms as a map to cowordisms. Let us choose an interpretation of the atomic type $O$ as a one-point boundary $$\d O=\d_lO\cup\d_rO$$ with $|\d_rO|=1$, $\d_lO=\emptyset$. By induction this gives us an interpretation $A\mapsto\d A$ of all types in $Tp(O)$ as boundaries. We extend this to an interpretation of the string signature in the category ${\bf Types}_T$ by defining the cowordism type $O$ on the boundary $\d O$ as the empty set. Any regular cowordism $\sigma:\d O\to \d O$ which is a morphism of types $\sigma:O\to O$, is a graph consisting of a single edge labeled with some word $w\in T^*$. We denote this cowordism as $graph(w)$. We interpret each constant $c\in T$ as the corresponding regular cowordism $graph(c):O\to O$. This gives us an interpretation of the signature $Str_T$. We denote the interpretation of a typeable term $t\in\Lambda(X,C)$ as $graph(t)$. Note that for any word $w\in T^*$ we have $graph(/w/)=graph(w)$. We call an interpretation of the above form a {\it standard interpretation of the string signature}. \subsection{Abstract categorial grammars} Given two signatures $\Sigma_i=(N_i,C_i,\tau_i)$, $i=1,2$, a {\it map of signatures} $$\phi:\Sigma_1\to\Sigma_2$$ is a pair $\phi=(F,G)$, where \begin{itemize} \item $F:Tp(\Sigma_1)\to Tp(\Sigma_2)$ is a function satisfying the homomorphism property $$F(A\multimap B)=F(A)\multimap F(B),$$ \item $G:C_1\to\Lambda(X,C_2)$ is a function such that for any $c\in C_1$ it holds that $\vdash_{\Sigma_2}G(c):F(\tau(c))$. \end{itemize} The map $G$ above extends inductively to a map $$G:\Lambda(X,C_1)\to\Lambda(X,C_1)$$ by $$G(x)=x,\mbox{ }x\in X,$$ $$G(ts)=(G(t)G(s)),\quad G(\lambda x.t)=(\lambda x.G(t)).$$ For economy of notation, we write $\phi(A)$ for $F(A)$ when $A\in Tp(C_1)$, and we write $\phi(t)$ for $G(t)$ when $t\in\Lambda(X,C_1)$. \bd A {\bf string abstract categorial grammar (string ACG)} $G$ is a tuple $G=(\Sigma,T, \phi,S)$, where \begin{itemize} \item $\Sigma$, is a signature; \item $T$ is a finite alphabet \item $\phi:\Sigma\to Str_T$, the {\bf lexicon}, is a map of signatures; \item $S$, {\bf the standard type}, is an atomic type of $\Sigma$, such that $\phi(S)=str$. \end{itemize} \ed The {\it string language $L(G) $ generated by $G$} is the set of words over $T$ given by $$ L(G)=\{w\in T^*|\mbox{ }\exists t\mbox{ }\vdash_\Sigma t:S\mbox{ and }\phi(t)=/w/\}. $$ Equivalently $$ L(G)=\{w\in T^*|\mbox{ }\exists t\mbox{ }\vdash_\Sigma t:S\mbox{ and }graph(t)=graph(w)\}. $$ \subsection{Encoding} Let $G=(\Sigma,T, \phi,S)$ be a string ACG. Choose some standard interpretation of $Str_T$ in ${\bf Types}_T$. This yields us an interpretation of the signature $\Sigma$ defined as follows. To any type $A\in Tp(\Sigma)$ we assign the boundary $$\d A=\d(\phi(A))$$ and the cowordism type $A\in {\bf Types}_T$ given by $$A=\{graph(\phi(t))|\mbox{ }\vdash_\Sigma t:A\}.$$ To any term $t$ typeable in $\Sigma$ we assign the cowordism $$graph(t)=graph(\phi(t)).$$ It is immediate from definitions that the interpretation is sound, i.e. we have the following. \nb\label{soundeness of ACG encoding} If $\vdash_\Sigma t:A$ then $graph(t)\in A$. $\Box$ \nbe \smallskip Now treating the set of atomic types of $\Sigma$ as literals and types of $\Sigma$ as ${\bf LL}$ formulas we construct an LLG $G'$ encoding $G$. Let $N$, $C$ be the sets of, respectively, atomic types and constants of $\Sigma$. We already have the assignment $A\mapsto\d A$ of elements of $N$ to boundaries. We define the set of axioms $$Lex=\{graph(c):\tau(c)|\mbox{ }c\in C\}.$$ The LLG $G'$ is defined as $G'=(N,T,Lex,S)$. Now, by induction on type inference rules using Note \ref{soundeness of ACG encoding} we prove that the language $L(G)$ generated by $G$ is a subset of language of $G'$. Proof of the opposite inclusion repeats the argument in Section \ref{encoding MCFG} where we consider encoding of MCFG. We consider the category ${\bf CTypes}_{L(G)}$ of closed types of $L(G)$ and observe that any cowordism type $A$ of $G'$ is a subset of the corresponding closed type of ${\bf CTypes}_{L(G)}$. We summarise. \bt\label{encoding ACG} If a language is generated by a string ACG then it is also generated by an LLG. $\Box$ \et \smallskip It seems an interesting question whether the converse is true or not. \smallskip {\bf Remark} Since MCFG embed into string ACG \cite{deGrootePogodalla}, Theorem \ref{encoding ACG} on encoding ACG in LLG grammars implies that MCFG embed into LLG. However it does not imply the converse statement (Theorem \ref{tens. free lex is MCFG}, that any $\otimes$-free lexicon gives rise to an MCFG). On the other hand it is not hard to see that Theorem \ref{tens. free lex is MCFG} together with Theorem \ref{encoding ACG} do imply the known result \cite{Salvati} that any second order string ACG generates a multiple context-free language. Thus we gave another, more ``category-theoretic'' proof of this result. \section{Encoding backpack problem} It is known that ACG, in general, can generate NP-complete languages. In view of Theorem \ref{encoding ACG} it is no wonder that LLG can generate NP-complete languages as well. In this last section we show how an LLG can generate solutions of the backpack problem. Our purpose here is mainly illustrative. We try to convince the reader that the geometric language of cowordisms is indeed intuitive and convenient for analysing language generation. We consider backpack problem in the form of the {\it subset sum problem}. \bd {\bf Subset sum problem (SSP)}: Given a finite sequence $s$ of integers, determine if there is a subsequence $s'\subseteq s$ such that $\sum\limits_{z\in s}z=0$. \ed SSP is known to be NP-complete, see \cite{Martello}. We now define a language representing solutions of SSP. We represent integers as words in the alphabet $\{+,-\}$, we call them {\it numerals}. An integer $z$ is represented (non-uniquely) as a word for which the difference of $+$ and $-$ occurrences equals $z$. We say that a numeral is {\it irreducible}, if it consists only of pluses or only of minuses. We represent finite sequences of integers as words in the alphabet $T=\{+,-,\bullet\}$, with $\bullet$ interpreted as a separation sign. Thus a word in this alphabet should be read as a list of numerals separated by bullets. When all numerals in the list are irreducible, we say that the list is irreducible. Note that any sequence of integers has unique representation as an irreducible list. We now construct a system of cowordisms over $T$ which (together with symmetry transformations) generates solutions of SSP. We will use four atomic boundaries $E,P,H,S$, each of them having one point in the left boundary and one point in the right boundary. First we construct a system which generates lists of numerals representing sequences that sum to zero. We define four cowordisms $$cons:S\otimes S\to S,\quad open:H\to S$$ $$ push:H\otimes H\to H\otimes H,\quad close:{\bf 1}\to H$$ in the graphical language as follows. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) to [out=0,in=90] (2.5,-0.5) to [out=-90,in=180] (3,-0.75); \draw[thick,<-](0,-0.5) to [out=0,in=90] (2,-1) to [out=-90,in=0] (0,-1.5); \draw[thick,<-](0,-2.)to [out=0,in=-90](2.5,-1.5) to [out=90,in=-180] (3,-1.25); \node[above left] at (0,-0.5) {$S$}; \node[above left] at (0,-2) {$S$}; \node[above right] at (3,-1.25) {$S$}; \node[above left] at (0,-1.25) {$\otimes$}; \node[above left] at(-1,-1.25) {$cons:$} }$$ $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (1,0); \draw[thick,<-](0,-0.5) -- (1,-0.5); \node[above right] at (1,-.5) {$S$}; \node[above left] at (0,-.5) {$H$}; \node[above left] at(-1,-.5) {$open:$}; }$$ $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (1,0); \draw[thick,<-](0,-0.5) -- (1,-0.5); \node[above right] at (1,-.5) {$H$}; \node[above left] at (0,-.5) {$H$}; \node[above] at (0.5,0) {$+$}; \draw[thick,->](0,-1.5) -- (1,-1.5); \draw[thick,<-](0,-2.) -- (1,-2.); \node[above right] at (1,-2) {$H$}; \node[above left] at (0,-2) {$H$}; \node[above] at (0.5,-1.5) {$-$}; \node[above right] at (1,-1.25) {$\otimes$}; \node[above left] at (0,-1.25) {$\otimes$}; \node[above left] at(-1,-1.25) {$push:$}; }$$ $$ \tikz[xscale=.7]{ \node[above] at (0.6,0) {$\bullet$}; \draw[thick,<-](1,0) to [out=-180,in=90] (0,-0.25) to [out=-90,in=-180] (1,-.5); \node[above right] at (1,-.5) {$H$}; \node[above left] at(-1,-.5) {$close:$}; }$$ The cowordism $cons$, by iterated compositions with itself, generates lists with arbitrary many empty slots. Then the cowordism $open$ converts them into slots that can be filled with pluses and minuses. Then $push$ fill the slots (always in pairs), and $close$ closes them. It is easy to see that all cowordisms from ${\bf 1}$ to $S$ generated by the above system (together with symmetry transformations) represent sequences of integers summing to zero, and vice versa, for any sequence summing to zero, its irreducible list representation is generated by the above. Now, in order to generate solutions of SSP we need some extra ``deceptive'' slots, which contain elements not summing to zero. These slots will be represented by the boundary $P$. We define cowordisms $$open_P:P\otimes S\to S,\quad close_P:{\bf 1}\to P,$$ $$\quad push_+:P\to P,\quad push_-:P\to P$$ as follows. $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) to [out=0,in=90] (2.5,-0.5) to [out=-90,in=180] (3,-0.75); \draw[thick,<-](0,-0.5) to [out=0,in=90] (2,-1) to [out=-90,in=0] (0,-1.5); \draw[thick,<-](0,-2.)to [out=0,in=-90](2.5,-1.5) to [out=90,in=-180] (3,-1.25); \node[above left] at (0,-0.5) {$P$}; \node[above left] at (0,-2) {$S$}; \node[above right] at (3,-1.25) {$S$}; \node[above left] at (0,-1.25) {$\otimes$}; \node[above left] at(-1,-1.25) {$open_P:$} }$$ $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (1,0); \draw[thick,<-](0,-0.5) -- (1,-0.5); \node[above right] at (1,-.5) {$P$}; \node[above left] at (0,-.5) {$P$}; \node[above] at (0.5,0) {$+$}; \node[above left] at(-1,-.5) {$push_+:$} }$$ $$ \tikz[xscale=.7]{ \draw[thick,->](0,0) -- (1,0); \draw[thick,<-](0,-0.5) -- (1,-0.5); \node[above right] at (1,-.5) {$P$}; \node[above left] at (0,-.5) {$P$}; \node[above] at (0.5,0) {$-$}; \node[above left] at(-1,-.5) {$push_-:$}; }$$ $$ \tikz[xscale=.7]{ \node[above] at (0.6,0) {$\bullet$}; \draw[thick,<-](1,0) to [out=-180,in=90] (0,-0.25) to [out=-90,in=-180] (1,-.5); \node[above right] at (1,-.5) {$P$}; \node[above left] at(-1,-.5) {$close_P:$}; }$$ The cowordism $open_P$ adds deceptive slots to the list, $push_-$ and $push_+$ fill them with arbitrary numerals, and $close_P$ closes them. Let us denote the set of cowordisms from ${\bf 1}$ to $S$ generated by the above system and symmetry as $L_0$. It is easy to see that $L_0$ membership problem is essentially equivalent SSP. In particular, a sequence $s$ of integers is a solution of SSP iff the corresponding irreducible list is in $L_0$. It follows that $L_0$ is NP-hard. It is also easy to show that $L_0$ membership problem is itself in NP, hence $L_0$ is, in fact, NP-complete. Finally, observe that if we define an LLG $G$ by a lexicon consisting of names of the above cowordisms, then $G$ will generate $L_0$. This is a technical and not difficult exercise in multiplicative linear logic proof-search.
{'timestamp': '2019-02-12T02:10:25', 'yymm': '1810', 'arxiv_id': '1810.02047', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02047'}
arxiv
\section{Experimental Details} All network architectures we use are standard architectures for the datasets of choice. All student/teacher pairs were of the same architecture type (e.g., ResNet to ResNet). For each dataset, we detail the architecture and hyperparameters used. All experiments were performed in PyTorch v0.4.0 with Python 3.5. Experiments were run on public cloud and custom servers using NVIDIA P100, V100, Titan Xp, and Titan V GPUs. All weights for architectures were initialized as in the original architecture. \subsection{CIFAR10/100} We used the same hyperparameters for CIFAR10 and CIFAR100. \minihead{ResNet} We use standard ResNets~\citep{he2016deep} for CIFAR10/100~\citep{krizhevsky2009learning,}. The architectures are parameterized by the number of ``computation heavy" layers, i.e., convolutional and fully connected layers, but not batch norm and ReLU layers. Thus, a ResNet-110 has 110 convolutional and fully connected layers. Each ResNet has three blocks, where the convolutional layers in each block have the same number of filters. The last convolutional layer in each block downsamples by a factor of two. The ResNets can be parameterized by the number of residual blocks in each block, where each residual block has two convolutional layers. This parameterization is the same parameterizing by the number of layers. For example, an [18, 18, 18] has 110 layers total, 108 layers in the blocks, along with an additional convolutional layer at the start and a fully connected layer. We show a table of the number of layers and block parameterizations in Table~\ref{table:resnet-types}. \begin{table} \centering \setlength\itemsep{2em} \begin{tabular}{ll} Model & Parameterization \\ \hline ResNe(X)t-20 & [3, 3, 3] \\ ResNe(X)t-32 & [5, 5, 5] \\ ResNe(X)t-44 & [7, 7, 7] \\ ResNe(X)t-56 & [9, 9, 9] \\ ResNe(X)t-110 & [18, 18, 18] \end{tabular} \caption{ResNet and ResNeXt types for CIFAR10/100.} \label{table:resnet-types} \end{table} For all experiments, we used a batch size of 32, SGD with a momentum of 0.9, and weight decay of 1e-4. For training from scratch, we trained with a starting learning rate of 0.1 for 200 epochs with milestones at 100 and 150 epochs, decaying the learning rate by a factor of 10. For KD, we trained with a starting learning rate of 0.1 for 250 epochs with milestones at 100 and 175 epochs, decaying the learning rate by a factor of 10. We used $\tau = 6$ and $\alpha = 0.95$. For LIT, we trained with a starting learning rate of 0.1 for 175 epochs with milestones at 60, 100, and 125 epochs, decaying the learning rate by a factor of 10. We then fine-tuned using the KD loss for another 75 epochs with a starting learning rate of 0.01 and milestones at 35 and 55 epochs. We used $\beta = 0.75$. \minihead{ResNeXt} We use standard ResNeXts~\citep{xie2017aggregated} for CIFAR10/100. The parameterization in terms of number of layers are the same for ResNet. ResNeXt has an additional parameter of the group cardinality. We use a group cardinality of 32 for all experiments, except the ones detailed below. For all experiments, we used a batch size of 32, SGD with a momentum of 0.9, and weight decay of 1e-4. For training from scratch, we trained with a starting learning rate of 0.1 for 300 epochs with milestones at 150 and 225 epochs, decaying the learning rate by a factor of 10. For KD, we trained with a starting learning rate of 0.1 for 300 epochs with milestones at 100, 175, and 225 epochs, decaying the learning rate by a factor of 10. We used $\tau = 6$ and $\alpha = 0.95$. For LIT, we trained with a starting learning rate of 0.1 for 200 epochs with milestones at 100, 145, and 175 epochs, decaying the learning rate by a factor of 10. We then fine-tuned using the KD loss for another 125 epochs with a starting learning rate of 0.01 and milestones at 65, 95, and 110 epochs. We used $\beta = 0.5$. \minihead{Reduced cardinality ResNeXt} All hyperparameters were the same as the standard ResNeXt experiments except we used $\beta = 0.25$ and a student cardinality of 16. \subsection{Amazon Reviews} We use standard VDCNNs~\citep{conneau2016very} for Amazon Reviews full and polarity~\citep{he2016ups}. VDCNN has an initial convolutional layer and four blocks of convolutional layers (each block has the same number, but vary between types of VDCNNs). Thus, a VDCNN-9 has an initial convolutional layer and two convolutional layers in each subsequent block. We consider VDCNN-9, VDCNN-17, and VDCNN-29 as in~\cite{conneau2016very}. For all experiments, we used a batch size of 128, SGD with a momentum of 0.9, and weight decay of 1e-4. For training from scratch, we trained with a starting learning rate of 0.01 for 15 epochs, with milestones at 3, 6, 9, 12, and 15 epochs, decaying the learning rate by a factor of 10. For KD, we trained with a starting learning rate of 0.01 for 18 epochs, with milestones at 3, 6, 9, 12, and 15 epochs, decaying the learning rate by a factor of 10. We used $\tau = 6$ and $\alpha = 0.98$. For LIT, we trained with a starting learning rate of 0.01 for 15 epochs, with milestones at 3, 6, 9, and 12 epochs, decaying the learning rate by a factor of 2. We then fine-tuned using the KD loss for another 10 epochs with a starting learning rate of 0.000625 and milestones at 4 and 8 epochs. We used $\beta = 0.02$. \subsection{StarGAN} We used the StarGAN as described in~\cite{choi2017stargan}. The original StarGAN has 18 total convolutional layers (including transposed convolutional layers), with 12 of the layers in the residual blocks (each residual block has two convolutional layers). We compressed the six residual blocks to two residual blocks. For all experiments, we used a batch size of 16, SGD with a momentum of 0.9, and weight decay of 1e-4. For training from scratch, we trained with a starting learning rate of 0.0001 for 20 epochs. The learning rate was decayed to 0 over the last 10 epochs. As KD does not apply, we did not run KD. For LIT, we trained with a starting learning rate of 0.0001 for 16 epochs, decaying the learning rate by 10 at epoch 8 (only the IR loss was used). We then fine-tuned with the discriminator with a starting learning rate of 0.00005 for 10 epochs, decaying the learning rate by 10 at epoch 5. \begin{figure}[t!] \centering \begin{subfigure}{0.32\columnwidth} \includegraphics[width=0.99\columnwidth]{figures/stargan/teacher-6-1.png} \caption{Teacher (18 layers)} \end{subfigure} \begin{subfigure}{0.32\columnwidth} \includegraphics[width=0.99\columnwidth]{figures/stargan/student-2-1.png} \caption{Student (10 layers)} \end{subfigure} \begin{subfigure}{0.32\columnwidth} \includegraphics[width=0.99\columnwidth]{figures/stargan/scratch-2-1.png} \caption{Trained from scratch (10 layers)} \end{subfigure} \caption{Randomly selected images from the teacher (six residual blocks, 18 total layers), student (two residual blocks, 10 total layers), and trained from scratch (two residual blocks, 10 total layers) StarGANs. As shown, LIT can appear to improve GAN performance while significantly compressing models. The columns are: Original, Black Hair, Blond Hair, Brown Hair, Male, Age.} \label{fig:stargan-many} \end{figure} \section{StarGAN images} We show a randomly selected set of images generated from the StarGAN teacher, student, and trained from scratch generators in Figure~\ref{fig:stargan-many}. \end{appendix} \section{Conclusion} We introduce LIT, a novel model compression technique that trains a student model from a teacher model's intermediate representations. LIT requires at least one intermediate layer of the student and teacher to match in width, which allows parts of the teacher model to be copied to the student model. By combining several such intermediate layers, LIT students learn a high quality representation of the teacher state without the associated depth. To overcome the lack of useful intermediate representations within the student model at the beginning of training, LIT uses the teacher's intermediate representations as input to the student model during training. We show that LIT can compress models up to 5.5$\times$ with no loss in accuracy on standard classification benchmark tasks, outperforming standard KD and hint training. We also show that LIT can compress StarGAN's generator, which is, to our knowledge, the first time a student/teacher training technique has been used to compress a GAN's generator. \section{Experiments} \label{sec:experiments} We evaluate LIT's efficacy at compressing models on a range of tasks and models, including image classification, sentiment analysis, and image-to-image translation (GAN). Throughout, we use student and teacher networks with the same broad architecture (e.g., ResNet to ResNet). We consider ResNet~\citep{he2016deep}, ResNeXt~\citep{xie2017aggregated}, VDCNN~\citep{conneau2016very}, and StarGAN~\citep{choi2017stargan}. We use standard architecture depths, widths, and learning rate schedules, and perform hyperparameter selection for the KD and LIT interpolation parameters, while also performing a sensitivity analysis of these hyperparameters in the sequel. \subsection{LIT significantly compresses models} \begin{table}[t!] \centering \small \setlength\itemsep{2em} \begin{tabular}{lll} Dataset & Task & Models \\ \hline CIFAR10 & Image classification & ResNet, ResNeXt \\ CIFAR100 & Image classification & ResNet, ResNeXt \\ Amazon Reviews & Sentiment analysis (full, polarity) & VDCNN \end{tabular} \vspace{-0.5em} \caption{List of datasets, tasks, and models for standard classification tasks we compress with LIT. We additionally compress StarGAN on CelebA.} \label{table:dataset-model} \vspace{-0.5em} \end{table} \minihead{LIT is effective at compressing a range of datasets and models} We ran LIT on a variety of models and datasets for image classification and sentiment analysis (Table~\ref{table:dataset-model}). We additionally performed KD and hint training on these datasets and models. We selected the hyperparameters sequentially (Section~\ref{sec:methods}). Figure~\ref{fig:cifar10} shows the results for ResNet and ResNeXt for CIFAR10 and CIFAR100, and Figure~\ref{fig:vdcnn} shows the results for VDCNN on Amazon Reviews (full, polarity). LIT can compress models by up to 5.5$\times$ (CIFAR10, ResNeXt 110 to 20) on image classification and up to 3.2$\times$ on sentiment analysis (Amazon Reviews, VDCNN 29 to 9), with no loss in accuracy. LIT outperforms KD and hint training on all settings, resulting in up to 5.5$\times$ smaller models with no loss in accuracy (CIFAR10, ResNeXt-110 vs ResNeXt-20). Additionally, LIT outperforms the recently proposed Born Again procedure in which the same architecture is used as both the student and teacher model~\citep{furlanello2018born} (i.e., only for improved accuracy, not for compression). We have found that, in some cases, training sequences of models using LIT results in higher performance. Thus, for VDCNN, we additionally compressed using LIT a VDCNN-29 to a VDCNN-17, and using this VDCNN-17, we trained a VDCNN-9 and VDCNN-17. Importantly, LIT can retain the same architectural patterns for both the student and teacher model and does not require that models be deeper and thinner as in FitNets~\citep{romero2014fitnets}. We also found that in some cases, KD degrades the accuracy of student models when the teacher model is the same architecture (ResNeXt-110 on CIFAR100, VDCNN-29 on Amazon Reviews polarity). This corroborates prior observations in~\cite{mishra2017apprentice}. \begin{figure}[t!] \centering \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-cifar10-resnet.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNet, end-to-end accuracy} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-cifar10-resnext.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNeXt, end-to-end accuracy} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-cifar100-resnet.pdf} \vspace{-0.5em} \caption{CIFAR100, ResNet, end-to-end accuracy} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-cifar100-resnext.pdf} \vspace{-0.5em} \caption{CIFAR100, ResNeXt, end-to-end accuracy} \end{subfigure} \vspace{-0.5em} \caption{The accuracy of ResNet and ResNeXt trained from scratch, trained via KD, and trained via LIT for CIFAR10/100. The teacher model was ResNet-110 and ResNeXt-110 respectively. As shown, LIT outperforms KD for every student model. The student architecture being the same as the parent architecture corresponds to born again networks, which LIT also outperforms. In some cases, KD can reduce the accuracy of the student model, as reported in~\cite{mishra2017apprentice}.} \label{fig:cifar10} \vspace{-0.5em} \end{figure} \begin{figure}[t!] \centering \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-vdcnn-full.pdf} \vspace{-0.5em} \caption{Amazon full, VDCNN, end-to-end accuracy} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/fu-vdcnn-polarity.pdf} \vspace{-0.5em} \caption{Amazon polarity, VDCNN, end-to-end accuracy} \end{subfigure} \vspace{-0.5em} \caption{The accuracy of VDCNN on Amazon reviews (full and polarity) trained from scratch, trained via KD, and trained via LIT.} \label{fig:vdcnn} \vspace{-0.5em} \end{figure} \minihead{LIT can reduce group cardinality} While LIT requires the size of at least one IR to be the same width between the teacher and student model, several classes of models have an internal width or group \emph{cardinality}. For example, ResNeXt~\citep{xie2017aggregated} has a ``grouped convolution", which is equivalent to several convolutions with the same input (see Figure $3$ in~\cite{xie2017aggregated}). The width of the network is not affected by the group size, so LIT is oblivious to the group size. We show that LIT can reduce the group cardinality for ResNeXt. We train student ResNeXts with cardinality 16 (instead of the default 32) from a ResNeXt-110 (cardinality 32). Figure~\ref{fig:cifar10-resnext-card} illustrates the results. As before, LIT outperforms KD and training from scratch in this setting. \begin{figure}[t!] \centering \includegraphics{figures/cifar10-resnext-card.pdf} \vspace{-0.5em} \caption{ResNeXt student models with cardinality 16 trained from a ResNeXt-110 with cardinality 32. We show that LIT can reduce the cardinality and that LIT outperforms KD.} \label{fig:cifar10-resnext-card} \vspace{-0.5em} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=0.9\columnwidth]{figures/stargan/stargan-selected.pdf} \vspace{-0.5em} \caption{Selected images from the teacher (six residual blocks), student (two residual blocks), and trained from scratch (two residual blocks) StarGANs. As shown (column two, four), LIT can appear to improve GAN performance while significantly compressing models. We show a randomly selected set of images in the Appendix. Best viewed in color.} \label{fig:stargan} \vspace{-0.5em} \end{figure} \minihead{LIT can compress GANs} To the best of our knowledge, LIT is the first student/teacher method to compress a GAN's generator, as KD is not applicable to the pixels (i.e., not probabilities) that GAN generators output. \begin{table}[t!] \centering \small \setlength\itemsep{2em} \begin{tabular}{lcc} Model & Inception score (higher is better) & FID score (lower is better) \\ \hline Teacher (18 layers) & 3.49 & 6.43\\ LIT student (10 layers) & \textbf{3.56} & \textbf{5.84} \\ Trained from scratch (10 layers) & 3.37 & 6.56 \\ Randomly initialized (10 layers) & 2.63 & 94.00 \\ Randomly initialized (18 layers) & 2.45 & 151.43 \end{tabular} \vspace{-0.5em} \caption{Inception and FID scores for different versions of StarGAN. Despite having fewer layers than the teacher, the LIT student model achieves the best scores.} \label{table:inception-score} \end{table} We compressed StarGAN's generator~\citep{choi2017stargan} using the LIT procedure with $\beta = 0$ (i.e., only using the intermediate representation loss). The original StarGAN has 18 total convolutional layers (including transposed convolutional layers), with 12 of the layers in the residual blocks (for a total of six residual blocks). We compressed the six residual blocks to two residual blocks (i.e., 12 to four layers) while keeping the rest of the layers fixed. The remaining layers for the teacher model were copied to the student model and fine-tuned. The discriminator remained fixed. As shown in Table~\ref{table:inception-score}, LIT outperforms all baselines in inception and FID score. Additionally, as shown in Figure~\ref{fig:stargan}, the student model appears to perceptually outperform both the teacher model and equivalent model trained from scratch, suggesting LIT can both compress GANs and serve as a form of regularization. \subsection{Impact of Training Techniques} \label{sec:eval-training} \begin{table}[t!] \centering \small \setlength\itemsep{2em} \begin{tabular}{ll} Type & Accuracy \\ \hline LIT & \textbf{93.25\%} \\ KD & 92.75\% \\ One IR, teacher input & 92.74\% \\ One IR, no teacher input (FitNets) & 92.68\% \\ Multiple IRs, no teacher input & 90.42\% \\ \end{tabular} \begin{tabular}{ll} Type & Accuracy \\ \hline LIT & \textbf{94.72\%} \\ KD & 94.42\% \\ One IR, teacher input & 94.21\% \\ One IR, no teacher input (FitNets) & 94.18\% \\ Multiple IRs, no teacher input & 91.27\% \end{tabular} \vspace{-0.5em} \caption{Ablation study of LIT. We performed LIT, KD, and three modifications of LIT. As shown, LIT outperforms KD and the modifications, while all the modifications underperform standard KD. \textbf{Left:} ResNet, \textbf{Right:} ResNeXt.} \label{table:ablation-ir} \vspace{-0.7em} \end{table} LIT uses block-wise training with the teacher IRs as input to the student model. To show the effectiveness of block-wise training, we tried other variations: 1) matching a single IR, with no input from the teacher (i.e., standard hint training/FitNets), 2) a single IR with teacher input, 3) multiple IRs with no teacher input. We performed these variations on a teacher model of ResNet-110 and a student model of ResNet-20 on CIFAR10 and similarly for ResNeXt. As shown in Table~\ref{table:ablation-ir}, none of the three variants are as effective as LIT or KD. Thus, we see that LIT's block-wise training is critical for high accuracy compression. \subsection{LIT is complementary to pruning} Pruning is a key technique in deep compression in which parts of a network are set to zero, which reduces the number of weights and, on specialized hardware, reduces the computational footprint of networks. To see if LIT models are amenable to pruning, we pruned ResNets trained via LIT. We additionally pruned ResNets trained from scratch. \begin{figure}[t!] \centering \includegraphics{figures/compression/comp-cifar10-resnet.pdf} \vspace{-0.5em} \caption{The size vs accuracy of various ResNets pruned on CIFAR10. LIT is pareto optimal for model size and accuracy.} \label{fig:compression} \vspace{-0.7em} \end{figure} As shown in Figure~\ref{fig:compression}, LIT models are pareto optimal in accuracy vs model size. Additionally, LIT models can be pruned, although less than their trained-from-scratch counterparts. However, LIT models are more accurate and are thus likely learning more meaningful representations. Thus, we expect LIT models to be more difficult to prune, as each weight is more important. \subsection{Sensitivity Analysis of Hyperparameters} \label{sec:hyperparameters} \begin{table}[t!] \centering \small \setlength\itemsep{2em} \begin{tabular}{lcc} Model & Loss & Accuracy \\ \hline ResNet & L2 & $93.20 \pm 0.04$ \\ ResNet & L1 & $93.19 \pm 0.05$ \\ ResNet & Smoothed L1 & $93.02 \pm 0.06$ \end{tabular} \quad \begin{tabular}{lcc} Model & Loss & Accuracy \\ \hline ResNeXt & L2 & $94.63 \pm 0.07$ \\ ResNeXt & L1 & $94.62 \pm 0.07$ \\ ResNeXt & Smoothed L1 & $93.86 \pm 0.08$ \end{tabular} \vspace{-0.5em} \caption{Effect of intermediate representation loss on student model accuracy. L2 and L1 do not significantly differ, but smoothed L1 degrades accuracy. Average of three runs.} \label{table:penalty} \vspace{-0.7em} \end{table} \minihead{Intermediate loss penalty} To see the affect of the intermediate loss penalty, we performed LIT from a teacher model of ResNet-110 to a student of ResNet-20 with the L1, L2, and smoothed L1 loss. The results are shown in Table~\ref{table:penalty}. As shown, L2 and L1 do not significantly differ, but smoothed L1 degrades accuracy. \begin{figure}[t!] \centering \begin{subfigure}{.49\columnwidth} \includegraphics{figures/alpha-cifar10-resnet.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNet, $\alpha$ sensitivity} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/alpha-cifar10-resnext.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNeXt, $\alpha$ sensitivity} \end{subfigure} \vspace{-0.5em} \caption{The accuracy of student models as $\alpha$ (KD's interpolation factor for the cross-entropy and logit loss) varies for ResNet and ResNeXt on CIFAR10. The optimal $\alpha$ varies by model type.} \label{fig:alpha-cifar10} \vspace{-0.7em} \end{figure} \begin{figure}[t!] \centering \begin{subfigure}{.49\columnwidth} \includegraphics{figures/beta-cifar10-resnet.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNet, $\beta$ sensitivity} \end{subfigure} \begin{subfigure}{.49\columnwidth} \includegraphics{figures/beta-cifar10-resnext.pdf} \vspace{-0.5em} \caption{CIFAR10, ResNeXt, $\beta$ sensitivity} \end{subfigure} \vspace{-0.5em} \caption{The accuracy of student models as $\beta$ (LIT's interpolation factor between KD loss and IR loss) varies for ResNet and ResNeXt on CIFAR10. As shown, LIT outperforms training only via KD ($\beta = 1$) and only via intermediate representations ($\beta = 0$). The optimal $\beta$ appears to be lower (i.e., closer to only using the intermediate representation loss) for more accurate models; we hypothesize that more accurate models learn more informative intermediate representations, which helps the students learn better.} \label{fig:beta-cifar10} \vspace{-0.7em} \end{figure} \minihead{$\alpha$ and $\beta$} Recall that $\alpha$ is the weighting parameter in KD and $\beta$ is the relative weight of KD vs the intermediate representation loss (Section~\ref{sec:methods}). To see the effect of of $\alpha$ (which is a KD hyperparameter), we varied $\alpha$ between 0 and 1 for ResNet and ResNeXt on CIFAR10 and CIFAR100. As shown in Figure~\ref{fig:alpha-cifar10}, $\alpha$ can significantly affect accuracy. Thus, we searched for $\alpha$ as opposed to using a static policy of 0.5 as in~\cite{hinton2015distilling}. We additionally varied $\beta$ between 0 and 1 for ResNet and ResNeXt on CIFAR10. As shown in Figure~\ref{fig:beta-cifar10}, the optimal $\beta$ varies between architectures but appears to be consistent within the same meta-architecture. \begin{table}[t!] \centering \small \setlength\itemsep{2em} \begin{tabular}{llc} Model & Precision & Accuracy \\ \hline ResNet & fp32 & $93.20 \pm 0.04$ \\ ResNet & Mixed & $93.17 \pm 0.07$ \end{tabular} \quad \begin{tabular}{llc} Model & Precision & Accuracy \\ \hline ResNeXt & fp32 & $94.63 \pm 0.07$ \\ ResNeXt & Mixed & $94.57 \pm 0.10$ \end{tabular} \vspace{-0.7em} \caption{Affect of mixed-precision training on the LIT procedure. Mixed-precision training does not significantly affect the accuracy of the LIT procedure. Average of three runs.} \label{table:mixed-precision} \vspace{-0.7em} \end{table} \minihead{LIT works with mixed precision} To confirm mixed precision training~\citep{micikevicius2017mixed} works with LIT, we ran LIT on ResNet and ResNeXt (the teacher had 110 layers and the student had 20 layers) on CIFAR10 with both fp32 and mixed precision training. The results are shown in Table~\ref{table:mixed-precision}. As shown, mixed precision results in a limited difference (0.06\%) in accuracies for both ResNet and ResNeXt. \section{Introduction} Modern deep networks have achieved increased accuracy by continuing to introduce more layers~\citep{ioffe2015batch, he2016deep} at the cost of higher computational overhead. In response, researchers have proposed many techniques to reduce this computational overhead at inference time, which broadly fall under two categories. First, in deep compression~\citep{han2015deep, zhu2016trained, li2016pruning, hubara2017quantized}, parts of a model are removed or quantized to reduce the number of weights and/or the computational footprint.\footnote{In this work, we refer to this class of methods as ``deep compression,'' and methods to reduce model size more generally as ``model compression.''} However, deep compression techniques typically require new hardware~\citep{han2016eie} to take advantage of the resulting model sparsity. Second, in student/teacher methods---introduced in knowledge distillation (KD)~\citep{hinton2015distilling} and further extended~\citep{romero2014fitnets, kim2016sequence, furlanello2018born}---a smaller student model learns from a large teacher model through distillation loss, wherein the student model attempts to match the logits of the teacher model. As there are no constraints on the teacher and student models, KD can produce hardware-friendly models: the student can be a standard model architecture (e.g., ResNet), optimized for a given hardware substrate. Hint training (i.e., FitNets~\citep{romero2014fitnets}) extends KD by using a teacher's intermediate representation (IR, i.e., the output from a hidden layer) to guide the training of the student model. The authors show that hint training with a single IR outperforms KD in compressing teacher networks (e.g., maxout networks~\citep{goodfellow2013maxout}) to thinner and deeper student networks. We ask the natural question: does hint training compress more modern, highly-structured, very deep networks---such as ResNet~\citep{he2016deep}, ResNeXt~\citep{xie2017aggregated}, VDCNN~\citep{conneau2016very}, and StarGAN~\citep{choi2017stargan}? We find that standard hint training (i.e., with a single hint) and training with multiple hints is not effective for modern deep networks (Section~\ref{sec:eval-training}). We hypothesize that, for modern deep networks, hint training causes unstable IRs: the deepest network considered in~\cite{romero2014fitnets} was only 17 layers, achieving 91.61\% on CIFAR10; in contrast, a modern 110-layer ResNet achieves 93.68\% on CIFAR10. In this work, we extend hint training's ability to transfer intermediate knowledge from teacher to student to reduce the depth of modern, highly-structured architectures (e.g., compressing a standard ResNeXt-110 to a standard ResNeXt-20 with no loss in accuracy). We do this via a novel method called b\textbf{L}ock-wise \textbf{I}ntermediate representation \textbf{T}raining (LIT), a student/teacher compression technique that outperforms training student networks from scratch, hint training, and KD. LIT targets highly structured, modern networks that consist of repetitive blocks (i.e., groups of layers) that can be scaled up/down for accuracy/speed trade-offs; for example, ResNets have standard configurations from 20 to hundreds of layers. LIT leverages two key ideas to reduce unstable IRs in deep networks. First, LIT directly trains student networks of the \emph{same width} as the teacher model (as opposed to using a single, thinner hint as in hint training). Second, LIT avoids unstable student IRs deep in the network by using the IR from the \emph{previous} block in the teacher model as input to the current student block during training; each student block is effectively trained in isolation to match the corresponding (deeper) block in the teacher. We show that LIT's block-wise training improves accuracy, allows for copying parts of the teacher model directly to the student model, and permits selective compression of networks (e.g., compressing one out of three blocks in a network and copying the rest). For example, consider compressing a ResNet-56 from a ResNet-110 (Figure~\ref{fig:lit-arch}), each of which have four sections. The IR loss is applied to the output of each block, and the teacher model's IRs are used as input to the student blocks. \begin{figure}[t!] \centering \includegraphics[width=0.95\columnwidth]{figures/lit-arch-cropped.pdf} \vspace{-0.3em} \caption{A schematic of LIT. In LIT, the teacher model's blocks are used as input to the student model's blocks during training, except for the first block. Specifically, denoting the blocks $S_1, ..., S_4$ for the student and $T_1, ..., T_4$ for the student, $S_2(T_1)$ is compared against $T_2$ in training and similarly for deeper parts of the network. $S_1$ and $T_1$ are directly compared. LIT additionally compares $S$ and $T$ through the KD loss. The teacher model is not updated in training.} \vspace{-0.7em} \label{fig:lit-arch} \end{figure} Because it is possible to transfer IRs directly, LIT is, to our knowledge, the first student/teacher compression method that works for GAN generators. LIT can compress GAN generators by only compressing the repetitive blocks present in certain GANs~\citep{choi2017stargan}. In contrast, KD does not apply directly as the KL divergence in KD loss operates on probabilities but not the pixels output by GAN generators. LIT can compress GANs by leveraging LIT's key property that, by matching the teacher IR dimensions, parts of the teacher network can be directly copied to the student network. We show that LIT outperforms standard KD on a range of models (ResNet, ResNeXt, VDCNN, StarGAN) and datasets (CIFAR10, CIFAR100, Amazon Reviews, CelebA): empirically, LIT can reduce model sizes from 1.7$\times$ to 5.5$\times$ with no loss in accuracy. Recent work on Born Again networks~\citep{furlanello2018born} uses standard KD to train identical student and teacher models to higher accuracies (i.e., no compression). We show that the benefits of this procedure also apply to LIT student/teacher training, and LIT enables up to 0.64\% higher accuracy than KD-based Born Again networks on the networks we consider. \subsubsection*{Acknowledgments} This research was supported in part by affiliate members and other supporters of the Stanford DAWN project---Ant Financial, Facebook, Google, Intel, Microsoft, NEC, Teradata, SAP, and VMware---as well as DARPA under No. FA8750-17-2-0095 (D3M), industrial gifts and support from Toyota Research Institute, Keysight Technologies, Hitachi, Northrop Grumman, NetApp, and the NSF under grants DGE-1656518 and CNS-1651570. \section{Methods} \label{sec:methods} LIT uses an augmented loss function and training procedure to distill a teacher model into a student model. In its training procedure, LIT both 1) penalizes deviations of the student model's IRs from the teacher model's IRs (IR loss) and 2) uses the KD loss (for the entire student network). As LIT directly penalizes deviations in IRs, LIT requires that the teacher model and student model have outputs of the same size at some intermediate layer. A key challenge in the LIT procedure is that the student network will not have meaningful IRs for a large part of the training (e.g., at the start of training when the weights are initialized randomly). To address this issue, LIT uses the teacher model's IRs as inputs to the student model (described below). We describe the overall LIT procedure, describe the KD loss, describe how IRs are used in LIT, and discuss hyperparameter optimization. \minihead{LIT} In LIT, we combine the KD and IR loss. We show that combining the losses results in smaller models for a fixed accuracy in Section~\ref{sec:experiments}. Specifically, for teacher $T$ and student $S$ the full LIT loss is: \begin{equation} \beta \cdot \mathcal{L}_{\mathrm{KD},\alpha}(T, S) + (1 - \beta) \cdot \mathcal{L}_{\mathrm{I}}(T, S) \end{equation} with $\alpha,\beta \in [0, 1]$ ($\alpha$ is described below, $\beta$ is an interpolation parameter). In some cases, we use $\beta = 0$, i.e., we only use the IR loss (e.g., for GANs, where KD does not apply). As the IRs have matching dimensions, LIT also allows parts of the teacher model to be copied directly into the student model. For example, for ResNets, we copy the teacher's first convolution (before the skip connections) and fully connected layer to the student model. LIT can also be used to compress specific parts of a model, as we do with StarGAN's generator~\citep{choi2017stargan}. Finally, after we train the student model with LIT, we fine-tune the student model with the KD loss. \minihead{Knowledge distillation loss} In KD, a (typically larger) teacher model or ensemble is used to train a (typically smaller) student model. Specifically, the KL-divergence between the probabilities of the student and teacher model is minimized, in addition to the standard cross-entropy loss. Formally, denote (for the teacher model) $q_i^\tau = \tfrac{\exp(z_i / \tau)}{\sum_j z_j / \tau}$ where $z_i$ are the inputs to the softmax and $\tau$ is a hyperparmeter that ``softens" the distribution. Denote $p_i^\tau$ to be the corresponding quantity for the student model. Then, the full KD loss is: \begin{equation} \mathcal{L}_{\mathrm{KD}}(p, q, y) = \alpha \cdot H(y, p) + (1 - \alpha) \cdot H(p, q) \end{equation} for $y$ to be the true labels, $H$ to be the cross-entropy loss, and $\alpha$ to be the interpolation parameter. \cite{hinton2015distilling} sets $\alpha = 0.5$, but we show that the choice of $\alpha$ can affect performance (Section~\ref{sec:hyperparameters}). \minihead{Training via intermediate representations} In LIT, we logically divide the student and teacher networks into $k$ sub-networks such that the input and output dimensions match for the corresponding sub-networks (an example is shown in Figure~\ref{fig:lit-arch}). Denote the full teacher network and student network to be $T$ and $S$ respectively. Denote the teacher sub-networks to be $T_i$ and the student sub-networks to be $S_i$ such that $T_i, S_i : \mathbb{R}^{n_{i-i}} \to \mathbb{R}^{n_{i}}$ and that the composition of the sub-networks is the full network, namely that $T_k(T_{k-1} (\cdots T_1(x))) = T(x)$. We will omit the argument when convenient. Denote the loss on the IR loss $l$ (e.g., L2 loss). The full intermediate loss (given the set of splits) is: \begin{equation} \mathcal{L}_{\mathrm{I}}(T, S) \vcentcolon= l(S_1, T_1) + \textstyle \sum_{i=2}^{k} l(S_i(T_{i-1}), T_i) \end{equation} Concretely, consider a ResNet-110 as the teacher and a ResNet-56 as the student, each with three ``sections", i.e., layers in the network with downsampling, and an L2 intermediate loss. Here, the first teacher ResNet ``section" is $T_1$, etc. and the L2 deviation from the feature maps, across all the downsampling feature maps, is the full intermediate loss. A schematic is shown in Figure~\ref{fig:lit-arch}. This procedure has two key decisions: 1) where to logically split the teacher and student models, and 2) the choice of IR loss. We discuss these settings in the hyperparameter optimization below. \minihead{Hyperparameter optimization} LIT inherits two hyperparameters from KD and introduces one more: $\tau$ (the temperature in KD), $\alpha$ (the interpolation parameter in KD), and $\beta$ (the interpolation parameter in LIT), along with an intermediate representation loss and split points. In this work, we only consider adding the IR loss between natural split points, e.g., when a downsampling occurs in a convolutional network. We have additionally found that L2 loss works well in practice, so we use the L2 loss for all experiments unless otherwise noted (Section~\ref{sec:hyperparameters}). We have found that iteratively setting $\tau$, then $\alpha$, then $\beta$ to work well in practice. We have found that the same hyperparameters work well for a given student and teacher structure (e.g., ResNet teacher and ResNet student). Thus, we use the same set of hyperparameters for a given student and teacher structure (e.g., we use the same hyperparameters for a teacher/student of ResNet-110/ResNet-20 and ResNet-110/ResNet-32). To set the hyperparameters for a given structure, we first set $\tau$ using a small student model, then $\alpha$ for the fixed $\tau$, then $\beta$ for the fixed $\alpha$ and $\tau$ (all on the validation set). \section{Related Work} \label{sec:related-work} \minihead{Knowledge distillation} \cite{hinton2015distilling, bucilua2006model} introduced knowledge distillation (KD) in which a teacher ensemble or model’s outputs are used to train a smaller student model, which inspired a variety of related methods, e.g., for cross-modal distillation or faster training~\citep{gupta2016cross, chen2015net2net, frosst2017distilling, romero2014fitnets, furlanello2018born}. FitNets extends KD by regressing a student model's IR to a teacher model's IR, as the student models they consider are thinner and deeper. \cite{wang2018progressive} extends FitNets by training networks iteratively using hints. In contrast, LIT uses the teacher IRs as input to the student model in training and directly penalizes deviations of the student model's IRs from teacher model's IRs, which helps guide training for higher accuracy and improved inference performance. In Born Again networks~\citep{furlanello2018born}, the same network architecture is used as both the teacher and student in standard KD, resulting in higher accuracy. We show that LIT outperforms the Born Again procedure on ResNet, ResNeXt, and VDCNN. \minihead{Deep compression} In deep compression, parts of a network (weights, groups of weights, kernels, or filters~\citep{mao2017exploring}) are removed for efficient inference~\citep{han2015deep}, and the weights of the network are quantized, hashed, or compressed~\citep{hubara2016binarized, rastegari2016xnor, zhu2016trained, hubara2017quantized}. These methods largely do not take advantage of a teacher model and typically require new hardware for efficiency gains~\citep{han2016eie}. Methods that prune filters~\citep{li2016pruning} can result in speedups on existing hardware, but largely degrade accuracy. We show that LIT models can be pruned, and thus these methods are complementary to LIT. \minihead{Network architectures for fast inference} Researchers have proposed network architectures (e.g., MobileNet~\citep{howard2017mobilenets}) and new operations for fast inference (e.g., ShuffleNet~\citep{zhang2017shufflenet}) on specific hardware. However, these architectures and operations are largely designed for power/resource-constrained mobile devices and sacrifice accuracy for low power. We focus on highly accurate, very deep networks in this work.
{'timestamp': '2018-10-05T02:02:47', 'yymm': '1810', 'arxiv_id': '1810.01937', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01937'}
arxiv
\section{Introduction} \label{sec:intro} With remarkable advances in computing power, today's complex physical systems can be simulated comparatively cheaply and to high accuracy by using mature libraries. The ability to simulate has dramatically driven down the cost of scientific inquiry in engineering settings, at least at initial proof-of-concept stages. Even so, computer models often idealize the system---they are biased---or require the setting of tuning parameters: inputs unknown or uncontrollable in actual physical processes in the field. An excellent example is the simulation of a free-falling object, which is a potentially involved if well-understood enterprise from a modeling perspective. Acceleration due to gravity might be known, but possibly not precisely. Coefficients of drag may be completely unknown. A model incorporating both factors but not others such as ambient air disturbance or rotational velocity could be biased in consistent but unpredictable ways. Researchers are interested in calibrating such models to experimental data. With a flexible yet sturdy apparatus, a limited number of field observations from physical experiments can provide valuable information to fine tune, improve fidelity, understand uncertainty, and correct bias between simulations and physical phenomena they model. When done right, tuned and bias-corrected simulations are more realistic, forecasts more reliable, and these can inform simulation redevelopment, if necessary. Here we are motivated by a calibration and uncertainty quantification goal in the development of a so-called \textit{honeycomb seal}, a component in high-pressure centrifugal compressors, with collaborators at Baker Hughes, a General Electric company (BHGE). Several studies in the literature treat similar components from a mechanical engineering perspective \citep[e.g.,][]{D'Souza:Childs:2002}. To our knowledge, however, no one has yet coupled mathematical models and field experimentation in this setting. Using a commercial simulator and a limited field experiment, our BHGE colleagues performed a nonlinear least-squares (NLS) calibration as a proof of concept. The results left much to be desired. Although we were initially optimistic that we could readily improve on this methodology, a careful exploratory analysis on computer model and field data revealed challenges hidden just below the surface. These included data size, dimensionality, computer simulation reliability, and the nonstationary nature of the dynamics under study. Taken separately, each stretches the limits of the canonical computer model calibration setup, especially in our favored Bayesian setting. Taken all at once, these challenges demanded a fresh perspective. Contributions by \citet[][KOH]{Kennedy:O'Hagan:2001} and \citet{Higdon:2004} lay the foundation for flexible Bayesian calibration of computer experiments, tailored to situations where simulations are computationally expensive and cheap, respectively. Our situation is somewhere in between, as we describe in more detail in Section \ref{sec:honeycomb}. To set the stage and establish some notation, we offer the following brief introduction. Denote by $\mathbf{x} \in \mathbb{R}^{p_x}$ the controllable inputs in a physical experiment and by $\mathbf{u} \in \mathbb{R}^{p_u}$ any additional (tuning) parameters to the computer model that are unobservable or uncontrollable (or even meaningless, such as mesh size) in the field. In the KOH framework, the physical field observations $y^F(\mathbf{x})$ are connected with computer model simulations $y^M(\mathbf{x}, \mathbf{u}^*)$ through a discrepancy term, or bias correction $b(\mathbf{x})$, between simulation and field as follows: \begin{equation} y^F(\mathbf{x}) = y^M(\mathbf{x}, \mathbf{u}^*) + b(\mathbf{x}) +\epsilon. \label{eq:koh} \end{equation} Here, $\mathbf{u}^*$ is the unknown ``true" or ``best" setting for the calibration input parameters, and $\epsilon\overset{\mathrm{iid}}{\sim} \mathcal N(0, \sigma^2_\epsilon)$ represents random noise in the field measurements. The main distinguishing feature between KOH and the work of \citeauthor{Higdon:2004}~is the treatment of $y^M(\cdot, \cdot)$. If simulation is fast, then \citeauthor{Higdon:2004}~describe how evaluations may be collected on-demand within the inferential procedure, for each choice of $\mathbf{u}$ entertained, with bias $b(\cdot)$ trained directly on residuals $y^F(\mathbf{X}^F) - y^M(\mathbf{X}^F,\mathbf{u})$ observed at a small number of $N_F$ field data input sites, $\mathbf{X}^F$. When simulations are slow on not readily available for on-demand evaluation, then KOH prescribe surrogate modeling to obtain a fitted $\hat{y}^M(\cdot,\cdot)$ from $N_M$ training evaluations $[(\mathbf{X}^M, \mathbf{U}^M), \mathbf{Y}^M]$, with inference being joint for the bias $b(\cdot)$ and tuning parameter settings, $\mathbf{u}$, via a Bayesian posterior. If Gaussian processes (GPs) are used both for the surrogate model and bias, a canonical choice in the computer experiments literature \citep{Sacks1989,Santner2003}, then that posterior enjoys a large degree of analytical tractability. Numerical methods such as Markov chain Monte Carlo (MCMC) facilitate learning in $\mathbf{u}$-space, potentially averaging over any GP hyperparameters, such as characteristic lengthscale or nugget. For GP details, see \citet{Rasmussen2006}. The KOH framework has been successfully implemented in many applications and has demonstrated empirically superior predictive power for new untried physical observations. The method is at the same time highly flexible and well regularized. Its main ingredients, coupled GPs ($\hat{y}^M$ and $\hat{b}$) and a latent input space ($\mathbf{u}$), have separately been proposed as tactics for adding fidelity to fitted GP surfaces, in particular as a thrifty means of relaxing stringent stationarity assumptions \citep[][]{ba:joseph:2012,bornn:shaddick:zidek:2012}. However, KOH is not without its drawbacks. One is identifiability, which is not a primary focus of this paper \citep[see, e.g.,][]{plumlee2017bayesian,tuo2015}. Of more pressing here are computational demands, especially in the face of the rapidly growing size of modern computer experiments, both in the number of runs $N_M$ and in the input dimension $p_x$ or, to a lesser extent, $p_u$. GPs require calculations cubic in $N_M$ to decompose large $N_M \times N_M$ covariance matrices, limiting experiment sizes to the small thousands in practice. KOH compounds the issue with $(N_M + N_F) \times (N_M + N_F)$ matrices. Bayesian analysis in input high dimension ($p_x + p_u$), coupled with the large $N_M$ to adequately cover such a big computer simulation space, is all but impossible without modification. Inroads have recently been made in order to effectively and tractably calibrate in settings where the computer experiment is orders of magnitude larger than typical. For example, \citet{gra:etal:2015} simplified KOH with three modern ideas: modularization \citep{Liu:2009} to simplify joint inference, local GP approximation \citep{gramacy:apley:2015} for fast nonstationary modeling, and derivative-free optimization \citep{AuCo04a,Le09b} for point estimation. While effective, Bayesian posterior uncertainty quantification (``the baby'') was all but thrown out (``with the bath water''). Here we propose a setup that borrows some of these themes, while at the same time backing off on others. We develop a flavor of local GP approximation that we call an {\em on-site surrogate, or OSS} that does not require modularization in order to fit within the KOH framework. As a result, we are able to stay within a Bayesian joint inferential setup, although we find it effective to perform a preanalysis via optimization, in part to prime the MCMC. We show how our OSSs accommodate a degree of nonstationarity while imposing a convenient sparsity structure on otherwise huge $(N_M + N_F) \times (N_M + N_F)$ coupled-GP covariance matrices, leading to fast decomposition under partitioned inverse identities. The result is a tractable calibration framework that is both more accurate out-of-sample and more descriptive about uncertainties than BHGE's NLS. The remainder of the paper is outlined as follows. Section \ref{sec:honeycomb} describes the honeycomb seal application, challenges stemming from its simulation, and subsequent attempts to calibrate via a limited field data. Section \ref{sec:localemu} introduces our novel OSS strategy for emulation within a calibration framework and application within an optimization/point-estimate setting. Section \ref{sec:fullBayes} expands this setup in Bayesian KOH-style. Returning to our motivating example, Section \ref{sec:results} demonstrates calibration results from both optimization and fully Bayesian approaches, including comparison with the simpler NLS strategy at BHGE. Section \ref{sec:discussion} concludes this paper with a brief discussion. \section{Honeycomb seal} \label{sec:honeycomb} The honeycomb seal is an important component widely used in BHGE's high-pressure centrifugal compressors to enhance rotor stability in oil and gas applications or to control leakage in aircraft gas turbines. The seal(s) and applications at BHGE are described by $p_x = 13$ design variables $\mathbf{x}$ characterizing geometry and flow dynamics: rotational speed, cell depth, seal diameter and length, inlet swirl, gas viscosity, gas temperature, compressibility factor, specific heat, inlet/outlet pressure, and clearance. The field experiment, from BHGE's component-level honeycomb seal test campaign, comprises $N_F = 292$ runs varying a subset of those conditions, $\mathbf{X}^F$, believed to have greatest variability during turbomachinery operation: clearance, swirl, cell depth, seal length, and seal diameter. Measured outputs include direct/cross stiffness and damping, at multiple frequencies. Here our focus is on the direct stiffness output $y \equiv k_{\mathrm{dir}}$ at 28 Hz. A few hundred runs in thirteen input dimensions is hardly sufficient to understand honeycomb seal dynamics to any reasonable degree in this highly nonlinear setting. Fortunately, the rotordynamics of seals like the honeycomb are relatively well understood, at least from a mathematical and computational modeling standpoint. Although input dimension is somewhat high by computer model calibration standards, library-based numerical routines provide ready access to calculations for direct/cross stiffness and damping for inputs like those listed above. In what follows, we provide some insight into one such solver and the advantages as well as challenges to using it (along with the field data) to better understand and predict the dynamics of our honeycomb seal. \subsection{{\tt ISOTSEAL} simulator} \label{sec:isotseal} A simulator called {\tt ISOTSEAL}, developed at Texas A\&M University \citep{isotseal}, offers a relatively speedy evaluation (about one second) of the response(s) of interest for the honeycomb seal under study at BHGE. {\tt ISOTSEAL} is built on bulk-flow theory, calculating gas seal force coefficients based on seal flow physics. Our BHGE colleagues have developed an {\sf R} interface mapping seventeen scalar inputs for the honeycomb seal experiment into the format required for {\tt ISOTSEAL}. Thirteen of those inputs match up with the columns of $\mathbf{X}^F$ (i.e., they are $\mathbf{x}$'s); four are tuning parameters $\mathbf{u}$, which could not be controlled in the field. These comprise statoric and rotoric friction coefficients $n_s, n_r$ and exponents $m_s, m_r$. They are the {\em friction factors} of the honeycomb seal. In the turbulent-lubrication model from bulk-flow theory, the shear stress $f$ is a function of the friction coefficient $n$ and exponent $m$ through the Blasius model $f =n \mathrm{Re}^m$, where $\mathrm{Re}$ is the Reynolds number \citep{Hirs:1973}. Applied separately for the stator ($s$) and rotor ($r$), friction factors $n$ and $m$ must be determined empirically from experimental data. To protect BHGE's intellectual property, but also for practical considerations, we work with friction factors coded to the unit cube. \[ (n_s, m_s, n_r, m_r)^\top \rightarrow (u_1, u_2, u_3, u_4)^\top \in [0,1]^4 \] These are treated as calibration parameters $\mathbf{u}$, with the goal of learning their setting via field data and {\tt ISOTSEAL} simulations. Although {\tt ISOTSEAL} is fast and has a reputation for delivering outputs faithful to the underlying physics, we identified several drawbacks in our application. For some input settings it fails to terminate, especially with friction factors ($\mathbf{u}$) near the boundary of their physically meaningful ranges.\footnote{At least for the commercial version of the simulator in use at BHGE, paired with their input--mapping front-end. The {\sf R} wrapper aborts the simulation and returns {\tt NA} after seven seconds of execution.} For others, where a response is provided, numerical instabilities and diverging approximation are evident. Although evaluations are operationally deterministic, in that providing the same input yields the same output, the behavior can seem otherwise unpredictable. Even subtle numerical ``jitters'' of this sort can thwart conventional GP interpolation \citep{gra:lee:2012}. As we show below, {\tt ISOTSEAL}'s jitters are sometimes extreme. Others have commented on similar drawbacks \citep{vann:2011}; modern applications of {\tt ISOTSEAL} may be pushing the boundaries of its engineering. \begin{figure}[ht!] \centering \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc1.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc2.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc3.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc4.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc5.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc6.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc11.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc14.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc12.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc10.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc9.png} \includegraphics[width=0.32\linewidth, trim=0 15 15 50, clip]{loc8.png} \caption{Local plots of ISOTSEAL response surface for direct stiffness (Kdir). Row 1: change of one input in grid in wide input ranges. Row 2: zoomed-in versions of row 1, changing one input in a much denser grid. Row 3: inexact simulations, changing one input in a grid in input space. Row 4: input trajectory between two arbitrary points from the input space, varying all inputs in grids. } \label{fig:loc1} \end{figure} Figure \ref{fig:loc1} shows example outputs $\mathbf{y}^M$ obtained by varying one input at a time in a narrow range, while fixing the others at sensible values (first three rows); and varying all inputs in grids between two arbitrary points (fourth row). The first row shows ideal settings: the response is a smooth function of the input over the range(s) entertained. The second row, however, zooming in on the same input--response scenarios, reveals a ``staircase/striation'' effect at small scales. The third row shows more concerning macro-level behavior over both narrow and wide input ranges. According to BHGE's rotordynamics experts, these ``staircase'' and discontinuity features could be related to tolerances imposed on first-order equilibrium and flow equations implemented in {\tt ISOTSEAL} The last row illustrates unpredictable regime-changing behavior and gaps due non-terminating simulation. Particular challenges exhibited by the bottom row notwithstanding, dynamics are clearly nonstationary from a global perspective. A great example of this is in the first column of the third row, where the response is at first slowly changing and then more rapidly oscillating. In that example, the regime change is smooth. In other cases, however, as in the middle column of the bottom row, a ``noisy'' discontinuity separates a hill-like feature from a steadier slope. An ordinary GP model, even with a nugget deployed to smooth over noiselike features by treating them as genuine noise \citep{gra:lee:2012}, could not accommodate such regime changes, smooth or otherwise. Consequently, initial attempts to emulate {\tt ISOTSEAL}-generated response surfaces via the canonical GP in the full (17-dimensional) input space were not successful. Even with space-filling designs sized in the several thousands, pushing the limits of the $\mathcal{O}(N^3)$ bottleneck of large matrix decompositions, we were unable to adequately capture the distinct features we saw in smaller, more localized experiments. Modest reductions in the input dimension---holding some inputs fixed---and, similarly, reductions in the width of the input domain for the remaining coordinates led to unremarkable improvement in terms of accuracy in out-of-sample predictions. Global nonstationarity, local features, numerical artifacts, and high input dimension proved to be a perfect storm. Section \ref{sec:localemu} uses those unsuccessful proof-of-concept fits as a benchmark, showing how our proposed on-site surrogate offers a far more accurate alternative, at least from a purely out-of-sample emulation perspective. \subsection{Nonlinear least-squares calibration} \label{sec:nls} To obtain a crude calibration to the small amount of field data they had, our BHGE colleagues performed a nonlinear least-squares analysis. Starting in a stable part of the input space, from the perspective of {\tt ISOTSEAL} behavior, they used a numerical optimizer---a Nash variant of Marquardt NLS via QR linear solver, {\tt nlfb} \citep{nlmrt}---to tune $\mathbf{u}$-values, that is, the four friction factors, based on a quadratic loss between simulated $y_i^M(\mathbf{x}_i, \mathbf{u})$ and observed output $y_i^F(\mathbf{x}_i)$ at the input training data sites $\mathbf{X}^F$ \begin{align} \hat{\mathbf{u}} = \mathrm{arg}\min_\mathbf{u} \left\{ \dfrac{1}{N_F} \sum_{i=1}^{N_F} \left[ y^F_{i}(\mathbf{x}_i)-y^M_i(\mathbf{x}_i, \mathbf{u}) \right]^2 \right\}, \label{eq:nls} \end{align} In search for $\hat{\mathbf{u}}$, each new $\mathbf{u}$-value tried by the {\tt nlfb} optimizer triggered $N_F$ calls to {\tt ISOTSEAL}, one for each row of the design parameters $\mathbf{X}^F$, much in the style of \citet{Higdon:2004} but without estimating a bias correction. To cope with failed {\tt ISOTSEAL} runs, {\tt nlfb} monitors the rate of missing values in evaluations. When the missingness rate is below a threshold (e.g., 10\%), a predetermined large residual value (100 on the original scale) is imputed for the missed residual to discourage convergence toward solutions nearby. Once above the threshold, {\tt nlfb} reports an error message and is started afresh. We repeated this experiment, starting instead from 100 random space-filling $\mathbf{u}$ values in hopes of improving on our BHGE colleagues' results with a best value at RMSE $=8.567$ and having a strong \blu{benchmark} for later comparison. Because this NLS setup does not model a discrepancy between $\mathbf{y}^M$ and $\mathbf{y}^F$, converged solutions have large quadratic loss, even in-sample. Among 100 restarts, two failed; and the other losses, mapped to the scale of $\mathbf{y}^F$ by taking the square root, had the following distribution. \begin{center} \begin{tabular}{rrrrrr} min & 25\% & med & mean & 75\% & max \\ \hline 6.605 & 8.161 & 8.401 & 10.117 & 9.099 & 25.787 \end{tabular} \end{center} The blue/circle marks in Figure \ref{fig:nls} show observed residuals between field data and NLS calibrated {\tt ISOTSEAL} with the best solution we obtained, $\hat{u}=(0.000, 0.000, 0.821, 0.996)^\top$. Notice that three of four friction factors are set at their limit values. This restart benefited from a serendipitous initialization, having initial RMSE of 9.219 converging to 6.605. However, Figure \ref{fig:nls} shows that many large residuals still remain (blue/circles). \begin{figure}[ht!] \centering \includegraphics[width=0.49\linewidth, trim=0 0 0 0, clip]{res1.pdf} \includegraphics[width=0.49\linewidth, trim=0 0 0 0, clip]{res2.pdf} \caption{Observed in-sample residuals between NLS calibrated {\tt ISOTSEAL} and OSS Bayes from field data. The left panel shows histograms of the residuals; the right panel shows them versus the true response. The NLS has in-sample RMSE $= 6.605$. The OSS Bayes has in-sample RMSE $=1.125$, which is further discussed in Section \ref{sec:oosresults}. } \label{fig:nls} \end{figure} The red/crosses comparator is based on our proposed methodology and is described in subsequent sections. For comparison, and to whet the reader's appetite, we note that the in-sample RMSE we obtained was 1.125. Out-of-sample results are provided in Section \ref{sec:oosresults}. We attribute NLS's relatively poor performance to two features. One is its inability to compensate for biases in {\tt ISOTSEAL} runs, relative to the outcome of field experiments. Another is that the solutions found were highly localized to the neighborhood of the starting configuration. A post mortem analysis revealed that this was due primarily to large missingness rates. Although we were confident that we could improve on this methodology and obtain more accurate predictions by correcting for bias between field and simulation in a Bayesian framework, it quickly became apparent that a standard, KOH-style analysis would be fraught with difficulty. In a test run, we used a space-filling design $\mathbf{X}^M$ and fit a global GP emulator in the 17-dimensional space of {\tt ISOTSEAL} runs $\mathbf{y}^M$ thus obtained. That surrogate offered nice-looking predictive surfaces and provided posterior surfaces for calibrated friction factors substantially different from those obtained from NLS (e.g., away from the boundary), but unfortunately the surrogates were highly inaccurate out of sample, as illustrated below. \section{Local design and emulation for calibration} \label{sec:localemu} Failed attempts at surrogate modeling {\tt ISOTSEAL}, either generally or for the specific purpose of calibration to field data [see Section \ref{sec:isotseal}], motivate our search for a new perspective. Local emulation has been proposed in the recent literature \citep{gra:etal:2015} as a means of circumventing large-data GP surrogate modeling for calibration, leveraging the important insight that surrogate evaluation is required only at field data locations $\mathbf{X}^F$, of which we have relatively few ($N_F = 292$). But in that context the input dimension was small, and here we are faced with the added challenges of numerical instability, nonstationary dynamics, and missing data. In this section we port that idea to our setting of on-site surrogates, leveraging relatively cheap {\tt ISOTSEAL} simulation, while mitigating problems of big $N_M$, big $p_x + p_u$, and challenging simulator dynamics. \subsection{On-site surrogates} \label{sec:oss} {\em On-site surrogates} (OSSs) reduce a $p = p_x + p_u =17$-dimensional problem into a $p_u =4$-dimensional problem by building as many surrogates as there are field data observations, $N_F = 292$. Let $\mathbf{x}$ denote a generic design variable setting and $\mathbf{u}$ a generic tuning vector (e.g., friction factor in {\tt ISOTSEAL}). Then the mapping from one big surrogate to many smaller ones may be conceptualized by the following chart: \begin{align} \hat{y}^M(\mathbf{x}, \mathbf{u}) \longrightarrow \hat{y}^M(\mathbf{x}_i, \mathbf{u}) \longrightarrow \hat{y}_i^M(\mathbf{u}), \quad \mbox{for } \; i = 1, 2, \dots, N_F. \end{align} That is, rather than building one big emulator for the entire $p$-dimensional input space $\hat{y}^M(\mathbf{x}, \mathbf{u})$, we instead train separate emulators $\hat{y}_i^M(\mathbf{u})$ focused on each site $\mathbf{x}_i$ where field data has been collected. In this way, OSSs are a divide-and-conquer scheme that swap joint modeling in a large $(\mathbf{x},\mathbf{u})$-space, where design coverage and modeling fidelity could at best be thin, for many smaller models in which, separately, ample coverage is attainable with modestly sized design in $\mathbf{u}$-space only. Fitting and simulation can be performed in parallel, since the calculations for each field data site $\mathbf{x}_i$, $i=1,\dots, N_F$ are both operationally and statistically independent. Nonstationary modeling is implicit, since each surrogate focuses on a different part of the input space. If simulations are erratic for some $(\mathbf{x}_i, \mathbf{u})$, say, the OSS indexed by $i$ can compensate by smoothing over with nonzero nuggets. If dynamics are well behaved for other sites $j$, OSSs can interpolate after the typical fashion. In some ways, OSSs are akin to an {\em in situ} emulator \citep{gul:2018}. Whereas the in situ emulator is tailored to uncertainty quantification around nominal inputs, OSSs are applied in multitude for each element of $\mathbf{X}^F$ in the calibration setting. Another distinction is the role of design in building OSSs. Here we propose separate designs at each $\mathbf{x}_i$ to learn each $\hat{\mathbf{y}}_i^M(\mathbf{u})$, rather than working with design subsets. A maximin Latin hypercube sample (LHS) is preferred for their space-filling and uniform margin properties \citep[see, e.g.,][]{morris:1995}. We use {\tt maximinLHS} in the {\tt lhs} \citep{lhs} for {\sf R}. Specifically, at each of the $N_F = 292$ field data sites, we create novel 1000-run maximin LHS designs for friction factors in $p_u = 4$-dimensional $\mathbf{u}$-space. In this way, we separately design a total of $N_M=292,000$ {\tt ISOTSEAL} simulation runs. With about one second for evaluation (for successfully terminating runs and about seven seconds waiting to terminate a failed run), this is a manageable workload requiring about 81 core-hours, or about one day on a modern hyperthreaded multicore workstation. Let $\mathbf{y}_i^M = y^M(\mathbf{U}_i)$ be a vector holding the $n_i$ converged {\tt ISOTSEAL} runs (out of the 1,000) at the $i^\mathrm{th}$ site, for $i=1,\dots,N_F$. $\mathbf{U}_i$ is the corresponding $n_i \times p_u$ on-site design matrix. In our {\tt ISOTSEAL} experiment, where $N_F=292$, a total of $N_M= \sum_{i=1}^{N_F}n_i= 286,282$ runs terminated successfully. Most sites (241) had a complete set of $n_i = 1000$ successful runs. Of the 51 with missing responses of varying multitudes, the smallest was $n_{238} = 574$. Each OSS comprises a fitted GP regression between successful on-site {\tt ISOTSEAL} run outputs $\mathbf{y}_i^M$ and $\mathbf{U}_i$. Specifically, $\hat{y}_i^M (\mathbf{U}_i)$ is built by fitting a stationary zero-mean GP using a scaled and nugget-augmented separable Gaussian power exponential kernel \begin{align} V_i(\mathbf{u}, \mathbf{u}') = \tau_i^2\exp\left\{ - \sum_{k=1}^{p_u} \frac{||\mathbf{u}_{ik} - \mathbf{u}'_{ik}||^2}{\theta_{ik}} + \delta_{u,u'} \eta_i\right\}, \label{eq:kernel} \end{align} where $\tau_i^2$ is a site-specific scale parameter, $\bm{\theta}_i=(\theta_{i1}, \theta_{i2}, \dots, \theta_{ip_u} )^\top$ is vector of site-specific lengthscales, $\eta_i$ is a nugget parameter,\footnote{Note that the nugget $\eta_i$ augmentation is applied only when $\mathbf{u}'$ and $\mathbf{u}$ are identically indexed, i.e., on the diagonal of a symmetric covariance matrix; not simply when their values happen to coincide.} and $\delta_{u,u'}$ is the Kronecker delta. Denote the set of hyperparameters of the $i^\mathrm{th}$ OSS as $\bm{\phi}_i=\{\tau^2_i, \bm{\theta}_i, \eta_i\}$, for $i=1, 2, \dots, N_F$. Although nuggets $\eta_i$ are usually fit to smooth over noise, here we are including them to smooth over any deterministic numerical ``jitters.'' Other mean and covariance structures may be reasonable, so in what follows let $\bm{\phi}_i$ stand in generically for the estimable quantities of each OSS. Although numerous options for inference exist, we prefer plug-in maximum likelihood estimates (MLEs) $\hat{\bm{\phi}}_i$, calculated in parallel for each $i=1,\dots,N_F = 292$ via {\tt L-BFGS-B} \citep{byrd:etal:1995} using analytic derivatives via {\tt mleGPsep} in the {\tt laGP} package \citep{laGP,gramacy:jss:2016} for {\sf R}. As we illustrate momentarily, this simple OSS strategy provides far more accurate emulation out-of-sample than does the best global alternative we could muster with a commensurate computational effort. \subsection{Merits of on-site surrogates} \label{sec:merits} To build a suitable global GP competitor, we created an $N_M = 8000$-run maximin LHS in $p=17$ input dimensions, fit a zero-mean GP based on a separable covariance structure (\ref{eq:kernel}), and estimated the 19-dimensional hyperparameters $\hat{\bm{\phi}}_g=\{\tau^2_g, \bm{\theta}_g, \eta_g\}$ via MLE. We chose 8,000 runs because that demanded a comparable computational effort to the OSS setup described in Section \ref{sec:oss}. Although the {\tt ISOTSEAL} simulation effort for 8,000 runs is far less than the 292K for the OSSs, the hyperparameter inference effort and subsequent prediction for an $N_M = 8000$-sized design is commensurate with that required for our 292 size $n_i \approx 1000$ OSS calculations. Repeated matrix decompositions in likelihood and derivative calculations in search of the MLE, requiring $\mathcal{O}(N_M^3)$ flops for the global surrogate, represented a heavy burden even when parallelized by multi-threaded linear algebra libraries such as the Intel Math Kernel Library. Similarly threaded calculations of $O(n_i^3)$ flops were faster even in 292 copies, in part because fewer evaluations were needed to learn hyperparameters $\hat{\bm{\phi}}_i$ in the lower-dimensional $\mathbf{u}$-space.\footnote{The OSSs learn $|\bm{\phi}_i| = 6$ compared to $|\bm{\phi}_g| = 19$ for the global analog. The latter thus demands more expensive gradient calculations. Moreover, the former generally converges to the same local optima when reinitialized, whereas the latter have many local minima due to nonstationary and locally ``jittery'' responses. Multiple restarts are required to mitigate the chance of finding vastly inferior local optima.} \begin{figure}[ht!] \centering \begin{minipage}{6cm} \includegraphics[scale=0.5,trim=10 40 10 50,clip]{RMSE.pdf} \end{minipage} \hspace{1cm} \begin{tabular}{r|rr} & global & OSS \\ \hline min & 0.871 & 0.008 \\ 25\% & 1.991 & 0.023 \\ med & 3.492 & 0.050 \\ mean & 3.619 & 0.120 \\ 75\% & 4.928 & 0.112 \\ max & 9.207 & 1.223 \end{tabular} \caption{Boxplots of 292 out-of-sample RMSEs, where each RMSE is computed by using novel $n_i' \leq 1,000$ on-site data from both global surrogate and OSSs.} \label{fig:rmse} \end{figure} Since the OSSs were trained on a much larger corpus of simulations, it is perhaps not surprising that they provide more accurate predictions out of sample. To demonstrate that empirically, Figure \ref{fig:rmse} summarizes the results of emulation accuracy from both global surrogate and OSSs. For our calibration goal, we need accurate emulation only at locations where we have field data $\mathbf{X}^F$. Therefore we entertain out-of-sample prediction accuracy only for those $\mathbf{X}^F$ sites. At each of the 292 field input sites $\mathbf{x}_i$, we design $\mathbf{U}_i'$ with 1,000 runs each, the same amount as the training set, via maximin LHS. In total we collected $N_M'=286,224$ testing {\tt ISOTSEAL} runs, which is fewer than we ran since some came back missing. A pair of RMSEs, based on the OSSs and global surrogates, were calculated at each site $i=1, 2, \dots, N_F = 292$ based on the $n_i' \approx 1,000$ testing runs located there. The distribution of these values is summarized in Figure \ref{fig:rmse}. From those boxplots, one can easily see that the OSSs yield far more accurate predictions. \begin{figure}[ht!] \centering \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local1} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local2} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local3}\\ \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local4} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local5} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local6}\\ \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local7} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local8} \includegraphics[width=0.32\linewidth, trim=0 10 20 5, clip=TRUE]{local9} \caption{Profile plots of OSSs via predictive means and 95\% predictive intervals (dashed-red). First row shows three well-behaved cases; middle row illustrates extrapolations to partially missing regimes; last row shows three cases where smoothing is required in order to cope with discontinuities. Red lines are the predicted mean (solid) and 95\% predictive intervals (dashed). Black horizontal lines show the field response $y_i^F$ at that location, $\mathbf{x}_i$, with $i$ provided in the main title.} \label{fig:loc2} \end{figure} Figure \ref{fig:loc2} supplements those results with a window into the behavior of the OSSs, in three glimpses. The first row shows three relatively well-behaved input settings by varying two $\mathbf{u}$-coordinates at $\mathbf{x}_{17}^F$, and one at $\mathbf{x}_{243}^F$. In all three cases, the three dashed-red lines describing the predictive distribution (via mean, and 95\% interval) completely cover the {\tt ISOTSEAL} simulations in that space. Both flat (middle panel) and wavier dynamics (outer panels) are exhibited, demonstrating a degree of nonstationary flexibility. The horizontal line indicates the field data $y_i^F$ value, and in two of those cases there is a substantial discrepancy between $y^M(\mathbf{x}_i, \mathbf{u})$, and $y_i^F$ for the range of $\mathbf{u}$-values on display. The middle row in the figure shows what happens when {\tt ISOTSEAL} runs fail to converge, again via two $\mathbf{u}$-coordinates for one OSS, at $\mathbf{x}_{41}^F$, and one for another $\mathbf{x}_{249}^F$. Notice that failures happen more often toward the edges of $\mathbf{u}$-space, but not exclusively. In all three cases the extrapolations are sensible and reflect diversity in waviness (first two flatter, third one wavier) that could not be accommodated by a globally stationary model. All three have the corresponding $y_i^F$-value within range, but only in the extrapolated regime. The last row of the figure shows how a nugget is used to smooth over bifurcating regime changes in the output from {\tt ISOTSEAL}, offering a sensible compromise and commensurately inflated uncertainty in order to cope with both regimes. All three cases map to outlying RMSE values (open circles beyond the whiskers OSS boxplot) from Figure $\ref{fig:rmse}$. Although they are among the hardest to predict out of sample, the overall magnitude of the error is small. Since the corresponding $y_i^F$-values (horizontal lines) are far from $y^M(\mathbf{x}_i, \mathbf{u})$, and $\hat{y}_i^M(\mathbf{u})$ in the $\mathbf{u}$-range under study, a substantial degree of bias correction is needed to effectively calibrate in this part of the input space. \subsection{Calibration as optimization with on-site surrogates} \label{sec:optim} Even with accurate OSSs at all field data locations, Bayesian calibration can still be computationally challenging in large-scale computer experiments. In the KOH framework (\ref{eq:koh}), both $\mathbf{u}^*$ and a bias correcting GP $b(\mathbf{x})$, via hyperparameters $\bm{\phi}_b$, are unknown and must jointly be estimated. The size of that parameter space, using a separable Gaussian kernel (\ref{eq:kernel}) for $b(\cdot)$, is large (19d) in our motivating honeycomb seal application. MCMC in such a high-dimensional space is fraught with computational challenges. As an alternative to the fully Bayesian method, presented shortly in Section \ref{sec:fullBayes} taking advantage of a sparse matrix structure, and to serve as a smart initialization of the resulting MCMC scheme, we propose here an adaptation of \citet{gra:etal:2015}'s modularized \citep{Liu:2009} calibration as optimization. Instead of sampling a full posterior distribution, $\hat{b}(\cdot)$ and $\hat{\mathbf{u}}$ are calculated as \begin{equation} \hat{\mathbf{u}} = \mathrm{arg}\max_\mathbf{u} \left\{ p(\mathbf{u}) \left[ \max_{\bm{\phi}_b} p_b(\bm{\phi}_b \mid \mathbf{D}^{B}_{N_F}(\mathbf{u}))\right] \right\}, \label{eq:opt} \end{equation} which explores different values of $\hat{\mathbf{u}}$ via the resulting posterior probability of discrepancy hyperparameters $p_b(\phi_b \mid \mathbf{D}^{B}_{N_F}(\mathbf{u}))$ applied to a data set of residuals $\mathbf{D}^B_{N_F}(\mathbf{u})$. Specifically, $\mathbf{D}^{B}_{N_F}(\mathbf{u})=(\mathbf{X}_{N_F}^F, \hat{\mathbf{y}}_{N_F}^{B|u})$ is the observed field inputs $\mathbf{X}_{N_F}^F$ and discrepancies $\hat{\mathbf{y}}_{N_F}^{B|\mathbf{u}}=\mathbf{y}_{N_F}^F-\hat{\mathbf{y}}_{N_F}^{M|\mathbf{u}}$ given a particular $\mathbf{u}$. The probability $p_b(\cdot \mid \cdot) $ refers to the marginal likelihood of the GP with parameters $\hat{\bm{\phi}}_b$ fit to those residuals via their own ``inner'' derivative-based optimization routine. The object in Eq.~(\ref{eq:opt}) basically encodes the idea that $\mathbf{u}$-settings leading to better-fitting GP bias corrections are preferred. A uniform prior $p(\mathbf{u})$ is a sensible default; however, we prefer independent $u_j \sim \mathrm{Beta}(2,2)$ in each coordinate as a means of regularizing the search by mildly penalizing boundary solutions, in part because we know that frictions factors at the boundaries of $\mathbf{u}$-space lean heavily on the surrogate as runs of {\tt ISOTSEAL} fail to converge there. Of course, any genuine prior information on $\mathbf{u}$ could be used here to further guide the calibration. Actually, this approach is not unlike the NLS one described in Section \ref{sec:nls}, augmented with OSSs (rather than raw {\tt ISOTSEAL} runs) and with bias correction. Instead of optimizing a least-squares criterion, our GP marginal likelihood-based loss is akin to a spatial Mahalanobis criterion \citep{bastos:ohagan:2009}. In practice, the log of the criteria in Eq.~(\ref{eq:opt}) can be optimized numerically with library methods such as ``L-BFGS-B", via {\tt optim} \citep{lbfgsb}, or {\tt nloptr} \citep{nloptr}. Since the optimizations are fast but local and since the surface being optimized can have many local optima, we entertain a large set of random restarts---in parallel---in search for the best (most global) $\hat{\mathbf{u}}$ and $\hat{b}(\cdot)$. To economize on space, we summarize here the outcome of this approach on the honeycomb seal, alongside its fully Bayesian KOH analog. A more detailed discussion of fully Bayesian calibration is provided in Section \ref{sec:fullBayes} with results in Section \ref{sec:results}. As mentioned above, our main use of this procedure is to prime the fully Bayesian KOH MCMC. Foreshadowing somewhat, we can see from Figure \ref{fig:res} that the point estimates $\hat{\mathbf{u}}$ so-obtained are not much different from the maximum {\em a posteriori} (MAP) found via KOH, yet at a fraction of the computational cost. Since MCMC is inherently serial and our randomly initialized optimizations may proceed in parallel, we can get a good $\hat{\mathbf{u}}$ in about an hour, whereas getting a good (effective) sample size from the posterior takes about a day. \section{Fully Bayesian calibration via on-site surrogates} \label{sec:fullBayes} The approach in Section \ref{sec:optim} is Bayesian in the sense that marginal likelihoods are used to estimate hyperparameters to the GP-based OSSs and discrepancy $b(\cdot)$, and priors are entertained for the friction factors $\mathbf{u}$. However, the modularized approach to joint modeling, via residuals from (posterior) predictive quantities paired with optimization-based point \blu{estimation}, makes the setup a poor man's Bayes at best. In the face of big data---large $N_M$, $N_F$ and $p_u$---such a setup may represent the only computationally tractable alternative. However, in our setting with moderate $N_F$ and $N_M = \sum_{i=1}^{N_F} n_i$ composed of independently modeled computer experiments of moderate size ($n_i \leq 1000$), fully Bayesian KOH-style calibration is within reach. As we show below, a careful application of partition inverse identities allows the implicit decomposition of a huge matrix via its sparse structure. \subsection{KOH setup using OSS} Our OSSs from Section \ref{sec:oss} are trained via $p_u$-dimensional on-site designs $\mathbf{U}_1, \mathbf{U}_2, \dots, \mathbf{U}_{N_F}$. Their row dimension, $n_i \leq 1000$, depends on the proportion of {\tt ISOTSEAL} runs that successfully completed. Collect these $N_M = \sum_{i=1}^{N_F} n_i$ outputs of those simulations, each tacitly paired with inputs $\mathbf{x}_i$, as $\mathbf{y}^M=(\mathbf{y}_1, \mathbf{y}_2, \dots, \mathbf{y}_{N_F})^\top$. The KOH framework compensates for surrogate biased computer model predictions under an unknown setting $\mathbf{u}$ by estimating a discrepancy $b(\cdot)$ via $N_F$ field data runs $\mathbf{y}^F$ observed at $N_F \times p_x$ inputs $\mathbf{X}^F$: \[ \mathbf{y}^F=y^M(\mathbf{U}) + b(\mathbf{X}^F), \quad \mbox{where} \quad \mathbf{U}=[\mathbf{u}^\top; \cdots; \mathbf{u}^\top]^\top \] stacks $N_F$ identical $p_u$-dimensional row vectors $\mathbf{u}^\top$. Under joint GP priors, for each of $N_F$ OSSs and $b(\cdot)$, the sampling model can be characterized by the following multivariate normal (MVN) distribution. \begin{align} \begin{bmatrix} \mathbf{y}^M \\ \mathbf{y}^F \end{bmatrix} = \begin{bmatrix} \mathbf{y}_1 \\ \mathbf{y}_2\\ \vdots \\\mathbf{y}_{N_F} \\ \mathbf{y}^F \end{bmatrix} = \begin{bmatrix} y_1(\mathbf{U}_1)\\ y_2(\mathbf{U}_2)\\ \vdots \\ y_{N_F}(\mathbf{U}_{N_F}) \\ y^M(\mathbf{U}) + b(\mathbf{X}^F) \end{bmatrix} \sim \mathcal{N}_{N_M + N_F}(\mathbf{0}, \mathbb{V}(\mathbf{u})) \label{eq:d} \end{align} Generally speaking, $\mathbb{V}(\mathbf{u})$ would be derived by hyperparameterized pairwise inverse distances between inputs on $(\mathbf{x},\mathbf{u})$-space. In our OSS setup, however, it has a special structure owing to the independent surrogates fit at each $\mathbf{x}_i$, for $i=1,\dots,N_F$. Let $\mathbf{V}_i \equiv V_i(\mathbf{U}_i, \mathbf{U}_i)$ denote the $n_i \times n_i$ covariance matrix for the $i^\mathrm{th}$ OSS, for example, following Eq.~(\ref{eq:kernel}). This notation deliberately suppresses dependence on hyperparameters $\bm{\phi}_i$, which is a topic we table momentarily to streamline the discussion here. Similarly, $V_b \equiv V_b(\mathbf{X}^F)$. Let $V_i(\mathbf{U}) \equiv V_i(\mathbf{U}, \mathbf{U}_i)$ be the $n_i \times N_F$ matrix of the $i^\mathrm{th}$ OSS's cross-covariances between field data locations, paired with $\mathbf{u}$-values, and $(\mathbf{x}_i, \mathbf{U}_i)$ design locations. Since the $i^\mathrm{th}$ OSS is tailored to $\mathbf{x}_i$ only, independent of the other $\mathbf{X}^F$, this matrix is zero except in the $i^\mathrm{th}$ row. Let $\mathbf{v} \mathbb{I}_{N_F}$ be a $N_F \times N_F$ diagonal matrix holding $V_i(\mathbf{u}', \mathbf{u}')$ values. Although expressed as a function of $\mathbf{u}'$ it is not actually a function of $\mathbf{u}'$ because the distance between $\mathbf{u}'$ and itself is zero. Using Eq.~(\ref{eq:kernel}) would yield $\mathbf{v} \mathbb{I}_{N_F} = \mathrm{Diag}[\tau_i^2 (1 + \eta_i)]$. With those definitions, we have the following: \begin{equation} \mathbb{V}(\mathbf{u}) = \begin{bmatrix} \mathbf{V}_1 & \mathbf{0} & \mathbf{0} & \mathbf{0}& V_1(\mathbf{U})^\top \\ \mathbf{0} & \mathbf{V}_2 & \mathbf{0} & \mathbf{0} & V_2(\mathbf{U})^\top \\ \mathbf{0} & \mathbf{0} & \ddots & \mathbf{0} & \vdots \\ \mathbf{0} & \mathbf{0} & \mathbf{0} & \mathbf{V}_{N_F} & V_{N_F}(\mathbf{U})^\top \\ V_1(\mathbf{U}) & V_2(\mathbf{U}) & \dots & V_{N_F}(\mathbf{U}) & \mathbf{v} \mathbb{I}_{N_F} + V_b(\mathbf{X}^F) \end{bmatrix} \equiv \begin{bmatrix} \mathbb{V}_{o} & \mathbb{V}^\top_{ob}(\mathbf{u}) \\ \mathbb{V}_{ob}(\mathbf{u}) & \mathbb{V}_{b} \end{bmatrix}. \label{eq:Vd} \end{equation} Although $\mathbb{V}(\mathbf{u})$ is huge, being $(N_M + N_F) \times (N_M + N_F)$ or roughly $292292 \times 292292 > 85$ billion entries in our honeycomb setup, it is sparse, having several orders of magnitude fewer nonzero entries---about 292 million in our setup. That is still too big, even for sparse matrix manipulation. Fortunately, the block diagonal structure makes it possible to work with, via more conventional libraries. Toward that end, denote by $\mathbb{V}_{o}=\Diag[\mathbf{V}_i(\mathbf{U}_i, \mathbf{U}_i)]$ the huge $N_F \cdot (n_i \times n_i)$ upper-left block diagonal submatrix from the OSSs. Let $\mathbb{V}_{b}=\mathbf{v}\mathbb{I}_{N_F} + V_b(\mathbf{X}^F)$ represent the remaining (dense) lower-right block, corresponding to the bias. Abstract by $\mathbb{V}_{ob}(\mathbf{u})$ and $V_{ob}^\top(\mathbf{u})$ the remaining, symmetric, rows and columns on the edges. Recall that the $V_i(\mathbf{U})$ therein are themselves sparse, comprising a single row of nonzero entries. Before detailing in Section \ref{sec:kohoss} how we use these blocks, first focus on the specific operations required. A fully Bayesian approach to inference for $\mathbf{u}$ via posterior $p(\mathbf{u} \mid \mathbf{y}^M, \mathbf{y}^F) \propto p( \mathbf{y}^M, \mathbf{y}^F \mid \mathbf{u}) \cdot p(\mathbf{u})$ involves evaluating an MVN likelihood \begin{equation} p( \mathbf{y}^M, \mathbf{y}^F \mid \mathbf{u}) \propto |\mathbb{V}(\mathbf{u}) |^{-\frac{1}{2}} \times \exp \left\{-\dfrac{1}{2} \begin{bmatrix}\mathbf{y}^M \\ \mathbf{y}^F\end{bmatrix}^\top \mathbb{V}^{-1}(\mathbf{u}) \begin{bmatrix}\mathbf{y}^M \\ \mathbf{y}^F\end{bmatrix} \right\}. \label{eq:lik} \end{equation} The main computational challenges are manifest in the inverse $\mathbb{V}^{-1}(\mathbf{u})$ and determinant $|\mathbb{V}(\mathbf{u})|$ calculations, both involving $\mathcal{O}((N_M+N_F)^3)$ flops in addition to $\mathcal{O}((N_M+N_F)^2)$ storage, assuming a dense representation. However, substantial savings comes from the sparse structure (\ref{eq:Vd}) of $\mathbb{V}(\mathbf{u})$ and that only a portion---the edges---involves $\mathbf{u}$. \subsection{On-site surrogate decomposition} \label{sec:kohoss} Partition inverse and determinant equations \citep[e.g.,][]{Petersen:2008} provide convenient forms for the requisite decompositions of $\mathbb{V}(\mathbf{u})$: \begin{align} \mathbb{V}^{-1}(\mathbf{u}) &=\begin{bmatrix} \mathbb{V}_{o} & \mathbb{V}_{ob}^\top(\mathbf{u}) \\ \mathbb{V}_{ob}(\mathbf{u}) & \mathbb{V}_{b} \end{bmatrix} ^{-1} \nonumber \!\!\!\!\!\! = \begin{bmatrix} \mathbb{V}_{o}^{-1} + \mathbb{V}_{o}^{-1} \mathbb{V}_{ob}^\top(\mathbf{u}) \mathbb{C}^{-1}(\mathbf{u}) \mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1} & - \mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u}) \mathbb{C}^{-1}(\mathbf{u}) \\ -\mathbb{C}^{-1}(\mathbf{u}) \mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1} & \mathbb{C}^{-1}(\mathbf{u})\end{bmatrix} \\ |\mathbb{V}(\mathbf{u})| &=\det\begin{bmatrix} \mathbb{V}_{o} & \mathbb{V}_{ob}^\top(\mathbf{u}) \\ \mathbb{V}_{ob}(\mathbf{u}) & \mathbb{V}_{b} \end{bmatrix}= \det(\mathbb{V}_{o}) \times \det(\mathbb{C(\mathbf{u})}), \label{eq:Vdet} \end{align} where $\mathbb{C}(\mathbf{u})= \mathbb{V}_{b} - \mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u})$. Eq.~(\ref{eq:Vdet}) involves a potentially huge $N_M \times N_M$ component $\mathbb{V}_{o}$, with $N_M=286,282$ in the honeycomb example. Since it is block diagonal, thanks to the OSS structure, we have \begin{equation} \mathbb{V}_{o}^{-1} = \Diag[\mathbf{V}_i^{-1}] \quad \mbox{ and } \quad\det(\mathbb{V}_{o})= \prod_{i=1}^{N_F} \det[\mathbf{V}_i]. \label{eq:Vo} \end{equation} In this way, an otherwise $\mathcal{O}(N_M^3)$ operation may instead by calculated via $N_F \times \mathcal{O}(n_i^3)$ calculations, potentially in parallel. If some $n_i$ are big, then the burden could still be substantial. However, both are constant with respect to $\mathbf{u}$, so only one such decomposition is required, even when entertaining thousands of potential $\mathbf{u}$. With $n_i \leq 1000$ in our honeycomb application, these calculations require mere seconds, even in serial. Similar tricks extend to other quantities involved in Eq.~(\ref{eq:Vdet}). Consider $\mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top (\mathbf{u})$, which appears multiple times in original and transposed forms. We have \begin{align} \mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u}) = \Diag [ \mathbf{V}_i^{-1} V_i(\mathbf{U})] =\Diag [\mathbf{h}_i(\mathbf{u})] \quad \mbox{where} \quad \mathbf{h}_i(\mathbf{u}) = \mathbf{V}_i^{-1} V_i(\mathbf{u}), \label{eq:VV} \end{align} and $V_i(\mathbf{u})$ is a vector holding the nonzero part of $V_i(\mathbf{U})$. In other words, $\mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u})$ is a $N_M \times N_F$ matrix comprising $N_F$ column vectors, whose $n_i$ nonzero entries $\mathbf{h}_i$ follow a block structure for columns $i=1,\dots N_F$. Each $\mathbf{h}_i(\mathbf{u})$ can be updated in parallel for new $\mathbf{u}$. Next consider $\mathbb{C}(\mathbf{u}) = \mathbb{V}_{b} -\mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u})$, which appears in each block of Eq.~(\ref{eq:Vdet}). $\mathbb{C}(\mathbf{u})$ is dense but is easy to compute because it is just $N_F \times N_F$. Recall from Eq~.\ref{eq:Vd} that $\mathbb{V}_{b}=\mathbf{v}\mathbb{I}_{N_F}+{V} _b(\mathbf{X}^F)$, which requires inversion only once because it is constant in $\mathbf{u}$. The next part $\mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u})$ extends nicely from $\mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u}) = \mathrm{Diag}[V_i(\mathbf{u})^\top \mathbf{h}_i(\mathbf{u})]$ following Eq.~(\ref{eq:VV}), an $N_F \times N_F$ diagonal matrix whose entries can be calculated alongside the $\mathbf{h}_i(\mathbf{u})$, similarly parallelized over $i=1,\dots,N_F$. Combining $\mathbb{V}_{o}^{-1}\mathbb{V}_{ob}^\top(\mathbf{u})$ and $\mathbb{C}(\mathbf{u})$ results gives $\mathbb{V}_{o}^{-1} \mathbb{V}_{ob}^\top(\mathbf{u}) \mathbb{C}^{-1}(\mathbf{u}) = \mathbf{H}(\mathbf{u}) \circ \mathbb{C}^{-1}(\mathbf{u})$, where ``$\circ$'' is the Hadamard product applied columnwise to $\mathbb{C}^{-1}(\mathbf{u})$ and where $\mathbf{H}(\mathbf{u}) = [\mathbf{h}_1(\mathbf{u}) ; \dots ; \mathbf{h}_{N_F}(\mathbf{u})]$. More concretely, \[ \mathbb{V}_{o}^{-1} \mathbb{V}_{ob}^\top(\mathbf{u}) \mathbb{C}^{-1}(\mathbf{u}) = \begin{bmatrix} c_{1,1}\mathbf{h}_1(\mathbf{u}) & c_{1,2}\mathbf{h}_1(\mathbf{u}) & \dots & c_{1,N_F}\mathbf{h}_1(\mathbf{u}) \\ c_{2,1}\mathbf{h}_2(\mathbf{u}) & c_{2,2}\mathbf{h}_2(\mathbf{u}) & \dots & c_{2,N_F}\mathbf{h}_2(\mathbf{u}) \\ \vdots & \vdots & \ddots & \vdots \\ c_{N_F,1}\mathbf{h}_{N_F}(\mathbf{u}) & c_{N_F,2}\mathbf{h}_{N_F}(\mathbf{u}) & \dots & c_{N_F,N_F}\mathbf{h}_{N_F}(\mathbf{u}) \end{bmatrix} \] where $c_{i,j}$ are scalar elements of $\mathbb{C}^{-1}(\mathbf{u})$. Returning to Eq.~(\ref{eq:Vdet}), combining with Eq.~(\ref{eq:Vo}), establishes the determinant analog. \begin{align} |\mathbb{V}(\mathbf{u})|= \det(\mathbb{V}_{o}) \times \det(\mathbb{C}(\mathbf{u}))= \prod_{i=1}^{N_F} \det[\mathbf{V}_i] \times \det(\mathbb{C}(\mathbf{u})) \end{align} The first component, $\prod_{i=1}^{N_F} \det[\mathbf{V}_i(\mathbf{U}_i, \mathbf{U}_i)]$, is composed of $\mathcal{O}(n_i^3)$ computations, constant in $\mathbf{u}$. Only the second component, $\det(\mathbb{C}(\mathbf{u}))$ needs to be updated with new $\mathbf{u}$. In summary, OSSs can be exploited to circumvent huge matrix computations involved in likelihood evaluation (\ref{eq:lik}), yielding a structure benefiting from a degree of precalculation, and from parallelization if desired. These features come on top of largely improved emulation accuracy demonstrated in Section \ref{sec:merits}, compared with the global alternative. \subsection{Priors and computation} \label{sec:mcmc} As briefly described in Section \ref{sec:optim}, we consider two priors on $\mathbf{u}$, the friction factors in our honeycomb example. The first is independent uniform, $u_j \stackrel{\mathrm{iid}}{\sim} \mathrm{Unif}(0,1)$. The second is $u_j \stackrel{\mathrm{iid}}{\sim} \mathrm{Beta}(2,2)$ as a means of regularizing posterior inference. The marginal posterior for $\mathbf{u}$ is known to sometimes concentrate on the boundaries $\mathbf{u}$-space, because of identifiability challenges in the KOH framework \citep[see, e.g.,][]{gra:etal:2015}. Furthermore, we know that {\tt ISOTSEAL} is least stable in that region. $\mathrm{Beta}(2,2)$ slightly discourages that boundary and commensurately elevates the posterior density of central values. This choice has the added benefit of providing better mixing in the MCMC described momentarily. The coupled GPs involved in the KOH setup are hyperparameterized by scales, lengthscales, and nuggets as in Eq.~(\ref{eq:kernel}). A fully Bayesian analysis would include these in the parameter space for posterior sampling, augmenting the dimension by an order of magnitude in many cases. In other words, the posterior becomes $p(\mathbf{u}, \mathbf{\Phi} \mid \mathbf{y}^M, \mathbf{y}^F)$, where $|\Phi| \in \mathcal{O}(p + p_x)$, $p=p_x+p_u$ for surrogate and $p_x$ for discrepancy, which would work out to more than thirty parameters in our honeycomb example. Because of that high dimensionality, a common simplifying tactic is to fix those $\mathbf{\Phi}$ at their MLE or MAP setting $\hat{\mathbf{\Phi}}$, found via numerical optimization. In our OSS setup, with $N_F = 292$ independent surrogates, the burden of hyperparameterization is exacerbated, with $|\Phi| \in \mathcal{O}(N_F p_u + p_x)$ being several orders of magnitude higher in dimension, over one thousand for honeycomb. This all but demands a setup where point estimates are first obtained via maximization, as in Section \ref{sec:optim}. That leaves only $\mathbf{u}$ for posterior sampling via $p(\mathbf{u} \mid \mathbf{y}^M, \mathbf{y}^F, \hat{\mathbf{\Phi}})$. Additionally, we initialize our Monte Carlo search of the posterior with $\hat{\mathbf{u}}$ values found via Section \ref{sec:optim}. Following KOH, we employ MCMC \citep{Hastings:1970, Gelfand:1990} to sample from the posterior in a Metropolis-within-Gibbs fashion \cite[see, e.g.,][]{hoff2009first}. Each Gibbs step utilizes a marginal random-walk Gaussian proposal $u_j' = u_j + s_j$, $s_j \stackrel{\mathrm{iid}}{\sim} \mathcal N(0, \sigma_j^2)$, $j=1,\dots, p_u$. A pilot tuning stage was used to tune the $\sigma_j$, leading to $\sigma=(0.02, 0.01, 0.2, 0.1)^\top$ in the honeycomb example. Figures \ref{fig:trace}--\ref{fig:res} in Section \ref{sec:calibresults} indicate good mixing and adequate posterior exploration of the four-dimensional space of friction factors. \section{Empirical results} \label{sec:results} Before detailing the outcome of this setup on our motivating honeycomb example, we illustrate the methodology in a more controlled setting. \subsection{Illustrative example} Consider a mathematical model $y^{M^*}(\cdot)$ with three inputs $(x, u_1, u_2)$, following \begin{equation} y^{M^*}(x, u_1, u_2) = \cos \left( \dfrac{25 \sin(x)\times x \times u_1}{x + u_2} \right), \label{eq:toy2} \end{equation} where $x \in [0, 1]$ is a one-dimensional field input and $\mathbf{u}=(u_1, u_2) \in [0, 1]^2$ are two-dimensional calibration parameters. Suppose the real process follows \[ y^R(x) = y^{M^*}(x, 0.8, 0.2) + b(x) \quad \mbox{where} \quad b(x) = \sin(4x). \] Mimicking the features of {\tt ISOTSEAL}, suppose the computer model $y^M$ is unreliable in its evaluation of the mathematical model $y^{M^*}$, sometimes returning {\tt NA} values. Specifically, suppose the response is missing when the $\mathbf{u}$ input is in its upper quartile, $u1 \times u2 > 0.5$, and $[5y^{M^*}] \mod 2 \equiv 0$, where $[\cdot]$ rounds to the nearest integer. Figure \ref{fig:toy} provides an illustration. \begin{figure}[ht!] \centering \includegraphics[width=0.32\linewidth, trim=0 10 20 15, clip]{toy1.pdf} \includegraphics[width=0.32\linewidth, trim=0 10 20 15, clip]{toy2.pdf} \includegraphics[width=0.32\linewidth, trim=0 10 20 15, clip]{toy3.pdf} \caption{Response surfaces illustrating computer model following (\ref{eq:toy2}) with missing values under three settings of $x$.} \label{fig:toy} \end{figure} Each panel in the figure shows the response as a function of $(u_1, u_2)$ for a different setting of $x$. Observe the nonstationary dynamics manifest in increasing waviness of the surface as $x$ increases. Similarly, the pattern of missingness becomes more complex for increasing $x$. Therefore, a global surrogate would struggle on two fronts: with stationarity as well as with (nonmissing) coverage of the design in $\mathbf{u}$-space. Now consider observing $N_F$ field realizations of $y^R(x) + \varepsilon$, where $\varepsilon \sim \mathcal{N}(0, 0.02^2)$, under a maximin LHS in $x$-space, and two variations on a computer experiment toward a calibrated model. The first involves a global GP surrogate fit to $N_M = 500$ computer model evaluations via a maximin LHS in $(x, \mathbf{u})$-space, where 33 (6.6\%) came back {\tt NA}. The second uses OSSs trained on $n_i = 200$ maximin LHSs in $\mathbf{u}$-space, paired with $x_i^F$ for $i=1,\dots,N_F$. Of the $N_M = 2,000$ such simulations, 95 came back missing (4.75\%). The sizes of these computer experiment designs were chosen so that the computing demands required for the global and OSS surrogates were commensurate. Counting flops, the global approach requires about $500^3 = 1.25 \times 10^8$, whereas the OSSs need $10\times 200^3 = 8\times 10^7$, which can be 10-fold parallelized if desired. Before turning to calibration, consider first the accuracy of the two surrogates. Mirroring Figure \ref{fig:rmse} for {\tt ISOTSEAL} in our honeycomb example, Figure \ref{fig:toyrmse} shows the result of an out-of-sample comparison of otherwise identical design. \begin{figure}[ht!] \centering \begin{minipage}{6cm} \includegraphics[scale=0.5,trim=10 40 10 50,clip]{rmse_toy.pdf} \end{minipage} \hspace{1cm} \begin{tabular}{r|rr} & global & OSS \\ \hline min & 0.0472 & 0.0004 \\ 25\% & 0.1090 & 0.0012 \\ med & 0.1357 & 0.0039 \\ mean & 0.1398 & 0.0052 \\ 75\% & 0.1673 & 0.0090 \\ max & 0.2403 & 0.0124 \end{tabular} \caption{Boxplots of 10 out-of-sample RMSEs, where each RMSE is computed by using novel $n_i' \leq 200$, for $i=1,\dots,N_F$.} \label{fig:toyrmse} \end{figure} The story here is similar to the one for {\tt ISOTSEAL}. Clearly, the OSSs are more accurate. They are better able to capture the nonstationarity nature of computer model $y^M(\cdot, \cdot)$ nearby to the field sites. Next, we compare calibration results from global surrogate optimization, OSSs via modularization/optimization [Section \ref{sec:optim}, and OSSs via full Bayes [Section \ref{sec:fullBayes}]. In this simple toy example, uniform priors $u_i \stackrel{\mathrm{iid}}{\sim}\mathrm{Unif}(0,1)$ are sufficient for good performance. The first row of Figure \ref{fig:toyresult} shows the distributions of converged $\hat{\mathbf{u}}$ via Eq.~(\ref{eq:opt}) from the optimization approach described in Section \ref{sec:optim}. The left panel corresponds to the lower-fidelity global surrogate and the right panel to the higher-fidelity OSSs. Converged solutions from 500 random initializations are shown. Terrain colors on the ranked log posteriors are provided to aid in visualization. The best single coordinate $\hat{\mathbf{u}}$ is indicated by the black dot. For comparison, the true $\mathbf{u}^*$ value is shown as red-dashed crosshairs. Although the best $\hat{\mathbf{u}}$ values found cluster near the truth, both are sometimes fooled by a posterior ridge in another quadrant of the space. \begin{figure}[ht!] \centering \includegraphics[width=0.425\linewidth, trim=0 10 20 15, clip]{toy_glob.pdf} \includegraphics[width=0.425\linewidth, trim=0 10 20 15, clip]{toy_opt.pdf} \\ \includegraphics[width=0.425\linewidth, trim=0 10 25 15, clip]{toy_bayes.pdf} \includegraphics[width=0.425\linewidth, trim=0 10 25 15, clip]{toy_bayes2.pdf} \caption{Calibration results from optimization and full Bayes for the toy example. Terrain colors are derived from ranks of log-scaled posteriors as a visual aid; black dots indicate the MAP setting; red dashed lines are the true values of calibration parameters, $\hat{\mathbf{u}}$.}% \label{fig:toyresult}% \end{figure} The second row of Figure \ref{fig:toyresult} shows the posterior distribution of $\mathbf{u}$ in full (left) and zoomed-in ranges (right). Compared with the OSS-based optimization approach, the KOH analog found $\mathbf{u}$'s tightly coupled around the truth. In this simple example, posterior uncertainty is low, in part because a relatively large computer experiment could be entertained in a small input dimension. In fact all three methods worked reasonably well. However, as we entertain more realistic settings, such as the honeycomb in 17 dimensions, only the methods based on OSSs are viable computationally (assuming a relatively dense sampling of the computer model is viable). \subsection{KOH versus modularized optimization: on honeycomb} \label{sec:calibresults} Here we return to our motivating honeycomb seal example, first providing a qualitative comparison between our two approaches based on OSSs, via modularized optimization [Section \ref{sec:optim}] and KOH [Section \ref{sec:fullBayes}]. We then turn to an out-of-sample comparison, pitting the KOH framework against the initial NLS analysis. Throughout, we use a regularizing independent $\mathrm{Beta}(2,2)$ prior on the components of $\mathbf{u}$. Appendix \ref{ap:unif} provides an analog presentation under a uniform prior, accompanied by a brief discussion. Figure \ref{fig:trace} shows traces of the samples obtained via our Metropolis-within-Gibbs scheme, described in Section \ref{sec:mcmc}. \begin{figure}[ht!] \centering \includegraphics[width=0.425\linewidth, trim=0 60 15 50, clip]{trace1.pdf} \includegraphics[width=0.425\linewidth, trim=0 60 15 50, clip]{trace2.pdf}\\ \includegraphics[width=0.425\linewidth, trim=0 15 15 50, clip]{trace3.pdf} \includegraphics[width=0.425\linewidth, trim=0 15 15 50, clip]{trace4.pdf} \caption{Trace plots of MCMC samples for all calibration parameters $\mathbf{u}$ after burn-in. Blue line indicates the best setting for $\mathbf{u}$ from optimization. Red line indicates the MAP $\mathbf{u}$ extracted from the samples; modular/opt added for comparison.}% \label{fig:trace}% \end{figure} The figure indicates clear convergence to the stationary distribution with mixing that is qualitatively quite good. The effective sample sizes (ESS) \citep{kass:1998}, marginally for all four friction factors, are sufficiently high at $\mathrm{ESS}_{u_1} = 1026$, $\mathrm{ESS}_{u_2}= 684$, $\mathrm{ESS}_{u_3}=2062$, $\mathrm{ESS}_{u_4}=1462$, respectively. Figure \ref{fig:trace} clearly shows that the posterior is, at least marginally, far more concentrated for the first two friction factors (first row) than for the last two. For a better joint glimpse at the four-dimensional posterior distribution of $\mathbf{u}$, the bottom-left panels of Figure \ref{fig:res} show these samples via pairs of coordinates. The points are colored by a rank-transformed log-scaled posterior evaluation as a means of better visualizing the high concentrations in a cramped space. Histograms along the diagonal panels show individual margins; panels on the top-right mirror those on the bottom-left but instead show solutions found by the modular/optimal approach [Section \ref{sec:optim}] in 500 random restarts. \begin{figure}[ht!] \centering \includegraphics[width=1\linewidth, trim=25 25 25 40,clip=TRUE]{results.png} \includegraphics[width=1\linewidth, trim=50 40 16 55,clip=TRUE]{colorscale.png} \caption{Bayesian KOH (lower and diagonal) posterior for $\mathbf{u}$ vs.~modularlized optimization (upper) analog, both under an independent $\mathrm{Beta}(2,2)$ prior for $\mathbf{u}$. Colors are derived from ranks of posterior probabilities to aid in visualization. Modularized results are from 500 converged optimization under random initialization. Black dots indicate MAP values.} \label{fig:res}% \end{figure} Several notable observations can be drawn from the plots in that figure. For one, consistency is high between the two approaches: KOH and modular/opt. Although the values of log posteriors evaluations are not directly comparable across the models, both agree on most probable values (black dots in the off-diagonal panels). A diversity of solutions from the optimization-based approach indicates that the solver struggles to navigate the log posterior surface but usually finds estimates that are in the right ballpark. The full posterior distribution via KOH indicates that the first two friction factors are well pinned-down by the posterior. However, posterior concentration is more diffuse for the latter two. A complicated correlation structure is evident in $(u_3, u_4)$. A similar suite of results under an independent uniform prior is provided in Appendix \ref{ap:unif}. The story there is similar, except that the posterior sampling concentrates more heavily on the boundary of $\mathbf{u}$-space for all four parameters. Considering that we know our {\tt ISOTSEAL} simulator is less reliable in those regimes, leading to far more missing values and thus requiring greater degree of extrapolation from our OSSs, we prefer the more stable regime (better emulation and MCMC mixing) offered by light penalization under a $\mathrm{Beta}(2,2)$ prior. \subsection{Out-of-sample prediction} \label{sec:oosresults} To close the loop on our NLS comparison from Section \ref{sec:nls}, particularly Figure \ref{fig:nls} highlighting in-sample prediction, we conclude our empirical work on the honeycomb with an exercise \blu{measuring} out-of-sample \blu{predictive accuracy}. \blu{Pointwise comparators based on several variations are entertained, e.g., with/without OSSs, with/without estimated discrepancies compensating for bias. Finally, we complete the Bayesian KOH OSS setup (Section \ref{sec:fullBayes}) with a predictor that tractably propagates uncertainty through the sparse covariance structure.} \blu{The NLS baseline from Section \ref{sec:nls} involves direct application of {\tt ISOTSEAL} for new physical (testing) site $\mathbf{x}_{\mathrm{\mathrm{new}}}$, paired with plug-in $\hat{\mathbf{u}}$ furnished by our BHGE colleagues: } \blu{ \begin{align} \hat{y}^F(\mathbf{x}_{\mathrm{\mathrm{new}}}) = {y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}},\hat{\mathbf{u}}^\text{NLS}) \end{align} } \blu{No bias correction is applied. Figure \ref{fig:loo}, augmenting Figure \ref{fig:nls}, provides a view into residuals under this comparator, and others explained momentarily. We clarify that these NLS results are "in-sample" as they use the same data our BHGE colleagues trained on. Precise root mean-squared errors (RMSEs) and $\hat{\mathbf{u}}$-values are summarized in Table \ref{tab:pred}.} \blu{Feeding $\hat{\mathbf{u}}$ directly into {\tt ISOTSEAL} is problematic because simulation dynamics are nonstationary, unstable, and unreliable.} We had trouble getting an implementation of this variation to behave reliably enough in order to report meaningful out-of-sample results. \blu{As demonstrated in Section \ref{sec:isotseal}, and the second row in Figure \ref{fig:loc2}, {\tt ISOTSEAL} can fail to converge and instead return ${y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}},\hat{\mathbf{u}})= $ {\tt NA} especially at $\mathbf{u}$ around the upper limit of their range(s). Our BHGE colleagues carefully engineered their NLS search to avoid problematic $\mathbf{u}$-settings. OSSs were proposed in order to more gracefully cope with {\tt NA}s and to correct for other idiosyncrasies. When predicting out of sample, a new OSS $\hat{y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}}, \cdot)$ must be fit via new on-site design $\mathbf{U}_{\mathrm{\mathrm{new}}}$ paired with $\mathbf{x}_{\mathrm{\mathrm{new}}}$. As with OSS training described in Section \ref{sec:oss}, we shall utilize a size $n=1000$ maximin LHS. } \blu{Surrogate $\hat{y}^M(., .)$ enables a full search of the entire $\mathbf{u}$-space, offering the potential of finding a better $\hat{\mathbf{u}}$ especially nearby regions where direct {\tt ISOTSEAL} runs may fail. Acting on OSSs without discrepancy correction, we find $\hat{\mathbf{u}}^{\text{OSS}}_\text{nobias}$ slightly different from the $\hat{\mathbf{u}}^\text{NLS}$ using direct {\tt ISOTSEAL} runs. See Table \ref{tab:pred}. To compare the predictive performance directly to the in-sample NLS, we plug-in $\hat{\mathbf{u}}^{\text{OSS}}_\text{nobias}$ for new site $\mathbf{x}_{\mathrm{\mathrm{new}}}$ though the new OSS: } \blu{ \begin{align} \hat{y}^F(\mathbf{x}_{\mathrm{\mathrm{new}}}) = \hat{y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}},\hat{\mathbf{u}}^{\text{OSS}}_\text{nobias}). \end{align} } \blu{Figure \ref{fig:loo} indicates similar residual behavior for these two comparators. OSSs without bias correction fares slightly worse than the NLS analog, however note that the latter is truly out-of-sample and the former was technically in-sample. The OSS version $\hat{y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}},\hat{\mathbf{u}}^{\text{OSS}}_\text{nobias})$ offers fuller uncertainty quantification in predictions, via local GP predictive variances.} \blu{Now consider variations which correct for potential bias between OSS and field data measurements.} Feed $\hat{\mathbf{u}}$ through the OSS and obtain \begin{align} \hat{y}^F(\mathbf{x}_{\mathrm{\mathrm{new}}}) = \hat{y}^M(\mathbf{x}_{\mathrm{\mathrm{new}}},\hat{\mathbf{u}}) + \hat{b}(\mathbf{x}_{\mathrm{\mathrm{new}}}) \end{align} To benchmark \blu{these} predictions \blu{out of sample} we designed the following leave-one-out (LOO) cross-validation (CV) experiment. Alternately excluding each field data location $i=1,\dots,N_F=292$, we fit 292 LOO discrepancy terms $\hat{b}^{(-i)}(\cdot)$ via residuals $\mathbf{y}^F_{(-i)}-\hat{\mathbf{y}}^M_{(-i)}$ and $\mathbf{X}^F_{(-i)}$. We could build a new OSS for $\mathbf{x}_i$, treating it as a $\mathbf{x}_{\mathrm{\mathrm{new}}}$ as described above, but instead it is equivalent (and computationally more thrifty) to use the $\mathbf{U}_i$ we already have. Based on those calculations, point predictions are composed of \begin{align} \hat{y}^F({\mathbf{x}_i}) = \hat{y}^M(\mathbf{x}_i, \hat{\mathbf{u}})+\hat{b}^{(-i)}(\mathbf{x}_i), \quad \mbox{for} \quad i=1, 2, \dots, N_F. \label{eq:LOO_bias} \end{align} Predictions thus obtained are compared with true outputs $\mathbf{y}^F$ and residuals for RMSE calculations. We note that this experiment focuses primarily on bias correction. New $\hat{\mathbf{u}}_{(-i)}$ are not calculated for each of $i=1,\dots,N_F$ \blu{due to the prohibitive computational cost.} \begin{figure}[ht!] \centering \includegraphics[width=0.49\linewidth, trim=0 0 0 0, clip]{LOO_res1.pdf} \includegraphics[width=0.49\linewidth, trim=0 0 0 0, clip]{LOO_res2.pdf} \caption{Residuals to honeycomb field data. The left panel shows histograms comparing three approaches; the right panel plots them versus the true response.} \label{fig:loo} \end{figure} Figure \ref{fig:loo} shows those LOO residuals graphically alongside our other comparators. Only results for $\hat{\mathbf{u}}$ via modular/opt framework are shown here since $\hat{\mathbf{u}}$ from the fully Bayes KOH setup are similar. The panels in the figure indicate that bias correction offers substantial improvement over NLS: in-sample NLS residuals are worse than LOO OSS Bayes results. Summarizing those residuals, \blu{modular/opt calibration with discrepancy has an leave-one-out RMSE of $2.126$, being even smaller than both the in-sample NLS value of $6.605$ reported in Section \ref{sec:nls} and the in-sample OSS no-bias value of $6.818$. Furthermore, LOO OSS modular/opt RMSE is comparable to its in-sample analog of $1.125$.} \begin{table}[ht!] \blu{ \centering \begin{tabular}{r | r | r | r | r | r} Method &$\hat{u}_1$ &$\hat{u}_2$ & $\hat{u}_3$& $\hat{u}_4$ & RMSE \\ \hline In-sample NLS & 0.00000 & 0.00000 & 0.82123 & 0.99615 & 6.605\\ OSS No Bias & 0.00877 & 0.17352 & 0.94893 & 0.94474& 6.818 \\ In-sample OSS Bayes & 0.93659 & 0.98348 & 0.28441 & 0.25975 & 1.125 \\ LOO OSS modular/opt & 0.93659 & 0.98348 & 0.28441 & 0.25975 & 2.126\\ LOO OSS KOH full Bayes & 0.93659 & 0.98348 & 0.28441 & 0.25975 & 1.957\\ \end{tabular} \caption{Estimated $\hat{\mathbf{u}}$ and RMSEs from in-sample and LOO comparisons.} \label{tab:pred} } \end{table} \blu{ Next we develop fully Bayesian prediction for $y^F(\mathbf{X}^F_{\mathrm{new}})$ at $N'_F$ new physical locations $\mathbf{X}^F_{\mathrm{new}}=(\mathbf{x}^{\mathrm{new}}_1, \mathbf{x}^{\mathrm{new}}_2, \dots, \mathbf{x}^{\mathrm{new}}_{N'_F})^\top$. As in the pointwise case, $N'_F$ new OSSs must be built on $N'_M$ new on-site simulations $\mathbf{y}^M_{\mathrm{new}} = (\mathbf{y}_{N_F+1}, \dots, \mathbf{y}_{N_F+N'_F})^\top$. Following from Eq.~(\ref{eq:lik}), \begin{align} \begin{bmatrix} \mathbf{y}^M \\ \mathbf{y}^F \\ \mathbf{y}^M_{\mathrm{new}} \\ \mathbf{y}^F_{\mathrm{new}} \end{bmatrix} = \begin{bmatrix} \mathbf{y}_1 \\ \vdots \\ \mathbf{y}_{N_F} \\ \mathbf{y}^F \\ \mathbf{y}_{N_F+1} \\ \vdots \\\mathbf{y}_{N_F + N'_F} \\ \mathbf{y}^F_{\mathrm{new}} \end{bmatrix} = \begin{bmatrix} y_1(\mathbf{U}_1)\\ \vdots \\ y_{N_F}(\mathbf{U}_{N_F}) \\ y^M(\mathbf{U}) + b(\mathbf{X}^F) \\ y_{N_F+1}(\mathbf{U}_{N_F+1})\\ \vdots \\ y_{N_F + N'_F}(\mathbf{U}_{N_F + N'_F}) \\ y^M_{\mathrm{new}}(\mathbf{U}_{N'_F}) + b(\mathbf{X}_{\mathrm{new}}^F) \end{bmatrix} \sim \mathcal{N (\mathbf{0}, \mathbb{V}^P(\mathbf{u})) \label{eq:d_new} \end{align} where $\mathbf{U}_{N'_F}=[\mathbf{u}^\top; \cdots; \mathbf{u}^\top]^\top$ stacks $N'_F$ identical $p_u$-dimensional row vectors $\mathbf{u}^\top$. The $(N_M + N_F + N'_M + N'_F) \times (N_M + N_F + N'_M + N'_F)$ covariance matrix $\mathbb{V}^P(\mathbf{u})$, combining OSS training data and out-of-sample data elements, may be built as follows \begin{align} \mathbb{V}^P(\mathbf{u}) =\begin{bmatrix} \mathbb{V}_{o} & \mathbb{V}^\top_{ob}(\mathbf{u}) & \mathbf{0} & \mathbf{0} \\ \mathbb{V}_{ob}(\mathbf{u}) & \mathbb{V}_{b} & \mathbf{0} & \mathbb{V}_{b}^\top(\mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F) \\ \mathbf{0} & \mathbf{0} & \mathbb{V}^{\mathrm{new}}_{o} & \mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u})^\top\\ \mathbf{0} & \mathbb{V}_{b}( \mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F) & \mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u}) & \mathbb{V}^{\mathrm{new}}_{b} \end{bmatrix}, \label{eq:Vdnew} \end{align} borrowing notation for $\mathbb{V}(\mathbf{u})$ from Eq.~(\ref{eq:Vd}). } \blu{Like $\mathbb{V}(\mathbf{u})$, $\mathbb{V}^P(\mathbf{u})$ emits sparse block-wise structure due to the OSSs. Extending from Eq.~(\ref{eq:Vd}), we have $\mathbb{V}^{\mathrm{new}}_{o}=\Diag[\mathbf{V}_i(\mathbf{U}_i, \mathbf{U}_i)]$, for $i = N_F+1, \dots, N_F+ N'_F$, an upper-left block diagonal submatrix. Similarly $\mathbb{V}^{\mathrm{new}}_{b}=\mathbf{v}_{\mathrm{new}} \mathbb{I}_{N'_F} + V_b(\mathbf{X}^F_{\mathrm{new}})$, where $\mathbf{v}_{\mathrm{new}} \mathbb{I}_{N'_F}$ is a diagonal of nugget effects from the new OSSs, and $ V_b(\mathbf{X}^F_{\mathrm{new}})$ is the covariance matrix on $\mathbf{X}^F_{\mathrm{new}}$ from the bias correction. $\mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u})$ and $\mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u})^\top$ are similar to $\mathbb{V}_{ob}(\mathbf{u})$ and $\mathbb{V}^\top_{ob}(\mathbf{u})$, composed of $V_i(\mathbf{U}_{N'_F})$ with $i = N_F + 1, \dots, N_F + N'_F$. Each $V_i(\mathbf{U}_{N'_F})$ is sparse with single row of non-zero entries. In Eq.~(\ref{eq:Vdnew}), the new OSS on $\mathbf{X}^F_{\mathrm{new}}$ is sparse between training data $(\mathbf{y}^M, \mathbf{y}^F)$ and new data $(\mathbf{y}^M_{\mathrm{new}}, \mathbf{y}^F_{\mathrm{new}})$, involving only the small $N'_F \times N_F$ bias covariance $\mathbb{V}_{b}(\mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F) $. } \blu{ Using those definitions, the predictive distribution of $\mathbf{y}^F_{\mathrm{new}}$ conditioning on both data sources, $(\mathbf{y}^M, \mathbf{y}^M_{\mathrm{new}})$ from simulation and $\mathbf{y}^F$ from physical experiments, hyperparameters $\bm{\Phi}$ and calibration parameter $\mathbf{u}$, is MVN with mean $\mathbf{m}_{\mathrm{new}}$ and covariance $\mathbf{V}_{\mathrm{new}}$ following \begin{align} \mathbf{m}_{\mathrm{new}} &= \mathbb{V}_{b}(\mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F) \mathbb{C}^{-1}(\mathbf{u})[ \mathbf{y}^F -\mathbb{V}_{ob}(\mathbf{u}) \mathbb{V}_{o}^{-1} \mathbf{y}^M] + \mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u}) (\mathbb{V}^{\mathrm{new}}_{o})^{-1}\mathbf{y}^M_{\mathrm{new}} \label{eq:mnew} \\ \mathbf{V}_{\mathrm{new}} &= \mathbb{V}^{\mathrm{new}}_{b}- \mathbb{V}_{b}(\mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F) \mathbb{C}^{-1}(\mathbf{u}) \mathbb{V}_{b}(\mathbf{X}^F_{\mathrm{new}}, \mathbf{X}^F)^\top -\mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u}) (\mathbb{V}^{\mathrm{new}}_{o})^{-1} \mathbb{V}^{\mathrm{new}}_{ob}(\mathbf{u})^\top. \label{eq:vnew} \end{align} Fully Bayesian uncertainty quantification using Eqs.~(\ref{eq:mnew}--\ref{eq:vnew}) is tractable. Sparse-matrix decompositions can be applied in a manner similar to likelihood evaluation Section \ref{sec:kohoss}. } \begin{figure}[ht!] \centering \includegraphics[width=0.65\linewidth, trim=0 0 0 0, clip]{pred_Bayes.pdf} \caption{\blu{Fully Bayesian out-of-sample predicted $\mathbf{y}^F$ with 95\% credible interval over observed honeycomb field data $\mathbf{y}^F$.}} \label{fig:predBayes} \end{figure} \blu{Consider deploying these equations in our out-of-sample setup, re-using the new OSSs trained for the pointwise comparisons. Following a similar LOO setup, we derive $(\mathbf{y}^F_{i} \mid \mathbf{y}^M_{-i}, \mathbf{y}^F_{-i}, \mathbf{y}^M_{i}, \bm{\Phi}, \mathbf{u}^{(t)}) \sim \mathcal{N}_{i}(\mathbf{m}_{i}, \mathbf{V}_{i} )$ via Eqs.~(\ref{eq:mnew}--\ref{eq:vnew}) integrating over $\mathbf{u}$ by aggregating over Monte Carlo samples for $\{\mathbf{u}^{(t)}\}_{t=1}^{T}$ shown in bottom-left panels of Figure \ref{fig:res}. When aggregating covariances, covariances of sample means are incorporated respecting the law of total variance. Figure \ref{fig:predBayes} shows this fully Bayesian predicted mean with 95\% credible interval over each observed $\mathbf{y}^F$. In contrast to to the previous leave-one-out experiments described in Eq. \ref{eq:LOO_bias}, which involved 292 LOO discrepancy terms $\hat{b}^{(-i)}(\cdot)$ via residuals $\mathbf{y}^F_{(-i)}-\hat{\mathbf{y}}^M_{(-i)}$ and $\mathbf{X}^F_{(-i)}$, results in Figure \ref{fig:predBayes} provide full out-of-sample posterior predictive uncertainty for both the simulation and the discrepancy correction.} \section{Discussion} \label{sec:discussion} Motivated by a computer model calibration problem the design of a seal used in turbines, we developed a thrifty new method to address several challenging features. Those challenges include a high-dimensional input space, local instability in computer model simulations, nonstationary simulator dynamics, and modeling for large computer experiments. Taken alone, each of these challenges has solutions that are, at least in some cases, well established in the literature. Taken together, a more deliberate and custom development was warranted. To meet those challenges, we developed the method of on-site surrogates. The construction of OSSs is motivated by the unique structure of the posterior distribution under study in the canonical \citeauthor{Kennedy:O'Hagan:2001} calibration framework, where predictions are needed only at a limited number of field data sites, no matter how big the computer experiment is. This unique structure allowed us to map a single, potentially high-dimensional problem, into a multitude of low-dimensional ones where computation can be performed in parallel. Two OSS-based calibration settings were entertained, one based on simple bias-corrected maximization and the other akin to the original KOH framework. Both were shown to empirically outperform simpler, yet high-powered, alternatives. Despite its many attractive features, there is clearly much potential to refine this approach, in particular the design and modeling behind the OSSs. While simple Latin hypercube samples and GPs with exponential kernels and nuggets work well, several simple extensions could be quite powerful. The need for such extensions, along at least one avenue, is perhaps revealed by the final row of Figure \ref{fig:loc2}. Those plots show bifurcating {\tt ISOTSEAL} runs due to numerical instabilities. Although inflated nuggets enable smoothing over those regimes, the result is uniformly high uncertainty for all inputs rather than just near the trouble spot. The reason is that the GP formulation being used is still (locally) stationary. Specifically, the error structure is homoskedastic. Using a heteroskedastic GP instead \citep{Binois2017}, say via {\tt hetGP} on CRAN \citep{hetGP}, could offer a potential remedy. In a follow-in paper \cite{Binois2018} showed how designs for effective {\tt hetGP} modeling could be built up sequentially, balancing an appropriate amount of exploration and replication in order to effectively learn signal-to-noise relationships in the data. Such an approach could represent an attractive alternative to simple LHSs in $\mathbf{u}$-space. Here we only entertained a single output $k_{\mathrm{dir}}$, at a single frequency, among a multitude of others and at other frequencies. In future work we plan to investigate a multiple output approach to calibration. Much work remains to assess the potential for such an approach, say via simple {\em co-kriging} \citep{verhoef:barry:1997} or a linear model of co-regionalization \citep[e.g.,][]{wack:1998}. Our BHGE collaborators' pilot study also indicated that there could potentially be input-dependent variations in the best setting of the friction factors. That is, we could be looking at a $\hat{\mathbf{u}}(\mathbf{x})$, perhaps for a subset of the coordinates of the 13-dimensional $\mathbf{x}$ input. Whether a simple partition-based or linear scheme might be appropriate, or if something more nonparametric like \citep{brown:atam:2016} is required, remains an open question. \blu{We'd like to close with a thought on confounding and identifiability, an ever-present concern in the KOH setting. OSSs are no help here, essentially chopping up the design space, limiting information sharing and reducing the (Bayesian) learning that could transpire about calibration parameters compared to the usual (global) setup. Although we have seen no evidence of concern, it is possible that OSSs would exacerbate the problem. However, we note that the underlying framework -- linking a latent $\mathbf{u}$-variable to a nonparametric discrepancy -- is identical whether or not OSSs are deployed. Accordingly, simplifications \citep{tuo2015} or extensions \citep{plumlee2017bayesian} are similarly viable as a means of limiting sources of confounding that challenges identifiability.} \blu{There are many reasons to calibrate, with KOH or otherwise. One is simply predictive; another is to get a sense of how the apparatus could be tuned, or to quantify how much information is in the data (and prior) about promising $\mathbf{u}$ settings. Both are very doable, and worth doing, even in the face of confounding. Our posterior summaries for $\mathbf{u}$ are a testament in this regard. In our toy example, which has many features in common with the motivating honeycomb seal, the posterior is quite peaked. Does this mean our $\hat{\mathbf{u}}$ or Bayesian samples $\mathbf{u}^{(t)}$ have identified the right $\mathbf{u}^*$? Possibly not in general, except that we know the truth in this case and identification can be confirmed. Our posterior for $\mathbf{u}$ in the honeycomb example shows sharp concentration for some inputs, less for others, and interpretable correlation in one pair $(u_3, u_4)$. Our colleagues at BHGE were not surprised by these results, and found them to be helpful in designing new field experiments. Although we cannot be confident about identification in this example, KOH has been a useful exercise.} \if00{ \subsubsection*{Acknowledgments} Authors JH, RBG, and MB are grateful for support from National Science Foundation grants DMS-1521702 and DMS-1821258. JH and RBG also gratefully acknowledge funding from a DOE LAB 17-1697 via subaward from Argonne National Laboratory for SciDAC/DOE Office of Science ASCR and High Energy Physics. The work of MB is partially supported by the U.S. Department of Energy, Office of Science, Office of Advanced Scientific Computing Research, under Contract No. DE-AC02-06CH11357. \blu{We thank Andrea Panizza for early NLS work on this project, and for initiating the line of research. We are grateful to two referees for thoughtful suggestions which led to many improvements. Finally, we wish to thank our collaborators at Baker Hughes/GE for being generous with their data, their time, and their expertise. \blu{} }\fi \section{Appendix: Calibration under uniform prior} \label{ap:unif} For completeness, we provide calibration results under a uniform prior in Figure \ref{fig:res2}, complementing those from Figure \ref{fig:res} under $\mathrm{Beta}(2,2)$. \begin{figure}[ht!] \centering \includegraphics[width=1\linewidth, trim=25 25 25 40,clip=TRUE]{kdir_uniform} \includegraphics[width=1\linewidth, trim=50 40 16 55,clip=TRUE]{colorscale.png} \caption{Bayesian KOH (lower and diagonal) posterior for $\mathbf{u}$ vs.~modularized optimization (upper) analog, both under an independent uniform prior for $\mathbf{u}$. Colors are derived from ranks of posterior probabilities to aid in visualization. Modularized results are from 500 converged optimization under random initialization. Black dots indicate MAP values. } \label{fig:res2} \end{figure} Compared with those results, the ones shown here more heavily concentrate on the boundaries of the study region. Also, somewhat more inconsistency exists between the modular/opt results and the fully Bayesian analog. The regularization effect of the $\mathrm{Beta}(2,2)$ leads to better numerics.
{'timestamp': '2019-07-19T02:13:55', 'yymm': '1810', 'arxiv_id': '1810.01903', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01903'}
arxiv
\section{Introduction} \iffalse With the increasing reliance on networking, we have a growing concern about cyber-security. For instance, distributed denial of service (DDoS) attacks are prevalent in the Internet, and a recent analysis shows that DDoS attack volumes increased by 50\% in Q2 2018.\footnote{https://www.link11.com/en/blog/latest-link11-ddos-report-shows-that-ddos-attack-volumes-increased-by-50-in-q2-2018/} Moreover, a new type of such attacks began to utilize hundreds of thousands of IoT devices\footnote{http://www.eweek.com/security/ddos-attack-snarls-friday-morning-internet-traffic.html}, which considerably outnumbers the traditional computers. In addition, the impacts of cyber-attacks are much more significant. Several datacenters were targeted by DDoS attacks in 2016, which caused Twitter, Spotify, and other major sites to closed down.\footnote{http://www.cisco.com/c/dam/en/us/solutions/collateral/service-provider/visual-networking-index-vni/complete-white-paper-c11-481360.pdf} In 2017, a ransomware attack (known as ``WannaCry'') hit the global world affecting over 10,000 organizations in over 150 countries.\footnote{http://www.gartner.com/newsroom/id/3715918} Data breach is also a growing concern with the financial and privacy problems. An example of the stunned incidents is the Equifax data breach lasted from mid-May to July and the hackers stole credit card numbers for over 200,000 people.\footnote{https://www.consumer.ftc.gov/blog/2017/09/equifax-data-breach-what-do} \fi With the growing intensity of cyber attacks, it is becoming even more crucial to identify this malicious activity in a timely manner. One such technique is scanning individual packets for textual patterns (also known as "signatures") that have been previously collected from other attack packets~\cite{vasilomanolakis2015taxonomy}. Although this idea is appealing due to its high detection accuracy, its limitations cannot be ignored, namely various encryption and privacy issues. Another approach in identifying potential network intrusions is the use of machine learning that relies on statistical information without analyzing internal payload~\cite{buczak2016survey}. Due to the rapid, modern development of machine learning technologies, this alternative approach has been widely accepted by the network intrusion detection research community. When applying this approach, datasets with associated label information is crucial to not only identify malicious packets and connections, but also to construct learning models. However, there is a lack of relevant, publicly available datasets for researchers in the network detection intrusion community. Thus, a substantial part of past network detection intrusion studies has only relied on a small number of public data sets such as KDD Cup 1999 Data\footnote{http://kdd.ics.uci.edu/databases/kddcup99/kddcup99.html}~\cite{ahmed2016survey}. The KDD Cup 1999 data was constructed by experts with substantial domain knowledge, to provide necessary connection and attack information (i.e., 41 attributes and the associated label for each connection). While this dataset is still relevant to this day in measuring initial performances of learning-based detection models, it is arguable that the KDD Cup 1999 data is outdated and ineffective in representing today's network, especially considering recent technological developments with a wide variety of services and applications. A critical part in creating datasets is the construction of labels. Like the KDD Cup 1999 data, label construction is often done by human experts, and is thus highly laborious and expensive. Because of this, only few public datasets have been published despite the growing importance of intrusion detection research. In this paper, we introduce our method to construct network flow data that would aid the development of learning-based intrusion detection methods, especially concerning that in a NetFlow-compatible format. Our method combines the packet meta-information with IDS logs to infer labels containing intrusion information for individual flows. In this study, we analyze MAWILab traces that provides IDS logs with the packet meta-data~\cite{MAWILab} to generate labeled flow data. The organization of the presentation is as follows. In Section~\ref{sec:public_datasets}, we introduce three public datasets containing label information for network intrusion detection research. We then transition into a two-step process which generates flow data and associated labels from the packet trace and IDS log file in Section~\ref{sec:method}. Our summary thus concludes our presentation in Section~\ref{sec:conc}. \section{Public Datasets for Network Intrusion Detection} \label{sec:public_datasets} In this section, we provide a short summary of recently collected public datasets, including the KDD Cup 1999 dataset. \paragraph{{\bf KDD Cup 1999 dataset}} The KDD Cup 1999 dataset contains 9-week TCP dump data collected from a local area network in 1998. Each connection record contains the basic features of TCP connection, such as login failure, root access attempt, and others, as well as traffic features including connection error rates. In total, there are 41 attributes from the three types of feature sets. Along with these features, an associated label is provided that can be classified in five categories: normal, DOS (denial-of-service), R2L (unauthorized access from a remote machine), U2R (unauthorized access to local root privileges), and probing (surveillance and other probing). The KDD Cup 1999 dataset contains a significant number of repeated connections, which may cause biased results when evaluating intrusion detection methods. A modified version of this dataset, known as NSL-KDD~\cite{NSLKDD}, reduces such repeated connections to improve the data's quality. \paragraph{{\bf UNSW-NB15 dataset}~\cite{moustafa2015unsw}} The UNSW-NB15 dataset is a more recent dataset, as it was collected in 2015. A traffic generator tool is configured on three servers; two of which are for the normal spread of traffic and one of which for malicious traffic. The routers in this configuration capture packets and create pcap files. The Bro-IDS tool\footnote{https://www.bro.org/} is utilized to generate log files from captured pcap files, along with 49 features. The total number of records is over two millions in four CSV files. This dataset also offers a training set and testing set for evaluation purpose. \paragraph{{\bf IDS 2017 dataset}~\cite{sharafaldin2018toward}} The testbed to collect data includes two networks: one for attacks and the other for victims. The captured dataset contains several different types of attacks including DoS, Web attack, infiltration attack, botnet attack, portscan, as well as background normal traffic generated by using abstract behavior of 25 users based on HTTP/HTTPS, FTP, SSH, and email protocols. The captured data is five days long, from Monday, July 3, 2017 to Friday July 7, 2017. The first day contains normal traffic only, while the other days have malicious activities. The number of records is over 2.8 millions with 85 features including label information. As seen above, all the datasets were constructed in simulated environments with dedicated networks and servers, an expensive and grueling task. In this work, we will demonstrate how to construct datasets beneficial for intrusion detection research from the packet meta-data and IDS logs, without configuring expensive simulated environments. \section{Data generation from MAWILab traces} \label{sec:method} In this section, we introduce our method to generate flow data with associated labels for network intrusion detection research. The generation process consists of the following two steps: \begin{enumerate} \item The first step extracts flow information from the packet trace file (pcap); \item The second step combines the IDS log data with the flow data constructed in the first step using the four-tuple of flow information (source/destination IP addresses and port numbers). \end{enumerate} We first describe the overview of the MAWILab data, and then present the data generation process in detail. \subsection{Description of MAWILab data} MAWILab provides a collection of network traffic traces and IDS logs, captured from a backbone link in Japan for about two decades up to now~\cite{mazel2014visual}\cite{callegari2016statistical}. The captured traces contain the TCP/IP packet header information without payloads in pcap files. One pcap file contains 15-minute data on a single day. The traces are publicly available to access.\footnote{http://mawi.wide.ad.jp/mawi/} In addition to the packet traces, it provides the IDS logs~\cite{MAWILab}. The log contains the label information as well as IP addresses and transport port numbers. The labels then are inferred using a graph-based method that compares and combines different and independent detection entities. Table~\ref{tab:mawilab_log} shows the columns in the IDS log. The label has three classes: {\em anomalous}  is for a true anomaly, {\em suspicious}  indicates the traffic is highly likely to be anomalous, and {\em notice}  is assigned if some detectors reported the traffic as an anomaly but it does not reach a consensus by the entire detectors. In the current design, we only consider {\em anomalous} and {\em suspicious} in our method. \begin{table}[!tb] \small \caption{MAWILab IDS log columns} \label{tab:mawilab_log} \centering \begin{tabular}{ll} \hline Column & Description \\ \hline sip & Source IP address \\ dip & Destination IP address \\ sport & source port \\ dport & destination port \\ taxonomy & Category of anomalies (e.g., Port scan, DoS, etc) \\ heuristic & Code assigned to anomalies \\ & using  the internal heuristic \\ distance & $D_n-D_a$, \\ & $D_n$=distance to normal traffic, \\ & $D_a$=distance to anomalous traffic \\ nbDetectors & Number of detectors reported this anomaly \\ label & \{anomalous, suspicious, notice\} \\ \hline \end{tabular} \end{table} \subsection{First step: generating flow data} We construct network flow data from MAWILab packet traces using SiLK\footnote{https://tools.netsa.cert.org/silk/}. To briefly summarize, SiLK (System for Internet-Level Knowledge) is a collection of traffic analysis tools developed to facilitate network traffic analysis. Using this tool, it is possible to extract the flow information from TCP dump files in question. Note that the output in this step will be combined with the IDS log data to generate the label information in the second step. To obtain the flow information, we use the following two commands in SiLK: {\tt rwptoflow} generates flow records from the given packet data, and {\tt rwcut} displays the selected fields from the SiLK flow records. The following shows how to extract the flow information from the packet trace using {\tt rwptoflow} and {\tt rwcut}. {\tt \small \begin{itemize} \item[$>$] rwptoflow path --flow-out=filename.rw \iffalse \item[$>$] rwstats path \\ --fileds=fieldsList \\ --values=Flows \\ --output-path=yyyymmdd\_result.data \\ --percentage=0 \fi \item[$>$] rwcut path --fields=fieldsList \\ --output-path=filename.data \end{itemize} } Here, ``path'' is the directory that the output file is stored, and ``filename'' is the output file name. For the {\tt --fields} option, ``fieldsList'' specifies a list of the fields saved in the output file. The list of the entire fields available can be found from: \url{https://tools.netsa.cert.org/silk/rwcut.html}. Note that {\tt rwstats} can be alternatively used instead of {\tt rwcut}, which makes a summary output and reorders the entries (in contrast, {\tt rwcut} preserves the output order). Here is an example. We downloaded a pcap file of ``201807011400.pcap.gz'' (1426.45 MB) from the trace repository.\footnote{\url{http://mawi.wide.ad.jp/mawi/samplepoint-F/2018/201807011400.html}} Then, the following commands are executed to obtain the flow data from the given trace. In this example, the resulted flow data is written to a file named ``20180701\_result.data''. {\tt \small \begin{itemize} \item[$>$] rwptoflow 201807011400.pcap --flow-out=20180701.rw \iffalse \item[$>$] rwstats 20180701.rw \\ --fields=1,2,3,4,5,6,7,8,9,10, \\ 11,12,13,14,15,20,21,25,26,27,28,29 \\ --values=Flows \\ --output-path=20180701\_result.data \\ --percentage=0 \fi \item[$>$] rwcut 20180701.rw \\ --fields=1,2,3,4,5,6,7,8,9,10, \\ 11,12,13,14,15,20,21,25,26,27,28,29 \\ --output-path=20180701\_result.data \end{itemize} } \subsection{Second step: combining flow data with IDS logs} \begin{table*}[!tb] \small \caption{Flow features resulted from the combining process} \label{tab:features} \centering \begin{tabular}{lll} \hline Feature & NetFlow v9 field & Description \\ \hline sIP & IPV4\_SRC\_ADDR & Source IP address \\ dIP & IPV4\_DST\_ADDR & Dest IP address \\ sPort & L4\_SRC\_PORT & Source port \\ dPort & L4\_DST\_PORT & Dest port \\ proto & PROTOCOL & IP protocol \\ packets & IN\_BYTES & Packet count \\ bytes & IN\_PKTS & Byte count \\ flags & TCP\_FLAGS & Bit-wise or of TCP flags over all packets \\ sTime & UNIX\_Seconds & Starting time of flow (in sec) \\ durat & & Duration of flow (in sec) \\ eTime & & End time of flow (in sec) \\ sen & FLOW\_SAMPLER\_ID & Name or ID of the sensor \\ in & SRC\_VLAN & Router SNMP input interface \\ out & DST\_VLAN & Router SNMP output interface \\ nhIP & IPV4\_NEXT\_HOP & Router next hop ID \\ senClass & & Class of sensor that collected flow (SiLK-specific) \\ typeFlow & & Type of flow for this sensor class (SiLK-specific) \\ iType & ICMP\_TYPE & ICMP type value for ICMP flows \\ iCode & & ICMP code value \\ initialF& & TCP flags on first packet in flow \\ sessionF& & Bit-wise OR of TCP flags over all packets except the first in the flow \\ attribut& & Flow attributes set by the flow generator \\ appli & & Guess as to the content of the flow \\ class & & \{normal, anomaly, unsure\} for anomaly detection \\ taxonomy & & Category of anomalies (e.g., Port scan, DoS, etc) \\ label & & \{normal, anomalous, suspicious, notice\} (MAWILab-specific)\\ heuristic & & Code assigned to anomalies (MAWILab-specific) \\ distance & & $D_n-D_a$ (MAWILab-specific) \\ nbDetectors & & Number of detectors reported this anomaly (MAWILab-specific)\\ \hline \end{tabular} \end{table*} To generate labeled flow data, the next step is to merge the output resulted from the first step with the associated IDS logs (i.e., the same-day logs as the traffic trace used in step 1). MAWILab provides two log files for a single day traffic trace: one with a suffix of `anomalous\_suspicious' containing the log records with the labels of anomalous and suspicious, and the other with a suffix of `notice' keeping the records with the label of notice. Again, we do not consider the label of notice since only a few detectors assumed the activity as an anomaly without making a full consent by the entire set of detectors. To combine, we utilize the four flow attributes of \{source IP address, source port, destination IP address, destination port\}, which are available in both of the flow data file and the IDS log file. For each entry in the log file, we search the flow records with the identical values for the above attributes in the flow data file. A flow record is labeled as {\em anomaly} in case of matching. It is possible that a log entry contains one or more null values for certain flow attributes. Here are two example log entries: R1:{\tt (sip=A, sport=B, dip=C, dport=D)} and R2:{\tt (sip=A, sport=null, dip=C, dport=null)}. In this example, R2 contains null values for {\tt sport} and {\tt dport}, while R1 specifies the entire flow attributes without a null. For the exposition purpose, we define $L$ as the number of flow attributes available (i.e., not null) in the log entry. Intuitively, the log entry with a higher $L$ value is more specific. Due to this reason, we give a higher precedence to a log entry with a higher $L$. Thus, R1 has a greater precedence than R1; that is, R1 $>$ R2 as $L(R1) > L(R2)$. Suppose a flow F1:{\tt (sip=A, sport=B, dip=C, dport=D)}. It shows an example of multiple match since F1 matches both R1 and R2. In that case, F1 is combined with R1 by the precedence rule. Rarely, there can be multiple matches for a single flow by multiple log entries with the same $L$. To see this, suppose F2:{\tt (sip=P, sport=Q, dip=R, dport=S)}, R3:{\tt (sip=P, dip=R)}, and R4:{\tt (dip=R, dport=S)}. In this case, F2 matches both of R3 and R4 with $L$=2. To take this into account, we apply a simple heuristic: (1) give a higher weight to victim than source (i.e., destination $>$ source, and (2) give a higher weight to host than service (i.e., IP address $>$ port number), and hence ({\tt dip $>$ sip $>$ dport $>$ sport}) for the identical $L$. By this rule, F2 is combined with R3 instead of R4. From IDS logs, we observed several IDS entries with $L$=1; that is, only a single attribute is available and the other three are null. For example, one entry in the IDS log contains {\tt (sip=null, sport=443, dip=null, dport=null)}. We also observed that there are about 16 million flows only matching with this record out of 68 million flows on that day (i.e., 23.5\%). The port number 443 is widely used for secure web browser communication, and response packets from web servers communicating over TLS/SSL often have this port number. We feel that it is somewhat risky to label such a large number of flows as {\em anomaly}. Due to this reason, we label the flows matching more than one attribute (i.e., $L>1$) as {\em anomaly}, while we label the flows matching only one attribute ($L=1$) as {\em unsure}. Any flow with no match is labeled as {\em normal}. The flow records labeled as {\em unsure} can be excluded by the users based on their discretion. Table~\ref{tab:features} shows the output format after combining. The feature of ``class'' is the new label created in the combining process, while the feature of ``label'' shows the MAWILab-defined label information. The table also shows how the features in the output are associated with the fields defined in NetFlow v9. \iffalse We implemented this combining process using Python. The program {\tt flowlabeling.py} takes the flow data file (resulted in step 1) and the IDS log file; for example, a flow data file of ``20180701\_result.data'' and the associated csv file of ``20180701\_anomalous\_suspicious.csv''. {\tt \small \begin{itemize} \item[$>$] python flowlabeling.py -h \\ usage: flowlabeling.py [-h] [-i INPUTFILE] [-c CLASSIFIER] [-o OUTPUTDIR] [-t DATESTR] [--sec] \\ Tool to combine the flow and classifier \\ optional arguments: \\ -h, --help show this help message and exit \\ -i INPUTFILE, --input INPUTFILE input file path. e.g. *\_result.data \\ -c CLASSIFIER, --classifier CLASSIFIER input classifier file path. e.g. *\_anomalous\_suspicious.csv \\ -o OUTPUTDIR, --output OUTPUTDIR output directory path \\ -t DATESTR, --time DATESTR datetime of the file. When used, -i and -o are ignored. \\ --sec flow times in seconds, rather than milliseconds. default False \\ \end{itemize} } We implemented another Python program {\tt flowsplitter.py} that breaks the outputs into multiple files with designated time windows. For example, it splits a 15-minute flow data into 180 sub-files under the assumption of 5-second time window. The program definition is as follows: {\tt \small \begin{itemize} \item[$>$] python flowsplitter.py -h \\ usage: flowsplitter.py [-h] [-i INPUTFILE] [-o OUTPUTDIR] [-t DATESTR] [-n SPLITSEC] \\ Tool to split the flow files in timed order \\ optional arguments: \\ -h, --help (show this help message and exit) \\ -i INPUTFILE, --input INPUTFILE (input flow file path. e.g. *\_mawilab\_flow.csv) \\ -o OUTPUTDIR, --output OUTPUTDIR (output directory path) \\ -t DATESTR, --time DATESTR (datetime of the file. When used, -i and -o are ignored.) \\ -n SPLITSEC (time separation in seconds. default 5 sec.) \\ --sec (flow times from rwstats in seconds, rather than milliseconds. default False.) \\ \end{itemize} } \fi We implemented this combining process using Python. A Python program {\tt flowlabeling.py} takes a flow data file (resulted in step 1) and an IDS log file, and produces a set of combined flows formatted in Table~\ref{tab:features}. Another Python program {\tt flowsplitter.py} breaks the outputs into multiple files with designated time windows. For example, it splits a 15-minute flow data into 180 sub-files under the assumption of 5-second time window. The programs are available from the following repository: \url{https://github.com/dcstamuc/FlowDataGen}. \section{Summary} \label{sec:conc} This paper introduced a method to construct network flow data that would aid the development of learning-based intrusion detection methods. Our method combines the packet meta-information with the IDS logs to infer labels containing intrusion information for individual network flows. To achieve this goal, we utilized the SiLK tool to extract the flow data from the TCP dump file, and implemented a Python program to combine the flow data with the IDS log. The generated flow data contains associated label information for intrusion detection research and is NetFlow compatible. We believe the introduced method would assist researchers in network intrusion detection to access recent network flow datasets with associated labels. \section*{Acknowledgment} \let\OLDthebibliography\thebibliography \renewcommand\thebibliography[1]{ \OLDthebibliography{#1} \setlength{\parskip}{0pt} \setlength{\itemsep}{2pt plus 0.3ex} } \fi \bibliographystyle{unsrt}
{'timestamp': '2018-10-05T02:03:03', 'yymm': '1810', 'arxiv_id': '1810.01945', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01945'}
arxiv
\section{} Foam geometry is broadly found in nature and artifacts such as the froth on beer and the large-scale structure of the cosmos. Epithelial sheet is a typical example of forming foam geometries in living multicellular organisms, which is referred to as cell packing geometry in the field of biology, and is a key component of shaping organs and embryos. Epithelial sheets dynamically change their geometries by turning over cells, as widely observed in morphogenesis, homeostasis, and carcinogenesis \cite{slattum2014tumour,lee2006epithelial,thiery2009epithelial,macara2014epithelial}. In usual, individual cells possess both apical and basal surfaces for maintaining the monolayer integrity of epithelial sheet, occasionally, from which a single cell is delaminated to either apical or basal side, which is also referred to as extrusion or protrusion. Typically, in vertebrates, apoptotic cells are delaminated to the apical side in replace of divided cells in homeostasis, whereas pre-cancer cells are delaminated to the basal side to form tumors in carcinogenesis \cite{slattum2014tumour}. Delaminations to basal side is also found in epithelial-mesenchymal transitions in both vertebrates and invertebrates \cite{lee2006epithelial,thiery2009epithelial}. Although most of studies have focused on the molecular mechanisms underlying each physiology, little attention has been given to the mechanical aspects of the 3D foam geometry of an epithelial sheet. Here, we present a general framework that describes the instability of 3D foam geometry in a sheet and discuss possible mechanisms of epithelial integrity and cell delaminations in physiology and pathophysiology. From a physical point of view, the cause of cell delaminations could be explained by the mechanical instability of the foam geometry of an epithelial sheet; i.e., Upon delaminations, the geometry transits in 3D space from a hexagonal symmetric monolayer to a locally delaminated sheet with apicobasal asymmetry. In physiology, this instability often results from cell-intrinsic force generation, via actomyosin contractility and cadherin- and integrin-based adhesion \cite{katoh2012epithelial,gudipaty2017epithelial,rosenblatt2001epithelial,hogan2009characterization,monier2015apico,kajita2014filamin,friedl2003tumour}. While these cell delaminations are regulated by cell-intrinsic genetic programs, cell delaminations are also affected by external forces from environments such as cell crowding \cite{marinari2012live,eisenhoffer2012crowding,levayer2016tissue}. Topology of cell configurations in the epithelial plane may also explain cell delaminations \cite{marinari2012live,tsuboi2018competition}. Thus, a mechanical description of the 3D foam geometry in a sheet could give a universal guide on the understandings of epithelial integrity and cell delaminations. In the past years, remarkable progress has been made in the mechanical descriptions of epithelial cell geometries \cite{hannezo2014theory,honda1982cell,farhadifar2007the,sedzinski2016emergence,misra2016shape}; e,g,, A pioneering work by Hannezo, et al. has explained buckling instabilities of an epithelial sheet based on the force balance among apical, lateral, and basal components \cite{hannezo2014theory}. Most of the studies assume the mean-field approximation of individual cell shapes; that implicitly assumes that cells robustly maintain a homogeneous monolayer sheet \cite{hannezo2014theory,honda1982cell,farhadifar2007the,misra2016shape}. Hannezo and his co-workers have also explained the emergence of an embedded cell to the apical side, based on the force balance on the apical plane \cite{sedzinski2016emergence}. However, the cell delamination is the process of local changes in multicellular geometries and force effects in 3D \cite{katoh2012epithelial,gudipaty2017epithelial,rosenblatt2001epithelial,hogan2009characterization,monier2015apico,kajita2014filamin}; thereby, we give a full 3D description of multiple cells upon delaminations using 3D vertex models \cite{honda2004a,okuda2013reversible,hashimoto2018topological}. Analytical calculations clarify how the force balance among apical, lateral, and basal components causes the instability of 3D foam geometry, disrupting the monolayer integrity of epithelial sheet to delaminate a cell selectively to either apical or basal side. \begin{figure} \includegraphics{LateralFig1.eps} \caption{ Mathematical model of the 3D foam geometry in a sheet. {\bf a}. Three-dimensional model of monolayer cell sheet with thickness $H$. {\bf b}. In-plane cell density of the sheet $\rho$ introduced in replace with $H$. The in-plane cell density is defined as $\rho = H / v$, where $v$ is the average cell volume. {\bf c}. Three-dimensional model of single cell with side number $n$, height $h$, volume $v$, and inclination $d$, embedded in a plane sheet. Cell inclination $d$ is defined as Eq. (2). we consider mechanical forces exerted on the apical surface (ca), lateral surface (cs), basal surface (cb) of the center cell, and the boundary faces between the surrounding cells (ss). {\bf d}. Physical states of cells embedded in a plane sheet characterized by inclination $d$. } \label{fig:1} \end{figure} First, we introduce a geometric model of cells embedded in a monolayer sheet. A cell sheet is modeled as a plane monolayer with homogeneous thickness $H$ ($>0$), where individual cells are modeled as polyhedrons with the average volume $v$ (Fig. 1a). Here, we parametrize $H$ by introducing the cell density in the sheet plane $\rho$ ($>0$) (Fig. 1b). Since the effective area of individual cells in the sheet plane is written by $v/H$, the in-plane cell density can be written as $\rho = H/v$. We focus on a single cell and its first neighbors embedded in a monolayer sheet (Fig. 1c), whereas effects of the second and more nearest neighbors are implicitly introduced via cell density $\rho$ as a mechanical environment. The focused cell is modeled as a $n$-side regular pyramid with height $h$ and volume $v$ ($n\ge3$, $0 < h \le H$, $>0$). In this geometry, the center cell has either or both of apical and basal surfaces, referred to as ``ca'' and ``cb'', respectively, and is adjacent to the $n$ surrounding cells via lateral boundary faces, referred to as ``cs''. The $n$ surrounding cells are also adjacent to each other via lateral boundary faces, referred to as ``ss'', aligning radially from the center cell. Using these symbols, the apical surface area of the center cell is represented by $s_\text{ca} (\ge0)$, the basal surface area of the center cell by $s_\text{cb} (\ge0)$, the total area of boundary faces between the center and surrounding cells by $s_\text{cs} (\ge0)$, the total area of boundary faces between the surrounding cells by $s_\text{ss} (\ge0)$, the apical perimeter of the center cell by $p_\text{ca} (\ge0)$, respectively. Key part of our model is the topological rearrangement of the 3D foam geometry (Fig. 1d): the center cell converges either the apical or basal surface and is delaminated to the opposite side. To parameterize these states uniquely, we introduce the degree of cell inclination $d$ as \begin{equation} d = \frac{H}{h} \frac{s_\text{ca}-s_\text{cb}}{s_\text{ca}+s_\text{cb}}. \end{equation} The set of $\rho$, $n$, $v$, and $d$ identifies a center cell geometry, and thereby formulates all of geometric parameters such as $H$, $h$, $s_\text{ca}$, $s_\text{cb}$, $s_\text{cs}$, and $s_\text{ss}$. Specifically, $d$ characterizes a cell state continuously over topological rearrangements of cells (Fig. 1d); basal delamination (B: $d<-1$), apical convergence (aC: $d=-1$), bipolar (P: $-1<d<1$), basal convergence (bC: $d=1$), and apical delamination (A: $d>1$). Next, we introduce a mechanical energy of a single cell and its neighbors embedded in a monolayer sheet: i) Given the incompressibility, the center cell volume $v$ is constant, as observed during several morphological changes \cite{weber2007tmod3,gelbart2012volume}. ii) Cells generate myosin-dependent cortical tension and cadherin- or integrin-dependent adhesion on individual cell surfaces according to the apicobasal polarity \cite{dawes2005folded}; a cortical actomyosin meshwork lines the apical surface (ca) \cite{lecuit2007cell}, whereas actin stress fibers and integrin-adhesion to substrate form the basal surface (cb) \cite{berrier2007cell}. Such cortical forces are also exerted on lateral boundaries between cells (cs, ss)\cite{manning2010coaction}. These surface energies are often modeled in first order approximation as those proportional to individual surface areas \cite{okuda2013reversible,hannezo2014theory,bielmeier2016interface}. The energies on the apical and basal surfaces are negligible, since the in-plane constraint of the sheet conserves the total areas of individual apical and basal surfaces. On the other hand, we expand the energy on lateral surfaces around the center cell, as $\kappa_\text{l} \left(s_\text{cs} + s_\text{ss} \right)$ where $\kappa_\text{l}$ is a positive modulus. iii) Individual epithelial cells form a contractile actomyosin belt and adherens junctions along apical cell perimeters (ca) \cite{lecuit2007cell}. This energy is often modeled as an elastic energy around a preferred perimeter $p_\text{eq}$ as $k_\text{a} \left( p - p_{\text{eq}} \right)^2$, where $k_\text{a}$ is a non-negative modulus \cite{farhadifar2007the,misra2016shape}. The first contribution of this energy over the center and neighboring cells can be expressed as $k_\text{a*} \left( p_\text{ca} - p_\text{eq} \right)^2$, where $k_\text{a*}$ is a non-negative modulus. Therefore, the mechanical energy reads \begin{equation} U_\text{s} = k_\text{a*} \left( p_\text{ca} - p_\text{eq} \right)^2 + \kappa_\text{l} \left(s_\text{cs} + s_\text{ss} \right). \end{equation} We analytically address the behavior of Eq. (2) in $\left| d \right| \ll 1$. Here, we assume that the center cell degradates its epithelial polarity ($k_\text{a*}=0$), as observed upon delaminations in physiology \cite{katoh2012epithelial,gudipaty2017epithelial}. The McLaurin expansion of Eq. (2) for $d$ can be factorized as \begin{equation} U_\text{s} = f_\text{0} \left( n, \rho, v \right) \kappa_\text{l} \\ + f_\text{2} \left( n, \rho, v \right) \kappa_\text{l} d^2 + O \left( d^4 \right). \end{equation} where $f_\text{0}$ and $f_\text{2}$ are the zeroth and second-order coefficients of $d$ as functions of $n$, $\rho$, and $v$. Therefore, the state at $d=0$ is stable when $f_\text{2} > 0$ and instable when $f_\text{2} < 0$. Specifically, $f_\text{2}$ is composed of two terms with respect to $s_\text{cs}$ and $s_\text{ss}$ as $f_\text{2} = f_\text{2cs} + f_\text{2ss}$, where the analytical solution gives $f_\text{2ss}>0$. These indicate that the balance between $s_\text{cs}$ and $s_\text{ss}$ induces an instability depending on $n$ and $\rho$. Therefore, a mechanical instability is inherent in the 3D foam geometry, especially cell-cell boundaries, to which mechanical disturbances may drastically transit cell states. \begin{figure} \includegraphics{LateralFig2.eps} \caption{ Dependence of cell states on in-plane topology and cell density. {\bf a}-{\bf b}. Energy landscapes of Eq. (2) with respect to the number of sides $n$ and the in-plane cell density $\rho$, respectively. Triangles ($\blacktriangle$) indicate energy minimum points, which out of scope are plotted on boundaries. {\bf c}. State diagram of Eq. (2) with respect to the number of sides $n$, the in-plane cell density $\rho$, and apical perimeter constraint $k_\text{a*}$. } \label{fig:2} \end{figure} Analytical calculations of Eq. (2) demonstrate that, a mechanical instability leading delaminations is caused by a spontaneous symmetry breaking, inherently depending on the 3D foam geometry; i.e., bipolar (P) becomes destabilized, and alternatively apical and basal delaminations (A, B) become stabilized when $n$ decreases (Fig. 2a) or $\rho$ increases (Fig. 2b). As expected from Eq. (3), the instability of bipolar (P) strongly depends on both $n$ and $\rho$; i.e., delaminations (A,B) become stabilized when $n < 6$ and $\rho \gtrsim 1.5 v^{-\frac{2}{3}}$, independently on $k_\text{a*}$ (Fig. 2c). Because in-plane cell density $\rho$ can be increased by external compressive forces from the environment, the resulting dependence on $n$ and $\rho$ indicates that the 3D foam geometries with $n \ge 6$ possess a mechanical resistance against external force but not those with $n \le 5$. The resulting dependence on $n$ and $\rho$ quite agrees with experimental observations. An epithelial sheet usually forms the hexagonal packing geometry ($n \approx 6$) and involves few cells with $n=3$ \cite{gibson2006emergence,farhadifar2007the}; in such geometry, most of delaminations occur after reducing the number of sides from $n \approx 6$ to $n \approx 3$ \cite{marinari2012live}. These geometric values of $n$ in physiology are quantitatively consistent with the transition threshold of $n$ determining the instability in this model (Fig. 2a,c). Moreover, cell crowding-induced delaminations, observed in physiology \cite{marinari2012live,eisenhoffer2012crowding,levayer2016tissue}, correspond to the delaminations induced by the increase in $\rho$ in this model (Fig. 2b,c). These agreements suggest the possibility that the mechanical instability is a central mechanism of epithelial cell delaminations. \begin{figure} \includegraphics{LateralFig3.eps} \caption{ Dependence of cell states on cell-intrinsic lateral force. {\bf a}. Energy landscape of Eq. (4) with respect to cell-intrinsic lateral force $\kappa_\text{l+}$. Triangles ($\blacktriangle$) indicate energy minimum points. {\bf b}. State diagram of Eq. (4) with respect to the number of sides $n$, in-plane cell density $\rho$, and cell-intrinsic lateral force $\kappa_\text{l+}$. Here, $k_\text{a*}=0$. } \label{fig:3} \end{figure} Cell-intrinsic force generation may also destabilize bipolar (P) and stabilize delaminations (A, B), similarly to the external compressive force via cell density shown in Fig. 2b,c. This is because Eq. (3) predicts that the balance between $s_\text{cs}$ and $s_\text{ss}$ induces an instability. As a cell-intrinsic force generation, we consider the force generated specifically by the center cell, and introduce a lateral energy $\kappa_\text{l+} s_{cs}$, proportional to the lateral surface area of the center cell $s_{cs}$. Therefore, Eq. (2) rereads \begin{equation} U_\text{l} = U_\text{s} + \kappa_\text{l+} s_\text{cs}. \end{equation} Analytical calculations of Eq. (4) demonstrate that the lateral force generation also provokes an instability in a similar symmetry-breaking manner (Fig. 3a). Interestingly, the lateral force generation induces an instability leading delaminations independent on the number of sides $n$ (Fig. 3b), whereas the geometries with $n \ge 6$ stabilize bipolar (P) robustly against the change in cell density $\rho$ (Fig. 2b,c). Moreover, in the geometries with $n \ge 4$, cells form a rosette-like structure (e.g. illustrated in Fig. 3b). These indicate that cell-intrinsic lateral force generation forcedly delaminates cells, independent on the foam geometry and disarrange the foam geometry in 3D. Cell-intrinsic lateral force generation $\kappa_\text{l+}$ (Fig. 3) corresponds to actomyosin accumulations along the apicobasal axis upon delaminations, observed in physiology as invertebrate cell apoptosis \cite{monier2015apico} and vertebrate cell invasion \cite{kajita2014filamin}. Rosette-like structures obtained in Fig. 3b are also formed upon delaminations in several physiologies \cite{rosenblatt2001epithelial,marinari2012live}. Therefore, cell-intrinsic lateral force generation may play a key role in cell delaminations in physiology. Notably, while delaminations (A,B) are stabilized by positive $\kappa_\text{l+}$ (constriction) in the geometry with high cell density (e.g., $\kappa_\text{l+}/\kappa_\text{l}=1$ in Fig. 3b), they are stabilized by negative $\kappa_\text{l+}$ (adhesion) in the geometry with low cell density (e.g., $\kappa_\text{l+}/\kappa_\text{l}=-1$ in Fig. 3b). This result suggests that force properties and their molecular machineries upon delaminations drastically differ by each physiology, depending on cell density. \begin{figure} \includegraphics{LateralFig4.eps} \caption{ Dependence of cell states on cell-intrinsic apical and basal forces. {\bf a}-{\bf b}. Energy landscapes of Eq. (5) with respect to apical $\lambda_\text{a+}$ and basal $\kappa_\text{b+}$ forces, respectively. Triangles ($\blacktriangle$) indicate energy minimum points, which out of scope are plotted on boundaries. Here, $n=6$, $\rho=5$, and $k_\text{a*}=0$. } \label{fig:4} \end{figure} Lastly, we address roles of cell-intrinsic force generation on apical and basal sides, since individual apical and basal regions also generate additional forces upon delaminations in physiology \cite{katoh2012epithelial,gudipaty2017epithelial,rosenblatt2001epithelial,monier2015apico,kajita2014filamin}. Thus, we consider additional apical and basal energies separately as follows: additional apical energy, $\lambda_\text{a+} p_\text{ca}$, proportional to the apical junction length $p_\text{ca}$, $\lambda_\text{a+}$; additional basal energy, $\kappa_\text{b+} s_{cs}$, proportional to the basal surface area $s_{cb}$. Therefore, Eq. (4) rereads \begin{equation} U_\text{e} = U_\text{l} + \lambda_\text{a+} p_\text{ca} + \kappa_\text{b+} s_\text{cb}. \end{equation} Analytical calculations of Eq. (5) demonstrate that the apical force ($\lambda_\text{a+}<0$) and basal force ($\kappa_\text{b+}<0$) suppress the bifurcation to apical and basal delaminations (A, B), leading to unistable delaminations to either apical or basal side (Fig. 4a,b). Notably, either positive $\lambda_\text{a+}$ or positive $\kappa_\text{b+}$ stabilizes apical or basal convergence (aC, bC); i.e., cells stably maintain pseudostratified structures. These indicate that roles of force generation drastically differs by where forces are exerted at subcellular level. \begin{figure} \includegraphics{LateralFig5.eps} \caption{ Combined effects of cell-intrinsic apical, basal, and lateral forces on stable cell states. {\bf a}-{\bf c}. State diagrams of Eq. (5) with respect to apical $\lambda_\text{a+}$ and basal $\kappa_\text{b+}$ forces in the cases with $\kappa_\text{l+}/\kappa_\text{l}=-1.0$, $0.0$, and $1.0$, respectively. Here, $n=6$, $\rho=5$, and $k_\text{a*}=0$. } \label{fig:5} \end{figure} Further calculations of Eq. (5) demonstrate that combining apical, basal, and lateral forces induces various bifurcations of stable cell states (Fig. 5); For example, when $\kappa_\text{l+}$ is negative (adhesion), various multiple-stable states emerge (Fig. 5a). As increasing $\kappa_\text{l+}$, bistable apical and basal delamination state (A, B) becomes stable (Fig. 5b), and is extended in the parameter space by positive $\kappa_\text{l+}$ (constriction) (Fig. 5c). In addition to the increase in $\kappa_\text{l+}$, the increase in either apical $\lambda_\text{a+}$ or basal $\kappa_\text{b+}$ force directs delaminations selectively to basal (B) or apical (A) side, respectively (Fig. 5b). The resulting dependence on $\lambda_\text{a+}$ and $\kappa_\text{b+}$ (Fig. 4) corresponds to the wide range of physiology; apical cell delamination is promoted by E-cadherin-based cell-cell adhesion on apical side \cite{hogan2009characterization}, corresponding to the decrease in apical forces $\lambda_\text{a+}$ (Fig. 4a). Basal cell invasion, corresponding to basal delamination (B) depends on integrin-based adhesion \cite{friedl2003tumour}, corresponding to the decrease in basal force $\kappa_\text{b+}$ (Fig. 4b). Pseudostratified structures predicted in Fig. 4a,b are also found in many tissues such as neuroepithelia \cite{miyata2001asymmetric,haubensak2004neurons} and bronchial epithelia \cite{rackley2012building}. Thus, predicted effects of lateral force generation $\kappa_\text{l+}$ (Fig. 3) as well as apical $\lambda_\text{a+}$ and basal $\kappa_\text{b+}$ force generation (Fig. 4) are highly consistent with local accumulations of mechanical factors such as actomyosin, cadherin, and integrin. Therefore, spatial distributions of these molecules should be rigorously regulated at subcellular level, whose defects may lead to pathologies relevant to epithelial integrity and delaminations. Spatial combinations of local force generation (Fig. 5) are actually often observed in physiology; e.g., expressions of Rho family downregulating actomyosin activities are deteriorated in human tumors \cite{del2005rho,abraham2001motility}, corresponding to the aberrant balance among the apical, basal, and lateral forces. Similarly, temporal patterns of force generation are also involved in physiology \cite{hogan2009characterization,friedl2003tumour,kajita2014filamin}. Therefore, further analyses of the effects of spatiotemporal force patterns would link the mechanical understandings to the underlying molecular regulations in each physiology. In summary, this study has analytically demonstrated a mechanical instability inherent in the 3D foam geometry of a cell monolayer. This result implies that maintaining a monolayer requires the proper cell geometry and force balance in 3D, which is ignored in well used 2D models in principle \cite{hannezo2014theory,honda1982cell,farhadifar2007the,misra2016shape}. Further calculations have shown several dependences of the stability on the cell geometry and force generation, which agree well with many {\it in vivo} and {\it in vitro} physiology. The agreement indicates a deep connection among 3D cell geometry, cellular force generation, and multicellular integrity in epithelia, suggesting the possibility that mechanical instability is a fundamental mechanism of determining cell delaminations and their directions, whose defects may cause diseases. Moreover, this model has explained various epithelial geometries including delaminations, rosette structures, and pseudostratified structures; hence, it can also be applicable to other phenomena such as epithelial homeostasis \cite{macara2014epithelial} and multilayerization \cite{miyata2001asymmetric,haubensak2004neurons,rackley2012building}. Therefore, this model will give a universal guide to understand the wide range of epithelial physiology in morphogenesis, homeostasis, and carcinogenesis. \begin{acknowledgments} We thank Dr. Tetsuya Hiraiwa at University of Tokyo, Dr. Romain Levayer at Institut Pasteur, Dr. Yosuke Ogura at RIKEN, and Dr. Katsuyoshi Matsushita at Osaka University for discussions. S.O. thanks his colleagues in the laboratory of Prof. Mototsugu Eiraku at Kyoto University for discussions. This work was supported by the JST/PRESTO Grant No. JPMJPR16F3. \end{acknowledgments}
{'timestamp': '2018-10-05T02:03:58', 'yymm': '1810', 'arxiv_id': '1810.01984', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01984'}
arxiv
\section{Applications: Autonomous Driving} Recent advances in machine learning paradigms have stimulated significant progress in the development of autonomous driving applications. Autonomous driving can be split into two major concepts: mediated perception approaches and behavior reflex approaches \cite{ChenDeepDriving}. Mediated perception regimes adopt numerous sub-components for identifying driving related objects, such as traffic lights, lanes, signs, and pedestrians, in order to create a representation of the car's surroundings. Using this information an AI based engine is utilized in order to identify the relevant objects in order to correctly control the car's velocity and direction\cite{ChenDeepDriving}. Behavior reflex approaches create mappings from sensory input images to driving actions. In these schemes, a neural network is trained to mimic a human driver by recording steering angles and sensory images recorded on a series of driving runs. While these schemes have proved to be largely successful, there is an urgent need to formally reason about the behavior of autonomous driving systems due to their safety critical nature. As a result, there has been great research impetus towards obtaining robust and scalable verification schemes. Thus, in this section, we present a brief survey of the existing verification approaches for autonomous driving applications. The paper \cite{wrro127573} describes the purpose and progress of the Safety of Autonomous Systems Working Group (SASWG), which was established by the Safety Critical Systems Club (SCSC). It emphasizes the importance of careful and tactful implementation of autonomous systems. They discuss the problems that are close to being solved, the problems with unclear solutions, and the problems with possibly no solution. The approach described in the paper is for the problem of autonomous systems safety in general. In \cite{2018arXiv180406760E}, the authors present a testing framework for test case generation and automatic falsification methods for cyber-physical systems called Sim-ATAV (Simulation-based Adversarial Testing of Autonomous Vehicles). This framework can be used to evaluate closed-loop properties of autonomous systems that include machine learning components using a test generation method called covering arrays. This is all performed in a virtual environment where the focus is on identifying perturbations that lead to unexpected behaviors. By utilizing advanced 3D models and image environments, the authors seek to bridge the gap between the virtual world and the real world. Their work demonstrates how to use test cases in order to identify problematic test scenarios and increase the reliability of autonomous vehicles. While most current approaches focus only on the machine learning components, the authors of this paper focus on the closed loop operation of the vehicles. It deals with verification and testing at the system level. Their paper demonstrates effective ways of testing discrete combinations of parameters and corner cases. In a recent paper~\cite{LangleyML2011}, Pat Langley details the history of the field of Machine Learning and the reasons for launching a new journal in the 1980's. Langley argues that Machine Learning was originally concerned with the development of intelligent systems that would display rich behavior on a set of complex tasks. However, in recent years, many researchers have focused on tasks that do not tackle intelligence or systems and have mainly been preoccupied by statistics and classification. This paper focuses on the need to "recover the discipline's original breadth of vision and its audacity to develop learning mechanisms that cover the full range of abilities in humans." Safety for cyber-physical systems that utilize controllers of neural networks needs to be verified using approaches such as those based in simulations~\cite{DBLP:journals/corr/abs-1804-03973}. \section{Architecture: Safe Monitoring and Control} It is unrealistic to believe that one will ever verify all parts of an autonomous CPS, as such a problem would be akin---and in fact far harder---than formally verifying that all components in a modern microprocessor consisting of billions of transistors meets a formal specification of every desirable behavior. Aside from it being unlikely that every specification would ever be formalized for such complex systems, the computational complexity of subproblems such as model checking, equivalence checking, etc. will never be fully realized, as the complexity is typically exponential in the size of the system (under some definition of size, such as lines of source code) and additionally the size of such systems is growing exponentially, especially as LECs are incorporated. As such, some of the most plausibly impactful methods to ensure autonomous CPS meet their specifications is through safety architectures, runtimne monitoring, runtime verification (RV), and runtime assurance (RTA). The paper \cite{johnson2016tecs} analyzes periodically-scheduled controller subsystems of cyber-physical systems using hybrid automata and associated analysis tools. However, reachability analysis tools do not perform well on periodically scheduled models due to a combination of large discrete jumps and nondeterminism associated with the start time of a controller. Thus, in this paper, the authors propose and demonstrate a solution that is validated through examining an abstraction mechanism in which every behavior of the original sampled system is contained in the continuous system. The authors also add a nondeterministic input. Using this framework, the authors demonstrate that reachability tools can better handle systems of this nature. Their approach is automated using the Hyst model transformation tool. In \cite{bak2015rtss}, Stanley Bak et al. present an alternate design for the Simplex Architecture that leverages linear matrix inequality optimization and hybrid systems reachability. In this framework, the region in which a complex controller can be use is extended by using real-time reachability computations. Additionally this approach decreases the conservatism in the switching logic. This work is the first to present a viable reachability algorithm based on a system's real-time conception of imprecise computation. Moreover, their algorithm returns an over-approximation of the reachable set that is improved over time. In the experimental evaluation of their methods, the authors demonstrate that a complex controller improves significantly using quick reachability calculations lasting tens of milliseconds that bound the future behavior of the system. Finally, they demonstrate that real-time reachability has applications beyond the Simplex architecture. The paper \cite{vijayakumar2018neural} presents a hybrid synthesis technique called Neural Guided Deductive Search (NGDS) that combines symbolic logic techniques and statistical models in order to produces programs that generalize well on previously unseen examples and satisfy a set of specifications. The programs are similar to data-driven systems. In their approach, the authors utilize deductive search in order to reduce the learning problem of a neural component into a simple supervised learning set up. Thus, as a result of this reduction, the authors are able to train their model on a limited amount of real world data and leverage the power of recurrent neural network encoders. The experimental evaluation of their methods demonstrates that their approach is superior to other approaches since it guarantees correctness and adequate generalization. Their approach is also faster than other synthesis regimes. The paper by Saunders et al~\cite{SaundersTrial2017} presents a safe reinforcement learning regime, called HIRL (human intervention reinforcement learning), that applies human oversight to the learning process in order to prevent catastrophic executions during the exploration process. In this framework, a human supervisor observes all of the agents actions and either allows an action to take place or blocks an action in the interest of safety. Once the human supervisor classifies a sufficient number of actions, the authors train a supervised learner to carry out this supervisory role and eliminate human intervention. In the experimental evaluation of their methods, the authors demonstrate that HIRL is successful in preventing harmful actions and that the learning process executes within an acceptable time period. \section{Conclusion} This paper surveys formal methods, verification and validation (V\&V), and architectural approaches to analyze and ideally assure safety of cyber-physical systems (CPS) that incorporate learning enabled components (LECs), such as neural networks. \section{Intelligent Control} \par Intelligent control can be spilt into many sub-domains utilizing techniques like, Neural Networks (NNs), Machine Learning (ML), Bayesian probability, fuzzy logic, and neuro-fuzzy hybridization. However, this section focuses primarily on intelligent control using Neural Networks but future revisions will include the other sub-domains. Neural Networks are systems designed to mimic the human brain. Each node in a NN is capable of making simple calculations. When nodes are connected in a network, the system is capable of calculating linear and nonlinear models in a timely and distributed manner. For more in-depth information about NNs, the introduction section of \cite{170966} contains a brief history of NNs. Additionally, \cite{80202} provides a foundational knowledge of how NNs and Recurrent Neural Networks (RNNs) have been combined and are used today in the field. The remainder of this section consists of summaries of influential and novel papers in the field of intelligent neural network control. Each paragraph summarizes a different paper. In \cite{DBLP:journals/corr/ZribiCD15}, an improved gradient descent method to adjust the PID Neural Network (PIDNN) parameters is used. A margin stability term is employed in the momentum function to modify the training speed depending of the robustness of the system. As a result, the learning algorithm system converges faster. The system is structured as a feedforward NN, where the PIDNN is placed in cascade with the plant NN model. The PIDNN always has one hidden layer with 3 neurons, representing the Kp, Ki, and Kd used in traditional PID controllers. In \cite{4812095}, a mixed locally recurrent neural network is used to create a PID Neural Network (PIDNN) nonlinear adaptive controller for an uncertain multivariable SIMO (single-input/multi-output) system. The PIDNN is placed in cascade with the plant, and the output of the plant is fed back to the PIDNN, which is subtracted from the reference input, to calculate the error that is used to update the weights of the PIDNN. The PIDNN structure studied consists of a single input and multiple outputs, one hidden layer with 3 neurons, the integral node with an output feedback, the derivative node with an activation feedback, and the proportional node (general node). All the activation functions are linear. The proposed controller can update the weights online using the resilient gradient descent back-propagation algorithm with sign. The only requirement for this method is that the initial weight values are required to start the system. The initial weight can run the system stably. In \cite{501721}, the authors focus on the stability of a control system with neural networks using a Lyapunov approach, which is derived using a parameter region (PR) method for the representation of the nonlinear parameters' location. A barrier Lyapunov function (BLF) is introduced to every step in a back-stepping procedure to overcome the effect of the full-state constraints. Fewer learning parameters are needed in the controller design. The dynamics of the neural network system are treated as linear differential inclusions (LDIs). The NN control system consists of an approximated plant and its controller, which is also represented by LDIs. Finally, they prove that all the signals of the closed-loop system are bounded and that the tracking error converges to a bounded compact set. In \cite{7185423}, an intelligent control methodology based on backstepping is developed for uncertain high-order systems. They show that the output-tracking performance of the system is achieved by a state feedback controller under two mild assumptions. By introducing a parameter in the derivations, the tracking error can be reduced through tuning the controller design parameters. In order to solve overparameterization, a common problem for adaptive control design, a controller with one adaptive law is proposed. In \cite{7087381}, an adaptive NN control and Nonlinear Model Predictive Control (NMPC) approach is proposed for a nonlinear system with a double-layer architecture. At the device layer, an adaptive NN control scheme is presented to guarantee the stability of the local nonlinear plant. Combining the overall performance index and index prediction unit, formed using radial basis function NNs, an NMPC method is proposed to optimize the performance index under the effects of network-induced delays and packet dropouts. In \cite{1296692}, a neural network controller for nonlinear discrete-time systems is designed, based on the structure of a linear Generalized Minimum Variance (GMV) controller. The system implemented consists of a fixed linear nominal model and a recurrent neural network that updates at each sampling interval. The adaptive control algorithm is derived by combining NNs and Lyapunov synthesis techniques, guaranteeing the stability of the system under certain assumptions. This method is tested with two simulation examples to show its efficiency. In \cite{1215406}, multilayer NNs are used to approximate the implicit desired feedback control. Under the Lipschitz condition assumption, by using converse Lyapunov theorem, they show that the system’s internal states do remain in a compact set. The main contributions are: a state feedback control and an observer-based NN output control of a SISO (Single-Input/Single-Output) nonaffine nonlinear system with zero dynamics using multilayer NNs, which can also be extended to affine systems. Finally, they proved the existence of an implicit feedback control based on the implicit function theorem. In \cite{363441}, two Diagonal Recurrent Neural Networks (DRNNs) are used for this control system, one as the controller and the other one as an identifier of the plant, whose output is used by the controller. Both have one hidden layer with sigmoid-type recurrent neurons. This control system is compared to Feedforward Neural Network (FNN) and Feedforward Recurrent Neural Network (FRNN) control systems. The advantages of using this system are fewer weights are required than with the FRNN model and it has dynamic mapping characteristics. These features allow the system to be used for online applications. A generalized dynamic backpropagation is used for the training of the parameters of the Diagonal Recurrent NeuroIdentifier (DRNI) and Diagonal Recurrent NeuroController (DRNC). Also, to ensure stability of the plant, they take an approach to find the bounds on learning rates based on the Lyapunov equation. In \cite{165588}, a neural network with one hidden layer of Gaussian radial basis functions is used to adaptively approximate the nonlinear dynamics of a system with a direct adaptive tracking control architecture. Considering some assumptions about the degree of smoothness of the nonlinear dynamics, the algorithm is proven to be globally stable. Using Lyapunov stability theory, a table weight adjustment mechanism is determined. Also, the tracking errors are shown to converge to a small neighborhood around zero. Another novelty of the paper is its unique feature of transitioning between adaptive and non-adaptive modes during its operation. In \cite{6937163}, a backstepping-based adaptive neural output-feedback control method is developed for nonstrict-feedback stochastic nonlinear systems with unmeasurable states, which most of the previous works assume are measurable. This method is based on the state observer and the combination of radial basis function and neural network's approximation capability. In this adaptive control system, only one adaptive parameter is involved, so the computational cost is reduced. This approach guarantees that the signals in the control-loop system remain semi-globally uniformly ultimately bounded and that the observer errors and output converge to a small range around the origin. In \cite{6783745}, a composite neural Desired State Configuration (DSC) design is studied for a class of SISO strict-feedback systems. The system is composed of radial basis function NNs and their goal is to eliminate the problem of explosion complexity. The adaptive control system uses the tracking error as well as a prediction error, which is calculated based on the accuracy of the identified neural models. In the composite NNs, the updating weights laws provide the ability of fast adaptation. Utilizing the Lyapunov method, the uniformly ultimate boundedness stability is verified. The goal of \cite{5430947} is to design a robust control system of uncertain multiple-input-multiple-output (MIMO) nonlinear systems with input deadzone and saturation. Considering the saturation and deadzone nonlinearities, a variable structure control (VSC) is presented. The cascade property of the system is used in developing the control structure and NN weight learning laws. Looking at the case when the control coefficient matrices are unknown, a robust backstepping technique in combination with NN approximation of the nonlinearities, the VSC control technique, and a Lyapunov synthesis, a control system is proposed. This method guarantees the stability of the closed-loop system and tracking errors converge to small residual sets. In \cite{7066958}, a decentralized control approach for MIMO large-scale systems with uncertain stochastic nonlinear dynamics and strong interconnections is proposed. The nonlinear dynamics are approximated using radial basis functions neural networks (RBFNNs), and the adaptive neural decentralized controller is constructed using backstepping technique. The other main contribution is the use of only one parameter in the control system, for each subsystem of n-order dynamics, which helps significantly improve the computational cost. It is proven that all signals are semi-globally uniformly ultimately bounded (SGUUB), and the tracking errors converge to a small range around the origin. Simulation examples are employed to show the effectiveness of this method. In \cite{7429795}, an adaptive neural network control method is presented for a class of SISO nonlinear systems with both unknown function and the full-state constraints. The full-state constraints are overcome by using a barrier Lyapunov function in every step for the backstepping procedure and their effect is mitigated. Another improvement, with respect to previous works, is the use of less learning parameters of nonlinear systems with unknown functions and full-state constraints, which reduces the computational cost. Using a BLF, it is proven that the signals are semiglobally bounded and the errors are driven to a small neighborhood around 0. In \cite{7087381}, a multirate networked industrial process control problem is considered using a double-layer architecture. At the device layer, where RBFNNs are used to approximate the nonlinear functions, an adaptive NN control approach is designed to solve the tracking problem and guarantee the stability of the plant. This layer is combined with the operation layer, where an NMPC method is proposed for optimizing the performance index under the effect of a network-induced delays, which is the result of the different sampling methods used in each layer. The lifting method is used to solve the problem of different sampling sizes. Finally, a stochastic variable satisfying the Bernoulli random distribution is utilized to model the network-induced packet dropout phenomenon at the operation layer. In \cite{6514578}, a method for learning from adaptive neural network control of a class of nonaffine nonlinear systems in uncertain dynamic environments is studied. The nonaffine nonlinear system is first converted into a semi-affine system using a filtered tracking error, the mean value theorem, and the implicit function theorem. Under input-to-state stability and the small gain theorem, the adaptive NN tracking control is designed, which is able to relax the constraint conditions of this class of systems, on top of overcoming its complex controllability problem. Under the persistent excitation (PE) condition (due to the use of RBFNNs), this proposed technique acquires knowledge from the implicit desired control input in the stable control process and stores the collected knowledge in memory. With this dynamic learning proposed, the NN learning control improves the control performance and enables closed-loop stability. In \cite{6627983}, an adaptive tracking control algorithm for nonlinear stochastic systems with unknown functions that uses backstepping is proposed and mathematically proved to work. There are fewer adjustable parameters than other algorithms which reduces the online computation load. They use Lyaponov analysis to prove that all the signals in the system are SGUUB in probability and that the system outputs track the reference signal to a bounded compact set. Their example is given as a simulation, no real-world tests were done. Future research will extend the usage to control MIMO systems with stochastic disturbance. This paper, \cite{ZHAO2015193}, proposes and proves an algorithm for handling switched stochastic nonlinear systems that have nonstrict-feedback with unknown nonsymmetric actuator dead-zones and arbitrary switching. They combine radial basis function neural network aproximation and adaptive backstepping with stochastic Lyapunov methods to develop a system that is SGUUB by the 4th moment. They show their results through a siulation with a ship manuevering system, but no real-world tests were completed. Future research will try to apply the same method to more complicated systems, such as high-order switched stochastic systems. This paper, \cite{6651788}, focuses on reducing vibrations in flexible crane systems, represented as partial-ordinary differential equations, by using an integral-barrier Lyapunov function (IBLF)-based control system. This technique is primarily used for ODE systems, but they are able to adapt it to fit their constraints. The simulated results are very promising. In \cite{572089}, two linear control models, two different Taylor expansion approximations of the nonlinear autoregressive moving average (NARMA) model, are presented. These two models are the NARMA-L1 and NARMA-L2 models. The fact that these controllers are linear in the control input extensively simplifies both the theoretical analysis and implementation. The primary case studied is when only the input and output are known, which means that the system identification and control have to be studied using only data from the input and output. The results obtained show that these models result in better control than an exact NARMA model, since dynamic gradient methods can be computationally intensive, so an approximation of them results in better identification. This paper, \cite{80202}, focuses on the identification and control of nonlinear dynamic plants using neural networks. They propose that multilayer neural networks and recurrent networks should be united for future use and show simulation results proving their claims. The paper is more foundational and should be read by people just starting out in the field because their explanations are in-depth and well cited. This paper, \cite{7086072}, presents an event-triggered control design for multi-input multi-output uncertain nonlinear continuos-time systems. By using neural network approximation properties in the context of event-based sampling, they found a way to reduce the network resource overhead using the Lyapunov technique to create an event-triggered condition. Additionally, the paper introduces a weight update law for aperiodic tuning of the neural network in order to relax the knowledge of complete system dynamics and reduce computation. Through proofs and simulations, they were able to prove closed-loop stability for the design. This paper, \cite{6736141}, proposes an iterative two-stage dual heuristic programming (DHP) method and a nonquadratic performance functional to solve optimal control problems for a class of discrete-time switched nonlinear systems subject to actuator saturation. The nonquadratic performance functional confronts the control constraints of the saturating actuator and the DHP method solves the Hamilton-Jacobi-Bellman equation. The mathematical proofs are validated by simulation results. This paper, \cite{7451284}, focuses on adaptive trajectory tracking control for a remotely operated vehicle (ROV) with an unknown dynamic model and an innaccurate thrust model. They propose a local recurrent neural network (local RNN) structure with a fast learning speed to hande these shortcomings. Their simulation results show that their method's tracking error converges in a finite time. However, the authors recommend future work to shorten the amount of time it takes to converge. In \cite{1281757}, the authors exhibit an approach to analyze neural network performance in control systems that are advanced adaptive. A tool is presented for measuring neural network operational performance from the output's error bar calculation. The tool can be used prior to deploying the system or while the system is in operation. The main purpose of the tool is to further neural network reliability in systems that are adaptive. Further work could include creating tools for verification and validation of adaptive systems and apply technology for adaptive neural networks to actual missions. In \cite{WEI2015106}, the authors present an algorithm for iterative adaptive dynamic programming (ADP) for problems of optimal tracking control on infinite horizon nonlinear system that are discrete-time. The algorithm efficiently solves the optimal tracking control problems. The performance index function's convergence analysis technique and the least upper bound of said function are developed and exhibited. They use neural networks for the iterative ADP algorithm implementation, for performing iteratively and tracking optimally. Further work could include analyzing the stability of the algorithm, examining the properties that interact with the system, and examining the reasons for errors in the iterations. In \cite{7067402}, the authors present a novel approach for backstepping output-feedback control of adaptive neural networks. Through the combination of radial basis functions and the aforementioned control approach, a controller for output-feedback adaptive neural networks was designed. In a closed-loop system, the controller supports boundedness, on a semiglobal level, for the signals in the system. The controller is adapted for nonstrict-feedback systems but can be applied to controlling both nonstrict- and strict-feedback systems. The control scheme can handle systems that are nonlinear and have nonstrict-feedback, making it a broad coverage scheme. In \cite{170966}, the authors present a survey of the theory and applications for control systems of neural networks. They give an overview of neural networks and discuss the benefits of them. Neural networks, like in the brain, have parallel processing, learning, mapping that is nonlinear, and generalization capabilities. The general neural network model is discussed along with recurrent and feed-forward neural networks. Some applications of neural networks that are discussed are recognition of patterns, planning and design, control, processing of knowledge information, and systems that are hybrid. The concept and applications of control that is based on neural networks, neuromorphic control, are discussed in detail. The last topic discussed in the paper is the fusion of fuzzy technology, artificial intelligence, and neural networks to create the FAN technology. In \cite{1866}, Behnam Bavarian presents a neural network based approach for the design and implementation of intelligent control systems. The author explores general problems in intelligent controller design where the control problem can be formulated as a broad mapping from a series of state changes to state actions. Two examples are discussed in the paper: the first explores the use of a bidirectional associative memory neural networks for sensor and actuator fault isolation, and the second deals with a hopfield neural network used to solve the traveling salesman problem. Overall, the authors demonstrate that neural networks represent a promising avenue of achieving intelligent control. The paper, \cite{Lewis}, investigates the promise of using neural networks for model-free learning controllers for non-linear systems. The authors primarily focus on multi-loop controllers where a neural networks is present in some of the loops and an outer unity-gain feedback loop. The authors further demonstrate that as the uncertainty about the controlled system increases, neural network controllers form an elegant control architecture that exhibit the hierarchical structure of other approaches. The topics explored in this paper include feedback linearization design of neural network controllers, neural network control for discrete time systems, feed-forward control structures of actuator compensation, reinforcement learning control using neural networks, and optimal control. The paper, \cite{7468475}, considers the trajectory tracking of a marine surface vessel with positional constraints in the presence of uncertainties in the environment. The authors use neural networks, in an adaptive control format, to model the environmental uncertainties. Their approach makes use of output feedback control defined by the Moore-Penrose pseudoinverse and state feedback control laws using a high gain observer. The authors demonstrate their method's abilities in achieving positional constraints. The authors provide simulation results that illustrate the efficacy of their results. The paper, \cite{7113913}, deals with the control of an n-link robotic manipulator with input saturation using adaptive impedance neural network control. The neural network model, employed in this approach, uses radial basis functions. The adaptive neural impedance controllers are designed using Lyapunov's method. Both full state and output feedback controllers are considered in this work along with an auxiliary signal specially designed to handle the saturation effect of a robotic manipulator. The paper, \cite{Xu2015}, presents the adaptive dynamic surface control of a hypersonic flight vehicle in an environment with unknown dynamics and input non-linearities. In this framework, the authors utilize a radial basis function based neural network control regime to estimate the control gain function and avoid the singularity problem. The authors also make use of dynamic surface control and the Nussbaum function in order to construct the controller. Their approach relies on functional decomposition where a PID controller is utilized for the velocity subsystem and the neural network control regime deals with the attitude subsystem. In this regime, stability is guaranteed via the Lyapunov approach and simulation results demonstrate the efficacy of their approach. In \cite{HE20141843}, Wei He et al. present the full-state and output feedback control of a thruster-assisted single-point mooring system in the presence of uncertainties and unknown backlash-like hysteresis nonlinearities. Their regime is based on the backstepping technique, Lyapunov synthesis, and adaptive neural network control. The backlash-like hysteresis is controlled using backstepping by modeling the hysteresis as a linear term and a bounded non-linear term. The neural networks are used to estimate unmeasurable states. Simulation results and further analysis demonstrate the feasibility of this approach. Moreover, the authors prove that their control schemes are semi-globally uniformly bounded. The paper, \cite{He2015}, presents a neural network based control regime for a robot with unknown system dynamics. The neural networks are used to deal with uncertainties in the system environment and to approximate the unknown model of the robot. Both full-state and output feedback control are utilized in this work. The authors demonstrate uniform ultimate boundedness using Lyapunov’s approach and further demonstrate convergence towards a small neighborhood of zero with an appropriate choice of design parameters. Simulation results demonstrate the effectiveness of their approach. \subsection{Stability Assurance while Learning the Optimal Policy} In optimal control theory, a cost function is given as $J(x,u) = \int_0^T r(x(t),u(t)) dt$ and an optimal controller is sought that minimizes $J$ while adhering to the dynamic constraints $\dot x = f(x) + g(x)u$ with $x(0) = x_0$ \cite{liberzon2011calculus}. When $T = \infty$ and the dynamic constraints are autonomous, the optimal value function $V^*(x_0) := \inf_{u \in \mathcal{U}} J(x(\cdot;x_0), u)$ is time invariant and satisfies the Hamilton-Jacobi-Bellman (HJB) equation \[ 0 = r(x,u^*) + (\Delta_x V^*)^T(f(x) + g(x)u^*), \] where $u^*$ is the optimal controller \cite{liberzon2011calculus,kamalapurkar2018reinforcement}. When $r(x(t),u(t)) = x^T(t) Q x(t) + u^T(t) R u(t)$, the optimal controller can be expressed, in terms of the optimal value function, as \[u^*(x) = -\frac12 R^{-1}g^T(x)\Delta_x V^*(x).\] However, there is a limited collection of dynamics for which a closed form solution to the HJB is known \cite{lewis2012optimal,liberzon2011calculus}. This motivates the investigation into numerical methods for determining the value function and subsequently an optimal controller. For offline optimal control problems, value and policy iteration \cite{bertsekas2005dynamic} are valuable tools for determining an approximation of the value function and optimal controller. However, it is desirable to learn the optimal value function and optimal controller online for many situations, such as when there are uncertainties in the dynamics that cannot be accounted for in an offline setting or in the presence exogenous disturbances \cite{vrabie2009neural}. There are several extant methods that learn the optimal controller online through the, so called, method of adaptive dynamic programming (ADP) that use an online actor-critic architecture for learning the optimal value function \cite{vamvoudakis2010online,stingu2011approximate,kamalapurkar2018reinforcement}. For example, the work of \cite{stingu2011approximate} uses a radial basis function network for approximating the value function, while \cite{kamalapurkar2015approximate} uses a polynomial basis. A local learning method was introduced in \cite{kamalapurkar2018reinforcement,kamalapurkar2016efficient} to reduce the computational overhead required for an accurate approximation. Online learning control problems face the issue of stability during the transient learning phase \cite{lewis2012optimal,kamalapurkar2018reinforcement}. As the weights of a neural network are tuned to improve the accuracy of the value function approximation and thus the accuracy of the controller, uncertainties can lead to unbounded trajectories and a loss of stability. Two main approaches have been utilized in the literature to provide assurances of stability during the learning phase of the optimal control problem. One approach uses the concept of persistence of excitation \cite{vamvoudakis2010online}, while the other utilizes concurrent learning \cite{kamalapurkar2016efficient,Kamalapurkar2013ConcurrentLA}. The implementation of both are used in tandem with Lyapunov stability analyses to provide stability guarantees \cite{vamvoudakis2010online,kamalapurkar2016efficient}. \section{Learning: Specification Inference and Learning} In \cite{JhaTeLEx2017}, Jha, Tiwari, Seshia, Sahai, and Shankar present an approach to passive learning of Signal Temporal Logic (STL) formulas that only observes the positive examples and excludes systemic safe active experimentation, which is outside of the traditional two categorizations. In practice, there are classifier-learning and active-learning techniques. Classifier-learning techniques use both positive and negative examples for STL formula learning and active-learning techniques experiment on the system to extract counterexamples. The authors evaluate their system on a metric of tightness, which represents predicates and temporal operators as smooth functions and is influenced by techniques for numerical optimization based on gradients. Further work would be parameter specification for tightening, examine proposed additional metrics, and parallelize the computation of the trace metrics. In \cite{JhaBoolean2017}, Jha, Raman, Pinto, Sahai, and Francis present an approach to Boolean formulae learning that queries example-labeling oracles. The main contribution of the paper is an algorithm for Boolean formulae learning with a given level of confidence. The aforementioned algorithm can be used to generate explanations for decisions made by Artificial Intelligence (AI) based systems. The benefits of making the self-explanation capabilities for AI systems would be easing the human-system interaction. Further work should include the utilization of a language with richer logic for the explanations involving real numbers and the generation of multiple valid justifications for any given inquiry. In \cite{FisacSafety2017}, Fisac et al. present a Hamilton-Jacobi reachability methods-based framework for general safety that works with any learning algorithm. The Gaussian processes and the reachability analysis used in the framework are computationally expensive and are not scalable. The main control theory aspect utilized in the framework is robust reachability combined with observational Bayesian analysis. The authors provide proof that the two methods in conjunction work well. Further work should include increasing the safety certificates with respect to intelligent systems. In \cite{HerbertFaSTrack2017}, Herbert et al. present an algorithm for fast and safe tracking (FaSTrack) in high dimensional systems called FaSTrackHD. The FaSTrack framework can be used in combination with a path planner to guarantee the safety and efficiency of the plan. This paper provides a look-up table tool, a framework for tool implementation, and a high-dimensional demonstration of the tool and framework combination. FaSTrack makes planners more robust while maintaining fast computation. Further work could include moving obstacle robustness, considering environmental disturbances to which the error bounds should adapt, and multi-planner demonstrations. In \cite{AkametaluReachability2014}, Akametalu et al. present an approach that utilizes a Gaussian process model and maximal safe set approximations to learn a system's unknown characteristics. Safety is incorporated in the metric through which the learning performance is evaluated, thus reducing controller switching. The safe learning algorithm presented is reachability-based. Through utilizing Gaussian processes, it learns a model of environmental disturbances. Overall, the algorithm provides better safety guarantees than the state-of-the-art frameworks. Further work could include safe set real-time updates and using sparse Gaussian processes to speed up the computations. In \cite{FisacPragmatic2017}, Fisac et al. present a solution to the value-alignment problem based on learning models that can be experientially verified. The framework interweaves human decision making and cooperative inverse reinforcement learning to solve the problem of value-alignment. This work shows that cooperative inverse reinforcement learning problems can be solved not just theoretically but practically. Further work should include making the approaches more efficient and utilizing human models that are more realistic. In \cite{ChenUAVSafety2017}, Chen et al. present an approach of creating platoons of unmanned aerial vehicles (UAVs) that uses Hamilton-Jacobi reachability analysis. In order to implement a sense of structure in the air, the approach requires that the platoons of UAVs fly on air highways. The authors verify their concept through simulating forming a platoon, an intruder vehicle, and transitioning between highways. The fast-marching algorithm is used to determine the air highway placements. The implemented algorithm takes an arbitrary cost map and determines the path set from the origin to the destination. As long as only one breach per platoon vehicle occurs, the controller assures that collisions will not occur with one altitude level. The addition of safety breaches requires additional altitude levels. In \cite{ChenSafePlatooning2017}, Chen, Hu, Mackin, Fisac, and Tomlin present an approach of safe and reliable platoons of unmanned aerial vehicles (UAVs) that uses Hamilton-Jacobi reachability analysis which is the initial work or a simplification of \cite{ChenUAVSafety2017}. In order to implement a type of structure in the air, the approach requires that the platoons of UAVs fly on air highways. They verify the concept through simulating a platoon formation, a vehicle intrusion, and transitioning between highways. The fast-marching algorithm is used to determine the air highway placements by taking an arbitrary cost map and determining the path set from the origin to the destination. As long as only one breach per platoon vehicle occurs, the controller assures that collisions will not occur with one altitude level. The addition of safety breaches requires additional altitude levels. In \cite{jin2015mining}, Jin et al. present a scalable framework to mine specifications from a closed-loop control model of an industrial system based on the system's behavior. The input is represented by a parametric signal temporal logic (PSTL)\cite{asarin2011parametric}, where time or scale values are unknown parameters. Based on the quantitative semantics of signal temporal logic (STL), a falsification engine in \cite{donze2010breach} is applied to check for the existence of traces violating current STL formulae. To find the strongest candidate specification, a parameter synthesis algorithm based on $\delta$-tight valuations is applied by finding the valuation closest to the boundary of a validity domain. Since the monotonicity of a PSTL formula will greatly decrease the computational complexity, they also propose an algorithm to check and take advantage of it. The framework's utility and scalability are tested on an automatic transmission model, an air-fuel ratio control model, and a diesel engine model. \subsection{Automata Learning} Automata Learning can be partitioned into active and passive learning approaches. Automata can be discrete, continuous, or hybrid in nature. Discrete automata are state machines where the states are discrete, whereas continuous automata are state machines where the states are continuous. Hybrid automata are state machines where the variables are set by ordinary differential equations. Active Learning allows the learner machine to decide from which data to learn \cite{SettlesActiveLearning2010} \cite{OlssonActive2009}. Active Learning is utilized in synthesizing membership queries, sampling based on selective streams, and sampling that is based on a data pool. The remainder of the section is split into learning hybrid automata, timed automata learning, discrete automata learning, and active learning of automata. In \cite{AngluinQuery1988}, Angluin studies and describes multiple types of queries in formal domains. They examined membership, equivalence, subset, superset, disjointness, and exhaustiveness queries. They applied the aforementioned types of queries to various domains. Singleton languages, \textit{k}-CNF formulas, \textit{k}-DNF formulas, monotone DNF formulas, regular languages, \textit{k}-bounded CFLs, \textit{k}-term DNF formulas, \textit{k}-clause CNF formulas, pattern languages, very restricted CFLs, and double sunflower are the domains examined in the paper. Their results show that some queries perform better on certain domains. In \cite{BalkanUnderminer2017}, Balkan, Tabuada, Deshmukh, Jin, and Kapinski present the framework, Underminer, for determining which behaviors are non-convergent in the designs of control systems that are embedded. The system being examined by the framework is considered a black-box, meaning that only the inputs and outputs are examined. The framework uses Convergence Classifier Functions (CCFs) to distinguish between the non-convergent behaviors and convergent behaviors. The framework can be applied to a system either in the early development stages or late in the controller development stage. The Underminer framework first determines the non-convergent behaviors using CCFs and then performs CCF automated test generation and examination. Temporal logic, Lyapunov functions, and machine learning classification techniques are all CCFs supported by Underminer. Optimizer-driven testing and sampling-based test generation techniques are utilized by Underminer during the test generation phase. \subsubsection{Hybrid Cases} In \cite{AnsinAutomated2013}, Ansin and Lundberg present the hybrid congruence generator extension (HyCGE) learning algorithm and examine its characteristics. The validity and accuracy of the algorithm are also graphically demonstrated. The ratio of the completeness was shown to have continuous growth for the example automata. A future application of the HyCGE algorithm is physical systems learning. Further work could include full diagrams and simulations of the human body through learning that is automated. The HyCGE learning algorithm can be used for the aforementioned automated learning. In \cite{MedhatFramework2015}, Medhat, Ramesh, Bonakdarpour, and Fischmeister present an approach for hybrid automata learning based on the implementations of control systems as black-boxes and examine the inputs and outputs of said systems. Input/output events are gathered from the observed traces, based on which target system is modeled with a Mealy machine. The dynamics of state variables in each discrete state are analyzed, where the time factor is involved. The framework is limited in that all of the types of signals may not be supported, hidden states cannot be observed, guards using output values for transitions can not be modeled, and that change from input to output is assumed instantaneous. Further work could include improving data preprocessing and segmentation; utilizing algorithms that have better efficiency; support for causality rules expansion; and automata inference improvements. In \cite{NiggemannLearning2012}, Niggemann, Stein, Maier, Voden\v{c}arevi\'{c}, and B\"{u}ning present and analyze the Hybrid Bottom-Up Timing Learning Algorithm (HyBUTLA), an algorithm for automata learning. The observed traces are segmented according to abrupt change in state values. The dynamics of each segments is modeled using linear regression or neural networks and is represented as a function within a state. Similarity of two states is tested by checking the probability for staying in the state versus a specific transition occurring. In a new bottom-up merging order, similar states get merged and the higher efficiency in comparison to traditional top-down order is verified. The scalability of HyBUTLA was tested using generated artificial data. Further work could include developing a better algorithm for hybrid state identification, using probability density functions instead of fixed time intervals, and further algorithmic plant applications. In \cite{SummervilleCHARDA2017}, Summerville, Osborn, and Mateas exhibit and evaluate the Causal Hybrid Automata Recovery via Dynamic Analysis (CHARDA) framework. The framework performs modal identification and learns the causal guards. In the first phase, one set of potential linear model templates has a cost function with penalty criteria applied to segment traces by switch-points and select the optimal models. For the guard condition, they applied Normalized Pointwise Mutual Information (NPMI) to select predicates from a predefined set for each mode transition. They tested the CHARDA framework on Super Mario Bros as a novel domain. Further work, with respect to the segmentation, could include testing the segmentation and then transition learning general framework to other techniques, determine the optimal method of differentiating between similar modes, and incorporate other approaches' techniques. Further work, for learning causal guards, could include testing it on other domains and improving upon the analytic precision. In \cite{BogomolovPDDL+2015}, Bogomolov, Magazzeni, Minopoli, and Wehrle examine the theoretical basis for translation using Planning Domain Definition Language+ (PDDL+). The translation of must-transition automata to only may-transition automata is the prime directive of their schema. PDDL+ is used since processes and events are well-handled. The construction of the translated hybrid automata causes the state space that is reachable to be the same as hybrid automata that are linear. Hybrid automata with dynamics that are affine have a reachable state result that is over-approximated. This paper founds the process of PDDL+ problem translation into hybrid automata that are standard. In \cite{grosu2007learning}, Grosu et al. propose a methodology for inferring cycle-linear hybrid automata for two types of excitable cells from virtual measurements generated by existing nonlinear models. In the first phase, traces of electrical signal, known as action potential with respect to time, are segmented by filtered null points and inflection points. Then, they apply modified Prony’s method to fit an exponential function to each of the segments within a predefined error bound, which derives a flow condition for each mode. The transition voltages for mode switches are approximated by a range of voltage obtained from transitions’ post states. In the second phase, all of the inferred linear hybrid automata are merged into a signal one by setting an epoch transition. The accuracy of the proposed method is tested by comparing it with the simulations of two existing models. \subsubsection{Timed Automata} In \cite{IegorovPeriodic2017}, Iegorov, Torres, and Fischmeister present PeTaMi (PEriodic TAsk MIner), a periodic task mining approach and tool that utilizes the information from the real-time systems being examined. The tool classifies the tasks into periodic and non-periodic and then, using only the periodic tasks, determines the time of response and periods for said tasks. This method is automatic and uses the timestamped traces of events for classification. The period and time of response for a periodic task is determine through the use of a clustering-based mining approach for temporal specifications. The tool examines the input trace of execution and trace fields and then classifies them into periodic or non-periodic. In order to evaluate the system, they tested it on an unmanned aerial vehicle (UAV) case study and a commercial car in operation case study. Those results were indicative of information needed to determine the period and response time for the periodic tasks. In \cite{VerwerEfficient2010}, Verwer presents an extensive study of the timed automata identification complexity theory. They also unveil an algorithm that uses labeled data to perform timed automata identification. The algorithm is then tested on real-time system identification with a behavior system for truck drivers. It was determined that deterministic timed automata (DTA), each with a single clock, have efficient identification, whereas DTA with more than one clock are not efficiently identifiable. They discuss the Real-Time Identification (RTI) algorithm which is efficiently used for deterministic real-time automata identification using only a input sample that is timed and labeled data. It was tested on artificial data. The RTI algorithm was tested on the truck driver system and had 80 percent accuracy. Further theoretical work could be focused on the theory of identifying timed automaton, algorithms for identifying timed automaton, or evaluating probabilistic models. Some further applications include behavior identification, visualization providing insight, or model checking identification. In \cite{FiterauCombining2016}, Fiter\u{a}u-Bro\c{s}tean, Janssen, and Vaandrager use a combination of model learning and model checking to infer models and thoroughly examine said models. They studied the Windows, Linux, and FreeBSD TCP (Free Berkeley Software Distribution Transmission Control Protocol) implementations. The TCP learning implementation includes upper layer calls, data transmission, servers and inferred TCP models, and learned models for all of the aforementioned operating systems. Model checking is used to fully examine the explicit models of the components. The described method is versatile and has variable applications. Further work could include making the construction of TCP abstractions completely automatic and creating state machine generation capable learning algorithms. Verwer, de Weerdt, and Witteveen present the efficiency of timed automata learning \cite{VerwerEfficiency2011}. They show that deterministic timed automata (DTAs) in general cannot be efficiently learned using labeled data but that one-clock DTAs (1-DTAs) can be efficiently learned using labeled data. They establish an algorithm for learning one-clock DTAs. Further work could include using an n-DTA identification algorithm to efficiently identify 1-DTAs and determining the largest class of efficiently learnable DTAs. In \cite{VerwerEfficiently2012}, Verwer, de Weerdt, and Witteveen present a deterministic real-time automaton (DRTA) learning algorithm, real-time identification (RTI) algorithm, utilizing event sequences that were labeled and time-stamped. The algorithm merges states based on the evidence to identify a deterministic finite-state automaton (DFA). The performance of the aforementioned algorithm is evaluated using artificially generated data. It is evident that it is harder to identify a DFA than to identify an equivalent DRTA. Further work could include extending the RTI algorithm to work for unlabeled data, enable identification of timed automata that are more general, and evaluate the performance of the adapted algorithms. In \cite{ZhangCar2017}, Zhang, Lin, Wang, and Verwer present a car-learning behavioral model that utilizes automata learning algorithms. Driving patterns are discovered from examining and extracting common sequences of states from the model. The model was trained and tested on the Next Generation SIMulation dataset exhibiting high accuracy. They also represent time data that is multivariate as strings that are symbolic and timed. The input data clustering utilizes the properties of the temporal processes. The mentioned utilizations significantly increased the accuracy of the data fitting. Further work could include comparing the model to other existing model implementations, apply to drivers' decision making, and assisting in the development of a car-following controller. In \cite{AartsLearning2012}, Aarts, Kuppens, Tretmans, Vaandrager, and Verwer demonstrate that the combination of tools for verification and testing software can be used in combination with active learning in an industrial environment. The tool combinations can be utilized to evaluate and improve upon the active learning results. They employ active state machine learning to perform conformance tests on implementations of the protocol for bounded retransmission. Further work could include improving upon the Markov Reward Model Checker (MRMC), TorXakis, and Tomte tools. In \cite{SmeenkApplying2015}, Smeenk, Moerman, Vaandrager, and Jansen present control software from industry with automata learning actively applied. They also examined LearnLib's capabilities with regards to learning the model of the Engine Status Manager (ESM). Due to the large number of abstractions required by LearnLib, the authors extended a preexisting algorithm to enable the computation of a sequence that is adaptive distinguishing. Using the algorithm extension, they learned a model using a Mealy machine for the ESM. The extended algorithm performed superiorly to other algorithms for conformance testing. Further work could include model learning for multi-functional ESM and model learning for ESM connecting components. In \cite{VerwerAlgorithm2007}, Verwer, de Weerdt, and Witteveen exhibit a real-time automata learning algorithm. The traditional algorithms involve state merges but their algorithm implements state splits, which utilize the time data. Real-time automata are prevalent in models of systems where behavior monitoring is vital. Further work could include extending the algorithm to cover probabilistic timed automata which would only require examining the positive examples and enable real-world applications. \subsubsection{Discrete Learning} In \cite{MuddassarIDS2012}, Sindhu and Meinke present the incremental distinguishing sequences (IDS) algorithm for learning deterministic finite automata (DFAs) incrementally using sequence differentiation. The performance analysis looked mainly at the variety of learning queries possible and the time taken for the learning. From the analysis, the algorithm is most applicable for problems in software engineering. In \cite{GiantamidisLearning2016}, Giantamidis and Tripakis present three algorithms for solving the problem of Moore Machine learning from input-output traces and formalize said problem. The first algorithm is the prefix tree acceptor product (PTAP) algorithm which, using self-loops, completes the Moore Machine formed from input-output trace data. The second algorithm is the PRPNI algorithm that utilizes the Regular Positive and Negative Inference (RPNI) algorithm for learning an automata product and encodes the Moore Machine. The third algorithm mentioned is the MooreMI algorithm which performs Moore Machine learning directly utilizing the state merging from the extended PTAP algorithm. Overall, the MooreMI algorithm is shown to be the most progressive algorithm of the set. Further work could include learning other types of state machines, making each algorithm incremental, more experimentation and implementation, and extending the algorithms to model any black-box system. \subsubsection{Active Learning} In \cite{RaffeltLearnLib2005}, Raffelt, Steffen, and Berg present LearnLib, a library for learning and experimenting on automata. The library has a modular structure conducive to scenario tailoring. Users have the ability to specify the model structure, the applied techniques for optimization, choose between the automatic and the interactive mode, and use a simulator for random models. The library examines the power of exploiting optimization properties. Further work could include extending the library by modular increases, other property exploitation, exploring other occurrences, and increasing the complexity of the scenarios of applications. Works also will include making LearnLib available online. In \cite{MertenNextGeneration2011}, Merten, Steffen, Howar, and Margaria present Next Generation LearnLib (NGLL) framework. The framework is intended to make the task of setup creation for fitting learning simpler. It allows for remote component integration into the framework so it can be used globally. NGLL has tools and methods available to perform a multitude of tasks, such as harnesses for testing a system, techniques for making a system more abstract or refining said system, and mechanisms for resetting a system. The framework was designed for ease of use with respect to controlling, adapting, or evaluating a system. In \cite{IsbernerOpenSource2015}, Isberner, Howar, and Steffen exhibit the new open-source version of LearnLib, an active automata learning library. It allows for visualization learning algorithm in-detail progress. The tool has a modular design which simplifies modifying features of the algorithm. The feature component, AutomataLib, is a finite-state machine data structure and algorithmic toolkit. The performance of the new LearnLib is efficient while allowing abstractions on a high-level. Further work could include adapting LearnLib Studio for the new LearnLib and extending the capabilities to enable register automata learning. \subsection{Safe Reinforcement Learning} Reinforcement Learning (RL) is a widely adopted frameworks in Artificial Intelligence for producing intelligent behavior in autonomous agents \cite{KaelblingSurvey1996}. \noindent By interacting with their environments, these autonomous agents can learn to execute optimal behaviors via trial and error over a specified time period\cite{Arulkumaran2017}. Thus, in this scheme, agents can be programmed to accomplish a wide range of tasks without forcing the programmer to delineate how these tasks should be carried out. Furthermore, reinforcement learning has exhibited great success in modeling interactions between an autonomous agent and its environment where a model is too difficult to procure. In fact, reinforcement learning has demonstrated great utility in contexts such as game playing, robotics applications, industrial automation, autonomous vehicles, complex financial models, and structured prediction \cite{KaelblingSurvey1996,BerkenkampSafeModelRL2017,Arulkumaran2017}. \par Although there has been great success in using reinforcement learning to solve low dimensional problems, the majority of learning approaches exhibit scalability issues. However, with the advent of successful deep learning paradigms there has been great research impetus in improving the scalability of reinforcement learning schemes through the use of neural networks. Using this framework, the field of Deep Reinforcement Learning has displayed great promise in accelerating progress within the reinforcement learning community by adequately addressing the prohibitive dimensionality issues associated with complex state action spaces \cite{Arulkumaran2017}. Coupled with the desire to enhance the efficiency of reinforcement learning regimes is the desire to guarantee safety, particularly in safety critical environments where there is significant risk towards the people and environments involved \cite{BerkenkampSafeModelRL2017}. As with many algorithms in machine learning, the majority of traditional reinforcement learning techniques are unable to provide guarantees about the safe operation of a system. However, in order to deploy this kind of software in safety critical settings, one must be able to provide formal arguments about the safe operation. Thus, in recent years there has been a great deal of research into developing safe reinforcement learning frameworks. \par In a classic reinforcement-learning architecture, an agent interacts with its environment over a given time period through observations and actions that are typically described by a Markov Decision Process (MDP) \cite{Arulkumaran2017}. During each time step an agent receives some information about the current state of its environment and chooses an action to perform generating an output about its altered state. Based on each action selection, a reinforcement signal denoting the value of this transition is communicated to the agent. Throughout the learning process, the agent is trained to select actions that maximize the long-term sum of reinforcement signals \cite{KaelblingSurvey1996}. There are numerous algorithms that allow an agent to select an optimal behavior policy through systematic trial and error and a survey of these techniques can be found in the following papers \cite{KaelblingSurvey1996,Arulkumaran2017}. Formally, the Markov Decision Process model can be defined as a tuple (\textit{S,A,T,R, $p_0$}) where: \begin{itemize} \item \textit{S} is a continuous set of states, \item \textit{A} is a set of continuous actions, \item \textit{T}: $S \times A \rightarrow S$ is a probabilistic transition function that maps a state action pair at some time $t$ onto a probabilistic distribution of states, \item \textit{R}: $S \times A \times S \rightarrow \mathbb{R}$ is an immediate reward function, \item and $p_0$ specifies a unique initial state \cite{AlshiekhSafeRL2017}. \end{itemize} Thus, the problem of reinforcement learning is to learn a policy $\pi_\theta: S \times A \rightarrow \mathbb{R}$ that mamximizes the cumulative discounted reward $\sum_{t=0}^{T-1} \gamma^TR(s_t,r_t,s_{t+1}) $ where \textit{R} is the reward at time step $t$ and $\gamma \in [0,1]$ is a discount factor that controls the influence of future rewards \cite{PintoRobust, QingkaiAcceleratedSafeRL2018}. Additionally, in most frameworks, there is a common assumption that the learning environment is non-deterministic in nature. Thus, the same choice of action by an agent may result in different reward values at different time instants \cite{KaelblingSurvey1996}. However, this assumption is often coupled with the presumption that the probabilities of making state transitions or observing certain reinforcement signals do not change over time \cite{KaelblingSurvey1996}. Despite the success of the MDP reinforcement learning model, this approach has several limitations. The MDP model suffers from representation limitations and not all learning agents can estimate a notion of a Markovian state \cite{ShalevMultiRL}. This shortcoming in representation is commonly found in robotics applications. Additionally, in some applications such as autonomous driving, the transition of states is dependent not only the agents actions but also on the actions of other agents. Moreover, in these cases, we must be able to guarantee safety during the exploration process in order to prevent dangerous and costly adverse scenarios. In response to the modeling, safety, and performance challenges present within the reinforcement learning community, numerous researchers have proposed various solutions aimed at generating effective, robust, and intelligent behavior \cite{ShalevMultiRL}. \par In a 2015 survey of existing safe reinforcement learning literature, Javier Garc\'ia defined safe reinforcement learning as "the process of learning policies that maximize the expectation of the return in problems in which it is important to ensure reasonable system performance and/or respect safety constraints during the learning and/or deployment processes \cite{GarciaSurvey}." Moreover, in his work, Garc\'ia notes that the idea of risk in safe reinforcement learning regimes is complex and takes many forms. In many works, risk is related to the presence of uncertainties in the environment with which an autonomous agent interacts. Thus, even if an agent is able to correctly learn an optimal behavior policy there are still risks associated with unexpected disturbances that may result in generalization and simulation-transfer issues \cite{GarciaSurvey}. Additionally, one must reason about the failure modes of learned policies in order to identify behaviors that may pose considerable danger to the agents and environments considered. In his survey, Garc\'ia identifies two fundamental approaches towards the problem of creating safe reinforcement learning architectures present in the research literature. The first set of methods alter the optimization criteria present in the learning process by incorporating a notion of risk into the reward optimization process. The second set of procedures modifies the exploration process of the learning agent either by including the likelihood of entering error states through the use of external knowledge or via the use of a risk metric \cite{GarciaSurvey}. Garc\'ia's survey provides a great review of these works and discusses several novel directions for researchers interested in the field. \par As mentioned above, one of the central foci in safe reinforcement learning algorithms is ensuring that agents do not behave in unexpected and errant ways during the exploration and learning processes. In many cases, the exploration process may be costly or dangerous and we are required to ensure safety at all times. Addressing this issue in their work, Theodore Perkins et al. propose a method, in \cite{PerkinsLyapunov}, for constructing safe and reliable learning agents for control problems using Lyapunov design principles. In their framework, an agent learns an optimal behavior by switching between a set of base level controllers designed using Lyapunov domain knowledge. Thus, the authors are able to ensure safe control by limiting the set of actions that an agent can select from in order to guarantee that every transition descends towards a Lyapunov function \cite{PerkinsLyapunov}. In fact, in the experimental evaluation of their techniques, the authors were able to demonstrate that this methodology was feasible regardless of the particular reinforcement learning algorithm selected. In a similar work introduced by Felix Berkenkamp et al. \cite{BerkenkampSafeModelRL2017}, the authors extend the results produced in the field of Lyapunov stability verification in order to obtain control policies that have provable stability and safety guarantees\footnote{An implementation of Felix Bergenkamp's methodology can be found at \url{https://github.com/befelix/safe_learning}}. In fact, the authors demonstrate that it is possible to learn an optimal policy with stability and safety guarantees while striving not to limit the state space from which an agent may select an action. Moreover, their approach allows an agent to collect data in order to expand the state space of the computed safe region while also improving the control policy \cite{BerkenkampSafeModelRL2017}. This is done by starting from a configuration that is assumed to be stable and gathering data at safe and informative points in order to improve the control policy using the newly obtained, enhanced model of the system. \par While the above approaches display promising results for achieving safe control, there are concerns that methods that limit the environment's state space may eliminate actions that are better in achieving an optimal cost. Additionally these methods require more data than traditional reinforcement learning regimes. Thus, these models may be more susceptible to model inaccuracies due to insufficient data and model disturbances \cite{GarciaSurvey,ThomasSafeRL,MunosSafeEfficientRL2016}. In support of these concerns, in their paper, Anayo Akametalu et al. cite that in reachability based algorithms, the computed safe region utilized in safe reinforcement learning algorithms may not accurately capture the true nature of disturbances present in an environment and therefore lead to safety guarantees that are no longer dependable. Thus, to address these concerns, the authors propose a learning regime that makes use of a Gaussian process to learn a system's unknown dynamics by iteratively approximating a safe set. Throughout the learning process, their safety model is validated online in real time allowing the authors to guarantee safety in conditions where the assumptions about environmental disturbances are incorrect. Moreover, their methodology makes use of a safety metric in order to limit the amount of time that their system interferes with the learning process. Their framework represents an interesting approach that proposes a reachability analysis scheme that cross validates the model online. In a similar work by Jeremy H. Gilula et al. \cite{GillulaGuaranteedSafeRL2012}, the authors present a guaranteed safe online learning framework for an aerial robot with a limited field of view. Their approach combines reachability analysis and online reinforcement learning. Simulation of their methods demonstrates that combining the two paradigms allows for high performance and safety. \par Another promising area of safe reinforcement learning makes use of model checking algorithms and methods derived form formal verification to ensure safety. In their paper, Mohammed Alshiekh et al. present a temporal logic based approach for learning optimal policies \cite{AlshiekhSafeRL2017}. To ensure that a system specification expressed in temporal logic is satisfied, the authors implemented a system, called shield, that alters the learning process in two fundamentally different ways. In the first regime, shield provides a list of safe actions from which an agent may select. In the second regime, shield monitors the actions of the learning agent and interferes only when necessary \cite{AlshiekhSafeRL2017}. In another work presented by Shashank Pathak et al. \cite{PathakSafeRLVerification2018}, the authors make use of probabilistic model checking algorithms in order to verify and repair learned policies. In this work, the authors provide a set of repair approaches and policy modification strategies that ensure that the probability of reaching unwanted states and executions, once the learning process terminates, remains within an acceptable bound. Additionally, the authors provide a benchmark, called "Slippery Grid World," that other authors may use to assess the scalability and effectiveness of their approaches \cite{PathakSafeRLVerification2018}. In a similar work done by Nathan Fulton and Andr\'e Platzer, the authors propose a technique, called Justified Speculative Control (JSC), for provably safe reinforcement learning \cite{FultonSafe18}. Their results combine formal verification and runtime monitoring in order to ensure the safety of a system. Moreover, their work contributes a set of proofs that transfer computer-checked safety proofs for hybrid dynamical systems to policies obtained by generic reinforcement learning algorithms \cite{FultonSafe18}. In their learning environment, verification results are maintained when learning agents limit their operation to remain within verified control choices. Thus, their regime is similar to many works cited in Garc\'ia's survey in which incorporating knowledge about safe control into the learning system preserves safety guarantees \cite{FultonSafe18,GarciaSurvey}. \par In recent years, researchers have demonstrated that machine learning models may be susceptible to attacks during all phases of the learning process \cite{KumarAdversarial2017}. The majority of models can be fooled by carefully crafted input samples that result in misclassification. Using these samples, an attacker may be able to slow the learning process or affect the performance of a model by causing the system to enter into a dangerous configuration. These concerns have served as the motivation for an emerging field of research called Adversarial Machine Learning \cite{KumarAdversarial2017}. While adversarial machine learning approaches usually deal with perception tasks in neural networks, there have been a few works proposed within the safe reinforcement learning community: particularly tasks related to autonomous vehicles and neural network aided reinforcement learning. In a paper proposed by Lerrel Pinot et al., the authors present a scheme for robust adversarial reinforcement learning \cite{PintoRobust}. They argue that numerous reinforcement learning regimes suffer from a high reliance on data causing them to suffer from generalization issues and errant behavior caused by the presence of environment disturbances. Thus, in order to design more disturbance-robust systems, the authors train agents in the presence of an adversarial agent that delivers model disturbances aimed at destabilizing the system \cite{PintoRobust}. Using a zero sum minmax objective function to learn a policy, the authors were able to successfully train an agent that was robust to the adversarial agent as well as other environmental disturbances. Moreover, their agent was more robust to differences in the testing and training environments. In a similar work done by Henrik Aslund et al., the authors present the concept of virtuously safe reinforcement learning which is defined as resilience toward perturbed perception, safe exploration, and safe interruption \cite{AslundVirtuouslySafeRL2018}. In their work, the authors demonstrate how to create a learning scheme in which agents are able to manage adversaries using four exploration strategies that accomplish the goal of virtuously safe reinforcement learning. \par In summary, Safe Reinforcement Learning techniques are used to address a wide range of problems where it is important to guarantee safety constraints of learning policies. There are numerous approaches with various drawbacks, advantages, and different conceptions of risk that have demonstrated great promise in ensuring that an agent will operate safely within its environment. However, there are still many open questions within this realm, such as balancing safety constraints with performance desires and improving the scalability and computational tractability of the current approaches \section{Motivation and Prevalence} Artificial intelligence (AI) is in a renaissance, and AI methods, such as machine learning (ML), are now at a level of accuracy and performance to be competitive or better than humans for many tasks. Deep neural networks (DNNs) in particular are increasingly effective at recognition and classification tasks. For instance, much of the sensing, estimation, and fusion of such data that enables applications such as autonomous driving and other autonomous cyber-physical systems (CPS) increasingly relies on DNNs and similar ML techniques. However, this progress comes at significant risk when these methods are deployed in operational safety-critical systems, especially those without direct human supervision. Building on applications of AI/ML in autonomous CPS, this paper surveys the current state-of-the-art for safely integrating AI/ML components---which we term \emph{learning enabled components (LECs)} into safety-critical CPS. This survey consists of several major parts, focused around how machine learning is enabling autonomy in CPS, including: illustrative applications, intelligent control, safety architectures with AI/ML components, understanding AI/ML components and systems through statistical and symbolic methods---such as specification inference and automata learning---safe planning, reachability analysis of AI/ML components, such as neural networks, etc. Much of the recent progress in AI/ML relies on advances in statistical methods, such as DNNs, where it is difficult to understand how components operate and how decisions are made. In contrast, much recent progress in formal methods relies around symbolic methods, where semantics and operational behaviors are precisely specified. \section{Preliminaries} \section{Verification for AI/ML Components and Systems} \subsection{Verification: Neural Network Reachability} Artificial neural networks are used in systems that introduce machine learning components to resolve complex problems. This can be attributed to the impressive ability of neural networks to approximate complex functions as shown by the Universal Approximation Theorem \cite{hornik1989multilayer}. Neural networks are trained over a finite amount of input and output data, and are expected to generalize said data and produce desirable outputs for the given inputs and even for previously unseen inputs. The data-driven nature and lack of efficient methods for analysis of neural networks leads to, in most cases, the treatment of neural networks as black boxes with no assurance in safety. However, due to the rapid development artificial intelligence inspired applications, neural networks have recently been deployed in several safety-critical systems such as self-driving vehicles \cite{bojarski2016end}, autonomous systems \cite{julian2017neural}, and aircraft collision avoidance procedures \cite{julian2016policy}. Regrettably, it has been observed that neural networks can react in unexpected and incorrect ways to even slight perturbations of their inputs \cite{szegedy2013intriguing}. Therefore, there is an urgent need for methods that can provide formal guarantees about the behavioral properties and specifications of neural networks, especially for the purpose of safety assurance \cite{Leofante2018}. Verifying neural networks is a hard problem, and it has been demonstrated that validating even simple properties about their behavior is an NP-complete problem \cite{katz2017reluplex}. The difficulties encountered in verification mainly arise from the presence of activation functions and the complex structure of neural networks. Moreover, neural networks are large-scale, nonlinear, non-convex, and often incomprehensible to humans. The action of a neuron depends on its activation function described as $y_i = f(\sum\nolimits_{j=1}^{n}\omega_{ij}x_j+\theta_i)$, where $x_j$ is the $j$th input of the $i$th neuron, $\omega_{ij}$ is the weight from the $j$th input to the $i$th neuron, $\theta_i$ is called the bias of the $i$th neuron, $y_i$ is the output of the $i$th neuron, and $f(\cdot)$ is the activation function. Typically, the activation function is either the rectified linear unit, logistic sigmoid, hyperbolic tangent, the exponential linear unit, or another linear function. To circumvent the difficulties brought by the nonlinearities present in the neural networks, the majority of recent results focus on activation functions of piecewise linear forms, $f(x) = \max(0,x)$, and in particular the Rectified Linear Unit (ReLU). For instance in \cite{xiang2017reachable_arxiv}, by taking advantage of the piecewise linear nature of ReLU activation functions, the output set computation can be formulated as operations of polytopes if the input set is given in the form of unions of polytopes. Figure \ref{fig:ReLU} shows a visualization of the polytopic operations using ReLU functions. The computation process involves standard polytope operations, such as intersection and projection, and all of these can be computed by employing sophisticated computational geometry tools, such as MPT3 \cite{MPT3}. The essence of the approach is to be able to obtain an exact output set with respect to the input set. However, the number of polytopes involved in the computation process increases exponentially with the number of neurons in its worst case performance which makes the method not scalable to neural networks with a large number of neurons. In practice however, the number of polytopes used in the computation process is usually smaller than worst case operation since empty sets are often produced during the computation procedure. By pre-classifying the active or inactive status of neurons before manipulating the polytopes of each layer and utilizing parallel computing techniques, the computational cost can be reduced to some extent. In the experimental evaluation of these techniques, the authors in \cite{xiang2017reachable_arxiv} were able to decrease the computational time to a third of the original computation time when analyzing a 7 layer network. Furthermore, the authors were able to utilize this approach for feedback control systems equipped with neural network controllers, where the controlled plant is considered to be a piecewise-linear dynamical system and their efforts are described in \cite{xiang2018reachable_acc}. It should be noted that in the verification of neural network control systems with more general activation functions, it is significantly more difficult. In \cite{scheibler2015towards}, they use bounded model checking (BMC) to create formulas that are solved using the satisfiability modulo theory (SMT)-solver iSAT3, which is able to deal with transcendental functions such as $\mathtt{exp}$ and $\mathtt{cos}$ that frequently appear in neural network controllers and plants. Although the verification framework is rigorously developed, the verification problem is hardly solved due to the curse of dimensionality and state-space explosion probems. \begin{figure} \begin{center} \includegraphics[width=9cm]{ReLU.eps} \caption{A visualization of the operations on polytopes using ReLU functions in \cite{xiang2017reachable_arxiv}.} \label{fig:ReLU} \end{center} \end{figure} The use of binary variables to encode piecewise linear functions is standard in optimization \cite{Robert2001linear}. In \cite{Lomuscio2017an_arxiv}, the constraints of ReLU functions are encoded as a Mixed-Integer Linear Programming (MILP). Combining output specifications that are expressed in terms of Linear Programming (LP), the verification problem for output set eventually turns to the feasibility problem of MILP. For layer $i$, the MILP encoding is given as \begin{align} \mathcal{C}_i = \{&x_{j}^{[i]}\ge W_j^{[i]}x^{[i-1]}+\theta_j^{i}, \nonumber \\ &x_{j}^{[i]}\le W_j^{[i]}x^{[i-1]}+\theta_j^{i} +M\delta_j^{[i]}, \nonumber \\ &x_j^{[i]} \ge 0, \nonumber \\ &x_j^{[i]} \le M(1-\delta_j^{[i]} \mid j =1\ldots\left|L^{[i]}\right|) \} \end{align} where $M$ is sufficiently large so that it is larger than the maximum possible output at any node. Similarly, a MILP problem is formulated in \cite{tjeng2017verifying}, where the authors conduct a robustness analysis and search for adversarial examples in ReLU neural networks. It is well known that MILP is an NP-hard problem and in \cite{dutta2017output,dutta2018output}, the authors elucidate significant efforts for solving MILP problems efficiently to make the approach scalable. Their methods combine MILP solvers with a local search yielding a more efficient solver for range estimation problems of ReLU neural networks than several other approaches. Basically, a local search is conducted using a gradient search and then a global search is formulated as MILP, as shown in Figure \ref{fig:MILP_improve}. Instead of finding the global optimum directly, it performs the search seeking values greater/smaller than the upper/lower bound obtained in the preceding local search. This is the primary reason for the computational complexity reduction. \begin{figure} \begin{center} \includegraphics[width=9cm]{MILP_improve.eps} \caption{Illustration of a combined local and global search for the MILP in \cite{dutta2017output}. $L_1,\ldots,L_6$ are local searches and $G_1,G_2$ are global searches.} \label{fig:MILP_improve} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=7cm]{PL.eps} \caption{ Figure 1 in \cite{ehlers2017formal}, which illustrates piecewise linear approximation of ReLU functions.} \label{fig:PL} \end{center} \end{figure} Recently, a verification engine for ReLU neural networks called $\mathrm{AI}^2$ was proposed in \cite{GehrAI}. In their approach, the authors abstract perturbed inputs and safety specifications as zonotopes, and reason about their behavior using operations for zonotopes. The framework $\mathrm{AI}^2$ is capable of handling neural networks of realistic size, and, in particular, their approach has had success dealing with convolutional neural networks. In another work, a software tool, called Sherlock, was developed based on the MILP verification approaches \cite{ehlers2017formal}. This LP-based framework combines satisfiability (SAT) solving and linear over-approximation of piecewise linear functions in order to verify ReLU neural networks against convex specifications. An illustration of a piecewise linear approximation for ReLU functions is shown in Figure \ref{fig:PL}. Given the output of a ReLU denoted by $d$ and the input $c \in [l, u]$, the relationship between $c$ and $d$ can be approximated by the linear constraints $d \ge 0$, $d \ge c$, and $d \ge u \frac{c-l}{u-l}$. Based on the LP problem formulation, additional heuristic algorithms were developed to detect infeasibility and imply phase inference faster. A tool, named \textit{Planet}, has been developed based on the results in \cite{ehlers2017formal}. In \cite{katz2017reluplex}, an algorithm, that stems from the Simplex Algorithm for linear functions, for ReLU functions is proposed. Due to the piecewise linear feature of ReLU functions, each node is divided into two nodes. Thus, in their formulation, each node consists of a forward-facing and backward-facing node. If the ReLU semantics are not satisfied, two additional update functions are given to fix the mismatching pairs. Thus, the search process is similar to the Simplex Algorithm that pivots and updates the basic and non-basic variables with the addition of a fixing process for ReLU activation pairs. In their paper, the authors detail an application of their methodology on a deep neural network implementation of a next-generation Airborne Collision Avoidance System for unmanned aircrafts (ACAS-X). A comparison of the verification approaches mentioned above can be found in \cite{bunel2017piecewise}. Additionally, in the paper, the authors present a novel approach for neural network verification called Branch and Bound Optimization. This approach adds one more layer behind the output layer $cy-b$ to represent the linear property $cy>b$ that we wish to verify. If $cy-b>0$, it means that the property is satisfied, otherwise it is unsatisfiable. Thus, the verification problem is converted into a computation of the minimum or maximum value of the output of the neural network. By treating the neural network as a nonlinear function, model-free optimization methods are utilized to find optimal solution. In order to have a global optimum, the input space is also discretized into sub-regions. This approach is not only applicable to ReLU neural networks, but the model-free method allows the approach to be applied to neural networks with more general activation functions. However, despite its generalization capabilities, in the model-free framework, there is no guarantee that the algorithm will converge to a solution. In \cite{narodytska2017verifying}, a MILP encoding scheme is used for a class of neural networks whose input spaces are encoded as binaries. This MILP encoding has a similar flavor to the other encodings present in the research literature for non-binarized networks. In their framework, since all the inputs are integer values, the real valued variables can be rounded so that they can be safely removed, resulting in a reformulated integer linear programming (ILP) problem that is smaller in comparison to the original MILP encoding. With the ILP encoding, a SAT solver is utilized in order to reason about the behavior of a mid-size binarized neural network. In another work presented by Osbert Bastani et al. \cite{bastani2016measuring}, the pointwise robustness of a neural network is analyzed using two robustness statistics based on a formulation of robustness as an LP problem. Besides the optimization approach proposed in \cite{bunel2017piecewise}, there are few other results for neural networks with general activation functions. In \cite{pulina2010abstraction,pulina2012challenging}, a piecewise-linearization of the nonlinear activation functions is used to reason about their behavior. In this framework, the authors replace the activation functions with piecewise constant approximations and use the bounded model checker hybrid satisfiability (HySAT) \cite{Franzle2007} to analyze various properties. In their paper, the authors highlight the difficulty of scaling this technique and, currently, are only able to tackle small networks with at most 20 hidden nodes. In \cite{xiang2017output}, a simulation-based approach was developed, which used a finite number of simulations/computations to estimate the reachable set of multi-layer neural networks in a general form. Despite this success, the approach lacks the ability to resolve the reachable set computation problem for neural networks that are large-scale, non-convex, and nonlinear. Still, simulation-based approaches, like the one developed in \cite{xiang2017output}, present a plausibly practical and efficient way of reasoning about neural network behavior. The critical step in improving simulation-based approaches is bridging the gap between finitely many simulations and the essentially infinite number of inputs that exist in the continuity set. A critical concept that is introduced in the work is called maximal sensitivity. Maximal sensitivity, defined formally below, is a measure of the maximal deviation of outputs for a set of inputs suffering disturbances in a bounded cell. \begin{definition} \label{def} Given a neural network $y = f (x)$, an input $x$ and disturbances $\left\|\Delta x \right\|\le\delta$, the maximum sensitivity of the neural network with input error $\delta$ at $x$ is defined by $ \epsilon(x,\delta)\triangleq\inf\{\epsilon:~\left\|\Delta y \right\|\le\epsilon, \mathrm{where}~y = f (x) ~\mathrm{and}~\left\|\Delta x \right\|\le\delta\} $. \end{definition} The output set of the neural network can be over-approximated by the union of a finite number of reachtubes computed using a union of individual cells that cover the input set. Thus, verification of a network can be done by checking the existence of intersections of the estimated reachable set and safety regions. This approach has been extended to allow for the reachable set estimation and verification of Nonlinear Autoregressive-Moving Average (NARMA) models in the form of neural networks \cite{xiang2018reachable}. In particular, it is applicable to a variety of neural networks regardless of the specific form of the activation functions. Given a neural network, there is a trade-off between the precision of the reachable set estimation and the number of simulations used to execute the procedure. In addition, since the approach executes in a layer-by-layer manner, the approximation error will accumulate as the number of layers present in the network increases. In this case, more simulations are required at the expense of increasing the computational cost. A similar approach for finding adversarial inputs using SMT solvers that relies on a layer-by-layer analysis is presented in \cite{huang2017safety}. The work focuses on the robustness of a neural network where safety is defined in terms of classification invariance within a small neighborhood of one individual input. An exhaustive search of the region is conducted by employing discretization and propagating the analysis layer by layer. In a similar manner, a recent paper, proposed by Wenjie Ruan et al. \cite{ruan2018global}, generalizes the local robustness criterion into a global notion of a set of test examples. In an effort to improve the overall robustness and generalization of neural networks, an empirical study on sensitivity and generalization in neural networks was performed in \cite{novak2018sensitivity}. The experiments, described in this work, survey thousands of models with various fully-connected architectures, optimizers, and other hyper-parameters, as well as four different image classification datasets. The observations contained in this work demonstrate that trained neural networks are more tolerant of input perturbations in the vicinity of the training data manifold. The factors associated with poor generalization, such as full-batch training or using random labels, correspond to lower robustness, while factors associated with good generalization, such as data augmentation and ReLU nonlinearities, give rise to more robust functions. Another fascinating area in neural network verification is falsification. The main objective of neural network falsification is to find adversarial examples capable of being misclassified that are created by a minimal input perturbation. In this arena, numerous approaches have been proposed with varying levels of efficacy and by conducting these studies the authors seek to improve the overall robustness of trained neural networks. With the above goals in mind, in \cite{huang2017safety}, Xiaowei Huang et al. proposed a framework for verifying the safety of network image classification decisions by searching for adversarial examples within a specified region. Their methods are implemented in a software tool called DLV (Deep Learning Verification). The authors cite that if a misclassification exists within a region, it will be found. The essence of their approach stems from the idea of point-wise robustness and, in order for a network to be considered safe, it should be stable in the presence of slight input perturbations. Thus, their method relies on propagating search regions and manipulations throughout the network, layer by layer. In a similar work by Chih-Hong Chen et al. \cite{cheng2017maximum}, the authors study the problem of ensuring that network based classifiers are resilient towards noisy or maliciously manipulated sensory input. Thus, they define resilience as the maximum amount of input perturbation that can be tolerated by the network and encode their problem using MILP. Their work is distinguishable since their methods provide measures that are a property of the network rather than related to a single input image. Thus, they allow others to quantitatively and formally gauge the resilience of a network. \par Motivated by the wealth of adversarial example generation approaches for neural network image classifiers, such as in \cite{novak2018sensitivity,weng2018towards,2018arXiv180406760E, DongDiscovering2017, hein2017formal}, Tommasso Derossi argued that majority of current techniques neglect the semantics and context of the overall systems in which the neural network is deployed. Moreover, the author argues that neglecting these aspects is ill-advised since context plays a crucial role in safety assurance and verification. Thus, in their paper \cite{dreossi2018semantic}, the authors present several ideas for integrating semantics into adversarial learning, including a semantic modification space and the use of more detailed information about the outputs produced by machine learning models. In another interesting work \cite{wicker2018feature}, Matthew Wicker et al. propose a feature-guided approach for testing image classifiers that does not require architectural knowledge of the network at hand. Their scheme is based on object detection techniques and they formulate the creation of adversarial examples as a two player stochastic game using Monte Carlo tree searching to explore the game state space in order to search for adversarial examples. The evaluation of their techniques is promising and the authors demonstrate that they can provide conditions in which no adversarial example exists. In a similar work by Tsui Weng et al. \cite{2018arXiv180110578W}, they present an attack independent robustness metric against adversarial examples for neural networks. Their approach converts the robustness analysis into a local Lipschitz constant estimation problem and uses Extreme Value Theory for efficient solving. \subsection{Testing for Adversarial Machine Learning Examples} Equally important are the numerous proposed defenses against adversarial manipulation and testing suites for neural network based classifiers. In \cite{kolter2017provable}, the authors present a method for training deep ReLU based classifiers that are provably robust against norm-bounded adversarial examples. The authors cite that their methods are able to detect all adversarial examples from a specified input set. However, their methods are overly conservative and may mistakenly flag inputs that are not adversarial. In another work, Aditi Raghunathan et al. \cite{raghunathan2018certified} propose defenses based on regularization for networks with a single hidden layer. Their approach is based on a semidefinite relaxation that outputs a differentiable certificate that no adversarial examples exist. The certificate is defined by computing the worst-case loss for a one layer hidden network. In \cite{SinhaCertifying2017}, the authors present a framework for defending against adversarial examples by using a distributionally robust optimization that guarantees performance through the use of a Lagrangian penalty formulation of the underlying training data distribution. They also provide a training method that augments parameters with worst-case distortions of the training data. The authors argue that their methods achieve satisfactory levels of robustness with little associated computational and statistical cost. Complementary to these techniques are the testing suites proposed to assess neural network safety. In \cite{sun2018testing}, the authors propose a set of four test coverage criteria for deep learning systems inspired by the modified condition/decision coverage criterion developed by NASA for avionics software. Their methods are implemented in a software tool called DeepCover.While their methods do not formally guarantee correct functionality, they give users confidence that the networks are reasonably free from defect. In a similar work by Lei Ma et al. \cite{LeiMaDeepGauge2018}, the authors present DeepGuage, a tool implementing multi-granularity testing criteria for deep learning systems. The aim of their tool is the construction of high quality test data that will provide guarantees about the performance, robustness, and generality of deep learning systems. Similarly, in \cite{tian2017deeptest}, an automatic test case generator is presented that leverages real-world changes in driving conditions like rain, fog, lighting conditions, etc. The tool, called \textit{DeepTest}\endnote{https://deeplearningtest.github.io/deepTest/}, systematically explores different parts of the deep neural network logic by generating test inputs that maximize the number of activated neurons. An improved version of the tool, called DeepXplore, is proposed in \cite{pei2017deepxplore}, which is the first efficient whitebox testing framework for large-scale deep learning systems. \subsection{Other Approaches} In \cite{dreossi2017compositional}, a compositional falsification framework where a temporal logic falsifier and a machine learning analyzer cooperate with the aim of finding falsifying executions of CPS models that involve machine learning components is presented. In \cite{Lomuscio2017an_arxiv}, Alessio Lomuscio and Lalit Maganti present a linear programming based method for reachability analysis in feed-forward neural networks with ReLU activation functions. Specifically, they address whether an arbitrary output can be gained for a fixed set of inputs by encoding the neural network into a linear constraint system. The authors then tailor the objective function to ensure safe tolerances in the floating point arithmetic associated with linear programming. Once the encoding of the network has been completed, the authors combine a set of specifications with the linear system and use Gurobi to achieve a solution. With the solutions returned by Gurobi, users can gauge the correctness of the network analyzed. The authors include an experimental analysis of several networks for various problems in control theory and demonstrate that their method solves reachability problems for networks with sizes on the order of 5000 neurons. In this paper \cite{scheibler2015towards}, the authors study the safety verification of a typical control problem, called the Cart Pole System, using bounded model checking. The authors use to the SMT solver, iSAT3, to check satisfiability of the created formulas. Their experimental results demonstrate that even the smallest bounded model checking instances could hardly be solved due to the non-linearity and non-invertibility of neural networks. However, in this work, the authors do not solve the safety verification problem. In this paper \cite{10.1007/978-3-540-30138-7_3}, Zeshan Kurd et al. define a constrained type of artificial neural network (ANN) that enables analytical certification arguments while still possessing profitable performance attributes. The proposed model is based upon a fuzzy system called the Fuzzy Self-Organising Map (FSOM). This model is a type of hybrid ANN with behavior that can be qualitatively and quantitatively described. Thus, one can reason about the safety of such a network by analyzing its adherence to safety requirements expressed as safety constraints. In their paper, the authors argue that this framework allows for the construction of arguments that highlight potential failure modes in the FSOM and, therefore, it can be considered a Safety Critical Artificial Neural network. Additionally, the authors demonstrate that the FSOM can be used for nonlinear function approximation with enhanced generalization. While most methods related to ANN verification interpret ANN as black boxes, this framework allows for white box analysis. In their paper \cite{PulinaNever}, Luca Pulina and Armando Tacchella present an abstraction-refinement and satisfiability modulo theory based tool for verifying feed-forward neural networks. Their scheme is based on encoding the network into a boolean satisfaction problem over linear arithmetic constraints. The inputs to the tool are a training set, several parameters concerning the structure of the network, a set of safety thresholds, an abstraction parameter, and a refinement rate. Using these inputs, the tool seeks to verify the safety thresholds. If it generates a counterexample, it passes the example to the original network in order to identify spurious counterexamples. Otherwise, the tool either returns that the network is safe or a counterexample and seeks to improve the network in an automated fashion. The authors evaluated their tool on various case studies in order to demonstrate the success and scalability of the approach. The paper, \cite{dvijotham2018dual}, presents a novel approach for neural network verification based on optimization and duality. The verification problem is posed as an optimization problem that tries to find the largest violation of a property related to the output of the network. If the largest violation is smaller than zero, then the property is verified. To do this, the authors use ideas from duality in optimization to obtain bounds on the optimal value of the verification problem. The authors cite that their method is sound but unfortunately in some cases cannot prove that a property is true. Their approach works on feedforward neural networks of any architecture and with arbitrary activation functions. Furthermore, it has been demonstrated that it performs just as well as the other verification methods that are currently available for networks with piecewise linear activation functions. Their approach is anytime in that it can be stopped at any point with a valid bound on the verification objective. The following paper, \cite{SunConcolic2018}, explores concolic testing for deep neural networks. Concolic Testing explores the execution paths of a software program to increase code coverage by alternating between concrete program execution and symbolic analysis. In this paper, the authors use quantified linear arithmetic over rationals (QLAR) to express test requirements aimed at finding adversarial examples. QLAR expresses a set of safety-related properties including Lipchitz continuity and several other coverage properties. The method proposed by the authors alternates between evaluating a DNN's activation patterns and symbolically generating new inputs. Their experimental results demonstrate that their methodology is superior to DeepXplore. Their method is implemented in a software tool. The following paper \cite{XieFuzzing2018} presents an automated testing framework called DeepHunter for identifying potential defects in deep neural networks using coverage-guided fuzz (CGF) testing. In this framework, the authors systematically create mutations of inputs in order to generate a set of tests that will test a neural network's behavior in corner case scenarios. The creation of input mutations is guided by a fuzzing strategy and one of the key components of CGF is feedback guidance. Thus, CGF is a feedback-guided framework that consistently updates the fuzzing strategy in order to promote efficiency and maximize test coverage. Additionally, the authors cite that their approach is scalable to real world neural networks since their approach organizes tests in batches and prioritizes tests that are given by the feedback signal. The authors evaluate their approach on seven neural networks with varying complexities and demonstrate that their approach can successfully detect erroneous behavior and potential defects in deep neural networks. Recently, numerous frameworks for deep neural network verification have made use of SMT solvers. However, the majority of these approaches are limited by the high computational cost caused by using these solvers. In this paper \cite{WangFormal2018}, the authors present a method for formally checking security properties of neural networks by leveraging interval arithmetic to compute rigorous bounds on the DNN's outputs. Their approach is easily parallelizable and makes use of symbolic interval analysis in order to minimize overestimations. The authors implement their approach as part of ReluVal, a system for checking the security properties of Relu-based DNNs. Their approach has been demonstrated to be able to outperform Reluplex by 200 times. Given an input range X and security property P, ReluVal propagates it layer by layer and applies a variety of optimizations to calculate the output range. In this paper \cite{DBLP:journals/corr/abs-1710-03107}, Chih-Hong Cheng et al. present a study of the verification of Binarizied neural networks (BNNs). This class of network has been demonstrated to be more power efficient in embedded system devices due to the fact that their weights, inputs, intermediate signals, outputs, and activation constraints are binary valued. Thus, the forward propagation of input signals is reduced to bit arithmetic. The authors argue that the verification of BNNs can be reduced to hardware verification and represents a more scalable problem than traditional neural network verification. The authors build on well known methods from hardware verification and transform the BNN and its specification into a combinational miter, which is an encoded equivalence check of two boolean circuits. This is then transformed into a SAT problem which can be solved using a variety of available software tools. The authors were not able to verify a network with a thousand nodes and cite that their future work will focus on verifying networks currently present in embedded devices. The following paper, \cite{hull2002verification}, presents a method for obtaining formal guarantees on the robustness of a classifier by giving instance-specific lower bounds on the norm of the input manipulation required to change the classifier decision. Their techniques can be applied to two widely used families of classifiers: kernel methods and neural networks. Furthermore, they propose the Cross-Lipschitz regularization functional that improves upon both the formal guarantees of the resulting classifier while achieving similar prediction performances as other forms of regularization. The authors also provide algorithms based on the first order approximation of the classifier with generated adversarial examples satisfying box constraints. The following paper, \cite{JI20177158}, presents the problem of estimation of reachable sets for Markov jump bidirectional associative memory (BAM) neural networks. The neural networks have inputs that are either unit-energy or unit-peak bounded disturbances and have time-varying delay and transition rates. The technique of partitioning the delays is used in response to the significant conservatism of the solution. They also focus on Markov jump BAM neural networks that are uncertain and have transition probabilities that are unknown. Further work could include estimation of the reachable set for Markov jump systems that are uncertain. The following paper, \cite{ZakrzewskiRandomized2004}, presents a randomized approach for rigorously verifying neural networks in safety critical applications. In an effort to mitigate challenges related to the curse of dimensionality, the authors make use of Monte Carlo methods to estimate the probability of neural network failure. However, although Monte Carlo methods are more efficient than methods that deterministically search through hyper-rectangular input spaces, they are probabilistic in nature. The objective of their approach is to verify that the input and output error of a network is small and remains within a specified bound. By drawing from sufficiently many points from an n-dimensional rectangle, the probability of the error becoming large may be made arbitrarily small. The authors further demonstrate that although the number of samples needed to guarantee this may be large, it is not as prohibitive as other methods. \defN{N} \defL{L} \def$I_N${$I_N$} \def$O_N${$O_N$} \noindent Breakdown of the neural network verification software tools currently available in the research literature. Table \ref{NNVerificationTable}, Table \ref{NNAdversarial}, and Table \ref{NNCoverTable} summarize the available tools for neural network verification, adversarial input robustness verification, and neural network testing respectively. They list key characteristics about each tool, reference the papers in which the methods can be found, and also provide the URL where each tool can be found. In each table, the letters \textit{I,O,L} and \textit{N} denote the number of inputs, outputs, layers, and neurons respectively. The analysis time listed is the worst case execution time of the verified examples in each paper. \begin{center} \begin{longtable}{ p{0.20\textwidth} | p{0.10\textwidth} | p{0.15\textwidth} | p{0.17\textwidth} | p{0.20\textwidth} | p{0.10\textwidth} } \caption{Neural Network Verification Tools \label{NNVerificationTable}}\\ Tool Name & Network Type & Verification Approach & Network Size (I,O,L,N) & Experimental Setup & Analysis Time (s)\\[0.5cm] \hline Reluplex\endnote{https://github.com/guykatzz/ReluplexCav2017} \cite{katz2017reluplex} & FNN & SMT & (5,5,8,2400) & \scriptsize{Ubuntu 16.04} & 394517 \\ Sherlock\endnote{https://github.com/souradeep-111/sherlock} \cite{dutta2017output} & FNN & MIP & (4,3,24,3822) & \scriptsize{Linux Server, Ubuntu 17.04,24 cores,64GB RAM} & 261540 \\ AnalyzeNN\endnote{https://github.com/dreossi/analyzeNN} \cite{dreossi2017compositional} & FNN, CNN & Signal Temporal Logic Falsification & (1,1,8,261)& \scriptsize{Dell XPS 8900 Intel(R) Core(TM) i7-6700 CPU 3.40 GHz 16 GB RAM, GPU NVIDIA GeForce GTX Titan X} & N/A \\ $\textrm{AI}^2$ \endnote{http://ai2.ethz.ch/} \cite{GehrAI} & FNN, CNN & Abstract Interpretation & (1,1,9,53000) & \scriptsize{Ubuntu 16.04.3 LTS, 2 Intel Xeon E5-2690 Processors, 512 GB RAM} & 75-3600 \\ PLNN\endnote{https://github.com/oval-group/PLNN-verification} \cite{bunel2017piecewise} & FNN, CNN & Branch and Bound & (5,5,6,300) & \scriptsize{single core, i7-5930K CPU, 32GB RAM, Timeout of 2 hrs, maximum memory 20 GB} & 5248.1 \\ Planet\endnote{https://github.com/progirep/planet} \cite{ehlers2017formal} & FNN, CNN & SAT,LP & (1,1,3,1341) & \scriptsize{Linux Intel Core i5-4200U 1.60 GHz CPU, 8 GB RAM, 1 hour timeout} &1955 \\ NeVer\endnote{http://www.mind-lab.it/never} \cite{PulinaNever} & FNN & SMT & (1,1,1,32) & \scriptsize{10 Linux workstations,Intel Core 2 Duo 2.13 GHz PCs with 4GB of RAM, Linux Debian 2.6.18.5} & 344.59 \\ \hline \end{longtable} \end{center} \begin{center} \begin{longtable}{ p{0.20\textwidth} | p{0.10\textwidth} | p{0.15\textwidth} | p{0.17\textwidth} | p{0.20\textwidth} | p{0.10\textwidth} } \caption{Verification Tools Concerned with Adversarial Input Robustness \label{NNAdversarial}}\\ Tool Name & Network Type & Verification Approach & Network Size (I,O,L,N) & Experimental Setup & Analysis Time (s)\\[0.1cm] \hline VeriDeep/DLV\endnote{https://github.com/VeriDeep/DLV}\cite{huang2017safety} & FNN, CNN & SMT & \small{(1,1,16, 138,357,544)} parameters &\scriptsize{MacBook Pro laptop, 2.7 GHz Intel Core i5 CPU, 8 GB RAM} & 60-120 per input \\ DeepGo\endnote{https://github.com/TrustAI/DeepGO} \cite{RuanDeepGO2018} & FNN, CNN & \small{Global Nested Optimization} & (1,1,7,412) & \scriptsize{Notebook computer Matlab 2018a i7-7700HQ CPU and 16GB RAM } & 5 \\ $L_0$-TRE\endnote{https://github.com/L0-TRE/L0-TRE} \cite{ruan2018global} & FNN, CNN & $L_0$-Norm robustness evaluation & \small{(1,1,101, 44,654,504 parameters)} & \scriptsize {Ubuntu 14.04.3 LTS NVIDIA GeForce GTX TITAN Black Intel(R) Core(TM) i5-4690s 3.20 GHz x 4} & \footnotesize{anytime algorithm} \\ SafeCV\endnote{https://github.com/matthewwicker/SafeCV} \cite{wicker2018feature} & CNN & \small{Adversarial Black-Box Falsification} & \small{(1,1,12,250,858 parameters)} & \small{N/A} & 20 \\ Certified ReLU Robustness\endnote{https://github.com/huanzhang12/CertifiedReLURobustness} \cite{weng2018towards} & FNN, CNN & MIP & \small{(1,1,7, 10,000)} & \scriptsize{a Intel Xeon E5-2683v3 (2.0 GHz) CPU} & 858 \\ NNAF\endnote{https://github.com/Microsoft/NeuralNetworkAnalysis} \cite{bastani2016measuring} & FNN, CNN & LP & \small{(1,1,7,60000 parameters)} & \small{8 core CPU} & $1.5$ per input \\ Convex Adversarial\endnote{https://github.com/locuslab/convex\_adversarial}\cite{kolter2017provable} & FNN, CNN & \small{Convex Outer Approximation} & (2,2,6,404) & \scriptsize{NVIDIA Titan X GPU} & 18000 \\ \hline \end{longtable} \end{center} \begin{center} \begin{longtable}{ p{0.20\textwidth} | p{0.10\textwidth} | p{0.15\textwidth} | p{0.17\textwidth} | p{0.18\textwidth} | p{0.10\textwidth} } \caption{Neural Network Testing Tools \label{NNCoverTable}}\\ Tool Name & Network Type & Verification Approach & Network Size (I,O,L,N) & Experimental Setup & Analysis Time (s)\\ \hline DeepCover\endnote{https://github.com/deep-cover/deep-cover} \cite{sun2018testing} & FNN, CNN & White-box LP inspired test criteria & (1,1,4,14208) & \scriptsize{Macbook 2.5 GHz Intel Core i5 8 GB RAM} & \footnotesize{0.94/LP call}\\[0.8 cm] DeepXplore\endnote{https://github.com/peikexin9/deepxplore} \cite{pei2017deepxplore} & FNN, CNN & Test input generation & (1,1,50,94059) & \scriptsize{Linux Ubuntu 16.04, Intel i7-6700HQ 2.60GHz, 4 cores, 16GB RAM NVIDIA GTX 1070 GPU} &\small{196.4 for 100\% coverage} \\[0.5cm] DeepConcolic\endnote{https://github.com/TrustAI/DeepConcolic} \cite{SunConcolic2018} & FNN, CNN & \small{Quantified Linear Arithmetic concolic testing} & (1,1,10,538) & \scriptsize{Intel(R) Core (TM) i5-4690S CPU @ 3.20 GHz x 4} & N/A \\ \hline \end{longtable} \end{center}
{'timestamp': '2018-10-05T02:04:08', 'yymm': '1810', 'arxiv_id': '1810.01989', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01989'}
arxiv
\subsubsection*{\bibname}} \usepackage{amsfonts} \usepackage{fancyhdr} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \usepackage{comment} \usepackage{amsmath} \usepackage{changepage} \usepackage{graphicx,amsmath,amssymb,fullpage, amsfonts,bbm,bbold} \usepackage{amssymb} \usepackage{graphicx}% \usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{positioning} \usepackage{booktabs} \newdimen\nodeDist \nodeDist=25mm \usepackage{array} \usepackage[flushleft]{threeparttable} \DeclareMathOperator{\iid}{\stackrel{\mbox{\tiny iid} }{\sim}} \newcommand{\mathbb{Q}}{\mathbb{Q}} \newcommand{\mathbb{R}}{\mathbb{R}} \newcommand{\mathbb{C}}{\mathbb{C}} \newcommand{\mathbb{Z}}{\mathbb{Z}} \newcommand{\text{Var}}{\text{Var}} \newcommand{\mathbb{E}}{\mathbb{E}} \newcommand{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}}{\mathrel{\text{\scalebox{1.07}{$\perp\mkern-10mu\perp$}}}} \newcommand{\mathrm{x}}{\mathrm{x}} \newcommand{\mathrm{w}}{\mathrm{w}} \newcommand{\mathrm{y}}{\mathrm{y}} \newcommand{\mathrm{r}}{\mathrm{r}} \newcommand{\mbox{{\small\textsc{N}}}}{\mbox{{\small\textsc{N}}}} \newcommand{\mathbf{X}}{\mathbf{X}} \newdimen\nodeDist \nodeDist=25mm \bibliographystyle{apalike} \begin{document} \twocolumn[ \aistatstitle{XBART: Accelerated Bayesian Additive Regression Trees} \aistatsauthor{ Jingyu He \And Saar Yalov \And P. Richard Hahn} \aistatsaddress{ University of Chicago \And Arizona State University \And Arizona State University } ] \begin{abstract} Bayesian additive regression trees (BART) \citep{chipman2010bart} is a powerful predictive model that often outperforms alternative models at out-of-sample prediction. BART is especially well-suited to settings with unstructured predictor variables and substantial sources of unmeasured variation as is typical in the social, behavioral and health sciences. This paper develops a modified version of BART that is amenable to fast posterior estimation. We present a stochastic hill climbing algorithm that matches the remarkable predictive accuracy of previous BART implementations, but is many times faster and less memory intensive. Simulation studies show that the new method is comparable in computation time and more accurate at function estimation than both random forests and gradient boosting. \end{abstract} \section{INTRODUCTION} Tree-based regression methods --- CART \citep{breiman1984classification}, random forests \citep{breiman2001random}, and gradient boosting \citep{breiman1997arcing, friedman2001greedy,friedman2002stochastic} --- are highly successful and widely used for supervised learning. Bayesian additive regression trees --- or BART --- is a closely related but less well-known method that often achieves superior prediction/estimation accuracy. The ``Bayesian CART'' (single-tree) model was introduced in \cite{chipman1998bayesian} and the BART model first appeared in \cite{chipman2010bart}, although software was publicly available as early as 2006. Contrary to common perception, BART is not merely a version of random forests or boosted regression trees in which prior distributions have been placed over model parameters. Instead, the Bayesian perspective leads to a fundamentally new tree growing criterion and algorithm, which yields a number of practical advantages --- robustness to the choice of user-selected tuning parameters, more accurate predictions, and a natural Bayesian measure of uncertainty. Despite these virtues, BART's wider adoption has been slowed by its more severe computational demands relative to alternatives, owing to its reliance on a random walk Metropolis-Hastings Markov chain Monte Carlo (MCMC) approach. The current fastest implementation, the {\tt R} package {\tt dbarts}, takes orders of magnitude longer than the widely-used {\tt R} package {\tt xgboost}, for example. This paper develops a variant of BART that is amenable to fast posterior estimation, making it almost as fast as {\tt xgboost} (after cross-validating), while still retaining BART's hyperparameter robustness and remarkable predictive accuracy. First, we describe the BART model to motivate our computational innovations. We derive the BART model's tree-growing criterion, which is notably different than the traditional sum-of-squares criterion used by other methods. We then describe the new algorithm accelerated Bayesian additive regression trees heuristic (XBART) and illustrate its impact on fast, accurate statistical prediction. Specifically, we compare the new method's performance to random forests, boosted regression trees, neural networks as well as the standard MCMC implementations of BART. \vspace{-3mm} \section{BART IN DETAIL} \subsection{The Model: Likelihood and Prior} The BART model is an additive error mean regression model \begin{equation}\label{additive} y_i = f(\mathrm{x}_i) + \epsilon_i \end{equation} where the $\epsilon_i$ are assumed to be independent mean zero Gaussians and $f(\cdot)$ is an unknown function. The BART prior represents the unknown function $f(\mathrm{x})$ as a sum of many piecewise constant binary regression trees: \begin{equation}\label{forest} f(\mathrm{x})=\sum_{l=1}^L g_l(\mathrm{x}, T_l, \mu_l) \end{equation} where $T_l$ denotes a regression tree and $\mu_l$ denotes a vector of scalar means associated to the leafs nodes of $T_l$. Each tree $T_l,\;1\leq l\leq L$, consists of a set of internal decision nodes which define a partition of the covariate space (say $\mathcal{A}_1,\dots,\mathcal{A}_{B(l)}$), as well as a set of terminal nodes or leaves corresponding to each element of the partition. Further, each element of the partition $\mathcal{A}_b$ is associated a parameter value, $\mu_{lb}$. Taken together the partition and the leaf parameters define a piecewise constant function: $g_l(x) = \mu_{lb}\ \text{if}\ x\in \mathcal{A}_b$; see Figure \ref{fig:treestep}. \begin{figure}[h] \begin{center} \begin{tikzpicture}[ scale=0.7, node/.style={% draw, rectangle, }, node2/.style={% draw, circle, }, ] \node [node] (A) {$x_1<0.8$}; \path (A) ++(-135:\nodeDist) node [node2] (B) {$\mu_{l1}$}; \path (A) ++(-45:\nodeDist) node [node] (C) {$x_2<0.4$}; \path (C) ++(-135:\nodeDist) node [node2] (D) {$\mu_{l2}$}; \path (C) ++(-45:\nodeDist) node [node2] (E) {$\mu_{l3}$}; \draw (A) -- (B) node [left,pos=0.25] {no}(A); \draw (A) -- (C) node [right,pos=0.25] {yes}(A); \draw (C) -- (D) node [left,pos=0.25] {no}(A); \draw (C) -- (E) node [right,pos=0.25] {yes}(A); \end{tikzpicture} \hspace{0.1\linewidth} \vspace{0.1in} \begin{tikzpicture}[scale=2.5] \draw [thick, -] (0,1) -- (0,0) -- (1,0) -- (1,1)--(0,1); \draw [thin, -] (0.8, 1) -- (0.8, 0); \draw [thin, -] (0.0, 0.4) -- (0.8, 0.4); \node at (-0.1,0.4) {0.4}; \node at (0.8,-0.1) {0.8}; \node at (0.5,-0.2) {$x_1$}; \node at (-0.3,0.5) {$x_2$}; \node at (0.9,0.5) {$\mu_{l1}$}; \node at (0.4,0.7) {$\mu_{l2}$}; \node at (0.4,0.2) {$\mu_{l3}$}; \end{tikzpicture} \end{center} \caption{(Top) An example binary tree, with internal nodes labelled by their splitting rules and terminal nodes labelled with the corresponding parameters $\mu_{lb}$. (Bottom) The corresponding partition of the sample space and the step function.} \label{fig:treestep} \end{figure} The tree prior $p(T_l)$ is specified by three components: (i) the probability of a node having children at depth $d$ \begin{equation*} \alpha (1+d)^{-\beta}, \qquad \alpha \in (0,1), \beta \in [0, \infty), \end{equation*} (ii) the uniform distribution over available predictors for splitting rule assignment at each interior node, and (iii) the uniform distribution on the discrete set of available splitting values for the assigned predictor at each interior node. This last choice has the appeal of invariance under monotone transformations of the predictors. \cite{chipman2010bart} recommend $\alpha=.95$ and $\beta=2$ to enforce small trees. Finally, the leaf mean parameters, $\mu_{lb}$ are assigned independent mean-zero normal priors: $\mu_{lb}\sim \mbox{{\small\textsc{N}}}(0,\tau)$. The parameter $\tau$ is a crucial regularization parameter; pointwise prior variance of $f$ is $\tau L$. \subsection{The BART Splitting criterion} By viewing the model as a data generating process, the Bayesian vantage point motivates modifications to the usual splitting criterion. Because the model stipulates that observations in the same leaf node share the same mean parameter, the prior predictive distribution --- obtained by integrating out the unknown group specific mean --- is simply a mean-zero multivariate normal distribution with covariance matrix \begin{equation*} \mathbf{V} = \tau \mathrm{J}\mathrm{J}^t + \sigma^2 \mathbf{I}, \end{equation*} where $\tau$ is the prior variance of the leaf-specific mean parameter, $\sigma^2$ is the variance of the additive error, and $\mathrm{J}$ is a column vector of all ones. Observe that the prior predictive density of $\mathrm{y} \sim \mbox{{\small\textsc{N}}}(0, \mathbf{V})$ is \begin{equation*} p(\mathrm{y} \mid \tau, \sigma^2) = (2\pi)^{-n/2}\det(\mathbf{V})^{-1/2} \exp{\left( -\frac{1}{2} \mathrm{y}^t \mathbf{V}^{-1} \mathrm{y} \right)}, \end{equation*} which can be simplified by a direct application of the matrix inversion lemma to $\mathbf{V}^{-1}$: \begin{equation*} \begin{aligned} \mathbf{V}^{-1}&= \sigma^{-2}\mathbf{I} - \frac{\tau}{\sigma^2(\sigma^2 + \tau n)} \mathrm{J}\mathrm{J}^t . \end{aligned} \end{equation*} Applying Sylvester's determinant theorem to $\det{\mathbf{V}^{-1}}$ and taking logarithms yields a marginal log-likelihood of \begin{equation*} \begin{aligned} -\frac{n}{2}& \log{(2\pi)}-n\log{(\sigma)} + \frac{1}{2} \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n} \right)} \\ &-\frac{1}{2} \frac{\mathrm{y}^t \mathrm{y}} {\sigma^{2}} + \frac{1}{2}\frac{\tau}{\sigma^2(\sigma^2 + \tau n)}s^2 , \end{aligned} \end{equation*} where we write $s \equiv \mathrm{y}^t\mathrm{J} = \sum_i y_i$ so that $\mathrm{y}^t \mathrm{J}\mathrm{J}^t \mathrm{y} = (\sum_i y_i)^2 = s^2$. This likelihood is applied separately to partitions of the data corresponding to the leaves of a single fixed regression tree. Because observations in different leaf nodes are independent (conditional on $\sigma^2$), the full marginal log-likelihood is given by \begin{equation*}\label{loglikelihood} \begin{aligned} &\sum_{b=1}^B \left \lbrace -\frac{n_b}{2} \log{(2\pi)} -n_b\log{(\sigma)} + \frac{1}{2} \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n_b} \right)} \right.\\ & \hspace{0.3in} - \left. \frac{1}{2}\frac{\mathrm{y}_b^t \mathrm{y}_b} {\sigma^{2}} + \frac{1}{2}\frac{\tau}{\sigma^2(\sigma^2 + \tau n_b)} s_b^2 \right \rbrace \\ & = -n \log{(2\pi)} - n \log{(\sigma)} - \frac{1}{2} \frac{\mathrm{y}^t \mathrm{y}} {\sigma^{2}} \\ & \hspace{0.3in} + \frac{1}{2} \sum_{b=1}^B \left \lbrace \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n_b} \right)} + \frac{\tau}{\sigma^2(\sigma^2 + \tau n_b)} s_b^2 \right \rbrace \end{aligned} \end{equation*} where $b$ runs over all the leaf nodes and $\sum_{b=1}^B n_b = n$. Notice that the first three terms are not functions of the partition (the tree parameter), so they are constant, leaving \begin{equation}\label{criterion} \frac{1}{2} \sum_{b=1}^B \left \lbrace \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n_b} \right)} + \frac{\tau}{\sigma^2(\sigma^2 + \tau n_b)} s_b^2 \right \rbrace \end{equation} as the model-based split criterion, where $(n_b, s_b, B)$ are functions of the data and the tree $T$. \subsection{The BART MCMC}\label{bart} The basic BART MCMC proceeds as a Metropolis-within-Gibbs algorithm, with the key update of the individual regression trees being conducted as a local random walk Metropolis-Hastings (MH) update, given all of the other trees as well as the residual variance parameter, $\sigma^2$. Let $\mathcal{T}$ denote the set of trees and $\mathcal{M}$ denote the set of leaf parameter vectors. Recall that $|\mathcal{T}| = |\mathcal{M}| = L$, and each $\mu_l \in \mathcal{M}$ is length $B(l)$. The sequence of Gibbs updates are \begin{enumerate} \item $T_l, \mu_l \mid \mathcal{T}_{-l}, \mathcal{M}_{-l}, \sigma^2, \mathrm{y}$, for $l = 1, \dots, L$, which is done compositionally (for each $l$) as \begin{enumerate} \item $T_l \mid \mathcal{T}_{-l}, \mathcal{M}_{-l}, \sigma^2, \mathrm{y}$, \item $\mu_l \mid \mathcal{T}, \mathcal{M}_{-l}, \sigma^2, \mathrm{y}$, \end{enumerate} \item $\sigma^2 \mid \mathcal{T}, \mathcal{M}, \mathrm{y}$. \end{enumerate} Taking advantage of the additive structure of the model, these updates can be written as \begin{enumerate} \item $T_l, \mu_l \mid \mathrm{r}_l, \sigma^2$, for $l = 1, \dots, L$, which is done compositionally (for each $l$) as \begin{enumerate} \item $T_l \mid \mathrm{r}_l, \sigma^2$, \item $\mu_l \mid T_l, \mathrm{r}_l, \sigma^2$, \end{enumerate} \item $\sigma^2 \mid \mathrm{r}$. \end{enumerate} for ``residuals'' defined as \begin{equation*} \mathrm{r}_l^{(k+1)} \equiv \mathrm{y} - \sum_{l' < l} g(\mathbf{X};T_{l'},\mu_{l'})^{(k+1)} - \sum_{l' > l} g(\mathbf{X};T_{l'},\mu_{l'})^{(k)}, \end{equation*} and \begin{equation*} \mathrm{r}^{(k)} \equiv \mathrm{y} - \sum_{l = 1}^L g(\mathbf{X};T_{l},\mu_{l})^{(k)}, \end{equation*} where $k$ indexes the Monte Carlo iteration. Update 1(a) is a Metropolis-Hastings update based on the integrated likelihood given in (\ref{criterion}). Update 1(b) is a conditionally conjugate Gaussian mean update done separately for each leaf node parameter $\mu_{lb}$, $b = 1\dots B(l)$. Update 2 is a conditionally conjugate inverse-Gamma update. Step 1(a) is handled with a random walk as follows. Given a current tree, $T$, modifications are proposed and either accepted or rejected according to a likelihood ratio based on (\ref{criterion}). \cite{chipman1998bayesian} describes proposals comprising a birth/death pair, in which a birth spawns to children from a given bottom node and a death kills a pair of sibling children; see \cite{pratola2016efficient} for alternative choices. For example, in a birth move, a variable to split on, as well as a cut-point to split at, are selected uniformly at random from the available splitting rules. Via these simple MH updates, BART stochastically searches through regression models of varying complexity (in terms of tree-depth). For ``smaller'' problems, with dozens of predictors and thousands of observations, this MCMC approach has proven to be remarkably effective; for larger problems, with hundreds of thousands of observations, it does not work well on standard desktops. In the next section, we present our new stochastic hill climbing algorithm called accelerated Bayesian additive regression trees (XBART), see algorithm \ref{alg:XBART}. It follows the Gibbs update framework but replace the Metropolis-Hastings updates of each single tree by a new grow-from-root backfitting strategy; see Algorithm \ref{alg:tree}. \section{XBART} \subsection{Grow-from-root backfitting} Rather than making small moves to a given tree $T_l^{(k)}$ at iteration $k+1$, here we ignore the current tree and grow an entirely new tree $T_l^{(k+1)}$ from scratch. We grow each tree recursively and stochastically and the tree growing process is also terminated stochastically, based on the ``residual'' data defined above. The pseudo-code is presented in Algorithm \ref{alg:tree}. Specifically, at each level of the recursion we consider every available cut-point (decision rule threshold) for each variable\footnote{For simplicity, in this paper we consider only continuous predictor variables.} and evaluate the integrated likelihood criterion, the exponential of expression (\ref{criterion}). We also consider the no-split option, which corresponds to a cut-point outside of the range of the available data. How many such {\em null} cut-points to consider is a modeling decision; we default to one such null cut-point per variable. Accordingly, with $C$ available active cut-points and $V$ total variables we perform $C\times V + 1$ likelihood evaluations. Each of the active cut-points is weighted by $\alpha (1+d)^{-\beta}$ and the unweighted cut-points weighted by $1 - \alpha (1+d)^{-\beta}$, as per the prior\footnote{Equivalently, the active cut-points are equally weighted and the no split option is weighted $V (\alpha^{-1}(1+d)^{\beta} - 1)$. An additional multiplier could be used here to encourage/discourage tree growth.}. Since data is pre-sorted, we index candidate cut-points by their rank, $c = 0, 1, \cdots, C\times V $ and $c = 0$ denotes a {\em null} cut-point, the ``do not split'' option. Selection of a variable to split on, and a cut-point to split at,are then chosen by Bayes rule: \begin{equation}\label{sample} \pi(v, c) = \frac{\exp{(\ell(c, v)}) \kappa(c)}{\sum_{v' = 1}^V \sum_{c'=0}^C \exp{(\ell(c',v'))} \kappa(c')} \end{equation} where \small \begin{equation*} \begin{aligned} \ell(v,c) &= \frac{1}{2} \left \lbrace \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n(\leq,v,c)} \right)} \right.\\ & \hspace{0.3in}+\left. \frac{\tau}{\sigma^2(\sigma^2 + \tau n(\leq,v,c))} s(\leq,v,c)^2 \right \rbrace\\ & + \frac{1}{2} \left \lbrace \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n(>,v,c)} \right)} \right.\\ & \hspace{0.3in} +\left. \frac{\tau}{\sigma^2(\sigma^2 + \tau n(>,v,c))} s(>,v,c)^2 \right \rbrace \end{aligned} \end{equation*} \normalsize for $c \neq 0$. Here $n(\leq,v,c)$ is the number of observations in the current leaf node that have $x_v \leq c$ and $s(\leq, v, c)$ is the sum of the residual $\mathrm{r}_l^{(k)}$ of those same observations; $n(>, v,c)$ and $s(>, v,c)$ are defined analogously. Also, $\kappa(c \neq 0) = 1$. For $c = 0$, corresponding to null cut-points or the stop-splitting option, we have instead \small \begin{equation*} \ell(v,c) = \frac{1}{2} \left \lbrace \log{ \left( \frac{\sigma^2}{\sigma^2 + \tau n} \right)} + \frac{\tau}{\sigma^2(\sigma^2 + \tau n)} s^2 \right \rbrace \end{equation*} \normalsize and $\kappa(0) = \frac{1 - \alpha (1+d)^{-\beta}}{\alpha (1+d)^{-\beta}}$, where $n$ denotes the number of observations in the current leaf node, $n = n(\leq,v,c) + n(>,v,c)$ and $s$ denotes the sum over all the current leaf data. Using this new tree-growing strategy, we find that different default parameters are advisable. We recommend $L = \frac{1}{4} (\log{n})^{\log \log n}$, $\alpha = 0.95$, $\beta = 1.25$ and $\tau = \frac{3}{10} \mbox{var}(\mathrm{y})/L$. This choice of $L$ is a function that is faster growing than $\log{n}$, but slower than $\sqrt{n}$, while the lower value of $\beta$ permits deeper trees (than BART's default $\beta = 2$). Allowing $L$ to grow as a function of the data permits smoother functions to be estimated more accurately as the sample size grows, whereas a sample size-independent choice would be limited in its smoothness by the number of trees. The suggested choice of $\tau$ dictates that {\em a priori} the function will account for 30\% of the observed variance of the response variable. Finally, while BART must be run for many thousands of iterations with a substantial burn-in period, our default suggestion is just 40 sweeps through the data, discarding the first 15 as burn-in. \begin{algorithm*}[h] \small \caption{Grow-from-root backfitting}\label{alg:tree} \begin{algorithmic} \Procedure{grow\_from\_root}{$\mathrm{y}$, $\mathbf{X}$, $C$, $m$, $\mathrm{w}$, $\sigma^2$}\Comment{Fit a tree using data $y$ and $\mathbf{X}$ by recursion.}\\ \textbf{output} A tree $T_l$ and a vector of split counts $\mathrm{w}_l$. \State $N\gets $ number of rows of $y, x$ \State Sample $m$ variables use weight $w$ as shown in section \ref{mtry}. \State Select $C$ cutpoints as shown in section \ref{cutpoints}. \State Evaluate $C\times m + 1$ candidate cutpoints and no-split option with equation (\ref{sample}). \State Sample one cutpoint propotional to equation (\ref{sample}). \If{sample no-split option} \State Sample leaf parameter from normal distribution $\mu\sim N\left(\sum y/\left[\sigma^2\left(\frac{1}{\tau} + \frac{N}{\sigma^2}\right)\right], 1/\left[\frac{1}{\tau} + \frac{N}{\sigma^2}\right]\right)$. \textbf{return} \Else \State $w_l[j] = w_l[j] + 1$, add count of selected split variable. \State Split data to left and right node. \State GROW\_FROM\_ROOT($y_{\text{left}}$,$\mathbf{X}_{\text{left}}$, $C$, $m$, $\mathrm{w}$, $\sigma^2$) \State GROW\_FROM\_ROOT($y_{\text{right}}$,$\mathbf{X}_{\text{right}}$, $C$, $m$, $\mathrm{w}$, $\sigma^2$) \EndIf \EndProcedure \end{algorithmic} \end{algorithm*} \subsection{Pre-sorting Features for Efficiency} Observe that the BART criterion depends on the partition sums only. An important implication of this, for computation, is that with sorted predictor variables the various cut-point integrated likelihoods can be computed rapidly via a single sweep through the data (per variable), taking cumulative sums. Let $\mathbf{O}$ denote the $V$-by-$n$ array such that $o_{vh}$ denotes the index, in the data, of the observation with the $h$th smallest value of the $v$th predictor variable $x_v$. Then, taking the cumulative sums gives \begin{equation} s(\leq,v,c) = \sum_{h \leq c} \mathrm{r}_{o_{vh}} \end{equation} and \begin{equation} s(>,v,c) = \sum_{h = 1}^n r_{lh}- s(\leq,v,c). \end{equation} The subscript $l$ on the residual indicates that these evaluations pertain to the update of the $l$th tree. The above formulation is useful if the data can be presorted and, furthermore, the sorting can be maintained at all levels of the recursive tree-growing process. To achieve this, we must ``sift'' each of the variables before passing to the next level of the recursion. Specifically, we form two new index matrices $\mathbf{O}^{\leq}$ and $\mathbf{O}^{>}$ that partition the data according to the selected split rule. For the selected split variable $v$ and selected split $c$, this is automatic: $O_v^{\leq} = O_{v,1:c}$ and $O_v^{>} = O_{v,(c+1):n}$. For the other $V-1$ variables, we sift them by looping through all $n$ available observations, populating $O^{ \leq}_{q}$ and $O^{>}_{q}$, for $q \neq v$, sequentially, with values $o_{qj}$ according to whether $x_{vo_{qj}} \leq c$ or $x_{vo_{qj}} > c$, for $j = 1, \dots, n$. Because the data is processed in sorted order, the ordering will be preserved in each of the new matrices $\mathbf{O}^{\leq}$ and $\mathbf{O}^{>}$. This strategy was first presented in \cite{mehta1996sliq} in the context of tree classification algorithms. \vspace{-3mm} \subsection{Recursively Defined Cut-points}\label{cutpoints} Evaluating the integrated likelihood criterion is straightforward, but the summation and normalization required to sample the cut-points contribute a substantial computational burden in its own right. Therefore, it is helpful to consider a restricted number of cut-points $C$. This can simply be achieved by taking every $j$th value (starting from the smallest) as an eligible split point with $j = \lfloor \frac{n_b-2}{C} \rfloor$. As the tree grows deeper, the amount of data that is skipped over diminishes. Eventually we get $n_b < C$, and each data point defines a unique cut-point. In this way the data could, without regularization, be fit perfectly, even though the number of cut-points at any given level is given an upper limit. As a default, we set the number of cut-points to $\max{(\sqrt{n},100)}$, where $n$ is the sample size of the entire data set. Our cut-point subsampling strategy is more naive than the cut-point subselection search heuristics used by {\tt XGBoost} \citep{chen2016xgboost} and {\tt LightGBM} \citep{ke2017lightgbm}, which both consider the gradient evaluated at each cut-point when determining the next split. Our approach does not consider the response information at all, but rather defines a predictor-dependent prior on the response surface. That is, given a design matrix $\mathbf{X}$, a sample functions can be drawn from the prior distribution by sampling trees, splitting uniformly at random among the cut-points defined by the node-specific quantiles, in a sequential fashion. In further contrast, the proposed method stochastically samples cut-points proportional to its objective function, rather than deterministically maximizing the likelihood-prior. Then, multiple sweeps are made through the data. Rather than greedy (approximate) optimization, like {\tt XGBoost} and {\tt LightGBM}, the proposed algorithm performs a stochastic hill climb by coordinate ascent over multiple sweeps through the parameters. \subsection{Sparse Proposal Distribution}\label{mtry} As a final modification, we strike an intermediate balance between the local BART updates, which randomly consider one variable at a time, and the all-variables Bayes rule described above. We do this by considering $m \leq V$ variables at a time when sampling each splitting rule. Rather than drawing these variables uniformly at random, as done in random forests, we introduce a parameter vector $\mathrm{w}$ which denotes the prior probability that a given variable is chosen to be split on, as suggested in \cite{linero2016bayesian}. Before sampling each splitting rule, we randomly select $m$ variables with probability proportional to $\mathrm{w}$. These $m$ variables are sampled sequentially and {\em without replacement}, with selection probability proportional to $\mathrm{w}$. The variable weight parameter $\mathrm{w}$ is given a Dirichlet prior with hyperparameter $\bar{\mathrm{w}}$ set to all ones and subsequently incremented to count the total number of splits across all trees. The split counts are then updated in between each tree sampling/growth step: \begin{equation} \bar{\mathrm{w}} \leftarrow \bar{\mathrm{w}} - \bar{\mathrm{w}}_l^{(k-1)} +\bar{\mathrm{w}}_l^{(k)} \end{equation} where $\bar{\mathrm{w}}_l^{(k)}$ denotes the length-$V$ vector recording the number of splits on each variable in tree $l$ at iteration $k$. The weight parameter is then resampled as $\mathrm{w} \sim \mbox{Dirichlet}(\bar{\mathrm{w}}).$ Splits that improve the likelihood function will be chosen more often than those that don't. The parameter $\mathrm{w}$ is then updated to reflect that, making chosen variables more likely to be considered in subsequent sweeps. In practice, we find it is helpful to use all $V$ variables during an initialization phase, to more rapidly obtain an accurate initial estimate of $\mathrm{w}$. \subsection{The Estimator} Given $K$ iterations of the algorithm, the final $K - I$ samples are used to compute a point-wise average function evaluation, where $I < K$ is denotes the length of the burn-in period. As mentioned above, we recommend $K = 40$ and $I = 15$ for routine use. The final estimator is therefore expressible as \begin{equation} \bar{f}(\mathbf{X}) = \frac{1}{K-I}\sum_{k > I}^K f^{(k)}(\mathbf{X}). \end{equation} where $f^{(k)}$ denotes a sample of the forest, as in expression \ref{forest}, drawn by algorithm \ref{alg:XBART}. We note that this corresponds to the Bayes optimal estimator under mean squared error estimation loss, provided that we have samples from a legitimate posterior distribution. As the grow-from-root strategy is not a proper full conditional, this estimator must be considered a greedy stochastic approximation (but see section \ref{mh}). Nonetheless, simulation results strongly suggest that the approximation is adequate. A few remarks on posterior uncertainty. First, with only $K = 40$ sweeps, the XBART posterior uncertainty is likely understated. However, the standard BART MCMC is probably not mixing well in most contexts, either, and yet still provides useful, if approximate, uncertainty quantification. Second, experiments with a version of XBART based on only the final sweep, $K - I = 1$, performed worse than methods with $K-I > 1$, suggesting that our posterior exploration, while imperfect, is still beneficial. \begin{algorithm*}[h] \small \caption{Accelerated Bayesian Additive Regression Trees (XBART)}\label{alg:XBART} \begin{algorithmic} \Procedure{XBART}{$\mathrm{y}, \mathbf{X},C,m, L, I, K, \alpha, \eta$} \Comment($\alpha, \eta$ are prior parameter of $\sigma^2$)\\ \textbf{output} Samples of forest \State $V\gets $ number of columns of $\mathbf{X}$ \State $N\gets $ number of rows of $\mathbf{X}$ \State Initialize $\mathrm{r}_l^{(0)} \leftarrow \mathrm{y} / L$. \For{$k$ in 1 to $K$} \For{$l$ in 1 to $L$} \State Calculate residual $\mathrm{r}_l^{(k)}$ as shown in section \ref{bart}. \If{$k < I $} \State GROW\_FROM\_ROOT($\mathrm{r}_l^{(k)}$,$\mathbf{X}$, $C$, $V$, $\mathrm{w}$, $\sigma^2$) \Comment{use all variables in burnin iterations} \Else \State GROW\_FROM\_ROOT($\mathrm{r}_l^{(k)}$,$\mathbf{X}$, $C$, $m$, $\mathrm{w}$, $\sigma^2$) \EndIf \State $\bar{\mathrm{w}} \gets \bar{\mathrm{w}} - \bar{\mathrm{w}}_l^{(k-1)}+ \bar{\mathrm{w}}_l^{k}$ \Comment{update $\bar{\mathrm{w}}$ with split counts of current tree} \State $\mathrm{w} \sim \mbox{Dirichlet}(\bar{\mathrm{w}})$ \State $\sigma^2 \sim \mbox{Inverse-Gamma}(N + \alpha, \mathrm{r}_l^{(k)t}\mathrm{r}_l^{(k)} + \eta)$ \EndFor \EndFor \textbf{return} \EndProcedure \end{algorithmic} \end{algorithm*} \subsection{Metropolis-Hastings Proposal Distribution}\label{mh} A fully Bayesian algorithm can be obtained by using the grow-from-root fitting algorithm as a data-driven Metropolis-Hastings proposal distribution. Importantly, the MH accept-reject step should be completed at the end of each {\em sweep}, that is, after proposing an entirely new set of trees and their associated parameters. Denote the current and proposed sets, repectively, by $F = \{\mathcal{T}, \mathcal{M}\}$ and $F' = \{\mathcal{T}', \mathcal{M}'\}$, where $\mathcal{T} = \{T_1, T_2, \dots, T_L\}$ and $\mathcal{M} = \{\mu_1, \mu_2, \dots, \mu_L\}$ denote the set of trees and leaf parameters, respectively. The grow-from-root algorithm generates a proposal of moving from $F$ to $F'$ with density $q(F', F)$ defined by a recursive product of terms as in 3.1. The probability of growing any particular tree is characterized by the probability of a certain sequence of split (or no-split) decisions encountered as one navigates down a given tree. The density of the leaf parameters, conditional on a given tree structure, follows from the corresponding conjugate normal update. See Algorithm \ref{alg:growprob}. To show that this MH procedure is valid, we need only show that any set of trees and parameters can be reached from any other set (positive recurrence) and that the proposal density is well-defined upon interchanging the sets of tree/parameter pairs; the construction of the usual Metropolis-Hastings ratio ensures detailed balance. Observe that one initializes the proposal process starting from a residual vector defined by $F$. To propose the first tree in $F'$, we ``kill'' the first tree from $F$ and grow an entirely new tree. In the second step, we recompute the residual and repeat, and so forth. After $L$ steps, $L$ new trees have been regrown in an unrestricted fashion. Although the trees grown in this sequence are not independent, their joint density is given by a product of conditional densities, all of the dependence being passed through the redefinition of the residual at each step; see Algorithm \ref{alg:evalprop}. Consequently, one can interchange the roles of $F$ and $F'$ in this elaborate proposal mechanism simply by beginning the process with the residual defined by $F'$ rather than $F$. Further work will consider the efficacy of this approach. \vspace{-3mm} \section{SIMULATION STUDIES} \subsection{Data Generating Process} To demonstrate the performance of the new accelerated BART heuristic, which we call XBART, we estimate function evaluations with a hold-out set that is a quarter of the training sample size and judge accuracy according to root mean squared error (RMSE). We consider four different challenging functions, $f$, as defined in Table \ref{tab:truef}. In all cases, $x_j \iid \mbox{{\small\textsc{N}}}(0,1)$ for $j = 1, \dots, d = 30$. The data is generated according to the additive error mode (\ref{additive}), with $\epsilon_i \iid \mbox{{\small\textsc{N}}}(0,1)$. We consider $\sigma = \kappa \mbox{Var}(f)$ for $\kappa \in \lbrace 1, 10 \rbrace$. \subsection{Methods} We compare to leading machine learning algorithms: random forests, gradient boosting machines, neural networks, and BART MCMC. All implementations had an {\tt R} interface and were the current fastest implementations to our knowledge: {\tt ranger} \citep{wright2015ranger}, {\tt xgboost} \citep{chen2016xgboost}, and {\tt Keras} \citep{chollet2015keras}, {\tt dbarts} respectively. For {\tt Keras} we used a single strong architecture but varied epochs depending on the noise in the problem. For {\tt xgboost} we consider two specifications, one using the software defaults and another determined by by 5-fold cross-validated grid optimization (see Table \ref{tab:f7}); a reduced grid of parameter values was used at sample sizes $n > 10,000$. Comparison with {\tt ranger} and {\tt dbarts} are shown in supplementary material. \begin{algorithm}[h] \caption{Grow Probability}\label{alg:growprob} \small \begin{algorithmic} \Procedure{GrowProb}{$r, T, \mu, X, h$} \State $\psi_h \leftarrow \pi(v_h(T), c_h(T)$ \Comment{From equation (3)} \If{$v_h(T)$ = NULL} \Comment{If this is bottom node} \State $\psi_h \leftarrow \psi_h \times \phi(\mu_h \mid \mu, \sigma^2)$ \Else \State$\psi_h \leftarrow $GrowProb($r_\text{left}, T, \mu, 2h$) \State$\psi_h \leftarrow $GrowProb($r_\text{right}, T, \mu, 2h+1$) \EndIf \State\textbf{return} $\psi_h$ \EndProcedure \end{algorithmic} \end{algorithm} \vspace{-3mm} \begin{algorithm}[h] \small \caption{Evaluate Proposal Density}\label{alg:evalprop} \begin{algorithmic} \Procedure{PropDens}{$F, F', y, \sigma^2, \tau, x$} \State Construct residual $r \leftarrow y - f(F_{2:L})$, initialize $q \leftarrow 1$ \For{$l$ in 1 to $L$} \State Set $\psi$$\leftarrow $Prod(GROWPROB($r, F'_l, \mu_l, x, h = 1$)) \State $q \leftarrow q\times\psi$ \State Update residual $r \leftarrow y - f(F_{(l+1):L}) - f(F'_{1:l})$ \EndFor \State\textbf{return} $q = q(F', F)$ \EndProcedure \end{algorithmic} \end{algorithm} \subsection{Computation} The software used was \texttt{R} version 3.4.4 with \texttt{xgboost} 0.71.2, \texttt{dbarts} version 0.9.1, \texttt{ranger} 0.10.1 and \texttt{keras} 2.2.0. The default hyperparameters for XGBoost are \texttt{eta} $= 0.3$, {\tt colsample\_bytree} $=1$, {\tt min\_child\_weight} $= 1$ and \texttt{max\_depth} $= 6$. Ranger was fit with \texttt{num.trees} $=500$ and \texttt{mtry} $ = 5 \approx \sqrt{d}$. BART, with the package {\tt dbarts}, was fit with the defaults of {\tt ntrees} $= 200$, {\tt alpha} $= 0.95$, {\tt beta} $=2$, with a burn-in of 5,000 samples ({\tt nskip} $=5000$) and 2,000 retrained posterior samples ({\tt ndpost} $=2000$). \vspace{-3mm} \begin{table}[h] \small \def1{1} \centering \caption{Four true $f$ functions} \begin{tabular}{l|m{2.15in}} \toprule Name &Function \\ \hline Linear & $ \mathrm{x}^t \mathrm{\gamma} $;\; $ \gamma_j = -2+ \frac{4(j-1)}{d-1} $\\ Single index & $10\sqrt{a} + \sin{(5a)}$;\;$a=\sum_{j=1}^{10} (x_j - \gamma_j)^2$;\; $\gamma_j = -1.5+ \frac{j-1}{3}$.\\ Trig + poly & $5\sin(3x_1)+2x_2^2 + 3x_3x_4 $\\ Max & $\max(x_1,x_2,x_3) $\\ \bottomrule \end{tabular} \label{tab:truef} \end{table} The default {\tt dbarts} algorithm uses an evenly spaced grid of 100 cut-point candidates along the observed range of each variable ({\tt numcuts} $=100$, {\tt usequants = FALSE}). For {\tt Keras} we build a network with two hidden layers (15 nodes each) using ReLU activation function, $\ell_1$ regularization at 0.01, and with 50/20 epochs depending on the signal to noise ratio. \vspace{-3mm} \begin{table}[h] \centering \small \caption{Hyperparameter Grid for XGBoost} \begin{tabular}{l|rr} \toprule Parameter name & $N = 10$K & $N > 10$K \\ \hline {\tt eta} & $\lbrace 0.1, 0.3\rbrace$ &$\lbrace 0.1, 0.3\rbrace$ \\ {\tt max\_depth} &$\lbrace 4, 8, 12\rbrace$ & $\lbrace 4, 12\rbrace$ \\ {\tt colsample\_bytree} & $\lbrace 0.7, 1 \rbrace$ & $\lbrace 0.7, 1 \rbrace$ \\ {\tt min\_child\_weight} & $\lbrace 1, 10, 15 \rbrace$ & $10$ \\ {\tt subsample} & 0.8 & 0.8 \\ {\tt gamma }& 0.1 & 0.1 \\ \bottomrule \end{tabular}% \label{tab:f7}% \end{table}% \vspace{-3mm} \subsection{Results} The performance of the new XBART algorithm was excellent, showing superior speed and performance relative to all the considered alternatives on essentially every data generating processes. The full results, averaged across five Monte Carlo replications, are reported in Tables \ref{tab:allall}. Neural networks perform as well as XBART in the low noise settings under the Max and Linear functions. Unsurprisingly, neural networks outperform XBART under the linear function with low noise. Across all data generating processes and sample sizes, XBART was 31\% more accurate than the cross-validated XGBoost method and typically faster. Specifically, the supplement examines the empirical examples given in \cite{chipman2010bart}. The XBART method was slower than the untuned default XGBoost method, but was 3.5 times more accurate. This pattern points to one of the main benefits of the proposed method, which is that it has excellent performance using the same hyperparameter settings across all data generating processes. Importantly, these default hyperparameter settings were decided on the basis of prior elicitation experiments using different true functions than were used in the reported simulations. While XGBoost is quite fast, the tuning processes is left to the user and can increase the total computational burden by orders of magnitude. Random forests and traditional MCMC BART were prohibitively slow at larger sample sizes. However, at $n = 10,000$ several notable patterns did emerge; see the supplementary material for full details. First was that BART and XBART typically gave very similar results, as would be expected. BART performed slightly better in the low noise setting and quite a bit worse in the high noise setting (likely due to inadequate burn-in period). Similarly, random forests do well in higher noise settings, while XGBoost and neural networks perform better in lower noise settings. \section{DISCUSSION} The grow-from-root strategy proposed here opens the door for computational innovations to be married to the novel BART stochastic fitting algorithm. Further, the proposed adaptive cut-points and variable selection proposal together define a novel predictor-dependent prior, marking a distinct Bayesian model. The simulation studies clearly demonstrate the beneficial synergy realized by the proposed approach: XBART is a state-of-the-art nonlinear regression method with computational demands that are competitive with the current fastest alternatives. In particular, the excellent performance without the need to cross-validate recommends XBART as a suitable default method for function estimation and prediction tasks when little is known about the response surface. \addtolength{\tabcolsep}{-2pt} \begin{table}[h] \centering \scriptsize \begin{tabular}{rllll} \multicolumn{5}{c}{$\kappa = 1$} \\\hline \toprule $n$ & XBART & XGB+CV & XGB & NN \\ \toprule \multicolumn{5}{c}{Linear} \\\hline 10k & 1.74 (20) & 2.63 (64) & 3.23 (0) & 1.39 (26) \\ 50k & 1.04 (180) & 1.99 (142) & 2.56 (4) & 0.66 (28) \\ 250k& 0.67 (1774) & 1.50 (1399) & 2.00 (55) & 0.28 (40) \\ \toprule \multicolumn{5}{c}{Max} \\\hline 10k & 0.39 (16) & 0.42 (62) & 0.79 (0) & 0.40 (30) \\ 50k & 0.25 (134) & 0.29 (140) & 0.58 (4) & 0.20 (32) \\ 250k & 0.14 (1188) & 0.21 (1554) & 0.41 (60) & 0.16 (44) \\ \toprule \multicolumn{5}{c}{Single Index} \\\hline 10k & 2.27 (17) & 2.65 (61) & 3.65 (0) & 2.76 (28) \\ 50k & 1.54 (153) & 1.61 (141) & 2.81 (4) & 1.93 (31) \\ 250k & 1.14 (1484) & 1.18 (1424) & 2.16 (55) & 1.67 (41) \\ \toprule \multicolumn{5}{c}{Trig + Poly} \\\hline 10k & 1.31 (17) & 2.08 (61) & 2.70 (0) & 3.96 (26) \\ 50k & 0.74 (147) & 1.29 (141) & 1.67 (4) & 3.33 (29) \\ 250k & 0.45 (1324) & 0.82 (1474) & 1.11 (59) & 2.56 (41) \\ \toprule \\ \multicolumn{5}{c}{$\kappa = 10$} \\\hline \toprule $n$ & XBART & XGB+CV & XGB & NN \\ \toprule \multicolumn{5}{c}{Linear} \\\hline 10k & 5.07 (16) & 8.04 (61) & 21.25 (0) & 7.39 (12) \\ 50k & 3.16 (135) & 5.47 (140) & 16.17 (4) & 3.62 (14) \\ 250k & 2.03 (1228) & 3.15 (1473) & 11.49 (54) & 1.89 (19) \\ \toprule \multicolumn{5}{c}{Max} \\\hline 10k & 1.94 (16) & 2.76 (60) & 7.18 (0) & 2.98 (15) \\ 50k & 1.22 (133) & 1.85 (139) & 5.49 (4) & 1.63 (16) \\ 250k & 0.75 (1196) & 1.05 (1485) & 3.85 (54) & 0.85 (22) \\ \toprule \multicolumn{5}{c}{Single Index} \\\hline 10k & 7.13 (16) & 10.61 (61) & 28.68 (0) & 9.43 (14) \\ 50k & 4.51 (133) & 6.91 (139) & 21.18 (4) & 6.42 (16) \\ 250k & 3.06 (1214) & 4.10 (1547) & 14.82 (54) & 4.72 (21) \\ \toprule \multicolumn{5}{c}{Trig + Poly} \\\hline 10k & 4.94 (16) & 7.16 (61) & 17.97 (0) & 8.20 (13) \\ 50k & 3.01 (132) & 4.92 (139) & 13.30 (4) & 5.53 (14) \\ 250k & 1.87 (1216) & 3.17 (1462) & 9.37 (49) & 4.13 (20) \\ \bottomrule \end{tabular}% \caption{Root mean squared error (RMSE) of each method. Column XGB+CV is result of XGBoost with tuning parameter by cross validation. The number in parenthesis is running time in seconds. First column is number of data observations (in thousands).} \label{tab:allall}% \end{table}% The source of XBART's superior performance is not entirely clear, but preliminary investigations point to two important factors. One, the BART splitting criterion involves (the current estimate of) the error standard deviation, $\sigma$, meaning that it is adaptively regularizing within the model fitting process. Two, we conjecture that the stochastic nature of the algorithm leads to better exploration of the parameter space than iterative optimizers. With fast model fitting software now in hand, this issue can be investigated more systematically in future work. Another line of future research is to incorporate XBART within extended BART models such as Bayesian causal forests \citep{hahn2017bayesian} and BART for log-linear models \citep{murray2017log}. \clearpage
{'timestamp': '2019-03-15T01:09:52', 'yymm': '1810', 'arxiv_id': '1810.02215', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02215'}
arxiv
\section{Introduction} \vspace{-0.2cm} Egomotion awareness plays a vital role in developing perception, cognition, and motor control for mobile agents through their own sensory experiences \cite{Agrawal2016}. Inertial information processing, a typical egomotion awareness process operating in the human vestibular system \cite{Cullen2012} contributes to a wide range of daily activities. Modern micro-electro-mechanical (MEMS) inertial measurements units (IMUs) are analogously able to sense angular and linear accelerations - they are small, cheap, energy efficient and widely employed in smartphones, robots and drones. Unlike other commonly used sensor modalities, such as GPS, radio and vision, inertial measurements are completely egocentric and as such are far less environment dependent. Developing accurate inertial tracking is thus of key importance for robot/pedestrian navigation and for self-motion estimation \cite{Harle2013}. Recent work in neural inertial tracking \cite{Chen2018} has demonstrated that deep neural networks are capable of extracting high level motion representations (displacement and heading angle) from raw IMU sequence data, and providing accurate trajectories. However, the task of turning inertial measurements into pose and odometry estimates is hugely complicated by the fact that different placements (e.g. carrying a smartphone in a pocket or in the hand) and orientations lead to significantly different inertial data in the sensor frame. For example, the uncertainties of phone placements, the corresponding motion dynamics, and the projection of gravity significantly alter the inertial measurements acquired from different domains (sensor frames) while the actual trajectories in the navigation frame are identical. The data-driven method that requires substantial labelled data for training, and a model trained on a single domain-specific dataset may not generalise well to new domains. It is clearly infeasible to collect labelled data from every possible attachment, as this requires specialized motion capture systems and a high degree of effort. In this paper, therefore, we propose a robust generative adversarial network for sequence domain transformation which is able to directly learn inertial tracking in unlabelled domains without using any paired sequences. We note that it is possible to train end-to-end deep neural networks when presented with large amounts of labelled data. The question becomes, how can we generalize to an arbitrary attachment in the absence of labels or a paired/time-synchronized sequence? Although from the observation the raw inertial data for each domain is very different, and the resulting odometry trajectories are also unrelated to one another, the underlying statistical distribution of odometry pose updates, if derived from a common agent (e.g. human motion), must be similar. Our intuition is to decompose the raw inertial data into a domain-invariant semantic representation, learning to discard the domain-specific motion sequence transformation. To overcome the challenges of generalising inertial tracking across different motion domains, we propose the \textbf{MotionTransformer} framework with Generative Adversarial Networks (GAN) for sensory sequence domain transformation. Its key novelty is in using a shared encoder to transform raw inertial sequences into a domain-invariant hidden representation, without the use of any paired data. Different from many GAN-based sequence generation models applied in the field of natural language processing \cite{Lample2018}, where the sequences consist of discrete symbols or words, our model is focused on transferring continuous long time series sensory data. \vspace{-0.2cm} \section{Model} \vspace{-0.2cm} \paragraph{Inertial Tracking Physical Model} Instead of directly predicting the trajectories conditioned on IMU outputs, we incorporate the neural model with a physical model for better inertial tracking inference. The physical model, derived from Newtonian Mechanics, integrates the angular rates of the sensor frame $\{ \mathbf{w}_{i} \}_{i=1}^N$ ($\mathbf{w}_i \in \mathbb{R}^3$ and $N$ is the length of the whole sequence) measured by the three-axis gyroscope into orientation attitudes. While the linear accelerations of the sensor frame $\{ \mathbf{a}_{i} \}_{i=1}^N (\mathbf{a}_i \in \mathbb{R}^3)$ measured by the three-axis accelerometer are transformed to the navigation frame and doubly integrated to give the position displacement, which discards the impact of the constant acceleration of gravity. This physical model is hard to implement directly on low-cost IMUs, because even a small measurement error will be exaggerated exponentially through the integration. Recent deep-learning based inertial tracking \cite{Chen2018} breaks the continuous integration by segmenting the sequence of inertial measurements $\{(\mathbf{a}_i, \mathbf{w}_i)\}_{i=1}^N$ into subsequences. We denote a subsequence as $\mathbf{x} = \{(\mathbf{a}_i, \mathbf{w}_i)\}_{i=1}^{n}$, whose length is $n$. By taking into subsequences as inputs, a recurrent neural network (RNN) is leveraged to periodically predict the polar vector $\mathbf{y} = (\Delta l, \Delta \psi)$, which represents the heading and location displacement: \begin{equation} (\Delta l, \Delta \psi) = \text{RNN} (\{(\mathbf{a}_i, \mathbf{w}_i)\}_{i=1}^{n}) \end{equation} Based on the predicted $(\Delta l, \Delta \psi)$, we are able to easily construct the trajectories. However, it requires a large labelled dataset to build an end-to-end inertial tracking system, and it is infeasible to label data for every possible domain due to the motion dynamics and unpredictability of device placements. \vspace{-0.2cm} \paragraph{MotionTransformer Framework} Here, we introduce the MotionTransformer framework, which is able to exploit the unlabelled sensory measurements, transfer the physical knowledge learned in one domain to new domains and carry out accurate inertial tracking. As Figure.~\ref{fig:overview} illustrates, our framework consists of encoder, generator, decoder and predictor modules. Assume a scenario of two domains: a source domain and a target domain, where the source domain has labelled sequences $(\mathbf{x}^S, \mathbf{y}^S)\in\mathbb{D}^S$ ($\mathbf{y}^S$ is the sequence label - the polar vector of $\mathbf{x}^S$), and the target domain only has unlabelled sequences $\mathbf{x}^T \in \mathbb{D}^T$. Note that the sequences $\mathbf{x}^S$ and $\mathbf{x}^T$ are not aligned. The objectives of MotionTransformer Framework are three-fold: 1) extracting domain-invariant representations $\mathbf{z}$ shared across domains; 2) generating $\mathbf{\hat{x}}^T$ in the the target domain conditioned on $\mathbf{x}^S$; 3) predicting sequence labels $\mathbf{y}^T$ in the target domain. \begin{figure} \centering \includegraphics[width=1\textwidth]{main_architecture4.pdf} \caption{\label{fig:overview} Architecture of Proposed MotionTransformer: including the source domain sequence \textbf{Encoder} (extracting common features across different domains), the target domain sequence \textbf{Generator} (generating sensory stream in the target domain), the sequence reconstruction \textbf{Decoder} (reconstructing the sequence for learning better representations) and the polar vector \textbf{Predictor} (producing consistent trajectory for inertial navigation). The GAN discriminators and the source domain Generator are omitted from this figure. } \end{figure} \vspace{-0.2cm} \paragraph{Inference} This section introduces the learning method for jointly training the modules of our MotionTransformer, including GAN loss $\mathcal{L}_{G}$, reconstruction loss $\mathcal{L}_{AE}$, prediction loss $\mathcal{L}_{pred}$, cycle-consistency $\mathcal{L}_{cycle}$ and perceptual consistency $\mathcal{L}_{percep}$: \begin{equation} \mathcal{L}_{total} = \mathcal{L}_{GAN} + \lambda_1 \mathcal{L}_{AE} + \lambda_2 \mathcal{L}_{pred} + \lambda_3 \mathcal{L}_{cycle} + \lambda_4 \mathcal{L}_{percep} \end{equation} where $\lambda_1$, $\lambda_2$, $\lambda_3$, and $\lambda_4$ are the hyper-parameters used as the trade-off for the optimization process. \vspace{-0.2cm} \section{Experiments} \vspace{-0.2cm} \paragraph{Inertial Tracking Dataset} \begin{figure*} \centering \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{a_s.pdf} \caption{\label{fig:heading source} Training in Source} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{a_t.pdf} \caption{\label{fig:heading target} Training in Target} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{a_da.pdf} \caption{\label{fig:heading da} MotionTransformer} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{l_s.pdf} \caption{\label{fig:length source} Training in Source} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{l_t.pdf} \caption{\label{fig:length target} Training in Target} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{l_da.pdf} \caption{\label{fig:length da} MotionTransformer} \end{subfigure} \caption{\label{fig:heading estimation} Heading displacement estimation from training in (a) source domain, (b) target domain and (c) MotionTransformer, and location displacement estimation from training in (d) source domain, (e) target domain and (f) MotionTransformer} \vspace{-0.5cm} \end{figure*} A commercial-off-the-shelf smartphone, the iPhone 7Plus, is employed to collect inertial measurement data of pedestrian random walking \cite{chen2018oxiod} \footnote{Dataset can be found at http://deepio.cs.ox.ac.uk}. The smartphone was attached in four different poses: handheld, pocket, handbag and trolley, each of which represents a domain that has dramatically distinct motion pattern with others. We use an optical motion capture system (Vicon) to record the ground truth of motion. The 100 Hz sensor readings are then segmented into sequences with corresponding labels, e.g. location and heading attitude displacement provided by Vicon system. These source-domain labels are used for MotionTransformer training while the target-domain labels are used for MotionTransformer evaluation only. The length of each sequence is 200 frames (2 seconds), including three linear accelerations and three angular rates per frame. In our training phase, we use 45544, 53631, 36410 and 29001 sequences for handheld, pocket, handbag and trolley domains, and set the hyper-parameters $\lambda_1=0.01$, $\lambda_2=100$, $\lambda_3=0.1$, and $\lambda_4=1$. \vspace{-0.2cm} \paragraph{Transferring Across Motion Domains} We evaluate our model on unsupervised motion domain transfer tasks. The source domain is the inertial data collected in the handheld attachment, while the target domains are those collected in the attachments of pocket, handbag and trolley. Its generalization performance is evaluated by comparing the label prediction (polar vector) with the ground-truth data. We compare with source-only, where we use the trained source predictor to predict data directly in the target domain and with target-only where we train the target dataset with target labels to show the performance of fully supervised learning. Figure \ref{fig:heading estimation} presents the predicted location and heading displacement in pocket domain for the three different techniques. It can be seen that source-only is unable to follow either delta heading or delta location accurately, whereas MotionTransformer achieves a level of performance close to the fully supervised target-only, especially for delta heading. \begin{figure*} \centering \begin{subfigure}[t]{0.25\textwidth} \includegraphics[width=\textwidth]{pocket3.pdf} \caption{\label{fig:traj_pocket} Pocket} \end{subfigure} \hspace{0.2cm} \begin{subfigure}[t]{0.25\textwidth} \includegraphics[width=\textwidth]{trolley3.pdf} \caption{\label{fig:traj_trolley} Trolley} \end{subfigure} \hspace{0.2cm} \begin{subfigure}[t]{0.25\textwidth} \includegraphics[width=\textwidth]{bag3.pdf} \caption{\label{fig:traj_bag} Bag} \end{subfigure} \vspace{-0.2cm} \caption{\label{fig:traj} Inertial tracking trajectories of (a) Pocket (b) Trolley (c) Handbag, comparing our proposed unsupervised MotionTransformer with Ground Truth and Supervised Learning. } \vspace{-0.2cm} \end{figure*} \vspace{-0.2cm} \paragraph{Inertial Tracking in Unlabelled Domains} We argue that the predicted label from our domain transformation framework is capable of solving a downstream task - inertial odometry tracking. In an inertial tracking task, the precision of the predicted label determines the localization accuracy, as the current location $(x_n, y_n)$ is calculated by using an initial location $(x_0, y_0)$ and heading, and chaining the results of previous windows via Eq. \ref{eq: location update}. This dead reckoning technique, also called path integration, can be widely found in animal navigation \cite{McNaughton2006}, which enables animals to use inertial cues (e.g. steps and turns) to track themselves in the absence of vision. The errors in path integration will accumulate and cause unavoidable drifts in trajectory estimation, which imposes a requirement for accurate motion domain transformation. Without domain adaptation, if the model trained on source domain is directly applied to target domains, it will not produce any meaningful trajectory. \begin{equation} \label{eq: location update} \left\{ \begin{aligned} x_n=x_0+\Delta l cos(\psi_0+\Delta \psi) \\ y_n=y_0+\Delta l sin(\psi_0+\Delta \psi) \end{aligned} \right. \end{equation} We show that the inertial tracking trajectory can be recovered from the labels predicted by our domain adaptation framework in \textit{unlabelled} domains. The participant walked with the device placed in the pocket, the handbag and on the trolley. The inertial data during test walking trajectory was not included in training dataset, and collected in different days. Figure \ref{fig:traj} illustrates that our proposed model succeeds in generating physically meaningful trajectories, close to the ground truth captured by Vicon system. It proves that exploiting the raw sensory stream and transforming to a common latent distribution can extract meaningful semantic features that help solve downstream tasks. \vspace{-0.2cm} \section{Conclusion and Discussion} \vspace{-0.2cm} Motion transformation between different domains is a challenging task, which typically requires the use of labeled data for training. In the presented framework, by transforming target domains to a consistent, invariant representation, a physically meaningful trajectory can be well reconstructed. Intuitively, our technique is learning how to transform data from an arbitrary sensor domain $\theta$ to a common latent representation. Analogously, this is equivalent to learning how to translate any sensor frame to the navigation frame, without any labels in the target domain. Although MotionTransformer has been shown to work on IMU data, the broad framework is likely to be suitable for any continuous, sequential domain transformation task where there is an underlying physical model. \vspace{-0.2cm} \bibliographystyle{plain}
{'timestamp': '2018-10-05T02:07:41', 'yymm': '1810', 'arxiv_id': '1810.02076', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02076'}
arxiv
\section{Introduction} Negation scope is the set of words whose meaning is affected by a word or morpheme expressing negation. For example, in (\ref{introex}), the words `you' and `drive' are in the scope of the negation cue `not'. \enumsentence{\label{introex} \uline{You} must \cue{not} \uline{drive} because it is dangerous. } Detecting negation scope is important for many applications, including biomedical information retrieval \citep[e.g.][]{morante2009metalearning}, sentiment analysis \citep[e.g.][]{councill2010what}, and machine translation \citep[e.g.][]{fancellu2014applying}. Its importance has prompted the development of several annotated corpora and classifiers that detect negation scope with high accuracy. Most of this work is confined to English. Supervised machine learning systems require annotated data, and annotating data for negation scope requires substantial effort, both to adapt annotation guidelines to new languages \cite{altuna2017scope}, and for the annotation itself. As a consequence, there are only a handful of annotated datasets for languages other than English, such as the Chinese Negation and Speculation corpus \citep[CNeSp,][]{zou2016research}. We ask: \textit{Can we learn a model that detects negation scope in English and use it in a language where annotations are not available?} \begin{CJK*}{UTF8}{gbsn} \begin{figure*}[t] \centering \begin{dependency}[theme = simple] \begin{deptext}[column sep=1em, row sep=4.5ex] \uline{You} \& must \& \cue{not} \& \uline{drive} \& because \& it \& is \& dangerous\\ \& 因为 \& 很 \& 危险 \& \uline{你} \& \cue{不} \& 能 \& \uline{开车}\\ \end{deptext} \draw[-,densely dotted] (\wordref{1}{5}.south)--(\wordref{2}{2}.north); \draw[-,densely dotted] (\wordref{1}{8}.south)--(\wordref{2}{4}.north); \draw[-,densely dotted] (\wordref{1}{1}.south)--(\wordref{2}{5}.north); \draw[-,densely dotted] (\wordref{1}{2}.south)--(\wordref{2}{7}.north); \draw[-,densely dotted] (\wordref{1}{3}.south)--(\wordref{2}{6}.north); \draw[-,densely dotted] (\wordref{1}{4}.south)--(\wordref{2}{8}.north); \deproot{4}{ROOT} \depedge{4}{1}{NUSBJ} \depedge{4}{2}{AUX} \depedge{4}{3}{NEG} \depedge{4}{8}{ADVCL} \depedge{8}{5}{MARK} \depedge{8}{6}{NSUBJ} \depedge{8}{7}{COP} \deproot[edge below]{8}{ROOT} \depedge[edge below]{8}{7}{AUX} \depedge[edge below]{8}{6}{NEG} \depedge[edge below]{8}{5}{NUSBJ} \depedge[edge below]{8}{4}{ADVCL} \depedge[edge below]{4}{3}{ADVMOD} \depedge[edge below]{4}{2}{MARK} \end{dependency} \caption{Example dependency parse for the sentence `You must not drive because it is dangerous' and its Chinese translation. While the word order differs in translation, each word in the negation scope stands in the same relation to the cue.} \label{depex} \end{figure*} \end{CJK*} To answer this question, we develop models on English using language agnostic features only and apply them to Chinese; though annotations are available for Chinese we use them only for testing to simulate our zero-resource setting. Our initial model is the state-of-the-art bidirectional LSTM (BiLSTM) of \citet{fancellu2016neural}, initialized with cross-lingual word embeddings and universal part-of-speech (PoS) tags. But BiLSTMs are sensitive to word order, so we also experiment with a cross-lingual input representation that abstracts from word order---syntax in the form of universal dependencies \citep[UD,][]{demarneffe2014universal}---since we expect that for examples like that in Fig. \ref{depex}, this will give our model a more consistent view of the input across languages. To condition our model on UD syntax, we consider two different encodings: a Bidirectional DependencyLSTM \citep[D-LSTM below, modeled after the treeLSTM of][]{tai2015tree} and a Graph Convolutional Network \cite[GCN below,][]{marcheggiani2017encoding} Our results show it is indeed possible to build models for cross-lingual negation scope detection with performance approaching that of a monolingual oracle. Modeling syntax in addition to surface word order is helpful, as shown by an ensemble of BiLSTM and D-LSTM models outperforming either model alone. Our results also show that cross-lingual word embeddings are not really necessary, suggesting that the model mainly relies on PoS, syntax, and punctuation boundaries---with the latter result reinforcing previous findings \citep{fancellu2017detecting}. Finally, error analysis show that our best model performs better when the cue is in the same dependency substructure as its scope (as it is in Fig~\ref{depex}) and fails to capture phenomena related to negation scope, such as neg-raising, where lexical information is required. \section{The task} Our input is a sentence with a negation cue, which can be a word (e.g. `not') or a multi-word unit (e.g. `by no means') inherently expressing negation. Our task is to identify the set of words in the scope of the cue; we use gold cues and do not perform automatic cue detection. For example, \cue{\textbf{writing cues in bold red}} and \uline{underlining scopes}: \enumsentence{\label{exinit} \begin{enumerate} \item[i] \uline{I} must \cue{not} \uline{go} \item[ii] I do\cue{n't} think \uline{he should come} . \item[iii] I did\cue{n't} miss the concert \uline{because I was sick} but because I was busy . \end{enumerate} } Detecting negation scope is challenging because it often interacts with other semantic phenomena. To resolve (\ref{exinit}.i), the system needs to know that `must' scopes over negation but other modals (e.g. `should') do not. Likewise for neg-raising, as in (\ref{exinit}.ii), the presence of certain verbs like `think' or `believe' requires the negation scope to span the object clause (i.e. `I think he should not come'). Finally, in (\ref{exinit}.iii), the causal clause is in the scope despite the marker directly preceding the verb `miss'. Similar interactions are attested in Chinese. However, the lack of markers for certain syntactic environments may pose different challenges, since scope boundaries are not defined explicitly. This is the case of clausal complements and descriptive clauses in the following examples which lack explicit markers (`to' and `that' in English). \begin{CJK*}{UTF8}{gbsn} \enumsentence{ \begin{enumerate} \item[i.] \shortex{5} {他 & 说 & \cue{不} & \uline{要} & \uline{等}} {He & say & not & need to & go} {``He says not to wait"} \item[ii.] \shortex{6} {我 & 有 & 衣服 & \cue{不} & \uline{要} & \uline{洗}} {I & have & clothes & not & need & wash} {``I have clothes that do not need to be washed"} \end{enumerate} } \end{CJK*} \section{Related work}\label{prevwork} Automatically detecting negation scope at the string level has been tackled by a variety of classifiers \citep[e.g.][]{lapponi2012uio,packard2014simple} exclusively in English or Chinese monolingual settings using language-specific heuristics or resources \citep[e.g. DeepBank][]{flickinger2012deepbank}. Corpora also reflect this limitation, with only one available in a language other than English. Recently, \citet{fancellu2016neural} proposed a BiLSTM model that can be easily repurposed to a new dataset without feature engineering, since it requires only word and universal PoS tags embeddings. Its performance is state-of-the-art in both English and Chinese, but to train it on another language we would still need annotations in that language. In the absence of annotated data in a target language, many work have underlined the usefulness of Universal Dependencies, a cross-lingually consistent syntactic annotation framework. \citet{tiedemann2015cross} and \citet{ammar2016many} explore the problem of parsing across the languages annotated for UD, while \citet{reddy2017universal} have converted UD annotation to logical form for universal semantic parsing and \citet{prazak2017cross} have used UD for cross-lingual SRL. \section{The models} \subsection{BiLSTM} Our BiLSTM model follows \citet{fancellu2016neural}, to which we refer the reader for further detail. Given a sentence $w = w_1$...$w_n$, we encode $w_i$ as \textit{d}-dimensional embedding vector, {\bf w}$_i$ $\in {\rm I\!R^{d_w}}$. Alongside {\bf w}$_i$, we also encode information 1) about whether a word $w_i$ is a cue or not, encoded in a cue-embedding vector {\bf c}$_i$ $\in$ ${\rm I\!R^{d_c}}$ and 2) about the universal PoS tag of $w_i$, represented as a PoS embedding vector {\bf p}$_i$ $\in$ ${\rm I\!R{^d_p}}$. We then concatenate these vectors to yield the input {\bf x}$_i$ as follows: \begin{figure}[h] \begin{equation} \begin{aligned} {\bf x}_i=[{\bf w}_i;{\bf c}_i;{\bf p}_i] \label{lstminput} \end{aligned} \end{equation} \end{figure} Our goal is to predict the negation scope $s \in \{1,0\}^{\mid w\mid}$, where $s_i=1$ if a token is part of the scope and 0 otherwise. \subsection{Bidirectional Dependency LSTM (D-LSTM)} We now turn to the encoding of a dependency tree, considering the example in Figure~\ref{depex}. We can traverse the tree bottom-up, from leaves to root, or top-down, from root to leaves. A top-down pass seems insufficient, since negation since cues are usually leaves as in the example. On the other hand, a bottom-up pass would fully encode the subtree rooted at the parent of the cue (in Fig.~\ref{depex}, `drive') but would not be able to encode information about the subordinate being out of scope. Hence we need a bi-directional model that can encode the tree bottom-up and top-down. But this is still insufficient unless the passes communicate: that is, if the bottom-up pass first collects information about the children of `drive', then the top-down pass can pick up that information and pass it downward, hence communicating information about `not' to its sibling nodes in scope. The model accepts as input dependency trees. A dependency tree $g$ is a tuple (V,E), where $V_g$ is the set of word-nodes and $E_g$ the set of dependency edges. Each $e \in E$ is assigned a dependency label $l$. We define as $p(v)$ the parent of node $v$ and $C(v)$ the set of its children. $r$ is the root node. We represent each word-node $v \in V$ as shown in Eq.\ref{initbtmup}. The input vector differs from the one used in the BiLSTM model in that we add an an extra embedding {\bf l} representing the dependency label of the word in $v$ and a linear transformation to allow multiple layers to be stacked together, as ${\bf x}_v$ can be replaced with the hidden state from a previous layer. \begin{figure}[h] \begin{equation} \begin{aligned} {\bf x}_v &= {\bf W}[{\bf x}_v;{\bf c}_v;{\bf p}_v;{\bf l}_v] + {\bf b} \label{initbtmup} \end{aligned} \end{equation} \end{figure} The computation of the bottom-up pass is the same as in \citet{tai2015tree}. This pass returns the state $s_v^\uparrow$ = $\langle $ {\bf h}$_v^\uparrow$, {\bf c}$_v^\uparrow$ $\rangle$, where {\bf h}$_v^\uparrow$ and {\bf c}$_v^\uparrow$ are the hidden state and the memory cell of node $v$. To address the lack of bi-directionality in the original child-sum TreeLSTM of \citet{tai2015tree}, we add a second top-down pass where we feed the states computed during the bottom-up pass; in this our model is very similar to the one of \citet{chen2017improved}. The top-down pass is similar to the bottom-up one but traverses the vertices in a topological order. To create a dependency between passes, we made the states computed during the bottom-up pass, ${\bf s_v^\uparrow}$, available in the form of additional weighted feature during the top-down pass. We start by computing the representation of the root node $r$ as follows: \begin{figure}[h] \begin{equation} \begin{aligned} {\bf s}_r^\downarrow &=LSTM({\bf x}_r,s_r^\uparrow) \end{aligned} \end{equation} \end{figure} When computing the state of a node top-down, we use the parent state the same we did for the children states in the bottom-up pass. The hidden representation of the remaining nodes $v$, {\bf $s_v^\downarrow$}, is computed as follows: \begin{figure}[t] \centering \includegraphics[scale=0.7]{treelstm} \caption{The D-LSTM architecture. Each word is represented by the concatenation of word, universal PoS tags, dependency label and cue features. The latter is a binary feature which is 1 if the word is a cue (like `not') and 0 otherwise. The bottom-up pass builds from the leaves (`you', `must' and `not') to the root (`drive') and the top-down in the opposite direction. The states built during both passes are exemplified by the $\uparrow$ and the $\downarrow$ respectively.} \label{treelstmfigure} \end{figure} \begin{equation} \begin{aligned} s_v^\downarrow &= LSTM({\bf x}_v, s_v^\uparrow, s_{p(v)}^\downarrow) \end{aligned} \end{equation} After both passes are computed, we pass the hidden states obtained at the end of the top-down pass to the softmax layer to compute the probability of a given node to be inside or outside the scope of negation.\footnote{We also experimented with concatenating the two passes together but saw no difference in performance} \begin{equation} \label{softmax} \begin{aligned} \hat p(y|{\bf h}_v) & = softmax({\bf W{\bf h}_v^\downarrow + b}) \end{aligned} \end{equation} A summary of the architecture is shown in Fig. \ref{treelstmfigure}. \subsection{Graph convolutional networks} Our GCN is based on \cite{marcheggiani2017encoding}, to which we refer the reader for details. The intuition behind a GCN is that the hidden representation for each node in the tree is a function that aggregates information from its immediate neighbors. To communicate information between nodes that are not immediate neighbors, this process is iterated a fixed number of times, where each iteration corresponds to a neural network layer. GCNs do not assume that their input directed, so they have no notion of bottom-up or top-down traversal and do not distinguish between parent or child nodes; directionality is encoded explicitly into the neighborhood function. The input to the model is a vector $[{\bf w_n;c_n;p_n}] \in {\rm I\!R}^{d^3}$, which is passed through a non-linearity or through a bi-LSTM before being fed to the GCN. The computation for the hidden state of a given node $v$ takes into account: the hidden state of a neighbor node $n$; the directionality of the edge between $v$ and $n$ and the dependency label with its directionality specified. For each directionality a different weight matrix W$_{dir(u,v)}$ is used. Unlike the D-LSTM, information regarding the dependency label is not encoded in the input but in the bias vector b$^{l(u,v)}$. This yields the following equation: \begin{equation} \label{gcneq} \begin{aligned} {\bf h^{(K+1)}_v} &= ReLU(\\ & \sum_{u \in \mathcal{N}(v)} g^{(K)}_{v,u}({\bf W^{(K)}}_{dir(u,v)}{\bf h_v} + {\bf b^{l(u,v)}})) \end{aligned} \end{equation} where g$_{(v,u)}$ is an edge-wise scalar gate to help weighing the importance of an edge-node pair amongst several neighbors and $K$ the current layer. However, whereas the original formulation of the GCN encodes information about the dependency labels in the bias term, we weight it alongside other input features. In this way, our GCN resembles the input of the D-LSTM. Our modification results in Eq~\ref{gcneq2} \begin{small} \begin{equation} \label{gcneq2} \begin{aligned} {\bf h^{(K+1)}_v} &= ReLU(\\ & \sum_{u \in \mathcal{N}(v)} g^{(K)}_{v,u}({\bf W^{(K)}}_{dir(u,v)}{\bf h_v} + {\bf W_l^{(K)} l}_{(u,v)}+ {\bf b})) \end{aligned} \end{equation} \end{small} \begin{figure} \centering \includegraphics[scale=0.7]{gcn} \caption{The CGN architecture. Hidden representations are built by aggregating neighboring nodes in the dependency trees, as represented by the dashed lines. The node itself is also taken into consideration as shown by the straight lines. Information propagates by stacking up different layers.} \label{gcnfigure} \end{figure} A summary of the architecture is shown in Fig. \ref{gcnfigure}. \subsection{Ensemble} Finally, we experiment with two different ensemble models, where we join together the BiLSTM with either the D-LSTM and GCN. We ensemble together our sequential classifier with each of the structured models, to see whether syntactic information can benefit from sequential information and viceversa. We experimented with three different ensemble techniques: a) jointly train the two systems and concatenate the output states of each word before softmax; b) feed the input through a BiLSTM layer (as shown in Eq.~\ref{lstminput}) before passing it through either the D-LSTM or the GCN (same to what \citet{marcheggiani2017encoding} have done to improve the performance of the GCN model) and c) voting. We found voting to achieve the best performance. We also experimented with different kind of voting and we opted for `confidence' voting, where for each word we choose the system where the absolute difference between probability of token being inside and outside the scope is larger. The results in the next section will be based on this last ensemble model. \section{Data and experiment settings} We experiment with \textsc{NegPar} \citep{liu2018negpar}, a parallel English-Chinese corpus of four Sherlock Holmes stories annotated for negation. Although the English side of \textsc{NegPar} leverages pre-existing annotations \citep[\textsc{ConanDoyleNeg}][]{morante2012conan}, most of it has been reannotated to better capture semantic phenomena related to negation scope like modality and neg-raising. Note that the Chinese translation often converts positive English statements to negative---for example, `This dress is cheap' becomes \begin{CJK*}{UTF8}{gbsn}这件衣服\cue{不}贵\end{CJK*} (`This dress is \cue{not} expensive'). Hence the Chinese contains more negation instances (Table~\ref{negpar_stats}). \begin{table}[] \begin{center} \begin{tabular}{lcc}\hline\hline & English & Chinese\\ \hline train & 981 & 1206\\ dev & 174 & 230\\ test & 263 & 341\\ \hline \end{tabular} \caption{Number of negation instances in the train, dev and test set in the English and Chinese sides of \textsc{NegPar}} \label{negpar_stats} \end{center} \end{table} We obtain PoS tags and dependency parses using the Stanford Parser \cite{chen2014fast}. In preliminary experiments, we compared UD version 1 and version 2, which have an important difference: the negation-specific \textit{neg} relation in version 1 is replaced by the more general \textit{advmod} label in version 2. We observed that UD1 performs consistently better, so all experiments reported below are based on version 1. PoS tags are converted into universal PoS tags.\footnote{Mapping available at \url{https://github.com/slavpetrov/universal-pos-tags}} The word segmentation the Chinese side of \textsc{NegPar} is based on also leverages Stanford toolkits \cite{chang2008optimizing}. When testing across language, we remove language-specific dependency tags (e.g.conj:and$\to$ conj). \begin{table*}[] \centering \scalebox{0.85}{ \begin{tabular}{lcccccccccccc} \hline \hline & \multicolumn{4}{c}{English} & \multicolumn{4}{c}{English$\to$Chinese} & \multicolumn{4}{c}{Chinese} \\ & P & R & F$_1$& PCS & P & R & F$_1$ & PCS & P & R & F$_1$ & PCS\\ \hline BiLSTM & 85.29 & 89.76 & 87.47 & 55.89 & 69.43 & 70.45 & 69.94 & 18.64 & 77.71 & {\bf 79.35} & 78.52 & 33.14\\ D-LSTM & 81.30 & 85.37 & 83.28 & 52.47 & 68.60 & 70.39 & 69.49 & 16.57 & 76.70 & 71.91 & 74.23 & 29.59\\ GCN & 81.78 & 81.09 & 81.43 & 46.18 & 72.60 & 59.71 & 65.53 & 17.46 & 72.09 & 75.19 & 73.61 & 23.69\\ BiLSTM+D-LSTM & 87.86 & {\bf 89.77} & {\bf 88.80} & {\bf 61.98} & 72.03 & {\bf 72.89} & {\bf 72.46} & 21.01 & {\bf 81.47} & 77.89 & {\bf 79.64} & {\bf 40.53}\\ BiLSTM+GCN & {\bf 88.19} & 87.34& 87.77 & 59.54 & {\bf 74.62} & 69.24 & 71.92 & {\bf 23.65} & 78.02& 78.89 & 78.95 & 37.28 \\ \hline \end{tabular} } \caption{(P)recision, (R)ecall, F$_1$, and percentage of correct Scope (PCS) for each model \textit{English}, where the model has been trained and tested in English; \textit{Chinese}, where the model has been trained and tested in Chinese; and \textit{English$\to$Chinese}, where the model has been trained in English and tested in Chinese.} \label{ressummary} \end{table*} We experimented with three different cross-lingual word embeddings: a) embeddings pre-trained on Wikipedia data \footnote{Available at \url{https://github.com/Babylonpartners/fastText_multilingual}} where a linear transformation has mapped Chinese and English embeddings into a common space \citep{smith2017offline}; b) average cross-lingual word-embeddings \cite{guo2016representation}, where the embedding vector of a Chinese word is an average of the embedding vectors of its English translations and c) where we take as the embedding vector of a Chinese word the one of the English word with the highest translation probability. We found that c) consistently outperforms the other methods and that's what we are going to use in our experiments. We observed that method a) in particular suffers from a coverage problem since the embeddings cover only 64\% of the training vocabulary. We obtain translation probabilities from approximately 2 million sentences of the UN corpus \cite{rafalovitch2009united} using fast\_align \cite{dyer2013simple}. Hyperparameter tuning was performed separately for each system. Both the D-LSTM and the GCN are optimized using Adam \citep{kingma2014adam}, with an initial learning rate of 0.005. We found 4 layers to yield the best performance for the GCN models. We use a dropout as regularizer; in the D-LSTM, dropout is performed on the output layer, whereas in the GCN we follow \citet{marcheggiani2017encoding} in performing dropout on the neighbors $N(v)$. We evaluate our models using precision, recall, and $F_1$ over the number of scope tokens; and using the percentage of \textit{full} scopes spans we correctly detect (PCS below). We evaluate our model cross-lingually by training in English and testing in Chinese (\textit{English$\to$Chinese}); and for comparison we test models that are trained and test monolingually, on only English or Chinese. \section{Results and Discussion} We summarize the results in Table \ref{ressummary} as follows: \begin{enumerate} \item {\bf Modeling syntax is useful, though not on its own}. The ensembles that incorporate syntax outperform other models on both F$_1$ and PCS in both the monolingual and cross-lingual settings, showing that syntax is indeed beneficial---note that they outpeform the state-of-the-art BiLSTM of \citet{fancellu2016neural,fancellu2017detecting}.\footnote{Our results are not directly comparable to those of \citet{fancellu2016neural,fancellu2017detecting} since the annotation of the English data is different.} The D-LSTM outperforms the GCN in the monolingual settings but the latter performs better in terms of full scope spans detected in the when training in English and testing in Chinese. \item {\bf The BiLSTM model on its own outperforms either syntactic model on its own by a large margin}. Perhaps surprisingly, the BiLSTM performs on par with the D-LSTM in the cross-lingual setting as well, despite relying solely on surface word order. We investigate this in more detail below. \item {\bf It is indeed possible to build a cross-lingual model of negation}, with performance that approaches that of a monolingual Chinese system. \end{enumerate} We also address the following questions:\\ \textit{Do all features contribute in the same way?} We perform feature ablation on our BiLSTM+D-LSTM ensemble by either removing the cross-lingual word embedding feature (\textit{-w}) or the universal PoS embedding feature (\textit{-p}) from either or both model in the ensemble (Table \ref{ensemble_abl}). Results for the BiLSTM+GCN ensemble are similar. Both ensembles show the same trend in that removing the cross-lingual word embedding or the universal PoS embedding feature from the structured models helps with both recall and $F_1$. This shows that both the D-LSTM and the GCN {\bf leverage the dependency structure as main feature for cross-lingual negation scope detection, with little impact from the other two features}. Results also show that for both ensembles, results are worse when removing the PoS embedding feature from the BiLSTM model, suggesting that the BiLSTM relies on PoS to model word order. \begin{table}[h] \centering \begin{tabular}{cl|l|l|l|l} & \multicolumn{4}{c}{~~~D-LSTM} \\ \multicolumn{1}{l}{\multirow{2}{*}{}} & \multirow{2}{*}{} & \multicolumn{1}{c}{all} & \multicolumn{1}{c}{-w} & \multicolumn{1}{c}{-p} & \multirow{2}{*}{} \\ \cline{2-6}\cline{2-6} \multirow{9}{*}{BiLSTM} & \multirow{3}{*}{all} & 75.09 & {\bf 78.27} & 74.32 & P\\ & & 62.59 & 62.36 & 64.38 & R \\ & & 68.27 & 69.55 & 69.17 & F$_1$ \\ \cline{2-6} & \multirow{3}{*}{-w} & 76.98 & 74.26 & 74.93 & P\\ & & 65.55 & {\bf 69.12} & 69.05 & R \\ & & 70.81 & 71.60 & {\bf 71.87} & F$_1$ \\ \cline{2-6} & \multirow{3}{*}{-p} & 75.38 & 73.2 & 71.86 & P \\ & & 56.68 & 56.62 & 59.79 & R \\ & & 64.71 & 64.04 & 65.28 & F$_1$ \end{tabular} \bigskip \caption{(P)recision, (R)ecall, and F$_1$ for the feature ablation experiments, where models trained on all the features (\textit{all}) are compared with models where cross-lingual word embeddings (\textit{-w}) and universal PoS tags (\textit{-p}) are removed. The row represents the three different ablated BiLSTM models, the columns the ablated D-LSTM models. Each cell represents an ensemble of these ablated models; for instance, the one with the highest F$_1$ (2$^{nd}$ row, 3$^{rd}$ column) is the ensemble of a BiLSTM where cross-lingual word embeddings are removed and a D-LSTM where universal PoS are removed.} \label{ensemble_abl} \end{table} \textit{Why are BiLSTM useful in cross-lingual settings?} Results in Table 2 might be surprising considering that the \textit{sequential nature} of the BiLSTM does not adapt well with difference in word ordering that language can exhibit. This might be an artifact of the two languages used in the experiment, since English and Chinese have similar word order. However, this also could be explained by a striking observation by \citet{fancellu2017detecting}, who showed that recurrent classifiers are very accurate when negation scope is delimited by punctuation and sentence boundaries but inaccurate otherwise. For example, they would correctly predict the scope in Ex. (\ref{punct}.i), which we refer to as an \emph{easy} case, but not the one in Ex. (\ref{punct}.ii), a \emph{hard} case. \enumsentence{\label{punct} i. `\uline{She is} \cue{not} \uline{a princess}', said the queen .\\ ii. \uline{I} eat pizza but \uline{do} \cue{not} \uline{drink beer} . } To assess whether BiLSTM learns that punctuation is informative also in a cross-linguistic setting, we carry out two additional experiments. First, we replicate the experiments \citet{fancellu2017detecting} and divide the development instances into two groups, the \textit{easy} instances, predictable by punctuation alone and the \textit{hard} instances where scope cannot be predicted by punctuation alone. If the predictions of the BiLSTM are guided by punctuation we would expect easy instances to be predicted correctly more often than hard ones. Results in Table \ref{punctanalysis} seems to confirm our prediction where the sequential model learns to use punctuation to detect negation scope. As for the hard cases we also noticed that in 47.6\% of the cases prediction begins or ends at a punctuation token. \begin{table}[h] \centering \begin{tabular}{ccc} \hline\hline condition & easy & hard\\ \hline Chinese & 48 & 22\\ English$\rightarrow$Chinese & 27 & 5\\ \hline \end{tabular} \caption{PCS for \textit{easy} and \textit{hard} instances using the BiLSTM model on the development set.} \label{punctanalysis} \end{table} Given these results, we expect performance to worsen when punctuation is removed from the training and test data, so that the model cannot rely on it. We tested this in a second experiment where we compare the performance of the BiLSTM model with the same model where punctuation in the input has been removed. Results in Table \ref{punctnopunct} confirm our hypothesis: the model with no punctuation performs significantly worse. \begin{table}[] \centering \begin{tabular}{ccccc} \hline\hline condition & P & R & F$_1$ & PCS\\ \hline with punctuation & 66.2 & 71.0 & 68.5 & 13.8\\ without & 57.7 & 59.8 & 58.4 & 8.6\\ \hline \end{tabular} \caption{Comparison between two BiLSTM models in the cross-lingual task on the development set, one with (\textit{punct}) and one without (\textit{no punct.}) punctuation tokens.} \label{punctnopunct} \end{table} \section{Error Analysis} \textit{What is our model learning?} To analyze the performance of our best ensemble model, the BiLSTM+D-LSTM, we look at the \textit{syntactic environment} scope appears in. We approximate this by looking at the least common ancestor for all the nodes in the scope and by taking the label its parent edge; if the scope is discontinuous, we take into consideration the labels on top of all spans. For each of the most frequent dependency labels, we report token-level F$_1$, as well as the percentage of correct scope spans we recover (PCS). \begin{table}[] \centering \begin{tabular}{ccccc} \hline \hline & \multicolumn{2}{c}{Chinese} & \multicolumn{2}{c}{English$\rightarrow$Chinese} \\ label & F$_1$ & PCS & F$_1$ & PCS\\ \hline root & 76.4 & 41.1 & 70.5 & 22.9\\ conj & 81.6 & 32 & 81.7 & 25.8\\ ccomp & 77.5 & 43 & 66.5 & 10.7\\ nsubj & 77.3 & 25 & 65.4 & 3.2\\ dep & 79.8 & 44 & 78.0 & 30.2\\ dobj & 70.8 & 6 & 63.2 & 9.3\\ nmod:prep & 68.9 & 0 & -- & -- \\ nmod & -- & -- & 55.9 & 5.2\\ advmod & 52.9 & 0 & 61 & 0\\ \hline \end{tabular} \caption{Analysis of the syntactic environment around the scope where the dependency label represents the parent of the least common ancestor of all the nodes in the scope. Labels are ordered from most to least frequent.} \label{depanalysis1} \end{table} Results are shown in Table \ref{depanalysis1} for both English$\rightarrow$Chinese and Chinese settings. In the former, we notice that there is usually a substantial loss in performance in terms of PCS but not in terms of F$_1$, meaning that although the scope is not exactly captured the model is still able to correctly detect approximately the same proportion of tokens. \begin{CJK*}{UTF8}{gbsn}\begin{figure*} \enumsentence{\label{negraiseerr} \begin{itemize} \item[a.] \shortex{9} {\{\uline{我} & 倒\} & \cue{没有} & \{想到 & \uline{你} & \uline{身上} & \uline{还} & \uline{有} & \uline{神经}\}} {I & instead & have not & thing & you & on your body & still & have & strength} {``I did not think you still had strength"} \item[b.] \shortex{8} {\{\uline{我}\} & \cue{并不} & \{认为 & \uline{我} & \uline{已} & \uline{弄清} & 全部 & \uline{情况}\}} {I & not & believe & I & already & clarify & all & facts} {``I really don't think I have clarified all the situation already"} \end{itemize} } \enumsentence{\label{meiyouerr} \shortex{11} {要是 & \{\uline{我} & \cue{没}有 & \uline{弄错}\} & 的话 & 我们 & 的 & 当事人 & 已经 & 来 & 了} {if & I & have not & mistake & if & we & DE & interested party & already & come & ASP} {``If it wasn't for my mistake, our person of interest would have come already"} } \end{figure*} In general, high performance is related to whether the cue is in the same dependency substructure as its scope. This happens when negation scope spans the entire sentence (`root') or when it spans complement (`ccomp') or coordinate clauses (`conj'), where the root is usually a verb which is the cue's parent. On the other hand, we found that the system do not detect full scope as well when the cue is in a different substructure than the scope. One of these cases involves neg-raising, which also requires lexical information and that the system always predict incorrectly. This is exemplified in (\ref{negraiseerr}.a) and (\ref{negraiseerr}.b) for the verbs 想到(`to think') and 认为(`to believe'), where the cue appears in the matrix clause but the scope spans the complement clause. On the other hand, we found that in 8 out of 10 instances the universal quantifier was correctly predicted with respect to the scope of negation, as shown in the example below. \enumsentence[]{\label{uniquanterr} \shortex{8} {\{\uline{礼靴} & \uline{和} & \uline{背心} & \uline{的} & \uline{钮扣}\} & 都 & \cue{没有} & \{\uline{扣好}\}} {Boots & and & vest & DE & button & all & not & button up} {``Boots and vest were both not buttoned up properly"} } Finally we found 8 cases where the systems does not distinguish the homographs 没有 (`have not'), where both characters are part of the cue and 没有 (`does not exist'), where only the first character is the cue and the second is the existential verb `there is' which is part of the scope. In these cases, the systems always include 没有 as part of the scope as shown in (\ref{meiyouerr}). \end{CJK*} \section{Conclusion} Let us go back to our initial research question: when detecting negation scope in a language other than English, \textit{can we train a system to detect negation scope in English using language agnostic features and apply it to a language where no annotations are available?} Although not quite as accurate as an oracle monolingual model, we show that this is indeed possible by an ensemble of neural networks, where syntactic and surface word order complement each other. More interestingly, we show that the contribution of other cross-lingual features, such as bilingual word embeddings is minor compared to the information extracted from syntax. We also found that this applies to recurrent models as well, where structural information is extracted in the form of punctuation boundaries around a negated scope. However, some phenomena related to negation scope, especially those requiring lexical information, are still missed by our system fail. We also suggest that future work could apply this method to languages where negation is realized in divergent ways from that of English, like those displaying double and morphological negation. \bibliographystyle{acl_natbib_nourl}
{'timestamp': '2018-10-05T02:10:26', 'yymm': '1810', 'arxiv_id': '1810.02156', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02156'}
arxiv
\section{Correlation Clustering} \applabel{correlation-clustering} \section{Introduction} \seclabel{introduction} Online Transaction Processing (OLTP) Systems rely on the concurrency control protocol to ensure serializability of transactions executed concurrently. When two transactions executing in parallel try to access the same data item (e.g., a tuple, index entry, table, etc.), concurrency control protocol coordinates their accesses such that the final result is still serializable. Different protocols achieve this in different ways. Locking-based protocols such as two-phase locking (2PL), associate a lock with each data item and a transaction must acquire all locks (either in shared or exclusive mode) for data items it accesses before releasing any. Validation-based protocols such as optimistic concurrency control(OCC) ~\cite{occ}, optimistically execute a transaction with potentially stale or dirty (i.e. uncommitted) data and validate for serializability before commit. Validation-based protocols~\cite{hekaton, silo} are known to be well-suited for workloads with low {\em data contention} or {\em conflicts}, i.e., when data items are being accessed by transactions concurrently, with at least one access being a write. Since conflicting accesses are rare, it is unlikely that the value of a data item is updated by another transaction during its execution, and hence validation mostly succeeds. On the other hand, for workloads where data contention is high, locking-based concurrency control protocols are generally preferred as they pessimistically block other transactions that require access to the same data item instead of incurring the overhead of repeatedly aborting and restarting the transaction like in OCC. When the workload is known to be partitionable, partitioned concurrency control~\cite{hstore} is preferred as it eliminates the lock acquisition and release overhead for individual data items by replacing it with a single partition lock. Recent empirical studies~\cite{dbx1000} have revealed that even 2PL-based protocols incur a heavy overhead in processing highly contended workloads due to lock thrashing (for ordered lock acquisition), high abort rates (for no-wait and wait-die protocols) or expensive deadlock-detection. Our main proposal in this paper is to eliminate concurrency control-induced overheads by intelligently scheduling these highly-contended transactions on cores such that the execution is serializable even \emph{without} any concurrency control. In this paper, we propose a new transaction processing scheme called \textsc{Strife}\xspace that exploits data contention to improve performance in multi-core OLTP systems under high contention. The key insight behind \textsc{Strife}\xspace is to recognize that most transactional workloads, even those with high data contention, can be partitioned into two portions: multiple {\em clusters} of transactions, where there are no data conflicts between any two clusters; and some {\em residuals} -- those that have data conflicts with atleast two other transactions belonging to different clusters. As an example (to be elaborated in~\secref{architecture}), a workload that consists of TPC-C\xspace new order transactions can be divided into two portions: each set of transactions that orders from the same warehouse constitutes a cluster, while those that order from multiple warehouses constitute the residuals. Since transactions in different clusters access disjoint sets of data items, they can be executed in parallel by assigning each cluster to a different core; each core can execute a given cluster {\em without any concurrency control}, and all of the executed transactions are guaranteed to commit (unless explicitly aborted). The residuals, on the other hand, can be executed serially either on a single core, again without any concurrency control, or across multiple cores with concurrency control applied. Our protocol aims to capture the ``best of both worlds'': partition the workload to identify as many clusters as possible as they can be executed without the overhead of running any concurrency control protocols, and minimize the number of residual transactions. The idea of transaction partitioning is similar to partitioned databases~\cite{hstore}, where data items are split across different machines or cores to avoid simultaneous access of the same data items from multiple transactions. However, data partitioning needs to be done statically prior to executing any transactions, and migrating data across different machines during transaction execution is expensive. \textsc{Strife}\xspace instead partitions transactions rather than data, and treats each batch of transaction as an opportunity to repartition, based on the access patterns that are inherent in the batch. Furthermore, since data access is a property that can change over different workloads, \textsc{Strife}\xspace is inspired by deterministic database systems~\cite{calvin} and executes transactions in {\em batches}. More precisely, \textsc{Strife}\xspace collects transactions into batches; partitions the transactions into conflict-free clusters and residuals; and executes them as described above. The same process repeats with a new batch of transactions, where they are partitioned before execution. Implementing \textsc{Strife}\xspace raises a number of challenges. Clearly, a naive partitioning that classifies all transactions as residuals would fulfill the description above, although doing so will simply reduce to standard concurrency control-based execution and not incur any performance benefit. On the other hand, if the residual clusters are forced to be small, then number of conflict-free clusters produced might be lesser. As such, we identify the following desiderata for our partitioning algorithm: \begin{myitemize} \item Minimize the number of residuals. \item Maximize the number and size of conflict-free clusters. \item Minimize the amount of time required to partition the transactions; time spent on partitioning takes away performance gain from executing without concurrency control. \end{myitemize} To address these challenges, \textsc{Strife}\xspace comes with a novel algorithm to partition an incoming batch of transactions. It first represents the transaction batch as an {\em access graph}, which is a bipartite graph describing each transaction and the data items that are accessed. Partitioning then proceeds in $3$ steps: we first sample on the access graph to form the initial seed clusters, we then allocate the remaining transactions into the clusters. The resulting clusters are merged based on their sizes, and any leftover transactions are collected as the residuals. The final clusters are then stored in a worklist, with the cores executing them in parallel before proceeding to execute the residuals afterwards. Our prototype implementation has shown that the \textsc{Strife}\xspace protocol can improve transaction throughput by up to 2$\times$, as compared to traditional protocols such as two-phase locking for high-contention workloads. In summary, we make the following contributions: \begin{myitemize} \item We propose a novel execution scheme for high contention workloads that is based on partitioning a batch of transactions into many conflict-free and a residual cluster. We use this clustering towards executing most transactions in the batch without any form of concurrency control except a few in the residual cluster. % \item We design a new algorithm for transaction partitioning based on their access patterns. Our algorithm uses a combination of sampling techniques and parallel data structures to ensure effiency. % \item We have implemented a prototype of the \textsc{Strife}\xspace concurrency control protocol, and evaluated using two popular transaction benchmarks: TPC-C\xspace~\cite{tpcc} and YCSB~\cite{ycsb}. The experiments show that \textsc{Strife}\xspace can substantially improve the performance of transactional systems under high-contention by partitioning the workloads into clusters and residuals. \end{myitemize} The rest of this paper is organized as follows: We first provide an overview of \textsc{Strife}\xspace in~\secref{architecture}. Then in~\secref{algorithm} we discuss our partitioning algorithm in detail. We present our evaluation of \textsc{Strife}\xspace in~\secref{evaluation}, followed by discussion of related work in~\secref{related-work}. \section{Evaluation} \seclabel{evaluation} We have implemented a prototype of \textsc{Strife}\xspace and evaluated the following aspects of \textsc{Strife}\xspace: \begin{myitemize} \item We compare the performance of \textsc{Strife}\xspace with variants of the two-phase locking protocol for high contention workloads. The results show that \textsc{Strife}\xspace achieves up to $2\times$ better throughput both on YCSB and TPC-C\xspace benchmark. \item We study the impact of the number of ``hot'' records on performance by varying the number of partitions in the YCSB mixture and number of warehouses in TPC-C\xspace. We show that \textsc{Strife}\xspace is able to improve its performance as the number of hot items that are mostly independently accessed increases. \item We characterize the scalability of \textsc{Strife}\xspace along with other protocols by varying the number of threads in the system for a highly contended YCSB and TPC-C\xspace workload and \textsc{Strife}\xspace outperforms traditional protocols by $2\times$ in terms of throughput. \item We evaluate the impact of contention by varying the zipfian constant of the YCSB workload. We observe that while other 2PL protocols perform better at lower contention workload, \textsc{Strife}\xspace outperforms them by up to $4\times$ in throughput when the contention is higher. \end{myitemize} \input{sections/implementation} \subsection{Experimental Setup} We run all our experiments on a multi-socket Intel (R) Xeon(R) CPU E7-4890 v2 @ 2.80GHz with 2TB Memory. Each socket has 15 physical and 30 logical cores. All our experiments are limited to cores on a single socket. We implemented \textsc{Strife}\xspace and our baselines in C++. In all our experiments we set the batch size to be $100$K transactions resulting in a latency of atmost $200$ms. Note that this is lower than recommended client response time of $500$ms for the TPC-C\xspace benchmark~\cite{tpcc}, and it did not result in any significant difference in the results. \subsection{Workloads} All our experiments use the following workloads: \begin{myitemize} \item \textbf{TPC-C}: We use the a subset of the standard TPC-C\xspace benchmark. We restrict our evaluation to a 50:50 mixture \texttt{New-Order} and \texttt{Payment} transactions. We pick these two transactions as they are short ones that can stress the overhead of using a concurrency control protocol. All tables in TPC-C\xspace have a key dependency on the \texttt{Warehouse} table, except for the \texttt{Items} table. Hence most transactions will access at least one of the warehouse tuple during execution. Each warehouses contains $10$ districts, each district contains $10$K customers. The catalog lists $100$K items and each warehouse has a stock record for each item. Our evaluation adheres to the TPC-C\xspace standards specification regarding remote accesses: $15$\% payment transactions are to remote warehouses and $1$\% of items are ordered from remote warehouses. Each \texttt{New-Order} transaction orders approximately $10$ items resulting in a total of $10$\% remote stock accesses. We do not, however, use secondary index to retrieve a customer record using last name and restrict to querying by the primary key \texttt{customer\_id} only. \item \textbf{YCSB}: The YCSB workload is designed to stress the concurrency control further and help in various micro-benchmark experiments. YCSB transactions are a sequence of read-write requests on a single table. The table contains $10$M keys with a payload size of $128$~bytes and is queried using its primary key. Transactions are generated as belonging to specific partitions where the intra-partition key-access is determined by a zipfian distribution. The distribution can be controlled using the \emph{zipfian constant}, denoted using $\theta$. The higher the value of $\theta$, the higher the frequency of accessing the hotter keys in the distribution. Each transaction consists of $20$ accesses with a $50$\% probability of reads vs. writes. In our experiments, we control the number of hot records by varying number of partitions. \end{myitemize} \subsection{Baselines} We compare our \textsc{Strife}\xspace prototype with variants of the two-phase locking (2PL) protocol. Several experimental studies~\cite{dbx1000} have shown that 2PL strategies outperform other validation or multi-version based protocols for highly contented workloads. Below are the implementation specifics of our baselines: \begin{myitemize} \item \textbf{NoWait}: NoWait is a variant of the 2PL protocol where a transaction acquires shared or exclusive locks depending on the access type during execution, and releases them only upon commit or abort. If a transaction is unable to acquire a lock, it is aborted immediately (without waiting) to prevent deadlocks. We use as many locks as the number of records in the database, each co-located with the record to avoid overheads due to a centralized lock table. \item \textbf{WaitDie}: WaitDie is another variant of 2PL that uses a combination of abort and wait decisions based on timestamps to prevent deadlocks. A transaction requesting for a shared or exclusive lock waits in the queue corresponding to the lock only when its timestamp is smaller than all the current owners of the data item. Since transactions in the waiting queue always have decreasing timestamps, there is no deadlock possible. We use a hardware counter-based scalable timestamp generation technique proposed in prior work~\cite{dbx1000}. \item \textbf{LockOrdered}: This is a deadlock-free variant of 2PL. Before execution, a transaction acquires shared or exclusive locks on all data items it accesses in some pre-determined order to prevent deadlocks, and releases them after committing the transaction. \item \textbf{WaitsForGraph}: We use a graph, called the \emph{waits-for graph} to track dependencies between transactions waiting to acquire logical locks and their current owners. Each database thread maintains a local partition of the wait-for graph similar in prior work~\cite{dbx1000}. A transaction is added to the waits-for graph only when a lock is currently held in a conflicting mode by other transaction(s). A cycle in the dependency graph implies a deadlock and the recently added transaction is aborted. \end{myitemize} \input{sections/hot-records-expt} \input{sections/scalability-expt} \input{sections/factor-analysis} \input{sections/impact-of-contention} \section{Related Work} \seclabel{related-work} \paragraph{Graph Partitioning} The scheduling problem we proposed and provided a heuristic problem can be fundamentally modeled as a graph partitioning problem called the $k$-way min cut optimization. Even though, the partitioning problem is NP-Complete, several algorithms have been developed that produces good partitions: including spectral methods~\cite{spectral-1, spectral-2} and geometric partition methods ~\cite{geometric-partition, geometric-partition-2} among others. Multi-level partitioning algorithms~\cite{multi-level} are known to produce better partitions with a moderate computational complexity -- the basic idea is that a large graph is coarsened down to a few hundred vertices, a bisection of this graph is computed and then projected back to the original graph through multi-step refinement. METIS~\cite{metis} is an open-source graph partitioning library developed based on this scheme. Our preliminary investigation revealed that these techniques are much more expensive and does not match the practical low-latency processing requirements of OLTP systems. \paragraph{Data Clustering} Our scheduling problem computes a clustering of data items simultaneously as we cluster transactions to ascertain conflict-freedom among the conflict-free clusters. An alternative approach that we investigated is to first partition the data items based on co-occurrence in the batch followed by clustering of transactions based on this partition. Most of the data clustering algorithms such as $k$-means clustering are iterative. Multiple scans of transactions and its read-write set incurs a significant overhead compared to the actual execution of transactions. However, our randomized solution is inspired by Ailon et. al.~\cite{ailon} solution to the correlation clustering problem where elements are clustered based on a similarity and dissimilarity score. \paragraph{Lock Contention} Johnson et. al.~\cite{speculative-lock-inheritance} identify the problem of lock contention on hot items and apply a speculative lock inheritance technique to skip the interaction with a centralized lock table by directly passing over locks from transactions to transactions; a core assumption in this work, which does not apply to the highly contended workloads we deal with, is that transactions mostly acquire shared locks on the hot items. Jung et. al.~\cite{scalable-lock-manager} identify lock manager as a significant bottleneck and propose a new design for lock manager with reduced latching. We have shown that \textsc{Strife}\xspace outperforms the 2PL protocols even under the optimistic assumption of highly scalable record-level locks. Sadoghi et. al.~\cite{lock-contention-mvcc} identify lock contention as a significant overhead proposes an MVCC based optimization to reduce it. Orthrus~\cite{high-contention} is a database design proposal for high contention workloads that partition the concurrency control and transaction execution functionalities into different threads. However, unlike our design, Orthrus still uses locks to perform concurrency control. Yu et. al.~\cite{dbx1000} evaluate OLTP performance on 1000 cores and report that locking-based protocols are perform worse on write-intensive workloads due to lock thrashing, while lightweight 2PL protocols such as NoWait and WaitDie result in a very high abort rate. \paragraph{Modular and Adaptive Concurrency Control} Callas~\cite{modular-concurrency-control} presents a modular concurrency control to ACID transactions that partitions transactions into groups that when executed independently under different concurrency protocols still ensures serializability. Callas uses the dependency graph of a workload similar to our system to group data items but is different from our approach in that we analyze every batch independently and hence can adapt to changing access patterns quickly. \texttt{IC3}~\cite{ic3} uses static analysis and dynamic dependency tracking to execute highly contended transactions as pieces on multiple cores in a constrained fashion that ensures serializability. Tang et. al. propose adaptive concurrency control(ACC) that dynamically clusters data items and chooses optimal concurrency control for each cluster using a machine learning model trained offline. \paragraph{Improvements to Traditional Protocols} Dashti et. al.~\cite{mvcc-repair} propose a new approach for validating MVCC transactions that uses the dependency graph to avoid unnecessary aborts of transactions. BCC~\cite{bcc} improves traditional OCC by dynamically tracking dependencies that help avoid false aborts during the validation phase. Yan et. al.~\cite{cong} improve 2PL by statically analyzing stored procedures to find an efficient lock acquisition order based on contention of data items in the workload. \paragraph{Partitioned and Deterministic Databases} H-Store~\cite{hstore, hstore-cc} partitions the database such that most transactions access a single partition thereby reducing the overall concurrency control overhead. Partitioned databases requires static determination of partitions and does not adapt to changing access patterns. Moreover, multi-partition transactions are known to cause a significant drop in OLTP performance~\cite{dbx1000} for partitioned databases. Pavlo et. al.~\cite{skew-aware} automatically repartitions a database based on a given workload using local neighborhood search. Calvin~\cite{calvin} is a distributed database that executes transactions by deterministically ordering them. Our choice of micro-batching transactions to schedule them optimally is inspired Calvin and related literature~\cite{adv-disadv} on determinstic databases. Pavlo et. al.~\cite{predictive-modeling} predict and choose the optimizations (such as intelligent scheduling) that a distributed OLTP system can employ during runtime using a combination of offline machine-learning and markov models. This approach, however, is not adaptive to dynamic workloads with changing access patterns. \section{Problem Statement} \seclabel{problem} We defined the notion of an oracle scheduler in \secref{architecture} as a clustering algorithm that partitions a batch into conflict-free clusters and a residual cluster. Such an oracle scheduler is not unique. For example, consider the partitionable variant\footnote{In this example, we consider only \texttt{New-Order} and \texttt{Payment} transactions without any remote payments or orders} of the TPCC workload. An algorithm (say $\mathcal{S}_1$) that clusters all transactions in the batch into a single conflict-free cluster is a trivial but correct scheduler. Similarly, an algorithm (say $\mathcal{S}_2$) that clusters all transactions belonging to the same warehouse together and those from different warehoses into different clusters. This scheduler produces $w$ (number of warehouses) clusters. Both these algorithms are correct oracle schedulers. However, $\mathcal{S}_2$ is preferred over $\mathcal{S}_1$ as it leads to a higher degree of parallelism during the \textsc{conflict-free}\xspace phase. In this section, we qualify the oracle scheduler with a notion of optimality. The throughput of transaction processing in \textsc{Strife}\xspace is inversely proportional to the average time taken to execute a single batch. The objective of a ``good" oracle scheduler is to minimize the total time taken to execute a batch of transactions $\mathcal{B}$. We formalize this optimization as a graph partitioning problem. Let $O$ be the set of objects in the database. Each transaction $T$ is represented as a pair $(D_T, A_T)$, where $D_T \subseteq O$ is the set of objects accessed by $T$ and $A_T: D_T \rightarrow \{\mathtt{r}, \mathtt{w}\}$ specifies the type of access for the corresponding data item, where \texttt{r} and \texttt{r} represent read and write accesses respectively. \paragraph{Conflict Graph} Given a batch of transactions $\mathcal{B}$, we define its corresponding conflict graph $\mathcal{C} = (\mathcal{B}, \mathcal{E})$ as a graph among transactions in the batch with an edge between two transactions $T$ and $T'$ when they have conflicting accesses to a data item. Specifically, edge $e = (T, T') \in \mathcal{E}$ when $\exists \ d \in D_T \text{ and } d \in D_{T'}$ such that either of the following is true: \begin{myitemize} \item $A_T(d) = \mathtt{r}$ and $A_{T'}(d) = \mathtt{w}$ \item $A_T(d) = \mathtt{w}$ and $A_{T'}(d) = \mathtt{r}$ \item $A_T(d) = \mathtt{w}$ and $A_{T'}(d) = \mathtt{w}$ \end{myitemize} \guna{add an example here} The oracle scheduler must partition the graph into $n$ conflict-free sets of vertices $C_1, C_2, ... C_n$ and a residual set of vertices $R$ such that the time taken to execute the batch is minimal. The execution time is the sum of time spent in the \textsc{analysis}\xspace phase, \textsc{conflict-free}\xspace phase and the \textsc{residual}\xspace phase. It can be modeled as follows: \begin{align*} t(\mathcal{B}) &= t(\textsc{analysis}\xspace) + t(\textsc{conflict-free}\xspace) + t(\textsc{residual}\xspace) \\ &= t(\textsc{analysis}\xspace) + \eta_1 * \max_i(|C_i|) + \frac{\eta_2}{n} * |R| \end{align*} where $\eta_1$ is a constant that denotes average time taken to execute a transaction without concurrency control; and $\eta_2$ denotes the average time taken to execute a transaction with concurrency control. The key observation here is that execution time depends on two factors that result from the analysis: (1) the maximum size of the conflict-free clusters $\max_i(|C_i|)$ and (2) the size of the residual cluster $|R|$. Minimizing $t(\mathcal{B})$ can be posed as a multi-objective optimization problem that minimizes both $\max_i(|C_i|)$ and $|R|$. However, solving a multi-objective optimization problem is expensive. Since, time taken to solve this problem, $t(\textsc{analysis}\xspace)$, adds to the total time to execute a batch, we simplify the problem by bounding one of the objectives. \paragraph{Bounded Outliers} We limit the number of transactions that are clustered into the residual cluster $R$ by bounding its size to a fraction of $|\mathcal{B}|$ using the parameter $\alpha$, where $0 \geq \alpha < 1 $. Parameter $\alpha$ controls the proportion of transactions that will be executed in the \textsc{conflict-free}\xspace and \textsc{residual}\xspace phases and the degree of parallelism in the \textsc{conflict-free}\xspace phase. A higher value of $\alpha$ allows more spurious transactions to be clustered into residual cluster and this leads to a higher degree of parallelism in the \textsc{conflict-free}\xspace phase; while a lower $\alpha$ value forces more of the spurious transactions to be included in the conflict-free clusters reducing the degree of parallelism during \textsc{conflict-free}\xspace phase.\alvin{also talk about how to come up with $\alpha$.} Based on the above simplification, we pose the oracle scheduler optimization problem as follows: \begin{framed} \begin{problemstatement*} Partition conflict-graph $\mathcal{C} = (\mathcal{B}, \mathcal{E})$ into $C_1, C_2, ... C_n$ and $R$ such that \begin{equation*} \min_{R, C_1, .., C_k} \max_i(|C_i|) \end{equation*} where \begin{myenumerate} \item $R, C_1, ..., C_k$ is a partition of $\mathcal{B}$ \item $\forall (T, T') \in \mathcal{E}$, we have $T \in C_i \implies T' \in C_i$ \item $|R| \leq \alpha * |\mathcal{B}|$ \end{myenumerate} \end{problemstatement*} \end{framed} Condition $\S1$ ensures that all transactions in $\mathcal{B}$ are executed exactly once. $\S2$ is critical for serializability of transaction execution (refer \theref{serializability}) as the conflict-free clusters $C_1, ... C_n$ may be executed concurrently without concurrency control. $\S3$ bounds the size of residual clusters relative to the size of the batch. Further, the above model assumes unit cost for each transaction. This can be extended in a straight-forward way by assigning weights to transactions based on its computation cost or read-write set cardinality. \section{Transaction Partitioning Algorithm} \seclabel{algorithm} \begin{figure} \centering \includegraphics[scale=0.75]{images/running-example} \caption{Example batch of TPC-C\xspace transactions} \figlabel{running-example} \end{figure} As mentioned, \textsc{Strife}\xspace partitions a batch of transactions $\mathcal{B}$ into a set of $k$ conflict-free clusters $C_1, C_2, \ldots, C_k$, and a residual $R$ of size at most $\alpha |\mathcal{B}|$, with $\alpha$ being a configurable parameter. This partitioning problem can be modeled as graph partitioning on the data access graph $\mathcal{A}$ that corresponds to $\mathcal{B}$. Graph partitioning in general is NP-complete, and hence obtaining the optimal solution is exponential in the size of the batch. Nevertheless, graph partitioning is a well researched area with many heuristic solutions. We review some of these solutions in \secref{related-work}. However, it is challenging to use an off-the-shelf solution to the problem at hand as most of the them do not meet the performance requirements in a low-latency transaction processing system. So, we developed a heuristic solution that exploits the contentious nature of each batch of transactions. Our partitioning algorithm is divided into three stages: (1) \textsc{spot}, (2) \textsc{allocate} and (3) \textsc{merge}. In the \textsc{spot} stage, we identify highly contended data items from the batch using a randomized sampling strategy. Each of those data items are allocated to a different cluster. Transactions in the batch are then allotted to one of these clusters in the \textsc{allocate} phase. Finally, in the \textsc{merge} phase, some of these clusters are merged together to form larger clusters when a significant number of transactions in the batch co-access data items from multiple clusters. We use \figref{running-example} derived from the TPC-C\xspace benchmark as an illustrative example. In the figure, a \texttt{new-order} transaction (black dots) shown inside a warehouse $w$ (circles) orders items only from warehouse $w$; and those that order from multiple warehouses are shown at their intersections. As shown in the figure, in the given batch the majority of transactions only orders locally from warehouses $w_1$ and $w_2$, while many transactions involving $w_3$ and $w_4$ order from multiple warehouses. Before running the three stages of our partitioning algorithm, we first perform simple pre-processing on the transactions. During pre-processing step, \textsc{Strife}\xspace receives incoming transactions, stores them in the current batch, and computes the set of data items that are accessed in a write mode by at least one transaction. Data items that are read-only in the entire batch are ignored for partitioning purposes. For example, \texttt{items} is a dimension table in the TPC-C\xspace benchmark that is mostly read and rarely updated; as a consequence many \texttt{items} elements in batch are ignored by our algorithm. In the rest of the algorithm, we consider only those data items $D_T$ in $T$ that are written to by at least one transaction in $\mathcal{B}$. \subsection{Spot Stage} \sseclabel{spot} During the spot stage we create initial seeds for the $k$ clusters by randomly choosing $k$ mutually non-conflicting transactions. The pseudo-code for this stage is shown in \algref{spot-pseudo-code}. Initially, all data items and transactions in the access graph $\mathcal{A}$ are unallocated to any cluster. We begin by picking a transaction $T$ from $\mathcal{B}$ uniformly at random. If none of the data items accessed by $T$, denoted $D_T$, is allocated to any cluster, then we create a new cluster $C_i$ and allot each $d \in D_T$ to cluster $C_i$. If any of the data items is already allocated to a cluster, we reject $T$ for the next sample. We repeat this randomized sampling of transactions for a constant $c$ number of times, where $c$ is some small factor times the number of cores. When all transactions in the batch access a single highly contended data item $d$, for example, the initial pick will create cluster $C_1$ and allot $d$ to $C_1$. All future samples are now rejected as they access $d$. In such a case, we revert back to fallback clustering and execute $C_1$ sequentially. The goal of the spot stage is to quickly identify highly contentious data items in the workload, as each such item should form their own cluster. To get some intuition of the working of the spot stage, suppose there are $k$ cores and the workload happens to have $k$ ``hot spot'' data items $d$, meaning data items that are each accessed by a fraction $1/k$ of all transactions in the batch. An ideal clustering should place each hot spot in a different cluster $C_i$. We observe that, in this case, with high probability, each of the hot spots is accessed by one of the transactions chosen by the spot stage as initial seeds. Indeed, every hot spot data item $d$ is picked with probability at least $1-(1-1/k)^c\approx 1$, because during each of the $c$ iterations, the probability that we chose a transaction that does not access $d$ is $1-1/k$ and, assuming $c \gg k$, we have $(1-1/k)^c \approx 0$. This means that, with high probability, the spot stage will form cluster seeds that are centered precisely around those few hot spot data items. By the same reasoning, if two hot spot data items are frequently accessed together, then with high probability the cluster that contains one will also contain the other. \begin{algorithm} \SetKwProg{Fn}{Function}{}{end} \SetKwProg{Proc}{Procedure}{}{end} \SetKwFunction{Cluster}{Cluster} \SetKwFunction{SpotStage}{SpotStage} \SetKwFunction{AllocateTxns}{AllocateTxns} \SetKwFunction{AllocateSkippedTxns}{AllocateSkippedTxns} \SetKwFunction{MergeClusters}{MergeClusters} \Fn{\SpotStage{$\mathcal{B}$}}{ $\forall d:$ d.Cluster = NULL\; R := $\{\}$ \tcp{Residual Cluster} k := 1\; \Repeat{$c$ times} { Pick a random transaction $T$ from $\mathcal{B}$\; \If{$\forall d \in D_T:$ d.Cluster = NULL} { Create a new cluster $C_k$\; Add $T$ to $C_k$\; \ForEach{$d \in T$} { d.Cluster = $C_k$\; } k++\; } } \Return $(C_1, C_2, ..., C_k)$\; } \caption{Pseudo-Code for the Spot Stage} \alglabel{spot-pseudo-code} \end{algorithm} In our example, it is we pick one of $w_1$ or $w_2$-only transaction in one of the rounds with a high probability. So, any $w_1$ or $w_2$ transaction picked in the future is simply rejected as the corresponding \texttt{warehouse} tuple is already allotted a cluster. Similarly, a $w_3 - w_4$ transaction might be picked in one of the rounds resulting in three base clusters. At this stage, further sampling of transactions does not increase the number of base clusters as all other transactions will be rejected. In an alternate scenario, a $w_3$-only and a $w_4$-only transaction might be picked before any $w_3-w_4$ transaction due to the randomness of the event resulting in $4$ base clusters. \subsection{Allocate Stage} \sseclabel{allocate} In this stage, we develop on the initial seed clusters created previously by allocating more transactions and data items accessed by them to these clusters. In this stage, we allocate transactions in two rounds. Let the seed clusters be $\{C_1, C_2, ..., C_k\}$. In the first round, we scan through transactions in $\mathcal{B}$ and try to allot a previously unallocated transaction $T$ to one of these clusters or as a residual based on the following criteria (refer \algref{allocate-pseudo-code} for details): \begin{myitemize} \item If none of the allocated transactions access data items in $D_T$, then we leave $T$ unallocated. \item If all of the data items in $D_T$ are allocated to a unique cluster $C$, then we allocate $T$ to $C$ as well and allocate all the other data items in $D_T$ to $C$. \item When data items in $D_T$ are allocated to more than one cluster, we allot $T$ to residuals $R$. \end{myitemize} Let the \emph{distance} between two transactions $T$ and $T'$, denoted $\eta(T, T')$, be $\frac{1}{2}$ the length of shortest path between them in $\mathcal{A}$. For example, distance between $T_1$ and $T_2$ in \figref{analysis}(a) is 1 due to $T_1 - w_1 - T_2$. Distance between $T$ and cluster $C$ is the shortest distance between any transaction in $C$ and $T$. At the end of first round, all transactions that are at a distance $1$ from initial seed clusters are allocated to one of $C_1, C_2, ..., C_k$ or $R$. If $\kappa$ is the maximum distance between two transactions in the same connected component, then repeating the above allocation round for $\kappa$ times will eventually allocates all transactions. However, we observe that in practice, $\kappa$ is close to $1$ for high contention workloads. Hence, in many cases we only need to run the above allocation mechanism once. Next, we handle the remaining transactions in $\mathcal{B}$ are left unallocated after the above process has taken place. To allocate them, we run a second round of allocation, but with a slight modification. Instead of skipping a transaction when $D_T$ is unallocated, we allot it to one of the $C_1, ... C_k$ clusters randomly. Transactions that were at a distance of $2$ from initial seed clusters are now at a distance of $1$ as new transactions have been allocated to them in the first round. So, some unallocated transactions will now have allocated data items. These are processed as in the first round: allocate to $C$ if it is the unique cluster for data items in $D_T$ and to $R$ if data items in $D_T$ are allocated to more than one cluster. At the end of the \textsc{allocate} stage, we have a set of clusters $\{C_1, ..., C_m\}$ (where $m \geq k$) and residual transactions $R$ such that all transactions in a cluster $C_i$ access data items only in $C_i$, and the transactions in $R$ access data items belonging to more than one of the $m$ clusters. \begin{algorithm} \SetKwProg{Fn}{Function}{}{end} \SetKwProg{Proc}{Procedure}{}{end} \SetKwFunction{Cluster}{Cluster} \SetKwFunction{AllocateStage}{AllocateStage} \SetKwFunction{AllocateTxns}{AllocateTxns} \SetKwFunction{AllocateSkippedTxns}{AllocateSkippedTxns} \SetKwFunction{MergeClusters}{MergeClusters} \Fn{\AllocateStage{$\mathcal{B}$}}{ \ForEach{$T \in B$} { \uIf{$\forall d \in D_T:$ d.Cluster = NULL} { skip\; } \uElseIf{$\forall d \in D_T:$ d.Cluster = NULL or unique $C$} { Add $T$ to $C$\; \ForEach{$d \in D_T$ and d.Cluster = NULL}{ d.Cluster = $C$\; } } \Else { Add $T$ to $R$ \; } } \ForEach{Unallocated $T \in B$} { \uIf{$\forall d \in D_T:$ d.Cluster = NULL} { Pick a random $C$ from $C_1, C_2, ..., C_k$\; Add $T$ to $C$\; \ForEach{$d \in D_T$ and d.Cluster = NULL}{ d.Cluster = $C$\; } } \uElseIf{$\forall d \in D_T:$ d.Cluster = NULL or unique $C$} { Add $T$ to $C$\; \ForEach{$d \in D_T$ and d.Cluster = NULL}{ d.Cluster = $C$\; } } \Else { Add $T$ to $R$ \; } } \Return $(C_1, ..., C_k, R)$\; } \caption{Pseudo-Code for the Allocate Stage} \alglabel{allocate-pseudo-code} \end{algorithm} In our TPC-C\xspace example, if the \textsc{spot} stage had resulted in $3$ base clusters one each for $w_1, w_2$ and $w_3-w_4$, then most transactions in $\mathcal{B}$ will be allocatted to one of the $3$ clusters in the \textsc{allocate} stage. A small number of transactions that are $w_1-w_3$ or $w_2-w_4$, however, will not be allocatted to either of these clusters and will be added to the residuals. If the \textsc{spot} stage produced $w_1, w_2, w_3$ and $w_4$ as base clusters, most of $w_1$ and $w_2$ transactions from $\mathcal{B}$ will be allocatted to its clusters. However, none of the $w_3-w_4$ transactions can be added to any of the clusters and hence will be added to the residual cluster. We further process the resulting clusters from this stage to reduce the size of the residual cluster. Our example does not execute the second round as all transactions are aready allocated during the first round. \subsection{Merge Stage} Depending on the nature of base clusters created in \textsc{spot} stage, the number of residual transactions that remain at the end of the \textsc{allocate} stage could be large. During \textsc{merge}, we merge some of these clusters to improve the quality of the clusters and to reduce the size of residual cluster. When two clusters $C_i$ and $C_j$ are merged to form a new cluster $C_k$, transactions in $R$ that access data items only from $C_i$ and $C_j$ can now be allocated to $C_k$ using the allocation criteria mentioned above. While merging reduces the number of residual transactions, excessive merging of clusters could result in forming one large cluster which reduces parallelism in \textsc{conflict-free}\xspace phase. Hence, we merge clusters until size of the residual cluster is smaller than the bound specified by the parameter $\alpha$, i.e. $|R| \leq \alpha |\mathcal{B}|$ using the scheme detailed in \algref{merge-pseudo-code}. $\alpha$ serves as a parameter that chooses between executing transactions on multiple cores with concurrency control (if $\alpha$ is small) versus on fewer cores but with no conflicts and without concurrency control (otherwise). Empirically, we found $\alpha = 0.2$ to be appropriate in our experiments. Let $N(C_i, C_j)$ denote the number of transactions in $R$ that access data items in $C_i$ and $C_j$. Note that the transactions that are accounted for in $N(C_i, C_j)$ can access data items from clusters other than $C_i$ and $C_j$ as well. If the two clusters $C_i$ and $C_j$ are separated, then all of the $N(C_i, C_j)$ transactions will be marked as residuals. So, we merge cluster pairs $C_i, C_j$ using the following criterion: \begin{equation*} N(C_i, C_j) > \alpha \times (|C_i| + |C_j| + N(C_i, C_j)) \end{equation*} Since, $|R| \leq \sum_{i \neq j} N(C_i, C_j)$, a merge scheme using the above criterion always results in the number of residuals being smaller than $\alpha |\mathcal{B}|$. Once all such clusters have been merged, transactions in the residual cluster are re-allocated to the new clusters when all data items accessed by a transaction belong one unique cluster. The resulting conflict-free clusters are then executed in parallel without any concurrency control, followed by the residuals with concurrency control applied as discussed in \secref{architecture}. \begin{algorithm} \SetKwProg{Fn}{Function}{}{end} \SetKwFunction{PivotStage}{PivotStage} \SetKwFunction{MergeStage}{MergeStage} \Fn{\MergeStage{$C_1, ..., C_k, R$}} { Clusters := $\{ C_1, C_2, ..., C_k \}$\; \ForEach{$C_i, C_j : N(C_i, C_j) \geq \alpha * (|C_i| + |C_j| + N(C_i, C_j))$} { Create new cluster $C$\; $C$ := $C_i \cup C_j$\; Remove $C_i, C_j$ from Clusters\; Add $C$ to Clusters\; \ForEach{$d:$ d.Cluster = $C_i$ or $C_j$} { d.Cluster = $C$\; } } \BlankLine \ForEach{$T \in R$} { \If{$\forall d \in D_T: d.Cluster = C$} { Add $T$ to $C$\; } } \Return{(Clusters, $R$)}\; } \caption{Pseudo-code for the Merge Stage} \alglabel{merge-pseudo-code} \end{algorithm} In our example, when the base clusters are $w_1, w_2, w_3-w_4$, the number of transactions that are allotted as residuals are small, and hence there is no merging of clusters needed. However, if the clusters are $w_1, w_2, w_3, w_4$, then size of the residual cluster is large and clusters $w_3$ and $w_4$ are merged. None of the other clusters are merged together as they do not satisfy the merge criterion. The final clusters are then $w_1, w_2$ and $w_3-w_4$ with a small amount of transactions ($w_1-w_3$ and $w_2-w_4$) in the residual cluster. In this example, our algorithm has essentially identified $3$ conflict-free clusters that can now executed without any concurrency control, where all transactions in these clusters access hot data items. \section{Discussion} \seclabel{discussion} In this section we discuss a few tradeoffs in the design of \textsc{Strife}\xspace. As discussed in~\secref{introduction}, \textsc{Strife}\xspace is inspired by empirical studies~\cite{oltp-looking-glass, dbx1000} that reported concurrency control to be a substantial overhead for transactional workloads with high contention. It is built on the insight to identify conflict-free clusters in workloads that can be executed in parallel without concurrency control. The main challenge in realizing this insight is to partition transactions into conflict-free clusters (as discussed in~\secref{architecture}) fast enough that does not outweigh the benefits of concurrency control free parallel execution. Most traditional approaches to graph partitioning (as discussed in~\secref{related-work}) do not meet this criterion. Hence, we designed a new heuristic that exploits the amount of data contention in each workload. Following are some pros and cons of our design choices: \begin{myitemize} \item Randomly sampling transactions (\secref{spot}) allows us to quickly spot contentious items in the workload to form initial seed clusters. Most other techniques require expensive tracking of access patterns for each data item. \item Another key observation that is specific to high contention workloads is that diameter of the access graph is often small (close to $1$). We characterize this in~\ssecref{contention}. This allows us to optimize the \textsc{allocate}\xspace phase by only needing to run atmost 2 rounds of allocation. \item On the contrary, for low contention workloads, the diameter of the access graph tends to be greater than 1. Hence we either need to run multiple rounds of \textsc{allocate}\xspace, or assign transactions randomly to the initial seed clusters, as detailed in \ssecref{allocate}. The former increases the amount time spent in \textsc{analysis}\xspace, while the latter results in sub-optimal clusters. We currently choose the latter, although the resulting throughput is still comparable to other locking-based protocols, as shown in~\figref{ycsb-contention-theta-main}. \item \textsc{merge}\xspace step uses an additional parameter $\alpha$ that determines which clusters to merge. Merging clusters results in two competing effects: (1) it reduces parallelism in the fast \textsc{conflict-free}\xspace phase; but (2) increases the number of transactions that are executed without concurrency control. A high value of $\alpha$ reduces the overall benefit of using \textsc{Strife}\xspace, while a small value of $\alpha$ can force merging of clusters and reduce parallelism. So, picking the right $\alpha$ is important to achieve good performance. \item The number of conflict-free clusters produced for a batch is an indicator of reasonable trade-off between performance and core utilization. This quantity can be used to provision the amount of resources for the OLTP component in hybrid transactional/analytical processing (HTAP)~\cite{htap} databases. \end{myitemize} \section{Conclusion} \seclabel{conclusion} We presented \textsc{Strife}\xspace, a transaction processing system for high-contention workloads. \textsc{Strife}\xspace is designed based on the insight that portions of a transactional workload can be executed as conflict-free clusters without any concurrency control, even when the workload has high data contention. We achieved this by developing a low-overhead partitioning algorithm that divides a batch of transacions into a set of conflict-free clusters and residuals. The clusters are executed on multiple cores without any concurrency control, followed by the residuals executed with concurrency control. Our experiments have showed that \textsc{Strife}\xspace can achieve substantial performance improvement, with $2\times$ throughput increase compared to standard locking-based protocols on TPC-C\xspace and YCSB workloads. \section{Overview} \seclabel{architecture} In \textsc{Strife}\xspace, transactions are scheduled on cores based on their data-access pattern. \textsc{Strife}\xspace collects and executes transactions in batches, and assumes that read-write set of a transaction can be obtained statically. In scenarios where that is not possible, one can use a two-stage execution strategy similar to deterministic databases~\cite{calvin}: first dynamically obtaining the complete read-write set using a reconnaissance query, followed by a conditional execution of the transaction. \textsc{Strife}\xspace employs a \emph{micro-batch architecture} to execute transactions. Incoming transactions are grouped together into batches, partitioned into clusters and residuals, and scheduled to be executed on multiple cores. Micro-batching allows \textsc{Strife}\xspace to analyze conflicting data accesses and utilize them to intelligently partition the workload. \begin{figure} \centering \includegraphics[width=0.75\linewidth]{images/architecture} \caption{Execution Scheme of \textsc{Strife}\xspace on $4$ cores} \figlabel{architecture} \end{figure} The execution scheme of \textsc{Strife}\xspace is shown in \figref{architecture}. A batch of transactions is executed in three phases: \textsc{analysis}\xspace, \textsc{conflict-free}\xspace and \textsc{residual}\xspace phase. First, the batch of transactions is analyzed and partitioned into a number of \emph{conflict-free} clusters and a small \emph{residual}. Each conflict-free cluster is then executed without any concurrency control in parallel on all cores in the \textsc{conflict-free}\xspace phase. After all clusters have finished execution, the residual transactions are executed on multiple cores with conventional concurrency control.\footnote{As mentioned in~\secref{introduction}, the residuals can be executed serially on a single core as well, although our experiments have shown that executing using multiple cores with concurrency control is a better strategy.} Once a batch is completed, \textsc{Strife}\xspace repeats by analyzing the next batch. We next give an overview of each of the three phases using an example workload. \subsection{\textsc{analysis}\xspace phase} \begin{figure} \centering \includegraphics[width=0.9\linewidth]{images/access-graph} \caption{Access Graph of a TPC-C\xspace transactions} \figlabel{access-graph} \end{figure} \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{images/outliers} \end{subfigure} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{images/optimal-solution} \end{subfigure} \caption{(a) Access Graph of TPC-C\xspace transactions (b) Optimal solutions for partitioning schemes} \figlabel{analysis} \end{figure*} The goal of the \textsc{analysis}\xspace phase is to partition the batch of transactions into clusters such that any two transactions from two different clusters are conflict-free. We explain the details next. To partition a batch of transactions, we first represent them using a {\em data access graph}. A data access graph is an undirected bipartite graph $\mathcal{A} = (\mathcal{B} \cup \mathcal{O}, \mathcal{E})$, where $\mathcal{B}$ is the set of transactions in the batch, $\mathcal{O}$ is the set of all data items (e.g., tuples or tables) accessed by transactions in $\mathcal{B}$, and the edges $\mathcal{E}$ contain all pairs $(T,d)$ where transaction $T$ accesses data item $d$. Two transactions $T, T'$ are said to be \emph{in conflict} if they access a common data item and at least one of them is a write. For example, \figref{access-graph} depicts the access graph of a batch of transactions from TPC-C\xspace benchmark. A \texttt{new-order} transaction simulates a customer order for approximately ten different items. The example in~\figref{access-graph} contains three different warehouses $w_1, w_2$ and $w_3$. Each warehouse maintains stock for a number of different items in the catalog. As shown in the figure, transactions $\set{T_1, \ldots, T_{12}}$ access data items from different tables in the TPC-C\xspace database. $T_1$, for example, writes to the \texttt{warehouse} tuple $w_1$ and a few other tuples from other tables such as \texttt{district} and \texttt{stock} that belong to $w_1$ as well. Transactions $T_1, T_2$ are in conflict because they both access $w_1$; whereas transactions $T_1, T_5$ are not. The batch shown in \figref{access-graph}, is said to be \emph{partitionable} as groups of transactions access disjoint sets of data items. It can be partitioned into three clusters that do not conflict with each other, and the clusters can be executed in parallel with each one scheduled on a different core. However, real workloads contain \emph{outliers} that access data items from multiple clusters. Consider the example shown in~\figref{analysis}(a), again of TPC-C\xspace {\tt new-order} transactions. Here, transactions $T_4$ and $T_8$ order items from multiple warehouses, resulting in a conflict with $T_2$ and $T_{10}$ respectively. There are two ways to execute $T_4$ and $T_8$: either merge the two clusters that $T_2$ and $T_{10}$ belong to and assign the resulting cluster to be executed on a single core, or move $T_4$ and $T_8$ into a separate cluster to be executed afterwards. As the former might result in a single large cluster that takes significant amount of time to execute, we take the latter approach where we consider $T_4$ and $T_8$ as residuals. This results in the remaining batch partitioned into three conflict-free clusters along with the residuals, as shown in \figref{analysis}(b). A \emph{clustering} is a partition of transactions $\mathcal{B}$ into $k+1$ sets $\set{C_1, C_2, \ldots, C_k, R}$ such that, for any $i \neq j$ and any transaction $T \in C_i, T' \in C_j$, $T$, $T'$ are not in conflict. Notice that no requirement is placed on the residuals $R$. The data access graph does not distinguish between read and write access, because \textsc{Strife}\xspace considers only data items for which there is at least one write by a transaction. Consequently, if any two transactions that access the same common item $d$ are placed in two distinct clusters, then at least one of them will have a write conflict with some other transaction, hence we do not need to consider the type of access to the data items. During the \textsc{conflict-free}\xspace phase, each cluster $C_i$ is executed on one dedicated core without any concurrency control between cores. After all clusters have finished, then, during the \textsc{residual}\xspace phase, the residual transactions are executed, still concurrently, but with conventional concurrency control applied. Ideally, we want $k$ to be at least as large as the number of cores to exploit parallelism at maximum during the \textsc{conflict-free}\xspace phase, and we want $R$ to be empty or as small as possible to reduce the cost of the \textsc{residual}\xspace phase. To get an intuition about the tradeoffs, we describe two naive clusterings. The first is the {\em fallback clustering}, where we place all transactions in $R$ and set $k=0$; this corresponds to running the entire batch using a conventional concurrency control mechanism. The second is the {\em sequential clustering}, where we place all transactions in $C_1$, and set $k=1$ and $R=\emptyset$; this corresponds to executing all transactions sequentially, on a single core. As one can imagine, neither of these would result in any significant performance improvement. Hence in practice we constrain $k$ to be at least as large as the number of cores, and $R$ to be no larger than some small fraction $\alpha$ of the transaction batch. In practice, a good clustering exists for most transaction workloads, except for the extreme cases. In one extreme, when all transactions in the batch access a very small number of highly contentious data items, then no good clustering exists besides fallback and sequential, and our system simply resorts to fallback clustering. Once the data contention decreases, i.e., the number of contentious data items $k$ increases to at least the number of cores, then a good clustering exists, and it centers around the contentious items. When the contention further decreases to the other extreme where all transactions access different data items, then any partitioning of the transactions into $k$ sets of roughly equal size would be the best clustering. Thus, we expect good clusterings to exist in all but most extreme workloads, and we validate this in ~\secref{evaluation}. The challenge is to find such a clustering very efficiently; we describe our clustering algorithm in~\secref{algorithm}. \subsection{\textsc{conflict-free}\xspace Phase} After partitioning the incoming workload into conflict-free clusters, \textsc{Strife}\xspace then schedules them to be executed in parallel on multiple \emph{execution threads}. Each execution thread obtains a conflict-free cluster and executes it to completion before moving to the next. Transactions belonging to the same cluster are executed serially one after another in the same execution thread. Since the scheduling algorithm guarantees that there are no conflicts across transactions from different clusters, there is no need for concurrency control in this phase. As noted earlier, concurrency control is a significant overhead in transactional systems, especially for worloads that have frequent access to highly contended data. Hence removing it will significantly improve performance. The degree of parallelism in this phase is determined by number of conflict-free clusters. Higher number of clusters result in them being executed in parallel, thereby reducing total time to execute all transactions in conflict-free clusters. Once an execution thread has completed executing a cluster, it tries to obtain the next one. If there is none, it waits for all other threads that are processing conflict-free clusters before moving to the next phase. This is because residual transactions could conflict with transactions that are currently being executed by other \textsc{conflict-free}\xspace phase threads without concurrency control. Hence, a skew in cluster sizes can cause a reduction in parallelism as threads that complete early cannot advance to next phase, although as our experiments show in~\secref{evaluation}, that is usually not the case. \subsection{\textsc{residual}\xspace phase} As we saw in our example from~\figref{analysis}(a), \textsc{Strife}\xspace identifies a few transactions to be outliers and considers them as residuals. These transactions conflict with transactions from more than one conflict-free cluster. We execute these residual transactions concurrently on all execution threads, but apply some form of concurrency control. Unlike the \textsc{conflict-free}\xspace phase where the we guarantee conflict-freedom, transactions executed in the \textsc{residual}\xspace phase require concurrency control to ensure serializability. We could use any serializable concurrency control protocol in this phase. In \textsc{Strife}\xspace, we use 2PL with \texttt{NO-WAIT} deadlock prevention policy as it has been shown to be highly scalable~\cite{dbx1000} with much less overhead compared to other protocols. Under this policy, when a transaction is aborted due to the concurrency control scheme, the execution thread retries it until successful commit or logical abort. Once all the residual transactions have been executed, the same process is repeated with \textsc{Strife}\xspace processes the next batch by running the \textsc{analysis}\xspace phase. \subsection{Implementation} We have implemented a prototype of \textsc{Strife}\xspace that schedules transactions based on the algorithm described above. \textsc{Strife}\xspace, at its core, is a multi-threaded transaction manager that interacts with the storage layer of the database using the standard \texttt{get-put} interface. A table is implemented as a collection of in-memory pages that contain sequentially organized records. Some tables are indexed using a hashmap that maps primary keys to records. We implement the index using libcuckoo ~\cite{libcuckoo} library, a thread-safe fast concurrent hashmap. Records contain additional meta-data required to do scheduling and concurrency control. We chose to co-locate this with the record to avoid overheads due to multiple hash lookups and focus primarily on concurrency control. As discussed earlier, \textsc{Strife}\xspace groups transactions together into batches and process them in a three phases. \paragraph{Partitioning} We prioritize minimizing the cost of \textsc{analysis}\xspace phase over the optimality of our scheduling algorithm. Threads synchronize after each of the three stages of the algorithm. First, the \textsc{spot}\xspace stage is executed using a single thread, followed by \textsc{allocate}\xspace in parallel. The batch is partitioned into equal chunks and a thread allocates transactions in its chunk to the base clusters created in \textsc{spot}\xspace phase. Each record has a \texttt{clusterId} as part of its meta-data and is updated atomically using an atomic \emph{compare-and-swap} operation. A transaction is allotted to a cluster only when all atomic operations on a transaction succeeds. This is followed by the \textsc{merge}\xspace stage that is carried out by a single thread. The cluster pair counts used in \textsc{merge}\xspace stage are gathered during the \textsc{allocate}\xspace phase using thread-local data structures and finally merged to obtain the global counts. Each cluster has a root, which initially points to itself. When merging two clusters, we modify the root of one cluster to point to another. To obtain the cluster to which a record or transaction belongs, we trace back to the root. Finally, similar to the \textsc{allocate}\xspace phase, the residual transactions are re-allocated to clusters in parallel. \paragraph{Execution} The analysis phase produces a set of conflict-free clusters and the residuals. The conflict-free clusters are stored in a multi-producer-multi-consumer concurrent queue, called the \emph{worklist}. Each thread dequeues a cluster from the worklist, executes it completely without any concurrency control and obtains the next. Threads wait until all other threads have completed executing the conflict-free clusters. Once the conflict-free clusters are executed, threads then execute the residual transactions. The residuals are stored in a shared concurrent queue among the threads. Threads dequeue a transaction, and execute it using the two-phase locking concurrency control under the \texttt{NoWait} policy (i.e., immediately aborts the transaction if it failes to grab a lock). \textsc{Strife}\xspace moves to the \textsc{analysis}\xspace phase of next batch once the \textsc{residual}\xspace phase is completed. Technically, the threads can start analyzing the next batch while \textsc{residual}\xspace phase of previous batch is in-progress. However, we did not implement this optimization to simplify the analysis and interpretability of results. \subsection{Varying number of hot records} \sseclabel{hot-records} \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/tpcc-contention-main.pdf} \figlabel{tpcc-contention-main} \end{subfigure} \hspace{0.5cm} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/tpcc-contention-pipeline.pdf} \figlabel{tpcc-contention-pipeline} \end{subfigure} \caption{Performance of TPC-C\xspace on $15$ cores: (a)Throughput vs. Number of Warehouses (b) Runtime Breakdown} \figlabel{tpcc-contention} \end{figure*} \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/ycsb-contention-main.pdf} \figlabel{ycsb-contention-main} \end{subfigure} \hspace{0.5cm} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/ycsb-contention-pipeline.pdf} \figlabel{ycsb-contention-pipeline} \end{subfigure} \caption{Performance of YCSB on $15$ cores: (a)Throughput vs. Number of Warehouses (b) Runtime Breakdown} \figlabel{ycsb-contention} \end{figure*} We first analyze the performance of \textsc{Strife}\xspace and compare it with our baseline concurrency control protocols under high contention by varying number of hot records. Contention in TPC-C\xspace workload can be controlled by varying the number of records in the warehouse table as all transactions access (i.e., read or write) the warehouse tuple. \figref{tpcc-contention}(a) shows throughput in number of transactions committed per second vs. number of warehouses. As the number of warehouses increases from left to right, contention in the workload \emph{decreases} from left to right. Payment transaction updates two contentious records: district and warehouse, while a new order reads warehouse and items tuples and updates district, customer, and other low contention items from stock table. In our experimental setup, we retry a transaction if aborts due to the concurrency control. The results of the experiment are shown in~\figref{tpcc-contention}(a) (for TPC-C\xspace) and~\figref{ycsb-contention}(a) (for YCSB) respectively. The results show that \textsc{Strife}\xspace significantly outperforms all other protocols by up to $2\times$ in terms of throughput. When contention decreases, any concurrency control protocol is expected to improve in performance. Specifically, the number of warehouses in the workload determines the number of conflict-free clusters produced by the \textsc{analysis}\xspace phase. When the number of warehouses (in TPC-C\xspace) or partitions (in YCSB) is greater than the number of available cores (15 in our experiments), the conflict-free clusters are executed in parallel without any concurrency control. However, other protocols are unable to exploit this parallelism as well as \textsc{Strife}\xspace because the workload still have significant number of conflicts within each warehouse. We now explain the results in detail. The LockOrdered protocol is based on ordered acquisition of logical locks on records. A thread spin-waits until a requested lock is granted. When the number of warehouses is $2$, most threads are blocked except for the two that current have ownership of locks on the warehouses. So, the performance of LockOrdered is poor when the number of warehouses is small. However, as we increase the warehouse from $2$ to $15$, the chance that a thread $T$ is blocked decreases by a factor of $\frac{2}{15}$, so the LockOrdered protocol is seen to recover the performance outperforming other 2PL variants. On the other hand, \textsc{Strife}\xspace eliminates the locking overhead, and thus results in much better performance. NoWait and WaitDie protocols use aborts to avoid deadlocks. The advantage of NoWait over WaitDie is that the former has very little overhead as it only needs a single record-level mutex for concurrency control. Hence aborts are cheap and even repeated retries are not very expensive. The WaitDie protocol incurs additional overhead in the form of waiting queue for each record. Another reason for the poor performance of WaitDie is that when a transaction with timestamp $t$ gets aborted as it is younger than the current owner, it is also younger than the waiters and hence during retry, it is highly likely that it aborts again. We observe the abort rate of WaitDie is more than $50$\% in our experiments. The WaitsForGraph is more conservative regarding aborting a transaction. It aborts a transaction only when there is a cycle in the global waits-for graph. Even though the graph is maintained in a scalable thread-local fashion, deadlock detection acquires locks on the data structures of other threads and hence serves as a concurrency bottleneck. Note that in TPC-C\xspace the actual occurrence of deadlocks is rare and cycle detection is purely an overhead. \figref{tpcc-contention}(b) depicts the average time taken by each phase in \textsc{Strife}\xspace for a batch of size $10$K transactions. The cost of analysis is almost constant as we vary the number of partitions. However, the residual phase time and hence the number of residual transactions drops steadily. This is because when a new order transaction $T$ belonging to warehouse $w$ orders an item from a remote warehouse $w'$, it accesses the corresponding stock $s$. It is considered an \emph{outlier} access only if there also exists a local transaction to $w'$ that accesses the same $s$. Otherwise $s$ will be part of $T$'s cluster and considered to be conflict-free. So, when the number of warehouses are small, there is a high probability that this happens and hence more residual transactions. We also observe that the time for \textsc{conflict-free}\xspace phase decreases steadily as we increase the number of partitions. This further validates that \textsc{Strife}\xspace exploits parallelism even in the high-contention workload. Next, we perform a similar experiment on the YCSB workload by varying the number of partitions. We use a zipfian constant of $0.9$ to produce a highly contended workload. The main difference between TPC-C\xspace and YCSB workload is that all transactions access one of the highly contended warehouse tuple in TPC-C\xspace, thereby reducing the diameter of the access graph of the batch to $1$. Whereas in YCSB, transactions belonging to a partition $p$ need not all access a single contentious data. The zipfian distribution creates a set of hot items in each partition with varying degrees of ``hotness". Finally, \figref{ycsb-contention}(a) shows the comparison of \textsc{Strife}\xspace with the baselines. The observations are largely similar to TPC-C\xspace. As the number of partitions increases, the total amount of contention in the batch decreases. While this improves the performance of all protocols, \textsc{Strife}\xspace still outperforms others with up to $2\times$ improvement in throughput, despite the fact that unlike TPC-C\xspace, almost $50$\% of time is spent in \textsc{analysis}\xspace for the $15$ partitions. The \textsc{conflict-free}\xspace phase steadily decreases as the batch can be executed in higher degrees of parallelism. We also note that even though the batch is completely partitionable into $15$ clusters by design, \textsc{analysis}\xspace phase produces more than $15$ clusters resulting in some single partition transactions being labeled as residuals. \subsection{Scalability} \sseclabel{scalability} In this section, we analyze the scalability of \textsc{Strife}\xspace and baselines on a high contention workload. We set the number of warehouses to be $4$ in TPC-C\xspace and vary number of cores. \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/tpcc-scalability-main.pdf} \figlabel{tpcc-scalability-main} \end{subfigure} \hspace{0.5cm} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/tpcc-scalability-pipeline.pdf} \figlabel{tpcc-scalability-pipeline} \end{subfigure} \caption{Scalability of TPC-C\xspace workload with $4$ warehouses: (a) Throughput vs. Cores (b) Runtime Breakdown} \figlabel{tpcc-scalability} \end{figure*} \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/ycsb-scalability-main.pdf} \figlabel{ycsb-scalability-main} \end{subfigure} \hspace{.5cm} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/ycsb-scalability-pipeline.pdf} \figlabel{ycsb-scalability-pipeline} \end{subfigure} \caption{Scalability of YCSB workload with $4$ partitions: (a) Throughput vs. Cores (b) Runtime Breakdown} \figlabel{ycsb-scalability} \end{figure*} The results are shown in \figref{tpcc-scalability}(a). When number of cores is $2$, performance of \textsc{Strife}\xspace and other protocols are almost similar. \textsc{Strife}\xspace clusters the batch into $4$ conflict-free clusters and residuals, which are then executed concurrently on $2$ cores. When number of cores is increased to $4$, throughput of \textsc{Strife}\xspace doubles as all the $4$ clusters can be executed simulatenously. Beyond $4$ cores, the number of conflict-free clusters produced is still $4$ and so there is no significant change in throughput. But since the \textsc{analysis}\xspace phase is executed in parallel, the time spent there decreases, and this improves throughput as we scale up the number of cores. As number of cores increases, with the same degree of contention (i.e., with $4$ warehouses) other concurrency protocols improve only marginally but are still much poorer than \textsc{Strife}\xspace. Increasing number of cores in the LockOrdered protocol, for example, results in additional threads unnecessarily spin-waiting on locks. Earlier work has revealed that for very high degrees of parallelism (1024 cores) this can lead to lock thrashing~\cite{dbx1000} and can be more detrimental. The WaitsForGraph protocol performs poorly in high contention as the number of transactions added to the waits-for-graph increases as the number of cores increase. Cost of cycle detection increases as it involves acquiring locks on the thread-local state of other threads. In NoWait and WaitDie, on the other hand, more cores result in increased abort rates because the probability that two conflicting transactions access same warehouse concurrently increases. For YCSB, we set the number of partitions to be $4$. The keys in the transactions are generated using a zipfian distribution with a $\theta$ value of $0.9$. For $\theta=0.9$, transactions access a set of hot items. \figref{ycsb-scalability}(a) depicts the scalability of our system and the 2PL variants on YCSB workload. Throughput doubles when increasing the cores from $2$ to $4$ due to similar reasons as TPC-C\xspace. However, beyond $4$ cores improvement in \textsc{Strife}\xspace performance is mainly attributed to the parallel execution of \textsc{analysis}\xspace phase. \figref{tpcc-scalability}(b) and \figref{ycsb-scalability}(b) show the runtime breakdown for TPC-C\xspace and YCSB workload respectively. In TPC-C\xspace, around $30$\% of time is spent on executing residuals with NoWait concurrency control. This is due to the remote payments are orders specified in the TPC-C\xspace standards specification. Analysis phase in YCSB is more expensive due to the nature of contention. We perform a more detailed analysis in the following section. \subsection{Factor Analysis} \sseclabel{factor-analysis} \begin{figure*} \centering \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/tpcc-factor-analysis.pdf} \figlabel{tpcc-factor-analysis} \end{subfigure} \hspace{0.5cm} \begin{subfigure}[t]{0.45\textwidth} \includegraphics[width=\linewidth]{plots/ycsb-factor-analysis.pdf} \figlabel{ycsb-factor-analysis} \end{subfigure} \caption{Analysis Phase Breakdown (a) TPC-C\xspace with $4$ warehouses (b) YCSB with $4$ partitions} \figlabel{factor-analysis} \end{figure*} We now analyze the cost of various stages in the \textsc{analysis}\xspace phase. The \textsc{analysis}\xspace phase happens in $4$ stages: \textsc{pre-processing}\xspace, \textsc{spot}\xspace, \textsc{allocate}\xspace and \textsc{merge}\xspace. \figref{factor-analysis}(a) shows the breakdown of cost of various the stages during analysis of each batch of $100$K transactions from the TPC-C\xspace workload with a $50$:$50$ mixture of new-order and payment transactions. With $2$ cores, most of the time (around $80$\%) is spent in allocating transactions to seed clusters and $20$\% on the pre-processing stage. As we increase the degree of parallelism, the time taken by the \textsc{allocate}\xspace and \textsc{pre-processing}\xspace stages drops steadily. Since we sample only a few transactions ($\approx 150$ for our experiments), the cost of \textsc{spot}\xspace stage is almost negligible and hence overlaps the cost of \textsc{merge}\xspace in the figure. As our TPC-C\xspace transactions can be clustered based on the warehouse that they access, the \textsc{spot}\xspace stage is able to identify seed clusters that correspond to warehouses easily. We set the value of $\alpha$ (that determines ratio of size of residual cluster) to be $0.2$ in all our experiments. Based on the seed clusters, \textsc{Strife}\xspace is able to allocate all transactions to a cluster corresponding to its warehouse cluster when there are no remote accesses and to the residual cluster when there are remote accesses. The main observation here is that \textsc{Strife}\xspace does not enter the \textsc{merge}\xspace stage as the number of transactions in \textsc{residual}\xspace cluster is already within the bounds specified by $\alpha$. Most of the time in \textsc{analysis}\xspace phase is spent in scanning through the read-write sets of transactions to allot them to a cluster in the \textsc{allocate}\xspace stage. The reduction in \textsc{allocate}\xspace and \textsc{pre-processing}\xspace stage cost is reflected marginally in the overall performance, as shown in \figref{tpcc-scalability}(a). The \textsc{analysis}\xspace phase breakdown for YCSB workload is shown in \figref{factor-analysis}(b). YCSB is different from TPC-C\xspace in that it has a set of hot items belonging to each partition. Let $d_1$ and $d_2$ be two such hot items: if $d_1$ and $d_2$ are selected into two different clusters in the \textsc{spot}\xspace stage, then all data items co-accessed with $d_1$ get allocatted separately and those with $d_2$ separately. Essentially it creates a partition within the YCSB partition rendering most transactions as residual in the \textsc{allocate}\xspace stage. Since the residual cluster size is large, we spend more time merging them. \subsection{Impact of Contention} \sseclabel{contention} \begin{figure} \centering \includegraphics[width=0.9\linewidth]{plots/ycsb-contention-theta.pdf} \caption{Contention Analysis on YCSB ($15$ partitions)} \figlabel{ycsb-contention-theta-main} \end{figure} Finally, we compare the performance of \textsc{Strife}\xspace with other protocols by varying the contention parameter $\theta$ of the YCSB\footnote{A similar experiment is not possible for the TPC-C\xspace workload as every new-order and payment transaction accesses the warehouse tuple, making it highly contended within the warehouse.} workload. Even though \textsc{Strife}\xspace is not designed for low-contention workloads, we present this analysis to empirically understand the behavior of our partitioning algorithm. The zipfian constant $\theta$ determines the frequency of access to popular items. For a small value of $\theta$ most transactions access different items leading to fewer conflicts in the workload. In the low contention case, most concurrency control protocols perform well. Especially, we see that NoWait and WaitDie protocols perform about $50$\% and LockOrdered about $20$\% better than \textsc{Strife}\xspace as shown in ~\figref{ycsb-contention-theta-main}. But, when we increase the value of theta, the number of conflicts in the workload increases as many transactions access a few hot items. In this high contention case, \textsc{Strife}\xspace outperforms other protocols by $5$x. Compared to the overheads of executing such a workload with concurrency control, the \textsc{analysis}\xspace quickly reveals the underlying structure of the batch which is used to schedule conflict-free clusters in parallel without any concurrency control.
{'timestamp': '2018-10-05T02:04:29', 'yymm': '1810', 'arxiv_id': '1810.01997', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01997'}
arxiv
\section{Introduction} Recent years have seen an outpouring of research on fairness and bias in machine learning models. This is not surprising, as fairness is a complex and multi-faceted concept that depends on context and culture. Narayanan described at least 21 mathematical definitions of fairness from the literature~\cite{Narayanan2018}. These are not just theoretical differences in how to measure fairness; different definitions produce entirely different outcomes. For example, ProPublica and Northpointe had a public debate on an important social justice issue (recidivism prediction) that was fundamentally about what is the right fairness metric \citep{Larson2016, Dieterich2016,Larson2016a}. Furthermore, researchers have shown that it is impossible to satisfy all definitions of fairness at the same time \cite{kleinberg2017fairness}. Thus, although fairness research is a very active field, clarity on which bias metrics and bias mitigation strategies are best is yet to be achieved~\cite{Freidler2018}. In addition to the multitude of fairness definitions, different bias handling algorithms address different parts of the model life-cycle, and understanding each research contribution, how, when and why to use it is challenging even for experts in algorithmic fairness. As a result, general public, fairness scientific community and AI practitioners need clarity on how to proceed. Currently the burden is on ML and AI developers, as they need to deal with questions such as ``Should the data be debiased?'', ``Should we create new classifiers that learn unbiased models?'', and ``Is it better to correct predictions from the model?'' To address these issues we have created AI Fairness 360 (AIF360), an extensible open source toolkit for detecting, understanding, and mitigating algorithmic biases. The goals of AIF360 are to promote a deeper understanding of fairness metrics and mitigation techniques; to enable an open common platform for fairness researchers and industry practitioners to share and benchmark their algorithms; and to help facilitate the transition of fairness research algorithms to use in an industrial setting. AIF360 will make it easier for developers and practitioners to understand bias metrics and mitigation and to foster further contributions and information sharing. To help increase the likelihood that AIF360 will develop into a flourishing open source community, we have designed the system to be extensible, adopted software engineering best practices to maintain code quality, and invested significantly in documentation, demos, and other artifacts. The initial AIF360 Python package implements techniques from 8 published papers from the broader algorithm fairness community. This includes over 71 bias detection metrics, 9 bias mitigation algorithms, and a unique extensible metric explanations facility to help consumers of the system understand the meaning of bias detection results. These techniques can all be called in a standard way, similar to scikit-learn's fit/transform/predict paradigm. In addition, there are several realistic tutorial examples and notebooks showing salient features for industry use that can be quickly adapted by practitioners. AIF360 is the first system to bring together in one open source toolkit: bias metrics, bias mitigation algorithms, bias metric explanations, and industrial usability. By integrating these aspects, AIF360 can enable stronger collaboration between AI fairness researchers and practitioners, helping to translate our collective research results to practicing data scientists, data engineers, and developers deploying solutions in a variety of industries. The contributions of this paper are \begin{itemize} \item an extensible architecture that incorporates dataset representations and algorithms for bias detection, bias mitigation, and bias metric explainability \item an empirical evaluation that demonstrates how AIF360 can be used for scientific comparisons of bias metrics and mitigation algorithms \item the design of an interactive web experience to introduce users to bias detection and mitigation techniques \end{itemize} This paper is organized as follows. In Section \ref{sec:terminology}, we introduce the basic terminology of bias detection and mitigation. In Section \ref{sec:relatedworks}, we review prior art and other open source libraries and contributions in this area. The overall architecture of the toolkit is outlined in Section \ref{sec:architecture}, while Sections \ref{sec:datasetclass}, \ref{sec:metricsclass}, \ref{sec:explainerclass}, and \ref{sec:algorithmsclass} present details of the underlying dataset, metrics, explainer, and algorithms base classes and abstractions, respectively. In Section \ref{sec:testing}, we review our testing protocols and test suite for maintaining quality code. In Section \ref{sec:eval_algs}, we discuss algorithm evaluation in bias checking and mitigation. In Section \ref{sec:webapp}, we describe the design of the front-end interactive experience, and the design of the back-end service. Concluding remarks and next steps are provided in Section \ref{sec:discussion}. \section{Terminology} \label{sec:terminology} In this section, we briefly define specialized terminology from the field of fairness in machine learning. A \emph{favorable label} is a label whose value corresponds to an outcome that provides an advantage to the recipient. Examples are receiving a loan, being hired for a job, and not being arrested. A \emph{protected attribute} is an attribute that partitions a population into groups that have parity in terms of benefit received. Examples include race, gender, caste, and religion. Protected attributes are not universal, but are application specific. A \emph{privileged} value of a protected attribute indicates a group that has historically been at a systematic advantage. \emph{Group fairness} is the goal of groups defined by protected attributes receiving similar treatments or outcomes. \emph{Individual fairness} is the goal of similar individuals receiving similar treatments or outcomes. \emph{Bias} is a systematic error. In the context of fairness, we are concerned with unwanted bias that places privileged groups at a systematic advantage and unprivileged groups at a systematic disadvantage. A \emph{fairness metric} is a quantification of unwanted bias in training data or models. A \emph{bias mitigation algorithm} is a procedure for reducing unwanted bias in training data or models. \section{Related Work} \label{sec:relatedworks} Several open source libraries have been developed in recent years to provide various levels of functionality in learning fair AI models. Many of these deal only with bias detection, and provide no techniques for mitigating such bias. Fairness Measures \cite{ Zehlike2017}, for example, provides several fairness metrics, including difference of means, disparate impact, and odds ratio. A set of datasets is also provided, though some datasets are not in the public domain and need explicit permission from the owners to access/use the data. Similarly, FairML \cite{ Adebayo2016} provides an auditing tool for predictive models by quantifying the relative effects of various inputs on a model’s predictions. This, in turn, can be used to assess the model’s fairness. FairTest \cite{Tramer2017}, on the other hand, approaches the task of detecting biases in a dataset by checking for associations between predicted labels and protected attributes. The methodology also provides a way to identify regions of the input space where an algorithm might incur unusually high errors. This toolkit also includes a rich catalog of datasets. Aequitas \cite{Aequitas2018} is another auditing toolkit for data scientists as well as policy makers; it has a Python library as well as an associated web site where data can be uploaded for bias analysis. It offers several fairness metrics, including demographic or statistical parity and disparate impact, along with a "fairness tree" to help users identify the correct metric to use for their particular situation. Aequitas's license does not allow commercial use. Finally, Themis \cite{Galhotra2017} is an open source bias toolbox that automatically generates test suites to measure discrimination in decisions made by a predictive system. A handful of toolkits address both bias detection as well as bias mitigation. Themis-ML \cite{Bantilan2018} is one such repository that provides a few fairness metrics, such as mean difference, as well as some bias mitigation algorithms, such as relabeling \cite{KamiranCalders2012}, additive counterfactually fair estimator \cite{Kusner2017}, and reject option classification \cite{Kamiran2012}. The repository contains a subset of the methods described in the paper. Fairness Comparison \cite{Freidler2018} is one of the more extensive libraries. It includes several bias detection metrics as well as bias mitigation methods, including disparate impact remover \cite{FeldmanFMSV2015}, prejudice remover \cite{kamishima2012fairness}, and two-Naive Bayes \cite{Calders2010}. Written primarily as a test-bed to allow different bias metrics and algorithms to be compared in a consistent way, it also allows the addition of additional algorithms and datasets. Our work on AIF360 aims to unify these efforts and bring together in one open source toolkit a comprehensive set of bias metrics, bias mitigation algorithms, bias metric explanations, and industrial usability. Another contribution of this work is a rigorous architectural design focused on extensibility, usability, explainability, and ease of benchmarking that goes beyond the existing work. We outline these design aspects in more details in the following sections. \section{Overarching Paradigm and Architecture} \label{sec:architecture} \begin{figure*} \centering \includegraphics[width=\linewidth]{sysml_pipeline} \vspace*{-1cm} \caption{The fairness pipeline. An example instantiation of this generic pipeline consists of loading data into a dataset object, transforming it into a fairer dataset using a fair pre-processing algorithm, learning a classifier from this transformed dataset, and obtaining predictions from this classifier. Metrics can be calculated on the original, transformed, and predicted datasets as well as between the transformed and predicted datasets. Many other instantiations are also possible.} \label{fig:pipeline} \end{figure*} AIF360 is designed as an end-to-end workflow with two goals: (a) ease of use and (b) extensibility. Users should be able to go from raw data to a fair model as easily as possible, while comprehending the intermediate results. Researchers should be able to contribute new functionality with minimal effort. Figure \ref{fig:pipeline} shows our generic pipeline for bias mitigation. Every output in this process (rectangles in the figure) is a new dataset that shares, at least, the same protected attributes as other datasets in the pipeline. Every transition is a transformation that may modify the features or labels or both between its input and output. Trapezoids represent learned models that can be used to make predictions on test data. There are also various stages in the pipeline where we can assess if bias is present using fairness metrics (not pictured), and obtain relevant explanations for the same (not pictured). These will each be discussed below. To ensure ease of use, we created simple abstractions for datasets, metrics, explainers, and algorithms. Metric classes compute fairness and accuracy metrics using one or two datasets, explainer classes provide explanations for the metrics, and algorithm classes implement bias mitigation algorithms. Each of these abstractions are discussed in detail in the subsequent sections. The term ``dataset'' refers to the dataset object created using our abstraction, as opposed to a CSV data file or a Pandas \texttt{DataFrame}. The base classes for the abstractions are general enough to be useful, but specific enough to prevent errors. For example, there is no functional difference between predictions and ground-truth data or training and testing data. Each dataset object contains both features and labels, so it can be both an output of one transformation and an input to another. More specialized subclasses benefit from inheritance while also providing some basic error-checking, such as determining what metrics are available for certain types of datasets. Finally, we are able to generate high-quality, informative documentation automatically by using Sphinx\footnote{\url{http://www.sphinx-doc.org/en/master/}} to parse the docstring blocks in the code. There are three main paths to the goal of making fair predictions (bottom right) --- these are labelled in bold: fair pre-processing, fair in-processing, and fair post-processing. Each corresponds to a category of bias mitigation algorithms we have implemented in AIF360. Functionally, however, all three classes of algorithms act on an input dataset and produce an output dataset. This paradigm and the terminology we use for method names are familiar to the machine learning/data science community and similar to those used in other libraries such as scikit-learn.\footnote{\url{http://scikit-learn.org}} Block arrows marked ``learn'' in Figure \ref{fig:pipeline} correspond to the \texttt{fit} method for a particular algorithm or class of algorithms. Sequences of arrows marked ``apply'' correspond to \texttt{transform} or \texttt{predict} methods. Predictions, by convention, result in an output that differs from the input by labels and not features or protected attributes. Transformations result in an output that may differ in any of those attributes. Although pre-, in-, and post-processing algorithms are all treated the same in our design, there are important considerations that the user must make in choosing which to use. For example, post-processing algorithms are easy to apply to existing classifiers without retraining. By making the distinction clear, which many libraries listed in Section \ref{sec:relatedworks} do not do, we hope to make the process transparent and easy to understand. As for extensibility, while we cannot generalize from only one user, we were very encouraged about how easy it is to use the toolkit when within days of the toolkit being made available, a researcher from the AI fairness field submitted a pull request asking to add his group's bias mitigation algorithm. In a subsequent interview, this contributor informed us that contributing to the toolkit did not take much time as: ``\textit{...it was very well structured and very easy to follow}''. A simplified UML class diagram of the code is provided in Appendix \ref{appendix:uml} for reference. Code snippets for an instantiation of the pipeline based on our AIF360 implementation is provided in Appendix \ref{appendix:snippets}. \section{Dataset Class} \label{sec:datasetclass} The \texttt{Dataset} class and its subclasses are a key abstraction that handle all forms of data. Training data is used to learn classifiers. Testing data is used to make predictions and compare metrics. Besides these standard aspects of a machine learning pipeline, fairness applications also require associating protected attributes with each instance or record in the data. To maintain a common format, independent of what algorithm or metric is being applied, we chose to structure the \texttt{Dataset} class so that all of these relevant attributes --- features, labels, protected attributes, and their respective identifiers (names describing each) --- are present and accessible from each instance of the class. Subclasses add further attributes that differentiate the dataset and dictate with which algorithms and metrics it is able to interact. Structured data is the primary form of dataset studied in the fairness literature and is represented by the \texttt{StructuredDataset} class. Further distinction is made for a \texttt{BinaryLabelDataset} --- a structured dataset that has a single label per instance that can only take one of two values: favorable or unfavorable. Unstructured data, which is receiving more attention from the fairness community, can be accommodated in our architecture by constructing a parallel class to the \texttt{StructuredDataset} class, without affecting existing classes or algorithms that are not applicable to unstructured data. The classes provide a common structure for the rest of the pipeline to use. However, since raw data comes in many forms, it is not possible to automatically load an arbitrary raw dataset without input from the user about the data format. The toolkit includes a \texttt{StandardDataset} class that standardizes the process of loading a dataset from CSV format and populating the necessary class attributes. Raw data must often be ``cleaned'' before being used and categorical features must be encoded as numerical entities. Furthermore, with the same raw data, different experiments are often run using subsets of features or protected attributes. The \texttt{StandardDataset} class handles these common tasks by providing a simple interface for the user to specify the columns of a Pandas \texttt{DataFrame} that correspond to features, labels, protected attributes, and optionally instance weights; the values of protected attributes that correspond to privileged status; the values of labels that correspond to favorable status; the features that need to be converted from categorical to numerical; and the subset of features to keep for the subsequent analysis. It also allows for arbitrary, user-defined data pre-processing, such as deriving new features from existing ones or filtering invalid instances. We extend the \texttt{StandardDataset} class with examples of commonly used datasets that can be used to load datasets in different manners without modifying code by simply passing different arguments to the constructor. This is in contrast with other tools that make it more difficult to configure the loading procedure at runtime. We currently provide an interface to seven popular datasets: \textit{Adult Census Income} \cite{Adult_Dataset}, \textit{German Credit} \cite{German_Dataset}, \textit{ProPublica Recidivism (COMPAS)} \cite{Compas_Dataset}, \textit{Bank Marketing} \cite{Bank_Dataset}, and three versions of \textit{Medical Expenditure Panel Surveys} \cite{MEPS_Dataset_15,MEPS_Dataset_16}. Besides serving as a structure that holds data to be used by bias mitigation algorithms or metrics, the \texttt{Dataset} class provides many important utility functions and capabilities. Using Python's \texttt{==} operator, we are able to compare equality of two datasets and even compare a subset of fields using a custom context manager \texttt{temporarily\_ignore}\footnote{A sample snippet of this functionality is as follows: \texttt{with transf.temporarily\_ignore(`labels'):} \texttt{\hspace{6ex}return transf == pred} This returns \texttt{True} if the two datasets \texttt{transf} and \texttt{pred} differ only in labels. } The \texttt{split} method allows for easy partitioning into training, testing, and possibly validation sets. We are also able to easily convert to Pandas \texttt{DataFrame} format for visualization, debugging, and compatibility with externally implemented code. Finally, we track basic metadata associated with each dataset instance. Primary among these is a simple form of provenance-tracking: after each modification by an algorithm, a new object is created and a pointer to the previous state is kept in the metadata along with details of the algorithm applied. This way, we maintain trust and transparency in the pipeline. \section{Metrics Class} \label{sec:metricsclass} The \texttt{Metric} class and its subclasses compute various individual and group fairness metrics to check for bias in datasets and models.\footnote{In the interest of space, we omit mathematical notation and definitions here. They may be found elsewhere, including the documentation for AIF360.} The \texttt{DatasetMetric} class and its subclass \texttt{BinaryLabelDatasetMetric} examine a single dataset as input (\texttt{StructuredDataset} and \texttt{BinaryLabelDataset}, respectively) and are typically applied in the left half of Figure \ref{fig:pipeline} to either the original dataset or the transformed dataset. The metrics therein are the group fairness measures of disparate (DI) and statistical parity difference (SPD) --- the ratio and difference, respectively, of the base rate conditioned on the protected attribute --- and the individual fairness measure \emph{consistency} defined by \citet{zemel2013fairrepresentations}. In contrast, the \texttt{SampleDistortionMetric} and \texttt{ClassificationMetric} classes examine two datasets as input. For classification metrics, the first input is the original or transformed dataset containing true labels, and the second input is the predicted dataset or fair predicted dataset, respectively, containing predicted labels. This metric class implements accuracy and fairness metrics on models. The sample distortion class contains distance computations between the same individual point in the original and transformed datasets for different distances. Such metrics are used, e.g. by \citet{CalmonWVRV2017}, to quantify individual fairness. A large collection of group fairness and accuracy metrics in the classification metric class are functions of the confusion matrix of the true labels and predicted labels, e.g. false negative rate difference and false discovery rate ratio. Two metrics important for later reference are average odds difference (the mean of the false positive rate difference and the true positive rate difference), and equal opportunity difference (the true positive rate difference). Classification metrics also include disparate impact and statistical parity difference, but based on predicted labels. Since the main computation of confusion matrices is common for a large set of metrics, we utilize memoization and caching of computations for performance on large-scale datasets. This class also contains metrics based on the generalized entropy index, which is able to quantify individual and group fairness with a single number \cite{Speicher2018}. Additional details on the metrics used in the evaluations (Section \ref{sec:eval_algs}) are given in Appendix \ref{appendix:expt_details}. There is a need for a large number and variety of fairness metrics in the toolkit because there is no one best metric relevant for all contexts. It must be chosen carefully, based on subject matter expertise and worldview \citep{FriedlerSV2016}. The comprehensiveness of the toolkit allows a user to not be hamstrung in making the most appropriate choice. \section{Explainer Class} \label{sec:explainerclass} The \texttt{Explainer} class is intended to be associated with the \texttt{Metric} class and provide further insights about computed fairness metrics. Different subclasses of varying complexity that extend the \texttt{Explainer} class can be created to output explanations that are meaningful to different user personas. To the best of our knowledge, this is the first fairness toolkit that stresses the need for explanations. The explainer capability implemented in the first release of AIF360 is basic reporting through "pretty print" and JSON outputs. Future releases may include methodologies such as fine-grained localization of bias (we describe the approach herein), actionable recourse analysis \cite{UstunSL2018}, and counterfactual fairness \cite{WachterMR2018}. \subsection{Reporting} \label{subsec:explainer:interface} \texttt{TextExplainer}, a subclass of \texttt{Explainer}, returns a plain text string with a metric value. For example, the explanation for the accuracy metric is simply the text string \textit{``Classification accuracy on $\langle$count$\rangle$ instances: $\langle$accuracy$\rangle$''}, where $\langle$count$\rangle$ represents the number of records, and $\langle$accuracy$\rangle$ the accuracy. This can be invoked for both the privileged and unprivileged instances by passing arguments. \texttt{JSONExplainer} extends \texttt{TextExplainer} and produces three output attributes in JSON format: (a) meta-attributes about the metric such as its name, a natural language description of its definition and its ideal value in a bias-free world, (b) statistical attributes that include the raw and derived numbers, and (c) the plain text explanation passed unchanged from the superclass \texttt{TextExplainer}. Outputs from this class are consumed by the Web application described in Section \ref{sec:webapp}. \subsection{Fine-grained localization} \begin{figure} \centering \begin{tabular}{cc} \includegraphics[height=1.4in]{adult_minority_breakup-edit.png} & \includegraphics[height=1.4in]{adult_majority_breakup-edit.png}\\ \footnotesize{(a)} & \footnotesize{(b)} \end{tabular} \caption{Protected attribute bias localization in (a) younger (unprivileged), and (b) older (privileged) groups in the \textit{German Credit} dataset. The 17--27 range in the younger group and the 43--58 range in the older group would be localized by the approach.} \label{fig:source_bias_numerical_fairnes_attr} \end{figure} A more insightful explanation for fairness metrics is the localization of the source of bias at a fine granularity in the protected attribute and feature spaces. In the protected attribute space, the approach finds the values in which the given fairness metric is diminished (unprivileged group) or enhanced (privileged group) compared to the entire group. In the feature space, the approach computes the given fairness metric across all feature values and localizes on ones that are most objectionable. Figure \ref{fig:source_bias_numerical_fairnes_attr} illustrates protected attribute bias localization on the \emph{German Credit} dataset, with age as the protected attribute. Figure \ref{fig:CT_search_rate} illustrates feature bias localization on the \emph{Stanford Open Policing} dataset \citep{pierson2017large} for Connecticut, with county name as the feature and race as the protected attribute. \begin{figure} \centering \includegraphics[height=2in]{CTcounty_name_race_search_rate_cmp.png} \caption{Feature bias localization in the \emph{Stanford Open Policing} dataset for Connecticut, with county name as the feature and race as the protected attribute. In Hartford County, the ratio of search rates for the unprivileged groups (black and Hispanic) in proportion to the search rate for the privileged group (this ratio is the DI fairness metric) is higher than the same metric in Middlesex County and others. The approach would localize Hartford County.} \label{fig:CT_search_rate} \end{figure} \section{Algorithms Class} \label{sec:algorithmsclass} Bias mitigation algorithms attempt to improve the fairness metrics by modifying the training data, the learning algorithm, or the predictions. These algorithm categories are known as pre-processing, in-processing, and post-processing, respectively \citep{DalessandroOL2017}. \subsection{Bias mitigation approaches} The bias mitigation algorithm categories are based on the location where these algorithms can intervene in a complete machine learning pipeline. If the algorithm is allowed to modify the training data, then pre-processing can be used. If it is allowed to change the learning procedure for a machine learning model, then in-processing can be used. If the algorithm can only treat the learned model as a black box without any ability to modify the training data or learning algorithm, then only post-processing can be used. This is illustrated in Figure \ref{fig:pipeline}. \subsection{Algorithms} AIF360 currently contains $9$ bias mitigation algorithms that span these three categories. All the algorithms are implemented by inheriting from the \texttt{Transformer} class. Transformers are an abstraction for any process that acts on an instance of \texttt{Dataset} class and returns a new, modified \texttt{Dataset} object. This definition encompasses pre-processing, in-processing, and post-processing algorithms. \noindent{\textbf{Pre-processing algorithms:}} Reweighing \citep{KamiranCalders2012} generates weights for the training examples in each (group, label) combination differently to ensure fairness before classification. Optimized preprocessing \citep{CalmonWVRV2017} learns a probabilistic transformation that edits the features and labels in the data with group fairness, individual distortion, and data fidelity constraints and objectives. Learning fair representations \citep{zemel2013fairrepresentations} finds a latent representation that encodes the data well but obfuscates information about protected attributes. Disparate impact remover \citep{FeldmanFMSV2015} edits feature values to increase group fairness while preserving rank-ordering within groups. \noindent{\textbf{In-processing algorithms:}} Adversarial debiasing \citep{ZhangLM2018} learns a classifier to maximize prediction accuracy and simultaneously reduce an adversary’s ability to determine the protected attribute from the predictions. This approach leads to a fair classifier as the predictions cannot carry any group discrimination information that the adversary can exploit. Prejudice remover \citep{kamishima2012fairness} adds a discrimination-aware regularization term to the learning objective. \noindent{\textbf{Post-processing algorithms:}} Equalized odds postprocessing \citep{hardt2016equality} solves a linear program to find probabilities with which to change output labels to optimize equalized odds. Calibrated equalized odds postprocessing \citep{pleiss2017fairness} optimizes over calibrated classifier score outputs to find probabilities with which to change output labels with an equalized odds objective. Reject option classification \citep{Kamiran2012} gives favorable outcomes to unprivileged groups and unfavorable outcomes to privileged groups in a confidence band around the decision boundary with the highest uncertainty. \section{Maintaining Code Quality} \label{sec:testing} Establishing and maintaining high quality code is crucial for an evolving open source system. Although we do not claim any novelty over modern software projects, we do feel that faithfully adopting such practices is another distinguishing feature of AIF360 relative to other fairness projects. An extensible toolkit should provide confidence to its contributors that, while it makes it is easy for them to extend, it does not alter the existing API contract. Our testing protocols are designed to cover software engineering aspects and comprehensive test suites that focus on the performance metrics of fairness detection and mitigation algorithms. The AIF360 Github repository is directly integrated with Travis CI,\footnote{\url{https://travis-ci.org/}} a continuous testing and integration framework, which invokes {\tt pytest} to run our unit tests. Any pull request automatically triggers the tests. The results of the tests are made available to the reviewer of the pull request to help ensure that changes to the code base do not introduce bugs that would break the tests. Unit test cases ensure that classes and functions defined in the different libraries are functionally correct and do not break the flow of the fairness detection and mitigation pipeline. Each of our classes is equipped with unit tests that attempt to cover every aspect of the class/module/functions. We have also developed a test suite to compute the metrics reported in Section \ref{sec:metricsclass}. Our measurements include aspects of the fairness metrics, classification metrics, dataset metrics, and distortion metrics, covering a total of 71 metrics at the time of this writing. These metrics tests can be invoked directly with any fairness algorithm. The test suite also provides unit tests for all bias mitigation algorithms and basic validation of the datasets. Our repository has two types of tests: (1) unit tests that test individual helper functions, and (2) integration tests that test a complete flowof bias mitigation algorithms in Jupyter notebooks. Table \ref{tab:devopstats} provides the statistics and code coverage information as reported by the tool \texttt{py.test --cov} and Jupyter notebook coverage using \texttt{py.test --nbval} . \begin{table}[h!] \begin{scriptsize} \caption{Statistics on the Test Suite for AIF360} \label{tab:devopstats} \begin{center} \begin{tabular}{|c|c|} \hline Metrics & Statistics \\ \hline Number of Unit Test cases & 23 test cases in 13 modules \\ Code Coverage (Helper Files) & 65\%\\ Code Coverage (Algorithms) & 58\%\\ \hline \end{tabular} \end{center} \end{scriptsize} \end{table} \vspace{-2mm} \section{Evaluation of the Algorithms} \label{sec:eval_algs} Fairness is a complex construct that cannot be captured with a one-size-fits-all solution. Hence, our goal in this evaluation is two-fold: (a) demonstrating the capabilities of our toolkit in terms of the various fairness metrics and bias mitigation algorithms, (b) showing how a user can understand the behavior of various metrics and bias mitigation algorithms on her dataset, and make an appropriate choice according to her needs. \begin{table} [h!] \begin{scriptsize} \caption{Overview of the experimental setup} \label{tab:evaluation} \centering \begin{tabular}{|c|c|} \hline Datasets & Adult Census Income, German Credit, COMPAS \\ \hline Metrics & Disparate impact\\ & Statistical parity difference \\ & Average odds difference \\ & Equal opportunity difference\\ \hline Classifiers & Logistic regression (LR),\\ & Random forest classifier (RF), Neural Network (NN)\\ \hline & Re-weighing \cite{KamiranCalders2012} \\ Pre-processing & Optimized pre-processing \cite{CalmonWVRV2017} \\ Algorithms & Learning fair representations \cite{zemel2013fairrepresentations}\\ & Disparate impact remover \cite{FeldmanFMSV2015} \\ \hline In-processing & Adversarial debiasing \cite{ZhangLM2018} \\ Algorithms & Prejudice remover \cite{kamishima2012fairness} \\ \hline Post-processing & Equalized odds post-processing \cite{hardt2016equality} \\ Algorithms & Calibrated eq. odds postprocessing \cite{pleiss2017fairness}\\ & Reject option classification \cite{Kamiran2012}\\ \hline \end{tabular} \end{scriptsize} \end{table} Table \ref{tab:evaluation} provides the datasets, metrics, classifiers, and bias mitigation algorithms used in our experiments. Additional details on the datasets and metrics are available in Appendix \ref{appendix:expt_details}. The processed \textit{Adult Census Income}, \textit{German Credit}, and \textit{COMPAS} datasets contain $45{,}222$, $1{,}000$ and $6{,}167$ records respectively. Except Adversarial debiasing and Disparate impact remover, all other bias mitigation algorithms use datasets that are cleaned and pre-processed in a similar way. Each dataset is randomly divided into $50\%$ training, $20\%$ validation, and $30\%$ test partitions. Each point in the figures of results consists of a mean and a spread ($\pm$1 standard deviation) computed using $25$ such random splits. For the random forest classifier, we set the number of trees to be $100$, and the minimum samples at a leaf node to be $20$. For fair pre-processing algorithms, since the original dataset itself gets transformed (see Figure \ref{fig:pipeline}), we compute fairness metrics before and after this transformation and present results in Figure \ref{fig:spddi}. For all datasets, the Re-weighing and Optimized pre-processing algorithms improve fairness in both metrics presented. However, the least improvement is with \textit{German Credit} dataset, possibly because it is the smallest in size. Results for disparate impact remover and learning fair representations algorithms are not shown since they do not modify the labels or protected attributes directly when transforming the dataset. Hence the SPD and DI values do not change during transformation. \begin{figure*}[h] \begin{scriptsize} \begin{subfigure}{1.0\textwidth} \centering \includegraphics[scale=0.30]{legend_ds_metric.png} \end{subfigure} \begin{subfigure}{0.24\textwidth} \centering \includegraphics[ width=1.7in]{reweighing_statistical_parity_difference.png} \caption{SPD - Re-weighing} \label{fig:reweighing_statistical_parity_difference} \end{subfigure} \begin{subfigure}{0.24\textwidth} \centering \includegraphics[ width=1.7in]{optim_preproc_statistical_parity_difference.png} \caption{SPD - Optimized pre-proc.} \label{fig:optim_preproc_statistical_parity_difference} \end{subfigure} \begin{subfigure}{0.24\textwidth} \centering \includegraphics[ width=1.7in]{reweighing_disparate_impact.png} \caption{DI - Re-weighing} \label{fig:reweighing_disparate_impact} \end{subfigure} \begin{subfigure}{0.24\textwidth} \centering \includegraphics[ width=1.7in]{optim_preproc_disparate_impact.png} \caption{DI - Optimized pre-proc.} \label{fig:optim_preproc_disparate_impact} \end{subfigure} \caption{Statistical Parity Difference (SPD) and Disparate Impact (DI) before (blue bar) and after (orange bar) applying pre-processing algorithms on various datasets for different protected attributes. The dark gray bars indicate the extent of $\pm$1 standard deviation. The ideal fair value of SPD is 0 and DI is 1.} \label{fig:spddi} \end{scriptsize} \end{figure*} \begin{figure*} \begin{scriptsize} \begin{subfigure}{1.0\textwidth} \centering \includegraphics[scale=0.25]{legend_hor.png} \end{subfigure} \begin{subfigure}{0.245\textwidth} \centering \includegraphics[scale=0.1]{adult_race_statistical_parity_difference_before.png} \includegraphics[scale=0.1]{adult_race_statistical_parity_difference_after.png} \label{fig:adult_race_statistical_parity_difference} \caption{Statistical parity difference} \end{subfigure} \begin{subfigure}{0.245\textwidth} \centering \includegraphics[scale=0.1]{adult_race_disparate_impact_before.png} \includegraphics[scale=0.1]{adult_race_disparate_impact_after.png} \label{fig:adult_race_disparate_impact} \caption{Disparate impact} \end{subfigure} \begin{subfigure}{0.245\textwidth} \centering \includegraphics[scale=0.1]{adult_race_average_odds_difference_before.png} \includegraphics[scale=0.1]{adult_race_average_odds_difference_after.png} \label{fig:adult_race_average_odds_difference} \caption{Average odds difference} \end{subfigure} \begin{subfigure}{0.245\textwidth} \centering \includegraphics[scale=0.1]{adult_race_equal_opportunity_difference_before.png} \includegraphics[scale=0.1]{adult_race_equal_opportunity_difference_after.png} \label{fig:adult_race_equal_opportunity_difference} \caption{Equal opportunity difference} \end{subfigure} \caption{Fairness vs. Balanced Accuracy before (top panel) and after (bottom panel) applying various bias mitigation algorithms. Four different fairness metrics are shown. In most cases two classifiers (Logistic regression - LR or Random forest classifier - RF) were used. The ideal fair value of disparate impact is 1, whereas for all other metrics it is 0. The circles indicate the mean value and bars indicate the extent of $\pm$1 standard deviation. Dataset: \textit{Adult}, Protected attribute: \textit{race}.} \label{fig:adult-race} \end{scriptsize} \end{figure*} We also train classifiers with and without bias mitigation for all the dataset and algorithm combinations. We then measure statistical parity difference and disparate impact using the predicted dataset, and average odds and equal opportunity difference using the input and predicted datasets. In all possible cases, the validation datasets were used to obtain the score threshold for the classifiers to maximize balanced accuracy. The results are all obtained on test partitions. An example result for \textit{Adult Census Income} dataset with \textit{race} as protected attribute is shown in Figure \ref{fig:adult-race}. The rest of the results referenced here are available in Appendix \ref{appendix:evaluationgraphs}. Disparate impact remover and adversarial debiasing use differently processed datasets and hence their metrics in the top panel are different from others. The first thing that strikes when glancing at the figure is that the four different metrics seem to be correlated. Also the uncertainty in classification accuracy is much smaller compared to the uncertainty in the fairness metrics. There is also correlation between the metrics computed using the LR and RF classifiers. The Reject option classification algorithm improves fairness quite a bit, but also suffers a significant reduction in accuracy. Reweighing and optimized pre-processing also show good improvement in fairness, but without much penalty in accuracy. The two equal odds post-processing methods do not show significant changes to accuracy or fairness. These evaluations can be used to arrive at an informed conclusion about the choice of bias mitigation algorithm depending on the application. Clearly, if modifying the data is possible reweighing or optimized pre-processing are good options. However, if post-processing is the only option, e.g., if the user has access only to black box models, reject option classification is shown to be a decent choice on average, although it is brittle. The effect of dataset size on these metrics becomes clear looking at Figures \ref{fig:german-sex} and \ref{fig:german-age}. The uncertainty is substantially higher in the case of \textit{German Credit} data. Fairness improvements are more mixed in the \textit{COMPAS} data, but Reweighing and Reject option classification still show up to be good choices. \section{Web Application} \label{sec:webapp} AIF360 includes not only the main toolkit code, but also an interactive Web experience (see Appendix \ref{appendix:posterpage} for a screen shot). Here we describe its front-end and back-end design. \subsection{Design of the interactive experience} The Web experience was designed to provide useful information for a diverse consumers. For business users, the interactive demonstration offers a sample of the toolkit's fairness checking and mitigation capabilities without requiring any programming knowledge. For new developers, the demonstration, notebook-based tutorials, guidance on algorithm selection, and access to a user community provide multiple ways to progress from their current level of understanding into the details of the code. For more advanced developers, the detailed documentation and code are directly accessible. The design of the Web experience proceeded through several iterations. Early clickable mock-ups of the interactive demonstration had users first select a dataset, one or two protected attributes to check for bias, and one of up to five metrics to use for checking. We learned, however, that this was overwhelming, even for those familiar with AI, since it required choices they were not yet equipped to make. As a result, we simplified the experience by asking users to first select only one of three datasets to explore. Bias checking results were then graphically presented for two protected attributes across five different metrics. Users could then select a mitigation algorithm leading to a report comparing bias before and after mitigation. The design of the charts for each bias metric also evolved in response to user feedback as we learned the importance of depicting a color-coded range of values considered fair or biased with more detailed information being available in an overlay. Figure \ref{fig:webui} shows the before and after mitigation graphs from the interactive Web experience. \begin{figure} [h!] \includegraphics[width=\linewidth]{web_ui_graphs.png} \caption{Graphs from the interactive web experience showing one of the metrics, for one of the datasets, before and after mitigation.} \label{fig:webui} \end{figure} The design of the rest of the site also went through several iterations. Of particular concern, the front page sought to convey toolkit richness while still being approachable. In the final design, a short textual introduction to the content of the site, along with direct links to the API documentation and code repository, is followed by a number of direct links to various levels of advice and examples. Further links to the individual datasets, the bias checkers, and the mitigation algorithms are also provided. In all this, we ensured the site was suitably responsive across all major desktop and mobile platforms. \subsection{Design of the back-end service} The demo web application not only provides a gentle introduction to the capabilities of the toolkit, but also serves as an example of deploying the toolkit to the cloud and converting it into a web service. We used Python's Flask framework for building the service and exposed a REST API that generates a bias report based on the following input parameters from a user: the dataset name, the protected attributes, the privileged and unprivileged groups, the chosen fairness metrics, and the chosen mitigation algorithm, if any. With these inputs, the back-end then runs a series of steps to 1) split the dataset into training, development, and validation sets; 2) train a logistic regression classifier on the training set; 3) run the bias-checking metrics on the classifier against the test dataset; 4) if a mitigation algorithm is chosen, run the mitigation algorithm with the appropriate pipeline (pre-processing, in-processing, or post-processing). The end result is then cached so that if the exact same inputs are provided, the result can be directly retrieved from cache and no additional computation is needed. The reason to truly use the toolkit code in serving the Web application rather than having a pre-computed lookup table of results is twofold: we want to make the app a real representation of the underlying capabilities (in fact, creating the Web app helped us debug a few items in the code), and we also avoid any issues of synchronizing updates to the metrics, explainers, and algorithms with the results shown: synchronization is automatic. Currently, the service is limited to three built-in datasets, but it can be expanded to support the user's own data upload. The service is also limited to building logistic regression classifiers, but again this can be expanded. Such expansions can be more easily implemented if this fairness service is integrated into a full AI suite that provides various classifier options and data storage solutions. \section{Conclusion} \label{sec:discussion} AIF360 is an open source toolkit that brings value to diverse users and practitioners. For fairness researchers, it provides a platform that enables them to: 1) experiment with and compare various existing bias detection and mitigation algorithms in a common framework, and gain insights into their practical usage; 2) contribute and benchmark new algorithms; 3) contribute new datasets and analyze them for bias. For developers, it provides: 1) education on the important issues in bias checking and mitigation, 2) guidance on which metrics and mitigation algorithms to use; 3) tutorials and sample notebooks that demonstrate bias mitigation in different industry settings; and 4) a Python package for detecting and mitigating bias in their workflows. Fairness is a multifaceted, context-dependent social construct that defies simple definition. The metrics and algorithms in AIF360 may be viewed from the lens of distributive justice \citep{HuC2018}, i.e., relating to decisions about who in a society receives which benefits and goods, and clearly do not capture the full scope of fairness in all situations. Even within distributive justice, more work is needed to apply the toolkit to additional datasets and situations. Future work could also expand the toolkit to measure and mitigate other aspects of justice such as compensatory justice, i.e. relating to the extent to which people are fairly compensated for harms done to them. Further work is also needed to extend the variety of types of explanations offered, and to create guidance for practitioners on when a specific kind of explanation is most appropriate. There is a lot of work left to do to achieve unbiased AI, we hope others in the research community continue to contribute to the toolkit their own approaches to fairness and bias checking, mitigation and explanation. \bibliographystyle{sysml2019}
{'timestamp': '2018-10-05T02:03:00', 'yymm': '1810', 'arxiv_id': '1810.01943', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01943'}
arxiv
\section{Models of Deferring} \label{sec:discussion} Whether or not a classifier is thought of as promoting fairness depends on the context; this is true for both deferring and non-deferring classifiers. In addition to the myriad considerations present for non-deferring classifiers, deferring classifiers and downstream decision makers introduce some additional axes for consideration. \paragraph{Cost to the individual:} Even though it is not intended to be a final decision, a deferral may impose burdensome costs to an individual being classified. It may mean that a defendant remains in jail while additional hearings are scheduled, that invasive and expensive medical tests are ordered, or that continued investigation engenders social stigma. These costs may not be borne equally by all individuals, and may depend on their group membership, their true type, or other factors. For example, a delay in granting a loan to a applicant may overly burden poorer applicants, even those very likely to repay. \paragraph{Cost to the decider:} Allowing deferrals might make the decision process more cost-effective: Given that in most cases making a determination is cheap, one may now invest more in the deferred cases. For instance, a team of trained moderators might be hired to manually review content on which an automated content filter defers, or an expensive investigation might be required to adjudicate insurance claims that are not cut-and-dry. \paragraph{Accuracy of downstream decision} One reason to defer is to introduce a delay that will allow for a more accurate decision. Thus the usefulness of allowing a classifier to defer depends on the accuracy of the downstream decision maker. Additional medical tests might allow for highly accurate diagnoses. But a judge deciding bail will be prone to a variety of errors and biases. \paragraph{``Fairness'' of downstream decision (and of composed classifier)} Similar to the above, the fairness of the downstream decision maker (however one wants to interpret that) will impact our interpretation of the deferring classifier. Here one should take into account also the "procedural" aspect of the two-step evaluation; here it is important that the downstream classifier will be deemed as "more fair" and "more knowledgeable" than the first stage. Exploring fairness criteria for systems of deferring classifiers and downstream decision-makers, e.g. as done in~\cite{bower} did for non-deferring classifiers, is an interesting direction for future work. \paragraph{Frequency of decisions} In many settings, the deferring classifier is a fast, automated test (e.g., automated risk assessment) while the downstream decision maker is a slow, manual process (e.g., parole board). However, we anticipate situations in which there may be repeated deferring classifiers chained together which comprise the complete decision making pipeline. For example, a doctor might have a sequence of diagnostic tests at her disposal as needed, or a bank might allow many rounds of appeal for loan applications, but with lengthy delays. Some applications might even permit hundreds or thousands of near-continuous deferring classifiers. As an example, consider a live video streaming platform that passively monitors streams for inappropriate content in real time. The automated passive monitor might decide the content is inappropriate, and shut it down; appropriate, and continue passive monitoring; or suspicious (by deferring), and begin active monitoring by devoting more computing resources or bringing in a human moderator. \subsection{Technical implications of deferral model} The contextual considerations discussed above directly impact the appropriate application of a deferring classifier and its goals. An obvious goal is to minimize the overall rate of deferrals while maintaining the best possible FPR, FNR, PPV, and NPV for the classifier conditioned on not deferring, and without considering the distribution of deferrals. However, one might desire very different properties from the distribution of deferrals in different contexts. The deferrals may be distributed differently among individuals with different true type, group membership, or soft-classifier scores, while the burden imposed by deferrals and errors may differ greatly between different populations. In a medical diagnosis scenario, a false negative (i.e., failing to diagnose a disease) may have serious consequences, and deferring to run additional non-invasive and inexpensive additional tests may be generally acceptable. On the other hand, an insurance provider may prefer to minimize expensive investigations by paying out more false claims. The context may also affect the way one defines the deferral analogues of \FPR and \FNR. While calibration, \PPV, and \NPV apply directly to deferring classifiers, it is not clear how best to generalize the definitions of error rates. For example, consider false positive rate: by Definition~\ref{defn:four-measures}, the false positive rate of a non-deferring hard classifier $\mathmode{\hat{Y}}$ for a group $g$ is $\FPR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF]$. The approach we take in Section~\ref{sec:deferrals} is to condition on not deferring (Definition~\ref{defn:conditional-measures}). A deferring classifier $\mathmode{\hat{Y}}$ that output $\pT$ on half of true negative instances (within a $g$) would have conditional false positive rate as low as 0.5 (if it never output $\punt$ on true negatives) or as high as $1$ (if it never output $\pF$ on true negatives). The conditional false positive rate is agnostic towards the downstream decision maker. It codifies no value judgements as to whether a deferral is desirable or undesirable as an individual nor whether deferrals ultimately result in accurate or inaccurate decisions. This is, itself, a value judgement. A second approach is to leave the original definition unchanged. The same deferring hard classifier as above would have unconditional false positive rate 0.5. This would be true regardless of whether $\mathmode{\hat{Y}}$ output $\pF$ or $\punt$ on the other half of true negative instances. We call this the \emph{unconditional false positive rate}. The unconditional false positive rate effectively categorizes deferrals as correct outputs. This may be appropriate if the downstream decision maker has very high accuracy. If, for example, a doctor orders an additional, more accurate diagnostic test in response to a deferral, the unconditional false positive rate might be appropriate. Finally, a third approach is to base our measure of inaccuracy on true negatives instead of false positives, a reverse of the above. Just as in the case of non-deferring classifiers, the relationships among these contrasting group statistics, their meaningfulness in different settings, and their application in different settings are not well understood and deserve further study. \section{Results for NPV and Continuous, Full Support APs} \subsection{Results for Negative Predictive Value (NPV)} \label{sec:appendix-npv} In Section~\ref{sec:postprocess-limits}, we proved limitations on the ability of post-processors to equalize PPV given a distribution on calibrated scores with finite support. For completeness, in this section, we give the statements of the analogous limitations for equalizing NPV and for continuous probability density functions with full support $[0,1]$. We start with the analogous statement of Proposition~\ref{prop:info-theory-impossibility-3} for NPV instead of PPV. \begin{proposition} \label{prop:info-theory-impossibility-npv} Fix two disjoint groups $g_1$ and $g_2$ with respective base rates $\BR_1$ and $\BR_2$ such that $\BR_1 \neq \BR_2$. Then there exists a soft-valued classifier $\mathmode{\hat{S}}$ that is groupwise calibrated, but for which there is no post-processor $\mathmode{\hat{D}}: [0,1] \times \mathmode{\mathcal{G}} \to \{0,1\}$ such that $\mathmode{\hat{D}} \circ \mathmode{\hat{S}}$ equalizes $\NPV$, unless $\Pr[\mathmode{\hat{D}}(BR_i, g_i)=0]=0$ for $i=1$ or $2$. \end{proposition} The nontriviality condition ensures that the NPV is well-defined on both groups (which can be compared to the nontriviality condition in Proposition~\ref{prop:info-theory-impossibility-3}, which ensures that the PPV is well-defined on both groups). The proof is essentially identical to the proof of Proposition~\ref{prop:info-theory-impossibility-3}: the fraction of predicted 0's in group $g_i$ that are true $0$'s is $1 - \BR_i$, as the post-processor has no other information by which to make its decision, and hence the NPVs are unequal due to the differing base rates. We now proceed to give the NPV analogs of our results on threshold post-processors in Section~\ref{sec:postprocess-limits}. We start with the analogous statement for Proposition~\ref{prop:trivial-threshold-equalizes} - that there is a class of simple group-blind threshold post-processors that equalizes the NPV across groups. \begin{proposition} \label{prop:trivial-threshold-equalizes-npv} For every nice groupwise calibrated soft classifier $\mathmode{\hat{S}}$ and for every group-blind threshold post-processor $\mathmode{\hat{D}}_{(\tau, \mathcal{R})}$ such that $\mathmode{\tau}(g) = \min(\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g))$ and $\mathcal{R}(g) <1$ for all $g$, the composed classifer $\mathmode{\hat{D}} \circ \mathmode{\hat{S}}$ equalizes $\NPV$s across all groups. \end{proposition} The existence of the threshold post-processors in Proposition~\ref{prop:trivial-threshold-equalizes-npv} follows from the assumed finiteness of the range of the soft classifier. In the case where the range of the soft classifier is infinite, such post-processors may not exist (as there may be no minimum element of the support). The proof is once again analogous to the proof of Proposition~\ref{prop:trivial-threshold-equalizes}: these classifiers only ever output 0 on the minimum element of the support of $\mathmode{\hat{\mathcal{P}}}_g$, and hence the NPV is simply 1 minus the smallest element of the support for each group. However, much like the case for PPV, other group-blind threshold post-processors cannot possibly equalize NPV. \begin{proposition}\label{prop:single-threshold-cannot-equalize-npv} There exists a groupwise-calibrated soft classifier with a nice AP for which no non-trivial group blind threshold post-processor, other than the ones in Proposition~\ref{prop:trivial-threshold-equalizes}, can equalize NPV across groups. \end{proposition} The example of the groupwise-calibrated soft classifier is the exact same one that shows the statement for PPV. Indeed, we can see this in the following way. We can make the example in the proof of Proposition~\ref{prop:single-threshold-cannot-equalize-npv} have equal base rates across groups, in which case it follows from Proposition~\ref{prop:single-threshold-cannot-equalize} due to Claim~\ref{claim:baserate-convex-comb}. When we turn to threshold post-processors that are not group-blind, we again get analogous results for NPV. \begin{proposition}\label{prop:2-thresh-equal-npv} Let $\mathmode{\mathcal{G}}$ be a set of groups. For any soft classifier $\mathmode{\hat{S}}$ with a nice AP $\mathmode{\hat{\mathcal{P}}}$ such that $\mathmode{\hat{S}}$ is groupwise-calibrated over $\mathmode{\mathcal{G}}$ and $|\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g})| \geq 2$ for all $g \in \mathmode{\mathcal{G}}$, there exists a (\emph{non-group-blind}), non-trivial threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ that is \emph{not} one of the group blind post-processors in Proposition~\ref{prop:trivial-threshold-equalizes}, such that the hard classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}$ equalizes NPV across $\mathmode{\mathcal{G}}$. This holds even if we require that the NPV of all the groups is an arbitrary value in $(\ps_{min}, \min_i \BR_{g_i})$, where $\min_i \BR_{g_i}$ is the minimum base rate among the groups and $\ps_{min}$ is the minimum score in the support of $\mathmode{\hat{\mathcal{P}}}_{g_i}$.\footnote{For the case where the support of $\mathmode{\hat{\mathcal{P}}}_{g_i}$ is infinite, $\ps_{min}$ should be the infimum of scores.} \end{proposition} Again the proof of this follows via the same kind of continuity argument as we used to prove Proposition~\ref{prop:2-thresh-equal-ppv}. By definition, each group has base rate at least $\min_i \BR_{g_i}$, and so if the post-processor always says 0 on some group $i$, then $\NPV_{g_i} = \BR_{g_i} \geq \min_i \BR_{g_i}$. Hence, for each group, we can start with the always-0 classifier and slide down the threshold until the desired NPV is reached. Finally, the socially unsatisfying example also generalizes to NPV. A privileged group will have higher scores than a disadvantaged group in general, and hence if they are given the same threshold, the NPV will be lower on the privileged group. To rectify this, the threshold for the disadvantaged group will have to moved higher, to decrease the \NPV. But then, the disadvantaged group is being subjected to a harsher standard. Finally we note that Claim~\ref{claim:ppv-continuity} also can be written with NPV instead of PPV, where the proof follows from using the characterization of NPV given in Proposition~\ref{prop:ppv-as-cond-exp}: \begin{claim}[Continuity of NPV] \label{claim:npv-continuity} Fix a soft classifier $\mathmode{\hat{S}}$ and a corresponding AP $\mathmode{\hat{\mathcal{P}}}$, as well as a group $g$. Let $\mathmode{\hat{D}}_1$ and $\mathmode{\hat{D}}_2$ be two post-processing algorithms. Let $\mathmode{\hat{\mathcal{P}}}_{g,\mathmode{\hat{D}}_1}$ be the expected conditional AP that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_g$ over scores in group $g$ and then conditioning on the scores that $\mathmode{\hat{D}}_1$ sends to 0, and define $\mathmode{\hat{\mathcal{P}}}_{g,\mathmode{\hat{D}}_2}$ similarly. If $d_{TV}(\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}, \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}) < \epsilon$, then $|\NPV_{g, \mathmode{\hat{D}}_1 \circ \mathmode{\hat{S}}} - \NPV_{g, \mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}}| < O(\epsilon)$. \end{claim} We omit the proof of Claim \ref{claim:npv-continuity}, which resembles the proof of Claim \ref{claim:ppv-continuity} and follows from Proposition \ref{prop:ppv-as-cond-exp}. \subsection{Results for Continuous, Full Support APs} \label{sec:appendix-cont} In this section, we briefly address how to extend our results on thresholds in Section~\ref{sec:postprocess-limits} to the setting where every AP $\mathmode{\hat{\mathcal{P}}}$ is a continuous probability distribution with $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g) = [0,1]$ for all $g \in G$ - that is, the support equals the entire interval $[0,1]$ for each group $g \in G$. Note that this automatically makes $\mathmode{\hat{\mathcal{P}}}$ a ``nice'' AP, and hence rules out the general counterexample we came up with in Proposition~\ref{prop:info-theory-impossibility-3}. For the purposes of this section, call such an AP that 1) $\mathmode{\hat{\mathcal{P}}}_g$ is a continuous probability density function for every $g \in G$ and 2) $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g) = [0,1]$ for all $g \in G$ a \emph{very nice} AP. As the name suggests, we can extend the remaining results in Section~\ref{sec:postprocess-limits} to the setting of very nice AP. We give the results for equalizing PPV as done in Section~\ref{sec:postprocess-limits}: extending these results to equalizing NPV in the setting of continuous, full support AP can be accomplished by combining the statements here with the modifications described in Section~\ref{sec:appendix-npv}. First, we note that a threshold post-processor can be described much more easily in the continuous setting than in the setting where the AP has finite support on each group. Indeed, in the setting where $\mathmode{\hat{\mathcal{P}}}_g$ is a continuous density function for all $g \in G$, the post-processor can truly be a threshold, with no question of how to classify the score that is exactly equal to the threshold $\tau$. This is because the score $\tau$ has probability 0 under the density $\mathmode{\hat{\mathcal{P}}}_g$. Hence, Proposition~\ref{prop:trivial-threshold-equalizes} has no true analog in this setting. This follows because the maximum element of the support in this case is 1, and a threshold at $\tau=1$ sends every score (outside of a measure 0 set) to 0. This allows us to strengthen Proposition~\ref{prop:single-threshold-cannot-equalize} accordingly. \begin{proposition}\label{prop:single-threshold-cannot-equalize-cont} There exists a groupwise-calibrated soft classifier with a very nice AP for which no non-trivial group blind threshold post-processor can equalize PPV across groups. \end{proposition} This follows from a nearly identical stochastic domination argument to the one used for Proposition~\ref{prop:single-threshold-cannot-equalize} - in fact, the natural generalization of the distributions given for the proof of Proposition~\ref{prop:single-threshold-cannot-equalize} to the continuous and full-support setting can be used in this proof. A non group blind threshold can still always equalize PPV for very nice APs. \begin{proposition} \label{prop:equalize-ppv-cont} Let $\mathmode{\mathcal{G}}$ be a set of groups. For any soft classifier $\mathmode{\hat{S}}$ with a very nice AP $\mathmode{\hat{\mathcal{P}}}$ such that $\mathmode{\hat{S}}$ is groupwise-calibrated over $\mathmode{\mathcal{G}}$, then there exists a non group blind, non-trivial threshold post-processor such that the hard classifier equalizes $PPV$ across $\mathmode{\mathcal{G}}$. This holds even if we require that the PPV of all the groups is equal to an arbitrary value in $(\max_i \BR_{g_i},1)$, where $\max_i \BR_{g_i}$ is the maximum base rate among the groups $g_i \in \mathmode{\mathcal{G}}$. \end{proposition} This follows from the same continuity approach as the proof of Proposition~\ref{prop:2-thresh-equal-ppv}, by sliding the threshold continuously down from 1 until the PPV reaches the desired value $v \in (\max_i \BR_{g_i},1)$. The socially unsatisfying example generalizes in the natural way - Example~\ref{ex:social-unsat} consists of one group having a monotonically increasing PMF and another one having a monotonically decreasing PMF. We can skip the discretization step in the definition of these PMFs and have them be continuous PDFs, and the example still goes through. We cannot equalize PPV and NPV simultaneously in general, just like in the finite support case (Proposition~\ref{prop:ppv-npv-impossibility}). \begin{proposition} Fix groups $g_1$ and $g_2$. There exists a soft classifier $\mathmode{\hat{S}}$ with a very nice AP~$\mathmode{\hat{\mathcal{P}}}$ such that no threshold post-processor can simultaneously equalize PPV and NPV between groups $g_1$ and $g_2$. \end{proposition} The proof we give of Proposition~\ref{prop:ppv-npv-impossibility} for finite support naturally generalizes to this case - in fact, we can simply use the same proof but without discretizing the probability distributions. The necessary lemmas about monotonicity of PPV and being able to express the base rate as a convex combination of PPV and NPV still hold. It is unsurprising that the result in Section~\ref{sec:deferrals} on using thresholds \emph{with deferrals} to equalize PPV and NPV also goes through for very nice AP. \begin{proposition} Let $\mathmode{\hat{S}}$ be groupwise calibrated for the $n$ groups $g_1,\ldots,g_n$, and suppose that $\mathmode{\hat{S}}$ has a very nice AP. Then there exists a nontrivial threshold decision rule rule such that the hard classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}} \circ \mathmode{\hat{S}}$ equalizes PPV and NPV for $\mathmode{\mathcal{G}}$. \end{proposition} Again, the explanation is very similar to the one for Proposition~\ref{prop:equalize-ppv-cont}. PPV and NPV change continuously when we slide the respective thresholds, and unlike the case without deferrals, we can change the PPV \emph{without} changing the NPV, by keeping the ``0'' threshold still and sliding the ``1'' threshold (and deferring in the middle). Hence, we can simply continuously slide the two thresholds on each group until they reached the desired values. \section{Deferral Preliminaries} \label{sec:deferral_prelims} In the first part of the paper, we considered the problem of post-processing calibrated soft classifiers, which output a score $\ps \in [0,1]$, into fair hard classifiers, which output a decision in $\mathmode{\hat{y}}\in\{\pF,\pT\}$, subject to a number of group fairness conditions. In the remainder of this work, we reconsider this problem, but with one important change: we allow classifiers to ``refuse to decide'' by outputting the special symbol $\punt$. We call such classifiers \emph{deferring} classifiers, borrowing the nomenclature from \cite{MPZ17}. The output $\punt$ is the deferring classifier's way of refusing to make a decision and deferring to a downstream decision maker. For example, a risk assessment tool might aid a parole board to make a decision by categorizing an individual as high risk or low risk, or it might output $\punt$---providing no advice and deferring to the judgment of the board. We now modify our notation appropriately. Instances $x$ are still associated with a true type $\mathmode{Y}(x) \in \{\tF, \tT\}$ and a group $\mathmode{G}(x) \in \mathmode{\mathcal{G}}$. A deferring hard classifier $\mathmode{\hat{Y}}$ is a randomized function $\mathmode{\hat{Y}}:\mathmode{\mathcal{X}} \to \{\pF,\pT, \punt\}$. A deferring soft classifier is a randomized function $\mathmode{\hat{S}}:\mathmode{\mathcal{X}}\to[0,1]\cup \{\punt\}$. A deferring hard (resp.~soft) post-processor is a randomized function $\mathmode{\hat{D}}: [0,1]\cup\{\punt\} \times \mathmode{\mathcal{G}} \to \{\pF,\pT,\punt\}$ (resp.~$\mathmode{\post^\mathsf{soft}}: [0,1] \cup \{\punt\} \times \mathmode{\mathcal{G}} \to [0,1] \cup \{\punt\}$) that takes as input the output of a deferring soft and post-processes it into a deferring hard (resp.~soft) classifier. \subsection{Types of downstream decision makers} It's important to recognize that deferring does not fix unfairness, it only transforms it. Ultimately, whether a deferring classifier is thought of as promoting fairness may depend on the nature of the downstream decision maker who must make decisions on instances which have been deferred. One convenient yet often unrealistic scenario is a ``perfect'' downstream decision maker: some procedure that is expensive to run but offers perfect (or near-perfect) accuracy. A perfectly accurate downstream decision maker is ``fair'' in a number of ways: it offers perfect PPV, NPV, FPR, and FNR to all groups;furthermore, it is also individually fair--- treating likes alike. The unfairness that remains in the overall system, therefore, is a function of the distribution of deferrals. A somewhat more realistic scenario is a ``perfect-but-painful'' downstream decision maker. This differs from the above in that it is costly not only to the entity making the decision, but also to the individual being decided upon. For example, an individual might receive accurate medical diagnoses only after being subjected to very invasive or harmful tests. The expense of deferral to the individual complicates our understanding of the fairness of the overall system. Another likely scenario is that $\pX$ results are passed to a different, potentially human decision-maker, which may not be as accurate as the original classifier (though is potentially inaccurate in an incomparable way). As in the earlier scenarios, unfairness may manifest itself in the decision to defer. However, there may be even greater unfairness to the deferred individuals. In either scenario, we may wish to minimize the total rate of deferrals, equalize it between groups, or restrict deferrals to a particular group. \subsection{Statistical properties of deferring classifiers: contrasting approaches} We wish to define statistical properties of deferring classifiers. While calibration, PPV, and NPV apply to deferring classifiers without change, it is not clear how best to generalize the definitions of FPR and FNR, or more generally the error rate. For example, recall the definition of the false positive rate (Definition~\ref{defn:four-measures}): The false positive rate of a (non-deferring) hard classifier $\mathmode{\hat{Y}}$ for a group $g$ is $\FPR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF]$. One possible approach to incorporating deferrals is to condition on not deferring. That is, define the \emph{conditional false positive rate} as $\Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF, \mathmode{\hat{Y}}(X_g) \neq \punt]$. A deferring classifier $\mathmode{\hat{Y}}$ that output $\pT$ on half of true negative instances (within a $g$) would have conditional false positive rate as low as 0.5 (if it never output $\punt$ on true negatives) or as high as $1$ (if it never output $\pF$ on true negatives). The conditional false positive rate is agnostic towards the downstream decision maker. It codifies no value judgments as to whether a deferral is desirable or undesirable as an individual nor whether deferrals ultimately result in accurate or inaccurate decisions. A second approach is to leave the original definition unchanged. The same deferring hard classifier as above would have (ordinary, not conditional) false positive rate $\Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF] =0.5$. This would be true regardless of whether $\mathmode{\hat{Y}}$ output $\pF$ or $\punt$ on the other half of true negative instances. We call this the \emph{unconditional false positive rate}. The unconditional false positive rate effectively categorizes deferrals as correct outputs. This may be appropriate if the downstream decision maker has very high accuracy. If, for example, a doctor orders an additional, more accurate diagnostic test in response to a deferral, the unconditional false positive rate might be appropriate. Finally, a third approach is to base our measure of inaccuracy on the true negatives instead of the false positives. Namely, we could consider $1-\Pr_{X \mathmode{\sim} \mathmode{\mathcal{X}}_g}[\mathmode{\hat{Y}}(X) = \pF \mid \mathmode{Y}(X) = \tF]$. In contrast to the unconditional false positive rate, this measure effectively categorizes deferrals as incorrect outputs. This may be appropriate if the downstream decision maker has is inaccurate, or if a deferral is associated with significant cost to the individual. Continuing the medical example, if the additional test requires an expensive and risky surgery, this third approach might be most appropriate. Just as in the case of non-deferring classifiers, the relationships among these contrasting group statistics, their meaningfulness in different settings, and their application in different settings are not well understood and deserve further study. In this work, we focus on the conditional versions of false positive and negative rates. \begin{definition}\label{defn:conditional-measures} The \emph{conditional false positive rate} and \emph{conditional false negative rate} of a deferring hard classifier $\mathmode{\hat{Y}}$ for a group $g$ are, respectively: \[ \cFPR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF, \mathmode{\hat{Y}}(X_g) \neq \punt]. \] \[ \cFNR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pF \mid \mathmode{Y}(X_g) = \tT, \mathmode{\hat{Y}}(X_g) \neq \punt]. \] \end{definition} We additionally consider a version of the distribution of calibrated scores conditioned on not deferring, which we call the \emph{conditional DOCS}. For non-deferring soft classifiers, Definitions~\ref{defn:conditional-docs} and \ref{defn:docs} coincide. \begin{definition} \label{defn:conditional-docs} The \emph{conditional DOCS} $\mathmode{\hat{\mathcal{P}}}_g$ of a classifier $\mathmode{\hat{S}}$ for a group $g$ is the PMF of $\mathmode{\hat{S}}(X_g)$, conditioned on not outputting $\punt$. That is, for $\ps \in [0,1]$, $\mathmode{\hat{\mathcal{P}}}_g(\ps) = \Pr[\mathmode{\hat{S}}(X_g) = \ps \mid \mathmode{\hat{S}}(X_g) \neq \punt].$ Note that the conditional DOCS is undefined if $\Pr[\mathmode{\hat{S}}(X_g) \neq \punt] = 0$. Abusing notation, we denote by $\mathmode{\hat{\mathcal{P}}}$ the collection $\{\mathmode{\hat{\mathcal{P}}}_g\}_{g\in \mathmode{\mathcal{G}}}$, and call it the \emph{conditional DOCS of~\mathmode{\hat{S}}}. \end{definition} Because they make no assumptions about the behavior of the downstream decision maker, the conditional error rates are applicable generally, but they can be difficult to interpret. They are also amenable to the consideration of additional goals which we will briefly address. For example, one could seek to minimize the total deferral rate, equalize the deferral rate among groups, or prefer deferrals on positive instances. \section{Introduction} The concept of {\em fairness} is deeply ingrained in our psyche as a fundamental, essential ingredient of Human existence. Indeed the perception of fairness, broadly construed as accepting each others' equal right for well being, is arguably one of the most basic tenets of cooperative societies of individuals in general, and Human existence in particular. However, as fundamental as this concept may be, it is also extremely elusive: different societies have developed very different notions of fairness and equality among individuals, subject to different religious, ethical, and social beliefs; in particular, the intricate interplay between fairness and {\em justice,} which is yet another somewhat elusive concept, is often not well-defined and a matter of subjective interpretation. The concept is further complicated by the fact that human decisions are often made with incomplete information and limited resources. These two factors must be taken into account when evaluating whether decision-making processes are ``fair.'' Indeed, these two aspects of the problem have become increasingly prominent as societies grow and decision processes become more complex and algorithmic. One way that researchers are responding to these growing concerns is by attempting to formulate precise notions for {\em fairness} of decisions processes, e.g. \cite{dwork,Kleinberg}. While these notions do not intend to capture the complexities of the ethical, socio-economic, or religious aspects of fairness, they do consider the fairness aspects of statistical decision-making processes with incomplete information. Essentially, these notions accept the fact that a decision process with incomplete information will inevitably make errors relative to the desired full-information notion (which is treated as a given), and provide guidelines on how to ``distribute the errors fairly'' across individuals, or alternatively across groups of individuals. These definitions have proven to be meaningful and eye opening; in particular, it has been demonstrated that some very natural notions of ``fair distribution of errors'' are mutually inconsistent: No decision mechanism with incomplete information can satisfy all, except for in trivial cases \cite{Cho17,Kleinberg}. Faced with this basic impossibility, we would like to better understand the process of decision making with incomplete information, and use this understanding to propose ways to circumvent this impossibility. Specifically, we concentrate on the task of post-processing a calibrated soft classifier under group fairness constraints. We suppose that individuals belong to one of two or more disjoint \emph{protected groups}. Our overall task is to decide whether a given individual has some hidden binary property $B$ in a way that ensures ``fair balancing of errors'' across the groups. For that purpose, we consider the following two-stage mechanism. The first stage consists of constructing a classifier $\mathmode{\hat{S}}$ that outputs for each individual $x$ a score $\ps \in [0,1]$ that is related to the chance that $x$ has property $B$. The only requirement we make of $\mathmode{\hat{S}}$ is group-wise calibration: for both $g_1$ and $g_2$, and for each $\ps\in[0,1]$, the fraction of individuals in the group that get score $\ps$ and have the property, out of all individuals in the group that get score $\ps$, is $\ps$. The second stage takes as input the output $\ps = \mathmode{\hat{S}}(x)$ of the first stage and the group to which $x$ belongs, and outputs a binary decision: its best guess at whether $x$ has property $B$. An attractive aspect of this two-stage mechanism is that each stage can be viewed as aimed at a different goal: The first stage is aimed at gathering information and providing the best accuracy possible, with only minimal regard to fairness (i.e only group-wise calibration). The second stage is aimed to extract a decision from the information collected in the first stage, while making sure that the errors are distributed ``fairly.'' To further focus our study, we take the first stage as a given and concentrate on the second. That is, we consider the problem of \emph{post-processing} the scores given by the calibrated soft classifier $\mathmode{\hat{S}}$ into binary predictions. A representative example is a judge making a bail decision based on a score provided by a software package. Following \cite{Cho17,EqualOpp} we consider the following four performance measures for the resulting binary classifier: the \emph{positive predictive value (PPV)}, namely the fraction of individuals that have the property among all individuals that the classifier predicted to have the property; The \emph{false positive rate (FPR)}, namely the fraction of individuals that were predicted to have the property among all individuals that don't have the property; The \emph{negative predictive value (NPV)} and \emph{false negative rate (FNR)}, which are defined analogously. Ideally, we would like to equalize each one of the four measures across the groups, i.e. the measure will have the same value when restricted to samples from each group. Unfortunately, however, we know that this is impossible in general \cite{Cho17,Kleinberg}. This leads us to a broad question that motivates our work: \begin{quote} Under what conditions can we post-process a calibrated soft classifier's outputs so that the resulting hard classifier equates a subset of $\{\PPV, \NPV, \FNR, \FPR\}$ across a set of protected groups? How can we balance these conflicting goals? \end{quote} \paragraph{Results: Post-Processing With Thesholds.} In a first set of results we consider the properties obtained by post-processing via a ``threshold'' mechanism. Naively, a threshold post-processing mechanism would return 1 for individual $x$ whenever the calibrated score $\ps(x)$ is above some fixed threshold, and return 0 otherwise. We somewhat extend this mechanism by allowing the post-processor ``fine-tune'' its decision by choosing the output probabilistically whenever the result of the soft classifier is exactly the threshold. We first observe that the popular and natural post-processing method of using a single threshold across all groups has an inherent deficiency: No such mechanism can in general guarantee equality of either PPV or NPV across the protected groups. We then show that, when using different thresholds for the different groups, one can equalize \emph{either} PPV or NPV (but not both) across the two groups, assuming the profile of $\mathmode{\hat{S}}$ has some non-degeneracy property. The combination of the impossibility of single threshold and the possibility of per-group threshold also stands in contrast to the belief that a soft classifier that is calibrated across both groups allows ``ignoring'' group-membership information in any post-processing decision \cite{MP17}. Indeed, the conversion to a binary decision ``loses information'' in different ways for the two groups, and so group membership becomes relevant again after post-processing. \paragraph{Results: Adding deferrals.} For the second set of results we consider post-processing strategies that do not always output a decision. Rather, with some probability the output is $\pX$, or ``I dont know", which means that the decision is deferred to another (hopefully higher quality, even if more expensive) process. Let us first present our technical results and then discuss potential interpretations and context. The first strategy is a natural extension of the per-group threshold: we use \emph{two} thresholds per group, returning 1 above the right threshold, 0 below the left threshold, and $\pX$ between the thresholds. We show that there always exists a way to choose the thresholds such that, conditioned on the decision not being $\pX$, both the PPV and NPV are equal across groups. Next we show a family of post-processing strategies where, conditioned on the decision not being $\pX$, {\em all four quantities} (PPV, NPV, FPR, FNR) are equal across groups. All strategies in this family have the following structure: Given an individual $x$, the strategy first makes a randomized decision whether to defer on $x$, where the probability depends on $\mathmode{\hat{S}}(x)$ and the group membership of $x$. If not deferred, then the decision is made via another post-processing technique. One method for determining the probabilities of deferrals is to make sure that, the distribution of scores returned by the calibrated soft classifier \emph{conditioned on not deferring,} is equal for the two groups (That is, let $p_{s,g}$ denote the probability, restricted to group $g$, that an element gets score $s$ conditioned on not deferring. Then for any $s$, we choose deferral probabilities so that $p_{s,g_1}=p_{s,g_2}$.) The resulting classifier can then be post-processed in \emph{any} group-blind way (say, via a single threshold mechanism as described above). Of course, the fact that all four quantities are equalized conditioned on not deferring does not, in and of itself, provide any guarantees regarding the fairness properties of the overall decision process --- which includes also the downstream decision mechanism. For one, it would be naive to simply assume that fairness ``composes'' \cite{DI18}. Furthermore, the impossibility of \cite{Cho17,Kleinberg} says that the overall decision-making process cannot possibly equalize all four measures. However, in some cases one can provide alternative (non-statistical) justification for the fairness of the overall process: For instance, if the downstream decision process never errs, the overall process might be considered ``procedurally fair.'' We present more detailed reflections on our deferral-based approach in Section~\ref{sec:discussion}. We note that deferring was considered in machine learning in a number of contexts, including the context of fairness-preservation \cite{MPZ17}. In these works, the classifier typically punts only when its confidence regarding some decision is low. By contrast, we use deferrals in order to ``equalize'' the probability mass functions of the soft classifier over the two groups, which may involve deferring on individuals for whom there is higher confidence. Indeed, deferring on some higher-confidence individuals seems inherent to our goal of equalizing PPV, NPV, FPR, and FNR while keeping the deferral rate low. Furthermore, our framework allows for a wide range of deferral strategies which might be used to promote additional goals. Pursuing alternate strategies for deferral is an interesting direction for future work. \paragraph{Experimental results.} We test our methodology on the Broward county dataset with COMPAS scores made public by ProPublica~\cite{angwin2016machine} in order to better understand its strengths and limitations. Indeed, it has been shown that the COMPAS scoring mechanism is an approximately calibrated soft classifier. We first ran our two-threshold post-processing mechanism and obtained a binary decision algorithm which equalizes both PPV and NPV across Caucasians and African-Americans. We then ran our post-processing mechanism with deferrals to equalize all four of PPV, NPV, FPR, FNR across the two groups, with three different methods for deciding how to defer: In the first method, decisions are deferred only for Caucasians; in the second, decisions are deferred only for African Americans; in the third method, decisions are deferred for an equal fraction of Caucasians and of African Americans. This fraction is precisely equal to the statistical (total variation) distance between the distributions of scores produced by the soft classifier on the two groups. More details about the results along with figures are given in Section~\ref{sec:experiments}. \paragraph{Extensions and open problems.} As just mentioned, a natural question is to find alternative ways for deciding when to defer, along with ways to argue fairness properties for the overall combined process. We also leave open the setting where individuals belong to multiple, potentially intersecting groups as in \cite{Multicalibration,gerrymandering}. Yet another question is to consider additional (or alternative) properties of soft classifiers that will make for more efficient or effective post-processing. \subsection{Related work} We briefly describe the works most closely related to ours, though both the list of works and their summaries are inevitably too short. Our work fits in a research program on group fairness notions following the work of Chouldechova \cite{Cho17} and Kleinberg et~al. \cite{Kleinberg}. Those works demonstrate the inherent infeasibility of simultaneously equalizing a collection of measures of group accuracy. Our work considers the notions of calibration as formalized in \cite{Pleiss} and those of PPV, NPV, FPR, and FNR from \cite{Cho17} and \cite{Kleinberg}. The power of post-processing calibrated scores into decisions using threshold classifiers in the context of fairness has been previously studied by Corbett-Davies, Pierson, Feller, Goel, and Huq \cite{Corbett}. As in our work, they show that it is feasible to equalize certain statistical fairness notions across groups using (possibly different) thresholds. They additionally show that these thresholds are in some sense optimal. Whereas \cite{Corbett} focuses on statistical parity, conditional statistical parity, and false positive rate, our most comparable results consider PPV. In our work, we further show that in some cases thresholds fail to equalize both PPV and NPV (called \emph{predictive parity} by \cite{Cho17}), unless we also allow our post-processor to defer on some inputs. Our work also studies methods of post-processing that are much more powerful than thresholding, especially when allowing deferrals. On the technical side, \cite{Corbett} assumes that their soft classifiers are supported on the continuous interval $[0,1]$, simplifying the analyses. We instead study classifiers with finite support as it is closer to true practice in many settings (e.g., COMPAS risk scores). Using deferrals to promote fairness has been considered also in the work of Madras, Pitassi, and Zemel \cite{MPZ17}. Specifically they consider how deferring on some inputs may promote a combination of accuracy and fairness, especially when taking explicit account of the downstream decision maker. They make use of two-threshold deferring post-processors like those discussed in Section 5. While it helped inform our work, \cite{MPZ17} takes a more experimental approach and focuses on minimizing the ``disparate impact,'' a measure of total difference in classification error between groups, while maximizing accuracy. One important difference between our works is that Madras et al.~distinguish between ``rejecting'' and ``deferring.'' Rejecting is oblivious as to properties of the downstream decision maker, while deferring tries to counteract the biases of the decision maker. Our work considers only the former notion, but uses the term ``defer" instead of ``reject." \section{The Limits of Post-Processing} \label{sec:postprocess-limits} Suppose throughout this section that $\mathmode{\hat{S}}$ is a groupwise calibrated soft classifier. Our goal in this section is to make binary predictions based on $\mathmode{\hat{S}}(x)$ --- and possibly the group $\mathmode{G}(x)$ --- subject to equalizing PPV and/or NPV among groups. That is, we wish to make a prediction using a hard post-processor $\post$ such that $\mathmode{\hat{Y}} =\post \circ \mathmode{\hat{S}}$ equalizes PPV and/or NPV among groups. We chose to concentrate first on (the limitations of) equalizing PPV and NPV rather than FPR and FNR due to the conceptual similarity of PPV and NPV to calibration. Also, the case of equalizing false positive rates with thresholds is addressed in ~\cite{Corbett}. \subsection{Fairness Conditions for Post-Processors} \label{sec:fair-post-process} We begin by making a simple observation about post-processing that provides some geometric intuition for the rest of this section. Just as in Proposition~\ref{prop:baserate-calibrated}, we can express $\PPV_{\mathmode{\hat{Y}}, g}$ and $\NPV_{\mathmode{\hat{Y}}, g}$ succinctly in terms of conditional expectations over the AP $\mathmode{\hat{\mathcal{P}}}_g$. \begin{proposition} \label{prop:ppv-as-cond-exp} Let $\mathmode{\hat{Y}} = \mathmode{\hat{D}} \circ \mathmode{\hat{S}}$ be a hard classifier that is non-trivial for all $g \in \mathmode{\mathcal{G}}$ where $\mathmode{\hat{S}}$ is groupwise calibrated with respect to $\mathmode{\mathcal{G}}$. For any $g \in \mathmode{\mathcal{G}}$ we have: \begin{align*} \PPV_{\mathmode{\hat{Y}},g} &= \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pT] \\ \NPV_{\mathmode{\hat{Y}},g} &= 1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pF] \end{align*} \end{proposition} \begin{proof}[Proof of Proposition~\ref{prop:ppv-as-cond-exp}] We first observe that the output of a post-processor is conditionally independent of the true type, conditioned on the output of the soft classifier it is post-processing and the group membership: \begin{fact} \label{fact:conditional-independence} Consider any randomized function $\mathmode{\hat{D}}: [0,1] \times \mathmode{\mathcal{G}} \to \{0,1\}$. Since $\mathmode{\hat{D}}$ is a randomized function with inputs $\ps \in [0,1]$ and $g \in \mathmode{\mathcal{G}}$, we have that \begin{equation} \label{eq:conditional-independence} (\mathmode{\hat{D}}(\mathmode{\hat{S}}(X),\mathmode{G}(X)) \perp \mathmode{Y}(X)) \mid (\mathmode{\hat{S}}(X),\mathmode{G}(X)) \end{equation} or in other words that $\mathmode{\hat{D}}(\mathmode{\hat{S}}(X), \mathmode{G}(X))$ is conditionally independent of the true type $\mathmode{Y}(X)$, since fixing the inputs to $\mathmode{\hat{D}}$ makes its output purely a function of its random string. \end{fact} Now recall that $\PPV_{\mathmode{\hat{Y}},g}$ and $\NPV_{\mathmode{\hat{Y}},g}$ are well-defined for all groups because $\mathmode{\hat{Y}}$ is non-trivial on all groups. We then have \begin{align*} \PPV_{\mathmode{\hat{Y}}, g} &= \Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{Y}}(X_g) = \pT] \\ &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \Pr[\mathmode{Y}(X_g) = 1 , \mathmode{\hat{S}}(X_g) = \ps \mid \post(\mathmode{\hat{S}}(X_g), g) = \pT] \\ &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{S}}(X_g) = \ps, \post(\mathmode{\hat{S}}(X_g), g)] \\ & \quad \cdot \Pr[\mathmode{\hat{S}}(X_g) = \ps | \post(\mathmode{\hat{S}}(X_g), g) = \pT] \\ &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \ps \Pr[\mathmode{\hat{S}}(X_g) = \ps | \post(\mathmode{\hat{S}}(X_g), g) = \pT] \\ &= \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pT] \end{align*} where the fourth line follows from the fact that the group $g$ is fixed within $\mathmode{\mathcal{X}}_g$, which lets us apply Fact~\ref{fact:conditional-independence}, and the fact that $\mathmode{\hat{S}}$ is calibrated on $g$. Similar simplifications give us that \begin{align*} \NPV_{\mathmode{\hat{Y}}, g} &= \Pr[\mathmode{Y}(X_g) = 0 \mid \post(\mathmode{\hat{S}}(X_g),g) = \pF] \\ &= 1 - \Pr[\mathmode{Y}(X_g) = 1 \mid \post(\mathmode{\hat{S}}(X_g),g) = \pF] \\ &= 1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \post(\mathmode{\hat{S}}(X_g), g) = \pF] \end{align*} \end{proof} Using Proposition~\ref{prop:ppv-as-cond-exp}, we can geometrically see how certain post-processing decision rules will interact with the AP for a group $g$. For example, using a threshold, the expected true positives, true negatives, false positives, and false negatives can be estimated, as shown in Figure \ref{fig:calibration-line-decide}. \begin{figure} \centering \includegraphics[width=0.5\hsize]{graphs/calibration_line_decide.png} \caption{Accuracy Profiles (APs, definition \ref{defn:docs}) yield useful geometric intuitions, which come from the calibration property (definition \ref{defn:calibration}). With a threshold, the expected PPV, NPV, FPR, and FNR can be seen visually.} \label{fig:calibration-line-decide} \end{figure} Proposition~\ref{prop:fpr-as-cond-exp} below gives a characterizations of the false positive and false negative rates in a manner analogous to how Proposition~\ref{prop:ppv-as-cond-exp} describes PPV and NPV: \begin{proposition} \label{prop:fpr-as-cond-exp} Let $\mathmode{\hat{Y}}$ and $\mathmode{\hat{S}}$ be hard and soft classifiers as in Proposition \ref{prop:ppv-as-cond-exp}. Then for any $g \in \mathmode{\mathcal{G}}$, \begin{align*} \FPR_{\mathmode{\hat{Y}},g} &= \Pr[\mathmode{\hat{Y}}(X_g) = \pT] \cdot \frac{1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pT]}{1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g)]} \\ \FNR_{\mathmode{\hat{Y}},g} &= \Pr[\mathmode{\hat{Y}}(X_g) = \pF] \cdot \frac{\mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pF]}{\mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g)]} \end{align*} Assume that $Pr[\mathmode{Y}(X_g) = 1] > 0$ and $Pr[\mathmode{Y}(X_g) = 0] > 0$ (that is, assume $0 < \BR_g < 1$) so that $\FPR$ and $\FNR$ are well-defined. \end{proposition} \begin{proof}[Proof of Proposition~\ref{prop:fpr-as-cond-exp}] We give the proof for $\FPR$, and the proof for $\FNR$ is similar. By applying Bayes' rule, we can write \begin{align} \FPR_{\mathmode{\hat{Y}}, g} &= \Pr[\mathmode{\hat{Y}}(X_g) = 1 \mid \mathmode{Y}(X_g) = 0] \nonumber \\ &= \Pr[\mathmode{Y}(X_g) = 0 \mid \mathmode{\hat{Y}}(X_g) = 1] \cdot \frac{\Pr[\mathmode{\hat{Y}}(X_g) = 1]}{\Pr[\mathmode{Y}(X_g) = 0]} \label{eq:fpr-as-cond-exp-1} \end{align} Noting that $\Pr[\mathmode{Y}(X_g) = 0 \mid \mathmode{\hat{Y}}(X_g) = 1] = 1 - \PPV_{\mathmode{\hat{Y}}, g}$, we can apply Proposition \ref{prop:ppv-as-cond-exp} and rearrange to write the RHS of Equation~\ref{eq:fpr-as-cond-exp-1} as follows. \begin{equation} \label{eq:fpr-as-cond-exp-2} \text{RHS of (\ref{eq:fpr-as-cond-exp-1})} = \Pr[\mathmode{\hat{Y}}(X_g) = 1] \cdot \frac{1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g) \mid \mathmode{\hat{Y}}(X_g) = \pT]}{\Pr[\mathmode{Y}(X_g) = 0]} \end{equation} We note that $\Pr[\mathmode{Y}(X_g) = 0] = 1 - \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g)]$ (Proposition~\ref{prop:baserate-calibrated}). Substituting this in to the RHS of Equation~\ref{eq:fpr-as-cond-exp-2}, we conclude the result. \end{proof} \subsection{General impossibility of equalizing PPV, NPV} It is not always possible to directly post-process a soft groupwise calibrated classifier into a hard one with equalized PPV (or NPV) for all groups, as we demonstrate by counterexample in Proposition~\ref{prop:info-theory-impossibility-3}. Before proceeding, we note that our counterexample is somewhat contrived---in particular, the AP induced by the soft classifier $\mathmode{\hat{S}}$ in the proof of Proposition~\ref{prop:info-theory-impossibility-3} takes only one value on each group. When the AP of $\mathmode{\hat{S}}$ is more nicely structured on each group, we will see that there are general methods to equalize PPV (or NPV). \begin{proposition} \label{prop:info-theory-impossibility-3} Fix two disjoint groups $g_1$ and $g_2$ with respective base rates $\BR_1$ and $\BR_2$ such that $\BR_1 \neq \BR_2$. Then there exists a soft classifier $\mathmode{\hat{S}}$ that is groupwise calibrated, but for which there is no post-processor $\mathmode{\hat{D}}: [0,1] \times \mathmode{\mathcal{G}} \to \mathmode{\{0,1\}}$ such that $\mathmode{\hat{D}} \circ \mathmode{\hat{S}}$ equalizes PPV, unless $\Pr[\mathmode{\hat{D}}(\BR_i, g_i) = 1] = 0$ for $i=1$ or 2. \end{proposition} \begin{proof}[Proof of Proposition \ref{prop:info-theory-impossibility-3}] Consider the classifier $\mathmode{\hat{S}}$ such that $\mathmode{\hat{S}}(x) = \BR_1$ if $x \in g_1$ and $\mathmode{\hat{S}}(x) = \BR_2$ if $x \in g_2$. This classifier is trivially groupwise calibrated. Since $\Pr[\mathmode{\hat{D}}(\BR_i, g_i) = 1] > 0$ for $i=1$ and 2, we conclude that $\PPV_{\mathmode{\hat{Y}}, g_i}$ is well-defined for $g_1$ and $g_2$. The proof now follows from the characterization of PPV in Proposition~\ref{prop:ppv-as-cond-exp}. This is because $\PPV_{\mathmode{\hat{Y}}, g_i}$ is equal to the expectation of $\mathmode{\hat{S}}(X)$ where $X$ is drawn from a distribution with support contained in $g_i$, and hence it is equal to $\BR_{i}$, and $\BR_{1} \neq \BR_{2}$. \end{proof} The analogous statement regarding impossibility of equalizing NPV is formulated as Proposition~\ref{prop:info-theory-impossibility-npv} in Appendix~\ref{sec:appendix-npv}. \subsection{A niceness Condition for APs} We now give a non-degeneracy condition condition on APs motivated by the impossibility result for post-processing given by Proposition~\ref{prop:info-theory-impossibility-3}. \begin{definition}[Niceness of APs] \label{def:nice-docs} Let $\mathmode{\mathcal{G}}$ be a set of groups. A distribution on calibrated scores $\mathmode{\hat{\mathcal{P}}}$ is \emph{nice} if $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)$ is the same for all $g \in \mathmode{\mathcal{G}}$. \end{definition} Note that this condition rules out the counterexample given by Proposition~\ref{prop:info-theory-impossibility-3}, since the APs in the counterexample had different (in fact, disjoint) supports for different groups. Hence, we can hope to successfully post-process soft classifiers with nice APs. \subsection{Equalizing PPV or NPV by Thresholding} \label{sec:thresholds} We pay special attention to thresholds because they are simple to understand and therefore very widely used. We use one slight modification to deterministic thresholds that adds an element of randomness: if a score is \emph{at} the threshold, we randomly determine which side of the threshold it falls on, according to a distribution defined below. \begin{definition}[Threshold Post-Processor]\label{defn:threshold-pp} A threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} : [0,1] \times \mathmode{\mathcal{G}} \rightarrow \{1,0\}$ is a function from a score $s \in [0,1]$ and a group $g \in \mathmode{\mathcal{G}}$, parameterized by $\tau$ and $\mathcal{R}$. The threshold parameter $\tau : \mathmode{\mathcal{G}} \rightarrow [0,1]$ specifies the threshold for the group $g$, and $\mathcal{R} : \mathmode{\mathcal{G}} \rightarrow [0,1]$ is the probability of returning 1 when the input score $s$ is on the threshold $\tau(g)$. It returns the following outputs: \begin{align*} \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}(\ps, g) = \begin{cases} \pT & \ps > \tau(g) \\ \pF & \ps < \tau(g) \\ \pT \text{ w.p. } \mathcal{R}(g) \text{ else } \pF & \ps = \tau(g) \end{cases} \end{align*} \end{definition} In the setting of an infinite number of scores and a continuous domain (i.e. scores are represented by a probability density function instead of a probability mass function), we can use purely deterministic threshold functions in which $\mathcal{R} \equiv 1$, and achieve very similar results for the rest of this section. If both $\mathmode{\tau}(g)$ and $\mathcal{R}(g)$ do not vary across groups $g \in \mathmode{\mathcal{G}}$, then the post-processor is the same across groups. In this case, we will call the post-processor a \emph{group blind} threshold post-processor, and will overload $\mathmode{\tau}$ and $\mathcal{R}$ to be constants. We now study the effectiveness of thresholds for post-processing soft classifiers with nice APs. The main takeaways are: \begin{enumerate} \item If the APs are nice, then threshold post-processors can equalize PPV (Propositions~\ref{prop:trivial-threshold-equalizes} and~\ref{prop:2-thresh-equal-ppv}). \item However, group blind threshold post-processors are rather limited in their ability to equalize PPV (Proposition~\ref{prop:single-threshold-cannot-equalize}). \item Furthermore, equalizing PPV with thresholds (group blind or otherwise) may have undesirable social consequences. \item Thresholds cannot always equalize PPV and NPV simultaneously, even for nice APs (Proposition~\ref{prop:ppv-npv-impossibility}). \end{enumerate} Results 1-3 also apply to NPV (see Proposition~\ref{prop:single-threshold-cannot-equalize-npv}). \subsubsection{Group Blind Thresholds} We begin by classifying which group-blind threshold post-processors can equalize PPVs across all groups (Propositions~\ref{prop:trivial-threshold-equalizes} and~\ref{prop:single-threshold-cannot-equalize}). By symmetry, our arguments give a similar characterization for equalizing NPVs. \begin{proposition}\label{prop:trivial-threshold-equalizes} For every nice groupwise calibrated soft classifier $\mathmode{\hat{S}}$ and for every group-blind threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ such that $\mathmode{\tau}(g) = \max(\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g))$ for all $g$, then the composed classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}$ equalizes PPVs across all groups for which $\mathmode{\hat{Y}}$ is non-trivial. \end{proposition} The existence of the threshold post-processors in Proposition~\ref{prop:trivial-threshold-equalizes} follows from the assumed finiteness of the range of the soft classifier. In the case where the range of the soft classifier is infinite, such post-processors may not exist. \begin{proof}[Proof of Proposition~\ref{prop:trivial-threshold-equalizes}] Any of the given post-processors only ever maps the largest score in the support of $\mathmode{\hat{\mathcal{P}}}_g$ to 1, for all groups $g$. Hence, $\PPV_g$ is exactly the largest score in $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)$. By the assumption that $\mathmode{\hat{\mathcal{P}}}$ is nice, $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)$ is the same for all groups $g$, and hence the PPV is equalized across groups. \end{proof} We prove the analogous statement for NPV in Proposition~\ref{prop:trivial-threshold-equalizes-npv} in the Appendix. We proceed to show that the post-processors described in Proposition~\ref{prop:trivial-threshold-equalizes} are the \emph{only} non-trivial, group blind post-processors that equalize PPV across groups in general, as we prove in Proposition~\ref{prop:single-threshold-cannot-equalize}. \begin{proposition}\label{prop:single-threshold-cannot-equalize} There exists a groupwise-calibrated soft classifier with a nice AP for which no non-trivial group blind threshold post-processor, other than the ones in Proposition~\ref{prop:trivial-threshold-equalizes}, can equalize PPV across groups. \end{proposition} At a high level, the proof of Proposition~\ref{prop:single-threshold-cannot-equalize} works as follows: We can make the AP on one group uniform, and the AP of another group strictly increasing. Then, threshold post-processors naturally favor the latter group, as the AP for that group gives more weight to higher scores than lower ones when compared to the former AP. Our characterization of PPV (Proposition~\ref{prop:ppv-as-cond-exp}) features prominently in the proof. In preparation to proving Proposition \ref{prop:single-threshold-cannot-equalize}, we first prove the following lemma: \begin{lemma} \label{lem:ppv-thresh} Let $g_1, g_2 \in \mathmode{\mathcal{G}}$ be two different groups, and fix a group-blind threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$. Let $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$ be the expected conditional AP on scores $\geq \mathmode{\tau}$ that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_{g_1}$ over scores in group $g_1$ and conditioning on the scores that $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ sends to 1, and similarly let $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ denote the same type of conditional AP when starting with the $\mathmode{\hat{\mathcal{P}}}_{g_2}$ over scores in group $g_2$. \\ If $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ strictly stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$, then \[ \PPV_{\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}, g_1} < \PPV_{\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}, g_2} \] \end{lemma} \begin{proof} We use the characterization of PPV given in Proposition~\ref{prop:ppv-as-cond-exp}, for the special case where the post-processor thresholds as described above. We can write the PPV for group $g_1$ as follows: \begin{align} \PPV_{\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}, g_1} &= \mathmode{\mathop{\mathbb{E}}}_{X_1\mathmode{\sim} \mathmode{\mathcal{X}}_{g_1}}[\mathmode{\hat{S}}(X_1) \mid \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}(X_1) = 1] \nonumber \\ &= \mathmode{\mathop{\mathbb{E}}}_{\ps \mathmode{\sim} \mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}}[\ps] \label{eq:ppv-thresh-1} \end{align} where the second line follows from the definition of $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$. Similarly, we have that \begin{equation} \label{eq:ppv-thresh-2} \PPV_{\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}, g_2} = \mathmode{\mathop{\mathbb{E}}}_{\ps \mathmode{\sim} \mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}}[\ps] \end{equation} Since $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$, the expectation on the RHS of Equation~\ref{eq:ppv-thresh-2} is larger than the expectation on the RHS of Equation~\ref{eq:ppv-thresh-1}, yielding the result. \end{proof} \begin{proof}[Proof of Proposition \ref{prop:single-threshold-cannot-equalize}] Fix two groups $g_1$ and $g_2$ and a finite set of points $S \subset [0,1]$ such that the PMFs of the soft classifier $\mathmode{\hat{S}}$ on $g_1$ and $g_2$ have support equal to $S$ - that is, $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_1}) = \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_2}) = S$. For concreteness, suppose that $|S| = 10$. Let the PMFs of the soft classifier $\mathmode{\hat{S}}$ on these two groups respectively be given by $\mathmode{\hat{\mathcal{P}}}_{g_1}(\ps) = 1/ |\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_1})|$ and $\mathmode{\hat{\mathcal{P}}}_{g_2}(\ps) \propto \ps$ for all $\ps \in S$, where $\mathmode{\hat{\mathcal{P}}}_{g_2}$ is normalized with a constant such that it sums to 1. Fix a group blind threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ that is not one of the ones mentioned in Proposition~\ref{prop:trivial-threshold-equalizes}. Since $\mathmode{\hat{S}}_{(\mathmode{\tau}, \mathcal{R})}$ is group blind, its threshold function is a constant which we name~$\mathmode{\tau}$. Let $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$ be the expected conditional AP on scores $\geq \mathmode{\tau}$ that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_{g_1}$ over scores in group $g_1$ and conditioning on the scores that $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ sends to 1. We can get this conditional PMF by removing scores $\ps < \mathmode{\tau}$, multiplying $\mathmode{\hat{\mathcal{P}}}_{g_1}(\mathmode{\tau})$ by $\mathcal{R}$, and re-normalizing the remaining values to get a distribution. Let $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ be defined similarly. We claim that $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ strictly stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$, which allows us to invoke Lemma~\ref{lem:ppv-thresh} to conclude that the PPV on the two groups are unequal. We now show that $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ strictly stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$. This is clearly true by design if $\mathcal{R} = 0$ or $1$: in this case, the post-processor is simply a deterministic threshold function, and we know by design that $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$ is uniform while $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ is a strictly increasing function. If $\mathcal{R} = r$ for some $r \in (0,1)$, then we can write $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$ as a convex combination of $\mathmode{\hat{\mathcal{P}}}_{g_1, \mathmode{\tau}, 0}$ and $\mathmode{\hat{\mathcal{P}}}_{g_1, \mathmode{\tau}, 1}$ (with weight $r$ on the distribution where $\mathcal{R} = 1$, and weight $1-r$ on the distribution where $\mathcal{R} = 0$). We can write $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ as the same convex combination of the conditional distributions over $g_2$ where $\mathcal{R} = 0$ and $\mathcal{R} = 1$. Since we already established stochastic domination for the cases where $\mathcal{R} = 0$ and $\mathcal{R} = 1$, this establishes stochastic domination for the case where $\mathcal{R} \in (0,1)$. \end{proof} We achieve the same result for NPV in Proposition~\ref{prop:single-threshold-cannot-equalize-npv}. In the setting where the range of the soft classifier is infinite and continuous, we show in Proposition~\ref{prop:single-threshold-cannot-equalize-cont} that a similar negative result holds, but without the existence of the classifiers in Proposition~\ref{prop:trivial-threshold-equalizes}. Propositions \ref{prop:trivial-threshold-equalizes} and \ref{prop:single-threshold-cannot-equalize} demonstrate the limitations of group blind thresholds on calibrated scores. Though this method of post-processing has social appeal, it does not actually preserve the fairness properties that one would expect. In the next section we repeat our analysis but relax our group blindness requirement. \subsubsection{Group-Aware Thresholds} If we allow the different groups to have different thresholds, then we grant ourselves more degrees of freedom to be able to satisfy binary fairness constraints. In particular, we can equalize PPV across groups in a more meaningful way than done in Proposition~\ref{prop:trivial-threshold-equalizes}. Recall that the group blind threshold post-processors in Proposition~\ref{prop:trivial-threshold-equalizes} are the only group blind threshold post-processors that work on certain nice APs (shown in Proposition~\ref{prop:single-threshold-cannot-equalize}). However, these post-processors have the property that the only score they map to $\pT$ is the largest score in the support, which can be undesirable for many applications. In particular, all classifiers in Proposition~\ref{prop:single-threshold-cannot-equalize} make the PPV on each group $g_i$ equal to the maximum score in the support of $\mathmode{\hat{\mathcal{P}}}_{g_i}$. However, the (not-necessarily-group-blind) threshold post-processors in Proposition~\ref{prop:2-thresh-equal-ppv} below can make the PPV on each group equal to any fixed value between the maximum base rate of $g_i$ and the maximum score in $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_i})$. \begin{proposition}\label{prop:2-thresh-equal-ppv} Let $\mathmode{\mathcal{G}}$ be a set of groups. For any soft classifier $\mathmode{\hat{S}}$ with a nice AP $\mathmode{\hat{\mathcal{P}}}$ such that $\mathmode{\hat{S}}$ is groupwise calibrated over $\mathmode{\mathcal{G}}$ and $|\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)| \geq 2$ for all $g \in \mathmode{\mathcal{G}}$, then there exists a non group blind, non-trivial threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ that is not one of the ones from Proposition~\ref{prop:trivial-threshold-equalizes} such that the hard classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}$ equalizes PPV across $\mathmode{\mathcal{G}}$. This holds even if we require that the PPV of all the groups is equal to an arbitrary value in $(\max_i \BR_{g_i}, \ps_{max})$, where $\max_i \BR_{g_i}$ is the maximum base rate among the groups $g_i \in \mathmode{\mathcal{G}}$ and $\ps_{max}$ is the maximum score in the support of $\mathmode{\hat{\mathcal{P}}}_{g_i}$.\footnote{For the case where the support of $\mathmode{\hat{\mathcal{P}}}_{g_i}$ is infinite, $\ps_{max}$ should be the supremum of scores.} Moreover, since this post-processor is not group blind, it is not one of the post-processors described in Proposition \ref{prop:trivial-threshold-equalizes}. \end{proposition} In preparation to proving Proposition \ref{prop:2-thresh-equal-ppv}, we first prove the following claim: \begin{claim}[Monotonicity of PPV and NPV] \label{claim:ppv-monotonicity} \label{claim:npv-monotonicity} Fix a soft classifier $\mathmode{\hat{S}}$ and corresponding AP $\mathmode{\hat{\mathcal{P}}}$, as well as a group $g$. Fix group blind threshold post-processors $\mathmode{\hat{D}}_{\mathmode{\tau}_1, \mathcal{R}_1}$ and $\mathmode{\hat{D}}_{\mathmode{\tau}_2, \mathcal{R}_2}$ such that either $\mathmode{\tau}_1 < \mathmode{\tau}_2$ or $\mathmode{\tau}_1 = \mathmode{\tau}_2$ and $\mathcal{R}_1 \geq \mathcal{R}_2$. Then:\\ (a) $\PPV_{\mathmode{\hat{D}}_{\mathmode{\tau}_1, \mathcal{R}_1} \circ \mathmode{\hat{S}}, g} \leq \PPV_{\mathmode{\hat{D}}_{\mathmode{\tau}_2, \mathcal{R}_2} \circ \mathmode{\hat{S}}, g}$\\ (b) $\NPV_{\mathmode{\hat{D}}_{\mathmode{\tau}_1, \mathcal{R}_1} \circ \mathmode{\hat{S}}, g} \leq \NPV_{\mathmode{\hat{D}}_{\mathmode{\tau}_2, \mathcal{R}_2} \circ \mathmode{\hat{S}}, g}$ \end{claim} \begin{proof} We show conclusion (a); conclusion (b) is shown analogously. Define $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\tau}_1, \mathcal{R}_1}$ to be the conditional PMF on scores $\geq \mathmode{\tau}_1$ that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_{g}$ over scores in group $g$ and conditioning on the scores that $\mathmode{\hat{D}}_{\mathmode{\tau}_1, \mathcal{R}_1}$ sends to 1, and let $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\tau}_2, \mathcal{R}_2}$ be defined similarly (but for the threshold post-processor $\mathmode{\hat{D}}_{\mathmode{\tau}_2, \mathcal{R}_2}$). We claim that $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\tau}_2, \mathcal{R}_2}$ stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\tau}_1, \mathcal{R}_1}$, which yields the desired result by the characterization of PPV given in Proposition~\ref{prop:ppv-as-cond-exp} (and more explicitly written in Equations~\ref{eq:ppv-thresh-1} and~\ref{eq:ppv-thresh-2}). \end{proof} \begin{proof}[Proof of Proposition \ref{prop:2-thresh-equal-ppv}] Fix a soft classifier $\mathmode{\hat{S}}$ with a nice AP $\mathmode{\hat{\mathcal{P}}}$ that is group-wise calibrated over $g_1, \ldots, g_n$, and fix a desired value $v \in (\max_i \BR_{g_i}, \ps_{max})$. We will show that we can design a threshold post-processor $(\mathmode{\tau}, \mathcal{R})$ such that $\PPV_{g, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} = v$ for all groups $g$. Fix an arbitrary group $g_j$. We proceed via a continuity argument to show that we can tune the threshold on $g_j$ to achieve PPV equal to $v$. The maximum possible value for $\PPV_{g_j, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}}$ is $\ps_{max}$ (achieved when $\mathmode{\tau} = \ps_{max}$, by Claim~\ref{claim:ppv-monotonicity}), where $\ps_{max}$ is the largest score in the support, as defined in the proposition statement\footnote{We ignore the trivial post-processor that never maps anything to 1, and hence leaves the PPV undefined.}. Furthermore, note that, for any group, a lower bound on the PPV of a hard classifier on that group is the base rate of the group, where the lower bound is matched by the trivial post-processor that sends every score to 1. This follows from Claim~\ref{claim:ppv-monotonicity}. We now claim that there is a setting of $\mathmode{\tau}(g_j)$ and $\mathcal{R}(g_j)$ that achieves $\PPV_{g, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} = v$. We accomplish this by showing that there is a way to change $(\mathmode{\tau}(g_j), \mathcal{R}(g_j))$ such that the PPV decreases continuously. We first show: \begin{claim}[Continuity of PPV] \label{claim:ppv-continuity} Fix a soft classifier $\mathmode{\hat{S}}$ and corresponding AP $\mathmode{\hat{\mathcal{P}}}$, as well as a group $g$. Suppose we have two post-processing algorithms, $\mathmode{\hat{D}}_1$ and $\mathmode{\hat{D}}_2$. Let $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}$ be the expected conditional AP that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_{g}$ over scores in group $g$ and conditioning on the scores that $\mathmode{\hat{D}}_1$ sends to 1, and define $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}$ similarly. If $d_{TV}(\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}, \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}) < \mathmode{\epsilon}$, then $|\PPV_{g, \mathmode{\hat{D}}_1 \circ \mathmode{\hat{S}}} - \PPV_{g, \mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}}| < O(\mathmode{\epsilon})$. Or in words, if the distance between the conditional APs is small, then the difference in PPV is small. \end{claim} \begin{proof} Recall the characterization of PPV given in Proposition~\ref{prop:ppv-as-cond-exp} (and more explicitly written in Equation~\ref{eq:ppv-thresh-1}). This tells us that the PPV of group $g$ for the classifier $\mathmode{\hat{D}}_1 \circ \mathmode{\hat{S}}$ is exactly the expectation of a random variable distributed according to $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}$. Similarly, the PPV of group $g$ for the classifier $\mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}$ is the expectation of a r.v. distributed according to $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}$. Since both $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}$ and $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}$ have support bounded between 0 and 1, their expectations can differ by at most $\mathmode{\epsilon}$, from which the claim follows. For completeness, we prove this below. Suppose wlog that $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}$ has the larger expectation. Let $S = \{ \ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g): \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}(\ps) > \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}(\ps)\}$. Then: \begin{align*} \PPV_{g, \mathmode{\hat{D}}_1 \circ \mathmode{\hat{S}}} &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \ps \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}(\ps) \\ &= \PPV_{g, \mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}} + \sum_{\ps \in S} \ps (\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_1}(\ps) - \mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}(\ps)) \\ &< \PPV_{g, \mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}} + \mathmode{\epsilon} \end{align*} where in the second line we use the fact that $\PPV_{g, \mathmode{\hat{D}}_2 \circ \mathmode{\hat{S}}}$ is the expectation of $\mathmode{\hat{\mathcal{P}}}_{g, \mathmode{\hat{D}}_2}$, and in the last line we use the fact that $\ps \in [0,1]$ and that the TV-distance between the two distributions is less than $\mathmode{\epsilon}$. \end{proof} Now, consider the following way to change $(\mathmode{\tau}(g_j), \mathcal{R}(g_j))$. Fix $\mathmode{\epsilon} > 0$, and an initial setting for $(\mathmode{\tau}(g_j), \mathcal{R}(g_j))$ s.t. $\mathmode{\tau}(g_j)$ is not the smallest item in the support or $\mathcal{R}(g_j) > \mathmode{\epsilon}$. Reduce $\mathcal{R}(g_j)$ by $\mathmode{\epsilon}$, wrapping around on the interval $(0,1]$ and decreasing $\mathmode{\tau}(g_j)$ to the next largest item in the support when this would otherwise make $\mathcal{R}(g_j)$ negative. This very minor transformation to the threshold changes the AP conditional on outputting 1 very slightly - so slightly that the TV distance between the old conditional AP and the new AP is at most some $\mathmode{\epsilon}'$ which is a function of $\mathmode{\epsilon}$. This lets us apply Claim~\ref{claim:ppv-continuity} to show that the PPV changes by at most a function of $\mathmode{\epsilon}$. So as we take $\mathmode{\epsilon}$ going towards 0, this shows that the PPV changes by an amount going towards 0. This establishes that the PPV changes ``continuously'' with respect to this deforming procedure. By Claim~\ref{claim:ppv-monotonicity}, we have that the above deforming procedure can only decrease the PPV. Therefore, we can continuously decrease the PPV, starting from $\ps_{max}$, by continuously deforming the threshold post-processor with the method above. Note that $\ps_{\max} > v > \max_i \BR_{g_i} \geq \BR_{g_j}$. By the Intermediate Value Theorem, there must be a setting of $(\mathmode{\tau}(g_j), \mathcal{R}(g_j))$ such that $\PPV_{g_j, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} = v$. \end{proof} We assert the analogous statement for the case of NPV in Claim~\ref{claim:npv-continuity}. The corresponding statement for the case of soft classifiers with infinite range is asserted in Proposition~\ref{prop:equalize-ppv-cont}. \subsubsection{The Limitations of Thresholding} \label{sec:limits-of-thresholds} While Proposition~\ref{prop:2-thresh-equal-ppv} shows that a threshold post-processor can equalize the PPV across $n$ groups, this threshold post-processor can be unsatisfying from a social justice standpoint. Consider an example with two groups $g_1$ and $g_2$, where group $g_2$ is ``privileged'' by having a higher base rate of, say, credit worthiness. Suppose that we have an AP that is decreasing with respect to score on group $g_1$, and increasing with respect to score on group $g_2$. This is illustrated in Example \ref{ex:social-unsat} and Figure~\ref{fig:undesirable-results}. This means that a group blind threshold post-processor yields larger PPV on $g_2$, since large scores are given more weight in $g_2$. So, to equalize the PPV between the two groups, we will classify more low scores as positive in $g_2$ than $g_1$. This effectively means that our threshold on group $g_2$ is \emph{more lenient} than our threshold on $g_1$, which seems blatantly unfair, since $g_2$ is the privileged group in the first place! \begin{example}[Socially Unsatisfying Example] \label{ex:social-unsat} Fix groups $g_1$ and $g_2$, and we fix the AP of the soft classifier $\mathmode{\hat{S}}$ as follows. Let $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_i})$ be $\{0, 0.01, 0.02, \ldots, 1)$ for $i=1$ and $2$, let $\mathmode{\hat{\mathcal{P}}}_{g_1}(\ps) \propto a-\ps$ for appropriately selected constant $a> 0$ and let $\mathmode{\hat{\mathcal{P}}}_{g_2}(\ps) \propto \ps$. Group $g_2$ has a higher base rate and may have social advantages over group $g_1$. Let $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ be a non-trivial post-processor. If $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ were group blind, then by Lemma~\ref{lem:ppv-thresh}, since $\mathmode{\hat{\mathcal{P}}}_{g_2, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}}$ stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}}$, the PPV on $g_2$ must be larger than the PPV of $g_1$. To equalize PPV, by Claim~\ref{claim:ppv-monotonicity}, we must have either $\mathmode{\tau}(g_2) < \mathmode{\tau}(g_1)$, or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) < \mathcal{R}(g_1)$. The disadvantaged group is now held to a \emph{higher} standard than the privileged group to maintain equality of PPV. Figure~\ref{fig:undesirable-results} illustrates example thresholds that equalize the PPV. \end{example} \begin{figure} \centering \includegraphics[width=0.5\hsize]{graphs/undesirable_results_from_n_thresh.png} \caption{Accompanying Example~\ref{ex:social-unsat}, the PPV for both groups is 0.77. However, the threshold for $g_1$ (dark blue) is \emph{higher} than the threshold for $g_2$ (orange), even though $g_2$ is likely the more privileged group.} \label{fig:undesirable-results} \end{figure} The only property needed for Example~\ref{ex:social-unsat} is that the AP of one (privileged) group stochastically dominates the AP of another (unprivileged) group. We suspect that this to will occur in many settings. Indeed, the COMPAS scores we analyze in Section~\ref{sec:experiments} have this property, when considering Caucasians as the privileged group and African-Americans the unprivileged group. As in the above example, using group-aware thresholds to equalize PPV between the groups on COMPAS data results in a more permissive decision rule for Caucasians, demonstrating a problem with this approach (see also Figure~\ref{fig:compas-thresholds}). Furthermore, thresholding cannot in general equalize both PPV and NPV simultaneously, even for nice APs and using non-group blind thresholds. \begin{proposition} \label{prop:ppv-npv-impossibility} Fix groups $g_1$ and $g_2$. There exists a soft classifier $\mathmode{\hat{S}}$ with a nice AP~$\mathmode{\hat{\mathcal{P}}}$ such that no threshold post-processor can simultaneously equalize PPV and NPV between groups $g_1$ and $g_2$. \end{proposition} Before proving the statement, we first show that the base rates of $g_1$ and $g_2$ can be written as convex combinations of the $\PPV$ and $1 - \NPV$ on the respective groups: \begin{claim} \label{claim:baserate-convex-comb} Fix any group $g \in \mathmode{\mathcal{G}}$, and let the hard classifier $\mathmode{\hat{Y}}$ be non-trivial. Then the base rate of $g$ can be written as a convex combination of $\PPV_{g, \mathmode{\hat{Y}}}$ and $1 - \NPV_{g, \mathmode{\hat{Y}}}$ \end{claim} \begin{proof} \begin{align*} \BR_g &= \Pr[Y(X_g) = 1] \\ &= \Pr[Y(X_g) = 1 \mid \mathmode{\hat{Y}}(X_g) = 1] \Pr[\mathmode{\hat{Y}}(X_g) = 1] \\ & \quad + \Pr[Y(X_g) = 1 \mid \mathmode{\hat{Y}}(X_g) = 0] \Pr[\mathmode{\hat{Y}}(X_g) = 0] \\ &= \PPV_{g, \mathmode{\hat{Y}}} \cdot \theta + (1 - \NPV_{g, \mathmode{\hat{Y}}}) \cdot (1 - \theta) \end{align*} where $\theta := \Pr[\mathmode{\hat{Y}}(X_g) = 1]$. \end{proof} A simple intuition for the proof of Proposition~\ref{prop:ppv-npv-impossibility} is as follows. Suppose we have two groups, and the soft classifier is almost perfect on one group - for all but a small fraction of people, it gives the correct binary score, and gives the remaining people score 0.5. On the other group, it is the opposite - almost every person is given score 0.5, and there are only a few people given their ground truth score. The corresponding APs of each group have equal supports, and therefore are ``nice.'' However, it is clear that any threshold post-processor on the first group will have extremely high PPV and NPV, while any threshold post-processor on the second group will have to make decision on where to round the people in the 0.5 bucket, and will correspondingly either have low PPV or NPV. This example is somewhat unsatisfying, as the AP satisfies niceness by a technicality (for example, it is extremely close to a AP with disjoint supports between groups). The proof generalizes the above example to a case where scores for one group are slightly more ``correlated'' with the ground truth labels than scores for the other group. Appendix~\ref{sec:appendix-cont} shows the corresponding result when the range of the soft classifier is infinite. \begin{proof}[Proof of Proposition~\ref{prop:ppv-npv-impossibility}] Let $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g_i})$ be $\{ 0.1, 0.2, \ldots, 0.9\}$ for $i=1$ and $2$. Let $\mathmode{\hat{\mathcal{P}}}_{g_1}$ be uniform over scores, and let $\mathmode{\hat{\mathcal{P}}}_{g_2}(\ps) = -a(\ps - 1/2)^2 + b$ for some appropriately chosen constants $a, b \geq 0$ such that $\mathmode{\hat{\mathcal{P}}}_{g_2}$ is a valid probability distribution. We claim that there is no threshold post-processor that can equalize PPV and NPV simultaneously for these two groups. First, note that the base rates for the two groups are equal to $1/2$ by design, due to the symmetric nature of the AP on each group. Just like in the proof of Proposition~\ref{prop:single-threshold-cannot-equalize}, we use the notation $\mathmode{\hat{\mathcal{P}}}_{g_1, \geq (\mathmode{\tau}, \mathcal{R})}$ to denote the conditional AP supported on scores $\geq \mathmode{\tau}$ that results from starting with the AP $\mathmode{\hat{\mathcal{P}}}_{g_1}$ over all scores in group $g_1$ and conditioning on the scores that $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ sends to 1, and define $\mathmode{\hat{\mathcal{P}}}_{g_2, \geq (\mathmode{\tau}, \mathcal{R})}$ similarly. Let $\mathmode{\hat{\mathcal{P}}}_{g_i, \leq (\mathmode{\tau}, \mathcal{R})}$ denote the conditional AP starting from group $g_i$ and conditioning on the scores that $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ sends to 0. We proceed by a case analysis on the location of the threshold for group $g_1$ - that is, on $\mathmode{\tau}(g_1)$. \paragraph{\textbf{Case 1: $\mathmode{\tau}(g_1) \geq 1/2$.}} First, suppose additionally that $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ is group blind over $g_1, g_2$, then $\mathmode{\hat{\mathcal{P}}}_{g_2, (\mathmode{\tau}, \mathcal{R})}$ is strictly stochastically dominated by $\mathmode{\hat{\mathcal{P}}}_{g_1, (\mathmode{\tau}, \mathcal{R})}$ so the PPV is lower on $g_2$ than $g_1$ (Lemma~\ref{lem:ppv-thresh}). Therefore, to equalize the PPV between the two groups, the threshold on group $g_2$ must be to the ``right'' of the threshold on $g_1$ (that is, either $\mathmode{\tau}(g_2) > \mathmode{\tau}(g_1)$ or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) < \mathcal{R}(g_1)$), which follows from Claim~\ref{claim:ppv-monotonicity}. However, we claim that this setting of thresholds makes the NPV on group $g_2$ lower than the NPV on group $g_1$. It suffices to show that, for any constant threshold post-processor classifier $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ with $\mathmode{\tau}(g_1) = \mathmode{\tau}(g_2) \geq 1/2$, the NPV on group $g_2$ is lower than the NPV on group $g_1$. This implies that the same statement holds when either $\mathmode{\tau}(g_2) > \mathmode{\tau}(g_1)$ or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) < \mathcal{R}(g_1)$ as well, due to the monotonicity property of NPV (Claim~\ref{claim:npv-monotonicity}). This suffices to prove Proposition~\ref{prop:ppv-npv-impossibility} for the case when $\mathmode{\tau}(g_1) \geq 1/2$: we need to set $\mathmode{\tau}(g_2), \mathcal{R}(g_2)$ such that either $\mathmode{\tau}(g_2) > \mathmode{\tau}(g_1)$ or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) < \mathcal{R}(g_1)$ in order to equalize PPV, but this leaves the NPV on group $g_2$ lower than the NPV on group $g_1$. Now we proceed to show that the NPV is lower on $g_2$ when the threshold post-processor is constant. Fix a constant threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})}$ with $\mathmode{\tau} \geq 1/2$. We have already established that this means that $\PPV_{g_2, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} < \PPV_{g_1, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}}$. Now, since the base rates of $g_1$ and $g_2$ are equal, this implies that \[ 1 - \NPV_{g_2, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} > 1 - \NPV_{g_1, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}}\] Rearranging, this shows that $\NPV_{g_2, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}} < \NPV_{g_1, \mathmode{\hat{D}}_{(\mathmode{\tau}, \mathcal{R})} \circ \mathmode{\hat{S}}}$, finishing the proof of this case. \paragraph{\textbf{Case 2: $\mathmode{\tau}(g_1) < 1/2$.}} The argument in this case is symmetrical to the previous case, where we switch the roles of PPV and NPV in the argument. We sketch it for the sake of completeness. Fix a constant threshold post-processor such that $\mathmode{\tau}(g_1) = \mathmode{\tau}(g_2) < 1/2$. By design, $\mathmode{\hat{\mathcal{P}}}_{g_2, \leq (\mathmode{\tau}, \mathcal{R})}$ strictly stochastically dominates $\mathmode{\hat{\mathcal{P}}}_{g_1, \leq (\mathmode{\tau}, \mathcal{R})}$. Hence, the $\NPV$ on group $g_2$ is smaller than the NPV on group $g_1$ (this follows from an analogous version of Lemma~\ref{lem:ppv-thresh} for NPV instead of PPV). This means that the threshold post-processor cannot be constant to equalize $\NPV$s - it must be moved such that either $\mathmode{\tau}(g_2) < \mathmode{\tau}(g_1)$ or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) > \mathcal{R}(g_1)$ (Claim~\ref{claim:npv-monotonicity}). However, by the same convex combination argument as in the previous case, we get that any such constant threshold post-processor must make the PPV on $g_2$ strictly smaller than the PPV on $g_1$. By the monotonicity of PPV, this means that any threshold post-processor with either $\mathmode{\tau}(g_2) < \mathmode{\tau}(g_1)$ or $\mathmode{\tau}(g_2) = \mathmode{\tau}(g_1)$ and $\mathcal{R}(g_2) > \mathcal{R}(g_1)$ must also make the PPV on $g_2$ smaller than the PPV on $g_1$, finishing the proof. \end{proof} \subsection{Equalizing APs} \label{sec:docs-without-deferrals} While thresholding is a conceptually simple approach to post-processing a soft classifier, its power is limited. We now consider a very different approach using soft post-processors to equalize the APs across groups of a soft classifier. The intuition is that if the APs are equal across groups, then any hard post-processor that is \emph{group blind} should result in equal PPV, NPV, FPR, and FNR. We formalize this intuition in Claim~\ref{claim:equalizing-docs-good}. Let $\mathmode{\hat{S}}$ be a soft classifier and for each group $g \in \mathmode{\mathcal{G}}$, let $\mathmode{\hat{\mathcal{P}}}_g$ be the AP of $\mathmode{\hat{S}}$ for group $g$. For a soft post-processor $\mathmode{\post^\mathsf{soft}}$, let $\mathmode{\hat{S}}' = \mathmode{\post^\mathsf{soft}} \circ \mathmode{\hat{S}}$ and let $\mathmode{\hat{\mathcal{P}}}'_g$ be the corresponding AP for group $g$. Our goal is to find a soft post-processor $\mathmode{\post^\mathsf{soft}}$ such that $\mathmode{\hat{S}}'$ is groupwise calibrated, and $\mathmode{\hat{\mathcal{P}}}'_g = \mathmode{\hat{\mathcal{P}}}'_{g'}$ for all $g,g'\in\mathmode{\mathcal{G}}$. In this section, we describe only one approach to constructing $\mathmode{\post^\mathsf{soft}}$ which we call \emph{mass averaging}. The approach of equalizing APs has a fundamental weakness: if $\mathmode{\hat{\mathcal{P}}}'_g = \mathmode{\hat{\mathcal{P}}}'_{g'}$ and both are calibrated, then $\BR_g = \BR_{g'}$. This severely limits applicability of this approach. However, this limitation will removed in Section~\ref{sec:docs-with-deferrals} by allowing deferrals. \begin{claim} \label{claim:equalizing-docs-good} If the APs are equal for two groups, then PPV, NPV, FPR, and FNR are equalized by any hard post-processor $\post$ satisfying group blindness. \end{claim} The group-blindness requirement in the claim is necessary: consider the (not group blind) post-processor that outputs 0 on one group and 1 on the other; PPV will not be equalized. \begin{proof}[Proof of Claim:~\ref{claim:equalizing-docs-good}] We prove only that PPV is equalized; the remaining properties may be proved similarly. Let $\mathmode{\hat{Y}} = \post \circ \mathmode{\hat{S}}$ be a hard classifier $\mathmode{\hat{Y}}$ that is a group blind post-processor $\mathmode{\hat{D}}$ composed with a calibrated soft classifier $\mathmode{\hat{S}}$. All probabilities below are over $X_g\mathmode{\sim} \mathmode{\mathcal{X}}_g$, and the coins of $\mathmode{\hat{S}}$ and $\post$. \begin{align*} &\PPV_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{Y}}(X_g,g)=1] \\ &= \frac{\Pr[\mathmode{Y}(X) = 1 ]}{\Pr[\mathmode{\hat{Y}}(X_g,g) =1]} \\ & \quad \cdot \sum_{\ps \in \supp(\mathmode{\hat{\mathcal{P}}}_g)} \biggl( \frac{\Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{S}}(X_g) = \ps]\cdot\Pr[\mathmode{\hat{S}}(X_g) = \ps ]}{\Pr[\mathmode{Y}(X_g) = 1]}\\ &\quad\quad\quad\quad\quad \cdot \Pr[\mathmode{\hat{Y}}(X_g,g) = 1 \mid \mathmode{\hat{S}}(X_g) = \ps, \mathmode{Y}(X_g) = 1]\biggr) \end{align*} Each factor in this product is equal across groups by the assumptions. Namely, $\Pr[\mathmode{Y}(X_g) = 1]$ is equalized by calibration and equalized APs; $\Pr[\mathmode{\hat{Y}}(X_g,g) =1 ]$ by group blindness and equalized APs; $\Pr[\mathmode{\hat{Y}}(X_g, g) = 1\mid \mathmode{\hat{S}}(X_g) = \ps, \mathmode{Y}(X_g) = 1]$ by group blindness; $\Pr[\mathmode{Y}(X_g) = 1\mid \mathmode{\hat{S}}(X_g) = \ps]$ by calibration; and finally $\Pr[\mathmode{\hat{S}}(X_g) = \ps ]$ by equalized APs. \end{proof} \subsubsection{Mass Averaging} The mass-averaging technique is best illustrated with an example. Suppose that $\mathmode{\hat{\mathcal{P}}}_{g_1}$ is uniform over $\{0,0.5,1\}$, and $\mathmode{\hat{\mathcal{P}}}_{g_2}$ is uniform over $\{0,1\}$. It is easy to define a soft post-processor \mathmode{\post^\mathsf{soft}} which equalizes these two APs. On $g_1$, we leave the score unchanged: $\mathmode{\post^\mathsf{soft}}(\ps,g_1) = \ps$. On $g_2$, we compute the output as $$ \mathmode{\post^\mathsf{soft}}(\ps,g_2) = \begin{cases} \ps & \text{w.p. } 2/3 \\ 0.5 & \text{w.p. } 1/3 \end{cases} .$$ The APs for groups $g_1$ and $g_2$ of the resulting soft classifier $\mathmode{\hat{S}}' = \mathmode{\post^\mathsf{soft}} \circ \mathmode{\hat{S}}$ are equal, and are equal to $\mathmode{\hat{\mathcal{P}}}_{g_1}$. In the example, the probability mass is being redistributed by averaging the scores. This can be equivalently viewed as adding noise to the scores and then recalibrating the scores, something discussed in \cite{Corbett}. More generally, a mass-averaging post processor $\mathmode{\post^\mathsf{soft}}$ assigns to each possible pair $(\ps,g)$ a distribution over possible output scores $\ps'$. Such a \mathmode{\post^\mathsf{soft}} is fully specified by $k\cdot k' \cdot |\mathmode{\mathcal{G}}|$ parameters, where $k$ is the number of possible values of $\ps$ and $k'$ is the number of possible values of $\ps'$. Given a soft classifier $\mathmode{\hat{S}}$ and a mass-averaging post processor $\mathmode{\post^\mathsf{soft}}$, the constraint that the resulting APs are equalized across groups is linear in these parameters. Such classifiers, therefore, may be found by a linear program. We do not explore the choice of mass-averaging post-processors further. \section{Preliminaries} \label{sec:prelims} We study the problem of binary classification. An \emph{instance} is an element, usually denoted $x$, of a universe $\mathmode{\mathcal{X}}$. We restrict our attention to instances sampled uniformly at random from the universe, denoted $X \mathmode{\sim} \mathmode{\mathcal{X}}$. Our theory extends directly to any other distribution on $\mathmode{\mathcal{X}}$; that distribution does not need to be known to the classifiers. Each instance $x$ is associated with a \emph{true type} $\mathmode{Y}(x) \in \{\tF, \tT\}$. Each instance $x$ is also associated with a \emph{group} $\mathmode{G}(x) \in \mathmode{\mathcal{G}}$, where $\mathmode{\mathcal{G}}$ is the set of groups. We restrict our attention to sets $\mathmode{\mathcal{G}}$ that form a partition of the universe $\mathmode{\mathcal{X}}$. We denote by $\mathmode{\mathcal{X}}_g$ the set of instances $x$ in group $g$, and by $X_g$ the random variable distributed uniformly over $\mathmode{\mathcal{X}}_g$. Note that for any events $E_1$ and $E_2$, $\Pr_{X \mathmode{\sim} \mathmode{\mathcal{X}}_g}[E_1 \mid E_2] = \Pr_{X \mathmode{\sim} \mathmode{\mathcal{X}}}[E_1 \mid E_2, \mathmode{G}(X) = g]$. \begin{definition}[Base rate (\BR)]\label{defn:base-rate} The \emph{base rate} of a group $g \in \mathmode{\mathcal{G}}$, is \begin{equation} \label{eq:base-rate-def} \BR_g = \Pr[\mathmode{Y}(X_g) = \tT] = \mathmode{\mathop{\mathbb{E}}}[\mathmode{Y}(X_g)]. \end{equation} \end{definition} \noindent When $\mathmode{\mathcal{X}}$ is finite, $\BR_g$ is simply the fraction of individuals $x$ in the group $g$ for whom $\mathmode{Y}(x)=\tT$. A \emph{classifier} is a randomized function with domain $\mathmode{\mathcal{X}}\times\mathmode{\mathcal{G}}$.\footnotemark A \emph{hard classifier}, denoted $\mathmode{\hat{Y}}$, outputs a \emph{prediction} in $\{\pF, \pT\}$, interpreted as a guess of the true type $\mathmode{Y}(x)$. A \emph{soft classifier}, denoted $\mathmode{\hat{S}}$, outputs a \emph{score} $\ps \in [0,1]$, interpreted as a measure of confidence that $\mathmode{Y}(x) = 1$. We restrict our attention to soft classifiers with finite image. We call a classifier \emph{group blind} if its output is independent of the input group $g$. For all groups $g \in \mathmode{\mathcal{G}}$, we call a hard classifier $\mathmode{\hat{Y}}$ \emph{non-trivial on $g$} if $\Pr[\mathmode{\hat{Y}}(X_g) = 1] > 0$ and $\Pr[\mathmode{\hat{Y}}(X_g) = 0] > 0$. Hard classifiers are \emph{trivial on $g$} if they are not non-trivial on $g$. \footnotetext{As the focus of this paper is on the post processing of classifiers, we set aside questions such as the origin of the given classifier, including the randomness used in training, the origin or quality of the training data, and societal factors affecting the classifier. In particular, the classifiers we consider in this work are memoryless: they do not remember inputs or random choices from previous invocations. That is, we assume that if $X,X'$ are two independent random variables drawn from $\mathmode{\mathcal{X}}$ then $\mathmode{\hat{S}}(X)$ and $\mathmode{\hat{S}}(X')$ (respectively $\mathmode{\hat{Y}}(X)$ and $\mathmode{\hat{Y}}(X')$) are also independent random variables. (Our formalism can be naturally extended also to classifiers with initial randomized preprocessing, by considering the family of derivative classifiers, where for each derivative classifier the random choices made at preprocessing are fixed to some value. The formalism can then be applied separately to each derivative classifier.) A \emph{post-processor} is a randomized function with domain $[0,1] \times \mathmode{\mathcal{G}}$. As with classifiers, a post-processor can be \emph{hard} or \emph{soft}. A hard post-processor, denoted $\mathmode{\hat{D}}$, outputs a prediction in $\{\pF,\pT\}$. A soft post-processor, denoted $\mathmode{\post^\mathsf{soft}}$, outputs a score $\ps \in [0,1]$. Observe that for a soft classifier $\mathmode{\hat{S}}$, $\mathmode{\hat{D}}\circ\mathmode{\hat{S}}$ is a hard classifier, and $\mathmode{\post^\mathsf{soft}}\circ\mathmode{\hat{S}}$ is a soft classifier. As with classifiers, we call a post-processor group blind if its output is independent of the group $g$, and we restrict our attention to post-processors with finite image. The restriction to finite image is for mathematical convenience (and also because digital memory leads to discrete universes); our results generalize to infinite images as well. In Section~\ref{sec:deferrals}, we expand the definitions of both classifier and post-processors to allow an additional input or output: the special symbol $\punt$. \begin{figure} \usetikzlibrary{decorations.text} \resizebox{\hsize}{!}{ \begin{tikzpicture}[mypostaction/.style 2 args={ decoration={ text align={ left indent=#1}, text along path, text={#2} }, decorate }, auto, node distance=4cm] \node[scale=0.6] [] (X) at (0,0) {$x \in \mathmode{\mathcal{X}}$}; \node[scale=0.6] (score) at (3,0) {$\ps \in [0,1]$}; \node[scale=0.6] (decision) at (8,0) {$\mathmode{\hat{y}} \in \{\pF, \pT\}$}; \draw [->] (X.east) -- (score.west) node [above, midway, scale=0.6] {``soft''} node [below, midway, scale=0.6] {$\mathmode{\hat{S}}$}; \draw [->] (score.east) -- (decision.west) node [above, midway, scale=0.6] {``hard post-processor''} node [below, midway, scale=0.6] {$\post$}; \draw [->] (score.east) -- (decision.west) node [above, midway, scale=0.6] {``hard post-processor''} node [below, midway, scale=0.6] {$\post$}; \draw[->] (X.north) to [out=20,in=160] (decision.north) {}; \draw[->] (2.5, -0.25) to [out=260, in=280, looseness=2] (3.5, -0.25) {}; \node[scale=0.6] (TEXTpostsoft) at (3.01,-0.6) {$\mathmode{\post^\mathsf{soft}}$}; \node[scale=0.6] (TEXTpostsoft) at (3,-1) {``soft post-processor''}; \node[scale=0.6] (TEXThard) at (4,1.12) {``hard''}; \node[scale=0.6] (TEXThard) at (4,0.82) {$\mathmode{\hat{Y}}$}; \end{tikzpicture} } \caption{We call a classifier that returns results in $[0,1]$ a \emph{soft classifier} to differentiate it from those which return results in $\{0,1\}$, which we call \emph{hard classifiers}. We refer to classifiers that take as input the output of a soft classifier as \emph{post-processors}.} \label{fig:notation} \end{figure} \subsection{Calibration} Several works concerning algorithmic fairness focus on various notions of \emph{calibration}. The following calibration notions are defined only over soft classifiers: \begin{definition}[Calibration (Soft)]\label{defn:calibration} We say a soft classifier $\mathmode{\hat{S}}$ is \emph{calibrated} if $\forall \ps \in [0,1]$ for which $\Pr_{X \mathmode{\sim} \mathmode{\mathcal{X}}}[\mathmode{\hat{S}}(X) = \ps] > 0$, \[ \Pr_{X \mathmode{\sim} \mathmode{\mathcal{X}}}[\mathmode{Y}(X) = \tT \mid \mathmode{\hat{S}}(X) = \ps] =\mathmode{\mathop{\mathbb{E}}}_{X \mathmode{\sim} \mathmode{\mathcal{X}}}[\mathmode{Y}(X) \mid \mathmode{\hat{S}}(X) = \ps] = \ps. \] The probability above is taken over the sampling of $\mathmode{X}$, as well as random choices made by $\mathmode{\hat{S}}$ at classification time. \end{definition} \begin{definition}[Groupwise Calibration (Soft)]\label{defn:groupwise-calibration} We say that a soft classifier $\mathmode{\hat{S}}$ is \emph{groupwise calibrated} if it is calibrated within all groups. That is, $\forall g \in \mathmode{\mathcal{G}}$ and $\forall \ps \in [0,1]$ for which $\Pr[\mathmode{\hat{S}}(X_g) = \ps] > 0$, we have that \[ \Pr[\mathmode{Y}(X_g) = \tT \mid \mathmode{\hat{S}}(X_g) = \ps] = \ps. \] \end{definition} Groupwise calibration is essentially the same notion as {\em multicalibration} \cite{Multicalibration} with the difference that in their case the true types are values in $[0,1]$. We use a different term to emphasize that we restrict our attention to collections of groups $\mathmode{\mathcal{G}}$ that form a partition of the universe $\mathmode{\mathcal{X}}$. The two definitions above are stated for soft classifiers whose output distribution is discrete, since we must be able to condition on the event $\mathmode{\hat{S}}(X)=\ps$ or $\mathmode{\hat{S}}(X_g)=\ps$. That said, it extends naturally to classifiers with continuously-distributed outputs provided that the conditional probabilities are well defined. \subsection{Accuracy Profiles (APs)} Throughout this work, we make repeated reference to the probability mass function of the random variable $\mathmode{\hat{S}}(X_g)$ for a calibrated soft classifier $\mathmode{\hat{S}}$ acting on a randomly distributed input $X_g$. We call this distribution on calibrated scores an \emph{accuracy profile} (AP). \begin{definition}[Accuracy Profile (AP)]\label{defn:docs} The \emph{accuracy profile (AP)} of a calibrated soft classifier $\mathmode{\hat{S}}$ for a group $g$, denoted by $\mathmode{\hat{\mathcal{P}}}_g$, is the PMF of $\mathmode{\hat{S}}(X_g)$. That is, for $\ps \in [0,1]$, $\mathmode{\hat{\mathcal{P}}}_g(\ps) = \Pr[\mathmode{\hat{S}}(X_g) = \ps].$ \end{definition} Abusing notation, we denote by $\mathmode{\hat{\mathcal{P}}}$ the collection $\{\mathmode{\hat{\mathcal{P}}}_g\}_{g\in \mathmode{\mathcal{G}}}$, and call it the \emph{AP of \mathmode{\hat{S}}}. We denote by $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)$ the support of the AP $\mathmode{\hat{\mathcal{P}}}_g$, namely the set $\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}) = \{\ps : \exists x \in \mathmode{\mathcal{X}}_g, \exists r \mbox{ s.t. } \mathmode{\hat{S}}(x,r) = \ps\} \subseteq [0,1]$. An accuracy profile is a distribution of scores for a calibrated classifier $\mathmode{\hat{S}}$. Because $\mathmode{\hat{S}}$ is calibrated, the AP conveys information about the performance of $\mathmode{\hat{S}}$, and is constrained by properties of the underlying distribution on $X$. For example, the AP's expectation is exactly the base rate for the population: \begin{proposition} \label{prop:baserate-calibrated} For any groupwise calibrated soft classifier $\mathmode{\hat{S}}$, for all groups $g \in \mathmode{\mathcal{G}}$: $\BR_g = \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g)]$. \end{proposition} \begin{proof}[Proof of Proposition~\ref{prop:baserate-calibrated}] \begin{align*} \BR_g &= \Pr[\mathmode{Y}(X_g) = \tT] \\ &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \Pr[\mathmode{Y}(X_g) = \tT \mid \mathmode{\hat{S}}(X_g) = \ps] \Pr[\mathmode{\hat{S}}(X_g) = \ps] \\ &= \sum_{\ps \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \ps \Pr[\mathmode{\hat{S}}(X_g) = \ps] \\ &= \mathmode{\mathop{\mathbb{E}}}[\mathmode{\hat{S}}(X_g)] \end{align*} where the third line follows from the definition of a calibrated classifier (Definition~\ref{defn:groupwise-calibration}). \end{proof} Accuracy profiles also provide useful geometric intuition for reasoning about the effects of post-processing calibrated scores. We elaborate on this in Section~\ref{sec:fair-post-process} (see Figure~\ref{fig:calibration-line-decide}). \subsection{Group Fairness Measures} Several well-studied measures of statistical ``fairness'' (e.g., \cite{EqualOpp,Cho17,Kleinberg, Pleiss,Multicalibration, gerrymandering}) look at how the following key performance measures of a classifier differ across groups. The \emph{false positive rate} (FPR) of a hard classifier $\mathmode{\hat{Y}}$ for a group $g$ is the rate at which $\mathmode{\hat{Y}}$ gives a positive classification among instances $x \in \mathmode{\mathcal{X}}_g$ with true type $\tF$. The \emph{false negative rate} (FNR) is defined analogously for predicted negative instances with true type $\tT$. \emph{Positive predictive value} (PPV) and \emph{negative predictive value} (NPV) track the rate of mistakes within instances that share a predicted type. Informally, positive predictive value captures how much meaning can be given to a predicted $\tT$, and negative predictive value is similar for predicted $\tF$. We now define these statistics formally. \begin{definition}\label{defn:four-measures} Given a hard classifier $\mathmode{\hat{Y}}$ and a group $g$, we define\\ \makebox[2.8in]{the \emph{false positive rate} of $\mathmode{\hat{Y}}$ for $g$: \hfill} $ \FPR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF] $;\\ \makebox[2.8in]{the \emph{false negative rate} of $\mathmode{\hat{Y}}$ for $g$: \hfill} $ \FNR_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{\hat{Y}}(X_g) = \pF \mid \mathmode{Y}(X_g) = \tT] $;\\ \makebox[2.8in]{the \emph{positive predictive value} of $\mathmode{\hat{Y}}$ for $g$: \hfill} $ \PPV_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{Y}(X_g) = \tT \mid \mathmode{\hat{Y}}(X_g) = \pT]$; \\ \makebox[2.8in]{the \emph{negative predictive value} of $\mathmode{\hat{Y}}$ for $g$: \hfill} $ \NPV_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{Y}(X_g) = \tF \mid \mathmode{\hat{Y}}(X_g) = \pF]. $ \end{definition} \smallskip The probability statements in the definitions above reflect two sources of randomness: the sampling of $X_g$ from the group $g$ and any random choices made by the classifier $\mathmode{\hat{Y}}$. Among previous works, some \cite{EqualOpp,Kleinberg} focus on equalizing only one or both of the false positive rates and false negative rates across groups, called \emph{balance} for the negative and positive classes, respectively. Equalizing positive and negative predictive value across groups is often combined into one condition called \emph{predictive parity} \cite{Cho17}. We split the value out to be a separate condition for the positive and negative predictive classes. Predictive parity appears to be a hard-classifier analogue of calibration: both can be interpreted as saying that the output of the classifier (hard or soft) contains all the information contained in group membership. Our results highlight that the relationship between these notions is more subtle than it first appears; see Section \ref{sec:postprocess-limits} for further discussion. \section{Post-Processing Calibrated Classifiers with Deferrals} \label{sec:deferrals} In the first part of the paper, we considered the problem of post-processing calibrated soft classifiers, which output a score $\ps \in [0,1]$, into fair hard classifiers, which output a decision in $\mathmode{\hat{y}}\in\{\pF,\pT\}$, subject to a number of group fairness conditions. In the remainder of this work, we reconsider this problem, but with one important change: we allow classifiers to ``refuse to decide'' by outputting the special symbol $\punt$. We call such classifiers \emph{deferring} classifiers, borrowing the nomenclature from \cite{MPZ17}. The output $\punt$ is the deferring classifier's way of refusing to make a decision and deferring to a downstream decision maker. For example, a risk assessment tool might aid a parole board to make a decision by categorizing an individual as high risk or low risk, or it might output $\punt$---providing no advice and deferring to the judgment of the board. We now modify our notation appropriately. Instances $x$ are still associated with a true type $\mathmode{Y}(x) \in \{\tF, \tT\}$ and a group $\mathmode{G}(x) \in \mathmode{\mathcal{G}}$. A deferring hard classifier $\mathmode{\hat{Y}}$ is a randomized function $\mathmode{\hat{Y}}:\mathmode{\mathcal{X}} \to \{\pF,\pT, \punt\}$. A deferring soft classifier is a randomized function $\mathmode{\hat{S}}:\mathmode{\mathcal{X}}\to[0,1]\cup \{\punt\}$. A deferring hard (resp.~soft) post-processor is a randomized function $\mathmode{\hat{D}}: [0,1]\cup\{\punt\} \times \mathmode{\mathcal{G}} \to \{\pF,\pT,\punt\}$ (resp.~$\mathmode{\post^\mathsf{soft}}: [0,1] \cup \{\punt\} \times \mathmode{\mathcal{G}} \to [0,1] \cup \{\punt\}$) that takes as input the output of a deferring soft and post-processes it into a deferring hard (resp.~soft) classifier. We also introduce new versions of the FPR and FNR, conditioned on not deferring. \begin{definition}\label{defn:conditional-measures} The \emph{conditional false positive rate} and \emph{conditional false negative rate} of a deferring hard classifier $\mathmode{\hat{Y}}$ for a group $g$ are, respectively: \begin{align*} \cFPR_{\mathmode{\hat{Y}},g} &= \Pr[\mathmode{\hat{Y}}(X_g) = \pT \mid \mathmode{Y}(X_g) = \tF, \mathmode{\hat{Y}}(X_g) \neq \punt] \\ \cFNR_{\mathmode{\hat{Y}},g} &= \Pr[\mathmode{\hat{Y}}(X_g) = \pF \mid \mathmode{Y}(X_g) = \tT, \mathmode{\hat{Y}}(X_g) \neq \punt]. \end{align*} \end{definition} We additionally consider a version of the accuracy profile conditioned on not deferring, which we call the \emph{conditional AP}. For non-deferring soft classifiers, Definitions~\ref{defn:conditional-docs} and \ref{defn:docs} coincide. \begin{definition} \label{defn:conditional-docs} The \emph{conditional AP} $\mathmode{\hat{\mathcal{P}}}_g$ of a classifier $\mathmode{\hat{S}}$ for a group $g$ is the PMF of $\mathmode{\hat{S}}(X_g)$, conditioned on not outputting $\punt$. That is, for $\ps \in [0,1]$, $\mathmode{\hat{\mathcal{P}}}_g(\ps) = \Pr[\mathmode{\hat{S}}(X_g) = \ps \mid \mathmode{\hat{S}}(X_g) \neq \punt].$ Note that the conditional AP is undefined if $\Pr[\mathmode{\hat{S}}(X_g) \neq \punt] = 0$. Abusing notation, we denote by $\mathmode{\hat{\mathcal{P}}}$ the collection $\{\mathmode{\hat{\mathcal{P}}}_g\}_{g\in \mathmode{\mathcal{G}}}$, and call it the \emph{conditional AP of~\mathmode{\hat{S}}}. \end{definition} The conditional error rates are applicable generally, but they can be difficult to interpret. The consequences of using the conditional FPR and FNR are discussed further in Section \ref{sec:discussion} along with a discussion of different deferral models. They are also amenable to the consideration of additional goals which we will briefly address. For example, one could seek to minimize the total deferral rate, equalize the deferral rate among groups, or prefer deferrals on positive instances. \subsection{Thresholding with deferrals} \label{sec:threshold-deferrals} We return now to the problem of post-processing of calibrated soft classifiers, but now with the extra power of deferring on some inputs. We revisit the two approaches discussed in Section~\ref{sec:postprocess-limits}: thresholding and equalizing APs. Proposition~\ref{prop:info-theory-impossibility-3} stated PPV and NPV cannot both be equalized across groups in general when using only a single threshold per group. By using two thresholds per groups and deferring on some inputs, PPV and NPV can always be equalized across groups. We post-process using two thresholds per group as follows: return $\pF$ when $\ps$ is lower than the first threshold, return $\mathmode{\bot}$ between the thresholds, and return $\pT$ above the second threshold, as shown in Figure \ref{fig:two-thresh-per-group}. This buys us more degrees of freedom when equalizing binary constraints, and it has the useful property that we say $\mathmode{\bot}$ on the instances where we are the least confident about the predicted type. We adapt our notation as follows: \begin{definition}[Deferring Threshold Post-Processor]\label{def:thresh-deferral} A deferring threshold post-processor $\mathmode{\hat{D}}_{(\tau_0,\tau_1,\mathcal{R}_0,\mathcal{R}_1)}$ assigns to each group $g$ two thresholds $\tau_0(g),\tau_1(g) \in \supp(\mathmode{\hat{\mathcal{P}}}_g)$, and two probabilities $\mathcal{R}_0(g),\mathcal{R}_1(g) \in [0,1]$, with the following requirements: \begin{enumerate} \item for all $g \in \mathmode{\mathcal{G}}$, $\tau_0(g) \le \tau_1(g)$ \item for all $g \in \mathmode{\mathcal{G}}$ for which $\tau_0(g) = \tau_1(g)$, $\mathcal{R}_1(g) + \mathcal{R}_0(g) \le 1$. This corresponds to the case where the two thresholds are the same, and therefore individuals with that score must be mapped to $\pT$ with probability $\mathcal{R}_1(g)$, and to $\pF$ with probability $\mathcal{R}_0(g)$, with the remainder mapped to $\mathmode{\bot}$. \end{enumerate} The corresponding threshold post-processor is defined as follows:\\ \resizebox{\hsize}{!}{ \begin{minipage}{\linewidth} \begin{align*} \mathmode{\hat{D}}_{(\tau_0, \tau_1, \mathcal{R}_0, \mathcal{R}_1)}(\ps, g) = \begin{cases} \pT & \ps > \tau_{1}(g) \\ \pF & \ps < \tau_0(g) \\ \mathmode{\bot} & \tau_0(g) < \ps < \tau_1(g) \\ \pT \text{ w.p. }\mathcal{R}_1(g), \text{ else }\mathmode{\bot} & \ps = \tau_1(g) \\ \pF \text{ w.p. }\mathcal{R}_0(g), \text{ else }\mathmode{\bot} & \ps = \tau_0(g) \\ \pT \text{ w.p. }\mathcal{R}_1(g), \pF \text{ w.p. }\mathcal{R}_0(g), \text{ else }\mathmode{\bot} & \ps = \tau_0(g) = \tau_1(g) \\ \mathmode{\bot} & \ps = \mathmode{\bot} \end{cases} \end{align*} \end{minipage}} \end{definition} \begin{figure} \centering \includegraphics[width=0.5\hsize]{graphs/two_thresholds_per_group.png} \caption{For threshold post-processors with deferrals, defer between the thresholds.} \label{fig:two-thresh-per-group} \end{figure} Using two thresholds allows the equalization of both PPV and NPV across groups in general, whereas without deferrals we could only equalize one or the other. We first demonstrate the existence of post-processors that are fairly limited, analogously to those defined in Proposition~\ref{prop:trivial-threshold-equalizes}. \begin{proposition}\label{prop:trivial-thresholds-deferrals} Let $\mathmode{\hat{S}}$ be a soft classifier with a nice AP for a set of groups $\mathmode{\mathcal{G}}$. Then every threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}_0, \mathmode{\tau}_1, \mathcal{R}_0, \mathcal{R}_1)}$ satisfying the following properties equalizes both the PPV and NPV for all groups in $\mathmode{\mathcal{G}}$ of the composed classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}}_{(\mathmode{\tau}_0, \mathmode{\tau}_1, \mathcal{R}_0, \mathcal{R}_1)} \circ \mathmode{\hat{S}}$: \begin{enumerate} \item $\tau_0(g) = \min(\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g))$ for all $g$ \item $\mathcal{R}_0(g) > 0$ for all $g$. \item $\tau_1(g) = \max(\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g))$ for all $g$ \item $\mathcal{R}_1(g) > 0$ for all $g$. \end{enumerate} \end{proposition} Notice that these classifiers cannot be trivial, because we defined $\mathcal{R}_0$ and $\mathcal{R}_1$ in a way that prohibits the possibility that the composed classifier never returns 0 or 1. For the cases where the range of soft classifier outputs is infinite and there is no max or min element, these classifiers do not exist. \begin{proof}[Proof of Proposition~\ref{prop:trivial-thresholds-deferrals}] The reasoning is similar to the non-deferral case for equality of PPV alone. The thresholds only allow one score $\ps$ to map to $\pF$ and one score to map to $\pT$. Thus, PPV for both groups is equal to the largest score in the support and NPV for both groups is equal to 1 minus the smallest score in the support. \end{proof} Now, much like in Proposition~\ref{prop:2-thresh-equal-ppv}, which showed the existence of meaningful non-trivial threshold post-processors that equalized PPV across groups, we show the existence of meaningful, nontrivial \emph{deferring} threshold post-processors that equalize PPV and NPV across groups. \begin{proposition}\label{prop:2n-thresholds-deferrals} Let $\mathmode{\hat{S}}$ be a soft classifier with a nice AP that is groupwise calibrated for a set of groups $\mathmode{\mathcal{G}}$. Suppose that $\vert\mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_{g})\vert \ge 2$ for all $g \in \mathmode{\mathcal{G}}$. Then there exists a non-trivial threshold post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}_0, \mathmode{\tau}_1, \mathcal{R}_0, \mathcal{R}_1)}$ that is not one of those defined in Proposition~\ref{prop:trivial-thresholds-deferrals}, such that the hard classifier $\mathmode{\hat{Y}} = \mathmode{\hat{D}}_{(\mathmode{\tau}_0, \mathmode{\tau}_1, \mathcal{R}_0, \mathcal{R}_1)} \circ \mathmode{\hat{S}}$ equalizes $\PPV_g$ and $\NPV_g$ for all $g \in \mathmode{\mathcal{G}}$. \end{proposition} The main idea of the proof of this proposition is to use Proposition \ref{prop:2-thresh-equal-ppv} twice: once for getting thresholds to equalize the PPV, and once for thresholds to equalize the NPV. These thresholds may be invalid because there may be a group $g$ for which $\tau_0(g) > \tau_1(g)$. We use Claims \ref{claim:ppv-monotonicity} and \ref{claim:ppv-continuity} to allow ourselves to push the PPV thresholds toward 1 and the NPV thresholds toward 0 until they no longer overlap, while still maintaining equalization of PPV and NPV for the other groups. \begin{proof}[Proof of Proposition \ref{prop:2n-thresholds-deferrals}] Recall by Claim~\ref{claim:ppv-monotonicity} that the PPV of $\mathmode{\hat{S}}$ on a group $g$ monotonically increases as $\tau_1(g)$ increases and, if $\mathmode{\tau}_1(g)$ is constant, as $\mathcal{R}_1(g)$ increases. By Claim~\ref{claim:npv-monotonicity}, NPV monotonically increases as $\tau_0(g)$ decreases, and, if $\mathmode{\tau}_0(g)$ is constant, as $\mathcal{R}_0(g)$ increases. Recall by Claim \ref{claim:ppv-continuity} that if the total variance distance between conditional APs (conditioned on being post-processed to a result of $\pT$) for different groups is at most $\epsilon$, then the PPV difference for these groups is bounded by $O(\epsilon)$. Thus, $\PPV_g$ is continuous and monotonically increasing with regard to $(\tau_1(g), \mathcal{R}_1(g))$. Similarly, $\NPV_g$ is continuous and monotonically increasing with $(-\tau_0(g), \mathcal{R}_0(g))$. We know by Proposition \ref{prop:2-thresh-equal-ppv} that there exists a non-group blind threshold rule (without deferrals) that equalizes the PPV among the groups. By the analogous Proposition~\ref{prop:2-thresh-equal-npv}, there exists a (different) non-group-blind threshold rule that equalizes the NPV among the groups. For both of these, we know that they are not the classifiers from Proposition~\ref{prop:trivial-thresholds-deferrals}. If the thresholds meet the conditions of being a deferring post-processor listed in Definition~\ref{def:thresh-deferral}, then the statement is proven. If they do not meet the conditions because the thresholds ``overlap,'' we repeat the following procedure until the conditions are met: \begin{enumerate} \item Let $g$ be a group for which the conditions are not met, i.e. either $\tau_0(g) > \tau_1(g)$, or $\tau_0(g) = \tau_1(g)$ and $\mathcal{R}_0(g) + \mathcal{R}_1(g) > 1$. \item If $\tau_0(g) > \tau_1(g)$, define $t' = \frac{\mathmode{\tau}_0(g) + \mathmode{\tau}_1(g)}{2}$. Let $t = \argmin_{s \in \mathsf{Supp}(\mathmode{\hat{\mathcal{P}}}_g)} \vert s - t' \vert$. Notice that $t \le \tau_0(g)$ and $t \ge \tau_1(g)$, but because by assumption $\tau_0(g) > \tau_1(g)$, $t$ cannot be equal to both thresholds. Set the new value for both thresholds to $t$: $\tau_0(g) = \tau_1(g) = t(g)$. \item If $\mathcal{R}_0(g) + \mathcal{R}(g) > 1$, then do the following: \begin{enumerate} \item If $\mathmode{\tau}_0(g)$ remained unaltered in the previous step, then keep $\mathcal{R}_0(g)$ the same, and set $\mathcal{R}_1(g) = 1 - \mathcal{R}_0(g)$. \item If $\mathmode{\tau}_1(g)$ remained unaltered in the previous step, then set $\mathcal{R}_1(g)$ the same and set $\mathcal{R}_0(g) = 1 - \mathcal{R}_1(g)$. \item If neither of these is true, then let $r = \frac{\mathcal{R}_0(g)}{\mathcal{R}_0(g) + \mathcal{R}_1(g)}$. Set $\mathcal{R}_0(g) = r$ and $\mathcal{R}_1(g) = 1-r$. \end{enumerate} \item These thresholds are no longer overlapping, but they altered $\PPV_g$ and $\NPV_g$. Notice that, by the monotonicity properties described above, the threshold rules were changed in ways that can only increase $\PPV_g$ or $\NPV_g$: \begin{enumerate} \item $\mathmode{\tau}_1(g)$ has increased or remained constant \item if $\mathmode{\tau}_1(g)$ remained constant, then $\mathcal{R}_1(g)$ also remained constant \item $\mathmode{\tau}_0(g)$ has decreased or remained constant \item if $\mathmode{\tau}_0(g)$ remained constant, then $\mathcal{R}_0(g)$ remained constant \end{enumerate} The new PPV and NPV for $g$ may now be higher than those of the other groups. \item For all other groups $g' \ne g$, by the Intermediate Value Theorem and the continuity of NPV, there exists some $(\mathmode{\tau}_0(g'), \mathcal{R}(g'))$ that sets $\NPV_{g'} = \NPV_g$, and by the monotonicity of NPV, this threshold is lower than the old one. Similarly, there exists some $(\mathmode{\tau}_1(g'), \mathcal{R}(g'))$ that sets $\PPV_{g'} = \PPV_g$ and it is higher than the old one. By the monotonicity of PPV and NPV, we know that this process will not cause non-overlapping thresholds to become overlapping. \end{enumerate} The ultimate effect of these steps was to reduce the number of overlapping thresholds by at least one. We can repeat this process up to $2|\mathmode{\mathcal{G}}|$ times until none of the thresholds overlap. Notice that this classifier is not one of the ones from Proposition~\ref{prop:trivial-thresholds-deferrals} - if we did not have to correct for ``overlapping,'' then this is true by assumption, and if we did do the correction process, then $\mathmode{\tau}_0(g) = \mathmode{\tau}_1(g)$ for at least one $g$, and by assumption we had $\vert\supp(\mathmode{\hat{\mathcal{P}}})\vert \ge 2$. Thus, we have created valid a post-processor $\mathmode{\hat{D}}_{(\mathmode{\tau}_0, \mathmode{\tau}_1, \mathcal{R}_0, \mathcal{R}_1)}$ that equalizes PPV and NPV for all groups simultaneously and is not one of the ones in Proposition~\ref{prop:trivial-thresholds-deferrals}, proving the claim. \end{proof} The following example demonstrates that it is sometimes possible to equalize PPV, NPV, FPR, and FNR using deferrals, but without equalizing the APs themselves: \begin{example}[Equalizing PPV, NPV, cFPR, and cFNR with Thresholds] \label{example:double-threshold-equalization} This example is presented with continuous support $[0,1]$ for simplicity. Consider two APs, one for group $g_1$ and one for $g_2$. Let the AP for $g_1$ be uniform (with density give by the line $\mathmode{\hat{\mathcal{P}}}(\ps) = 1$), and let the AP for group $g_2$ have density given by the parabola $\mathmode{\hat{\mathcal{P}}}(\ps) = 6\ps(1-\ps)$, as shown in Figure \ref{fig:parabola-line}. Consider the post-processor $\mathmode{\post^\mathsf{soft}}_{(\tau_0, \tau_1)}$.\footnote{In the case where the distributions are continuous, $\mathcal{R}_0$ and $\mathcal{R}_1$ are meaningless because $\Pr[\ps = \tau_0(g)] = \Pr[\ps = \tau_1(g)]= 0 \forall \ps$.} Let $\tau_0(g_1) = \tau_0(g_1) = 0.5$, let $\tau_0(g_2) = \frac16(5 - \sqrt{7})$ and let $\tau_1(g_2) = 1 - \frac16(5 - \sqrt{7})$ as shown in Figure \ref{fig:parabola-line}. The PPV and NPV of both groups is $\frac34$, and the \cFPR and \cFNR of both is $\frac14$, thus equalizing all four values. This example is somewhat unsatisfactory because the base rates are equal in the two groups. We did not find a similar example without equal base rates. \end{example} \begin{figure}[htp] \centering \includegraphics[width=0.5\hsize]{graphs/parabola_line_thresh_example.png} \caption{This threshold post-processor equalizes PPV, NPV, cFPR, and cFNR as described in Example \ref{example:double-threshold-equalization}. } \label{fig:parabola-line} \end{figure} \subsection{Equalizing APs with deferrals} \label{sec:docs-with-deferrals} As with Claim~\ref{claim:equalizing-docs-good}, equalizing the conditional APs between groups renders trivial the task of downstream decision-making subject to equality of PPV, NPV, cFPR, and cFNR. Importantly, unlike in Section~\ref{sec:docs-without-deferrals}, equalizing the conditional APs between groups does not require the groups to have equal base rates, greatly increasing the applicability of this approach. \begin{claim} \label{claim:equalizing-conditional-docs-good} If the conditional APs are equal for two groups, then PPV, NPV, cFPR, and cFNR are equalized (or simultaneously undefined) by any hard deferring post-processor $\mathmode{\hat{D}}$ satisfying (1) \emph{group blindness} and (2) $\mathmode{\hat{D}}(\punt,g) = \punt \ (\forall g)$. \end{claim} The additional condition---that $\mathmode{\hat{D}}$ defers on input $\punt$---is necessary: if $\mathmode{\hat{D}}$ output $1$ on all inputs (even on $\punt$), then PPV would remain unequal as long as the base rates differed. The proof is similar to the proof of Claim~\ref{claim:equalizing-docs-good}. \begin{proof}[Proof of Claim~\ref{claim:equalizing-conditional-docs-good}] We prove only that PPV is equalized; the remaining properties may be proved similarly. Let $\mathmode{\hat{Y}} = \mathmode{\hat{D}} \circ \mathmode{\hat{S}}$. All probabilities below are over $X_g\mathmode{\sim} \mathmode{\mathcal{X}}_g$, and the coins of $\mathmode{\hat{S}}$ and $\mathmode{\hat{D}}$. \begin{align*} &\PPV_{\mathmode{\hat{Y}},g} = \Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{Y}}(X_g,g)=1] \\ &= \frac{\Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{S}}(X_g) \neq \punt]}{\Pr[\mathmode{\hat{Y}}(X_g,g) =1\mid \mathmode{\hat{S}}(X_g) \neq \punt]} \\ & \quad \cdot \sum_{\ps \in \supp(\mathmode{\hat{\mathcal{P}}}_g)} \biggl( \frac{\Pr[\mathmode{Y}(X_g) = 1 \mid \mathmode{\hat{S}}(X_g) = \ps]\cdot\Pr[\mathmode{\hat{S}}(X_g) = \ps \mid \mathmode{\hat{S}}(X_g) \neq \punt]}{\Pr[\mathmode{Y}(X_g) = 1\mid \mathmode{\hat{S}}(X_g) \neq \punt]}\\ &\quad\quad\quad\quad\quad \cdot \Pr[\mathmode{\hat{D}}(s,g) = 1 \mid \mathmode{\hat{S}}(X_g) = \ps, \mathmode{Y}(X_g) = 1]\biggr) \end{align*} Each factor in this product is equal across groups by the assumptions. Namely, $\Pr[\mathmode{Y}(X_g) = 1\mid \mathmode{\hat{S}}(X_g) \neq \punt]$ is equalized by calibration and equalized APs; $\Pr[\mathmode{\hat{Y}}(X_g,g) =1 \mid \mathmode{\hat{S}}(X_g) \neq \punt]$ by group blindness and equalized APs; $\Pr[\mathmode{\hat{D}}(s, g) = 1\mid \mathmode{\hat{S}}(X_g) = \ps, \mathmode{Y}(X_g) = 1]$ by group blindness; $\Pr[\mathmode{Y}(X_g) = 1\mid \mathmode{\hat{S}}(X_g) = \ps]$ by calibration; and finally $\Pr[\mathmode{\hat{S}}(X_g) = \ps \mid \mathmode{\hat{S}}(X_g) \neq \punt]$ by equalized APs. \end{proof} Deferrals are a powerful tool for manipulating, and thereby equalizing, conditional APs. Consider a function $Q:(\ps,g) \mapsto [0,1]$ \begin{align*} \mathmode{\post^\mathsf{soft}}_{Q}(\ps, g) = \begin{cases} \punt & \text{if } \ps = \punt \\ \punt \text{ w.p. } Q(\ps, g)\text{, else }\ps & \text{otherwise} \end{cases} \end{align*} If $\mathmode{\hat{S}}$ is a calibrated classifier, the soft deferring classifier $\mathmode{\hat{S}}' := \mathmode{\post^\mathsf{soft}}_{Q} \circ \mathmode{\hat{S}}$ is still calibrated. For a group $g$, let $\mathmode{\hat{\mathcal{P}}}_g$ be the AP of $\mathmode{\hat{S}}$ and $\mathmode{\hat{\mathcal{P}}}'_g$ be the AP of $\mathmode{\hat{S}}'$. There is a simple graphical intuition for the shape of $\mathmode{\hat{\mathcal{P}}}'_g$, as shown in Figure~\ref{fig:transform_docs1_to_docs2}. More formally, \begin{equation} \label{eq:defer-equal-docs} \mathmode{\hat{\mathcal{P}}}'_g(\ps) = \frac{\mathmode{\hat{\mathcal{P}}}_g(\ps)(1-Q(\ps,g))}{1-\Delta} \end{equation} where $\Delta := \Pr[\mathmode{\hat{S}}'(X_g) = \punt \mid \mathmode{\hat{S}}(X_g) \neq \punt] = \sum_{\ps\in\supp(\mathmode{\hat{\mathcal{P}}}_g)}\mathmode{\hat{\mathcal{P}}}_g(\ps)Q(\ps,g)$. \medskip By appropriate choice of $Q$, any conditional AP can be transformed into almost any other conditional AP. \begin{theorem} \label{thm:defer-to-any-docs} Let $\mathmode{\hat{\mathcal{P}}}_g$ be a conditional AP of a soft classifier $\mathmode{\hat{S}}$ on group $g$, and let $\mathmode{\hat{\mathcal{P}}}^*$ be any probability mass function such that $\supp(\mathmode{\hat{\mathcal{P}}}^*) \subseteq \supp(\mathmode{\hat{\mathcal{P}}}_g)$. Then there exists $Q$ for which the calibrated AP $\mathmode{\hat{\mathcal{P}}}'_g$ of $\mathmode{\post^\mathsf{soft}}_{Q}\circ\mathmode{\hat{S}}$ is equal to $\mathmode{\hat{\mathcal{P}}}^*$. \end{theorem} \begin{proof}[Proof of Theorem~\ref{thm:defer-to-any-docs}] Let $\Delta = 1 - \min_{\ps\in \supp(\mathmode{\hat{\mathcal{P}}}_g)} \frac{\mathmode{\hat{\mathcal{P}}}_g(\ps)}{\mathmode{\hat{\mathcal{P}}}^*(\ps)}$. For all $\ps \in \supp(\mathmode{\hat{\mathcal{P}}}_g)$, let $$Q(\ps,g) = 1 - \frac{\mathmode{\hat{\mathcal{P}}}^*(\ps)}{\mathmode{\hat{\mathcal{P}}}_g(\ps)}\cdot(1-\Delta).$$ Observe that \begin{align*} \sum_{\ps \in \supp(\mathmode{\hat{\mathcal{P}}}_g)}\mathmode{\hat{\mathcal{P}}}_g(\ps)Q(\ps,g) &= \sum_{\ps \in \supp(\mathmode{\hat{\mathcal{P}}}_g)} \left( \mathmode{\hat{\mathcal{P}}}_g(\ps) - (1-\Delta) \mathmode{\hat{\mathcal{P}}}^*(\ps) \right) \\ &= \Delta \end{align*} and hence $\Delta$ is defined as in Equation~\ref{eq:defer-equal-docs}, where we used the fact that $\sum \mathmode{\hat{\mathcal{P}}}_g(\ps) = \sum \mathmode{\hat{\mathcal{P}}}^*(\ps) = 1$ in the last line. Plugging into the earlier formula for $\mathmode{\hat{\mathcal{P}}}'_g$ (Equation~\ref{eq:defer-equal-docs}) completes the proof. \end{proof} Together, Theorem~\ref{thm:defer-to-any-docs} and Claim~\ref{claim:equalizing-conditional-docs-good} suggest a general framework for using deferrals to post-process a soft, possibly deferring classifier $\mathmode{\hat{S}}$ which is groupwise calibrated into a hard deferring classifier which simultaneously equalizes PPV, NPV, cFPR, and cFNR across groups, as follows. For each $g \in \mathmode{\mathcal{G}}$, let $\mathmode{\hat{\mathcal{P}}}_g$ be the conditional AP of $\mathmode{\hat{S}}$ for group $g$. Let $\mathmode{\hat{\mathcal{P}}}^*$ be any conditional AP such that $\supp(\mathmode{\hat{\mathcal{P}}}^*) \subseteq \cap_{g\in \mathmode{\mathcal{G}}}\supp(\mathmode{\hat{\mathcal{P}}}_g)$. Use Theorem~\ref{thm:defer-to-any-docs} to equalize the conditional APs for all groups $g\in \mathmode{\mathcal{G}}$. Then use any hard post-processor $\mathmode{\hat{D}}$ satisfying the requirements of Claim~\ref{claim:equalizing-conditional-docs-good} to make the ultimate deferring hard classifier. This method is shown in Figure \ref{fig:transform_docs1_to_docs2}. This framework allows for enormous flexibility in the choice of both $\mathmode{\hat{\mathcal{P}}}^*$ and $\mathmode{\hat{D}}$, even when considering just two groups $g_1$ and $g_2$. In Figure~\ref{fig:min-pdf}, we illustrate the first step of the framework on a COMPAS dataset using $\min\{\mathmode{\hat{\mathcal{P}}}_{g_1},\mathmode{\hat{\mathcal{P}}}_{g_2}\}$ as $\mathmode{\hat{\mathcal{P}}}^*$, where $g_1$ is African-Americans and $g_2$ is Caucasians. In Figures~\ref{fig:compas-black-to-white} and~\ref{fig:compas-white-to-black} in Section~\ref{sec:experiments}, we also use $\mathmode{\hat{\mathcal{P}}}_{g_1}$ and $\mathmode{\hat{\mathcal{P}}}_{g_2}$ as $\mathmode{\hat{\mathcal{P}}}^*$. \begin{figure}[htp] \centering \includegraphics[width=0.5\hsize]{graphs/transform_pdf1_to_pdf2.png} \caption{Choosing deferrals cleverly allows transforming one AP into another (conditional) AP. In this example, the solid orange line is the original AP $\mathmode{\hat{\mathcal{P}}}_g = \Pr[\mathmode{\hat{S}}(X_g) = s]$. By deferring at the rates indicated by the shaded region, the resulting conditional AP $\mathmode{\hat{\mathcal{P}}}_g' = \Pr[\mathmode{\hat{S}}(X_g)=s \mid \mathmode{\hat{S}}(X_g) \ne \pX]$ is represented by the dark blue line. The area of the shaded region is $\Delta$.} \label{fig:transform_docs1_to_docs2} \end{figure} One can design $\mathmode{\hat{\mathcal{P}}}^*$ to achieve additional goals. For example, the choice $\mathmode{\hat{\mathcal{P}}}^* = \min\{\mathmode{\hat{\mathcal{P}}}_{g_1},\mathmode{\hat{\mathcal{P}}}_{g_2}\}$ results in \emph{equal deferral rate} across each group (equal to the total variation distance between the two initial conditional APs). The framework can be further expanded by combining deferrals with other methods for manipulating conditional APs, including the mass-averaging discussed in Section~\ref{sec:docs-without-deferrals}. A better understanding of these techniques is left for future work. \section{Experiments on COMPAS Data} \label{sec:experiments} We test our methodology on the Broward County data made publicly available by ProPublica \cite{angwin2016machine}. This data set contains the recidivism risk decile scores given by the COMPAS tool, 2-year recidivism outcomes, and a number of demographic and crime-related variables on individuals who were scored in 2013 and 2014. We restrict our attention to the subset of defendants whose race is recorded as African-American or Caucasian. These will form the two groups with respect to which we wish to examine different fairness criteria. After applying the same data pre-processing and filtering as reported in the ProPublica analysis, we are left with a data set on n = 5278 individuals, of whom 3175 are African-American and 2103 are Caucasian. \\ \noindent Indeed, it has been shown that the COMPAS scoring mechanism is an approximately calibrated soft classifier with 10 possible outcomes. We note here that the distribution of the COMPAS scores differs significantly across the two groups. In particular, the scores for Caucasians are more evenly distributed as opposed to the skewed distribution seen with African-Americans. \subsection{Thresholding with Deferrals} We first ran our two-threshold post-processing mechanism (Section~\ref{sec:threshold-deferrals}) and obtained a binary decision algorithm with deferrals which equalizes both PPV and NPV across Caucasians and African-Americans (See Figure \ref{fig:compas-thresholds}). For simplicity we avoid using randomization for members within a particular decile score and instead settle for approximate equalization of PPV and NPV. We observe that the percent of deferrals in total is smaller than 20\% of the decisions to be made which shows that a fairly large number of the defendants can be classified without having to defer to a downstream decision maker. \begin{figure}[htp] \centering \subfloat{\includegraphics[width=0.4\hsize]{graphs/black_thresholds.pdf}} \hspace*{2cm} \subfloat{\includegraphics[width=0.4\hsize]{graphs/white_thresholds.pdf}} \caption{Two thresholds are applied to each AP for the COMPAS data from 2016, (approximately) equalizing PPV and NPV. In the left plot we show the thresholds for the African American group, and in the right plot, we show the thresholds for the Caucasian group.} \label{fig:compas-thresholds} \end{figure} The thresholds suffer from the issue highlighted in Example~\ref{ex:social-unsat}, demonstrating that blindly equalizing PPV and NPV using thresholds can be problematic. Namely, the resulting deferring hard classifier is much stricter for African-Americans than for Caucasians. Next we look at our post-processing mechanisms to equalize all four quantities PPV, NPR, FPR, and NPR using deferrals (Section~\ref{sec:docs-with-deferrals}). As was noted earlier in the paper, equalizing the APs of the two groups post-deferral achieves the goal of equalizing all four of the above quantities. We implement two methods for doing so. \subsection{Converting one AP into Another} In the first method, decisions are deferred only on one group so as to convert its AP into that of the other group. First, we consider deferring only on Caucasians to convert their AP into that of African-Americans (Figure~\ref{fig:compas-white-to-black}); next, decisions are deferred only for African Americans (Figure~\ref{fig:compas-black-to-white}). \begin{figure*}[htp] \centering \begin{minipage}{.5\textwidth} \centering \includegraphics[width=0.8\linewidth]{graphs/black_to_white.pdf} \caption{Our conditional AP equalization method applied to COMPAS data from 2016. We use deferrals to create a conditional AP for African Americans that matches the AP for Caucasians.} \label{fig:compas-black-to-white} \end{minipage}% \hspace*{1cm} \begin{minipage}{.5\textwidth} \centering \includegraphics[width=0.8\linewidth]{graphs/white_to_black.pdf} \caption{We create a conditional AP for Caucasians using the AP for African Americans. Notice the difference in the rates and distributions of deferrals between the two methods.} \label{fig:compas-white-to-black} \end{minipage} \end{figure*} \iffalse \begin{figure}[h] \includegraphics[width=0.5\hsize]{graphs/black_to_white.pdf} \caption{Our conditional AP equalization method applied to COMPAS data from 2016. We use deferrals to create a conditional AP for African Americans that matches the AP for Caucasians.} \label{fig:compas-black-to-white} \end{figure} \begin{figure}[htp] \includegraphics[width=0.5\hsize]{graphs/white_to_black.pdf} \caption{Our conditional AP equalization method applied to COMPAS data from 2016. We create a conditional AP for Caucasians using the AP for African Americans. Notice the difference in the rates and distributions of deferrals between the two methods.} \label{fig:compas-white-to-black} \end{figure} \fi \subsection{Equalizing APs} Alternately we have a second method where decisions are deferred for an equal fraction of Caucasians and of African Americans (Figure~\ref{fig:min-pdf}). This fraction is precisely equal to the statistical (\emph{total variation}) distance between the distributions of scores produced by the soft classifier on the two groups. \begin{figure}[htp] \centering \includegraphics[width=0.5\hsize]{graphs/min_method.pdf} \caption{A version of our conditional AP equalization method applied to COMPAS data from 2016. The AP for African Americans and the AP for Caucasians are converted into a conditional AP that has the same distribution as the pointwise minimum of the two APs. Notice that the total deferral rate is equalized between the two groups (this is equal to precisely the total variation distance between the two APs), but the distribution of deferrals across scores is not.} \label{fig:min-pdf} \end{figure} We observe several striking phenomena on the COMPAS data set. First, using the method of deferring only on African-Americans we defer on roughly 36\% of the total decisions. This number goes down to roughly 25\% when we defer only on Caucasians. This seems to suggest as a general heuristic to try and use deferrals on the group with smaller size. The total deferral fraction is also roughly 25\% when we defer on an equal fraction of Caucasians and African-Americans. Second, for all three methods that equalize the score distributions, deferrals happen more on the ``extremes'', namely on individuals with respect to which the classifier had relatively high confidence (either close to 0 or close to 1). This stands in sharp contrast to how the two-threshold method (Figure \ref{fig:compas-thresholds}) distributes its deferrals---they occur only in the middle of the distribution (namely for elements for which the classifier is ``unsure''). More work is needed to better understand the full space of deferral strategies.
{'timestamp': '2019-01-23T02:25:20', 'yymm': '1810', 'arxiv_id': '1810.02003', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02003'}
arxiv
\section{Introduction}\label{sec:introduction} Synthesizing high-quality 3D mesh sequences is of great significance in computer graphics and animation. In recent years, many techniques~\cite{Bogo2014,Dou2016,Stoll2010} have been developed to capture 3D shape animations, which are represented by sequences of triangular meshes with detailed geometry. Analyzing such animation sequences for synthesizing new realistic 3D mesh sequences is very useful in practice for the film and game industry. Although deep learning has achieved significant success in synthesizing a variety of media types, directly synthesizing mesh animation sequences by deep learning methods remains unexplored. In this paper, we propose a novel long short-term memory (LSTM)~\cite{hochreiter1997long} architecture to learn from mesh sequences and perform sequence generation, prediction and completion. A major challenge to achieve this is to go beyond individual meshes and understand the \emph{temporal} relationships among them. Previous work on mesh data tries to perform clustering and shape analysis~\cite{huang2015analysis,sidi2011unsupervised} on the \emph{whole} datasets. However, none of them pay attention to temporal information, which is crucial for animation sequences. Thanks to the development of deep learning methods such as the recurrent neural network (RNN) and its variants LSTM~\cite{hochreiter1997long} and gated recurrent unit (GRU)~\cite{cho2014learning}, one can more easily manipulate sequences. Based on RNNs, impressive results have been achieved in tasks with regard to video, audio and text, \emph{e.g}~movie prediction~\cite{mathieu2015deep,oh2015action}, music composition~\cite{lyu2015modelling}, text generation~\cite{vinyals2015show} and completion~\cite{melamud2016context2vec}. However, applying deep learning methods to triangle meshes is not a trivial task due to their irregular topology and high dimensionality. Researchers often use fully connected networks in text or audio. Different from them, 3D shapes have spatial locality, which is suitable to work with convolutional neural networks (CNNs). However, unlike 2D images, shapes do not have regular topology. Recent effort has been made for lifting 2D CNN to 3D data~\cite{kalogerakis20173d}, including multi-view~\cite{su2015multi} or 3D voxel~\cite{riegler2017octnet,wu2016learning} representations. Alternatively, meshes can be treated as graphs, and based on this a recent review~\cite{bronstein2017geometric} summarizes state-of-the-art deep learning methods in spectral and spatial domains. In order to reduce the number of parameters and extract intrinsic features, we utilize a CNN~\cite{duvenaud2015convolutional} defined on a shape deformation representation~\cite{gao2017sparse} that can effectively represent flexible and large-scale deformations. In summary, to analyze 3D mesh animation sequences, we propose a novel bidirectional LSTM architecture combined with mesh convolutions. The main contributions of this paper are: \begin{enumerate} \item We propose the first method to cope with mesh animation sequences, which allows generating sequences conditioned on given shapes, completing missing mesh sequences based on keyframes with realism and diversity and improving the generation of mesh sequences as more initial frames are provided. These capabilities significantly advance state-of-the-art techniques. \qyl{\item We design a share-weight bidirectional LSTM architecture that is able to boost performance and generate two sequences in opposite directions. Bidirectional generation also stabilizes training process and helps to complete a sequence in a more natural way.} \end{enumerate} \qyl{In the following, we first review relevant work, then presents our feature representation, network architecture, and loss functions. In Experiments section, we show extensive experimental results to justify our design and compare our work with previous work both qualitatively and quantitatively. Finally, we draw conclusions of our work.} \section{Related Work}\label{sec:relatedwork} \textbf{Sequence Generation with RNNs}. The recurrent neural network and its variants, such as LSTM~\cite{hochreiter1997long} and GRU~\cite{cho2014learning}, have been widely used in dealing with sequential data, including text~\cite{bowman2015generating,mikolov2011extensions}, video~\cite{mathieu2015deep,oh2015action} and audio~\cite{chung2015recurrent,marchi2014multi}. \cite{srivastava2015unsupervised} learn representations of video by LSTM in an unsupervised manner. PredNet~\cite{lotter2016deep} learns to predict future frames by comparing errors between prediction and observation. \cite{yu2017seqgan} incorporate policy gradients with generative adversarial nets (GAN)~\cite{goodfellow2014generative} and LSTM to generate sequences. Attempts have also been made to predict video frames using CNNs~\cite{vondrick2016generating}. To avoid predicting videos directly in the high-dimensional pixel space, some work uses high-level abstraction such as human poses~\cite{walker2017pose,cai2017deep} to assist with generation. In the human motion area, researchers utilize RNNs to predict or generate realistic motion sequences. \cite{fragkiadaki2015recurrent} propose an encoder-recurrent-decoder (ERD) to learn spatial embeddings and temporal sequences of videos and motion capture. \cite{gregor2015draw} generate image sequences with a sequential variational auto-encoder, where two RNN chains are used to encode and decode the sampled sequences accordingly. However, such approaches that iteratively take the output as input to the next stage could cause error accumulation and make the sequence freeze or diverge. To address this problem, \cite{li2017auto} present Auto-Conditioned RNNs (acRNNs) whose inputs are previous output frames interleaved with ground truth. With ground truth frames at the beginning of a sequence, acRNN can also generate output sequences conditioned on given input sequences. \cite{martinez2017human} build a sequence-to-sequence architecture which is able to predict multiple actions, but they do not have spatial encoding modules. Using an encoder-decoder structure, \cite{butepage2017deep} extract feature representations of human motion for prediction and classification. \cite{cai2017deep} use GAN and LSTM to generate actions or complete sequences by optimizing the input vector of the GAN. \textbf{3D Shape Generation}. Generating 3D shapes is an important task in graphics and vision community. Its down-stream applications include shape prediction, reconstruction and sequence completion. Nevertheless, such tasks are more challenging due to the high dimensionality and irregular connectivity of mesh data. Previous work mostly generates 3D shapes via interpolation or extrapolation in parameterized representations. \cite{huber2017smooth} propose to interpolate shapes in a Riemannian shell space. Based on existing shapes, data-driven methods (e.g.~\cite{gao2017data}) can generate realistic samples. However, such traditional methods focusing on shape representations and shape analysis have limited learning capabilities. More recently, \cite{tan2017variational} propose to use Variational Autoencoders (VAEs) to map mesh models into a latent space and generate new models by decoding latent vectors. Locally deformed shapes can also be generated by a combination of deep learning and sparse regularization~\cite{tan2017mesh}. While these learning based methods can produce new shapes which are more diverse and realistic, the temporal information of mesh animation sequences is not fully explored. \section{Methodology}\label{sec:methodology} \begin{figure*}[t] \begin{center} \includegraphics[width=0.8\linewidth]{arch.png} \end{center} \caption{Architecture of our network. (a) shows that our network is composed of LSTM module $cell$ and mesh convolution module $Conv,tCnv$. Take the network $S_t$ at time step $t$ as an example, the input to $Conv$ is the deformation representation $X_t$. The interface between $cell$ and $Conv$ is a fully connected layer, which outputs a low-dimensional vector $z$ into $cell$. $tCnv$, a stack of transpose convolution layers, mirrors $Conv$ and shares weights with it. The output of $tCnv$ is the feature change $\delta X_t$. $\delta X_t+X_t$ gives the predicted feature for time step $t+1$, which is fed into $S_{t+1}$ iteratively. (b) is our bidirectional LSTM. Both chains have the same architecture as in (a), and the only difference is their opposite direction. The forward chain takes the first model as input and the backward chain takes the last. They share weights and their predictions are constrained to match with each other. } \label{fig:networkstruct} \end{figure*} \subsection{Mesh Sequence Representation}\label{sec:representation} Mesh animation sequences are typically represented as a set of meshes with the same vertex connectivity and different vertex positions. Such meshes can be obtained by consistent remeshing or mesh deformation, and become very common nowadays due to the improved scanning and modeling techniques. These animated mesh sequences usually contain large-scale and complex deformations. \qyl{In this work, we represent shapes using a shape deformation representation~\cite{gao2017sparse}, a state-of-the-art representation which works well for large-scale deformation and suitable for deep learning methods.} Assume the mesh sequence dataset $M$ contains $n$ shapes and each mesh is denoted is as $m_t$ ($t=1, 2, \dots, n$). We denote $\bm{p}_{t,i}\in \mathbb{R}^3$ as the $i^{\rm th}$ vertex of the $t^{\rm th}$ model. $\bm{D}_{t,i}$ represents the deformation gradient defined in each 1-ring vertex neighborhood, which is computed as \begin{equation}\label{equa:T} \underset{\bm{D_{t,i}}}{\arg\min}=\underset{j\in N_i}{\sum} c_{ij}\left\|(\bm{p}_{t,i}-\bm{p}_{t,j})-\bm{D_{t,i}}(\bm{p}_{1,i}-\bm{p}_{1,j})\right\|_{2}^2 \end{equation} where $N_i$ is the 1-ring neighbors of the $i^{\rm th}$ vertex of the $t^{\rm th}$ shape, and $c_{ij}$ is the cotangent weight to avoid discretization bias~\cite{Levi}. The deformation gradient matrix $\bm{D_{t,i}}$ is decomposed into rotation matrix $\bm{R_{t,i}}$ and scaling matrix $\bm{S_{t,i}}$: $\bm{D_{t,i}}=\bm{R_{t,i}}\bm{S_{t,i}}$. The difficulty for representing large-scale deformations is that the same rotation matrix $\bm{R_{t,i}}$ is mapped to two rotation axes with opposite directions, and the associated rotation angle can include different number of cycles. To solve this rotation ambiguity problem, a global integer programming based method~\cite{gao2017sparse} is applied to obtain as-consistent-as-possible assignment which outputs a feature vector $\bm{q_{t,i}}\in\mathbb{R}^9$. The mesh representation $X_t$ is eventually produced by linearly normalizing each dimension of $\bm{q_{t,i}}$ into $[-0.95,0.95]$~\cite{tan2017variational}. \subsection{Generative Model}\label{sec:model} The overall architecture of our approach is illustrated in Fig.~\ref{fig:networkstruct}. In this illustration, we denote LSTM cells as $cell$. $Conv$ refers to the mesh convolutional operations~\cite{duvenaud2015convolutional,tan2017mesh} and $tCnv$ represents transpose convolutions. For each convolutional filter, the output at a vertex is computed by a weighted sum of its 1-ring neighbors along with a bias: \begin{equation}\label{equa:conv} y_{i} = W_{1}x_i+W_{2}\frac{\sum_{j=1}^{d_i}x_{n_{ij}}}{d_i}+b \end{equation} where $x_i$ and $y_i$ are input and output at the $i^{\rm th}$ vertex, $W_1$, $W_2$ and $b$ are the filter's weights and bias, $d_{i}$ is the degree of the $i^{\rm th}$ vertex, and $n_{ij}$ is the $j^{\rm th}$ 1-ring neighbor of the $i^{\rm th}$ vertex. The interface between LSTM module and mesh convolution layers is a fully connected layer. Given the LSTM state $s_t$ and model $X_t$, we first describe how to generate the next model $X_{t+1}$. First we put $X_t$ into the mesh convolutional sub-network $Conv$, which outputs a low-dimensional latent vector $z=Conv(X)$. After that, $z$ is sent to LSTM cell $cell$ and the output is in the following form: $(\hat{z}, s_{t+1})=cell(z, s_t)$, where $s_{t+1}$ represents the updated state and $\hat{z}$ is the updated latent vector. $\hat{z}$ is then passed to transpose mesh convolution $tCnv$. Similar to many sequence generation algorithms, the output of $tCnv(\hat{z})=\delta X_{t}=X_{t+1}-X_{t}$ is defined as the difference between the next and current models, instead of $X_{t+1}$ to alleviate error accumulation. In the end, the generated model from $X_t$ is simply worked out as $X_{t+1}=X_{t}+\delta X_{t}$. Consecutive models are generated iteratively in the same way. For simplicity, the whole process in one iteration is denoted as $(s_{t+1},X_{t+1})=G(s_t,X_t)$\\ Fig.~\ref{fig:networkstruct} illustrates the whole process of generating sequential data using our model. Suppose that we already have a set of models $S_{i,j}=\{X_{i}, X_{i+1},..., X_{j}\},(i\leq j)$. To extend the sequence, we would like to predict its $n$ future models $S_{j+1,j+n|i,j}=\{X_{j+1}, X_{j+2},..., X_{j+n}|X_{i},X_{i+1},..., X_{j}\}$. Our method first puts the existing models into the network in their order, lets the LSTM cell update its state to $s_j$ from an initial state $s_0$. When it comes to the $j^{\rm th}$ model, the network outputs $X_{j+1}$, which is afterwards treated as the $j+1^{\rm st}$ input, and this process repeats for $n$ times, leading to the follow-up sequence $S_{j+1,j+n|i,j}$. \subsection{Bidirectional Generation}\label{sec:bigen} Sequence generation is a promising while challenging problem in various data forms like video, music and text, not only for the potentially tricky way to exploit temporal information but also about how to obtain enough training data. When the data is scarce for a specific application, which is often the case for 3D model datasets, training can be problematic. However, unlike text, movie and audio, 3D model sequences can be more flexible. On the one hand, the order of 3D shape sequences is less strict, i.e., the inverse of a motion can also be reasonable. On the other hand, there are usually multiple plausible paths between two shapes. Based on those two observations, we propose a bidirectional generation constraint, which avoids restricting results to specific deformation paths, as shown in Fig.~\ref{fig:networkstruct}. From a 3D model dataset, we arbitrarily choose two models $X_{a}, X_{b}$ as endpoints of two inverse $n$-length sequences $S^{f}, S^{b}$ such that $S^{f}_1=S^{b}_n=X_{a},S^{f}_n=S^{b}_1=X_{b}$. Let $X_{a}, X_{b}$ have opposite initial states $s^{f}_0,s^{b}_0$, we expect them to generate similar models, satisfying $\forall 1\leq i\leq n,S^{f}_i \approx S^{b}_{n+1-i}$. \subsection{Loss Function}\label{sec:loss} In this paper, the loss function is composed of three terms as \begin{equation}\label{equa:lossall} L = L_{reconstruct}+\alpha_1 L_{bidirection}+\alpha_2 L_{reg} \end{equation} To illustrate this, let the ground truth models be $\{X_1,X_2,...,X_n\}$, which are expected to be the results of forward sequence $S^f$ and backward sequence $S^b$. The reconstruction loss $L_{reconstruct}=\sum_{i=1}^{n}(||S^{f}_{i}-X_i||+||S^{b}_{i}-X_{n+1-i}||)$ forces both sequences to resemble samples from the dataset. Meanwhile, as described before, bidirectional sequence $S^f,S^b$ share weights and have similar outputs, which is ensured by bidirectional loss $L_{bidirection}=\sum_{i=1}^{n}||S^{f}_i-S^{b}_{n+1-i}||$. Furthermore, $L_{reg}=L_{KL}+L_2$ contains KL divergence term and $L_2$ loss to regularize the network. The KL divergence between the low-dimensional vector and Gaussian distribution is computed so as to get a good mapping. Therefore, we have $L_{KL}=D_{KL}(q(z|X)|p(z))$, where $q(z|X)$ is the posterior distribution and $p(z)$ is the Gaussian prior distribution. In experiments, we set $\alpha_1=0.5,\alpha_2=0.1$. \section{Experiments}\label{sec:experiments} \begin{figure*}[t] \begin{center} \includegraphics[width=0.95\linewidth]{qualit.png} \end{center} \caption{Qualitative results of our method on Dyna~\cite{pons2015dyna}, handstand~\cite{vlasic2008articulated} and horse~\cite{sumner2004deformation}. We give one source model to the network and it generates the following four shapes. This is the first approach able to generate a whole sequence from only one mesh.} \label{fig:qual} \end{figure*} \begin{figure*}[t] \begin{center} \includegraphics[width=.95\linewidth]{line.png} \end{center} \caption{Shape feature change between subsequent frames of different methods. This line graph depicts the amount of feature changes $mean(||X_{t}-X_{t+1}||/X_{t})$ between consecutive frames. The proposed method (blue) has stable and visible changes. Networks without KL loss or BD-training suffer from frozen sequences, and the one without $L_2$ regularization has significant jerk.} \label{fig:line} \end{figure*} \subsection{Framework Evaluation}\label{sec:evaluation} We now evaluate the effectiveness of different components in our framework. \textbf{Bidirectional generation.} \qyl{We propose a share-weight bidirectional LSTM (BD-LSTM) to better utilize temporal information and facilitate sequence completion.} Fig.~\ref{fig:completion} demonstrates that our BD-LSTM can produce results with better diversity. On the other hand, the $L_{bidirection}$ and $L_{KL}$ terms impose stronger constraints during training and consequently helps predict more accurate sequences. According to the numerical results in Tab.~\ref{tab:arch_test}, our method is more effective than existing methods~\cite{tan2017variational,gao2017sparse}. \qyl{Moreover, our method benefits from multiple initial frames, as well as the bidirectional constraint. In Tab.~\ref{tab:rebutaladd}, we show the results if we do not use our BD-LSTM or leave out $L_{KL}$ term.} \textbf{Loss terms.} Error accumulation is a common problem in sequence generation tasks~\cite{gregor2015draw,li2017auto,martinez2017human}. Generated meshes usually freeze because results tend to stay at an average shape, or even diverge to random results. To address this problem, we use three methods, 1) $L_{KL}$ divergence to regularize the internal distribution, 2) $L_2$ regularization loss to mitigate overfitting, and 3) bidirectional generation to impose an additional constraint. To justify those terms, we train models without one of the three. For unidirectional sequences, we only use one direction of LSTM. The line graphs in Fig.~\ref{fig:line} shows representation changes $mean(||X_{t}-X_{t+1}||/X_{t})$ between adjacent frames $X_{t}$ and $X_{t+1}$. The four networks are trained on Dyna~\cite{pons2015dyna} for 7000 iterations, and tested on 32 randomly chosen sequences. From the test one can see that without KL or BD-LSTM, the sequence tends to freeze. Meanwhile, $L_2$ regularization helps to reduce jerk. In Tab. \textbf{Initial frames.} Generating a sequence based on initial frames is an important application. In theory, the more bootstrap frames we have, the more knowledge we obtain about the sequence therefore we are supposed to make more accurate prediction. Previous mesh generation approaches, however, are based on interpolation/extrapolation, which can only use two of the existing models (endpoints). Our method can take advantage of all input frames by feeding them into the LSTM. A previous human motion prediction method uses $u(=4)$ frames to start the recurrent network~\cite{li2017auto}. We test $u=1$ and $u=3$ in Tab.~\ref{tab:arch_test} to show that more initial frames can reduce the distance between prediction and ground truth. \begin{table}[tb] \begin{center} \setlength{\abovecaptionskip}{2pt} \begin{tabular}{|c|c|c|c|} \hline Ours & Std. BD-LSTM & Unidir. LSTM & no $L_{KL}$ \\ \hline \textbf{88} & 123 & 114 & 103 \\ \hline \end{tabular} \rightline{per-vertex position error($\times 10^{-4}$)} \caption{\qyl{Average vertex position errors on the Punching dataset~\cite{pons2015dyna} with different network architectures. We can see that our share-weight BD-LSTM outperforms standard BD-LSTM and unidirectional LSTM. Also we observe a decrease in accuracy if the $L_{KL}$ term is omitted.}} \label{tab:rebutaladd} \end{center} \end{table} \begin{figure*}[t] \begin{center} \includegraphics[width=.95\linewidth]{gene.png} \end{center} \begin{tabular}{p{4.3cm}p{4.3cm}p{4.3cm}p{4cm}} (a) Ground Truth&(b) \cite{gao2017sparse}&(c) \cite{tan2017variational}&(d) Ours \end{tabular} \caption{Comparison with other work on sequence generation. In this experiment, two consecutive frames are sent into the network, and we aim to predict the future $5^{\rm th},10^{\rm th},15^{\rm th}$ shapes. (a) shows the ground truth of relevant shapes; (b) is obtained by using linear extrapolation on the feature~\cite{gao2017sparse}; (c) is extrapolation on a feature from deep learning~\cite{tan2017variational}; (d) is our result. We can see that extrapolation-based generation fails when predicting frames further away. (b) totally fails on the $15^{\rm th}$ frame. and (c) also produces abnormal deformation, as highlighted in the red circles. In contrast, our method forms a natural cycle and avoids exceeding the limits (following the horse's stride). } \label{fig:gene} \end{figure*} \begin{figure*}[t] \begin{center} \includegraphics[width=.9\linewidth]{condition.png} \end{center} \caption{Conditional generation. Trained with a mixture of different Dyna datasets, our network can output sequences conditioned on the first two input shapes. For examples, on the right of the figure, we feed two fit female shapes into the network. The second frame in (c) lifts her right leg while (d) lifts the left leg. Our model can perceive their differences and predict subsequent motion according to the condition. Similar results can be observed in the fat male example on the left.} \label{fig:conditional} \end{figure*} \begin{figure*}[t] \begin{center} \includegraphics[width=0.9\linewidth]{completion.png} \end{center} \caption{Diversified sequence completion. We show the completion results produced by different methods. Source (first) and target (last) shapes are shared among all the sequences. (a) is the ground truth from f\_ 50004\_jumpingJacks dataset~\cite{pons2015dyna}; (b)(c)(d) use our BD-LSTM; (e) is the optimization+unidirectional baseline strategy described in \qyl{the paper}; (f), (g) and (h) are interpolation results using \cite{tan2017variational}, \cite{gao2017data} and \cite{gao2017sparse} accordingly. We can see that (f)(g)(h) generate almost identical shapes because interpolation follows the shortest path between source and target. Compared to (e), our method can generate diverse, plausible results for users to choose.} \label{fig:completion} \end{figure*} \begin{table*}[t] \begin{center} \setlength{\abovecaptionskip}{2pt} \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{Method} & \multicolumn{3}{|c|}{Punching} & \multicolumn{3}{|c|}{ShakeArm} & \multicolumn{3}{|c|}{Handstand} & \multicolumn{3}{|c|}{Horse} \\ \cline{2-13} &5&10&15&5&10&15&5&10&15&5&10&15\\ \hline \hline Ours+1 IF& 175& 156& 285& 335& 381& 319& 323 & 527& 516& 603& 869& 1328\\ \hline Ours+3 IF& 95& 84& {\bf 107}& 301& {\bf 226}&{\bf 290}& 212 & {\bf 379}& {\bf 428}&451& {\bf 329}& {\bf 671}\\ \hline \hline \cite{tan2017variational}& 132& 240& 457& {\bf 291}& 433& 688& {\bf 93}& 489& 797& {\bf 286}& 713&1032\\ \hline \cite{gao2017sparse}& 294& 361& 413& 391& 472& 110& 487& 401&1589& 334& 1051& 1568\\ \hline \end{tabular} \rightline{per-vertex position error($\times 10^{-4}$)} \caption{Comparison of variants of our method and previous work on per-vertex position error (average distance between vertex positions of ground truth and prediction). In this experiment, we observe that more initial frames (IF) will improve the performance. Our method outperforms \cite{tan2017variational} and extrapolation+~\cite{gao2017sparse} since they suffer from error accumulation thus the accuracy degrades as the sequence moves on. } \label{tab:arch_test} \end{center} \end{table*} \subsection{Sequence Generation} \label{sec:generation} We now evaluate sequence generation capability of the proposed method. Starting from some initial frames, sequence generation predicts future frames. \textbf{Generating sequences.} As far as we are aware, this is the first work to learn and generate arbitrarily long mesh sequences. Given two initial frames, people used to generate meshes through extrapolation~\cite{tan2017mesh}. However, simply extrapolating shapes fail to capture long-term temporal information, \emph{e.g}~periodicity of the sequence. With the help of LSTM, our model can record history information and iterate to generate realistic mesh sequences in any length, even if the number of models in the dataset is limited. In the experiment, we feed first two mesh models to the LSTM and let it generate following frames. Qualitative and quantitative results are shown respectively In Fig.~\ref{fig:qual} and Tab.~\ref{tab:arch_test}. We compare our model with ground truth as well as previous extrapolation-based methods~\cite{tan2017variational,gao2017sparse}. Fig.~\ref{fig:gene} plots the predictions on the $5^{\rm th}$, $10^{\rm th}$ and $15^{\rm th}$ future frames. We can see that both extrapolation methods fail on the $15^{\rm th}$ frame, because linearly extending the motion path eventually exceeds the plausible deformation space. In contrast, our method is aware of periodicity of the sequence, and able to return back once reaching the extreme point, producing natural motion cycles. \textbf{Conditional generation.} Another promising application of our method is to generate sequences of various shapes conditioned on the provided initial frames. Previous approaches achieve conditional human motion generation on video~\cite{srivastava2015unsupervised} and skeletons~\cite{cai2017deep}, but not on 3D shape sequences. To illustrate the effectiveness of our method, we take Dyna~\cite{pons2015dyna} as an example. In this collection of datasets, there are female/male models of different subjects and actions. All meshes in different datasets have the same number of vertices and share connectivity, so we train our model on a mixture of those datasets. In testing, we feed $u(=2)$ bootstrap models with a certain body mass index (BMI)/gender/motion as input, and get the following $n(=16)$ sequences as output. We show our results in Fig.~\ref{fig:conditional}. The observation is that our method can generate human shapes in different subjects and gender. Furthermore, even if the first frame is the same, the network can produce different action sequences according to the second frame. \subsection{Sequence Completion} \label{sec:completion} We now consider another important application namely sequence completion, which produces in-between shapes given two endpoint frames. \textbf{Completion based on key frames.} Completing a mesh sequence based on given anchors is an important application in animation. In our approach, we clip the target sequence by keyframes. For each segment, we run our bidirectional network by treating two keyframes as endpoints. Once the forward and backward sequences converge at a model, we stitch them to form a whole sequence. Since the computation is identical for each segment, for illustration we show an example of completing one segment constrained on two key frames. Fig~\ref{fig:completion} shows an example on the Dyna Dataset~\cite{pons2015dyna}. (f)(b)(h) are all interpolation-based. Those methods generate shapes along the shortest path between them, which are almost still because of high similarity between the first and last models. \textbf{Generating novel sequence.} Previous interpolation-based methods usually adopt a deterministic strategy to complete sequences, and thus result in a monotonous sequence. Our work, however, is able to produce diversified sequence completion results. By assigning a random vector to the LSTM state, the network generates different sequences as shown in Fig.~\ref{fig:completion}. In the real world, there are often more than one possible motions between two static poses and our model can therefore better describe such characteristics in human motion than other generation methods. \\ To test alternative completion strategies, we also implement an optimization+unidirection~\cite{cai2017deep} strategy. Given the source model $X_0$ and $X_n$, we first find the optimal LSTM initial state $\hat{s_0} = \underset{s_0}{\arg\min}||\hat{X_n}-X_n|| $, where \begin{equation}\label{equa:s} \left\{ \begin{aligned} (\hat{X_t},s_t)&=G(X_0,s_0) & i=t \\ (\hat{X}_{t+1},s_{t+1})&=G(\hat{X_t},s_t) & i > t \end{aligned} \right. \end{equation} After solving the optimization problem with~\cite{hansen2001completely}, we then compute $\{\hat{X_t}\}$ through Eq.~\ref{equa:s}. The result is shown in Fig.~\ref{fig:completion} (e). Compared to interpolation strategies, the optimization+unidirection algorithm can achieve more realistic morphing, but it does not provide diverse possible choices as our BD-approach. \subsection{Implementation Details}\label{sec:Implementation} We use Tensorflow as the framework of our implementation. Experiments are performed on a PC with an Intel Core i7-2600 CPU and an NVIDIA Tesla K40c GPU. We use Adam optimizer~\cite{kingma2014adam} to update weights, with default Adam parameters $\beta _1=0.9,\beta _2=0.999$ as in \cite{kingma2014adam}. For each dataset, we randomly exclude a subsequence, which takes up 20\% of the dataset, as a a test set. A training process takes 7000 iterations, lasting for around 8 hours. In each iteration, we generate 8 sequences, each of them containing 32 shapes. For the dataset where motion is slow~\cite{pons2015dyna}, we sample every other model in sequences. For all experiments, the LSTM $cell$ has 3 layers and 128 hidden dimensions, and we set initial states as $s^{f}_0=-s^{b}_0=[0.1]^{128}$. The mesh convolution module $Conv$ is composed of 3 layers with $tanh$ as the activation function. Transpose convolutions $tCnv$ mirrors $Conv$ and shares the same weights. \section{Conclusion} In this paper, we propose the first deep architecture to generate mesh animation sequences, which can not only predict future frames given initial frames, but also complete mesh sequences based on key frames and generate sequences conditioned on given shapes. Extensive qualitative and quantitative evaluation demonstrates that our method achieves state-of-the-art generation results, and our completion strategy is also able to produce diverse realistic results. {\small
{'timestamp': '2018-10-05T02:06:30', 'yymm': '1810', 'arxiv_id': '1810.02042', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02042'}
arxiv
\section{Description of purpose} The availability of training data in medical image segmentation problems is often very limited. In such cases, convolutional neural networks (CNNs) tend to overfit due to a lack of feature generalization to variations in shapes and appearance, and over parameterization. In order to address generalization, one has to find models that generate features equivariant or invariant under different transformations of the input. Equivariance of feature maps generated by CNNs to certain transformations can be obtained by using group convolutions \cite{cohen16} where different orientations of the features maps are learnt by kernels with shared weights. However, the resulting equivariance is restricted to only linear and symmetric transformations. In order to reach generalization across a large group of transformations one has to rely on data augmentation. Data augmentation is commonly achieved by applying transformations that generate warped versions of the available training data. The choice of the transformation in literature so far has been fairly arbitrary -- often restricted to rotations, translations, reflections, and very small nonlinear deformations~\cite{roth2015,NIPS2015_5854,hauberg2016}. Some degree of learning the right kind of transformations needed to improve the network performance was introduced in~\cite{NIPS2015_5854}. Hauberg et al.~\cite{hauberg2016} proposed a diffeomorphic registration approach where the distribution of transformations are learnt by explicitly constructing it by performing pair-wise registration of $N$ more similar images. Once the distribution is constructed, new transformations are sampled and applied to the training data to obtain data for augmentation. However, variations captured by the probability density function (pdf) of transformations is strongly dependent on the choice of $N$. One may circumvent this dependency by registering all the possible pairwise images in the dataset, however, it is computationally expensive and images that cannot be plausibly registered may induce transformations that are not meaningful. In order to obtain a model that produces transformations that capture shape variations in training data automatically, we propose Probabilistic Augmentation of Data using Diffeomorphic Image Transformation (PADDIT). PADDIT involves an unsupervised approach to learn shape variations that naturally appear in the training dataset. This is done by first constructing an unbiased template image that represents the central tendency of shapes in the training dataset. We sample -- using a Hamiltonian Monte Carlo (HMC) scheme~\cite{duane1987} -- transformations that warp the training images to the generated mean template. The sampled transformations are used to perturb training data which is then used for augmentation. We use convolutional neural networks (CNNs) to segment T1/FLAIR brain magnetic resonance images (MRI) for white matter hyperintensities. We show that PADDIT outperforms CNN methods that use either no data augmentation or limited augmentation (using random B-spline transformations). \section{Methods} Probabilistic Bayesian models for template estimation in registration was introduced by \cite{zhang2013}, albeit using a different class of transformations. In short, the method views image registration as a maximum a posteriori (MAP) problem where the similarity between two images ($I_1$, $I_2$) is the likelihood. The transformations are (lie group exponential of a time-constant velocity field $\bold v$) regularized by a prior which is in the form of a norm attached to velocity field. Formally, it is a minimization of the energy \begin{equation} \label{reg} E(I_1, I_2, \bold v) = \|I_1 \circ \mathrm{Exp}(\bold{v}) - I_2\|^2 + \lambda \|\bold{v}\|^2. \end{equation} The norm on the vector field is generally induced by a differential operator. However, we directly choose a kernel {inducing a} reproducing kernel Hilbert space to parameterize the velocity field~\cite{Pai:2016dz}. Given a finite set of kernels, the regularization takes the form, $ \|\bold{v}\|^2 = \sum_i \sum_j a^T K(x_i,x_j) a,$ where $a$ are the vectors attached to each spatial kernel, and $(x_{i},x_{j}) \in \Omega$ is the spatial position of each kernel $K$. Using the $L2$ distance metric between two images (minimization of~\eqref{reg}), one can formulate template estimation as a Fr{\'e}chet mean estimation problem. In other words, given a set of $N$ images (or observations) $I_1, \dots, I_N$, the atlas $\hat{I} $ is the minimization of the sum-of-squared distances function $(\hat{I} = \arg\!\min_{I_T} \frac{1}{N} \sum_{k=1}^N \|I_T-I_k\|^2.)$ Since~\eqref{reg} is viewed as a MAP problem, the velocity fields are considered as latent variables, i.e., $a \sim \mathcal{N}(0, K)$, a normal distribution with zero mean and covariance $K$ derived from a kernel function. In the presence of latent variables, the template estimation is posed as an expectation maximization (EM) problem. Further, for simplicity, we assume an i.i.d.\ noise at each voxel, with a likelihood term (for each $k^{\text{th}}$ observation) given by \begin{equation} p(I_k|\bold{v}_k,I_T,\sigma) = \frac{1}{(2\pi)^{V/2}\sigma^V} \mathrm{exp}\left(-\frac{\|I_T - I_k\circ\mathrm{Exp}(\bold{v}_k)\|^2}{2\sigma^2}\right), \end{equation} where $\theta=\{ \sigma, I_T \}$ are the parameters to be estimated via MAP; $\sigma$ is the noise variance, $I_T$ is the mean template, and $V$ is the number of voxels. Each observation can be viewed as a random variation around a mean ($I_T \circ \mathrm{Exp}(- \bold v)$). The prior on the velocity field may be defined in terms of the norm as: $p(\bold{v}_k) = \frac{1}{(2\pi)^{V/2}|K|^\frac{1}{2}}\mathrm{exp}\left(-\frac{\|\bold{v}_k\|^2}{2}\right).$ Estimating the posterior distribution $p(\theta|I_k) = p(I_k|\theta)p(\theta) = \int_\bold v p(I_k|\bold v,\theta) p(\bold v) d\bold v$ involves the marginalization of it over the latent variables. This is computationally intractable due to the dimensionality of $\bold v$. To solve this, Hamiltonian Monte Carlo (HMC)~\cite{neal2011} is employed to sample velocity field for marginalization. The posterior distribution to draw $S$ number of samples from is \begin{equation} \mathrm{log}\prod_{k=1}^N p(\theta|I_k) = \sum_{s=1}^S \mathrm{log} \prod_{k=1}^N p(I_k|\bold{v}_{ks}, \theta) p(\bold{v}_{ks}), \end{equation} The sampled velocity fields ($\bold{v}_{ks}$ of the $k^{\text{th}}$ image) are used in an EM algorithm to estimate an optimal~$\theta$. A single-scale Wendland kernel~\citep{Pai:2016dz} is used to parameterize the velocity field and construct the covariance matrix for regularization. Once a template is estimated, the posterior distribution is sampled for a set of velocity fields for each training data. To induce more variations, the velocity fields are randomly integrated between 0 and 1. The training samples are deformed with cubic interpolation for the image, and nearest neighbor interpolation for the atlas to create the new set of synthetic data. The input (for one image as an example) to the deep-learning network will be of the form $ \langle\langle I_n,L_n\rangle{},\langle I_n\circ\mathrm{Exp}(\bold{v}_{n1}), L_n\circ\mathrm{Exp}(\bold{v}_{n1}) \rangle{}, \dots \langle I_n\circ\mathrm{Exp}(\bold{v}_{nA}), L_n\circ\mathrm{Exp}(\bold{v}_{nA}) \rangle{} \rangle{}, $ where $A$ is the number of augmentations and $L_n$ is the label of input image $I_n$. {Note that the label is a segmentation assigning a class to each voxel and is transformed using the same transformation accordingly.} \newcommand{\ensuremath{\text{Cp}}}{\ensuremath{\text{Cp}}} \newcommand{\ensuremath{\text{Sd}}}{\ensuremath{\text{Sd}}} \section{Experiments and Results} We considered CNNs based on a U-net architecture in our experiments. To evaluate the proposed method, the performance of CNNs trained with data augmentation using PADDIT was compared to training without augmentation and training with augmentation using deformations based on random B-splines -- we call this method the baseline. The above-mentioned strategies were applied to White Matter Hyperintensities (WMH) segmentation from FLAIR and T1 MRI scans. To this end, we use the training dataset from the 2017 WMH segmentation MICCAI challenge \footnote{http://wmh.isi.uu.nl}. The set is composed of T1/FLAIR MRI scans and manual annotations for WMH from 60 subjects. The dataset was split into a training(30), validation(5) and testing(10) set. For each method two different deformed versions of each training case were created, i.e the training set size was tripled. The Random deformations for the baseline were obtained by using a deformation field defined on a grid with $\ensuremath{\text{Cp}}{}$ number of control points and B-spline interpolation. The size of deformation was controlled by adding Gaussian noise with $0$ mean and standard deviation $\ensuremath{\text{Sd}}{}$. We evaluate the impact of $\ensuremath{\text{Cp}}{}$ and $\ensuremath{\text{Sd}}{}$ hyperparameters, specifically we tried: $\ensuremath{\text{Cp}}{} = [4\times4\times4,8\times8\times8,16\times16\times16]$ and $\ensuremath{\text{Sd}}{} = [2,4,6] $. Figure \ref{fig:ex_deformations} shows examples of the obtained deformed versions of a FLAIR scan from one subject from the training dataset. As can be observed, both methods generated new shapes for WMHs regions. It is worth noting, however, that images provided by PADDIT look more realistic and without drastic alterations to the Brain. In contrast, those obtained using random B-spline deformations exhibit some aberrations in cortical and ventricular structures depending on the size of the deformation used. \begin{table}[!ht] \centering \begin{tabular}{c c|cccc} & & & \ensuremath{\text{Sd}}{}:2 & \ensuremath{\text{Sd}}{}:4 & \ensuremath{\text{Sd}}{}:6 \\ \rotatebox{90}{ \ \ \ FLAIR} &\includegraphics[width=5em,height=8em,angle=90]{Figures/Eg1_flair_original.png} & \ensuremath{\text{Cp}}{}: 4 & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_4_2.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_4_4.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_4_6.png}\\ \rotatebox{90}{\small{PADDIT 1}} & \includegraphics[width=5em,height=8em,angle=90]{Figures/EX1.png} & \ensuremath{\text{Cp}}{}: 8 & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_8_2.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_8_4.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_8_6.png}\\ \rotatebox{90}{ PADDIT 2} &\includegraphics[width=5em,height=8em,angle=90]{Figures/EX2.png} & \ensuremath{\text{Cp}}{}: 16 & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_16_2.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_16_4.png} & \includegraphics[width=5em,height=8em,angle=90]{Figures/FLAIR_16_6.png}\\ \end{tabular} \caption{Example of generated deformations. The first column shows the original FLAIR image, and the two deformed versions using PADDIT. Remaining columns show different configurations used to get the random B-spline based deformations}\label{fig:ex_deformations} \end{table} Figure \ref{fig:Performance_valtest}, shows the dice performance at each epoch on the validation and testing set. It is worth noting that PADDIT achieved higher accuracy than training with random B-spline deformations as well as training without augmentation. Also, it can be noted that random B-spline deformations did not provide a consistent improvement compared to the training without data augmentation. For the final assessment of PADDIT, the validation data was used for early stopping. The final evaluation of each method is carried out on the testing set using the network configuration at the epoch where it showed the highest accuracy on the validation set. The best configuration for random deformations was achieved using $\ensuremath{\text{Cp}}{} = 8\times 8 \times 8$ and $ \ensuremath{\text{Sd}}{} = 4$ For PADDIT, the control points were placed every 8 voxels. Results for evaluation on the testing set are summarized in Table \ref{Final_evaluation}. Our proposed method PADDIT achieved $\approx 0.2$ higher dice accuracy compared to the network performance without data augmentation and $\approx 0.15$ compared to the baseline data augmentation approach (best configuration). (both differences where statistically significant ($p<0.5$)) \begin{table}[!ht] \centering \begin{tabular}{cc} \includegraphics[height=4.5cm,width=7.5cm]{Figures/Validation.png} & \includegraphics[height=4.5cm,width=7.5cm]{Figures/Test.png} \\ \end{tabular} \caption{Performance on the validation and testing set for each method. Dice is computed at each epoch}\label{fig:Performance_valtest} \end{table} \renewcommand{\tablename}{Table} \begin{table}[!ht] \centering \begin{tabular}{cccccccccccc} \hline & \rotatebox{90}{\vtop{\hbox{\strut Non Data} \hbox{\strut Aug}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 4} \hbox{\strut \ensuremath{\text{Sd}}{}:2}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 4} \hbox{\strut \ensuremath{\text{Sd}}{}:4}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 4} \hbox{\strut \ensuremath{\text{Sd}}{}:6}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 8} \hbox{\strut \ensuremath{\text{Sd}}{}:2}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 8} \hbox{\strut \ensuremath{\text{Sd}}{}:4}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 8} \hbox{\strut \ensuremath{\text{Sd}}{}:6}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 16} \hbox{\strut \ensuremath{\text{Sd}}{}:2}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 16} \hbox{\strut \ensuremath{\text{Sd}}{}:4}}} & \rotatebox{90}{\vtop{\hbox{\strut Rd \ensuremath{\text{Cp}}{}: 16} \hbox{\strut \ensuremath{\text{Sd}}{}:6}}} & \rotatebox{90}{PADDIT } \\ \hline \hline Dice (mean) & 0.66321 & 0.6628 & 0.6347 & \underline{0.6661}& 0.6452 & 0.6438 & 0.6566 & 0.6358 & 0.6587 & 0.6535 & \textbf{0.6813} \\ Dice (std) & 0.24829 & 0.2260 & 0.2466 & \underline{0.2274} & 0.2347 & 0.2403 & 0.2327 & 0.2457 & 0.2238 & 0.2341 & \textbf{0.2185} \\ \hline \end{tabular} \caption{Segmentation accuracy for all the assessed strategies, the highest dice score achieved by the random B-spline deformation approach is underlined}\label{Final_evaluation} \end{table} \section{New or breakthrough work to be presented} Even though several configurations of random transformations generated realistic looking images, they were not necessarily useful in CNN training. On the other hand, the best configuration of random transformations generated images that were not necessarily biologically plausible. We hypothesize that such noisy data may help the optimization to find better minimums. However, one has to be careful in choosing the configuration of transformations since other configurations with a higher magnitude of deformations had a negative effect on the training. In the case of PADDIT, one need not worry about the transformation configuration too much since the method learns the right transformation needed to capture the shape variations in the data set. Hence, the resulting synthetic images were both realistic and useful for CNN training. \section{Conclusion} The proposed probabilistic augmentation approach PADDIT, proved to be an effective way to increase the training set by generating new training images which improve the segmentation performance of CNN's based approaches. From the results it is evident that the network trained with PADDIT performed statistically significantly better than the networks with either no data augmentation or random B-splines based augmentation. \textbf{This work has not been submitted for publication or presentation elsewhere.} \section*{Acknowledgments} This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No 721820. We would like to thank both Microsoft and NVIDIA for providing computational resources on the Azure platform for this project. \bibliographystyle{spiebib}
{'timestamp': '2018-10-05T02:02:42', 'yymm': '1810', 'arxiv_id': '1810.01928', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01928'}
arxiv
\section{Introduction} The thriving of Deep Neural Networks (DNN), especially Convolutional Neural Network (CNN), is empowered by the advance of hardware accelerators, such as GPU \cite{CUDA}, TPU \cite{TPU}, and neural network accelerators integrated into various embedded processors~\cite{Sim:2016:TDC}. The major challenges of accelerating classical CNNs, which are based on floating-point arithmetic, are (1) off-chip Dynamic Random-Access Memory (DRAM) access power overhead, and (2) on-chip data storage constraints. Many prior works have been proposed to accelerate CNNs by exploiting sparsity \cite{Han} or leveraging data reuse \cite{Eyeriss}. Among all kinds of solutions to the above challenges, quantization with reduced bitwidth in network parameters and input data is one of the most promising approaches. Algorithms such as \cite{ZhuHMD16, ZhouYGXC17, Binarynet} have successfully reduced the bitwidth of network weights while maintaining a high precision for image classification tasks. In particular, Binary Neural Network (BNN), a binary quantized version of CNN, has been studied extensively since it can significantly alleviate the DRAM memory access overhead and on-chip storage constraints. In BNN, the multiplication and addition in traditional floating point CNN inference are replaced by more power-efficient, compact, and faster bit operations, which are suitable for reconfigurable logic like Field-Programmable Gate Array (FPGA). However, though the bitwidth in both computation and storage has been considerably reduced, the total number of Multiplication and ACcumulation (MAC) operations still remains the same. For example, binarized VGG-16 neural network ~\cite{DBLP:journals/corr/SimonyanZ14a} has reduced the network storage by around 5$\times$ but it still requires many computations ( $\sim$15.5 Giga MAC operations) to do inference on one input image ~\cite{liang2018fp}\cite{umuroglu2017finn}\cite{kim2017kernel}. To reduce the number of MAC operations, we leverage the key property of BNN: As the input and kernel weights of BNN are -1/+1, they both exhibit high similarity. Intuitively, the input similarity comes from the spatial continuity of the image to classify, and the kernel similarity comes from the correlation of features represented by different binarized weight kernels \cite{courbariaux2016binarized}. To prove this property of BNN, we studied the similarity of input and kernel across different applications and networks, as shown in Table~\ref{tab:sim}. The kernel similarity is computed based on the re-ordering algorithm described in section ~\ref{reorder}. The average input and kernel similarity ratio is ranging from 78\% $\sim$ 84\% and 59\% $\sim$ 64\% for network models \cite{Binarynet} \cite{DBLP:journals/corr/LinCY13}. However, if the weights of BNN are binarized but the activations are finely quantized (Table~\ref{tab:sim}), which is a favorable setting in many current works~\cite{DBLP:journals/corr/CourbariauxBD15}, the kernel similarity is much higher than the input similarity. In other words, we see that the degree of these similarities highly depends on the dataset and network architectures. Based on these observations, we propose an architecture of BNN accelerator that leverages input and kernel similarities to reduce the number of MAC operations at inference time. Instead of directly computing the XNOR between the input activation and kernel weights, we first check the input or kernel weight difference between the current and previous computation stage, which focuses on different image regions or different weight kernels, and then reuse the results from the previous computation. Thus, the data buffer access or MAC operations can be bypassed if there is no difference from the previous stage. Our analysis shows that 80\% of the computation and 40\% of the buffer access on average can be skipped in this way. As a result, our design can reduce the total power consumption by around 17\% and on-chip power consumption by 54 \% in comparison to the one without using our reuse method. Our design is also 1.9$\times$ more area-efficient compared to the state-of-the-art BNN accelerator. In addition, we observed that similarites can vary for different applications. Therefore, we provide analysis and insights to pick the better one from our proposed two reuse strategies for different datasets and network models. \begin{table*}[t] \caption{Input and kernel similarity ratio across different networks and datasets. A=(8,4) means 8-bit fixed point activation input including 4-bit fractional part. LeNet-5 and NIN are trained on XNOR-Net \cite{xnornet}.} \label{tab:sim} \begin{tabular}{cccccc} \toprule Dataset & Network & Min Input Sim (\%) & Avg Input Sim (\%) & Max Input Sim(\%) & Kernel Sim (\%) \\ \midrule MNIST & LeNet-5 & 66.6 & \textbf{79.3} & 88.6 & 59.8\\ \hline MNIST & LeNet-5, A=(8,4) & 10.6 & 37.5 & 67.0 & \textbf{59.8}\\ \hline Cifar-10 & BinaryNet & 59.6 & \textbf{78.6} & 95.6 & 58.8\\ \hline Cifar-10 & BinaryNet, A=(8,4)& 1.8 & 17.3 & 72.2 & \textbf{58.8}\\ \hline Cifar-10 & NIN & 51.3 & \textbf{83.9} & 97.2 & 64.5\\ \hline Cifar-10 & NIN, A=(8,4) & 2.7 & 23.5 & 66.7 & \textbf{64.5}\\ \bottomrule \end{tabular} \end{table*} To sum up, we make the following contributions: \squishlist \item We analyze the input and kernel similarity in BNN across different applications. We also show that the degree of similarity depends on datasets and network architectures and we generate insights to select the best strategy. \item To the best of our knowledge, we are the first to exploit input and kernel similarity to reduce computation redundancy to accelerate BNN inference. We propose two types of novel, scalable, and energy-efficient BNN accelerator design to leverage different types of similarity. Our comparison between these two accelerators provide guidelines to pick the best one or even combine them together. \item Our implementation indicates that by exploiting similarities in BNN, we can push the efficiency and speed of its inference to a higher level. \squishend The code of this work will be made public online. The rest of this paper is organized as follows: Section 2 gives an introduction of CNN and BNN inference; Section 3 describes our motivation to exploit input and kernel similarity and presents our method; Section 4 provides the hardware architecture of the accelerator; Section 5 reports our experiments and findings; Section 6 reviews previous work on traditional accelerator design; finally, we discuss potential future work in Section 7 and conclude the paper in Section 8. \section{Background} \subsection{Convolutional Neural Networks} Convolutional Neural Networks (CNNs) are commonly used for image processing, object recognition and video classification ~\cite{DBLP:journals/corr/SimonyanZ14a}. A convolutional layer implements a set of kernels to detect features in the input image. A kernel is defined by a set of weights $W$ and a bias term $B$. Each convolutional layer applies multiple kernels on the input where each kernel scans through the input in a sliding way, resulting in multiple output feature maps (\textit{ofmap}). Note that, unlike what happens in Fully-Connected (FC) layers, the weights of a kernel are shared across different locations on the input. Formally, suppose the input vector is $X$ and weight vector of a kernel is $W$, then the \textit{ofmap} $O$ of this convolution operation is the dot product between them, added by the bias $B$, and followed by a non-linear activation function $g(\cdot)$ as shown in Equation ~\ref{eq:1}: \begin{equation}\label{eq:1} O = g(W \cdot X + B) \end{equation} In CNNs, a pooling layer is usually added after a convolutional layer. FC layers are often appended after several stacked convolutional blocks. During training, the ground-truth output serves as a supervision signal to learn parameters $W$ and $B$ by minimizing a loss function. After a CNN has been trained, the network inference is applied to the test image. Previous work ~\cite{7827589} shows that the computation of the CNN inference is dominated by the convolution operation, which is our main focus in this work. Thanks to the idea of weight sharing, lots of computation are actually not necessary because convolution is naturally a sliding-based operation. The goal of this paper is to reduce the computation cost of convolutions by exploiting what we have already computed so that we can reuse them instead of computing repeatedly. \subsection{Binarized Neural Networks} Recent studies identify that there is no need to employ full-precision weights and activations since CNN is highly fault-tolerant ~\cite{8416871}; we can preserve the accuracy of a neural network using quantized fixed-point values, which is called quantized neural network (QNN) \cite{DBLP:journals/corr/HubaraCSEB16}. An extreme case of QNN is Binarized Neural Network (BNN) ~\cite{xnornet}, which adopts weights and activations with only two possible values (e.g., -1 and +1). The most widely used binarization strategy is called deterministic binarization, as illustrated in Equation ~\ref{eq:2}. This strategy is preferred because it is suitable for hardware accelerations. \begin{equation}\label{eq:2} x_{b} = \text{Sign}(x) \end{equation} Here, $x$ can be any weight or activation input and $x_{b}$ is its binarized version. It has been shown that input activation binarization causes much more degradation to the accuracy of BNN classification compared with weight binarization \cite{courbariaux2016binarized, zhou2016dorefa, zhu2018binary}. Thus we consider two BNN configurations: (i) Both input and weights are binarized. (ii) Input is quantized to fixed-point values and weights are binarized. These two configurations also affect our design choice and will be described in Sec 3.2. As for implementation of this paper, we mainly focus on accelerating a BNN model developed by Courbariaux et al. in \cite{Binarynet}. However, our proposed scheme can be employed on any BNN, which has convolution operations during inference phase. Throughout the rest of this paper, we represent the input activation vector $X$ of the BNN as $\text{IA}(h,w,c)$, corresponding to the horizontal index, vertical index, and channel index. We further denote the weight vector $W$ by $W(r,s,c,k)$, corresponding to horizontal index, vertical index, channel index and kernel index. \section{Design Principles} In this section, we first introduce the objective of our method with a key observation on BNN's property (Sec 3.1), which drives our proposed reuse principle (Sec 3.2). Moreover, we solve an offline optimization problem to further improve the gain (Sec 3.3). \subsection{Motivation} To realize a design that can efficiently accelerate BNN inference, typically people tend to optimize an objective called \textit{throughput} which can be described by \textit{frame per second} (FPS) as Equation ~\ref{eqfps}: \begin{equation}\label{eqfps} \text{FPS} = \frac{ \# \text{Multipliers} \times \text{Utilization}}{ \# \text{Ops\_per\_image}} \end{equation} where \textit{Utilization} indicates the ratio of time for multipliers doing inference over the total runtime. To increase the FPS, previous BNN works seek to increase the number of multipliers by reducing the control overhead. Other works exploit a highly parallelized computation architecture that can increase the \textit{Utilization}. But another orthogonal direction for increasing the FPS is by reducing the number of $Ops\_per\_image$, which has not been fully exploited in current works. In this paper, we notice that a large amount of computation redundancy exists in BNN inference. Thus, our approach aims to reduce the number of $Ops\_per\_image$ -- that is to utilize the input or kernel similarities which will be discussed in section ~\ref{reusestrategy}. Our work also has the advantage of reducing on-chip power consumption. Specifically, the data buffer access and computation power can be saved as a result of the reduced number of \textit{Ops\_per\_image}. \subsection{Similarity Inspired Reuse Strategy} \label{reusestrategy} Recall that our objective is to reduce the number of \textit{Ops\_per\_image} to maximize the throughput. Unlike floating-point values in CNNs, BNN has binarized weight and input after the model is trained. Thus, BNN has only two values (-1/+1), which means we have 50\% chance of having the same value if we pick random two numbers in weight or input. In what follows, we introduce two types of similarity and show our statistical results. \noindent\textbf{Input similarity: } Input similarity naturally exists in various datasets when we use BNN to classify images. Most natural images have spatial continuity and adjacent pixels are similar. In consequence, the binarized \textit{ofmaps} are also very likely to be spatially similar. \noindent\textbf{Kernel similarity: } kernel similarity comes from the affinity of features represented by different binarized weight kernels. It has been shown in literature that weight kernels of BNN are highly similar (only 42$\%$ are unique on Cifar-10 in \cite{courbariaux2016binarized}). The kernel similarity can be further optimized by using the algorithm introduced in Section \ref{reorder} which can be computed off-line. Based on these properties, we did an experiment on multiple BNN models to evaluate the input and kernel similarities which are defined as Equation ~\ref{eqia} and ~\ref{eqw}. \begin{equation}\label{eqia} \text{IA}(h,w,c) = \text{IA}(h,w-1,c), 0 < w \leq W_m \end{equation} \begin{equation}\label{eqw} W(r,s,c,k) = W(r,s,c,k-1), 0 < k \leq K \end{equation} The input or weight \textit{similarity ratio} is defined as the input or weight values that are subjected to Equation \ref{eqia} and Equation \ref{eqw} over the size of total input and weight values. The results are illustrated in Table ~\ref{tab:sim}. The reported kernel similarity is optimized by using the algorithm as described in section ~\ref{reorder}. As we can see in Table ~\ref{tab:sim}, the BNN has different average similarity ratio in both weight and input across different models. For BinaryNet \cite{Binarynet}, the average input and kernel similarity are $\sim$78\% and $\sim$58\% respectively, which indicates a high computational redundancy in BNN inference and so does NIN on XNOR-Net \cite{xnornet}. For BNN trained by XNOR-Net on MNIST, the average similarity ratio on input and weights are $\sim$79.3\% and $\sim$59.8\% respectively. We also observe that many of the BNN models are implemented with fixed-point input activations to maintain high classification accuracy \cite{zhou2016dorefa}. For BNN with fixed-point input and binarized weight, the input similarity is much lower than kernel similarity as shown in Table ~\ref{tab:sim}. Therefore, which one is better varies case by case. The comparison and determination can be done off-line after the network and dataset are obtained. Depends on the insights generated by our experiment results, we develop two types of neural networks acceleration strategies which exploits either weight or input similarity to reduce redundant computations. We now introduce two computation reuse strategies to leverage these two types of similarity respectively. \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/fig_method_4.pdf} \caption{Method of exploiting input and kernel similarity. (1) shows the computation without using the reuse strategy. (2) illustrates the computation with reuse strategy. The computation of STAGE II reuse the computation result from STAGE I by exploiting (a) input similarity (b) kernel similarity} \label{fig:Method} \vspace{-0.1in} \end{figure} In Figure ~\ref{fig:Method}, we use a simple example to illustrate the idea of computation reuse. CNN inference involves multiple dot products between input and kernels and they are computed in a sequential manner. The two stages shown in Figure ~\ref{fig:Method} represent two consecutive dot products during convolution. As shown in Figure ~\ref{fig:Method} (1), the traditional way of computing dot product between the input pixels and different $1\times1$ weight kernels is by doing bitwise XNOR and then popcounts the resulted vector for accumulation for both \textit{STAGE I} and \textit{STAGE II}. With the computation reuse strategy (Figure ~\ref{fig:Method} (2)), we still compute the result in the traditional fashion in \textit{STAGE I}. In \textit{STAGE II}, instead of computing the dot product again in the traditional way, we can save computations by updating the result from \textit{STAGE I}. This method can be applied to leverage either input or kernel similarity. Note that here we use $1\times1$ kernel for intuitive illustration, but our reuse strategy can be easily extended to larger weight kernels using parallelism, such as $3\times3$ kernels used in our experiments (Section ~\ref{eva}). The details of the two methods are further analyzed below. \vspace{3pt} \noindent\textbf{Input Reuse:} For input reuse, assume the computation of \textit{STAGE I} is finished in Figure ~\ref{fig:Method}(2). For the next dot product computation in \textit{STAGE II}, we can first check the difference between the current input (\textit{STAGE II}) and the previous one (\textit{STAGE I}). Then, we can update the previous result from \textit{STAGE I} based on this difference. In this way, the number of required bitwise operations can be greatly reduced compared to the traditional way of computation if the inputs exhibit high similarity. The computation of similarity needs to be done only once, compared with directly computing dot product repeatedly. Besides, only a small subset of weight (colored ones shown in \textit{STAGE II} of Figure ~\ref{fig:Method}(2)) needs to be read out from on-chip memory. \vspace{3pt} \noindent\textbf{Weight Reuse:} Different weight values at the same position of different kernels, i.e., weights at $(r,s,c,k_i)$ and $(r,s,c,k_j)$ ($k_i$ and $k_j$ denote the indices of two different kernels), exhibits high similarity. This similarity across different weight kernels can also be exploited in the similar way as the input reuse strategy. For the weight reuse strategy, the process of reuse shares the same principle with the input reuse. As shown in Figure ~\ref{fig:Method} (b), instead of computing the difference between input activations, we first check the difference between kernels and then update the previous dot product result accordingly. Moreover, we find that the original computation order of the dot product between input and kernels can be further optimized off-line to achieve high degree of kernel similarity ratio, which will be discussed below. \subsection{Improve Weight Reuse by Optimization} \label{reorder} \begin{figure}[bth] \centering \includegraphics[width=0.4\textwidth]{Graph_opt} \caption{Graph optimization illustration to optimize convolution order of kernels.} \label{fig:graph_opt} \vspace{-0.1in} \end{figure} \begin{algorithm} \textbf{Given}: A set of convolution kernels $V$ within a layer, and $K$ partitions required\\ \textbf{Output}: $K$ sets of optimized order of kernels where each set has size $|V|/K$\\ Construct a graph $G(V,E,W)$ where $w(v_{i},v_{j})=\#\text{Params}^{\text{Diff}}_{i,j} / \#\text{Params}_{i,j}$ (dissimilarity)\; Partition $G$ into $K$ subgraphs by maximizing $\sum_{e_{ij} \in \text{inter-subgraph-links}} w(v_{i},v_{j})$, each denoted as $G_{k}, k=1, ..., K$\; \For{each $G_{k}$}{ Find the shortest Hamiltonian Path $H_{k}$ in $G_{k}$\; } \textbf{Return: }$K$ sets of optimized kernel order as $\left \{H_{k}, k=1, 2, ..., K \right \}$\; \caption{Weight Reuse Optimization} \end{algorithm} Although regular weight reuse can accelerate BNN inference reasonably, we find that it is possible to optimize the weight reuse by re-ordering the convolution on kernels in each layer. In other words, the default computation order of kernels may not be good enough. Here we develop an algorithm to find a better order of convolutions using graph optimization. As shown in Fig. \ref{fig:graph_opt}, we build a graph $G(V, E, W)$ where each vertex $v \in V$ corresponds to one kernel. Two vertices are connected by link $e \in E$ with weight $w \in W$ where $w$ represents degree of dissimilarity between two kernels. To find the optimal order of convolutions, we need to search for the scheduling where the total dissimilarity is minimized, i.e., total similarity is maximized. \subsubsection{Graph Partitioning. } We first partition the graph into several subgraphs. The reason is that our proposed architecture has limitations on the number of kernels for reverting in each computation unit (i.e., Set 1 and 2 in Fig. \ref{fig:graph_opt}). Suppose there we partitioned all the kernels into $K$ subset, then each computation unit will work on $|V|/K$ kernels. To partition the original graph into $K$ subgraphs, we maximize the summed weight of links in between subgraphs. In other words, we maximize the dissimilarity in between group of kernels so that similarity is maximized within each group. \subsubsection{Sub-Graph Optimization. } For each subgraph containing $|V|/K$ vertices, we compute the shortest Hamiltonian path thus the accumulated dissimilarity is minimized along the path. Here we use a greedy approach to solve Hamiltonian path problem in an efficient way because the graph can be very large if there exists a lot of kernels within a layer (e.g., 1024), although non-greedy approach may be viable when the graph size is small, since this is optimized offline after BNN has been trained. The complete algorithm is shown in Algorithm 1. After the above optimization, we can get the optimized order of convolution in terms of kernel indices for each computation unit. Then we will send this indexing map to the hardware in order to process it. In this design, in order to alleviate the hardware complexity and the overhead of the \textit{ofmaps} reverting process, we put a limitation on $|V|/K$ to be 64. More complicated design to optimize partitions may be considered in future work. \section{Hardware Architecture} In this section, we introduce a hardware architecture that exploits the BNN similarity to save computations and memory accesses. Recall that we have two types of reuse strategies discussed in the above section and so we present two types of accelerators that leverage input and kernel similarity, respectively. \subsection{Input Reuse Accelerator} \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/fig_diagram.pdf} \caption{Block diagram of (a) input reuse accelerator and (b) weight reuse accelerator} \label{fig:block} \vspace{-0.1in} \end{figure} The block diagram of the architecture that exploits the input similarity accelerator is shown in Figure \ref{fig:block} (a). For the input reuse accelerator, the execution has mainly three stages -- data loading, computation, and accumulation. For the data loading stage, the input and weight data will be read from off-chip memory and be stored into the data buffer and weight memory banks (WBank). During the execution of a binarized convolution layer, the input data will be read from one data buffer and written to another equally size buffer. The read or write mode of data buffer A and B (Figure ~\ref{fig:block}) will be switched for the computation of different layers so the input of each layer does not need to transfer back and forth between on-chip and off-chip memory. During the computation stage, the entire system works in a producer and consumer fashion. The producer is the checking Engine (Chk) which is implemented as a bitwise C-by-C subtraction logic for checking the current input versus the previous one. For the computation of the first input during computation stage, which is corresponding to the \textit{STAGE I} discussed in Section ~\ref{reusestrategy}, Chk will broadcast the original input value and the Processing Elements (PE) will compute the result in the traditional way by using XNOR and popcount. For the rest of the input, we will use the reuse method for the computation, which is consistent with \textit{STAGE II} mentioned in Section ~\ref{reusestrategy}. During the reuse computation, Chk subtracts the current input with the previous one to check the difference. Once the checking is failed, the Chk will broadcast the subtraction result to all the PEs through a broadcasting bus. PE will read the weight out of the Wbank and scan the bus to find the different elements and update the reuse buffer which contains the result of last execution. The different input values will be executed by $n$ different PEs simultaneously. Each PE is assigned with a reuse buffer, a Wbank, and an Output Activation bank (OAbank). The storage of weight is partitioned in kernel or $k$ dimensions, so that the \textit{ofmaps} result will not interleave across different OAbanks. Once the current pixel has finished broadcasting, the accumulation stage will begin. The address generator and accumulator will collect the results in the reuse buffer and accumulate them into the corresponding position of OAbank. \subsubsection{Address Generator and Accumulator} The address generator calculates the destination address for different intermediate result in the reuse buffer. The OAbank accumulation controller will collect the result in reuse buffer and reduce them into the correct positions in OAbank which indicates by the address generator. The address of the \textit{ofmap} $(h_o,w_o,c_o)$ (subscript $o$ denotes output) of the given input locating at $(h,w,c)$ and weight locating at $(r,s,c,k)$ can be calculated as $(h-r,w-s,k)$ or $(h-r+1,w-s+1,k)$ if padding mode is enabled. \subsubsection{Batch Normalization Engine} Once the computation of the current layer is finished, the batch normalization engine will concatenate the \textit{ofmaps} results from different OAbanks and normalize the output by subtracting the normalization factor before binarizing the value into -1/+1. Our strategy of doing batch normalization and pooling is similar to previous BNN acceleration work like \cite{umuroglu2017finn}\cite{zhao2017accelerating}. Batch-normalization and activation functions are done together by comparing to the normalization factors across different \textit{ofmaps} computed offline and then the pooling is done by using lightweight boolean AND operator. The entire batch normalization engine in our design for input similarity accelerator consumes 1541LUT and 432FF for a PE size of 8. \subsection{Weight Reuse Accelerator} For the weight reuse accelerator, the architecture is very similar to the input reuse accelerator. First, as is shown in Figure \ref{fig:block} (b), different lines of the input activation (IA) will be evenly distributed across PEs instead of different weight kernels for input reuse accelerators. But still, two equally-sized buffers will be assigned to each PE. The IA data will be read from and written into two separate buffers as the input reuse accelerator. Second, instead of broadcasting the input difference to PE like the input reuse accelerators, weight reuse accelerator broadcasts the difference between the weight kernels to PE. We first pre-process the weights off-line by using the algorithm introduced in Section \ref{reorder} to reorder the weight kernels with different $k$ dimensions to produce similarity. The hardware allows the weight kernel to be executed out-of-order in a given re-ordering range as we will revert the sequence of the \textit{ofmaps} on-chip. Larger reordering range can achieve even higher degrees of similarity among weight kernels but also introduces higher \textit{ofmap} reverting overhead. The sequence information of the permuted weight kernels needs to be loaded on-chip for reverting the \textit{ofmaps}. But overall, assuming the reordering range is 64, the sequence information overhead is 10K bits which is less than 0.2\% of the size of the weight kernels and thus can be ignored. We also replace the representation of -1/+1 in weight kernel with "same" (0) and "different" (1), except for the first dot product computation. In this way, the on-chip checking process can bypass the subtraction logic. Once the computation begins, the weights will be loaded into the weight buffer and the input activation will be distributed to the IA buffers on-chip. The checking engine does not need to do subtraction as the weights have been pre-processed off-line in the representation of in "different" (1) versus "same" (0). The first weight kernel to be computed will still use the original value with XNOR and popcount for accumulation. It will also be stored in the checking engine as a \textit{weight base} which will be continuously updated during the checking process. The goal of the \textit{weight base} is to keep the latest version of the real weight value to recover the weight difference during the computation. For the rest of the computations, we begin to use the weight reuse strategy for computation. The Chk will scan the weight value to check the similarity. Once the similarity check fails in the computation, the Chk will generate the weight difference based on the \textit{weight base} vector and broadcast the weight difference to all the PEs where different lines of the input activation are stored. In the meanwhile, the Chk will update the \textit{weight base} which is the real weight data used for the following computation. The address generator is still used for the calculation of a uniform address for PE reduction once a weight kernel finishes broadcasting. As the input is not duplicated in different IA buffer, some results in OAbank are partial sums which need to be further reduced in the last stage before the batch normalization and pooling. The final batch normalization engine will finish the last reduction before the batch normalization and \textit{ofmap} reverting process. The final result will be stored back into the data buffer once the execution is finished. Overall, the design of weight reuse acceleration is a symmetric version of input reuse accelerator where we exploit kernel similarity across different. The differences between input reuse and weight reuse accelerator are mainly in the reduction and reverting logic. More complicated design can achieve better parallelization which is left for future work. \section{Evaluation} \label{eva} In this section, we evaluate our proposed reuse strategies on a real FPGA board. The following results show increased performance by using our method compared with benchmark BNN model in terms of speed and energy efficiency. \subsection{Prototype Implementation} To evaluate our design, we implement two types of BNN inference accelerators which exploits input and weight reuse strategies respectively for convolutional layers (conv). The process of decision-making between input or weight reuse strategy depends on the performance of the two types of accelerators on a given model. We test the design on the BinaryNet -- an inference model for CIFAR-10 \cite{Krizhevsky09} ($32 \times 32 $ color images) classification. The pre-trained BinaryNet \cite{Binarynet} neural network is from the open-source code of \cite{zhao2017accelerating}. The summary of the workload is listed in Table ~\ref{tab:workload}. The BinaryNet for CIFAR-10 model can achieve $11.19\%$ testing error. Our design can also be used to accelerate BNN models other than BinaryNet with arbitrary weight kernel size. The prototype is implemented by using high-level synthesize tool Xilinx SDx 2018.1. The accelerated functions are written in high-level programming language. The SDx synthesize tool can automatically generate essential AXI bus for memory communication between off-chip memory and FPGA. The SDx tool also synthesizes the marked function into RTL and bitstream. During the inference, the CPU will awake the FPGA acceleration once the hardware function is called. Our design is implemented on the Xilinx Zynq ZCU104 board containing an ARM Cortex-A53 processor with a target clock frequency of 200MHz. As our design is scalable in the number of PEs, we configure the design with 8 PEs in the following experiments. \begin{table} \caption{Summary of the workload} \label{tab:workload} \begin{tabular}{ccccc} \toprule layer & \thead{input dim \\$(h,w)$} & \thead{weight dim \\$(r,s,c,k)$} & \thead{weight size \\(Bits)} & \thead{graph partition parameters\\ $(V,K)$} \\ \midrule conv1 & 32,32& 3,3,128,128& 144K & 64,2 \\ pool & 32,32 & - & -& - \\ conv2 & 16,16&3,3,128,256& 288K& 64,4 \\ conv3 & 16,16&3,3,256,256& 576K& 64,4 \\ pool & 16,16&-& -& - \\ conv4 & 8,8&3,3,256,512& 1.1M& 64,8 \\ conv5 & 8,8&3,3,512,512& 2.3M& 64,8 \\ pool & 8,8& - & -& - \\ \bottomrule \end{tabular} \end{table} \subsection{Performance Analysis} \label{perf} \subsubsection{Sensitivity to input similarity} \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/fig_trend.pdf} \caption{Performance of the accelerators as a function of the input and kernel similarity. The vertical dash line in the graph indicates the average input image similarity among the testing dataset. The baseline is the runtime of input reuse accelerator without using the reuse technique.} \label{fig:fig_result_1} \vspace{-0.3in} \end{figure} To show how we choose between the input and the weight reuse accelerator, we study the influence of input similarity ratio on the performance of the two designs. Figure \ref{fig:fig_result_1} shows the speedup of accelerators as a function of the input similarity ratio defined in Section \ref{reorder}. The input reuse accelerator provides a variable speedup which depends on the similarity ratio of the input application. However, the weight reuse accelerator can provide a stable speedup which is based on the similarity ratio between weight kernels after re-ordering. As is shown by the vertical dash line in Figure \ref{fig:fig_result_1}, the speedup at the point of average input similarities of the input applications which is corresponding to the third row of Table ~\ref{tab:sim}, input reuse strategy can provide a better performance compared to weight reuse. Thus, we can conclude that for CIFAR-10 model, input reuse accelerator can provide a better performance and should be used for this BNN architecture. For BNN models with fixed-point input activations, as is shown in the \ref{tab:sim} where the input is fixed-point value, the similarity ratio for input is low and the decision-making process may prefer weight reuse strategy in such case. The analysis for BNN models which prefer weight reuse is left for future work. We also compare the performance of the input accelerator for different types of applications, "rand" indicates the input image is random (-1/+1) series, while "img" is the average performance of the testing images from CIFAR-10 testing dataset, "max" is tested when all the pixels of the input image is in the same color, i.e., all the pixels in the classified input image are the same, "w/o computation" indicates the runtime restricted by off-chip data transfer and CPU control overhead. Figure \ref{fig:fig_chart1} shows the effect of these input applications versus speedup. For conv4 and conv5, the speedup of exploiting the input similarity is small and this is due to that the input activation size is small and weight size is large. We expect to see the bottleneck in these layers is in the off-chip memory bandwidth. In terms of the speedup by weight reuse, we notice that the similarity ratio of kernel similarity cannot bring too much gain in the speedup. The detail of the speedup of weight re-ordering algorithm is shown in Figure ~\ref{fig:weight}. "wt orig" indicates the performance of original weight order and 'wt re-order' represents the performance of the acceleration applied with off-line reordered algorithm. By utilizing the re-ordering strategy, the inference can achieve 1.26 $\times$ speedup on average. \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/input.pdf} \caption{Speedup of the input similarity accelerator across different layers for different types of applications} \label{fig:fig_chart1} \vspace{-0.1in} \end{figure} To show the reduction in weight buffer access and the total number of operations by exploiting the BNN reuse technique, we study the reduction of weight buffer access and bitwise operations as is shown in Figure \ref{fig:fig_w}. The baseline is the weight buffer access and bit operations without using the input reuse technique. As the size of weights on-chip dominates the input activation size, we consider only the weight bank access in this experiment to approximate the total data buffer access in this analysis. We observe that on average, the input reuse technique saves weight bank access by $40\%$ and bitwise operations by 80\% for the testing images, which can lead to reduction in on-chip power consumption. The accelerator will bypass almost all the weight bank access and bitwise operations if the input application exhibits maximal similarity. We can conclude that there is a high proportion of on-chip computation redundancy in BNN inference. And this property can be leveraged to reduce the on-chip power consumption and further accelerate the inference of BNN. \begin{table*} \caption{Resource utilization and comparison to prior work.} \label{tab:comparison} \begin{tabular}{cccccc} \toprule & FPGA'16~\cite{Qiu} & FPGA'16~\cite{Suda} & FPGA'17\cite{zhao2017accelerating}& Our Design PE8 & Our Design PE16\\ \hline \midrule board & \thead{Zynq \\ XC7Z045} & \thead{Stratix-V \\GSD8} & \thead{Zynq \\ XC7Z020}& \thead{Zynq \\ XCZU7EV} & \thead{Zynq \\ XCZU7EV} \\ \hline clock(MHz) & 150 & 120 & 147& 200 & 200\\ \hline precision (bit) & 8-16 & 16 & 1-2& 1-2& 1-2\\ \hline kLUTs & 183 & 120* & 46.9& 45 & 72\\ \hline FF & 128K & no report & 46K & 13K & 19K \\ \hline DSPs & 780 & 760* & 3 & 5 & 1 \\ \hline BRAM & 486 & 1377 & 94 & 112 & 1 \\ \hline GOPS (conv) & 187.8 & 136.5 & 318.9 & \thead{ Rand 306.6 \\ Img 411.4 \\ Max 539.9 } & \thead{ Rand 713.3 \\ Img 917.7 \\ Max 975.4 } \\ \hline \textbf{GOPS/kLUT} & \textbf{1.46} & \textbf{1.14} & \textbf{6.79}& \textbf{9.14} & \textbf{12.74}\\ \bottomrule \multicolumn{6}{c}{\footnotesize * refers to the approximation result from previous paper} \end{tabular} \end{table*} \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/wt.pdf} \caption{Speedup of using the weight re-order algorithm. The baseline is the weight reuse architecture without using the reuse technique} \label{fig:weight} \vspace{-0.1in} \end{figure} \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/fig_w_access.pdf} \caption{Percentage of reduced weight bank access across different convolution layers } \label{fig:fig_w} \vspace{-0.1in} \end{figure} \begin{figure}[bth] \centering \includegraphics[width=0.5\textwidth]{figure/fig_pop.pdf} \caption{Percentage of reduced number of popcount across different convolution layers} \label{fig:fig_pop} \vspace{-0.1in} \end{figure} \subsection{Power Analysis} To further analyze the power savings in our accelerator, we study the power consumption which is measured at the socket by using a power monitor. The power consumption of programmable logic is calculated by subtracting the power measured while BNN is running with the power measured at idle stage. The measured results are averaged over a period of time while the accelerator is doing required inference. \begin{table} \caption{Power consumption of the programmable logic} \label{tab:power} \begin{tabular}{|c|c|c|c|c|c|} \hline & w/o reuse &w/o compute & img & max \\ \hline Power (W) & 0.36 & 0.21 & 0.30 & 0.23 \\ \hline \end{tabular} \end{table} Table \ref{tab:power} shows the power consumption of the programmable logic when FPGA is inferencing three different types of applications which are described above in Section ~\ref{perf}. We also added a comparison column which shows the power consumption of data transfer without any on-chip computation. We can conclude that the input reuse strategy on average can reduce the total power consumption by $17\%$ and on-chip power consumption by $54\%$ compared to the baseline accelerator without exploiting the similarity reuse technique. \subsection{Comparison with Prior Work} We also compared our results with the state-of-the-art BNN design as shown in \ref{tab:comparison}. As we focused on light-weight architecture for BNN acceleration, we choose a baseline with similar resource consumption for comparison and both of our architectures are for single-bit input and weight. We also put the result with floating point CNN accelerator ~\cite{Qiu} and ~\cite{Suda} here. Our design is scalable with configurable number of PE. With a large amount of PEs, the on-chip computation will mostly be restricted by the memory bandwidth, the average giga-operations-per-second (GOPS) for testing image becomes closer to the "max" GOPS when we scale the PE size to 16. Our result shows that with PE size of 8 and 16, the design achieves the 9.14 and 12.74GOPS/kLUT, which are 1.34$\times$ and 1.87$\times$ more area-efficient compared to our baseline. The power result is not fair to compare as our FPGA platform of implementation is not the same. \section{Related works} \textbf{Binarized Neural Network: } People have found that it is unnecessary to use floating weights and activations while preserving the accuracy of a neural network. The first approach is to use low-bitwidth fix-point numbers to approximate real values, which is called Quantized Neural Network (QNN) \cite{DBLP:journals/corr/HubaraCSEB16}. However, they cannot fully speed it up because we still need to live with costly operations on multiple bits. Binarized Neural Network (BNN) was originally proposed in \cite{courbariaux2016binarized} and has received a lot of attention in the research community since bit operations are fast and energy efficient compared to floating-point operations. They have shown the advantage of BNNs in terms of speed, memory usage and power consumption compared with traditional floating number CNN. Many recent works have been proposed to cure BNN's optimization problem during training \cite{xnornet, zhou2016dorefa, Binarynet}. Recently people use ensemble strategy to build a strong binarized network to make BNN both accurate and robust \cite{zhu2018binary}. In this work, we mainly focus on further accelerating BNN inference on FPGA, and our method can be applied to any state-of-the-art BNN architectures. \textbf{FPGA acceleration for CNN: } FPGA acceleration of CNNs is gaining increasing attention due to the promising performance and cost efficiency. For instance, Zeng et al.~\cite{Zeng} proposed to employ frequency domain technique to accelerate floating point CNN. Escher et al.~\cite{Escher2018} proposed a design that accelerates CNN by optimizing the on-chip storage through identifying optimal batch size for CNNs. Previous work~\cite{7577308} proposed a layer pipelined structure for accelerating large-scale CNN. Ma et al.~\cite{7577356} proposed a compiler design for a scalable RTL to accelerate CNN. Qiu et al.~\cite{Qiu} adopted singular values decomposition to reduce fully-connected layer bandwidth restriction. A recent study~\cite{7827589} develops a uniform matrix multiplication to accelerate CNNs. Zhang et al.~\cite{Zhang:2015:OFA:2684746.2689060} proposed the roofline model which illustrate the computation and memory bond for CNN acceleration and used the model to find the best configuration acceleration. \textbf{FPGA acceleration for BNN: } Several recent studies explore FPGA acceleration of BNNs. FINN \cite{umuroglu2017finn} resolved the memory bond issue by storing all the parameters on-chip. Nakahara et al.~\cite{Nakahara} presented a modified BNN version of YOLOv2 to perform real-time localization and classification. ~\cite{Liang:2018:FPB:3198485.3198711} proposed a Resource-Aware Model for optimizing on-chip resource by quantized some part of the input activation. Kim et al.~\cite{kim2017kernel} proposed a kernel decomposition method for BNNs to reduce computation by half. Li et al.~\cite{Li:2017:EFA} developed an FPGA-based BNN accelerator by leveraging the look-up table (LUT) resources on FPGAs. In order to efficiently implement the normalization and binarization in BNNs with FPGA's LUTs, the design merges the two into a single comparison operation. The study also performs a design space exploration in order to model throughput to improve acceleration performance. Although the design optimizes computation resource utilization by LUT-based computation, the performance is still susceptible to data access bottlenecks~\cite{Zhang:2015:OFA:2684746.2689060}. \textbf{ASIC acceleration for BNN: } XNORBIN~\cite{DBLP:journals/corr/abs-1803-05849} and Conti et al.~\cite{8412533} implemented Application-specific integrated circuit (ASIC) based BNN accelerators. Their designs adopted loop unrolling and data reuse to exploit the inherent parallelism of BNNs. However, the design simply maps BNN algorithms onto hardware. As a result, their performance improved over traditional neural network accelerations implementations is due to the efficiency of native BNN algorithms. YodaNN ~\cite{7560203} and BRein Memory ~\cite{8226999} are proposed ASIC accelerators for accelerating BNN inference. \textbf{Computation reuse for CNN: } Computation reuse strategies have been proposed for DNN. Marc et al. ~\cite{Marc2018} exploits input similarity between frames to reduce the computation of fixed point DNN inference. The reuse strategy quantizes the input first before checking the value with previous input. Thus, the method will sacrifice a little bit of classification precision. UCNN ~\cite{hegde2018ucnn} quantizes the weight by using TTQ (or INQ) strategy, so only 3 (or 17) possible values of weight are available in the network. They sort the weights off-line based on weight values to factorize dot product and reduce computation power consumption. These prior works on BNN and FPGA, ASIC for accelerating CNNs have enlightened the path of developing high-performance and energy-efficient neural network acceleration. To our knowledge, this is the first paper to exploit similarity in kernels and input activations to effectively accelerate BNNs on FPGA. \section{Discussion} \textbf{Comparison between input and weight reuse: } In this paper, we show better performance in speed and energy by using the two types of reuse strategies, i.e., input and weight reuse. From Table ~\ref{tab:sim}, we also notice their differences in different datasets and network models. Generally speaking, the input activation binarization is causing much more harm to performance over weight binarization in BNN, and many high-performance BNNs still prefer using floating or quantized input \cite{zhou2016dorefa}. In such case, weight reuse seems to be a better strategy since it can guarantee a higher degree of similarity. But for BNN where input activation is binarized as well \cite{xnornet}, input reuse is highly preferred for most image classification tasks. We believe more exploration can be made on smartly switching these two strategies and also studying whether the acceleration variance would cause problems in real-time applications or not. \textbf{Combination of both reuse strategies: } Another important perspective brought by this paper is to study the mixing architecture which combines these two reuse strategies together in order to gain advantages from both. There may be extra overhead to realize this combination since the hardware architecture could be different. One of the promising next step is to design a more complicated architecture on FPGA that can efficiently accelerate inference by maximizing total similarities. \textbf{Improving current inference architecture: } The ideal architecture to reduce computation redundancy should decrease the number of $Ops\_per\_image$ in Equation ~\ref{eqfps} without affecting the \textit{Utilization}. Our proof-of-concept architecture is constrained by the off-chip memory bandwidth under some circumstances. Besides, the control overhead for the reduction must also be considered. This results in a small gap between the performance of our accelerator without using the reuse strategy and the-state-of-the-art design. In our future work, we will exploit the similarity without affecting the utilization of multipliers. It is also possible to combine the input or weight reuse strategy with some previous BNN acceleration techniques ~\cite{umuroglu2017finn}, for example, storing all the weights on-chip for resolving the memory issue. In addition, the design should remain in low control overhead which saves on-chip resource for more computation units. \section{Conclusions} In this paper, we propose a new FPGA-based BNN acceleration scheme, which incorporates both algorithm and hardware architecture design principles. Our design focuses on reducing latency and power consumption of BNNs by exploiting input and kernel similarities. We have shown that BNN inference has the property of high ratio of similarity in both input and kernel weights. The similarity of the input image comes from the spatial continuity between input pixels. Kernel similarity can be enhanced by applying to a proposed reordering algorithm. With different fixed-point representation for BNN input activation, either input or weight exhibits higher similarity ratio which can be exploited to reduce the bit operations and buffer access. By leveraging these two properties of the BNN, we proposed two types of accelerators, which can be applied to different situations. We also summarized the insights generated by comparing these two accelerators to assist strategy selection and combination. Our experiment shows that the power and speed of BNN inference can be largely improved through reducing computation redundancy. We believe this work makes an important step towards deploying neural networks to real-time applications. \vspace{-0.1in} \section*{Acknowledgement} This work is done during the internship at Iluvatar CoreX. We thank Tien-Pei Chen and Po-Wei Chou for the guidance on FPGA HLS problems. We would also like to thank Wei Shu and Pingping Shao for many helpful discussions. \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2018-10-05T02:07:25', 'yymm': '1810', 'arxiv_id': '1810.02068', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02068'}
arxiv
\section{\large \textbf{DICTA Publication License for PID \# 1222850}} \onecolumn{% \centering \LARGE DICTA Publication License for PID \# 1222850\\[1.5em] \large \textbf{Paper Title:} Image and Encoded Text Fusion for Multi-Modal Classification\\[1em] \large \textbf{Author:} I. Gallo, A. Calefati, S. Nawaz, M.K. Janjua\\[1em]} \large \section{License} Copyright 2018 IEEE. Published in the Digital Image Computing: Techniques and Applications, 2018 (DICTA 2018), 10-13 December 2018 in Canberra, Australia. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works, must be obtained from the IEEE. Contact: Manager, Copyrights and Permissions / IEEE Service Center / 445 Hoes Lane / P.O. Box 1331 / Piscataway, NJ 08855-1331, USA. Telephone: + Intl. 908-562-3966 \twocolumn \maketitle \begin{abstract} Multi-modal approaches employ data from multiple input streams such as textual and visual domains. Deep neural networks have been successfully employed for these approaches. In this paper, we present a novel multi-modal approach that fuses images and text descriptions to improve multi-modal classification performance in real-world scenarios. The proposed approach embeds an encoded text onto an image to obtain an information enriched image. To learn feature representations of resulting images, standard Convolutional Neural Networks (CNNs) is employed for classification task. We demonstrate how a CNN based pipeline can be used to learn representations of the novel fusion approach. We compare our approach with individual sources on two large scale multi-modal classification datasets while obtaining encouraging results. Furthermore, we evaluate our approach against two famous multi-modal strategies namely early fusion and late fusion. \end{abstract} \begin{figure}[ht!] \centering \begin{subfigure}[b]{0.40\linewidth} \centering\includegraphics[width=\textwidth]{helmet4bike} \caption{Useful accessory for those who ride a \textbf{bike}. Size 46-52. \label{subfig:helmet}} \end{subfigure}~~~ \begin{subfigure}[b]{0.40\linewidth} \centering\includegraphics[width=\textwidth]{bike} \caption{The First \textbf{Bike} Pink Arrow dedicated to little girls. \label{subfig:bike}} \end{subfigure}\\ \begin{subfigure}[b]{0.45\linewidth} \centering\includegraphics[width=\textwidth]{telescoping-ladder} \caption{Telescopic \textbf{ladder} to partial or total opening. Ideal for any external intervention.\label{subfig:ladder}} \end{subfigure}~~~% \begin{subfigure}[b]{0.45\linewidth} \centering\includegraphics[width=\textwidth]{scaffolding} \caption{Custom multifunction dynamic construction \textbf{scaffolding}, simple for decoration.\label{subfig:scaffolding}} \end{subfigure} \caption{In the top row, an example of ambiguous text descriptions that can be disambiguated with the analysis of the accompanying images. In the bottom row, an examples of ambiguous images that can be disambiguated with the analysis of the associated text descriptions. } \label{fig:the-problem} \end{figure} \section{Introduction} With the rapid rise of e-commerce, the web has increasingly become multi-modal, making the question of multi-modal strategy ever more important. However, modalities in multi-modal approach come from different input sources (text/image~\cite{gallo2017multimodal,kiela:2014:Learning,kiela2018efficient} , audio/video~\cite{ngiam2011multimodal} etc.) and are often characterized by distinct statistical properties, making it difficult to create a joint representation that uniquely captures the ``concept'' in the real-world applications. For example, Figure~\ref{fig:the-problem} shows two adverts typically available on e-commerce website, where two objects have seemingly similar text descriptions in first row but seemingly different images. On the other hand we have two different text descriptions but similar images in the second row. This leads us to create a joint representation of an image and text description for this classification problem. Multi-modal strategy can exploit such scenario to remove ambiguity and improve classification performance. The use of multi-modal approach based on image and text features is extensively employed on a variety of tasks including modeling semantic relatedness, compositionality, classification and retrieval~\cite{guillaumin2010multimodal,kiela:2014:Learning,leong2011going,feng2010visual,kiela2018efficient,wang2016learning}. Typically, in multi-modal approach, image features are extracted using CNNs. Whereas, to generate text features, Bag-of-Words models or Log-linear Skip-gram Models~\cite{mikolov2013efficient} are commonly employed. This represents a challenge to find relationships between features of multiple modalities along with representation, translation, alignment, and co-learning as stated in~\cite{baltruvsaitis2018multimodal}. With this work, we present a novel strategy which combines a text encoding schema to fuse text features and image in an unified information enriched image. We merge both text encoding and image into a single source so that it can be used with a CNN. We demonstrate that by adding encoded text information in an image, multi-modal classification results can be improved compared to the best one obtained on a uni-modality (image/text). Intuitively superimposing text descriptions onto images may not sound motivating due to several reasons. Since the idea is overlaying the encoded text description onto an image, it might affect the image perception in general. However, this is not true, the main strength of the approach is that embedded text can be overlaid onto the image with fixed width regardless of the size of text description. We experiment with different embedding sizes to verify that image perception is not affected. Figure~\ref{fig:text-vs-multimodal} plots different embedding sizes to explain the network behavior under such scenario. Main contributions of our paper are listed below: \begin{itemize} \item We present a novel data fusion mechanism based on encoded text description and associated image for multi-modal classification. \item We show that fused data is classified with a standard CNN based architectures, typically employed in image classification. \item We evaluate the fused multi-modal approach on two large scale datasets to show the effectiveness of our approach. \end{itemize} \begin{figure*}[t] \centering \includegraphics[width=0.9\textwidth]{proposed_model} \caption{The proposed text and image fusion model for deep multi-modal classification. The text encoded (a) is passed to the output layer. After the training step only the text features (a) are extracted and then drawn over the original image in order to generate a new multimodal dataset. } \label{fig:proposed-model} \end{figure*} \section{Related Work} There are two general multi-modal fusion strategies to fuse text and images features, namely early fusion and late fusion~\cite{atrey2010multimodal,baltruvsaitis2018multimodal}, each one having its advantages and disadvantages. Early fusion is an initial attempt by the researchers towards multi-modal representation learning. Early fusion methods concatenates text and image features into a single vector which is used as input pattern for the final classifier. The technique is employed for various tasks~\cite{Bruni:2011:Distributional,kiela:2014:Learning,kiela2018efficient}. The main benefit of early fusion is that it can learn to exploit the correlation and interactions between low level features of each modality. In contrast, late fusion~\cite{poria2015deep} uses decision values from each modal and fuses them using a fusion mechanism. Multiple works ~\cite{shutova2016black,evangelopoulos2013multimodal} employ different fusion mechanisms such as averaging, voting schemes, variance etc. The work in~\cite{gallo2017multimodal} showcased a comparative study of early and late fusion multi-modal methods. Late fusion produced better performance compared to early fusion method, however, it comes with the price of an increased learning effort. In addition, a strategy must be introduced to assign a weight to each classifier employed. This presents another challenge in late fusion strategy. Our method is inspired from early fusion~\cite{kiela:2014:Learning}, however, taking advantage of the idea of our previous work~\cite{gallo2017semantic} we concatenate encoded text features into an image to obtain an information enriched image. In this work, we encode text features onto an image with an encoding schema similar to the one proposed in~\cite{gallo2017semantic}. The main difference lies in the type of embedding used: our previous work~\cite{gallo2017semantic} used the encoding extracted from Word2Vec and therefore we obtained a numeric vector for each word in a text document, while in this work we extract text features from a CNN network for text classification, trained using all the words available in a description. In the next sections, the encoding technique used to graphically represent the text above the image, will be summarized. Multi-modal fusion methods are successfully employed to other modalities, e.g. video and audio ~\cite{ngiam2011multimodal,nagrani2018seeing}. Other interesting examples of multi-modal approaches that make use of deep networks include restricted Boltzmann machines~\cite{srivastava2012multimodal}, auto-encoders~\cite{wu2013online}. \begin{table} \begin{center} \caption{Network configuration summary. $k$, $s$ and $p$ stand for kernel size, stride and padding size respectively. In the convolution layer, we use 128 filters for each of the following sizes 3,4,5 (the first one is showed below). The embedding size is $w=128$. } \label{tab:network-info} \begin{tabular}{lccccc} \hline\noalign{\smallskip} Type & Configuration \\ \noalign{\smallskip} \hline \noalign{\smallskip} Output & num. classes \\ Fully Connected & $H_t$(encoded-text-h) $\times$ $W_t$(encoded-text-w) $\times 3$ \\ MaxPool-1D & $h$:$S-k+1$, $k$:1, $s$:1, $p$:1 \\ Convolutional-1D & $w$(embedding-size), $k$:$3\times w$, $s$:1, $p$:1 \\ Input & $S$: 100 words (sequence length) \\ \hline \end{tabular} \end{center} \end{table} \section{The Proposed Approach} \label{proposed-approach} In this work we take a cue from our previous work~\cite{gallo2017semantic} to transform a text document onto an image to be classified with a CNN. However, instead of using numeric values from Word2Vec model to represent a text document, we are using a new approach involving a CNN trained for text classification. First, we transform the text document into a visual representation to construct an information enriched image containing text features and image. Finally, we solve the multi-modal problem using this image to train a CNN generally used for image classification. We use a variant of the CNN model proposed by Kim~\cite{kim2014convolutional} for text document classification. The input layer is a text document followed by a convolution layer with multiple filters, then a max-pooling layer followed by a fully connected layer, and finally a softmax classifier. The network configuration summary is show in Table~\ref{tab:network-info}. Text features are extracted from the fully connected layer (Figure~\ref{fig:proposed-model}a) and transformed into an RGB encoding so that it can be overlaid onto an image associated with the text document. Figure~\ref{fig:proposed-model} shows architectural representation of the model used to encode the text dataset into an image dataset (Figure~\ref{fig:proposed-model}b) to obtain a multi-modal dataset. In the second step, resulting images are fed to any baseline CNN for classification. The major advantage of our method is that we can cast a uni-modal into a multi-modal CNN without the need of adapting the model itself. This approach is suitable to be adopted in multi-modal methods because a CNN architecture can extract information from both the encoded text and the related image. \subsection{Encoding Scheme} \label{sec:proposed-encoding-technique} We exploit the CNN model proposed by Kim~\cite{kim2014convolutional} which performs text to visual features transformation within a single step. Figure~\ref{fig:proposed-model} summarizes the encoding system used in this work, where a reshape was applied to the fully connected layer showed in Figure~\ref{fig:proposed-model}a to transform an array into an image representing the encoded text to be superimposed on the original image. Features are extracted from the trained CNN model and transformed into a visual representation of the document. In practice, we used feature vectors showed in Figure~\ref{fig:proposed-model}a, having a size $L=3\cdot w\cdot h$ that is a multiple of 3 in order to be transformed into a color image. We used the same concept of \textit{superpixel} used in~\cite{gallo2017semantic} to represent a sequence of three values $\in L$ as an area with a uniform color of $P\times P$ dimension. In this way textual features are represented as a sequence of superpixel, drawn from left to right and from top to bottom, starting from a certain position of the scaled image (see some examples of the final multi-modal image in Figure~\ref{fig:encoding-examples} and Figure~\ref{fig:very-similar-encoding}). Finally, we encode an entire text document within the image plane and then the next multi-modal CNN model can work simultaneously on both modalities. This approach has an advantage to the work in~\cite{gallo2017semantic}, in fact in our work it is possible to encode long text documents because we encode the entire document in the same image area having fixed size equals to $w\times h\times 3$. \begin{figure*}[t] \centering \begin{tabular}{ll|ll} \multicolumn{2}{c}{UMPC Food-101} & \multicolumn{2}{c}{Ferramenta} \\ \noalign{\smallskip} \hline \noalign{\smallskip} \includegraphics[width=0.215\textwidth]{omelette_54-10x1} & \includegraphics[width=0.215\textwidth]{omelette_54-50x2} & \includegraphics[width=0.215\textwidth]{scaffale-10x1-199503822} & \includegraphics[width=0.215\textwidth]{scaffale-50x5-199503822} \end{tabular} \caption{Two encoding examples taken from two datasets. Images on the left column show an encoding of $10$ superpixel length while on the right column we have an encoding of length equal to $250$ superpixel. All images are $227\times 227$ in size having an encoding superpixel equals to $3\times 3$ pixels for Ferramenta dataset and $4\times 4$ for Food-101 dataset. } \label{fig:encoding-examples} \end{figure*} \section{Datasets} In multi-modal dataset, modalities are obtained from different input sources. Datasets used in this work consist of images and accompanying text descriptions. We select Ferramenta~\cite{gallo2017multimodal} multi-modal dataset that are created from e-commerce website. Furthermore, we select UMPC Food-101~\cite{wang2015recipe} multi-modal dataset to show the applicability of our approach to other domains. Table~\ref{tab:dataset-info} shows information on these datasets. The first column shows the number of class labels available in datasets. While second and third columns show split on train and test sets. The last column indicates the language of text description available for these datasets. Table~\ref{tab:img-text} shows image and associated text description randomly selected from each multi-modal dataset. \begin{table}[t!] \begin{center} \caption{Information on multi-modal datasets used in this work. A multi-modal dataset consists of an image and accompanying text description. The last column indicates the text description language.} \label{tab:dataset-info} \begin{tabular}{lccccc} \hline\noalign{\smallskip} Dataset & \#Cls & Train & Test & Lang. \\ \noalign{\smallskip} \hline \noalign{\smallskip} Ferramenta & 52 & 66,141 & 21,869 & IT \\ Food-101 & 101 & 67,988 & 22,716 & EN \\ \hline \end{tabular} \end{center} \end{table} \begin{table*}[t!] \begin{center} \caption{An image and an associated text description randomly taken from each multi-modal dataset. Text descriptions in Ferramenta multi-modal dataset is translated from Italian to English for readers. UMPC Food-101 multi-modal dataset contains long text descriptions for food recipes however, we include a short text description.} \label{tab:img-text} \begin{tabular}{l m{2.6cm} m{6.0cm}} \noalign{\smallskip} \hline \noalign{\smallskip} Dataset & Image & Text Description \\ \noalign{\smallskip} \hline \noalign{\smallskip} Ferramenta~\cite{gallo2017multimodal} & \includegraphics[width=0.14\textwidth]{190728025} & saratoga chestnut brown spray paint 400 ml happy color, quick-drying bright spray enamel for interiors and exteriors for applications on furniture chairs doors frames ornaments and all surfaces in wood metal ceramic glass plaster and masonite. \\ \\ UPMC Food-101~\cite{wang2015recipe} & \includegraphics[width=0.14\textwidth]{ravioli_319} & Robiola-Cheese-Filled Ravioli Recipe Pasta Recipes ...\\ \\ \hline \end{tabular} \end{center} \end{table*} \begin{table} \begin{center} \caption{Classification results comparison on only-text, only-image and fused images. There are two baseline models for images and fused-images, while we use only one baseline for text-only scores.} \label{tab:main-results} \begin{tabular}{lccccccc} \hline\noalign{\smallskip} Dataset & Text & \multicolumn{2}{c}{Image} & \multicolumn{2}{c}{Fusion} \\ & & AlexNet & GoogleNet & AlexNet & GoogleNet\\ \noalign{\smallskip} \hline \noalign{\smallskip} Ferramenta & 92.09 & 92.36 & 92.47 & 95.15 & 95.45 \\ Food-101 & 79.78 & 42.01 & 55.65 & 82.90 & 83.37 \\ \hline \end{tabular} \end{center} \end{table} Ferramenta multi-modal dataset~\cite{gallo2017semantic} consists of $88,010$ adverts split in $66,141$ adverts for train set and $21,869$ adverts for test set, belonging to $52$ classes. Ferramenta dataset provides a text and representative image for each commercial advertisement. It is interesting to note that text descriptions in this dataset are in Italian Language. The second dataset that we use in our experiments is named UPMC Food-101 multi-modal dataset ~\cite{wang2015recipe}, containing about $100,000$ items of food recipes classified in $101$ classes. This dataset is collected from the web and each item consists of an image and the HTML webpage on which it was found. We have extracted the title from HTML document to use it in lieu of text description. Classes in the dataset are the $101$ most popular categories from the food picture sharing website\footnote{www.foodspotting.com}. \section{Experiments} \subsection{Preprocessing} The proposed multi-modal approach transforms text descriptions and embeds them onto associated images to obtain information enriched images. An example of information enriched image is shown in Figure~\ref{fig:encoding-examples}. In this work, the transformed text description is embedded into a RGB image with an image size of $227\times227$ for UMPC Food-101 and Ferramenta multi-modal datasets. \begin{figure} \centering \includegraphics[width=1.0\columnwidth]{ferramenta-text-image-comparison} \caption{Comparison between the CNN that uses only text documents and only images with the CNN that uses fusion of image and encoded text, as the dimension of the text embedding varies. In this experiment the Ferramenta multi-modal dataset is used. } \label{fig:text-vs-multimodal} \end{figure} \subsection{Detailed CNN settings} We use a standard AlexNet~\cite{krizhevsky2012imagenet} and GoogleNet~\cite{Szegedy_2015_CVPR} on the Deep Learning GPU Training System (DIGITS) with default configuration. For fair comparison, we use same CNN settings for experiments using only images and fused images. We use standard CNN hyperparameters. The initial learning rate is set to 0.01 along with Stochastic Gradient Descent (SGD) as optimizer. The network is trained for a total of $60$ epochs and/or till no further improvement is noticed to avoid over fitting. In our experiments, accuracy is used to measure classification performances. The aim of the experiment is to show that by adding encoded text information in images it is possible to obtain better classification results compared to the best one obtained using a uni-modal (Text/Image). We conducted following experiments with this aim in mind: (1) classification with CNN using only images, (2) classification with CNN using only text descriptions, (3) classification with CNN using fused images, (4) comparison with early and late fusion strategies. \begin{table}[t!] \begin{center} \caption{Comparison of our approach with early and late fusion strategies. The results on the Ferramenta dataset are extracted from paper~\cite{gallo2017multimodal}} \label{tab:early-late-results} \begin{tabular}{lccccccc} \hline\noalign{\smallskip} Dataset & Early F. & Late F. & Proposed \\ \noalign{\smallskip} \hline \noalign{\smallskip} Ferramenta & 89.53 & 94.42 & \textbf{95.15} \\ Food-101 & 60.83 & 34.43 & \textbf{82.90} \\ \hline \end{tabular} \end{center} \end{table} The first experiment consists of extracting only text descriptions from multi-modal datasets, then we train text classification model shown in Figure~\ref{fig:proposed-model}. Results are shown in first column of Table~\ref{tab:main-results}. It is very important to observe how the text encoding extracted is similar to each other when the text description represents similar objects, even when the text information and the images are different from each other (see the example of text encoding in Figure~\ref{fig:very-similar-encoding}). The second experiment consists of extracting only images from multi-modal datasets, then we train AlexNet~\cite{krizhevsky2012imagenet} and GoogleNet~\cite{Szegedy_2015_CVPR} CNNs from scratch using DIGITS. Second and third columns of Table~\ref{tab:main-results} shows these results. Images in Ferramenta multi-modal dataset contain objects on a white background, this explains excellent classification results obtained on images alone. On the contrary, images in the UPMC Food-101 multi-modal dataset are with complex background and extracted from different contexts, which leads to a low classification performance on images only. \begin{figure*} \centering \begin{tabular}{m{4cm}m{2cm}m{4cm}m{2cm}} \hline \multicolumn{2}{c|}{Ferramenta} & \multicolumn{2}{c}{UMPC Food-101} \\ \hline \fbox{\includegraphics[width=0.215\textwidth]{118430197}} & bahco 9070p chiave inglese regolabile ergonomica 15 3 cm 6 pollici a becco reversibile colore nero & \fbox{\includegraphics[width=0.215\textwidth]{cannoli_22}} & Cannoli Recipe - Food.com \\ \fbox{\includegraphics[width=0.215\textwidth]{121917326}} & connex cox550110 chiave inglese regolabile 25 4 cm & \fbox{\includegraphics[width=0.215\textwidth]{cannoli_333}} & homemade cannoli filling The 350 Degree Oven \\ \fbox{\includegraphics[width=0.215\textwidth]{128082739}} & axis 28831 chiave inglese regolabile con impugnatura morbida e rullo estremamente scorrevole 200 mm $\dots$ & \fbox{\includegraphics[width=0.215\textwidth]{cannoli_473}} & Cake Boss Cannoli Cake Ideas and Designs \\ \fbox{\includegraphics[width=0.215\textwidth]{151827007}} & sam outillage 54 c10 chiave a rullino cromata 10 lunghezza 255 mm sam & \fbox{\includegraphics[width=0.215\textwidth]{cannoli_725}} & Scones* Biscotti* Cannoli on Pinterest \\ \fbox{\includegraphics[width=0.215\textwidth]{154756164}} & faithfull chiave regolabile 150 mm & \fbox{\includegraphics[width=0.215\textwidth]{cannoli_878}} & Sicilian Cannoli Recipe The Daily Meal \\ \end{tabular} \caption{ Each column contains $5$ images and associated text descriptions belonging to a particular class of Ferramenta and UPMC Food-101 datasets. Futhermore, each image contains the proposed encoded text. Note that the text encodings on each column are similar to each other even if the text and images are different from each other. } \label{fig:very-similar-encoding} \end{figure*} The third experiment consists of employing fused images from multi-modal datasets. We train AlexNet~\cite{krizhevsky2012imagenet} and GoogleNet~\cite{Szegedy_2015_CVPR} CNNs from scratch using DIGITS. Results in Table~\ref{tab:main-results} indicate that the proposed fusion approach outperforms uni-modal methods. Furthermore, the approach is language independent, Ferramenta text descriptions are in Italian. Results on UPMC Food-101 clearly indicate benefit of our proposed approach, increasing the classification performance by two folds. This performance gain is due to leveraging on multi-modal representation learning. In fourth experiment, we compare our approach with early and late fusion as shown in Table~\ref{tab:early-late-results}. Experimental setting is inspired from the work~\cite{gallo2017multimodal}. In particular we use \textit{Logarithmic Opinion Pool}~\cite{Rokach:2010:Ensemble} as a late fusion approach using Random Forest model applied to the 1000 Bag-of-Words while as early fusion we use a Support Vector Machine on the concatenation of Doc2Vec features and 4096 visual features from a trained CNN. Our proposed approach surpasses standard early and late fusion strategies which further reinforces strength of our approach. The Figure~\ref{fig:text-vs-multimodal} explores text embedding dimension sizes against $3$ different CNN based architectures i.e. text only, image only and fused image. We see that with lower text-embedding dimension, the fused architecture has an increased performance as compared to the text only architecture. Eventually, both architectures plateau as embedding dimension increases. However, the fused image architecture always maintains the upper bound over the other. \section{Conclusion} In this work, we proposed a new approach to merge image with their text description so that any CNN architecture can be employed as a multi-modal classification system. To the best of our knowledge, the proposed approach is the only one that simultaneously exploits text and image casted to a single source, making it possible to use a single classifier. We obtained promising results and the classification accuracy achieved using our approach is always higher compared to fusion strategies or single modalities. Another very important contribution of this work concerns the joint representation into the same source of two heterogeneous modalities. This aspect paves the way to a still open set of problems related to the translation from one modality to another where relationships between modalities are subjective. \bibliographystyle{IEEEtran}
{'timestamp': '2018-10-05T02:04:48', 'yymm': '1810', 'arxiv_id': '1810.02001', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02001'}
arxiv
\section{Introduction} We consider the problem of object detection in unconstrained videos with close to zero supervision for video domain. Object detection in videos is a crucial component in several downstream vision applications such as video anomaly detection, autonomous driving, tracking etc. In this work, we assume that we only have access to a fully annotated dataset of still images (which we refer to as \textit{source domain}) while there is no annotation (not even any form of weak supervision) for video domain (which we refer to as \textit{target domain}). Intuitively, an object detector trained on still images performs worse on video frames primarily due to significant appearance disparities between the two domains. Specifically, still images retain much more high frequency components and are less cluttered/occluded. Conversely, objects in videos often suffer from motion blur and poor resolution. Thus even though we have availability of large-scale annotated image datasets such as ImageNet\cite{deng2009imagenet}, MS-COCO\cite{lin2014microsoft}, PASCAL \cite{everingham2010pascal}, performance of image object detectors on videos are worse compared to training on manually annotated video datasets \cite{gokberk2014multi, song2014learning}. An immediate direction of effort can be to annotate video datasets. However, annotating large scale video datasets demand humongous manual labor, time and cost. \par Though collecting annotated video seems a daunting task, there is abundance of unlabeled natural videos available publicly from sources such as Youtube and Flickr. The aim of this paper is to exploit such unlabeled videos to learn an end-to-end trainable network to transform images sampled from static image dataset to `appear' as if being sampled from a video dataset. Following this, if we train an object detector on such `\textit{transformed image dataset}', we expect to see a boost in the generalization capability of the detector on videos(See Fig. \ref{fig_cover} for exemplary success). Specifically our contributions in this paper can be summarized as: \begin{enumerate} \item We apply the concept of cycle consistent image-to-image translation\cite{zhu2017unpaired} with generative adversarial networks(GAN) \cite{goodfellow2014generative} for learning a completely unsupervised transformation from image to video in pixel domain. To our best knowledge, this work is the first demonstration of the applicability of GAN based pixel level domain adaptation for adapting object detectors across image to video. \item We empirically show the importance of cyclic network architecture for training an unsupervised GAN based image translation framework. \item Evaluations on recently released Youtube-Objects \cite{kalogeiton2016analysing} and Youtube-Objects-Subset \cite{tang2013discriminative} datasets reveal that our approach of domain adaptation improves upon two contemporary baseline state-of-the-art image object detectors. Also, we get competitive performance compared to recent weakly supervised methods. \end{enumerate} \begin{figure*}[!t] \centering \includegraphics[scale=0.3]{effect_now1.jpg} \caption{Effect of applying learnt transformations on high quality static VOC images to appear as if being sampled from a video sequence. Note (left) how the legs of the bird get almost blended with nearby surroundings after transformation. Also, we show a case(right) where discriminative fur colors of a cat get desaturated and details such as eyes, whiskers and ears becomes indistinguishable. Training object detectors on such adversarially perturbed images helps in improving test performance on actual video frames. Best appreciated when viewed in color and zoomed up.}% \label{fig_effect \end{figure*} \section{Related Works} \subsection{Object Detection} Object detection in still images is one of the traditional genres of computer vision research \cite{dalal2005histograms, felzenszwalb2010object,girshick2014rich, malisiewicz2011ensemble}. These methods require bounding box annotations on a large sample of diversified images. Although annotating boxes for large datasets is tedious it is necessary especially for deep learning frameworks in which the complexity of the neural net makes it vulnerable to overfitting if not trained with sufficiently large labeled datasets. To circumnavigate this requirement there are two genres of approach closely related to our current effort. One line of approach is weakly supervised object localization \cite{bilen2014weakly,kumar2010self, prest2012learning,rochan2015weakly,vcip,bmvc}, wherein we only have meta information such as the presence/absence of an object category. Majority of these algorithms are based on multiple instance learning(MIL) framework. In this formulation, an image is represented as a bag of regions. It is assumed if an object category is marked as `present' in an image then one of the regions in positive bag tightly bound the object while a tag of `absent' mean no regions contain the object. MIL training alternates between learning an appearance model and selecting the proper region in positive bags which contain the object using the learnt appearance model. However, weakly supervised training is very difficult and its performance is still not at par with fully supervised methods \cite{gokberk2014multi, song2014learning}. \par The second line of effort is to exploit information from both videos and images \cite{prest2012learning, sharma2013efficient, leistner2011improving}. In \cite{prest2012learning}, Prest \textit{et al.} presented a framework for adapting detectors from videos to images (which is opposite to ours). First, they learn an automated video object localizer in videos. This is followed by training video object detector under a domain adaptation setting with fully annotated image data and weakly annotated video data. In \cite{sharma2013efficient}, Sharma and Nevatia present a framework for detecting humans in videos by online refinement of a baseline pre-trained detector. The idea is to apply the pre-trained detector at a high recall rate so that it outputs a lot of true positive regions. The false positive regions are discarded by an online refinement. Clearly, this method is not suited for real-time applications. Our detector modules consist of Faster R-CNN \cite{faster} which runs in near real time. Also, we experiment on wide varieties of moving objects(rather than only humans) under more unconstrained environments. \subsection{Generative Adversarial Networks} Generative adversarial network\cite{goodfellow2014generative} has two parametrized models, discriminator and generator pitted against each other in a zero-sum game. The generator network's input is a noise vector, $z$, drawn from a prior noise distribution, $p_z(z)$. Following \cite{goodfellow2014generative}, $z\sim \mathcal{U}[-1,1]$ (uniform distribution) and generator maps it onto an image, $y$; $G~: z~ \rightarrow y$. The discriminator classifies samples between true data distribution $p_{data}$ and the generated distribution, $p_G$. Specifically, generator and discriminator play the following game on $V(D, G)$: $$\underset{G}{min}~~ \underset{D}{max}~~ V(D, G) = \mathbb{E}_{x\sim p_{data}(x)}[\log D(x)]$$ \begin{equation} + ~~\mathbb{E}_{z\sim p_{z}(z)}[1 - D(G(z))] \end{equation} With sufficient capacity for both generator and discriminator, this min-max game has global optimum when $p_{data}=p_G$ \cite{goodfellow2014generative}. Empirically, it has been observed that for the generator, it is prudent to maximize $\log (D(G(z)))$ instead of minimizing $\log [1 - D(G(z))] $. \subsection{Image to Image Translation with Adversarial Learning} Our core motivation is to transform a static image to appear as if being sampled from a dataset of video frames. This can be seen as an appearance mapping in pixel space, which is nowadays studied under the umbrella of adversarial image-to-image translation genre. GANs show the potential to approximate an unknown static distribution. This property has been recently leveraged by several authors for pixel level domain adaptation \cite{shrivastava2017learning, pix2pix2017, bousmalis2017unsupervised}. The basic idea is to have paired image samples in both domains, $X$ and $Y$ and then learn a conditional generator network(conditioned on an image sampled from $X$) to map to $Y$. The discriminator's task is to identify whether an image is sampled from $Y$ or is transformed from $X$. Shrivastava \textit{et al.} \cite{shrivastava2017learning} and Bousmalis \textit{et al.} \cite{bousmalis2017unsupervised} had the common motivation to design a `refiner' network to transform synthetic images to appear like real images and then train discriminative models on these transformed synthetic datasets. This is helpful because getting labelled data in a rendered/synthetic domain is often free of cost. Though promising, these methods were only applied for inferencing on very small objects such as estimating gaze from a properly cropped out human eye sample of resolution 35$\times$55. In \cite{bousmalis2017unsupervised}, the authors presented results of recognition and pose estimation from specifically centre cropped small objects such as `phone', `lamp' etc., from Cropped LineMod dataset \cite{wohlhart2015learning}. Our application case is much more difficult as we are working with non cropped image/video frames in the wild with the problem of detecting an arbitrary number of instances of a given class in an image. The first success of applying GANs for high resolution (256$\times$ 256) image-to-image translation was proposed by Isola \textit{et al.} \cite{pix2pix2017}. Their framework, for example, transforms sketch of a shoe to real textured consumer shoe or converts an aerial map to actual city image. Though promising, this method is restricted in applicability due to the requirement of paired examples across both domains. This is specifically restrictive in our case because it is not possible to have an object with the same scale and orientation to be present in both image and video datasets. To mitigate this restriction, Zhu \textit{et al.} \cite{zhu2017unpaired} proposed to incorporate a cycle consistency loss so that a forward transform, $F(X)$, followed by a backward transform, G(F(x)), gives back the starting distribution, $X$. The same restriction is applied for domain $Y$. The cycle consistency loss is a key component to learn in absence of paired data and is thus well suited for our application use case. \section{Our Approach} Our aim is to learn an unsupervised mapping between two domains of data, viz., high-quality static images, $X$, and the other domain of video frames, $Y$. We have unpaired training samples, $x_1, x_2,... , x_N \in X$ and $y_1, y_2,... , y_M \in Y$. We denote data distribution as $x \sim p_{data}(x)$ and $y \sim p_{data}(y)$. In Fig. \ref{fig_flow} we show the two components of adversarial transformation and cycle consistency loss between image and video domains. There are two transformation networks, $G(\cdot)$ and $F(\cdot)$, which map $X \rightarrow Y$ and $Y \rightarrow X$ respectively. \subsection{Adversarial Transformation} Domain discriminator, $D_Y$, discriminates between images transformed from the static images and frames sampled from videos. The adversarial loss for this forward transformation is defined as, $$L(G, D_Y, X, Y) = \mathbb{E}_{y \sim p_{data(y)}} [\log D_Y(y)] +$$ \begin{equation} \mathbb{E}_{x \sim p_{data(x)}} [\log (1 - D_Y(G(x)))] \label{eq_d_y} \end{equation} $D_X$ discriminates between video frames transformed to image domain and images sampled from static image database. The corresponding adversarial loss is, $$L(F, D_X, Y, X) = \mathbb{E}_{x \sim p_{data(x)}} [\log D_X(x)] + $$ \begin{equation} \mathbb{E}_{y \sim p_{data(y)}} [\log (1 - D_X(F(y)))] \label{eq_d_x} \end{equation} \subsection{Cycle Consistency Loss} Theoretically, with enough capacity, $G$ and $F$ can learn to generate samples from $Y$ and $X$ respectively. However, without any additional constraint, a given sample from $X$ can be mapped to any random point in $Y$ and be indistinguishable from real samples of $Y$. For example, if we provide an image of a car from the static dataset, $G$ can map it to look like a car from video dataset, but can change the scale and pose of the car. Though, this might not be an issue from an artistic point of view, it is a point of concern for training object detectors because we will use the bounding box annotations from the original static image. Thus we cannot afford to have any structural change during mapping from $X \rightarrow Y$. To restrict the domain of possible transformations, a cycle loss is introduced such that learned mapping respects the following sequence of transformation constraint. \begin{equation} x \rightarrow G(x) \rightarrow F(G(x)) \approx x. \end{equation} This ensures that the learned cyclic mapping can start from a given image $x\sim X$ and we get back $x$ after the two transformations of the cycle. This is termed as the forward cycle consistency constraint and the corresponding loss is, \begin{equation} L_{fwd}(G, F) = \mathbb{E}_{x \sim p_{data(x)}}||F(G(x)-x)||_1 \end{equation} A similar consistency is also imposed for frames being converted to static images with $F(\cdot)$ and back to video frames with $G(\cdot)$. The following constraint needs to be maintained, \begin{equation} y \rightarrow F(y) \rightarrow G(F(y)) \approx y \end{equation} and the corresponding backward consistency loss is \begin{equation} L_{bwd}(G,F) = \mathbb{E}_{y \sim p_{data(y)}}||G(F(y)-y)||_1 \end{equation} \subsection{Complete Objective} The complete objective function can be written as, $$L(G, F, D_X, D_Y) = L(G, D_Y, X, Y) + L(F, D_X, Y, X) + $$ \begin{equation} \lambda(L_{fwd}(G, F) + L_{bwd}(G,F)), \end{equation} where $\lambda$ controls the relative importance of cycle consistency loss over the adversarial loss. The task is to find optimum, $G^*$ and $F^*$ such that, \begin{equation} G^*, F^* = \underset{G, F}{\arg\min} \underset{D_X, D_Y}{\max} L(G, F, D_X, D_Y) \end{equation} \section{Implementation Details} Our entire framework consists of two phases of training. In the first phase, we train the CycleGAN network to transform high-quality static images to appear as video frames. So, a given image dataset is transformed into a pseudo video dataset. The next phase is training a standard object detector on the previously transformed image dataset using the same annotations of the original static image dataset. CycleGAN is not required during object detection testing. \subsection{Object Detector} In this paper we have used two contemporary object detectors viz., Faster R-CNN \cite{faster}\footnote{Available at: \href{https://github.com/smallcorgi/Faster-RCNN_TF}{https:\/\/github.com\/smallcorgi\/Faster-RCNN\_TF}} and RFB Net \cite{liu2017receptive} \footnote{Available at: \href{https://github.com/lzx1413/PytorchSSD}{https:\/\/github.com\/lzx1413\/PytorchSSD}}. We have used the default settings in the respective papers for training on all different variants of the training datasets. \begin{figure*}[!t] \centering \includegraphics[scale=0.36]{benefit.jpg} \caption{Benefit of cycle consistent GAN for image to image translation over a simple forward transform. In each tuple, left column: original VOC image, middle column: ForwardGAN transformed image and right column: transformed image by CycleGAN. A ForwardGAN only itself is not able to maintain the structural information in this high dimensional space. The degradations by this framework are not representative of frames from videos and thus training object detectors on these transformed images yield inferior results. Visually, CycleGAN does not degrade the essential structural information of the transformed images but still incorporates necessary perturbations to become indistinguishable from YTO frames. Training object detectors on CycleGAN transformed images thus results in better performance than training on ForwardGAN transformed images. }% \label{fig_gans}% \end{figure*} \subsection{CycleGAN} We have trained CycleGAN, on unaligned images and video frames. During training, images are resized to 286$\times$286 and then randomly cropped to 256$\times$256 to increase the robustness of the model. During inference, transformation is done on 256$\times$256 resized image and then rescaled to the original resolution before object detection. We have modelled the generator with 9 resnet blocks as implemented in \cite{he2016deep} and the discriminator with PatchGAN classifier \cite{pix2pix2017, li2016precomputed}\footnote{Implementation: \href{https://github.com/junyanz/CycleGAN}{https://github.com/junyanz/CycleGAN}}. GAN loss is implemented with vanilla GAN \cite{goodfellow2014generative} objective, while cycle loss is L$_1$ loss. We have considered $\lambda$ = 10. We have considered a batch size of 1 and used Adam optimizer \cite{kingma2014adam} with a momentum of 0.5 and an initial learning rate of 0.0002. \subsection{Timings} All computations are performed on NVIDIA Tesla K40C 12GB GPU. Training of CycleGAN with 5000 images each in source and target domain takes 2 days. Faster R-CNN training on image dataset takes 12 hours, while RFB Net training takes 10 hours. During testing, on average, Faster R-CNN and RFB Net run at about 7/8 frames per second. \section{Experiments} In the first part, we show the visual effects of applying adversarial transformation on static images and in second half we visually and numerically show the benefit of pixel level domain adaptation for object detection in videos. \begin{figure*}[!h] \centering \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{head1.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{head2.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{2.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{4.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{5.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{6.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{7.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{8.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{16.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{3.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{13.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{14.jpg} \end{minipage} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{15.jpg} \end{minipage} \hspace{2mm} \begin{minipage}[t]{0.38\textwidth} \includegraphics[width=\linewidth]{9.jpg} \end{minipage} \caption{Exemplary detections on Youtube-Objects dataset using Faster R-CNN trained on CycleGAN transformed VOC(propsed) and original VOC(baseline). Training on CycleGAN transformed dataset enables an object detector to deal with visual characteristics of videos such as cluttered background, motion blur effect, small size of objects etc., and thus improves detection performance on test set sampled from video sequences. Please note how small objects such as distant persons, bikes, animals are detected by our model. Also note how our model is robust to distant blurry objects, cluttered/occluded group of objects. All these are achieved with zero video supervision.} \end{figure*} \subsection{Datasets} \par We use fully annotated dataset of static images as source domain and a dataset of unannotated video frames as target domain. Please note in this paper we are performing object detection on stand-alone video frames and not on video sequences. Exploiting temporal information for efficient object detection is a separate genre of research and is not the main interest of the paper. \par For source domain we use the images from PASCAL VOC 2007 dataset \cite{everingham2010pascal}, which is a standard dataset for object detection. PASCAL VOC 2007 dataset consists of about 5000 training and 5000 testing images for 20 object categories. We train the object detector on all 20 object categories. For the target domain we use video frames from YouTube-Objects dataset \cite{prest2012learning} which consists of about 4300 training and 1800 testing images over 10 object categories which forms a subset of PASCAL VOC dataset. Testing is done on the annotated test set of Youtube-Objects dataset (YTO). For testing, we also consider another dataset, Youtube-Objects-Subset\cite{tang2013discriminative} which is derived from the videos of Youtube-Objects dataset but has more ground truth annotations. Please note we never make use of bounding box annotations on video training set in any stage of our framework. \subsection{CycleGAN Training} \subsubsection{Effect of adversarial image transformation } After completion of CycleGAN training, we would expect a high quality static image to be transformed to visually look like a video frame. In general, after the transformation, static images loose high frequency components, colors tend to get desaturated, discriminative parts gets blended with surroundings. We show some exemplary transformations in Fig. \ref{fig_effect}. \begin{figure*}[!t] \centering \includegraphics[scale=0.4]{visual_difference.jpg} \caption{Visualizing domain differences between images from VOC(top row) and YTO(bottom row) datasets. Images in VOC are sharper, rich in color representation and properly focused. Objects in YTO are usually not focused, blurred and manifests color desaturation.}% \label{fig_visual_difference}% \end{figure*} \subsubsection{ForwardGAN} To appreciate the benefit of such a cyclic structure in our adversarial network, we also trained a simple forward transform GAN with only the video domain discriminator. We term this transformation as ForwardGAN. This is similar to the methods of \cite{shrivastava2017learning,bousmalis2017unsupervised}. The discriminator discriminates between video frames and forward transformed static images. As we can see in Fig. \ref{fig_gans}, ForwardGAN adds implausible structural perturbations to the images. Hence the results of training object detectors on these images gave poor test results. \begin{table*}[!t] \scriptsize \begin{center} \caption { Comparison of detection performances(mean Average Precision: mAP) of Faster R-CNN object detector (trained on different variants of training datasets) on Youtube-Objects dataset } \begin{tabular}{c|cccccccccc|c} \hline \hspace{0.5in} Train Set \hspace{0.5in} & aero & bird & boat & car & cat & cow & dog & horse & bike & train & mAP\\ \hline Original VOC(Lower Bound) & 75.0 & 89.9 & 35.1 & 68.9 & 56.7 & 46.2 & 45.7 & 39.8 & 62.6 & 46.2 & 56.6 \\ ForwardGAN VOC & 75.3 & 83.1 & 31.4 & 68.3 & 51.0 & 55.8 & 37.6 & 41.9 & 61.5 & 47.3 & 55.3 \\ CycleGAN VOC(\textbf{Proposed})& 77.8 & 89.6 & 34.9 & 70.9 & 58.3 & 65.6 & 45.7 & 44.7 & 62.6 & 51.4 & 60.2 \\ Conditioned CycleGAN VOC(\textbf{Proposed})& 79.6 & 90.4 & 37.5 & 71.9 & 61.1 & 67.4 & 47.7 & 46.3 & 64.8 & 52.8 & 62.0 \\ Youtube-Object(Upper Bound) & 78.1 & 91.3 &46.7&72.3 & 62.1 & 69.6 & 46.6 & 48.0 & 63.1 & 53.7 & 63.1\\ \hline \label{tab:table-one} \end{tabular} \end{center} \end{table*} \begin{table*}[!h] \scriptsize \begin{center} \caption { Comparison of detection performances(mean Average Precision: mAP) of RFBNet object detector (trained on different variants of training datasets) on Youtube-Objects-Subset dataset} % \begin{tabular}{c|cccccccccc|c} \hline \hspace{0.5in}Train Set \hspace{0.5in} & aero & bird & boat & car & cat & cow & dog & horse & bike & train & mAP \\ \hline Original VOC(Lower Bound) & 75.2 & 80.9 & 45.1 & 74.5 & 45.5 & 40.1 & 33.7 & 37.4 & 61.8 & 58.8 & 55.3 \\ ForwardGAN VOC & 72.7 & 67.8 & 41.1 & 67.7 & 38.0 & 58.8 & 35.7 & 34.5 & 59.6 & 64.7 & 54.0 \\ CycleGAN VOC(\textbf{Proposed}) & 82.0 & 82.6 & 48.4 & 74.7 & 49.2 & 56.3 & 34.1 & 42.0 & 60.4 & 71.0 & 60.1 \\ Conditioned CycleGAN VOC(\textbf{Proposed}) & 83.0 & 83.8 & 49.2 & 76.1 & 51.0 & 56.7 & 35.2 & 42.7 & 61.9 & 72.1 & 61.2 \\ Youtube-Object(Upper Bound) & 83.5 & 84.6 & 48.9 & 75.2 & 51.6 & 58.0 & 36.9 & 45.3 & 62.7 & 74.1 & 62.1 \\ \hline \label{tab:table-two} \end{tabular} \end{center} \end{table*} \begin{table*}[!h] \scriptsize \centering \caption {Comparison of CorLoc on Youtube-Objects and Youtube-Objects-Subset dataset. Proposed methods refer to performances of Faster R-CNN models trained on CycleGAN and class conditioned CycleGAN transformed PASCAL VOC datasets. } \begin{tabular}{cccccc}\hline \multicolumn{6}{c}{Youtube Objects Dataset} \\\hline Proposal Only\cite{rochan2015weakly} & Proposal + Transfer\cite{rochan2015weakly}& Teh \textit{et al.}\cite{vcip} & Chanda \textit{et al.}\cite{bmvc} & \textbf{Proposed} & \textbf{Proposed(Conditioned)}\\\hline 51.5 & 55.3 & 56.7 & 61.9 & 58.8 & 61.6 \\\hline \multicolumn{6}{c}{Youtube Objects Subset Dataset} \\ 36.0 & 41.6 & 48.5 & 51.1 & 50.8 & 52.1 \\ \hline \label{table_compare} \end{tabular} \end{table*} \subsubsection{Dataset adaptation or regularization ?} Fig. \ref{fig_effect} might tempt one to believe that proposed model succeeds just by adding some noise to the training data and thereby making training data more difficult. In Fig. \ref{fig_visual_difference} we show some examples from original VOC and YTO. Indeed, we can appreciate that objects in YTO suffer from defocussing, blurriness, color desaturation effects. Our framework learns this distribution difference automatically instead of relying on manual hand crafted dataset augmentation techniques. In fact, in our initial experiments, we augmented original VOC with Gaussian noise of standard deviation 0.01, 0.05, 0.1, 0.5 and 1. mAP of Faster RCNN trained on these augmented datasets and tested on YTO were 56.4, 57.1, 57.2, 50.3 and 44.1. We also tried with Gaussian blurring of VOC images with kernel sizes of 5, 9 and 13 at standard deviation of 2. mAPs on YTO were 56.4, 57.0 and 56.8. With standard deviation of 4, mAPs were 56.3, 57.2 and 55.9. Thus, it is safe to say simple dataset augmentations do not help in the current domain adaptation problem. \subsection{Object Detection} \subsubsection{Evaluation Metrics} A commonly used metric for evaluating object detection is mean Average Precision(mAP)\cite{everingham2010pascal}. According to Pascal criterion, a detected bounding box, $B_p$, is considered as true positive, $TP$, if, Intersection Over Union (IoU) = $\frac{area(B_p \cap B_{gt})}{area(B_p \cup B_{gt})} \ge 0.5$, else $B_p$ is considered as a false positive, $FP$. $B_{gt}$ is an annotated box. mAP is defined as the mean of average precision over all classes. Another popular measure is CorLoc \cite{corloc} which is given by $\frac{TP}{TP + FP}$. CorLoc can be interpreted as the proportion of detected bounding boxes which satisfy the Pascal criterion.\\ \textbf{Special care on Youtube-Objects-Subset dataset:} The annotations released for this dataset consist of pixel-wise segmentation maps instead of bounding boxes as in Youtube-Objects. We convert the segmentation maps to bounding boxes by enclosing the segmentation maps by smallest possible rectangles. We also followed the conversion strategy as proposed in \cite{vcip}; converting a detected bounding box to a segmentation map using grab-cut algorithm \cite{rother2004grabcut}\footnote{Available: \href{https://docs.opencv.org/trunk/d8/d83/tutorial\_py\_grabcut.html}{https://docs.opencv.org/trunk/d8/d83/tutorial\_py\_grabcut.html}}. Under this formulation, IoU is measured with respect to the overlap of segmentation maps. The numerical results following both paradigms are almost comparable and thus, following \cite{vcip}, we stick to the latter framework. \subsubsection{Comparing Baselines} \par As a baseline we train standard object detectors on PASCAL VOC dataset and test on video frames without any adaptation. This gives us the lower bound of performance. The upper bound is achieved by training detectors on annotated video frames. To show the robustness of the approach, we report the observed effect of domain adaptation using two different object detectors, viz., Faster R-CNN and RFBNet300. We have considered backbone as VGG16 for both detectors. In Table \ref{tab:table-one} we compare the performances of Faster R-CNN trained on different versions of training set and then tested on Youtube-Objects(YTO) test set. In Table \ref{tab:table-two} we report performances with RFBNet300 network tested on Youtube-Objects-Subset. For both detectors, we see an appreciable boost in performance if trained on CycleGAN transformed images dataset compared to original VOC dataset. Of course, training on labelled YTO frames still gives the upper bound of performance but using our proposed method we reduce the performance gap appreciably. Also, it is to be noted that the training of ForwardGAN deteriorates performance even worse than training on original VOC. Tables \ref{tab:table-one} and \ref{tab:table-two} strongly bolster our hypothesis that visual domain adaptation is a viable approach for cross domain learning of object detectors with close to zero supervision in unlabeled domain. Next, in Table \ref{table_compare}, we also compare our model with some of the contemporary weakly supervised baselines. In \cite{rochan2015weakly} (proposal only) refers to learning of appearance model based on object proposals on weakly annotated frames while (proposal + transfer) refers to combination of appearance model from 'novel' objects (video) and transferred appearance model from 'familiar' annotated objects (static images). Method of Chanda \textit{et al.}\cite{bmvc} is based on a 2-stream network, wherein one stream they perform regular fully supervised image object detection and in another stream, they perform frame level classification on the weakly annotated videos. These 2 streams share parameters to counter domain shift factors. Teh \textit{et al.}\cite{vcip} proposed an attention network so as to mimic the score of region proposal networks on weakly annotated objects to be similar to a strong fully supervised object detector. Please note all these competing methods assume the presence of meta information such as presence/absence of object categories on each training video frame. However, we assume no information to be associated on video training dataset. It is evident from Table \ref{table_compare} that our model presents competitive performance(better in majority cases) compared to these methods. \subsection{Can YTO class labels help CycleGAN?} One of the drawbacks\footnote{See discussion: \href{https://github.com/junyanz/CycleGAN\#failure-cases}{https://github.com/junyanz/CycleGAN\#failure-cases}} of CycleGAN is that it is tough to train if the two domains differ structurally. In our case, this bottleneck arises because, without a priori knowledge of labels, a given mini batch can consist of different object categories. To mitigate this drawback one can train a separate CycleGAN conditioned on each category on YTO. This requires weak label information for each frame. So, during offline CycleGAN training, we train 10 different networks to individually transform each category. However, we still need to train only a single object detector on this conglomerated transformed dataset. Such use of weak labels further boosts the performance of our framework as reported in Tables \ref{tab:table-one}, \ref{tab:table-two} and \ref{table_compare}. This observation indicates that class conditioned CycleGANs are better at capturing the appearance diversities across two datasets. \section{Conclusion} In this paper, we mainly focused on unsupervised pixel level domain adaptation for transferring image object detectors for videos. In contrast to the contemporary trend of weakly supervised learning on videos which still requires manual intervention in videos, our framework requires no supervision. The core idea is to pose the problem as an adversarial image-to-image translation for converting annotated static images to be visually indistinguishable from video frames. We also showed that the inclusion of class labels on videos improves our framework further. A straightforward application of our model will be to automatically annotate large video datasets for object detection. Currently, our method is focused on detecting objects on standalone video frames. An immediate extension would be to leverage temporal information in videos for enhanced detection performance. Moreover, the ideas of the paper in general, should encourage researchers towards other interesting visual domain adaptation applications such as emotion recognition from 3D face avatars, learning pose estimation in a virtual world, robotic navigation in simulated environments and finally applying in real world frameworks. {\small \bibliographystyle{ieee}
{'timestamp': '2018-10-05T02:07:34', 'yymm': '1810', 'arxiv_id': '1810.02074', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02074'}
arxiv
\section{\bf Introduction} Convolutional Neural Networks(CNN) have led to many performance breakthroughs in image classification, video object tracking, and audio processing applications\cite{lecun_deep_2015}. Since AlexNet won the ILSVRC 2012 and is more than 10\% lower than other contemporary competitors on top-5 error rate\cite{krizhevsky_imagenet_2012}, CNN evolved into many different models, such as GoogLeNet\cite{szegedy_going_2015}, VGG\cite{simonyan_very_2014}, ResNet\cite{he_deep_2015}. Using Graphics Processing Unit(GPU) to accelerate convolution computations plays an important role in CNN's success, since convolution is the most time-consuming part in CNN, and the throughput of convolution is prior than accuracy\cite{gupta_deep_2015}. However, for large scale Convolutional Neural Networks(CNN), modern computing hardware often encounter on-chip memory bottleneck when dealing with high volume convolution calculations\cite{chandrasekhar_compression_2017,rhu_vdnn:_2016}. Recently, many researchers show interest on emerging memristor crossbar for its computing-in-memory feature\cite{gao_demonstration_2016,adam_3-d_2017,hu_memristor-based_2018,liu_harmonica:_2016,yu_neuro-inspired_2018,li_analogue_2018}. A memristor crossbar can carry out large-scale analog vector matrix multiplication in one step by collecting analog output with input signal flowing through the array, where weights are stored non-volatilely at cross-point memristor devices. Since weight storage and weighted summation both happen at the same location of memristors, it enables ultra-high computing efficiency as well as low communication requirement. Overall, memrisotr crossbar-based implementation may overcome von-Neumann architecture's shortage and are suitable for deep learning inference functions. However, integrating analog memristor crossbars with digital circuits is not trivial. One of the key issues is that a rigorous circuit simulation is still missing for memristor-based CNN implementations, especially on the modeling of analog memristor crossbar behavior. As SPICE is too slow on simulating large-scale memristor crossbar arrays, specific tools have been developed to investigate memristor-based neural network (NN) implementations\cite{xia_mnsim:_2016}\cite{chen_neurosim:_2018}. Although they provide accurate estimation for speed, area and power, the prediction of functionality is questionable due to over-simplified memristor crossbar models, which is also lack of experiment verification at large scale. It leads to a serious question: \textit{if we implement state-of-the-art CNNs with memristors, will it really work?} This question can only be addressed with an analog circuit simulation for all the memristor crossbars in CNNs, since it is the most immature part in the whole system. In this paper, we investigate memristor-based large-scale CNN implementation with experiment verified memristor crossbar simulators. Our contributions are listed as below: \begin{itemize} \item First, we provided an efficient mapping method to map high dimension kernels to 2-D memristor crossbars using realistic circuit components. \item Second, we developed an improved conversion algorithm to convert kernel to crossbar conductance with consideration of non-ideal hardware as well as data/kernel patterns. \item Third, we addressed the aforementioned question with ResNet-20 on cifar-10. A careful simulation is done at all convolution layers to capture the error propagation in CNN. Our result shows that 8-bit ADC/DAC quantization is necessary to preserve the classification accuracy. \end{itemize} \section{\bf Priliminary} \subsection{\bf Deep Residual Neural Network} Deep residual neural network(ResNet) was firstly introduced in ILSVRC 2015 \cite{he_deep_2015}. So far, ResNet is the state-of-the-art CNN on image classification problems. An ensemble of residual nets up to 152 layers achieves 3.57\% error on the ImageNet test set and won the 1st place on the ILSVRC 2015 classification competition. To evaluate how state-of-the-art CNNs perform on memristor crossbar arrays, ResNet is an ideal case study. Fig.\ref{fig_resnet} shows the basic block diagram of ResNet. It combines multiple convolution, batch normalization, and rectified linear units(ReLU) together as its basic building block. Different from other CNNs, ResNet uses a shortcut to add input data to the output result of a block. If two data inputs have different dimensions at the summation stage, a $1 \times 1$ convolution layer will be introduced in shortcut to match the dimension. The summation result is sent to ReLU and pass to the next Block. At the end of ResNet, pooling layer, one or more Fully Connected (FC) layers, and a softmax layer are used in sequence to generate final classification result. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/ResNet.png} \caption{Basic block diagram of ResNet.} \label{fig_resnet} \end{figure} \subsection{\bf 1T1M crossbar for VMM} Fig.\ref{fig_xbar}(a) shows the general structure of a one-transistor-one-memristor (1T1M) crossbar for vector matrix multiplication (VMM). In this structure, memristor crossbar is the core component as it enables analog current weighted summation, which leads to ultra efficient VMM operation. A $m \times n$ memristor crossbar is made by $m$ row and $n$ column metal wires where memristors formed at intersecting points. Each memristor can be tuned to arbitrary conductance within its programmable range. To enable precise, non-disturbing tuning in large crossbar arrays, 1T1M cell (Fig.\ref{fig_xbar}(b).) is necessary to program the entire array with arbitrary conductance matrix $G$. By applying voltage inputs $V$ at the rows simultaneously and read current outputs $I$ from the columns, analog weighted summation is achieved through Kirchhoff's Current Law and Ohm's Law. In an ideal crossbar, input-output relationship can be represented as below: $$ I = VG $$ By mapping input vector $X$ to input voltage $V$, matrix $A$ to conductance $G$, and output current $I$ back to output result $Y$, a memristor crossbar can be regarded as an analog VMM module to realize $Y=XA$ in one step. Note that $I = VG$ is only valid for ideal crossbar while wire resistance can be ignored and device conductance is independent of voltage/current. In real crossbars, the input-output relationship is far more complex and needs analog circuit simulation. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{images/1T1Mxbar_VMM.png} \caption{1T1M crossbar for VMM operation. (a) shows the overall circuit diagram; (b) shows the 1T1M cell (c) shows the ramping ADC design.} \label{fig_xbar} \end{figure} Fig.\ref{fig_xbar}(c) illustrates a ramping ADC design\cite{delagnes_low_2007}, it uses a shared ramping signal generator and counter to support multiple channels simultaneously. The ramping signal generator produces increasing/decreasing analog voltage signal to all comparators, and its analog value is synchronized with the digital representation in the counter. Comparators compare the crossbar output to the ramping signal. Once a flip is detected, comparator captures the current value in the counter, which is the corresponding digital representation of crossbar output. This concept can be applied to DAC design as well. Overall, The ramping ADC/DAC design can achieve lower area and power for multi-channel applications, and it is a suitable digital interface for crossbar-based accelerators. \subsection{\bf Experiment-Verified Crossbar Simulator and The Conversion Algorithm} So far, simulation tools like MNSIM and NeuroSim provide excellent architecture-level analysis. However, their memristor crossbar models are over simplified. In MNSIM\cite{xia_mnsim:_2016}, an estimated behavior model is used instead of solving node equations; In NeuroSim\cite{chen_neurosim:_2018}, the impact of wire resistance is simplified by adding wire resistance to cross-point devices. All of these over-simplifications result in unignorable error between predicted output to real output of crossbars. And this error become even more severe in large scale implementations. In short, coarse modeling of crossbar may be acceptable on power/area/speed estimations, but is questionable on functionality evaluations, such as computing accuracy at layers, or classification accuracy of NN implementations. After all, to evaluate NN's functionality on memristor-based implementations, an accurate crossbar simulator is necessary. An accurate crossbar simulator should use realistic device models, solve node equations with consideration of wire resistance and other circuit parameters, then finally verified with experiment result at large scales. Here We adapt the experiment-verified memristor crossbar simulator from \cite{hu_memristor-based_2018}. Fig.\ref{fig_1T1Msim} illustrates the simulation result of the memristor crossbar simulator, which is verified with experiment up to $128 \times 64$. Besides the simulator, the conversion algorithm, as a mapping method is employed to improve VMM computing accuracy with consideration of wire resistance and device nonlinearity\cite{hu_dot-product_2016}. The conversion algorithm uses a conversion signal $V_{conv}$ to find a new conductance mapping $G'$, so that $$ VG \approx \mathrm{CrossbarSim}(V, G') $$ where CrossbarSim() is the realistic crossbar model. Although the original conversion algorithm provides 7$\sim$8 bit-accuracy result for general VMM, it does not consider impact of data/weight patterns in specific applications, which may affect its performance significantly. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/1T1Msim.png} \caption{1T1M simulation and experiment result \protect\cite{hu_memristor-based_2018}. Wire segment resistance is calibrated to 1$\Omega$, transistor and memristor models are calibrated with in-array device test.} \label{fig_1T1Msim} \end{figure} \section{\bf Methodology} In this work, we take ResNet-20 as our case study for memristor-based CNN implementation. We first provide a dense mapping method to map high dimension kernels onto 2-D memristor crossbar arrays efficiently. By doing a near full circuit simulation of memristor-based implementation for ResNet-20, we explain how to optimize the conversion signal for each layer based on its corresponding convolution kernel and data pattern. Moreover, we introduce an additional calibration step to further improve the performance and robustness of the circuit. Our memristor-based CNN implementation can give precise convolution result for each layer, and its precision is independent of data sparsity and kernel types. \subsection{\bf Dense mapping for crossbar-based convolution} In ResNet, each convolution layer has a 4-D kernel, as illustrated in Table.\ref{Table_mapping}. For example, the 3*3*3*16 kernel of 'Conv0' means it has 16 sets of 3*3*3 3-D kernels, and each 3-D kernels contains 3 2-D kernels for the 3 channels (RGB) of color images. To perform convolution on memristor crossbar, we need convert high dimensional convolution into 2-D VMM. It is well known that 2D convolution can be implemented using matrix multiplication by converting kernel to a Toeplitz matrix. Topelitz matrices are sparse matrices which contains many zeros, so we named this method as \textit{sparse mapping}. \begin{figure}[t] \centering \includegraphics[width=0.465\textwidth]{images/dense_map.png} \caption{Dense mapping for input data size (j,k,p), where j,k,p means data height, width, and channel, respectively. The circuit needs j*k iterations to process the input data.} \label{Fig_densemap} \end{figure} However, sparse mapping has three major issues: First, memristor crossbar is by nature a dense array structure with positive values, not efficient for sparse matrix implementation. Mapping a sparse matrix to crossbar means that the memristors assigned with zero entries would do nothing but adding error to the final result due to leakage current, as well as waste circuit area. Second, sparse mapping requires a huge crossbar array, which is not always feasible, and vulnerable to noise and defects. third, sparse mapping requires a large peripheral circuit to support the huge array. Since peripheral circuit dominates the total power/area, the hardware implementation of sparse mapping would be too costly to afford. Fig.\ref{Fig_densemap} illustrates the concept of dense mapping. In contrast to sparse mapping, we developed a new method, named as \textit{dense mapping}, targeting on using small and dense representations to implement convolutions on memristor crossbars efficiently. Each 2-D kernel is unrolled to a vector and mapped to the column of crossbar so that one crossbar can implement multiple 2-D kernels as long as it has enough columns. For input signal, only data within the convolution window is converted to the row inputs of crossbar arrays. For data with multiple channels, 2-D kernels for different channels are stacked into the same column, as input from different channels can be supplied to different rows and weighted summed together. An input shift register stores the input data within convolution window at the current iteration, and updates its storage as window moves through the entire data space. The convolution result for data within the convolution window are collected at the column outputs of crossbar. In this way, a single memristor-based convolution kernel needs $j$*$k$ iterations for input data with size ($j$, $k$, $p$) where $j$, $k$, $p$ are data height, width, and channel, respectively. Comparing dense mapping to sparse mapping, it is a trade-off between time multiplexing and space multiplexing. Sparse mapping uses much more extra hardware to produce result without iteration. However, its efficiency exponentially drops as data/kernel scale up, which means, more and more devices in a rectangular crossbar are unused for increasing data/kernel size. Dense mapping is a more adequate and practical method comparing to sparse mapping. It not only achieves 100\% usage of devices, but also easy to implement and provide sufficient performance in speed for CNN applications. From Table \ref{Table_mapping}, one classification in ResNet-20 needs 9089 iterations in sequential, if no parallel copies of hardware are used. Note that summation (sum\#) is in parallel of convolutions so it's not counted in total iterations. Assuming memristor crossbar runs at 100 MHz \cite{hu_dot-product_2016}, for each classification the convolution part takes only 0.09 ms, which is way fast enough for real-time classification requirement. \begin{table}[t] \caption{Dense mapping of ResNet-20 convolution layers for $32 \times 32$ color image classification from cifar-10 dataset} \centering \begin{tabular}{|p{1.8cm}|p{1.8cm}|p{1.5cm}|p{2cm}|} \hline \textbf{Layer name} & \textbf{Kernel size} & \textbf{Crossbar Size} & \textbf{Iteration per. class.}\TBstrut\\ \hline Conv0 & 3*3*3*16 & 27*16 & 1024 \TBstrut\\ \hline Conv1-2 & 3*3*16*16 & 144*16 & 1024 \TBstrut\\ \hline Sum1 & 1*1*16*16 & 16*16 & 1024 \TBstrut\\ \hline Conv3-6 & 3*3*16*16 & 144*16 & 1024 \TBstrut\\ \hline Sum2 & 1*1*16*32 & 16*32 & 256 \TBstrut\\ \hline Conv7 & 3*3*16*32 & 144*32 & 256 \TBstrut\\ \hline Conv8-12 & 3*3*32*32 & 288*32 & 256 \TBstrut\\ \hline Sum3 & 1*1*32*64 & 32*64 & 64 \TBstrut\\ \hline Conv13 & 3*3*32*64 & 288*64 & 64 \TBstrut\\ \hline Conv14-18 & 3*3*64*64 & 576*64 & 64 \TBstrut\\ \hline FC & 1*1*64*10 & 64*10 & 1 \TBstrut\\ \hline \end{tabular} \label{Table_mapping} \end{table} \subsection{\bf Improved conversion algorithm} Algorithm \ref{alg_1} summarizes the flow of crossbar-based convolution with the improved conversion algorithm. Table \ref{Table_functions} explains the important functions in the algorithm. After initialization, if the kernel is already mapped and converted onto crossbars, it will directly jump to the computing step to simulate crossbar-based convolution. So to implement ResNet-20 with multiple convolution layers, we only need to do mapping/conversion once for inferencing. \begin{algorithm} \caption{Crossbar-based convolution with improved conversion algorithm}\label{euclid} \begin{algorithmic}[1] \State Initialization: setup crossbar parameters(wire resistance, memristor conductance range, etc...) \State Get a batch of input data \State If kernel $K$ is mapped and converted, jump to {\bf computing}. \State Dense mapping kernel $K$ to conductance matrix $G$ \State Optimize conversion signal \State $InputVectors \gets \text{Partition input data}$ \State $CaliSample \gets \text{Random pick from } InputVectors$ \State $G' \gets \text{Conversion}(G,V_{conv})$ \State $P \gets \text{GetCaliPara}(G',CaliSample)$ \State Begin \textbf{computing} \While {$\sim$end of $InputVectors$} \State $V_{in}[i] \gets InputVector[i]$ \State $I_{out}[i] = \text{CrossbarSim}(G', V_{in}[i])$ \State $Output[i] = \text{Calibration}(I_{out}[i],InputVector[i],P)$ \State $i \gets i + 1$ \EndWhile \State $\text{Convolution result} \gets \text{reshape}(Output)$ \State End \textbf{computing} \end{algorithmic} \label{alg_1} \end{algorithm} \begin{table}[t] \caption{Explanations for functions in algorithm \ref{alg_1}} \centering \begin{tabular}{|l|p{6.5cm}|} \hline \textbf{Function} & \textbf{Explanation}\TBstrut\\ \hline CrossbarSim & Experiment verified crossbar simulator from \cite{hu_memristor-based_2018}\TBstrut\\ \hline Conversion & Solve $V_{conv} \cdot G = \mathrm{CrossbarSim}(V_{conv}, G')$ to get G'.\TBstrut \\ \hline GetCaliPara & Get 1st order poly fitting result $P$ by fitting crossbar\Tstrut \ output to ideal output of calibration samples.\Bstrut\\ \hline Calibration & Use $P$ and $InputVector[i]$ to map $I_{out}[i]$ to\Tstrut \ $Output[i]$. Here $InputVector[i]$ is needed, because in VMM $Y = XA$, if $A$ contains negative values, $Y$ can be calculated by $Y = X(A + c) - c*\mathrm{sum}(X)$, while c is a large enough scalar to shift $A$ to all positive.\Bstrut\\ \hline \end{tabular} \label{Table_functions} \end{table} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/Sparsity_vs_layer.png} \caption{Input data sparsity at each convolution layer of ResNet-20} \label{fig_data_sparsity} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/kernelType.png} \caption{Three kernel types in CNN with different limitations on weight} \label{fig_kernel_type} \end{figure} \subsubsection{\bf Data and kernel pattern in ResNet} Data in ResNet has high sparsity due to ReLU. Fig. \ref{fig_data_sparsity} shows the data sparsity at each convolution layer of ResNet-20. The impact of data sparsity should be considered when choosing conversion signal as well as gathering calibration samples. similarly, we found that kernels in CNN have different distributions. In Fig.\ref{fig_kernel_type} we list three typical kernel types regarding to their weight value distributions. Usually there are three typical kernel types: Kernel type 1 refers to a weight distribution close to Gaussian, usually it happens when training algorithms put no limitation on weight values, such as ResNet. Kernel type 2 refers to training algorithm that preventing weight values goes near zero\cite{han_deep_2015}. Kernel type 3 refers to Binary Neural Networks where weights can only be -1, 0(sparse), or 1\cite{courbariaux_binarized_2016}. It worth investigating how different kennel types in CNN impact the quality of crossbar-based convolution. \subsubsection{\bf Optimize conversion signal} To better quantize the computing accuracy, we define relative error as below: $$ \mathrm{Relative~Error} = \mathrm{Absolute~Error}/\mathrm{Output~Range} $$ While Absolute Error is the absolute error of crossbar output, and Output Range is the ideal convolution output range for each kernel. Relative error can be converted to output bit accuracy as below: $$ \mathrm{Bit~Accuracy} = log_2(1/\mathrm{Relative~Error} + 1) $$ The original conversion algorithm takes the maximum input vector as its conversion signal, which works well with dense matrix and dense input signals. However in CNN, we need to consider the sparsity of data to optimize the conversion signal. By testing various different conversion signals across different kernels, we notice that the amplitude of conversion signal is critical, while the sparsity of conversion signal is not as important. Fig.\ref{fig_diffamp} shows the relative error distribution with different conversion signal amplitudes in crossbar with size $144 \times 16$. We found that a conversion signal with too large amplitude (all 1) will cause over compensation in the signal loss due to wire resistance, and a too small conversion signal (all 0.001) do have enough compensation and both of them result in large error in output. So for crossbar size $144 \times 16$, all 0.1 signal appears to be the best conversion signal, and other conversion signal close to it generate similar error distribution. \subsubsection{\bf Calibration} In addition to original conversion algorithm, we add a calibration stage to further improve the result. It randomly picks 10 samples from the input data set, and runs a 1st order polynomial fit to fit crossbar output to ideal output. The generated fitting vector $P$ is fixed per crossbar, and can be easily embedded in ADC/DAC configurations. Fig.\ref{fig_diff_signal_type} shows the relative error with different calibration signals, and here using shuffled input can achieve the best result. \section{\bf Result} \subsection{\bf Simulation setup} In our work, convolution and fully-connected (FC)layers are implemented by analog memristor crossbars with digital interface. Other functions, such as pooling, ReLU, batch normalization, etc., are processed by digital circuits. The CNN is offline-trained, then its kernels are converted to the conductance of memristors for inference. Our crossbar simulator is configured as below: Lowest memristor resistance $R_{on}$ = 15k$\Omega$, Highest memristor resistance $R_{off}$ = 300k$\Omega$, wire resistance per segment is set to 1$\Omega$, sensing voltage = 0.2V. Input/Output resistance of crossbar are set to 1$\Omega$. Input voltage range is [0, 0.2V]. The crossbar simulation tool is adapted from \cite{hu_memristor-based_2018}. \subsection{\bf Individual convolution layer simulation} We first run circuit simulation at individual convolution layers to understand the impact of input data sparsity, kernel type and size on convolution accuracy. Fig.\ref{fig_288x32} illustrate the impact of input data sparsity. There are three observations: first, our method provides $\sim$50\% better overall accuracy than the original conversion algorithm. Second, our method gives lower relative error when ideal value is small. Third, our method minimizes the impact of data sparsity comparing to original conversion algorithm. Fig.\ref{fig_kernel type} summarizes the mean/worst relative error across three types of kernels with different input sparsity and crossbar sizes. It shows that our method is independent of kernel type and data sparsity. \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/conversion_2.png} \caption{Relative error with different conversion signal amplitudes on crossbar(size: $144 \times 16$), (a),(b),(c),(d) are conversion signals with all 1, 0.1, 0.01, 0.001 respectively.} \label{fig_diffamp} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/cali_relative_2.png} \caption{Calibration with different signal types on crossbar(size: $288 \times 32$), (a):Non-calibration, (b):random calibration signal, (c):random but decreased value(rand/cali\_iters),(d):chosen from shuffled input.} \label{fig_diff_signal_type} \end{figure} \begin{figure}[tp] \centering \includegraphics[width=0.5\textwidth]{images/288_4.png} \caption{Relative error of $288 \times 32$ crossbar. (a),(b): improved conversion algorithm, (c),(d): original conversion algorithm} \label{fig_288x32} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/different_kernel_type.png} \caption{Mean/Worst relative error with different kernel types, data sparsities and crossbar sizes} \label{fig_kernel type} \end{figure} \subsection{\bf End-to-end simulation for ResNet} It is more important to predict how errors propagate and accumulate in deep neural networks, and evaluate its impact on the final classification result. Fig.\ref{fig_layer_error} shows the error propagation at each convolution layer in ResNet-20. Fig.\ref{fig_ResNet_result} shows the classification result. Different ADC/DAC quantization settings are applied and we can see that 8-bit quantization is necessary to prevent error accumulation. Without quantization, the error will propagate from beginning to the end and affect the classification result, which is also not practical for large-scale implementation. Due to long simulation time (15mins/image), we used a subset of cifar-10 containing 150 testing images. It appears that 8-bit quantization is a good balance between error suppression and information preservation, as it achieves even slightly better classification result than software. 6-bit or 4-bit quantization cause error accumulate through all layers and lead to a significant drop in classification accuracy. With 6-bit, error rate increased by 73\% from 10\% to 17.3\% , and 4-bit increases the error rate by a factor of 8 from 11.3\% to 88.7\%. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/layer_compa.png} \caption{Error propagation along layers in ResNet-20, solid lines represent mean error, dash lines represent worst error.} \label{fig_layer_error} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/quantization.png} \caption{ResNet-20 result with different quantization settings} \label{fig_ResNet_result} \end{figure} \section{\bf Conclusions} In this work, We take ResNet as case study to investigate how modern CNN performs on memristor-based implementations. Our methods includes an dense mapping and an improved conversion algorithm, which can achieve 0.25\% mean relative error ($\sim$ 8.6 bits) or 1.2\% worst relative error ($\sim$ 6.4 bits) for crossbar size $576 \times 64$. We performed a rigorous analog simulation for every convolution layers to give an accurate prediction of error propagation in ResNet. We find that 8-bit ADC/DAC is necessary to prevent classification degradation. Our method can be applied to general CNNs due to its independence of input data sparsity and kernel types. \bibliographystyle{IEEE} \section{\bf Introduction} Convolutional Neural Networks(CNN) have led to many performance breakthroughs in image classification, video object tracking, and audio processing applications\cite{lecun_deep_2015}. Since AlexNet won the ILSVRC 2012 and is more than 10\% lower than other contemporary competitors on top-5 error rate\cite{krizhevsky_imagenet_2012}, CNN evolved into many different models, such as GoogLeNet\cite{szegedy_going_2015}, VGG\cite{simonyan_very_2014}, ResNet\cite{he_deep_2015}. Using Graphics Processing Unit(GPU) to accelerate convolution computations plays an important role in CNN's success, since convolution is the most time-consuming part in CNN, and the throughput of convolution is prior than accuracy\cite{gupta_deep_2015}. However, for large scale Convolutional Neural Networks(CNN), modern computing hardware often encounter on-chip memory bottleneck when dealing with high volume convolution calculations\cite{chandrasekhar_compression_2017,rhu_vdnn:_2016}. Recently, many researchers show interest on emerging memristor crossbar for its computing-in-memory feature\cite{gao_demonstration_2016,adam_3-d_2017,hu_memristor-based_2018,liu_harmonica:_2016,yu_neuro-inspired_2018,li_analogue_2018}. A memristor crossbar can carry out large-scale analog vector matrix multiplication in one step by collecting analog output with input signal flowing through the array, where weights are stored non-volatilely at cross-point memristor devices. Since weight storage and weighted summation both happen at the same location of memristors, it enables ultra-high computing efficiency as well as low communication requirement. Overall, memrisotr crossbar-based implementation may overcome von-Neumann architecture's shortage and are suitable for deep learning inference functions. However, integrating analog memristor crossbars with digital circuits is not trivial. One of the key issues is that a rigorous circuit simulation is still missing for memristor-based CNN implementations, especially on the modeling of analog memristor crossbar behavior. As SPICE is too slow on simulating large-scale memristor crossbar arrays, specific tools have been developed to investigate memristor-based neural network (NN) implementations\cite{xia_mnsim:_2016}\cite{chen_neurosim:_2018}. Although they provide accurate estimation for speed, area and power, the prediction of functionality is questionable due to over-simplified memristor crossbar models, which is also lack of experiment verification at large scale. It leads to a serious question: \textit{if we implement state-of-the-art CNNs with memristors, will it really work?} This question can only be addressed with an analog circuit simulation for all the memristor crossbars in CNNs, since it is the most immature part in the whole system. In this paper, we investigate memristor-based large-scale CNN implementation with experiment verified memristor crossbar simulators. Our contributions are listed as below: \begin{itemize} \item First, we provided an efficient mapping method to map high dimension kernels to 2-D memristor crossbars using realistic circuit components. \item Second, we developed an improved conversion algorithm to convert kernel to crossbar conductance with consideration of non-ideal hardware as well as data/kernel patterns. \item Third, we addressed the aforementioned question with ResNet-20 on cifar-10. A careful simulation is done at all convolution layers to capture the error propagation in CNN. Our result shows that 8-bit ADC/DAC quantization is necessary to preserve the classification accuracy. \end{itemize} \section{\bf Priliminary} \subsection{\bf Deep Residual Neural Network} Deep residual neural network(ResNet) was firstly introduced in ILSVRC 2015 \cite{he_deep_2015}. So far, ResNet is the state-of-the-art CNN on image classification problems. An ensemble of residual nets up to 152 layers achieves 3.57\% error on the ImageNet test set and won the 1st place on the ILSVRC 2015 classification competition. To evaluate how state-of-the-art CNNs perform on memristor crossbar arrays, ResNet is an ideal case study. Fig.\ref{fig_resnet} shows the basic block diagram of ResNet. It combines multiple convolution, batch normalization, and rectified linear units(ReLU) together as its basic building block. Different from other CNNs, ResNet uses a shortcut to add input data to the output result of a block. If two data inputs have different dimensions at the summation stage, a $1 \times 1$ convolution layer will be introduced in shortcut to match the dimension. The summation result is sent to ReLU and pass to the next Block. At the end of ResNet, pooling layer, one or more Fully Connected (FC) layers, and a softmax layer are used in sequence to generate final classification result. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/ResNet.png} \caption{Basic block diagram of ResNet.} \label{fig_resnet} \end{figure} \subsection{\bf 1T1M crossbar for VMM} Fig.\ref{fig_xbar}(a) shows the general structure of a one-transistor-one-memristor (1T1M) crossbar for vector matrix multiplication (VMM). In this structure, memristor crossbar is the core component as it enables analog current weighted summation, which leads to ultra efficient VMM operation. A $m \times n$ memristor crossbar is made by $m$ row and $n$ column metal wires where memristors formed at intersecting points. Each memristor can be tuned to arbitrary conductance within its programmable range. To enable precise, non-disturbing tuning in large crossbar arrays, 1T1M cell (Fig.\ref{fig_xbar}(b).) is necessary to program the entire array with arbitrary conductance matrix $G$. By applying voltage inputs $V$ at the rows simultaneously and read current outputs $I$ from the columns, analog weighted summation is achieved through Kirchhoff's Current Law and Ohm's Law. In an ideal crossbar, input-output relationship can be represented as below: $$ I = VG $$ By mapping input vector $X$ to input voltage $V$, matrix $A$ to conductance $G$, and output current $I$ back to output result $Y$, a memristor crossbar can be regarded as an analog VMM module to realize $Y=XA$ in one step. Note that $I = VG$ is only valid for ideal crossbar while wire resistance can be ignored and device conductance is independent of voltage/current. In real crossbars, the input-output relationship is far more complex and needs analog circuit simulation. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{images/1T1Mxbar_VMM.png} \caption{1T1M crossbar for VMM operation. (a) shows the overall circuit diagram; (b) shows the 1T1M cell (c) shows the ramping ADC design.} \label{fig_xbar} \end{figure} Fig.\ref{fig_xbar}(c) illustrates a ramping ADC design\cite{delagnes_low_2007}, it uses a shared ramping signal generator and counter to support multiple channels simultaneously. The ramping signal generator produces increasing/decreasing analog voltage signal to all comparators, and its analog value is synchronized with the digital representation in the counter. Comparators compare the crossbar output to the ramping signal. Once a flip is detected, comparator captures the current value in the counter, which is the corresponding digital representation of crossbar output. This concept can be applied to DAC design as well. Overall, The ramping ADC/DAC design can achieve lower area and power for multi-channel applications, and it is a suitable digital interface for crossbar-based accelerators. \subsection{\bf Experiment-Verified Crossbar Simulator and The Conversion Algorithm} So far, simulation tools like MNSIM and NeuroSim provide excellent architecture-level analysis. However, their memristor crossbar models are over simplified. In MNSIM\cite{xia_mnsim:_2016}, an estimated behavior model is used instead of solving node equations; In NeuroSim\cite{chen_neurosim:_2018}, the impact of wire resistance is simplified by adding wire resistance to cross-point devices. All of these over-simplifications result in unignorable error between predicted output to real output of crossbars. And this error become even more severe in large scale implementations. In short, coarse modeling of crossbar may be acceptable on power/area/speed estimations, but is questionable on functionality evaluations, such as computing accuracy at layers, or classification accuracy of NN implementations. After all, to evaluate NN's functionality on memristor-based implementations, an accurate crossbar simulator is necessary. An accurate crossbar simulator should use realistic device models, solve node equations with consideration of wire resistance and other circuit parameters, then finally verified with experiment result at large scales. Here We adapt the experiment-verified memristor crossbar simulator from \cite{hu_memristor-based_2018}. Fig.\ref{fig_1T1Msim} illustrates the simulation result of the memristor crossbar simulator, which is verified with experiment up to $128 \times 64$. Besides the simulator, the conversion algorithm, as a mapping method is employed to improve VMM computing accuracy with consideration of wire resistance and device nonlinearity\cite{hu_dot-product_2016}. The conversion algorithm uses a conversion signal $V_{conv}$ to find a new conductance mapping $G'$, so that $$ VG \approx \mathrm{CrossbarSim}(V, G') $$ where CrossbarSim() is the realistic crossbar model. Although the original conversion algorithm provides 7$\sim$8 bit-accuracy result for general VMM, it does not consider impact of data/weight patterns in specific applications, which may affect its performance significantly. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/1T1Msim.png} \caption{1T1M simulation and experiment result \protect\cite{hu_memristor-based_2018}. Wire segment resistance is calibrated to 1$\Omega$, transistor and memristor models are calibrated with in-array device test.} \label{fig_1T1Msim} \end{figure} \section{\bf Methodology} In this work, we take ResNet-20 as our case study for memristor-based CNN implementation. We first provide a dense mapping method to map high dimension kernels onto 2-D memristor crossbar arrays efficiently. By doing a near full circuit simulation of memristor-based implementation for ResNet-20, we explain how to optimize the conversion signal for each layer based on its corresponding convolution kernel and data pattern. Moreover, we introduce an additional calibration step to further improve the performance and robustness of the circuit. Our memristor-based CNN implementation can give precise convolution result for each layer, and its precision is independent of data sparsity and kernel types. \subsection{\bf Dense mapping for crossbar-based convolution} In ResNet, each convolution layer has a 4-D kernel, as illustrated in Table.\ref{Table_mapping}. For example, the 3*3*3*16 kernel of 'Conv0' means it has 16 sets of 3*3*3 3-D kernels, and each 3-D kernels contains 3 2-D kernels for the 3 channels (RGB) of color images. To perform convolution on memristor crossbar, we need convert high dimensional convolution into 2-D VMM. It is well known that 2D convolution can be implemented using matrix multiplication by converting kernel to a Toeplitz matrix. Topelitz matrices are sparse matrices which contains many zeros, so we named this method as \textit{sparse mapping}. \begin{figure}[t] \centering \includegraphics[width=0.465\textwidth]{images/dense_map.png} \caption{Dense mapping for input data size (j,k,p), where j,k,p means data height, width, and channel, respectively. The circuit needs j*k iterations to process the input data.} \label{Fig_densemap} \end{figure} However, sparse mapping has three major issues: First, memristor crossbar is by nature a dense array structure with positive values, not efficient for sparse matrix implementation. Mapping a sparse matrix to crossbar means that the memristors assigned with zero entries would do nothing but adding error to the final result due to leakage current, as well as waste circuit area. Second, sparse mapping requires a huge crossbar array, which is not always feasible, and vulnerable to noise and defects. third, sparse mapping requires a large peripheral circuit to support the huge array. Since peripheral circuit dominates the total power/area, the hardware implementation of sparse mapping would be too costly to afford. Fig.\ref{Fig_densemap} illustrates the concept of dense mapping. In contrast to sparse mapping, we developed a new method, named as \textit{dense mapping}, targeting on using small and dense representations to implement convolutions on memristor crossbars efficiently. Each 2-D kernel is unrolled to a vector and mapped to the column of crossbar so that one crossbar can implement multiple 2-D kernels as long as it has enough columns. For input signal, only data within the convolution window is converted to the row inputs of crossbar arrays. For data with multiple channels, 2-D kernels for different channels are stacked into the same column, as input from different channels can be supplied to different rows and weighted summed together. An input shift register stores the input data within convolution window at the current iteration, and updates its storage as window moves through the entire data space. The convolution result for data within the convolution window are collected at the column outputs of crossbar. In this way, a single memristor-based convolution kernel needs $j$*$k$ iterations for input data with size ($j$, $k$, $p$) where $j$, $k$, $p$ are data height, width, and channel, respectively. Comparing dense mapping to sparse mapping, it is a trade-off between time multiplexing and space multiplexing. Sparse mapping uses much more extra hardware to produce result without iteration. However, its efficiency exponentially drops as data/kernel scale up, which means, more and more devices in a rectangular crossbar are unused for increasing data/kernel size. Dense mapping is a more adequate and practical method comparing to sparse mapping. It not only achieves 100\% usage of devices, but also easy to implement and provide sufficient performance in speed for CNN applications. From Table \ref{Table_mapping}, one classification in ResNet-20 needs 9089 iterations in sequential, if no parallel copies of hardware are used. Note that summation (sum\#) is in parallel of convolutions so it's not counted in total iterations. Assuming memristor crossbar runs at 100 MHz \cite{hu_dot-product_2016}, for each classification the convolution part takes only 0.09 ms, which is way fast enough for real-time classification requirement. \begin{table}[t] \caption{Dense mapping of ResNet-20 convolution layers for $32 \times 32$ color image classification from cifar-10 dataset} \centering \begin{tabular}{|p{1.8cm}|p{1.8cm}|p{1.5cm}|p{2cm}|} \hline \textbf{Layer name} & \textbf{Kernel size} & \textbf{Crossbar Size} & \textbf{Iteration per. class.}\TBstrut\\ \hline Conv0 & 3*3*3*16 & 27*16 & 1024 \TBstrut\\ \hline Conv1-2 & 3*3*16*16 & 144*16 & 1024 \TBstrut\\ \hline Sum1 & 1*1*16*16 & 16*16 & 1024 \TBstrut\\ \hline Conv3-6 & 3*3*16*16 & 144*16 & 1024 \TBstrut\\ \hline Sum2 & 1*1*16*32 & 16*32 & 256 \TBstrut\\ \hline Conv7 & 3*3*16*32 & 144*32 & 256 \TBstrut\\ \hline Conv8-12 & 3*3*32*32 & 288*32 & 256 \TBstrut\\ \hline Sum3 & 1*1*32*64 & 32*64 & 64 \TBstrut\\ \hline Conv13 & 3*3*32*64 & 288*64 & 64 \TBstrut\\ \hline Conv14-18 & 3*3*64*64 & 576*64 & 64 \TBstrut\\ \hline FC & 1*1*64*10 & 64*10 & 1 \TBstrut\\ \hline \end{tabular} \label{Table_mapping} \end{table} \subsection{\bf Improved conversion algorithm} Algorithm \ref{alg_1} summarizes the flow of crossbar-based convolution with the improved conversion algorithm. Table \ref{Table_functions} explains the important functions in the algorithm. After initialization, if the kernel is already mapped and converted onto crossbars, it will directly jump to the computing step to simulate crossbar-based convolution. So to implement ResNet-20 with multiple convolution layers, we only need to do mapping/conversion once for inferencing. \begin{algorithm} \caption{Crossbar-based convolution with improved conversion algorithm}\label{euclid} \begin{algorithmic}[1] \State Initialization: setup crossbar parameters(wire resistance, memristor conductance range, etc...) \State Get a batch of input data \State If kernel $K$ is mapped and converted, jump to {\bf computing}. \State Dense mapping kernel $K$ to conductance matrix $G$ \State Optimize conversion signal \State $InputVectors \gets \text{Partition input data}$ \State $CaliSample \gets \text{Random pick from } InputVectors$ \State $G' \gets \text{Conversion}(G,V_{conv})$ \State $P \gets \text{GetCaliPara}(G',CaliSample)$ \State Begin \textbf{computing} \While {$\sim$end of $InputVectors$} \State $V_{in}[i] \gets InputVector[i]$ \State $I_{out}[i] = \text{CrossbarSim}(G', V_{in}[i])$ \State $Output[i] = \text{Calibration}(I_{out}[i],InputVector[i],P)$ \State $i \gets i + 1$ \EndWhile \State $\text{Convolution result} \gets \text{reshape}(Output)$ \State End \textbf{computing} \end{algorithmic} \label{alg_1} \end{algorithm} \begin{table}[t] \caption{Explanations for functions in algorithm \ref{alg_1}} \centering \begin{tabular}{|l|p{6.5cm}|} \hline \textbf{Function} & \textbf{Explanation}\TBstrut\\ \hline CrossbarSim & Experiment verified crossbar simulator from \cite{hu_memristor-based_2018}\TBstrut\\ \hline Conversion & Solve $V_{conv} \cdot G = \mathrm{CrossbarSim}(V_{conv}, G')$ to get G'.\TBstrut \\ \hline GetCaliPara & Get 1st order poly fitting result $P$ by fitting crossbar\Tstrut \ output to ideal output of calibration samples.\Bstrut\\ \hline Calibration & Use $P$ and $InputVector[i]$ to map $I_{out}[i]$ to\Tstrut \ $Output[i]$. Here $InputVector[i]$ is needed, because in VMM $Y = XA$, if $A$ contains negative values, $Y$ can be calculated by $Y = X(A + c) - c*\mathrm{sum}(X)$, while c is a large enough scalar to shift $A$ to all positive.\Bstrut\\ \hline \end{tabular} \label{Table_functions} \end{table} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/Sparsity_vs_layer.png} \caption{Input data sparsity at each convolution layer of ResNet-20} \label{fig_data_sparsity} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/kernelType.png} \caption{Three kernel types in CNN with different limitations on weight} \label{fig_kernel_type} \end{figure} \subsubsection{\bf Data and kernel pattern in ResNet} Data in ResNet has high sparsity due to ReLU. Fig. \ref{fig_data_sparsity} shows the data sparsity at each convolution layer of ResNet-20. The impact of data sparsity should be considered when choosing conversion signal as well as gathering calibration samples. similarly, we found that kernels in CNN have different distributions. In Fig.\ref{fig_kernel_type} we list three typical kernel types regarding to their weight value distributions. Usually there are three typical kernel types: Kernel type 1 refers to a weight distribution close to Gaussian, usually it happens when training algorithms put no limitation on weight values, such as ResNet. Kernel type 2 refers to training algorithm that preventing weight values goes near zero\cite{han_deep_2015}. Kernel type 3 refers to Binary Neural Networks where weights can only be -1, 0(sparse), or 1\cite{courbariaux_binarized_2016}. It worth investigating how different kennel types in CNN impact the quality of crossbar-based convolution. \subsubsection{\bf Optimize conversion signal} To better quantize the computing accuracy, we define relative error as below: $$ \mathrm{Relative~Error} = \mathrm{Absolute~Error}/\mathrm{Output~Range} $$ While Absolute Error is the absolute error of crossbar output, and Output Range is the ideal convolution output range for each kernel. Relative error can be converted to output bit accuracy as below: $$ \mathrm{Bit~Accuracy} = log_2(1/\mathrm{Relative~Error} + 1) $$ The original conversion algorithm takes the maximum input vector as its conversion signal, which works well with dense matrix and dense input signals. However in CNN, we need to consider the sparsity of data to optimize the conversion signal. By testing various different conversion signals across different kernels, we notice that the amplitude of conversion signal is critical, while the sparsity of conversion signal is not as important. Fig.\ref{fig_diffamp} shows the relative error distribution with different conversion signal amplitudes in crossbar with size $144 \times 16$. We found that a conversion signal with too large amplitude (all 1) will cause over compensation in the signal loss due to wire resistance, and a too small conversion signal (all 0.001) do have enough compensation and both of them result in large error in output. So for crossbar size $144 \times 16$, all 0.1 signal appears to be the best conversion signal, and other conversion signal close to it generate similar error distribution. \subsubsection{\bf Calibration} In addition to original conversion algorithm, we add a calibration stage to further improve the result. It randomly picks 10 samples from the input data set, and runs a 1st order polynomial fit to fit crossbar output to ideal output. The generated fitting vector $P$ is fixed per crossbar, and can be easily embedded in ADC/DAC configurations. Fig.\ref{fig_diff_signal_type} shows the relative error with different calibration signals, and here using shuffled input can achieve the best result. \section{\bf Result} \subsection{\bf Simulation setup} In our work, convolution and fully-connected (FC)layers are implemented by analog memristor crossbars with digital interface. Other functions, such as pooling, ReLU, batch normalization, etc., are processed by digital circuits. The CNN is offline-trained, then its kernels are converted to the conductance of memristors for inference. Our crossbar simulator is configured as below: Lowest memristor resistance $R_{on}$ = 15k$\Omega$, Highest memristor resistance $R_{off}$ = 300k$\Omega$, wire resistance per segment is set to 1$\Omega$, sensing voltage = 0.2V. Input/Output resistance of crossbar are set to 1$\Omega$. Input voltage range is [0, 0.2V]. The crossbar simulation tool is adapted from \cite{hu_memristor-based_2018}. \subsection{\bf Individual convolution layer simulation} We first run circuit simulation at individual convolution layers to understand the impact of input data sparsity, kernel type and size on convolution accuracy. Fig.\ref{fig_288x32} illustrate the impact of input data sparsity. There are three observations: first, our method provides $\sim$50\% better overall accuracy than the original conversion algorithm. Second, our method gives lower relative error when ideal value is small. Third, our method minimizes the impact of data sparsity comparing to original conversion algorithm. Fig.\ref{fig_kernel type} summarizes the mean/worst relative error across three types of kernels with different input sparsity and crossbar sizes. It shows that our method is independent of kernel type and data sparsity. \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/conversion_2.png} \caption{Relative error with different conversion signal amplitudes on crossbar(size: $144 \times 16$), (a),(b),(c),(d) are conversion signals with all 1, 0.1, 0.01, 0.001 respectively.} \label{fig_diffamp} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{images/cali_relative_2.png} \caption{Calibration with different signal types on crossbar(size: $288 \times 32$), (a):Non-calibration, (b):random calibration signal, (c):random but decreased value(rand/cali\_iters),(d):chosen from shuffled input.} \label{fig_diff_signal_type} \end{figure} \begin{figure}[tp] \centering \includegraphics[width=0.5\textwidth]{images/288_4.png} \caption{Relative error of $288 \times 32$ crossbar. (a),(b): improved conversion algorithm, (c),(d): original conversion algorithm} \label{fig_288x32} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/different_kernel_type.png} \caption{Mean/Worst relative error with different kernel types, data sparsities and crossbar sizes} \label{fig_kernel type} \end{figure} \subsection{\bf End-to-end simulation for ResNet} It is more important to predict how errors propagate and accumulate in deep neural networks, and evaluate its impact on the final classification result. Fig.\ref{fig_layer_error} shows the error propagation at each convolution layer in ResNet-20. Fig.\ref{fig_ResNet_result} shows the classification result. Different ADC/DAC quantization settings are applied and we can see that 8-bit quantization is necessary to prevent error accumulation. Without quantization, the error will propagate from beginning to the end and affect the classification result, which is also not practical for large-scale implementation. Due to long simulation time (15mins/image), we used a subset of cifar-10 containing 150 testing images. It appears that 8-bit quantization is a good balance between error suppression and information preservation, as it achieves even slightly better classification result than software. 6-bit or 4-bit quantization cause error accumulate through all layers and lead to a significant drop in classification accuracy. With 6-bit, error rate increased by 73\% from 10\% to 17.3\% , and 4-bit increases the error rate by a factor of 8 from 11.3\% to 88.7\%. \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/layer_compa.png} \caption{Error propagation along layers in ResNet-20, solid lines represent mean error, dash lines represent worst error.} \label{fig_layer_error} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{images/quantization.png} \caption{ResNet-20 result with different quantization settings} \label{fig_ResNet_result} \end{figure} \section{\bf Conclusions} In this work, We take ResNet as case study to investigate how modern CNN performs on memristor-based implementations. Our methods includes an dense mapping and an improved conversion algorithm, which can achieve 0.25\% mean relative error ($\sim$ 8.6 bits) or 1.2\% worst relative error ($\sim$ 6.4 bits) for crossbar size $576 \times 64$. We performed a rigorous analog simulation for every convolution layers to give an accurate prediction of error propagation in ResNet. We find that 8-bit ADC/DAC is necessary to prevent classification degradation. Our method can be applied to general CNNs due to its independence of input data sparsity and kernel types. \bibliographystyle{IEEE}
{'timestamp': '2018-10-05T02:12:02', 'yymm': '1810', 'arxiv_id': '1810.02225', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02225'}
arxiv
\section{Discussion Points} \section{Conclusion} \label{sec:conc} In this paper, the problem of response and recovery of successful intrusion attacks on a DBMS is addressed. We propose PIMS, a data partitioning-based intrusion management system for DBMSs, that can endure intense malicious intrusion attacks. A new fine-grained dependency model that captures the intra-transaction and inter-transaction dependencies is introduced. We introduce a data partitioning scheme, termed IBs, with the objective to limit the extent of the damage into partitions. We formulate the IB demarcation problem as a cost-driven optimization problem and prove that IBDP is NP-hard, and propose efficient heuristic solutions. We present the architecture of PIMS and conduct various experiments to evaluate its performance. We show that although PIMS incurs response time overhead, the reduction in the number of affected transactions and the recovery time is up to 48\% and 52\%, respectively. \bibliographystyle{unsrt} \ifCLASSOPTIONcompsoc \section*{Acknowledgment} This work is supported by Northrop Grumman. \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran} \section{Background} \label{sec:bg} In this section, we present the database and transaction model and explain the threat model. In addition, we present an overview of the state-of-the-art malicious transaction recovery mechanisms in DBMSs. \begin{figure}[!t] \centering \subfigure[Transaction history $H_1$]{\label{fig:h1} \includegraphics[width=\columnwidth]{./figures/history.pdf}} \\ \subfigure[Precedence graph]{\label{fig:tdg}\includegraphics[width=0.3\columnwidth]{./figures/tsg.pdf}} \hskip 0.5truein \caption{Transaction history and PG.} \label{fig:hist} \vspace{-3 mm} \end{figure} \subsection{Database and Transaction Model } \label{sec:dtmodel} A database is a set of $n$ tuples denoted by $D = \{o_1,o_2,\ldots,o_n\}$, where $o_i$ refers to a tuple. A transaction $t_i$ is a partially ordered set of operations, with a partial ordering relation $<_i$ \cite{bernstein1987concurrency}. The read and write (update) operations on a tuple, say $o \in D$, of $t_i$ are denoted by $r_{i}[o]$ and $w_{i}[o]$, respectively. The set of tuples that are read and updated by a transaction $t_i$ are denoted by $R_{i}$ and $W_{i}$, respectively. Formally, $t_i$ is defined as follows \cite{bernstein1987concurrency}: \begin{enumerate} \item $t_i \subseteq \{ w_i [o],r_i [o] | o \in D\} \cup \{a_i,c_i\}$ \item if $w_i[o], r_i[o] \in t_i,$ then either $w_i[o] <_i r_i[o] $ or $r_i[o] <_i w_i[o]$ \item $a_i \in t_i$ if and only if $c_i \notin t_i$, and \item for any operation $p \in t_i$, $p <_i t$ where $t$ is either $a_i$ or $c_i$ (whichever in $t_i$) \end{enumerate} where $a_i$ and $c_i$ denote the \textit{abort} and \textit{commit} operations of $t_i$, respectively. In essence, Condition (1) defines the types of operations in $t_i$. Condition (2) requires that the order of execution of Read and Write operations on a data item is specified by $<_i$. Condition (3) says that $t_i$ either commits or aborts, while Condition (4) specifies that \textit{commit} (or \textit{abort}) must follow all other operations. For a set of $m$ transactions $T = \{t_1,t_2,...,t_m \}$, a complete history $H$ over $T$ is a partial order with the ordering relation $<_H$, where $H = \cup_{i=1}^m t_i$ and $<_H \supseteq \cup_{i=1}^m <_i$. In other words, the execution history represented by $H$ involves all transactions in $T$ and matches all operation orderings that are specified within each transaction. Two transactions $t_i$ and $t_j$ in $H$ are \textit{dependent} if (i) $t_i$ is directly followed by $t_j$, i.e., $t_i <_H t_j$, and (ii) $W_{t_i} \cap R_{t_j} \neq \emptyset$. The dependency between $t_i$ and $t_j$ is read "$t_j$ depends on $t_i$". In general, $t_j$ depends on $t_i$ if (i) $t_i <_H t_{k_1} <_H \ldots <_H t_{k_n} <_H t_j$, and (ii) $(W_{t_i} - \cup_{l=1,..,n} W_{t_{k_l}}) \cap R_{t_j} \neq \emptyset$. The dependencies among $T$ in the history $H$ is modeled using the transaction Precedence Graph (PG) \cite{bernstein1987concurrency}. PG is a directed graph $PG=\{ V,E\}$, where $V$ is a set of nodes; each node representing a committed transaction in $H$, and $E$ is a set of edges; each edge representing a dependency between two transactions. In other words, an edge between two transactions $t_i$ and $t_j$ exists if $t_j$ depends on $t_i$. Fig. \ref{fig:h1} illustrates a History $H_1$ over $T = \{ t_1,t_2,t_3,t_4\}$. $H_1$'s corresponding PG is in Fig. \ref{fig:tdg}. $t_2$ depends on $t_1$ because $t_1$ updates $o_2$ that is later read by $t_2$. Similarly, $t_3$ depends on $t_1$ and $t_4$ depends on $t_3$. \subsection{Threat Model} In this paper, our focus is on the data corruption caused by transaction-level attacks in the DBMS. These attacks can be manifested either through masquerade access or by exploiting application vulnerabilities, e.g., SQL injection, Cross Site Scripting (XSS), and Cross-Site Request Forgery (CSRF) \cite{srinivasan2017web}. A transaction, say $t_m$, is \textbf{malicious} if it tampers the database by updating one or more tuples with incorrect data. In this context, a malicious transaction corrupts the data due to either an attack or through a user fault. A transaction, say $t_a$, is \textbf{affected} if $t_a$ directly (or indirectly) depends on a malicious or an affected transaction, i.e., $W_{t_m} \cap R_{t_a} \neq \emptyset$ (or $W_{t_j} \cap R_{t_a} \neq \emptyset$ such that $W_{t_m} \cap R_{t_j} \neq \emptyset \forall t_j \in T$). All malicious and affected transactions are invalid transactions. The execution of an invalid transaction takes the DBMS into an invalid state. For example, assume that Transaction $t_1$ in Fig. \ref{fig:tdg} is malicious. Then, both $t_2$ and $t_3$ are affected transactions. We assume that a malicious transaction does not depend on other transactions, i.e., a malicious transaction cannot be an affected transaction. Furthermore, we assume that we can undo the effects of committed transactions. Throughout the rest of the paper, we deal with integrity attacks in which either an authorized or non-authorized user intentionally tampers with the data by injecting wrong values into some tuples. This attack can temporarily impair the availability of the DBMS during the recovery period. We rely on the existence of an IDS to detect the malicious transactions \cite{shebaro2013postgresql}. Note that the IDS alarm is received after the malicious transactions commit. We assume that the presence of an access control policy is sufficient to prevent any confidentiality attacks. Moreover, we assume that there are security countermeasures to prevent other availability attacks, e.g., Denial-of-Service (DoS) \cite{bertino2005database}. \subsection{Recovery from Malicious Transactions} Handling the recovery of malicious transactions requires \textit{undoing} the committed malicious and affected transactions. There are two common approaches to undo committed transactions: \textit{rollback} and \textit{compensation}. The rollback approach is to roll back all the operations performed by the committed transaction to a point that is free of damage \cite{mohan1992efficient}. On the other hand, the compensation approach seeks to selectively undo committed transactions without rolling back the state of the DBMS into a previous state \cite{korth1990formal}. PIMS is relevant to the work in \cite{liu2004design,ammann2002recovery}, in which a real-time approach tracks the inter-transaction dependency, marks the affected transactions, and repairs the damage. The recovery is perfromed in two stages: damage assessment and damage repair. In the damage assessment stage, the complete and correct set of affected transactions is identified. This stage is challenging because the assessment is conducted on-the-fly while the system is processed other concurrent transactions. Due to transaction dependency, the damage might spread. Therefore, the damage assessment is terminated whenever there are no more transactions that cause spread of the damage. Once the damage assessment stage is completed, all the identified affected transaction are repaired by rolling them back without affecting the other transactions in the system. PIMS's recovery approach is different than \cite{liu2004design,ammann2002recovery} in a sense that PIMS aggressively terminates the damage spread by stopping the execution of the concurrent transactions momentarily during the damage assessment process. Moreover, PIMS adopts data partitioning scheme that provides a proactive damage confinement mechanism by designating a group of tuples to prevent the spread of the damage into the entire database. \section{The Architecture of PIMS} \label{sec:IMS} In this section, we introduce the architecture of PIMS. The proposed architecture for PIMS is given in Fig. \ref{fig:ims_arch}. PIMS is composed of five components: the IBDP solver, the transactions log, the Admission Controller (AC), the Response Subsystem (RES), and the Recovery Subsystem (REC). In addition, PIMS maintains a Corrupted Tuples Table (CTT) to track the status of the damage caused by the malicious transactions. The IBDP solver generates the IB assignment as discussed in the previous section. The transactions log stores information about the read/write operations of transactions. The log is essential for the recovery procedure to construct compensating transactions. The functionality of AC includes parsing the transactions, regulating the admission of transactions to DBMS, and maintaining the IB assignment table. AC determines whether to block or allow incoming transactions depending on the status of the damage and the assigned IB. When a committed transaction is identified as malicious, RES extracts the commit and detection times of the malicious transaction, approximates the set of corrupted tuples immediately, and stores it in CTT. Although the approximated set can include uncorrupted tuples, the objective is to reduce the risk of executing benign transactions that might propagate the damage unwillingly. Then, REC analyzes the inter-transaction dependency in transactions log and identifies the \textit{correct} and \textit{complete} set of affected transactions. The correct set of affected transactions means that no transactions are falsely identified as affected, while the complete set means that the set contains every affected transactions caused by the attack. We refer to this set as the set of \textbf{Affected Transactions} (AT). When AT is identified, the benign tuples are removed from CTT, and consequently can be accessed by the requesting transactions immediately. On the other hand, the corrupted tuples are blocked and will be recovered by the compensating transactions. The recovered tuples are removed from CTT gradually in order to increase the system availability. In the following sections, we present detailed information about the functionality of each component. \label{sec:ims} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth,height=5cm]{./figures/arch.pdf} \caption{PIMS Architecture.} \label{fig:ims_arch} \vspace{-3 mm} \end{figure} \subsection{Transactions Log} In order to obtain accurate information about the extent of the damage caused by the malicious transaction, the read/write operations of all transactions need to be logged. However, conventional undo/redo logs and DBMS triggers only record write operations. To address this issue, we have implemented a read/write log that records the transaction ID, the tuple ID, the before-image (the previous value), the after-image (the current value), and the time-stamp for each read and update operation. The transactions log is implemented in the DBMS kernel to reduce the overhead of logging. The transactions log is maintained as a table in the DBMS for efficient retrieval by PIMS. The transactions log is used by AC to check if a transaction reads from corrupted tuples, and by RES to identify AT. \subsection{The Admission Controller (AC)} AC has three subcomponents: the Parser, the IB Manager (IBM), and the Transaction Mediator (TM). The parser extracts the read/write set from transactions. IBM maintains in the IB table information about the IBs including the set of boundary tuples and the transaction-to-IB assignment. The functionality of IBM is to manage the access to the boundary tuples. In essence, the updated boundary tuples are locked by IBM until IDS reports the status of the updating transaction. If the transaction is identified as malicious, then the locked boundary tuples are added to CTT. Otherwise, the locked boundary tuples are released. One problem is that IDS only triggers an alarm when a malicious transaction is detected. We assume that IDS has a detection delay of $\Delta$ $ms$. The boundary tuples are locked for a sufficient time after which the updating transaction can never be detected as malicious. We set PIMS to wait for 1.5 $\times \Delta$ ms before releasing the boundary tuples. The objective of locking the boundary tuples after update is to assure that the damage does not propagate to other IBs. We refer to the process of locking the boundary tuples as \textit{delayed access} mechanism. TM checks if the transaction's read/write set contains any tuple that exists in CTT or BT. If a tuple in the read set exists in CTT, the transaction is suspended. On the other hand, if a tuple in the write set exists in CTT, then the transaction is executed, and the tuples are removed from CTT and are excluded from subsequent undo and redo operations. AC is signaled on two events: 1) the corrupted tuples are recovered, or 2) the recovery procedure is completed. When signaled, TM executes the suspended transaction if its read tuples are all recovered. Otherwise, the transaction remains suspended until a new signal is received from RES or REC. If the transaction's read/write set contains a tuple that exists in BT, then the transaction is suspended until the tuples are released by IBM. Before executing the transaction, AC acquires the locks associated with the assigned IB(s). The lock is to ensure that no concurrent recovery procedure is running on the IB(s). The lock is released by AC when the transaction is executed successfully. The overall procedure for admission control is listed in Algorithm \ref{alg:adm}. Notice that multiple instances of the admission controller can be executed using multiple threads to increase transaction concurrency. We rely on the available Concurrency APIs to queue the incoming transactions when TM threads are busy waiting for signals. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_i$} \KwOut{} $RW_{t_i} \leftarrow$ the read/write tuples set $t_i$\\ \While{$RW_{t_i} \cap BT \neq \emptyset$}{ Wait until the requested $BT$ is released\\ } \While{$ RW_{t_i} \cap CTT \neq \emptyset$ }{ Wait until request tuples in CTT are recovered and released\\ } \tcc{Wait until lock is acquired} Acquire lock on $IB_{t_i}$ \\ Execute $t_i$\\ Release lock on $IB_{t_i}$\\ \caption{Admission control} \label{alg:adm} \end{algorithm} \subsection{The Response Subsystem (RES)} RES is activated when a transaction $t_m$ is detected as malicious by IDS. The objective of RES is to prevent subsequent benign transactions from reading corrupted tuples that are updated by $t_m$, and thus control the spread of the damage. RES collects the time information about $t_m$ from IDS and the transactions log, i.e., the commit timestamp $t_m^c$ and the detection timestamp $t_m^d$. Moreover, RES extracts $IB_{t_{m}}$, the set of IBs that are spanned by $t_m$, from the IB table. Consequently, RES adds all tuples in $IB_{t_m}$ that have been updated between $t_m^c$ and $t_m^d$ to CTT. Notice that the tuples that are updated between $t_m^c$ and $t_m^d$ but not assigned to $IB_{t_m}$ are not added to CTT. Thus, PIMS provides more accurate damage confinement as compared to ITDB, which blocks all tuples on temporal basis only. Nevertheless, CTT might contain uncorrupted tuples updated by benign transactions that are independent from $t_m$. Once enough information about the inter-transaction dependencies between $t_m$ and subsequent transactions is gathered, PIMS removes the uncorrupted tuples from CTT as explained in the next section. The procedure of RES is summarized in Algorithm \ref{alg:res}. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_m, t_m^d$} \KwOut{Updated $CTT$} $t_m^c$ $\leftarrow$ get commit time of $t_m$\\ Find $IB_{t_m}$ the set of IBs spanned by $t_m$\\ \For{tuples updated between $t_m^c$ and $t_m^d$}{ \If{tuple is assigned to an $IB \in IB_{t_m}$}{ Add tuple to $CTT$ } } \caption{Intrusion Response} \label{alg:res} \end{algorithm} \subsection{The Recovery Subsystem (REC)} \label{sec:RES} REC is the core component of PIMS that identifies AT and executes compensating transactions for the corrupted tuples. The compensating transactions perform two operations: \textit{undo} and \textit{redo}. The undo operation unwinds the effect of the malicious transaction and each transaction in AT. By performing the undo operation, the state of the DBMS returns to the state just before the malicious transaction is executed. However, the update operations performed by the subsequent benign transactions are lost. The redo operation preserves the lost updates by re-executing each transaction in AT. Notice that the malicious transaction is not re-executed because its updates are undesirable. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_m, IB_{t_m}$} \KwOut{Updated CTT} Acquire recovery lock in every $IB \in IB_{t_m}$\\ Block new transactions in $IB_{t_m}$\\ Wait for currently running transaction in $IB_{t_m}$ to commit\\ Find the set of affected transaction $AT_{t_m}$ \\ Find the $S$ set of all updated tuples by $t_m$ and $t_a \in AT$\\ Resume new transaction in $IB_{t_m}$\\ \For{$o \in CTT$}{ \If{$o \notin S$}{ Remove $o$ from CTT and flag as valid } } Resume transactions to $IB_{t_m}$\\ \tcc{ Phase \RNum{1}} Undo $t_m$\\ \For{$T_a \in AT_{t_m}$}{ Undo $T_a$ \\ } \tcc{ Phase \RNum{2} } \For{$T_a \in AT_{t_m}$}{ Redo $T_a$ \\ } \caption{Intrusion Recovery} \label{alg:rec} \end{algorithm} The overall algorithm for REC is listed in Algorithm \ref{alg:rec}. REC is activated once the response procedure is finished. Thus, the response and recovery transactions are executed serially. Serializing the response and recovery procedures is essential since the recovery mechanism uses CTT that is updated by the response subsystem. REC temporarily blocks new transactions to prevent new transactions from reading the corrupted tuples while REC identifies AT. This is achieved by acquiring locks on $IB_{t_{m}}$. Incoming transactions are blocked by AC. Notice that the active transactions are not preempted. When all active transactions are committed, the \textit{Dependency Analyzer} scans the transactions log starting from $t_m^c$ through the current timestamp in order to find AT. The write set of each transaction in AT is extracted and is added to CTT. The \textit{Damage Assessment} subsystem removes the uncorrupted tuples that have been initially added by RES from CTT. At this point, CTT contains the correct and complete set of the corrupted tuples caused by $t_m$. The \textit{Compensation Manager} (CM) executes a sequence of compensating transactions that gradually repair the damage. Damage repair is performed in two phases. In Phase 1, CM executes compensating transactions that unwind the effect of the malicious and affected transactions. CM uses the transactions log table to find the correct version of the corrupted tuples. In particular, CM updates the corrupted tuples with the values of the most recent versions before the execution of the malicious transaction. The compensating transactions are executed in the order at which the malicious and affected transactions are committed. At the end of this phase, \textit{Damage Cleansing} (DC) removes the recovered tuples from CTT and signals AC to resume any blocked transactions. In the second phase, CM executes compensating transactions that re-execute each transaction in AT in the same order at which they are committed. The information required to re-execute the transactions, e.g., old balance, is maintained in the transactions log. Once an affected transaction is re-executed successfully, DC removes the set of recovered tuples from CTT and signals AC. \subsection{Managing Multiple Malicious Transactions} The advantage of partitioning the tuples into IBs is to execute concurrent response and recovery procedures on different IBs. The reason is that all transactions in AT are guaranteed to be contained in $IB_{t_m}$. As a result, concurrent recovery procedures do not perform conflicting operations while recovering the corrupted tuples. Multiple instances of response and recovery procedures are executed using multiple threads. In the case when multiple malicious transactions are detected within the same IB, the recovery procedures need to be coordinated to avoid out-of-order execution of the recovery operations. The strategy is to execute the recovery procedures for the malicious transactions in the same order in which they are detected. \section{Background} \label{sec:bg} In this section, we present the database and transaction model and explain the threat model. In addition, we present an overview of the state-of-the-art malicious transaction recovery mechanisms in DBMSs. \begin{figure}[!t] \centering \subfigure[Transaction history $H_1$]{\label{fig:h1} \includegraphics[width=\columnwidth]{./figures/history.pdf}} \\ \subfigure[Precedence graph]{\label{fig:tdg}\includegraphics[width=0.3\columnwidth]{./figures/tsg.pdf}} \hskip 0.5truein \caption{Transaction history and PG.} \label{fig:hist} \vspace{-3 mm} \end{figure} \subsection{Database and Transaction Model } \label{sec:dtmodel} A database is a set of $n$ tuples denoted by $D = \{o_1,o_2,\ldots,o_n\}$, where $o_i$ refers to a tuple. A transaction $t_i$ is a partially ordered set of operations, with a partial ordering relation $<_i$ \cite{bernstein1987concurrency}. The read and write (update) operations on a tuple, say $o \in D$, of $t_i$ are denoted by $r_{i}[o]$ and $w_{i}[o]$, respectively. The set of tuples that are read and updated by a transaction $t_i$ are denoted by $R_{i}$ and $W_{i}$, respectively. Formally, $t_i$ is defined as follows \cite{bernstein1987concurrency}: \begin{enumerate} \item $t_i \subseteq \{ w_i [o],r_i [o] | o \in D\} \cup \{a_i,c_i\}$ \item if $w_i[o], r_i[o] \in t_i,$ then either $w_i[o] <_i r_i[o] $ or $r_i[o] <_i w_i[o]$ \item $a_i \in t_i$ if and only if $c_i \notin t_i$, and \item for any operation $p \in t_i$, $p <_i t$ where $t$ is either $a_i$ or $c_i$ (whichever in $t_i$) \end{enumerate} where $a_i$ and $c_i$ denote the \textit{abort} and \textit{commit} operations of $t_i$, respectively. In essence, Condition (1) defines the types of operations in $t_i$. Condition (2) requires that the order of execution of Read and Write operations on a data item is specified by $<_i$. Condition (3) says that $t_i$ either commits or aborts, while Condition (4) specifies that \textit{commit} (or \textit{abort}) must follow all other operations. For a set of $m$ transactions $T = \{t_1,t_2,...,t_m \}$, a complete history $H$ over $T$ is a partial order with the ordering relation $<_H$, where $H = \cup_{i=1}^m t_i$ and $<_H \supseteq \cup_{i=1}^m <_i$. In other words, the execution history represented by $H$ involves all transactions in $T$ and matches all operation orderings that are specified within each transaction. Two transactions $t_i$ and $t_j$ in $H$ are \textit{dependent} if (i) $t_i$ is directly followed by $t_j$, i.e., $t_i <_H t_j$, and (ii) $W_{t_i} \cap R_{t_j} \neq \emptyset$. The dependency between $t_i$ and $t_j$ is read "$t_j$ depends on $t_i$". In general, $t_j$ depends on $t_i$ if (i) $t_i <_H t_{k_1} <_H \ldots <_H t_{k_n} <_H t_j$, and (ii) $(W_{t_i} - \cup_{l=1,..,n} W_{t_{k_l}}) \cap R_{t_j} \neq \emptyset$. The dependencies among $T$ in the history $H$ is modeled using the transaction Precedence Graph (PG) \cite{bernstein1987concurrency}. PG is a directed graph $PG=\{ V,E\}$, where $V$ is a set of nodes; each node representing a committed transaction in $H$, and $E$ is a set of edges; each edge representing a dependency between two transactions. In other words, an edge between two transactions $t_i$ and $t_j$ exists if $t_j$ depends on $t_i$. Fig. \ref{fig:h1} illustrates a History $H_1$ over $T = \{ t_1,t_2,t_3,t_4\}$. $H_1$'s corresponding PG is in Fig. \ref{fig:tdg}. $t_2$ depends on $t_1$ because $t_1$ updates $o_2$ that is later read by $t_2$. Similarly, $t_3$ depends on $t_1$ and $t_4$ depends on $t_3$. \subsection{Threat Model} In this paper, our focus is on the data corruption caused by transaction-level attacks in the DBMS. These attacks can be manifested either through masquerade access or by exploiting application vulnerabilities, e.g., SQL injection, Cross Site Scripting (XSS), and Cross-Site Request Forgery (CSRF) \cite{srinivasan2017web}. A transaction, say $t_m$, is \textbf{malicious} if it tampers the database by updating one or more tuples with incorrect data. In this context, a malicious transaction corrupts the data due to either an attack or through a user fault. A transaction, say $t_a$, is \textbf{affected} if $t_a$ directly (or indirectly) depends on a malicious or an affected transaction, i.e., $W_{t_m} \cap R_{t_a} \neq \emptyset$ (or $W_{t_j} \cap R_{t_a} \neq \emptyset$ such that $W_{t_m} \cap R_{t_j} \neq \emptyset \forall t_j \in T$). All malicious and affected transactions are invalid transactions. The execution of an invalid transaction takes the DBMS into an invalid state. For example, assume that Transaction $t_1$ in Fig. \ref{fig:tdg} is malicious. Then, both $t_2$ and $t_3$ are affected transactions. We assume that a malicious transaction does not depend on other transactions, i.e., a malicious transaction cannot be an affected transaction. Furthermore, we assume that we can undo the effects of committed transactions. Throughout the rest of the paper, we deal with integrity attacks in which either an authorized or non-authorized user intentionally tampers with the data by injecting wrong values into some tuples. This attack can temporarily impair the availability of the DBMS during the recovery period. We rely on the existence of an IDS to detect the malicious transactions \cite{shebaro2013postgresql}. Note that the IDS alarm is received after the malicious transactions commit. We assume that the presence of an access control policy is sufficient to prevent any confidentiality attacks. Moreover, we assume that there are security countermeasures to prevent other availability attacks, e.g., Denial-of-Service (DoS) \cite{bertino2005database}. \subsection{Recovery from Malicious Transactions} Handling the recovery of malicious transactions requires \textit{undoing} the committed malicious and affected transactions. There are two common approaches to undo committed transactions: \textit{rollback} and \textit{compensation}. The rollback approach is to roll back all the operations performed by the committed transaction to a point that is free of damage \cite{mohan1992efficient}. On the other hand, the compensation approach seeks to selectively undo committed transactions without rolling back the state of the DBMS into a previous state \cite{korth1990formal}. PIMS is relevant to the work in \cite{liu2004design,ammann2002recovery}, in which a real-time approach tracks the inter-transaction dependency, marks the affected transactions, and repairs the damage. The recovery is perfromed in two stages: damage assessment and damage repair. In the damage assessment stage, the complete and correct set of affected transactions is identified. This stage is challenging because the assessment is conducted on-the-fly while the system is processed other concurrent transactions. Due to transaction dependency, the damage might spread. Therefore, the damage assessment is terminated whenever there are no more transactions that cause spread of the damage. Once the damage assessment stage is completed, all the identified affected transaction are repaired by rolling them back without affecting the other transactions in the system. PIMS's recovery approach is different than \cite{liu2004design,ammann2002recovery} in a sense that PIMS aggressively terminates the damage spread by stopping the execution of the concurrent transactions momentarily during the damage assessment process. Moreover, PIMS adopts data partitioning scheme that provides a proactive damage confinement mechanism by designating a group of tuples to prevent the spread of the damage into the entire database. \section{Introduction} Data-intensive applications exhibit increasing reliance on efficient and scalable Database Management Systems (DBMSs). Examples of these applications are abound in the domain of banking, manufacturing, health care, and enterprise applications \cite{chen2014data}. Since data is the most valuable asset in organizations, it is crucial to design attack-resilient DBMSs to protect the confidentiality, integrity, and availability of the data in the presence of Cyber attacks \cite{stoneburner2002sp,bertino2005database}. Although research in database security has made significant progress in protecting from Cyber attacks, applications and infrastructures are still exposed to a large number of vulnerabilities. Even a single intrusion can cause catastrophic cascading effects due to data dependency and application interoperability. Therefore, a holistic approach for designing an intrusion management mechanism that includes intrusion detection, response, and recovery is needed \cite{kamra2011design,ammann2002recovery}. An Intrusion Detection System (IDS) is integrated with the DBMS to prevent Cyber attacks. The objective of an IDS is to monitor and detect illegal access and malicious actions that take place in the database. However, an IDS is not designed to repair the damages caused by successful attacks. IDS is often integrated with intrusion response and recovery mechanisms to alleviate the damage caused by the malicious attacks \cite{kamra2011design}. Several efforts have been directed towards developing dynamic damage tracking approach to perform on-the-fly damage repair, for example intrusion-tolerant database systems \cite{liu2004design,ammann2002recovery}. However, such systems have limitations in the ability to maintain high availability under severe intrusion attacks. One of the limitations for these systems is the prolonged recovery time due inter-transaction dependency. {\bf{Motivating Example:}} \textit{Fig. \ref{fig:motsc} gives an example scenario for a Banking system with three benign users (B,C, and D), and a malevolent user (A). User A executes a malicious transaction that updates accounts $X$ and $Y$ with incorrect amounts of money as illustrated in Fig. \ref{fig:motsc}. Then, Users B and C withdraw from accounts $X$ and $Y$, respectively. IDS detects the malicious transaction executed by User A and triggers an alert to the database security administrator that temporarily blocks the incoming transactions and starts the recovery procedure. Meanwhile, User D attempts to access account $Z$. However, this request is denied until the damage is recovered. When the recovery transaction is finished, the accounts of Users A and B are compensated, i.e., withdraws money from account $X$ and credits account $Y$.} In the above example, the recovery time depends on the number of dependent transactions that are executed before the IDS detects the malicious transaction. Consequently, the availability of the DBMS is impaired when the recovery procedure takes a long duration. Therefore, it is important to contain the damage once malicious transactions are detected. Containment of the damage can be achieved by tracking the inter-transaction dependencies and devising a fast confinement strategy to contain the damage. In this paper, we propose a new real-time response and recovery architecture, termed Partition-based Intrusion Management System (PIMS), for DBMSs. We assume that existing IDS, e.g., \cite{kamra2011design,shebaro2013postgresql}, can be integrated with PIMS. PIMS is based on an adaptive access and admission control mechanism that responds to intrusions by selectively blocking segments of data that have been affected by the intrusion. The access control mechanism provides a fine-grained control policy to allow graceful degradation of database services in order to maintain a desired level of availability while the system is undergoing through impending attacks. The unique feature of PIMS is the deployment of a data partitioning technique to confine the damage and improve the availability of the system. The contribution of this paper is summarized as follows. First, we propose the concept of Intrusion Boundary (IB) that defines the extent of the damage over the set of transactional workload. We formulate the IB demarcation as an optimization problem as a Mixed Integer Non-Linear Programming model (MINLP). The output of the optimization problem is a balanced IB assignment of transactions to partitions with minimum overlapping. We prove that the IB demarcation problem is NP-hard. Accordingly, we introduce two heuristics to provide a polynomial time solution. Finally, we introduce response and recovery mechanisms that use the proposed IB assignment to improve the intrusion response and recovery in terms of availability and response time. The rest of the paper is organized as follows. Section \ref{sec:bg} presents relevant background. Section \ref{sec:ibf} presents the definition and formulation of the IB demarcation problem, its hardness proof, and present two new heuristics. Section \ref{sec:IMS} describes the design and implementation of PIMS. The performance evaluation and the experimental results of PIMS are presented in Section \ref{sec:exp}. The related work is presented in Section \ref{sec:related}. Finally, Section \ref{sec:conc} concludes the paper. \begin{figure}[t!] \centering \includegraphics[width=\columnwidth,scale=0.5]{./figures/motsc.pdf} \caption{Motivating example.} \label{fig:motsc} \vspace{-3 mm} \end{figure} \section{Related Work} \label{sec:related} Security measures in DBMSs includes the protection of data confidentiality, integrity, and availability \cite{nist2002risk,bertino2005database}. A broad span of research addresses the protection of data confidentiality in DBMSs including authorization, e.g., \cite{chaudhuri2007fine}, access control, e.g., \cite{sandhu1996role}, encryption, e.g., \cite{sarfraz2015dbmask}, and inference and disclosure control, e.g., \cite{chen2008protection}. The integrity risk data in DBMSs is jointly prevented by using access control mechanisms and semantic integrity constraints to verify the correctness of the database state after updates\cite{bertino2005database}. The availability of data is protected by providing fault-tolerance \cite{fault-tolerancegashi}, replication \cite{patino2005middle}, and intrusion detection techniques \cite{milenkoski2015evaluating}. In the case of successful intrusion attacks, the effects of the committed transactions are undesirable. The methodology of undoing a committed transaction can be generally handled by one of two approaches: rollback or compensation. The rollback approach is achieved by rolling back all desirable and undesirable activities to a point that is free from damage \cite{mohan1992efficient}. On the other hand, compensation approach unwinds the effect of selective committed transactions by executing special compensating transactions. The compensation operations are either action-oriented or effect-oriented \cite{korth1990formal}. In this paper, we follow an effect-oriented compensation approach to recover from the damage caused by the malicious and affected transactions. Several solutions have been proposed for intrusion recovery in database-backed applications. A generic intrusion-tolerant architecture for web-servers uses redundancy and diversification principles proposed in \cite{saidane2009design}. In \cite{chandra2011intrusion}, WARP is proposed to recover from intrusions in web-applications by rolling back the database and replaying subsequent legitimate actions to correct the state of the DBMS. In \cite{pardal2017rectify}, an intrusion recovery tool for database-backed applications running in Platform-as-a-Service clouds is proposed. The tool uses machine learning techniques to associate the application requests to the DBMS statements, and then uses existing recovery algorithms to recover from the damage in the DBMS. PIMS is designed as a middle-layer between the DBMS and the application that performs automatic intrusion response and recovery in the DBMS independently from the running applications. Previous work in intrusion recovery in DBMSs can be broadly classified into two categories: transaction-level and data-level approaches. In the transaction-level approach, the general direction is to selectively rollback or compensate for the damaged tuples. In \cite{ammann2002recovery}, a suite of recovery algorithms is proposed to unwind the effect of malicious transactions for offline and online recovery. In \cite{liu2004design,bai2009data}, the authors present ITDB and DTQR, respectively, that implement the recovery algorithms in \cite{ammann2002recovery} on top of a Commercial-Off-The-Shelf DBMS. In \cite{chiueh2008accurate}, a damage assessment and repair system, termed Phoenix, is introduced. The core component in Phoenix is the inter-transaction dependency tracking that maintains such persistent dependency information at run-time. On the other hand, data-dependency approach provides a flexible recovery at the object-level. In \cite{panda2002extended}, a damage assessment technique using data dependency analysis is proposed to obtain precise information about the set of corrupted data. PIMS uses a hybrid approach between data-level dependency and transaction-level approach to track the damage. In particular, the damage assessment is performed at the data-level, while the response and recovery procedures are performed at the transaction-level. Moreover, PIMS addresses the problem of prolonged online recovery procedure in \cite{ammann2002recovery}. Date partitioning schemes are used to improve the availability and scalability of the DBMS. In \cite{curino2010schism}, a workload-aware approach for partitioning the data is proposed. The partitioning approach models the data objects as a graph that is then partitioned into $k$ balanced partitions such that the number of distributed transactions is minimized. In \cite{quamar2013sword}, a scalable workload-aware data placement that uses hyper-graph compression techniques to deal with large-scale datasets is proposed. Online partitioning techniques adaptively partition data based on emerging hotspots, workload skews, and load spikes. In \cite{turcu2016automated}, a methodology for using automatic data partitioning that prefers partitions with independent transactions is proposed. In \cite{taft2014store}, E-store is proposed that provides an elastic planning and reconfiguration system to mitigate the challenges paired with workload skews. None of the above partitioning scheme considers the security aspects of DBMS. The IB demarcation scheme partitions the workload with the objective to improve the availability by confining the damage caused by intrusion attacks. \section*{Proof of Theorem \ref{th:ibdp}} \label{app:a} \begin{proof} \end{proof} \section{Discussion Points} \section{Conclusion} \label{sec:conc} In this paper, the problem of response and recovery of successful intrusion attacks on a DBMS is addressed. We propose PIMS, a data partitioning-based intrusion management system for DBMSs, that can endure intense malicious intrusion attacks. A new fine-grained dependency model that captures the intra-transaction and inter-transaction dependencies is introduced. We introduce a data partitioning scheme, termed IBs, with the objective to limit the extent of the damage into partitions. We formulate the IB demarcation problem as a cost-driven optimization problem and prove that IBDP is NP-hard, and propose efficient heuristic solutions. We present the architecture of PIMS and conduct various experiments to evaluate its performance. We show that although PIMS incurs response time overhead, the reduction in the number of affected transactions and the recovery time is up to 48\% and 52\%, respectively. \bibliographystyle{unsrt} \ifCLASSOPTIONcompsoc \section*{Acknowledgment} This work is supported by Northrop Grumman. \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran} \section{Intrusion Boundary Demarcation using Data Partitioning} \label{sec:ibf} In this section, we present a data-level model to represent intra-transaction and inter-transaction dependencies. Accordingly, we define the IB demarcation problem, and formulate it as MINLP optimization problem. Finally, we prove the problem's hardness and present two efficient heuristics to solve the IB demarcation problem. \subsection{The IB Demarcation Problem} The objective of the IB demarcation problem is to partition the tuples into $k$ partitions, i.e., IBs, with minimum overlap. The advantage of the IB demarcation is to confine the damage into a single IB, and thus increases the data availability in the presence of attacks. Notice that, the overlap among partitions depends on the inter-transaction dependency. For workloads with independent transactions, the demarcation results in non-overlapping IBs. On the other hand, for workloads with high inter-transaction dependencies the IB demarcation results in overlapping IBs. The IB demarcation is defined as follows. \begin{defn} (Intrusion Boundary Demarcation Problem (IBDP)) Given the set of transactions $T$ over a set of $n$ tuples, IBDP is to assign the transactions into $k$ IBs such that the overlap among the IBs is minimized and the sizes of the IBs are almost equal. \end{defn} \subsubsection{Problem Formulation} The demarcation of IBs is controlled by the dependencies among the tuples that are accessed by multiple transactions. We formulate IBDP as a dual-objective MINLP. The first objective function focuses on damage containment that minimizes the overlap among IBs. In order to define this objective function, we define the set of Boundary Tuples (BT) as follows. \begin{defn} (Boundary tuple) A tuple, say $o \in D$, termed a \textbf{boundary} tuples if $o$ is assigned to two or more IBs. The set of boundary tuples in the IB assignment is denoted by $BT$. Observe that BT $\subseteq ST $. \end{defn} It is sufficient to minimize the number of boundary tuples in order to minimize the overlap among IBs. Thus, the objective function can be defined as follows. \begin{equation} f_1(B) = \sum_{i=1}^n b_i \label{eq:f1} \end{equation} where B is the boundary tuples vector that indicates if a tuple is boundary, i.e., $b_k$=1 if the $i^{th}$ tuple is a boundary tuple, and 0, otherwise (notice that $|B|$ = n). The intuition behind minimizing the number of boundary tuples is to limit the damage propagation across IBs. However, Equation \ref{eq:f1} is oblivious to the number of IBs that share a boundary tuple. This number is termed the \textit{degree of sharing}. A boundary tuple that is shared between 2 IBs has less risk of damage propagation as compared to a boundary tuple that is shared among multiple IBs. The degree of sharing is incorporated in Equation \ref{eq:f1} in the following way. \begin{equation} f_1(B,\mathit{TuIB}) = \sum_{i=1}^n b_i \left( \sum_{j=1}^k \mathit{TuIB}_{ij} - 1\right) \label{eq:f1_2} \end{equation} where $\mathit{TuIB}$ is the IB assignment matrix for the tuples, i.e., $\mathit{TuIB}_{ij}$ = 1 if the $i^{th}$ tuple is assigned to the $j^{th}$ IB, and 0, otherwise. The sum $\sum_{j=1}^k \mathit{TuIB}_{ij}$ is the number of IBs to which the $i^{th}$ tuple is assigned, whereas the sum $\sum_{i=1}^n \mathit{TuIB}_{ij}$ is the size of the $j^{th}$ IB. The second objective function focuses on the overall availability. The goal of this objective function is to prevent skewed IB assignment by balancing the sizes of the IBs. Formally, the objective of balancing the sizes of IBs is defined as follows. \begin{equation} f_2(\mathit{TuIB}) = \sqrt{\sum_{i=1}^k \sum_{j>i}^k \left( \sum_{\ell=1}^n \mathit{TuIB}_{\ell i} - \sum_{\ell=1}^n \mathit{TuIB}_{\ell j} \right)^2} \label{eq:f2_1} \end{equation} Let $\mathit{TrIB}$ be the IB assignment matrix for the transactions, i.e., $\mathit{TrIB}_{ij}=1$ if the $i^{th}$ transaction is assigned to the $j^{th}$ IB, and 0, otherwise. Similarly, Let $\mathit{TuTr}$ be a binary matrix representing the association of tuples to the transactions, i.e., $\mathit{TuTr}_{ij}=1$ if the $i^{th}$ tuples is accessed by the $j^{th}$ transaction, and 0, otherwise. Although a transaction might span multiple IBs, each transaction must be fully contained within a single IB. The intuition is that by containing a transaction within an IB, the damage is confined in that IB if the transaction is detected as malicious. Accordingly, IBDP is formulated as MINLP using objective functions $f_1$ and $f_2$ as follows. \vspace{-3 mm} \begin{align} & \underset{\mathit{TuIB},\mathit{TrIB},B}{\text{Minimize }} \nonumber & & f_1(B,\mathit{TuIB}) +f_2(\mathit{TuIB})\\ \nonumber & \text{subject to} \\ & & & \sum_{j=1}^k \mathit{TuIB}_{ij} -1 \leq k b_i , \ \ \ \forall i \in \{ 1,\ldots,n\} \label{eq:c1} \\ & & & 2- \sum_{j=1}^k \mathit{TuIB}_{ij} \leq k (1-b_i) , \nonumber \\ & & & \ \ \ \forall i \in \{ 1,\ldots,n\} \label{eq:c2} \\ & & & \sum_{i=1}^{n} \mathit{TuTr}_{i\ell} - \sum_{i=1}^{n} \mathit{TuTr}_{i\ell} * \mathit{TuIB}_{ij} \geq \nonumber \\ & & & 1-\mathit{TrIB}_{\ell j} \label{eq:c3} \\ & & & \ \ \ \ \ \forall \ell \in \{ 1,\ldots,m\}, j \in \{ 1,\ldots,k\} \nonumber \\ & & & \sum_{j=1}^k \mathit{TrIB}_{ij} = 1 \ \ \ \ \forall i \in \{ 1,\ldots,m\} \ \ \ \label{eq:c4} \\ & & & \sum_{i=1}^n \mathit{TuIB}_{ij} \geq 1 \ \ \ \ \forall j \in \{ 1,\ldots,k\} \ \ \ \label{eq:c5} \\ & & & TuIB_{ij} \in \{0,1\}, TrIB_{ij} \in \{0,1\}, \nonumber \\ & & & b_i \in \{0,1\} \label{eq:c6} \\ \nonumber \label{eq:op2} \vspace{-3 mm} \end{align} The outputs of the optimization problem are the IB assignment matrix of the tuples $\mathit{TuIB}$, the IBs assignment matrix of the transactions $\mathit{TrIB}$, and the set of boundary tuples $B$. Constraints (\ref{eq:c1}) and (\ref{eq:c2}) collectively check if a tuple is assigned to multiple IBs. Accordingly, the constraints set $b_i =1$ if the $i^{th}$ tuple is boundary, and 0, otherwise. Full containment of a transaction within a single IB is checked by constraints (\ref{eq:c3}) and (\ref{eq:c4}). In particular, a transaction $t_{\ell}$ is assigned to the $j^{th}$ IB only if all the tuples access by $t\_{\ell}$ are assigned to the $j^{th}$ IB. Constraint (\ref{eq:c5}) forces the size of each IB to be at least one tuples, while constraint (\ref{eq:c6}) forces $\mathit{TuIB}$, $\mathit{TrIB}$, and $B$ to be binary matrices. \begin{theorem} IBDP is NP-hard. \label{th:ibdp} \end{theorem} \label{app:a} \subsection{Heuristics for IB Demarcation} We introduce two efficient greedy-based heuristics to solve IBDP. All algorithms take the set of transaction and the number of IBs as input. The output is a transaction-to-IB assignment. The algorithms start with an empty IB assignment and iteratively assign transactions to IBs based on greedy decisions that optimize the objective functions. The first heuristic is Best-Fit Assignment (BFA) that reduces the number of boundary tuples produced by the IB assignment. The intuition of the assignment is that BFA assigns the transaction to the IB that shares the largest number of shared tuples. The second heuristic is Balanced Assignment (BA) that assigns transactions such that the sizes of all IBs are almost equal. This is achieved by assigning, at each iteration, the transaction to the IB that is the smallest in size. Detailed discussion about each algorithm is presented in the following sections. \subsection{Best-Fit Assignment (BFA)} BFA is listed in Algorithm \ref{alg:bfa}. The algorithm starts with the empty IB assignment set $\mathcal{S}$ and empty assigned transactions set $A$ (Line 1). Then, the transactions are sorted based on the number of internal tuples in descending order (Line 2). The sorted transaction set is stored in Set $T$. Then, the algorithm initially assigns the first $k$ transactions to the empty IBs (Lines 3-9). As a result, the overlap among the IBs is minimized. This is correct because the first $k$ transactions in $T$ have the least number of shared tuples. For the remaining transactions in $T$, each transaction $t$ is assigned to the IB that shares the largest number of shared tuples with $t$ (Lines 10-19). In particular, the set of assigned transactions that overlap with $t$ is stored in $NT$ (Line 11). Then, the IBs of each transaction in $NT$ is stored in $NIB$ (Line 12). $NIB$ contains the set of all IBs that share tuples with $t$. If the set $NIB$ is not empty, $t$ is assigned to the IB that has the largest number of shared tuples with $t$ (Line 14-16). Otherwise, $t$ is assigned to the smallest IB in $\mathcal{S}$. \begin{lemma} The complexity of BFA is $O(nm^2 + knm)$. \label{lem:1} \end{lemma} \begin{proof} \label{app:pf1} BFA sorts the set of transactions based on the number of internal tuples in each transaction (Line 3). Sorting Set $T$ has a runtime complexity of $\mathcal{O}(m \log m)$. The loop in Lines 3-9 assigns a single transaction to each empty IB. Thus, the loop has a runtime complexity of $\mathcal{O}(k)$. Then, BFA assigns transactions to the best-fit IB (Lines 10-19). The runtime complexity of finding the set $NT$ and $NIB$ is $\mathcal{O}(nm)$ (Lines 11 and 12). Finding $ib_{max}$, the IB that has the largest number of tuples shared with $t$, and assigning $t$ in Lines 13-18 has a runtime complexity of $\mathcal{O}(nk)$. The runtime complexity for assigning all the transactions is $\mathcal{O}(m ( nm + nk))$. The overall complexity of BFA is $\mathcal{O}(m \log m + k + nm^2 + knm)$, i.e., approximately $~ \mathcal{O}(nm^2 + knm)$. \end{proof} \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$k$} \KwOut{$\mathcal{S}=\{ib_1,...,ib_k\}$} $\mathcal{S}=\emptyset$, $A = \emptyset$\\ $T \leftarrow$Sort transactions based on the number of internal tuples in descending order \\ \For{$i=1..k$}{ $t \leftarrow$ largest transaction in $T$ \\ $ib_i = \{ t \}$\\ $\mathcal{S} = \mathcal{S} \cup \{ ib_i\}$\\ Add $t$ to $A$\\ Remove $t$ from $T$\\ } \For{$t \in T$}{ Find $NT$ the set of assigned transaction that overlap with $t$\\ Find $NIB$ the set of IBs that overlap with $t$\\ \uIf{$NIB \neq \emptyset$}{ Find $ib_{max} \in NIB$ that has the largest number of tuples shared with $t$\\ $ib_{max} = ib_{max} \cup t$ \\ } \Else{ Assign $t$ to the smallest $ib$\\ } } \Return{$\mathcal{S}$} \caption{Best Fit Assignment} \label{alg:bfa} \end{algorithm} \section{Performance Evaluation} \label{sec:exp} In this section, performance evaluation of the proposed PIMS framework is presented. First, we discuss the synthetic workload used for the performance evaluation. Then, we evaluate the performance of the proposed IB demarcation heuristics. Finally, we conduct extensive system evaluation of PIMS using synthesized workloads, and present the performance results. \subsection{Synthetic Transactional Workload} Several benchmarks have been developed to evaluate the performance of OLTP systems, e.g., TPC-C \cite{tpcc}, \textit{SmallBank} \cite{alomari2008cost}, and YCSB \cite{cooper2010benchmarking}. However, no benchmark has been developed to evaluate the performance of intrusion management systems in OLTP. In order to evaluate the performance of PIMS, we have developed a malicious transaction workload benchmark that generates long chains of dependent transactions. These long chains of dependent transactions amplify the potential damage that can be caused by the malicious transactions. In essence, executing dependent transactions shortly after malicious transactions induce the spread of damage. Thus, the proposed benchmark allows the assessment of the capability of the intrusion management systems to confine and recover the damage without degrading the performance of the DBMS. The proposed benchmark simulates a banking money-transfer application. In essence, the benchmark consists of a single data table, \textit{Checking}, that has two attributes: \textit{id} and \textit{balance}. The benchmark has three types of money transfer transactions: \textit{distribute}, \textit{collect}, and \textit{many-to-many} transfer. A distribute transaction transfers money from a single account to $N$ other accounts; A collect transaction transfers money from $M$ accounts to a single account; A many-to-many transactions transfers money from $N$ accounts to another $M$ accounts. The benchmark is implemented on an OLTP-benchmark testbed for relational databases \cite{difallah2013oltp}. We now explain the process of generating a workload of $m$ transactions. We use four parameters to characterize the workload: 1) the inter-transaction dependency probability threshold $\beta$, 2) the maximum number of dependent transactions $Tx_{max}$, 3) the amount of transferred money $\gamma$, and 4) the maximum transaction size $Size_{max}$. First, the inter-transaction dependency is modeled using PG. PG is constructed using the Erd\"{o}s-Renyi model \cite{erdos1960evolution}, in which an edge has probability $p$ of existence. The degree of inter-transaction dependency is controlled by grouping transactions into small groups. Within each group, a pair of transactions are dependent if $p$ is greater than $\beta$. Semantically, each group models money transfer transactions within a city, state, or country. In order to avoid fully connected graphs within the group of transactions, the number of allowed dependent transactions is limited to $Tx_{max}$. In other words, a transaction can be dependent to no more than $Tx_{max}$ transactions. Once a PG is created, tuples are assigned to the transactions as follows. The size of each transactions is determined using a uniform distribution with a range of [2,$Size_{\text{max}}$]. The transaction type is randomly selected from distribute, collect, or many-to-many. Each transaction shares a single tuple with the set of its dependent transactions. The value of $\gamma$ is chosen from a uniform distribution with range of [0.01,0.1]. Accordingly, the query is generated. Each transaction contains a single query. We generate 4 workloads with different sizes, mainly, 5000, 10000, 15000, and 20000 transactions. For each workload, we vary the value of $\beta$ to be 0.25, 0.5, and 0.75. \subsection{Evaluation of the IB Demarcation Heuristics} \label{sec:heurPer} In this section, we evaluate the performance of the proposed heuristics using a synthetic transactional workload. We compare the performance of the proposed heuristics with two assignment techniques: Random Assignment (RA) and Skewed Assignment (SA). In RA, transactions are assigned to the IBs randomly. In SA, transaction are randomly assigned to the IBs following an 80-20 rule, i.e., 80\% of the transactions are assigned to 20\% of the IBs. SA is used to emphasize the importance of the size balancing objective (Equation \ref{eq:f2_1}). We use two metrics to evaluate the performance of the heuristics: the total number of boundary tuples (Equation \ref{eq:f1_2}), and the assignment fairness index. The fairness index is used to assess the performance in terms of size balancing among IBs. The fairness index is an adaptation of the Jain's fairness index \cite{jain1999throughput} in the following way. \begin{equation} \mathcal{J}(IB_1,IB_2,\ldots,IB_k) = \frac{(\sum_{i=1}^k |IB_i|)^2}{k \cdot \sum_{i=1}^k |IB_i|^2} \end{equation} where $|IB_i|$ is the number of transactions assigned to the i$th$ IB. In the first experiment, we vary the number of IBs, k, using a workload of 5000 transactions, and $\beta=0.75$. The number of boundary tuples increases as $k$ increases (refer to Fig. \ref{fig:ddg_ibs_bo}). The reason is that as $k$ increases, the number of contained transactions in each IB is reduced. As a result, the overlap among IBs increases and thus increases the total number of boundary tuples. We observe that BFA produces a less number of boundary tuples compared to BA and RA. The reason is that BFA performs a greedy decision to reduce the number of boundary tuples when assigning a transaction to IBs. Moreover, BA performs better than RA because BA attempts to balance the sizes of the IBs. Notice that SA produces less boundary tuples than BFA for $k$ $<$10, but more boundary tuples when k$>$10. The reason is that, when the number of IBs is small, e.g., for k=5 and k=10, 80\% of the transactions are assigned only to 1 IB and 2 IBs, respectively. Thus, most of the inter-transaction dependencies are contained in at most 2 IBs. BFA and BA produce fair assignment as in Fig. \ref{fig:ddg_ibs_fi}. SA performs the worst by design, while RA performs better when the number of transactions is large and the number of IBs is small because the random assignment tends to be fair. In the next experiment, we vary the number of transactions and the value of $\beta$ while generating the IB assignment with $k= 10$. We observe that increasing the number of transactions increases the number of boundary tuples as in Fig. \ref{fig:ddg_tx_bo}. The reason is that increasing the number of transactions increases the number of shared tuples among transactions. Notice that the set of boundary tuples is a subset of the shared tuples. Similarly, increasing the value of $\beta$ increases the number of boundary tuples as in Fig. \ref{fig:ddg_alpha_bo}. The reason is that as the value of $\beta$ increases, the number of dependent transactions increases. As a result, the number of shared tuples increases. \begin{figure}[t!] \centering \subfigure[Number of boundary tuples]{\label{fig:ddg_ibs_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/ibs/bo.pdf}}% \subfigure[Fairness index]{\label{fig:ddg_ibs_fi}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/ibs/fair.pdf}} \caption{Effect of $k$ on a workload of 5000 transaction with $\alpha=0.75$.} \label{fig:ddg_ibs} \vspace{-3 mm} \end{figure} \begin{figure}[t!] \centering \subfigure[Effect of the number transactions]{\label{fig:ddg_tx_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/size/bo}}% \subfigure[Effect of $\beta$]{\label{fig:ddg_alpha_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/connectivity/bo}}% \caption{Effect of the number of transactions and value of $\beta$ on a workload 5000 transaction with $\alpha=0.75$.} \label{fig:ddg_tx} \vspace{-3 mm} \end{figure} \subsection{PIMS Performance Evaluation} The experiments are conducted on a Dell Power Edge R420 server with 6-core Intel E5-2620v3 CPU, 120 GB of RAM, and Ubuntu Server 16.0 LTS OS. We use PostgreSQL 9.5. PIMS is implemented using Java and is connected to PostgreSQL using JDBC. We use 8 workers (threads) for the admission controller and an unlimited pool of threads for the response and recovery procedures. Before each experiment, the Checking table is populated with 100,000 tuples of unique IDs and initial balance of \$10,000. We use a B-tree index on the Checking table to improve the query execution time. We assume that the transactions are submitted according to a Poisson distribution with an arrival rate of $\lambda$. Furthermore, malicious transactions are injected into the workload using a uniform distribution over time. The number of malicious transactions is based on the attack intensity $\pi$ that is a percentage of the total number of transactions. We evaluate the performance of PIMS using four metrics: 1) the number of affected transactions, 2) the number of blocked transactions, 3) the average recovery time, and 4) the average response time. The number of blocked transactions indicates the performance of PIMS in terms of availability, while the number of affected transactions indicates the cost of damage. The average response time is computed based on the response times of all committed transactions. We compare the performance of PIMS using the proposed heuristics, i.e., BFA and BA, with RA and SA. We refer to PIMS with k$>$1 as "PIMS\_k". We often use PIMS\_k\_BFA, PIMS\_k\_BA, PIMS\_k\_RA, and PIMS\_k\_SA to differentiate between the assignment techniques as needed. The performance of PIMS is compared against PIMS\_1 (denoted by \textit{One IB}) and ITDB \cite{bai2009data}. We use a workload of 5000 transactions to conduct the experiments, unless stated otherwise. In each experiment, we run PIMS with $k$ values of 5, 10, 15, and 20. We do not notice any improvement in the performance beyond 20 IBs. \subsubsection{Read Log Overhead} In this experiment, we study the overhead of logging the transaction read/write operations. Figs. \ref{fig:readoverhead_th} and \ref{fig:readoverhead_res} give the throughput and response time with logging (PIMS) and without logging (no logging) for various values of $\lambda$. Notice that the throughput in both cases match the transaction arrival rate. However, logging read/write operations adds 30\% overhead to the response time. This overhead is inevitable because PIMS relies on the transactions log to identify AT, and generate the compensating transactions. \begin{figure}[t!] \centering \subfigure[Throughput]{\label{fig:readoverhead_th} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/readLogOverhead/throughput}}% \subfigure[Response time]{\label{fig:readoverhead_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/readLogOverhead/response}} \caption{Overhead of logging read operations.} \label{fig:readoverhead} \vspace{-3 mm} \end{figure} \subsubsection{Effect of Attack Intensity} In this experiment, we compare the performance of PIMS and OneIB with ITDB as the attack intensity $\pi$ increases. We use $k=10$ and $\Delta = 100 \ ms$ to plot the results using BFA and BA assignments. Refer to Fig. \ref{fig:numMal}. We observe that the extent of the damage increases as the attack intensity increases. In particular, the number of affected transactions increases as the number of malicious transactions increases. This is intuitive because increasing the number of malicious transactions increases the number of affected transactions with the same inter-transaction dependency. However, the average time to recover the damage remains constant as in Fig. \ref{fig:numMal_rec}. Observe that the number of affected transactions and the average recovery time for PIMS\_10\_BFA and PIMS\_10\_BA are less than OneIB and ITDB. The reason is that PIMS employs the delayed access mechanism that takes a proactive approach to block the incoming transactions that can potentially spread the damage. However, the disadvantage of the delayed access mechanism is the increase in the number of blocked transactions and average response time as in Fig. \ref{fig:numMal_blk} and \ref{fig:numMal_res}. PIMS\_BFA has less response time as compared to PIMS\_BA because BFA generates lower number of boundary tuples. Notice that the delayed access mechanism is not active in the case of OneIB and ITDB because there are no boundary tuples, and thus the response time is lower than PIMS. Notice that, in general, increasing the number of affected transactions increases the number of compensating transactions to be performed. Consequently, the average recovery time increases. Similarly, increasing the number of blocked transactions increases the average response time. Even though OneIB and ITDB almost have the same number of affected transactions with the same attack intensity, OneIB encounters less recovery time as compared to ITDB. The reason is that ITDB needs multiple passes on the transactions logs to find AT \cite{ammann2002recovery}, while OneIB needs a single pass because it temporarily blocks transactions. However, the overhead of blocking incoming transactions is an increase in the number of blocked transactions and response time in OneIB as compared to ITDB. We note that the proposed response and recovery methodology, i.e., PIMS, reduces the number of affected transactions by at least 33\% as compared to ITDB. Consequently, the average recovery time is reduced by 50\%, i.e., 150 $ms$ in PIMS\_10\_BFA as compared to 300 $ms$ in ITDB with 750 malicious transactions. The downside is that PIMS incurs a larger number of blocked transactions due to blocking the transactions that request to read boundary tuples. The increase in the response time is around 60\% as compared to ITDB. Nevertheless, the average response time for PIMS does not exceed 50 $ms$ when the attack intensity is 15\%. Fig. \ref{fig:numMal_th} gives the throughput of PIMS and OneIB as the attack intensity increases for $\Delta=100$ $ms$ and $\lambda=10$. We note that PIMS and OneIB match the transaction arrival rate $\lambda$, and thus does not incur any overhead on the throughput. \begin{figure}[t!] \centering \subfigure[Affected transactions]{\label{fig:numMal_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/affTx}}% \subfigure[Blocked transactions]{\label{fig:numMal_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/blocked}} \subfigure[Average recovery time]{\label{fig:numMal_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/recovery}}% \subfigure[Average response time]{\label{fig:numMal_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/response}}% \caption{Effect of $\pi$ with $\Delta = 100$ $ms$ and $\lambda =10$.} \label{fig:numMal} \vspace{-3 mm} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/throughput} \caption{Throughput of PIMS and OneIB for different values of ($\pi$) with $\Delta = 100$ $ms$ and $\lambda =10$.} \label{fig:numMal_th} \vspace{-3 mm} \end{figure} \subsubsection{The Effect of The Number of IBs} \label{exp:ibs} \begin{figure}[th!] \centering \subfigure[Affected transactions]{\label{fig:ibs_d100_l10_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/affTx}}% \subfigure[Blocked transactions]{\label{fig:ibs_d100_l10_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/allBlocked}} \subfigure[Average recovery time]{\label{fig:ibs_d100_l10_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/recovery}}% \subfigure[Average response time]{\label{fig:ibs_d100_l10_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/response}}% \caption{Effect of $k$ with $\lambda=10$, $\Delta =100$ $ms$, and $\pi=10\%$ malicious intensity.} \label{fig:ibs_d100_l10} \vspace{-3 mm} \end{figure} In this experiment, we evaluate the performance of PIMS with various values of $k$, i.e., 1, 5, 10, 15, and 20. We compare the results of PIMS\_BFA and PIMS\_BA with oneIB. Moreover, we study the performance of PIMS\_RA and PIMS\_SA to demonstrate the effectiveness of the proposed heuristics. Fig. \ref{fig:ibs_d100_l10} gives the performance of PIMS with $ \Delta=100 $ $ms$, $\lambda = 10$, and $\pi=10\%$, i.e., 500 malicious transactions. From Fig. \ref{fig:ibs_d100_l10}, increasing $k$ improves the performance of PIMS. In particular, the number of affected transactions is reduced by at least 5\%, 18\%, 26\%, and 48\% using SA, BFA, BA, and RA, respectively. Consequently, the average recovery time decreases as $k$ increases. However, PIMS incurs at least 20\%, 37\%, 50\%, and 63\% of response time overhead in SA, BFA, BA, and RA, respectively, as Fig. \ref{fig:ibs_d100_l10_res} illustrates. The reason is due to the increase in the number of boundary tuples. We note that the increase in the response time overhead is marginal as the value of $k$ increases beyond 10. Although PIMS\_BFA has the least reduction in recovery time as compared to PIMS\_BA and PIMS\_RA, PIMS\_BFA has the minimum response time overhead. We note that PIMS\_SA has less response time than PIMS\_BFA when $k<10$ because the number of boundary tuples generated by SA is less than BFA as explained in Section \ref{sec:heurPer}. However, the response time of PIMS\_SA increases dramatically for k$>$10 as the assignment skewness is higher. On the other hand, PIMS\_RA outperforms PIMS\_BFA and PIMS\_BA in terms of reducing the number of affected transactions, and thus the recovery time. PIMS\_RA incurs the highest overhead in response time. In conclusion, we note that PIMS\_BFA and PIMS\_BA produce a balanced performance in terms of recovery and response time as compared to PIMS\_RA and PIMS\_SA over a wide range of $k$ values. In the next experiment, we study the effect of the delayed access mechanism on the performance of PIMS. We compare the performance of PIMS\_BFA, PIMS\_BA, PIMS\_RA, and PIMS\_SA with delay and without delay. From Fig. \ref{fig:noDelay_aff}, the number of affected transactions is larger when the delayed access mechanism is off. The reason is that the damage propagates across the IBs. However, the shortcoming of the delayed access mechanism is the increase in the response time overhead as in Fig. \ref{fig:noDelay_res}. The reason is the increase in the number of blocked transactions due to blocking boundary tuples. The overhead is more noticeable in the case of PIMS\_RA as compared to PIMS\_BFA. In conclusion, the delayed access mechanism allows to contain the damage and reduce the recovery time in the case of PIMS\_BFA and PIMS\_BA. Moreover, PIMS with delayed access mechanism maintains a reasonable response time overhead, and thus improves the overall availability. \begin{figure}[t!] \centering \subfigure[Affected transactions]{\label{fig:noDelay_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/affTx}}% \subfigure[Blocked transactions]{\label{fig:noDelay_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/allBlocked}} \subfigure[Average recovery time]{\label{fig:noDelay_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/recovery}}% \subfigure[Average response time]{\label{fig:noDelay_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/response}}% \caption{Effect of the delayed access mechanism with $\Delta=100$ $ms$, $\lambda=10$, and $\pi=10\%$.} \label{fig:noDelay} \vspace{-3 mm} \end{figure} \section{Performance Evaluation} \label{sec:exp} In this section, performance evaluation of the proposed PIMS framework is presented. First, we discuss the synthetic workload used for the performance evaluation. Then, we evaluate the performance of the proposed IB demarcation heuristics. Finally, we conduct extensive system evaluation of PIMS using synthesized workloads, and present the performance results. \subsection{Synthetic Transactional Workload} Several benchmarks have been developed to evaluate the performance of OLTP systems, e.g., TPC-C \cite{tpcc}, \textit{SmallBank} \cite{alomari2008cost}, and YCSB \cite{cooper2010benchmarking}. However, no benchmark has been developed to evaluate the performance of intrusion management systems in OLTP. In order to evaluate the performance of PIMS, we have developed a malicious transaction workload benchmark that generates long chains of dependent transactions. These long chains of dependent transactions amplify the potential damage that can be caused by the malicious transactions. In essence, executing dependent transactions shortly after malicious transactions induce the spread of damage. Thus, the proposed benchmark allows the assessment of the capability of the intrusion management systems to confine and recover the damage without degrading the performance of the DBMS. The proposed benchmark simulates a banking money-transfer application. In essence, the benchmark consists of a single data table, \textit{Checking}, that has two attributes: \textit{id} and \textit{balance}. The benchmark has three types of money transfer transactions: \textit{distribute}, \textit{collect}, and \textit{many-to-many} transfer. A distribute transaction transfers money from a single account to $N$ other accounts; A collect transaction transfers money from $M$ accounts to a single account; A many-to-many transactions transfers money from $N$ accounts to another $M$ accounts. The benchmark is implemented on an OLTP-benchmark testbed for relational databases \cite{difallah2013oltp}. We now explain the process of generating a workload of $m$ transactions. We use four parameters to characterize the workload: 1) the inter-transaction dependency probability threshold $\beta$, 2) the maximum number of dependent transactions $Tx_{max}$, 3) the amount of transferred money $\gamma$, and 4) the maximum transaction size $Size_{max}$. First, the inter-transaction dependency is modeled using PG. PG is constructed using the Erd\"{o}s-Renyi model \cite{erdos1960evolution}, in which an edge has probability $p$ of existence. The degree of inter-transaction dependency is controlled by grouping transactions into small groups. Within each group, a pair of transactions are dependent if $p$ is greater than $\beta$. Semantically, each group models money transfer transactions within a city, state, or country. In order to avoid fully connected graphs within the group of transactions, the number of allowed dependent transactions is limited to $Tx_{max}$. In other words, a transaction can be dependent to no more than $Tx_{max}$ transactions. Once a PG is created, tuples are assigned to the transactions as follows. The size of each transactions is determined using a uniform distribution with a range of [2,$Size_{\text{max}}$]. The transaction type is randomly selected from distribute, collect, or many-to-many. Each transaction shares a single tuple with the set of its dependent transactions. The value of $\gamma$ is chosen from a uniform distribution with range of [0.01,0.1]. Accordingly, the query is generated. Each transaction contains a single query. We generate 4 workloads with different sizes, mainly, 5000, 10000, 15000, and 20000 transactions. For each workload, we vary the value of $\beta$ to be 0.25, 0.5, and 0.75. \subsection{Evaluation of the IB Demarcation Heuristics} \label{sec:heurPer} In this section, we evaluate the performance of the proposed heuristics using a synthetic transactional workload. We compare the performance of the proposed heuristics with two assignment techniques: Random Assignment (RA) and Skewed Assignment (SA). In RA, transactions are assigned to the IBs randomly. In SA, transaction are randomly assigned to the IBs following an 80-20 rule, i.e., 80\% of the transactions are assigned to 20\% of the IBs. SA is used to emphasize the importance of the size balancing objective (Equation \ref{eq:f2_1}). We use two metrics to evaluate the performance of the heuristics: the total number of boundary tuples (Equation \ref{eq:f1_2}), and the assignment fairness index. The fairness index is used to assess the performance in terms of size balancing among IBs. The fairness index is an adaptation of the Jain's fairness index \cite{jain1999throughput} in the following way. \begin{equation} \mathcal{J}(IB_1,IB_2,\ldots,IB_k) = \frac{(\sum_{i=1}^k |IB_i|)^2}{k \cdot \sum_{i=1}^k |IB_i|^2} \end{equation} where $|IB_i|$ is the number of transactions assigned to the i$th$ IB. In the first experiment, we vary the number of IBs, k, using a workload of 5000 transactions, and $\beta=0.75$. The number of boundary tuples increases as $k$ increases (refer to Fig. \ref{fig:ddg_ibs_bo}). The reason is that as $k$ increases, the number of contained transactions in each IB is reduced. As a result, the overlap among IBs increases and thus increases the total number of boundary tuples. We observe that BFA produces a less number of boundary tuples compared to BA and RA. The reason is that BFA performs a greedy decision to reduce the number of boundary tuples when assigning a transaction to IBs. Moreover, BA performs better than RA because BA attempts to balance the sizes of the IBs. Notice that SA produces less boundary tuples than BFA for $k$ $<$10, but more boundary tuples when k$>$10. The reason is that, when the number of IBs is small, e.g., for k=5 and k=10, 80\% of the transactions are assigned only to 1 IB and 2 IBs, respectively. Thus, most of the inter-transaction dependencies are contained in at most 2 IBs. BFA and BA produce fair assignment as in Fig. \ref{fig:ddg_ibs_fi}. SA performs the worst by design, while RA performs better when the number of transactions is large and the number of IBs is small because the random assignment tends to be fair. In the next experiment, we vary the number of transactions and the value of $\beta$ while generating the IB assignment with $k= 10$. We observe that increasing the number of transactions increases the number of boundary tuples as in Fig. \ref{fig:ddg_tx_bo}. The reason is that increasing the number of transactions increases the number of shared tuples among transactions. Notice that the set of boundary tuples is a subset of the shared tuples. Similarly, increasing the value of $\beta$ increases the number of boundary tuples as in Fig. \ref{fig:ddg_alpha_bo}. The reason is that as the value of $\beta$ increases, the number of dependent transactions increases. As a result, the number of shared tuples increases. \begin{figure}[t!] \centering \subfigure[Number of boundary tuples]{\label{fig:ddg_ibs_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/ibs/bo.pdf}}% \subfigure[Fairness index]{\label{fig:ddg_ibs_fi}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/ibs/fair.pdf}} \caption{Effect of $k$ on a workload of 5000 transaction with $\alpha=0.75$.} \label{fig:ddg_ibs} \vspace{-3 mm} \end{figure} \begin{figure}[t!] \centering \subfigure[Effect of the number transactions]{\label{fig:ddg_tx_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/size/bo}}% \subfigure[Effect of $\beta$]{\label{fig:ddg_alpha_bo} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/heuristics/connectivity/bo}}% \caption{Effect of the number of transactions and value of $\beta$ on a workload 5000 transaction with $\alpha=0.75$.} \label{fig:ddg_tx} \vspace{-3 mm} \end{figure} \subsection{PIMS Performance Evaluation} The experiments are conducted on a Dell Power Edge R420 server with 6-core Intel E5-2620v3 CPU, 120 GB of RAM, and Ubuntu Server 16.0 LTS OS. We use PostgreSQL 9.5. PIMS is implemented using Java and is connected to PostgreSQL using JDBC. We use 8 workers (threads) for the admission controller and an unlimited pool of threads for the response and recovery procedures. Before each experiment, the Checking table is populated with 100,000 tuples of unique IDs and initial balance of \$10,000. We use a B-tree index on the Checking table to improve the query execution time. We assume that the transactions are submitted according to a Poisson distribution with an arrival rate of $\lambda$. Furthermore, malicious transactions are injected into the workload using a uniform distribution over time. The number of malicious transactions is based on the attack intensity $\pi$ that is a percentage of the total number of transactions. We evaluate the performance of PIMS using four metrics: 1) the number of affected transactions, 2) the number of blocked transactions, 3) the average recovery time, and 4) the average response time. The number of blocked transactions indicates the performance of PIMS in terms of availability, while the number of affected transactions indicates the cost of damage. The average response time is computed based on the response times of all committed transactions. We compare the performance of PIMS using the proposed heuristics, i.e., BFA and BA, with RA and SA. We refer to PIMS with k$>$1 as "PIMS\_k". We often use PIMS\_k\_BFA, PIMS\_k\_BA, PIMS\_k\_RA, and PIMS\_k\_SA to differentiate between the assignment techniques as needed. The performance of PIMS is compared against PIMS\_1 (denoted by \textit{One IB}) and ITDB \cite{bai2009data}. We use a workload of 5000 transactions to conduct the experiments, unless stated otherwise. In each experiment, we run PIMS with $k$ values of 5, 10, 15, and 20. We do not notice any improvement in the performance beyond 20 IBs. \subsubsection{Read Log Overhead} In this experiment, we study the overhead of logging the transaction read/write operations. Figs. \ref{fig:readoverhead_th} and \ref{fig:readoverhead_res} give the throughput and response time with logging (PIMS) and without logging (no logging) for various values of $\lambda$. Notice that the throughput in both cases match the transaction arrival rate. However, logging read/write operations adds 30\% overhead to the response time. This overhead is inevitable because PIMS relies on the transactions log to identify AT, and generate the compensating transactions. \begin{figure}[t!] \centering \subfigure[Throughput]{\label{fig:readoverhead_th} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/readLogOverhead/throughput}}% \subfigure[Response time]{\label{fig:readoverhead_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/readLogOverhead/response}} \caption{Overhead of logging read operations.} \label{fig:readoverhead} \vspace{-3 mm} \end{figure} \subsubsection{Effect of Attack Intensity} In this experiment, we compare the performance of PIMS and OneIB with ITDB as the attack intensity $\pi$ increases. We use $k=10$ and $\Delta = 100 \ ms$ to plot the results using BFA and BA assignments. Refer to Fig. \ref{fig:numMal}. We observe that the extent of the damage increases as the attack intensity increases. In particular, the number of affected transactions increases as the number of malicious transactions increases. This is intuitive because increasing the number of malicious transactions increases the number of affected transactions with the same inter-transaction dependency. However, the average time to recover the damage remains constant as in Fig. \ref{fig:numMal_rec}. Observe that the number of affected transactions and the average recovery time for PIMS\_10\_BFA and PIMS\_10\_BA are less than OneIB and ITDB. The reason is that PIMS employs the delayed access mechanism that takes a proactive approach to block the incoming transactions that can potentially spread the damage. However, the disadvantage of the delayed access mechanism is the increase in the number of blocked transactions and average response time as in Fig. \ref{fig:numMal_blk} and \ref{fig:numMal_res}. PIMS\_BFA has less response time as compared to PIMS\_BA because BFA generates lower number of boundary tuples. Notice that the delayed access mechanism is not active in the case of OneIB and ITDB because there are no boundary tuples, and thus the response time is lower than PIMS. Notice that, in general, increasing the number of affected transactions increases the number of compensating transactions to be performed. Consequently, the average recovery time increases. Similarly, increasing the number of blocked transactions increases the average response time. Even though OneIB and ITDB almost have the same number of affected transactions with the same attack intensity, OneIB encounters less recovery time as compared to ITDB. The reason is that ITDB needs multiple passes on the transactions logs to find AT \cite{ammann2002recovery}, while OneIB needs a single pass because it temporarily blocks transactions. However, the overhead of blocking incoming transactions is an increase in the number of blocked transactions and response time in OneIB as compared to ITDB. We note that the proposed response and recovery methodology, i.e., PIMS, reduces the number of affected transactions by at least 33\% as compared to ITDB. Consequently, the average recovery time is reduced by 50\%, i.e., 150 $ms$ in PIMS\_10\_BFA as compared to 300 $ms$ in ITDB with 750 malicious transactions. The downside is that PIMS incurs a larger number of blocked transactions due to blocking the transactions that request to read boundary tuples. The increase in the response time is around 60\% as compared to ITDB. Nevertheless, the average response time for PIMS does not exceed 50 $ms$ when the attack intensity is 15\%. Fig. \ref{fig:numMal_th} gives the throughput of PIMS and OneIB as the attack intensity increases for $\Delta=100$ $ms$ and $\lambda=10$. We note that PIMS and OneIB match the transaction arrival rate $\lambda$, and thus does not incur any overhead on the throughput. \begin{figure}[t!] \centering \subfigure[Affected transactions]{\label{fig:numMal_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/affTx}}% \subfigure[Blocked transactions]{\label{fig:numMal_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/blocked}} \subfigure[Average recovery time]{\label{fig:numMal_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/recovery}}% \subfigure[Average response time]{\label{fig:numMal_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/response}}% \caption{Effect of $\pi$ with $\Delta = 100$ $ms$ and $\lambda =10$.} \label{fig:numMal} \vspace{-3 mm} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/numOfMal/throughput} \caption{Throughput of PIMS and OneIB for different values of ($\pi$) with $\Delta = 100$ $ms$ and $\lambda =10$.} \label{fig:numMal_th} \vspace{-3 mm} \end{figure} \subsubsection{The Effect of The Number of IBs} \label{exp:ibs} \begin{figure}[th!] \centering \subfigure[Affected transactions]{\label{fig:ibs_d100_l10_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/affTx}}% \subfigure[Blocked transactions]{\label{fig:ibs_d100_l10_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/allBlocked}} \subfigure[Average recovery time]{\label{fig:ibs_d100_l10_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/recovery}}% \subfigure[Average response time]{\label{fig:ibs_d100_l10_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/delta100_lambda10/response}}% \caption{Effect of $k$ with $\lambda=10$, $\Delta =100$ $ms$, and $\pi=10\%$ malicious intensity.} \label{fig:ibs_d100_l10} \vspace{-3 mm} \end{figure} In this experiment, we evaluate the performance of PIMS with various values of $k$, i.e., 1, 5, 10, 15, and 20. We compare the results of PIMS\_BFA and PIMS\_BA with oneIB. Moreover, we study the performance of PIMS\_RA and PIMS\_SA to demonstrate the effectiveness of the proposed heuristics. Fig. \ref{fig:ibs_d100_l10} gives the performance of PIMS with $ \Delta=100 $ $ms$, $\lambda = 10$, and $\pi=10\%$, i.e., 500 malicious transactions. From Fig. \ref{fig:ibs_d100_l10}, increasing $k$ improves the performance of PIMS. In particular, the number of affected transactions is reduced by at least 5\%, 18\%, 26\%, and 48\% using SA, BFA, BA, and RA, respectively. Consequently, the average recovery time decreases as $k$ increases. However, PIMS incurs at least 20\%, 37\%, 50\%, and 63\% of response time overhead in SA, BFA, BA, and RA, respectively, as Fig. \ref{fig:ibs_d100_l10_res} illustrates. The reason is due to the increase in the number of boundary tuples. We note that the increase in the response time overhead is marginal as the value of $k$ increases beyond 10. Although PIMS\_BFA has the least reduction in recovery time as compared to PIMS\_BA and PIMS\_RA, PIMS\_BFA has the minimum response time overhead. We note that PIMS\_SA has less response time than PIMS\_BFA when $k<10$ because the number of boundary tuples generated by SA is less than BFA as explained in Section \ref{sec:heurPer}. However, the response time of PIMS\_SA increases dramatically for k$>$10 as the assignment skewness is higher. On the other hand, PIMS\_RA outperforms PIMS\_BFA and PIMS\_BA in terms of reducing the number of affected transactions, and thus the recovery time. PIMS\_RA incurs the highest overhead in response time. In conclusion, we note that PIMS\_BFA and PIMS\_BA produce a balanced performance in terms of recovery and response time as compared to PIMS\_RA and PIMS\_SA over a wide range of $k$ values. In the next experiment, we study the effect of the delayed access mechanism on the performance of PIMS. We compare the performance of PIMS\_BFA, PIMS\_BA, PIMS\_RA, and PIMS\_SA with delay and without delay. From Fig. \ref{fig:noDelay_aff}, the number of affected transactions is larger when the delayed access mechanism is off. The reason is that the damage propagates across the IBs. However, the shortcoming of the delayed access mechanism is the increase in the response time overhead as in Fig. \ref{fig:noDelay_res}. The reason is the increase in the number of blocked transactions due to blocking boundary tuples. The overhead is more noticeable in the case of PIMS\_RA as compared to PIMS\_BFA. In conclusion, the delayed access mechanism allows to contain the damage and reduce the recovery time in the case of PIMS\_BFA and PIMS\_BA. Moreover, PIMS with delayed access mechanism maintains a reasonable response time overhead, and thus improves the overall availability. \begin{figure}[t!] \centering \subfigure[Affected transactions]{\label{fig:noDelay_aff} \includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/affTx}}% \subfigure[Blocked transactions]{\label{fig:noDelay_blk}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/allBlocked}} \subfigure[Average recovery time]{\label{fig:noDelay_rec}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/recovery}}% \subfigure[Average response time]{\label{fig:noDelay_res}\includegraphics[width=0.5\columnwidth]{./figures/gnuplot/noHotspot_100k/noDelay/response}}% \caption{Effect of the delayed access mechanism with $\Delta=100$ $ms$, $\lambda=10$, and $\pi=10\%$.} \label{fig:noDelay} \vspace{-3 mm} \end{figure} \section{Intrusion Boundary Demarcation using Data Partitioning} \label{sec:ibf} In this section, we present a data-level model to represent intra-transaction and inter-transaction dependencies. Accordingly, we define the IB demarcation problem, and formulate it as MINLP optimization problem. Finally, we prove the problem's hardness and present two efficient heuristics to solve the IB demarcation problem. \subsection{The IB Demarcation Problem} The objective of the IB demarcation problem is to partition the tuples into $k$ partitions, i.e., IBs, with minimum overlap. The advantage of the IB demarcation is to confine the damage into a single IB, and thus increases the data availability in the presence of attacks. Notice that, the overlap among partitions depends on the inter-transaction dependency. For workloads with independent transactions, the demarcation results in non-overlapping IBs. On the other hand, for workloads with high inter-transaction dependencies the IB demarcation results in overlapping IBs. The IB demarcation is defined as follows. \begin{defn} (Intrusion Boundary Demarcation Problem (IBDP)) Given the set of transactions $T$ over a set of $n$ tuples, IBDP is to assign the transactions into $k$ IBs such that the overlap among the IBs is minimized and the sizes of the IBs are almost equal. \end{defn} \subsubsection{Problem Formulation} The demarcation of IBs is controlled by the dependencies among the tuples that are accessed by multiple transactions. We formulate IBDP as a dual-objective MINLP. The first objective function focuses on damage containment that minimizes the overlap among IBs. In order to define this objective function, we define the set of Boundary Tuples (BT) as follows. \begin{defn} (Boundary tuple) A tuple, say $o \in D$, termed a \textbf{boundary} tuples if $o$ is assigned to two or more IBs. The set of boundary tuples in the IB assignment is denoted by $BT$. Observe that BT $\subseteq ST $. \end{defn} It is sufficient to minimize the number of boundary tuples in order to minimize the overlap among IBs. Thus, the objective function can be defined as follows. \begin{equation} f_1(B) = \sum_{i=1}^n b_i \label{eq:f1} \end{equation} where B is the boundary tuples vector that indicates if a tuple is boundary, i.e., $b_k$=1 if the $i^{th}$ tuple is a boundary tuple, and 0, otherwise (notice that $|B|$ = n). The intuition behind minimizing the number of boundary tuples is to limit the damage propagation across IBs. However, Equation \ref{eq:f1} is oblivious to the number of IBs that share a boundary tuple. This number is termed the \textit{degree of sharing}. A boundary tuple that is shared between 2 IBs has less risk of damage propagation as compared to a boundary tuple that is shared among multiple IBs. The degree of sharing is incorporated in Equation \ref{eq:f1} in the following way. \begin{equation} f_1(B,\mathit{TuIB}) = \sum_{i=1}^n b_i \left( \sum_{j=1}^k \mathit{TuIB}_{ij} - 1\right) \label{eq:f1_2} \end{equation} where $\mathit{TuIB}$ is the IB assignment matrix for the tuples, i.e., $\mathit{TuIB}_{ij}$ = 1 if the $i^{th}$ tuple is assigned to the $j^{th}$ IB, and 0, otherwise. The sum $\sum_{j=1}^k \mathit{TuIB}_{ij}$ is the number of IBs to which the $i^{th}$ tuple is assigned, whereas the sum $\sum_{i=1}^n \mathit{TuIB}_{ij}$ is the size of the $j^{th}$ IB. The second objective function focuses on the overall availability. The goal of this objective function is to prevent skewed IB assignment by balancing the sizes of the IBs. Formally, the objective of balancing the sizes of IBs is defined as follows. \begin{equation} f_2(\mathit{TuIB}) = \sqrt{\sum_{i=1}^k \sum_{j>i}^k \left( \sum_{\ell=1}^n \mathit{TuIB}_{\ell i} - \sum_{\ell=1}^n \mathit{TuIB}_{\ell j} \right)^2} \label{eq:f2_1} \end{equation} Let $\mathit{TrIB}$ be the IB assignment matrix for the transactions, i.e., $\mathit{TrIB}_{ij}=1$ if the $i^{th}$ transaction is assigned to the $j^{th}$ IB, and 0, otherwise. Similarly, Let $\mathit{TuTr}$ be a binary matrix representing the association of tuples to the transactions, i.e., $\mathit{TuTr}_{ij}=1$ if the $i^{th}$ tuples is accessed by the $j^{th}$ transaction, and 0, otherwise. Although a transaction might span multiple IBs, each transaction must be fully contained within a single IB. The intuition is that by containing a transaction within an IB, the damage is confined in that IB if the transaction is detected as malicious. Accordingly, IBDP is formulated as MINLP using objective functions $f_1$ and $f_2$ as follows. \vspace{-3 mm} \begin{align} & \underset{\mathit{TuIB},\mathit{TrIB},B}{\text{Minimize }} \nonumber & & f_1(B,\mathit{TuIB}) +f_2(\mathit{TuIB})\\ \nonumber & \text{subject to} \\ & & & \sum_{j=1}^k \mathit{TuIB}_{ij} -1 \leq k b_i , \ \ \ \forall i \in \{ 1,\ldots,n\} \label{eq:c1} \\ & & & 2- \sum_{j=1}^k \mathit{TuIB}_{ij} \leq k (1-b_i) , \nonumber \\ & & & \ \ \ \forall i \in \{ 1,\ldots,n\} \label{eq:c2} \\ & & & \sum_{i=1}^{n} \mathit{TuTr}_{i\ell} - \sum_{i=1}^{n} \mathit{TuTr}_{i\ell} * \mathit{TuIB}_{ij} \geq \nonumber \\ & & & 1-\mathit{TrIB}_{\ell j} \label{eq:c3} \\ & & & \ \ \ \ \ \forall \ell \in \{ 1,\ldots,m\}, j \in \{ 1,\ldots,k\} \nonumber \\ & & & \sum_{j=1}^k \mathit{TrIB}_{ij} = 1 \ \ \ \ \forall i \in \{ 1,\ldots,m\} \ \ \ \label{eq:c4} \\ & & & \sum_{i=1}^n \mathit{TuIB}_{ij} \geq 1 \ \ \ \ \forall j \in \{ 1,\ldots,k\} \ \ \ \label{eq:c5} \\ & & & TuIB_{ij} \in \{0,1\}, TrIB_{ij} \in \{0,1\}, \nonumber \\ & & & b_i \in \{0,1\} \label{eq:c6} \\ \nonumber \label{eq:op2} \vspace{-3 mm} \end{align} The outputs of the optimization problem are the IB assignment matrix of the tuples $\mathit{TuIB}$, the IBs assignment matrix of the transactions $\mathit{TrIB}$, and the set of boundary tuples $B$. Constraints (\ref{eq:c1}) and (\ref{eq:c2}) collectively check if a tuple is assigned to multiple IBs. Accordingly, the constraints set $b_i =1$ if the $i^{th}$ tuple is boundary, and 0, otherwise. Full containment of a transaction within a single IB is checked by constraints (\ref{eq:c3}) and (\ref{eq:c4}). In particular, a transaction $t_{\ell}$ is assigned to the $j^{th}$ IB only if all the tuples access by $t\_{\ell}$ are assigned to the $j^{th}$ IB. Constraint (\ref{eq:c5}) forces the size of each IB to be at least one tuples, while constraint (\ref{eq:c6}) forces $\mathit{TuIB}$, $\mathit{TrIB}$, and $B$ to be binary matrices. \begin{theorem} IBDP is NP-hard. \label{th:ibdp} \end{theorem} \label{app:a} \subsection{Heuristics for IB Demarcation} We introduce two efficient greedy-based heuristics to solve IBDP. All algorithms take the set of transaction and the number of IBs as input. The output is a transaction-to-IB assignment. The algorithms start with an empty IB assignment and iteratively assign transactions to IBs based on greedy decisions that optimize the objective functions. The first heuristic is Best-Fit Assignment (BFA) that reduces the number of boundary tuples produced by the IB assignment. The intuition of the assignment is that BFA assigns the transaction to the IB that shares the largest number of shared tuples. The second heuristic is Balanced Assignment (BA) that assigns transactions such that the sizes of all IBs are almost equal. This is achieved by assigning, at each iteration, the transaction to the IB that is the smallest in size. Detailed discussion about each algorithm is presented in the following sections. \subsection{Best-Fit Assignment (BFA)} BFA is listed in Algorithm \ref{alg:bfa}. The algorithm starts with the empty IB assignment set $\mathcal{S}$ and empty assigned transactions set $A$ (Line 1). Then, the transactions are sorted based on the number of internal tuples in descending order (Line 2). The sorted transaction set is stored in Set $T$. Then, the algorithm initially assigns the first $k$ transactions to the empty IBs (Lines 3-9). As a result, the overlap among the IBs is minimized. This is correct because the first $k$ transactions in $T$ have the least number of shared tuples. For the remaining transactions in $T$, each transaction $t$ is assigned to the IB that shares the largest number of shared tuples with $t$ (Lines 10-19). In particular, the set of assigned transactions that overlap with $t$ is stored in $NT$ (Line 11). Then, the IBs of each transaction in $NT$ is stored in $NIB$ (Line 12). $NIB$ contains the set of all IBs that share tuples with $t$. If the set $NIB$ is not empty, $t$ is assigned to the IB that has the largest number of shared tuples with $t$ (Line 14-16). Otherwise, $t$ is assigned to the smallest IB in $\mathcal{S}$. \begin{lemma} The complexity of BFA is $O(nm^2 + knm)$. \label{lem:1} \end{lemma} \begin{proof} \label{app:pf1} BFA sorts the set of transactions based on the number of internal tuples in each transaction (Line 3). Sorting Set $T$ has a runtime complexity of $\mathcal{O}(m \log m)$. The loop in Lines 3-9 assigns a single transaction to each empty IB. Thus, the loop has a runtime complexity of $\mathcal{O}(k)$. Then, BFA assigns transactions to the best-fit IB (Lines 10-19). The runtime complexity of finding the set $NT$ and $NIB$ is $\mathcal{O}(nm)$ (Lines 11 and 12). Finding $ib_{max}$, the IB that has the largest number of tuples shared with $t$, and assigning $t$ in Lines 13-18 has a runtime complexity of $\mathcal{O}(nk)$. The runtime complexity for assigning all the transactions is $\mathcal{O}(m ( nm + nk))$. The overall complexity of BFA is $\mathcal{O}(m \log m + k + nm^2 + knm)$, i.e., approximately $~ \mathcal{O}(nm^2 + knm)$. \end{proof} \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$k$} \KwOut{$\mathcal{S}=\{ib_1,...,ib_k\}$} $\mathcal{S}=\emptyset$, $A = \emptyset$\\ $T \leftarrow$Sort transactions based on the number of internal tuples in descending order \\ \For{$i=1..k$}{ $t \leftarrow$ largest transaction in $T$ \\ $ib_i = \{ t \}$\\ $\mathcal{S} = \mathcal{S} \cup \{ ib_i\}$\\ Add $t$ to $A$\\ Remove $t$ from $T$\\ } \For{$t \in T$}{ Find $NT$ the set of assigned transaction that overlap with $t$\\ Find $NIB$ the set of IBs that overlap with $t$\\ \uIf{$NIB \neq \emptyset$}{ Find $ib_{max} \in NIB$ that has the largest number of tuples shared with $t$\\ $ib_{max} = ib_{max} \cup t$ \\ } \Else{ Assign $t$ to the smallest $ib$\\ } } \Return{$\mathcal{S}$} \caption{Best Fit Assignment} \label{alg:bfa} \end{algorithm} \section{The Architecture of PIMS} \label{sec:IMS} In this section, we introduce the architecture of PIMS. The proposed architecture for PIMS is given in Fig. \ref{fig:ims_arch}. PIMS is composed of five components: the IBDP solver, the transactions log, the Admission Controller (AC), the Response Subsystem (RES), and the Recovery Subsystem (REC). In addition, PIMS maintains a Corrupted Tuples Table (CTT) to track the status of the damage caused by the malicious transactions. The IBDP solver generates the IB assignment as discussed in the previous section. The transactions log stores information about the read/write operations of transactions. The log is essential for the recovery procedure to construct compensating transactions. The functionality of AC includes parsing the transactions, regulating the admission of transactions to DBMS, and maintaining the IB assignment table. AC determines whether to block or allow incoming transactions depending on the status of the damage and the assigned IB. When a committed transaction is identified as malicious, RES extracts the commit and detection times of the malicious transaction, approximates the set of corrupted tuples immediately, and stores it in CTT. Although the approximated set can include uncorrupted tuples, the objective is to reduce the risk of executing benign transactions that might propagate the damage unwillingly. Then, REC analyzes the inter-transaction dependency in transactions log and identifies the \textit{correct} and \textit{complete} set of affected transactions. The correct set of affected transactions means that no transactions are falsely identified as affected, while the complete set means that the set contains every affected transactions caused by the attack. We refer to this set as the set of \textbf{Affected Transactions} (AT). When AT is identified, the benign tuples are removed from CTT, and consequently can be accessed by the requesting transactions immediately. On the other hand, the corrupted tuples are blocked and will be recovered by the compensating transactions. The recovered tuples are removed from CTT gradually in order to increase the system availability. In the following sections, we present detailed information about the functionality of each component. \label{sec:ims} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth,height=5cm]{./figures/arch.pdf} \caption{PIMS Architecture.} \label{fig:ims_arch} \vspace{-3 mm} \end{figure} \subsection{Transactions Log} In order to obtain accurate information about the extent of the damage caused by the malicious transaction, the read/write operations of all transactions need to be logged. However, conventional undo/redo logs and DBMS triggers only record write operations. To address this issue, we have implemented a read/write log that records the transaction ID, the tuple ID, the before-image (the previous value), the after-image (the current value), and the time-stamp for each read and update operation. The transactions log is implemented in the DBMS kernel to reduce the overhead of logging. The transactions log is maintained as a table in the DBMS for efficient retrieval by PIMS. The transactions log is used by AC to check if a transaction reads from corrupted tuples, and by RES to identify AT. \subsection{The Admission Controller (AC)} AC has three subcomponents: the Parser, the IB Manager (IBM), and the Transaction Mediator (TM). The parser extracts the read/write set from transactions. IBM maintains in the IB table information about the IBs including the set of boundary tuples and the transaction-to-IB assignment. The functionality of IBM is to manage the access to the boundary tuples. In essence, the updated boundary tuples are locked by IBM until IDS reports the status of the updating transaction. If the transaction is identified as malicious, then the locked boundary tuples are added to CTT. Otherwise, the locked boundary tuples are released. One problem is that IDS only triggers an alarm when a malicious transaction is detected. We assume that IDS has a detection delay of $\Delta$ $ms$. The boundary tuples are locked for a sufficient time after which the updating transaction can never be detected as malicious. We set PIMS to wait for 1.5 $\times \Delta$ ms before releasing the boundary tuples. The objective of locking the boundary tuples after update is to assure that the damage does not propagate to other IBs. We refer to the process of locking the boundary tuples as \textit{delayed access} mechanism. TM checks if the transaction's read/write set contains any tuple that exists in CTT or BT. If a tuple in the read set exists in CTT, the transaction is suspended. On the other hand, if a tuple in the write set exists in CTT, then the transaction is executed, and the tuples are removed from CTT and are excluded from subsequent undo and redo operations. AC is signaled on two events: 1) the corrupted tuples are recovered, or 2) the recovery procedure is completed. When signaled, TM executes the suspended transaction if its read tuples are all recovered. Otherwise, the transaction remains suspended until a new signal is received from RES or REC. If the transaction's read/write set contains a tuple that exists in BT, then the transaction is suspended until the tuples are released by IBM. Before executing the transaction, AC acquires the locks associated with the assigned IB(s). The lock is to ensure that no concurrent recovery procedure is running on the IB(s). The lock is released by AC when the transaction is executed successfully. The overall procedure for admission control is listed in Algorithm \ref{alg:adm}. Notice that multiple instances of the admission controller can be executed using multiple threads to increase transaction concurrency. We rely on the available Concurrency APIs to queue the incoming transactions when TM threads are busy waiting for signals. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_i$} \KwOut{} $RW_{t_i} \leftarrow$ the read/write tuples set $t_i$\\ \While{$RW_{t_i} \cap BT \neq \emptyset$}{ Wait until the requested $BT$ is released\\ } \While{$ RW_{t_i} \cap CTT \neq \emptyset$ }{ Wait until request tuples in CTT are recovered and released\\ } \tcc{Wait until lock is acquired} Acquire lock on $IB_{t_i}$ \\ Execute $t_i$\\ Release lock on $IB_{t_i}$\\ \caption{Admission control} \label{alg:adm} \end{algorithm} \subsection{The Response Subsystem (RES)} RES is activated when a transaction $t_m$ is detected as malicious by IDS. The objective of RES is to prevent subsequent benign transactions from reading corrupted tuples that are updated by $t_m$, and thus control the spread of the damage. RES collects the time information about $t_m$ from IDS and the transactions log, i.e., the commit timestamp $t_m^c$ and the detection timestamp $t_m^d$. Moreover, RES extracts $IB_{t_{m}}$, the set of IBs that are spanned by $t_m$, from the IB table. Consequently, RES adds all tuples in $IB_{t_m}$ that have been updated between $t_m^c$ and $t_m^d$ to CTT. Notice that the tuples that are updated between $t_m^c$ and $t_m^d$ but not assigned to $IB_{t_m}$ are not added to CTT. Thus, PIMS provides more accurate damage confinement as compared to ITDB, which blocks all tuples on temporal basis only. Nevertheless, CTT might contain uncorrupted tuples updated by benign transactions that are independent from $t_m$. Once enough information about the inter-transaction dependencies between $t_m$ and subsequent transactions is gathered, PIMS removes the uncorrupted tuples from CTT as explained in the next section. The procedure of RES is summarized in Algorithm \ref{alg:res}. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_m, t_m^d$} \KwOut{Updated $CTT$} $t_m^c$ $\leftarrow$ get commit time of $t_m$\\ Find $IB_{t_m}$ the set of IBs spanned by $t_m$\\ \For{tuples updated between $t_m^c$ and $t_m^d$}{ \If{tuple is assigned to an $IB \in IB_{t_m}$}{ Add tuple to $CTT$ } } \caption{Intrusion Response} \label{alg:res} \end{algorithm} \subsection{The Recovery Subsystem (REC)} \label{sec:RES} REC is the core component of PIMS that identifies AT and executes compensating transactions for the corrupted tuples. The compensating transactions perform two operations: \textit{undo} and \textit{redo}. The undo operation unwinds the effect of the malicious transaction and each transaction in AT. By performing the undo operation, the state of the DBMS returns to the state just before the malicious transaction is executed. However, the update operations performed by the subsequent benign transactions are lost. The redo operation preserves the lost updates by re-executing each transaction in AT. Notice that the malicious transaction is not re-executed because its updates are undesirable. \begin{algorithm}[t!] \small \SetNlSty{normal}{}{.} \KwIn{$t_m, IB_{t_m}$} \KwOut{Updated CTT} Acquire recovery lock in every $IB \in IB_{t_m}$\\ Block new transactions in $IB_{t_m}$\\ Wait for currently running transaction in $IB_{t_m}$ to commit\\ Find the set of affected transaction $AT_{t_m}$ \\ Find the $S$ set of all updated tuples by $t_m$ and $t_a \in AT$\\ Resume new transaction in $IB_{t_m}$\\ \For{$o \in CTT$}{ \If{$o \notin S$}{ Remove $o$ from CTT and flag as valid } } Resume transactions to $IB_{t_m}$\\ \tcc{ Phase \RNum{1}} Undo $t_m$\\ \For{$T_a \in AT_{t_m}$}{ Undo $T_a$ \\ } \tcc{ Phase \RNum{2} } \For{$T_a \in AT_{t_m}$}{ Redo $T_a$ \\ } \caption{Intrusion Recovery} \label{alg:rec} \end{algorithm} The overall algorithm for REC is listed in Algorithm \ref{alg:rec}. REC is activated once the response procedure is finished. Thus, the response and recovery transactions are executed serially. Serializing the response and recovery procedures is essential since the recovery mechanism uses CTT that is updated by the response subsystem. REC temporarily blocks new transactions to prevent new transactions from reading the corrupted tuples while REC identifies AT. This is achieved by acquiring locks on $IB_{t_{m}}$. Incoming transactions are blocked by AC. Notice that the active transactions are not preempted. When all active transactions are committed, the \textit{Dependency Analyzer} scans the transactions log starting from $t_m^c$ through the current timestamp in order to find AT. The write set of each transaction in AT is extracted and is added to CTT. The \textit{Damage Assessment} subsystem removes the uncorrupted tuples that have been initially added by RES from CTT. At this point, CTT contains the correct and complete set of the corrupted tuples caused by $t_m$. The \textit{Compensation Manager} (CM) executes a sequence of compensating transactions that gradually repair the damage. Damage repair is performed in two phases. In Phase 1, CM executes compensating transactions that unwind the effect of the malicious and affected transactions. CM uses the transactions log table to find the correct version of the corrupted tuples. In particular, CM updates the corrupted tuples with the values of the most recent versions before the execution of the malicious transaction. The compensating transactions are executed in the order at which the malicious and affected transactions are committed. At the end of this phase, \textit{Damage Cleansing} (DC) removes the recovered tuples from CTT and signals AC to resume any blocked transactions. In the second phase, CM executes compensating transactions that re-execute each transaction in AT in the same order at which they are committed. The information required to re-execute the transactions, e.g., old balance, is maintained in the transactions log. Once an affected transaction is re-executed successfully, DC removes the set of recovered tuples from CTT and signals AC. \subsection{Managing Multiple Malicious Transactions} The advantage of partitioning the tuples into IBs is to execute concurrent response and recovery procedures on different IBs. The reason is that all transactions in AT are guaranteed to be contained in $IB_{t_m}$. As a result, concurrent recovery procedures do not perform conflicting operations while recovering the corrupted tuples. Multiple instances of response and recovery procedures are executed using multiple threads. In the case when multiple malicious transactions are detected within the same IB, the recovery procedures need to be coordinated to avoid out-of-order execution of the recovery operations. The strategy is to execute the recovery procedures for the malicious transactions in the same order in which they are detected. \section{Introduction} Data-intensive applications exhibit increasing reliance on efficient and scalable Database Management Systems (DBMSs). Examples of these applications are abound in the domain of banking, manufacturing, health care, and enterprise applications \cite{chen2014data}. Since data is the most valuable asset in organizations, it is crucial to design attack-resilient DBMSs to protect the confidentiality, integrity, and availability of the data in the presence of Cyber attacks \cite{stoneburner2002sp,bertino2005database}. Although research in database security has made significant progress in protecting from Cyber attacks, applications and infrastructures are still exposed to a large number of vulnerabilities. Even a single intrusion can cause catastrophic cascading effects due to data dependency and application interoperability. Therefore, a holistic approach for designing an intrusion management mechanism that includes intrusion detection, response, and recovery is needed \cite{kamra2011design,ammann2002recovery}. An Intrusion Detection System (IDS) is integrated with the DBMS to prevent Cyber attacks. The objective of an IDS is to monitor and detect illegal access and malicious actions that take place in the database. However, an IDS is not designed to repair the damages caused by successful attacks. IDS is often integrated with intrusion response and recovery mechanisms to alleviate the damage caused by the malicious attacks \cite{kamra2011design}. Several efforts have been directed towards developing dynamic damage tracking approach to perform on-the-fly damage repair, for example intrusion-tolerant database systems \cite{liu2004design,ammann2002recovery}. However, such systems have limitations in the ability to maintain high availability under severe intrusion attacks. One of the limitations for these systems is the prolonged recovery time due inter-transaction dependency. {\bf{Motivating Example:}} \textit{Fig. \ref{fig:motsc} gives an example scenario for a Banking system with three benign users (B,C, and D), and a malevolent user (A). User A executes a malicious transaction that updates accounts $X$ and $Y$ with incorrect amounts of money as illustrated in Fig. \ref{fig:motsc}. Then, Users B and C withdraw from accounts $X$ and $Y$, respectively. IDS detects the malicious transaction executed by User A and triggers an alert to the database security administrator that temporarily blocks the incoming transactions and starts the recovery procedure. Meanwhile, User D attempts to access account $Z$. However, this request is denied until the damage is recovered. When the recovery transaction is finished, the accounts of Users A and B are compensated, i.e., withdraws money from account $X$ and credits account $Y$.} In the above example, the recovery time depends on the number of dependent transactions that are executed before the IDS detects the malicious transaction. Consequently, the availability of the DBMS is impaired when the recovery procedure takes a long duration. Therefore, it is important to contain the damage once malicious transactions are detected. Containment of the damage can be achieved by tracking the inter-transaction dependencies and devising a fast confinement strategy to contain the damage. In this paper, we propose a new real-time response and recovery architecture, termed Partition-based Intrusion Management System (PIMS), for DBMSs. We assume that existing IDS, e.g., \cite{kamra2011design,shebaro2013postgresql}, can be integrated with PIMS. PIMS is based on an adaptive access and admission control mechanism that responds to intrusions by selectively blocking segments of data that have been affected by the intrusion. The access control mechanism provides a fine-grained control policy to allow graceful degradation of database services in order to maintain a desired level of availability while the system is undergoing through impending attacks. The unique feature of PIMS is the deployment of a data partitioning technique to confine the damage and improve the availability of the system. The contribution of this paper is summarized as follows. First, we propose the concept of Intrusion Boundary (IB) that defines the extent of the damage over the set of transactional workload. We formulate the IB demarcation as an optimization problem as a Mixed Integer Non-Linear Programming model (MINLP). The output of the optimization problem is a balanced IB assignment of transactions to partitions with minimum overlapping. We prove that the IB demarcation problem is NP-hard. Accordingly, we introduce two heuristics to provide a polynomial time solution. Finally, we introduce response and recovery mechanisms that use the proposed IB assignment to improve the intrusion response and recovery in terms of availability and response time. The rest of the paper is organized as follows. Section \ref{sec:bg} presents relevant background. Section \ref{sec:ibf} presents the definition and formulation of the IB demarcation problem, its hardness proof, and present two new heuristics. Section \ref{sec:IMS} describes the design and implementation of PIMS. The performance evaluation and the experimental results of PIMS are presented in Section \ref{sec:exp}. The related work is presented in Section \ref{sec:related}. Finally, Section \ref{sec:conc} concludes the paper. \begin{figure}[t!] \centering \includegraphics[width=\columnwidth,scale=0.5]{./figures/motsc.pdf} \caption{Motivating example.} \label{fig:motsc} \vspace{-3 mm} \end{figure} \section*{Proof of Theorem \ref{th:ibdp}} \label{app:a} \begin{proof} \end{proof} \section{Related Work} \label{sec:related} Security measures in DBMSs includes the protection of data confidentiality, integrity, and availability \cite{nist2002risk,bertino2005database}. A broad span of research addresses the protection of data confidentiality in DBMSs including authorization, e.g., \cite{chaudhuri2007fine}, access control, e.g., \cite{sandhu1996role}, encryption, e.g., \cite{sarfraz2015dbmask}, and inference and disclosure control, e.g., \cite{chen2008protection}. The integrity risk data in DBMSs is jointly prevented by using access control mechanisms and semantic integrity constraints to verify the correctness of the database state after updates\cite{bertino2005database}. The availability of data is protected by providing fault-tolerance \cite{fault-tolerancegashi}, replication \cite{patino2005middle}, and intrusion detection techniques \cite{milenkoski2015evaluating}. In the case of successful intrusion attacks, the effects of the committed transactions are undesirable. The methodology of undoing a committed transaction can be generally handled by one of two approaches: rollback or compensation. The rollback approach is achieved by rolling back all desirable and undesirable activities to a point that is free from damage \cite{mohan1992efficient}. On the other hand, compensation approach unwinds the effect of selective committed transactions by executing special compensating transactions. The compensation operations are either action-oriented or effect-oriented \cite{korth1990formal}. In this paper, we follow an effect-oriented compensation approach to recover from the damage caused by the malicious and affected transactions. Several solutions have been proposed for intrusion recovery in database-backed applications. A generic intrusion-tolerant architecture for web-servers uses redundancy and diversification principles proposed in \cite{saidane2009design}. In \cite{chandra2011intrusion}, WARP is proposed to recover from intrusions in web-applications by rolling back the database and replaying subsequent legitimate actions to correct the state of the DBMS. In \cite{pardal2017rectify}, an intrusion recovery tool for database-backed applications running in Platform-as-a-Service clouds is proposed. The tool uses machine learning techniques to associate the application requests to the DBMS statements, and then uses existing recovery algorithms to recover from the damage in the DBMS. PIMS is designed as a middle-layer between the DBMS and the application that performs automatic intrusion response and recovery in the DBMS independently from the running applications. Previous work in intrusion recovery in DBMSs can be broadly classified into two categories: transaction-level and data-level approaches. In the transaction-level approach, the general direction is to selectively rollback or compensate for the damaged tuples. In \cite{ammann2002recovery}, a suite of recovery algorithms is proposed to unwind the effect of malicious transactions for offline and online recovery. In \cite{liu2004design,bai2009data}, the authors present ITDB and DTQR, respectively, that implement the recovery algorithms in \cite{ammann2002recovery} on top of a Commercial-Off-The-Shelf DBMS. In \cite{chiueh2008accurate}, a damage assessment and repair system, termed Phoenix, is introduced. The core component in Phoenix is the inter-transaction dependency tracking that maintains such persistent dependency information at run-time. On the other hand, data-dependency approach provides a flexible recovery at the object-level. In \cite{panda2002extended}, a damage assessment technique using data dependency analysis is proposed to obtain precise information about the set of corrupted data. PIMS uses a hybrid approach between data-level dependency and transaction-level approach to track the damage. In particular, the damage assessment is performed at the data-level, while the response and recovery procedures are performed at the transaction-level. Moreover, PIMS addresses the problem of prolonged online recovery procedure in \cite{ammann2002recovery}. Date partitioning schemes are used to improve the availability and scalability of the DBMS. In \cite{curino2010schism}, a workload-aware approach for partitioning the data is proposed. The partitioning approach models the data objects as a graph that is then partitioned into $k$ balanced partitions such that the number of distributed transactions is minimized. In \cite{quamar2013sword}, a scalable workload-aware data placement that uses hyper-graph compression techniques to deal with large-scale datasets is proposed. Online partitioning techniques adaptively partition data based on emerging hotspots, workload skews, and load spikes. In \cite{turcu2016automated}, a methodology for using automatic data partitioning that prefers partitions with independent transactions is proposed. In \cite{taft2014store}, E-store is proposed that provides an elastic planning and reconfiguration system to mitigate the challenges paired with workload skews. None of the above partitioning scheme considers the security aspects of DBMS. The IB demarcation scheme partitions the workload with the objective to improve the availability by confining the damage caused by intrusion attacks.
{'timestamp': '2018-10-09T02:03:17', 'yymm': '1810', 'arxiv_id': '1810.02061', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02061'}
arxiv
\section{Introduction}\label{sec:introduction}} \else \section{Introduction} \label{sec:introduction} \fi \IEEEPARstart{P}{rocedural} content generation (PCG) algorithms are increasingly being used to derive new content for a wide variety of games\cite{PCGSURVEY}. Using the PCG taxonomy described by Togelius et al. \cite{SBPCG}, PCG can occur {\it offline} (beforehand) or {\it online} (dynamically during the game), the content can be {\it constructed} by a system of rules, or use a {\it generate-and-test} process to winnow potential candidates for inclusion in the game, and the algorithm can be {\it deterministic} and fixed or {\it stochastic}, incorporating randomness. Following the puzzle terminology of Browne \cite{PUZZLENATURE}, such that there is a setter who creates challenges and a solver who solves them, we can apply the above PCG terminology to puzzle design. Setters typically {\it construct} their challenges using creative yet {\it deterministic} means. Researchers have explored using PCG to replace the setter, employing metaheuristics to find interesting challenges for deductive logic puzzles, ranging from Sudoku \cite{SUDOKU} to Nonograms \cite{NONOGRAM}. These algorithms construct their challenges offline or online, and guarantee they are solvable, but substitute {\it stochastic} algorithms for the creative human process. Khalifa and Fayek\cite{PUZZLELANG} investigated a combination of construction and generate-and-test PCG for Sokoban and related games within a genetic algorithm framework, and this approach was extended to Monte Carlo Tree Search by Kartal et al. \cite{SOKOBAN}. A less-explored variety of puzzle with relation to PCG are physical solitaire games, for example sliding block puzzles \cite{FIFTEEN} (including Rush Hour\footnote{https://www.thinkfun.com/products/rush-hour/}), and Hi-Q (generalized peg solitaire) \cite{PEG}. In these games, solvers must manipulate physical pieces to solve a challenge. Since the initial setup for these games must be executed by the solver, providing the solver with predefined challenges created offline and a solution book is common practice. PCG can also be applied to these games by, again, constructing challenges offline and guaranteeing they are solvable, as seen in recent work by Fogleman \cite{RUSHHOUR} and K{\"o}pp \cite{TANGRAM}. There are, however, alternative PCG approaches available for physical solitaire games, most popularly demonstrated by the card game Klondike Solitaire \cite{morehead2014complete}. In particular, this game uses an {\it online, stochastic, generate-and-test} PCG algorithm, which is as simple as shuffling the deck of cards at the start of the game. Also of note, the {\it test} portion of the generate-and-test algorithm is left to the solver as they play through the game. Wolter \cite{SOLITAIREVARIANTS} developed the Politaire system, and examines the effect of various shuffling algorithms across multiple solitaire card game variations. One variant called Thoughtful Solitaire, played such that all card locations are known to the solver at the beginning of the game, has been separately found to have between 82\% and 91.44\% of generated challenges solvable \cite{THOUGHTFUL}. While some claim that solitaire games with potentially unwinnable challenges are ``a rather sad form of amusing oneself," \cite{de1981pretzel} others find a ``catharsis [in] patience" even without perfect solvability \cite{morehead2014complete}. Thus, to address either side, when designing such a random setup process to assemble a challenge, two questions naturally arise for the designer:{\it What percentage of such challenges can be solved? Are the created challenges interesting?}\cite{MCPUZZLE} Also, since these puzzle challenges are instantiated by the solver, they are restricted to using only the components included in the puzzle. However, as much of PCG research involves digital games and puzzles, where algorithms are only limited by computational time and space constraints, there is little research into the relationship between the structural design of physical puzzle components and PCG. To understand this component/algorithm relationship, we examine three different styles of physical solitaire games with perfect information that incorporate {\it online, stochastic, generate-and-test} PCG algorithms for challenge setup: BoxOff \cite{BoxOffGAMES} , a token removal puzzle, Pretzel \cite{de1981pretzel} , a card arrangement puzzle, and Fujisan\footnote{http://www.ludism.org/ppwiki/Fuji-san}, a transportation puzzle. Each of these puzzles includes a basic algorithm where simple components (tokens or cards) are randomly shuffled to create a challenge. We define these components to become {\it entangled} if their arrangement is no longer independent, either due to algorithmic constraints, or having been subsumed by new, larger components. We provide detailed descriptions of entangled game components and challenge setup algorithms for each game, then compare and contrast these using computational Monte Carlo simulations. Finally, we evaluate these algorithms with respect to solvability and interest. We find that entanglements that incorporate desirable constraints based on each puzzle's mechanics are more successful across both metrics. \section{BoxOff} \begin{figure}[t] \centering \includegraphics[width=6.8cm]{boxoff6x83.png} \caption{A sample 6$\times$8 BoxOff challenge with three colors.} \label{fig:boxoffbig} \end{figure} \noindent BoxOff is a 2D token removal puzzle designed by Stephen Myers \cite{BoxOffGAMES}. Challenges for this puzzle consist of a 6$\times$8 grid of squares filled with exactly 16 each of three colors, an example of which is shown in Figure \ref{fig:boxoffbig}. The challenge is solved when every square in the grid has been eliminated. The solver can eliminate two squares of the same color at a time if either of the following two rules apply. \begin{enumerate} \item The two squares are adjacent. \item All other squares inside the box that circumscribes the two squares have previously been eliminated.\footnote{Rule 1 is actually subsumed by this rule, however, we find it helpful to separate them into two cases to facilitate our component design discussions.} \end{enumerate} Figure \ref{fig:boxoffrules} shows an in-progress BoxOff challenge. The solver has a few options available, two of which are highlighted in dashed boxes. They could eliminate the two yellow squares in the upper-left quadrant using Rule 1, or eliminate the two blue squares in the middle using Rule 2. An invalid move is also shown in the upper right quadrant, where Rule 2 would not apply because of the blue square in the circumscribed box around the two red squares. \begin{figure}[t] \centering \includegraphics[width=6.8cm]{boxoffrules1.png} \caption{Application of Rules 1 and 2 to an in-progress BoxOff challenge, and an illustrative invalid move.} \label{fig:boxoffrules} \end{figure} Browne and Maire previously investigated altering the game design parameters for BoxOff using Monte Carlo simulation \cite{MCPUZZLE}. They explored multiple grid sizes and numbers of colors, $(h, w, c)$, where $h \times w$ is the size of the grid, and $c$ is the number of colors, ultimately finding that challenges generated for the original (6, 8, 3) puzzle configuration described by Myers were highly solvable and robust against random solvers. Other configurations, either of smaller board sizes, or more colors, exhibited poor solvability. In particular, we will examine the (4, 6, 4) puzzle, where challenge solvability was approximately 25\%, and the (6, 6, 6) puzzle, where challenge solvability was less than 5\%. \subsection{Components and Algorithms} \noindent Here we discuss two different sets of physical components and their resulting PCG algorithms that can be used for challenge setup for Boxoff. The components of a physical BoxOff puzzle consist of circular tokens equal to the number of grid squares. These tokens are equally distributed among the number of colors. With these components, the solver can employ a simple shuffling algorithm to create a challenge. \begin{quote} {\it \bf Shuffled:} Shuffle the color tokens randomly, and arrange them into a grid. \end{quote} We can use the multinomial theorem to determine that this method can create $\frac{(hw)!}{c!^{k}}$, where $k=\frac{hw}{c}$. In the (4, 6, 4) puzzle this is $\approx 10^{11}$ possible challenges. We acknowledge here and in subsequent calculations that rotational, horizontal, and vertical symmetry will alter the precise number of challenges, but not by an order of magnitude. This shuffling works very well on moderate sized boards with few colors, achieving near 100\% solvability, but as demonstrated by Browne and Maire, it suffers when applied to more colors, as shown in Figure \ref{fig:boxoff666}. The uniform nature of the shuffling appears to prevent a critical mass of adjacent tokens of the same color. Such adjacent tokens are the only way Rule 1 above can be fulfilled so that more distant tokens can then be eliminated via Rule 2. \begin{figure}[t] \centering \includegraphics[width=5.6cm]{boxoff666basic1.png} \caption{A sample (6, 6, 6) BoxOff challenge, generated with a simple shuffle of the 36 color tokens. } \label{fig:boxoff666} \end{figure} \begin{figure}[t] \centering \includegraphics[width=5.6cm]{boxofftiles1.png} \caption{Sample L-Tiles for BoxOff challenge creation. Tiles can be rotated 180 degrees, and the dashed line shows how they can be flipped. } \label{fig:ltiles} \end{figure} To address this issue, we introduce an {\it entangled} abstraction for creating challenges using L-shaped tiles, as shown in Figure \ref{fig:ltiles}. These tiles allow us to entangle the colors on the tiles to create particular local color distributions. Our goal in creating these tiles is to encourage more adjacent tokens of the same color. However, we also must avoid creating situations where all tiles are adjacent to tokens of the same color, else the puzzle becomes trivial to solve. For both the 4$\times$6 and 6$\times$6 grids, each tile is composed of exactly two squares of the same color, which we label $S$, and one square of a different color, labeled $D$. Each color is chosen as $S$ twice to ensure an equal distribution of the adjacent squares. We then distribute the third square colors using a cyclic arrangement of the colors, as shown in Figure \ref{fig:boxoffcycle}, where arrows are drawn from $S$ to $D$ for each tile in the set. To increase the number of possible challenges, these tiles can be flipped to a mirror image along the center square of the L. \begin{figure}[t] \centering \includegraphics[width=8.8cm]{boxoffcycle1.png} \caption{Cycle of color connections used to construct L-Tiles for BoxOff challenges, (4, 6, 4) on the left, and (6, 6, 6) challenges on the right.} \label{fig:boxoffcycle} \end{figure} Each of these tiles has two possible orientations, for a total of $2^{t}t!$, where $t=\frac{hw}{3}$, for $\approx 10^{6}$ possible challenges in the (4, 6, 4) puzzle. The algorithm to create a challenge then is as follows: \begin{quote} {\it \bf L-Tiles:} Shuffle and flip the tiles randomly, then arrange into a grid of connected 2$\times$3 subgrids. \end{quote} Figure \ref{fig:boxofftiles} shows a (4, 6, 4) grid created with L-tiles. To physically play BoxOff with this tile setup, the solver will need to place neutral tokens on each square as they are eliminated, continuing until the board is full of tokens. We note that this provides an additional advantage of preserving the challenge throughout play; should the solver fail, all neutral tokens can be removed from the tiles and another attempt to solve the challenge can be made. \begin{figure}[t] \centering \includegraphics[width=5.6cm]{boxoff46tiles1.png} \caption{A sample (4, 6, 4) BoxOff challenge, generated using L-Tiles. } \label{fig:boxofftiles} \end{figure} \subsection{Evaluation} \noindent We encoded a Monte Carlo BoxOff challenge generator using C\#, and implemented a breadth-first solver for BoxOff challenges. For each PCG algorithm, we generated 1000 random challenges. For each generated challenge in our trials, we recorded if the challenge was solvable. The code used for our simulations for this and subsequent puzzles is available on Github \footnote{http://github.com/mgoadric/entangled-components}. To enable testing for statistical significance on solvability between these algorithms, we divided our pool of generated challenges into 10 trials of 100 challenges. We repeated this for both the (4, 6, 4) puzzle and the (6, 6, 6) puzzle. We will use two criteria to quantify each of the above components and algorithms. First, we judge a PCG algorithm to be working well when a high percentage of generated challenges are solvable by our solver. Beyond solvability, we also wish for PCG algorithms to maintain or improve on the challenge interest for the basic \textbf{Shuffled} algorithm. \subsubsection{Solvability} \begin{figure}[t] \includegraphics[width=8.8cm]{boxoffsolvability.png} \caption{Effect of challenge generation algorithms on solvability for BoxOff (4, 6, 4) and (6, 6, 6). $P(S_p)$ denoted in red with hatching, and $P(S_r)$ shown in blue with dots.} \label{fig:boxoffsolvediff} \end{figure} Figure \ref{fig:boxoffsolvediff} shows the challenge solvability, in red with slashes, for the (4, 6, 4) BoxOff. This plot displays the distribution of the two PCG algorithms across the 10 trials in a box-and-whisker plot. We found the {\bf L-Tiles} setup method produces solvable challenges at a rate of 88\%, a marked increase over the {\bf Shuffled} probability of 27\%, with this difference being statistically significant. Similarly, Figure \ref{fig:boxoffsolvediff} also shows the solvability distributions in red for the (6, 6, 6) puzzle. We again saw a drastic increase in solvability, moving from 3\% for {\bf Shuffled} up to 57\% for {\bf L-Tiles}. \subsubsection{Interest} Following Browne and Maire \cite{MCPUZZLE}, if a challenge is solvable by the solver choosing random moves each time, then the challenge lacks interest. Denoting the probability of solvability using the breadth-first search solver as $P(S_p)$ and the probability of the random solver as $P(S_r)$, we can calculate $P(S_p) - P(S_r)$, the difference between the intelligent and random solvability. Figure \ref{fig:boxoffsolvediff} also shows, in blue with dots, the solvability rate for these algorithm when using a random solver. We see in both cases for {\bf L-Tiles}, there is an increase in the random solver performance over {\bf Shuffled}. However, there remains a significant gap between the general and random solvability in both puzzles. For the (4, 6, 4) puzzle, this difference is 62\%, and for the (6, 6, 6) puzzle, this difference is 50\%. We can conclude that while more easy challenges are generated from {\bf L-Tiles}, the large majority of generated solvable challenges involve interesting solutions. \section{Pretzel} \noindent The Montana family of patience card games includes variations such as Gaps, Spaces, Vacancies, Clown, Paganini, Red Moon, and Blue Moon. One variant, which allows no re-shuffles or re-deals, is a puzzle described and named by de Bruijn \cite{de1981pretzel} called Pretzel solitaire. To set up a Pretzel challenge, denoted as $(k, n)$, where $k$ represents the number of suits and $n$ represents the number of ranks in each suit, the solver shuffles a deck containing one card for each of $n$ ranks in $k$ suits. The shuffled cards are dealt face-up into a grid with $k$ rows, each with $n$ columns. The solver then removes the lowest ranked card of each suit (traditionally aces) and places them in a new column to the left of the existing grid in a prescribed order (traditionally for four suits, from top to bottom: spades[$\spadesuit$], hearts[$\heartsuit$], diamonds[$\diamondsuit$], clubs[$\clubsuit$]). Doing so vacates $k$ cells in the grid, thereafter called holes. The solver's goal is to arrange all cards into ascending sorted order, one suit per row, following a single rule: \begin{enumerate} \item A card may be moved from any grid location into any hole only if the card being moved is of the same suit and exactly one rank higher than the card immediately to the hole's left. \end{enumerate} \begin{figure}[t] \centering \includegraphics[width=7cm]{pretzel4x8.png} \caption{Pretzel solitaire challenge with four suits and eight ranks, generated with the Sequential Suits method.} \label{fig:pretzelsequential} \end{figure} \subsection{Components and Algorithms} \noindent Here we explore different PCG algorithms that can be used for Pretzel challenge setup. Each algorithm uses the features of the existing components, a standard French deck of cards, in different ways. We start with the traditional method of straightforwardly shuffling and dealing. \begin{quote} {\bf Shuffled:} Shuffle the entire deck and deal all cards into the grid, left to right, top to bottom. \end{quote} The number of possible challenges that result from the standard shuffle is the total number of permutations of cards in the deck, namely $(kn)!$. For the (4, 4) case, this is $16! \approx 10^{13}$ distinct challenges. In his paper, de Bruijn empirically established a solvability of 45\% for the (4, 4) case with a \textbf{Shuffled} setup. In an attempt to improve solvability with the next two setup algorithms, we introduce \textit{entanglement} of the cards by first dividing the deck into smaller decks according to suit. The two algorithms differ in how they distribute these \textit{entangled} components to complete the setup. Although the \textit{entanglement} is not preserved during play, the lasting effects of deck substitution during setup are nonetheless observable by measures similar to the other games we explored. \begin{quote} {\bf Sequential Suits:} Divide the deck into $k$ smaller decks, each comprising all cards of a single suit. Shuffle each suit deck separately. Deal the top card from the first suit deck, then the top card from the second suit deck, and so on. After the top card of each suit deck has been dealt, return to the first suit deck and deal the top card, then the top card of the second suit deck, and so on. Proceed in like fashion until all cards have been dealt, left to right, top to bottom. \end{quote} Figure \ref{fig:pretzelsequential} shows a sample Pretzel solitaire challenge with four suits and eight ranks, generated with the \textbf{Sequential Suits} method. The \textbf{Sequential Suits} setup algorithm generates $n!^{k}$ possible challenges. For the sake of comparison with \textbf{Shuffled}, the (4, 4) case with \textbf{Sequential Suits} provides $4!^{4} \approx 10^{5}$ distinct challenges. Depending on the ratio of $k$ to $n$, challenges generated by this algorithm exhibit various distinct vertical or diagonal suit patterns across the play grid. After observing some gains in solvability arising from such patterns, we pushed the pattern to its logical limit: \begin{quote} {\bf Banded Suits:} Divide the deck into $k$ smaller decks, each comprising all cards of a single suit. Shuffle each suit deck separately. Deal all cards from the first suit deck \textbf{top to bottom, left to right}. After each suit deck is exhausted, continue dealing with the next suit deck. Proceed in like fashion until all cards have been dealt, \textbf{top to bottom, left to right}. \end{quote} Dealing the cards from top to bottom, left to right is essential to the \textbf{Banded Suits} algorithm. In other words, the solver deals the first card into the upper-left location in the grid, then deals the next directly below the first in the same column, and so on. Only as each column is filled are cards dealt into the next column to the right. The result is $k$ bold, vertical suit bands. As with \textbf{Sequential Suits}, distinct challenges created from \textbf{Banded Suits} is equal to $n!^{k}$. Also, note that \textbf{Sequential Suits} and \textbf{Banded Suits} produce identical suit patterns when $k = n$, but differing patterns for $k \neq n$. \subsection{Evaluation} \noindent As with BoxOff, we encoded a Monte Carlo Pretzel challenge generator using C\#, and a breadth-first solver for Pretzel challenges. For each PCG algorithm, we generated 1000 random challenges. For each generated challenge in our trials, we recorded whether the challenge was solvable, and if so, we also recorded the minimum solution length found with our solver. To enable testing for statistical significance on solvability between these algorithms, we divided our pool of generated challenges into 10 trials of 100 challenges. \subsubsection{Solvability} \begin{figure}[t] \includegraphics[width=8.8cm]{pretzelfulln.png} \caption{Effect of challenge generation algorithms on solvability for Pretzel, four suits and 2-9 ranks.} \label{fig:pretzelfullsolve} \end{figure} \begin{figure}[t] \centering \includegraphics[width=8cm]{pretzel48length.png} \caption{Histograms showing the effect of Pretzel challenge generation algorithms on solution length, four suits and eight ranks.} \label{fig:pretzellength} \end{figure} \begin{figure}[t] \includegraphics[width=8.8cm]{pretzelfullinterest.png} \caption{Effect of challenge generation algorithms on $P(S_p) - P(S_r)$ for Pretzel, four suits and 2-9 ranks.} \label{fig:pretzelinterest} \end{figure} Figure \ref{fig:pretzelfullsolve} compares the solvability of our three setup algorithms for four suits and two through nine ranks per suit. Solvability is displayed using the blue dotted line for \textbf{Shuffled}, the orange dashed line for \textbf{Sequential Suits}, and the solid green line for \textbf{Banded Suits}. Although the number of ranks is always a whole number, and intermediate, fractional rank values are therefore not sensible, we have used continuous lines in the figure to better depict overall trends for all algorithms tested and to highlight the oscillating nature of solvability for \textbf{Sequential Suits}. We found that whether entanglement helped or hindered solvability when using the \textbf{Sequential Suits} setup algorithm is dependent on whether the number of ranks in the deck is even or odd. We also observed a marked increase in solvability with \textbf{Banded Suits} as compared to \textbf{Shuffled}, with the increase being statistically significant for all ranks tested. We include more details on the success of entangled components in Section \ref{entangled}. The cost of solvability gains for \textbf{Banded Suits} is a decrease in minimum required solution length (in moves) which became statistically significant as the number of ranks increased. As a specific example, Figure \ref{fig:pretzellength} graphs the distribution of minimum required solution lengths recorded by our breadth-first solver for each of the setup algorithms in the (4, 8) case. The median minimum required solution lengths for \textbf{Shuffled} and \textbf{Sequential Suits} were identical at 44, while the median for \textbf{Banded Suits} dipped to 42. As with BoxOff, however, we judge the interest of challenges not primarily by their solution lengths, but by their resistance to random play. \subsubsection{Interest} Again denoting the probability of solving using the breadth-first search solver as $P(S_p)$ and the probability of the random solver as $P(S_r)$, we calculated $P(S_p) - P(S_r)$ using each of the setup algorithms across two through nine ranks in four suits. The results are shown in Figure \ref{fig:pretzelinterest}. The blue dotted line displays this value for \textbf{Shuffled}, the orange dashed line represents \textbf{Sequential Suits}, and the solid green line shows \textbf{Banded Suits}. Here we see that \textbf{Banded Suits} exhibits the desired resistance to random play. For (4, 4) Pretzels, \textbf{Sequential Suits} and \textbf{Banded Suits} perform similarly. This is expected since they produce identical suit patterns for this case. But at five ranks and beyond, intelligent play outpaces random play by a significant margin as compared with \textbf{Shuffled} and \textbf{Sequential Suits}. We conclude that despite a slight decrease in minimum required solution length for \textbf{Banded Suits}, interest is retained. \section{Fujisan} \noindent Fujisan was created specifically for the piecepack game system \cite{GAMESYSTEM}. In Fujisan, a solver must find a way to cooperatively move four Shinto Priests to the top of Mt. Fuji through incremental steps up the mountainside. Functionally, the area of play consists of a grid of spaces arranged into two rows by twelve columns. Each space contains a single value in the range of 0 to 5, inclusive. The two middle columns together comprise the mountain {\it summit}, while each other column forms a {\it step} of the mountain. Four pawns, representing the Priests, start off the mountain, just outside the two columns furthest from the summit. \begin{figure}[t] \centering \includegraphics[width=7.8cm]{priestrulesfixed2.png} \caption{The start of a solution demonstrating the rules of Priest movement in Fujisan, with move notation followed by the matching rule. } \label{fig:priestrules} \end{figure} The goal of the solver is to move Priests one at a time until all four are at the summit. A Priest can be moved according to the following rules: \begin{enumerate} \item No more than one Priest may occupy a space at any given time. \item A Priest may move onto a space if that space's value matches the number of unoccupied spaces the Priest must move in a straight line, left or right, to get there (including the destination space itself, but not including the Priest's starting space). % \begin{enumerate} \item Occupied spaces (containing intervening Priests) are not counted when determining the distance from a Priest to a given space. % \end{enumerate} \item A Priest may move freely up and down between the two spaces of any given step of the mountain. % \begin{enumerate} \item A Priest's first move from the starting position must land on the mountain; that is, the Priest cannot move up or down while on the ground. \end{enumerate} \item A Priest that lands on the mountain's summit can no longer move left or right, but may still move freely up or down within the column.\footnote{The original rules of Fujisan also allowed a Priest on the summit to freely move left and right at the summit. The summit rule as written here was made for the Engraved Tiles version, and we used this formulation of the rule for the computational simulations of all versions discussed.} \begin{enumerate} \item A Priest may pass over the summit as part of a move. \end{enumerate} \end{enumerate} Figure \ref{fig:priestrules} shows a visual example of how these rules can be used to begin solving a sample challenge. We denote the goal summit spaces in gray. \subsection{Components and Algorithms} \label{section:pcgalgs} \noindent Here we explore three different sets of physical components and their resulting PCG algorithms that can be used for challenge setup for Fujisan. The piecepack is a set of board game parts that can be used to design and play a wide variety of games\cite{GAMESYSTEM}. The mountain in Fujisan was constructed with game tiles each marked with a 2$\times$2 grid. The values were added using 24 round coins, which represented the cross product of two sets: suits (sun, moon, crown, arms) and values (0, 1, 2, 3, 4, 5). Values are indicated on the front of the coin, while suits are found on the back. We examine first a simple algorithm that can make use of the piecepack coin components to generate randomness. \begin{quote} {\it \bf Shuffled:} Shuffle the 24 coins face-down. For each space on the board, randomly select one coin and place it face-up on this space. \end{quote} We can use the multinomial theorem to determine that this method can create $\frac{24!}{4!^{6}} \approx 10^{14}$ possible challenges. We acknowledge here and in subsequent calculations that rotational, horizontal, and vertical symmetry will alter the precise number of challenges, but not by an order of magnitude. However, if two 0 coins end up placed in the same column, then it becomes impossible to move a Priest onto that column. This creates holes in our challenges and reduces the number of solvable setups. More importantly, when both spaces of either of the summit columns contain 0s, the challenge becomes impossible to solve. The original published Fujisan ruleset was devised to address the issue of double 0 steps, adding the constraint that each step must have two different values. This was achieved by using the suit information on the backs of the coins to \textit{entangle} the coins as they are placed, similar to the \textbf{Sequential Suits} method for Pretzel. \begin{quote} {\it \bf Piecepack:} Shuffle the 24 coins face-down, and separate into four groups based on their suit. Then repeatedly place two coins on the two right-most available spaces, choosing from each of the suits in turn (sun, moon, crown, arms). \end{quote} With each space limited to choosing from a particular suit, the \textbf{Piecepack} algorithm will generate $6!^4 \approx 10^{10}$ possible challenges. This algorithm will guarantee there are no double numbers on a step, thus eliminating the double 0 issue noted above. \begin{figure}[t] \centering \includegraphics[width=3cm]{engravedsample.png} \caption{Sample Engraved Fujisan Tiles.} \label{fig:engravedsample} \end{figure} \begin{figure}[b] \includegraphics[width=8.8cm]{fujisan-engraved.png} \caption{A sample Fujisan challenge from the Engraved Tiles algorithm.} \label{fig:tileexample} \end{figure} Another way to entangle the components in Fujisan is to combine the values with the 2$\times$2 tiles, engraving numerals onto the spaces, similar to the \textbf{L-Tiles} method for BoxOff. Here, we explore creating tiles with every possible pairing of values 0 through 5, including pairing a value with itself, and repeating these values diagonally on the tiles. Example tiles of this style are shown in Figure \ref{fig:engravedsample}. We remove the 0:0 pairing, since it can create unsolvable challenges, leaving 20 tiles. \begin{quote} {\it \bf Engraved Tiles:} Shuffle the tiles face-down. Then, assemble the mountain by turning tiles face-up, using six for the bottom layer, five for the next layer, then four, then three, and finally two. The summit will be the center four spaces. \end{quote} This further constrains each pair of numbers to appear no more than once in the puzzle, except for the top two tiles. There are 20 possible tiles, and only 10 of them can be seen once the puzzle is constructed, as shown in Figure \ref{fig:tileexample}. 15 of these tiles have two possible orientations, for a total of $\sum_{i = 5}^{10}{15 \choose i}\binom{5}{10 - i}2^{i}10! \approx 10^{13} $ possible challenges. Furthermore, a standard double-six domino set, which includes 28 dominoes, can be used as entangled components. If we eliminate those dominoes that include a 6, along with all doubles, we are left with 15 dominoes. \begin{quote} {\it \bf Dominoes:} Shuffle the dominoes face-down. Place 12 of these dominoes face-up in a row to create the mountain. Place a face-down domino on each side of the mountain to denote the starting locations for the Priests. Place the remaining face-down domino horizontally in the middle to raise up the two central dominoes, denoting the summit. \end{quote} This constraint is similar to \textbf{Engraved Tiles}, but with a subset of the value pairs, thus a different probability on their selection. Additionally, unlike \textbf{Engraved Tiles}, the summit values are distinct from the two steps closest the summit. With 15 possible dominoes, only 12 of them are used in the challenge, as shown in Figure \ref{fig:dominoexample}. Each of these dominoes has two possible orientations, for a total of ${15 \choose 12}2^{12}12! \approx 10^{14}$ possible challenges. \begin{figure}[b] \includegraphics[width=8.8cm]{dominoexample.png} \caption{A sample Fujisan challenge from the Dominoes algorithm.} \label{fig:dominoexample} \end{figure} \subsection{Evaluation} \noindent \begin{figure}[t] \includegraphics[width=8.8cm]{standalonesolve2.png} \caption{Effect of Fujisan challenge generation algorithms on solvability.} \label{fig:strategycomp} \end{figure} We encoded a Monte Carlo Fujisan challenge generator using C\#, along with an A* solver for Fujisan challenges. Our admissible heuristic for A* is the number of empty spaces on the summit. For each PCG algorithm, we generated 1000 random challenges. For each generated challenge in our trials, we recorded if the challenge was solvable, and if so, we also recorded the minimum solution length found with our A* solver. To enable testing for statistical significance on solvability between these algorithms, we divided our pool of generated challenges into 10 trials of 100 challenges. \subsubsection{Solvability} Figure \ref{fig:strategycomp} shows the distribution of solvability for the four PCG algorithms across the 10 trials in a box-and-whisker plot. Each method produces a healthy probability of solvable challenges. {\bf Shuffled} has the lowest mean value for solvability at 85\%, and this result is significantly lower than the other three algorithms, which is confirmed by t-tests using a p-value of 0.05. Within the top three algorithms, only {\bf Dominoes} is statistically higher than {\bf Piecepack}. \subsubsection{Interest} Applying the interest metric of Brown and Maire \cite{MCPUZZLE} across all of our PCG algorithms, we found that $P(S_r)$, the probability that a random solver would win, was less than 0.003, making $P(S_p) - P(S_r)$ equivalent to solvability. As our goal is to determine if the above algorithms change the interest distribution of generated challenges, we consider two other measures found by Jaru{\v{s}}ek and Pel{\'a}nek to be correlated with challenge difficulty for one-way transport puzzles: the minimum number of moves required to solve the challenge, and the number of counter-intuitive moves along the minimum solution path. \cite{jaruvsek2010difficulty} \cite{jaruvsek2011determines} First, we determined that a move in Fujisan is counter-intuitive if it involves moving a Priest further away from the summit. For each solvable challenge, we counted the number of counter-intuitive moves used on the minimum solution path length. Using this metric, values ranged from 0-8, and we found that there was no statistical difference between the four algorithms. Second, we calculated the distribution of minimum solution path length generated by each algorithm. We compared here the median length generated by each algorithm. The shortest possible solution to a Fujisan challenge involves eight moves, while the longest-known constructed challenge requires 62 moves\footnote{http://www.ludism.org/ppwiki/Fuji-san\#Heading9}. \begin{figure}[t] \centering \includegraphics[width=8cm]{fujisandiff4.png} \caption{Histograms showing the effect of Fujisan challenge generation algorithms on minimum solution length.} \label{fig:difficultycomp} \end{figure} Figure \ref{fig:difficultycomp} shows histograms of the minimum solution length for solvable challenges, pooled across all trials for each algorithm. The median is denoted with a dotted line. Our algorithms appear to follow a Poisson distribution rather than a normal distribution, since the smallest possible solution length for any challenge is 8, and the maximum solution length is currently unbounded. We employ a Kruskal-Wallis H-test \cite{KRUSKAL} to determine if the median length of our four algorithms is statistically the same, and we rejected this null hypothesis very strongly, with a p-value of $6.4 \times 10^{-9}$. The algorithm responsible for this result was {\bf Engraved Tiles}. We can see a strong tendency to have shorter solution lengths, with almost 10\% of challenges having a solution length of eight or nine, whereas for {\bf Dominoes}, this is true for only 3\% of challenges. In {\bf Engraved Tiles}, there are five tiles that contain a zero value; since there will be ten total tiles hidden, on average a challenge will contain 2.5 zero values. It appears that zero values are one part of what makes Fujisan challenges interesting. \section{Entangled Components} \label{entangled} \noindent Recall that we define components to become {\it entangled} if their arrangement is no longer independent, either due to algorithmic constraints, or having been subsumed by new, larger components. In each of the explored puzzles above, we see that entangled components can be used to produce challenges with higher solvability without sacrificing the interesting qualities of the puzzle. Here we provide evidence that this is due to aligning the entanglements with desirable portions of the underlying puzzle mechanics. For each puzzle, metrics can be found that are correlated with higher solvability. Entangled components can then be biased toward solvability by encouraging these metrics in generated challenges. In BoxOff, Rule 1 underscores the importance of adjacent grid squares of the same color, as they are the first moves available in the game. The (4, 6, 4) board contains 38 unique pairs of adjacent grid squares. If we randomly distribute the four colors using the \textbf{Shuffled} method, on average a pair will be the same color 22\% of the time. We label this metric {\it pair equality}. However, if we separate the generated challenges by solvability, we see in Figure \ref{fig:boxoffconnected} that while unsolvable challenges average 20\% pair equality, for solvable challenges the average increases to 26\%, and this difference is statistically significant. \begin{figure}[t] \includegraphics[width=8.8cm]{pairequal.png} \caption{Average pair equality for (4, 6, 4) color BoxOff challenges across each setup algorithm. Solvable challenges shown in black, and unsolvable challenges shown in white.} \label{fig:boxoffconnected} \end{figure} Through entanglement, the \textbf{L-Tiles} constrain adjacent pairs such that at least eight of them are the same color, resulting in a minimum of 21\% pair equality. Thus, these challenges are more likely to be in the solvable range, as shown in Figure \ref{fig:boxoffconnected}, with 32\% pair equality for unsolvable challenges, and 34\% pair equality for those that are solvable. To verify that the entangled components must align with the puzzle mechanics, we also tested a configuration of \textbf{L-Tiles} for the (4, 6, 4) puzzle with three unique colors on each tile, evenly distributed among the colors. This resulted in an overall solvability of 8.2\%, much worse than using the original \textbf{Shuffled} algorithm. To better understand how entangled components improve solvability for Pretzel solitaire, it is revealing to compare the dip in solvability for (4, 3) \textbf{Sequential Suits} with the dramatic spike in solvability for (4, 4) \textbf{Sequential Suits}, both clearly evident in Figure \ref{fig:pretzelfullsolve}. As discussed by de Bruijn, sequences of necessarily dependent moves that turn back on themselves to form loops, which de Bruijn calls cyclic blockades, are the bane of the Pretzel solver. Once a cyclic blockade forms, the Pretzel is no longer solvable. These can either be present immediately following the deal or can develop during the course of play. (4, 3) Pretzels with \textbf{Sequential Suits} are highly prone to at least two shapes of dealt cyclic blockades that are readily detected. To recognize the first, we observe that exactly three spades will be dealt into the grid in a diagonal line, from the first column of the first row to the third column of the third row. There is a 1 in 6 chance that the $3\spadesuit$ will be dealt into the first column of the first row and the $2\spadesuit$ into the third column of the third row. When this occurs, the $2\spadesuit$ can never move into its goal location, occupied by the $3\spadesuit$, which itself cannot move into a hole following the $2\spadesuit$, since the $2\spadesuit$ is in the rightmost column and is unable to leave that column. We shall call this shape of cyclic blockade a Ducking Crab. So, at least 1 in 6 (4, 3) Pretzels with \textbf{Sequential Suits} are unsolvable immediately after setup. Notice, however, that a Ducking Crab is just as probable for diamonds, so at least 1 in 3 are immediately unsolvable. A second shape of cyclic blockade that plagues \textbf{Sequential Suits} for the (4, 3) case occurs when the $2\clubsuit$ and $2\heartsuit$ are dealt into each other's goal locations, preventing either from ever moving. Such Duelling Deuces occur in 1 of 9 challenges. Ducking Crabs and Duelling Deuces are not, of course, exclusive to (4, 3) Pretzels with \textbf{Sequential Suits}. Nor have we attempted to identify and enumerate an exhaustive list of every possible shape for cyclic blockades. We offer Ducking Crabs and Duelling Deuces merely as examples of the kinds of structures that limit solvability for Pretzels. They are suitable examples not only because they account for a significant portion of unsolvable (4, 3) Pretzels with \textbf{Sequential Suits}, but also because it is plain to see how both are completely avoided by \textbf{Sequential Suits} for the (4, 4) case and indeed for all cases $S = V$, as well as \textbf{Banded Suits}. With a stripe of spades filling the first column, there can only ever be a single 2 in the column, preventing Deulling Deuces. Although the $3\spadesuit$ might be dealt into $2\spadesuit$'s goal location, the $2\spadesuit$ can never be dealt into the rightmost column, so Ducking Crabs are likewise impossible. Thus for Pretzel solitaire, entangled components help to avoid some, but not all, of the structures that destroy solvability. For Fujisan, the entangled components are a direct result of the puzzle movement mechanics. We first develop a metric called {\it connectivity} based on Rule 2 to explore the connections between steps in a challenge. We say step $A$ is connected to step $B$ in Fujisan if there is a move available according to Rule 2 from $B$ to $A$. This metric, only an approximation of true puzzle connectivity as it ignores connections possible from Rule 2.a with intermediate Priests, contains enough information to bias our entangled components. \begin{figure}[t] \includegraphics[width=8.8cm]{connectivity.png} \caption{Average connectedness for Fujisan challenges across each setup algorithm. Solvable challenges shown in black, and unsolvable challenges shown in white.} \label{fig:connected} \end{figure} Figure \ref{fig:connected} shows the average step connectivity within a challenge for each setup algorithm, differentiating solvable challenges in black from unsolvable challenges in white. In the \textbf{Shuffled} algorithm, we can see a large divide between solvable and unsolvable challenges, and across all algorithms, higher connectivity is always related to higher solvability. Also, both \textbf{Piecepack} and \textbf{Dominoes} require that each step has two unique values. In these two algorithms, this uniqueness constraint strongly increases the connectivity of both solvable and unsolvable challenges, but the divide remains intact. However, even if each step is well-connected to other steps, the connections could form patterns and loops between the steps, thus breaking the potential Priest movement into disjoint sets. If we add a restriction that each step pair in a challenge be a unique set of values, this will cause the connections between steps to be more distributed and bind the puzzle together as a whole. In our experiments, we found that Shuffled challenges which fit this restriction can be solved at a rate of 89\%, a statistical improvement over the general Shuffled challenge population. As we noted earlier, the {\bf Engraved Tiles} and {\bf Dominoes} incorporate this prohibition on the repetition of steps as they subsume the coins into larger components. In fact, the most successful algorithm, {\bf Dominoes}, combines both of these constraints to create well-connected and well-distributed challenges. \section{Conclusion} \label{sec:Conclusion} \noindent Our work introduces the idea of entangled components for physical solitaire puzzle games, and explores their implications for procedural content generation algorithms across three puzzles. We can see that subtle changes in the game components can affect their random distribution, leading to large-scale changes on the generated challenges. When aligned with the puzzle mechanics, entangled components lead to increased challenge solvability without sacrificing the interesting nature of the puzzle. There are many open questions related to physical games and PCG. First, we believe there is work to be done in formalizing, and validating with human subjects, an ease of physical setup metric. While the \textbf{Shuffled} algorithm for each puzzle is very simple to execute, some of the more entangled algorithms could be time-consuming and tedious for a human to implement. A simple approximation metric would be the time complexity of the algorithm; however, certain operations that are straightforward to a computer can be difficult for humans to track, and vice versa. With a formal metric, game designers could be inclined to include more intricate PCG algorithms when provided guarantees these algorithms can reasonably be executed by a human player. A further point to clarify is the exact relationship between challenge interest and challenge difficulty. We focused here on how entangled components maintained challenge interest, but this simplifies the potential for gradations of challenge difficulty within each puzzle. Validating a sophisticated difficulty metric for each puzzle, again with human subject tests as disussed in Jaru{\v{s}}ek and Pel{\'a}nek \cite{jaruvsek2011determines} , could further illustrate the effects of entangled components. Finally, are there general entangled methods that allow solvers to {\it construct} challenges online to guarantee solvability, as opposed to the {\it generate-and-test} algorithms discussed here? While this may be possible in certain situations, care must be taken that the construction process does not give away the solution to the challenge. \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran}
{'timestamp': '2019-05-28T02:15:33', 'yymm': '1810', 'arxiv_id': '1810.01926', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01926'}
arxiv
\section{Algorithm and Optimizations} This section gives an overview of our algorithm and presents several optimization methods. Fig. \ref{fig:wino_overview} shows the overview of our algorithm which consists of three stages of the Winograd-based convolution: input feature map and kernel transformations, matrix multiplications, and the inverse transformation of the output feature maps. These three stages form the pipeline of the data flow of our system design. \subsection{Reduction to Matrix multiplication} \label{wino_matmul} By reformulating \eqref{eq:2d_wino} with the augmentation on the channel dimension, filter $k$, tile coordinates $\left(\tilde{x}, \tilde{y}\right)$, and substitution of $U = G g G^T$ and $V = B^T d B$, we get \begin{equation} \label{eq:2d_wino_multi_chnl} Y_{k, \tilde{x}, \tilde{y}} = A^T \left[ \sum_{c=1}^C U_{k, c} \odot V_{c, \tilde{x}, \tilde{y}} \right] A \end{equation} The summation part inside the parenthesis of \eqref{eq:2d_wino_multi_chnl} can be disentangled into $(m + r - 1)^2$ individual multiplication of a matrix of size $\left(C \times K \right)$ with another of size $\left(C \times \lceil H/m \rceil \lceil W/m \rceil \right)$. \begin{align*} \mathcal{M}_{ k, \tilde{x}, \tilde{y} } = \sum_{c=1}^C U_{k, c} \odot V_{ c, \tilde{x}, \tilde{y} } \quad \xrightarrow[ \text{$\left(\tilde{i}, \tilde{j}\right)$ of tile} ]{\text{collapsing $\left(\tilde{x}, \tilde{y} \right)$ to $b$}} \nonumber \\ \mathcal{M}_{\left(k, b\right)}^{\left(\tilde{i}, \tilde{j}\right)} = \sum_{c=1}^C U_{k, c}^{\left(\tilde{i}, \tilde{j}\right)} V_{c, b}^{\left(\tilde{i}, \tilde{j}\right)} \label{eq:wino_2_mtx} \end{align*} Another benefit of this reformation into matrix multiplications is that the number of inverse transforms has also been reduced over $C$ channels \cite{Lavin2016FastAF}, since the factorization of inverse transform along channels amortizes the cost. With this reformation, the matrix multiplications are then efficiently implemented on FPGAs. \subsection{Matrix multiplications and memory access patterns} \begin{figure}[!ht] \includegraphics[width=.44\textwidth]{z-morton_addr.png} \caption{Z-Morton memory layout for both dense and sparse matrix \cite{Frigo_cache, DEEPA2012916}: $(a)$ the translation from logical layout to physical layout, $(b)$ the block-based compressed coordinates (BCOO, $l \times l$ block and $l=4$ for our design) for pruned Winograd weights} \label{fig:z_morton_addr} \end{figure} As described in section \ref{wino_matmul}, Winograd convolution can be computed efficiently with matrix multiplications on GPUs or FPGA platforms. To optimze the performance of matrix multiplication, we employ the Z-Morton memory layout \cite{Frigo_cache}, which has been widely studied for the Cache oblivious algorithms on multithreaded CPUs \cite{Frigo_cache, 1058095} and image processing on FPGAs \cite{DEEPA2012916}. This memory layout increases both spatial and temporal locality of memory accesses of matrix multiplication and arithmetic operations \cite{Frigo_cache}. \begin{algorithm}[H] \caption{Divide and Conquer Matrix Multiplication}\label{algo:matmul} \begin{algorithmic}[1] \Function{recursive-matmult}{$A, B, C$} \State $n = A.rows$ \If{$n == l$} \Comment $l$ is the smallest tiling size \State $c_{1,1} = a_{1,1} \times b_{1, 1}$ \Comment matrix multiply of $l \times l$ tiles \Else \State partition $A$, $B$, and $C$ into tiles of size $\frac{n}{2} \times \frac{n}{2}$ \State $C_{1,1} = \Call{recursive-matmult}{A_{1,1},B_{1,1}}$ \State $\qquad + \Call{recursive-matmult}{A_{1,2},B_{2,1}}$ \State $C_{1,2} = \Call{recursive-matmult}{A_{1,1},B_{1,2}}$ \State $\qquad + \Call{recursive-matmult}{A_{1,2},B_{2,2}}$ \State $C_{2,1} = \Call{recursive-matmult}{A_{2,1},B_{1,1}}$ \State $\qquad + \Call{recursive-matmult}{A_{2,2},B_{2,1}}$ \State $C_{2,2} = \Call{recursive-matmult}{A_{2,1},B_{1,2}}$ \State $\qquad + \Call{recursive-matmult}{A_{2,2},B_{2,2}}$ \EndIf \State ${\bf return} \, C$ \EndFunction \end{algorithmic} \end{algorithm} Z-Morton uses a \textit{divide and conquer} approach to access the memory as in Fig. \ref{fig:z_morton_addr} $\left(a\right)$. It is actually derived from the recursive matrix multiplication described in \textit{Algorithm} \ref{algo:matmul}. Compared with Strassen's algorithm, the latter is not cache-friendly in real situations, whereas the former can provide notable improvement in performance \cite{1058095}. Note, instead of implementing the algorithm exactly, we unrolled memory access order to reorganize the memory layout. The physical memory layout in FPGAs is essentially linear, Fig \ref{fig:z_morton_addr} ($a$) also provides an example of translating the logical block address to physical block address. As shown in Fig. \ref{fig:z_morton_addr} ($a$), the address translation is easily implemented with LUTs in FPGAs by interleaving the bits of the logical column and row addresses to generate the physical address of a block. \subsection{Pruned Winograd weights and memory access patterns} After pruning the Winograd weights, we store them in a block-based sparse coordinates format (BCOO)\textendash only those $4 \times 4$ blocks containing nonzeros will be compressed and stored. Fig. \ref{fig:z_morton_addr} ($b$) shows an example where the block $B_5$ is a $4 \times 4$ tile, and it has 3 nonzeros. The information of these nonzeros are stored into vectors $BN$, $BI$, $AI$, $AJ$, and $AN$. $BN$ contains the block number for each block in memory layout, e.g. 5 for $B_5$. $BI$ is the list of starting indices of each block within the other three arrays, e.g. $i_5$ of $BI$ refers to the starting index in $AI$, $AJ$, and $AN$ of information corresponding to $B_5$. Elements in $AI$ and $AJ$ represent the row and column number of the nonzeros in its own block, respectively, and $AN$ stores the value of the corresponding nonzero. For $B_5$, the values of nonzeros are $b_{0,0}$, $b_{1,2}$, and $b_{3,1}$, the corresponding column numbers are 0, 2, 1 and row numbers are 0, 1, 3 in $AJ$ and $AI$, respectively. The compressed blocks are still fetched following the order determined by Z-Morton layout. \section{Architecture Design} This section discusses our implementation of accelerator for Winograd convolution. The most time-consuming parts in the computation pipeline are the Winograd transform for feature maps and matrix multiplications. In our design, we propose using unified small-scale systolic arrays, of size $l \times l $ $\left( l = m + r - 1 \right)$, for both these arithmetic operations. \subsection{Winograd transform by Systolic Arrays} Recall the $2$-$D$ Winograd transform nesting 2 transform matrices, $B^T \cdot D \cdot B$. \begin{figure}[!ht] \includegraphics[width=.40\textwidth]{winograd_transform_systolic.png} \caption{Small-scale Systolic Arrays for Winograd Transform} \label{fig:wt_systolic} \end{figure} Instead of directly computing $B^T \cdot D \cdot B$, we change it into $\left( D^T \cdot B \right)^T \cdot B$. Thus, we let transform matrix $B$ be stationary inside the systolic arrays. In the first iteration \circled{1} of the Fig. \ref{fig:wt_systolic} $D^T$ passes through systolic arrays to operate with \textit{B} and the output is $P = \left(C + D^T \cdot B\right)^T$ (no additional transpose needed). This intermediate result $\left( D^T \cdot B \right)^T$ feeds back to systolic arrays as "new $D^T$" in the second iteration \circled{2}. Then $P\textprime = C\textprime + P \cdot B = \left( D^T \cdot B \right)^T \cdot B = B^T \cdot D \cdot B$ is the final resutl. Note that \textit{C} and \textit{C$\textprime$} are zero-matrices and there is no multiplication occured inside these systolic arrays\textendash the value of elements of \textit{B} is just used to control the adder\textendash such as, "1" for addition, "-1" for subtraction, and "0" for passing by the data to next processing element (PE) inside its systolic array. The data sharing is through the overlapping of tiles, which has been described in section \ref{subsec:2d_wino}. Fig. \ref{fig:wt_systolic} illustrates that $\left( m + r - 1 \right)$ wide data stream into each systolic array, and among these data, $\left(r - 1\right)$ of them travel through the current systolic array and are forwarded to the next systolic array at the same direction. The output is streamed out in the orthogonal direction after two iterations as stated previously, and is transfered into shift-registers for scattering into matrices. \subsection{Matrix Multiplication by Systolic Arrays} To perform the recursive matrix multiplication \textit{Algorithm \ref{algo:matmul}} with hardware, we conceive the cluster of small-scale systolic arrays. Each cluster consists of 4 $l \times l$ systolic arrays ($l = 4$ for our case) and a set of shared circular FIFO built by shift-registers, shown in Fig. \ref{fig:mm_systolic}. To understand how this cluster works, let us examine the example from Fig. \ref{fig:z_morton_addr}. By unrolling the recursive code given by \textit{Algorithm \ref{algo:matmul}} and using the tiles of matrices organized by Z-Morton layout, we calculate sub-matrix $C_{0}$ by summing up the products of submatrices $A_0 \times B_0$ and $A_1 \times B_2$, $C_4$ by sum of $A_0 \times B_4$ and $A_1 \times B_6$, and so on. {\small \begin{align*} C_0 \, &\text{+=} \, A_0 \times B_0 + A_1 \times B_2;\\ C_4 \, &\text{+=} \, A_0 \times B_4 + A_1 \times B_6;\\ C_8 \, &\text{+=} \, A_8 \times B_0 + A_9 \times B_2;\\ C_{12} \, &\text{+=} \, A_8 \times B_4 + A_9 \times B_6; \\ \cdots \\ C_0 \, &\text{+=} \, A_4 \times B_8 + A_5 \times B_{10};\\ C_4 \, &\text{+=} \, A_4 \times B_{12} + A_{5} \times B_{14};\\ \cdots \end{align*} } \begin{figure} \center \includegraphics[width=.45\textwidth]{systolic_array_matmul.png} \caption{Systolic Arrays for \textit{Algorithm \ref{algo:matmul}}: $(a)$ the original design for dense case, $(b)$ modified architecture for sparse case} \label{fig:mm_systolic} \end{figure} As shown in Fig.\ref{fig:mm_systolic} (\textit{a}), $A_0$ is shared by northwest and southwest systolic arrays, $A_8$ is shared by northeast and southeast systolic arrays, and so on. After the first iteration, the partial results of $C_0$, $C_4$, $C_8$, and $C_{12}$ are produced and stored inside the corresponding systolic arrays. In the second iteration, the blocks $A_1$, $A_9$, $B_4$, and $B_9$ get into their corresponding systolic arrays and perform the matrix multiplications, and their products are accumulated to the partial results, which still stay in their systolic arrays from iteration 1. At iteration 3 the results of $C_0$, $C_4$, $C_8$, and $C_{12}$ are spilled out, and systolic arrays continue to work on the partial results of $C_1$, $C_5$, $C_9$, and $C_{13}$. This procedure continues until all the submatrices are calculated. Also the sharing of circular FIFOs reduces the memory bandwidth requirement by 4 folds. When the computation is comprised of sparse matrix multiplications, we need some modifications on the cluster of systolic arrays. First, each of the circular FIFOs which supply the compressed Winograd weight blocks need to be equipped with a decompressor. Second, the circular FIFOs for Winograd feature maps are virtually split into two halves since some Winograd feature maps blocks are no longer shared between the systolic arrays. The overall memory access pattern is now determined by how the sparse blocks distributed in the memory layout. Take the sparse blocks $B_2$ and $B_5$ from Fig. \ref{fig:z_morton_addr} for example; now we notice that the computation of $C_0$ becomes $A_1 \times B_2$ only, $C_8$ becomes $A_9 \times B_2$, block $B_2$ is still shared by the products of submatrices $C_0$ and $C_8$. \subsection{Extends the computation into third dimension} \begin{figure}[h!] \center \includegraphics[width=.34\textwidth]{matmult_3d.png} \caption{Extension of computation to 3-$D$ dimension} \label{fig:3d_systolic} \end{figure} Whenever the computation resource is available, we can extend the computation into higher dimensions. As we have analyzed in section \ref{wino_matmul}, there are $\left(m + r - 1 \right)^2$ independent matrix multiplications, and they can be executed in parallel with several clusters of systolic arrays as demonstrated in Fig. \ref{fig:3d_systolic}. With this enhencement, the DSP utilization and throughput of the FPGA system are dramatically improved. In our design, we organize the DSPs into 8 clusters due to the limited amount of DSPs in our FPGA board. \subsection{Extension to other types of layers} In addition to convolution layers, fully-connected (FC) layers are essentially computed through matrix multiplications. Therefore, the techniques previously discussed can be also employed to FC layers. ReLU layers and Max Pooling layers are easily implemented by accompanying comparators to the output buffers. \section{Background} \subsection{Spatial Convolution} The convolution layer in a feedforward pass takes $C$ channels of $H \times W$ feature maps \textit{D} as input, and convolve each of $K$ filters of dimension $C \times r \times r$ with the input feature maps to produce $K$ output featre maps, \textit{Y}, of dimension $\left( H - r + 1 \right) \times \left( W - r + 1\right)$. Let $s$ be the stride and assume that the width and height of the filters are the same, then the mathematical description of the convolution is \begin{equation} Y_{k, i, j} = \sum_{t=1}^C \sum_{p=1}^r \sum_{q=1}^r G_{k, t, p, q} \times D_{t, i * s + p, j * s + q} \end{equation} \subsection{Winograd Algorithm} Winograd proposed an efficient algorithm for short convolutions \cite{1980-winograd} in computing of finite impulse response (FIR) filters in the signal processing field. \cite{Lavin2016FastAF} extends the Winograd algorithm to convolutional neural networks on GPU and CPU. By applying Winograd transform to an r-tap FIR filter denoted as $F\left(m, r\right)$, which computes $m$ outputs with the filter size of $r$, the number of multiplications is reduced from $m \times r$, if through the spatial convolution, to $m + r + 1$. \subsubsection{1-D Winograd Convolution} Taking $F\left(2, 3 \right)$ as an example, Winograd algorithm first transforms an input vector $d = \left(d_0, d_1, d_2, d_3\right)$ and filter $g = \left(g_0, g_1, g_2\right)$ into $j = \left(j_0, j_1, j_2, j_3\right)$ and $h = \left(h_0, h_1, h_2, h_3\right)$ respectively through \begin{align*} j_0 = d_0 - d_2, & \quad h_0 = g_0 \\ j_1 = d_1 + d_2, & \quad h_1 = \frac{g_0 + g_1 + g_2}{2} \\ j_2 = d_2 - d_1, & \quad h_2 = \frac{g_0 - g_1 + g_2}{2} \\ j_3 = d_1 - d_3, & \quad h_3 = g_2 \label{eq:wino_j_h} \end{align*} Next, element-wise multiplications are performed: \begin{equation} \label{eq:wino_elmt_wise} c_0 = j_0 \times h_0, \, c_1 = j_1 \times h_1, \, c_2 = j_2 \times h_2, \, c_3 = j_3 \times h_3 \end{equation} Finally, the output $y = \left(y_0, y_1\right)$ can be generated via: \begin{equation} y_0 = c_0 + c_1 + c_2, \quad y_1 = c_1 - c_2 - c_3 \end{equation} The matrix form of the above procedure can be written as $y = A^T \left[ \left(G g \right) \odot \left(B^T d \right)\right] $, where $\odot$ represents element-wise multiplication and \begin{align*} A^T = \begin{bmatrix} 1 & 1 & 1 & 0 \\ 0 & 1 & -1 & -1 \end{bmatrix}\, G = \begin{bmatrix} 1 & 0 & 0 \\ \frac{1}{2} & \frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & -\frac{1}{2} & \frac{1}{2} \\ 0 & 0 & 1 \end{bmatrix} \, B^T = \begin{bmatrix} 1 & 0 & -1 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & -1 & 1 & 0 \\ 0 & 1 & 0 & -1 \end{bmatrix} \end{align*} The element-wise product in \eqref{eq:wino_elmt_wise} requires $m + r - 1 = 4$ multiplications, whereas the direct method does $m \times r = 2 \times 3 = 6$ multiplications. \subsubsection{2-D Winograd Convolution} \label{subsec:2d_wino} The 1-D Winograd algorithm can be easily extended to 2-D or higher dimensional convolutions by being nested with itself. 2-D Winograd algorithm $F\left(m \times m, r \times r\right)$ can be formulated as follows, \begin{equation} \label{eq:2d_wino} Y = A^T \left[ \left(G g G^T\right) \odot \left(B^T d B\right) \right] A \end{equation} where $d$ and $g$ are tiles of input and the filter, having size of $l \times l$ ($l = m + r - 1$) and $r \times r$, respectively. The size of the output tile $Y$ is $m \times m$. \\ For larger input images, the Winograd transform is performed with the overlapping of tiles, with overlapping size $r - 1$, along each dimension. When applying Winograd algorithm to a convolution layer of CNNs, the tiles along the channel dimension of this layer can be fetched simultaneously and each of them is applied with \eqref{eq:2d_wino}. \section{Conclusion} In this paper we propose a design with highly efficient recursive memory access layout for both dense and sparse Winograd convolutions, unified systolic arrays for both Winograd transforms and matrix multiplications, and a three dimensional compute engine for Winograd convolution. We also provide a comprehensive algorithmic level analysis for the performance model of the Winograd convolution. We achieve high computation power usage and high power efficiency in our design. There are several aspects that we can investigate further in the future. In particular, the automation design flow will help a lot to reduce the burden of development. And, the progress in memory technology is also a promissing solution as more and more new FPGA architecture incorporate such kind of brilliant concept. \section{Experimental Evaluation} $VGG$ \cite{Simonyan14c} is one of the most popular and mature deep learning models which has been widely used in research and industry. In this work, we use $VGG16$ for our analysis and experiments. \subsection{Experiment Setup} For the CNN model part, we set the input feature map size to $224 \times 224 \times 3$, which are standard input dimensions for VGG pipeline. Table \ref{tab:nb_params} shows the number of neurons and weights of each layer in different stages after the Winograd transform. For the hardware part, we evaluate our design on an FPGA board, Xilinx Virtex Ultrascale XCVU095. Although it is not fabricated with the lastest technologies, and equips only with a medium amount of DSPs (768 DSPs), this configuration reveals better the performance gain than the lastest FPGAs since optimizations for FPGAs with scarce computation power is more representative. \begin{table*} \caption{Comparison with State-of-the-art implementations} \label{tab:fpga_comp} \begin{tabular}{@{}cccccccc@{}} \toprule Impl. & FPGA'15 \cite{Zhang2015} & FPGA'16 \cite{Zhang2016} & FPGA'16 \cite{Suda2016} & \multicolumn{2}{c}{DAC '17 \cite{Wei2017}} & \multicolumn{2}{c}{our impl.} \\ \midrule FPGA & V7 VX485T & Xilinx VC709 & Stratix-V GSD8 & \multicolumn{2}{c}{Arria10 GT1150} & \multicolumn{2}{c}{V-Ultra XCVU095} \\ Precision & 32 bit float & 16 bit fixed & 8-16 bit fixed & 32 bit float & \multicolumn{1}{l}{8-16 bit fixed} & \multicolumn{2}{c}{8-16 bit fixed} \\ Frequency (MHz) & 100 & 200 & 120 & 221.65 & 231.85 & \multicolumn{2}{c}{150} \\ Throughput (Gops/s) & 61.6 & 354 & 47.5 & 460.5 & 1171.3 & \begin{tabular}[c]{@{}c@{}}460.8/230.4 \\ (8 bit/16 bit fixed)\end{tabular} & \begin{tabular}[c]{@{}c@{}}921.6 (projected, \\ 8 bit fixed sparse)\end{tabular} \\ DSP utilization & 1120/1400 & 2833/3632 & 727/1963 & 1340/1523 & 1500/3046 & \multicolumn{2}{c}{(512+256)/768} \\ Power efficiency (Gops/s/W) & 3.31 & 14.22 & 1.84 & \multicolumn{2}{c}{25.78} & \multicolumn{2}{c}{55.9} \\ \bottomrule \end{tabular} \end{table*} \begin{figure}[h!] \includegraphics[width=.48\textwidth]{energy_latency.png} \caption{Energy consumption estimation and latency of Winograd convolution} \label{fig:energy_wino} \end{figure} \subsection{Experiment on energy consumption analysis} \label{sec:experiment_energy} Fig. \ref{fig:energy_wino} (\textit{a}) plots the trend when different $m$ is applied. The simulations run by synthesis tools show that the design with small values of $m$ normally consume less energy. In order to simplify our design, we decide to use $m=2$, which eventually affects the dimension of our systolic arrays, tiling size, memory access patterns of our accelerator design, and so on. Although the plot indicates that $m=4$ might be the optimal value for the energy consumption, we are limited by other hardware resources in our FPGA system, but the situation might be different if designing with a different FPGA system. In Fig. \ref{fig:energy_wino} (\textit{b}) we provide the latencies for the inference by VGG with different configuration of \textit{m} and sparsity ranging from $60\%$ to $90\%$. For the best case, we achieve almost $5\times$ speedup. \begin{table}[h] \caption{Resource usage} \label{tab:fpga_rsc} \begin{tabular}{ccccc} \toprule Resources & LUTs & FF & BRAM & DSP \\ \midrule Used & 241,202 & 634,136 & 1,480 & \makecell{512 (arith.) + 256 (wino.)} \\ Available\cite{xilinx2015} & 537,600 & 1,057,200 & 1,728 & 768 \\ Percentage & 44.9\% & 60.8\% & 85.6\% & \makecell{67\% + 33\% =100\%} \\ \bottomrule \end{tabular} \end{table} \subsection{Results and analysis} With $m=2$, we get the synthesized result with the resource usage as shown in Table \ref{tab:fpga_rsc}. The end-to-end comparison with the state-of-art CNN FPPGA accelerators is listed in Table \ref{tab:fpga_comp}. We achieve the highest DSP usage and power efficiency. Due to time limitations, we only test our design on a medium scale FPGA. In current design, we use four $4 \times 4$ systolic arrays as one cluster for one matrix multiplication, and stack 8 such clusters for eight matrix multiplications in parallel. Meanwhile, 16 $4 \times 4 $ systolic arrays work on the Winograd transform. In total, all 768 PEs are used. We will try to transfer our design to the latest and most powerful FPGA board in the future, and the performance will be improved further. \section{Design Space Exploration} \subsection{Model Analysis} A detailed study of the complexity of Winograd convolution is conducted in the following subsections, it helps us to design an optimzed accelerator for both dense and sparse cases. \subsubsection{Data Layout of Winograd transform} As previously mentioned, the input feature maps are fed in system in real-time. It's not convenient to prune them during the inference, and it will increase the difficulty in system design. Moreover, the multiplication of a sparse matrix with a dense one does not necessarily produce another sparse matrix. In such case, our analysis keeps the same characteristics of feature maps for both dense and sparse cases. The volume of $i^{th}$ Winograd convolution layer $D_{wi}^{i}$, the volume of corresponding Winograd weights $D_{wk}^{i}$ (without pruning), and the volume of the results $D_{wo}^{i}$ before the inverse Winograd transform can be computed as \begin{equation} \label{eq:nb_wi} D_{wi}^{i} = \left\lceil \frac{H}{m} \right\rceil \times \left\lceil \frac{W}{m} \right\rceil \times C \times l^2 \approx \left(\frac{l}{m}\right)^2 \times H \times W \times C \end{equation} \begin{equation} \label{eq:nb_wo} D_{wo}^{i} = \left\lceil \frac{H}{m} \right\rceil \times \left\lceil \frac{W}{m} \right\rceil \times K \times l^2 \approx \left(\frac{l}{m}\right)^2 \times H \times W \times K \end{equation} \begin{equation} \label{eq:nb_wk} D_{wk}^{i} = C \times K \times l^2 \end{equation} The Winograd transform dilates both the input feature maps and weights by a scale factor of $\left(\frac{l}{m}\right)^2$, e.g. when $m$ takes value of 2 and $r$ of 3, the transformed feature maps and weights require roughly 1.78 times larger storage. The increased volume of the storage not only affects the latency of computations due to the drastically slow access speed, but also causes more energy consumption. \subsubsection{Arithmetic complexity} The arithmetic complexity greatly depends on the data layout since the volume of feature maps and weights decides how much data does the algorithm needs to process. The number of multiplications performed by Winograd convolution layer $i$ is \begin{align*} M_W^i = \left\lceil \frac{H}{m} \right\rceil \cdot \left\lceil \frac{W}{m} \right\rceil \cdot C \cdot K \cdot l^2 \approx H \cdot W \cdot C \cdot K \cdot \left(\frac{l}{m}\right)^2 \end{align*} The number of additions involved in matrix multiplications is \begin{align*} S_W^i = \left\lceil \frac{H}{m} \right\rceil \cdot \left\lceil \frac{W}{m} \right\rceil \cdot \left(C - 1\right) \cdot K \cdot l^2 \approx H \cdot W \cdot \left(C - 1\right) \cdot K \cdot \left(\frac{l}{m}\right)^2 \end{align*} The number of additions required by Winograd transforms are $S_B$ and $S_A$ for $\left(B^TdB\right)$ and $\left(A^T \left[\mathcal{M}_{k, \tilde{x}, \tilde{y}}\right] A\right)$ respectively. In most cases, Winograd transform matrices $B$ and $A$ are sparse, therefore, \eqref{eq:nb_add_wb} and \eqref{eq:nb_add_wa} utilize the operator $nnz\left( \cdot \right)$ (number of nonzeros). \begin{equation} \label{eq:nb_add_wb} S_B^i = 2 \times \left\lceil \frac{H}{m} \right\rceil \times \left\lceil \frac{W}{m} \right\rceil \times C \times K \times l \times \left[nnz\left(B\right) - l \right] \end{equation} \begin{equation} \label{eq:nb_add_wa} S_A^i = 2 \times \left\lceil \frac{H}{m} \right\rceil \times \left\lceil \frac{W}{m} \right\rceil \times C \times K \times l \times \left[nnz\left(A\right) - m \right] \end{equation} The Winograd weights are pre-calculated and stored in memory, so the overhead of computing Winograd weights has not been taken into account. \subsubsection{Optimal Winograd transform and the corresponding "$m$" } \begin{figure}[h!] \includegraphics[width=.37\textwidth]{mem_hier_energy.png} \caption{Data movement energy comparison among memory hierarchies \cite{Sze2017HardwareFM}} \label{fig:mem_hier_energy} \end{figure} When the value of $r$ is specified, e.g. $r=3$ for every layer of $VGG$, the value of $m$ is crucial for determining both the power consumption and the arithmetic complexity. Furthermore, the calculation of the optimal power consumption is straightforward, whereas the optimal computation time is much more complicated to evaluate. Since the degree of parallelism and the memory access patterns are dynamic, these uncertain factors hinder accurate estimation of optimal computation time in an obvious mathematical analysis. Therefore, we focus on the analysis of achieving the optimal power consumption as the reference. As shown in Fig. \ref{fig:mem_hier_energy}, the energy consumption for local (e.g. buffers, FIFOs) and external memory accesses are several times and orders of magnitude higher than arithmetic operations, respectively \cite{Sze2017HardwareFM}. Let us assume for the sake of simplicity that every storage element in both local and external memory is accessed exactly once, transformed feature maps are stored in local memory after Winograd transform, and the Winograd weights are read from external memory. Let $E_{me}$ and $E_{ml}$ be the unit energies consumed by an access to the external memory and an access to the local memory, respectively. Let $E_{mul}$ and $E_{add}$ be the unit energies consumed by a multiplication operation and an addition operation, respectively. Then the total energy consumption of layer $i$ is \begin{align*} E_{tot}^i = E_{ml} \cdot \left(D_{wi}^i + D_{wo}^i\right) + E_{me} \cdot D_{wk}^i + \\ E_{mul} \cdot M_W^i + E_{add} \cdot \left(S_W^i + S_B^i + S_A^i\right) \end{align*} Another fact derived by eq. \eqref{eq:nb_wi} and \eqref{eq:nb_wk} is that greater $m$ generates less elements of the transformed feature maps but more elements of the transformed weights. This fact indicates that the pruning of Winograd weights is more efficient with greater $m$. After having given the above formulas and summarizations, we conduct the analysis and experiments in section \ref{sec:experiment_energy}. \section{Introduction} Convolutional neural network (CNN) is a class of deep learning algorithms which has become dominant in various computer vision tasks \cite{Zhang2018InterpretingCK, liu2016ssd}, so it is attracting research on acceleration for computational and power efficiencies. The core computations in the algorithm are convolution operations with multi-dimensional data, e.g. 3-\textit{D} feature maps (FM) and 4-\textit{D} filters, which require a high density of memory accesses and high throughput of the computation engine. One research topic emerging in recent years is to deploy the convolution operations onto FPGAs \cite{Zhang2015, Suda2016, Zhang2016, 7929549}, since FPGAs consist of massive compute units, e.g. DSP blocks, and storage elements interconnected by reconfigurable switch blocks. The most recent works on systolic array-based FPGA accelerators \cite{Wei2017, Cong2018} deliver significant performance improvement on the automation of high-level synthesis (HLS) design flow. Unlike the works \cite{LeCun2011, Wei2017}, which first construct 2-\textit{D} mesh architecture for systolic array then let the loops of codes to fit on these arrays (bitstream generated once), we recursively break the memory layout down to small blocks then map these blocks onto small-scale systolic arrays to perform multiplications of submatrices, and share these submatrices among working arrays to reduce required memory bandwidth. Another performance improvement can be achieved from algorithmic perspective by applying the Winograd transform. This approach attracts more and more attention from researchers since its first GPU implmentation \cite{Lavin2016FastAF}. Winograd CNN accelerators on FPGAs are also well studied recently \cite{7929549, Aydonat2017}; however, the greater volume after the Winograd transformation is stressing on FPGAs. To handle this issue we adopt an efficient memory layout, adopt the pruned Winograd weights \cite{choi2018} and their elaborate hardware, and extend the computation into 3-\textit{D}. Pruning neural networks has been proven to greatly decrease both latency and energy consumption for all range of devices \cite{han2015deep_compression}. The major contributions are summarized in the following: \begin{itemize} \item \textbf{Unified small-scale systolic arrays for both Winograd transform and matrix multiplications}. We maximize the reusability of the existing design, e.g. RTL, for multiple modules. These modules share common characteristics, like matrix multiplication alike arithmetic operations. \item \textbf{Efficient memory access layout.} We employ a recursive memory access pattern to increase locality of buffers. This pattern significantly impacts the overall performance. \item \textbf{Block-based sparse matrix compression.} We employ this compression technique to adopt the above mentioned recursive memory layout. \item \textbf{A comprehensive model analysis of Winograd convolution.} We propose an analytical model to investigate the performance and energy consumption, and based on the analysis we use the conclusion as our design guidance. \end{itemize}
{'timestamp': '2018-10-05T02:03:30', 'yymm': '1810', 'arxiv_id': '1810.01973', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01973'}
arxiv
\section{Introduction} Humans have the ability to incrementally learn new pieces of information through time, building over previously acquired knowledge. This process is most of the time nondestructive, and results in what is often referred to as ``curriculum learning'' in the literature~\cite{bengio2009curriculum}. On the contrary, it has been known for decades that neural networks learning procedures, despite the fact they originally were proposed as a simplifying model for brain mechanisms, suffer from ``catastrophic forgetting''~\cite{kasabov2013evolving,french1999catastrophic}, or the fact that previously learned knowledge is destroyed when learning new one. During last years, deep learning has become the golden standard in many supervised learning challenges, especially in the field of computer vision~\cite{iandola2016squeezenet,DBLP:journals/corr/SimonyanZ14a,szegedy2015rethinking}. Deep Learning relies on the use of a large number of trainable parameters, that are carefully adjusted using stochastic gradient descent based algorithms. Learning novel data using the same set of parameters inevitably leads to the loss of the previously acquired knowledge. This is why many techniques have proposed to learn distinct deep learning systems over the course of time, letting another algorithm decide which one to use at prediction stage~\cite{girshick2014rich,pan2010survey}. Such methods can quickly result in very complex systems, that are likely to fail in adversarial conditions. Formally, an incremental learning approach would satisfy the following criteria~\cite{rebuffi-cvpr2017}: \begin{enumerate} \item An ability to learn data using one (or a few) example(s) at a time, in any order, without requiring to reconsider or store previous ones. \item An ability to sustain a classification accuracy comparable to state-of-art methods while traversing successive incremental learning stages, thus avoiding catastrophic forgetting. \item Low computation and memory footprints, during training and classifying phases, that should remain sublinear in both of number of examples and their dimension. \end{enumerate} Satisfying these three criteria while keeping competitive accuracy of the proposed systems has remained a key open challenge. A promising venue of research lies in ``transfer learning'' methods~\cite{girshick2014rich}, that make use of very efficient pre-trained deep neural networks previously obtained using huge datasets of signals related to the tasks at hand. As a result, very high quality feature vectors can be used to feed the incremental learning techniques, which can then achieve reasonable performances despite using simplistic mechanisms~\cite{pan2010survey}. In this paper, we introduce Transfer Increment Learning with Data Augmentation (TILDA), an incremental learning method that provides a) a robust selection of feature vectors in subspaces, and b) prediction procedures making use of data-augmentation. We stress the method using challenging vision datasets, namely CIFAR10, CIFAR100 and ImageNet LSVRC 2012. As a result the proposed method allows us to: \begin{itemize} \item Perform incremental learning following the above-mentioned definition, \item Approach state-of-the-art performances on vision datasets, \item Reduce memory usage and computation time by several order of magnitude compared to other incremental approaches. \end{itemize} \begin{figure*} \begin{tikzpicture}[scale=0.8] \node[text width=1cm] at (0,-0.6) {\footnotesize Input \\Signal}; \node[text width=1cm] at (0.3,-1.2) {$\textbf{s}$}; \draw[->,very thick] (-0.6,-1.5) -- (0.4,-1.5); \draw (1,-5) -- (3,-5) -- (3,2.5) -- (1,2.5) -- cycle; \node[text width=1cm] at (2.1,-1) {Data}; \node[text width=1cm] at (1.8,-1.8) {Augmen-}; \node[text width=1cm] at (2.1,-2.1) {tation}; \draw[->,very thick] (3.2,.7) -- (4,0.7); \draw[->,very thick] (3.2,-1) -- (4,-1); \draw[->,very thick] (3.2,-3.3) -- (4,-3.3); \draw[dashed] (3.5,-1.2) -- (3.5,-2.7); \node[text width=1cm] at (3.9,1.1) {$\textbf{s}_1$}; \node[text width=1cm] at (3.9,-0.6) {$\textbf{s}_2$}; \node[text width=1cm] at (3.9,-3) {$\textbf{s}_R$}; \draw (4.2,-5)--(6.2,-5)--(6.2,2.5)--(4.2,2.5)-- cycle; \node[text width=1cm] at (5.2,-0.5) {Pre-trained}; \node[text width=1cm] at (5.2,-1.6) {DNN}; \draw[->,very thick] (6.2,.7) -- (7,.7) -- (7.4,2)--(7.7,2); \draw[->,very thick] (6.2,-1) -- (7,-1); \draw[->,very thick] (6.2,-3.3) -- (7,-3.3); \draw[dashed] (6.5,-1.2) -- (6.5,-2.7); \node[text width=1cm] at (6.9,1.1) {$\textbf{x}_1$}; \node[text width=1cm] at (6.9,-0.6) {$\textbf{x}_2$}; \node[text width=1cm] at (6.9,-3) {$\textbf{x}_R$}; \draw (8,0) -- (9.5,0) -- (9.5,5) -- (8,5) -- cycle; \node[text width=1cm] at (9,3) {Split}; \node[text width=1cm] at (8.8,2.5) {feature}; \node[text width=1cm] at (8.85,2) {vector}; \draw[->,very thick] (9.7,4.2) -- (10.5,4.2); \draw[->,very thick] (9.7,2.5) -- (10.5,2.5); \draw[->,very thick] (9.7,.8) -- (10.5,.8); \draw[dashed] (10,2.2) -- (10,1.3); \node[text width=1cm] at (10.3,4.5) {$\textbf{x}_{1,1}$}; \node[text width=1cm] at (10.3,2.8) {$\textbf{x}_{1,2}$}; \node[text width=1cm] at (10.3,1.1) {$\textbf{x}_{1,P}$}; \draw (10.8,5.4) -- (12.2,5.4) -- (12.2,3.7) -- (10.8,3.7) -- cycle; \draw (10.8,3.5) -- (12.2,3.5) -- (12.2,1.8) -- (10.8,1.8) -- cycle; \draw (10.8,1.6) -- (12.2,1.6) -- (12.2,-.1) -- (10.8,-.1) -- cycle; \node[text width=1cm] at (11.5,4.6) {NCMC}; \node[text width=1cm] at (11.5,2.7) {NCMC}; \node[text width=1cm] at (11.5,.8) {NCMC}; \draw[->,very thick] (12.4,4.4) -- (13.1,4.4); \draw[->,very thick] (12.4,2.5) -- (13.1,2.5); \draw[->,very thick] (12.4,.8) -- (13.1,.8); \draw[dashed] (12.7,2.2) -- (12.7,1.3); \node[text width=1cm] at (13,4.7) {$\tilde{c}_{1,1}$}; \node[text width=1cm] at (13,2.8) {$\tilde{c}_{1,2}$}; \node[text width=1cm] at (13,1.1) {$\tilde{c}_{1,P}$}; \draw (13.3,0) -- (15,0) -- (15,5) -- (13.3,5) -- cycle; \node[text width=1cm] at (14,3) {Majority}; \node[text width=1cm] at (14.3,2.6) {vote}; \draw[->,very thick] (15.2,2.5) -- (16.3,2.5); \node[text width=1cm] at (16,2.8) {$\tilde{c}_{1}$}; \draw[dashed] (7.1,-1) -- (15.1,-1); \draw[->,very thick] (15.2,-1) -- (16.3,-1); \node[text width=1cm] at (16,-.7) {$\tilde{c}_{2}$}; \draw[dashed] (7.1,-3.3) -- (15.1,-3.3); \draw[->,very thick] (15.2,-3.3) -- (16.3,-3.3); \node[text width=1cm] at (16,-3) {$\tilde{c}_{R}$}; \draw (16.5,-4) -- (18.2,-4) -- (18.2,4) -- (16.5,4) -- cycle; \draw[dashed] (15.6,-1.2) -- (15.6,-2.7); \node[text width=1cm] at (17.2,.5) {Majority}; \node[text width=1cm] at (17.5,-.3) {vote}; \draw[->,very thick] (18.4,0) -- (20,0); \node[text width=1cm] at (19.5,.4) {$\tilde{C}$}; \end{tikzpicture} \caption{Overview of the proposed method. Given an input signal $\textbf{s}$, we first use data augmentation to generate a multiple version of the input signal $\left(\textbf{s}_r\right)_{1\leq r \leq R}$. Then we use a pre-trained DNN for feature extraction and obtain the corresponding feature vectors $\left(\textbf{x}_r\right)_{1\leq r \leq R}$. Subsequently, we split each feature vector $\textbf{x}_r$ into $P$ equal parts $\left(\textbf{x}_{r,p}\right)_{1\leq p \leq P}$, and classify each part $\textbf{x}_{r,p}$ using a NCM-inspired classifiers (NCMC) containing anchor vectors $\left(\textbf{Y}_{c,p}\right)_{1\leq c \leq C}$. We obtain a class for each part $c_{r,p}$ and do a majority vote to get the class of $\textbf{x}_r$. Finally, a second majority vote is done thanks to the obtained classes $\left(c_r\right)_{1\leq r \leq R}$ of all generated signals to get assigned class $\tilde{C}$ to the original input signal $s$.} \label{fig:Proposed Method Figure} \end{figure*} \section{Related Work} \label{previous work} There has been interests in incremental learning for a long time~\cite{schlimmer1986case,thrun1996learning,zhou2002hybrid}. For example, methods have been proposed~\cite{iSVM,poggio2001incremental,zheng2013online} to address this problem with the aim at bounding memory footprint (c.f. criterion 3.). These approaches perform learning one subset at a time using Support Vector Machines (SVMs). More precisely, a new SVM is trained for each batch of new data, exploiting previous support vectors. Since the latter are not conveying the full extent of previous data, the newly trained SVM suffers from \emph{catastrophic forgetting}~\cite{kasabov2013evolving,french1999catastrophic}, and thus violate criterion 2 defined in the introduction. Another incremental learning algorithm, called ``Learn++'' was introduced~\cite{learn++,muhlbaier2009learn}. This algorithm adds weak one-vs-all classifiers to accommodate new classes. Therefore, it may result in an excessive computational complexity and memory usage, disobeying criterion 3. It also needs training data for all classes to occur repeatedly, which contradicts criterion 1 Research showed also the possibility for the sequential learning of data~\cite{pentina2015curriculum}. however, this requires to choose a correct ordering of the whole dataset, which does not fulfil criterion 1. In~\cite{mensink2013distance}, the authors proposed to use a pre-trained and unchanged DNN as feature extractor followed by the Nearest Class Mean classifier (NCM). NCM summarises each class using the average feature vector of all examples observed for the class so far. Classification processes by assigning the class of the most similar average vector using a metric that can be learned from data. Compared to other parametric classifiers~\cite{mensink2012metric,mensink2013distance,ristin2014incremental}, NCM showed better performances in incremental learning scenarios. However, NCM gives a lower accuracy than state-of-art methods even when it uses all the dataset, hence does not fulfil criterion 2. In~\cite{hacenebudget}, a quite different incremental method called Budget Restricted Incremental Learning (BRIL) was proposed. BRIL combines ``transfer learning''~\cite{girshick2014rich,pan2010survey} with binary associative memories. A pre-trained DNN is used as feature extractor, as mentioned in~\cite{mensink2013distance}, while binary associative memories act as a classifier. A product random sampling is performed as an intermediate between the pre-trained DNN and the classifier. Despite being compliant with criteria 1 and 3, the accuracy remains significantly lower than existing counterparts, which violates criterion 2. Kuzborskij et al~\cite{kuzborskij2013n} showed that new classes can be added to a multi-class classifier with limited impact on accuracy when the classifiers can be retrained from at least a small amount of data belonging to all classes. Using this, in~\cite{rebuffi-cvpr2017} the authors proposed an incremental learning method called ``Incremental Classifier and Representation Learning'' (iCaRL), based on a trainable DNN feature extractor, followed by a single classification layer. The classification process is inspired by NCM: it computes the mean of feature vectors for each class, and assign the label of the nearest prototype. However, memory usage can easily increase, especially when the dataset is made of high resolution images such as ImageNet, which may violate criterion 3. Moreover, the iCaRL method, when trained on data streams containing only few classes at a time, provides low accuracy as shown in~\cite{rebuffi-cvpr2017}, hence iCaRL does not respect criterion 2. To reach good performances and a comparable accuracy to state-of-art methods, iCaRL thus needs to be trained over batches of data containing a large part of the dataset, which does not correspond to an incremental learning scenario and infringes~1. In this paper, we introduce TILDA that builds upon previously proposed work, attempting to cover all 3 criteria for efficient incremental learning. As in iCaRL and BRIL, TILDA uses a pre-trained DNN as feature extractor. TILDA also uses an NCM-inspired classifier over the feature vectors obtained from by the pre-trained DNN. Data augmentation is performed on both training and classification datasets, aiming to improve accuracy. Consequently, there is no need to retrain the system with previous data, nor to perform computationally intensive processing when new data comes in. In addition, learning new data does not damage previously learned information. \section{Proposed Method} \label{propose} In this section, we describe the TILDA method. We start by giving a high level overview of the process, and then we explain the details. \subsection{Overview of the Proposed Method} \label{overview} TILDA is built upon four main steps: 1) a pre-trained DNN to perform feature extraction, 2) a technique to project features into low dimensional subspaces, 3) an assembly of NCM-inspired Classifiers (NCMC) applied independently in each subspace (c.f. Figure~\ref{fig:Proposed Method Figure}) and 4) a data augmentation inspired scheme to increase accuracy of the classifying process. We develop these steps in the following paragraphs. The first step consists of using the internal layers of a pre-trained DNN~\cite{krizhevsky2012imagenet} as a generic feature extractor on which subsequent learning is performed. This process has become increasingly popular in the past few years and is often referred to as ``Transfer Learning''~\cite{Oquab_2014_CVPR}. The aim is to transfer acquired knowledge on a dataset to another related problem~\cite{pan2010survey}. In the following step we project feature vectors into multiple low dimensional subspaces. More precisely, we split feature vectors into $P$ subvectors. For each class and each subspace, we produce $k$ anchor vectors conveying robust statistical properties about corresponding feature subvectors. Then, in each subspace anchor vectors are exploited to perform weak classification of the input data. We use here a NCM inspired method. A majority vote is then performed to obtain an aggregate decision. Finally, we perform data augmentation on the input signals, be them training or testing inputs, thus obtaining multiple decisions for each input data as well as more robust classifiers in each subspace. A second majority vote is performed using these decisions to generate a global prediction. \subsection{Details of the Proposed Method} \label{improvement} \subsubsection{Pre-Trained Deep Neural Networks} \label{ssec:num1} To obtain features from an input signal, TILDA relies on using DNNs that are pre-trained on a large number of examples. Consequently, using the pre-trained inner layers of the DNN acts as a generic feature extractor~\cite{Oquab_2014_CVPR,DBLP:journals/corr/HongYKH15,pan2010survey}. As a matter of fact, inner layers of a deep DNN offer a good generic description of an input image, even when it does not belong to the learning domain~\cite{Oquab_2014_CVPR}. Using ``Transfer Learning'' ideas, we are not interested in this work in the network's architecture details, as we simply use the appropriate layers to extract features from a given input. In the remainder of this paper, we denote by $\textbf{s}^m$ the $m$-th input training signal and by $\textbf{x}^m$ its corresponding feature vector, where $1 \leq m \leq M$ and $M$ is the total number of training signals. \subsubsection{Projection to Low Dimensional Subspaces} Feature extraction allows us to consider the feature vector $\textbf{x}^m$ instead of the input signal $\textbf{s}^m$. Formally, let us denote $\textbf{x}_c^m$ the fact that feature vector $\textbf{x}^m$ belongs to class $c$. We split each $\textbf{x}_c^m$ into $P$ parts, denoted $\left(\textbf{x}_{c,p}^m\right)_{1\leq p \leq P}$. For each class and each subspace, we create $k$ anchor vectors initialised with 0s, each of them associated with a counter, also initialised by 0. Considering the $p$-th subspace and the $c$-th class, we denote by $Y_{c,p}=[\textbf{y}_{c,p,1},..., \textbf{y}_{c,p,k}]$ the corresponding anchor vectors and $N_{c,p}=[n_{c,p,1},\dots, n_{c,p,k}]$ their associated counters. For each $c$ and $p$, we aim at using the corresponding anchor vectors as centroids of a clustering of $\{\textbf{x}_{c,p}^m\}$. To this end, at each step of the training process, we ensure that each anchor vector is a centroid of a clustering of already processed input subvectors, and the associated counter accounts for the cardinality of the corresponding cluster. Then, each time an input training vector is processed, we identify an anchor vector to be updated. The update simply consists of computing a new anchor vector obtained as a barycenter of the old one with weight given by its counter and the input subvector with weight 1, then incrementing the counter. This procedure is detailed in~Algorithm~\ref{Algo:one}. Namely, rather than simply associating the new subvector with the closest anchor vector, what would inevitably lead to unbalanced counters and thus poor performance in prediction, we prefer to take into account counters while performing this association. More precisely, we linearly penalize anchor vectors that are already made of the combination of many subvectors. Note that when two or more anchor vectors gives the same results (distances multiplied by counters), we choose uniformly at random one of these anchor vectors. \begin{algorithm} \caption{Incremental Learning of Anchor Subvectors} \textbf{Input}: streaming feature vector $\textbf{x}_c^{m}$\\ \begin{algorithmic} \FOR{$p:=1$ to $P$} \FOR{$i:=1$ to $k$} \STATE $d_i=\| \textbf{x}_{p} - \textbf{y}_{c,p,i}\|_2$ \STATE $R_i=d_i n_{c,p,i}$ \ENDFOR \STATE $\tilde{k}=\displaystyle{\arg\min_{i}R_i}$ \STATE $\textbf{y}_{c,p,\tilde{k}} \leftarrow \textbf{y}_{c,p,\tilde{k}} n_{c,p,\tilde{k}} + \textbf{x}_{c,p}^{m}$ \STATE $n_{c,p,\tilde{k}} \leftarrow n_{c,p,\tilde{k}} + 1$ \STATE $\textbf{y}_{c,p,\tilde{k}} \leftarrow \textbf{y}_{c,p,\tilde{k}}/n_{c,p,\tilde{k}}$ \ENDFOR \end{algorithmic} \label{Algo:one} \end{algorithm} Note that the learning process is independent on the order of streaming data, and is performed one example at a time, thus enforcing criterion 1 of incremental learning methods described in the introduction. \subsubsection{Aggregation of subspaces weak classifiers} At prediction stage, consider an input signal $\textbf{s}$ and the associated feature vector $\textbf{x}$. We split $\textbf{x}$ into the corresponding $P$ parts and obtain $\left(\textbf{x}_p\right)_{1\leq p \leq P}$. We compute Euclidean distances between each $\textbf{x}_p$ and all anchor subvectors $\textbf{y}_{c,p,i}$ for which the counter is not 0. Note that there are at most $k C$ such distances, where $C$ is the number of classes seen so far. The class of the closest average anchor subvector is considered as the decision for the $p$-th subspace. Finally, we apply a majority vote over all subspaces to achieve an aggregate decision (c.f. Algorithm~\ref{Algo:two}). Note that more elaborate strategies can result in higher accuracy but may require more computation during the learning phase as well as memorisation of previously seen examples. \begin{algorithm} \caption{Predicting the Class of a Test Input Signal} \textbf{Input}: input signal $\textbf{s}$\\ \begin{algorithmic} \STATE Compute the feature vector $\textbf{x}$ associated with $\textbf{s}$ \STATE Initialize the vote vector $\textbf{v}$ as the \textbf{0 vector} with dimension $C$ \FOR{$p:=1$ to $P$} \STATE $v_p = \displaystyle{\arg\min_{c} \left[\min_{i}\| \textbf{x}_{p} - \textbf{y}_{c,p,i}\|_2\right]}$ \STATE $\textbf{v}_{v_p} = \textbf{v}_{v_p} + 1$ \ENDFOR \STATE $\tilde{C} = \displaystyle{\arg\max_c (\textbf{v}_c)}$ \end{algorithmic} \label{Algo:two} \textbf{Output}: class $\tilde{C}$ attributed to $\textbf{s}$ \\ \end{algorithm} \subsubsection{Data Augmentation} We use two data augmentation methods to improve the accuracy and robustness during training and classification. \textbf{Data Augmentation during Training}\\ To improve the accuracy without increasing memory usage, data augmentation is applied to the training dataset. We generate multiple version of each training input signal, and we consider the resulting dataset as an input to train the model. \textbf{Data Augmentation during Classification}\\ In addition, we propose to obtain multiple predictions for each input signal $\textbf{s}$ using data augmentation~\cite{ciresan3deep}. The idea is to generate multiple versions of the input signal $\textbf{s}$ that we denote $\left(\textbf{s}_r\right)_{1\leq r \leq R}$. We perform a prediction of the class associated with each $\textbf{s}_r$ independently, and then perform a majority vote to obtain the final prediction. \subsubsection{Remarks} We point out multiple facts about the proposed method: \begin{enumerate}[label=\alph*)] \item The learning procedure performs learning one example at a time, \item The learning procedure is computationally light as it only requires performing of the order of $d$ operations where $d$ is the dimension of feature vectors, \item The learning procedure has a small memory footprint, as it only stores averages of feature vectors, \item The learning procedure is such that adding new examples can only increase robustness of the method, so that there is no catastrophic forgetting, \item During prediction stage, memory usage is of the order of $kCd$ and thus is independent on the number of examples and grows linearly with the number of classes, \item During prediction stage, computations are of the order of $kCdR$ elementary operations. \end{enumerate} From these facts we derive that TILDA is compliant with criteria 1 and 3 defined in the introduction. In the next section, we devise a set of experiments to evaluate the classification accuracy of the proposed method on challenging datasets (criterion 2). \section{Experiments} \label{experiments} In this section we describe the protocol used to test the proposed method and compare its accuracy and memory usage with other incremental learning methods. \subsection{Benchmark Protocol} We propose an incremental learning scenario in which we have streaming data containing new classes/examples. We test and compare Budget Restricted Incremental Learning (BRIL), Nearest Neighbour search (NN), Nearest Class Mean classifier (NCM), Learn++, incremental Classifier and Representation Learning (iCaRL), and finally the proposed method (TILDA). Learn++ uses Classification And Regression Trees (CART) as weak classifiers. We evaluate the different methods using CIFAR10, CIFAR100 and ImageNet ILSVRC 2012~\cite{russakovsky2015imagenet}. We also use $50$ ImageNet classes which have not been used to train the CNN (denoted ImageNet50), and which contains $900$/$100$ training/test images per class. All methods take the same feature vectors extracted from Inception V3~\cite{szegedy2015rethinking} as input. This requires to modify iCaRL method by replacing its CNN with a fully connected network. In the following, and for the iCaRL method, we use a MultiLayer Perceptron (MLP) with one hidden layer containing $1024$ neurons, and output layer containing $C$ neurons, where $C$ is the number of classes. The non-incremental learning methods (NI) used are denoted by TMLP and TSVM. TMLP uses transfer learning to compute feature extractors of input data through Inception V3, and then trains a MLP over feature vectors, using the hyperparameters previously described for iCaRL. TSVM method uses Inception V3 to get feature vectors as well, and uses them to train an SVM using Radial Basis Function kernel. Data augmentation used in TILDA generates a horizontal flip of the original image, and shifts the pixels of the image by one pixel at a time (to the left, right, top, bottom, and on the four diagonals). Thus we generate $R=10$ images (8 generated by shifting pixels on the image, one generated by horizontal flip and the original one). \subsection{Results} As a preliminary experiment, we aim to show that replacing the last layers of Inception V3 by the proposed method does not compromise the performances obtained on Imagenet ILSVRC 2012. The 5-top accuracy is $94.4\%$ when we use TILDA with $p=16$ and $k=30$, and $96.5\%$ when we use the last layers of Inception V3 to classify data. The accuracy obtained by TILDA approaches the one obtained by Inception V3, thus our method does not bring a considerable decrease in performances. The second experiment is performed on CIFAR10/100, ImageNet50 and ImageNet ILSVRC 2012, in which we show the contribution of data augmentation, NCM-inspired classification, and subspace division on classification accuracy. Therefore, we define three methods: TILDA-DA does not use data augmentation and classifies only the original image, TILDA-NCM disregards NCM inspired classification and uses $k$ feature vectors randomly chosen per class, and TILDA-P which is TILDA method with no splitting of vectors. Table~\ref{table:table1} summarises the accuracy of TILDA, TILDA-DA, TILDA-NCM and TILDA-P, when performing one-shot learning (learn one example at a time). We notice that TILDA-DA, TILDA-NCM and TILDA-P reach lower accuracy than TILDA, which confirms that the combination of data augmentation with NCM-inspired classification and supspace division can achieve good performances. \begin{figure*} \centering \begin{tabular}{ccc} \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Value of $k$,ylabel=Accuracy (\%), legend style={at={(.699,0.324)},anchor=north west}, legend entries={$P=1$, $P=8$, $P=16$, $P=32$ }, legend plot pos=right \addplot coordinates {(1,83.9)(10,86.1)(20,86.68)(30,87.44)}; \addplot coordinates {(1,83.96)(10,87.16)(20,88.21)(30,88.22)}; \addplot coordinates {(1,84)(10,87.31)(20,88.38)(30,88.7)}; \addplot coordinates {(1,84.4)(10,87.5)(20,88.1)(30,88.3)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Value of $k$,ylabel=Accuracy (\%), legend style={at={(.699,0.324)},anchor=north west}, legend entries={$P=1$, $P=8$, $P=16$, $P=32$}, legend plot pos=right \addplot coordinates {(1,60.23)(10,65.17)(20,65.93)(30,67)}; \addplot coordinates {(1,60.31)(10,67.13)(20,68.23)(30,69.2)}; \addplot coordinates {(1,60.53)(10,67.81)(20,69.1)(30,69.7)}; \addplot coordinates {(1,60.05)(10,67.62)(20,68.72)(30,69.37)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Value of $k$,ylabel=Accuracy (\%), legend style={at={(.699,0.324)},anchor=north west}, legend entries={$P=1$, $P=8$, $P=16$, $P=32$}, legend plot pos=right \addplot coordinates {(1,68.6)(10,71.6)(20,72.2)(30,72.6)}; \addplot coordinates {(1,68.6)(10,73.6)(20,74.4)(30,75)}; \addplot coordinates {(1,69)(10,74.6)(20,75.4)(30,76)}; \addplot coordinates {(1,68.4)(10,73.2)(20,74.6)(30,75)}; \end{axis} \end{tikzpicture} \\ \end{tabular} \caption{Evolution of the accuracy as a function of $P$ and $k$ for CIFAR10 (left), CIFAR100 (middle) and ImageNet50 (right).} \label{fig:pk} \end{figure*} In the third experiment, we study the effect of both quantization parameters $P$ and $k$ on the accuracy of TILDA (c.f. Figure~\ref{fig:pk}). This experiment demonstrates that TILDA reaches best performances for $P=16$. In the following, we perform experiments using TILDA with $P=16$ and $k=30$. Note that in order to be fair in comparison with other techniques, we do not perform data-augmentation during training or prediction in TILDA in the upcoming experiments. The fourth experiment is stressing the effect of class-incremental learning. We adopt a class-incremental scenario (CI), in which methods are trained over streaming data providing all examples from one class simultaneously, one class at a time. We test and compare TILDA-DA, NCM, Learn++ and iCaRL on CIFAR10/100 and ImageNet50 (c.f. Figure~\ref{fig:incremental_classe}). Learn++ adds one weak classifier each time a novel class is introduced, and iCaRL stores $30$ feature vectors per class. We can see that TILDA-DA outperforms the other methods in this setting. \begin{figure*} \centering \begin{tabular}{ccc} \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Number of classes,ylabel=Accuracy (\%), legend style={at={(0,0.385)},anchor=north west}, legend entries={TILDA-DA, NN, NCM, Learn++,iCaRL }, legend plot pos=right \addplot coordinates {(2,97.9)(3,96)(4,94)(5,91.3)(6,88.5)(7,87.44)(8,86.8)(9,86.7)(10,86.8)}; \addplot coordinates {(1,100)(2,98)(3,96)(4,93)(5,90)(6,88)(7,87)(8,86)(9,85.4)(10,85)}; \addplot coordinates {(1,100)(2,97)(3,95)(4,92)(5,89)(6,86)(7,84)(8,83.6)(9,83.4)(10,83.2)}; \addplot coordinates {(1,100)(2,93)(3,89)(4,85)(5,83)(6,81.66)(7,80.8)(8,80.11)(9,80)(10,79.83)}; \addplot[color=green,mark=*] coordinates {(1,100)(2,92)(3,88)(4,84)(5,81)(6,79)(7,77)(8,75)(9,74)(10,73)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Number of classes,ylabel=Accuracy (\%), legend style={at={(.619,1)},anchor=north west}, legend entries={TILDA-DA, NN, NCM, Learn++,iCaRL }, legend plot pos=right \addplot coordinates {(1,100)(10,90)(20,83)(30,78)(40,75)(50,73)(60,71)(70,69)(80,67)(90,66)(100,65.3)}; \addplot coordinates {(1,100)(10,89)(20,81)(30,77)(40,74)(50,70)(60,68)(70,66)(80,63.8)(90,63)(100,62)}; \addplot coordinates {(1,100)(10,89)(20,80.57)(30,75)(40,70.9)(50,68.1)(60,65.4)(70,63)(80,60.6)(90,59)(100,58.25)}; \addplot coordinates {(1,100)(10,75.3)(20,61.85)(30,56.93)(40,51.95)(50,48)(60,42.67)(70,40)(80,37.2)(90,35)(100,33.8)}; \addplot[color=green,mark=*] coordinates {(1,100)(10,90)(20,81)(30,72)(40,64)(50,55)(60,48)(70,43)(80,39)(90,38)(100,37)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Number of classes,ylabel=Accuracy (\%), legend style={at={(.616,1)},anchor=north west}, legend entries={TILDA-DA, NN, NCM, Learn++,iCaRL}, legend plot pos=right \addplot coordinates {(1,100)(10,95)(20,87)(30,80)(40,76)(50,74)}; \addplot coordinates {(1,100)(10,92.5)(20,82)(30,75)(40,70.9)(50,69.7)}; \addplot coordinates {(1,100)(10,91)(20,79)(30,74)(40,70)(50,67)}; \addplot coordinates {(1,100)(10,83)(20,70)(30,63)(40,57)(50,54.2)}; \addplot [color=green,mark=*] coordinates {(1,100)(10,88)(20,77)(30,72)(40,68)(50,64)}; \end{axis} \end{tikzpicture} \\ \end{tabular} \caption{Evolution of the accuracy as a function of number of classes for CIFAR10 (left), CIFAR100 (middle) and ImageNet50 (right).} \label{fig:incremental_classe} \end{figure*} The next experiment illustrates the behaviour of the accuracy when trying to obtain incremental information from new examples of the same class. We adopt an example-incremental scenario (EI), in which we train the method over streaming data providing new examples without introducing new classes. We test and compare TILDA-DA, NCM, NN, Learn++ and BRIL on CIFAR10/100 and ImageNet50. We divide these datasets into $10$ equal size parts, each part containing $5000$ examples ($500/50$ example per class) for CIFAR10/100 and $4500$ examples ($90$ per class) for ImageNet50, and learn one part at a time. Learn++ adds one weak classifier each time a new part is learned. Figure~\ref{fig:incremental_example} shows that all methods handle example-incremental learning and improve their accuracy each time they learn new information provided by new examples. TILDA-DA consistently obtains higher accuracy than Learn++, NCM, NN and BRIL regardless of the quantity of provided data. Note that Learn++ needs large number of examples to perform, and obtains a low accuracy when only few examples are provided. \begin{figure*} \centering \begin{tabular}{ccc} \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Proportion of database,ylabel=Accuracy (\%), legend style={at={(.62,.38)},anchor=north west}, legend entries={TILDA-DA, NCM, Learn++, NN,BRIL}, legend plot pos=right \addplot coordinates {(.1,84.8)(.2,85)(.3,85.3)(.4,85.5)(.5,85.7)(.6,85.8)(.7,86)(.8,86.2)(.9,86.4)(1,86.5)}; \addplot coordinates {(.1,82.32)(.2,82.68)(.3,82.76)(.4,82.78)(.5,82.79)(.6,82.83)(.7,82.89)(.8,82.92)(.9,82.93)(1,82.96)}; \addplot coordinates {((.10,60)(.20,66)(.30,71)(.40,74)(.50,75.7)(.60,77)(.70,78)(.80,78.6)(.90,79.2)(1,79.53)}; \addplot coordinates {(.10,81.32)(.20,82.84)(.40,83.82)(1,85)}; \addplot [color=green,mark=*] coordinates {(0.1,72)(0.2,75.65)(0.3,77.5)(0.4,79.1)(0.6,80.74)(0.7,81.2)(0.8,81.69)(0.9,81.9)(1,82)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Proportion of database,ylabel=Accuracy (\%), legend style={at={(.62,.38)},anchor=north west}, legend entries={TILDA-DA, NCM, Learn++, NN,BRIL}, legend plot pos=right \addplot coordinates {(.1,55)(.2,59.8)(.3,61.7)(.4,63)(.5,64)(.6,64.7)(.7,65)(.8,65.15)(.9,65.25)(1,65.3)}; \addplot coordinates {(.1,55)(.2,56.9)(.3,57.2)(.4,57.4)(.5,57.55)(.6,57.7)(.7,57.82)(.8,57.92)(.9,58)(1,58.25)}; \addplot coordinates {((.10,16)(.20,22)(.30,25)(.40,27)(.50,29.28)(.60,31)(.70,32.5)(.80,33)(.90,33.4)(1,33.88)}; \addplot coordinates {(.1,49.66)(.2,53.3)(.3,55)(.4,56.17)(.5,57.2)(.6,57.59)(.7,58.6)(.8,59)(.9,59.9)(1,60.3)}; \addplot [color=green,mark=*] coordinates {(.1,37)(0.2,44)(.3,47)(0.4,50)(.5,52)(0.6,54)(.7,55.7)(0.8,56.4)(.9,56.8)(1,57)}; \end{axis} \end{tikzpicture} & \begin{tikzpicture}[scale=0.6] \begin{axis}[xlabel=Proportion of dataset,ylabel=Accuracy (\%), legend style={at={(.62,.38)},anchor=north west}, legend entries={TILDA-DA, NCM, Learn++, NN, BRIL}, legend plot pos=right \addplot coordinates {(.1,70)(.2,72)(.3,73)(.4,73.38)(.5,73.5)(.6,73.6)(.7,73.7)(.8,73.8)(.9,73.9)(1,74)}; \addplot coordinates {(.1,66)(.2,66.34)(.3,66.5)(.4,66.8)(.5,66.9)(.6,67)(.7,67.1)(.8,67.13)(.9,67.17)(1,67.2)}; \addplot coordinates {(.1,32)(.2,33)(.3,36.5)(.4,41)(.5,43.6)(.6,46)(.7,47)(.8,48.5)(.9,49.7)(1,50)}; \addplot coordinates {(.1,62.5)(.2,65)(.3,66.7)(.4,67.5)(.5,68)(.6,68.6)(.7,69)(.8,69.2)(.9,69.4)(1,69.7)}; \addplot [color=green,mark=*] coordinates {(.1,45.7)(.2,50)(.3,54)(.4,57)(.5,59)(.6,61)(.7,63)(.8,64.5)(.9,66)(1,67.4)}; \end{axis} \end{tikzpicture} \\ \end{tabular} \caption{Evolution of the accuracy as a function of number of learning examples for CIFAR10 (left), CIFAR100 (middle) and ImageNet50 (right).} \label{fig:incremental_example} \end{figure*} \begin{table*} \centering \caption{Accuracy on CIFAR10/100, ImageNet50 and ImageNet ILSVRC 2012. TILDA uses the following parameter: $P=16$ and $k=30$ . We learn incrementally one example at a time.} \centering {\renewcommand{\arraystretch}{1.3}% \begin{tabular} { | l | l | l | l | l | l |} \hline & TILDA & TILDA-DA & TILDA-NCM & TILDA-P\\ \hline CIFAR100 & $\textbf{69.6\%}$ & $65.3\%$ & $60.7\%$ & $67\%$ \\ \hline CIFAR10 & $\textbf{88.7\%}$ & $86.6\%$ & $84.11\%$ & $87\%$ \\ \hline ImageNet50 & $\textbf{76\%}$ & $74.4\%$ & $69.2\%$ & $72\%$ \\ \hline ILSVRC 2012 & $\textbf{94.4\%}$ &$91\%$ & $89.6\%$ & $90\%$ \\ \hline \end{tabular}} \quad \vspace{.3cm} \label{table:table1} \end{table*} \begin{table*} \centering \caption{Comparison of accuracy (Acc) and memory usage (M) relative to full dataset (corresponding to $100\%$) for the different methods. Note that memory usage of Learn++ method represents the size of weak classifiers, and for iCaRL represents the stored feature vectors and the size of the trainable neural network.} \centering {\renewcommand{\arraystretch}{1.3}% \small{\begin{tabular} {| l | l | l | l | l | l | l | l | l | } \cline{2-9} \multicolumn{1}{l|}{} & \multicolumn{2}{c|}{only CI} & \multicolumn{5}{c|}{both CI and EI} & \multicolumn{1}{c|}{only EI} \\ \cline{2-9} \multicolumn{1}{l|}{} & Learn++ & iCaRL & TILDA & TILDA-DA & NN & NCM & BRIL & Learn++ \\ \hline Acc (CIFAR100) & $34\%$ & $30\%$ & $\textbf{69.6\%}$ & $\textbf{65.3\%}$ & $60.2\%$ & $58.25\%$ & $57\%$ & $34\%$ \\ \cline{1-9} M (CIFAR100) & $10.5\%$ & $8\%$ & $6\%$ & $6\%$ & $100\%$ & $\textbf{0.2\%}$ & $6\%$ & $6.8\%$ \\ \hline Acc (CIFAR10) & $79.8\%$ & $41\%$ & $\textbf{88.7\%}$ & $\textbf{86.6\%}$ & $85\%$ & $83\%$ & $82\%$ & $79.5\%$ \\ \cline{1-9} M (CIFAR10) & $0.65\%$ & $2.7\%$ & $0.6\%$ & $0.6\%$ & $100\%$ & $\textbf{0.02\%}$ & $0.6\%$ & $0.65\%$ \\ \hline Acc (ImageNet50) & $54.2\%$ & $64\%$ & $\textbf{76\%}$ & $\textbf{74.4\%}$ & $69.7\%$ & $67.2\%$ & $67.4\%$ & $50\%$ \\ \hline M (ImageNet50) & $4.7\%$ & $5.6\%$ & $3.3\%$ & $3.3\%$ & $100\%$ & $\textbf{0.11\%}$ & $3.3\%$ & $3\%$ \\ \hline \end{tabular}}} \quad \vspace{.3cm} \label{tab:all} \end{table*} Table~\ref{tab:all} presents the different incremental learning methods, obtained accuracies and memory footprints. Learn++ uses either class-incremental scenario (CI) or example-incremental scenario (EI). iCaRL performs learning process using CI. TILDA, NN, NCM, and BRIL use one-shot learning to process one example at a time providing a novel class or additional information, thus they handle both class-incremental and example-incremental at the same time. TILDA outperforms all other incremental learning methods on both accuracy and memory usage. The last evaluation we perform aims to compare TILDA with a non incremental learning method such as TMLP and TSVM. To do this, we store and train these methods on the whole dataset. The parameters used for TILDA are $P=16$ and $k=30$ for CIFAR10/100 and ImageNet50. Table~\ref{tab:final} shows that TILDA reaches an accuracy comparable to state-of-art methods. As shown by the different evaluation, the TILDA method can at any instant classify data with a good accuracy (c.f. Figure~\ref{fig:incremental_classe} and Figure~\ref{fig:incremental_example}), outperforms other incremental learning methods (c.f. Table~\ref{tab:all}), and approaches state-of-art accuracy (c.f. Table~\ref{tab:final}). Consequently, TILDA fulfils criterion 2. \begin{table*} \caption{Comparison of TILDA with non-incremental learning methods in a non-incremental learning scenario.} \centering {\renewcommand{\arraystretch}{1.3}% \begin{tabular} { | l | l | l | l | l | } \hline & TILDA & TILDA-DA & TMLP & TSVM \\ \hline Acc (CIFAR100) & $\textbf{69.6\%}$ & $65.16\%$ & $68.6\%$ & $67.6\%$ \\ \hline M (CIFAR100) & $\textbf{6\%}$ & $\textbf{6\%}$ & $100\%$ & $100\%$ \\ \hline Acc (CIFAR10) & $88.7\%$ & $86.6\%$ & $90\%$ & $89.2\%$ \\ \hline M (CIFAR10) & $\textbf{0.6\%}$ & $\textbf{0.6\%}$ & $100\%$ & $100\%$ \\ \hline Acc (ImageNet50) & $\textbf{76\%}$ & $74.4\%$ & $75.2\%$ & $75\%$ \\ \hline M (ImageNet50) & $\textbf{3.3\%}$ & $\textbf{3.3\%}$ & $100\%$ & $100\%$ \\ \hline \end{tabular}} \quad \vspace{.3cm} \label{tab:final} \end{table*} \section{Conclusion} In this paper, we have introduced TILDA, a new incremental learning approach inspired by recently proposed methods. TILDA relies on a pre-trained DNN to process data, a projection technique that defines low-dimensional subspaces, NCM inspired classifiers, and data augmentation at both the training and prediction phases. This addresses previous concerns from previous methods of: a) iCaRL as it reaches a good accuracy when stream data contains one class at a time, b) BRIL as it provides a good accuracy comparable to state-of-art method, c) NCM as it uses $k$ anchor vectors instead of one and other methods to increase the accuracy, and d) Learn++ as it still performs well even if steam data does not contains examples of all classes each time. Experiments on challenging datasets show that: a) TILDA does not suffer from catastrophic forgetting, in such a way we get the same accuracy and model representation in both incremental learning and offline learning, b) TILDA approaches state-of-art accuracy, c) TILDA uses much less memory usage and gets the same accuracy as nearest neighbour search or even better, d) TILDA still gives a good accuracy even in the case where we have only one class each time, e) and finally, to our knowledge TILDA is the incremental method that reaches the best accuracy. This method is also promising for embedded devices, since it is not necessary to train a DNN or compute extensive operations for learning. In future work, we plan to explore further the methods for splitting feature vectors, data augmentation strategies and a weighted majority vote to improve the accuracy. We also plan to propose a hardware architecture of TILDA for incremental learning on chip. \label{conclusion} \bibliographystyle{aaai}
{'timestamp': '2018-10-05T02:05:46', 'yymm': '1810', 'arxiv_id': '1810.02020', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02020'}
arxiv
\section{Abstract} We extract pixel-level masks of extreme weather patterns using variants of Tiramisu and DeepLabv3+ neural networks. We describe improvements to the software frameworks, input pipeline, and the network training algorithms necessary to efficiently scale deep learning on the Piz Daint and Summit systems. The Tiramisu network scales to 5300 P100 GPUs with a sustained throughput of 21.0 PF/s and parallel efficiency of 79.0\%. DeepLabv3+ scales up to 27360\, V100 GPUs with a sustained throughput of 325.8\, PF/s and a parallel efficiency of 90.7\% in single precision. By taking advantage of the FP16 Tensor Cores, a half-precision version of the DeepLabv3+ network achieves a peak and sustained throughput of 1.13\, EF/s and 999.0\, PF/s respectively. \end{abstract} \section{Justification} \label{sec:justification} \vspace*{-0.25cm} We apply segmentation architectures to climate datasets; achieving state-of-the-art weather pattern masks. We scale the architectures to 27360\, Volta GPUs, obtaining a peak (sustained) FP16 performance of 1.13\, EF/s (1.0\, EF/s). We developed methodologies at system level and several deep learning algorithmic innovations to achieve this unprecedented scaling. \section{Performance Attributes} \label{sec:attributes} \begin{center} \begin{tabular}{p{4cm}p{4cm}} \hline Performance Attribute & Our submission \\ \hline \hline Category of Achievement & Peak performance, Time-to-solution\\ Type of Method Used & Deep Learning \\ Results reported on basis of & Whole application \\ & including I/O\\ Precision reported & Mixed precision \\ System scale & Measured on full system \\ Measurement mechanism & Application timers \\ \hline \end{tabular} \end{center} \section{Overview} \label{sec:science-drivers} \subsection{Pattern Detection for Characterizing Extreme Weather} Climate change poses a major challenge to humanity in the 21st century. Several nations are considering adaptation and mitigation strategies pertaining to global, mean quantities such as temperature, or sea-level rise. Increasingly, state and local governments are interested in the question of how extreme weather events will change and affect their local communities. For instance, the state of California receives over 50\% of its rainfall through Atmospheric Rivers (ARs), and Water Resource Management planners are interested in understanding if AR tracks will shift in the future, potentially resulting in a dramatic shortfall in fresh water supply. In the state of Florida, homeowners are interested in understanding if Tropical Cyclones (TCs) or hurricanes will become more intense and start making landfall more often. This has a direct impact on home prices and the insurance industry. TCs have caused the US economy over \$200B worth of damage in 2017, and a range of stakeholders are interested in a more careful characterization of the change in number and intensity of such extreme weather patterns in the coming decades. In order to address these important questions, climate scientists routinely configure and run high-fidelity simulations under a range of different climate change scenarios. Each simulation produces 10s of TBs of high-fidelity output which requires automated analysis. Thus far, climate data analysts have relied entirely upon multi-variate threshold conditions for prescribing extreme weather patterns~\cite{prabhat:teca:2012}. Recent efforts~\cite{liu2016application,globenet, racah:nips17} have shown that deep learning can be successfully applied for detection, classification and localization of extreme weather patterns. In this paper, we push the frontier of deep learning methods to extract high-quality, pixel-level segmentation masks of weather patterns. In this work, we use the TensorFlow~\cite{tensorflow2015-whitepaper,tensorflow-site} deep learning framework, which allows the programmatic definition of even very complicated network {\em graphs} in tens of lines of Python code. TensorFlow provides portability with its capability to map a graph onto multi- and many-core CPUs as well as GPUs. Due to the heavy use of linear algebra-based primitives (e.g. convolutions), most networks (including ours) perform very well on GPUs. The graph also captures the parallelism available in the computation, and TensorFlow uses a dynamic scheduler to select which operation (or {\em layer}) to compute based on the availability of inputs. (Scheduling is performed independently on each process in a distributed job, leading to challenges with collective communication described in Section~\ref{subsec:allreduce}.) A deep learning model is trained by comparing its output to known {\em labels}, using a {\em loss function} to quantify the differences between the two. The model parameters (e.g. convolution weights) form a very-high-dimensional (typically millions) space, and training becomes an optimization problem to find the point in the space that minimizes the loss. Each layer is differentiable by construction, and variants of gradient descent are typically used for optimization. Since training sets can be very large, the most common variant is stochastic gradient descent, which performs updates based on randomly-selected subsets (or {\em batches}) of the overall training set. To parallelize training, a common technique is to replicate the model across ranks, with each rank processing a different local batch of images. Updates to the model are aggregated between ranks during each training step. As a deep learning problem is ``scaled out,'' the size of the global batch (combined batch across all ranks) grows but the size of the overall training set remains fixed, making it distinct from traditional weak scaling. The effect of batch size on convergence rate is not fully understood, but with the right {\em hyperparameters} (parameters for the optimizer rather than the model), larger batches require fewer steps to converge, improving overall time to solution if the parallel efficiency is sufficiently high. Although an analogous form of strong scaling also exists (keeping the global batch size constant as worker count grows), it is generally only of interest when effective hyperparameters cannot be found for a larger global batch size. \subsubsection{Segmentation Architecture} \begin{figure} \centering \includegraphics[width=\linewidth]{figures/deeplab-network-cropped.pdf} \caption{\label{fig:deeplab} Schematic of the modified DeepLabv3+ network used in this work. The encoder (which uses a ResNet-50 core) and atrous spatial pyramid pooling (ASPP) blocks are changed for the larger input resolution. The DeepLabv3+ decoder has been replaced with one that operates at full resolution to produce precise segmentation boundaries. Standard convolutions are in dark blue, and deconvolutional layers are light blue. Atrous convolution layers are in green and specify the {\em dilation} parameter used.} \vspace{-5mm} \end{figure} High-level frameworks like TensorFlow make it convenient to experiment with different networks. We evaluated two very different networks for our segmentation needs. The first is a modification of the \emph{Tiramisu} network~\cite{jegou2017one}. Tiramisu is an extension to the Residual Network (ResNet) architecture~\cite{he2016deep} which introduced \emph{skip connections} between layers to force the network to learn residual corrections to layer inputs. Where ResNet uses addition, Tiramisu uses concatenation to combine the inputs of one or more layers of the network with their respective outputs. The Tiramisu network is comprised of a \emph{down path} that creates an \emph{information bottle-neck} and an \emph{up path} that reconstructs the input. To perform pixel-level segmentation, Tiramisu includes skip connections spanning the down and up paths to allow re-introduction of information lost in the down path. Our Tiramisu network uses five dense blocks in each direction, with 2,2,2,4 and 5 layers respectively (top to bottom). We then train the model using adaptive moment estimation (ADAM)~\cite{kingma2014adam}. The second network we evaluated is based on the recent DeepLabv3+ network \cite{deeplabv3plus2018} and is shown in Figure~\ref{fig:deeplab}. DeepLabv3+ is an {\em encoder-decoder architure} that uses well-proven networks (in our case ResNet-50) as a core. The {\em encoder} performs a function similar to Tiramisu's down path but avoids loss of information by replacing some of the downscaling with {\em atrous convolution}. Atrous convolutions sample the input sparsely according to a specified {\em dilation} factor to detect larger features. This simplifies the {\em decoder} (corresponding to Tiramisu's up path) considerably. Our modifications to these existing networks are described in Section~\ref{sec:mod_arch}. \subsubsection{Climate Dataset and Ground Truth Labels} We utilize 0.25-degree Community Atmosphere Model (CAM5) output for this study. Climate variables are stored on an $1152\!\times\! 768$ spatial grid, with a temporal resolution of 3 hours. Over 100 years of simulation output are available in HDF5 files. Ideally, climate scientists would hand-label pixel masks corresponding to events. In practice, scientists currently use a combination of heuristics to produce masks on large datasets. The first step is to process climate model output with the Toolkit for Extreme Climate Analysis~\cite{prabhat:teca:2012,prabhat:teca:2015} to identify TCs. A floodfill algorithm is used to create spatial masks of ARs~\cite{shields2018atmospheric}, which provides the labels for our training process. There are about 63K high-resolution samples in total, which are split into 80\% training, 10\% test and 10\% validation sets. We use all available 16 variables (water vapor, wind, precipitation, temperature, pressure, etc). The pixel mask labels correspond to 3 classes: Tropical Cyclone (TC), Atmospheric River (AR) and background (BG) class. \subsection{Contributions} Motivated by the problem of finding extreme weather patterns in climate data, our paper makes the following contributions: \begin{itemize} \item{We adapt state-of-the art Tiramisu and DeepLabv3+ architectures to solve segmentation problems on high resolution, multi-variate scientific datasets.} \item{We make a number of system-level innovations in data staging, efficient parallel I/O, and optimized networking collectives to enable our DL applications to scale to the largest GPU-based HPC systems in the world (Section~\ref{subsec:system-innovations}).} \item{We make a number of algorithmic innovations to enable DL networks to converge at scale (Section~\ref{subsec:dl-innovations}).} \item{We demonstrate good scaling on up to 27360\, GPUs, obtaining 999.0\, PF/s sustained performance and a parallel efficiency of 90.7\% (Section~\ref{sec:results}) for half precision. The peak performance we obtained at that concurrency and precision was 1.13\, EF/s.} \item{Our code is implemented in TensorFlow and Horovod; our performance optimizations are broadly applicable to the general deep learning + HPC community, our stack is already being used by several other projects.} \end{itemize} While our work is conducted in the context of a specific science driver, most of our proposed innovations are applicable to generic deep learning workloads at scale. \section{State of the Art} \label{sec:intro} \subsection{State-of-the-art in Scientific Deep Learning} In recent years, the scientific community has begun to adopt deep learning methods and frameworks as tools for scientific analysis and discovery~\cite{oreilly,radovic:2018,Mathuriya:2018,Guzik:2016,DanielG:2018,regier:2015}. Early applications were focused on adapting off-the-shelf convolutional neural networks from natural image processing applications or recurrent neural networks from speech recognition applications (for a review see~\cite{karpatne_climate_2017}). There is currently a shift in the community towards incorporating scientific principles (e.g. physical laws such as energy or momentum conservation) and common assumptions (e.g. temporal and/or spatial coherence). Some recent examples in the domain areas related to ours include simulation of local wind field patterns via coupled autoencoder architectures~\cite{henningh_latnet_2017}, turbulence modeling for climate simulations via deep networks trained with loss functions that incorporate physical terms~\cite{wang_piml_2017}, and supervised applications of extreme weather pattern detection~\cite{liu2016application}. The field of physics-informed deep learning for scientific and engineering applications is in its infancy, and this paper is a timely contribution focused on exploring the computational limits of representative architectures that many of the above approaches are based on. \subsection{State-of-the-art in Large-Scale Deep Learning} Modern-day deep neural networks build upon the work laid out by McCullogh and Pitt~\cite{mcculloch1943logical}, and Rosenblatt (perceptron)~\cite{rosenblatt1958perceptron}. While forming the foundation for deep learning, these early models often struggled as the network size increases, limiting their utility in the analysis of complex systems. More recently, work by Krizhevsky~\cite{krizhevsky2012imagenet} opened the flood gates for modern day Deep Learning, showing impressive performance on hard vision tasks using large supervised deep networks. This breakthrough was made possible in part by the rapid increase in computational power of modern computing systems. Since then, the complexity of tasks and the size of the networks have been growing steadily over the years, arguably requiring larger and more powerful platforms. There has been more recent work on scaling deep learning up to larger node counts and performance. Preferred Networks, Inc. demonstrated ResNet-50 converging to 75\% accuracy in 15 minutes using the ChainerMN~\cite{chainermn_mlsys2017} framework on 1024 NVIDIA Tesla P100 GPUs at a total global batch size of 32K for 90 epochs~\cite{pfn-rn50}. Jia at al.~\cite{Tencent}, concurrent with this work, demonstrated scaling to 2048 NVIDIA Tesla P40 GPUs at 64K batch size, achieving convergence in 6.6 minutes using TensorFlow. To effectively utilize leadership class systems, we need to push scaling significantly further than previous work. Most work on classification networks uses relatively small images from the computer vision community. Our work extends Deep Learning to handle much larger input in the form of snapshots from a scientific simulation. These "images" can be millions of pixels in size and generally have many more channels than the red, green, and blue of commodity imaging sensors. We are also contending with a significantly larger dataset that pushes the limits of the file system and requires new data handling techniques. \section{Innovations} \label{sec:innovations} \subsection{System Innovations} \label{subsec:system-innovations} \subsubsection{High speed parallel data staging} \label{subsec:data-staging} Modern neural networks require large amounts of input data and therefore training can easily be bottlenecked by an inability to bring input data to the GPU in a timely fashion. For instance, a single GPU training our modified Tiramisu network can consume 189 MB/s, already above the capabilities of a local hard drive, which means the 6 GPUs on a Summit node require a combined 1.14 GB/s. A training run using 1024 nodes therefore requires a sustained read bandwidth of 1.16 TB/s, and running on the full Summit system will require 5.23 TB/s, more than twice the target performance of the GPFS file system. Summit makes available 800 GB of high-speed SSD storage on each node to help with local bandwidth needs. While a training data set can be quite large (the climate data used in this study is currently 3.5 TB), in a distributed training setting, it suffices for each node to have access to a significant fraction of the overall data set. The images selected by each rank are combined to form a batch, so a sufficient (and independently selected) set of samples for each rank to choose from results in batches that are statistically very similar to a batch selected from the entire data set. In our experiments, 250 images per GPU (1500 per node) are sufficient to maintain convergence. Unfortunately, a naive staging script that asked each of 1024 nodes to copy its own subset of the full data set from GPFS required 10-20 minutes to complete and rendered the global file system nearly unusable for other users of the machine during that time. With this approach, each individual file from the data set was being read by 23 nodes on average. To address this, we developed a distributed data staging system that first divides the data set into disjoint pieces to be read by each rank. Each rank's I/O throughput was further improved by running multiple threads that perform file reads in parallel -- using eight threads instead of one increased the achieved read bandwidth from 1.79 GB/s on average to 11.98 GB/s, an improvement of $6.7\times$. Once all files in the data set have been read from GPFS, point-to-point MPI messages are used to distribute copies of each file to other nodes that require it. This approach takes advantage of the significantly higher bandwidth of the Infiniband network and places no further load on the file system. Our improved script is able to stage in data for 1024 (4500) nodes on Summit in under 3 (7) minutes. On Piz Daint, where no local SSDs are available, the only node local storage with sufficient bandwidth to feed the P100 GPU is the Linux \texttt{tmpfs} (DRAM), which has much more limited capacity. \subsubsection{Optimized data ingestion pipeline} Although the staging of input data into fast local storage eliminates bottlenecks and variability from global file system reads, optimization is also required for the TensorFlow input pipeline that reads the input files and converts them into the tensors that are fed through the network. By default, the operations to read and transform input data are placed in the same operation graph as the networks themselves, causing idle time on the GPU while the CPU performs input-related tasks. This serialization can be eliminated by enabling the prefetching option of TensorFlow datasets, which allows the input pipeline to run ahead of rest of the network, placing processed input data into a queue. As long as the queue remains non-empty, the network can obtain its next input immediately upon completion of the previous one. The queue depth can be made deep enough to insulate against variability in the input processing rate, but the average production rate must still exceed the average consumption rate. As a further optimization, TensorFlow allows for concurrent processing of multiple input files using its \texttt{map} operator; however, the HDF5 library used to read the climate data serializes all operations, negating the benefit of parallel operation. By using the Python \texttt{multiprocessing} module, we were able to transform these parallel worker threads into parallel worker processes, each using its own instance of the HDF5 library. With 4 background processes taking care of reading and processing input data, the input pipeline can more closely match the training throughput of both networks, even when using FP16 precision. \subsubsection{Hierarchical all-reduce} \label{subsec:allreduce} Network training is distributed across multiple GPUs using Horovod~\cite{sergeev2018horovod}. Horovod is a Python module that uses MPI to transform a single-process TensorFlow application into a data-parallel implementation. Each MPI rank creates its own identical copy of the TensorFlow operation graph. Horovod then inserts all-reduce operations into the back-propagation computation to average the computed gradients from each rank's network. Ranks update their local models independently, but (assuming consistent initialization) the use of gradients averaged across all the ranks results in identical updates (i.e. synchronous distributed training). Although it is possible for a TensorFlow+Horovod implementation to use multiple GPUs per rank, we adopted the simpler approach of using a different MPI rank for each GPU (i.e. 6 ranks per node on Summit), allowing the same code to be used on both Summit and Piz Daint. Horovod has been shown to have good scalability up to 1024 GPUs, but as we scaled further, we saw a dramatic loss in parallel efficiency resulting from two issues. The first issue was a bottleneck on the first rank, which acts as a centralized scheduler for Horovod operations. As each TensorFlow process is independently scheduling the operations in its graph, different ranks might attempt to execute their all-reduce operations in different orders, resulting in deadlock. Horovod resolves this by dynamically reordering all-reduce operations to be consistent across all ranks. Each rank sends a message to the controller (rank 0) indicating readiness to perform a given all-reduce operation. Once the controller has received messages from all ranks for one or more operations, it sends a return message to every rank with an ordered list of tensors on which to perform collective operations. Our network has over a hundred allreduce operations per step, forcing the controller to receive and then send millions of messages per second for larger jobs. A distribution of the scheduling load is not possible, as all ranks must agree on a total order of collective operations to perform, so we chose instead to perform hierarchical aggregation of the control messages. The ranks are organized into a tree of configurable radix $r$, and each node in the tree waits for readiness messages from all of its direct children (and its own local operation) before sending a readiness message to its parent in the tree. Rank 0 sits at the root of the tree and uses the original Horovod algorithm for scheduling, but operates as if there were only $r{+}1$ ranks to coordinate. When a rank receives a message to start collective operations, it first relays that message to its children (if any) and then initiates the collective. This recursive broadcast approach guarantees that no rank sends or receives more than $r{+}1$ messages for each tensor, reducing the message load to mere thousands of messages per second, regardless of scale. Tuning of broadcast tree shapes can be important when latency is a concern, but TensorFlow's dynamic scheduler makes it fairly tolerant to small latency differences, and we observed no measureable performance difference for values of $r$ between 2 and 8. The second issue to address was the performance of the collective all-reduce operations themselves. The existing Horovod implementation is able to reduce data residing on GPUs in two different ways, either by a standard \texttt{MPI\_Allreduce} or by using the NVIDIA Collective Communications Library (NCCL)\cite{nccl-site}. Both have their strengths: MPI often uses tree-based communication patterns for performance at scale, while NCCL uses a systolic ring approach that takes advantage of the bandwidth of GPUs that are connected with NVLink within a Summit node. To obtain both the scalability of MPI and the local bandwidth improvements of NCCL, we implemented a hybrid all-reduce approach. Data is first reduced across the GPUs within a node using NCCL. Once those 6 ranks have the same locally-reduced data, 4 of the ranks (two on each CPU socket) each perform an \texttt{MPI\_Allreduce} on a quarter of the data, sharing with the corresponding rank on every other node and obtaining their quarter of the final result. Finally, NCCL broadcast operations are used within the node to ensure each of the 6 GPUs has a full copy of the entire all-reduce result. The decision to have 4 local ranks perform MPI operations was based on experimentation, but suggests that a 1:1 mapping between communicating processes and virtual network devices is the most efficient strategy on Summit (each node has a dual-rail Mellanox IB ConnectX-5 EX adapter that is virtualized as 4 IB devices). With only a single GPU per node, Piz Daint does not benefit from this hybrid all-reduce implementation, but with the trend towards higher GPU counts per node, we expect this optimization to be beneficial on future machines as well. \subsection{Deep Learning Innovations} \label{subsec:dl-innovations} \subsubsection{Weighted loss} The image segmentation task for climate analysis is challenging because of the high class imbalance: about 98.2\% of the pixels are BG and about 1.7\% of the overall pixels are ARs. Pixels labelled as TCs make up less than 0.1\% of the total. With an unweighted loss function, each pixel contributes equally to the loss function, and a network can (and did, in practice) achieve high accuracy (98.2\% in our case) by simply predicting the dominant background class for all pixels. To improve upon this situation, we use a weighted loss calculation in which the loss for each pixel is weighted based on its labeled class. The per-pixel weight map is calculated as part of the input processing pipeline and provided to the GPU along with the input image. Our initial experiments used the inverse of the class frequencies for weights, attempting to equalize the collective loss contribution from each class. We found that this approach led to numerical stability issues, especially with FP16 training, due to the large difference in per-pixel loss magnitudes. We examined more moderate weightings of the classes and found that using the inverse square root of the frequencies addressed stability concerns while still encouraging the network to learn to recognize the minority classes (see Figure~\ref{fig:deeplab-seg}). \subsubsection{LARC} Layer-wise adaptive rate control (LARC)~\cite{larc-paper} is designed to control the magnitude of weight updates by keeping them small compared to the norm of layer's weights. LARC uses a separate independent learning rate for every layer instead of every weight. The magnitude of the update is defined with respect to the weight's norm. LARC improves the accuracy of large networks, especially when trained using large batch sizes. Compared to layer-wise adaptive rate scaling (LARS)~\cite{2017arXiv170803888Y}, LARC removes the need for complex learning rate warm-up techniques and is thus much easier to use. Given all these advantages, we use LARC for the results reported in this study. \subsubsection{Multi-channel segmentation} Traditional image segmentation tasks work on 3-channel RGB images. However, scientific datasets can be comprised of many channels: in case of the CAM5 climate dataset, those can incorporate fields such as temperature, wind speeds, pressure values, and humidity at different altitudes. Our initial experiments on Piz Daint used 4 channels that were thought to be the most important, but when the network was moved to Summit, the additional computational capabilities allowed the use of all 16 channels, which improved the accuracy of the models dramatically. The optimal subset of channels to use likely lies in between these two, and we plan to take advantage of the ability to rapidly train this network at scale to tune for the right subset. \subsubsection{Gradient lag} \label{subsec:gradient_lag} Most of the all-reduce operations required for gradient computation can be overlapped with other computation, but the top-most layer's gradient computation is a sequential bottleneck for a standard optimizer. The network-induced latency of this computation can limit performance at large scale. To improve parallel efficiency, we modified the optimizer to use the gradients computed in the previous step when performing weight updates. In addition to improving the overlap of communication and computation, this {\em lagging} of the gradients allows Horovod to more efficiently batch the tensors for all-reduce computations, increasing network throughput. Although a change to the optimizer usually requires changes to the hyperparameters to maintain convergence properties, the performance benefit is usually worth the effort at large scale. A similar gradient lagging strategy, known as elastic averaging SGD (EASGD) was shown to be effective, with even larger degrees of lag~\cite{EASGD}. \subsubsection{Modifications to the neural network architectures} \label{sec:mod_arch} The developers of the original Tiramisu network advocate the use of many layers with a relatively small growth rate per layer (e.g. 12 or 16)~\cite{jegou2017one} and our initial network design used a growth rate of 16. This network learned well, but performance analysis of the resulting TensorFlow operations on Pascal and Volta GPUs found considerable room for improvement and we determined that a growth rate of 32 would be significantly more efficient. To keep the overall network size roughly the same, we reduced the number of layers in each dense block by a factor of two and changed the convolutions from $3\! \times\!3$ to $5\!\times\!5$ to maintain the same receptive field. Not only was the new network much faster to compute, we found that it trained faster and yielded a better model than our original network. For DeepLabv3+, the atrous convolutions result in a more computationally expensive network than Tiramisu. The standard DeepLabv3+ design makes the compromise of performing segmentation at one-quarter resolution (i.e. $288 \times 192$ rather than $1152 \times 768$) to keep the computation tractable for less-powerful systems, at the cost of fidelity in the resulting masks. The irregular and fine-scale nature of our segmentation labels requires operating at the native resolution of the dataset. With the unparalleled performance of Summit available for this work, we were able to replace the standard DeepLabv3+ decoder with one that operates at full resolution, thereby benefiting the science use case. \subsection{HPC Systems and Environment} \subsubsection{Piz Daint} \label{sec:piz} Piz Daint at CSCS~\cite{pizdaint-site} is a hybrid Cray XC40/XC50 system. We will only consider the XC50 portion of the machine in this paper. The latter is comprised of 5320 hybrid CPU+GPU nodes. The CPU are single-socket Intel Xeon E5-2695v3 with 12 hardware cores which can host 2 HyperThreads each at 2.6 GHz. Each node has 64 GB of DDR memory and is further equipped with one NVIDIA Pascal GPU (P100) with 16 GB HBM2 memory and 32 GB/s PCIe bidirectional bandwidth. The nodes are connected by a low-latency high-bandwidth Aries interconnect with a diameter-5 Dragonfly topology. The peak single-precision floating point performance of the machine is 50.6 PF/s, twice the quoted 25.3 PF/s double-precision performance~\cite{top500-pizdaint-site}. The global LUSTRE file system offers a peak bandwidth of 744 GB/s for reads and a total capacity of 28 PB. \emph{Software environment:} On Piz Daint, we use TensorFlow v1.6, compiled with CUDA 8.0 and the cuDNN 7.1.1 backend. We use our improved Horovod with hierarchical control plane which is based on the official v0.12.0 release. We compile it against Cray MPICH v7.6.0 and enable CUDA-aware collectives. \subsubsection{Summit} \label{sec:summit} Summit is the new leadership class supercomputer installed at the Oak Ridge National Laboratory (ORNL). This system is the current top-ranked supercomputer in the TOP500 rankings, the first on the list to surpass the 100 double-precision PF mark on the HPL benchmark~\cite{top500-summit-site}. The system is comprised of 4608 nodes, each equipped with two IBM Power 9 CPUs and 6 NVIDIA Volta GPUs (V100) with 16 GB HBM2 memory. Each Power 9 CPU is connected to 3 Volta GPUs using NVIDIA high-speed interconnect NVLink, capable of 300 GB/s bi-directional bandwidth. Each node has 512 GB of system memory and a 1.6 TB NVMe disk, half of which is available to jobs to be used as burst buffer. Dual-rail EDR Infiniband cards connect all the nodes using a non-blocking fat-tree topology. The nodes can access a POSIX-based IBM Spectrum Scale parallel file system with a current capacity of 3 PB and approximate maximum speed of 30 GB/s. The Volta architecture includes Tensor Cores that provide mixed-precision operations. In each cycle, each of the 640 Tensor Cores can perform 64 floating-point Fused-Multiply-Add (FMA) operations with input values in half precision and output values either in half (FP16) or single precision (FP32). Deep Learning workloads are able to use mixed-precision. Utilizing the Tensor Cores, each Volta GPU can perform 125 trillion floating-point operations per second, resulting in a peak node performance of 750 TF/s. \emph{Software environment:} On Summit, we use TensorFlow v1.8 compiled with CUDA 9.2 and cuDNN v7.2 backend. We again use our improved Horovod with hierarchical control plane which is based on the official v0.12.0 release. We compile it against IBM Spectrum MPI v10.2 and also NCCL v2.2.13 for fast GPU-based intranode all-reduces. \section{Performance Measurement} \label{sec:measurement} \input{single_gpu_table} Training performance of a deep neural network is generally reported in images (or batches) per second, but it can be useful to convert these numbers into floating point performance (i.e. FLOP/s). To do so, we incorporate some Python code that performs an analysis on the TensorFlow operation graph constructed by the application. The nodes of the graph are traversed and the number of FLOPs required for each operation is computed. This graph-based analysis is essential for computing an accurate FLOP count when working with an application that defines multiple networks that share nodes. For convolution nodes, additional analysis was required as there are multiple algorithmic formulations available, some of which require different quantities of floating point operations. TensorFlow dynamically tunes the algorithm choice for best performance, so it was necessary to use the API tracing capability in cuDNN to determine the algorithm selection. With the current versions of TensorFlow and cuDNN, we found that all convolutions were performed using either implicit GEMMs or direct convolutions. For example, a $3\!\times\!3$ direct convolution on a $1152 \!\times\!768$ image with $48$ input channels, $32$ output channels and a batch size of $2$ requires $3 \!\times \!3 \!\times\! 1152 \!\times \!768 \!\times\! 48 \!\times\! 32 \!\times\! 2\! \times\! 2 = 48.9\! \times 10^9$ FLOPs. (The final factor of 2 follows the normal convention of counting both multiplies and additions as FLOPs.) Once the FLOP count per step has been determined, we normalize this by the number of samples (images) per step. Based on the number of steps we can then compute the number of samples processed in that step per rank and compute statistics on the time series of steps. If not otherwise stated, we compute the mean number of processed samples for every step over ranks and the median of the result over time and quote this as our sustained throughput. We further compute an (asymmetric) error bar based on the central 68\% confidence interval (computed from the 0.16 and 0.84 percentiles) over time. Using the FLOP per sample we can then compute a FLOP rate by multiplying the total processed samples per second with the FLOP per sample. As is common for deep learning training situations, a series of additional calculations is carried out on the validation data set after each epoch, i.e. a full pass over the training data has been performed. Our data staging technique holds the number of steps in an epoch constant as we scale to larger node counts, keeping the epoch sizes large enough that this overhead is negligible once amortized over the steps. \input{single_node_table} \input{07a-Systems} \subsection{Climate Science Results} \label{sec:science_results} \begin{figure*}[ht] \begin{subfigure}[b]{0.64\textwidth} \includegraphics[width=\textwidth]{figures/results_full.png} \caption{Segmentation masks overlaid on a globe. Colors (white->yellow) indicate IWV (integrated water vapor, $kg/m^{2}$), one of the 16 input channels used by the network. \label{subfig:deeplab-seg-full}} \end{subfigure} \hfill \begin{subfigure}[b]{0.33\textwidth} \includegraphics[width=\textwidth]{figures/results_zoom.png} \caption{Detailed inset showing predictions (red and blue) vs. labels used in training (black). \label{subfig:deeplab-seg-zoom}} \end{subfigure} \caption{Segmentation results from modified DeepLabv3+ network. Atmospheric rivers (ARs) are labeled in blue, while tropical cyclones (TCs) are labeled in red. \label{fig:deeplab-seg}} \vspace{-4mm} \end{figure*} Segmentation accuracy is often measured using the {\em intersection over union} (IoU) metric. The Tiramisu network obtained an IoU of 59\% on our validation data set, while our modified DeepLabv3+ network was able to achieve 73\% IoU. Visually, this translates into qualitatively pleasing masks as seen in Figure~\ref{fig:deeplab-seg}. Not only does the network find the same atmospheric features, it makes a very good approximation of their exact boundaries. In some cases, the boundaries predicted by the model appear to be superior to the labels provided by heuristics. One of the tropical cyclones in Figure~\ref{subfig:deeplab-seg-zoom} does suffer from overprediction. This is an expected consequence of our weighted loss function, which penalizes a false negative on a TC by roughly $37 \times$ more than a false positive. \section{Performance Results} \label{sec:results} \subsection{Single GPU Performance}\label{sec:single-node-performance} Using the methodology described in Section~\ref{sec:measurement}, we determined the number of floating point operations required to process a single image with the Tiramisu and DeepLabv3+ networks. Combining these values with the sustained training rate (in samples/s) per GPU yields the sustained single GPU compute performance in Flop/s for each network. For both networks, a single image per GPU is processed per training step when FP32 precision is used, while for FP16, the lower memory footprint enables batches of two images per GPU to be processed during each training step. Single GPU performance results from this analysis can be found in Figure~\ref{fig:single-gpu-perf}. From the tabulated data, we observed that the DeepLabv3+ network utilizes compute resources more efficiently than Tiramisu, achieving a higher percentage of peak Flop/s for both FP32 and FP16 computations. However, when comparing FP32 to FP16 computations across all results, the FP16 results are notably less efficient. To determine the source of these performance inefficiencies, we made a detailed analysis of the work performed on the GPU using the CUDA profiling tools. Figure~\ref{fig:single-node-perf} provides a summary of this analysis, with further per-network details shown in Figure~\ref{fig:single-node-perf-tiramisu} (Tiramisu) and Figure~\ref{fig:single-node-perf-deeplab} (DeepLabv3+). In order to capture the cost of all-reduce operations, this analysis was performed on a job running across 4 Summit nodes (24 GPUs), so the numbers differ slightly from the single GPU performance discussed above. Multiple runs were required to measure different performance counters, and the non-determinism in TensorFlow's execution of the graph adds some noise to the measurements (which, in some cases, causes ratios to slightly exceed 100\%). Further, each training step requires thousands of kernels, making a traditional roofline analysis difficult. Instead, we grouped kernels into eight categories and looked at the computational and memory needs of each category. All of the computationally intensive kernels are in the forward and backwards convolutions, which get fairly good utilization of the FP32 computing resources. However, the analysis shows that the Tiramisu network's convolution kernels become memory limited when using FP16 precision. This is a fundamental limitation of the Tiramisu-style network due to its small filter sizes per layer. The convolutions in the DeepLabv3+ use much larger channel counts per layer, resulting in higher computational intensity. This reduces the overall memory demand and improves datapath utilization. In addition to the convolutional layers, neural networks require many point-wise operations in the forward and backward passes (e.g. bias and dropout layers) as well as in the optimizer. The most expensive of these are in the forward pass, and get very good memory utilization for both FP32 and FP16 precisions. A small but significant contribution to the overall step time comes from copies and transpose operations that are inserted by TensorFlow. Although both networks can be implemented without extra copies (by assembling layers in place), the TensorFlow graph optimization pass is not able to make such a specific optimization. As a final optimization, we modified the data layout of the decoder stage of the DeepLapv3+ network to produce fewer extraneous transposes. This modification yielded a ~10\% speedup compared to the original code for our largest scale run. Finally, the NCCL kernels used for the intra-node portion of the all-reduce operations are bottlenecked by the bandwidth of the NVLink connections rather than the DRAM bandwidth (as described in Section~\ref{subsec:allreduce}, the MPI portion of the all-reduces is performed on the CPU concurrently with GPU and is not shown here). Our analysis found that the GPU is kept completely busy for the FP32 cases, indicating that any performance improvements have to come from optimizing or eliminating some of the kernels running on the GPU. The most beneficial kernels to optimize are the convolutions, but with so many different kernels being used, the effort would be significant, and would deny the application the benefit of any improvements that are made to the cuDNN library. For example, a move from cuDNN v7.0.5 to v7.1.2 early in the project resulted in a 5\% performance improvement with no changes to the application. We explored a move away from TensorFlow, implementing the network directly with cuDNN library calls, but the resulting code was much harder to maintain than the TensorFlow version. A 5-10\% performance gain was not worth the impact on programmer productivity. The final optimization strategy, and the one we are pursuing, is to make incremental improvements within TensorFlow to improve the memory management and fuse some of the point-wise operations together to reduce the number of times tensors are read and written to DRAM. This might also allow the batch size to be increased, which would also improve the efficiency of the convolutional stages. With the use of significantly faster math in the FP16 cases, the memory-bound kernels consume a larger fraction of the overall step time, and any optimizations to eliminate copies or fuse point-wise tasks will help the FP16 even more than FP32. The profile for the FP16 also shows some periods where the GPU has run out of work, suggesting that code running on the CPU such as the input pipeline or the TensorFlow scheduler may require additional optimization as well. \subsection{Scaling Experiments} \label{sec:scaling-experiments} We perform several scaling experiments on Piz Daint and Summit. On Piz Daint, we ran the Tiramisu network only, while on Summit, both Tiramisu and DeepLabv3+ networks were run. The experiment setup is slightly different for the two systems and we explain the details below. We bind one MPI rank to each GPU which amounts to one rank per node on Piz Daint and six ranks per node on Summit. On Piz Daint, we scale the training up from a single GPU to the full machine, i.e. 5300 nodes. We also compare the scaling behavior when staging input data against reading it from the global Lustre file system. On Summit, we run with a single GPU as a baseline, but then sweep from 1 to 4560\, nodes using all 6 GPUs per node (i.e. 6 to 27360\, GPUs). The scaling results are shown in Figure~\ref{fig:weakscale_tiramisu}. We find that the training performance of Tiramisu scales to a sustained 21.0 PF/s on the full Piz Daint machine, achieving parallel efficiencies of 83.4\% at 2048 nodes and 79.0\% at 5300 nodes in FP32. On Summit, scaling Tiramisu to 4096 nodes yields a sustained throughput of 176.8 PF/s and 492.2 PF/s for FP32 and FP16 precision respectively, maintaining parallel efficiencies above 90\% in both cases. Moving on to DeepLabv3+, scaling to 4560\, nodes with FP32 precision yields a sustained throughput of 325.8\, PF/s and a parallel efficiency of 90.7\%. The FP16 network reaches a peak 1.13\, EF/s, sustained 999.0\, PF/s and 90.7\% parallel efficiency at that scale. The highest performing results were obtained on Summit in the cases with gradient lag (see Section~\ref{subsec:gradient_lag}) enabled, corresponding to the data labeled ``lag 1" in Figure~\ref{fig:weakscale_tiramisu}. The results clearly indicate the effectiveness of the lagged scheme in improving the overall application scalability. \begin{figure*}[ht] \centering \begin{minipage}{.494\textwidth} \includegraphics[width=0.99\linewidth] {figures/weak_scaling_tiramisu_combined_gb.pdf} \subcaption{Tiramisu} \end{minipage} \begin{minipage}{.494\textwidth} \includegraphics[width=0.99\linewidth] {figures/weak_scaling_deeplab_combined_gb.pdf} \subcaption{DeepLabv3+} \end{minipage} \caption{\label{fig:weakscale_tiramisu}Weak scaling results in terms of images/sec and sustained performance in PF/s on Summit (FP16 and FP32, Tiramisu and DeepLabv3+) and Piz Daint (FP32, Tiramisu). The dashed lines represent the ideal scaling lines for the different architectures and precisions.} \end{figure*} \begin{figure}[ht] \centering \includegraphics[width=0.9\linewidth]{figures/weak_scaling_tiramisu_fs_dependence.pdf} \caption{\label{fig:fsdep_tiramisu}Dependence of weak scaling on input data location on Piz Daint.} \end{figure} To demonstrate the benefit of the data staging process described in Section~\ref{subsec:data-staging}, we experimented on Piz Daint with reading input data directly from the global file system and highlight results in Figure~\ref{fig:fsdep_tiramisu}. Performance matches the runs using data staging at lower node counts, but the difference becomes apparent at larger scales. On 2048 GPUs, the parallel efficiency has dropped to 75.8\%, a 9.5\% penalty for not staging the input data in the local \texttt{tmpfs} storage. Additionally, the throughput shows larger variability. At this scale, the neural network is demanding nearly 110 GB/s of input data, very close to the file system's limit of 112 GB/s. Therefore, we did not attempt to scale beyond 2048 nodes without data staging. \subsection{Convergence at Scale} A major challenge for deep neural networks is to maintain convergence properties (and with good accuracy) as the network training is scaled out. To demonstrate the stability of our network at large scales, we performed longer runs on up to 1024 Summit nodes using both the FP32 and FP16 precision modes, training the network to convergence. As with the scaling runs, the dataset is resampled to put 1500 files per node, improving the statistical properties of the large batches being used at this scale. The training in each case was performed for a fixed number of epochs (targeting a total training time of just over two hours). The training loss curve for these runs are shown in Figure~\ref{fig:hero_loss} along with curves for runs at smaller scales (384 GPUs and 1536 GPUs). Moving averages over 10 step windows are used to filter out step-to-step fluctuations in the loss. As can be seen in Figure~\ref{fig:hero_loss}, all of the configurations are converging with both FP16 and FP32. Tiramisu as well as DeepLabv3+ network is stable at large scale with the initially chosen set of hyperparameters. Tuning of hyperparameters is always necessary when scaling up a network, and we expect that the time to solution will improve further as they are dialed in. There are a few other important things to notice in Figure~\ref{fig:hero_loss} 1) FP16 converges in significantly less time that FP32; 2) DeepLabV3+ generally converges faster than Tiramisu; 3) And lag0 vs lag1 with DeepLabV3+ has nearly identical training loss curves. The ability to perform these experiments in an hour or two rather than days is a key enabler to being able to perform training at these scales and explore the hyperparameter and algorithm space. \begin{figure}[t] \centering \includegraphics[width=0.9\linewidth]{figures/climate_loss_curve.pdf} \caption{\label{fig:hero_loss} Training loss curves for various concurrencies and precisions for the Tiramisu and DeepLabv3+ architectures.} \end{figure} \input{08a-ScienceResults} \section{Conclusions} \label{sec:conclusions} We have presented the first exascale-class deep learning application. Motivated by the important problem of segmenting extreme weather patterns, we have successfully applied the Tiramisu and DeepLabv3+ architectures to high resolution, multi-variate climate datasets. We developed a number of enhancements to the deep learning algorithms (custom loss function, optimization schemes, channels and network architecture) to obtain excellent qualitative and quantitative results. We built upon a number of system-level optimizations (advanced data staging, optimized data ingestion, and hierarchical all-reduce communication) to scale the scientific application to an unprecedented level of concurrency (4560\, Summit nodes, 27360\, Volta GPUs), scaling efficiency (90.7\%) and performance (1.13\, EF/s peak, 999.0\, PF/s sustained). Our work extends open-source TensorFlow and Horovod tools, thereby benefiting the broader scientific and commercial deep learning communities. The environment we have developed is already in use by other teams on Summit and the methodologies will extend to current and future HPC platforms. \section{Implications} \label{sec:future} \subsection{Climate Science} This is the first successful demonstration of the application of Deep Learning for extracting pixel-level segmentation masks in the climate science community. This analysis opens the door for more sophisticated characterization of extreme weather than what has been possible before. Prior to this work, climate scientists reported coarse summary statistics such as number of global storms. In contrast, we can now compute conditional precipitation, wind velocity profiles and power dissipation indices for \emph{individual} storm systems. These sophisticated metrics will enable us to characterize the \emph{impact} from each event (physical damage to infrastructure, flooding, monetary loss, etc) with unprecedented fidelity. In the future, we will explore advanced architectures that can consider temporal evolution of storms. This will increase the resident size of the network architecture, requiring model (as well as data) parallelism for efficient execution. We also plan on working with the climate science community to generate high quality ground truth datasets without resorting to heuristics. Developing accessible interfaces for specifying masks, and bootstrapping the process using online, semi-supervised methods is an area for further investigation. \subsection{Future Systems} Scaling Deep Learning further on future exascale machines with purely data parallel techniques will prove to be numerically difficult. Techniques such as LARC have increased the total global batch size that can converge, but we view the incorporation of model parallel approaches as being indispensable in the foreseeable future. Systems like Summit (with high speed NVLink connections between processors) are amenable to domain decomposition techniques that split layers across processors. Exploring model parallel implementation across nodes is a natural extension, that will require investments in more complex collectives in software libraries like Horovod and NCCL, and optimizations at the algorithm as well at network switch level. Additional training performance optimizations will increase the rate at which we need to feed input data to the networks, further exacerbating the parallel I/O problem. While compression techniques can be used at the expense of already heavily utilized main processors, more memory close to the compute elements, such as node-local non-volatile memory, may help reduce the pressure on the global file system. There is also a potential for processing at the storage layer itself to aid in data processing and augmentation. Generally the stress on the dataplane and communication layers will quickly increase, requiring holistic approaches towards hardware and software co-design. To conclude, we believe that field of Deep Learning is poised to have a major impact on the scientific world. Scientific data requires training and inference at scale, and while Deep Learning might appear to be a natural fit for existing petascale and future exascale HPC systems, careful consideration must be given towards balancing various subsystems (CPUs, GPUs/accelerators, memory, storage, I/O and network) to obtain high scaling efficiencies. Sustained investments are required in the software ecosystem to seamlessly utilize algorithmic innovations in this exciting, dynamic area. \section*{Acknowledgments} This research used resources of the National Energy Research Scientific Computing Center (NERSC), a DOE Office of Science User Facility supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC02-05CH11231. This work was supported by a grant from the Swiss National Supercomputing Centre (CSCS) under Project ID g107. We thank Nicholas Cardo, Andreas Joksch, Miguel Gila and the CSCS staff for assistance in using Piz Daint. We thank Paul Tucker and Rajat Monga from Google for helpful discussions pertaining to TensorFlow. Michael Wehner, Karthik Kashinath, Burlen Loring, Travis O'Brien and Bill Collins from LBNL were instrumental in motivating the climate science problem and providing datasets. This research used the Summit system at the Oak Ridge Leadership Computing Facility at the Oak Ridge National Laboratory, which is supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC05-00OR22725. We are very grateful to OLCF staff: Veronica Melesse Vergara; Don Maxwell, and Matthew Ezell for their assistance with the runs, and Arjun Shankar; Ashley Barker; Tjerk Straatsma and Jack Wells for programmatic support. \section{Detailed Performance Analysis Results} \input{single_node_details} \end{document}
{'timestamp': '2018-10-05T02:04:23', 'yymm': '1810', 'arxiv_id': '1810.01993', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01993'}
arxiv
\section{Introduction} \label{sec:1} Academic institutes in a country are the biggest stake holders in the knowledge production, diffusion, and innovation. Institutions nurture the manpower and provide resources to conduct research. Cumulative effort of academic institutions, Industry, and government agencies is essential for building an efficient knowledge economy \cite{chen2017research,laursen2011exploring}. Studies suggest that \cite{SCImago} that developed countries dominate with their share in total research output measured via publications and citations. However in recent years developing countries like India, Brazil, China etc have significantly increased their global share of research output. Exploring and understanding the major factors and policies leading to this accelerated growth is of interest to both academicians and policy makers ~\cite{garfield1983mapping,gupta2009status,SCImago,arunachalam1998science} Flow of scientific knowledge across people, institutions and countries through collaborations and citations determine the evolution of scientific discoveries and technological growth. Quantitative analysis of different forms of networks constructed from bibliometric data provide an insight into underlying structural and dynamic properties of scientific collaboration~\cite{herrera2010mapping,singh2018structure}. In the last two decades, the rapid growth of network science and availability of large scale data on scientific publications has led to large scale studies on analysis of patterns of scientific collaboration and citations \cite{newman2001structure,barabasi2002evolution}. Analysis of the evolution of co-authorship and citation networks have largely focused on the interactions between individuals and Institutions at global level to explain the functioning of ecosystem of scientific collaboration \cite{mazloumian2013global,dong2017century}. These studies have shown broad features such as power law behavior of the collaboration networks \cite{newman2001structure}, preferential attachment \cite{newman2001clustering}, knowledge flow map \cite{mazloumian2013global}, aging in collaboration strength and citations \cite{borner2004simultaneous, hajra2005aging,wang2013quantifying}, and geographic proximity~\cite{laursen2011exploring,katz1994geographical,pan2012world,ma2014effect}. In this work, we focus on the collaboration and citations networks in American Physical Society (APS) journals with at least one author with an Indian affiliation. The motivation behind restricting to country specific study at mesoscopic Institution level is three fold. First, studies on large scale datasets in scientific collaboration networks at global level often masks the small scale dynamics that are specific to Institutions, cities, and countries. While large scale studies highlight the global average trend in network measures, small scale studies give deeper insight into nature of interactions between institutes that drive the collaborations~\cite{mazloumian2013global,pan2012world,ma2014effect,gasko2016new,hou2007structure}. Secondly, investigating the behavior of these networks at country level helps us to reveal multitude of factors such as type of Institutions, characteristic of the Institutions, and location of Institutions which influence collaborations. Thirdly, extracting the factors influencing collaborations are useful in framing of higher education and research policy, allocation and prioritization of resources at the Institutional level. In this work, we have constructed different types of Networks representing collaboration between Institutions, citations flow between Institutions and broadly across the category of the Institutions. Using different network measures, we have analyzed the strength of collaboration between Institutions, importance of Institutions, constructed spatial network of collaborations, analyzed the role of geographical proximity in collaboration. \section{Data} We use journal papers published by American Physical Society(APS) between 1970-2013 in journals Physical Review A-E, Physical Review Letters, and Review of Modern Physics. Since our study restricted to India, we have chosen all the articles such that there is at least one author with Indian affiliation. The total number of such papers was 14,704. From each of these articles we extract the affiliations of all the authors and extract the national origins for outside. We mark all the non-Indian affiliations in our subset as 'Foreign' and only extract respective countries. For the Indian affiliations, we extract the Institute name, type of Institution, city and the pin-code. We disambiguate the Institute affiliation naming and assign a unique ID. The disambiguation is done using string matching, edit distance measures to compare Institutes names, and manually checked for repetitions. This reduced the total number of distinct institutes from 7180 to 677. Out of the reduced set, we could map 628 institutes to their pin-code locations. After cleaning the data, we classified each institute based on the categories as described below, and constructed the following networks for our analysis. We use the classification of Indian higher education Institutions by University Grants Commission (UGC) of India~\cite{ugc}, which are based on degree awarding category, managing bodies such as state, central or private, and sources of funding (see Table. \ref{tab:1}). We also included special categories which are certified by UGC, but not given a standard category (such as Private Institutes and State Research Institutes). \begin{table*}[htbp] \caption{Categories of Institutions} \resizebox{0.6\textwidth}{!}{ \begin{tabular}{l|l|p{6cm}} \hline \textbf{Type of Institutes} & \textbf{Acronym} & \textbf{Function} \\ \hline National Research Institutes & NRI & Research Institutions funded by the central government \\ Institutes of National Importance & INI & Teaching (both UG and PG) and research Institutions, declared by as INI by Government of India \\ Central Universities & CU & Public Universities formed by Central Act. \\ State Universities & SU & Public Universities formed by State Act. \\ State Colleges & SC & Colleges affiliated to State Universities \\ Central Colleges & CC & Colleges affiliated to Central Universities \\ Deemed Universities & DU & Public or Private Universities which can award degrees on their own , and declared as deemed by UGC \\ Private Universities & PU & Universities established through a state or central act by a sponsoring body which can be a registered Society, Trust or Non-profit Company \\ Private Institutes & PI & Stand alone private Institutions recognized by government \\ State Research Institutes & SRI & These are research Institutions funded by the state government \\ \hline \end{tabular} } \label{tab:1} \end{table*} \begin{figure*}[htbp] \centering \framebox{\includegraphics[scale = 0.45]{indiawrd13}} \caption{Map of India's Global collaboration based on the publications in APS journals between 1970-2013. Each red dot in within is an institute while outside India they represent capital cities of the respective countries.} \label{f1} \end{figure*} \section{Methods} \label{sec:2} We have explored collaborations by constructing networks at the Institution level, its geographic location, and category. This allows us to explore the network properties at multiple scales by constructing super nodes from individual nodes. We also explore citations between these Institutions to assess the knowledge flow between Institutions and their category. \\ ~ \\ \textbf{Construction of Networks}\\ \textit{Institute Collaboration Network} : We construct a weighted undirected networks with institutes as nodes, where the edge weights between two nodes $i,j$, represent the number of co-authored pairs between these Institutions. In Fig. ~\ref{f1}, we show the map of collaborations between Indian Institutions and different countries of the world. \\ \textit{Institute Citation Networks}: Here, the weighted directed network is constructed with institutes as nodes, and for two nodes $i,j$, the edge weight $e(i \rightarrow j)$ from $i\rightarrow j$, denotes the number of citations authors from $i$ have cited authors from $j$.\\ \textit{Network based on Institution Type}: Institutions of same type are clubbed into single super node, and network based on collaboration/citation between super-nodes are constructed as in Fig~\ref{f2} and Fig~\ref{f4}. To track the evolution of these networks, we construct cumulative graphs at one year time interval from 1970-2013. At a given time $t$, the network will have information about all the collaboration or citation between the nodes from $0$ to $t$. \\ ~ \\ \textbf{Network Measures}\\ We measure the normalized \textbf{strength of collaboration} between two institutes by $ {\cal N }_{ij}= \frac{C_{ij}}{w_i \times w_j}$~\cite{pan2012world}, where $C_{ij}$ is the number of common papers between nodes $i$ and $j$, and $w_i$ and $w_j$ are the number of papers published individually by $i$ and $j$ respectively.To characterize the structural significance of nodes in the network we use three centrality measures: Betweenness, Average Degree, Clustering and Page-Rank centrality~\cite{newman2010networks}. The knowledge flow in and out of a node is measured in the Institute citation network as (a) $ {\cal F} _i^{out}= k_{i}^{in} \times \frac{ W_i^{in}}{W_i^{in} + W_i^{out}}$ and (b) $ {\cal F} _i^{in}= -k_{i}^{out} \times \frac{ W_i^{out}}{W_i^{in} + W_i^{out}}$ where $k_i^{in}$, $k_i^{out}$ are in-degree and out-degree of a node, and $W_i^{in}$, $W_i^{out}$ are total incoming and outgoing weights respectively. For our analysis, we performed measurements on the \textit{cumulative} collaboration and citation networks between institutes up to 2013. The centrality value of each super node in every case is the average of values of its constituents. We measure the distance between two Institutions by measuring the Vincenti (great arc) between the pin-codes representing these Institutions. We club the distance in 50 km bins. Gephi~\cite{ICWSM09154} software and Networkx~\cite{hagberg2005networkx} package in python were used for calculations and visualizations. \vspace{-0.5cm} \section{Results} In our analysis, we have addressed four questions related to collaboration , affiliation, distance between Institutions, and type of Institution based on analysis of different types of network discussed in the methods section. \\ ~ \\ \textbf{Does collaboration depend on Geographic proximity?}\\ With the advancement in telecommunication and transportation technology it seems natural that communication has overcome the distance barrier \cite{freidman2005world,graham1998end}. However, studies have shown that geographic proximity still plays a role in establishing connections \cite{laursen2011exploring,ma2014effect,pan2012world}. In our study we address this question by measuring change in frequency of collaboration and strength of collaboration vs. distance between Institutions. \begin{figure*} \centering \includegraphics[scale = 0.45]{boxplot1} \includegraphics[width=0.35\linewidth]{distVScolab} \includegraphics[width=0.35\linewidth]{data} \caption{Dependence of the strength of collaboration with geographic distance between Institutes (a- Top) Box of the collaboration strength ${\cal N}_{ij}$ versus distance (in multiples of 50 kms) (b-bottom left) Frequency of collaboration with distance (c-bottom right) Mean strength of collaboration $\langle {\cal N}_{ij} \rangle$ versus distance. Panel (c) Average cumulative strength of collaboration ${\cal N}_{ij}$ (from 1970-2013) with distance in multiples of 50kms ( Note the change in y axis scale). } \label{f7} \end{figure*} Fig.\ref{f7} top panel shows the box plots of the strength of collaboration (${\cal N}_{ij}$) as defined in Section\ref{sec:2} for different distance bins. Each bin $b_k$ is 50kms wide and data includes all the pairs $i,j$ such that $50(k-1)\leq d_{ij}<50k $ . There is broad declining trend in the median of the normalized collaboration strength with distance. However, after the 31st bin (1500- 1550 kms), there is a surge in collaborations and then the trend is uneven. Bottom left panel shows the average strength of collaboration $ \langle {\cal N}_{ij}\rangle$ versus distance for different time periods, Panel (c) shows the cumulative strength of collaborations up to 2013 in log-linear scale. After $b_1$, there is a big drop in $ \langle {\cal N}_{ij}\rangle$ . People collaborate mostly within their own Institutions and with people in their city. Afterwards, the collaborations broadly decrease, but there are many spikes in between, which is likely due to peaks in the pair correlation function between population of cities $C(\mathbf r)=\langle P(\mathbf x) P(\mathbf x+ \mathbf r)\rangle$ . There is no indication for a power law decay in $ \langle {\cal N}_{ij}\rangle$ with distance. \begin{figure*} \centering \includegraphics[scale = 0.35]{SC-X.pdf} \includegraphics[scale = 0.35]{SU-X.pdf} \includegraphics[scale = 0.35]{NRI-X.pdf} \includegraphics[scale = 0.35]{INI-X.pdf} \caption{Comparing the Frequency of collaboration of SC,SU,NRI and INI's with institutes of other categories denoted by -X. SC and SU have more local collaborations while NRI and INI's have collaborations spread over wider distances.} \label{f10} \end{figure*} To explain the variance in collaboration versus distance, we split the collaborations in to Institutional groups (categories) as in Table .\ref{tab:1} and study the frequency of collaborations between four different pair of groups $SC-X, SU-X, NRI-X ,$ and $INI-X$ as in Fig.\ref{f10}. Here $X$ denotes all category of Institutions combined. The State Colleges (SC) and State Universities (SU) collaborate strongly with Institutions in the close proximity than farther cities (Top panels ). On the other hand National Research Institutions (NRI) and Institutes of National importance (INI) don't show strong dependency on distance. In all graphs we notice an increase in frequency of collaborations at distances between 750-1650km(15-35 bin). This is largely due to collaborations between Institutions located in highly populous metropolitan areas such as Delhi, Kolkata, Mumbai, Bangalore,and Chennai. The aerial distance between these cities lies in this range. We argue that the strength of collaboration between NRI and INI in major cites can be the reason for fluctuations in Fig. \ref{f7}(c). \\ ~ \\ \textbf{Does collaboration between Institutions depend on their productivity?}\\ The number of publications by authors affiliated to an institute is a strong indicator of its research output. We hypothesize that collaboration strength depends on the category of Institutions and its productivity. We build network of Institutional category by creating super nodes from the individual nodes as described in the methods section. In Table \ref{tab:2}, we tabulate the number of papers, number of institutions, and papers per Institute in each category. Of all the publications in the dataset, NRI's contribute to $63\%$ of papers followed by SU's ($23\%$) and INI's($18\%$). The total research productivity is highest for NRI (9292), followed by SU (3438) and INIs (2635). The average productivity is (papers per Institute) is highest for NRIs (122.3) followed by CU (65.1) and NRIs (57.3). \begin{table*} \caption{Number of Papers from Different types of Institutes in the dataset studied till 2013} \label{tab:2} \resizebox{0.65\textwidth}{!}{ \begin{tabular}{p{2cm}|p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}} \hline\noalign{\smallskip} & NRI & INI & CU & SU & SC & CC & DU & PU & PI & SRI \\ Papers & 9292 & 2635 & 2083 & 3438 & 1482 & 1 & 9 & 85 & 57 & 25 \\ \hline Institutions & 76 & 46 & 32 & 109 & 301 & 1 & 4 & 18 & 19 & 6 \\ \hline Papers per Institute & 122.3 & 57.3 & 65.1 & 31.5 & 4.9 & 1 & 2.25 & 4.7 & 2.68 & 4.17 \\ \hline \end{tabular} } \end{table*} In Fig.\ref{f2}, we show the collaboration network between Institution categories (panel a) and their corresponding weighted adjacency matrix (panel (b). In panel (a), the size of the node represents the total publications. Edge width shows the number of collaborations between authors of the Institutions. Groups are arranged according to the decreasing order of their productivity measured in papers per Institution in the category. We see that the highly productive groups in the top left corner collaborate most among themselves. The NRI, CU, and INI lead in relative contribution. Some premier institutions that fall in this category are Indian Institute of Science (IISc), Saha Institute of Nuclear Physics (SINP), Punjab University, Benaras Hindu University (BHU), Institute of Mathematical Sciences (IMSc), Tata Institute of fundamental Research (TIFR), and different Indian Institute of Technology (IITs). These institutes are mostly autonomous and are most favorable centers for pursuing higher education in India. \begin{figure*} \centering \includegraphics[width= 0.4\linewidth]{group_colab_f} \includegraphics[width = 0.5\linewidth]{m1} \caption{Collaboration between different types of Institutions (a) Network representation. Size of the node is proportional to the total number of papers published from institutes falling in the category as in\ref{tab:1}. Edge width is proportional to the number of co-authorship events.Self edges represent collaboration amongst institute of same kind. (b) Matrix representation of the collaboration of panel (a) , where the type of Institutions are sorted according to their productivity (as defined in the text). } \label{f2} \end{figure*} \textbf{Network structural differences across different Institutions and their types}\\ In Fig. \ref{f3}, we show the cumulative Institute collaboration network from APS publications in India as of 2013. The nodes are colored according to their category as in Fig. \ref{f2} (a) and spatially located based on their pin-codes. \begin{figure*} \centering \includegraphics[width=0.4\linewidth]{I13} \includegraphics[width=0.15\linewidth]{f5_lgnd} \caption{Collaboration between Indian Institutes marked by their pin-codes in 2013. The Nodes are colored based on their type as in Fig. \ref{f2} } \label{f3} \end{figure*} \begin{figure*} \centering \includegraphics[width=0.35\linewidth]{AvgDegree} \includegraphics[width=0.35\linewidth]{Clustering} \includegraphics[width=0.35\linewidth]{Betweenness} \includegraphics[width=0.35\linewidth]{PageRank} \caption{Comparison of centrality measures for Institutes grouped into different categories.} \label{f3a} \end{figure*} \begin{figure*} \centering \includegraphics[width= 0.4\linewidth]{group_cit_2013} \includegraphics[width= 0.5\linewidth]{cit_matrix.pdf} \caption{Institutes clubbed as super nodes representing citations exchanged between different types of institutes.Size of the node is proportional to the total number of papers published from institutes falling in the category. Edge width is proportional to the number of citations exchanged.} \label{f4} \end{figure*} \begin{figure*} \centering \includegraphics[scale=0.35]{cit_hub} \caption{Dominant institutes in the knowledge network constructed from the dataset. Size is proportional to weighted in-degree. All these institute are located in major cities of India acting as knowledge hubs.} \label{f5} \end{figure*} \begin{figure*} \centering \includegraphics[width=0.7\linewidth]{source_sink} \caption{Effective incoming and outgoing citations shared by each node. This represents the knowledge transferring(${\cal F}_i^{out}$ positive y-axis) and receiving(${\cal F}_i^{in}$ negative y-axis) capacity of every node in the network.Each category of institute is color coded} \label{f6} \end{figure*} In Fig. \ref{f3a}, we compare four different measures: average degree, clustering coefficient, betweenness, and page rank for top five productive category of Institutions. These measures help us to assess the strength and dominant role of each category of Institutions within the network. Average degree tells us the average number of connections nodes, betweenness tells the centrality of a node in connecting different parts of the network, and page rank measures importance of node, and the Clustering defines the average connectivity of the neighborhood~\cite{newman2010networks,newman2001clustering}. NRI's have the highest average degree, betweenness and page rank indicating their dominant position in collaboration network. Central Universities have highest average clustering coefficient, highlighting their role bringing different type of Institutions in collaborations. State colleges, though fare low in average degree, betweenness, and page rank, they tend to form highly clustered groups in the network. \textbf{Does knowledge flow across Institutions depend on the category of Institutions?}\\ Citations are an indirect measure of the flow of ideas between authors. At an aggregate level, citations between Institutions is an indicator of the knowledge flow across them ~\cite{mazloumian2013global}. The knowledge flow network based on the citations exchanged between Institutions (see methods for details) between them is shown in Fig. \ref{f4} (a). The corresponding directed and weighted adjacency matrix between type of Institutions is shown in panel (b) of Fig. \ref{f4}. Node size represent the total number of published. NRI category is the largest in the group and also shows the most incitations within group. The matrix shows, that maximum citations flow between high productive Institutions like NRI, CU, INI , SU, and SC. The pattern is similar what we observe in Fig. \ref{f2}. In Fig.\ref{f5}, we show the Giant Connected Component (GCC) for the knowledge network at Institutional level, and highlight the Institutes which receive high in citations. These can be considered as knowledge hubs in the Institutional network and are located in the major cities of India. Of all the nodes in the GCC, NRI's, INI's, CU's and SU's have nodes that act as knowledge centers. The biggest center for knowledge share is Tata Institute of Fundamental Research(NRI) based on the given dataset. To compare the inward and outward flow of knowledge, we compute the effective in flow ${\cal F}_i^{in} $ and outflow ${\cal F}_i^{out} $ (see methods for details) measures for different Institutions in the GCC. The results split according to categories is shown in Fig. \ref{f6}. We find that top knowledge sources also acts as knowledge sinks. \section{Conclusion} To the best of our knowledge, this is the first study to map the collaboration and knowledge flow between institutions in India and their categories. We have compared whether the geographic scaling law (inverse distance) in scientific collaborations at global level are valid at local level or not. We do not find any strong evidence for inverse power law dependence in collaboration strength with respect to distance. We have identified the type of Institutions which dominate the research output in India measured through number of papers, collaborations, and knowledge flow. We find that National Research Institutions (NRI), Central Universities (CU), and Institutes of National Importance (INI) dominate the research output in Physics based on APS dataset. The major cities in India like Delhi, Mumbai, Kolkata, Bangalore, Chennai are largest knowledge hubs for India followed by Kanpur, Allahabad, Ahmedabad and Bhubaneshwar. These cities are also known to host premier educational and research Institutions in the country. State Universities and state colleges collaborate closely with Institutions closer to them. While, National Institutions like NRIs and INIs have broad collaborations in all major cities across India. Highly productive Institutions collaborate more amongst each other and cite each others work more frequently. We identified leading Institutions which act as knowledge sources. Our study was limited to Physics papers published in American Physical Society (APS) journals from 1970-2013 with at least one Indian affiliation. This does not cover the full spectrum of publications in India over different disciplines. Hence broad generalizations on the scientific out put and flow cannot be made. However results from our analysis are in agreement with reports that study India's research output on a larger scale and give a reasonable idea about the existing knowledge network in India. We believe this study could be helpful for framing policies to promote research collaborations between institutes and sharing of resources. In future, we plan to scale this study to include large datasets and cover more indexed publications and implement network modeling to understand the dynamics behind observed evolution. \bibliographystyle{unsrt}
{'timestamp': '2018-10-05T02:09:46', 'yymm': '1810', 'arxiv_id': '1810.02129', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02129'}
arxiv
\section{Experimental details} \label{sec:exp_details} The grid width $\alpha$ of each grid was initialized according to the bit-width $b$ and the maximum and minimum values of the input $x$ to the quantizer\footnote{For activations we computed the minimum and maximum on a random minibatch of inputs.}. Since the inputs $\tilde{x}$ in both cases for our approach are stochastic it makes sense to assume a width for the grid that is slightly larger than the standard width $t = (\max(x) - \min(x)) / 2^b$; for the activations, whenever $b > 4$, we initialize $\alpha = t + 3t/2^b$, for $4 \geq b > 2$ we used $\alpha = t + 3t/2^{b+1} $ and finally for $b = 2$ we used $\alpha = t$. Since with ReLU activations the magnitude can become quite large (thus leading to increased quantization noise for smaller bit widths), this scheme keeps the noise injected to the network in check. For the weights we always used an initial $\alpha = t + 3t/2^b$. The standard deviation of the logistic noise $\sigma$ was initialized to be three times smaller than the width $\alpha$, i.e. $\sigma = \alpha / 3$. Under this specification, most of the probability mass of the logistic distribution is initially (roughly) in the bins containing the closest grid point and its' two neighbors. The moving averages of layer statistics that are aggregated during the training phase for the batch normalization do not necessarily reflect the statistics of the quantized model accurately. Even though RQ aims to minimize the gap between training and testing phase, we found that the aggregated statistics in combination with the learned scale and shift parameters of batch normalization lead to decreased test performance. In order to avoid this drop in accuracy, we apply the insights from \citep{peters2018probabilistic} and recompute the statistics of the quantized model before reporting the final test error rate. The final models were determined through early stopping using the validation loss computed with minibatch statistics, in case the model uses batch normalization. For the MNIST experiment we rescaled the input to the [-1, 1] range, employed no regularization and the network was trained with Adam~\citep{kingma2014adam} and a batch size of 128. We used a local grid whenever the bit width was larger than 2 for both, weights and biases (shared grid parameters), as well as for the ouputs of the ReLU, with $\delta = 3$. For the 8 and 4 bit networks we used a temperature $\lambda$ of 2 whereas for the 2 bit models we used a temperature of 1 for RQ. We trained the 8 and 4 bit networks for 100 epochs using a learning rate of 1e-3 and the 2 bit networks for 200 epochs with a learning rate of 5e-4. In all of the cases the learning rate was annealed to zero during the last 50 epochs. For the CIFAR 10 experiment, the hyperparameters were chosen identically to the LeNet-5 experiments except a few differences. We chose a learning rate ot 1e-4 instead of 1e-3 for 8 and 4 bit networks and trained for 300 epochs with a batch size of 100. We also included a weight decay term of 1e-4 for the 8 bit networks. For the 2 bit model we started with a learning rate of 1e-3. The VGG model contains a batch normalization layer after every convolutional layer, but preceeded by max pooling, if present. \section{Imagenet details} \label{sec:imagenet_details} Each channel of the input images was preprocessed by subtracting the mean and dividing by the standard deviation of that channel across the training set. We then resized the images such that the shorter side is set to 256 and then applied random 224x224 crops and random horizontal flips for data augmentation. For evaluation we consider the center 224x224 crop of the images. We trained the base Resnet-18 model with stochastic gradient descent, a batch size of 128, nesterov momentum of 0.9 and a learning rate of 0.1 which was multiplied by 0.1 at the 30th and 60th epoch. We also applied weight decay with a strength of 1e-4. For the quantized model fine-tuning phase, we used Adam with a learning rate of $5e^{-6}$, a batch size of 24 and a momentum of 0.99. We used a temperature of 2 for both RQ variants. Following the strategy in \citep{jacob2017quantization}, we did not quantize the biases. Table \ref{tab:imagenet_results} contains the error rates for Resnet-18 and Mobilenet on which Figure \ref{fig:discr_process} is based on. Algorithm and architecture specific changes are mentioned explicitly through footnotes. \begin{table}[hbt!] \centering \caption{Top-1 and top-5 error (\%) with Resnet18 and Mobilenet (full resolution and multiplier of one) on Imagenet} \label{tab:imagenet_results} \begin{tabular}{lD{/}{/}{2.2}D{.}{.}{2.2}D{.}{.}{2.2}D{.}{.}{2.2}D{.}{.}{2.2}} \toprule & & \multicolumn{2}{c}{ Resnet18}& \multicolumn{2}{c}{Mobilenet}\\ \midrule Method & \multicolumn{1}{c}{\# Bits weights/act.} & \multicolumn{1}{c}{Top-1} & \multicolumn{1}{c}{Top-5} & \multicolumn{1}{c}{Top-1} & \multicolumn{1}{c}{Top-5} \\ \midrule Original & 32/32 & 30.46 & 10.81 & 29.39 & 10.53\\ \midrule SR+DR & 8/8 & 31.83 & 11.48 & 28.70 & 10.04 \\ \citep{gupta2015deep,gysel2018ristretto} & 6/6 & 40.75 & 16.90 & 33.34 & 12.83 \\ & 5/5 & 45.48 & 20.16 & 40.61 & 17.65 \\ \midrule Rounding & 8/8 & 30.22 & 10.60 & \text{-} & \text{-} \\ & 6/6 & 31.61 & 11.32 & \text{-} & \text{-} \\ & 5/5 & 36.97 & 14.95 & \text{-} & \text{-} \\ & 4/4 & 78.79 & 57.10 & \text{-}& \text{-} \\ \midrule \citep{jacob2017quantization}\footnote{\label{fn:foldedBN}Includes folded batch normalization} & 8/8 & 29.62 & 10.45 & 30.30 & 10.50 \\ & 6/6 & 32.69 & 12.46 &\text{-}&\text{-}\\ & 5/5 & 35.36 & 13.33 &\text{-}&\text{-}\\ \midrule LR Net~\citep{shayer2018learning} & 1/32\footnote{\label{fn:firstlast}First and last layer not quantized} & 40.10 & 17.70 &\text{-}&\text{-}\\ & 2/32\footnote{First layer not quantized}& 36.50 & 15.20 &\text{-}& \text{-}\\ \midrule QSM~\citep{sheng2018quantization}\footref{fn:foldedBN} \footnote{Modified architecture} & 8/8 &\text{-}&\text{-}& 31.97 &\text{-}\\ \midrule TWN~\citep{li2016ternary} & 2/32 & 38.20 & 15.80 &\text{-}& \text{-}\\ INQ~\citep{zhou2017incremental} & 5/32 & 31.02 & 10.90 &\text{-}& \text{-}\\ BWN~\citep{rastegari2016xnor} & 1/32 & 39.20 & 17.00 &\text{-}&\text{-}\\ XNOR-net~\citep{rastegari2016xnor} & 1/1 & 48.80 & 26.80 &\text{-}&\text{-}\\ HWGQ~\citep{cai2017deep}\footref{fn:firstlast} & 1/2 & 40.4 & 17.8 &\text{-}&\text{-}\\ \midrule ELQ~\citep{zhou2018explicit} & 1/32 & 35.28 & 13.96 &\text{-}&\text{-}\\ & 2/32 & 32.48 & 11.95 &\text{-}&\text{-}\\ \midrule SYQ~\citep{faraone2018syq}\footnote{Weights of first and last layer not quantized} & 1/8 & 37.1\hphantom{0} & 15.4\hphantom{0} &\text{-}&\text{-}\\ & 2/8 & 32.3\hphantom{0} & 12.2\hphantom{0} &\text{-}&\text{-}\\ \midrule Apprentice~\citep{mishra2017apprentice}\footref{fn:firstlast} & 2/8 & 32 & - & - & - \\ & 4/8 & 29.6 & - & - & - \\ \midrule RQ (ours) & 8/8 & 30.03 & 10.56 & 29.57 & 10.58 \\ & 6/6 & 31.35 & 11.22 & 31.98 & 12.00 \\ & 5/5 & 34.90 & 13.43 & 38.62 & 16.27 \\ & 4/4 & 38.48 & 16.01 &\text{-}&\text{-}\\ \midrule RQ ST (ours)& 8/8 & 30.37 & 10.67 & 29.94 & 10.48\\ & 6/6 & 31.85 & 11.62 & 32.38 & 12.22 \\ & 5/5 & 36.65 & 14.54 & 43.15 & 19.65\\ & 4/4 & 37.54 & 15.22 &\text{-}& \text{-}\\ \bottomrule \end{tabular} \end{table} \subsection{\cite{jacob2017quantization} for Resnet18} \label{sec:jacobResNet18} We used the code provided at \url{https://github.com/tensorflow/models/tree/master/official/resnet} and modified the construction of the training and evaluation graph by inserting quantization operations provided by the \texttt{tensorflow.contrib.quantize} package. In a first step, the unmodified code was used to train a high-precision Resnet18 model using the hyper-parameter settings for the learning rate scheduling that are provided in the github repository. More specifically, the model was trained for $90$ epochs with a batch size of $128$. The learning rate scheduling involved a "warm up" period in which the learning rate was annealed from zero to $0.64$ over the first $50k$ steps, after which it was divided by $10$ after epochs $30,60$ and $80$ respectively. Gradients were modified using a momentum of $0.9$. Final test performance under this procedure is $29.53\%$ top-1 error and $10.44\%$ top-5 error. From the high-precision model checkpoint, the final quantized model was then fine-tuned for $10$ epochs using a constant learning rate of $1e^{-4}$ and momentum of $0.9$. We did not freeze the moving averages of the batch normalization layers. Finally, we found that re-estimating the batchnorm statistics was harmful for this algorithm. We hypothesise that this is due to the usage of folded batch normalization, which incorporates the statistics into the construction of the grid at training time. \subsection{\cite{jacob2017quantization} for Mobilenet} \label{sec:jacobMobilenet} The $8/8$ bit results for quantizing Mobilenet provided in table \ref{tab:imagenet_results} are read off from Figure 4.1 in \cite{jacob2017quantization}. The pre-trained models published at \url{https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md} originally reflected that number up until commit \texttt{4415c2613b0c74032a7c631769ef9fa7f5477d88}, but have since been updated to improved error rates of $29.9$ and $11.1$ respectively. Unfortunately, there are several conflicting sources for quantized Mobilenet results and pretrained-models within the tensorflow github repository. \url{https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/g3doc/models.md#image-classification-quantized-models}, for example, reports error rates of $30.0$ and $11.0$, whereas at \url{https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/quantize} the reported top-1 error rate is $30.3$. We attempted to use the provided training scripts in the \url{https://github.com/tensorflow/models/blob/master/research/slim} repository to train lower-bit mobilenet variants, but did not succeed in doing so. We experimented with learning rates in the range of $[5e^{-6}, 5e^{-5}, 1e^{-4}]$ for $5/5$, $6/6$ and $8/8$ bit-width variants, but could not achieve significant accuracy improvements within the first $10$ epochs of fine-tuning of the high-precision model published at \url{https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md}. After $10$ epochs, the $8/8$ version achieved $31.39$ top-1 error with a learning rate of $1e^{-4}$ and as such is worse than the published results. We therefore chose to only include the published numbers for the $8/8$ bit model and leave addition hyperparameter tuning to future work. \section{Discussion} \label{sec:conclusion} We have introduced Relaxed Quantization (RQ), a powerful and versatile algorithm for learning low-bit neural networks using a uniform quantization scheme. As such, the models trained by this method can be easily transferred and executed on low-bit fixed point chipsets. We have extensively evaluated RQ on various image classification benchmarks and have shown that it allows for the better trade-offs between accuracy and bit operations per second. Future hardware might enable us to cheaply do non-uniform quantization, for which this method can be easily extended. \citep{lai2017deep,ortiz2018low} for example, show the benefits of low-bit floating point weights that can be efficiently implemented in hardware. The floating point quantization grid can be easily learned with RQ by redefining $\hat{\mathcal{G}}$. General non-uniform quantization, as described for example in~\citep{baskin2018uniq}, is a natural extension to RQ, whose exploration we leave to future work. Currently, the bit-width of every quantizer is determined beforehand, but in future work we will explore learning the required bit precision within this framework. In our experiments, batch normalization was implemented as a sequence of convolution, batch normalization and quantization. On a low-precision chip, however, batch normalization would be ''folded" ~\citep{jacob2017quantization} into the kernel and bias of the convolution, the result of which is then rounded to low precision. In order to accurately reflect this folding at test time, future work on the proposed algorithm will emulate folded batchnorm at training time and learn the corresponding quantization grid of the modified kernel and bias. For fast model evaluation on low-precision hardware, quantization goes hand-in-hand with network pruning. The proposed method is orthogonal to pruning methods such as, for example, $L_0$ regularization~\citep{louizos2017learning}, which allows for group sparsity and pruning of hidden units. \section{Experiments} \label{sec:experiments} For the subsequent experiments RQ will correspond to the proposed procedure that has concrete sampling and RQ ST will correspond to the proposed procedure that uses the Gumbel-softmax straight-through estimator~\citep{jang2016categorical} for the gradient. We did not optimize an offset for the grids in order to be able to represent the number zero exactly, which allows for sparcity and is required for zero-padding. Furthermore we assumed a grid that starts from zero when quantizing the outputs of ReLU. We provide further details on the experimental settings at Appendix~\ref{sec:exp_details}. We will also provide results of our own implementation of stochastic rounding~\citep{gupta2015deep} with the dynamic fixed point format~\citep{gysel2018ristretto} (SR+DR). Here we used the same hyperparameters as for RQ. All experiments were implemented with TensorFlow~\citep{tensorflow2015-whitepaper}, using the Keras library~\citep{chollet2015keras}. \subsection{LeNet-5 on MNIST and VGG7 on CIFAR 10} For the first task we considered the toy LeNet-5 network trained on MNIST with the 32C5 - MP2 - 64C5 - MP2 - 512FC - Softmax architecture and the VGG 2x(128C3) - MP2 - 2x(256C3) - MP2 - 2x(512C3) - MP2 - 1024FC - Softmax architecture on the CIFAR 10 dataset. Details about the hyperparameter settings can be found in Appendix~\ref{sec:exp_details}. By observing the results in Table~\ref{tab:mnist_results}, we see that our method can achieve competitive results that improve upon several recent works on neural network quantization. Considering that we achieve lower test error for 8 bit quantization than the high-precision models, we can see how RQ has a regularizing effect. Generally speaking we found that the gradient variance for low bit-widths (i.e. 2-4 bits) in RQ needs to be kept in check through appropriate learning rates. \begin{table}[hbt!] \centering \caption{Test error (\%) on MNIST and CIFAR 10 using LeNet5-Caffe and VGG-7 respectively. Two and four bit for VGG with SR+DR resulted in a big gap between training and validation accuracy, so we omit those results.} \label{tab:mnist_results} \begin{tabular}{lD{/}{/}{2.2}D{.}{.}{2.2}D{.}{.}{2.2}} \toprule Method & \multicolumn{1}{c}{\# Bits weights/act.} & \multicolumn{1}{c}{MNIST} & \multicolumn{1}{c}{CIFAR 10}\\ \midrule Original & 32/32 & 0.64 & 6.95\\ \midrule SR+DR & 8/8 & 0.58 & 7.06\\ \citep{gupta2015deep,gysel2018ristretto}& 4/4 & 0.66 & \text{-} \\ & 2/2 & 1.03 & \text{-} \\ \midrule Deep Comp.~\citep{han2015deep} & (5\text{-}8)/32 & 0.74 & \text{-}\\ TWN~\citep{li2016ternary} & 2/32 & 0.65\footnote{\label{fn:BN_conv}With batch normalization after convolution}& 7.44\\ BWN~\citep{rastegari2016xnor} & 1/32 & \text{-} & 9.88 \\ XNOR-net~\citep{rastegari2016xnor} & 1/1& \text{-} & 10.17 \\ SWS~\citep{ullrich2017soft} & 3/32 & 0.97 & \text{-}\\ Bayesian Comp.~\citep{louizos2017bayesian} & (7\text{-}18)/32 & 1.00 & \text{-} \\ VNQ~\citep{achterhold2018variational} & 2/32 & 0.73 & \text{-} \\ WAGE~\citep{wu2018training} & 2/8 & 0.40& 6.78\\ \midrule LR Net~\citep{shayer2018learning}\footnote{Last layer in full precision} & 1/32 & 0.53\footref{fn:BN_conv} & 6.82\\ & 2/32 & 0.50\footref{fn:BN_conv} & 6.74\\ \midrule RQ (ours) & 8/8 & 0.55 & 6.70\\ & 4/4 & 0.58 & 8.43\\ & 2/2 & 0.76 & 11.75 \\ \midrule RQ ST (ours) & 8/8 & 0.56 & 6.72 \\ & 4/4 & 0.61 & 7.96 \\ & 2/2 & 0.63 & 9.08 \\ \bottomrule \end{tabular} \end{table} \subsection{Resnet-18 and Mobilenet on Imagenet} In order to demonstrate the effectiveness of our proposed approach on large scale tasks we considered the task of quantizing a Resnet-18~\citep{he2016deep} as well as a Mobilenet~\citep{howard2017mobilenets} trained on the Imagenet (ILSVRC2012) dataset. For the Resnet-18 experiment, we started from a pre-trained full precision model that was trained for 90 epochs. We provide further details about the training procedure in Appendix~\ref{sec:imagenet_details}. The Mobilenet was initialized with the pretrained model available on the tensorflow github repository\footnote{\url{https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md}}. We quantized the weights of all layers, post ReLU activations and average pooling layer for various bit-widths via fine-tuning for ten epochs. Further details can be found in Appendix~\ref{sec:imagenet_details}. Some of the existing quantization works do not quantize the first (and sometimes) last layer. Doing so simplifies the problem but it can, depending on the model and input dimensions, significantly increase the amount of computation required. We therefore make use of the bit operations per second (BOPs) metric~\citep{baskin2018uniq}, which can be seen as a proxy for the execution speed on appropriate hardware. In BOPs, the impact of not quantizing the first layer in, for example, the Resnet-18 model on Imagenet, becomes apparent: keeping the first layer in full precision requires roughly $2.5$ times as many BOPs for one forward pass through the whole network compared to quantizing all weights and activations to $5$ bits. \begin{figure*}[t!] \centering \begin{subfigure}[t]{.5\textwidth} \includegraphics[trim={2cm 1cm 3cm 2cm},width=\linewidth]{figures/resnet18_bop_comp.png} \caption{Resnet-18} \label{fig:res18_bop} \end{subfigure \begin{subfigure}[t]{.5\textwidth} \includegraphics[trim={1cm 1cm 4cm 2cm},width=\linewidth]{figures/mobilenet_bop_comp.png} \caption{Mobilenet} \label{fig:mn_bop} \end{subfigure} \caption{Best viewed in color. Comparison of various methods on Resnet-18 and Mobilenet according to top-1 error (on the y-axis) and bit operations per second (on the x-axis) computed according to the formula described in~\cite{baskin2018uniq}. Each dashed line corresponds to employing a specific bit configuration for every layer's weights and activations. Values for top-1 and top-5 errors are given in Table \ref{tab:imagenet_results} in the Appendix. We compare against multiple works that employ fixed-point quantization: SR+DR~\citep{gupta2015deep,gysel2018ristretto}, LR Net~\citep{shayer2018learning},~\cite{jacob2017quantization}, TWN~\citep{li2016ternary}, INQ~\citep{zhou2017incremental}, BWN~\citep{rastegari2016xnor}, XNOR-net~\citep{rastegari2016xnor}, HWGQ~\citep{cai2017deep}, ELQ~\cite{zhou2018explicit}, SYQ~\citep{faraone2018syq}, Apprentice~\citep{mishra2017apprentice}, QSM~\citep{sheng2018quantization} and rounding.}\label{fig:acc_bop_comp} \end{figure*} Figure~\ref{fig:acc_bop_comp} compares a wide range of methods in terms of accuracy and BOPs. We choose to compare only against methods that employ fixed-point quantization on Resnet-18 and Mobilenet, hence do not compare with non-uniform quantization techniques, such as the one described at~\cite{baskin2018uniq}. In addition to our own implementation of~\citep{gupta2015deep} with the dynamic fixed point format~\citep{gysel2018ristretto}, we also report results of ``rounding''. This corresponds to simply rounding the pre-trained high-precision model followed by re-estimation of the batchnorm statistics. The grid in this case is defined as the initial grid used for fine-tuning with RQ. For batchnorm re-estimation and grid initialization, please confer Appendix~\ref{sec:exp_details}. In Figure \ref{fig:res18_bop} we observe that on ResNet-18 the RQ variants form the ``Pareto frontier'' in the trade-off between accuracy and efficiency, along with SYQ, Apprentice and~\cite{jacob2017quantization}. SYQ, however, employs ``bucketing'' and Apprentice uses distillation, both of which can be combined with RQ and improve performance.~\cite{jacob2017quantization} does better than RQ with 8 bits, however RQ improved w.r.t. to its pretrained model, whereas~\cite{jacob2017quantization} decreased slightly. For experimental details with~\cite{jacob2017quantization}, please confer Appendix~\ref{sec:jacobResNet18}. SR+DR underperforms in this setting and is worse than simple rounding for 5 to 8 bits. For Mobilenet, \ref{fig:mn_bop} shows that RQ is competitive to existing approaches. Simple rounding resulted in almost random chance for all of the bit configurations. SR+DR shows its strength for the $8$ bit scenario, while in the lower bit regime, RQ outperforms competitive approaches. \section{Introduction} Neural networks excel in a variety of large scale problems due to their highly flexible parametric nature. However, deploying big models on resource constrained devices, such as mobile phones, drones or IoT devices is still challenging because they require a large amount of power, memory and computation. Neural network compression is a means to tackle this issue and has therefore become an important research topic. Neural network compression can be, roughly, divided into two not mutually exclusive categories: pruning and quantization. While pruning~\citep{lecun1990optimal,han2015deep} aims to make the model ``smaller'' by altering the architecture, quantization aims to reduce the precision of the arithmetic operations in the network. In this paper we focus on the latter. Most network quantization methods either simulate or enforce discretization of the network during training, e.g. via rounding of the weights and activations. Although seemingly straighforward, the discontinuity of the discretization makes the gradient-based optimization infeasible. The reason is that there is no gradient of the loss with respect to the parameters. A workaround to the discontinuity are the ``pseudo-gradients'' according to the straight-through estimator~\citep{bengio2013estimating}, which have been successfully used for training low-bit width architectures at e.g.~\cite{hubara2016quantized, zhu2016trained}. The purpose of this work is to introduce a novel quantization procedure, Relaxed Quantization (RQ). RQ can bypass the non-differentiability of the quantization operation during training by smoothing it appropriately. The contributions of this paper are four-fold: \textbf{First}, we show how to make the set of quantization targets part of the training process such that we can optimize them with gradient descent. \textbf{Second}, we introduce a way to discretize the network by converting distributions over the weights and activations to categorical distributions over the quantization grid. \textbf{Third}, we show that we can obtain a ``smooth'' quantization procedure by replacing the categorical distributions with concrete~\citep{maddison2016concrete,jang2016categorical} equivalents. \textbf{Finally} we show that stochastic rounding~\citep{gupta2015deep}, one of the most popular quantization techniques, can be seen as a special case of the proposed framework. We present the details of our approach in Section~\ref{sec:method}, discuss related work in Section~\ref{sec:related} and experimentally validate it in Section~\ref{sec:experiments}. Finally we conclude and provide fruitful directions for future research in Section~\ref{sec:conclusion}. \section{Relaxed quantization for discretizing neural networks} \label{sec:method} The central element for the discretization of weights and activations of a neural network is a quantizer $q(\cdot)$. The quantizer receives a (usually) continous signal as input and discretizes it to a countable set of values. This process is inherently lossy and non-invertible: given the output of the quantizer, it is impossible to determine the exact value of the input. One of the simplest quantizers is the rounding function: \begin{align*} q(x) = \alpha \bigg\lfloor \frac{x}{\alpha} + \frac{1}{2}\bigg\rfloor, \end{align*} where $\alpha$ corresponds to the step size of the quantizer. With $\alpha = 1$, the quantizer rounds $x$ to its nearest integer number. Unfortunately, we cannot simply apply the rounding quantizer to discretize the weights and activations of a neural network. Because of the quantizers' lossy and non-invertible nature, important information might be destroyed and lead to a decrease in accuracy. To this end, it is preferable to train the neural network while simulating the effects of quantization during the training procedure. This encourages the weights and activations to be robust to quantization and therefore decreases the performance gap between a full-precision neural network and its discretized version. However, the aforementioned rounding process is non-differentiable. As a result, we cannot directly optimize the discretized network with stochastic gradient descent, the workhorse of neural network optimization. In this work, we posit a ``smooth'' quantizer as a possible way for enabling gradient based optimization. \subsection{Learning (fixed point) quantizers via gradient descent} The proposed quantizer comprises four elements: a vocabulary, its noise model and the resulting discretization procedure, as well as a final relaxation step to enable gradient based optimization. \begin{figure*}[t!] \centering \begin{subfigure}[t]{.45\textwidth} \includegraphics[width=.95\linewidth]{figures/logistic_discr.png} \caption{} \label{fig:logistic_discr} \end{subfigure}\hspace{2em}% \begin{subfigure}[t]{.45\textwidth} \includegraphics[width=.95\linewidth]{figures/cat_discr.png} \caption{} \label{fig:cat_discr} \end{subfigure} \caption{The proposed discretization process. \textbf{(a)} Given a distribution $p(\tilde{x})$ over the real line we partition it into $K$ intervals of width $\alpha$ where the center of each of the intervals is a grid point $g_i$. The shaded area corresponds to the probability of $\tilde{x}$ falling inside the interval containing that specific $g_i$. \textbf{(b)} Categorical distribution over the grid obtained after discretization. The probability of each of the grid points $g_i$ is equal to the probability of $\tilde{x}$ falling inside their respective intervals.}\label{fig:discr_process} \end{figure*} \textbf{The first element} of the quantizer is the vocabulary: it is the set of (countable) output values that the quantizer can produce. In our case, this vocabulary has an inherent structure, as it is a grid of ordered scalars. For fixed point quantization the grid $\mathcal{G}$ is defined as \begin{align} \mathcal{G} = \left[-2^{b-1}, \dots, 0, \dots, 2^{b-1} - 1\right], \end{align} where $b$ is the number of available bits that allow for $K = 2^b$ possible integer values. By construction this grid of values is agnostic to the input signal $x$ and hence suboptimal; to allow for the grid to adapt to $x$ we introduce two free parameters, a scale $\alpha$ and an offset $\beta$. This leads to a learnable grid via $\hat{\mathcal{G}} = \alpha \mathcal{G} + \beta$ that can adapt to the range and location of the input signal. \textbf{The second element} of the quantizer is the assumption about the input noise $\epsilon$; it determines how probable it is for a specific value of the input signal to move to each grid point. Adding noise to $x$ will result in a quantizer that is, on average, a smooth function of its input. In essense, this is an application of variational optimization~\citep{staines2012variational} to the non-differentiable rounding function, which enables us to do gradient based optimization. We model this form of noise as acting additively to the input signal $x$ and being governed by a distribution $p(\epsilon)$. This process induces a distribution $p(\tilde{x})$ where $\tilde{x} = x + \epsilon$. In the next step of the quantization procedure, we discretize $p(\tilde{x})$ according to the quantization grid $\hat{\mathcal{G}}$; this neccesitates the evaluation of the cumulative distribution function (CDF). For this reason, we will assume that the noise is distributed according to a zero mean logistic distribution with a standard deviation $\sigma$, i.e. $L(0, \sigma)$, hence leading to $p(\tilde{x}) = L(x, \sigma)$. The CDF of the logistic distribution is the sigmoid function which is easy to evaluate and backpropagate through. Using Gaussian distributions proved to be less effective in preliminary experiments. Other distributions are conceivable and we will briefly discuss the choice of a uniform distribution in Section \ref{sec:rel_sr}. \textbf{The third element} is, given the aforementioned assumptions, how the quantizer determines an appropriate assignment for each realization of the input signal $x$. Due to the stochastic nature of $\tilde{x}$, a deterministic round-to-nearest operation will result in a stochastic quantizer for $x$. Quantizing $x$ in this manner corresponds to discretizing $p(\tilde{x})$ onto $\hat{\mathcal{G}}$ and then sampling grid points $g_i$ from it. More specifically, we construct a categorical distribution over the grid by adopting intervals of width equal to $\alpha$ centered at each of the grid points. The probability of selecting that particular grid point will now be equal to the probability of $\tilde{x}$ falling inside those intervals: \begin{align} p(\hat{x} = g_i|x,\sigma) & = P(\tilde{x} \leq (g_i + \alpha/2)) - P(\tilde{x} < (g_i - \alpha/2)))\label{eq:grid_prob} \\ & = \text{Sigmoid}((g_i + \alpha/2 - x)/\sigma) - \text{Sigmoid}((g_i - \alpha/2 - x) / \sigma) \label{eq:log_grid_prob}, \end{align} where $\hat{x}$ corresponds to the quantized variable, $P(\cdot)$ corresponds to the CDF and the step from \eqref{eq:grid_prob} to \eqref{eq:log_grid_prob} is due to the logistic noise assumption. A visualization of the aforementioned process can be seen in Figure~\ref{fig:discr_process}. For the first and last grid point we will assume that they reside within $(g_0 - \alpha/2, g_0 + \alpha/2]$ and $(g_K - \alpha/2, g_K + \alpha/2]$ respectively. Under this assumption we will have to truncate $p(\tilde{x})$ such that it only has support within $(g_0 - \alpha/2, g_K + \alpha/2]$. Fortunately this is easy to do, as it corresponds to just a simple modification of the CDF: \begin{align}\label{eq:renorm_cdf} P(\tilde{x} \leq c | \tilde{x} \in (g_0 - \alpha/2, g_K + \alpha/2]) = \frac{P(\tilde{x} \leq c) - P(\tilde{x} < (g_0 - \alpha/2))}{P(\tilde{x} \leq (g_K + \alpha/2)) - P(\tilde{x} < (g_0 - \alpha/2))}. \end{align} Armed with this categorical distribution over the grid, the quantizer proceeds to assign a specific grid value to $\hat{x}$ by drawing a random sample. This procedure emulates quantization noise, which prevents the model from fitting the data. This noise can be reduced in two ways: by clustering the weights and activations around the points of the grid and by reducing the logistic noise $\sigma$. As $\sigma \rightarrow 0$, the CDF converges towards the step function, prohibiting gradient flow. On the other hand, if $\epsilon$ is too high, the optimization procedure is very noisy, prohibiting convergence. For this reason, during optimization we initialize $\sigma$ in a sensible range, such that $L(x, \sigma)$ covers a significant portion of the grid. Please confer Appendix \ref{sec:exp_details} for details. We then let $\sigma$ be freely optimized via gradient descent such that the loss is minimized. Both effects reduce the gap between the function that the neural network computes during training time vs. test time. We illustrate this in Figure~\ref{fig:weight_clustering}. \textbf{The fourth element} of the procedure is the relaxation of the non-differentiable categorical distribution sampling. This is achieved by replacing the categorical distribution with a concrete distribution ~\citep{maddison2016concrete,jang2016categorical}. This relaxation procedure corresponds to adopting a ``smooth'' categorical distribution that can be seen as a ``noisy'' softmax. Let $\pi_i$ be the categorical probability of sampling grid point $i$, i.e. $\pi_i = p(\hat{x} = g_i)$; the ``smoothed'' quantized value $\hat{x}$ can be obtained via: \begin{align u_i \sim \text{Gumbel}(0, 1), \qquad z_i = \frac{\exp((\log \pi_i + u_i) / \lambda)}{\sum_j \exp((\log \pi_j + u_j) / \lambda)},\qquad \hat{x} = \sum_{i=1}^{K}z_i g_i, \label{eq:full_grid_sample} \end{align} where $z_i$ is the random sample from the concrete distribution and $\lambda$ is a temperature parameter that controls the degree of approximation, since as $\lambda \rightarrow 0$ the concrete distribution becomes a categorical. We have thus defined a fully differentiable ``soft'' quantization procedure that allows for stochastic gradients for both the quantizer parameters $\alpha, \beta, \sigma$ as well as the input signal $x$ (e.g. the weights or the activations of a neural network). We refer to this alrogithm as Relaxed Quantization (RQ). We summarize its forward pass as performed during training in Algorithm~\ref{alg:sample_soft}. It is also worthwhile to notice that if there were no noise at the input $x$ then the categorical distribution would have non-zero mass only at a single value, thus prohibiting gradient based optimization for $x$ and $\sigma$. \begin{figure}[t!] \centering \includegraphics[width=1\linewidth]{figures/lenet_means_ddnn_3.png} \caption[]{Best viewed in color. Illustration of the inductive bias obtained via training with the proposed quantizer; means of the logistic distribution over the weights for each layer of the LeNet-5 when trained with 2 bits per weight and activation. Each color corresponds to an assignment to a particular grid point and the vertical dashed lines correspond to the grid points ($\beta=0$). We can clearly see that the real valued weights are naturally encouraged through training to cluster into multiple modes, one for each grid point. It should also be mentioned, that for the right and leftmost grid points the probability of selecting them is maximized by moving the corresponding weight furthest right or left respectively. Interestingly, we observe that the network converged to ternary weights for the input and (almost) binary weights for the output layer.}\label{fig:weight_clustering} \end{figure} One drawback of this approach is that the smoothed quantized values defined in \eqref{eq:full_grid_sample} do not have to coincide with grid points, as $\*z$ is not a one-hot vector. Instead, these values can lie anywhere between the smallest and largest grid point, something which is impossible with e.g. stochastic rounding~\citep{gupta2015deep}. In order to make sure that only grid-points are sampled, we propose an alternative algorithm RQ ST in which we use the variant of the straight-through (ST) estimator proposed in~\cite{jang2016categorical}. Here we sample the actual categorical distribution during the forward pass but assume a sample from the concrete distribution for the backward pass. While this gradient estimator is obviously biased, in practice it works as the ``gradients'' seem to point towards a valid direction. We perform experiments with both variants. After convergence, we can obtain a ``hard'' quantization procedure, i.e. select points from the grid, at test time by either reverting to a categorical distribution (instead of the continuous surrogate) or by rounding to the nearest grid point. In this paper we chose the latter as it is more aligned with the low-resource environments in which quantized models will be deployed. Furthermore, with this goal in mind, we employ two quantization grids with their own learnable scalar $\alpha, \sigma$ (and potentially $\beta$) parameters for each layer; one for the weights and one for the activations. \subsection{Scalable quantization via a local grid} Sampling $\hat{x}$ based on drawing $K$ random numbers for the concrete distribution as described in \eqref{eq:full_grid_sample} can be very expensive for larger values of $K$. Firstly, drawing $K$ random numbers for every individual weight and activation in a neural network drastically increases the number of operations required in the forward pass. Secondly, it also requires keeping many more numbers in memory for gradient computations during the backward pass. Compared to a standard neural network or stochastic rounding approaches, the proposed procedure can thus be infeasible for larger models and datasets. \begin{wrapfigure}[9]{r}{0.34\textwidth} \centering \vspace{-10pt} \includegraphics[width=\textwidth]{figures/local_grid.png} \caption{Local grid construction} \vspace{-5pt} \label{fig:loc_grid} \end{wrapfigure} Fortunately, we can make sampling $\hat{x}$ independent of the grid size by assuming zero probability for grid-points that lie far away from the signal $x$. Specifically, by only considering grid points that are within $\delta$ standard deviations away from $x$, we truncate $p(\tilde{x})$ such that it lies within a ``localized" grid around $x$. To simplify the computation required for determining the local grid elements, we choose the grid point closest to $x$, $\lfloor x\rceil$, as the center of the local grid (Figure~\ref{fig:loc_grid}). Since $\sigma$ is shared between all elements of the weight matrix or activation, the local grid has the same width for every element. The computation of the probabilities over the localized grid is similar to the truncation happening in \eqref{eq:renorm_cdf} and the smoothed quantized value is obtained via a manner similar to \eqref{eq:full_grid_sample}: \begin{align} P(\tilde{x} \leq c | \tilde{x} \in (\lfloor x\rceil - \delta\sigma, \lfloor x\rceil + \delta\sigma]) & = \frac{P(\tilde{x} \leq c) - P(\tilde{x} < \lfloor x\rceil - \delta\sigma)}{P(\tilde{x} \leq \lfloor x\rceil + \delta\sigma) - P(\tilde{x} < \lfloor x\rceil - \delta\sigma)} \\ \quad \hat{x} &= \sum\limits_{g_i \in (\lfloor x\rceil - \delta\sigma, \lfloor x\rceil + \delta\sigma]} z_i g_i \end{align} \begin{figure}[t!] \null\hfill \begin{minipage}[t]{.5\linewidth} \begin{algorithm}[H] \caption{Quantization during training.} \label{alg:sample_soft} \begin{algorithmic} \REQUIRE Input $x$, grid $\hat{\mathcal{G}}$, scale of the grid $\alpha$, \\ scale of noise $\sigma$, temperature $\lambda$, fuzz param. $\epsilon$ \STATE $\*r = [\hat{\mathcal{G}} - \alpha / 2, g_K + \alpha / 2]$ \quad \# interval points \STATE $\*c = \text{Sigmoid}((\*r - x) / \sigma)$ \quad \# evaluate CDF \STATE $\pi_i = \frac{c[i+1] - c[i] + \epsilon}{c[K+1] - c[1] + K\epsilon}$ \quad \# categorical distr. \STATE $\*z \sim \text{Concrete}(\!\pi, \lambda)$ \STATE \textbf{return} $\sum_i z_i g_i$ \end{algorithmic}% \end{algorithm}% \end{minipage}% \hfill \begin{minipage}[t]{.5\linewidth} \begin{algorithm}[H] \caption{Quantization during testing.} \label{alg:sample_hard} \begin{algorithmic} \REQUIRE Input $x$, scale and offset of the grid $\alpha, \beta$, \\ minimum and maximum values $g_0, g_K$ \STATE $y = \alpha \cdot \text{round}((x - \beta) / \alpha) + \beta$ \STATE \textbf{return } $ \min(g_K, \max(g_0, y)$ \end{algorithmic}% \end{algorithm}% \end{minipage} \end{figure} \subsection{Relation to Stochastic Rounding} \label{sec:rel_sr} One of the pioneering works in neural network quantization has been the work of~\cite{gupta2015deep}; it introduced stochastic rounding, a technique that is one of the most popular approaches for training neural networks with reduced numerical precision. Instead of rounding to the nearest representable value, the stochastic rounding procedure selects one of the two closest grid points with probability depending on the distance of the high precision input from these grid points. In fact, we can view stochastic rounding as a special case of RQ where $p(\tilde{x}) = U(x-\frac{\alpha}{2},x+\frac{\alpha}{2})$. This uniform distribution centered at $x$ of width equal to the grid width $\alpha$ generally has support only for the closest grid point. Discretizing this distribution to a categorical over the quantization grid however assigns probabilities to the two closest grid points as in stochastic rounding, following \eqref{eq:grid_prob}: \begin{align} p(\hat{x} = \left\lfloor \frac{x}{\alpha} \right\rfloor \alpha \,|x) & = P(\tilde{x} \leq (\left\lfloor \frac{x}{\alpha} \right\rfloor \alpha + \alpha/2)) - P(\tilde{x} < (\left \lfloor \frac{x}{\alpha} \right\rfloor \alpha - \alpha/2)) =\left\lceil \frac{x}{\alpha} \right\rceil - \frac{x}{\alpha}. \end{align} Stochastic rounding has proven to be a very powerful quantization scheme, even though it relies on biased gradient estimates for the rounding procedure. On the one hand, RQ provides a way to circumvent this estimator at the cost of optimizing a surrogate objective. On the other hand, RQ ST makes use of the unreasonably effective straight-through estimator as used in~\cite{jang2016categorical} to avoid optimizing a surrogate objective, at the cost of biased gradients. Compared to stochastic rounding, RQ ST further allows sampling of not only the two closest grid points, but also has support for more distant ones depending on the estimated input noise $\sigma$. Intuitively, this allows for larger steps in the input space without first having to decrease variance at the traversion between grid sections. \section{Related Work} \label{sec:related} In this work we focus on hardware oriented quantization approaches. As opposed to methods that focus only on weight quantization and network compression for a reduced memory footprint, quantizing all operations within the network aims to additionally provide reduced execution speeds. Within the body of work that considers quantizing weights and activations fall papers using stochastic rounding ~\citep{gupta2015deep,hubara2016quantized,gysel2018ristretto,wu2018training}.~\citep{wu2018training} also consider quantized backpropagation, which is out-of-scope for this work. Furthermore, another line of work considers binarizing \citep{courbariaux2015binaryconnect,zhou2018explicit} or ternarizing \citep{li2016ternary,zhou2018explicit} weights and activations~\citep{hubara2016quantized,rastegari2016xnor,zhou2016dorefa} via the straight-through gradient estimator~\citep{bengio2013estimating}; these allow for fast implementations of convolutions using only bit-shift operations. In a similar vein, the straight through estimator has also been used in~\cite{cai2017deep,faraone2018syq,jacob2017quantization,zhou2017incremental,mishra2017apprentice} for quantizing neural networks to arbitrary bit-precision. In these approaches, the full precision weights that are updated during training correspond to the means of the logistic distributions that are used in RQ. Furthermore,~\cite{jacob2017quantization} maintains moving averages for the minimum and maximum observed values for activations while parameterises the network's weights' grids via their minimum and maximum values directly. This fixed-point grid is therefore learned during training, however without gradient descent; unlike the proposed RQ. Alternatively, instead of discretizing real valued weights,~\cite{shayer2018learning} directly optimize discrete distributions over them. While providing promising results, this approach does not generalize straightforwardly to activation quantization. Another line of work quantizes networks through regularization. ~\citep{louizos2017bayesian} formulate a variational approach that allows for heuristically determining the required bit-width precision for each weight of the model. Improving upon this work, \citep{achterhold2018variational} proposed a quantizing prior that encourages ternary weights during training. Similarly to RQ, this method also allows for optimizing the scale of the ternary grid. In contrast to RQ, this is only done implicitly via the regularization term. One drawback of these approaches is that the strength of the regularization decays with the amount of training data, thus potentially reducing their effectiveness on large datasets. Weights in a neural network are usually not distributed uniformly within a layer. As a result, performing non-uniform quantization is usually more effective. \citep{baskin2018uniq} employ a stochastic quantizer by first uniformizing the weight or activation distribution through a non-linear transformation and then injecting uniform noise into this transformed space. \citep{polino2018model} propose a version of their method in which the quantizer's code book is learned by gradient descent, resulting in a non-uniformly spaced grid. Another line of works quantizes by clustering and therefore falls into this category; ~\citep{han2015deep,ullrich2017soft} represent each of the weights by the centroid of its closest cluster. While such non-uniform techniques can be indeed effective, they do not allow for efficient implementations on todays hardware. Within the liteterature on quantizing neural networks there are many approaches that are orthogonal to our work and could potentially be combined for additional improvements.~\citep{mishra2017apprentice,polino2018model} use knowledge distrillation techniques to good effect, whereas works such as~\citep{mishra2017wrpn} modify the architecture to compensate for lower precision computations.~\citep{zhou2017incremental,zhou2018explicit,baskin2018uniq} perform quantization in an step-by-step manner going from input layer to output, thus allowing the later layers to more easily adapt to the rounding errors introduced.~\cite{polino2018model,faraone2018syq} further employ ``bucketing", where small groups of weights share a grid, instead of one grid per layer. As an example from~\cite{polino2018model}, a bucket size of $256$ weights per grid on Resnet-18 translates to $\sim 45.7k$ separate weight quantization grids as opposed to $22$ in RQ. \subsubsection*{Acknowledgments} We would like to thank Peter O'Connor and Rianne van den Berg for feedback on a draft of this paper.
{'timestamp': '2018-10-05T02:00:18', 'yymm': '1810', 'arxiv_id': '1810.01875', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01875'}
arxiv
\section{\label{sec:intro}Introduction} Biochemical reaction networks play a central role in cellular response to external stimuli (such as cell-cell signaling), converting inter-cellular signals into a driven chemical response~\cite{signalling}. A prominent communication channel for chemical signals across the cell membrane are G-protein coupled receptors (GPCRs). Diffusible agonist ligands bind to the extracellular face of a GPCR and allosterically induce a conformational change on its intracellular face. This conformational change alters the binding affinity between diffusible G-proteins and the receptor, eliciting a series of reactions ultimately leading to the cellular response~\cite{nobel2012}. In mammals, GPCRs mediate many physiological responses---to changes in concentrations of peptides, hormones, lipids, neurotransmitters, ions, odorants, tastants, and light. Since $\sim$1000 human genes code for GPCRs~\cite{nobel1,nobel2}, we predict that an energetically efficient signaling process through a GPCR would provide a selective advantage, such that evolved signaling pathways could be expected to exhibit impressive efficiency. The GPCR signaling process can be modeled as changes in the chemical potential of the G-protein at the cell membrane. For given desired equilibrium endpoints of chemical potential, any protocol (schedule of changing chemical potential) that proceeds quasi-statically (at negligible speed) requires the same input energy in the form of chemical potential work, an amount equal to the free energy change between the equilibrium ensembles at the two endpoint chemical potentials. For protocols that proceed at a finite velocity, different protocols differ in their energetic costs, and hence in the required number of signaling molecules the signaling cell must secrete. Here we develop theory describing how a cell can achieve a given dynamic signaling outcome at minimal energetic cost. This maps neatly onto a problem in nonequilibrium statistical mechanics, that of finding a protocol that minimizes the excess work associated with finite-time changes in a control parameter~\cite{molecularmachines}. Starting from a theoretical framework developed in \cite{OptimalPaths} to approximate the thermodynamic cost (excess work) of rapid changes in an arbitrary control parameter, we extend the formalism to address changes in chemical potential, and derive protocols that minimize the required work. We find that near equilibrium, the excess work is determined by the auto-covariance of the protein copy number. For the special case of linear-order chemical reactions, we derive analytic forms of the generalized friction tensor, and the required work for both designed and naive (constant-velocity) protocols. We illustrate these results in simple chemical reaction schemes: an open system exchanging molecules with a molecular reservoir, and a closed system with fixed total copy number. \section{\label{sec:theoryReview}Theoretical review} We first present a review of minimum-dissipation nonequilibrium control in the linear-response framework. Applying linear-response theory~\cite{OptimalPaths} gives a near-equilibrium expression for the average excess power (excess above the average power if the system were equilibrated throughout the driving protocol) exerted by an external agent changing control parameters $\lambda$ that are coupled to the system in the canonical ensemble, \begin{align} \label{Excess Power} \mathrm d_t W_{\rm ex}(t) \approx \mathrm d_t \lambda_{j} \ \zeta_{j \ell}[\lambda(t)] \ \mathrm d_t \lambda_{\ell} \ , \end{align} in terms of the generalized friction tensor \begin{align} \label{Zeta} \zeta_{j \ell}(\lambda) \equiv \beta \int_{0}^{\infty} \mathrm d t \, \langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda} \ . \end{align} Here $\mathrm d_t \lambda_j$ denotes the time derivative, $\beta \equiv k_{\rm B}T^{-1}$ is inverse temperature, $f_{j} \equiv -\partial_{\lambda_{j}} U$ is the force conjugate to the $j$th control parameter, and $\langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda}$ is the force covariance defined in terms of equilibrium fluctuations $\delta f_{j}(t) \equiv f_{j}(t) - \langle f_{j}\rangle_{\lambda}$. $\langle \cdots \rangle_{\lambda}$ indicate an equilibrium average for fixed $\lambda$. Throughout, we adopt the Einstein summation convention of implied summation over repeated indices. The generalized friction tensor $\zeta_{j \ell}$ is the Hadamard product $\beta \langle\delta f_{j} \delta f_{\ell}\rangle_{\lambda} \circ \tau_{j \ell}$ of the conjugate force covariance (the force fluctuations) and the integral relaxation time \begin{align} \label{relax1} \tau_{j \ell} \equiv \int_{0}^{\infty} \mathrm d t \frac{\langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda}}{\langle \delta f_{j} \delta f_{\ell}\rangle_{\lambda}} \ , \end{align} the characteristic time it takes for these fluctuations to die out. The generalized friction tensor reflects the increased energy cost associated with rapid driving through control parameter space. Integrating the excess power~\eqref{Excess Power} over the control parameter protocol gives the mean excess work, \begin{align} \label{excess work} W_{\rm ex} = \int_{0}^{\Delta t} \mathrm d t \ \mathrm d_t W_{\rm ex}(t) \ , \end{align} above and beyond the quasi-static work. Under the linear-response approximation, the excess work is minimized for a `designed' protocol with constant excess power~\cite{OptimalPaths}. For a single control parameter, this amounts to proceeding with a velocity $\mathrm d_t \lambda^{\rm des} \propto \zeta(\lambda)^{-1/2}$, which when normalized to complete the protocol in a fixed allotted time $\Delta t$, gives \begin{align} \label{lambdaoptdot2} \mathrm d_t \lambda^{\rm des} = \frac{\int_{\lambda_{\rm i}}^{\lambda_{\rm f}}\mathrm d\lambda' \sqrt{\zeta(\lambda')}}{\sqrt{\zeta(\lambda)} \Delta t} \ , \end{align} for initial and final chemical potentials $\lambda_{\rm i}$ and $\lambda_{\rm f}$, respectively. Thus for a fixed protocol time, work is minimized by driving the system (changing the control parameter) slowly in regions of high friction, and quickly in areas of low friction. The ratio of excess works during the naive and designed protocols is~\cite{Workratio} \begin{align} \label{Ratio} \frac{W_{\rm ex}^{\rm naive}}{W_{\rm ex}^{\rm des}} = \frac{\Delta \lambda \int_{\lambda_{\rm i}}^{\lambda_{\rm f}} \zeta(\lambda) \, \mathrm d\lambda}{\left[\int_{\lambda_{\rm i}}^{\lambda_{\rm f}} \sqrt{\zeta(\lambda)} \, \mathrm d\lambda\right]^2} \ . \end{align} \section{Driving chemical potential} A system of $n$ different chemical species at thermal and chemical equilibrium with a single heat reservoir and multiple particle reservoirs at temperature $T$ and chemical potentials $\mu_{j}$, respectively, is described by the grand canonical ensemble (GCE) with free energy (\emph{grand potential}) \begin{align} \label{Free energy} \Phi_{\rm G} \equiv U - TS - \mu_{j} N_{j} \ , \end{align} for system energy $U$, entropy $S$, and copy number $N_{j}$ of the $j$th chemical species. In this study, the control parameters $\lambda_i$ are chemical potentials $\mu_i$, and hence the conjugate forces are the copy numbers, $f_{j} = -\partial_{\mu_{j}} \Phi_{\rm G} = N_{j}$. This produces a friction tensor and excess work \begin{subequations} \begin{align} \label{Zeta cov} \zeta_{j \ell}(\mu) &= \beta \int_{0}^{\infty} \mathrm d t \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle_{\mu} \\ \label{Free energy friction} &= \beta \langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}\circ \tau_{j \ell}(\mu) \\ \label{Free Energy Work} W_{\rm ex} &= \beta \int_{0}^{\Delta t} \mathrm d t \, \mathrm d_t \mu_{j} \langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}\circ \tau_{j \ell}(\mu) \mathrm d_t \mu_{\ell} \ . \end{align} \end{subequations} The total work during a chemical-potential protocol is the equilibrium free energy change, plus an additional contribution from the excess work. This extra cost is proportional to the relaxation time $\tau$ and equilibrium copy-number covariance $\langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}$, so reaction systems subject to large and long-persisting fluctuations in protein copy number require greater energy input to rapidly change their chemical potential. \section{\label{Linear Markov chemical reaction networks}Linear Markov chemical reaction networks} The dependence of the friction tensor $\zeta$ on control parameter $\mu$, and thus the solution for the designed protocol, is a function of the topology and kinetics of the chemical reaction network. For linear-order chemical reactions, the autocovariance---and therefore the friction tensor---can be solved exactly~\cite{Closedfirstorder,Firstorderreactions}, and for higher-order reactions it can be approximated using moment-closure techniques~\cite{Momentclosure}. Here we model the stochastic behavior of chemical reaction systems assuming Markovian dynamics, where the future dynamics depends exclusively on the present state. A linear-order chemical reaction system with multiple chemical species (and fixed chemical potential) satisfies~\cite{Closedfirstorder} \begin{align} \label{mean evolution} \mathrm d_t \overline{N_{j}(t)} = -K_{j \ell} \overline{N_{\ell}(t)} + k^{\rm s}_{j} \ , \end{align} where $K \equiv K^{\rm d} - K^{\rm con}$, $K^{\rm d}$ is the diagonal matrix of degradation rates, $K^{\rm con}$ is the matrix of conversion reaction rates, $k^{\rm s}$ are the production rates from a constant source, and an overbar indicates a (in general out-of-equilibrium) ensemble average. For notational simplicity, in this section we suppress explicit dependence on $\mu$. Equation~\eqref{mean evolution} has the general solution \begin{align} \label{Mean time evolution} \overline{N_{j}(t)} = &\left[e^{-K t}\right]_{j \ell} N_{\ell}(0) \\ &+\left(1-\left[e^{-K t}\right]_{j \ell}\right) \int_{0}^{t}\mathrm d t'\left[e^{-K t'}\right]_{j \ell}k^{\rm s}_{\ell} \ . \nonumber \end{align} Assuming $K$ is diagonalizable, then $e^{-K t} = V e^{-D}V^{-1}$, where $D$ is the diagonal eigenvalue matrix, and $V$ is the eigenvector matrix, whose rows are the corresponding eigenvectors of $K$. If $K$ is not diagonalizable, then other standard methods of computing the matrix exponential can be employed~\cite{matrixexponential,newmatrixexponential}. For a linear Markov reaction network, the auto-covariance obeys a similar time evolution equation as the mean~\cite{Gardiner}: \begin{align} \label{cov evolution} \mathrm d_t \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle = -K_{jm}\langle \delta N_{m}(t) \delta N_{\ell}(0)\rangle \ . \end{align} Assuming the system is initially at equilibrium, this has the solution \begin{align} \label{autocovariance} \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle &= \left[e^{-K t}\right]_{jm}\langle \delta N_{m}\delta N_{\ell}\rangle \\ &= V_{j m} \left[e^{-D t}\right]_{mn}V^{-1}_{np}\langle \delta N_{p}\delta N_{\ell}\rangle \ . \end{align} This produces a friction tensor \begin{align} \label{zeta} \zeta_{j \ell} &= \beta \int_{0}^{\infty}\mathrm d t \, V_{jm} \left[e^{-D t}\right]_{mn}V^{-1}_{np} \langle \delta N_{p}\delta N_{\ell}\rangle \\ \label{zeta2} &= \beta V_{jm} [D^{-1}]_{mn} V^{-1}_{np} \langle \delta N_{p}\delta N_{\ell}\rangle \ . \end{align} Strictly speaking, for the case of a zero eigenvalue, $D_{jj} = 0$ for some $j$, so $D^{-1}$ does not exist; however, simply computing $V_{jm} \left[e^{-D t}\right]_{mn}V^{-1}_{np}$ before integrating avoids this problem. A \emph{conversion network} allows only conversion, degradation, and source reactions~\cite{Firstorderreactions}. It is \emph{open} when it has at least one degradation or source reaction. The equilibrium distribution (reached in the $t\to \infty$ limit of \eqref{Mean time evolution}) of any species in an open linear conversion network is a Poisson distribution, with mean and covariance~\cite{Firstorderreactions} \begin{align} \label{Open Variance} \langle \delta N_{j}\delta N_{\ell} \rangle^{\rm o}& = \langle N_{j} \rangle^{\rm o}\delta_{j\ell} = V_{jm}[D^{-1}]_{mn}V^{-1}_{np}k^{\rm s}_{p}\delta_{j\ell} \ , \end{align} where $\delta_{j\ell}$ is the Kronecker delta, equal to $1$ if $j = \ell$, and $0$ otherwise. The friction tensor for an open system can therefore be fully determined from the equilibrium mean and reaction rates as \begin{align} \label{Zeta open} \zeta_{j\ell}^{\rm o} = \beta V_{jm}[D^{-1}]_{mn}V^{-1}_{n\ell}\langle N _{\ell}\rangle^{\rm o} \delta_{jl} \ . \end{align} The relaxation time is $\tau_{j\ell}^{\rm o} = V_{jm} [D^{-1}]_{mn} V^{-1}_{n\ell}\delta_{jl}$, which is proportional to the mean copy number~\eqref{Open Variance}. Hence an increase in mean copy number has the compound effect of increasing both the size and lifetime of fluctuations. Therefore, the designed chemical-potential protocol drives slowly in areas of large mean copy number and quickly in areas of low mean copy number. For a linear \emph{closed} conversion network (no sources or degradation), the equilibrium distribution is not Poisson~\cite{Firstorderreactions}, but the mean, variance, and covariance can still be solved analytically using standard linear algebra techniques~\cite{Closedfirstorder,Firstorderreactions}. The equilibrium covariance is \begin{align} \label{closed covariance} \langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = \langle N_{j}\rangle^{\rm c}\left(\delta_{j \ell}-\frac{\langle N_{\ell}\rangle^{\rm c}}{N_{\rm tot}}\right) \ , \end{align} where $N_{\rm tot} = \sum_{j}N_{j}$ is the total number of chemical molecules. For chemical reaction systems with a \emph{strongly connected} reaction graph (\emph{i.e.}, any species can be reached from any other via a set of allowed reactions), $K$ has exactly one zero eigenvalue, and the equilibrium probability distribution across all species is multinomial~\cite{Firstorderreactions}, $\pi_{j} = v^{0}_{j}/\sum_{\ell}v^{0}_{\ell}$, where $v^{0}_{j}$ is the $j$th component of the eigenvector with zero eigenvalue. The multinomial mean copy number of species $j$ is simply $\langle N_{j} \rangle = N_{\rm tot}\pi_{j}$, producing covariance \begin{align} \label{closed correlation} \langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = N_{\rm tot}\pi_{j}(\delta_{j \ell} - \pi_{\ell}) \ . \end{align} Substituting the covariance~\eqref{closed covariance} into the friction~\eqref{zeta} gives \begin{align} \label{Closed Zeta2} \zeta_{j \ell}^{\rm c} = \beta V_{jm}[D^{-1}]_{mn}V^{-1}_{np} \langle N_{p}\rangle^{\rm c}\left(\delta_{p \ell}-\frac{\langle N_{\ell}\rangle^{\rm c}}{N_{\rm tot}}\right) \ . \end{align} Unlike for the open system, the closed covariance~\eqref{closed covariance} does not monotonically increase with mean copy number, but rather is largest when the two species have equal mean copy numbers and is smallest when one species dominates. If $j = \ell$, then the covariance reduces to the variance, which is maximized at $\langle N_{j}\rangle^{\rm c} = N_{\rm tot}/2$ and minimized at $\langle N_{j}\rangle^{\rm c} = N_{\rm tot}$ or $\langle N_{j} \rangle^{\rm c} = 0$. When $j\neq \ell$, $\langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = -\langle N_{j}\rangle^{\rm c}\langle N_{\ell}\rangle^{\rm c}/N_{\rm tot}$, which is always negative and reaches its maximum magnitude when $\langle N_{j}\rangle^{\rm c} = \langle N_{\ell} \rangle^{\rm c} = N_{\rm tot}/2$. For small mean copy number relative to the total, $\langle N_{\ell}\rangle^{\rm c} \ll N_{\rm tot}$, the friction of a closed system~\eqref{Closed Zeta2} reduces to that of an open system~\eqref{Zeta open}, since the second term in parentheses in \eqref{Closed Zeta2} becomes negligible. The large total number of molecules acts as a constant source, or chemical bath, making the closed and open systems equivalent. In order to interpret the form of the closed-system relaxation time $\tau_{j\ell}^{\rm c} = V_{jm} [D^{-1}]_{mn} V^{-1}_{n\ell}$, we recognize that the eigenvalues of $K$ in a closed system have non-negative real components~\cite{Firstorderreactions}. Furthermore, if the system satisfies detailed balance, then the eigenvalues of $K$ are real~\cite{realeigenvalues,realeigenvaluestwo}. Thus $\tau_{j \ell}$ is non-negative. As we have seen, all off-diagonal components of the covariance are negative and all diagonal components are positive, therefore the same is true of the friction tensor, the product of covariance and relaxation time. Although the friction tensor can have negative specific entries, it is positive semidefinite since it is an auto-covariance matrix~\cite{OptimalPaths}. The friction tensors \eqref{zeta}, \eqref{Zeta open}, and \eqref{Closed Zeta2} imply analytic solutions for the designed protocol of any linear Markov chemical reaction. In the following sections we examine specific reaction networks to gain further insight into designed protocols. \section{\label{Closed system}Closed system} As a simple tractable model, we examine a two-state chemical reaction with respective binding and unbinding rates $k_1$ and $k_{-1}$ (Fig.~\ref{Reaction}), nominally meant to represent G-proteins binding to the GPCR at the cell membrane. \begin{figure} \begin{center} \includegraphics[scale = 0.25]{Diagram.png} \caption{Two-state chemical reaction network representing bound and unbound G-proteins. Proteins bind at rate $k_{1}=k$ and unbind at rate $k_{-1}=ke^{-\mu}$.} \label{Reaction} \end{center} \end{figure} The chemical potential is the externally controlled signal, for example as modulated by the number of expressed agonist molecules, or experimentally controlled light power for a light-gated GPCR. It is natural to model the membrane binding rate $k_1=k$ as depending on the dynamic encounter rate and not on the strength of the chemical potential, and the membrane unbinding rate $k_{-1}$ as depending on how tightly the protein is bound, and hence on the chemical potential difference $\mu$ between unbound and bound states, as \begin{equation} \label{rate chemical dependence} k_{-1} = ke^{-\mu} \ . \end{equation} $\mu = 0$ produces equal binding and unbinding rates, $k_{1} = k_{-1}$. (This specific dependence of rates on chemical potential is consistent with~\cite{brownsivak2017,brownsivak2018} for a splitting factor~\cite{split1,split2} of $0$, although our framework could be applied to any splitting factor.) For simplicity, here and in subsequent sections, energies are written in units of $k_{\rm B}T$ (equivalent to setting $\beta = 1$). We additionally assume a fixed total number of molecules $N_{\rm tot} = N_{\rm UB}+N_{\rm B}$, with variable numbers of unbound ($N_{\rm UB}$) and bound ($N_{\rm B}$) molecules. The reaction-rate matrix is \begin{align} K = \left[ {\begin{array}{cc} ke^{- \mu}&-k \\ -ke^{- \mu}&k \\ \end{array} } \right] \ . \end{align} In \S\ref{Linear Markov chemical reaction networks}, we derived simple expressions for the auto-covariance~\eqref{autocovariance}, equilibrium covariance~\eqref{closed correlation}, and friction~\eqref{Closed Zeta2}. With one chemical potential, there is only the $j=\ell=1$ component, giving equilibrium variance \begin{align} \label{closedvar} \langle (\delta N_{\rm B})^{2}\rangle^{\rm c}_{\mu} = N_{\rm tot} \frac{e^{-\mu}}{(1+e^{-\mu})^2} \ , \end{align} relaxation time \begin{align} \label{closedtau} \tau(\mu) = \frac{1}{k(1+e^{-\mu})} \ , \end{align} and friction \begin{align} \label{closed friction} \zeta(\mu) &= N_{\rm tot} \frac{e^{-\mu}}{k(1+e^{-\mu})^3} \ . \end{align} The variance is maximized at $\mu = 0$. For $e^{\mu} \gg 1$, the variance decays exponentially with $\mu$ as $\langle (\delta N_{\rm B})^{2}\rangle^{\rm c}_{\mu} \approx N_{\rm tot} e^{-\mu}$. Figure~\ref{friction Plot} plots the dependence of friction coefficient on $\mu$, for several binding rates $k$. Physically, as $\mu$ increases, molecules are held more tightly to the membrane (unbinding rate decreases), and thus copy-number fluctuations relax more slowly. The relaxation time is sigmoidal in $\mu$, with $\tau(\mu \to -\infty) \to 0$ and $\tau(\mu \to \infty) \to 1/k$. The first limit corresponds to molecules bound very loosely to the membrane, such that the unbinding rate is much larger than the binding rate, with fluctuations decaying rapidly. The latter limit corresponds to tightly bound molecules such that the binding rate is much larger than unbinding, causing fluctuations to decay slowly and most molecules to be bound: the relaxation time is maximized when all molecules are bound. Ultimately, this asymmetry in relaxation time is caused by the asymmetric dependence of the forward and reverse reaction rates on chemical potential: $k_{1}$ is independent of $\mu$ and $k_{-1}\propto e^{-\mu}$. The friction is minimized (and vanishes) when either all molecules are bound or all are unbound. The friction peaks at $\mu = \ln2$, when $2/3$ of all molecules are bound, $\langle N_{\rm B} \rangle^{\rm c} = \tfrac{2}{3}N_{\rm tot}$). Physically, the resistance increases when driving away from either all-bound or all-unbound: as the mean copy number of the less common species increases, the resistance to changes in chemical potential increases. This can be rationalized because the variance is maximized at $\mu=0$, when each state (bound and unbound) contains on average half the total number of molecules, whereas the relaxation time is maximized when all the molecules are bound, thus shifting the maximal friction to occur past an even split in each state. At chemical potentials well below this maximum (for $e^{\mu} \ll 1$), the friction increases as $e^{2\mu}$, whereas for large chemical potentials ($e^{\mu} \gg 1$), the friction decays exponentially with chemical potential, $\zeta \to e^{-\mu}$. Figure~\ref{friction Plot} shows these differing slopes. The designed protocol drives slowly in control parameter regimes of high friction which, due to the exponential dependence of friction on chemical potential~\eqref{closed friction}, produces large variations in chemical potential velocity and potentially large energetic saving. This behaviour is illustrated in Fig.~\ref{friction Plot}. \begin{figure} \includegraphics[width=\columnwidth]{friction} \caption{Generalized friction coefficient $\zeta$ (in units of seconds, since $k_{\rm B}T$ is set to unity) as a function of chemical potential $\mu$, for various binding rates $k$ (different colors). The horizontal axis is shifted by $\ln 2$ so that the friction of the closed system is maximized at $0$. For simplicity, the total protein copy number $N_{\rm tot}$ is normalized to $1$.} \label{friction Plot} \end{figure} With a single control parameter, the designed protocol is easily solved using \eqref{lambdaoptdot2}: \begin{align} \label{closed lambdaoptdot3} \mathrm d_t \mu^{\rm des}|_{\mu} = &\frac{ 2\sqrt{1+e^{\mu}}(1+e^{-\mu})}{\Delta t} \left(\frac{1}{\sqrt{1+e^{\mu_{\rm i}}}}-\frac{1}{\sqrt{1+e^{\mu_{\rm f}}}}\right) \ . \end{align} The velocity of the designed protocol reaches a minimum when the friction is at a maximum, $\mu = \ln 2$. Appendix~\ref{Designed copy number} derives the equivalent designed mean-copy-number protocol, which increases as $\mathrm d_t \langle N_{\rm B}\rangle^{\rm c~des} \propto \sqrt{\langle N_{\rm UB}\rangle^{\rm c}}$. Appendix~\ref{initial and final velocity} compares the initial and final designed protocol velocities, and demonstrates that for small changes in chemical potential, the designed protocol reduces to the naive. The designed protocol produces an excess work \begin{align} \label{closeddesignedwork} W_{\rm ex}^{\rm c~des} = &\frac{4N_{\rm tot} }{k \Delta t} \left( \frac{1}{\sqrt{1+e^{\mu_{\rm i}}}} - \frac{1}{\sqrt{1+e^{\mu_{\rm f}}}}\right)^{2} \ . \end{align} For significant changes in chemical potential, either increases ($e^{\mu_{\rm f}} \gg e^{\mu_{\rm i}}$ and $e^{\mu_{\rm f}} \gg 1$) or decreases ($e^{\mu_{\rm f}} \ll e^{\mu_{\rm i}}$ and $e^{\mu_{\rm f}} \ll 1)$, the designed excess work becomes independent of $\mu_{\rm f}$. The naive protocol changes chemical potential at constant velocity $\mathrm d_t \mu^{\rm naive} = \Delta\mu/\Delta t$ and produces excess work~\eqref{excess work} \begin{align} \label{closednaivework} W_{\rm ex}^{\rm c~naive} = N_{\rm tot} \frac{\Delta\mu}{\Delta t} \frac{1}{2k}\left[\frac{1+2e^{\mu_{\rm i}}}{(1+e^{\mu_{\rm i}})^{2}}-\frac{1+2e^{\mu_{\rm f}}}{(1+e^{\mu_{\rm f}})^{2}}\right] \ . \end{align} For significant changes in chemical potential, the naive excess work \eqref{closednaivework} scales linearly with $\Delta\mu \equiv \mu_{\rm f}-\mu_{\rm i}$. This is in contrast to the excess work from the designed protocol \eqref{closeddesignedwork}, which becomes independent of $\mu_{\rm f}$ in this limit. We quantify the thermodynamic benefit of designed driving by the ratio of the excess works incurred during the naive and designed protocols~\eqref{Ratio}: \begin{align} \label{closedratio} \frac{W_{\rm ex}^{\rm c~naive}}{W_{\rm ex}^{\rm c~des}} &= \Delta\mu \frac{\frac{(1+2e^{\mu_{\rm i}})(1+e^{\mu_{\rm f}})}{1+e^{\mu_{\rm i}}}-\frac{(1+2e^{\mu_{\rm f}})(1+e^{\mu_{\rm i}})}{1+e^{\mu_{\rm f}}}}{8\left(\sqrt{1+e^{\mu_{\rm i}}}-\sqrt{1+e^{\mu_{\rm f}}}\right)^{2}} \ . \end{align} The ratio does not depend on the raw binding/unbinding rate $k$. For significant chemical potential changes, the excess-work ratio scales linearly with $\Delta\mu$. Appendix~\ref{small chemical potential} shows that for small changes $\Delta\mu$ in chemical potential, both the naive excess work and the excess-work ratio increase quadratically in $\Delta\mu$. The only parameters in \eqref{closedratio} are the initial and final chemical potentials $\mu_{\rm i}$ and $\mu_{\rm f}$. Figure~\ref{Ratio Plot} demonstrates that the excess work ratio is non-monotonic in $\mu_{\rm f}$, empirically peaking near the local maximum in the friction; however, after decreasing for a short distance, the ratio begins to increase linearly. This transition can occur for either positive or negative chemical potential distances, depending on which side of the maximum friction the protocol starts. Such a feature is not found for a protocol initially at the peak friction. The asymmetry in excess work ratio on different sides of the maximal friction is caused by the friction scaling as $e^{2\mu}$ for chemical potentials below the peak and as $e^{-\mu}$ for chemical potentials above the peak (Fig.~\ref{friction Plot}), itself a result of the asymmetric chemical potential dependence of the forward and reverse reaction rates. Outside of this region, more significant chemical potential changes still produce greater benefits from the designed protocol (quadratic for small $\Delta\mu$ and linear for large $\Delta\mu$). \begin{figure} \includegraphics[width=\columnwidth]{ratio} \caption{The ratio of naive to designed excess works as a function of the final chemical potential $\mu_{\rm f} - \ln 2$, for varying shifted initial chemical potential $\mu_{\rm i} - \ln 2$ (different colors). Horizontal axis is shifted to $\mu_{\rm f} - \ln 2$, so that the protocol crosses the maximal friction at $0$.} \label{Ratio Plot} \end{figure} \section{\label{two state open}Open system} When the unbinding rate is much larger than the binding rate (for $e^{\mu} \ll 1$), and hence $\langle N_{\rm UB}\rangle^{\rm c} \gg \langle N_{\rm B}\rangle^{\rm c}$, $N_{\rm UB}$ is effectively constant over copy-number fluctuations, and thus the system is effectively open, with $K = -K^{\rm d} = -k_{-1}$ and $k^{\rm s} = N_{\rm bath} k$. This limit produces particularly simple forms for the variance~\eqref{closedvar} \begin{align} \label{openvar} \langle \left(\delta N_{B}\right)^{2}\rangle_{\mu}^{\rm o} = N_{\rm bath} e^{\mu} \ , \end{align} relaxation time~\eqref{closedtau} \begin{align} \label{opentau} \tau(\mu) = \frac{e^{\mu}}{k} \ , \end{align} and friction~\eqref{closed friction} \begin{align} \label{openfriction} \zeta(\mu) = N_{\rm bath}\frac{e^{2 \mu}}{k} \ . \end{align} Both the copy-number variance~\eqref{openvar} and relaxation time~\eqref{opentau} increase exponentially with $\mu$. The relaxation time only depends on the unbinding rate, the characteristic time for a membrane-bound molecule to unbind, and since the (Poissonian) copy-number variance equals the mean, larger $\mu$ decreases the unbinding rate, increasing copy-number mean and thus decreasing the relaxation time and variance. Combining \eqref{lambdaoptdot2} with \eqref{openfriction} leads to the designed protocol velocity, \begin{equation} \label{muoptdot open} \mathrm d_t \mu^{\rm des}|_{\mu} = \frac{e^{-\mu}\left(e^{\mu_{\rm f}}-e^{\mu_{\rm i}}\right)}{\Delta t} \ . \end{equation} When driving the system from low to high chemical potential, as time progresses the designed protocol slows as $e^{-\mu}$. Appendix~\ref{Designed copy number} derives the designed protocol in terms of mean copy number, which amounts to driving at constant velocity $\mathrm d_t \langle N_{\rm B}\rangle^{\rm o} = \Delta \langle N_{\rm B}\rangle^{\rm o}/\Delta t$, equivalent to the naive mean-copy-number protocol. Appendix~\ref{initial and final velocity} shows that the initial velocity is exponentially faster than the final, and for small changes in chemical potential the designed protocol reduces to the naive. The designed chemical-potential protocol produces a constant excess power, leading to total excess work~\eqref{excess work} \begin{align} \label{opendesignedwork} W_{\rm ex}^{\rm o~des} = N_{\rm bath} \frac{e^{2 \mu_{\rm i}}}{k \Delta t}(e^{\Delta\mu} - 1)^2 \ . \end{align} For large increases in chemical potential ($e^{\Delta\mu} \gg 1$), the designed excess work increases exponentially in chemical potential distance, incurring large energetic costs; conversely, for large decreases in chemical potential, the excess work is independent of the chemical potential change $\Delta \mu$. The excess power during the naive (constant-velocity) protocol \eqref{Excess Power} produces excess work~\eqref{excess work} \begin{align} \label{opennaivework} W_{\rm ex}^{\rm o~naive} = N_{\rm bath} \frac{\Delta\mu}{\Delta t} \frac{ e^{2 \mu_{\rm i}}}{2k}(e^{2\Delta\mu} - 1) \ . \end{align} For large $\Delta\mu$, the naive excess work increases exponentially in chemical potential, thus incurring huge energetic costs. When significantly reducing chemical potential ($e^{2\Delta\mu} \ll 1$), the excess work increases linearly with decreasing $\Delta\mu$, which is a significantly slower rate than for chemical potential increases, but still significantly faster than the designed protocol~\eqref{opendesignedwork}, for which the excess work becomes independent of chemical potential. The friction is smaller at lower chemical potentials; therefore, reducing chemical potential carries the system through regions of control parameter space with lower resistance, thereby slowing the increase in energetic cost associated with greater-magnitude changes of chemical potential. Increasing chemical potential carries the system towards parameter space with higher resistance, further exacerbating the energetic cost. The excess work ratio is \begin{align} \frac{W_{\rm ex}^{\rm o~naive}}{W_{\rm ex}^{\rm o~des}}= \frac{\Delta\mu}{2}\frac{e^{\Delta\mu} + 1}{e^{\Delta\mu}-1} \ . \end{align} Despite the magnitude of the naive work increasing slowly for chemical potential reductions, the ratio is symmetric about $\Delta\mu = 0$. As the chemical potential change $|\Delta\mu|$ increases, so does the ratio of the excess works, and hence the energetic savings from using the designed protocol. \section{Discussion} Living things accrue a selective advantage if they can use less energy to achieve their required functions. In the task of dynamic cell-cell signaling, methods for achieving given changes in the target cell at minimum energy expenditure may point toward design principles for intercellular communication. We have developed a theoretical framework to approximate the energetic cost of rapidly changing chemical potential, and we used it to design finite-time chemical-potential protocols that (under linear response) reduce the excess work incurred in dynamically driven biochemical reaction networks. We analyzed the designed protocol for an arbitrary linear Markov chemical reaction network, and we applied it to an exactly solvable model system with only binding/unbinding reactions: a closed system with a fixed total number of proteins, which in the limit of small chemical potential can effectively be treated as an open system connected to a chemical bath. The designed protocol for such a linear chemical reaction system is simply determined by the collection of reaction rates. This approach can be generalized to non-linear chemical reactions by using moment-closure techniques to obtain approximate solutions. We find that for a two-state closed system, the generalized friction---the resistance to changes in chemical potential---is minimized (at $0$) when all proteins are either bound or unbound, and is maximized when $2/3$ of all proteins are bound, when the binding rate equals twice the unbinding rate. This corresponds to a balance between the largest fluctuations (when the binding rate equals the unbinding rate) and the largest relaxation time (for small unbinding rate and tightly bound proteins). Under these conditions, the designed protocol changes the chemical potential slowest at intermediate mean copy number. For an open system, the friction increases monotonically with mean copy number. Therefore, a protocol that minimizes energetic cost (near equilibrium) changes the chemical potential slowly when mean copy number is high and quickly when mean copy number is low. Similar analysis shows that when chemical potential exponentially enhances binding rather than exponentially suppressing unbinding (for a splitting factor~\cite{split1,split2} of $1$), friction is maximized when $1/3$ of all proteins are bound, corresponding to a binding rate half of the unbinding rate. When the chemical potential enhances binding and suppresses unbinding equally (splitting factor of $1/2$) friction is maximized when $1/2$ of all proteins are bound, corresponding to equal binding and unbinding rates; however, no closed-form solutions for the designed protocols and excess works for intermediate splitting factors in $(0,1)$ are known. Our analysis focused on chemical networks with known (and simple) topologies and reaction rates. It would be interesting to see how these results change for more complicated chemical networks. For example, a chemically bistable system (with two metastable copy-number states) would have significantly longer relaxation times at chemical potentials for which the system is bistable. Similar to recent results for a particle diffusing over a bistable potential~\cite{Workratio}, we expect the friction to be peaked at such bistability-inducing chemical potentials, meaning that work-minimizing protocols slow down near the threshold chemical potential to allow chemical fluctuations time to kick the system into the desired metastable state. In the absence of such detailed information, one could phenomenologically map out the generalized friction coefficient through monitoring copy-number fluctuations~\cite{Dar:2012ab} at various fixed chemical potentials, then use the linear-response theory to infer the corresponding designed protocols, in analogy to recent work in single-molecule contexts~\cite{tafoya2018using}. The less energy used during operation, the fewer signaling proteins that must be produced and dynamically secreted. Such designed control analysis makes strong predictions about the dynamic interactions that communicate information and regulate behavior in an energetically efficient manner. To the extent that energetic efficiency is an important functional characteristic for such signaling pathways, experiments may uncover signatures of these design criteria in evolved molecular and cellular systems. There are several known mechanisms by which a signaling cell can dynamically control a target cell's response to take advantage of designed protocols. The simplest method is by dynamically controlling the number of diffusible agonists secreted. Another method, used by $\beta$-adrenergic receptor kinases~\cite{nobel80} and rhodopsin kinase~\cite{nobel81}, is phosphorylation, which increases the affinity of the receptor for regulatory proteins called arrestins~\cite{nobel82,nobel83}, in turn down-regulating the number of active receptors. Additionally, recycling of receptors and internalization via endocytosis can regulate the signal~\cite{nobel84,nobel85}. All of these techniques are employed to adjust the number of active GPCRs and therefore allow for the control of the binding affinity and reaction rates of the G-protein between the bound and unbound states. Recent experimental advances make possible the precise spatial and temporal control of binding affinity between different chemical species, and hence of protein spatial localization within a cell. In particular, optogenetic techniques allow for the use of light to adjust the binding affinity between a light-gated protein and its binding partner~\cite{accuracy}. Changes in binding affinity are effectively changes in the chemical potential of one class of proteins in the vicinity of another, thus allowing for the dynamic experimental implementation of our proposed control strategies. \begin{acknowledgments} The authors thank Aidan I.~Brown, Joseph N.~E.~Lucero, and Alzbeta Medvedova (SFU Physics) for enlightening discussions. This research was supported by funding from a Natural Sciences and Engineering Research Council of Canada (NSERC) Discovery Grant, a Tier-II Canada Research Chair, and the Faculty of Science, Simon Fraser University through the President's Research Start-up Grant (all to D.~A.~S.). \end{acknowledgments} \section{\label{sec:intro}Introduction} Biochemical reaction networks play a central role in cellular response to external stimuli (such as cell-cell signaling), converting inter-cellular signals into a driven chemical response~\cite{signalling}. A prominent communication channel for chemical signals across the cell membrane are G-protein coupled receptors (GPCRs). Diffusible agonist ligands bind to the extracellular face of a GPCR and allosterically induce a conformational change on its intracellular face. This conformational change alters the binding affinity between diffusible G-proteins and the receptor, eliciting a series of reactions ultimately leading to the cellular response~\cite{nobel2012}. In mammals, GPCRs mediate many physiological responses---to changes in concentrations of peptides, hormones, lipids, neurotransmitters, ions, odorants, tastants, and light. Since $\sim$1000 human genes code for GPCRs~\cite{nobel1,nobel2}, we predict that an energetically efficient signaling process through a GPCR would provide a selective advantage, such that evolved signaling pathways could be expected to exhibit impressive efficiency. The GPCR signaling process can be modeled as changes in the chemical potential of the G-protein at the cell membrane. For given desired equilibrium endpoints of chemical potential, any protocol (schedule of changing chemical potential) that proceeds quasi-statically (at negligible speed) requires the same input energy in the form of chemical potential work, an amount equal to the free energy change between the equilibrium ensembles at the two endpoint chemical potentials. For protocols that proceed at a finite velocity, different protocols differ in their energetic costs, and hence in the required number of signaling molecules the signaling cell must secrete. Here we develop theory describing how a cell can achieve a given dynamic signaling outcome at minimal energetic cost. This maps neatly onto a problem in nonequilibrium statistical mechanics, that of finding a protocol that minimizes the excess work associated with finite-time changes in a control parameter~\cite{molecularmachines}. Starting from a theoretical framework developed in \cite{OptimalPaths} to approximate the thermodynamic cost (excess work) of rapid changes in an arbitrary control parameter, we extend the formalism to address changes in chemical potential, and derive protocols that minimize the required work. We find that near equilibrium, the excess work is determined by the auto-covariance of the protein copy number. For the special case of linear-order chemical reactions, we derive analytic forms of the generalized friction tensor, and the required work for both designed and naive (constant-velocity) protocols. We illustrate these results in simple chemical reaction schemes: an open system exchanging molecules with a molecular reservoir, and a closed system with fixed total copy number. \section{\label{sec:theoryReview}Theoretical review} We first present a review of minimum-dissipation nonequilibrium control in the linear-response framework. Applying linear-response theory~\cite{OptimalPaths} gives a near-equilibrium expression for the average excess power (excess above the average power if the system were equilibrated throughout the driving protocol) exerted by an external agent changing control parameters $\lambda$ that are coupled to the system in the canonical ensemble, \begin{align} \label{Excess Power} \mathrm d_t W_{\rm ex}(t) \approx \mathrm d_t \lambda_{j} \ \zeta_{j \ell}[\lambda(t)] \ \mathrm d_t \lambda_{\ell} \ , \end{align} in terms of the generalized friction tensor \begin{align} \label{Zeta} \zeta_{j \ell}(\lambda) \equiv \beta \int_{0}^{\infty} \mathrm d t \, \langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda} \ . \end{align} Here $\mathrm d_t \lambda_j$ denotes the time derivative, $\beta \equiv k_{\rm B}T^{-1}$ is inverse temperature, $f_{j} \equiv -\partial_{\lambda_{j}} U$ is the force conjugate to the $j$th control parameter, and $\langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda}$ is the force covariance defined in terms of equilibrium fluctuations $\delta f_{j}(t) \equiv f_{j}(t) - \langle f_{j}\rangle_{\lambda}$. $\langle \cdots \rangle_{\lambda}$ indicate an equilibrium average for fixed $\lambda$. Throughout, we adopt the Einstein summation convention of implied summation over repeated indices. The generalized friction tensor $\zeta_{j \ell}$ is the Hadamard product $\beta \langle\delta f_{j} \delta f_{\ell}\rangle_{\lambda} \circ \tau_{j \ell}$ of the conjugate force covariance (the force fluctuations) and the integral relaxation time \begin{align} \label{relax1} \tau_{j \ell} \equiv \int_{0}^{\infty} \mathrm d t \frac{\langle \delta f_{j}(t) \delta f_{\ell}(0)\rangle_{\lambda}}{\langle \delta f_{j} \delta f_{\ell}\rangle_{\lambda}} \ , \end{align} the characteristic time it takes for these fluctuations to die out. The generalized friction tensor reflects the increased energy cost associated with rapid driving through control parameter space. Integrating the excess power~\eqref{Excess Power} over the control parameter protocol gives the mean excess work, \begin{align} \label{excess work} W_{\rm ex} = \int_{0}^{\Delta t} \mathrm d t \ \mathrm d_t W_{\rm ex}(t) \ , \end{align} above and beyond the quasi-static work. Under the linear-response approximation, the excess work is minimized for a `designed' protocol with constant excess power~\cite{OptimalPaths}. For a single control parameter, this amounts to proceeding with a velocity $\mathrm d_t \lambda^{\rm des} \propto \zeta(\lambda)^{-1/2}$, which when normalized to complete the protocol in a fixed allotted time $\Delta t$, gives \begin{align} \label{lambdaoptdot2} \mathrm d_t \lambda^{\rm des} = \frac{\int_{\lambda_{\rm i}}^{\lambda_{\rm f}}\mathrm d\lambda' \sqrt{\zeta(\lambda')}}{\sqrt{\zeta(\lambda)} \Delta t} \ , \end{align} for initial and final chemical potentials $\lambda_{\rm i}$ and $\lambda_{\rm f}$, respectively. Thus for a fixed protocol time, work is minimized by driving the system (changing the control parameter) slowly in regions of high friction, and quickly in areas of low friction. The ratio of excess works during the naive and designed protocols is~\cite{Workratio} \begin{align} \label{Ratio} \frac{W_{\rm ex}^{\rm naive}}{W_{\rm ex}^{\rm des}} = \frac{\Delta \lambda \int_{\lambda_{\rm i}}^{\lambda_{\rm f}} \zeta(\lambda) \, \mathrm d\lambda}{\left[\int_{\lambda_{\rm i}}^{\lambda_{\rm f}} \sqrt{\zeta(\lambda)} \, \mathrm d\lambda\right]^2} \ . \end{align} \section{Driving chemical potential} A system of $n$ different chemical species at thermal and chemical equilibrium with a single heat reservoir and multiple particle reservoirs at temperature $T$ and chemical potentials $\mu_{j}$, respectively, is described by the grand canonical ensemble (GCE) with free energy (\emph{grand potential}) \begin{align} \label{Free energy} \Phi_{\rm G} \equiv U - TS - \mu_{j} N_{j} \ , \end{align} for system energy $U$, entropy $S$, and copy number $N_{j}$ of the $j$th chemical species. In this study, the control parameters $\lambda_i$ are chemical potentials $\mu_i$, and hence the conjugate forces are the copy numbers, $f_{j} = -\partial_{\mu_{j}} \Phi_{\rm G} = N_{j}$. This produces a friction tensor and excess work \begin{subequations} \begin{align} \label{Zeta cov} \zeta_{j \ell}(\mu) &= \beta \int_{0}^{\infty} \mathrm d t \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle_{\mu} \\ \label{Free energy friction} &= \beta \langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}\circ \tau_{j \ell}(\mu) \\ \label{Free Energy Work} W_{\rm ex} &= \beta \int_{0}^{\Delta t} \mathrm d t \, \mathrm d_t \mu_{j} \langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}\circ \tau_{j \ell}(\mu) \mathrm d_t \mu_{\ell} \ . \end{align} \end{subequations} The total work during a chemical-potential protocol is the equilibrium free energy change, plus an additional contribution from the excess work. This extra cost is proportional to the relaxation time $\tau$ and equilibrium copy-number covariance $\langle \delta N_{j} \delta N_{\ell}\rangle_{\mu}$, so reaction systems subject to large and long-persisting fluctuations in protein copy number require greater energy input to rapidly change their chemical potential. \section{\label{Linear Markov chemical reaction networks}Linear Markov chemical reaction networks} The dependence of the friction tensor $\zeta$ on control parameter $\mu$, and thus the solution for the designed protocol, is a function of the topology and kinetics of the chemical reaction network. For linear-order chemical reactions, the autocovariance---and therefore the friction tensor---can be solved exactly~\cite{Closedfirstorder,Firstorderreactions}, and for higher-order reactions it can be approximated using moment-closure techniques~\cite{Momentclosure}. Here we model the stochastic behavior of chemical reaction systems assuming Markovian dynamics, where the future dynamics depends exclusively on the present state. A linear-order chemical reaction system with multiple chemical species (and fixed chemical potential) satisfies~\cite{Closedfirstorder} \begin{align} \label{mean evolution} \mathrm d_t \overline{N_{j}(t)} = -K_{j \ell} \overline{N_{\ell}(t)} + k^{\rm s}_{j} \ , \end{align} where $K \equiv K^{\rm d} - K^{\rm con}$, $K^{\rm d}$ is the diagonal matrix of degradation rates, $K^{\rm con}$ is the matrix of conversion reaction rates, $k^{\rm s}$ are the production rates from a constant source, and an overbar indicates a (in general out-of-equilibrium) ensemble average. For notational simplicity, in this section we suppress explicit dependence on $\mu$. Equation~\eqref{mean evolution} has the general solution \begin{align} \label{Mean time evolution} \overline{N_{j}(t)} = &\left[e^{-K t}\right]_{j \ell} N_{\ell}(0) \\ &+\left(1-\left[e^{-K t}\right]_{j \ell}\right) \int_{0}^{t}\mathrm d t'\left[e^{-K t'}\right]_{j \ell}k^{\rm s}_{\ell} \ . \nonumber \end{align} Assuming $K$ is diagonalizable, then $e^{-K t} = V e^{-D}V^{-1}$, where $D$ is the diagonal eigenvalue matrix, and $V$ is the eigenvector matrix, whose rows are the corresponding eigenvectors of $K$. If $K$ is not diagonalizable, then other standard methods of computing the matrix exponential can be employed~\cite{matrixexponential,newmatrixexponential}. For a linear Markov reaction network, the auto-covariance obeys a similar time evolution equation as the mean~\cite{Gardiner}: \begin{align} \label{cov evolution} \mathrm d_t \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle = -K_{jm}\langle \delta N_{m}(t) \delta N_{\ell}(0)\rangle \ . \end{align} Assuming the system is initially at equilibrium, this has the solution \begin{align} \label{autocovariance} \langle \delta N_{j}(t) \delta N_{\ell}(0)\rangle &= \left[e^{-K t}\right]_{jm}\langle \delta N_{m}\delta N_{\ell}\rangle \\ &= V_{j m} \left[e^{-D t}\right]_{mn}V^{-1}_{np}\langle \delta N_{p}\delta N_{\ell}\rangle \ . \end{align} This produces a friction tensor \begin{align} \label{zeta} \zeta_{j \ell} &= \beta \int_{0}^{\infty}\mathrm d t \, V_{jm} \left[e^{-D t}\right]_{mn}V^{-1}_{np} \langle \delta N_{p}\delta N_{\ell}\rangle \\ \label{zeta2} &= \beta V_{jm} [D^{-1}]_{mn} V^{-1}_{np} \langle \delta N_{p}\delta N_{\ell}\rangle \ . \end{align} Strictly speaking, for the case of a zero eigenvalue, $D_{jj} = 0$ for some $j$, so $D^{-1}$ does not exist; however, simply computing $V_{jm} \left[e^{-D t}\right]_{mn}V^{-1}_{np}$ before integrating avoids this problem. A \emph{conversion network} allows only conversion, degradation, and source reactions~\cite{Firstorderreactions}. It is \emph{open} when it has at least one degradation or source reaction. The equilibrium distribution (reached in the $t\to \infty$ limit of \eqref{Mean time evolution}) of any species in an open linear conversion network is a Poisson distribution, with mean and covariance~\cite{Firstorderreactions} \begin{align} \label{Open Variance} \langle \delta N_{j}\delta N_{\ell} \rangle^{\rm o}& = \langle N_{j} \rangle^{\rm o}\delta_{j\ell} = V_{jm}[D^{-1}]_{mn}V^{-1}_{np}k^{\rm s}_{p}\delta_{j\ell} \ , \end{align} where $\delta_{j\ell}$ is the Kronecker delta, equal to $1$ if $j = \ell$, and $0$ otherwise. The friction tensor for an open system can therefore be fully determined from the equilibrium mean and reaction rates as \begin{align} \label{Zeta open} \zeta_{j\ell}^{\rm o} = \beta V_{jm}[D^{-1}]_{mn}V^{-1}_{n\ell}\langle N _{\ell}\rangle^{\rm o} \delta_{jl} \ . \end{align} The relaxation time is $\tau_{j\ell}^{\rm o} = V_{jm} [D^{-1}]_{mn} V^{-1}_{n\ell}\delta_{jl}$, which is proportional to the mean copy number~\eqref{Open Variance}. Hence an increase in mean copy number has the compound effect of increasing both the size and lifetime of fluctuations. Therefore, the designed chemical-potential protocol drives slowly in areas of large mean copy number and quickly in areas of low mean copy number. For a linear \emph{closed} conversion network (no sources or degradation), the equilibrium distribution is not Poisson~\cite{Firstorderreactions}, but the mean, variance, and covariance can still be solved analytically using standard linear algebra techniques~\cite{Closedfirstorder,Firstorderreactions}. The equilibrium covariance is \begin{align} \label{closed covariance} \langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = \langle N_{j}\rangle^{\rm c}\left(\delta_{j \ell}-\frac{\langle N_{\ell}\rangle^{\rm c}}{N_{\rm tot}}\right) \ , \end{align} where $N_{\rm tot} = \sum_{j}N_{j}$ is the total number of chemical molecules. For chemical reaction systems with a \emph{strongly connected} reaction graph (\emph{i.e.}, any species can be reached from any other via a set of allowed reactions), $K$ has exactly one zero eigenvalue, and the equilibrium probability distribution across all species is multinomial~\cite{Firstorderreactions}, $\pi_{j} = v^{0}_{j}/\sum_{\ell}v^{0}_{\ell}$, where $v^{0}_{j}$ is the $j$th component of the eigenvector with zero eigenvalue. The multinomial mean copy number of species $j$ is simply $\langle N_{j} \rangle = N_{\rm tot}\pi_{j}$, producing covariance \begin{align} \label{closed correlation} \langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = N_{\rm tot}\pi_{j}(\delta_{j \ell} - \pi_{\ell}) \ . \end{align} Substituting the covariance~\eqref{closed covariance} into the friction~\eqref{zeta} gives \begin{align} \label{Closed Zeta2} \zeta_{j \ell}^{\rm c} = \beta V_{jm}[D^{-1}]_{mn}V^{-1}_{np} \langle N_{p}\rangle^{\rm c}\left(\delta_{p \ell}-\frac{\langle N_{\ell}\rangle^{\rm c}}{N_{\rm tot}}\right) \ . \end{align} Unlike for the open system, the closed covariance~\eqref{closed covariance} does not monotonically increase with mean copy number, but rather is largest when the two species have equal mean copy numbers and is smallest when one species dominates. If $j = \ell$, then the covariance reduces to the variance, which is maximized at $\langle N_{j}\rangle^{\rm c} = N_{\rm tot}/2$ and minimized at $\langle N_{j}\rangle^{\rm c} = N_{\rm tot}$ or $\langle N_{j} \rangle^{\rm c} = 0$. When $j\neq \ell$, $\langle \delta N_{j}\delta N_{\ell}\rangle^{\rm c} = -\langle N_{j}\rangle^{\rm c}\langle N_{\ell}\rangle^{\rm c}/N_{\rm tot}$, which is always negative and reaches its maximum magnitude when $\langle N_{j}\rangle^{\rm c} = \langle N_{\ell} \rangle^{\rm c} = N_{\rm tot}/2$. For small mean copy number relative to the total, $\langle N_{\ell}\rangle^{\rm c} \ll N_{\rm tot}$, the friction of a closed system~\eqref{Closed Zeta2} reduces to that of an open system~\eqref{Zeta open}, since the second term in parentheses in \eqref{Closed Zeta2} becomes negligible. The large total number of molecules acts as a constant source, or chemical bath, making the closed and open systems equivalent. In order to interpret the form of the closed-system relaxation time $\tau_{j\ell}^{\rm c} = V_{jm} [D^{-1}]_{mn} V^{-1}_{n\ell}$, we recognize that the eigenvalues of $K$ in a closed system have non-negative real components~\cite{Firstorderreactions}. Furthermore, if the system satisfies detailed balance, then the eigenvalues of $K$ are real~\cite{realeigenvalues,realeigenvaluestwo}. Thus $\tau_{j \ell}$ is non-negative. As we have seen, all off-diagonal components of the covariance are negative and all diagonal components are positive, therefore the same is true of the friction tensor, the product of covariance and relaxation time. Although the friction tensor can have negative specific entries, it is positive semidefinite since it is an auto-covariance matrix~\cite{OptimalPaths}. The friction tensors \eqref{zeta}, \eqref{Zeta open}, and \eqref{Closed Zeta2} imply analytic solutions for the designed protocol of any linear Markov chemical reaction. In the following sections we examine specific reaction networks to gain further insight into designed protocols. \section{\label{Closed system}Closed system} As a simple tractable model, we examine a two-state chemical reaction with respective binding and unbinding rates $k_1$ and $k_{-1}$ (Fig.~\ref{Reaction}), nominally meant to represent G-proteins binding to the GPCR at the cell membrane. \begin{figure} \begin{center} \includegraphics[scale = 0.25]{Diagram.png} \caption{Two-state chemical reaction network representing bound and unbound G-proteins. Proteins bind at rate $k_{1}=k$ and unbind at rate $k_{-1}=ke^{-\mu}$.} \label{Reaction} \end{center} \end{figure} The chemical potential is the externally controlled signal, for example as modulated by the number of expressed agonist molecules, or experimentally controlled light power for a light-gated GPCR. It is natural to model the membrane binding rate $k_1=k$ as depending on the dynamic encounter rate and not on the strength of the chemical potential, and the membrane unbinding rate $k_{-1}$ as depending on how tightly the protein is bound, and hence on the chemical potential difference $\mu$ between unbound and bound states, as \begin{equation} \label{rate chemical dependence} k_{-1} = ke^{-\mu} \ . \end{equation} $\mu = 0$ produces equal binding and unbinding rates, $k_{1} = k_{-1}$. (This specific dependence of rates on chemical potential is consistent with~\cite{brownsivak2017,brownsivak2018} for a splitting factor~\cite{split1,split2} of $0$, although our framework could be applied to any splitting factor.) For simplicity, here and in subsequent sections, energies are written in units of $k_{\rm B}T$ (equivalent to setting $\beta = 1$). We additionally assume a fixed total number of molecules $N_{\rm tot} = N_{\rm UB}+N_{\rm B}$, with variable numbers of unbound ($N_{\rm UB}$) and bound ($N_{\rm B}$) molecules. The reaction-rate matrix is \begin{align} K = \left[ {\begin{array}{cc} ke^{- \mu}&-k \\ -ke^{- \mu}&k \\ \end{array} } \right] \ . \end{align} In \S\ref{Linear Markov chemical reaction networks}, we derived simple expressions for the auto-covariance~\eqref{autocovariance}, equilibrium covariance~\eqref{closed correlation}, and friction~\eqref{Closed Zeta2}. With one chemical potential, there is only the $j=\ell=1$ component, giving equilibrium variance \begin{align} \label{closedvar} \langle (\delta N_{\rm B})^{2}\rangle^{\rm c}_{\mu} = N_{\rm tot} \frac{e^{-\mu}}{(1+e^{-\mu})^2} \ , \end{align} relaxation time \begin{align} \label{closedtau} \tau(\mu) = \frac{1}{k(1+e^{-\mu})} \ , \end{align} and friction \begin{align} \label{closed friction} \zeta(\mu) &= N_{\rm tot} \frac{e^{-\mu}}{k(1+e^{-\mu})^3} \ . \end{align} The variance is maximized at $\mu = 0$. For $e^{\mu} \gg 1$, the variance decays exponentially with $\mu$ as $\langle (\delta N_{\rm B})^{2}\rangle^{\rm c}_{\mu} \approx N_{\rm tot} e^{-\mu}$. Figure~\ref{friction Plot} plots the dependence of friction coefficient on $\mu$, for several binding rates $k$. Physically, as $\mu$ increases, molecules are held more tightly to the membrane (unbinding rate decreases), and thus copy-number fluctuations relax more slowly. The relaxation time is sigmoidal in $\mu$, with $\tau(\mu \to -\infty) \to 0$ and $\tau(\mu \to \infty) \to 1/k$. The first limit corresponds to molecules bound very loosely to the membrane, such that the unbinding rate is much larger than the binding rate, with fluctuations decaying rapidly. The latter limit corresponds to tightly bound molecules such that the binding rate is much larger than unbinding, causing fluctuations to decay slowly and most molecules to be bound: the relaxation time is maximized when all molecules are bound. Ultimately, this asymmetry in relaxation time is caused by the asymmetric dependence of the forward and reverse reaction rates on chemical potential: $k_{1}$ is independent of $\mu$ and $k_{-1}\propto e^{-\mu}$. The friction is minimized (and vanishes) when either all molecules are bound or all are unbound. The friction peaks at $\mu = \ln2$, when $2/3$ of all molecules are bound, $\langle N_{\rm B} \rangle^{\rm c} = \tfrac{2}{3}N_{\rm tot}$). Physically, the resistance increases when driving away from either all-bound or all-unbound: as the mean copy number of the less common species increases, the resistance to changes in chemical potential increases. This can be rationalized because the variance is maximized at $\mu=0$, when each state (bound and unbound) contains on average half the total number of molecules, whereas the relaxation time is maximized when all the molecules are bound, thus shifting the maximal friction to occur past an even split in each state. At chemical potentials well below this maximum (for $e^{\mu} \ll 1$), the friction increases as $e^{2\mu}$, whereas for large chemical potentials ($e^{\mu} \gg 1$), the friction decays exponentially with chemical potential, $\zeta \to e^{-\mu}$. Figure~\ref{friction Plot} shows these differing slopes. The designed protocol drives slowly in control parameter regimes of high friction which, due to the exponential dependence of friction on chemical potential~\eqref{closed friction}, produces large variations in chemical potential velocity and potentially large energetic saving. This behaviour is illustrated in Fig.~\ref{friction Plot}. \begin{figure} \includegraphics[width=\columnwidth]{friction} \caption{Generalized friction coefficient $\zeta$ (in units of seconds, since $k_{\rm B}T$ is set to unity) as a function of chemical potential $\mu$, for various binding rates $k$ (different colors). The horizontal axis is shifted by $\ln 2$ so that the friction of the closed system is maximized at $0$. For simplicity, the total protein copy number $N_{\rm tot}$ is normalized to $1$.} \label{friction Plot} \end{figure} With a single control parameter, the designed protocol is easily solved using \eqref{lambdaoptdot2}: \begin{align} \label{closed lambdaoptdot3} \mathrm d_t \mu^{\rm des}|_{\mu} = &\frac{ 2\sqrt{1+e^{\mu}}(1+e^{-\mu})}{\Delta t} \left(\frac{1}{\sqrt{1+e^{\mu_{\rm i}}}}-\frac{1}{\sqrt{1+e^{\mu_{\rm f}}}}\right) \ . \end{align} The velocity of the designed protocol reaches a minimum when the friction is at a maximum, $\mu = \ln 2$. Appendix~\ref{Designed copy number} derives the equivalent designed mean-copy-number protocol, which increases as $\mathrm d_t \langle N_{\rm B}\rangle^{\rm c~des} \propto \sqrt{\langle N_{\rm UB}\rangle^{\rm c}}$. Appendix~\ref{initial and final velocity} compares the initial and final designed protocol velocities, and demonstrates that for small changes in chemical potential, the designed protocol reduces to the naive. The designed protocol produces an excess work \begin{align} \label{closeddesignedwork} W_{\rm ex}^{\rm c~des} = &\frac{4N_{\rm tot} }{k \Delta t} \left( \frac{1}{\sqrt{1+e^{\mu_{\rm i}}}} - \frac{1}{\sqrt{1+e^{\mu_{\rm f}}}}\right)^{2} \ . \end{align} For significant changes in chemical potential, either increases ($e^{\mu_{\rm f}} \gg e^{\mu_{\rm i}}$ and $e^{\mu_{\rm f}} \gg 1$) or decreases ($e^{\mu_{\rm f}} \ll e^{\mu_{\rm i}}$ and $e^{\mu_{\rm f}} \ll 1)$, the designed excess work becomes independent of $\mu_{\rm f}$. The naive protocol changes chemical potential at constant velocity $\mathrm d_t \mu^{\rm naive} = \Delta\mu/\Delta t$ and produces excess work~\eqref{excess work} \begin{align} \label{closednaivework} W_{\rm ex}^{\rm c~naive} = N_{\rm tot} \frac{\Delta\mu}{\Delta t} \frac{1}{2k}\left[\frac{1+2e^{\mu_{\rm i}}}{(1+e^{\mu_{\rm i}})^{2}}-\frac{1+2e^{\mu_{\rm f}}}{(1+e^{\mu_{\rm f}})^{2}}\right] \ . \end{align} For significant changes in chemical potential, the naive excess work \eqref{closednaivework} scales linearly with $\Delta\mu \equiv \mu_{\rm f}-\mu_{\rm i}$. This is in contrast to the excess work from the designed protocol \eqref{closeddesignedwork}, which becomes independent of $\mu_{\rm f}$ in this limit. We quantify the thermodynamic benefit of designed driving by the ratio of the excess works incurred during the naive and designed protocols~\eqref{Ratio}: \begin{align} \label{closedratio} \frac{W_{\rm ex}^{\rm c~naive}}{W_{\rm ex}^{\rm c~des}} &= \Delta\mu \frac{\frac{(1+2e^{\mu_{\rm i}})(1+e^{\mu_{\rm f}})}{1+e^{\mu_{\rm i}}}-\frac{(1+2e^{\mu_{\rm f}})(1+e^{\mu_{\rm i}})}{1+e^{\mu_{\rm f}}}}{8\left(\sqrt{1+e^{\mu_{\rm i}}}-\sqrt{1+e^{\mu_{\rm f}}}\right)^{2}} \ . \end{align} The ratio does not depend on the raw binding/unbinding rate $k$. For significant chemical potential changes, the excess-work ratio scales linearly with $\Delta\mu$. Appendix~\ref{small chemical potential} shows that for small changes $\Delta\mu$ in chemical potential, both the naive excess work and the excess-work ratio increase quadratically in $\Delta\mu$. The only parameters in \eqref{closedratio} are the initial and final chemical potentials $\mu_{\rm i}$ and $\mu_{\rm f}$. Figure~\ref{Ratio Plot} demonstrates that the excess work ratio is non-monotonic in $\mu_{\rm f}$, empirically peaking near the local maximum in the friction; however, after decreasing for a short distance, the ratio begins to increase linearly. This transition can occur for either positive or negative chemical potential distances, depending on which side of the maximum friction the protocol starts. Such a feature is not found for a protocol initially at the peak friction. The asymmetry in excess work ratio on different sides of the maximal friction is caused by the friction scaling as $e^{2\mu}$ for chemical potentials below the peak and as $e^{-\mu}$ for chemical potentials above the peak (Fig.~\ref{friction Plot}), itself a result of the asymmetric chemical potential dependence of the forward and reverse reaction rates. Outside of this region, more significant chemical potential changes still produce greater benefits from the designed protocol (quadratic for small $\Delta\mu$ and linear for large $\Delta\mu$). \begin{figure} \includegraphics[width=\columnwidth]{ratio} \caption{The ratio of naive to designed excess works as a function of the final chemical potential $\mu_{\rm f} - \ln 2$, for varying shifted initial chemical potential $\mu_{\rm i} - \ln 2$ (different colors). Horizontal axis is shifted to $\mu_{\rm f} - \ln 2$, so that the protocol crosses the maximal friction at $0$.} \label{Ratio Plot} \end{figure} \section{\label{two state open}Open system} When the unbinding rate is much larger than the binding rate (for $e^{\mu} \ll 1$), and hence $\langle N_{\rm UB}\rangle^{\rm c} \gg \langle N_{\rm B}\rangle^{\rm c}$, $N_{\rm UB}$ is effectively constant over copy-number fluctuations, and thus the system is effectively open, with $K = -K^{\rm d} = -k_{-1}$ and $k^{\rm s} = N_{\rm bath} k$. This limit produces particularly simple forms for the variance~\eqref{closedvar} \begin{align} \label{openvar} \langle \left(\delta N_{B}\right)^{2}\rangle_{\mu}^{\rm o} = N_{\rm bath} e^{\mu} \ , \end{align} relaxation time~\eqref{closedtau} \begin{align} \label{opentau} \tau(\mu) = \frac{e^{\mu}}{k} \ , \end{align} and friction~\eqref{closed friction} \begin{align} \label{openfriction} \zeta(\mu) = N_{\rm bath}\frac{e^{2 \mu}}{k} \ . \end{align} Both the copy-number variance~\eqref{openvar} and relaxation time~\eqref{opentau} increase exponentially with $\mu$. The relaxation time only depends on the unbinding rate, the characteristic time for a membrane-bound molecule to unbind, and since the (Poissonian) copy-number variance equals the mean, larger $\mu$ decreases the unbinding rate, increasing copy-number mean and thus decreasing the relaxation time and variance. Combining \eqref{lambdaoptdot2} with \eqref{openfriction} leads to the designed protocol velocity, \begin{equation} \label{muoptdot open} \mathrm d_t \mu^{\rm des}|_{\mu} = \frac{e^{-\mu}\left(e^{\mu_{\rm f}}-e^{\mu_{\rm i}}\right)}{\Delta t} \ . \end{equation} When driving the system from low to high chemical potential, as time progresses the designed protocol slows as $e^{-\mu}$. Appendix~\ref{Designed copy number} derives the designed protocol in terms of mean copy number, which amounts to driving at constant velocity $\mathrm d_t \langle N_{\rm B}\rangle^{\rm o} = \Delta \langle N_{\rm B}\rangle^{\rm o}/\Delta t$, equivalent to the naive mean-copy-number protocol. Appendix~\ref{initial and final velocity} shows that the initial velocity is exponentially faster than the final, and for small changes in chemical potential the designed protocol reduces to the naive. The designed chemical-potential protocol produces a constant excess power, leading to total excess work~\eqref{excess work} \begin{align} \label{opendesignedwork} W_{\rm ex}^{\rm o~des} = N_{\rm bath} \frac{e^{2 \mu_{\rm i}}}{k \Delta t}(e^{\Delta\mu} - 1)^2 \ . \end{align} For large increases in chemical potential ($e^{\Delta\mu} \gg 1$), the designed excess work increases exponentially in chemical potential distance, incurring large energetic costs; conversely, for large decreases in chemical potential, the excess work is independent of the chemical potential change $\Delta \mu$. The excess power during the naive (constant-velocity) protocol \eqref{Excess Power} produces excess work~\eqref{excess work} \begin{align} \label{opennaivework} W_{\rm ex}^{\rm o~naive} = N_{\rm bath} \frac{\Delta\mu}{\Delta t} \frac{ e^{2 \mu_{\rm i}}}{2k}(e^{2\Delta\mu} - 1) \ . \end{align} For large $\Delta\mu$, the naive excess work increases exponentially in chemical potential, thus incurring huge energetic costs. When significantly reducing chemical potential ($e^{2\Delta\mu} \ll 1$), the excess work increases linearly with decreasing $\Delta\mu$, which is a significantly slower rate than for chemical potential increases, but still significantly faster than the designed protocol~\eqref{opendesignedwork}, for which the excess work becomes independent of chemical potential. The friction is smaller at lower chemical potentials; therefore, reducing chemical potential carries the system through regions of control parameter space with lower resistance, thereby slowing the increase in energetic cost associated with greater-magnitude changes of chemical potential. Increasing chemical potential carries the system towards parameter space with higher resistance, further exacerbating the energetic cost. The excess work ratio is \begin{align} \frac{W_{\rm ex}^{\rm o~naive}}{W_{\rm ex}^{\rm o~des}}= \frac{\Delta\mu}{2}\frac{e^{\Delta\mu} + 1}{e^{\Delta\mu}-1} \ . \end{align} Despite the magnitude of the naive work increasing slowly for chemical potential reductions, the ratio is symmetric about $\Delta\mu = 0$. As the chemical potential change $|\Delta\mu|$ increases, so does the ratio of the excess works, and hence the energetic savings from using the designed protocol. \section{Discussion} Living things accrue a selective advantage if they can use less energy to achieve their required functions. In the task of dynamic cell-cell signaling, methods for achieving given changes in the target cell at minimum energy expenditure may point toward design principles for intercellular communication. We have developed a theoretical framework to approximate the energetic cost of rapidly changing chemical potential, and we used it to design finite-time chemical-potential protocols that (under linear response) reduce the excess work incurred in dynamically driven biochemical reaction networks. We analyzed the designed protocol for an arbitrary linear Markov chemical reaction network, and we applied it to an exactly solvable model system with only binding/unbinding reactions: a closed system with a fixed total number of proteins, which in the limit of small chemical potential can effectively be treated as an open system connected to a chemical bath. The designed protocol for such a linear chemical reaction system is simply determined by the collection of reaction rates. This approach can be generalized to non-linear chemical reactions by using moment-closure techniques to obtain approximate solutions. We find that for a two-state closed system, the generalized friction---the resistance to changes in chemical potential---is minimized (at $0$) when all proteins are either bound or unbound, and is maximized when $2/3$ of all proteins are bound, when the binding rate equals twice the unbinding rate. This corresponds to a balance between the largest fluctuations (when the binding rate equals the unbinding rate) and the largest relaxation time (for small unbinding rate and tightly bound proteins). Under these conditions, the designed protocol changes the chemical potential slowest at intermediate mean copy number. For an open system, the friction increases monotonically with mean copy number. Therefore, a protocol that minimizes energetic cost (near equilibrium) changes the chemical potential slowly when mean copy number is high and quickly when mean copy number is low. Similar analysis shows that when chemical potential exponentially enhances binding rather than exponentially suppressing unbinding (for a splitting factor~\cite{split1,split2} of $1$), friction is maximized when $1/3$ of all proteins are bound, corresponding to a binding rate half of the unbinding rate. When the chemical potential enhances binding and suppresses unbinding equally (splitting factor of $1/2$) friction is maximized when $1/2$ of all proteins are bound, corresponding to equal binding and unbinding rates; however, no closed-form solutions for the designed protocols and excess works for intermediate splitting factors in $(0,1)$ are known. Our analysis focused on chemical networks with known (and simple) topologies and reaction rates. It would be interesting to see how these results change for more complicated chemical networks. For example, a chemically bistable system (with two metastable copy-number states) would have significantly longer relaxation times at chemical potentials for which the system is bistable. Similar to recent results for a particle diffusing over a bistable potential~\cite{Workratio}, we expect the friction to be peaked at such bistability-inducing chemical potentials, meaning that work-minimizing protocols slow down near the threshold chemical potential to allow chemical fluctuations time to kick the system into the desired metastable state. In the absence of such detailed information, one could phenomenologically map out the generalized friction coefficient through monitoring copy-number fluctuations~\cite{Dar:2012ab} at various fixed chemical potentials, then use the linear-response theory to infer the corresponding designed protocols, in analogy to recent work in single-molecule contexts~\cite{tafoya2018using}. The less energy used during operation, the fewer signaling proteins that must be produced and dynamically secreted. Such designed control analysis makes strong predictions about the dynamic interactions that communicate information and regulate behavior in an energetically efficient manner. To the extent that energetic efficiency is an important functional characteristic for such signaling pathways, experiments may uncover signatures of these design criteria in evolved molecular and cellular systems. There are several known mechanisms by which a signaling cell can dynamically control a target cell's response to take advantage of designed protocols. The simplest method is by dynamically controlling the number of diffusible agonists secreted. Another method, used by $\beta$-adrenergic receptor kinases~\cite{nobel80} and rhodopsin kinase~\cite{nobel81}, is phosphorylation, which increases the affinity of the receptor for regulatory proteins called arrestins~\cite{nobel82,nobel83}, in turn down-regulating the number of active receptors. Additionally, recycling of receptors and internalization via endocytosis can regulate the signal~\cite{nobel84,nobel85}. All of these techniques are employed to adjust the number of active GPCRs and therefore allow for the control of the binding affinity and reaction rates of the G-protein between the bound and unbound states. Recent experimental advances make possible the precise spatial and temporal control of binding affinity between different chemical species, and hence of protein spatial localization within a cell. In particular, optogenetic techniques allow for the use of light to adjust the binding affinity between a light-gated protein and its binding partner~\cite{accuracy}. Changes in binding affinity are effectively changes in the chemical potential of one class of proteins in the vicinity of another, thus allowing for the dynamic experimental implementation of our proposed control strategies. \begin{acknowledgments} The authors thank Aidan I.~Brown, Joseph N.~E.~Lucero, and Alzbeta Medvedova (SFU Physics) for enlightening discussions. This research was supported by funding from a Natural Sciences and Engineering Research Council of Canada (NSERC) Discovery Grant, a Tier-II Canada Research Chair, and the Faculty of Science, Simon Fraser University through the President's Research Start-up Grant (all to D.~A.~S.). \end{acknowledgments}
{'timestamp': '2018-10-05T02:06:41', 'yymm': '1810', 'arxiv_id': '1810.02046', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02046'}
arxiv
\section{Introduction} Electroencephalography (EEG) is an electrophysiological method to record the voltage fluctuations of ionic current within the neurons of brains \cite{tomida2015active}. An EEG based Brain-Computer Interface (BCI) enables people to communicate with the outside world by interpreting the EEG signals of their brains to interact with devices such as wheelchairs and intelligent robots \cite{zhang2017intent}. BCI systems have been widely studied for various real-world applications ranging from the healthcare domain \cite{pinheiro2016wheelchair,kaya20141d} to the entertainment industry \cite{Alomari2014}. The availability of portable and affordable EEG collection devices (e.g., Emotiv and OpenBCI), has opened up new opportunities for developing BCI applications that could help us in our daily functions, e.g., personal assistants and healthcare management. Such {\it in-situ} use of this technology necessitates a shift towards a non-invasive way to collect EEG signals from the cortex surface \cite{jayakar2016diagnostic} (also employed by the aforementioned portable devices) as opposed to invasive approaches which rely on inserting electrodes into the scalp \cite{volker2018deep}. However, one major challenge faced by the non-invasive collection of EEG signals is the low signal to noise ratio \cite{zhang2018converting}. This can be attributed to internal and external effects. The former include the loss in the strength of the signals as the pass through the thick medium of the skull, lack of concentration from the individual, etc. The latter includes the impact of environmental noise, light stimuli and fidelity of acquisition device. It has been shown that the fidelity (measured as SNR) of non-invasive EEG signals is approximately only about 5\% of that of the signals collected through sophisticated but invasive method \cite{ball2009signal}. As a result, EEG signals inherently lack sufficient spatial resolution and insight on activities of deep brain structures. To this end, several studies have focused on denoising the signals and dealing with the aforementioned artefacts by statistical feature extraction (e.g., Principal Component Analysis, Independent Component Analysis, Autoregressive model, wavelet analysis) \cite{shaw2016statistical,michelmann2018data,li2015autoregressive,zhang2017classification} and deep learning (e.g., Recurrent Neural Networks, Autoencoder) \cite{li2017emotion,liu2017multi,li2015feature,lin2016classification}. To the best of our knowledge, the idea of exploiting multi-faceted spatial relationships of multiple EEG channels has not yet been fully explored. Addressing the aforementioned issue, in this work, we propose a unified approach by learning the robust structured EEG feature representations for recognizing the imagery of object seen by the individual. We first design a multi-class Common Spatial Pattern (CSP) for distilling the compact representations. CSP has proven success in extracting features using eigen decomposition based on the variance between variant classes \cite{elisha2017eeg}. Next, we propose Dynamical Graph Representation (DGR) of EEG signals to adaptively embed the spatial relationship among the channels (each channel represents one EEG electrode) and their neighbors by learning a dynamic adjacent matrix. Finally, a Convolutional Neural Network (CNN) is employed to aggregate higher-level spatial variations from the transformed graph representations. Built on top of the abovementioned computational framework, we present a mind-controlled end-to-end system with integrated graphical interface, called {\it Brain2Object}. It enables an individual to print a physical replica on an object that she is observing by interpreting visually evoked EEG signals in a real-time manner. To enable the end-to-end workflow, the proposed system gathers the user's brain activities through EEG acquisition equipment and forwards the collected EEG data to a pre-trained model which automatically recognizes the object that the user is observing. Imagine that a child observes a toy, for example Pinkie Pie (from {\it My Little Pony}) belonging to her friend and likes it very much and wishes that she can have one too. Brain2Object can make her wish a reality by translating her brain signals to command the 3D printer to fabricate a copy. The ability to print a replica model of any observable object could be of tremendous value to a variety of professionals including engineers, artists, construction workers, students, teachers, law enforcement, urban planners, etc. By automating the process, {\it Brain2Object} takes mystery of reading human mind out of the realm of experts and opens up the possibility of a wide range of BCI applications that can be useful for the masses. To summarize, the paper makes the following key contributions: \begin{itemize} \item We present an end-to-end digital fabrication system, {\it Brain2Object}, atop of the precise decoding of human brain signals that allows an individual to instantly create a real-world replica (or model) of any object in her gaze. The proposed system could learn an illustration of an object seen by an individual from visually-evoked EEG signals, and print a model in real-time by automatically instructing a wireless connected 3D printer. \item We propose an effective EEG decoding model by learning a dynamical graph representation, which could adaptively embed structured EEG spatial correlations during the training process. A convolutional neural network is integrated for capturing discriminative feature representations as well as the intrinsic connections among the various EEG channels. \item The proposed approach is evaluated over a large scale benchmark dataset and a limited but locally collected dataset. Our method outperforms a wide range of baselines and state-of-the-art approaches in both instances, thus demonstrating the generalized nature of the approach. Finally, a prototype implementation demonstrates the practicality of {\it Brain2Object}. \end{itemize} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{system_overview.pdf} \caption{Brain2Object overview. The object (e.g., Pinkie Pie) observed by the user is reflected in the visually evoked EEG signals, which can be accurately recognized by the pre-trained recognition model. The recognition module employs multi-class CSP for separating the multivariate signals into additive subcomponents which have maximum differences. The spatial dependencies among processed data is extracted by DGR and then forwarded to the CNN for recognition. The schematic of the identified object is loaded from the model library of the 3D printer to fabricate a replica..} \label{fig:overview} \vspace{-3mm} \end{figure*} \section{The Proposed System} \label{sec:the_proposed_system} \subsection{System Overview} \label{sec:system_overview} The overall aim of {\it Brain2Object} is to automatically recognize the object that the user desires to fabricate by analyzing her visually-evoked brain signals and actuate a 3D printer accordingly. As shown in Figure~\ref{fig:overview}, the system is made up of an offline and online component. The offline component is aimed to build a robust and effective unified classification model which can recognize the specific object that the user is observing by analyzing the corresponding brain signals that are evoked during this process. For this purpose, we first record the EEG signals of individuals while they are observing a wide range of objects (the details will be introduced in Section~\ref{sec:data_acquisition}). Next, the gathered EEG data are analyzed using multi-class CSP \cite{ang2008filter} to extract the eigenvalues of various categories of objects. CSP has been widely used in EEG signal analysis (such as motor-imagery brain activity classification \cite{kang2014bayesian,wang2006common}) and achieves comparable performance. Thus, in our system, we adopt CSP for discriminative preprocessing. Through CSP, the EEG signals are mapping to an optimal space where the inter-category distance is maximized. Moreover, considering the global spatial relationship among EEG channels, we propose DGR to transform the CSP processed signals to a new space since graph representation has been shown to be helpful in refining and capturing spatial information \cite{song2018eeg}. In the embedded space which encompasses the topological structure among the biological brain neurons, each channel not only represents the amplitude of the measured signals but also reflects the dependency with other channels. CNNs are widely used for processing of two dimensional data in applications such as image recognition \cite{ciresan2011convolutional}, ubiquitous \cite{ning2018deepmag}, and object searching \cite{ren2017faster}, due to their salient features such as regularized structure, good spatial locality and translation invariance. Thus, we employ CNN as a classifier to distinguish the graph embedded features. After a number of training epochs, the converged classification model with stable weights is stored for online recognition. During online operation, the user wears an EEG signal acquisition equipment, while she is concentrating on a physical object, which collects her brain signals in real time. The gathered signals are forwarded to the pre-trained model which aims to recognize the object.. For example, as shown in Figure~\ref{fig:overview}, the user is focusing on `Pinkie Pie' instead of other ponies, the pre-trained model is empowered to automatically recognize the object and send an appropriate command to the 3D printer, which loads the 3D physical model and fabricates a copy. \subsection{Multi-class Common Spatial Filtering} \label{sub:common_spatial_pattern} CSP is widely used in BCI field to find spatial filters which can maximize variance between classes on which it is conditioned \cite{meisheri2018multiclass}. It has been successfully used for recognition of movement-related EEG \cite{ramoser2000optimal}. CSP was first introduced in binary classification problems but has since been extended to multi-class scenarios \cite{ang2012filter}. In this paper, we adopt the one-vs-others strategy for multi-class CSP analysis. Assume the gathered EEG data can be denoted by $\mathbb{E} = \{\bm{E}_i, i \in 1, 2, \cdots, N\}$ where $N$ denotes the number of samples and each sample $\bm{E}_i \in \mathbb{R}^{M \times L}$ where $M$ denotes the number of EEG channels and $L$ denotes the number of time slices. For example, assume the EEG collection equipment contains 64 channels and has a sampling frequency of 260 Hz, then data collected for 1 second can be represented by a 2-dimension matrix $\bm{E}_i \in \mathbb{R}^{64 \times 260}$ where each row denotes one channel and each column denotes one time slice. For each specific sample, we first calculate the covariance matrix as \cite{meisheri2018multiclass} $$\bm{C}_i = \frac{\bm{E}_i\bm{E}_i^T}{trace(\bm{E}_i\bm{E}_i^T)}$$ where $^T$ refers to the transpose operation and $trace()$ denotes the sum of the diagonal values in $\bm{E}_i$. The covariance matrix $\bm{C}_i$ presents the correlation between different columns (sampling points) in $\bm{E}_i$. In other words, $C_i$ captures the temporal dependencies in the EEG samples. Suppose there are overall $K \in \mathbb{R}$ categories correspond to the total number of objects for which EEG data is collected.For each category, the average covariance matrix is computed as $$\bar{\bm{C}}_k = \frac{1}{N_k}\sum_{i=1}^{N_k} \bm{C}_i$$ where $N_k$ denotes the number of distinct samples of the $k$-th category. The composite covariance matrix id defined by the sum of each category's covariance matrix \begin{equation}\label{eq:1} \bar{\bm{C}} = \sum_{k=1}^{K}\bar{\bm{C}}_k \end{equation} The eigen value $\bm{\lambda}$ and eigen vector $\bm{U}$ of $\bar{\bm{C}}$ can be deduced as \begin{equation}\label{eq:2} \bar{\bm{C}} = \bm{U}\bm{\lambda}\bm{U}^T \end{equation} In order to de-correlate the covariance matrix, we apply the whitening transformation on the eigen vector which is descendingly sorted by eigen values. The whitened matrix is calculated as $$\bm{S} = \bm{P} \bar{\bm{C}} \bm{P}^T$$ where $\bm{S}$ has unit diagonal covariance and $\bm{P}$ can be represented by $$\bm{P} = \sqrt{\bm{\lambda}^{-1}}\bm{U}$$ Based on Equation (\ref{eq:1}), we have $$\bm{S}_i = \sum_{k=1}^{K}\bm{P} \bar{\bm{C}_i} \bm{P}^T; \indent \bm{S} = \sum_{k=1}^{K}\bm{S}_i$$ Combining with the Equation (\ref{eq:2}), we have $$\bm{S}_i = \sum_{k=1}^{K}\bm{B} \bm{\lambda}_i \bm{B}^T$$ where $\bm{B} = \bm{P} \bm{U} $ can be regarded as the common eigen vector. Since $\bm{S}$ has unit diagonal covariance, $$\sum_{k=1}^{K}\bm{\lambda}_i = \bm{E}$$ where $ \bm{I}$ denotes the identity matrix. The main purpose of CSP is to maximize the distance among various categories in a transformed space, in other word, to optimize the equation \cite{parra2005recipes} \begin{equation}\label{eq:3} \bm{w}^* = \arg\max{\frac{\bm{w}\bm{S}_i\bm{w}^T}{\sum_{j\neq i}\bm{w}\bm{S}_j\bm{w}^T}} \end{equation} where $\bm{S}_j (j\neq i)$ denotes all other classes except class $i$ (one-vs-others). Equation (\ref{eq:3}) is in the form of Rayleigh quotient and the solution can be calculated by generalized eigenvalue \begin{equation}\label{eq:4} \bm{S}_i\bm{w} = \bm{\lambda}\sum_{j\neq i}\bm{S}_j\bm{w} \end{equation} The eigenvector of the above equation is the required transformation weights. All the EEG samples share the same weights $\bm{s}$. In case of the information loss, we employ the full eigenvectors. Generally, the EEG time series has more samples than the number of channels, i.e. $L>M$, thus the transformation weights have shape $[M, M]$ the processed sample can be described as $\bar{\bm{E}} = \bm{w}\bm{E}$ where $\bar{\bm{E}} \in \mathbb{R}^{M\times L}$. \begin{figure}[t] \centering \begin{subfigure}[t]{0.2\textwidth} \centering \includegraphics[width=\textwidth]{graph.pdf} \caption{Graph} \end{subfigure}% \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{adjacent.pdf} \caption{Adjacency matrix} \end{subfigure}% \caption{Example of a complete weighted undirected graph with 5 vertices and the corresponding adjacency matrix. The five vertices are reading from Frontal (F) and Temporal (T) lobes of human brain. The adjacency matrix is symmetric matrices, in which the colors denote the connection weights.} \label{fig:graph} \vspace{-3mm} \end{figure} \subsection{Dynamical Graph Representation} \label{sub:dynamical_graph_representation} In post-CSP processed EEG data $\bar{\bm{E}}$, each channel (row) separately provides the voltage amplitude of a specific electrode (e.g., the value of channel $F3$ reflects the amplitude of EEG electrode $F3$) instead of the aggregated spatial information. The signals are discrete and discontinuous in the spatial domain. Hence, traditional spatial feature representation methods such as CNN are not well suited for further processing \cite{song2018eeg}. Instead, we invoke the knowledge of the connections of the brain neurons to map $\bar{\bm{E}}$ to a new space where each element represents not only the specific channel amplitude but also the spatial relationship with its neighboring channels. For this purpose, we regard the brain network as a complete weighted undirected graph with $M$ vertices where each vertex denotes a channel. The term `complete' denotes each vertex is connected to all the residual vertices in this graph. The graph can be defined as $\mathcal{G} = \{\mathcal{V}, \mathcal{E}, \mathcal{A}\}$ where $\mathcal{V} \in \mathbb{R}^M$ denotes the set of vertex with the number of $|\mathcal{V}| = M$ and $\mathcal{E}$ denotes the set of edges connecting the vertices. Suppose $\mathcal{A} \ \in \mathbb{R}^{M\times M}$ denotes the adjacency matrix representing the connectivity within $\mathcal{V}$. In particular, the element in the $i$-th row and $j$-th column of the adjacency matrix measures the weight or importance of the edges between the $i$-th and the $j$-th vertices. The graph representation is dynamic, which means that the elements of the adjacency matrix are adaptively updated with the evolution of the model during training.. Hence, the name, Dynamic Graph Representation (DGR). Figure~\ref{fig:graph} illustrates an example of a complete weighted undirected graph which is composited by five vertices which are reading from Frontal (F) and Temporal (T) lobes of the human brain. The diagonal elements are zero since each vertex is not connected to itself. However, the proposed representation should also contain information representative of each individual vertex. To incorporate this information, we include an identity matrix I. The resulting DGR is thus represented as $$\bm{E}' = (\mathcal{A}+\bm{I})\bar{\bm{E}}$$ The represented data $\bm{E}'$ with shape $[M, L]$ can dynamically learn the intrinsic relationship between different EEG channels by training a neural network and thus benefit most from discriminative EEG feature extraction. \subsection{Convolutional Neural Networks} \label{sub:convolutional_neural_networks} The DGR representation of the EEG signals serves as input to a specified CNN structure for feature refining and classification. CNN could capture the distinctive dependencies among the patterns associated to different EEG categories. The designed CNN comprises of one convolutional layer followed by three fully-connected layers (as shown in Figure~\ref{fig:overview}). The convolutional layer contains a set of filters to convolve the EEG data followed by the nonlinear transformation to extract the geographical features. The input $\bm{E}'$ has shape $[M, L]$ with depth as $1$. We choose $D$ convolutional filters with size $[2,2]$ and stride size $[1, 1]$. The stride denotes the x-movements and y-movements distance of the filters. Same shape zero padding is used, which keeps the sample shape constant during the the convolution calculation. In the convolutional operation, the feature maps from the input layer are convolved with the learnable filters and fed to the activation function to generate the output feature map. For a specific convolutional area $\bm{x}$ which has the same shape as the filter, the convolutional operation can be described as $$\bm{x}' = tanh(\sum_{i}\sum_{j}\bm{f}_{ij}*\bm{x}_{ij})$$ where $\bm{x}'$ denotes the filtered results while $\bm{f}_{ij}$ denotes the $i$-th row and the $j$-th column element in the trainable filter. We adopt the widely used tanh activation function for nonlinearity. The depth of EEG sample transfers to $D$ through the convolutional layer and the sample shape is changed to $[M, L, D]$. The features learned from the filters are concatenated and flattened to $[1, M*L*D]$ and forwarded to the first fully-connected layer. Thus, the first fully connected layer has $M*L*D$ neurons, after which, the second and the third (the output layer) fully-connected layers have $D'$ and $K$ neurons, respectively. The operation between the fully-connected layers can be represented by $$\bm{E^{h+1}} = softmax(\bar{\bm{w}}\bm{E^{h}} + \bar{\bm{b}})$$ where $h$ denotes the $h$-th layer and $\bar{\bm{w}}$, $\bar{\bm{b}}$ denote the corresponding weights matrix and biases. The softmax function is used for activation. For each EEG sample, the corresponding label information is presented by one-hot label $\bm{y} \in \mathbb{R}^K$. The error between the predicted results and the ground truth is evaluated by cross-entropy $$loss = - \sum_{k=1}^{K}\bm{y}_klog(p_k)$$ where $p_k$ denotes the predicted probability of observation of an object belonging to category $k$. The calculated error is optimized by the AdamOptimizer algorithm. To minimize the possibility of overfitting, we the dropout strategy and set the drop rate to 50\%. \begin{figure}[t] \centering \includegraphics[width=0.35\textwidth]{experiment.pdf} \caption{Data acquisition experiment. The participant wears the EPOC+ Emotiv headset with 14 channels siting in front of a monitor which shows the Pinkie Pie. } \label{fig:experiment} \vspace{-3mm} \end{figure} \section{Data Acquisition} \label{sec:data_acquisition} In this section, we aim to gather a local EEG dataset which reflects the user's brain voltage fluctuation under visual stimulation of a number of object images. In the ideal environment, the system is expected to recognize the EEG pattern of a random image. However, as this is a first exploration of this idea, we limit our study to include images of 4 objects: a car, a boat, Pinkie Pie Pony and Mario (from the video game). We recruit 8 healthy participants (aged 22-27 years) including 5 males and 3 females to participate this study. The data collection is conducted in a quiet room. As shown in Figure~\ref{fig:experiment}, the subject wears the EPOC+ Emotiv EEG headset which contains 14 channels corresponding to the 10-20 system (which is an internationally recognized method to describe and apply the location of scalp electrodes). The sampling rate is set as 128 Hz and the headset can wireless connection with the computer over Bluetooth. The participants sit in a comfortable armchair, maintain a relaxed composure and gaze at a monitor placed approximately 0.5 meters in front of them. Each subject participates in 10 sessions and each session contains 4 trials. Each trial lasts for 15 seconds and is comprised of three phases, each lasting 5 seconds. In the first phase, the monitor shows an empty slide and the subject is asked to be relaxed. In the second phase, a random object picture is presented in the middle of the screen and the subject is instructed to focus on the projected image. The final phase is identical to the first phase. Naturally, only EEF signals collected during the second phase are used in our dataset. In the second phase, the image is chosen with equal probability from the 4 aforementioned images. To keep the balance of the dataset, the final EEG data of each specific participant is composed of 40 trials where each object appears 10 times. For each subject, there are 40 trials where each trial lasts for 5 seconds. Hence, each participant contributes 200 seconds of EEG signals. Since the sampling rate is 128 Hz, each subject contributes $25,600 = 128\times 200$ sampling points, which means the dataset has $204,800 $ sampling points in total. \section{Experiments} \label{sec:experiments} \subsection{Datasets} \label{sub:datasets} In Section~\ref{sec:data_acquisition}, we introduced data acquisition experiments that were conducted locally in our lab. However, this local dataset has several drawbacks: 1) the spatial and temporal resolution is limited, since the headset used only has 14 channels and a low sampling frequency of 128 Hz.; 2) the fidelity (measured by the signal to noise ratio) of the signals is low as the resolution of recording the voltage is $0.51V$, which is significantly lower than more sophisticated devices such as those used for medical studies (e.g., BCI2000); 3) the limited (8) number of participants in our dataset. A dataset containing a wider population of subjects is necessary for effective evaluations. Therefore, in addition to the local dataset which is referred to as EEG-L in the rest of the paper, we utilize a rich widely used public dataset, which is named EEG-P. The EEG-P (eegmmidb\footnote{\url{https://www.physionet.org/pn4/eegmmidb/}}) is collected by the BCI200 EEG system which records the brain signals using 64 channels with a sampling rate of 160Hz. EEG data is recorded while the subjects are provided a visual stimuli (on a monitor) of certain actions and asked to imagine performing those actions. The four actions (left hand, right hand, both hands, and both feet) are labelled from 1 to 4. In our dataset, the 560,000 samples belonging to 4 different labels and 20 subjects are selected with each subject having 28,000 samples. In EEG-L, the four objects (Mario, car, boat, and Pinkie Pie pony) are labelled as 1, 2, 3, 4, correspondingly. Both datasets are further sub-divided into a training set and testing set. The former comprises 80\% of the data, while the latter contains the remaining 20\%. The training set is split into 4 equal mini-batches (i.e., each mini-batch has 20\% of the data). All the features are normalized by z-score method. The normalization parameters are noted for use during the online phase. The segmentation time window is set to 64 and 16 for EEG-P and EEG-L, respectively. The rate of overlap is 50\% for both datasets. \begin{table}[] \centering \caption{Overall comparison with state-of-the-art models and } \label{tab:overall_comparison} \resizebox{0.5\textwidth}{!}{ \begin{tabular}{llllll} \hline \textbf{Dataset} & \textbf{Method} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{F-1} \\ \hline \multirow{11}{*}{\textbf{EEG-P}} & \textbf{KNN} & 0.6962 & 0.7325 & 0.7552 & 0.7437 \\ & \textbf{RF} & 0.7137 & 0.7536 & 0.7328 & 0.7431 \\ & \textbf{SVM} & 0.6692 & 0.7122 & 0.7156 & 0.7139 \\ & \textbf{CSP+KNN} & 0.9134 & 0.9273 & 0.9135 & 0.9203 \\ & \textbf{CNN} & 0.8638 & 0.8619 & 0.8722 & 0.8670 \\ & \textbf{\cite{sturm2016interpretable}} & 0.8327 &0.8556& 0.8559& 0.8557 \\ & \textbf{\cite{yang2015use}} & 0.8631 &0.8725 &0.8669 &0.8697 \\ & \textbf{\cite{park2014augmented}} & 0.8915 &0.9013 &0.9125 &0.9069\\ & \textbf{\cite{thomas2017eeg}} & 0.7986 &0.8031& 0.8219& 0.8124\\ &\textbf{\cite{zhang2018converting}} &0.8325&0.8261& 0.8433 &0.8346\\ & \textbf{Ours} & \textbf{0.9258} & \textbf{0.9325} & \textbf{0.925} & \textbf{0.9287} \\ \hline \multirow{11}{*}{\textbf{EEG-L}} & \textbf{KNN} & 0.5108 & 0.5212 & 0.5436 & 0.5322 \\ & \textbf{RF} & 0.5826 & 0.6258 & 0.6246 & 0.6252 \\ & \textbf{SVM} & 0.6538 & 0.6684 & 0.6825 & 0.6754 \\ & \textbf{CSP+KNN} & 0.5833 & 0.5773 & 0.5833 & 0.5803 \\ & \textbf{CNN} & 0.6863 & 0.7021 & 0.6038 & 0.6493 \\ & \textbf{\cite{sturm2016interpretable}} & 0.6988 &0.7021 &0.7086& 0.7053 \\ & \textbf{\cite{yang2015use}} & 0.5832& 0.5968 &0.6013 &0.5990 \\ & \textbf{\cite{park2014augmented}} & 0.6892 &0.6995 &0.7021& 0.7008 \\ & \textbf{\cite{thomas2017eeg}} & 0.6679& 0.6759 &0.6821 &0.6790 \\ &\textbf{\cite{zhang2018converting}} &0.6731 &0.6889 &0.6921 &0.6905 \\ & \textbf{Ours} & \textbf{0.7523} & \textbf{0.7602} & \textbf{0.7528} & \textbf{0.7564} \\ \hline \end{tabular} } \end{table} \begin{figure*}[t] \centering \begin{subfigure}[t]{0.21\textwidth} \centering \includegraphics[width=\textwidth]{EEG_P_cm-eps-converted-to.pdf} \caption{EEG-P confusion matrix} \end{subfigure}% \begin{subfigure}[t]{0.21\textwidth} \centering \includegraphics[width=\textwidth]{EEG_L_cm-eps-converted-to.pdf} \caption{EEG-L confusion matrix} \end{subfigure}% \begin{subfigure}[t]{0.28\textwidth} \centering \includegraphics[width=\textwidth]{EEG_P_roc_-eps-converted-to.pdf} \caption{EEG-P ROC and AUC} \end{subfigure}% \begin{subfigure}[t]{0.28\textwidth} \centering \includegraphics[width=\textwidth]{EEG_L_roc_-eps-converted-to.pdf} \caption{EEG-L ROC and AUC} \end{subfigure}% \caption{Confusion matrix and ROC curves with AUC score. The ROC curve of EEG-P has log scaled x-axis.} \label{fig:cm_roc} \vspace{-3mm} \end{figure*} \subsection{Overall Comparison} \label{sub:overall_comparison} Next, we report the performance of Brain2Object. Recall the adopted classification method combines the multi-class CSP and the convolutional neural networks. All the experiments are run on the Titan X (Pascal) GPU and accuracy results presented are averaged over 5 runs. First, we provide the overall comparison with several widely used baselines including KNN, Random Forest (RF), Support Vector Machine (SVM). The key parameters of the baselines are listed here: KNN with 3 nearest neighbors; SVM with RBF kernel; RF with 50 trees. The independent CNN has the identical structure of the CNN component in our system as introduced in Section~\ref{sub:convolutional_neural_networks}. The kernel and stride information have been provided above, the learning rate is set as 0.0005 and the depth of convolutional layer $D$ equals to 10. The number of hidden neurons in the second fully-connected layer is 1000 for EEG-P and 120 for EEG-L. All the parameters are determined by empirical tuning. We also compare with a range of competitive state-of-the-art models: \begin{itemize} \item Sturm et al. \cite{sturm2016interpretable} proposes the application of Deep Neural Networks with layer-wise relevance propagation for EEG data analysis. \item Yang et al. \cite{yang2015use} combines augmented CSP with CNNs for motor imagery performance recognition. \item Park et al. \cite{park2014augmented} introduces an augmented complex-valued CSP based on the correlation between EEG channels. \item Thomas et al. \cite{thomas2017eeg} study EEG classification by selecting the subject-specific spatial and spectral features. \item Zhang et al. \cite{zhang2018converting} combines Recurrent Neural Networks (RNNs) with CNN in order to extract the temporal-spatial features from brain signals. \end{itemize} The results are depicted in Table~\ref{tab:overall_comparison}. Observe that our method achieves the highest accuracy (which corresponds to 0.9258 for EEG-P and 0.7523 for EEG-L) in comparison with numerous state-of-the-art approaches for both datasets. The experiments thus demonstrate the robustness, effectiveness and generality of our method. One can also readily observe that all methods achieve lower accuracy for EEG-L and as compared to EEG-P. Some of the drawbacks of EEG-L were already highlighted in Section~\ref{sub:datasets} including low fidelity, poor spatial-temporal coverage and equipment limitations. Another reason could be the fact that our participants did not have extensive experience with the usage of EEG headsets and neither were there any specialized technicians available to assist. Finally, the emotional state of the participants may have also influenced the EEG signals. We present a range of additional metrics for our approach. This includes the confusion matrix and ROC curves with AUC scores in Figure~\ref{fig:cm_roc} and precision, recall and F-1 score for each category in Table~\ref{tab:report}. \begin{table}[] \centering \caption{Classification report including precision, recall, and F-1 score } \label{tab:report} \resizebox{0.4\textwidth}{!}{ \begin{tabular}{l|l|llll} \hline \multirow{2}{*}{\textbf{Dataset}} & \multirow{2}{*}{\textbf{Metrics}} & \multicolumn{4}{c}{\textbf{Category}} \\ \cline{3-6} & & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} \\ \hline \multirow{3}{*}{\textbf{EEG-P}} & \textbf{Precision} & 0.88 & 1 & 1 & 0.85 \\ & \textbf{Recall} & 0.89 & 0.97 & 0.84 & 1 \\ & \textbf{F-1} & 0.88 & 0.98 & 0.92 & 0.92 \\ \hline \multirow{3}{*}{\textbf{EEG-L}} & \textbf{Precision} & 0.77 & 0.77 & 0.66 & 0.84 \\ & \textbf{Recall} & 0.82 & 0.79 & 0.77 & 0.63 \\ & \textbf{F-1} & 0.8 & 0.78 & 0.71 & 0.72 \\ \hline \end{tabular} } \end{table} \begin{figure}[t] \centering \includegraphics[width=0.4\textwidth]{latency-eps-converted-to.pdf} \caption{Latency comparison against the accuracy. It can be observed that our approach achieves the highest accuracy with an acceptable latency. } \label{fig:latency} \vspace{-3mm} \end{figure} \begin{figure}[t] \centering \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{visual_EEG_P_original-eps-converted-to.pdf} \caption{EEG-P raw data} \end{subfigure}% \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{visual_EEG_P_feature-eps-converted-to.pdf} \caption{EEG-P feature} \end{subfigure}% \vspace{5mm} \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{visual_EEG_L_original-eps-converted-to.pdf} \caption{EEG-L raw data} \end{subfigure}% \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{visual_EEG_L_feature-eps-converted-to.pdf} \caption{EEG-L feature} \end{subfigure}% \caption{A visualization comparing the raw data and extracted features for the two datasets. Both the raw data and the extracted feature are visualized from the corresponding testing set. This comparison demonstrates that our approach can (i) maximize the distance between the EEG data points and (ii) accurately extract the distinctive representations from the raw data.} \label{fig:visualization} \vspace{-3mm} \end{figure} \subsection{Latency} \label{sub:latency} In addition to accuracy, latency is also an important performance metric for a system such as Brain2Object. Figure~\ref{fig:latency} illustrates the latency achieved by our method in comparison with a selected sub-set of baselines used in Section~\ref{sub:overall_comparison}. We can observe that our approach has competitive latency compared with other methods while achieving the highest accuracy. The overall latency is less than 0.5 second. We computed the latency incurred by the different methods that are employed in our system and observed that CNN requires about 0.35 seconds for execution, while CSP and DGR together only require about 0.12 seconds. This illustrates that the use of deep learning techniques do not have a significant effect on the overall latency. In a fully functional system, the end-to-end latency is not only comprised of the algorithmic latency but also includes the delay incurred for signal acquisition and signal transmission. The latter will be discussed in Section~\ref{sec:online_demonstration}. In the following, we evaluate the signal acquisition latency. In the proposed system, the signal collection time is related to the acquisition equipment, in essential, the sampling rate. For BCI2000, a single sample/segment is composed of 64 time points, which is gathered in $0.4 = 64/160$ seconds with 160 Hz sampling frequency. On the other hand, the Epoc+ Emotiv headset only requires $ 0.11= 14/128$ seconds for signal collection. We can observe that the precise equipment can achieve higher accuracy but demand larger latency. In contrast, the off-the-shelf low fidelity headset has lower accuracy but also low latency. But this statement, which is similar to `no free lunch' rule, is based on the fact that our segment length equals the channel number. Could EEG-P keep the high level accuracy with the decrease of channel amount in order to implement competitive performance with low latency at the same time? This meaningful scope deserves more attention in the future. \subsection{Visualization} \label{sub:visualization} To offer a different perspective into the performance of our system, we present a visualization of the data at two levels. At the system level, as a unified classification model, we visualize the raw EEG data and the extracted distinguishable features for comparison. In Figure~\ref{fig:visualization}, the visualization of both EEG-P and EEG-L are presented. Through the comparison, we can demonstrate that our approach maximizes the distance among EEG signals and has the ability to automatic extract the distinctive representations from raw data. At the component level, we present the topography of various categories in each dataset. Figure~\ref{fig:topo} provides the EEG topographies after CSP processing. The first row represents the EEG-P dataset with 64 channels while the second row represents the EEG-L dataset with 14 channels. The channel names and positions strictly obey the international 10-20 system. Through the comparison, it can be observed that the patterns belong to different categories are obviously varying. This suggests that the CSP processed features ought to be classified easily. \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{topo.pdf} \caption{Topography after CSP processing. Each topography in the first row contains 64 channels while the second row map contains 14 channels. Through the comparison, it can be observed that the patterns belong to different categories are obviously variant, which indicates that the CSP processed features ought to be easier classified. } \label{fig:topo} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{online_scenario.pdf} \caption{Online testing scenario. The user's EEG signals are collected by Emotiv headset for recognition. The correspond object will be printed through the 3D printer.} \label{fig:online_scenario} \vspace{-3mm} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{GUI.png} \caption{User Interface. } \label{fig:GUI} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{online_workflow.pdf} \caption{Online workflow of {\it Brain2Object}. The user's EEG signals are collected and send to the server through client 1. The server loads the pre-trained model to recognize the target object and send to both the interface for showing the user feedback and the 3D printer for printing. The solid line denotes signal transmission while the slash line denotes feedback.} \label{fig:online_workflow} \vspace{-3mm} \end{figure} \section{Online Demonstration} \label{sec:online_demonstration} In this section, we summarize our experience in developing a working prototype of Brain2Object. Figure~\ref{fig:online_scenario} shows the working prototype in action. A video demonstration can be accessed through this site\footnote{\url{https://drive.google.com/open?id=1jzZzKkWWGhBkFJTaAgVZ5zKSnd4Ho5DD}}. The graphical user interface is provided in Figure~\ref{fig:GUI}. The top of the interface shows the port number and baud rate of the IP printer. The IP address of the server which stores the pre-trained model and makes the object recognition decision is also shown. The main body of the interface displays object models for the four objects in our experiments, namely, Mario, car, boat and Pinkie Pie Pony. Figure~\ref{fig:online_workflow} illustrates the operational workflow of the Brain2Object demonstrator. While the user is focusing on a target object (e.g., the Pinkie Pie), the corresponding brain signals are collected by a properly mounted Emotiv headset and transmitted to client 1 over Bluetooth. Client 1 sends the EEG signal to the server over a TCP connection. The server loads the pre-trained EEG recognition model and classifies the EEG signal to one of the four categories. The classification result is forwarded to the interface through client 2. The interface will highlight the selected object by changing the color of the other 3 objects to gray (the selected object remains blue). Simultaneously, the selected object is dispatched to the printer driver which generates the corresponding Gcode which can be recognized by the mechanical 3D printer. Finally, the Gcode is sent to the 3D printer, which brings the object to life. We used a Tonxy X1 desktop 3D with the following specifications. Printer size:$220\times 220 \times 250 mm$, build area: $150\times 150 \times 150 mm$, MK10 extruder diameter: 1.75mm, nozzle diameter: 0.4mm, engraving accuracy: 0.1mm, filament material: 1.75mm polylactic acid (PLA). The physical 3D model can be transmitted from a computer to the printer or directly stored in minor SD card mounted on the printer. The sampling frequency of the Emotiv headset is 128 Hz which indicates it can collect 128 sampling point each second. The pre-trained recognition model requires each sample with 14 sampling point and each sampling point corresponds to a classification output. To achieve steadiness and reliability, the server will maintains a window of the last 10 classification output and a count of how many times each of the 4 objects has been recognized. The server will send the target to the client 2 only if one specific target appears more than 6 times in this window. In this situation, the classification is higher than 90\% although the latency is increased to about 2 sec which includes data collection time (1.1 sec), recognition time (0.47 sec), transmission time, etc. \section{Discussion and Future Work} \label{sec:discussion_and_future_work} In this section, we discuss the challenges and potential directions for future research. First, the proposed approach is significantly influenced by the quality of the EEG data. The pre-trained model shows better performance on the clean and precise public dataset than on our local dataset. This suggests the need to develop novel classification methods that are robust to noisy and low resolution EEG signals. Another concern is the adaptability over different EEG acquisition equipment. Ideally, it is highly desirable that the model can consistently achieve accurate performance across a range of hardware platforms. However, the popular platforms (e.g., Emotiv, NeuroSky, OpenBCI) have different characteristics like sampling resolution, number of channels, positioning of channels on the scalp, , etc. Thus, there is still innovation required to develop robust and adaptive brain signal classification algorithms. Second, the object repository in this work is limited. An ideal instantiation of Brain2Object should recognize any object the user observed. However, in this paper, the object repository only contains four items . The limitation of the repository scale is constrained by the learning algorithm, i.e., the ability of multi-class classification algorithms to discriminate between a large number of classes.. The classification accuracy dramatically reduces with the increase of category numbers. In our pre-experiment which are not presented in this paper for the space limitation, in the offline test, the proposed approach can achieve around 90\% on binary classification using the Emotiv headset, however, the accuracy drops to nears 80\% with three categories and about 70\% with 4 objects. In our future work, we attempt to propose an algorithm to increase the multi-class classification performance. Additionally, the ideal printing system is supposed to automatically detects the object which the subject `thinking' (without visual stimulation) instead of `observing' (with visual stimulation). however, the EEG SNR without visual stimulation is much lower than the SNR with visual stimulation. To enhance the SNR and help the subject to concentrate on the object, we adopt visual stimuli in our experiments. Therefore, in the local dataset and the online demonstration phase, the corresponding object images are shown on the monitor to remind the participants. However, the public dataset not only contains visual stimuli but also includes motor imagery, which is one possible reason why EEG-P is classified so accurately. Most of the existing public EEG dataset with visual stimulation focus on motor imagery (like the selected EEG-P) or evoked potentials \cite{odom2010iscev}. In the latter instance, the visual images are flashed at a high frequency which results in pulsed EEG data, i.e. as objects flash by, short pulses of corresponding EEG data are generated. However, the model used in this paper is based on stable EEG signal caused by steady stimuli. Hence, we select EEG-P instead of evoked potential-based dataset for the evaluation. Furthermore, through the online demonstration experiment, we observed that the online performance is lower than the off-line analysis, which could be attributed to a number of reasons: 1) the user’s mental state and fluctuations in emotions may affect the quality of the EEG signals. For instance, if the pre-trained model is tuned based on the EEG data which is collected when the user is relaxed, the classification performance may be affected while the user is excited in the online phase. 2) the conductive of the electrodes in headset is not exactly invariant during the off-line stage and online stage, which will have impact on the data quality; 3) subtle variations (e.g., the position of each of the electrodes) in the way the EEG headset is mounted on the subject’s head may also influent online decision making; 4) subjects often have difficulty in maintaining concentration during signal acquisition. \section{Related Work} \label{sec:related_work} The problem of accurately classifying EEG signals has been extensively researched in recent years \cite{michelmann2018data,li2015autoregressive,zhang2017classification,liu2017multi,li2015feature,lin2016classification,acharya2018deep,ma2015resting,lawhern2016eegnet,li2017emotion}. Michelmann et al. \cite{michelmann2018data} use Independent Component Analysis to derive filter coefficients that reflect the statistical dependencies of the data at hand. This work quantitatively shows that ICA outperforms the bipolar referencing operation in sensitivity and importantly in specificity when revealing local time series from the superposition of neighboring channels. Liu et al. \cite{liu2017multi} propose a multi-layer RNN based model with two attention mechanisms, which achieves high accuracy and boosts the computational efficiency of EEG signal classification. Zhang et al. \cite{zhang2017classification} present two combination strategies of feature extraction on EEG signals where the first strategy assembles the autoregressive coefficients and approximate entropy and the second strategy adopts wavelet packet decomposition. Among the existing studies, the spatial feature based algorithms had been illustrated to be one of the most promising methods. In particular, CNN, as one of the most popular and powerful deep learning structures, had been widely used to cope with various EEG-based applications. Acharya et al. \cite{acharya2018deep} employ a standard CNN to analyze patients' brain signals in order to detect normal, preictal, and the seizure state. Ma et al. \cite{ma2015resting} apply CNN to automatically extract an individual's best and most unique neural features and conduct classification, using EEG data derived from both resting states with open eyes and resting state with closed eyes, for the aim of individual identification. Lawhern et al. \cite{lawhern2016eegnet} introduce the use of depth-wise and separable convolutions to construct an EEG-specific model which encapsulates well-known EEG feature extraction concepts for BCI. Zhang et al. \cite{zhang2018converting} exploit the temporal-spatial information extracted by a combined RNN and CNN, however, this work is based on single sample classification which causes the unstable performance in online stage. \section{Conclusion} \label{sec:conclusion} In this paper, we propose an end-to-end printing system based on the combination of multi-class CSP and graph embedded CNN. The performance of the proposed model is evaluated over two datasets in off-line and also demonstrated in the online environment. {\it Brain2Object} serves as a harbinger for exciting BCI applications which can help individuals with various tasks in their daily lives. The proposed system employs multi-class CSP to map the EEG data to a common space for the aim of maximizing the distance among various EEG patterns. The processed data are embedded by dynamic graph transformation and then fed into a designed convolutional neural network for automatically spatial feature learning. Extensive evaluations using a large-scale public dataset and a more relevant but limited local dataset showed that our scheme significantly outperforms a number of state-of-the-art approaches. The system latency is shown to be acceptable and a visualization of the signals is presented to offer additional perspectives into the performance. The online demonstration is presented to show the applicability of the proposed system. \newpage
{'timestamp': '2018-10-05T02:11:57', 'yymm': '1810', 'arxiv_id': '1810.02223', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02223'}
arxiv
\section{Introduction} \label{sec:introduction} In multivariate analysis, one of the fundamental inferential problems is to test a hypothesis involving a linear transformation of regression coefficients under a linear model. Suppose $\mathbf{Y}$ is a $p\times N$ matrix of observations modeled as \begin{align} \label{eq:linear_model} \mathbf{Y} &= BX + \Sigma_p^{1/2}\mathbf{{Z}}~, \end{align} where ~(i)~ $B$ is a $p\times k$ matrix of regression coefficients; ~(ii)~ $X$ is a $k\times N$ design matrix of rank $k$; ~(iii)~$\mathbf{{Z}}$ is a $p\times N$ matrix with i.i.d.\ entries having zero mean and unit variance; and ~(iv)~ $\Sigma_p$, a $p\times p$ nonnegative definite matrix, is the population covariance matrix of the errors, with $\Sigma_p^{1/2}$ a ``square-root'' of $\Sigma_p$ so that $\Sigma_p= \Sigma_p^{1/2}(\Sigma_p^{1/2})^T$. General linear hypotheses involving the linear model (\ref{eq:linear_model}) are of the form \begin{equation} \label{eq:general_linear_hypothesis} H_0\colon BC=0 \qquad \mbox{vs.} \qquad H_a\colon BC\neq0, \end{equation} for an arbitrary $k\times q$ ``constraints matrix'' $C$, subject to the requirement that $BC$ is estimable. Without loss of generality, $C$ is taken to be of rank $q$. Throughout, we assume that $q$ and $k$ are fixed, even as observation dimension $p$ and sample size $N$ increase to infinity. Henceforth, $n = N-k$ is used to denote the effective sample size, which is also the degree of freedom associated with the sample error covariance matrix. With various choices of $X$ and $C$, the testing formulation incorporates many hypotheses of interest. For example, multivariate analysis of variance (MANOVA) is a special case. When the sample size $N$ is substantially larger than the dimension $p$ of the observations, this problem is well-studied. \citet{anderson1958introduction} and \citet{muirhead2009aspects} are among standard references. Various classical inferential procedures involve the matrices \begin{align} \widehat{\bm\Sigma}_p =& \frac{1}{n} \mathbf{Y}(I- X^T (XX^T)^{-1} X ) \mathbf{Y}^T, \label{eq:Sigma_hat}\\ \widehat{\mathbf{H}}_p =& \frac{1}{n} \mathbf{Y} X^T(XX^T)^{-1} C[C^T(XX^T)^{-1}C]^{-1}C^T (XX^T)^{-1} X\mathbf{Y}^T, \label{eq:H_hat} \end{align} so that $\widehat{\bm\Sigma}_p$ is the residual covariance of the full model, an estimator of $\Sigma_p$, while $\widehat{\mathbf{H}}_p$ is the hypothesis sums of squares and cross products matrix, scaled by $n^{-1}$. In a one-way MANOVA set-up, $\widehat{\bm\Sigma}_p$ and $\widehat{\mathbf{H}}_p$ are, respectively, the within-group and between-group sums of squares and products matrices, scaled by $n^{-1}$. In the rest of the paper, we shall refer to $\widehat{\bm\Sigma}_p$ as the sample covariance matrix. The testing problem (\ref{eq:general_linear_hypothesis}) is well-studied in the classical multivariate analysis literature. Three standard test procedures are the likelihood ratio test (LR), Lawley--Hotelling trace test (LH) and Bartlett--Nanda--Pillai trace (BNP) test. They are called \emph{invariant tests}, since under Gaussianity the null distributions of the test statistics are invariant with respect to $\Sigma_p$. One common feature is that all test statistics are linear functionals of the spectrum of $\widehat{\mathbf{H}}_p\widehat{\bm\Sigma}_p^{-1}$. Since this matrix is asymmetric, for convenience, a standard transformation is applied, giving the expressions of the invariant tests as follows. Define \begin{align} Q_n &= X^T(XX^T)^{-1} C[C^T(XX^T)^{-1}C]^{-1/2}\label{eq:Q},\\ \mathbf{M}_0 &= \frac{1}{n} Q^T_n \mathbf{Y}^T \widehat{\bm\Sigma}_p^{-1} \mathbf{Y} Q_n. \nonumber \end{align} The matrix $Q_nQ_n^T$ is the ``hat matrix'' of the reduced model under the null hypothesis. Note that the non-zero eigenvalues of $\widehat{\mathbf{H}}_p\widehat{\bm\Sigma}_p^{-1} = n^{-1}\mathbf{Y} Q_nQ_n^T \mathbf{Y}^T \widehat{\bm\Sigma}_p^{-1}$ are the same as those of $\mathbf{M}_0$. The test statistics for the LR, LH and BNP tests can be expressed as \begin{align*} &T_0^{\rm LR} = \sum\nolimits_{i=1}^q \log\{1+\lambda_i(\mathbf{M}_0)\}, \\ &T_0^{\rm LH} = \sum\nolimits_{i=1}^q \lambda_i(\mathbf{M}_0), \\ &T_0^{\rm BNP} = \sum\nolimits_{i=1}^q \lambda_i(\mathbf{M}_0)/\{1+\lambda_i(\mathbf{M}_0)\}. \end{align*} The symbol $\lambda_i(\cdot)$ denotes the $i$-th largest eigenvalue of a symmetric matrix, further using the convention that $\lambda_{\max}(\cdot)$ and $\lambda_{\min}(\cdot )$ indicate the largest and smallest eigenvalue. In contemporary statistical research and applications, high-dimensional data whose dimension is at least comparable to the sample size is ubiquitous. In this paper, focus is on the interesting boundary case when dimension and sample sizes are comparable. Primarily due to inconsistency of conventional estimators of model parameters --- such as $\widehat{\bm\Sigma}_p$ ---, classical test procedures for the hypothesis \eqref{eq:general_linear_hypothesis} --- such as the LR, LH and BNP tests --- perform poorly in such settings. When the dimension $p$ is larger than the degree of freedom $n$, the invariant tests are not even well-defined because $\widehat{\bm\Sigma}_p$ is singular. Even when $p$ is strictly less than $n$, but the ratio $\gamma_n = p/n$ is close to $1$, these tests are known to have poor power behavior. Asymptotic results when $\gamma_n\to \gamma \in(0,1)$ were obtained in \citet{fujikoshi2004asymptotic} under Gaussianity of the populations, and more recently in \citet{bai2017limiting} under more general settings that only require the existence of certain moments. Pioneering work on modifying the classical solutions in high dimension is in \citet{bai2013testing}, who corrected the scaling of the LR statistic when $n\geq p$ but $p$, $k$ and $q$ are proportional to $n$. The corrected LR statistic was shown to have significantly more power than its classical counterpart. In contrast, in this paper, we focus on the setting where $k$ and $q$ are fixed even as $n,p \to \infty$ so that $\gamma_n=p/n\to \gamma\in(0,\infty)$. In the multivariate regression problem, this corresponds to a situation where the response is high-dimensional, while the predictor is finite-dimensional. In the MANOVA problem, this framework corresponds to high-dimensional observations belonging to one of a finite number of populations. To the best of our knowledge, when $n<p$, the linear hypothesis testing problem has been studied in depth only for specific submodels of \eqref{eq:linear_model}, primarily for the important case of two-sample tests for equality of population means. For the latter tests, a widely used idea is to construct modified statistics based on replacing $\widehat{\bm\Sigma}_p^{-1}$ with an appropriate substitute. This approach was pioneered in \citet{bai1996effect} and further developed in \citet{chen2010two}. Various extensions to one-way MANOVA \citep{srivastava2006multivariate, yamada2015testing, srivastava2006multivariate, hu2017testing} and a general multi-sample Behrens--Fisher problem under heteroscedasticity \citep{zhou2017high} exist. Other notable works for the two-sample problem include \citet{biswas2014nonparametric, chang2017simulation,chen2014two,guo2016tests,lopes2011more,srivastava2016raptt,wang2015high}. A second approach aims to regularize $\widehat{\bm\Sigma}_p$ to address the issue of its near-singularity in high dimensions; see \citet{chen2011regularized} and \citet{LiAuePaulPengWang} for ridge-type penalties in two-sample settings. Finally, another alternative line of attack consists of exploiting sparsity; see \citet{tony2014two, cai2014high}. In this paper, we seek to regularize the spectrum of $\widehat{\bm\Sigma}_p$ by flexible shrinkage functions. For a symmetric $p\times p$ matrix $A$ and a function $g(\cdot)$ on $\mathbb{R}$, define \[ g(A) = R_A \mbox{diag}\big(g(\lambda_1(A)),\dots, g(\lambda_p(A)) \big) R_A^T, \] where $R_A$ is the matrix of eigenvectors associated with the ordered eigenvalues of $A$. Now, consider any real-valued function $f(\cdot)$ on $\mathbb{R}$ that is analytic over a specific domain associated with the limiting behavior of the eigenvalues of $\widehat{\bm\Sigma}_p$, as elaborated in Section \ref{sec:methodology}. The proposed statistics are functionals of eigenvalues of the regularized quadratic forms \[\mathbf{M}(f) = \frac{1}{n} Q_n^T \mathbf{Y}^T f(\widehat{\bm\Sigma}_p) \mathbf{Y} Q_n.\] Specifically, we propose regularized versions of LR, LH and BNP test criteria, namely \begin{align*} T^{\rm LR}(f) &= \sum\nolimits_{i=1}^q \log\{1+\lambda_i(\mathbf{M}(f))\},\\ T^{\rm LH}(f) &= \sum\nolimits_{i=1}^q \lambda_i(\mathbf{M}(f)),\\ T^{\rm BNP}(f)&= \sum\nolimits_{i=1}^q \lambda_i(\mathbf{M}(f))/\{1+\lambda_i(\mathbf{M}(f))\}. \end{align*} These test statistics are designed to capture possible departures from the null hypothesis, when $\widehat{\bm\Sigma}_p$ is replaced by $f(\widehat{\bm\Sigma}_p)$, while suitable choices of the regularizer $f$ allow for getting around the problem of singularity or near-singularity when $p$ is comparable to $n$. Notice that $\mathbf{M}(f)$ has the same non-zero eigenvalues as $f(\widehat{\bm\Sigma}_p)\widehat{\mathbf{H}}_p$. Thus, the proposed test family is a generalization of the classical statistics based on $\widehat{\bm\Sigma}_p^{-1} \widehat{\mathbf{H}}_p$. Importantly, $\mathbf{M}(f)$ --- and consequently the proposed statistics --- is \emph{rotation-invariant}, which means if a linear transformation is applied to the observations with an arbitrary orthogonal matrix, the statistic remains unchanged. It is a desirable property when not much additional knowledge about $\Sigma_p$ and $BC$ is available. It should be noted that the two-sample mean tests by \citet{bai1996effect} and \citet{LiAuePaulPengWang}, together with their generalization to MANOVA, are special cases of the proposed family with $f(x) = 1$ and $f(x) = 1/(x+\lambda)$, $\lambda>0$, respectively. The present work builds on the work by \citet{LiAuePaulPengWang}. The theoretical analysis also involves an extension of the analytical framework adopted by \citet{pan2011central} in their study of the asymptotic behavior of Hotelling's $T^2$ statistic for non-Gaussian observations. However, the current work goes well beyond the existing literature in several aspects. We highlight these as the key contributions of this manuscript: (a) We propose new families of rotation-invariant tests for general linear hypotheses for multivariate regression problems involving high-dimensional response and fixed-dimensional predictor variables that incorporate a flexible regularization scheme to account for the dimensionality of the observations growing proportional to the sample size. (b) Unlike \citet{LiAuePaulPengWang}, who assumed sub-Gaussianity, here only the existence of finite fourth moments of the observations is required. (c) Unlike \citet{pan2011central}, who assumed $\Sigma_p = I_p$, $\Sigma_p$ is allowed to be fairly arbitrary and subjected only to some standard conditions on the limiting behavior of its spectrum. (d) We carry out a detailed analysis of the power characteristics of the proposed tests. The proposal of a class of local alternatives enables a clear interpretation of the contributions of different parameters in the performance of the test. (e) We develop a data-driven test procedure based on the principle of maximizing asymptotic power under appropriate local alternatives. This principle leads to the definition of a composite test that combines the optimal tests associated with a set of different kinds of local alternatives. The latter formulation is an extension of the data-adaptive test procedure designed by \citet{LiAuePaulPengWang} for the two-sample testing problem. The rest of the paper is organized as follows. Section \ref{sec:methodology} introduces the asymptotics of the proposed test family both under the null hypothesis and under a class of local alternatives. Using these local alternatives, in Section \ref{sec:locally_most_powerful_test} a data-driven shrinkage selection methodology based on maximizing asymptotic power is developed. In Section \ref{sec:ridge_regu_higher_order}, an application of the asymptotic theory and the shrinkage selection method is given for the ridge-regularization family. An extension of ridge-regularization to higher orders is also discussed. The results of a simulation study are reported in Section \ref{sec:simulation}. In the Appendix, a proof outline of the main theorem is presented, while technical details and proofs of other theorems are collected in the Supplementary Material, which is available at \url{anson.ucdavis.edu \section{Asymptotic theory} \label{sec:methodology} After giving necessary preliminaries on \emph{Random Matrix Theory} (RMT), the asymptotic theory of the proposed tests under the null hypothesis and under various local alternative models is presented in this section. For any $p\times p$ symmetric matrix $A$, define the \emph{Empirical Spectral Distribution} (ESD) $F^A$ of $A$ by \[F^A(\tau) = p^{-1} \sum\nolimits_{i=1}^p \mathbbm{1}_{\{\lambda_i(A)\leq \tau\} }.\] In the following, $\|\cdot\|_{\max}$ stands for the maximum absolute value of the entries of a matrix. The following assumptions are employed. \begin{itemize}\itemsep0.3em \item[\textbf{C1}] (Moment conditions) $\mathbf{{Z}}$ has i.i.d. entries $z_{ij}$ such that $\mathbb{E} z_{ij}=0$, $\mathbb{E} z_{ij}^2 = 1$, $\mathbb{E} z_{ij}^4 <\infty$; \item[\textbf{C2}] (High-dimensional setting) $k$ and $q$ are fixed, while $p,n\to\infty$ such that $\gamma_n = p/n \to \gamma \in (0,\infty)$ and $\sqrt{n}|\gamma_n-\gamma|\to0$; \item[\textbf{C3}] (Boundedness of spectral norm) $\Sigma_p$ is non-negative definite; $\limsup_p\lambda_{\max}(\Sigma_p)<\infty$; \item[\textbf{C4}] (Asymptotic stability of ESD) There exists a distribution $L^{\Sigma}$ with compact support in $[0, \infty)$, non-degenerate at zero, such that $\sqrt{n} {\mathcal D}_{W}(F^{\Sigma_p}, L^{\Sigma}) \to 0$, as $n,p\to\infty$, where $\mathcal{D}_{W}(F_1, F_2)$ denotes the \emph{Wasserstein distance} between distributions $F_1$ and $F_2$, defined as \[\mathcal{D}_{W}(F_1,F_2) = \sup_f\Big\{ \Big|\int fdF_1 - \int f dF_2 \Big|\colon f \mbox{ is 1-Lipschitz} \Big\}.\] \item[\textbf{C5}] (Asymptotically full rank) $X$ is of full rank and $n^{-1}XX^T$ converges to a positive definite $k\times k$ matrix. Moreover, $\limsup_{n\to\infty}\|X\|_{\max}<\infty$; \item[\textbf{C6}] (Asymptotically estimable) $\liminf_{n\to\infty}\lambda_{\min}(C^T(n^{-1}XX^T)^{-1}C)>0$. \end{itemize} \subsection{Preliminaries on random matrix theory} \label{subsec:background} Recall that the Stieltjes transform $m_G(\cdot)$ of any function $G$ of bounded variation on $\mathbb{R}$ is defined by \[ m_G(\mathfrak{\mathbbm{z}}) = \int_{-\infty}^\infty \frac{dG(x)}{x-\mathbbm{z}}, \qquad \mathbbm{z}\in \mathbb{C}^+ \coloneqq \{u+iv\colon v>0\}. \] Minor modifications of a standard RMT result imply that, under Conditions \textbf{C1}--\textbf{C6}, the ESD $F^{\widehat{\bm\Sigma}_p}$ converges almost surely to a nonrandom distribution $F^\infty$ at all points of continuity of $F^\infty$. This limit is determined in such a way that for any $z\in\mathbb{C}^{+}$, the Stieltjes transform $m(\cdot)=m_{F^\infty}(\cdot)$ of $F^\infty$ is the unique solution in $\mathbb{C}^{+}$ of the equation \begin{equation} m(\mathbbm{z})= \int \frac{dL^{\Sigma}(\tau)}{\tau(1-\gamma-\gamma \mathbbm{z} m(\mathbbm{z}))-\mathbbm{z}}. \label{eq:M-P-Eq} \end{equation} Equation (\ref{eq:M-P-Eq}) is often referred to as the Mar\v{c}enko--Pastur equation. Moreover, pointwise almost surely for $\mathbbm{z}\in \mathbb{C}^+$, $m_{F^{\widehat{\bm\Sigma}_p}}(\mathbbm{z})$ converges to $m_{F^\infty}(\mathbbm{z})$. The convergence holds even when $\mathbbm{z}\in \mathbb{R}_{-}$ (negative reals) with a smooth extension of $m_{F^\infty}$ to $\mathbb{R}_{-}$. Readers may refer to \citet bai2004clt} and \citet{paul2014random} for more details. From now on, for notational simplicity, we shall write $m_{F^\infty}(\mathbbm{z})$ as $m(\mathbbm{z})$ and write $m_{F^{\widehat{\bm\Sigma}_p}}(\mathbbm{z})$ as $m_{n,p}(\mathbbm{z})$. Note that \[ m_{n,p}(\mathbbm{z}) = p^{-1}\mathrm{tr} (\widehat{\bm\Sigma}_p-\mathbbm{z} I_p)^{-1} \] and define \begin{equation}\label{eq:Theta} \Theta(\mathbbm{z},\gamma)= \{1-\gamma -\gamma\mathbbm{z} m(\mathbbm{z})\}^{-1}. \end{equation} It is known that $(\widehat{\bm\Sigma}_p- \mathbbm{z} I_p)^{-1}$, for any fixed $\mathbbm{z}\in \mathbb{C}^+$, has a \emph{deterministic equivalent} (\citet{bai2004clt,liu2015marvcenko,LiAuePaulPengWang}), given by \[\{\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p -\mathbbm{z} I\}^{-1}, \] in the sense that for symmetric matrices $A$ bounded in operator norm, as $n\to \infty$, \[p^{-1} \mathrm{tr}[(\widehat{\bm\Sigma}_p -\mathbbm{z} I_p)^{-1}A] - p^{-1} \mathrm{tr}[\{\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p -\mathbbm{z} I\}^{-1}A] \to 0, \mbox{~~~with probability 1.}\] Resolvent and deterministic equivalent will be used frequently in this paper. They will appear for example as Cauchy kernels in contour integrals in various places. \subsection{Asymptotics under the null hypothesis} \label{subsec:asym_null} To begin with, for $k\geq 1$, denote by $\mathbf{W} = [w_{ij}]_{i,j=1}^k$ the \emph{Gaussian Orthogonal Ensemble} (\textbf{GOE}) defined by (1)~ $w_{ij}=w_{ji}$; (2) $w_{ii} \sim \mathcal{N}(0,1)$, $w_{ij}\sim \mathcal{N}(0,1/2)$, $i\neq j$; (3) $w_{ij}$'s are jointly independent for $1 \leq i \leq j \leq k$. Throughout this paper, $f(\cdot)$ is assumed to be analytic in an open interval containing \[ \mathcal{X} \coloneqq [0,~\limsup\nolimits_{p\to\infty}\lambda_{\max}(\Sigma_p)(1+\sqrt{\gamma})^2]. \] Let $\mathcal{C}$ to be a closed contour enclosing $\mathcal{X}$ such that $f(\cdot)$ has a complex extension to the interior of $\mathcal{C}$. Further use $\mathcal{C}^2$ to denote $\mathcal{C} \otimes \mathcal{C} = \{(\mathbbm{z}_1,\mathbbm{z}_2)\colon \mathbbm{z}_1, \mathbbm{z}_2\in\mathcal{C}\}$. \begin{theorem} Suppose \textbf{C1}--\textbf{C6} hold. Under the null hypothesis $H_0\colon BC=0$, \[ {\sqrt{n}}\{\mathbf{M}(f) - \Omega(f,\gamma) I_q \} \Longrightarrow {\Delta^{1/2}(f,\gamma)} \mathbf{W}, \] where $\Longrightarrow$ denotes weak convergence and $\Omega(f,\gamma)$ and $\Delta(f,\gamma)$ are as follows. \[\Omega(f,\gamma) = \frac{-1}{2\pi i}\oint_\mathcal{C} f(\mathbbm{z}) (\Theta(\mathbbm{z},\gamma)-1) d\mathbbm{z}.\] See (\ref{eq:Theta}) for the definition of $\Theta(\mathbbm{z},\gamma)$. For any two analytic functions $f_1$ and $f_2$, \begin{equation*} \Delta(f_1,f_2,\gamma) = \frac{2}{(2\pi i)^2}\oiint_{\mathcal{C}^2} f_1(\mathbbm{z}_1)f_2(\mathbbm{z}_2) \delta(\mathbbm{z}_1,\mathbbm{z}_2,\gamma)d\mathbbm{z}_1 d\mathbbm{z}_2, \end{equation*} and $\Delta(f,f,\gamma)$ is written as $\Delta(f,\gamma)$ for simplicity. The kernel $\delta(\mathbbm{z}_1,\mathbbm{z}_2,\gamma)$ is such that \begin{align*} \delta(\mathbbm{z}_1,\mathbbm{z}_2,\gamma) &= {\Theta(\mathbbm{z}_1,\gamma)\Theta(\mathbbm{z}_2,\gamma)} \Big[\frac{\mathbbm{z}_1 \Theta(\mathbbm{z}_1,\gamma) - \mathbbm{z}_2 \Theta(\mathbbm{z}_2,\gamma)}{\mathbbm{z}_1-\mathbbm{z}_2} -1\Big],\\ \delta(\mathbbm{z},\mathbbm{z},\gamma) &= \lim_{\mathbbm{z}_2\to\mathbbm{z}} \delta(\mathbbm{z},\mathbbm{z}_2,\gamma) = {\Theta^2(\mathbbm{z},\gamma)}\Big[ \frac{\partial \mathbbm{z} \Theta(\mathbbm{z},\gamma)}{\partial\mathbbm{z}} -1\Big] \\ & = \gamma\{1+ \mathbbm{z} m(\mathbbm{z})\} \Theta^3(\mathbbm{z},\gamma) + \gamma\mathbbm{z} \{ m(\mathbbm{z}) +\mathbbm{z} m'(\mathbbm{z})\}\Theta^4(\mathbbm{z},\gamma). \end{align*} The contour integral is taken counter-clockwise. \label{thm:asmp_null} \end{theorem} Using knowledge of the eigenvalues of the \textbf{GOE} leads to the following statement. \begin{corollary} Under the conditions of Theorem \ref{thm:asmp_null}, assume further that $\Delta(f,\gamma)> 0$. Let \[ \tilde{\lambda}_i =\frac{\sqrt{n}}{ \Delta^{1/2}(f,\gamma)} \{\lambda_i(\mathbf{M}(f)) - \Omega(f,\gamma)\}, \qquad i = 1,\dots,q. \] Then, the limiting joint density function of $(\tilde{\lambda}_1,\dots,\tilde{\lambda}_q)$ at $y_1\geq y_2\geq \cdots \geq y_q $ is given by \[\Big(2^{q/2} \prod_{i=1}^q \Gamma(i/2)\Big)^{-1}\prod_{i<j}(y_i-y_j) \exp\Big(-\frac{1}{2}\sum\limits_{i=1}^q y_i^2\Big). \] \label{corollary:eigenvalues_GOE} \end{corollary} Although without closed forms, $\Omega(f,\gamma)$ and $\Delta(f,\gamma)$ do not depend on the choice of $\mathcal{C}$ used to compute the contour integral. With the resolvent as kernel $\mathbf{M}(f)$ can be expressed as the integral of $f(\mathbbm{z}) n^{-1} Q_n^T \mathbf{Y}^T (\widehat{\bm\Sigma}_p -\mathbbm{z} I_p)^{-1} \mathbf{Y} Q_n$ on any contour $\mathcal{C}$, up to a scaling factor. The quadratic form $n^{-1} Q_n^T \mathbf{Y}^T (\widehat{\bm\Sigma}_p -\mathbbm{z} I_p)^{-1} \mathbf{Y} Q_n$ is then shown to concentrate around $[\Theta(\mathbbm{z},\gamma)-1] I_q$, which consequently serves as the integral kernel in $\Omega(f,\gamma)$. The kernel $\delta(\mathbbm{z}_1,\mathbbm{z}_2,\gamma)$ of $\Delta(f,\gamma)$ is the limit of $\mathbb{E}[n^{-1}\mathrm{tr}\{(\widehat{\bm\Sigma}_p -\mathbbm{z}_1 I_p)^{-1}\Sigma_p(\widehat{\bm\Sigma}_p -\mathbbm{z}_2 I_p)^{-1}\Sigma_p\}]$. \begin{remark} \label{remark:0_variance} Two sufficient conditions for $\Delta(f,\gamma)>0$ are \vspace{-.2cm} \begin{itemize} \itemsep-.5ex \item[(1)] $f(x)>0 \mbox{ for } x \in \mathcal{X}$; \item[(2)] $f(x)\geq 0 \mbox{ for } x \in \mathcal{X}$, with $f(x)\neq0$ for some $x\in\mathcal{X}$, and $\liminf\lambda_{\min}(\Sigma_p) >0.$ \end{itemize} \end{remark} It would be convenient if $\Omega(f,\gamma)$ and $\Delta(f,\gamma)$ had closed forms in order to avoid computational inefficiencies. Closed forms are available for special cases as shown in the following lemma. \begin{lemma} \label{lemma:special_form_ARHT} When $f(x,\ell) = (x-\ell)^{-1}$ with $\ell\in \mathbb{R}^-$, the contour integrals in Theorem \ref{thm:asmp_null} have closed forms, namely, for $j$, $j_1$, $j_2$ $= 0,1,2,\dots$, \begin{align*} &\frac{-1}{2\pi i}\oint_\mathcal{C} \frac{\partial^j f(\mathbbm{z},\ell)}{\partial \ell^j} (\Theta(\mathbbm{z},\gamma)-1)d\mathbbm{z} = \frac{\partial^{j}(\Theta(\ell,\gamma) -1)}{\partial \ell^{j}},\\[5pt] & \frac{1}{(2\pi i)^2} \oiint_{\mathcal{C}^2}\frac{\partial^{j_1} f(\mathbbm{z}_1,\ell_1)}{\partial \ell^{j_1}_1} \frac{\partial^{j_2} f(\mathbbm{z}_2,\ell_2)}{\partial \ell^{j_2}_2} \delta(\mathbbm{z}_1,\mathbbm{z}_2, \gamma) d\mathbbm{z}_1 d\mathbbm{z}_2 = \frac{\partial^{j_1+j_2}\delta(\ell_1,\ell_2,\gamma)}{\partial \ell^{j_1}_1 \partial \ell^{j_2}_2}. \end{align*} The results continue to hold when $\ell \in \mathbb{C}\setminus\mathcal{X}$. \end{lemma} Lemma \ref{lemma:special_form_ARHT} indicates that it is possible to have convenient and accurate estimators of the asymptotic mean and variance of $\mathbf{M}(f)$ under ridge-regularization. The result easily generalizes to the setting when $f(x)$ is a linear combination of functions of the form $(x-\ell_j)^{-1}$, for any finite collection of $\ell_j$'s. We elaborate on this in Section \ref{sec:ridge_regu_higher_order}. To conduct the tests, consistent estimators of $\Omega(f,\gamma)$ and $\Delta(f,\gamma)$ are needed. \begin{lemma} \label{lemma:emp_counterpart} Let $\widehat{\Theta}(\mathbbm{z},\gamma_n)$ and $\widehat{\delta}(\mathbbm{z}_1,\mathbbm{z}_2,\gamma_n)$ be the plug-in estimators of ${\Theta}(\mathbbm{z},\gamma)$ and ${\delta}(\mathbbm{z}_1,\break\mathbbm{z}_2,\gamma)$, with $(m(\mathbbm{z}),\gamma)$ estimated by $(m_{n,p}(\mathbbm{z}),\gamma_n)$. For general $f$, $f_1$, $f_2$, we can estimate $\Omega(f,\gamma)$ and $\Delta(f_1,f_2,\gamma)$ by replacing ${\Theta}(\mathbbm{z},\gamma)$ and $\delta(\mathbbm{z}_1,\mathbbm{z}_2,\gamma)$ with $\widehat{\Theta}(\mathbbm{z},\gamma_n)$ and $\widehat{\delta}(\mathbbm{z}_1,\mathbbm{z}_2,\gamma_n)$. Denote the resulting estimators by $\widehat{\Omega}(f,\gamma_n)$ and $\widehat{\Delta}(f_1,f_2,\gamma_n)$. Then, \begin{align*} &\sqrt{n} |\widehat{\Omega}(f,\gamma_n) -\Omega(f,\gamma) | \stackrel{P}{\longrightarrow}0, \\[5pt] &\sqrt{n} |\widehat{\Delta}(f_1,f_2,\gamma_n) - \Delta(f_1,f_2,\gamma)| \stackrel{P}{\longrightarrow}0, \end{align*} where $\stackrel{P}{\longrightarrow}$ indicates convergence in probability. Again, we write $\widehat{\Delta}(f,f,\gamma_n)$ as $\widehat{\Delta}(f,\gamma_n)$. For the special case of $f^{(j)}(x,\ell) =\partial^j (x-\ell)^{-1}/\partial\ell^j$, $j=0,1,2,\dots$ and $\ell\in \mathbb{C}\setminus \mathcal{X}$, using Lemma \ref{lemma:special_form_ARHT}, natural estimators in closed forms are \begin{align*} &\widehat{\Omega}(f^{(j)}(x,\ell) ,\gamma_n)= \frac{\partial^{j}(\widehat\Theta(\ell,\gamma_n) -1)}{\partial \ell^{j}}, \\ &\widehat{\Delta}(f^{(j_1)}(x,\ell_1), f^{(j_2)}(x,\ell_2),\gamma_n) = \frac{\partial^{j_1+j_2}2\widehat\delta(\ell_1,\ell_2,\gamma_n)}{\partial \ell^{j_1}_1 \partial \ell^{j_2}_2}. \end{align*} In particular, for $j,j_1,j_2=0$, \begin{align*} &\widehat{\Omega}(f(x,\ell),\gamma_n) = \widehat\Theta(\ell,\gamma_n) -1,\\ &\widehat{\Delta}(f(x,\ell_1),f(x,\ell_2),\gamma_n)= 2\widehat{\delta}(\ell_1,\ell_2,\gamma_n). \end{align*} The estimators are consistent, for any fixed $j$ and $\ell$. Given the eigenvalues of $\widehat{\bm\Sigma}_p$, the computational complexity of calculating the above estimators is $O(p)$. \end{lemma} Recall the definitions of $T^{\rm LR}(f), T^{\rm LH}(f)$ and $T^{\rm BNP}(f)$ from Section \ref{sec:introduction}. \begin{theorem} \label{thm:asy_null_three_stat} Suppose \textbf{C1}--\textbf{C6} hold and $\Delta(f,\gamma)>0$. Under $H_0\colon BC=0$, \begin{align*} \widehat{T}^{\rm LR}(f) &\coloneqq\frac{\sqrt{n}\{1+\widehat{\Omega}(f,\gamma_n)\} }{q^{1/2}\widehat{\Delta}^{1/2}(f,\gamma_n)} [T^{\rm LR}(f) - q \log\{1+\widehat{\Omega}(f,\gamma_n)\}] {\Longrightarrow} \mathcal{N}(0,1),\\ \widehat{T}^{\rm LH}(f) &\coloneqq\frac{\sqrt{n}}{q^{1/2}\widehat{\Delta}^{1/2}(f,\gamma_n)}\{T^{\rm LH}(f) - q\widehat{\Omega}(f,\gamma_n)\}{\Longrightarrow} \mathcal{N}(0,1),\\ \widehat{T}^{\rm BNP}(f) &\coloneqq\frac{\sqrt{n}\{1+\widehat{\Omega}(f,\gamma_n)\}^2}{q^{1/2}\widehat{\Delta}^{1/2}(f,\gamma_n)}\Big\{T^{\rm BNP}(f) - q\frac{\widehat{\Omega}(f,\gamma_n)}{1+\widehat{\Omega}(f,\gamma_n)}\Big\} {\Longrightarrow} \mathcal{N}(0,1). \end{align*} For any of the three tests, the null hypothesis is rejected at asymptotic level $\alpha$, if \break$\widehat{T}(f) > \xi_\alpha$, where $\xi_\alpha$ is the $1-\alpha$ quantile of the standard normal distribution. \end{theorem} \subsection{Asymptotic power under local alternatives} \label{subsec:asym_power} This subsection deals with the behavior of the proposed family of tests under a host of local alternatives. We start with deterministic alternatives, a framework commonly used in the literature to study the asymptotic power of inferential procedures. Next, we consider a Bayesian framework, using a class of priors that characterize the structure of the alternatives. Because the results to follow simultaneously hold for $\widehat{T}^{\rm LR}(f)$, $\widehat{T}^{\rm LH}(f)$ and $\widehat{T}^{\rm BNP}(f)$, the unifying notation $\widehat{T}(f)$ will be used to refer to each of the test statistics. \subsubsection{Deterministic local alternatives} Consider a sequence of $BC$ such that, on an open subset of $\mathbb{C}$ containing $\mathcal{X}$, \begin{equation} \sqrt{n} C^T B^T \{\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p - \mathbbm{z} I\}^{-1} BC \longrightarrow D(\mathbbm{z},\gamma)\quad \mbox{ pointwise, as }n,p\to\infty. \label{eq:determ_local_alternatives} \end{equation} Observe that $\mathbf{Y} Q_n =\sqrt{n} BC [C^T (n^{-1} XX^T )^{-1} C]^{-1/2} + \Sigma_p^{1/2}\mathbf{{Z}} Q_n$ and define \begin{equation} \calH(D,f) = T^{-1/2} \Big[\frac{-1}{2\pi i} \oint_\mathcal{C} f(\mathbbm{z}) D(\mathbbm{z},\gamma) d\mathbbm{z}\Big]T^{-1/2}, \mbox{ where} \label{eq:Omega_def} \end{equation} \begin{equation}\label{eq:T_matrix_def} T = \lim_{n\to\infty} C^T (n^{-1} XX^T )^{-1} C. \end{equation} Note that $T$ exists and is non-singular under \textbf{C5} and \textbf{C6}. {If further $f(x)\geq 0$ for any $x \in \mathcal{X}$, $\calH (D,f)$ is non-negative definite. } \begin{theorem} \label{thm:local_power_Mf} Suppose \textbf{C1}--\textbf{C6} and (\ref{eq:determ_local_alternatives}) hold, and $\Delta(f,\gamma)>0$. Then, as $n\to\infty$, \[ \frac{\sqrt{n}}{\Delta^{1/2}(f,\gamma)} \{\mathbf{M}(f) - \Omega(f,\gamma) I_q \} {\Longrightarrow} \mathbf{W} + \frac{\calH(D,f)}{\Delta^{1/2}(f,\gamma)}. \] \end{theorem} Denote the power functions of $\widehat{T}(f)$ at asymptotic level $\alpha$, conditional on $BC$, by \[ \Upsilon(BC,f) = \mathbb{P}(\widehat{T}(f) >\xi_\alpha \mid BC). \] The asymptotic behavior of the power functions is described in the following corollary. \begin{corollary} Under the assumptions of Theorem~\ref{thm:local_power_Mf}, as $n\to\infty$, \[ \Upsilon(BC,f) \longrightarrow \Phi\Big(-\xi_\alpha + \frac{\mathrm{tr}(\calH(D,f))}{q^{1/2} \Delta^{1/2}(f,\gamma)}\Big), \] where $\Phi$ is the standard normal CDF. \label{corollary:local_power_three_stat} \end{corollary} \begin{remark} Corollary \ref{corollary:local_power_three_stat} indicates the three proposed statistics have identical asymptotic powers under the assumed local alternatives. This is because the first-order Taylor expansions of $x$, $\log(1+x)$ and $x/(1+x)$ coincide at $0$. However, the respective empirical powers may differ considerably for moderate sample sizes. \label{remark:local_power_identical} \end{remark} The following remark provides a sufficient condition under which \eqref{eq:determ_local_alternatives} is satisfied. Denoting the columns of $BC$ by $[\mu_1,\dots,\mu_q]$, it follows that \[\sqrt{n} C^T B^T \{\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p - \mathbbm{z} I\}^{-1} BC = \sqrt{n} \Big[\mu_i^T \{\Theta^{-1}(\mathbbm{z},\gamma)\Sigma_p -\mathbbm{z} I_p\}^{-1}\mu_j \Big]_{i,j=1}^q. \] \vspace{-5pt} \begin{remark} (a) Let $\mathbf{E}_{m,p}$ denote the eigen-projection associated with $\lambda_{m,p}=\lambda_m(\Sigma_p)$. Suppose that there exists a sequence (in $p$) of mappings $[\mathfrak{B}_{ij;p}]_{i,j=1}^q$ from $[0,\infty)^{q^2} $ to $[0,\infty)^{q^2}$, satisfying $\mathfrak{B}_{ij;p}(\lambda_{m,p}) = \sqrt{n} p \mu_i^T \mathbf{E}_{m,p} \mu_j$, $ m =1,\dots,p$, and a mapping\break $[\mathfrak{B}_{ij;\infty}]_{i,j=1}^q$ continuous on $[0,\infty)^{q^2}$ such that, as $p\to\infty$ and for $1\leq i, j \leq q$, \[ \int |\mathfrak{B}_{ij;p}(x) - \mathfrak{B}_{ij;\infty}(x)| d F^{\Sigma_p}(x) \to 0. \] Then, under \textbf{C4}, it follows that (\ref{eq:determ_local_alternatives}) holds with $D(\mathbbm{z},\gamma) = [d_{ij}(\mathbbm{z},\gamma)]_{i,j=1}^q$ and \[d_{ij}(\mathbbm{z},\gamma)=\int \frac{\mathfrak{B}_{ij;\infty}(x) d L^{\Sigma}(x)}{x\Theta^{-1}(\mathbbm{z},\gamma) -\mathbbm{z}} =\int \frac{\mathfrak{B}_{ij;\infty}(x) d L^{\Sigma}(x)}{x\{ 1-\gamma - \gamma \mathbbm{z} m(\mathbbm{z}) \} -\mathbbm{z}}. \] (b) If $\Sigma_p = I_p$, then (\ref{eq:determ_local_alternatives}) is satisfied if $\sqrt{n} \mu_i^T\mu_j \to \mathcal{K}_{ij}$, for some constants $\mathcal{K}_{ij}$, $1\leq i, j \leq q$. In this case, $D(\mathbbm{z},\gamma) =(\Theta^{-1}(\mathbbm{z},\gamma) -\mathbbm{z})^{-1} [\mathcal{K}_{ij}]_{i,j=1}^q$. \label{remark:project_mu_eigenSigma} \end{remark} \subsubsection{Probabilistic local alternatives} \label{subsubsec:probabilistic_local_alternatives} While deterministic local alternatives provide useful information, they are somewhat restrictive for the purpose of a systematic investigation of the power characteristics. Therefore, probabilistic alternatives are considered in the form of a sequence of prior distributions for $BC$. This has the added advantage of providing flexibility for incorporating structural information about the regression parameters and the constraints matrices. The proposed formulation of probabilistic alternatives can be seen as an extension of the proposal adopted by \citet{LiAuePaulPengWang} in the context of two-sample tests for equality of means. One challenge associated with formulating meaningful alternatives to the hypothesis \eqref{eq:general_linear_hypothesis}, when compared to the two-sample testing problem, is that there are many more plausible ways in which the null hypothesis can be violated. Considering this, we propose a class of alternatives, that on one hand can incorporate a multitude of structures of the parameter $BC$, while on the other hand retains analytical tractability in terms of providing interpretable expressions for the local asymptotic power. Assume the following prior model of $BC$ with separable covariance \begin{equation} BC = n^{-1/4} p^{-1/2} \mathcal{R} \bm{\mathcal{V}} {\mathcal{S}}^T, \label{eq:proba_local_alter_model} \end{equation} where $\bm{\mathcal{V}}$ is a $p\times m$ stochastic matrix ($m\geq1$ fixed) with independent elements $\nu_{ij}$ such that $\mathbb{E}[\nu_{ij}] =0$, $\mathbb{E}[|\nu_{ij}|^2] =1$ and $\max_{ij}\mathbb{E}[ |\nu_{ij}|^4] \leq p^{c_\nu} $ for some $c_{\nu} \in (0,1)$; $\mathcal{R}$ is a $p\times p$ deterministic matrix and ${\mathcal{S}}$ is a fixed $q\times m$ matrix. Moreover, let $\|\mathcal{R}\|_2 \leq \mathcal{K}_1<\infty$ and suppose there is a nonrandom function $h(\mathbbm{z},\gamma)$ such that, as $p\to\infty$, on an open subset of $\mathbb{C}$ containing $\mathcal{X}$, \begin{equation} p^{-1} \mathrm{tr}\{(\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p - \mathbbm{z} I)^{-1} \mathcal{R}\bR^T\} \to h(\mathbbm{z},\gamma) \qquad\mbox{ pointwise}. \label{eq:covariance_prior_condition} \end{equation} Recalling that $(\Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p - \mathbbm{z} I)^{-1}$ is the deterministic equivalent of the resolvent $(\widehat{\bm\Sigma}_p - \mathbbm{z} I)^{-1}$, existence of the limit \eqref{eq:covariance_prior_condition} also implies that $p^{-1} \mathrm{tr}\{(\widehat{\bm\Sigma}_p - \mathbbm{z} I)^{-1}\mathcal{R}\bR^T\}$ converges pointwise in probability to $h(\mathbbm{z},\gamma)$. Notice also that $p^{-1} \mathrm{tr}\{(\widehat{\bm\Sigma}_p - \mathbbm{z} I)^{-1}\mathcal{R}\bR^T\}$ is the Stieltjes transform of a measure supported on the eigenvalues of $\widehat{\bm\Sigma}_p$. Model \eqref{eq:proba_local_alter_model} leads to a fairly broad covariance design for multi-dimensional random elements, encompassing structures commonly encountered in many application domains, especially in spatio-temporal statistics. We give some representative examples by considering various functional forms of the matrix ${\mathcal{S}}$. Denote by $\mu_j$ the columns of $BC$ and by $V_j$ the columns of $\bm{\mathcal{V}}$. \begin{exa} \label{ex} {\rm In all that follows $j$ takes values in $1,\ldots,q$. \vspace{-.2cm} \begin{itemize}\setlength\itemsep{-0.1em} \item[(a)] {\it Independent}: $\mu_j = n^{-1/4} p^{-1/2} \mathcal{R} V_j$; \item[(b)] {\it Longitudinal}: $\mu_j = n^{-1/4} p^{-1/2} \mathcal{R}(V_1 + V_2 j + \cdots + V_m j^{m-1})$; \item[(c)] {\it Moving average}: $\mu_j = n^{-1/4} p^{-1/2} \mathcal{R} [V_{j+t} + \theta_1V_{j+t-1} +\cdots + \theta_tV_{j}]$ for constants $\theta_1,\ldots,\theta_t$. \end{itemize} } \end{exa} Taking the MANOVA problem to illustrate, suppose that the columns of $B$ represent group mean vectors, and suppose $C$ is the matrix that determines successive contrasts among them. Then, $\mu_j$ is the difference between the means of group $j$ and group $j+1$. Parts (a)--(c) of Example \ref{ex} correspond then to $\mu_1,\ldots,\mu_q$ respectively following an independent, a longitudinal and a moving average process. The row-wise covariance structure is assumed to be such that each $\mu_j$ has a covariance matrix proportional to $n^{-1/2}p^{-1}\mathcal{R}\bR^T$. The factor $n^{-1/2}p^{-1}$ provides the scaling for the tests to have non-trivial local power. A sufficient condition that leads to (\ref{eq:covariance_prior_condition}), similar to Remark \ref{remark:project_mu_eigenSigma}, is to postulate the existence of functions $\tilde{\mathfrak{B}}_p$ satisfying $\tilde{\mathfrak{B}}_p(\lambda_{j,p}) = \mathrm{tr}\{\mathbf{E}_{j,p} \mathcal{R}\bR^T\}$, $j=1,\dots,p$, and \[\int |\tilde{\mathfrak{B}}_p(x) -\tilde{\mathfrak{B}}_{\infty}(x)|d F^{\Sigma_p}(x) \to 0\] for some function $\tilde{\mathfrak{B}}_\infty$ continuous on $[0,\infty)$, where $\lambda_{j,p}$ is the $j$th eigenvalue of $\Sigma_p$ and $\mathbf{E}_{j,p}$ is the eigen-projection associated with $\lambda_{j,p}$. Then \begin{equation} h(\mathbbm{z},\gamma) = \int\frac{\tilde{\mathfrak{B}}_\infty(x) dL^{\Sigma}(x)}{x\{1-\gamma-\gamma\mathbbm{z} m(\mathbbm{z})\}-\mathbbm{z}} . \label{eq:h_form} \end{equation} Equations \eqref{eq:covariance_prior_condition} and \eqref{eq:h_form} indicate that $h(\mathbbm{z},\gamma)$ effectively captures the distribution of the total spectral mass of $\mathcal{R}\bR^T$ across the spectral coordinates of $\Sigma_p$, also taking into account the dimensionality effect through the aspect ratio $\gamma$. Later, we shall discuss specific classes of the matrices $\mathcal{R}$ that lead to analytically tractable expressions for $h(\mathbbm{z},\gamma)$, with the structure of $\mathcal{R}$ linking the parameter $BC$ under the alternative through \eqref{eq:proba_local_alter_model} to the structure of $\Sigma_p$. Another important feature of the probabilistic model is that it incorporates both dense and sparse alternatives through different specifications of the innovation variables $\nu_{ij}$. We consider two special cases. \begin{enumerate}\itemsep-.1ex \item \textit{Dense alternative:} $\nu_{ij} \sim \mathcal{N}(0,1)$; \item \textit{Sparse alternative:} $\nu_{ij} \sim G_\eta$, for some $\eta\in(0,1)$, where $G_\eta$ is the discrete probability distribution assigning mass $1-p^{-\eta}$ to $0$ and mass $(1/2)p^{-\eta}$ to the points $\pm p^{\eta/2}$. \end{enumerate} Note that the usual notion of sparsity corresponds to the setting where in addition, $\mathcal{R} = I_p$. More generally, the second specification above formulates a prior model for $BC$ that is sparse in the coordinate system determined by $\mathcal{R}$. In particular, if $\mathcal{R}\bR^T$ is a polynomial in $\Sigma_p$ (see Section~\ref{subsec:polynomial_alternatives} for a discussion), $BC$ can be seen as sparse in the spectral coordinates of $\Sigma_p$. \begin{theorem} Suppose that \textbf{C1}--\textbf{C6} hold and $\Delta(f,\gamma)>0$. Also suppose that, under $H_a$, $BC$ has a prior distribution given by (\ref{eq:proba_local_alter_model}). Then, the power function of each of the three test statistics satisfies \begin{equation} \Upsilon(BC,f) \stackrel{L_1}\longrightarrow \Phi\Big(-\xi_\alpha + \frac{ \mathrm{tr}({\mathcal{S}}\bcalS^T T^{-1}) }{ q^{1/2} \Delta^{1/2}(f,\gamma)}\oint_{\mathcal{C}} \frac{-1}{2\pi i}f(\mathbbm{z}) h(\mathbbm{z},\gamma) d\mathbbm{z}\Big) , \label{eq:converge_local_power_prob} \end{equation} as $n\to\infty$, where $T$ is as in (\ref{eq:T_matrix_def}) and {$\stackrel{L_1}\longrightarrow$ indicates $L_1$-convergence (with respect to the prior measure of $BC$)}. \label{thm:probability_local_power_three_stat} \end{theorem} \begin{remark} Even if the quantity $h_p(\mathbbm{z},\gamma) = p^{-1} \mathrm{tr}\{( \Theta^{-1}(\mathbbm{z},\gamma) \Sigma_p - \mathbbm{z} I)^{-1} \mathcal{R}\bR^T\}$ does not converge, it can be verified that the difference between the left- and right-hand sides of \eqref{eq:converge_local_power_prob} still converges to zero in $L_1$ if $h(\mathbbm{z},\gamma)$ is replaced by $h_p(\mathbbm{z},\gamma)$. \label{remark:h_not_converge} \end{remark} Observe that the matrices $\mathcal{R}$ and ${\mathcal{S}}$ decouple in the expression (\ref{eq:converge_local_power_prob}) for the asymptotic power. Dependence on the unknown error covariance matrix $\Sigma_p$, besides $\Delta^{1/2}(f,\gamma)$, is only through the function $h(\mathbbm{z},\nu)$, which incorporates the structure of the matrix $\mathcal{R}\bR^T$. It is also noticeable that distributional characteristics of the variables $\nu_{ij}$ do not affect the asymptotic power. Indeed, the proposed tests have the same local asymptotic power under both sparse and dense alternatives. \section{Data-driven selection of shrinkage} \label{sec:locally_most_powerful_test} In this section, we introduce a data-driven procedure to select the ``optimal'' $f$ from a parametric family $\mathfrak{F}$ of shrinkage functions. The strategy is to maximize the local power function $\Upsilon(BC,f)$ over $f$, given a class of probabilistic local alternatives as in \eqref{eq:proba_local_alter_model}. In designing the classes of alternatives, we focus our attention only on the specification of $\mathcal{R}$. This is because, as the expression \eqref{eq:converge_local_power_prob} shows, the dependence on the matrix ${\mathcal{S}}$ is only through a multiplier involving a ``known'' matrix $T$, while the effect of the unknown covariance $\Sigma_p$ (and its interaction with $\mathcal{R}$) manifests itself through the function $h(\mathbbm{z},\gamma)$. Another reason for focusing on $\mathcal{R}$ is that the choice of ${\mathcal{S}}$ is closely related to the specific type of linear model being considered, while the choice of $\mathcal{R}$ is associated with the structure of the error distribution. We present some settings of $BC$ for which $h(\mathbbm{z},\gamma)$ can be computed explicitly. We also verify that the standardized test statistic with the data-driven selection of $f$ is still asymptotically standard normal under suitable conditions. Hence, the Type 1 error rate of the tests is asymptotically not inflated, although the same data is used for both shrinkage selection and testing. Lastly, we present a composite test procedure that combines the optimal tests corresponding to different prior models of $BC$ and thereby improves adaptivity to various kinds of alternatives. \subsection{Shrinkage family} \label{subsec:shrinkage_family} Suppose the family of shrinkage functions is such that \[\mathfrak{F} = \{f_{\ell}\colon \ell \in \mathcal{L}\}, \] \begin{itemize}\itemsep-.1ex \item[(i)] $\mathcal{L}$ is a compact subset of $\mathbb{R}^r$, $r\in \mathbb{N}^+$; \item[(ii)] There is a closed, connected subset $\mathcal{Z}$ of $\mathbb{C}$ such that $\mathcal{X}= [0,~\limsup_p\lambda_{\max}(\Sigma_p)(1+\sqrt{\gamma})^2]\subset \mathcal{Z}$, and the third-order partial derivatives of $f_{\ell}$ with respect to $\ell$ are continuous on $\mathcal{L}\otimes \mathcal{Z}$; \item[(iii)] The gradient $\nabla_{\ell}f_{\ell}$ and the Hessian $\nabla^2_{\ell} f_{\ell}$ of $f_{\ell}$ with respect to $\ell$ have analytic extensions to $\mathcal{Z}$ for all $\ell\in \mathcal{L}$; \item[(iv)] $\inf_{\ell\in \mathcal{L}}\Delta(f_\ell,\gamma)>0$. \end{itemize} Under the probabilistic prior model \eqref{eq:proba_local_alter_model} with $h(\mathbbm{z},\gamma)$ in (\ref{eq:covariance_prior_condition}) given, define \[\Xi(\ell,h,\gamma) = \frac{-1}{2\pi i \Delta^{1/2}(f_\ell,\gamma)} \oint_{\mathcal{C}} f_\ell(\mathbbm{z}) h(\mathbbm{z},\gamma) d\mathbbm{z}.\] Theorem \ref{thm:probability_local_power_three_stat} suggests that $\ell$ should be chosen such that $\Xi(\ell,h,\gamma)$ is maximized, that is, \[ \ell_{opt} = \mbox{arg}\max_{\ell\in \mathcal{L}}\Xi(\ell,h,\gamma). \] The test with the selected shrinkage will then be the locally most powerful test under the alternatives specified by \eqref{eq:proba_local_alter_model} and \eqref{eq:covariance_prior_condition} for any given choice of ${\mathcal{S}}$. Since $\Xi(\ell,h,\gamma)$ is continuous with respect to $\ell$ under condition (i)--(iv), $\ell_{opt}$ exists. Importantly, $\Xi(\ell,h,\gamma)$ does not rely on ${\mathcal{S}}$. In other words, different column-wise covariance structures of $BC$ are uniform in terms of selecting the optimal shrinkage. This significantly simplifies the selection procedure. Recall that $h(\mathbbm{z},\ell)$ is the limit of $p^{-1}\mathrm{tr}\{(\Theta^{-1}(\mathbbm{z},\gamma)\Sigma_p -\mathbbm{z} I)^{-1}\mathcal{R}\bR^T\}$. We next present two possible settings of $\mathcal{R}\bR^T$ under which $h(\mathbbm{z},\gamma)$ and consequently $\Xi(\ell,h,\gamma)$ can be accurately estimated: \begin{itemize}\itemsep-.1ex \item[(1)] Suppose $\mathcal{R}\bR^T$ is specified. Then, $h(\mathbbm{z},\gamma)$ is estimated by $\widehat{h}(\mathbbm{z},\gamma_n) = p^{-1}\mathrm{tr}\{(\widehat{\bm\Sigma}_p-\mathbbm{z} I)^{-1}\mathcal{R}\bR^T\}$ and \[ \widehat{\Xi}(\ell,\widehat{h},\gamma_n) \coloneqq \frac{-1}{2\pi i \widehat\Delta^{1/2}(f_\ell,\gamma_n)} \oint_{\mathcal{C}} f_{\ell}(\mathbbm{z}) \widehat{h}(\mathbbm{z},\gamma_n) d\mathbbm{z} \] is a consistent estimator of $\Xi(f,h,\gamma)$. As an example of this scenario, assume that the $p$ components of $\mu_j$ admit a natural ordering such that the dependence between their coordinates is a function of the difference between their indexes. Then we may set $\mathcal{R}\bR^T$ to be a Toeplitz matrix (stationary auto-covariance structure). \item[(2)] Only the spectral mass distribution of $\mathcal{R}\bR^T$ in the form of $\tilde{\mathfrak{B}}_\infty$ described in \eqref{eq:h_form} is specified. \end{itemize} The remainder of this section is devoted to dealing with the second scenario. \subsection{Polynomial alternatives} \label{subsec:polynomial_alternatives} Even if $\tilde{\mathfrak{B}}_\infty$ is given, the estimation of $h(\mathbbm{z},\gamma)$ is still challenging since it involves the unknown limiting spectral distribution $L^{\Sigma}$. In order to estimate $h(\mathbbm{z},\gamma)$, it is convenient to have it in a closed form. It is feasible if $\tilde{\mathfrak{B}}_\infty$ is a polynomial, which is true if $\mathcal{R}\bR^T$ is a matrix polynomial in $\Sigma_p$. Since any smooth function can be approximated by polynomials, this formulation is quite flexible and practically beneficial. Assume therefore that \begin{equation} \label{eq:poly_approx_bRbR} \mathcal{R}\bR^T = \sum\nolimits_{j=0}^s {t}_j \Sigma_p^j, \end{equation} where $t_0,\dots,t_s$ are pre-specified weights such that $\sum_{j=0}^s {t}_j \Sigma^j_p$ is nonnegative definite. Under the model, \[ h(\mathbbm{z},\gamma) = \lim_{p\to\infty} p^{-1} \mathrm{tr}[(\Theta^{-1}(\mathbbm{z},\gamma)\Sigma_p -\mathbbm{z} I )^{-1} \sum\nolimits_{j=0}^s {t}_j \Sigma_p^j] = \sum\nolimits_{j=0}^s t_j \rho_j(\mathbbm{z},\gamma), \] where the functions $\rho_j(\mathbbm{z},\gamma)$ satisfy the recursive formula \citep[see][]{ledoit2011eigenvectors} \[ \rho_0(\mathbbm{z},\gamma) = m(\mathbbm{z}), \qquad \rho_{j+1}(\mathbbm{z},\gamma) = \Theta(\mathbbm{z},\gamma) \Big[ \int x^j dL^{\Sigma}(x) + \mathbbm{z} \rho_j(\mathbbm{z},\gamma)\Big]. \] For any $j\in \mathbb{N}$, $\int x^j dL^{\Sigma}(x)$, and consequently $\rho_j(\mathbbm{z},\gamma)$, can be estimated consistently \citep[Lemma 1]{bai2010estimation}. Specifically, $p^{-1}\mathrm{tr}(\widehat{\bm\Sigma}_p)$ is a consistent estimator of $\int x dL^{\Sigma}(x)$. In practice, we restrict to the case $s = 2$. There are several considerations that guided this choice of $s$ as stated in \citet{LiAuePaulPengWang}. First, for $s = 2$, all quantities involved can be computed explicitly without requiring knowledge of higher-order moments of the observations. Also, the corresponding estimating equations for $h(\mathbbm{z},\gamma)$ are more stable as they do not involve higher-order spectral moments. Second, the choice of $s = 2$ yields a significant, yet nontrivial, concentration of the prior covariance of $\mu_j$, $j=1,\dots,q$, (that is $\mathcal{R}\bR^T$ up to a scaling factor) in the directions of the leading eigenvectors of $\Sigma_p$. Finally, the choice $s=2$ allows for both convex and concave shapes of the spectral mass distribution $\tilde{\mathfrak{B}}_\infty$ since the latter becomes a quadratic function. With $s=2$, we estimate $\rho_0(\mathbbm{z},\gamma)$, $\rho_1(\mathbbm{z},\gamma)$, $\rho_2(\mathbbm{z},\gamma)$, and $h(\mathbbm{z},\gamma)$ by \begin{equation} \label{eq:rho0_3} \begin{split} &\widehat{\rho}_0(\mathbbm{z},\gamma_n) = m_{n,p}(\mathbbm{z}), \\ &\widehat{\rho}_1(\mathbbm{z},\gamma_n) = \widehat{\Theta}(\mathbbm{z},\gamma_n)[1 + \mathbbm{z} m_{n,p}(\mathbbm{z})], \\ &\widehat{\rho}_2(\mathbbm{z},\gamma_n) = \widehat{\Theta}(\mathbbm{z},\gamma_n)\big[p^{-1}\mathrm{tr}(\widehat{\bm\Sigma}_p) + \mathbbm{z} \widehat{\rho}_1(\mathbbm{z},\gamma_n) \big],\\ &\widehat{h}(\mathbbm{z},\gamma_n) = \sum\nolimits_{j=0}^2 t_j \widehat{\rho}_j(\mathbbm{z},\gamma_n). \end{split} \end{equation} The algorithm for the data-driven shrinkage selection is stated next. \begin{algo}[Data-driven shrinkage selection] {~} \vspace{-.2cm} \begin{itemize}\itemsep-.2ex \item[1.] Specify prior weights $\tilde{t} = (t_0,t_1,t_2)$. The canonical choices are $(1,0,0)$, $(0,1,0)$, $(0,0,1)$; \item[2.] Compute $\widehat{h}(\mathbbm{z},\gamma_n) = \sum_{j=0}^2 t_j \widehat{\rho}_j(\mathbbm{z},\gamma_n)$; \item[3.] For any $\ell\in \mathcal{L}$, numerically compute the integral \[\widehat{\Xi}(\ell,\widehat{h},\gamma_n) = \frac{-1}{2\pi i \widehat\Delta^{1/2}(f_\ell,\gamma_n)} \oint_{\mathcal{C}} f_{\ell}(\mathbbm{z}) \widehat{h}(\mathbbm{z},\gamma_n) d\mathbbm{z} ;\] \item[4.] Select $\ell_{opt}(\tilde{t}) = \mbox{arg}\max_{\ell\in \mathcal{L}}\widehat{\Xi}(\ell,\widehat{h},\gamma_n)$. \end{itemize} \label{algo:empricial_selection_shrinkage} \end{algo} The behavior of the tests applied with the data-driven shrinkage selection is described in the following theorem. \begin{theorem} \label{thm:consistency_emp_selection_shrinkage} Suppose \textbf{C1}--\textbf{C6} hold and $\mathfrak{F}$ satisfies conditions (i)--(iv). Then, \begin{itemize} \item[(1)] $\sup_{\ell\in \mathcal{L}}\sqrt{n}|\widehat{\Xi}(\ell,\widehat{h},\gamma_n) -\Xi(\ell,h,\gamma)| \stackrel{P}{\longrightarrow}0$ as $n\to\infty$. \item[(2)] Let $\ell^*$ be any local maximizer of $\Xi(\ell,h,\gamma)$ in the interior of $\mathcal{L}$. Assume there exists a neighborhood of $\ell^*$ such that for all feasible points $\ell\in \mathcal{L}$ within the neighborhood, there exists a constant $\mathcal{K}>0$ such that \begin{equation} \label{eq:converge_Xi} \Xi(\ell,h,\gamma) -\Xi(\ell^*,h,\gamma) \leq -\mathcal{K} \|\ell - \ell^* \|_2^2. \end{equation} Then, there exists a sequence ($\ell^*_{n}\colon n\in\mathbb{N}$) of local maximizers of $(\widehat{\Xi}(\ell,\widehat{h},\gamma_n)\colon n\in\mathbb{N})$ satisfying \begin{equation} n^{1/4} \|\ell^*_{n} - \ell^* \|_2 = O_p(1) \qquad (n\to\infty). \label{eq:consistency_emp_selection_shrinkage_eq1} \end{equation} Further, recalling notation in Section \ref{sec:methodology}, under the null hypothesis, \begin{equation} \frac{\sqrt{n}}{\widehat{\Delta}^{1/2}(f_{\ell^*_{n}} ,\gamma_n) } \{ \mathbf{M}(f_{\ell^*_{n}}) - \widehat{\Omega}(f_{\ell^*_{n}},\gamma_n) I_q\} \Longrightarrow \mathbf{W}. \label{eq:consistency_emp_selection_shrinkage_eq2} \end{equation} \item[(3)] Let $\ell^*$ be any local maximizer of~$\Xi(\ell,h,\gamma)$ on the boundary of $\mathcal{L}$. Assume there exists a neighborhood of $\ell^*$ such that for all feasible points $\ell\in \mathcal{L}$ within the neighborhood, there is a constant $\mathcal{K}'>0$ satisfying \begin{equation} \label{eq:converge_Xi_boundary} \Xi(\ell,h,\gamma) -\Xi(\ell^*,h,\gamma) \leq -\mathcal{K}' \|\ell - \ell^* \|_2 . \end{equation} Then, (\ref{eq:consistency_emp_selection_shrinkage_eq1}) and (\ref{eq:consistency_emp_selection_shrinkage_eq2}) still hold. \end{itemize} \end{theorem} The two conditions \eqref{eq:converge_Xi} and \eqref{eq:converge_Xi_boundary} ensure that the parameter $\ell^*$ is locally identifiable in a neighborhood of $\ell^*$. In general, the two conditions depend on the structure of $L^{\Sigma}$. \subsection{Combination of prior models} \label{subsec:combination_priors} An extensive simulation analysis revealed that there is considerable variation in the shape of the power functions and the values of $\tilde{t} = (t_0,t_1,t_2)$, especially when the condition number of $\Sigma_p$ is relatively large. In this subsection, we consider a convenient collection of priors that are representative of certain structural scenarios. A composite test, called $\widehat{T}_{\max}$, is defined as the maximum of the standardized statistics $\widehat{T}(f_{\ell_i^*})$ where $\ell_i^*$ is obtained from Algorithm \ref{algo:empricial_selection_shrinkage} under prior $\tilde{t}_i$, $i=1,\dots, m$. The following strategy is applicable to LR, LH and BNP. We therefore continue to use $\widehat{T}(f)$ to denote the general test statistic. In summary, we propose to test the hypothesis by rejecting for large values of the statistic \[ \widehat{T}_{\max} = \max_{\tilde{t}\in \widetilde{\Pi}} \widehat{T}(f_{\ell_i^*} ), \] where $\widetilde{\Pi} = \{\tilde{t}_1,\dots,\tilde{t}_m\}$, $m\geq 1$, is a pre-specified finite class of weights. A simple but effective choice of $\widetilde{\Pi}$ consists of the three canonical weights $\tilde{t}_1 = (1,0,0)$, $\tilde{t}_2 = (0,1,0)$, $\tilde{t}_3 = (0,0,1)$. \begin{theorem} \label{thm:asymp_normality_Tmax} Suppose \textbf{C1}--\textbf{C6} hold and $\mathfrak{F}$ satisfies condition (i)--(iv). For each $i= 1,\dots, m$, {assume that $\ell_{in}^*$ is a sequence of local maximizers of the empirical power function $\widehat{\Xi}(\ell,\widehat{h},\gamma_n)$ under prior model with weight $\tilde{t}_i$ such that \[n^{1/4} \|\ell_{in}^* - \ell_{i}^*\|_2 = O_p(1).\] (See (\ref{eq:consistency_emp_selection_shrinkage_eq1})).} Then, under the null hypothesis $H_0\colon BC= 0$, \[ \big(\widehat{T}(f_{\ell_{1n}^*}),\dots,\widehat{T}(f_{\ell_{mn}^*}) \big) \Longrightarrow \mathcal{N}\big(0, \Delta_*\big), \] where $\Delta_*$ is an $m\times m$ matrix with diagonal entries $1$ and $(i,j)$-th off-diagonal entry \[ \Delta^{-1/2} (f_{\ell^*_{i}},\gamma) \Delta(f_{\ell^*_{i}},f_{\ell^*_{j}},\gamma) \Delta^{-1/2} (f_{\ell^*_{j}},\gamma). \] \end{theorem} Theorem \ref{thm:asymp_normality_Tmax} shows that $\widehat{T}_{\max}$ has a non-degenerate limiting distribution under $H_0$. It is worth mentioning that LR, LH and BNP share the covariance matrix $\Delta_*$. Theorem \ref{thm:asymp_normality_Tmax} can be used to determine the cut-off values of the test by deriving analytical formulas for the quantiles of the limiting distribution. Aiming to avoid complex calculations, a parametric bootstrap procedure is applied to approximate the cut-off values. Specifically, $\Delta_*$ is first estimated by $\widehat{\Delta}_*$, and then bootstrap replicates are generated by simulating from $\mathcal{N}(0, \widehat{\Delta}^*)$, thereby providing an approximation of the null distribution of $\widehat{T}_{\max}$. Replacing $\Delta(f_{\ell^*_{i}},f_{\ell^*_{j}},\gamma)$ with $\widehat{\Delta}(f_{\ell^*_{i}},f_{\ell^*_{j}},\gamma_n)$ yields the natural estimator. \begin{remark} \label{remark:non_negative_Delta*} Observe that $\widehat{\Delta}_*$ defined above may not be nonnegative definite even though it is symmetric. If such a case occurs, the resulting estimator can be projected onto its closest non-negative definite matrix simply by setting the negative eigenvalues to zero. This covariance matrix estimator is denoted by $\widehat{\Delta}_*^+$ and it is used for generating the bootstraps samples. \end{remark} \section{Ridge and higher-order regularizers} \label{sec:ridge_regu_higher_order} \subsection{Ridge regularization} \label{subsec:ridge_regu} One of the most commonly used shrinkage procedures in statistics is ridge regularization, corresponding to choosing $f_{\ell}(x) = 1/(x - \ell)$, $\ell <0$, so that $f_{\ell}(\widehat{\bm\Sigma}_p) = (\widehat{\bm\Sigma}_p - \ell I_p)^{-1}$. It is an effective way to shift $\widehat{\bm\Sigma}_p$ away from singularity by adding a ridge term $-\ell I_p$. In this subsection, we apply the results of Sections \ref{sec:methodology} and \ref{sec:locally_most_powerful_test} using the ridge-shrinkage family \[\mathfrak{F}_{ridge} \coloneqq \{f_{\ell}(x) = (x -\ell)^{-1} ,\ \ell \in [\underline{\ell},\ \overline{\ell}]\}, \quad -\infty<\underline{\ell}<\overline{\ell}<0.\] In the literature, ridge-regularization was applied to high-dimensional one- and two-sample mean tests in \citet{chen2011regularized} and \citet{LiAuePaulPengWang}. Hence, this subsection is a generalization of their methods to general linear hypotheses. From the aspect of population covariance estimation, ridge-regularization can be viewed as an order-one estimation where $\Sigma_p$ is estimated by a weighted average of $\widehat{\bm\Sigma}_p$ and $I_p$, namely $\alpha_0 I_p + \alpha_1 \widehat{\bm\Sigma}_p $. The estimator is equivalent to ridge-regularization with $\ell = {-\alpha_0/\alpha_1}$ for testing purposes. Within a restricted region of $(\alpha_1,\alpha_2)$, the large eigenvalues of $\widehat{\bm\Sigma}_p$ are shrunk down and the small ones are lifted upward. It is a desired property since in high-dimensional settings, large sample eigenvalues are systematically biased upward and small sample eigenvalues downwards. An important advantage of ridge regularization is that the test procedure is computationally efficient due to the fact that $\Omega(f_{\ell},\gamma)$ and $\Delta(f_{\ell},\gamma)$ admit closed forms as shown in Lemma \ref{lemma:special_form_ARHT}. These quantities can be estimated by $\widehat{\Omega}_{\ell}(\gamma_n)=\widehat\Theta(\ell,\gamma_n)-1$ and $\widehat{\Delta}_{\ell}(\gamma_n)=2\widehat\delta(\ell,\ell,\gamma_n)$, respectively. A closed-form estimator $\widehat{\Xi}_\ell(\widehat{h},\gamma_n)$ is then also available for $\Xi({\ell}, h, \gamma)$. This leads to the following algorithm. \begin{algo}[Ridge-regularized test procedure] \label{algo:ridge_tests} {~} \vspace{-.1cm} \begin{itemize}\itemsep-.1ex \item[1.] Specify prior weights $\tilde{t} = (t_0,t_1,t_2)$; \item[2.] With $m_{n,p}(\ell) = p^{-1}\mathrm{tr}(\widehat{\bm\Sigma}_p -\ell I_p)^{-1}$, compute, for any $\ell\in [\underline{\ell}, \overline{\ell}]$, \begin{align*} \widehat{\Theta}({\ell}, \gamma_n) &= \{1-\gamma_n -\gamma_n\ell m_{n,p}(\ell)\}^{-1},\\ \widehat{\Omega}_{\ell}(\gamma_n) &= \widehat{\Theta}(\ell,\gamma_n) -1 ,\\ \widehat{\Delta}_\ell(\gamma_n) &= 2\gamma_n\{1+ \ell m_{n,p}(\ell)\} \widehat{\Theta}^3(\ell,\gamma_n) + 2\gamma_n\ell \{ m_{n,p}(\ell) + \ell m'_{n,p}(\ell)\}\widehat{\Theta}^4(\ell, \gamma_n); \end{align*} \item[3.] For any $\ell\in [\underline{\ell},~ \overline{\ell}]$, compute $\widehat{h}(\ell,\gamma_n) = \sum_{j=0}^2 t_j \widehat{\rho}_j(\ell,\gamma_n)$ as defined in (\ref{eq:rho0_3}) and \[\widehat{\Xi}_{\ell}(\widehat{h},\gamma_n) = \frac{\widehat{h}(\ell,\gamma_n) }{\widehat\Delta^{1/2}_{\ell}(\gamma_n)};\] \item[4.] Select $\ell^{*} = \mbox{arg}\max_{\ell\in [\underline{\ell}, ~\overline{\ell}]}\widehat{\Xi}_\ell(\widehat{h},\gamma_n)$; \item[5.] Use one of the standardized statistics \begin{align*} \widehat{T}^{\rm LR}(\ell^{*}) & \coloneqq\frac{\sqrt{n}\{1+\widehat{\Omega}_{\ell^{*}}(\gamma_n)\} }{q^{1/2}\widehat{\Delta}^{1/2}_{\ell^{*}}(\gamma_n)} [T^{\rm LR}(\ell^{*}) - q \log\{1+\widehat{\Omega}_{\ell^{*}}(\gamma_n)\}],\\ \widehat{T}^{\rm LH}(\ell^{*}) & \coloneqq\frac{\sqrt{n}}{q^{1/2}\widehat{\Delta}^{1/2}_{\ell^{*}}(\gamma_n)}[T^{\rm LH}(\ell^{*}) - q\widehat{\Omega}_{\ell^{*}}(\gamma_n)],\\ \widehat{T}^{\rm BNP}(\ell^{*}) & \coloneqq\frac{\sqrt{n}\{1+\widehat{\Omega}_{\ell^{*}}(\gamma_n)\}^2}{q^{1/2}\widehat{\Delta}^{1/2}_{\ell^{*}}(\gamma_n)}\Big[T^{\rm BNP}(\ell^{*}) - \frac{q\widehat{\Omega}_{\ell^{*}}(\gamma_n)}{1+\widehat{\Omega}_{\ell^{*}}(\gamma_n)}\Big], \end{align*} where \begin{align*} T^{\rm LR}(\ell^{*}) = \sum\nolimits_{i=1}^q\log(1 + \lambda_i), \quad T^{\rm LH}(\ell^{*}) = \sum\nolimits_{i=1}^q \lambda_i, \quad T^{\rm BNP}(\ell^{*}) = \sum\nolimits_{i=1}^q \frac{\lambda_i}{1+\lambda_i}, \end{align*} and $\lambda_1,\ldots,\lambda_q$ are the eigenvalues of $n^{-1} Q_n^T \mathbf{Y}^T(\widehat{\bm\Sigma}_p - \ell^{*} I_p)^{-1} \mathbf{Y} Q_n$. Reject the null at asymptotic level $\alpha$ if the test statistic value exceeds $\xi_\alpha$. \end{itemize} \end{algo} Although in theory any negative $\ell^*$ is allowed in the test procedure, in practice, meaningful lower and upper bounds $\underline{\ell}$ and $\overline{\ell}$ are needed to ensure stability of the test statistics when $p \approx n$ or $p>n$ and also to carry out the search for optimal $\ell$ at a low computational cost. In our simulation settings we use $\overline{\ell} = - p^{-1} \mathrm{tr}(\widehat{\bm\Sigma}_p)/100$ and $\underline{\ell} = - 20\lambda_{\max}(\widehat{\bm\Sigma}_p)$, which generally lead to quite robust performance. \begin{table}[htbp] \setlength{\belowcaptionskip}{-10pt} \begin{center} \scriptsize \resizebox{\textwidth}{!}{ \begin{tabular}{cc@{\quad}ccc@{\quad}ccc@{\quad}ccc@{\quad}ccc} \hline \multicolumn{2}{c}{\multirow{2}{*}{} & \multicolumn{6}{c}{$\Sigma =I_p$} & \multicolumn{6}{c}{$\Sigma = \Sigma_{den}$} \\ & & \multicolumn{3}{c}{$k =3$} & \multicolumn{3}{c}{$k=5$} & \multicolumn{3}{c}{$k =3$} & \multicolumn{3}{c}{$k=5$} \\ \multicolumn{2}{c}{$n=300$,\ $p\ =$} & 150 & 600 & 3000 & 150 & 600 & 3000 & 150 & 600 & 3000 & 150 & 600 & 3000 \\ \cline{1-14} \multirow{3}{*}{LR$_{\rm ridge}$} & $\tilde{t}_1 $ & 5.4 & 5.2 & 5.1 & 5.2 & 5.1 & 5.1 & 4.9 & 4.4 & 4.7 & 4.4 & 3.3 & 4.2 \\ & $\tilde{t}_2 $ & 5.4 & 5.2 & 5.1 & 5.2 & 5.1 & 5.1 & 4.9 & 5.2 & 4.9 & 4.4 & 4.9 & 4.7 \\ & $\tilde{t}_3 $ & 5.3 & 5.2 & 5.1 & 5.2 & 5.1 & 5.1 & 5.8 & 5.9 & 5.1 & 5.3 & 5.2 & 4.9 \\[.1cm] \multirow{3}{*}{LH$_{\rm ridge}$} & $\tilde{t}_1 $ & 5.4 & 5.2 & 5.1 & 5.3 & 5.1 & 5.2 & 6.2 & 7.2 & 5.7 & 6.2 & 7.7 & 6.0 \\ & $\tilde{t}_2 $ & 5.4 & 5.2 & 5.1 & 5.3 & 5.1 & 5.2 & 6.2 & 5.9 & 5.2 & 6.2 & 5.9 & 5.1 \\ & $\tilde{t}_3 $ & 5.3 & 5.2 & 5.1 & 5.3 & 5.1 & 5.2 & 5.8 & 5.9 & 5.2 & 5.4 & 5.2 & 5.0 \\[.1cm] \multirow{3}{*}{BNP$_{\rm ridge}$} & $\tilde{t}_1 $ & 5.3 & 5.2 & 5.0 & 5.2 & 5.0 & 5.0 & 4.0 & 2.5 & 3.7 & 2.9 & 1.3 & 3.1 \\ & $\tilde{t}_2 $ & 5.4 & 5.2 & 5.0 & 5.2 & 5.0 & 5.0 & 4.0 & 4.7 & 4.6 & 2.9 & 3.9 & 4.4 \\ & $\tilde{t}_3 $ & 5.3 & 5.2 & 5.0 & 5.2 & 5.0 & 5.0 & 5.8 & 5.8 & 5.0 & 5.3 & 5.1 & 4.7 \\ \hline \multirow{3}{*}{LR$_{\rm high}$} & $\tilde{t}_1 $ &6.5 &6.3 &5.3 &6.5 & 5.3 & 5.5 & 6.0 & 5.8 & 5.1 & 6.5 &5.9 & 4.5 \\ & $\tilde{t}_2 $ &6.5 & 6.3 & 5.3 & 6.5 & 5.3 & 5.5 & 8.3 & 6.8 & 5.5 & 8.4 & 7.2 & 5.2\\ & $\tilde{t}_3 $ &6.6 &6.3 &5.3 &6.6 &5.3 &5.5 &6.7 &6.7 &5.5 &6.4 &7.1 &5.2 \\[.1cm] \multirow{3}{*}{LH$_{\rm high}$} & $\tilde{t}_1 $ &6.7 &6.4 &5.4 &6.8 &5.5 &5.7 &6.1 &5.9 &5.7 &6.7 &6.2 &5.5 \\ & $\tilde{t}_2 $ &6.7 &6.4 &5.4 &6.8 &5.4 &5.7 &8.3 &6.8 &5.6 &8.5 &7.3 &5.5\\ & $\tilde{t}_3 $ &6.7 &6.4 &5.4 &6.8 &5.4 &5.7 &6.7 &6.7 &5.6 &6.5 &7.2 &5.5 \\[.1cm] \multirow{3}{*}{BNP$_{\rm high}$} & $\tilde{t}_1 $ &6.2 &6.3 &5.2 &6.1 &5.3 &5.2 &5.9 &5.7 &4.6 &6.4 &5.5 &3.7 \\ & $\tilde{t}_2 $ &6.3 &6.3 &5.2 &6.1 &5.2 &5.2 &8.3 &6.7 &5.3 &8.3 &7.0 &4.9 \\ & $\tilde{t}_3 $ &6.3 &6.3 &5.1 &6.1 &5.2 &5.2 &6.6 &6.6 &5.3 &6.4 &6.9 &4.9 \\ \hline \multicolumn{2}{l}{~LR$_{\rm comp}$} &5.1 &5.1 &5.0 &5.4 &5.3 &5.0 &6.0 &5.1 &5.5 &5.6 &5.0 &5.1 \\[.1cm] \multicolumn{2}{l}{~LH$_{\rm comp}$} &5.1 &5.1 &5.1 &5.5 &5.3 &5.1 &6.7 &5.8 &5.9 &6.9 &6.2 &5.7 \\[.1cm] \multicolumn{2}{l}{~BNP$_{\rm comp}$} &5.1 &5.0 &5.0 &5.4 &5.2 &5.0 &5.4 &4.5 &5.1 &4.7 &4.4 &4.6\\ \hline \multicolumn{2}{l}{~ZGZ} &5.6 &5.7 &5.2 &5.6 &4.8 &5.2 &5.9 &5.5 &5.4 &5.4 &5.4 &5.3\\ \multicolumn{2}{l}{~CX (Oracle)} &5.6 & 6.3 &7.0 &7.3 &6.9 & 8.6 &5.8 &5.9 &6.8 &6.0 &7.2 &9.0 \\ \hline \end{tabular}} \caption{\footnotesize Empirical sizes at level $5\%$. $\Sigma = \mbox{ID}$ and $\Sigma_{den}$; $\tilde{t}_1 = (1,0,0),$ $\tilde{t}_2 = (0,1,0)$, $\tilde{t}_3= (0,0,1)$.} \label{table:emp_size_ID_den} \end{center} \end{table} The composite test procedure with ridge-regularization is summarized below. \begin{algo}[Composite ridge-regularized test procedure] \label{algo:composite_ridge_test} {~} \vspace{-.1cm} \begin{itemize}\itemsep-.1ex \item[1.] Select prior weights $\widetilde{\Pi} = (\tilde{t}_1,\dots,\tilde{t}_m) $. The canonical choice is $((1,0,0), (0,1,0),\break (0,0,1))$; \item[2.] For each $\tilde{t}_j$ in $\widetilde{\Pi}$, run Algorithm \ref{algo:ridge_tests}, get the standardized test statistic $\widehat{T}(\ell^*_j)$ and compute $\widehat{T}_{\max} = \max_{1\leq j \leq m} \widehat{T}(\ell^*_j)$; \item[3.] With the selected tuning parameters $(\ell^*_1,\ell^*_2,\ell^*_3)$ compute the matrix $\widehat{\Delta}_*$ whose diagonal elements are equal to one and whose $(i,j)$-th entry for $i\neq j$ is \[\widehat{\Delta}^{-1/2}_{\ell^*_i}(\gamma_n)\widehat{\Delta}_{\ell^*_i,\ell^*_j}(\gamma_n)\widehat{\Delta}^{-1/2}_{\ell^*_j}(\gamma_n),\] where $\widehat{\Delta}_{\ell^*_i}(\gamma_n)$ is defined in Step 2 of Algorithm \ref{algo:ridge_tests} and \begin{align*} \widehat{\Delta}_{\ell^*_i,\ell^*_j}(\gamma_n) = 2\widehat{\Theta}({\ell^*_i}, \gamma_n) \widehat{\Theta}({\ell^*_j}, \gamma_n) \Big[\frac{\ell^*_i \widehat{\Theta}({\ell^*_i}, \gamma_n)- \ell^*_j\widehat{\Theta}({\ell^*_j}, \gamma_n) }{\ell^*_i -\ell^*_j }-1\Big]; \end{align*} \item[4.] Project $\widehat{\Delta}_*$ to its closest non-negative definite matrix $\widehat{\Delta}^+_*$ by setting the negative eigenvalues to zero. Generate $\varepsilon_1,\dots, \varepsilon_{G}$ with $\varepsilon_{b} = \max_{1\leq i\leq m} Z_i^{(b)}$ with $Z^{(b)} = [Z_i^{(b)}]_{i=1}^m \sim \mathcal{N}(0,\widehat{\Delta}^+_*)$. \item[5.] Compute the $p$-value as $G^{-1} \sum_{b=1}^G \mathbbm{1}\{\varepsilon_b > \widehat{T}_{\max}\}$. \end{itemize} \end{algo} \subsection{Extension to higher-order regularizers} \label{subsec:higher_order_extension} Through an extensive simulation study in a MANOVA setting, it is shown in Section \ref{sec:simulation} that the ridge-regularized tests compare favorably against a host of existing test procedures. This is consistent with the findings in \citet{LiAuePaulPengWang} in the two-sample mean test framework. Ridge-shrinkage rescales $\widehat{\mathbf{H}}_p$ by $(\widehat{\bm\Sigma}_p- \ell I_p)^{-1}$ instead of $\widehat{\bm\Sigma}_p^{-1}$. Broader classes of scaling matrices have been studied extensively \citep[see][for an overview]{ledoit2012nonlinear}. They can be set up in the form $f(\widehat{\bm\Sigma}_p)$. When $f(\cdot)$ is analytic, such scaling falls within the class of the proposed tests. The flexibility provided by a larger class of scaling matrices can be useful to design test procedures for detecting a specific kind of alternative. The choice of the test procedure may for example be guided by questions such as \emph{Which $f$ leads to the best asymptotic power under a specific sequence of local alternatives, if $H_0$ is rejected based on large eigenvalues of $\mathbf{M}(f)$?} While a full characterization of this question is beyond the scope of this paper, a partial answer may be provided by restricting to functions $f$ in the higher-order class \[ \mathfrak{F}_{{\rm high}} = \Big\{ f_{\ell}(x) = \Big[\sum\nolimits_{j=0}^\kappa l_j x^j\Big]^{-1}\colon \ell = (l_0, \dots, l_\kappa)^T \in \mathcal{G} \Big\}, \] where $\mathcal{G}$ is such that $f_{\ell}$ is uniformly bounded and monotonically decreasing on $\mathcal{X}$, for any $\ell\in \mathcal{G}$. These higher-order shrinkage functions are weighted averages of ridge-type shrinkage functions. To see this, suppose the polynomial $\sum_{j=0}^\kappa l_j x^j$ has roots $r_1,\dots, r_{\kappa_0}\in\mathbb{C}\setminus\mathcal{X}$ with multiplicity $s_1,\dots, s_{\kappa_0}\in\mathbb{N}^+$. Via basic algebra, $f_{\ell}$ can be expressed as \begin{equation} \label{eq:weight_average_repexression_f} f_{\ell}(x) = \Big[\sum\nolimits_{j=0}^\kappa l_j x^j\Big]^{-1} = \sum\nolimits_{j=1}^{\kappa_0}\sum\nolimits_{i=1}^{s_{\kappa_0}} w_{ji} (x -r_j)^{-i}, \end{equation} with some weights $w_{ji}\in\mathbb{C}$. If all roots are simple, $f_{\ell}$ is a weighted average of ridge-regularization with $\kappa$ different parameters. Heuristically, it is expected that a higher order $f_{\ell}$ yields tests more robust against unfavorable selection of ridge shrinkage parameter. The design of $\mathcal{G}$ is not easy when $\kappa$ is large. Here, we select $\kappa = 3$, which is the minimum degree that allows $f^{-1}_{\ell}$ to be both locally convex and concave. In this case, the complexity of selecting the optimal regularizer is significantly higher than for ridge-regularization. Due to space limitations, we move the design of $\mathcal{G}$ and the test procedure when $\kappa=3$ to Section \ref{sec:add_material_higher_order} of the Supplementary Material. \section{Simulations} \label{sec:simulation} In this section, the proposed tests are compared by means of a simulation study to two representative existing methods in the literature, \citet{zhou2017high} (ZGZ) and \citet{cai2014high} (CX). We focus on one-way MANOVA, a set-up for which both competing methods are applicable. It is worth mentioning that CX requires a good estimator of the precision matrix $\Sigma_p^{-1}$, that is typically unavailable when both $\Sigma_p$ and $\Sigma_p^{-1}$ are dense. In the simulations, the true $\Sigma_p^{-1}$ is utilized for CX, thus making it an oracle procedure. In the following, LR$_{\rm ridge}$, LH$_{\rm ridge}$, and BNP$_{\rm ridge}$ denote the ridge-regularized tests presented in Algorithm \ref{algo:ridge_tests}. LR$_{\rm high}$, LH$_{\rm high}$, and BNP$_{\rm high}$ denote the tests with higher-order shrinkage introduced in Section \ref{subsec:higher_order_extension} with $\kappa =3$. LR$_{\rm comp}$, LH$_{\rm comp}$ and BNP$_{\rm comp}$ denote the composite ridge-regularized tests of Algorithm \ref{algo:composite_ridge_test} with the canonical choice of $\widetilde{\Pi}= ((1,0,0), (0,1,0), (0,0,1))$. \subsection{Settings} The observation matrix $\mathbf{Y}$ was generated as in (\ref{eq:linear_model}) with normally distributed $\mathbf{{Z}}$. Specifically, we selected $k =3$ or $5$, and $N =300$. For $k=3$, the three groups had $75, 90$ and $135$ observations, respectively. For $k=5$, the design was balanced with each group containing $60$ observations. The dimension $p$ was $150, 600, 3000$, so that $\gamma_n = p/n \approx 0.5, 2$ and $10$. The columns of $B$ were the $k$ group mean vectors. Accordingly, the columns of $X$ were the group index indicators of observation subjects. We selected $C$ to be the successive contrast matrix of order $q = k-1$. This is a standard one-way MANOVA setting. \begin{figure}[htbp] \setlength{\belowcaptionskip}{-5pt} \includegraphics[width = \linewidth,height = 0.4\linewidth]{SA_Sigma_Dense_K_5_Prior_100_Method_BNP.eps} \caption{\footnotesize Size-adjusted power with $\Sigma=\Sigma_{den}$,~$k=5$. Rows (top to bottom): $B =\mbox{Dense and Sparse} $; Columns (left to right): $p = 150, 600, 3000$. BNP$_{\rm comp}$ (red, solid); ZGZ (green, solid); oracle CX (purple, solid); BNP$_{\rm ridge}$ (black, dashed) and BNP$_{\rm high}$ (blue, dotted-dashed) with $\tilde{t} = (1,0,0)$.} \label{fig:SA_Sigma_dense_k5_t100_BNP} \end{figure} Under the null, $B$ is the zero matrix. Under the alternative, for each setting of the parameters and each replicate, $B$ is generated using one of the following models. \begin{itemize} \item[(i)] \emph{Dense alternative}: The entries of $B$ are i.i.d.\ $\mathcal{N}(0,c^2)$ with $c = O(n^{-1/4}p^{-1/2})$ used to tune signal strength to a non-trivial level. \item[(ii)] \emph{Sparse altenative}: $B = c \mathcal{R} \bm{\mathcal{V}}$ with $c = O(n^{-1/4}p^{-1/2})$, where $\mathcal{R}$ is a diagonal $p\times p$ matrix with 10\% randomly and uniformly selected diagonal entries being $\sqrt{10}$ and the remaining 90\% being equal to 0, and $\bm{\mathcal{V}}$ is a $p\times p$ matrix with i.i.d.\ standard normal entries. \end{itemize} The following four models for the covariance matrix $\Sigma =\Sigma_p$ were considered. All models were further scaled so that $\mathrm{tr}(\Sigma_p) = p$. \begin{itemize} \item[(i)] \emph{Identity matrix} (ID): $\Sigma = I_p$. \item[(ii)] \emph{Dense case} $\Sigma_{den}$: Here $\Sigma= P \Sigma_{(1)} P^T$ with a unitary matrix $P$ randomly generated from the Haar measure and resampled for each different setting, and a diagonal matrix $\Sigma_{(1)}$ whose eigenvalues are given by $\lambda_j = (0.1+j)^6 + 0.05 p^6$, $j = 1,\dots,p$. The eigenvalues of $\Sigma$ decay slowly, so that no dominating leading eigenvalue exists. \item[(iii)] \emph{Toeplitz case} $\Sigma_{toep}$: Here $\Sigma$ is a Teoplitz matrix with the $(i,j)$-th element equal to $0.5^{|i-j|}$. It is a setting where $\Sigma^{-1}$ is sparse but $\Sigma$ is dense. \item[(iv)] \emph{Discrete case} $\Sigma_{dis}$: Here $\Sigma= P \Sigma_{(2)} P^T$ with $P$ generated in the same way as in (ii), and $\Sigma_{(2)}$ is a diagonal matrix with 40\% eigenvalues 1, 40\% eigenvalues 3 and 20\% eigenvalues 10. \end{itemize} \begin{table}[htbp] \setlength{\belowcaptionskip}{-10pt} \begin{center} \scriptsize \resizebox{\textwidth}{!}{ \begin{tabular}{cc@{\quad}ccc@{\quad}ccc@{\quad}ccc@{\quad}ccc} \hline \multicolumn{2}{c}{\multirow{2}{*}{} & \multicolumn{6}{c}{$\Sigma =\Sigma_{dis}$} & \multicolumn{6}{c}{$\Sigma = \Sigma_{toep}$} \\ & & \multicolumn{3}{c}{$k =3$} & \multicolumn{3}{c}{$k=5$} & \multicolumn{3}{c}{$k =3$} & \multicolumn{3}{c}{$k=5$} \\ \multicolumn{2}{c}{$n=300$,\ $p\ =$} & 150 & 600 & 3000 & 150 & 600 & 3000 & 150 & 600 & 3000 & 150 & 600 & 3000 \\ \cline{1-14} \multirow{3}{*}{LR$_{\rm ridge}$}& $\tilde{t}_1 $ & 4.8 & 5.0 & 4.6 & 4.7 & 4.5 & 5.0 & 5.4 & 4.4 & 4.8 & 4.5 & 4.6 & 4.6 \\ & $\tilde{t}_2 $ &5.1 & 5.2 & 4.9 & 5.2 & 4.6 & 5.1 & 5.4 & 4.9 & 4.9 & 4.9 & 4.8 & 5.0 \\ & $\tilde{t}_3 $ &5.6 & 5.5 & 5.1 & 5.7 & 5.3 & 5.3 & 5.8 & 5.2 & 5.0 & 5.7 & 5.4 & 5.1 \\[.1cm] \multirow{3}{*}{LH$_{\rm ridge}$}& $\tilde{t}_1 $ &5.8 & 6.0 & 5.2 & 6.6 & 6.3 & 5.6 & 6.4 & 5.3 & 5.2 & 6.2 & 6.3 & 5.3 \\ & $\tilde{t}_2 $ & 5.7 & 5.7 & 5.1 & 6.3 & 5.6 & 5.5 & 5.9 & 5.3 & 5.0 & 5.8 & 5.6 & 5.3 \\ & $\tilde{t}_3 $ &5.6 & 5.5 & 5.2 & 5.8 & 5.3 & 5.4 & 5.8 & 5.3 & 5.1 & 5.7 & 5.4 & 5.2 \\[.1cm] \multirow{3}{*}{BNP$_{\rm ridge}$}& $\tilde{t}_1 $ & 3.9 & 4.1 & 4.3 & 3.1 & 3.1 & 4.1 & 4.4 & 3.7 & 4.4 & 3.2 & 3.4 & 3.9 \\ & $\tilde{t}_2 $ &4.6 & 4.8 & 4.8 & 4.1 & 4.0 & 4.9 & 4.9 & 4.4 & 4.8 & 4.1 & 4.3 & 4.7 \\ & $\tilde{t}_3 $ &5.5 & 5.5 & 5.0 & 5.7 & 5.2 & 5.1 & 5.8 & 5.2 & 5.0 & 5.6 & 5.4 & 5.1 \\ \hline \multirow{3}{*}{LR$_{\rm high}$} & $\tilde{t}_1 $ &6.3 &6.4 &4.8 &5.9 &7.0 &5.5 &7.1 &7.0 &5.3 &7.5 &6.9 &5.2\\ & $\tilde{t}_2 $ &7.9 &6.5 &4.8 &8.3 &7.1 &5.5 &7.6 &7.2 &5.3 &7.8 &7.0 &5.2\\ & $\tilde{t}_3 $ & 6.1 &5.6 &4.8 &6.4 &6.1 &5.5 &6.7 &6.5 &5.3 &6.6 &6.4 &5.2\\[.1cm] \multirow{3}{*}{LH$_{\rm high}$} & $\tilde{t}_1 $ & 6.6 &6.5 &5.0 &6.2 &7.2 &5.7 &7.2 &7.2 &5.5 &7.7 &7.0 &5.5\\ & $\tilde{t}_2 $ &8.0 &6.6 &5.0 &8.5 &7.2 &5.7 &7.8 &7.2 &5.5 &8.0 &7.1 &5.5\\ & $\tilde{t}_3 $ &6.2 &5.6 &5.0 &6.5 &6.2 &5.7 &6.7 &6.5 &5.5 &6.7 &6.5 &5.5\\[.1cm] \multirow{3}{*}{BNP$_{\rm high}$} & $\tilde{t}_1 $ &6.1 &6.3 &4.7 &5.6 &6.8 &5.3 &7.1 &7.0 &5.2 &7.2 &6.8 &5.1\\ & $\tilde{t}_2 $ &7.9 &6.4 &4.7 &8.2 &7.0 &5.3 &7.5 &7.1 &5.2 &7.7 &7.0 &5.1\\ &$\tilde{t}_3 $ &6.1 &5.5 &4.7 &6.4 &6.0 &5.3 &6.6 &6.4 &5.2 &6.5 &6.3 &5.1\\ \hline \multicolumn{2}{l}{~LR$_{\rm comp}$} &6.2 &5.2 &5.0 &5.2 &5.3 &5.5 &5.9 &5.0 &5.1 &5.5 &4.9 &4.9\\[.1cm] \multicolumn{2}{l}{~LH$_{\rm comp}$} &7.0 &5.9 &5.3 &6.5 &6.4 &6.0 &6.6 &5.6 &5.3 &6.6 &5.7 &5.3\\[.1cm] \multicolumn{2}{l}{~BNP$_{\rm comp}$} &5.5 &4.6 &4.8 &4.4 &4.6 &5.0 &5.4 &4.6 &4.9 &4.8 &4.4 &4.6\\ \hline \multicolumn{2}{l}{~ZGZ} &5.5 &4.7 &4.6 &5.7 &5.1 &5.3 &6.0 &5.5 &5.0 &5.9 &5.6 &5.0 \\[.1cm] \multicolumn{2}{l}{~CX (Oracle) } &5.3 &5.9 &6.6 &6.8 &7.2 &8.6 &5.3 &6.2 &6.8 &6.8 &7.2 &8.4\\ \hline \end{tabular}} \caption{\footnotesize Empirical sizes at level $5\%$. $\Sigma = \Sigma_{dis}$ and $\Sigma_{toep}$; $\tilde{t}_1 = (1,0,0),$ $\tilde{t}_2 = (0,1,0)$, $\tilde{t}_3= (0,0,1)$.} \label{table:emp_size_dis_toep} \end{center} \end{table} All tests were conducted at significance level $\alpha = 0.05$. Empirical sizes for the various tests are shown in Tables \ref{table:emp_size_ID_den} and \ref{table:emp_size_dis_toep}. Empirical power curves versus expected signal strength $n^{1/4}p^{1/2}c$ are reported in Figures \ref{fig:SA_Sigma_dense_k5_t100_BNP}--\ref{fig:SA_Sigma_toep_k3_t010_LR}. To better compare the power of each test, curves are displayed after size adjustment where the tests utilize the size-adjusted cut-off values based on the actual null distribution computed by simulations. Counterparts of Figures \ref{fig:SA_Sigma_dense_k5_t100_BNP}--\ref{fig:SA_Sigma_toep_k3_t010_LR} that utilize asymptotic (approximate) cut-off values are reported in Section \ref{sec:nominal_simulation} of the Supplementary Material. The difference between the two types is limited. LR, LH and BNP criteria behave similarly across simulation settings, as indicated by Theorem \ref{thm:probability_local_power_three_stat}. Therefore, only one of them is displayed in each figure for ease of visualization. More figures can be found in Section \ref{sec:additional_simulation} of the Supplementary Material. Note that, in some of the settings, several of the power curves nearly overlap, creating an occlusion effect. Then, power curves corresponding to the composite tests are plotted as the top layer. \subsection{Summary of simulation results} \label{subsec:summary_simulation} Tables \ref{table:emp_size_ID_den} and \ref{table:emp_size_dis_toep} show the empirical sizes of the proposed tests are mostly controlled under 7.5\%. The slight oversize is caused by the fact that $\mathbf{M}(f)$ behaves like a quadratic form, therefore the finite sample distribution is skewed. LR and BNP tests are more conservative than LH tests because the former two calibrate the statistics by transforming eigenvalues of $\mathbf{M}(f)$. Ridge-regularized tests are slightly more conservative under higher-order shrinkage. \begin{figure}[htbp] \setlength{\belowcaptionskip}{-10pt} \includegraphics[width = \linewidth,height = 0.4\linewidth]{SA_Sigma_Dense_K_5_Prior_001_Method_LH.eps} \caption{\footnotesize Size-adjusted power with $\Sigma=\Sigma_{den}$,~$k=5$. Rows (top to bottom): $B =\mbox{Dense and Sparse} $; Columns (left to right): $p = 150, 600, 3000$. LH$_{\rm comp}$ (red, solid); ZGZ (green, solid); oracle CX (purple, solid); LH$_{\rm ridge}$ (black, dashed) and LH$_{\rm high}$ (blue, dotted-dashed) with $\tilde{t} = (0,0,1)$.} \label{fig:SA_Sigma_dense_k5_t001_LH} \end{figure} Note that in both simulation settings, $B$ consists of independent entries. Therefore, $\tilde{t}_1 = (1,0,0)$ is considered as a correctly specified prior, while $\tilde{t}_2 = (0,1,0)$ and $\tilde{t}_3 = (0,0,1)$ are considered as moderately and severely misspecified, respectively. {The composite tests combine $\tilde{t}_1$, $\tilde{t}_2$ and $\tilde{t}_3$, and are therefore considered as consistently capturing the correct prior. We shall treat the composite tests as a baseline to study the effect of prior misspecification, by comparing them to tests using a single $\tilde{t}$. } For each simulation configuration considered in this study, the proposed procedures are as powerful as the procedure with the best performance, except for the cases when $B$ is sparse, $p$ is small, and priors are severely misspecified in the proposed tests; {see Figure \ref{fig:SA_Sigma_toep_k3_t001_LR} in the Supplementary Material}. We highlight the following observations based on the simulation results. \begin{itemize}\itemsep-.2ex \item[(1)] {The composite tests are slightly less efficient than BNP$_{\rm ridge}$ and BNP$_{\rm high}$ when the correct prior $\tilde{t}_1$ is used, as in Figure \ref{fig:SA_Sigma_dense_k5_t100_BNP}. However, as in Figure \ref{fig:SA_Sigma_dense_k5_t001_LH}, when the prior is severely misspecified, the composite test is significantly more powerful. It suggests that the composite tests are robust against prior misspecification, although losing some efficiency against tests with correctly specified priors.} \begin{figure}[htbp] \setlength{\belowcaptionskip}{-5pt} \includegraphics[width = \linewidth,height = 0.4\linewidth]{SA_Sigma_Toeplitz_K_3_Prior_010_Method_LR.eps} \caption{\footnotesize Size-adjusted power with $\Sigma=\Sigma_{toep}$,~$k=3$. Rows (top to bottom): $B =\mbox{Dense and Sparse} $; Columns (left to right): $p = 150, 600, 3000$. LR$_{\rm comp}$ (red, solid); ZGZ (green, solid); oracle CX (purple, solid); LR$_{\rm ridge}$ (black, dashed) and LR$_{\rm high}$ (blue, dotted-dashed) with $\tilde{t} = (0,1,0)$.} \label{fig:SA_Sigma_toep_k3_t010_LR} \end{figure} \item[(2)] {Although ridge-shrinkage and higher-order shrinkage behave similarly under the correct prior, the latter outperforms the former when the prior is misspecified; see Figure \ref{fig:SA_Sigma_dense_k5_t001_LH}. This provides evidence for the robustness of high-order shrinkage against unfavorable ridge shrinkage parameter selection. } \item[(3)] ZGZ is a special case of the proposed test family with $f(x)=1$ for all $x$, which amounts to replacing $\widehat{\bm\Sigma}_p$ with $I_p$. When $\Sigma_p=I_p$, ZGZ appears to be the reasonable option at least intuitively. Note, both $\mathfrak{F}_{\rm ridge}$ and $\mathfrak{F}_{{\rm high}}$ contain functions close to $f(x)=1$. Figures for $\Sigma_p = I_p$ displayed in Section \ref{sec:additional_simulation} of the Supplementary Material show that the proposed tests perform as well as ZGZ in that case. It may be viewed as evidence of the effectiveness of the data-driven shrinkage selection strategy detailed in Section \ref{sec:locally_most_powerful_test}. \item[(4)] {Comparing to ZGZ, when the eigenvalues of $\Sigma_p$ are disperse, the proposed tests are significantly more powerful when $p=150$ and $600$, but behave similarly as ZGZ when $p=3000$. On the other hand, as in Figure \ref{fig:SA_Sigma_dense_k5_t001_LH}, the ridge-regularized test with a severely misspecified prior $\tilde{t}_3$, is close to ZGZ. } \item[(5)] CX is a test specifically designed for sparse alternatives. The procedure shows its advantage in favorable settings, especially when $p=150$. Simulation results suggest that the proposed tests are still comparable to CX even under sparse $BC$ and $\Sigma_p^{-1}$, as long as the prior in use is not severely misspecified. When $p$ is large, the proposed tests are significantly better when $\Sigma_p = I_p$. Evidence may be found in Figures \ref{fig:SA_Sigma_ID_k3_t100_LH}, \ref{fig:SA_Sigma_ID_k5_t010_BNP} and \ref{fig:SA_Sigma_ID_k3_t001_LR} of the Supplementary Material. \end{itemize} \bibliographystyle{apalike}
{'timestamp': '2018-10-05T02:06:39', 'yymm': '1810', 'arxiv_id': '1810.02043', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02043'}
arxiv
\section{Introduction} \subsection{Motivation} \label{motivation} Estimating statistical relationships between variables is fundamental to any knowledge discovery process and has become an important topic in the database community \cite{chen1996data, zhu2002statstream, hall2003benchmarking}. Knowing the relationship between attributes, one can infer useful knowledge about unknown outcomes. For example, knowing that weight and arterial pressure correlate with the odds of contracting certain diseases may guide physicians, to predict whether a patient will become sick within a year or not. Modern database systems gather and store data at very high rates. With predictive maintenance for instance, data often is a stream produced in real-time by multiple sensors. In this setting, the timely detection of changes in the stream is crucial. The early discovery of anomalies can lead to, say, faster recovery and tremendous cost savings. Real-time detection is challenging because of a phenomenon known as \textit{concept drift}~\cite{Barddal2015}: The data distribution and correlation structure can change over time, be it gradually, be it abruptly, in unexpected ways. A real-world example illustrates this: \begin{figure}[] \centering \includegraphics[width=0.98\linewidth]{example_concept_drift.pdf} \caption{Example of concept drift in dependency monitoring.} \label{fig:bioliq} \end{figure} \begin{exmp} \label{exp1} Let \textit{T} and \textit{F} be two sensor streams in a pyrolytic plant. Stream \textit{T} is the temperature in a reactor, while stream \textit{F} is the filling level of the flue gas cyclone connected to its output. Figure~\ref{fig:bioliq} graphs a 24-hours time span with a sampling rate of one second, i.e., $24 \cdot 60^2 = 86400$ values in total, which we scale to $[0,1]$. We report the Mutual Information (\textit{MI}) \cite{shannon1951mathematical} between \textit{T} and \textit{F} at any time over the last 15 minutes, using a sliding window over the last $900$ values. \textit{MI} quantifies the information shared by both variables. At the beginning, the reactor heats up to its operational temperature. The material introduced into the reactor leads to the production of flue gas, stored temporarily in the cyclone for further processing. The \textit{MI} of the two streams suddenly drops from 2.5 bits to 0 at 7:45. The cyclone does not seem to operate as it should, i.e., as in the later time span between 12:00 and 20:00. This is a sign of interruption in the production process. Such interruptions can become very costly if unnoticed. Thus, a careful monitoring of the plant elements is essential, as drifting dependencies might indicate abnormal events. \end{exmp} While the example only features two streams of data, effects over multiple streams are interesting as well. In the real world, data streams often are an open-ended, ever evolving collection of sensor signals. The signals can be noisy, redundant or generated at a varying speed. In such contexts, one needs a dependency estimator satisfying all requirements described next. To our knowledge, any existing solution only fulfils some of them at best. In this article, we propose a new estimator with all these characteristics. \textbf{R1: Multivariate.} Bivariate dependency measures \cite{Szekely2009, Reshef2011} only apply to attribute pairs. Estimating the dependency between more than two attributes is useful as well, but existing attempts to generalize bivariate measures lack efficiency or effectiveness, as we will show in this paper. \textbf{R2: Efficient.} For monitoring, one needs to estimate dependency `at least as fast' as the stream. Next, one often is not only interested in a particular set of attributes, but potentially all of them. Since the number of attribute combinations grows exponentially with the number of attributes, the efficiency of the estimator is crucial, with large data streams in particular. \textbf{R3: General-purpose.} Dependency estimators should not be restricted to specific types of dependency. Existing multivariate estimators are typically limited, e.g., \cite{Schmid2007} can only detect monotonous dependencies and \cite{Nguyen2015UDS} only functional ones. \textbf{R4: Intuitive.} A method is intuitive if its parameters are easy to set, i.e., users understand their impact on the estimation process. Existing solutions typically require a number of unintuitive parameters, and the suggestion of `good' pa\-ra\-me\-ter values often happens at the discretion of the inventors. Different values often yield very different results. Hence, we target at a method that is intuitive to use. \textbf{R5: Non-parametric.} Since real data can exhibit virtually any kind of distribution, it is not reasonable to use measures relying on parametric assumptions. The risk is to systematically miss relevant effects with wrong assumptions. \textbf{R6: Interpretable.} The results of dependency estimators should be interpretable: There should be a maximum and a minimum, such that one can easily interpret a given estimate from `highly dependent' to `independent'. \textbf{R7: Sensitive.} Dependency estimation is not only about deciding whether a relationship exists, but also about quantifying its strength. Database entries generally are observations sampled from a potentially noisy process. The same dependency should get a higher score when observed with more objects, as the size of the observed effect is larger. \textbf{R8: Robust.} Real-world data may be of poor quality. It is common to discretise attributes, for a more compact representation. Next, measuring devices often have a limited precision, such that values are rounded or trimmed, wrongly leading to data points with exactly the same values. Such artefacts can have a negative influence on the estimation. Estimators need to be robust against duplicates and imprecision. \textbf{R9: Anytime flexibility.} A database may be too large to allow for acceptable computation times, and the rate of incoming items from a data stream may vary. Users should be able to trade accuracy for a faster computation and to interrupt the estimation process at any time. In other words, users can set a `budget' they are willing to spend. Conversely, the estimator should return approximate results, ideally with a known quality, in case of early termination. \subsection{Contributions} \textbf{We introduce a framework to estimate multivariate dependency, named \textit{Monte Carlo Dependency Estimation} \textit{(MCDE)}}. \textit{MCDE} quantifies the dependency of an attribute set as the average discrepancy between marginal and conditional distributions via Monte Carlo simulations. Iteratively, a condition is applied on each dimension, in a process called \textit{subspace slicing} \cite{Keller2012}. A statistical test quantifies the discrepancy between the marginal and conditional distributions of a dimension taken at random. \textit{MCDE} is abstract, since the underlying statistical test is left unspecified. We determine a lower bound for the quality of the estimation, allowing to trade a quantifiable level of accuracy for a computational advantage. \textbf{As a proof of concept, we instantiate a new dependency measure within \textit{MCDE}, named \textit{Mann-Whitney\,P} (\textit{MWP})}. \textit{MWP} relies on the \textit{Mann-Whitney U} test, a well-known non-parametric statistical test \cite{Mann1947}, to quantify the average discrepancy between the marginal and conditional distributions. We describe the implementation of \textit{MWP} in detail. \textbf{We compare our estimator to the state of the art}. We benchmark each approach using an assortment of synthetic dependencies. In particular, we measure the statistical power and execution time of each approach. This will show that \textit{MWP} fulfils all requirements while the existing ones do not. \textbf{We release our source code and experiments on GitHub\footnote{\url{https://github.com/edouardfouche/mcde}}} with documentation to ensure reproducibility. \smallskip Paper outline: Section \ref{relatedwork} reviews related work. Section~\ref{mcde} describes \textit{MCDE} and \textit{MWP}. Section \ref{evaluation} evaluates \textit{MWP} and compares it to the state of the art. Section \ref{conclusions} concludes. \section{Related Work} \label{relatedwork} Estimating the correlation of a set of attributes has been of interest for more than a century. Many bivariate measures exist \cite{Spearman1904, Szekely2009, Reshef2011, Lopez-Paz2013}; a famous one is Pearson's \textit{r}, also commonly known as \textit{Pearson correlation coefficient}. However, they are not applicable to multivariate analysis (\textbf{R1}). Also, they often have other drawbacks. For example, Pearson's \textit{r} is parametric (\textbf{R5}) and targets at linear dependencies (\textbf{R3}). There exist attempts to extend bivariate dependency measures to the multivariate case. Schmid \textit{et al.}\ \cite{Schmid2007} propose an extension of Spearman's $\rho$ to multivariate data (\textit{MS}), but this is still limited to monotonous relationships (\textbf{R3}). Several authors also propose extensions of \textit{MI} \cite{Timme2014}. For example, Interaction Information (\textit{II}) \cite{McGill1954} quantifies the `synergy' or `redundancy' in a set of variables. Similarly, Total Correlation (\textit{TC}) \cite{5392532} quantifies the total amount of information. However, information-theoretic measures are difficult to estimate, as they require the knowledge of the underlying probability distributions. Density estimation methods, based on kernels, histograms or local densities, all require to set unintuitive parameters (\textbf{R4}) and may be computationally expensive (\textbf{R2}). Next, with many dimensions, multivariate density estimation becomes meaningless, due to the \textit{curse of dimensionality} \cite{bellman1957}. Information-theoretic measures also are difficult to interpret (\textbf{R6}), since they are unbounded and usually expressed in bits. More recently, \textit{CMI} \cite{Nguyen2013CMI}, \textit{MAC} \cite{Nguyen2014MAC} and \textit{UDS} \cite{Nguyen2015UDS} have been proposed as multivariate dependency measures. They are remotely related to concepts from information theory, as they rely on the so-called \textit{cumulative entropy} \cite{Crescenzo2009}. However, these measures are computationally expensive (\textbf{R2}) and not intuitive to use (\textbf{R4}). They also are difficult to interpret, because their theoretical maximum and minimum vary with the number of dimensions (\textbf{R6}). To our knowledge, Requirements \textbf{R7-9} have not been considered in the literature so far. Another approach, named \textit{HiCS} \cite{Keller2012}, is the one most similar to \textit{MCDE}-\textit{MWP}. It introduces \textit{subspace slicing} as a heuristic to quantify the discrepancy between marginal and conditional distributions. The resulting estimate is used to discover outliers in large databases. Yet the suitability of \textit{HiCS} as a dependency estimators is so far unknown. In Section \ref{evaluation}, we compare our estimator \textit{MWP} to the related work, namely \textit{MS}, \textit{TC}, \textit{II}, \textit{CMI}, \textit{MAC}, \textit{UDS} and \textit{HiCS}. \section{The MCDE Framework} \label{mcde} Dependency estimation determines to which extent a variable relationship differs from randomness. In this spirit, \textit{MCDE} quantifies a dependency, i.e., an extent of independence violation, based on marginal and conditional distributions. \subsection{Notation} Let $DB$ be a database with $n$ objects and $d$ dimensions. It is a set of attributes, or variables, $D=\{s_1, \dots, s_d\}$ and a list of objects $B = (\vec{x}_{1}, \dots, \vec{x}_{n})$ where $\vec{x}_{i} = \langle x_{i}^{s_{j}} \rangle_{j \in \{1, \dots, d\}}$ is a \mbox{$d$-dimensional} vector of real numbers. We call a subspace $S$ a projection of the database on $d'$ attributes, with $S \subseteq D$ and $d' \leq d$. We refer to its dimensionality as $|S| = d'$. To formalize our dependency estimator, we treat the attributes in $D$ as random variables, i.e., a random variable $X_{s_j}$ represents each attribute $s_j \in D$. Additionally, $p(X)$ is the joint probability density function (\textit{pdf}) of a random vector $X = \left \langle X_{s_{i}}\right \rangle _{s_i \in S}$, and $\hat{p}(X)$ is its estimation. We use $p_{s_{j}}(X)$ and $\hat{p}_{s_{j}}(X)$ for the marginal \textit{pdf} of $s_{j}$. $\mathcal{P}(S)$ denotes the power set of $S$, i.e., the set of all attribute subsets. For any attribute subset $S' \in \mathcal{P}(S)$, its random vector is $X_{S'}= \left \langle X_{s_i}\right \rangle _{s_{i} \in S'}$, and its complement random vector is $\overline{X_{S'}} = X_{S \setminus S'} = \left \langle X_{s_i}\right \rangle _{s_{i} \in S \setminus S'}$. \subsection{Theory of MCDE} \subsubsection{Measuring Dependencies as contrast} A set of variables is \textit{independent} or \textit{uncorrelated} if and only if all the variables are \textbf{mutually independent}. By treating the attributes of a subspace as random variables, we can define the independence assumption of a subspace as follows: \begin{dfn}[Independence Assumption] \label{IA1} The independence assumption $\mathcal{H}$ of a subspace $S$ holds if and only if the random variables $\{ X_{s_i} : s_i \in S \}$ are mutually independent, i.e.: \begin{align} \mathcal{H}(S) \Leftrightarrow p(X) = \prod_{s_{i} \in S} p_{s_{i}}(X) \label{eq:IA1} \end{align} \end{dfn} Under the independence assumption, the joint distribution of the subspace $S$ is \textbf{expected} to be equal to the product of its marginal distributions. We can define a degree of dependency, or correlation, based on the degree to which $\mathcal{H}$ does not hold: \begin{dfn}[Degree of Dependency] \label{DependencyDegree} The degree of dependency $\mathcal{D}$ of a subspace $S$ is the discrepancy, abbreviated as $disc$, between the \textbf{observed} joint distribution $p^{o}(X)$ and $p^{e}(X) = \prod_{s_{i} \in S} p^{o}_{s_{i}}(X)$, the \textbf{expected} joint distribution: \begin{align} \mathcal{D}(S) &\equiv disc \left(p^{o}(X),p^{e}(X)\right) \end{align} \end{dfn} While one can estimate the discrepancy between two probability distributions, using for instance the Kullback-Leibler divergence \cite{kullback1951information}, this is not trivial here because $p^o(X)$ and $p^{e}(X)$ are a priori unknown. We work around this as follows: \begin{lemma} \label{lemma1} The independence assumption $\mathcal{H}$ of a subspace $S$ holds if and only if the joint \textit{pdf} for all $S' \in \mathcal{P}(S)$ is equal to its joint conditional \textit{pdf} given all other variables $S \setminus S'$: \begin{align} \mathcal{H}(S) \Leftrightarrow p(X_{S'}|\overline{X_{S'}}) = p(X_{S'}) && \forall S' \in \mathcal{P}(S) \end{align} \end{lemma} \begin{proof} Since all variables in $S$ are mutually independent, for any $S' \in \mathcal{P}(S)$ we also have $p(X_{S'}) = \prod_{s_{i} \in S'} p_{s_{i}}(X)$, then \begin{align*} \mathcal{H}(S) &\Leftrightarrow~ p(X) = \prod_{s_{i} \in S} p_{s_{i}}(X) &&~ \\ \mathcal{H}(S) &\Leftrightarrow~ p(X) = p(X_{S'}) * \prod_{s_{i} \in S \setminus S'} p_{s_{i}}(X) && \forall S' \in \mathcal{P}(S) \\ \mathcal{H}(S) &\Leftrightarrow~ \frac{p(X)}{p(\overline{X_{S'}})} = p(X_{S'}) && \forall S' \in \mathcal{P}(S) \end{align*} By the definition of the conditional \textit{pdf}: \begin{align*} \mathcal{H}(S) &\Leftrightarrow~ p(X_{S'}|\overline{X_{S'}}) = p(X_{S'}) && \forall S' \in \mathcal{P}(S) \label{lastofproof1} \qedhere \end{align*} \end{proof} Lemma \ref{lemma1} provides an alternative definition of $\mathcal{H}$. However, it is still problematic for the following reasons: First, one requires multivariate density estimation to estimate $p(X_{S'})$ and $p(X_{S'}|\overline{X_{S'}})$ with $|S'| \geq 1$ in the multivariate case. Second, even if one could estimate $p(X_{S'})$ and $p(X_{S'}|\overline{X_{S'}})$, estimating densities for all $ S' \in \mathcal{P}(S)$ is intractable. So we instead relax the problem by considering only subspaces with $|S'| = 1$, i.e., we only look at the marginal \textit{pdf} of single variables. \begin{dfn}[Relaxed Independence Assumption] The relaxed independence assumption $\mathcal{H}^*$ of a subspace $S$ holds if and only if the marginal distribution $p_{s_{i}}(X)$ of each variable $s_i \in S$ equals $p_{s_{i}}(X|\overline{X_{s_i}})$, i.e., the conditional \textit{pdf} of $s_i$: \begin{align*} \mathcal{H}^*(S) \Leftrightarrow p_{s_{i}}(X|\overline{X_{s_i}}) = p_{s_{i}}(X) && \forall s_i \in S \end{align*} \end{dfn} \begin{theorem}[Independence Assumption Relaxation] \label{IA2} We can relax $\mathcal{H}$ into $\mathcal{H}^*$ for any $S$, such that $\mathcal{H}(S) \Rightarrow \mathcal{H}^*(S)$. \end{theorem} \begin{proof} Using Lemma \ref{lemma1}: \begin{align*} \mathcal{H}(S) &\Leftrightarrow p(X_{S'}|\overline{X_{S'}}) = p(X_{S'}) && \forall S' \in \mathcal{P}(S) &~\\ \mathcal{H}(S) &\Rightarrow p(X_{S^1}|\overline{X_{S^1}}) = p(X_{S^1}) && \forall S^1 \in \mathcal{P}(S) :|S^1| = 1 &~\\ \mathcal{H}(S) &\Rightarrow p_{s_i}(X|\overline{X_{s_i}}) = p_{s_{i}}(X) && \forall s_i \in S &\qedhere \end{align*} \end{proof} Loosely speaking, the relaxed independence assumption holds if and only if knowing the value of all variables but $s_i$ does not bring any information about $s_i$. Since $\mathcal{H}(S) \Rightarrow \mathcal{H}^*(S)$, we have $\neg \mathcal{H}^*(S) \Rightarrow \neg \mathcal{H}(S)$. I.e., showing that $\mathcal{H}^*$ does not hold is a condition sufficient but not necessary to show that $\mathcal{H}$ does not hold. Thus, we can define a relaxed degree of dependency $\mathcal{D}^*$ of a subspace $S$, as the discrepancy of the observed marginal distribution $p^o_{s_i}(X)$ and the expected one $p^{e}_{s_i}(X)$. Under the relaxed independence assumption $\mathcal{H}^*$, we have $p^{e}_{s_i}(X) = p^o_{s_i}(X|\overline{X_{s_i}}), \forall s_i \in S$. We define $\mathcal{D}^*$ as the expected value of those discrepancies: \begin{dfn}[Relaxed Degree of Dependency] \label{def:RelaxedDegree} \begin{align} \mathcal{D}^*(S) &\equiv \mathop{\mathbb{E}}_{s_i \in S} \Big[disc \left( p^o_{s_{i}}(X) , p^o_{s_i}(X|\overline{X_{s_i}}) \right) \Big] \end{align} \end{dfn} This definition is broad and contains a whole class of dependency estimators, e.g., \cite{Keller2012}. This class of estimators aims at measuring a so-called notion of \textit{contrast} of the subspace. $\mathcal{D}^*$ -- or \textit{contrast} -- is a variant of $\mathcal{D}$ which is much easier to estimate: First, it relies on the comparison of marginal against conditional densities, i.e., multivariate density estimation is not required. Second, the number of degrees of freedom of $\mathcal{H}^*(S)$ increases linearly with $|S|$, while exponentially for $\mathcal{H}(S)$. Thus, $\mathcal{D}^*$ is much less expensive to estimate than $\mathcal{D}$. By definition, $\mathcal{D}^*$ does not take into account the dependency between multivariate subsets, but only of each individual variable versus all others. However, we argue that this relaxation is not problematic. In fact, the detection of dependency is only interesting as long as we can observe effects w.r.t.\ the marginal and conditional distributions. In real-world scenarios, one is typically looking for interpretable influences of particular variables -- so-called `targets' -- on the system and vice versa. \subsubsection{Simulating Conditional Dependencies via Slicing} \label{sec:slicing} The main difficulty to estimate $\mathcal{D}^*$ is estimating the conditional distributions $p^o_{s_i}(X|\overline{X_{s_i}})$, because the underlying data distribution is unknown. As suggested in \cite{Keller2012}, we can simulate conditional distributions by applying a set of conditions \mbox{to $S$}, in a process called \textit{subspace slicing}. \begin{dfn}[Subspace Slice] \label{slice} A subspace slice $c_{i}$ of $S$ is a set of $\left |S \right |-1$ conditions, where each condition is an interval $\left [l_{s_j}, u_{s_j} \right ]$, which restricts the values of $s_j \in S \setminus {s_i}$: \begin{equation} \begin{split} &c_i = \left \{ \left[l_{s_j}, u_{s_j} \right] : s_j \in S\setminus s_i \right \}~~s.t.~~\forall \left[l_{s_j}, u_{s_j}\right] \in c_i, \\ & \left | \left \{\vec{x_k}: \vec{x_k} \in B \wedge x_k^{s_j} \in \left [l_{s_j}, u_{s_j} \right ] \right \} \right | = n' \end{split} \end{equation} where $n' \in \{1, \dots, n\}$ is the number of objects per condition, and $s_i$ is the \textbf{reference} dimension. We say that $\vec{x_k} \in c_i$ when $\vec{x_k}$ fulfils all the conditions in $c_i$. We define $\bar{c}_i$ as the set of complementary conditions of a given $c_i$: \begin{align} \bar{c}_i = \left \{ (-\infty, l_{s_j}) \cup (u_{s_j}, \infty) : \left[l_{s_j}, u_{s_j}\right] \in c_i \right\} \end{align} $p_{s_i | c_i}(X)$ and $p_{s_i | \bar{c}_i}(X)$ denote the conditional \textit{pdf} of the observation in the slice $c_i$ and its complement $\bar{c}_i$ respectively. $\mathcal{P}^{c}(S)$ is the set of all possible slices in $S$. \end{dfn} We choose each interval in a slice at random and independently from each other. Under the independence assumption, the expected share of observations $\alpha$ in the slice is equal to: \begin{align} \alpha = (n'/n)^{|S|-1} \end{align} Interestingly, $n'$ can be determined given $\alpha$ as only exogenous parameter and the dimensionality $|S|$: \begin{align} n' = \left \lceil n \sqrt[|S|-1]{\alpha}\, \right \rceil \end{align} As a result, subspace slicing can be done in a \textbf{di\-men\-sio\-na\-li\-ty-aware} fashion. When $\alpha$ is a constant, the expected number of objects per slice does not change between subspaces with different dimensionality. One can see subspace slicing as a dynamic grid-based method, which does not suffer from the curse of dimensionality. \begin{dfn}[Dimensionality-aware Slice] \label{def:dynamic-slice} A dimensionality-aware slice $c^\alpha_i$ of subspace $S$ is a set of $\left |S \right |-1$ conditions: \begin{align} c^\alpha_i = c_i~~s.t.~~n' = \left \lceil n \sqrt[|S|-1]{\alpha}\, \right \rceil \end{align} \end{dfn} For brevity, we assume a fixed $\alpha \in (0,1)$ and write $c_i = c_i^\alpha$, and we omit $(X)$ in $p_{s_j}(X)$ and $p_{s_j|c_j}(X)$ in the following. The idea behind dimensionality-aware slicing is to simulate conditional distributions empirically. Under the $\mathcal{H}^*$-assumption, the conditional distribution $p_{s_i|c_i}$ is equal to the marginal distribution $p_{s_i}$, for any dimension $s_i$ and slice $c_i$. \begin{theorem}[$\mathcal{H}^*$ and Conditional Distributions] \label{theorem2} \begin{align} \mathcal{H}^*(S) \Leftrightarrow p_{s_i | {c_i}} &= p_{s_i} &\forall s_i \in S, \forall c_i \in \mathcal{P}^{c}(S) \end{align} \end{theorem} \begin{proof} By contradiction, using Theorem \ref{IA2}. \begin{align*} \intertext{`$\Leftarrow$': From Theorem \ref{IA2}, assume $\mathcal{H}^*(S)$ and that } ~& \exists s_j \in S : p_{s_j}(X|\overline{X_j}) \neq p_{s_j} \\ &\Rightarrow \exists c_j \in \mathcal{P}^c(S) : p_{s_j | c_j} \neq p_{s_j} \\ &\Rightarrow \text{Contradiction of Theorem \ref{theorem2}} \notag \intertext{`$\Rightarrow$': From Theorem \ref{theorem2}, assume $\mathcal{H}^*(S)$ and that } ~& \exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j} \\ &\Rightarrow p_{s_j}(X|\overline{X_{s_j}}) \neq p_{s_j} \\ &\Rightarrow \text{Contradiction of Theorem \ref{IA2}} \qedhere \end{align*} \end{proof} \subsubsection{Discrepancy Estimation} In reality, one only has access to a limited number of observations. Thus, one must quantify the discrepancy between empirical distributions. The basic idea is to use a statistical test $\mathcal{T}$: \begin{align} disc \left ( \hat{p}_{s_i} , \hat{p}_{s_i | {c_i}} \right ) \equiv \mathcal{T}\left( \hat{p}_{s_i}, \hat{p}_{s_i | {c_i}} \right ) \end{align} However, since the number of observations is finite, the observations underlying $\hat{p}_{s_i | {c_i}}$ are \textbf{included} in the set of observations from $\hat{p}_{s_i}$. This is problematic, as statistical tests assume the two samples to be \textbf{distinct}. Plus, when $\alpha \approx 1$, $\hat{p}_{s_i | {c_i}}$ converges to $\hat{p}_{s_i}$, i.e., the two populations are nearly the same. Conversely, $\alpha \approx 0$ yields spurious effects, since the observations from $\hat{p}_{s_i | {c_i}}$ are then few. We solve the problem by observing that $p_{s_i | {c_i}}$ and $p_{s_i | {\bar{c}_i}}$ must be equal under $\mathcal{H}^*$. \begin{theorem}[$\mathcal{H}^*$ and Complementary Conditions] \label{theorem3} \begin{align} \mathcal{H}^*(S) \Leftrightarrow p_{s_i | {\bar{c}_i}} &= p_{s_i | {c_i}} &\forall s_i \in S, \forall c_i \in \mathcal{P}^{c}(S) \end{align} \end{theorem} \begin{proof} By contradiction, using Theorem \ref{theorem2}. \begin{align*} \intertext{`$\Leftarrow$': From Theorem \ref{theorem2}, assume $\mathcal{H}^*(S)$ and that} ~ &\exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j} \\ \intertext{\quad since $p_{s_j} = p_{s_j | c_j \cup \bar{c}_j}$,} &\Rightarrow \exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j | c_j \cup \bar{c}_j} \\ &\Rightarrow \exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j | \bar{c}_j} \\ &\Rightarrow \text{Contradiction of Theorem \ref{theorem3}} \\ \intertext{`$\Rightarrow$': From Theorem \ref{theorem3}, assume $\mathcal{H}^*(S)$ and that} ~ &\exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j | \bar{c}_j} \\ &\Rightarrow \exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j \cup c_j} \neq p_{s_j | \bar{c}_j \cup c_j} \\ \intertext{\quad since $c_j \cup c_j = c_j$ and $p_{s_j} = p_{s_j | \bar{c}_j \cup c_j}$,} &\Rightarrow \exists s_j \in S, \exists c_j \in P^c(S) : p_{s_j | c_j} \neq p_{s_j} \\ &\Rightarrow \text{Contradiction of Theorem \ref{theorem2}} \qedhere \end{align*} \end{proof} Hence, one can evaluate the $\mathcal{H}^*$-assumption by looking instead at the discrepancies between the conditional distribution and its complementary conditional distribution. When doing so, the samples obtained from both distributions are distinct. We have defined dimensionality-aware slicing based on $\alpha$, the expected share of observations in the slice $c_i$. Thus, the expected share of observations $\bar{\alpha}$ in $\bar{c}_i$ equals $1-\alpha$. This leads to setting $\alpha = 0.5$, so that $\bar{\alpha} = \alpha$. This choice is pertinent for statistical testing, as equal sample sizes lead to higher statistical stability, and we get rid of parameter $\alpha$. We also propose to restrict the domain of the reference dimension $s_i$ to the same proportion $\alpha$ of objects: \begin{dfn}[Marginal Restriction] A marginal restriction is a condition on the reference dimension $s_i$, i.e., an interval $r_i:[l_{s_i}, u_{s_i}]$, such that $|\{ \vec{x_j} : x^{s_i}_j \in B \wedge x^{s_i}_j \in r_i | = \left \lceil \alpha \cdot n \right \rceil$. We define $p_{s_i | {c_i} | r_i}$ as the restricted conditional distribution given $c_i$, $r_i$. $\mathcal{P}^{r}(S)$ is the set of all restrictions. \end{dfn} With the marginal restriction, the approach becomes more sensitive to local effects in the marginal distribution, compared to simply considering the full range. Furthermore, this reduces the number of points in the two samples by $\alpha$, leading to lower computational requirements of the underlying statistical test. \begin{figure} \hfill \begin{subfigure}{0.329\linewidth} \begin{center} \includegraphics[width=\linewidth]{independent_2D.png} \end{center} \caption{Independent} \label{fig:slicing-independent} \end{subfigure}\hfil \begin{subfigure}{0.329\linewidth} \begin{center} \includegraphics[width=\linewidth]{linear_2D.png \end{center} \caption{Linear} \label{fig:slicing-linear} \end{subfigure}\hfill \begin{subfigure}{0.329\linewidth} \begin{center} \includegraphics[width=\linewidth]{circle_2D.png \end{center} \caption{Circle} \label{fig:slicing-circle} \end{subfigure} \hfill \caption{Slicing in 2-D subspaces, with $\alpha = 0.5$} \label{fig:slicing} \end{figure} We illustrate slicing in Figure \ref{fig:slicing}, with an independent subspace on the left-hand side and with subspaces with noisy dependencies on the right. The grey lines show a random slice $c_x$ on the $y$-axis. Two black bold lines stand for the restriction $r_x$. The points in dark blue are in the restricted slice $c_x | r_x$ and the points in light orange are in $\bar{c}_x | r_x$. Using histograms, we plot along the $x$-axis the distribution of the points in both samples. From the histograms, we can see that the two distributions are relatively similar for Figure \ref{fig:slicing-independent}, while they are markedly different for Figure \ref{fig:slicing-linear} and \ref{fig:slicing-circle}. In the end, after each slicing operation, one obtains two object samples $B_{c_i | r_i }$ and $B_{\bar{c}_i | r_i }$ such that $B_{c_i | r_i } \cap B_{\bar{c}_i | r_i } = \emptyset$, and we use a statistical test $\mathcal{T}$ to estimate the discrepancy between $\hat{p}_{s_i | {c_i} | r_i }$ and $\hat{p}_{s_i | {\bar{c}_i} | r_i }$. A statistical test $\mathcal{T} \left( B_1, B_2 \right)$ on two samples $B_1$ and $B_2$ typically yields a $p$-value. Traditionally, one uses $p$-value to assess the \textit{statistical significance}. It is the probability to falsely reject a true null hypothesis, where the null hypothesis is the independence. Conversely, $p^c = 1-p$ is a \textit{confidence level} or probability to truly reject a false null hypothesis. The rationale behind $\mathcal{D}^*$ is to yield values quantifying the independence violation. We define our own notion of \textit{contrast}, abbreviated as $\mathcal{C}$, as the expected value of the \textit{confidence level} of a statistical test $\mathcal{T}$ between the samples from the conditional distributions for all the possible dimensions $s_i$, slices $c_i$ and restrictions $r_i$: \begin{dfn}[Contrast $\mathcal{C}$] \label{def:contrast-test} \begin{align} \mathcal{C}(S) &\equiv \mathop{\mathbb{E}}_{\{c_i,r_i\} \in {\mathcal{P}^{c}\times}\mathcal{P}^{r}} \Big [ \mathcal{T} \left (B_{c_i | r_i }, B_{\bar{c}_i | r_i } \right ) \Big ] \end{align} where $\mathcal{T}$ yields $p^c$-values, and we draw $c_i$, $r_i$ randomly and independently from each other w.r.t. any dimension $s_i \in S$. \end{dfn} By definition, and independently from the underlying test, $\mathcal{T} \sim \mathcal{U}[0,1]$ when the two samples are independent from each other, and $\mathcal{T} \approx 1$ as the evidence against independence becomes stronger. The properties of $\mathcal{C}$ follow: \begin{itemize} \item $\mathcal{C}$ converges to $1$ as the dependency strength in $S$ increases, since the $p^c$-values converge stochastically to $1$. \item $\mathcal{C}$ converges to $0.5$ when $S$ is independent, since the distribution of the $p^c$-values converges to $\mathcal{U}[0,1]$. \item $\mathcal{C}$ is bounded between $0$ and $1$, as the $p^c$-values are bounded between $0$ and $1$. \end{itemize} \subsubsection{Monte Carlo Approximation} \label{montecarlosimulation} Unfortunately, $\mathcal{C}$ is impossible to compute exactly. Namely, one would need to know the distribution of $B_{c_i | r_i }$ and $B_{\bar{c}_i | r_i }$ for every dimension, slice and restriction. Instead, the idea is to approximate $\mathcal{C}$ via Monte Carlo (MC) simulations, using $M$ iterations. For each iteration, we choose the reference dimension, slice and restriction at random. The \textit{approximated contrast} $\mathcal{\hat{C}}$ is defined as follows: \begin{dfn}[Approximated Contrast $\mathcal{\hat{C}}$] \label{def:contrast-approx} \begin{align} \mathcal{\hat{C}}(S) &= \frac{1}{M} \sum_{m=1}^{M} \mathcal{T} \left ( B_{ \left [c_i | r_i \right ]_m }, B_{\left [\bar{c}_i | r_i \right ]_m } \right ) \end{align} where $\left [c_i | r_i \right ]_m$ means that we draw $i$, $c_i$ and $r_i$ randomly at iteration~$m$, i.e., $i \leftarrow \{1,...,|S|\}$ and $\{c_i, r_i\} \leftarrow \mathcal{P}^{c} \times \mathcal{P}^{r}$. \end{dfn} \label{bound} Interestingly, we can bound the quality of the approximation. From Hoeffding's inequality \cite{Hoeffding1963}, we derive a bound on the probability of $\mathcal{\hat{C}}$ to deviate not less than $\varepsilon$ from $\mathcal{C}$. The bound decreases exponentially with increasing $M$: \begin{theorem}[Hoeffding's Bound of $\mathcal{\hat{C}}$] \label{"th:hoeffding-chernoff-contrast"} \begin{align} \Pr\left(| \mathcal{\hat{C}} - \mathcal{C} | \geq \varepsilon \right) \leq 2e^{-2M \varepsilon^2} \end{align} where $M$ is the number of MC iterations, and $0 < \varepsilon < 1 - \mathcal{C}$. \end{theorem} \begin{proof} Let us first restate Theorem 1 from Hoeffding \cite{Hoeffding1963}: Let $X_1, X_2, \dots, X_n$ be independent random variables $0 \leq X_i \leq 1$ for $i \in \{1,\dots,n\}$ and let $\bar{X} = \frac{1}{n}(X_1 + X_2 + \dots + X_n)$ be their mean with expected value $E[\bar{X}]$. Then, for $0<t<1-E[\bar{X}]$: \begin{align*} \Pr\left(\bar{X}-E[\bar{X}] \geq t \right) \leq e^{-2nt^2} && \Pr\left(\bar{X}-E[\bar{X}] \leq t \right) \leq e^{-2nt^2} \end{align*} We can treat each MC iteration $m_1, m_2, \dots, m_M$ as i.i.d. random variables $X_{m_1}, X_{m_2}, \dots, X_{m_M}$ in $[0,1]$ with mean $\mathcal{\hat{C}}$ and expected value $E[\mathcal{\hat{C}}] = \mathcal{C}$ (\mbox{Definition \ref{def:contrast-test}}). Thus, for $0 < \varepsilon < 1 - \mathcal{C}$, we have $\Pr (| \mathcal{\hat{C}} - \mathcal{C} | \geq \varepsilon) \leq 2e^{-2M \varepsilon^2}$. \end{proof} This is very useful. For instance, when $M=200$, the probability of $\mathcal{\hat{C}}$ to deviate more than $0.1$ from its expected value is less than $2e^{-4} \approx 0.04$, and this bound decreases exponentially with $M$. Thus, one can adjust the computational requirements of $\mathcal{\hat{C}}$, given the available resources or a desired quality level. In other words, users can set $M$ intuitively, as it leads to an expected quality, and vice versa. Furthermore, $M$ is the only parameter of the \textit{MCDE} framework. \subsection{Instantiation as \textit{MWP}} \label{instantiation-as-mwp} To use the \textit{MCDE} framework, one must instantiate a suitable statistical test as $\mathcal{T}$. To comply with our requirements, this statistical test needs to be \textbf{non-parametric} (\textbf{R5}) and \mbox{\textbf{\textbf{robust}} (\textbf{R8})}. As a proof of concept, we instantiate $\mathcal{T}$ as a two-sided \emph{Mann-Whitney U} test \cite{Mann1947}, abbreviated as \emph{U} hereafter. The \emph{U} test has the following features which other statistical tests may lack. First, it is one of the most powerful statistical tests \cite{Mood1954}: Its power-efficiency approaches 95.5\% when comparing it to the $t$-test, as the number of observations $n$ increases. But contrary to the $t$-test, the \emph{U} test is \textbf{non-parametric}. Second, \cite{Dixon1954} shows that the \emph{U} test is more efficient than the \textit{Kolmogorov-Smirnov} test for large samples. Finally, the \emph{U} test does not require continuous data, as it operates on ranks. Thus, it is \textbf{robust} and applicable to virtually any kind of ordinal measurements. We review the definition of the \textit{U} test \cite{Siegel1956} between two samples $B_1$ and $B_2$ with size $n_1$ and $n_2$. It tests the null hypothesis that it is equally likely that a randomly selected value from one sample will be less than or greater than a randomly selected value from the other sample. $R_1$ and $R_2$ are the sums of ranks of the objects in $B_1$ and $B_2$, obtained by ranking the values of $B_1$ and $B_2$ together, starting with $0$. In case of ties, the ranks of the tying objects are \textit{adjusted}, i.e., become the average of their ranks. \begin{align} \textit{U test} :&& p = \Phi(Z)~\text{or}~1-\Phi(Z) && Z = \frac{ U - \mu }{\sigma} \end{align} Here, one can choose $U = U_1$ or $U = U_2$ equivalently, with: \begin{align} U_1 = R_1 - \frac{n_1(n_1-1)}{2} && U_2 = R_2 - \frac{n_2(n_2-1)}{2} \end{align} $\Phi$ is the cumulative distribution function (\textit{cdf}) of the normal distribution; $\mu$, $\sigma$ are defined as: \begin{align} \mu = \frac{n_1 n_2}{2} && \sigma = \sqrt{\frac{n_1 n_2}{12} \left ( (n+1) - \sum_{i=1}^{k} \frac{t_i^3 - t_i}{n(n-1)} \right ) } \end{align} The summation term of $\sigma$ is a correction for ties, where $t_i$ is the number of observations sharing rank $i$, and $k$ is the number of distinct ranks. For large enough samples, typically $n > 30$, the values of $U$ are normally distributed \cite{Mann1947} with mean $\mu$ and standard deviation $\sigma$. $Z$ is the standardized score, since \mbox{$Z \sim \mathcal{N}(0,1)$}. If $U = U_1$, then $Z \ll 0$ and $p \approx 0$ when the ranks of $A_1$ are stochastically smaller than those of $A_2$. Conversely, when the ranks of $A_1$ are stochastically larger, then $Z \gg 0$ and $p \approx 1$. Both cases indicate an independence violation. As both directions are relevant, our test should capture them equally. We implement a two-sided version of the \textit{Mann-Whitney U} test, which we dub $\mathcal{T}_{\textit{MWP}}$. The letter \textit{P} emphasises that the test returns a $p^c$-value, as required by the \textit{MCDE} framework: \begin{align} \mathcal{T}_{\textit{MWP}}: && {p^c}= \Phi^{1/2}(Z') && Z' = |Z| && U = U_1 \end{align} Since $Z \sim \mathcal{N}(0,1)$, $Z'$ follows the so-called half-normal distribution with \textit{cdf} $\Phi^{1/2}$. Since $|U_1 - \mu|$ = $|U_2 - \mu|$, we can simply set $U = U_1$ or $U = U_2$ arbitrarily, i.e., one only needs to sum the ranks of one of the samples. In the end, when the independence assumption does not hold, we expect the ranks of the two samples after slicing to differ, which leads to $\mathcal{T}_{\textit{MWP}} \approx 1$. Thus, the test complies with Definitions \ref{def:contrast-test} and \ref{def:contrast-approx}. We define \textit{MWP} or $\mathcal{\hat{C}}_{\textit{MWP}}$ as the instantiation of $\mathcal{\hat{C}}$ using $\mathcal{T}_{\textit{MWP}}$ as statistical test: \begin{dfn}[Mann-Whitney P (\textit{MWP})] \begin{align} \text{\textit{MWP}} = \mathcal{\hat{C}}_{\textit{MWP}} = \frac{1}{M} \sum_{m=1}^{M} \mathcal{T}_{\textit{MWP}} \left (B_{\left [c_i | r_i \right ]_m }, B_{ \left [\bar{c}_i | r_i \right ]_m } \right ) \end{align} \end{dfn} \subsection{Algorithmic Considerations \& Complexity} We now outline our algorithm to efficiently compute \textit{MWP}. \subsubsection{Computing an Index Structure} \label{computing-index} The \textit{MCDE}-\textit{MWP} approach requires the creation of an index, as a preprocessing step, to avoid the expensive repetition of sorting operations. The index $\mathcal{I}$ is a one-dimensional structure containing the adjusted ranks and tying values corrections for each dimension. It consists of $|S|$ elements $\{I_1, \dots, I_{|S|} \}$, where $I_i$ is an array of $3$-tuple $[(l_1^i, a_1^i, b_1^i),\dots,(l_n^i, a_n^i, b_n^i)]$ ordered by $s_i$ in ascending order. In this tuple, $l^i$ are the row numbers of the values of $s_i$, $a^i$ are the \textit{adjusted} ranks and $b^i$ the accumulated correction of the standard deviation $\sigma$ from the first element. We denote $I_i[j]$, $s_i[j]$ as the $j$-th elements of $I_i$ and $s_i$; we refer to the components of $I_i[j]$ as $l_j^i$, $a_j^i$, $b_j^i$. We outline the construction of the index in Algorithm \ref{indexconstruction}. For each attribute $s_i$, we sort the values (Line~$4$) and perform a single pass over the sorted list to adjust the ranks and the correction for ties. Thus, the index construction complexity is in $O(|S| \cdot (n \cdot log(n) + n))$. \begin{algorithm} \caption{MWP Index Construction}\label{indexconstruction} \begin{algorithmic}[1] \Function{ConstructIndex}{$S = \{s_i\}_{i \in \{1,\dots,d\}}$} \For{$i = 1$ to $|S|$} \State $r^i \gets \left[0,\dots,n-1\right]$ \State $l^i \gets$ sort $r^i$ by $s_i$ in ascending order \State $I_i \gets \left[(l^i_1, r^i_1),\dots,(l^i_n, r^i_n)\right]$ \Comment{Initialize $I_i:(l^i, r^i)$} \State $j \gets 1$ ; $correction \gets 0$ \While{$j \leq n$} \State $k \gets j$ ; $t \gets 1$ ; $adjust \gets 0$ \While{$(k < n-1) \wedge (s_{i}[l^i_k] = s_{i}[l^i_{k+1}])$} \State $adjust \gets adjust + r^i_{k}$ \State increment $k$ and $t$ \EndWhile \If{$k > j$} \Comment{Adjust the rank and correction} \State $adjusted \gets (adjust + r^i_{k}) / t$ \State $correction \gets correction + t^3 - t$ \For{$m \gets j$ to $k$} \State $I_i[m] \gets (l_m^i, adjusted, correction)$ \EndFor \Else $~~I_i[j] \gets (l_j^i, r_j^i, correction)$ \EndIf \State $j \gets j + t$ \EndWhile \EndFor \State \Return $\mathcal{I}: \{I_1, \dots, I_{|S|} \}$ with $I_i: (l^i, a^i, b^i)$ \EndFunction \end{algorithmic} \end{algorithm} \subsubsection{Slicing over the Index Structure} We can slice the input data efficiently, because the tuples are already sorted in the index structure. We successively mask the row numbers based on a random condition for all but one reference attribute $s_r$. Algorithm \ref{slicing} is the pseudocode of the slicing process. The complexity of slicing is in $O(|S| \cdot n)$. \begin{algorithm} \caption{Dynamic Slicing}\label{slicing} \begin{algorithmic}[1] \Function{Slice}{$\mathcal{I}: \{I_1, \dots. I_{|S|} \}$, $r$} \State $slice \gets$ Array of $n$ boolean values initialized to $\textit{true}$ \State $slicesize \gets \left \lceil n \cdot \sqrt[|S|-1]{\alpha}\, \right \rceil $ \For{$I_i \in \mathcal{I} \setminus I_{r}$} \State $start \gets$ random integer in $[1,n-slicesize]$ \State $end \gets$ $start + slicesize$ \For{$j \gets 1$ until $start$ and $end+1$ to $n$} \State $slice[l_j^i] \gets \textit{false}$ \EndFor \EndFor \State \Return $slice$ \EndFunction \end{algorithmic} \end{algorithm} \subsubsection{Computing the Statistical Test} We give the pseudocode to compute the statistical test in Algorithm \ref{TMWP}. We determine a restriction $[start, end]$ on $s_{r}$ and sum the adjusted ranks of the objects that belong to the slice. Thanks to the marginal restriction, we compute the statistical test in a subsample of size $n' < n$. Since the ranks in this subset may not start from $0$, we adjust the sum of the ranks $R_1$ (Line $11$). Then, we compute a correction term (Line $14$) using the cumulative correction $b^r$ to adjust $\sigma$ for ties (Line $15$). We compute the statistical test via a single pass, considering only elements between $start$ and $end$. Each operation requires constant time, thus, the complexity of this step is in $O(n)$. \begin{algorithm} \caption{$\mathcal{T}_{\textit{MWP}}$}\label{TMWP} \begin{algorithmic}[1] \Function{Compute $\mathcal{T}_{\textit{MWP}}$}{$\mathcal{I}: \{I_1, \dots. I_{|S|} \}$, $slice$, $r$} \State $start \gets$ random integer in $[1,n \cdot (1-\alpha)]$ \State $end \gets$ $start + \left \lceil n \cdot \alpha \right \rceil$ \State $R_1 \gets 0$ ; $n_1 \gets 0$ \For{$j \gets start$ to $end$} \If{$slice[l^r_{j}] = \textit{true}$} \State $R_1 \gets R_1 + a^r_{j}$ \State $n_1 \gets n_1 + 1$ \EndIf \EndFor \State{$n' \gets end - start $} % \If{$n_1 = 0$ or $n_1 = n'$} \Return $1$% \EndIf \State $U_1 \gets R_1 - start \cdot n_1$ \State $n_2 \gets n' - n_1$ \State $\mu \gets (n_1 \cdot n_2)/ 2$ \State $correction \gets (b^r_{end-1}-b^r_{start-1})/(n'\cdot (n'-1))$ \State $\sigma \gets \sqrt{((n_1 \cdot n_2)/12) \cdot {(n'+1-correction)}}$ \State \Return $\Phi^{1/2}(|U_1 - \mu| / \sigma)$ \EndFunction \end{algorithmic} \end{algorithm} \subsubsection{Computing \textit{MWP}} \label{ComputingMWP} To determine $\mathcal{\hat{C}}_{\textit{MWP}}$ of a subspace $S$, we first construct the index. Then, in $M$ iterations, we slice the data set (Algorithm \ref{slicing}) and compute $\mathcal{T}_{\textit{MWP}}$ (Algorithm \ref{TMWP}). \textit{MWP} is the average of $\mathcal{T}_{\textit{MWP}}$. See Algorithm \ref{MWP_alg}. \begin{algorithm} \caption{\textit{MWP}}\label{MWP_alg} \begin{algorithmic}[1] \Function{\textit{MWP}}{$S = \{s_i\}_{i \in \{1, \dots, d\} }$} \State $\mathcal{I} \gets$ \Call{ConstructIndex}{$S$} ; $\textit{MWP} \gets 0$ \For{$m \gets 1$ to $M$} \State $r \gets$ random integer in $\left[ 1,d \right]$ \State $slice \gets$ \Call{Slice}{$\mathcal{I}$, $r$} \State $\textit{MWP} \gets \textit{MWP } +$ \Call{Compute $\mathcal{T}_{\textit{MWP}}$}{$\mathcal{I}$ , $slice$, $r$} \EndFor \State $\textit{MWP} \gets \textit{MWP} / M$ \State \Return \textit{MWP} \EndFunction \end{algorithmic} \end{algorithm} When one wants to replace the statistical test, one only needs to change Algorithm \ref{TMWP}. The rest is part of the \textit{MCDE} framework and does not require any adaptation. \subsubsection{Complexity} The overall complexity of \textit{MWP} is in $O(|S| \cdot (n \cdot log(n) + n) + M \cdot(|S|\cdot n + n))$. Since $|S| \ll n$, this simplifies to $O(n \cdot log(n) + M\cdot n)$. The index construction is asymptotically the most expensive step, as it is in $O(n \cdot log(n))$. However, one only needs to construct the index once. When the index for a given data set is available, one can compute \textit{MWP} in linear time for the exponential number of subspaces. Interestingly, \textit{MWP} is trivial to parallelise: one can compute the elements of the index structure $I_1, \dots, I_{|S|}$ in parallel, as they are independent from each other. Similarly, one can parallelise each Monte Carlo iteration in the loop at Line 3 of Algorithm \ref{MWP_alg}. This is useful, as multi-core architectures are ubiquitous in modern database systems. Thus, \textit{MWP} scales well with the size of the data set. We will verify this claim via experiments in Section \ref{scalability}. \section{Evaluation} \label{evaluation} In this section, we show via experiments that \textit{MWP} fulfils our requirements from Section~\ref{motivation}. We also compare our approach to a range of state-of-the-art dependency estimators, namely \textit{MS}, \textit{II}, \textit{TC}, \textit{CMI}, \textit{MAC}, \textit{UDS} and \textit{HiCS}. We implement \textit{MWP} in Scala, while other approaches are implemented in Java. Note that, fundamentally, the impact of this difference on runtime is low, as both run in the JVM. We re-implement \textit{MS} following \cite{Schmid2007}, \textit{TC} and \textit{II} following \cite{Timme2014} using Kraskov's \cite{Kraskov2004} and Kozachenko \& Leonenko estimators respectively, with parameter $k=4$. We use the R*-tree implementation from ELKI \cite{DBLP:journals/pvldb/SchubertKEZSZ15} to increase the efficiency of nearest neighbour queries. For \textit{CMI}, \textit{MAC}, \textit{UDS} and \textit{HiCS}, we use the implementation provided in \cite{Nguyen2015UDS}. Each algorithm runs single-threaded in a server with 32 cores at 2.2 GHz and 64GB RAM. We use the default parameters, if any. If not stated otherwise, the data samples we use in our experiments have the size $n = 1000$, $d = 3$, and we set $M = 50$ for \textit{MWP} and \textit{HiCS}. In most existing studies, such as in \cite{Nguyen2014MAC, Reshef2011}, $n$ usually is equal or lower. \subsection{Methodology} To compare the approaches, the idea is to characterise the distribution of the score they produce w.r.t.\ different dependencies of variable strength and noise. Intuitively, stronger dependencies should lead to higher scores than noisier ones. \subsubsection{Dependency Generation} For benchmarking, we use an assortment of 12 multivariate dependencies scaled to $[0,1]$. Figure \ref{fig:deps-plot} represents each of them in two and three dimensions. For each dependency, we repeatedly draw $n$ objects with $d$ dimensions, to which we add Gaussian noise with standard deviation $\sigma$, which we call \textit{noise level}. \newcommand{0.32}{0.32} \begin{figure} \centering \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Cross-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Cross-3-00-crop.pdf} \hfill \caption{Cross (C)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/DoubleLinear_025-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/DoubleLinear_025-3-00-crop.pdf} \hfill \caption{Double linear (Dl)} \end{subfigure} \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Hourglass-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Hourglass-3-00-crop.pdf} \hfill \caption{Hourglass (H)} \end{subfigure} ~\\ \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Hypercube-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Hypercube-3-00-crop.pdf} \hfill \caption{Hypercube (Hc)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Hollowcube-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Hollowcube-3-00-crop.pdf} \hfill \caption{Hc Graph (HcG)} \end{subfigure} \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Sphere-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Sphere-3-00-crop.pdf} \hfill \caption{Hypersphere (Hs)} \end{subfigure} ~\\ \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Linear-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Linear-3-00-crop.pdf} \hfill \caption{Linear (L)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/EvenPower_1-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/EvenPower_1-3-00-crop.pdf} \hfill \caption{Parabolic (P)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Sine_1-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Sine_1-3-00-crop.pdf} \hfill \caption{Sine (P=1) (S1)} \end{subfigure} % ~\\ \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Sine_5-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Sine_5-3-00-crop.pdf} \hfill \caption{Sine (P=5) (S5)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Star-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Star-3-00-crop.pdf} \hfill \caption{Star (St)} \end{subfigure} % \hfill \begin{subfigure}[b]{0.32\linewidth} \hfill \includegraphics[width=0.32\linewidth]{plot-dep/Zinv-2-00-crop.pdf} \hfill \includegraphics[width=0.35\linewidth]{plot-dep/Zinv-3-00-crop.pdf} \hfill \caption{Z inversed (Zi)} \end{subfigure} \caption{12 selected multidimensional dependencies} \label{fig:deps-plot} \end{figure} \subsubsection{Score Distribution and Statistical Power} A dependency estimator $\mathcal{E}$ is an operator $\mathcal{E}(S) \mapsto \textit{score}$ which computes a \textit{score} for a subspace $S$. We inspect the \textit{score} of each estimator $\mathcal{E}$ against each dependency \textbf{X}, with increasing noise level $\sigma$. We consider $30$ noise levels, distributed linearly from $0$ to $1$. For better comparability, we also include the independent subspace \textbf{I} in the experiments, where each attribute is i.i.d.\ in $\mathcal{U}[0,1]$. For each dependency and each noise level, we draw $500$ subspaces to compute the estimate. We record the average (avg) and standard deviation (std) for each estimator and, in analogy to other bivariate and multivariate studies \cite{Nguyen2015UDS, Reshef2011, Kinney2013}, we compute the so-called statistical power. \begin{dfn}[Power] The power of an estimator $\mathcal{E}$ w.r.t.\ \textbf{X} with $\sigma$, $n$ and $d$ is the probability of the \textit{score} of $\mathcal{E}$ to be larger than a $\gamma$-th percentile of the \textit{scores} w.r.t. the independence \textbf{I}: \normalfont \begin{align} \Pr\left ( \mathcal{E}\left(Inst_{n \times d}^{\textbf{X},\sigma}\right) > \left \{\mathcal{E}\left(Inst_{n \times d}^{\textbf{I},0}\right) \right \}^{P_\gamma} \right ) \end{align} \end{dfn} $Inst_{n \times d}^{\textbf{X},\sigma}$ is a random instantiation of a subspace as dependency \textbf{X} with noise level $\sigma$, which has $n$ objects and $d$ dimensions. $\{x\}^{P_\gamma}$ stands for the $\gamma$-th percentile of the set $\{x\}$, i.e., a value $v$ such that $\gamma \%$ of the values in $\{x\}$ are smaller than $v$. Note that, since the attributes of \textbf{I} are independent, adding noise does not have any effect on dependence, so we set noise to 0 when instantiating \textbf{I}. To estimate the power, we draw two sets of $500$ estimates from $\textbf{X}$, $\sigma$ and $\textbf{I}$ respectively: \begin{align*} \Sigma^\mathcal{E}_{\textbf{X}, \sigma} : \left \{ \mathcal{E}\left(Inst_{n \times d}^{\textbf{X},\sigma}\right) \right \}_{i=1}^{500} ~ &&\Sigma^{\mathcal{E}}_\textbf{I} : \left \{ \mathcal{E}\left(Inst_{n \times d}^{\textbf{I},0}\right) \right \}_{i=1}^{500} \end{align*} Then, we count the elements in $\Sigma^\mathcal{E}_{\textbf{X}, \sigma}$ greater than $\left \{\Sigma^{\mathcal{E}}_\textbf{I} \right \}^{P_\gamma}$: \begin{align} power^{\textbf{X},\sigma}_{n \times d,\gamma }(\mathcal{E}) = \frac{\left|\left\{x:x \in \Sigma^\mathcal{E}_{\textbf{X}, \sigma} ~\wedge~ x > \left \{\Sigma^{\mathcal{E}}_\textbf{I} \right \}^{P_\gamma}\right \}\right|}{500} \end{align} One can interpret $power$ as the probability to correctly reject the independence hypothesis with $\gamma \%$ confidence. In other words, the power quantifies how well a dependency measure, such as \textit{MWP}, can differentiate between the independence \textbf{I} and a given dependency \textbf{X} with noise level $\sigma$. For our experiments, we choose $\gamma =95$. In the case of Interaction Information (\textit{II}), values can be negative or positive, depending on whether the dependency is a `synergy' or a `redundancy'. For \textit{II}, we measure power using the absolute value of its score. \subsection{General characteristics of \textit{MWP}} \label{mwp_under_scrutinity} First, we look at the evolution of the scores of \textit{MWP} regarding the dimensionality $d$, sample size $n$ and $M$. \subsubsection{Influence of dimensionality $d$} \begin{figure} \includegraphics[width=1.02\linewidth]{MWP_d.pdf} \caption{\textit{MWP} w.r.t. dimensionality $d$} \label{fig:momentsMWP} \end{figure} Figure~\ref{fig:momentsMWP} graphs the evolution of \textit{MWP} for $d = 2,3,5$. Please note that the figures are best seen in colour. The expectation is that the scores are high for noiseless dependencies, i.e., the left side of the plot is blue, and decrease gradually as we add noise. A noise level $\sigma = 1$ is comparably high, since the data is scaled to $[0,1]$. Thus, the right side of the plot should be red, standing for low scores. As we see, the average \textit{MWP} decreases gradually for each dependency. The same level of noise does not seem to affect each estimate equally, also regarding dimensionality. For instance, the estimates of \textbf{L}, \textbf{P} and \textbf{S1} are larger at $d=2$. While the estimates of \textbf{Hc}, \textbf{HcG}, \textbf{P} and \textbf{Zi} decrease with increasing $d$, they increase for \textbf{C} and \textbf{St}. The standard deviation of \textit{MWP} increases with noise and decreases with $d$. In particular, \textbf{L}, \textbf{C} and \textbf{Hs} have a low standard deviation. This means that fewer iterations are in fact required to estimate stronger dependencies at a given accuracy. The statistical power does not seem to vary much with dimensionality for most dependencies. It decreases with $d$ for \textbf{Hc}, \textbf{HcG}, \textbf{Hs}, \textbf{P} and \textbf{Zi}, while it increases for \textbf{C}, \textbf{S5} and \textbf{St}. All in all, each dependency yields a score larger than the independence \textbf{I} up to a certain level of noise, leading to a high power. This indicates that \textit{MWP} is \textbf{general-purpose} (\textbf{R3}). \begin{figure} \includegraphics[width=\linewidth]{MWP_N.pdf} ~ \includegraphics[width=\linewidth]{MWP_M.pdf} \caption{Power of \textit{MWP} w.r.t. $n$ and $M$} \label{fig:NM_MWP} \end{figure} \subsubsection{Influence of sample size $n$ and parameter $M$} Figure~\ref{fig:NM_MWP} shows that power globally increases with $n$, but it is still high for most dependencies with low $n$, provided noise is moderate. As we can see, the average score of \textit{MWP} tends to increase with $n$, which explains the gain in power. In fact, that is because \textit{MWP} is \textbf{sensitive} (\textbf{R7}), as we discuss in \mbox{Section \ref{sensitivity}}. Similarly, power increases slightly as $M$ increases, but the effect is visible only for \textbf{S5} and \textbf{Zi}. This increase of power is easily explained by the fact that the standard deviation of \textit{MWP} decreases, which is what Theorem \ref{"th:hoeffding-chernoff-contrast"} predicted: with more iterations, the values concentrate more around $\mathcal{C}$. In the end, we see that \textit{MWP} is already useful for small $n$ or small $M$, even though more iterations or more data samples yield higher power when data is noisy. \subsection{Score Distribution and Statistical Power} \label{distribution} \begin{figure*} \includegraphics[width=\linewidth]{avg_std_all.pdf} \caption{Distribution of dependency estimation scores, $d=3$} \label{fig:contrast_all} \end{figure*} We now observe the distribution of the scores for each approach in Figure \ref{fig:contrast_all}. First, we see that the average score of \textit{MWP} is most similar to \textit{TC}. \textit{TC} however is unbounded, and a logarithmic scale is necessary to visualize it. This means that the estimates of TC change very abruptly. \textit{II} can yield positive or negative values. Since both cases are interesting, we visualize the absolute value of \textit{II} with a logarithmic scale. We mark the dependencies which obtain a positive score in their noiseless form with a plus sign. Like \textit{TC}, \textit{II} assigns high absolute scores to every noiseless dependency. However, the score decreases rapidly with noise, except for \textbf{L}. \textit{HiCS} shows a similar behaviour as \textit{MWP}, except that the scores decrease faster, and that a large number of dependencies starts with a relatively low score, even in the noiseless form, such as \textbf{C}, \textbf{Dl}, \textbf{H}, \textbf{Hs}, \textbf{S5} and \textbf{St}. Next, \textit{MS} and \textit{UDS} are restricted to monotonous and bijective functional relationships respectively. They can detect only 3 out of 12 dependencies. \textit{MAC} and \textit{CMI} behave curiously. Their scores change noticeably only for \textbf{C}, \textbf{Dl}, \textbf{L}, \textbf{P} and \textbf{S1}. The values of \textit{MAC} also change very abruptly and even non-monotonously with noise. For example, \textbf{L} and \textbf{S1} obtain lower scores with a noise level of 0.3 than with higher noise levels. \textit{CMI} evolves smoothly. However, for many dependencies, including \textbf{I}, the score increases again with more noise: The shades on the right are lighter, which shows a bias towards noise, independently from the underlying relationship. By looking at \textit{MWP} and \textit{MS}, we see that the standard deviation behaves similarly: It decreases as the score increases. We observe the opposite for \textit{HiCS}. The standard deviation of \textit{CMI} reaches its highest level at a certain noise level, around $0.2$ for \textbf{L}, and tends to increase slightly again with more noise. For \textit{UDS} and \textit{MAC}, the evolution of the standard deviation looks very unstable. The standard deviation of \textit{TC} and \textit{II} does not change much, except for noiseless dependencies. While the scores of \textit{HiCS}, \textit{UDS}, \textit{MAC} and \textit{CMI} are expected to be in $[0,1]$, the theoretical maximum or minimum is never reached, even if our benchmark features both strong and weak dependencies. On the other hand, \textit{MWP} and \textit{MS} exploit all the values of their range, being $[0.5,1]$ and $[0,1]$ respectively. Thus, they are easier to interpret (\textbf{R6}). \begin{figure} \begin{subfigure}[b]{\linewidth} \includegraphics[width=\linewidth]{power_all_d3.pdf} \caption{$d=3$} \end{subfigure} \begin{subfigure}[b]{\linewidth} \includegraphics[width=\linewidth]{power_all_d5.pdf} \caption{$d=5$} \end{subfigure} \caption{Power against each dependency} \label{fig:E_Power} \end{figure} Figure \ref{fig:E_Power} reveals that \textit{MWP}, \textit{TC} and \textit{HiCS} achieve high power in any situation up to a certain extent of noise. \textit{MWP} shows slightly more power with \textbf{C}, \textbf{H}, \textbf{Hc}, \textbf{HcG}, \textbf{Hs} and \textbf{St}. \textit{II} can detect almost every dependency but the power decreases rapidly with noise and dimensionality. \textit{MS} detects \textbf{Dl}, \textbf{L}, \textbf{P}, \textbf{S1}, \textbf{S5} and \textbf{Zi}, but misses all other dependencies. \textit{MAC} looks unstable, since its power evolves in a non-monotonous way and decreases with increasing dimensionality by much. In fact, it is not able to detect most dependencies for $d=5$. \textit{UDS} can only detect \textbf{L}, \textbf{P} and \textbf{S1}, a clear limitation. \textit{CMI} has maximal power for each dependency and noise level for $d=3$, which is unrealistic: \textit{CMI} reaches its lowest score against the noiseless \textbf{I}, our baseline for power. This means that \textit{CMI} cannot distinguish between noise and dependence. \subsection{Sensitivity} \label{sensitivity} \textbf{R7} states that estimators should also reflect the strength of the observed effect w.r.t. the number of observations. Figure \ref{fig:All_sensitivity} graphs the average score from 500 instances of each dependency with a small noise level of $1/30$. The average of \textit{MWP} obtained for each dependency converges to 1 consistently with more samples, except for the independence. Its values stabilize around $0.5$. This means that \textit{MWP} is \textbf{sensitive} (\textbf{R7}). \textit{TC} behaves similarly to \textit{MWP}: When the sample size increases, the score tends to increase as well. However, it is not bounded. While the scores of \textit{II} seem to increase with sample size, they decrease in terms of absolute value, except for \textbf{Hs}. \textit{MS} is completely insensitive to changes in the sample size. \textit{HiCS}, \textit{UDS}, \textit{MAC} and \textit{CMI} behave antagonistically: Their scores tends to go down as the sample size increases, even in the case of the independence \textbf{I}. This implies that their minimum or maximum score varies with the sample size, highlighting also interpretability (\textbf{R6}) problems. \begin{figure} \includegraphics[width=\linewidth]{sensitivity_all.pdf} \caption{Average score w.r.t. $n$, $\sigma = 1/30$} \label{fig:All_sensitivity} \end{figure} \subsection{Robustness} \label{robustness} Data is often imperfect, i.e., values are rounded or trimmed. In some cases, this may lead to wrong estimates, e.g., an independent space is declared as strongly dependent. We simulate data imperfections by discretising a 3-dimensional linear dependency into a number $\omega$ of discrete values from 100 to 1. With only one value, the space is completely redundant, i.e., its \textit{contrast} should be minimal. We compare the power of \textit{MWP} and of the other approaches against the linear dependency \textbf{L} and the independence \textbf{I} for different levels of discretisation. Figure \ref{fig:E_Discrete_Power} displays the results. Since \textit{TC} and \textit{II} rely on a nearest neighbours algorithm, they fail when the same observation is present more than $k$ times i.e., they are by design not robust; we exclude them from the analysis. \textit{HiCS} yields high power in the case of discrete values, even with \textbf{I}. This is because \textit{HiCS} uses the \textit{Kolmogorov-Smirnov} test which assumes continuous data. Thus, \textit{HiCS} is not robust. Also, the power of \textit{CMI} wrongly increases as we add noise to \textbf{I}, provided that the discretisation level $\omega$ is not less than $10$. This explains why the power of \textit{CMI} is high for every dependency in Section \ref{distribution}. \textit{CMI} rejects the independence for independent spaces as well, i.e., it is not robust. On the other hand, \textit{MWP}, \textit{MS}, \textit{UDS} and \textit{MAC} appear \textbf{robust} (\textbf{R8}). In Figure \ref{fig:E_Discrete_average}, we see that the score of \textit{CMI} tends to increase slightly for \textbf{I} as we add noise, provided that $\omega > 5$. Also, the score of \textit{HiCS} increases for both \textbf{I} and \textbf{L} when $\omega \leq 5$. \textit{MAC} converges to $0.4$ as noise increases for $\omega > 10$. On the other hand, \textit{MWP} converges to $0$ as the space becomes discrete. This is an interesting feature of our estimator: discrete spaces are of lower interested, since the notion of \textit{contrast} is not defined there. It allows analysts to draw a line between discrete and real-valued attributes in terms of interestingness. \begin{figure} \begin{subfigure}[b]{\linewidth} \includegraphics[width=\linewidth]{discrete_power.pdf} \caption{Power} \label{fig:E_Discrete_Power} \end{subfigure} \begin{subfigure}[b]{\linewidth} \includegraphics[width=\linewidth]{discrete_avg.pdf} \caption{Average} \label{fig:E_Discrete_average} \end{subfigure} \caption{Power and average score of each approach w.r.t. $\omega$} \label{fig:E_Discrete} \end{figure} \subsection{Scalability} \label{scalability} \begin{figure} \includegraphics[width=\linewidth]{scalability_nd.pdf} \caption{Execution time w.r.t. $n$ and $d$} \label{fig:Runtime_n_d} \end{figure} We now look at the runtime requirements of our approach. We measure the average CPU time for each estimator against 500 data sets with a growing number of objects $n$ and dimensionality $d$. Note that which data set we use only has a marginal effect on the measured time. For consistency, we use instantiations of \textbf{I} for every estimator. Figure \ref{fig:Runtime_n_d} graphs the results. As we can see, \textit{MWP} is the second fastest after \textit{MS}. \textit{HiCS} and \textit{CMI} scale relatively well with $n$ and $d$. There is a second group formed by \textit{TC}, \textit{II} and \textit{UDS} one order of magnitude slower. However, \textit{II} does not scale well with $d$. \textit{MAC} is way behind all others. One should note that the runtime of \textit{MWP} can be further improved via parallelisation and prior indexing. \subsection{Discussion} Our study has shown that \textit{MWP} fulfils all the requirements we have laid out. We have compared \textit{MWP} to a range of multi\-variate (\textbf{R1}) and non-parametric (\textbf{R5}) approaches. We have shown to which extent they are efficient (\textbf{R2}), general-purpose (\textbf{R3}), interpretable (\textbf{R6}), sensitive to effect size (\textbf{R7}) and robust (\textbf{R8}). Each approach, except \textit{MWP} and \textit{MS}, has at least one unintuitive parameter (\textbf{R4}): \textit{TC} and \textit{II} require $k \in \mathbb{N}$, \textit{CMI} requires $Q \in \mathbb{N}$, \textit{MAC} requires $\epsilon \in (0,1)$, \textit{UDS} requires $\beta \in \mathbb{N}$, \textit{HiCS} requires $\alpha \in (0,1)$. Next, only \textit{MWP} and \textit{HiCS} allow to trade accuracy for a computational advantage (\textbf{R9}). Table~\ref{table:requirements} summarizes our findings. \begin{table}[ht] \centering \begin{tabular}{l c c c c c c c c c} \hline Estimator & \textbf{R1} & \textbf{R2} & \textbf{R3} & \textbf{R4} & \textbf{R5} & \textbf{R6} & \textbf{R7} & \textbf{R8} & \textbf{R9}\\ \hline \textit{MS} & \ding{51} & ++ & \ding{55} & \ding{51} & \ding{51} & \ding{51} & \ding{55} & \ding{51} & \ding{55} \\ \textit{TC} & \ding{51} & - & \ding{51} & \ding{55} & \ding{51} & \ding{55} & \ding{51} & \ding{55} & \ding{55}\\ \textit{II} & \ding{51} & -{}- & \ding{55} & \ding{55} & \ding{51} & \ding{55} & \ding{55} & \ding{55} & \ding{55}\\ \textit{CMI} & \ding{51} & + & \ding{55} & \ding{55} & \ding{51} & \ding{55} & \ding{55} & \ding{55} & \ding{55}\\ \textit{MAC} & \ding{51} & -{}- & \ding{55} & \ding{55} & \ding{51} & \ding{55} & \ding{55} & \ding{51} & \ding{55}\\ \textit{UDS} & \ding{51} & - & \ding{55} & \ding{55} & \ding{51} & \ding{55} & \ding{55} & \ding{51} & \ding{55}\\ \textit{HiCS} & \ding{51} & + & \ding{51} & \ding{55} & \ding{51} & \ding{55} & \ding{55} & \ding{55} & \ding{51} \\ \textit{MWP} & \ding{51} & ++ & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} & \ding{51} \\ \hline \end{tabular} \caption{Requirement fulfilment} \label{table:requirements} \end{table} All in all, \textit{MWP} establishes itself as a state-of-the-art estima\-tor: It is versatile, allowing quality-runtime trade-offs and parallelisation, which is useful when time is critical, e.g., in large data streams. At the same time, it shows very good detection quality with no restriction on the dependency type, while being easy to use and interpret. \textit{MWP} features a unique blend of desirable properties that so far no competitor offers. \section{Conclusions \& Outlook} \label{conclusions} In this paper, we have introduced \textit{MCDE}, a framework to estimate multivariate dependency, and its instantiation as \textit{MWP}. We have shown that \textit{MWP} fulfils all the requirements one would expect from a state-of-the-art dependency estimator. Compared to other approaches, it provides high statistical power on a large panel of dependencies, while being very efficient. Thus, \textit{MCDE}-\textit{MWP} is particularly promising for correlation monitoring in data streams. As future work, we will study the deployment of \textit{MCDE} in streaming scenarios. Our goal is to characterize the \textbf{anytime flexibility} of \textit{MCDE} by refining the bound presented in Theorem \ref{"th:hoeffding-chernoff-contrast"} via further assumptions. It will also be interesting to consider different instantiations of the statistical test, e.g., by comparing recent modifications of the \textit{Mann-Whitney\,U} test, such as \cite{fligner1981robust} and \cite{brunner2000nonparametric}. Finally, the efficiency of \textit{MCDE} in the streaming setting could be further improved via efficient insert and delete index operations. \section*{Acknowledgements} This work was partially supported by the DFG Research Training Group 2153: `Energy Status Data -- Informatics Methods for its Collection, Analysis and Exploitation' and the German Federal Ministry of Education and Research (BMBF) via Software Campus (01IS17042). \balance
{'timestamp': '2018-10-05T02:09:05', 'yymm': '1810', 'arxiv_id': '1810.02112', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02112'}
arxiv
\section{Introduction} Current societies are exposed to a continuous flow of information that results in a large production of data (e.g. news articles, micro-blogs, social media posts, among others), at different moments in time. In addition to this, the consumption of information has dramatically changed: more and more people directly access information through social media platforms (e.g. Facebook and Twitter), and are less and less exposed to a diversity of perspectives and opinions. The combination of these factors may easily result in \textit{information overload} and impenetrable ``\textit{filter bubbles}''. Events, i.e. things that happen or hold as true in the world, are the basic components of such data stream. Being able to correctly identify and classify them plays a major role to develop robust solutions to deal with the current stream of data (e.g. the storyline framework~\cite{vossen2015storylines}), as well to improve the performance of many Natural Language Processing (NLP) applications such as automatic summarization and question answering (Q.A.). Event detection and classification has seen a growing interest in the NLP community thanks to the availability of annotated corpora~\cite{ACE-event-2005,pustetal03-IWCS,W16-5706,CYBULSKA+VOSSEN:2014} and evaluation campaigns~\cite{verhagen-EtAl:2007:SemEval-2007,verhagen2010semeval,uzzanametal2013,bethard2015semeval,bethard2016semeval,minard2015semeval}. In the context of the 2014 EVALITA Workshop, the EVENTI evaluation exercise~\cite{casellietal-evalita2014}\footnote{\url{https://sites.google.com/site/eventievalita2014/}} was organized to promote research in Italian Temporal Processing, of which event detection and classification is a core subtask. Since the EVENTI campaign, there has been a lack of further research, especially in the application of deep learning models to this task in Italian. The contributions of this paper are the followings: i.) the adaptation of a state-of-the-art sequence to sequence (seq2seq) neural system to event detection and classification for Italian in a single step approach; ii.) an investigation on the quality of existing Italian word embeddings for this task; iii.) a comparison against a state-of-the-art discrete classifier. The pre-trained models and scripts running the system (or re-train it) are publicly available.~\footnote{\url{https://github.com/tommasoc80/Event_detection_CLiC-it2018}}. \begin{table*}[!t] \begin{minipage}[!th]{0.45\textwidth} \centering \small \begin{tabular}{lrrr} POS & Training & Dev. & Test \\ \hline Noun & 6,710 & 111 & 1,499 \\ Verb & 11,269 & 193 & 2,426 \\ Adjective & 610 & 9 & 118 \\ Preposition & 146 & 1 & 25\\ \hline Overall Event Tokens & 18,735 & 314 & 4,068 \\ \end{tabular} \caption{\label{tab:pos} Distribution of the event mentions per POS per token in all datasets of the EVENTI corpus.} \end{minipage} \hfill \begin{minipage}[!th]{0.45\textwidth} \centering \small \begin{tabular}{lrrr} Class & Training & Dev. & Test \\ \hline OCCURRENCE & 9,041 & 162 & 1,949\\ ASPECTUAL & 446 & 14 & 107 \\ I\_STATE & 1,599 & 29 & 355 \\ I\_ACTION & 1,476 & 25 & 357 \\ PERCEPTION & 162 & 2 & 37 \\ REPORTING & 714 & 8 & 149 \\ STATE & 4,090 & 61 & 843 \\ \hline Overall Events & 17,528 & 301 & 3,798 \\ \end{tabular} \caption{\label{tab:class} Distribution of the event mentions per class in all datasets of the EVENTI corpus.} \end{minipage} \end{table*} \section{Task Description} We follow the formulation of the task as specified in the EVENTI exercise: determine the extent and the class of event mentions in a text, according to the It-TimeML $<$EVENT$>$ tag definition (Subtask B in EVENTI). In EVENTI, the tag $<$EVENT$>$ is applied to every linguistic expression denoting a situation that happens or occurs, or a state in which something obtains or holds true, regardless of the specific parts-of-speech that may realize it. EVENTI distinguishes between single token and multi-tokens events, where the latter are restricted to specific cases of eventive multi-word expressions in lexicographic dictionaries (e.g. ``\textit{fare le valigie}'' [to pack]), verbal periphrases (e.g. ``\textit{(essere) in grado di}'' [(to be) able to]; ``\textit{c'\`e}'' [there is]), and named events (e.g. ``\textit{la strage di Beslan}'' [Beslan school siege]). Each event is further assigned to one of 7 possible classes, namely: OCCURRENCE, ASPECTUAL, PERCEPTION, REPORTING, I(NTESIONAL)\_STATE, I(NTENSIONAL)\_ACTION, and STATE. These classes are derived from the English TimeML Annotation Guidelines~\cite{pustejovsky2003timeml}. The TimeML event classes distinguishes with respect to other classifications, such as ACE~\cite{ACE-event-2005} or FrameNet~\cite{framenet}, because they expresses relationships the target event participates in (such as factual, evidential, reported, intensional) rather than semantic categories denoting the meaning of the event. This means that the EVENT classes are assigned by taking into account both the semantic and the syntactic context of occurrence of the target event. Readers are referred to the EVENTI Annotation Guidelines for more details\footnote{\url{https://sites.google.com/site/eventievalita2014/file-cabinet}}. \subsection{Dataset} The EVENTI corpus consists of three datasets: the Main Task training data, the Main task test data, and the Pilot task test data. The Main Task data are on contemporary news articles, while the Pilot Task on historical news articles. For our experiments, we focused only on the Main Task. In addition to the training and test data, we have created also a Main Task development set by excluding from the training data all the articles that composed the test data of the Italian dataset at the SemEval 2010 TempEval-2 campaign~\cite{verhagen2010semeval}. The new partition of the corpus results in the following distribution of the $<$EVENT$>$ tag: i) 17,528 events in the training data, of which 1,207 are multi-token mentions; ii.) 301 events in the development set, of which 13 are multi-token mentions; and finally, iii.) 3,798 events in the Main task test, of which 271 are multi-token mentions. Tables~\ref{tab:pos} and ~\ref{tab:class} report, respectively, the distribution of the events per token part-of speech (POS) and per event class. Not surprisingly, verbs are the largest annotated category, followed by nouns, adjectives, and prepositional phrases. Such a distribution reflects both a kind of ``natural'' distribution of the realization of events in an Indo-european language, and, at the same time, specific annotation choices. For instance, adjectives have been annotated only when in a predicative position and when introduced by a copula or a copular construction. As for the classes, OCCURRENCE and STATE represent the large majority of all events, followed by the intensional ones (I\_STATE and I\_ACTION), expressing some factual relationship between the target events and their arguments, and finally the others (REPORTING, ASPECTUAL, and PERCEPTION). \section{System and Experiments} We adapted a publicly available Bi-LSTM network with a CRF classifier as last layer~\cite{reimers-gurevych:2017:EMNLP2017}.~\footnote{\url{https://github.com/UKPLab/emnlp2017-bilstm-cnn-crf}} \cite{reimers-gurevych:2017:EMNLP2017} demonstrated that word embeddings, among other hyper-parameters, have a major impact on the performance of the network, regardless of the specific task. On the basis of these experimental observations, we decided to investigate the impact of different Italian word embeddings for the Subtask B Main Task of the EVENTI exercise. We thus selected 5 word embeddings for Italian to initialize the network, differentiating one with respect to each other either for the representation model used (\texttt{word2vec} \textit{vs}. GloVe; CBOW \textit{vs}. skip-gram), dimensionality (300 \textit{vs}. 100), or corpora used for their generation (Italian Wikipedia \textit{vs}. crawled web document \textit{vs}. large textual corpora or archives): \begin{table*}[!t] \centering \small \begin{tabular}{lrrrrrrrr} & \multicolumn{4}{r}{Strict Evaluation} & \multicolumn{4}{r}{Relaxed Evaluation} \\ \hline Embedding Parameter & R & P & F1 & F1-class & R & P & F1 & F1-class \\ \hline Berardi2015\_w2v & 0.868 & 0.868 & 0.868 & 0.705 & 0.892 & 0.892 & 0.892 & 0.725 \\ Berardi2015\_Glove & 0.848 & 0.872 & 0.860 & 0.697 & 0.870 & 0.895 & 0.882 & 0.714 \\ Fastext-It & \bf 0.897 & 0.863 & \bf 0.880 & \bf 0.736 & \bf 0.921 & 0.887 & \bf 0.903 & \bf 0.756 \\ ILC-ItWack & 0.831 & \bf 0.884 & 0.856 & 0.702 & 0.860 & \bf 0.914 & 0.886 & 0.725 \\ DH-FBK\_100 & 0.855 & 0.859 & 0.857 & 0.685 & 0.881 & 0.885 & 0.883 & 0.705 \\ \hline \hline FBK-HLT@EVENTI 2014 & 0.850 & \textit{0.884} & 0.867 & 0.671 & 0.868 & 0.902 & 0.884 & 0.685 \\ \end{tabular} \caption{\label{tab:subtask-all} Results for Bubtask B Main Task - Event detection and classification.} \end{table*} \begin{itemize} \item Berardi2015\_w2v~\cite{berardi2015word}: 300 dimension word embeddings generated using the \texttt{word2vec}~\cite{mikolov2013distributed} skip-gram model~\footnote{Parameters: negative sampling 10, context window 10} from the Italian Wikipedia; \item Berardi2015\_glove~\cite{berardi2015word}: 300 dimensions word embeddings generated using the GloVe model~\cite{pennington2014glove} from the Italian Wikipedia\footnote{Berardi2015\_w2v and Berardi2015\_glove uses a 2015 dump of the Italian Wikipedia}; \item Fastext-It: 300 dimension word embeddings from the Italian Wikipedia~\footnote{Wikipedia dump not specified.} obtained using Bojanovsky's skip-gram model representation~\cite{bojanowski2016enriching}, where each word is represented as a bag of character n-grams~\footnote{\url{https://github.com/facebookresearch/fastText/blob/master/pretrained-vectors.md}}; \item ILC-ItWack~\cite{cimino2016building}: 300 dimension word embeddings generated by using the \texttt{word2vec} CBOW model~\footnote{Parameters: context window 5.} from the ItWack corpus; \item DH-FBK\_100~\cite{tonelliimpact}: 100 dimension word and phrase embeddings, generated using the \texttt{word2vec} and \texttt{phrase2vec} models, from 1.3 billion word corpus (Italian Wikipedia, OpenSubtitles2016~\cite{lison2016opensubtitles2016}, PAISA corpus~\footnote{\url{http://www.corpusitaliano.it/}}, and the Gazzetta Ufficiale). \end{itemize} As for the other parameters, the network maintains the optimized configurations used for the event detection task for English~\cite{reimers-gurevych:2017:EMNLP2017}: two LSTM layers of 100 units each, \textit{Nadam} optimizer, variational dropout (0.5, 0.5), with gradient normalization ($\tau$ = 1), and batch size of 8. Character-level embeddings, learned using a Convolutional Neural Network (CNN)~\cite{P16-1101}, are concatenated with the word embedding vector to feed into the LSTM network. Final layer of the network is a CRF classifier. Evaluation is conducted using the EVENTI evaluation framework. Standard Precision, Recall, and F1 apply for the event detection. Given that the extent of an event tag may be composed by more than one tokens, systems are evaluated both for strict match, i.e. one point only if all tokens which compose an $<$EVENT$>$ tag are correctly identified, and relaxed match, i.e. one point for any correct overlap between the system output and the reference gold data. The classification aspect is evaluated using the F1-attribute score~\cite{uzzanametal2013}, that captures how well a system identify both the entity (extent) and attribute (i.e. class) together. We approached the task in a single-step by detecting and classifying event mentions at once rather than in the standard two step approach, i.e. detection first and classification on top of the detected elements. The task is formulated as a seq2seq problem, by converting the original annotation format into an BIO scheme (Beginning, Inside, Outside), with the resulting alphabet being B-\textit{class\_label}, I-\textit{class\_label} and O. Example~\ref{example-rec-class-event} below illustrates a simplified version of the problem for a short sentence: \enumsentence{ \begin{small} \begin{tabbing} \ \= \underline{input \ \ } \ \= \underline{\ problem\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ } \ \ \ \ \ \ \= \underline{solution}\\ \> Marco \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> O\\ \> pensa \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> B-ISTATE\\ \> di \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> O\\ \> andare \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> B-OCCUR\\ \> a \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> O\\ \> casa \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> O\\ \> . \> (B-STATE $|$ I-STATE $|$ \dots $|$ O) \> O\\ \end{tabbing} \end{small}}\label{example-rec-class-event} \subsection{Results and Discussion} Results for the experiments are illustrated in Table~\ref{tab:subtask-all}. We also report the results of the best system that participated at EVENTI Subtask B, FBK-HLT~\cite{mirza2014fbk}. FBK-HLT is a cascade of two SVM classifiers (one for detection and one for classification) based on rich linguistic features. Figure~\ref{fig:volumes} plots charts comparing F1 scores of the network initialized with each of the five embeddings against the FBK-HLT system for the event detection and classification tasks, respectively. The results of the Bi-LSTM-CRF network are varied in both evaluation configurations. The differences are mainly due to the embeddings used to initialize the network. The best embedding configuration is Fastext-It that differentiate from all the others for the approach used for generating the embeddings. Embedding's dimensionality impacts on the performances supporting the findings in ~\cite{reimers-gurevych:2017:EMNLP2017}, but it seems that the quantity (and variety) of data used to generate the embeddings can have a mitigating effect, as shown by the results of the DH-FBK-100 configuration (especially in the classification subtask, and in the Recall scores for the event extent subtask). Coverage of the embeddings (and consequenlty, tokenization of the dataset and the embeddings) is a further aspect to keep into account, but it seems to have a minor impact with respect to dimensionality. It turns out that~\cite{berardi2015word}'s embeddings are those suffering the most from out of vocabulary (OVV) tokens (2.14\% and 1.06\% in training, 2.77\% and 1.84\% in test for the \texttt{word2vec} model and GloVe, respectively) with respect to the others. However, they still outperform DH-FBK\_100 and ILC-ItWack, whose OVV are much lower (0.73\% in training and 1.12\% in test for DH-FBK\_100; 0.74\% in training and 0.83\% in test for ILC-ItWack). \begin{figure} \begin{center} \includegraphics[width=0.5\textwidth]{plot_performance.png} \caption{Plots of F1 scores of the Bi-LSTM-CRF systems against the FBK-HLT system for Event Extent (left side) and Event Class (right side). F1 scores refers to the } \label{fig:volumes} \end{center} \end{figure} The network obtains the best F1 score, both for detection (F1 of 0.880 for strict evaluation and 0.903 for relaxed evaluation with Fastext-It embeddings) and for classification (F1-class of 0.756 for strict evaluation, and 0.751 for relaxed evaluation with Fastext-It embeddings). Although FBK-HLT suffers in the classification subtask, it qualifies as a highly competitive system for the detection subtask. By observing the strict F1 scores, FBK-HLT beats three configurations (DH-FBK-100, ILC-ItWack, Berardi2015\_Glove)~\footnote{$p$-value $<$ 0.005 only against Berardi2015\_Glove and DH-FBK-100, with McNemar's test.}, almost equals one (Berardi2015\_w2v)~\footnote{$p$-value $>$ 0.005 with McNemar's test.}, and it is outperformed only by one (Fastext-It)~\footnote{$p$-value $<$ 0.005 with McNemar's test.}. In the relaxed evaluation setting, DH-FBK-100 is the only configuration that does not beat FBK-HLT (although the difference is only 0.001 point). Nevertheless, it is remarkable to observe that FBK-HLT has a very high Precision (0.902, relaxed evaluation mode), that is overcome by only one embedding configuration, ILC-ItWack. The results also indicates that word embeddings have a major contribution on Recall, supporting observations that distributed representations have better generalization capabilities than discrete feature vectors. This is further supported by the fact that these results are obtained using a single step approach, where the network has to deal with a total of 15 possible different labels. We further compared the outputs of the best model, i.e. Fastext-It, against FBK-HLT. As for the event detection subtask, we have adopted an event-based analysis rather than a token based one, as this will provide better insights on errors concerning multi-token events and event parts-of-speech (see Table~\ref{tab:pos} for reference).~\footnote{Note that POS are manually tagged for events, not for their components.} By analyzing the True Positives, we observe that the Fastext-It model has better performances than FBK-HLT with nouns (77.78\% \textit{vs}. 65.64\%, respectively) and prepositional phrases (28.00\% \textit{vs}. 16.00\%, respectively). Performances are very close for verbs (88.04\% \textit{vs}. 88.49\%, respectively) and adjectives (80.50\% \textit{vs}. 79.66\%, respectively). These results, especially those for prepositional phrases, indicates that the Bi-LSTM-CRF network structure and embeddings are also much more robust at detecting multi-tokens instances of events, and difficult realizations of events, such as nouns. Concerning the classification, we focused on the mismatches between correctly identified events (extent layer) and class assignment. The Fastext-It model wrongly assigns the class to only 557 event tokens compared to the 729 cases for FBK-HLT. The distribution of the class errors, in terms of absolute numbers, is the same between the two systems, with the top three wrong classes being, in both cases, OCCURRENCE, I\_ACTION and STATE. OCCURRENCE, not surprisingly, is the class that tends to be assigned more often by both systems, being also the most frequent. However, if FBK-HLT largely overgeneralizes OCCURRENCE (59.53\% of all class errors), this corresponds to only one third of the errors (37.70\%) in the Bi-LSTM-CRF network. Other notable differences concern I\_ACTION (27.82\% of errors for the Bi-LSTM-CRF \textit{vs}. 17.28\% for FBK-HLT), STATE (8.79\% for the Bi-LSTM-CRF \textit{vs}. 15.22\% for FBK-HLT) and REPORTING (7.89\% for the Bi-LSTM-CRF \textit{vs}. 2.33\% for FBK-HLT) classes. \section{Conclusion and Future Work} This paper has investigated the application of different word embeddings for the initialization of a state-of-the-art Bi-LSTM-CRF network to solve the event detection and classification task in Italian, according to the EVENTI exercise. We obtained new state-of-the-art results using the Fastext-It embeddings, and improved the F1-class score of 6.5 points in strict evaluation mode. As for the event detection subtask, we observe a limited improvement (+1.3 points in strict F1), mainly due to gains in Recall. Such results are extremely positive as the task has been modeled in a single step approach, i.e. detection and classification at once, for the first time in Italian. Further support that embeddings have a major impact in the performance of neural architectures is provided, as the variations in performance of the Bi-LSMT-CRF models show. This is due to a combination of factors such as dimensionality, (raw) data, and the method used for generating the embeddings. Future work should focus on the development of embeddings that move away from the basic word level, integrating extra layers of linguistic analysis (e.g. syntactic dependencies)~\cite{komninos2016dependency}, that have proven to be very powerful for the same task in English. \section*{Acknowledgments} The author wants to thank all researchers and research groups who made available their word embeddings and their code. Sharing is caring. \bibliographystyle{acl}
{'timestamp': '2018-10-05T02:12:06', 'yymm': '1810', 'arxiv_id': '1810.02229', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02229'}
arxiv
\section{Specification} \label{sec:spec} Randen is an instantiation of Reverie, a sponge-like construction that scrambles its internal state using a permutation \cite{reverie}. To avoid the ambiguities of pseudocode, we describe its parts using standard C++11, plus explanatory text. The permutation operates on 128-bit pieces of the state called `branches'. This corresponds to the block size of AES. For convenience, we assume the availability of a platform-specific 128-bit SIMD vector type \texttt{V} with associated \texttt{Load}, \texttt{Store} and \texttt{AES} functions. \subsection{Initialization} Randen operates on a 2048-bit state, of which the first 128 bits are the inaccessible `inner' portion corresponding to the `capacity' of a sponge. The remaining `outer' bits are the generated random bits. To simplify initialization of the state, we partition it into 32 64-bit integers, two per 128-bit branch. Zero-initializing the state yields a valid generator, but applications will typically set some of its outer bits to arbitrary user-specified `seed' values. Providing more than 128 seed bits may help against multi-user attacks involving precomputation. We suggest a 256-bit seed, specified as four 64-bit \texttt{seed} integers. For more thorough diffusion, the seeds should be placed into `even-numbered` (according to zero-based index) branches of the state, e.g.\ the third (with zero-based indices 4, 5 in the array of 64-bit integers) and fifth. {\small \begin{lstlisting}[numbers=none] uint64_t state[32]; memset(state, 0, sizeof(state)); state[4] = seed0; state[5] = seed1; state[8] = seed2; state[9] = seed3; \end{lstlisting}} \subsection{Permutation} Randen's \texttt{Permute} is a generalized type-2 Feistel network \cite{type2Feistel} with 16 branches of 128 bits. \begin{figure}[ht] \includegraphics[trim=6cm 7.5cm 11cm 7.5cm]{gen_feistel}% \caption{One round of a four-branch type-2 generalized Feistel network with a block shuffle. F is a 128-bit permutation consisting of two AES rounds, described below.} \label{fig:feistel} \end{figure} \noindent It consists of two layers (Figure~\ref{fig:feistel}). The first (denoted \texttt{RoundFunctions}) XORs odd-numbered branches $\mathrm{s}_\mathrm{i}$ with a function \texttt{F} of their even-numbered neighbors. \texttt{F} is the same as in Simpira~v2 \cite{simpira}: two rounds of AES. The first round's constant, denoted \texttt{key}, is unique for every instance of \texttt{F}. This avoids any potential weaknesses due to weak or structured round constants, e.g.\ in Simpira v1 \cite{simpira}[p.~12]. We will discuss the size and purpose of the constants in the description of \texttt{Permute} below. The second constant is zero, which enables an optimization below. {\small \begin{lstlisting}[numbers=none] // Round function: two-round AES with a unique round constant. V F(const V even, const V key) { const V f1 = AES(even, key); return AES(f1, zero); } \end{lstlisting}} \noindent For every adjacent pair of \texttt{even} and \texttt{odd} branches, \texttt{RoundFunctions} loads the two corresponding 128-bit pieces of the state and overwrites \texttt{odd} with \texttt{F(even, key) XOR odd}. {\small \begin{lstlisting}[numbers=none] const V* RoundFunctions(const V* keys) { for (int branch = 0; branch < 16; branch += 2) { const V even = Load(state, branch); const V odd = Load(state, branch + 1); const V new_odd = F(even, *keys++) ^ odd; Store(new_odd, state, branch + 1); } return keys; } \end{lstlisting}} \noindent Note that the XOR can be computed for free because the last step of AES simply XORs with its round constant. We change the second AES round constant in \texttt{F} from \texttt{zero} (which has no effect) to \texttt{odd}. The \texttt{key} passed to each call to \texttt{F} comes from an array of eight AES keys. The second layer of the Feistel network (denoted \texttt{BlockShuffle}) rearranges the 128-bit branches into the prescribed order \cite{improvedFeistel}[p.~21, no.~10]. We permute the state such that the previous branch 7 comes first, followed by 2, 13, 4 and so on (see \texttt{shuffle} below): {\small \begin{lstlisting}[numbers=none] void BlockShuffle() { uint64_t source[32]; memcpy(source, state, sizeof(source)); constexpr int shuffle[16] = { 7, 2, 13, 4, 11, 8, 3, 6, 15, 0, 9, 10, 1, 14, 5, 12}; for (int branch = 0; branch < 16; ++branch) { const V v = Load(source, shuffle[branch]); Store(v, state, branch); } } \end{lstlisting}} \noindent Together, these two layers constitute one round of a generalized Feistel network. The final permutation \texttt{Permute} consists of 17 rounds. Each invocation of the \texttt{RoundFunctions} layer requires eight AES round constants, for a total of 2176 bytes. {\small \begin{lstlisting}[numbers=none] void Permute() { // Round keys for one AES per Feistel round and branch. const V* keys = Keys(); for (int round = 0; round < 17; ++round) { keys = RoundFunctions(keys); BlockShuffle(); } } \end{lstlisting}} \noindent The \texttt{keys} can be a fixed array of nothing-up-my-sleeve numbers shared by all generators. However, our indistinguishability result (Section~\ref{sec:indist}) assumes a keyed/secret permutation, otherwise attackers could distinguish the permutation from random by querying it and verifying the expected result. Applications running on secure servers may reasonably expect that attackers do not have access to the key. For additional safety, applications could instead generate the keys at startup using a stream cipher such as ChaCha20 keyed with 256 bits obtained from a trusted source such as the operating system. Note that the generator remains backtracking-resistant (Section~\ref{sec:backtracking}) even if the keys are leaked. \subsection{Generator} Now that we have defined the permutation, Reverie's \texttt{Generate} produces random outer bits by invoking \texttt{Permute} on the state and XORing the inner bits with the value they had before the permutation, which cannot be reversed by an attacker with knowledge of the current state \cite{reverie}: {\small \begin{lstlisting}[numbers=none] void Generate() { const uint64_t prev_inner[2] = { state[0], state[1] }; Permute(); // Ensure backtracking resistance. state[0] ^= prev_inner[0]; state[1] ^= prev_inner[1]; } \end{lstlisting}} \noindent As a result, the last 1920 bits of \texttt{state} are uniform random and available for use. In practice, the generator is packaged as a C++ `random engine' that returns 32 or 64-bit bundles of random bits and calls \texttt{Generate} again once all remaining bits have been consumed. \section{Rationale} \label{sec:rationale} Here we briefly justify design decisions. \begin{description} \item[The AES block cipher] is well-understood and often hardware-accelerated. Intel's AESNI instructions \cite{intelAESNI} are five to ten times faster than optimized software implementations \cite{kasperAES, softwareAES2}. This implies a software-only Randen would be unacceptably slow (and likely vulnerable to side-channel attacks). On CPUs without hardware AES, it may be faster to replace AES with SIMD-friendly permutations such as ChaCha \cite{ebacsStream}. However, most modern CPUs have AES hardware, including POWER (\texttt{VCIPHER} \cite{powerAES}) and ARMv8 (\texttt{AESE} \cite{armManual}). \item[Two AES rounds] are necessary for full-bit diffusion \cite{simpira} and more efficient than a single round in terms of the ratio of active s-boxes\footnote{in a standard type-2 Feistel with four branches.} \cite{doubleSP}. \item[Dense and independent AES round keys] ensure that an AES round breaks the symmetry of plaintext with all-equal columns. We use unique keys to rule out attacks similar to those on Haraka~v1 \cite{harakaV2} and Simpira~v1 \cite{simpira}. This requires a total of 2176 bytes, which is somewhat excessive, but the keys are typically hardcoded (but not necessarily public) nothing-up-my-sleeve numbers and there is little cost to loading unique keys because they easily fit in the L1 cache. \item[Type-2 generalized Feistel networks] are often used to construct large permutations from smaller blocks. These constructions are `sound' in the sense that they are strong pseudorandom permutations after sufficient rounds of a pseudorandom function \cite{improvedFeistel}. In contrast to the $b > 8$ variants of Simpira~v2 \cite{simpira}, they enable good performance without relying on multiple independent inputs to keep the CPU pipeline filled. \item[An improved block shuffle] for the generalized Feistel network reaches full sub-block diffusion (i.e.\ each block depends on every other input block) much sooner than traditional cyclic shifts \cite{improvedFeistel}. It also reduces vulnerability to sliced-biclique \cite{newDiffusion} and integral attacks \cite{genFeistelEval}[p.~226]. \item[16-branch generalized Feistel networks] are the largest for which the diffusion properties are known \cite{newDiffusion}. Larger branch counts have two related benefits without requiring multiple independent inputs like Simpira~\cite{simpira}. First, they enable parallel evaluation of the round functions, which hides the long latency of \texttt{AESENC} \cite{intelOpt}. Second, they can benefit from increased hardware parallelism such as recently announced quadruple-AES hardware \cite{intelExtensions}[p.~2-14]. \item[A 2048-bit permutation] is a natural result of 16-branch Feistel with 128-bit AES blocks. Larger states cannot be accommodated within the 16 SSE4 registers. \item[17 Feistel rounds] improve the diffusion relative to the minimum of 16~rounds required for Feistel block diffusion (propagating input differences to each branch of the state) \cite{improvedFeistel}. \item[Reverie] is an efficient construction for backtracking-resistant generators. It avoids the heavy rekeying cost of CTR-DRBG and exposes fewer prior outputs than an only periodically re-keyed stream cipher. \item[Reseeding] the state from external entropy sources periodically is beyond the scope of this paper because our applications typically require reproducible sequences of random numbers. \end{description} \section{Implementation details} \label{sec:impl} We implement the algorithm in C++ using SIMD intrinsics that are available on current Intel, AMD and POWER CPUs. The final optimized code is quite short (only about 150 lines) and very similar to the straightforward listings above! If \texttt{state} is a restrict-qualified pointer, Clang understands that \texttt{BlockShuffle} simply renames memory locations. We have released this code \cite{randenGithub} under an open-source license so our results can be reproduced. In the rest of this section, we study how well the algorithm maps to the Haswell and Skylake microarchitectures. Despite the high-level implementation, the measured \texttt{Permute} throughput is within 5\% of the lower bound (one \texttt{AESENC} per cycle). Intel's IACA simulator \cite{intelIACA} reports the code is bottlenecked by the `frontend' in addition to the expected port 5 (\texttt{AESENC}), but still claims its throughput should exactly match the lower bound. Note that IACA does not model memory accesses, and the limited set of 16 SSE4 registers necessitates many spills to memory, so the 5\% difference is probably due to loads. However, we also investigate the alleged frontend limitation using performance counters captured via the Linux perf utility. Is decode throughput the bottleneck? This can be a problem because the 16 byte fetch window (unchanged since Pentium Pro) is too small for large SIMD instructions (\emph{nine} bytes for \texttt{AESENC} with a 32-bit offset). Two such instructions do not fit in a fetch window, so only one can decode per cycle. However, Sandy Bridge and later Intel CPUs include a decoded instruction cache (DSB), which is very helpful because it avoids the 16-byte limitation. Indeed we find 99.9\% of \textmu ops are delivered from the DSB. However, the effective DSB capacity is lower than the documented maximum of 1536 \textmu ops. Fully unrolling the Feistel rounds generates about 750~\textmu ops and causes a 10x increase in DSB misses. Unrolling by a factor of two generates good code. Is microcode a factor? In 2012 there was speculation that \texttt{AESENC} uses the microcode sequencer (MSROM) \cite{aesMSROM}. We can confirm this is not the case (on Haswell) because \verb|IDQ.MS_UOPS (79_30)| is zero. Given the low values of \verb|IDQ_UOPS_NOT_DELIVERED.CORE (9C_01)|, we can conclude the bottleneck does not involve the decoders. What about other stalls? \verb|LD_BLOCKS_PARTIAL.ADDRESS_ALIAS (07_01)| detects 4K aliasing between compiler-generated spills to the stack and loads of round keys. This is difficult to reliably avoid, but only affects 1\% of all instructions. \verb|RESOURCE_STALLS (A2_FF)| affect 18\% of all instructions; 90\% of these are waiting for the reservation station. We speculate that this is due to a lack of physical registers and/or waiting for loads. Either way, the problem should disappear on Skylake. With its 32 vector registers, we can devote 8 to the AES inputs and outputs (updated in-place) and 8+8 to hold the XOR inputs for the next two rounds, thus entirely avoiding spills. In summary, it appears difficult to further optimize the implementation. We emphasize that the compiler and out-of-order CPU extract good performance (within 5\% of the lower bound) from our minimally annotated high-level language implementation. \section{Smoke test} Every random generator should avoid `recognizable patterns', which can cause systematic errors in applications such as simulations \cite{rngCorrelation}. In the next section, we argue Randen is computationally indistinguishable from random, which implies the non-existence of any patterns. However, general-purpose generators are unable to furnish such arguments, so they instead apply statistical tests to detect obvious flaws. Several batteries of tests are well-known and often used for verifying empirical randomness. For completeness, we also apply them to Randen. We begin with BigCrush from TestU01 version 1.2.3 \cite{testu01}. Its interface requires a small wrapper around the raw generator \cite{testu01Guide}: {\small \begin{lstlisting}[numbers=none] randen::Randen<uint32_t> engine; uint32_t Rand32() { return engine(); } int main(int, char*[]) { unif01_Gen* gen = unif01_CreateExternGenBits("R", Rand32); bbattery_BigCrush(gen); unif01_DeleteExternGenBits(gen); return 0; } \end{lstlisting}} \noindent All 160 tests pass for PCG \cite{pcg} and Randen with original and inverted bits. By contrast, BigCrush reports two failures when testing MT19937 and one near-failure for AES-CTR (p-value of 0.000092, but it did not recur in subsequent test(s)) \cite{testu01}. We also test Randen with the current version 0.93 of PractRand \cite{practrand}. To avoid file or pipe overhead, we integrate Randen into the \texttt{DummyRNG} class by having its \texttt{raw32} function return Randen's output. The test battery is invoked with default settings via \verb|./RNG_test dummy -multithreaded|. Running all tests up to the upper limit of 32~terabytes reports two `unusual' p-values (0.9921 and 0.0013). Note that \texttt{pcg64} also leads to an unusual p-value (0.0016) in a much smaller test, and failures have more extreme p-values, e.g.\ $10^{-351}$ for Mersenne Twister \cite{practrandXORO}. We conclude that Randen passes state of the art tests of empirical randomness about as well as \texttt{pcg64} and better than Mersenne Twister. \section{Conclusion} Recent random generators have desirable characteristics: SIMD-accelerated Mersenne Twister (MT) is efficient \cite{avxMT}. PCG has good statistical properties \cite{pcg}. AES-CTR is unpredictable by attackers. AES-CTR-DRBG ensures backtracking resistance \cite{nistRequirements}. Thanks to recent hardware acceleration of AES, a single generator can now achieve all these goals! This work proposes \textbf{Randen}, an instantiation of Reverie \cite{reverie} with a permutation based on a generalized Feistel structure. We show that it is `strong', i.e.\ computationally indistinguishable from random and backtracking resistant. This high level of security is useful even for general-purpose applications such as shuffling and sampling because it greatly increases the attacker cost of triggering worst-case behavior in randomized algorithms. Note that Randen is not intended for cryptographic applications such as key generation, but the permutation may also be useful for wide-block ciphers and hashing functions. Despite its statistical quality and resistance to attacks, Randen is actually faster than the commonly used MT generator, ChaCha8, ISAAC, Philox and a variant of PCG in some real-world benchmarks on Haswell and POWER 8. We invite external analysis and verification of Randen's properties and suggest it as a safer alternative to arguably obsolete \cite{pcg}[p.~6] algorithms such as small linear congruential generators, linear feedback shift registers, well equidistributed long-period linear \cite{well}, unaugmented XorShift, and MT. \section{Introduction} Pseudorandom number generators are very widely used. For example, searching Github for C++ code containing mt19937 (Mersenne Twister) returns 220,000 hits. Some of these usages will be vulnerable to unexpected correlations \cite{rngCorrelation} or exploitation by attackers \cite{weakRngDefinition}. To avoid having to audit each call site, we propose to replace most of them with our new fast and `strong' generator. \subsection{Definition of strong} In this paper, we choose to characterize a strong deterministic random generator by two properties: \begin{enumerate} \item Even relatively powerful adversaries able to generate and store up to $2^{64}$ random outputs cannot distinguish the output from random unless they know the current state. This property is useful even for non-cryptographic applications: it implies empirical randomness, which reduces the likelihood of flaws such as correlations that might affect simulations \cite{rngCorrelation}. This property also ensures adversaries cannot predict future outputs, which makes it harder for them to trigger worst cases in randomized algorithms. \item Past outputs cannot be reconstructed even after the state is compromised. This is known as enhanced backward secrecy \cite{bsiRequirements}, forward security \cite{dodisRequirements} and backtracking resistance \cite{nistRequirements}. We use the latter name because it is more clear. This may not be necessary for simulation applications, but it prevents adversaries from discovering past behavior, e.g. which inputs were sampled. \end{enumerate} \noindent The notion of `robustness' from the literature also requires generators to recover security after a state compromise \cite{dodisRequirements}. This is typically achieved by periodically reseeding from an entropy source. However, our applications require at least the option of deterministic results for reproducibility and debugging. Our definition of `strong' describes the achievable security in this model. \subsection{Existing generators} \begin{description} \item[RC4] was a popular stream cipher designed in 1987, but attacks with practical complexity have recently been published \cite{rc4Weak}. \item[ISAAC] was published in 1996 and has some similarities with RC4. It has many weak initial states, though the resulting biases can be avoided with a modified algorithm \cite{isaacWeak}. Despite the large 1024 byte state, ISAAC is relatively fast and widely used \cite{kneuselRNG}[p.~200]. \item[ChaCha20] is an ARX-based hash/stream cipher used by OpenBSD \texttt{arc4random} and Linux 4.8 \verb|/dev/urandom|. It is an order of magnitude slower than some general-purpose generators \cite{pcg}[p.~41]; a similar result is observed in our benchmark. Note that a ChaCha20 generator reportedly fails one part \cite{kneuselRNG}[p.~205] of the dieharder test of empirical randomness. \item[Tyche-i] is based on ChaCha and reaches 1.5 cycles per byte \cite{tycheChacha}. However, its authors discovered some short cycles and recommended a workaround that is seven times slower \cite{tycheAddon}. \item[Mersenne Twister] is a popular general-purpose generator included in the C++ standard library. It is fast but not strong: the generated numbers are an easily inverted bijection (`tempering function') of a portion of the state, so adversaries learn the entire state after generating one full buffer. \item[xorshift128+ and xoroshiro128+] \cite{xoroshiro} fail a PractRand test due to lack of randomness in the lower bit \cite{practrandXORO}; the latter is also easily distinguishable from random \cite{xoroCracking}. \item[Philox] is a noncryptographic counter-based generator with an iterated bijection based on a Feistel network using double-width multiplications \cite{salmonRNG}. It passes the TestU01 suite by construction \cite{testu01}. GPU implementations achieve very high throughput \cite{salmonRNG}, but our benchmarks indicate our hardware AES-based permutation is twice as fast on CPUs. \item[PCG] includes an extension that XORs the output of a 128-bit generator with one of 32 table entries \cite{pcg}. Periodically scrambling the table using entropy from the state might be sufficient for backtracking resistance, which the previously mentioned generators lack. However, PCG makes no concrete security claims \cite{pcgCode}. Although its statistical quality appears good, we are unaware of any existing proofs of indistinguishability and backtracking resistance, so PCG is not known to be strong. \item[AES-CTR] is a block-cipher mode that can be used as a generator by enciphering all-zero plaintexts \cite{salmonRNG}. Although indistinguishable from random, this lacks backtracking resistance. Once the attacker knows the current counter value and key, they can reconstruct all prior outputs. \item[AES-CTR-DRBG] is a strong generator specified in NIST~800-90A~\cite{nistRequirements}. Similarly to Fortuna~\cite{fortuna}, it periodically re-keys based on the current output. However, this is about five times slower than AES-CTR, and too slow for general purpose use (see Section~\ref{sec:speed}). Note that relaxing the re-keying requirements, e.g.\ only after every 100 blocks, greatly reduces the overhead and could yield a faster generator. However, applications may not be willing to accept exposing several thousand prior outputs when the state leaks. \item[Fast-key-erasure RNGs] are a more efficient alternative to CTR-DRBG without the potential for unsafe usage \cite{fastErasure}. Bernstein reiterates the importance of backtracking resistance and proposes to generate a buffer of random bits using a stream cipher, immediately overwriting its key with part of the buffer, and returning the rest. However, there are two integration issues with this approach. If the stream cipher relies on AVX2 or AVX-512 SIMD for speed \cite{vectorChacha}, there is a risk of slowing down the entire application. Frequency throttling has been identified as a cause \cite{avxThrottle}, but this only applies to ChaCha20-Poly1305. Salsa/ChaCha are unaffected because they only require low-power operations, whereas the multiplications in Poly1305 trigger throttling. Instead, we are concerned about another AVX2 implementation detail: a warmup period of about 60,000 cycles triggered by the first AVX2 instruction within a 675~\textmu s window. During this time, SIMD instructions are considerably slower; Haswell CPUs can even stall for 10~\textmu s due to their internal voltage regulator. Thus, sporadic use of stream ciphers relying on AVX2/AVX-512 can slow down the entire application, or even unrelated jobs running on the same socket. The second integration issue is buffer size. Stream ciphers are considerably slower for small buffers \cite{ebacsStream}, which are preferred by applications and library writers because generators may be short-lived or only used to produce a few numbers. Our proposed approach avoids both issues. First, 128-bit AES hardware runs at full frequency without warmup, and is performance-portable to other 128-bit SIMD architectures -- see our measurements in Section~\ref{sec:speed}. Second, our Feistel permutation does not require a buffer larger than its 256-byte size. \end{description} \noindent We are unaware of any existing generator that is both strong and fast in real-world applications. \subsection{Intended applications} We argue that the default choice of random generators should be `strong'. This makes it harder to attack randomized algorithms and trigger skewed samples or worst-case performance. Security-critical applications such as generating cryptographic keys should continue to use well-studied and trusted cryptographic generators such as Fortuna \cite{fortuna}. However, these are too slow to be accepted for general use. For example, we have tens of thousands of high-end CPU cores occupied by general-purpose random generators. Thus, the speed of our proposed generator is important. Because Mersenne Twister is commonly used in C++ applications (see Github usage above), we assume its level of performance is generally acceptable. The Randen generator is designed to reach similar performance. Note that applications that require many random numbers without any concern for security (such as Monte-Carlo simulations) may still prefer a faster but weaker generator such as \texttt{pcg32} \cite{pcgCode}. For other applications, we suggest using Randen because it is strong and tends to outperform Mersenne Twister (see Section~\ref{sec:speed}). \subsection{Contributions} This paper makes four contributions: \begin{itemize} \item Introducing Randen\footnote{RANDen = RANDom number generator, or beetroots in Swiss German.}, a new generator based on Reverie \cite{reverie} instantiated with a generalized Feistel structure \cite{improvedFeistel} (Section~\ref{sec:spec}). \item Arguing that Randen is `strong', and explaining why this is important even for non-cryptographic applications (Section~\ref{sec:security}). \item Showing that existing secure generators are too slow for general purpose use (Section~\ref{sec:speed}). By contrast, Randen outperforms Mersenne Twister in some real-world use cases despite providing a higher level of security. To the best of our knowledge, Randen is the fastest `strong' software generator. \item Proposing an efficient algorithm for lower-bounding active s-boxes in 16-branch generalized Feistel networks with SPSP-type round functions (Appendix~\ref{sec:search}). We provide results for up to 24~rounds, whereas prior work reaches 18 rounds \cite{feistelSboxes}. \end{itemize} \section*{Absence of backdoors} We, the designers of Randen, faithfully declare that we have not inserted any weaknesses in this algorithm/implementation, nor have we discovered any weakness not described in this paper. \ifIsSubmission\else \section*{Acknowledgment} Thanks to Jeffrey Lim, Titus Winters, Chandler Carruth and Daniel Lemire for suggestions and technical help on improving the benchmarks. We also appreciate the many clear and accessible posts on practical random number generation topics by Melissa O'Neill (author of PCG). \fi \section{Active Functions in 16-branch Feistel} \label{sec:search} \begin{lemma} A type-2 generalized Feistel network with 16 branches and an improved block shuffle \cite{improvedFeistel} has at least as many differentially active functions as listed in Table~\ref{tab:active}. \end{lemma} \noindent To the best of our knowledge, these bounds are new. Note that the 6-round bound is the same as reported for a type-2 network with four branches \cite{doubleSP}. We will establish our bounds via exhaustive enumeration. Type-2 Feistel networks update their odd branches by XORing them with the result of a function of the corresponding even branch: \verb|new_odd := F(even) XOR odd|. There are two simple properties (numbered 3 and 4 \cite{boundDoubleSP}[p.~83]) regarding the propagation of differences. First, if both \texttt{even} and \texttt{odd} are differentially inactive, then so is \verb|new_odd|. Second, at least two of them are active if any of the three are active. Thus, given an input configuration (i.e.\ whether each branch is differentially active), the output is active if exactly one input is active. The inputs are booleans, so this corresponds to simply XORing them. Next, our simulator counts the number of active functions (i.e.\ the number of differentially active even input branches), shuffles the outputs and passes them as inputs to the next round. This process is repeated for every round up to the desired limit. We consider all $2^{16}$ input configurations except the trivial case of zero input differences. This logic is implemented by the following Python script. \definecolor{green}{rgb}{0,0.6,0} \begin{lstlisting}[frame=single,numbers=none,language=Python, commentstyle=\color{green},keywordstyle=\color{blue}] # (Over)estimates a lower bound of differentially active # functions in a 16-branch generalized Feistel network. ROUNDS = range(6) BRANCHES = 16 idx = range(BRANCHES / 2) # indices within odd/even bit_shifts = [2 * i for i in idx] # Shuffle: `Improving the Generalized Feistel' No.10 shuffle_for_new_odd = (3,6,5,1,7,4,0,2) # = even i / 2 shuffle_for_new_even = (1,2,4,3,0,5,7,6) # = odd i / 2 min_active_funcs = 99999 def XorResult(even, xor): # Page 83 in `Generalized Feistel networks revisited'. # 3) if even (input to F) and the XOR input are both # zero (inactive), so is the XOR result. if even == 0 and xor == 0: return 0 # 4) otherwise, at least two of the inputs/output are # active => an inactive input implies active output. if even == 0 and xor == 1: return 1 if even == 1 and xor == 0: return 1 # Assume inactive => overestimate the lower bound! return 0 # For every combination of differentially active # branches except all-zero (no active functions): for bits in range(1, 1 << BRANCHES): # Extract bits into integers, partition into even/odd. even = [((bits >> bit_shifts[i]) & 1) for i in idx] odd = [((bits >> (bit_shifts[i] + 1)) & 1) for i in idx] # Total differentially active functions. active_funcs = 0 for round in ROUNDS: # Active functions (nonzero even[]) in this round. active_funcs += even.count(1) # Shuffle(even) will later replace the current odd. new_odd = [even[shuffle_for_new_odd[i]] for i in idx] # Shuffle(F(even, odd)) replaces the current even. f_out = [XorResult(even[i], odd[i]) for i in idx] even = [f_out[shuffle_for_new_even[i]] for i in idx] odd = new_odd # Remember and report the lowest. min_active_funcs = min(min_active_funcs, active_funcs) print min_active_funcs \end{lstlisting} Note an important limitation of this algorithm: Property~4 does not provide any guidance when both inputs are active. The differences may cancel, or not. Thus, this algorithm does not guarantee a lower bound, but it does indicate such a bound is at most six. We now extend the search to cover all these possibilities and thus obtain a lower bound. The search can be paused and resumed from a `state' consisting of the round number, odd/even status, and the number of active functions so far. When both inputs are active, we enqueue new states with every possible combination of the output. Although quick to compute for six rounds, additional rounds yield trillions of possible combinations. We retain a brute-force approach, but add some optimizations to make the search tractable. First, the odd and even differentially-active status can be represented as separate bit arrays, such that all calls to \texttt{XorResult} simplify to a single 8-bit XOR and the shuffle reduces to an 8-bit table lookup. Second, we can prune search areas where \verb|active_funcs| already exceeds the minimum seen so far, because they will not influence the lower bound. Third, a fixed-size priority-queue with bitwise operations reduces the space and time overhead to constants. The C++ source code corresponding to this description will later be open-sourced alongside the Randen implementation \cite{randenGithub}. It can trace about a trillion combinations arising during 18 rounds within a few minutes on a workstation with 24 cores. \section{Security} \label{sec:security} Some developers are unaware that randomized applications can be vulnerable to adversaries and we have observed reluctance to sacrifice speed for security. It is expensive to audit tens of thousands of random generator usages to determine the appropriate security/speed tradeoff. We therefore propose to provide a higher baseline level of security than existing general-purpose generators. To gain user acceptance, we ensure our generator remains within the performance envelope of Mersenne Twister. What security guarantees can we provide? In this paper, a `strong' generator is characterized by two properties: computational indistinguishability from random, and backtracking resistance. In the following, we show that these hold for Randen. \subsection{Indistinguishability} \label{sec:indist} `Indistinguishable from random' is a very strong property often used in cryptography. We emphasize that security-critical applications should continue to use trusted cryptographically secure generators. However, other applications also benefit from a strong generator. Indistinguishability implies the output is unpredictable, which prevents adversaries from triggering worst case execution time in randomized algorithms such as Quicksort (quadratic rather than linearithmic time), or influencing the samples drawn by randomized online sampling algorithms. We now apply a standard computational indistinguishability argument. Suppose a deterministic adversary is given query access to either a real or ideal (i.e.\ uniform random) generator and returns 0 or 1 to indicate which generator it is interacting with. We assume an adversary cannot issue more than $2^{64}$ permutation queries. Then, a real generator is computationally indistinguishable from random if the distinguishing advantage (absolute difference in probability of any such adversary returning 1 when given the ideal vs.\ real generator) is negligible. \begin{lemma} \label{lem:randenIndist} In the ideal permutation model, if the Randen permutation is replaced with an ideal permutation, Randen is indistinguishable from random by adversaries limited to $2^{64}$ permutation queries. \end{lemma} \begin{proof} Randen is an instantiation of Reverie, which guarantees that the best possible attack must guess its inner bits \cite{reverie}[p.~12]. That requires an average of $2^{127}$ evaluations of the Randen permutation, which is beyond the capabilities of our assumed adversary. \end{proof} There are two practical difficulties with the ideal permutation model. First, attackers can trivially distinguish a Randen permutation with known key by simply querying it. In this section, we need to assume the permutation is keyed. Second, a truly random permutation is impractical because its representation requires $\log_2{2^{128}!} \approx 10^{40}$ bits. We could instead argue that the generalized Feistel structure of the Randen permutation ensures it would be indistinguishable from random if its round functions were pseudorandom \cite{improvedFeistel}. However, our round function consists of two rounds of AES, and up to three are efficiently distinguishable from random \cite{designAES}. We could construct a round function that is believed to be indistinguishable from a random function by XORing two permutations \cite{sumPRP} that are widely recognized to be secure, such as 10~rounds of AES. Unfortunately this would be about ten times slower. Instead, we will study known attacks on the actual Randen permutation. \begin{table}[h] \caption{Lower bound on active functions after a given number of rounds of a 16-branch type-2 Feistel network with improved block shuffle. Derived via exhaustive search in Appendix~\ref{sec:search}.} \label{tab:active} \centering \begin{tabular}{r|l|r|l} Rounds & Active Functions & Rounds & Active Functions\\ \midrule 1 & 0 & 13 & 27\\ 2 & 1 & 14 & 30\\ 3 & 2 & 15 & 32\\ 4 & 3 & 16 & 35\\ 5 & 4 & 17 & 36\\ 6 & 6 & 18 & 39\\ 7 & 8 & 19 & 41\\ 8 & 11 & 20 & 44\\ 9 & 14 & 21 & 45\\ 10 & 18 & 22 & 48\\ 11 & 22 & 23 & 50\\ 12 & 24 & 24 & 53\\ \end{tabular} \end{table} The security of Substitution-Permutation (SP) networks such as AES is often established by showing sufficiently many s-boxes are active to resist differential and linear attacks \cite{simpira}. Such results are also available for generalized Feistel networks, but they are specific to the number of branches and type of round function. We use 16 branches and SPSP-type functions (two rounds of AES). Existing results are available for either situation, but not both. 6 rounds of SPSP functions in a 4-branch type-2 network guarantee 6 differentially active \emph{functions} \cite{doubleSP}. 17 rounds of SP functions in a 16-branch network with improved diffusion guarantee 78 active s-boxes \cite{feistelSboxes}[p.~226]. Later in this section, we provide new results for 16-branch networks with SPSP functions. Note that 16-branch Feistel networks have a maximum impossible differential characteristic of 14 rounds \cite{improvedFeistel}, and the sliced biclique technique only attacks 15 rounds \cite{newDiffusion}. A recent attempt to find integral distinguishers reports `difficulty' for such large branch counts \cite{genFeistelEval}[p.~219]. We compute new lower bounds for active functions in 16-branch type-2 Feistel networks via exhaustive search. Details of the algorithm are deferred to Appendix~\ref{sec:search}. The resulting lower bounds are given in Table~\ref{tab:active}. Note that we are able to compute bounds for up to 24 rounds, whereas prior results for 16-branch Feistel networks only extend to 18 rounds \cite{feistelSboxes}. A meet in the middle attack \cite{twineMITM} splits a permutation into three parts. Hence, we consider the number of active functions after six rounds. \begin{theorem} \label{the:diff} The probability of differential characteristics and correlation of linear characteristics of six rounds of the Randen permutation are at most $2^{-180}$ and $2^{-90}$. \end{theorem} \begin{proof} Per Table~\ref{tab:active}, at least six functions are active after six rounds. Each active SPSP function provides at least $\mathcal{B}(M)$ active s-boxes \cite{doubleSP}. $\mathcal{B}(M)$ is the branch number of the SP permutation layer, which is 5 for AES. Thus, at least 30 s-boxes are active. Each active AES s-box contributes a maximum differential probability $2^{-6}$ and correlation amplitude $2^{-3}$ \cite{designAES}. Thus, the overall differential probability and linear correlation are $2^{-6 \cdot 30}$ and $2^{-3 \cdot 30}$. \end{proof} \noindent Note that Simpira's security arguments only require 25 active s-boxes \cite{simpira}. Also, Table~\ref{tab:active} indicates there are $36 \cdot \mathcal{B}(M) = 180$ active s-boxes after our 17 rounds with SPSP functions. By contrast, the prior bound for SP functions only guarantees 78~active s-boxes after 17~rounds \cite{feistelSboxes}[p.~226]. \begin{claim} A keyed Randen permutation cannot be distinguished from random with complexity less than $2^{64}$. \end{claim} This bound is a conservative estimate based on our initial analysis. Per Theorem~\ref{the:diff}, differential/linear attack complexity is $2^{180}$ and $2^{90}$. Symmetry attacks on AES are also unlikely to succeed because our round keys lack structure. Note that Randen involves 17 AES subrounds per 16 permuted bytes, versus only 10 for the AES-128 cipher. Any distinguishers would seem to imply new (or unknown to us) attacks on generalized Feistel with AES-like rounds. For comparison, a recent successful attack on the full SHA-1 involved $2^{63}$ work at an estimated cost of 110,000 USD \cite{sha1Attack}. We assume this is a sufficient deterrent to predicting outputs. \begin{lemma} If a computationally bounded adversary cannot distinguish the Randen permutation from random, then they cannot predict the Randen output with less than $2^{64}$ work based only on prior outputs. \end{lemma} \begin{proof} In this setting, adversaries do not know the AES round keys. The only way adversaries can access the permutation is by requesting random output. We can meet the requirements of Lemma~\ref{lem:randenIndist} by instantiating Randen with an oracle implementing a randomly keyed Randen permutation. From the perspective of the adversary, this behaves in the same way as Randen instantiated with a real permutation. Then, the Randen output is indistinguishable from random, which implies unpredictability by contradiction (predicting a future output would also allow an adversary to distinguish the generator from random). \end{proof} Note that ``based only on prior outputs'' excludes cases where attackers gain access to the inner state. By contrast, NIST~800~90a requires prediction resistance even after the state is compromised \cite{nistRequirements}. This would entail periodic reseeding from external entropy sources, which we must avoid to ensure repeatability. Instead, we note that side-channels such as core dumps and paging \cite{stateSecrecy} are less relevant in a server environment and can be mitigated with the help of the operating system (using \texttt{madvise} and \texttt{mlock}). Then, attackers can only guess the inner state at a cost of $2^{127}$, which is beyond their assumed capability. \subsection{Backtracking resistance} \label{sec:backtracking} The second property is backtracking resistance: adversaries have a negligible advantage at distinguishing prior outputs from random even if they gain access to the state \cite{onBacktracking}. This is important for portable devices and long-running applications without access to external entropy because it ensures adversaries cannot reconstruct prior outputs. If a generator is robust, it also provides backtracking resistance (also known as forward security) \cite{dodisRequirements}. Reverie is robust in the ideal permutation model \cite{reverie} and the previous section argues that instantiating Reverie with a random Randen permutation retains its security guarantees. However, robustness requires reseeding the generator from external entropy, which is not always possible in our applications. We instead show that backtracking resistance follows from the security of Reverie's next function \cite{reverie}[p.~12], i.e.\ Randen's \texttt{Generate}. Assume an adversary has gained access to the current \texttt{state} and AES keys. This allows them to invert the Randen permutation. Note that Reverie's security model assumes a public permutation that attackers can already invert. We will illustrate the backtracking resistance in a scenario with two calls to \texttt{Generate}. Additional calls do not affect the argument. For the following, let us define new notation: the state after the first ($k=1$) and second ($k=2$) call to \texttt{Generate} can be partitioned into inner/outer parts $i_k$ and $o_k$. Let $i_0$ and $o_0$ denote the uniform random initial state. Per Lemma~1 of Reverie \cite{reverie}[p.~12], the return values of \texttt{Generate} are indistinguishable from random. However, the attacker knows all random outputs (i.e.\ outer states $o_0,o_1$) and learns the current state $i_2,o_2$. Does this allow them to recover the remaining prior inner states $i_0,i_1$? Recall that the final \texttt{Generate} returns \texttt{Permute}($i_1,o_1$) XOR ($i_1$, zero). All terms except $i_1$ are known. However, the attacker cannot query the permutation in either direction without guessing the $i_1$ value at a cost of $2^{127}$; this is best possible attack on Reverie \cite{reverie}. Hence, knowledge of $o_0,o_1,o_2,i_2$ is insufficient, and adversaries cannot expect to distinguish prior outputs from random with less than $2^{127}$ forward or backward queries to the permutation (e.g.\ by guessing the inner bits) \cite{reverie}[p.~12]. Therefore, Randen is backtracking-resistant. \section{Performance} % \label{sec:speed} % \subsection{Contenders} We emphasize that our comparison involves three groups of generators, in increasing order of security. \subsubsection*{Insecure generators} To establish a performance baseline, we include the commonly used but insecure Mersenne Twister (`MT') as implemented by the C++11 standard library. Note that faster variants of MT exist \cite{fastMT, avxMT}. However, we advocate using more secure generators in most applications with the exception of Monte Carlo simulations. \subsubsection*{Medium-strength} Several recent generators are at least nontrivial to distinguish from random, although indistinguishability and backtracking-resistance have not been formally shown. We include `Philox' \cite{salmonRNG} and \verb|pcg64_c32| \cite{pcg} (`PCG'), both of which make no concrete security claims. We also place ISAAC into this category -- although no bias has been shown, there are doubts about its security and similarity to RC4. \subsubsection*{Strong} The third group consists of generators with security claims (see Section~\ref{sec:security}). In addition to Randen, we include `ChaCha20' (provided by Linux 4.9 \verb|/dev/urandom| \cite{linuxChaCha}) and `CTR-DRBG' from NIST~SP~800-90A (provided by Windows 7 \texttt{BCryptGenRandom}). These have higher overhead, possibly due to calling into kernel mode. We reduce this somewhat by using a 256-byte buffer, the same size as Randen. To fully exclude the OS overhead, we also include a user-mode SSE2 implementation of ChaCha8 by Orson Peters that uses a single 64-byte block. Note that Bernstein recommends ChaCha20 instead due to its higher security margin \cite{djbTwitter}. \subsection{Infrastructure} All generators except `CTR-DRBG' are implemented in C++ and compiled using Clang \texttt{r331746} with {\small\texttt{-O3 -std=gnu++11}}. The `x86' benchmark is pinned to a single core of a lightly loaded dual-socket Xeon E5-2690~v3 clocked at 2.6~GHz running Linux 4.9 with Turbo Boost and throttling disabled. We also report performance on a POWER~8e clocked at 3.6~GHz (`PPC'). The `CTR-DRBG' measurements are obtained on an Intel i7~4790K CPU clocked at 4.0~GHz running Windows 7 x64 and using the Microsoft Visual Studio 2017 compiler. To increase the precision and accuracy of generator speed measurements, we use an \ifIsSubmission improved benchmarking infrastructure. \else improved version of the `nanobenchmark' infrastructure \cite{nanobenchmark} developed for HighwayHash. \fi It prevents elision of the generator by passing its output as an input to an empty inline assembly block marked as modifying memory. To reduce variability between runs, it records high-resolution timestamps (in units of CPU cycles) from the invariant TSC, uses fences to ensure the measured code is not reordered by the compiler nor CPU, subtracts the overhead of the TSC reads and uses the median (for small sample counts) or mode as a robust estimator of the central tendency. As a result, variability between measurements (defined as median absolute deviation from the median) is about 0.2\%. To improve comparability between benchmarks of different sizes, we divide the elapsed times by the number of random bytes generated to yield cycles per byte. Note that the PPC elapsed times are relative to its 512~MHz timebase, so we multiply measurements by $7 \approx 3600 / 512$ to obtain CPU cycles. \subsection{Benchmarks} We go beyond conventional microbenchmarks by including three simple real-world applications of random numbers: a Fisher-Yates shuffle \cite{fisherYatesShuffle}, reservoir sampling \cite{reservoirSampling}, and a Monte Carlo estimator for the value of $\pi$. Together, these exercise all consumers of random bits in the C++ standard library. We emphasize that our measurements encompass the entire application, viz.: the algorithm consuming random numbers (e.g. shuffling) plus buffer-empty checks required by the C++ random generator interface plus the generator itself. Thus, the reported throughput will naturally be lower than best-case microbenchmarks of a stream cipher or merely generating large quantities of random bits. \subsubsection{Microbenchmark} C++11 only requires amortized constant-time complexity for its uniform random generators. This allows them to return numbers from a large buffer which is periodically refilled. To measure the amortized cost, we must ensure the elapsed time measurements include sufficient refills. Although the buffer sizes are known, C++11 does not provide a guaranteed means of flushing or querying the buffer. We therefore generate 800~KB of random bits such that the cost of `wasting' part of the final buffer is negligible. \begin{table}[H] \caption{Cycles per byte for a small loop, plus variability (MAD is the median absolute deviation) and speedup factor of Randen vs.\ other generators.} \label{tab:loop} \centering \begin{tabular}{r|r|r||r|r} Engine & x86 (MAD) & Speedup & PPC (MAD) & Speedup\\ \midrule Randen & 1.54 ($\pm$ 0.002) & -- & 2.94 ($\pm$ 0.007) & -- \\ PCG & 0.78 ($\pm$ 0.003) & 0.5 & 1.68 ($\pm$ 0.007) & 0.6 \\ MT & 1.79 ($\pm$ 0.001) & 1.2 & 3.99 ($\pm$ 0.014) & 1.4 \\ ChaCha8 & 3.02 ($\pm$ 0.003) & 2.0 & & \\ ISAAC & 4.08 ($\pm$ 0.006) & 2.6 & 7.91 ($\pm$ 0.014) & 2.7 \\ Philox & 4.70 ($\pm$ 0.003) & 3.1 & 9.94 ($\pm$ 0.014) & 3.4 \\ ChaCha20 & 15.27 ($\pm$ 0.018) & 9.9 & 197.96 ($\pm$ 0.315) & 67.3 \\ CTR-DRBG & 16.80 ($\pm$ 0.009) & 11.2 & & \\ \end{tabular} \end{table} \noindent The x86 microbenchmark (Table~\ref{tab:loop}) seems to indicate PCG is twice as fast as Randen, which is in turn 1.2 times as fast as MT. The trend is similar on PPC. Despite their high precision (median absolute deviation below 0.2\%), these microbenchmark results are quite irrelevant in practice --- which actual application repeatedly calls a random generator and ignores the results? Any that do should use the more efficient \texttt{discard} function instead. As we will see, these results are not representative of real-world performance. There are at least three reasons why microbenchmarks may mischaracterize actual performance. First, their small working set leads to unrealistically high cache and TLB hit rates. Second, tight loops benefit from special CPU decoding hardware \cite{agnerMicroarch}[p.~123]. Third, simple microbenchmarks may use fewer CPU resources (e.g.\ registers and load-store buffers) than real-world applications. \subsubsection{Shuffle} For a more realistic use case, we measure a Fisher-Yates shuffle that swaps elements at a randomly chosen position. Although the C++ standard library provides an implementation (\verb|std::shuffle|), its mapping of random bits to uniform integers is quite slow. Instead of costly divisions, we use a multiplication followed by bit-shift \cite{lemireMod}. The resulting shuffle is about three times as fast as \verb|std::shuffle|. The array is 400~KB large, which exceeds the 256~KiB L2 cache on x86 but fits into the 512~KiB PPC cache. We observe different performance characteristics (Table~\ref{tab:shuffle}) than in the microbenchmark. As shown by the `Randen factor' columns, Randen is 1.2 times as fast as PCG and slightly faster than MT on x86. By contrast, MT is the fastest on PPC. In all benchmarks, Randen is roughly twice as fast as ISAAC, which is still faster than Philox. Replacing ChaCha20/CTR-DRBG with Randen leads to an overall shuffle speedup of 7 to 8, and 36 on PPC. We see nearly identical results on x86 for 100~KB and 25~KB inputs, which fit into L2 and L1, respectively. This implies that caching and prefetching are effective. Indeed VTune reports that only Philox and ChaCha20 have high levels of load/store stalls: 45\% and 85\%, versus less than 30\% for the other generators. \begin{table}[H] \caption{Cycles per byte for engines called from Fisher-Yates shuffle, plus variability (MAD is the median absolute deviation) and speedup factor of Randen vs.\ other generators.} \label{tab:shuffle} \centering \begin{tabular}{r|r|r||r|r} Engine & x86 (MAD) & Speedup & PPC (MAD) & Speedup\\ \midrule Randen & 2.19 ($\pm$ 0.004) & -- & 5.46 ($\pm$ 0.014) & -- \\ PCG & 2.65 ($\pm$ 0.005) & 1.2 & 6.65 ($\pm$ 0.014) & 1.2 \\ MT & 2.19 ($\pm$ 0.004) & 1.0 & 4.48 ($\pm$ 0.021) & 0.8 \\ ChaCha8 & 3.63 ($\pm$ 0.006) & 1.7 & & \\ ISAAC & 4.15 ($\pm$ 0.007) & 1.9 & 8.19 ($\pm$ 0.021) & 1.5 \\ Philox & 4.87 ($\pm$ 0.008) & 2.2 & 10.57 ($\pm$ 0.021) & 1.9 \\ ChaCha20 & 15.87 ($\pm$ 0.027) & 7.2 & 198.24 ($\pm$ 0.917) & 36.3 \\ CTR-DRBG & 20.45 ($\pm$ 0.017) & 8.2 & & \\ \end{tabular} \end{table} \subsubsection{Sample} Our third benchmark measures reservoir sampling, a randomized online algorithm for retaining an 80~KB subset of a 400~KB data stream. It probabilistically overwrites prior samples at random position. As with shuffling, using a division-free mapping of random bits to integers is much faster than \verb|std::uniform_int_distribution|. We see similar performance (Table~\ref{tab:sample}), except that Randen is now 1.2 times as fast as PCG on x86, and 1.4 on PPC. On both platforms, Randen outperforms MT. Also as before, speeds are comparable when reducing the input sizes to one quarter. \begin{table}[H] \caption{Cycles per byte for engines called from reservoir sampling, plus variability (MAD is the median absolute deviation) and speedup factor of Randen vs.\ other generators.} \label{tab:sample} \centering \begin{tabular}{r|r|r||r|r} Engine & x86 (MAD) & Speedup & PPC (MAD) & Speedup\\ \midrule Randen & 2.60 ($\pm$ 0.008) & -- & 4.97 ($\pm$ 0.007) & -- \\ PCG & 3.03 ($\pm$ 0.009) & 1.2 & 6.72 ($\pm$ 0.021) & 1.4 \\ MT & 2.82 ($\pm$ 0.009) & 1.1 & 5.32 ($\pm$ 0.014) & 1.1 \\ ChaCha8 & 3.75 ($\pm$ 0.008) & 1.4 & & \\ ISAAC & 4.46 ($\pm$ 0.014) & 1.7 & 8.12 ($\pm$ 0.014) & 1.6 \\ Philox & 4.95 ($\pm$ 0.009) & 1.9 & 9.87 ($\pm$ 0.007) & 2.0 \\ ChaCha20 & 13.46 ($\pm$ 0.017) & 5.2 & 159.67 ($\pm$ 0.168) & 32.1 \\ CTR-DRBG & 16.41 ($\pm$ 0.015) & 6.4 & & \\ \end{tabular} \end{table} \subsubsection{Monte Carlo} The fourth benchmark is Monte Carlo estimation of the value of $\pi$ via the ratio of points that fall within a unit circle versus the unit square. This is similar to the microbenchmark in that it calls the generator 200,000 times in a fairly tight loop. Note that \verb|std::uniform_real_distribution| is slow and not actually uniform \cite{uniformBug}, so we again implement a replacement. It constructs an IEEE-754 mantissa using the lower 53 bits of a generated \verb|uint64_t| and chooses an exponent based on the base-2 logarithm of its upper bit. The results in Table~\ref{tab:montecarlo} show that PCG is 1.2 times as fast as Randen on x86 but slower on PPC. Randen outperforms MT on both platforms. \begin{table}[H] \caption{Cycles per byte for engines called from a Monte Carlo simulation, plus variability (MAD is the median absolute deviation) and speedup factor of Randen vs.\ other generators.} \label{tab:montecarlo} \centering \begin{tabular}{r|r|r||r|r} Engine & x86 (MAD) & Speedup & PPC (MAD) & Speedup\\ \midrule Randen & 2.14 ($\pm$ 0.002) & -- & 3.43 ($\pm$ 0.007) & -- \\ PCG & 1.69 ($\pm$ 0.031) & 0.8 & 3.85 ($\pm$ 0.007) & 1.1 \\ MT & 2.55 ($\pm$ 0.015) & 1.2 & 4.90 ($\pm$ 0.007) & 1.4 \\ ChaCha8 & 4.58 ($\pm$ 0.002) & 2.1 & & \\ ISAAC & 4.35 ($\pm$ 0.003) & 2.0 & 8.54 ($\pm$ 0.056) & 2.5 \\ Philox & 4.97 ($\pm$ 0.002) & 2.3 & 11.62 ($\pm$ 0.014) & 3.4 \\ ChaCha20 & 16.65 ($\pm$ 0.006) & 7.8 & 194.53 ($\pm$ 8.428) & 56.7 \\ CTR-DRBG & 17.37 ($\pm$ 0.031) & 9.3 & & \\ \end{tabular} \end{table} \subsection{Discussion} To summarize the four benchmarks, we compute the geometric means of the `Randen factors' from the above tables, i.e.\ the cost (cycles per byte) of other generators divided by that of Randen (Table~\ref{tab:geomean}). Due to the large differences in the (lack of) security guarantees of the various generators, we discuss them separately. \begin{table}[H] \caption{Geometric means of Randen speedup factors across the benchmarks. A value of 1.1 indicates the benchmarks run 1.1 times as fast after replacing MT with Randen.} \label{tab:geomean} \centering \begin{tabular}{r|r|r} Engine & x86 & PPC\\ \midrule PCG & 0.9 & 1.0\\ MT & 1.1 & 1.1\\ ChaCha8 & 1.8 & \\ ISAAC & 2.0 & 2.0\\ Philox & 2.3 & 2.6\\ ChaCha20 & 7.3 & 45.9\\ CTR-DRBG & 8.5 & \\ \end{tabular} \end{table} \subsubsection*{Insecure generators} One of our main results is that the Randen generator does not increase CPU cost relative to the commonly used but insecure Mersenne Twister generator. The geometric mean of speed ratios indicates Randen is slightly faster on both x86 and PPC. \subsubsection*{Medium-strength} Randen is about twice as fast as ISAAC and Philox in all benchmarks. Our choice of geometric mean indicates PCG is the fastest on x86, and tied for first on PPC. However, this is mainly due to its result in the (unrealistic) microbenchmark. PCG is a good choice for Monte Carlo applications but Randen is 1.2 to 1.4 times as fast for shuffling and sampling. Note that ISAAC, Philox and PCG lack concrete security claims and have not been shown to be indistinguishable from random nor backtracking-resistant. To the best of our knowledge, Randen is the fastest software generator with these properties. \subsubsection*{Strong} Is it feasible to use cryptographically secure generators as the default even in non-cryptographic applications? This depends on the scale of usage. We profiled production code running company-wide and found that traditional non-cryptographic random generators account for tens of thousands of CPU cores. From this and the above benchmarks, we conclude it would be too expensive to use an OS-provided ChaCha20 (\verb|/dev/urandom|) or CTR-DRBG (\texttt{BCryptGenRandom}) as general-purpose generators. By contrast, Randen is 5 to 10 times as fast in real-world benchmarks. Switching from Mersenne Twister to Randen would actually reduce cost (according to the geometric mean of our benchmarks), while greatly increasing the baseline security of non-cryptographic randomized applications.
{'timestamp': '2018-10-05T02:12:05', 'yymm': '1810', 'arxiv_id': '1810.02227', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02227'}
arxiv
\section{Analysis} \label{sec:analysis} \newcommand{\mathcal{H}_{m^2}}{\mathcal{H}_{m^2}} \newcommand{\mathcal{H}_m^{\otimes m}}{\mathcal{H}_m^{\otimes m}} The goal of this section is to prove that the decompressor works correctly, with high probablity, provided the preprocessing stage returns the appropriate sets $\{S_j\}$. Specifically, we prove Theorem~\ref{thm:main-analysis} as stated below. But first we need a definition of ``nice'' sets $\{S_j\}$: We will later show that pre-processing produces such sets and compression and decompression work correctly (w.h.p.) given nice sets. \iffalse{ To state Theorem~\ref{thm:main-analysis}, we need the following definition of a ``row-independent'' distribution, which will be very helpful in the analysis. \mnote{Folded definition into definition of $\mathcal{H}$. } \begin{definition}[$\mathcal{H}_t$] \label{def:Ht} Let $\mathcal{H}$ be a (stationary) Markov source with alphabet $\Sigma$. For every $t \in \N$, define $\mathcal{H}_t$ as the distribution of $Y_1, Y_2, \dots Y_t$ generated by $\mathcal{H}$. Similarly, define $\mathcal{H}_t^{\otimes s}$ as the distribution on $\Sigma^{s \x t}$ where each row is independent and distributed according to $\mathcal{H}_t$. \end{definition} We will also use the following definition of ``nice'' sets $\{S_j\}$, and will later show that the pre-processing produces such sets. }\fi \begin{definition}[$(\eps, \zeta)$-niceness] \label{def:nice} Let $\mathcal{H}$ be a Markov source. For every $m \in \N$ and $n = m^2$, let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$ be the corresponding ``independent'' distribution. Let $\bar{U} := P_m^{\rm column}(\bar{Z})$. We call sets $S_1, S_2, \dots S_m \subseteq [m]$ \emph{``$(\eps, \zeta)$-nice''} if they satisfy the following: \begin{enumerate} \item $\sum_j |S_j| \leq \bar{H}(Z) + \eps n$ \item $\forall j \in [m], i \not\in S_j: \bar{H}(\bar{U}_{(i, j)} | \bar{U}_{\prec (i, j)}) < \zeta$ \end{enumerate} \end{definition} Now, the rest of this section will show the following. \begin{theorem} \label{thm:main-analysis} There exists a polynomial $p(\cdot)$ such that for every $\eps > 0$, $\tau > 0$, and $n = m^2 > p(\tau/\eps)$ the following holds: Let $\mathcal{H}$ be an aperiodic irreducible Markov source with alphabet $\F_q$, mixing time $\tau$ and underlying state space $[\ell]$. Define random variables $Z = (Z_{11}, Z_{12} \dots Z_{mm}) \sim \mathcal{H}_{m^2}$ as generated by $\mathcal{H}$. Then, for all sets $S_1, S_2, \dots S_m \subseteq [m]$ that are $(\eps, \zeta)$-nice as per Definition~\ref{def:nice}, we have: $$\Pr_{Z}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(Z; \{S_j\}_{j \in [m]})) \neq Z] \leq n\zeta + m \exp(-\eps m / \tau)$$ \end{theorem} \subsection{Proof Overview} Throughout this section, let $\mathcal{H}$ be a stationary Markov source with alphabet $\F_q$ and mixing-time $\tau$. The key part of the analysis is showing that compression and decompression succeed when applied to the ``independent'' distribution $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$. To do this, we first show that the compression transform ``polarizes'' entropies, which follows directly from the results of \cite{BGNRS,polar-small-error}. Then we show that, provided ``nice'' sets can be computed (low-entropy sets, a la Definition~\ref{def:nice}), the compression and decompression succeed with high probability. This also follows essentially in a black-box fashion from the results of \cite{BGNRS}. Finally, we argue that the compression and decompression also work for the actual distribution $Z \sim \mathcal{H}_{m^2}$, simply by observing that the involved variables are close in distribution. We later describe how such ``nice'' sets can be computed in polynomial time, given the description of the Markov source $\mathcal{H}$. \subsection{Polarization} In this section, we show that the compression transform $P^{\rm column}_m$ polarizes entropies. \begin{lemma} \label{lem:polarization} Let $\mathcal{H}$ be a Markov source, and let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$. Let $\bar{U} = P^{\rm column}_m(\bar{Z})$. Then, there exists a polynomial $p(\cdot)$ such that for every $\eps > 0$, there exists $\beta > 0$ such that if $m > p(1/\eps)$, the following holds: For all but $\eps$-fraction of indices $i, j \in [m] \times [m]$, the normalized entropy $$\bar{H}(\bar{U}_{i, j} | \bar{U}_{\prec (i, j)}) \not\in (\exp(-m^\beta), 1- \eps)$$ \end{lemma} \begin{proof} We will show that for each column $\bar{U}^j$, all but $\eps$-fraction of indices $i \in [m]$ have entropies $$\bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) \not\in (\exp(-m^\beta), 1- \eps)$$ Indeed, this follows directly from the analysis in \cite{polar-small-error}. For each $j$, the set of variables $ (\bar{Z}^j_1, \bar{Z}^{<j}_1), (\bar{Z}^j_2, \bar{Z}^{<j}_2), \dots, (\bar{Z}^j_m, \bar{Z}^{<j}_m) $ are independent and identically distributed. Thus, Theorem~\ref{thm:exp-polar} from \cite{polar-small-error} (reproduced below) implies that the conditional entropies are polarized. Specifically, let $p(\cdot)$ and $\beta$ be as guaranteed by Theorem~\ref{thm:exp-polar}, for the distribution $\mathcal{D}) \equiv (\bar{Z}^j_1, \bar{Z}^{<j}_1)$. Then, since $P_m = M^{\otimes t}$, we have \begin{align*} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) &= \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, P_m(\bar{Z}^{< j})) \tag{by definition} \\ &= \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{Z}^{< j}) \tag{$P_m$ is invertible} \\ &\not\in (\exp(-m^\beta), 1- \eps) \tag{Theorem~\ref{thm:exp-polar} \qedhere} \end{align*} \end{proof} The following theorem is direct from the works \cite{polar-small-error}. \begin{theorem} \label{thm:exp-polar} For every $k \in \N$, prime $q$, mixing-matrix $M \in \F_q^{k \x k}$, discrete set $\mathcal{Y}$, and any distribution $\mathcal{D} \in \Delta(\F_q \x \mathcal{Y})$, the following holds. Define the random vectors $A := (A_1, A_2, \dots A_n)$ and $B := (B_1, B_2, \dots B_n)$ where $n=k^t$ and each component $(A_i, B_i)$ is independent and identically distributed $(A_i, B_i) \sim \mathcal{D}$. Let $X := M^{\otimes t}A$. Then, the conditional entropies of $X$ are \emph{polarized}: There exists a polynomial $p(\cdot)$ and $\beta > 0$ such that for every $\eps > 0$, if $n = k^t > p(1/\eps)$, then all but $\eps$-fraction of indices $i \in [n]$ have normalized entropy $$ \bar{H}(X_i | X_{< i}, B) \not\in (\exp(-n^\beta), 1- \eps) \ . $$ \end{theorem} \subsection{Independent Analysis} Now we show that the Polar Compressor and Decompresser succeed with high probability, when applied to the ``independent'' input distribution $\bar{Z}$. First, we recall the (inefficient) Successive-Cancellation Decoder of Polar Codes. This is reproduced as in \cite{BGNRS}, with minor notational changes. We will use this decoder to reason about the efficient fast decoder. The \textsc{SC-Decoder} is intended to decode from the encoding $U_S$ where $U := M^{\otimes t} Z$, coordinates of $Z$ are independent, and $U_S$ is the high-entropy coordinates of $U$. It outputs an estimate $\hat U$ of $U$ that is correct with high probability, from which we can decode the original inputs $\hat Z := (M^{-1})^{\otimes t} \hat U$. The \textsc{SC-Decoder} takes as input the \emph{product distribution} on inputs $\mathcal{D}_Z \in \Delta(\F_q^m)$, as well as the high-entropy coordinates $U_S$. \begin{algorithm}[H] \caption{Successive-Cancellation Decoder} \label{algo:sc-decoder} \begin{algorithmic}[1] \Const{$M \in \F_q^{k \x k}, m = k^t, S \subseteq [m]$} \Require{Product distribution $\mathcal{D}_Z \in (\Delta(\F_q))^{\otimes m}$, and encoding $U_S$} \Ensure{${\hat U} \in \F_q^m$} \Procedure{SC-Decoder}{$\mathcal{D}_Z; U_S$} \State Compute joint distribution $\mathcal{D_U} \in \Delta(\F_q^m)$ of $\{U := M^{\otimes t} Z\}_{Z \sim \mathcal{D}_Z}$ \ForAll{$i = 1, \dots, m$} \If{$i \not\in S$} \State $\hat{{U}}_i \gets \argmax_{x \in \F_q} \Pr_{U \sim \mathcal{D}_U}({U}_i = x)$ \Else \State $\hat{{U}}_i \gets U_i$ \EndIf \State Update distribution $\mathcal{D}_U$ to be conditioned on ${U}_i = \hat{{U}}_i$ \EndFor \State \Return ${\hat U}$ \EndProcedure \end{algorithmic} \end{algorithm} Note that several of the above steps, including computing the joint distribution $\mathcal{D}_U$ and marginal distributions of $U_i$, are not computationally efficient. The following claim is equivalent to \cite[Claim A.1]{BGNRS}, and states that the failure probability of the \textsc{SC-Decoder} is at most the sum of conditional entropies on the unspecified coordinates of $U$. \begin{claim} \label{lem:sc-dec-H} Let $\widetilde{Z} \in \F_q^m$ be a random vector with independent (not necessarily identically distributed) components $\widetilde{Z}_i$. Denote the distribution of $\widetilde Z$ as $\mathcal{D}_{\widetilde Z}$. Let $\widetilde U := P_m(\widetilde Z)$, and $S \subseteq [m]$. Then, $$\Pr[\text{\sc SC-Decoder}(\mathcal{D}_{\widetilde Z}; \widetilde{U}_S) \neq U] \leq \sum_{i \not\in S} \bar{H}(\widetilde{U}_i | \widetilde{U}_{< i}) $$ \end{claim} \newcommand{\mathcal{D}_{z^j | z^{<j}}}{\mathcal{D}_{z^j | z^{<j}}} \begin{claim} \label{lem:sc-dec-matrix} Let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$, and let $\bar{U} = P^{\rm column}_m(\bar{Z})$. For a fixed $j \in [m]$ and fixed conditioning $z^{< j} \in \F_q^{m \x (j-1)}$, let $\mathcal{D}_{z^j | z^{<j}}$ denote the distribution $\bar{Z}^{j} | \{\bar{Z}^{< j} = z^{< j}\}$. Then, for all $j \in [m]$ and all $S \subseteq [m]$, $$\Pr_{\substack{ z \sim \bar{Z}\\ u \gets P_m(z^j)\\ \mathcal{D}_{z^j | z^{<j}} \equiv \{\bar{Z}^{j} | \bar{Z}^{< j} = z^{< j}\} }} [\text{\sc SC-Decoder}(\mathcal{D}_{z^j | z^{<j}}; u^{j}_S) \neq u^{j}] \leq \sum_{i \not\in S} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) $$ \end{claim} \begin{proof} This follows directly from Claim~\ref{lem:sc-dec-H}. \begin{align*} &\E_{\substack{ z \sim \bar{Z}\\ u \gets P_m(z^j)\\ \mathcal{D}_{z^j | z^{<j}} \equiv \{\bar{Z}^{j} | \bar{Z}^{< j} = z^{< j}\} }} [\1\{\text{\sc SC-Decoder}(\mathcal{D}_{z^j | z^{<j}}; u^{j}_S) \neq u^{j}\}]\\ &= \E_{\substack{ z^{< j} \sim \bar{Z}^{< j}\\ }}[ \E_{\substack{ \mathcal{D}_{z^j | z^{<j}} \equiv \{\bar{Z}^{j} | \bar{Z}^{< j} = z^{< j}\}\\ z^j \sim \mathcal{D}_{z^j | z^{<j}}\\ u \gets P_m(z^j) }}[ \1\{\text{\sc SC-Decoder}(\mathcal{D}_{z^j | z^{<j}}; u^{j}_S) \neq u^{j}\} ]]\\ &= \E_{\substack{ z^{< j} \sim \bar{Z}^{< j}\\ }}\left[ \Pr_{\substack{\widetilde{Z} \sim \mathcal{D}_{z^j | z^{<j}}\\ \widetilde{U} \gets P_m(\widetilde Z)}}[ \text{\sc SC-Decoder}(\mathcal{D}_{\widetilde Z}; \widetilde{U}_S) \neq \widetilde{U} ]\right]\\ &\leq \E_{\substack{ z^{< j} \sim \bar{Z}^{< j} }}\left[ \sum_{i \not\in S} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{Z}^{< j} = z^{< j}) \right] \tag{by Claim~\ref{lem:sc-dec-H}}\\ &= \E_{\substack{ z^{< j} \sim \bar{Z}^{< j}\\ u^{<j} \gets P_m(z^{<j}) }}\left[ \sum_{i \not\in S} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j} = u^{< j}) \right]\\ &= \sum_{i \not\in S} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) \qedhere \end{align*} \end{proof} \noindent Using the \textsc{SC-Decoder}, we can define the following (inefficient) decompresser. We will then relate its performance to the fast decompressor, and thereby conclude the desired correctness property of the latter. \begin{algorithm}[H] \caption{SC Polar Decompressor} \label{algo:sc-decompressor} \begin{algorithmic}[1] \Const{$M \in \F_q^{k \x k}$, $m = k^t, n = m^2$} \Require{$U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m} \in \F_q^m$, and Markov source $\mathcal{H}$} \Ensure{$\hat Z \in \F_q^{m \x m}$} \Procedure{SC-Polar-Decompress$_{\mathcal{H}}$}{$U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m}$} \ForAll{$j \in [m]$} \If{$j \leq (1-\eps)m$} \State{Compute the distribution $\mathcal{D}_{z^j | \hat{z}^{<j}} \equiv \bar{Z}^j | \{\bar{Z}^{<j} = \hat z^{<j}\}$}, for $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$. \State{Set $\hat U^j \gets \text{\sc SC-Decoder}(\mathcal{D}_{z^j | \hat{z}^{<j}}; U^{j}_{S_j})$ } \label{ln:Uhat} \Else \State{Set $\hat U^j \gets U^j_{S_j}$} \Comment{Note here $S_j = [m]$} \label{ln:Uhat2} \EndIf \State{Set $\hat Z^j \gets (M^{-1})^{\otimes t} \hat U^j$} \label{ln:hatZ} \EndFor \State \Return{$\hat Z$} \EndProcedure \end{algorithmic} \end{algorithm} \begin{claim} \label{lem:sc-entropy-bound} Let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$, and $\bar{U} := P^{\rm column}_m(\bar{Z})$. Then, for all sets $S_1, S_2, \dots S_m \subseteq [m]$, $$\Pr_{\substack{\bar{U} \gets P^{\rm column}_m(\bar{Z})}} [\text{\sc SC-Polar-Decompress$_{\mathcal{H}}$}(U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m}) \neq \bar{U}] \leq \sum_{j\in [m], i \not\in S_j} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) $$ \end{claim} \begin{proof} This follows directly from Claim~\ref{lem:sc-dec-matrix}. \begin{align*} &\Pr_{\substack{\bar{U} \gets P^{\rm column}_m(\bar{Z})}} [\text{\sc SC-Polar-Decompress}(U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m}) \neq \bar{U}]\\ &= \Pr_{\substack{\bar{U} \gets P^{\rm column}_m(\bar{Z})}} \left[ \bigcup_{j \in [m]} \{ \hat U^j \neq \bar{U}^j \text{ and } \hat U^{<j} = \bar{U}^{< j}\} \right] \tag{for random variables $\hat U^j$ defined as in Lines~\ref{ln:Uhat},~\ref{ln:Uhat2} of Algorithm~\ref{algo:sc-decompressor}}\\ &\leq \sum_{j \in [m]} \Pr[\hat U^j \neq \bar{U}^j | \hat U^{<j} = \bar{U}^{< j}]\\ &= \sum_{j \in [m]} \Pr[\hat U^j \neq \bar{U}^j | \hat Z^{<j} = \bar{Z}^{< j}] \tag{by definition of $\hat Z$ in Line~\ref{ln:hatZ}}\\ &= \sum_{1 \leq j \leq (1-\eps)m} \Pr_{\substack{ z \sim \bar{Z}\\ u \gets P_m(z^j)\\ \mathcal{D}_{z^j | z^{<j}} \equiv \{\bar{Z}^{j} | \bar{Z}^{< j} = z^{< j}\} }} [\text{\sc SC-Decoder}(\mathcal{D}_{z^j | z^{<j}}; u^{j}_{S_j}) \neq u^{j}]\\ &\leq \sum_{j \in [m]} \sum_{i \not\in S_j} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) \quad \text{(by Claim~\ref{lem:sc-dec-matrix})} \quad \qedhere \end{align*} \end{proof} We now analyze the fast decompressor. This is defined identically to the SC Polar Decompressor, except using the \textsc{Fast-Decoder} from \cite[Algorithm 4]{BGNRS} instead of the Successive-Cancellation Decoder. Note the \textsc{Fast-Decoder} outputs an estimate of the input $\hat Z$ directly. The following claim reproduced from \cite[Lemma A.4]{BGNRS} states that the Fast Decoder operates identically as the Successive-Cancellation Decoder. \begin{claim} \label{lem:fast-equivalence} For all $m = k^t$, all product distributions $\mathcal{D}_Z$ over $\F_q^m$ (ie, where each coordinate ${Z}_{{i}} \in \F_q$ is independent), for all sets $S \subseteq [m]$ and all values $U \in (\F_q \cup \{\bot\})^{m}$ of the coordinates $S$ (such that $\forall i \in S: U_i \neq \bot$), the following holds: $$ M^{\otimes t} \cdot \textsc{Fast-Decoder}(\mathcal{D}_Z; U) = \textsc{SC-Decoder}(\mathcal{D}_Z; U_S). $$ \end{claim} In particular, this directly yields the following analogue of Claim~\ref{lem:sc-entropy-bound}, for \textsc{Polar-Decompress}. \begin{claim} \label{lem:fast-entropy-bound} Let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$ and $\bar{U} := P^{\rm column}_m(\bar{Z})$. Then, for all sets $S_1, S_2, \dots S_m \subseteq [m]$, $$\Pr_{\substack{\bar{U} \gets P^{\rm column}_m(\bar{Z})}} [\text{\sc Polar-Decompress}(U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m}) \neq \bar{U}] \leq \sum_{j\in [m], i \not\in S_j} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j}) $$ \end{claim} \subsection{Proof of Main Theorem} At this point, we can show the entire process of compression and decompression succeeds with high probability, proving Theorem~\ref{thm:main-analysis}. First, we argue $\mathcal{H}_{m^2}$ and $\mathcal{H}_m^{\otimes m}$ are close in the appropriate sense. \begin{lemma} \label{lem:hybrids} Let $Z \sim \mathcal{H}_{m^2}$ and $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$. Then, for every $\ell \in [m]$, the distribution of $Z^{< m - \ell}$ and $\bar{Z}^{< m - \ell}$ are $m\cdot \exp(-\ell / \tau)$-close in $L_1$. \end{lemma} \begin{proof} We proceed by a sequence of $m$ hybrids, changing one row at a time to being independent. Let the $i$-th hybrid be $H_i := Z^{< m - \ell}_{\leq i} \circ \bar{Z}^{< m - \ell}_{> i}$, that is, the first $i$ rows of $Z$, with the remaining rows replaced by iid copies of $Z_1$. Consider moving from $H_{i+1}$ to $H_i$. Conditioned on the first $i$ rows of $Z^{< m - \ell}$, the distribution of the hidden state of the Markov source, at the beginning of the $(i+1)$th row, is $\exp(-\ell/\tau)$-close to its stationary distribution $\pi$ (since $\ell$ steps pass between $Z_{i, m-\ell}$ and $Z_{i+1, 1}$). Recall that the distribution of $Z_1$ is generated by the Markov source starting from $\pi$. Thus, the distribution of the $(i+1)$th row of $Z$, conditioned on the first $i$ rows of $Z^{< m - \ell}$, is $\exp(-\ell/\tau)$-close to the distribution of $Z_1$. So, $|H_{i+1} - H_i|_1 \leq \exp(-\ell/\tau)$. Since we pass through $m$ hybrids, the total $L_1$ distance is at most $m\cdot \exp(-\ell / \tau)$. \end{proof} \begin{proof}[Proof of Theorem~\ref{thm:main-analysis}] First, we show the corresponding claim about the ``independent'' distribution $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$: \begin{claim} \label{lem:fullZiid} For $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$, we have: $$\Pr_{\bar{U} \gets P^{\rm column}_m(\bar{Z})}[\textsc{Polar-Decompress}(\bar{U}^1_{S_1}, \bar{U}^1_{S_2}, \dots \bar{U}^m_{S_m}) \neq \bar{Z}] \leq n\zeta$$ or equivalently, $$\Pr_{\bar{Z} \sim \mathcal{H}_m^{\otimes m}}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(\bar{Z}; \{S_j\}_{j \in [m]})) \neq \bar{Z}] \leq n \zeta$$ \end{claim} \begin{proof} By Claim~\ref{lem:fast-entropy-bound}, we have \begin{align*} \Pr_{\bar{U} \gets P^{\rm column}_m(\bar{Z})}[ \textsc{Polar-Decompress}(\bar{U}^1_{S_1}, \bar{U}^1_{S_2}, \dots \bar{U}^m_{S_m}) \neq \bar{Z}] &\leq \sum_{j\in [m], i \not\in S_j} \bar{H}(\bar{U}^j_i | \bar{U}^j_{< i}, \bar{U}^{< j})\\ &\leq n \zeta \quad \text{(by $(\eps, \zeta)$-niceness)} \quad \qedhere \end{align*} \end{proof} Continuing the proof of Theorem~\ref{thm:main-analysis}, notice that the composition of \textsc{Polar-Compress} and \textsc{Polar-Decompress} always operate as the identity transform on the inputs $Z^j$ for $j > (1-\eps)m$. Thus, it suffices to consider the behavior of this composition on inputs $Z^{\leq (1-\eps)m}$. In this case, Lemma~\ref{lem:hybrids} guarantees that the distributions of $\bar{Z}^{\leq (1-\eps)m}$ and $Z^{\leq (1-\eps)m}$ are close in $L_1$, and thus we may conclude by Claim~\ref{lem:fullZiid}: \iffalse \begin{align*} &\Pr_{Z}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(Z; \{S_j\}_{j \in [m]})) \neq Z]\\ &\leq \Pr_{\bar{Z}}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(\bar{Z}; \{S_j\}_{j \in [m]})) \neq \bar{Z}] + m \exp(-\eps m / \tau) \tag{Lemma~\ref{lem:hybrids}}\\ &\leq \exp(-n^\beta) + m \exp(-\eps m/ \tau) \tag{Lemma~\ref{lem:fullZiid}}\\ &\leq \mathcal{O}(\exp(-c \cdot n^{\beta'} / \tau)) \tag{For some constants $c, \beta'$.} \end{align*} \fi \begin{align*} &\Pr_{Z \sim \mathcal{H}_{m^2}}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(Z; \{S_j\}_{j \in [m]})) \neq Z]\\ &\leq \Pr_{\bar{Z} \sim \mathcal{H}_m^{\otimes m}}[\textsc{Polar-Decompress}(\textsc{Polar-Compress}(\bar{Z}; \{S_j\}_{j \in [m]})) \neq \bar{Z}] + m \exp(-\eps m / \tau) \tag{Lemma~\ref{lem:hybrids}}\\ &\leq n\zeta + m \exp(-\eps m/ \tau) \quad \text{(Claim~\ref{lem:fullZiid})} \quad \qedhere \end{align*} \end{proof} \section{Forward Algorithm} \label{app:forward-algo} \begin{algorithm}[H] \caption{Forward Algorithm} \label{algo:forward} \begin{algorithmic}[1] \Require{$n \in \N$. Markov source $\mathcal{H}$ with state-space $[\ell]$, alphabet $\Sigma$, stationary distribution $\pi \in \Delta([\ell])$, transition matrix $\Pi \in \R^{\ell \x \ell}$}, and output distributions $\{\mathcal{S}_i \in \Delta(\Sigma)\}_{i \in [\ell]}$. And $y = (y_1, y_2, \dots y_{n-1})$ for $y_i \in \Sigma$. \Ensure{Distribution $Y_n \in \Delta(\Sigma)$} \Procedure{ForwardInfer}{$\mathcal{H}=(\ell, \Sigma, \pi, \Pi, \{\mathcal{S}_i\}), n, y$} \State $s_0 \gets \pi$. \ForAll{$t = 1, 2, \dots {n-1}$} \State Define $s_t \in \Delta([\ell])$ by $s_t(i) \gets \frac{ (\Pi s_{t-1})_i \cdot \mathcal{S}_i(y_t) } { \sum_{j \in [\ell]} (\Pi s_{t-1})_j \cdot \mathcal{S}_j(y_t) }$ \Comment{Treating $s_{t-1}$ as a vector in the probability simplex embedded in $\R^\ell$} \EndFor \State $s_n \gets \Pi s_{n-1}$. \State \Return The distribution $Y_n := \E_{i \sim s_n}[\mathcal{S}_i]$. \EndProcedure \end{algorithmic} \end{algorithm} \begin{claim} For every Markov source $\mathcal{H} = (\ell, \Sigma, \pi, \Pi, \{\mathcal{S}_i\})$, let random variables $Y_1, \dots Y_n \sim \mathcal{H}_n$. For every setting $y = (y_1, y_2, \dots y_{n-1})$ for $y_i \in \Sigma$, let $\mathcal{D}_{Y_n | Y_{< n} = y}$ denote the distribution of $Y_n$ conditioned on $Y_{< n} = y$. Then, $$ \textsc{ForwardInfer}(\mathcal{H}, n, y) \equiv \mathcal{D}_{Y_n | Y_{< n} = y} $$ \end{claim} This follows inductively, from the fact that $s_t$ as maintained by the algorithm is exactly the distribution of $S_t | \{Y_{\leq t} = y_{\leq t}\}$, where $S_t$ is the hidden state of $\mathcal{H}$ after $t$ steps. \section{Connection to Learning Parity with Noise} \label{app:LPN} The problem of learning parity with noise (LPN) is the following. Fix an (unknown) string $a \in \F_2^\ell$ and $\eta > 0$ and let $D_{a,\eta}$ be the distribution on $\F_2^{\ell+1}$ whose samples $(x,y)$ are generated as follows: Draw $x \in \F_2^\ell$ uniformly and let $z\in Bern(\eta)$ be drawn independent of $x$ and let $y = \langle a,x \rangle + z$ where $ \langle a,x \rangle = \sum_{i=1}^\ell a_i x_i $. Given samples $(x_1,y_1),\ldots,(x_m,y_m)$ drawn i.i.d. from such a distribution, the LPN problem is the task of ``learning'' $a$. It is well known that $a$ is uniquely determined by $O(\ell)$ samples (i.e., $m = O(\ell)$) where the constant in the $O(\cdot)$ depends on $\eta < 1/2$. However no polynomial time algorithms are known that work with $m = \mathop{\mathrm{poly}}(\ell)$ and determine $a$ for any $\eta > 0$ and indeed this is believed to be a hard task in learning. We refer to this hardness assumption as the LPN hypothesis. The connection to learning Markovian sources comes from the fact that samples from the distribution $D_{a,\eta}$ can be generated by an $O(\ell)$-state Markov chain. (Briefly the states are indexed $(i,b,c)$ indicating $\sum_{j=1}^{i-1} a_j x_j = b$ and $x_i = c$. For $i < \ell$ the state $(i,b,c)$ outputs $c$ and transtions to $(i+1,b+c,0)$ w.p. 1/2 and to $(i+1,b+c,1)$ w.p. 1/2. When $i = \ell$, the state $(i,b,c)$ outputs $(c,b+c)$ w.p. $1-\eta$ and $(c,b+c+1)$ w.p. $\eta$ and transitions to $(1,0,0)$ w.p. 1/2 and to $(1,0,1)$ w.p. $1/2$.) The entropy of this source is $(\ell+H(\eta))/(\ell+1)$. A compression with $\eps = (1 - H(\eta))/(2(\ell+1))$ with $\mathop{\mathrm{poly}}(\ell/\eps)$ samples from the source would distinguish this source from purely random strings which in turn enables recovery of $a$, contradicting the LPN hypothesis. We thus conclude that compressing an {\em unknown} Markov source with number of samples that is a polynomial in the mixing time and the inverse of the gap to capacity contradicts the LPN hypothesis. \end{appendix} \section{Construction} \label{sec:construct} \subsection{Compression Algorithm} Our compression, decompression and preprocessing algorithms are defined with respect to arbitrary mixing matrices $M \in \F_q^{k \x k}$. (Recall that mixing matrices were defined in Definition~\ref{def:mixing}.) Though a reader seeking simplicity may set $k=2$ and $M = \left[\begin{array}{ll} 1 & 1\\ 0 & 1\end{array}\right]$. Given integer $t$, let $m = k^t$ and let $P_m = P_{m,M}: \F_q^m \to \F_q^m$ be the polarization transform given by $P_m = M^{\otimes t}$. \begin{algorithm}[H] \caption{{\sc Polar-Compress}} \label{algo:compressor} \begin{algorithmic}[1] \Const{$M \in \F_q^{k \x k}$, $m = k^t, n = m^2$} \Require{$Z = (Z_{11},Z_{12},\ldots,Z_{mm}) \in \F_q^n$, and sets $S_j \subseteq [m]$ for $j \in [m]$} \Ensure{$U^j_{S_j} \in \F_q^{s_j}$ for all $j \in [m]$} \Comment{$s_j := |S_j|$ for $j \leq (1-\eps) m$, and $s_j := m$ otherwise.} \Procedure{Polar-Compress}{$Z; \{S_j\}_{j \in [m]}$} \ForAll{$j \in [m]$} \State{Compute $U^j := P_m(Z^j)$.} \If{$j \leq (1-\eps)m$} \State{Output $U^j_{S_j}$} \Else \State{Output $U^j$} \EndIf \EndFor \EndProcedure \end{algorithmic} \end{algorithm} \iffalse \subsection{Compression for Non-Stationary Sources} We now consider the case of Markov sources when the underlying Markov chain is known to both compressor and decompresser, but the distribution of the initial state is unknown (and potentially adversarially chosen). The idea is simply to wait until the chain has mixed, and then compress as usual, as if it were a stationary Markov source. \begin{algorithm}[H] \caption{Polar Compressor 2} \label{algo:compressor} \begin{algorithmic}[1] \Const{$M \in \F_q^{k \x k}$, $m = k^t, n = m^2$} \Require{$Z_1, Z_2, \dots Z_n \in \F_q$} \Ensure{$U \in \F_q^s$} \Procedure{Polar-Compress-2}{$Z$} \State{Output $Z_1, \dots Z_{\eps n}$} \State{Output \textsc{Polar-Compress}($Z_{> \eps n}$)} \EndProcedure \end{algorithmic} \end{algorithm} \fi \subsection{Fast Decompressor} The decompressor below makes black-box use of the \textsc{Fast-Decoder} from \cite[Algorithm 4]{BGNRS}. The \textsc{Fast-Decoder} takes as input the description of a \emph{product distribution} $\mathcal{D}_Z$ on inputs in $\F_q^m$, as well as the specified coordinates of the compression $U$. It is intended to decode from the encoding $U' \in \{\F_q \cup \{\bot\}\}^m$, where $U := M^{\otimes t} Z$, coordinates of $Z$ are independent, and $U'$ is defined by $U$ on the high-entropy coordinates of $U$ (and $\bot$ otherwise). It outputs an estimate $\hat Z$ of the input $Z$. \newcommand{\mathcal{D}_{z^j | \hat{z}^{<j}}}{\mathcal{D}_{z^j | \hat{z}^{<j}}} \begin{algorithm}[H] \caption{{\sc Polar-Decompress}} \label{algo:fast-decompressor} \begin{algorithmic}[1] \Const{$M \in \F_q^{k \x k}$, $m = k^t, n = m^2$} \Require{Markov Source $\mathcal{H}$ and $U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m} \in \F_q^m$} \Ensure{$\hat Z \in \F_q^{m \x m}$} \Procedure{Polar-Decompress}{$\mathcal{H}; U^1_{S_1}, U^2_{S_2}, \dots, U^m_{S_m}$} \ForAll{$j \in [m]$} \If{$j \leq (1-\eps)m$} \State{Compute the distribution $\mathcal{D}_{z^j | \hat{z}^{<j}} \equiv \bar{Z}^j | \{\bar{Z}^{<j} = \hat Z^{<j}\}$}, using the \emph{Forward Algorithm} on Markov Source $\mathcal{H}$. \label{ln:inference} \State{Define $U^j \in \{\F_q \cup \{\bot\}\}^m$ by extending $U^j_{S_j}$ using $\bot$ in the unspecified coordinates.} \State{Set $\hat Z^j \gets \text{\sc Fast-Decoder}(\mathcal{D}_{z^j | \hat{z}^{<j}}; U^{j})$ } \label{line:fastdc} \label{ln:decoder} \Else \State{Set $\hat Z^j \gets (M^{-1})^{\otimes t} \hat U_{S_j}^j$} \Comment{Note here $S_j = [m]$} \EndIf \EndFor \State \Return{$\hat Z$} \EndProcedure \end{algorithmic} \end{algorithm} Note that, for a Markov source $\mathcal{H}$ on $\ell$ states, Line ~\ref{ln:inference} takes time $\mathcal{O}_q(m^2\ell^2)$ (time $\mathcal{O}_q(m \ell^2)$ per coordinate of $\bar{Z}^j$, using the Forward Algorithm). The \textsc{Fast-Decoder} call in Line ~\ref{ln:decoder} takes time $\mathcal{O}_q(m \log m)$. Thus, the total runtime is $\mathcal{O}_q(m^3 \ell^2 + m^2 \log m) = \mathcal{O}_q(n^{3/2} \ell^2 + n \log n)$. \section{Introduction} \label{sec:intro} We study the problem of designing coding schemes, specifically encoding and decoding algorithms, that overcome errors caused by stochastic, but not memoryless, channels. Specifically we consider the class of ``(hidden) Markov channels'' that are stateful, with the states evolving according to some Markov process, and where the distribution of error depends on the state.\footnote{We use the term {\em hidden} to emphasize the fact that the state itself is not directly observable from the actions of the channel, though in the interest of succinctness we will omit this term for most of the rest of this section.} Such Markovian models capture many natural settings of error, such as bursty error models. (See for example, Figure~\ref{fig:one}.) Yet they are often less understood than their memoryless counterparts (or even ``explicit Markov models'' where the state is completely determined by the actions of the channel). For instance (though this is not relevant to our work) even the capacity of such channels is not known to have a closed form expression in terms of channel parameters. (In particular the exact capacity of the channel in Figure~\ref{fig:one} is not known as a function of $\delta$, $p$ and $q$!) \begin{figure}[h] \centering\includegraphics[scale=.5]{Markov-fig2.pdf} \caption{A Markovian Channel: The Nice state flips bits with probability $\delta$ whereas the Noisy state flips with probability $1/2 - \delta$. The stationary probability of the Nice state is $q/p$ times that of the Noisy state.}\label{fig:one} \end{figure} In this work we aim to design coding schemes that achieve rates arbitrarily close to capacity. Specifically given a channel of capacity $C$ and gap parameter $\epsilon > 0$, we would like to design codes that achieve a rate of at least $C - \epsilon$, that admit polynomial time algorithms even at small block lengths $n \geq \mathop{\mathrm{poly}}(1/\epsilon)$. Even for the memoryless case such coding schemes were not known till recently. In 2008, Arikan~\cite{arikan-polar} invented a completely novel approach to constructing codes based on ``channel polarization" for communication on binary-input memoryless channels, and proved that they enable achieving capacity in the limit of large code lengths with near-linear complexity encoding and decoding. In 2013, independent works by Guruswami and Xia~\cite{GX15} and Hassani et al.~\cite{HAU14} gave a finite-length analysis of Arikan's polar codes, proving that they approach capacity fast, at block lengths bounded by $\mathop{\mathrm{poly}}(1/\epsilon)$ where $\epsilon > 0$ is the difference between the channel capacity and code rate. The success of polar codes on the memoryless channels might lead to the hope that maybe these codes, or some variants, might lead to similar coding schemes for channels with memory. But such a hope is not easily justified: the analysis of polar codes relies heavily on the fact that errors introduced by the channel are independent and this is exactly what is not true for channels with memory. Despite this seemingly insurmountable barrier, \c{S}a\c{s}o\u{g}lu~\cite{Sasoglu} and later \c{S}a\c{s}o\u{g}lu\ and Tal~\cite{SasogluTal} showed, quite surprisingly, that the analysis of polar codes can be carried out even with Markovian channels (and potentially even broader classes of channels). Specifically they show that these codes converge to capacity and even the probability of decoding error, under maximum likelihood decoding, drops exponentially fast in the block length (specifically as $2^{-n^{\Omega(1)}}$ on codes of length $n$; see also \cite{ShuvalTal}, where exponentially fast polarization was also shown at the high entropy end). An extension of Arikan's successive cancellation decoder from the memoryless case was also given by \cite{WHYLH}, building on an earlier version~\cite{WLH} specific to intersymbol interference channels, leading to efficient decoding algorithms. However, none of the works above give small bounds on the block length of the codes as a function of the gap to capacity, and more centrally to this work, on the mixing time of the Markov chain. The latter issue gains importance when we turn to the issue of ``compressing Markov sources'' which turns out to be an intimately related task to that of error-correction for Markov channels as we elaborate below and which is also the central task we turn to in this paper. We start by describing Markov source and the (linear) compression problem. A (hidden) Markov source over alphabet $\Sigma$ is given by a Markov chain on some finite state space where each state $s$ has an associated distribution $D_s$ over $\Sigma$. The source produces information by performing a walk on the chain and at each time step $t$, outputting a letter of $\Sigma$ drawn according to the distribution associated with the state at time $t$ (independent of all previous choices, and previous states).\footnote{The phrase ``hidden'' emphasizes the fact that the output produced by the source does not necessarily reveal the sequence of states visited.} In the special case of additive Markovian channels where the output of the channel is the sum of the transmitted word with an error vector produced by a Markov source, a well-known correspondence shows that error-correction for the additive Markov channel reduces to the task of designing a compression and decompression algorithm for Markovian sources, with the compression being {\em linear}. Indeed in this paper we only focus on this task: our goal turns into that of compressing $n$ bits generated by the source to its entropy upto an additive factor of $\epsilon n$, while $n$ is only polynomially large in $1/\epsilon$. A central issue in the task of compressing a source is whether the source is {\em known} to the compression algorithm or not. While ostensibly the problem should be easier in the ``known'' setting than in the ``unknown'' one, we are not aware of any formal results suggesting a difference in complexity. It turns out that compression in the setting where the source is unknown is at least as hard as ``learning parity with noise'' (we argue this in Appendix~\ref{app:LPN}), {\em if} the compression works at lengths polynomial in the mixing time and gap to capacity. This suggests that the unknown source setting is hard (under some current beliefs). No corresponding hardness was known for the task of compressing sources when they are known, but no easiness result seems to have been known either (and certainly no linear compression algorithm was known). This leads to the main question addressed (positively) in this work. \paragraph{Our Results.} Our main result is a construction of codes for {\em additive Markov channels} that gets $\epsilon$ close to capacity at block lengths polynomial in $1/\epsilon$ and the mixing time of the Markov chain, with polynomial (in fact near-linear) encoding and decoding time. Informally additive channels are those that map inputs from some alphabet $\Sigma$ to outputs over $\Sigma$ with an abelian group defined on $\Sigma$ and the channel generates an error sequence independent of the input sequence, and the output of the channel is just the coordinatewise sum of the input sequence with the error sequence. (In our case the alphabet $\Sigma$ is a finite field of prime cardinality.) The exact class of channels is described in Definition~\ref{def:amc}, and Theorem~\ref{thm:main-channel} states our result formally. We stress that we work with additive channels only for conceptual simplicity and that our results should extend to more general symmetric channels though we don't do so here. Prior to this work no non-trivial Markov channel was known to achieve efficient encoding and decoding at block lengths polynomial in either parameter (gap to capacity or mixing time). Our construction and analyses turn out to be relatively simple given the works of \c{S}a\c{s}o\u{g}lu\ and Tal~\cite{Sasoglu,SasogluTal} and the work of Blasiok et al.~\cite{BGNRS}. The former provides insights on how to work with channels with memory, whereas the latter provides tools needed to get short block length and cleaner abstractions of the efficient decoding algorithm that enable us to apply it in our setting. Our codes are a slight variant of polar codes, where we apply the polar transforms independently to blocks of inputs. This enables us to apply the analysis of \cite{BGNRS} in an essentially black box manner, benefiting both from its polynomially fast convergence guarantee to capacity as well as its generality covering all polarizing matrices over any prime alphabet (and not just the basic Boolean $2 \times 2$ transform covered in \cite{SasogluTal}). We give a more detailed summary of how our codes are obtained and how we analyze them in Section~\ref{sec:overview} after stating our results and main theorem formally. \section{Overview of our construction} \label{sec:overview} \smallskip \noindent \textbf{Basics of polarization.} We start with the basics of polarization in the setting of compressing samples from an i.i.d. source. To compress a sequence $Z \in \F_2^n$ drawn from some source, the idea is to build an invertible linear function $P$ such that for all but $\epsilon$ fraction of the output coordinates $i\in [n]$, the conditional entropy $H(P(Z)_i | P(Z)_{<i})$ is close to $0$ and or close to $1$. (Such an effect is called \emph{polarization}, as the entropies are driven to polarize toward the two extreme values.) Since a deterministic invertible transformation preserves the total entropy, it follows that roughly $H(Z)$ output coordinates can have entropy close to $1$ and $n-H(Z)$ coordinates have (conditional) entropy close to $0$. Letting $S$ denote the coordinates whose conditional entropies that are not close to zero, the compression function is simply $Z \mapsto P(Z)_S$, the projection of the output $P(Z)$ onto the coordinates in $S$. Picking a random linear function $P$ would satisfy the properties above with high probability, but this is not known (and unlikely) to be accompanied by efficient algorithms. To get the algorithmics (how to compute $P$ efficiently, to determine $S$ efficiently, and to decompress efficiently) one uses a recursive construction of $P$. For our purposes the following explanation works best: Let $n=m^2$ and view $Z = (Z_{11},Z_{12},\ldots,Z_{mm})$ and as an $m \times m$ matrix over $\F_2$, where the elements of $Z$ arrive one row at a time. Let $P_m^{\rm row}(\cdot)$ denote the operation mapping $\F_2^{m \times m}$ to $\F_2^{m \times m}$ that applies $P_m$ to each row of separately. Let $P_m^{\rm column}(\cdot)$ denote the operation that applies $P_m$ to each column separately. Then $P_n(Z) = P_m^{\rm column}(P_m^{\rm row}(Z))^T$. The base case is given by $P_2(U,V) = (U+V,V)$. Intuitively, when the elements of $Z$ are {\em independent} and identical, the operation $P_m$ already polarizes the outputs somewhat and so a moderate fraction of the outputs of $P_m^{\rm row}(Z)$ have conditional entropies moderately close to $0$ or $1$. The further application of $P_m^{\rm column}(\cdot)$ further polarizes the output bringing a larger fraction of he conditional entropies of the output even closer to $0$ or $1$. \medskip\noindent \textbf{Polarization for Markovian Sources.} When applied to source $Z$ with memory, roughly the analysis in \cite{SasogluTal}, reinterpreted to facilitate our subsequent modification of the above polar constructuion, goes as follows: Since the elements of the row $Z_i$ are not really independent one cannot count on the polarization effects of $P_m^{\rm row}$. But, letting $U = P_m^{\rm row}(Z)$ one can show that most elements of the column of $U^j$ are almost independent of each other, provided $m$ is much larger than the mixing time of the source. (Here we imagine that the entries of $Z$ arrive row-by-row, so that the source outputs within each row are temporally well-separated from most entries of the previous row, when $m$ is large.) Further, this almost independence holds even when conditioning on the columns $U^{<j}$ for most values of $j$. Thus the operation $P_m^{\rm column}(\cdot)$ continues to have its polarization effects and this is good enough to get a qualitatively strong polarization theorem (about the operator $P_n$!). The above analysis is asymptotic, proving that in the limit of $n \to \infty$, we get optimal compression. However, we do not know how to give an effective finite-length analysis of the polarization process for Markovian process, as the analysis in \cite{GX15,HAU14} crucially rely on independence which we lack within a row. \medskip\noindent\textbf{Our Modified Code and Ingredients of Analysis.} To enable a finite-length analysis, we make a minor, but quite important, alteration to the polar code: Instead of using $P_n(Z) = P_m^{\rm column}(P_m^{\rm row}(Z))^T$ we simply use the transformation $\tilde{P}_n = P_m^{\rm column}(Z)^T$ (or in other words, we replace the inner function $P_m^{\rm row}(\cdot)$ in the definition of $P_n$ by the identity function). This implies that we lose whatever polarization effects of $P_m^{\rm row}$ we may have been counting on, but as pointed out above, for Markov sources, we weren't counting on polarization here anyway! The crucial property we identify and exploit in the analysis is the following: the Markovian nature of the source plus the row-by-row arrival ordering of $Z$, implies that the distribution of the $j$'th source column $Z^j$ conditioned on the previous columns $Z^{<j} = z^{<j}$, is a \emph{close to} a product distribution, for all but the last few (say $\epsilon m$) columns. \footnote{We handle the non-independence in the last few columns, by simply outputting those columns $P_m(Z^j)$ in entirety, rather than only a set $S_j$ of entropy-carrying positions. This only adds an $\epsilon$ fraction to the output length, which we can afford.} It turns out that the analysis of the polar transform $P_m$ only needs independent inputs, which however need not be identically distributed. We are then able to apply the recent analysis from \cite{BGNRS}, essentially as black box, to argue that $P_m$ will compress each of the conditioned sources $Z^j | {Z^{< j} = z^{< j}}$ to its respective entropy, and also establish fast convergence via quantitatively strong polynomial (in the gap to capacity) upper bounds on the $m$ needed to achieve this. Further, we automatically benefit from the generality of the analysis in \cite{BGNRS}, which applies not only to the $2 \times 2$ transform $P_2$ at the base case, but in fact any $k \times k$ transform (satisfying some minimal necessary conditions) over an arbitrary prime field $\F_q$. Previous works on polar coding for Markovian sources~\cite{Sasoglu,SasogluTal,WHYLH} only applied for Boolean sources. We remark that the use of the identity transform for the rows in $\tilde{P}_n$ is quite counterintuitive. It implies that the compression matrix is a block diagonal matrix (after some permutation of the rows and columns) --- and in turn this seems to suggest that we are compressing different parts of the input sequence ``independently''. However this is not quite true. The relationship between the blocks ends up influencing the final set $S$ of the bits of $\tilde{P}_n(Z)$ that are output by the compression algorithm. Furthermore the decompression relies on the information obtained from the decompression of the blocks corresponding to $Z^{<j}$ to compute the block $Z^j$. \medskip\noindent\textbf{Decompression algorithm.} Our alteration to apply the identity transform for the rows also helps us with the task of decompression. Toward this, we build on a decompression algorithm for memoryless sources from \cite{BGNRS} that is somewhat different looking from the usual ones in the polar coding literature. This algorithm aims to compute $U = P_m^{\rm row}(Z)$ one {\em column} at a time, given $P_n(Z)|_S$. Given the first $j-1$ columns $U^{<j} = u^{<j}$, the algorithm first computes the conditional distribution of $U^j$ conditioned on $U^{<j} = u^{<j}$ and then uses a recursive decoding algorithm for $P_m$ to determine $U^j$. The key to the recursive use is again that the decoding algorithm works as long as the input variables are independent (and in particular, does not need them to be identically distributed). In our Markovian setting, we now have to compute the conditional distribution of $Z^j$ conditioned on $Z^{<j} = z^{<j}$. But as mentioned above, this conditional distribution is close to a product distribution, say $D_j(z^{< j})$ (except for the last few columns $j$ where decompression is trivial as we output the entire column). Further, the marginals of this product distribution are easily computed using dynamic programming (via what is called the ``Forward Algorithm'' for hidden Markov models, described for completeness in Appendix~\ref{app:forward-algo}). We can then determine the $j$'th column $Z^j$ (having already recovered the first $j-1$ columns as $z^{< j}$) by running (in a black box fashion) the polar decompressor from \cite{BGNRS} for the memoryless case, feeding this product distribution $D_j(z^{< j})$ as the source distribution. \medskip\noindent\textbf{Computing the output indices.} Finally we need one more piece to make the result fully constructive. This is the preprocessing needed to compute the subset $S$ of the coordinates of $\tilde{P}_n(Z)$ that have noticeable conditional entropy. For the memoryless case these computations were shown to be polynomial time computable in the works of \cite{PHTT,GX15,TalVardy}. We manage to extend the ideas from Guruswami and Xia~\cite{GX15} to the case of Markovian channels as well. It turns out the only ingredients needed to make this computation work are, again, the ability to compute the distributions of $Z^j$ conditioned on $Z^{<j} = z^{<j}$ for typical values of $z^{<j}$. We note that unlike in the setting of memoryless channels (or i.i.d. sources) our preprocessing step is randomized. We believe this is related to the issue that there is no ``closed'' form solutions to basic questions related to Markovian sources and channels (such as the capacity of the channel in Figure~\ref{fig:one}) and this forces us to use some random sampling and estimation to compute some of the conditional entropies needed by our algorithms. \medskip\noindent\textbf{Organization of rest of the paper.} In the next section (Section~\ref{sec:construct}) we describe our compression and decompression algorithms. In Section~\ref{sec:analysis} we describe a notion of ``nice''-ness for the preprocessing stage and show that if the preprocessing algorithm returns a nice output, then the compression and decompression algorithm work correctly with moderately high probability (over the message produced by the source). In Section~\ref{sec:preprocess} we describe our preprocessing algorithm that returns a nice set with all but exponentially small failure probability (over its internal coin tosses). Finally in Section~\ref{sec:proofs} we give the formal proofs of Theorems~\ref{thm:main}~and~\ref{thm:main-channel}. \iffalse \paragraph{Decoding Complexity and challenges.} We now turn to the algorithmic issues, which lead to our work. The most basic algorithm for polynomial time decoding is the ``successive cancellation'' decoder that aims to compute, given an index $I \in [n]$ and $w_{<I}$, the distribution of $(P_n(Z))_{I}$ conditioned on $P_n(Z)_{<I} = w_{<I}$. (This algorithm does not rely on the ``matrix'' view of $Z$ or the output.) This computation seems to be complex --- we are not aware of efficient algorithms to do so for the case of Markovian sources. A natural divide and conquer strategy that eventually relies on breaking $Z$ down in to smaller pieces works wells when $Z$ is memoryless but fails when $Z$ has memory and the pieces are no longer independent. This seems to have been the main algorithmic obstacle in compressing Markovian sources. When trying to apply this algorithm in the Markovian case, $U_j$'s are almost independent (as observed in \cite{SasogluTal}) but we still have the obstacle of computing the distribution of $U_j$ conditioned on $u_{<j}$ and we don't know how to do that. (Specifically, this seems to require computing the distribution of $Z_j$ given that $Z_{<j}$ lies in some given affine subspace.) \fi \section{Preprocessing} \label{sec:preprocess} \newcommand{d_C}{d_C} \newcommand{\mathbb{D}}{\mathbb{D}} In this section, we describe a pre-processing algorithm to find the $(\eps, \zeta)$-nice sets, as defined in Definition~\ref{def:nice}, that are required by the compression and decompression algorithms. Recall the notion of a mixing matrix (Definition~\ref{def:mixing}). The following theorem shows that for every prime alphabet $\F_q$ and mixing matrix $M \in \F_q^{k \x k}$, there is an efficient algorithm that can find nice sets in polynomial time. Specifically, we prove the following theorem. \begin{theorem} \label{thm:preproc} For every prime $q$ and mixing-matrix $M \in \F_q^{k \x k}$, there exists a polynomial $p(\cdot)$ and a polynomial time preprocessing algorithm \textsc{Polar-Preprocess} (Algorithm~\ref{algo:subset}), such that for every $\eps > 0$ and $m > p(1/\eps)$, the following holds: Let $\mathcal{H}$ be a Markov source with mixing-time $\tau$, alphabet $\F_q$, and underlying state space $[\ell]$. Let $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$ for $m = k^t$, and $\bar{U} := P_m^{\rm column}(\bar{Z})$. Let $$S_1, S_2, \dots S_m \gets \textsc{Polar-Preprocess}(q,k,t, M, \mathcal{H})$$ Then, except with probability $\exp(-\Omega(m))$ over the randomness of the algorithm, the output sets $S_1, S_2, \dots S_m \subseteq [m]$ are $(\eps, \zeta = \mathcal{O}(\frac{1}{n^3}))$-nice for $\mathcal{H}$. Further, the algorithm runs in time $poly_q(m, \ell, 1/\eps)$. \end{theorem} Our main goal will be to estimate the conditional entropies $$ \bar{H}(\bar{U}_{(i, j)} | \bar{U}_{\prec (i, j)}) = \bar{H}(\bar{U}_{i, j} | \bar{U}_{<i, j}, \bar{U}^{< j}) = \bar{H}(\bar{U}_{i, j} | \bar{U}_{<i, j}, \bar{Z}^{< j}) $$ for $\bar{Z} \sim \mathcal{H}_m^{\otimes m}$ and $\bar{U} := P^{\rm column}_m(\bar{Z})$. Then, we will construct the ``nice'' sets by defining, for each $j$, $S_j$ as the set of indices with high entropy: $S_j := \{i \in [m]: \bar{H}(\bar{U}_{i, j} | \bar{U}_{<i, j}, \bar{Z}^{< j}) > \frac{1}{n^3} \}$. By Polarization (Lemma~\ref{lem:polarization}), these sets have size at most $\sum_j |S_j| \leq \bar{H}(Z) + \eps n$, since they must have conditional entropies close to $1$ (except possibly for some $\eps$ fraction of indices $(i, j) \in [m] \x [m]$). We will estimate conditional entropies $\bar{H}(\bar{U}_{i, j} | \bar{U}_{<i, j}, \bar{Z}^{< j})$ by approximately tracking the distribution of variables as we apply successive tensor-powers of $M$. Since we are only interested in conditional entropies, it is sufficient to ``quantize'' the true distribution of, for example $U_i | U_{< i}$, into an approximation $U_i | A$, such that $H(U_i | U_{< i}) \approx H(U_i | A)$. This algorithm follows the same high-level strategy of \cite{GX15}, of approximating the conditional distributions via quantized bins. It turns out that this strategy can be implemented for Markov sources, using the fact that Markov sources are constructive. We define our notions of approximation, and formalize this strategy below. \subsection{Notation and Preliminaries} \begin{definition}[Associated Conditional Distribution] Let $X$ be a random variable taking values in universe $U$, and let $W$ be an arbitrary random variable. Let $\mathcal{D}_{X | w} \in \Delta(U)$ denote the conditional distribution of $X | \{W = w\}$. Let $\mathbb{D}_{X | W} \in \Delta(\Delta(U))$ be the distribution over $\mathcal{D}_{X | w}$ defined by sampling $w \sim W$. We call $\mathbb{D}_{X | W}$ the \emph{associated conditional distribution to $X | W$}. \end{definition} As above, we use boldface $\mathbb{D}$ to denote objects of type $\Delta(\Delta(U))$. Note that we can operate on conditional distributions as we would on their underlying random variables. For example, for random variables $(A_1, W)$ and $(A_2, Y)$ such that $A_1, A_2 \in \F_q$ and $(A_1, W)$ is independent from $(A_2, Y)$, the associated conditional distribution of $A_1 + A_2 | Y, W$ can be computed from the associated conditional distributions of $A_1 | Y$ and $A_2 | W$. To more easily describe such operations on conditional distributions (which may not always arise from underlying random variables), we define the \emph{implicit random variables} associated to a conditional distribution: \begin{definition}[Implicit Random Variables Associated to Conditional Distribution] For every $\mathbb{D}_{X | W} \in \Delta(\Delta(U))$, define \emph{implicit random variables $X, W$ associated to $\mathbb{D}_{X | W}$} as random variables $(X, W)$ such that the associated conditional distribution to $X | W$ is exactly $\mathbb{D}_{X | W}$. Note that there is not a unique choice of such random variables. \end{definition} Using this, we can naturally define (for example) $\mathbb{D}_{A_1 + A_2 | W, Y}$ and $\mathbb{D}_{A_2 | W, Y, A_1 + A_2}$ from any $\mathbb{D}_{A_1, W}, \mathbb{D}_{A_2, Y} \in \Delta(\Delta(\F_q))$. Note that we will always be performing such operations assuming independence of the involved implicit random variables, ie $(A_1, W)$ and $(A_2, Y)$. \begin{definition}[Conditional Distance] Let $(X, W)$ and $(Y, Z)$ be two joint distributions, such that $X$ and $Y$ take values in the same universe $U$. Let $\mathbb{D}_{X | W}$ and $\mathbb{D}_{Y | Z}$ be the associated distributions in $\Delta(\Delta(U))$. Then, define the \emph{conditional distance} $$ d_C(\mathbb{D}_{X | W}, \mathbb{D}_{Y | Z}) := \min_{\substack{(A, B): \text{a distribution in } \Delta(\Delta(U) \x \Delta(U))\\ \text{s.t. marginals of $A$ match $\mathbb{D}_{X | W}$, and}\\ \text{marginals of $B$ match $\mathbb{D}_{Y | Z}$} }} ~~\E_{(D_A, D_B) \sim (A, B)}[||D_A - D_B||_1] $$ Note that $d_C$ can be equivalently defined as an optimal transportation cost between two distributions in $\Delta(\Delta(U))$, where the cost of moving a unit of mass between points $D_i, D_j \in \Delta(U)$ is $||D_i - D_j||_1$. \end{definition} This metric behaves naturally under post-processing: \begin{claim} \label{lem:postproc} For all $\mathbb{D}_{X|W}, \mathbb{D}_{X'|W'} \in \Delta(\Delta(U))$, and any $f: U \to V$, $$ d_C(\mathbb{D}_{f(X)|W}, \mathbb{D}_{f(X')|W'}) \leq d_C(\mathbb{D}_{X|W}, \mathbb{D}_{X'|W'}) $$ \end{claim} For computational purposes, we represent the space of distributions using $\eps$-nets: \begin{definition}[$\eps$-nets] For every set $U$ and any $\eps > 0$, let $T_\eps(U) \subseteq \Delta(U)$ be an $\eps$-net of $\Delta(U)$ with respect to $L_1$. That is, for every $\mathcal{D} \in \Delta(U)$, there exists $\hat{\mathcal{D}} \in T_\eps(U)$ such that $||\mathcal{D} - \hat{\mathcal{D}}||_1 \leq \eps$. Note that for $|U| = |\F_q| = q$, $T_{\eps}(U)$ can be chosen such that $|T_{\eps}(U)| \leq {\frac{q}{\eps} + q \choose q} \leq (\frac{2q}{\eps})^q = poly_q(1/\eps)$. Moreover, $\Delta(T_{\eps}(U))$ is an $\eps$-net of $\Delta(\Delta(U))$ under the $d_C$-metric. \end{definition} \subsection{Conditional Distribution Approximation} The below procedure takes as input a conditional distribution $\mathbb{D}_{Z | W} \in \Delta(\Delta(\F_q))$, and computes an approximation to the conditional distribution of $U_I | (U_{\prec I}, W_1, \dots W_{k^t})$, for an index $I \in [k]^t$, where $U := M^{\otimes t} Z$ and $\{(Z_i, W_i)\}_{i \in [k^t]}$ are independently defined by $\mathbb{D}_{Z|W}$. \begin{algorithm}[H] \caption{Conditional Distribution Approximation} \label{algo:dist-approx} \begin{algorithmic}[1] \Require{Conditional distribution on inputs $\mathbb{D}_{Z | W} \in \Delta(\Delta(\F_q))$, $\eps > 0$, $t \in \N$, index $I \in [k]^t$, and $M \in \F_q^{k \x k}$} \Ensure{Conditional distribution $\tilde{\mathbb{D}}_{U | W} \in \Delta(\Delta(\F_q))$, an approximation to $U_I | (U_{\prec I}, W_1, \dots W_{k^t})$ for $U := M^{\otimes t} Z$ and $\{(Z_i, W_i)\}_{i \in [k^t]}$ independently defined by $\mathbb{D}_{Z|W}$.} \Procedure{ApproxDist}{$\mathbb{D}_{Z|W}, \eps, t, I = (I_1, \dots, I_t), M$} \If{$t=0$} \State \Return $\mathbb{D}_{Z|W}$ \Else \State $\hat{\mathbb{D}}_{Z| Y} \gets \textsc{ApproxDist}(\mathbb{D}_{Z|W}, \eps/(2k), t-1, I_{< t}= (I_1, \dots, I_{t-1}), M)$ \label{ln:induction} \State $j \gets I_t$. \State Explicitly compute the following conditional distribution $\hat{\mathbb{D}}_{U_j | U_{< j}, Y_1, \dots Y_k} \in \Delta(\Delta(\F_q))$: \State \quad \quad Let $(Z,Y)$ be the implicit random variables associated to $\hat{\mathbb{D}}_{Z | Y}$. \State \quad \quad Let $\{(Z_i, Y_i)\}_{i \in [k]}$ be independent random variables distributed identically to $(Z, Y)$. \State \quad \quad Define random vector $U := M \cdot Z'$, Where $Z' = (Z_1, \dots Z_k)$. \State \quad \quad Let $\hat{\mathbb{D}}_{U_j | U_{< j}, Y_1, \dots Y_k}$ be the associated conditional distribution to $U_j | U_{< j}, Y_1, \dots Y_k$. \label{ln:Mtensor} \State Round $\hat{\mathbb{D}}_{U_j | U_{< j}, Y_1, \dots Y_k}$ to $\tilde{\mathbb{D}}_{U | Y} \in \Delta(T_{\eps/2}(\F_q))$, a point in the $\eps/2$-net of $\Delta(\Delta(\F_q))$ under $d_C$. \label{ln:round} \State \Return $\tilde{\mathbb{D}}_{U | Y}$. \EndIf \EndProcedure \end{algorithmic} \end{algorithm} Note that if the input $\mathbb{D}_{Z | W}$ is specified in an $\eps$-net $\Delta(T_{\eps}(\F_q))$, then the above procedure runs in time $poly_q(m, 1/\eps)$ for $m = k^t$. \begin{lemma} \label{lem:approxdist} For all $\mathbb{D}_{Z|W} \in \Delta(\Delta(U)), \eps > 0, t \in \N, M \in \F_q^{k \x k}$, and $I \in [k]^t$, we have $$d_C(\textsc{ApproxDist}(\mathbb{D}_{Z|W}, \eps, t, I, M) ~~,~~ \mathbb{D}_{U_I | U_{\prec I}, W_1, \dots W_{k^t}}) \leq \eps$$ where $\mathbb{D}_{U_I | U_{\prec I}, W_1, \dots W_{k^t}}$ is the associated conditional distribution to the random variables defined as follows. Let $(Z,W)$ be the implicit random variables associated to $\mathbb{D}_{Z | W}$. Let $\{(Z_i, W_i)\}_{i \in [k^t]}$ be independent random variables distributed identically to $(Z, W)$. Finally, define random vector $U := M^{\otimes t} \cdot Z'$, where $Z' = (Z_1, \dots Z_{k^t})$. \end{lemma} \begin{proof} First, notice that for $\eps=0$ (ie, omitting the rounding in Line~\ref{ln:round}), these distributions are identical: $$\textsc{ApproxDist}(\mathbb{D}_{Z|W}, \eps=0, t, I, M) \equiv \mathbb{D}_{U_I | U_{\prec I}, W_1, \dots W_k}$$ It remains to prove that the rounding approximately preserves this. We can prove the lemma by induction on $t$. Suppose the statement holds for $t-1$. Let $I' := I_{< t}$. Let $\hat{\mathbb{D}}_{Z | Y}$ be the result of the recursive call on Line~\ref{ln:induction}. By the inductive hypothesis, $$d_C(\hat{\mathbb{D}}_{Z | Y} ~,~ \mathbb{D}_{U'_{I'} | U'_{\prec I'}, W_1, \dots W_{k^{t-1}}}) \leq \eps/(2k)$$ where $U' := M^{\otimes t-1} \tilde Z$ for $\tilde Z := (Z_1, \dots, Z_{k^{t-1}})$ and $\{(Z_i, W_i)\}_{i \in [k^t]}$ independent random variables distributed according to $\mathbb{D}_{Z | W}$. Now, by the triangle inequality and Claim~\ref{lem:postproc}, the distribution $\hat{\mathbb{D}}_{U_I | U_{\prec I}, Y_1, \dots Y_k}$ (defined in Line~\ref{ln:Mtensor} using the tensor-product recursion) satisfies: $$ d_C(\hat{\mathbb{D}}_{U_I | U_{\prec I}, Y_1, \dots Y_k} ~,~ \mathbb{D}_{U_I | U_{\prec I}, W_1, \dots W_{k^t}}) \leq \eps/2 $$ Now, by rounding to an $\eps/2$-net in Line~\ref{ln:round}, this distance is distorted by at most an additional $\eps/2$. Thus: $$ d_C(\tilde{\mathbb{D}}_{U | Y} ~,~ \mathbb{D}_{U_I | U_{\prec I}, W_1, \dots W_{k^t}}) \leq \eps \ . \qedhere $$ \end{proof} \subsection{Approximating Conditional Entropies} Here we use Algorithm~\ref{algo:dist-approx} directly to approximate conditional entropies: \begin{theorem} \label{thm:entropy-approx} For every field $\F_q$, conditional distribution $\mathbb{D}_{Z | W} \in \Delta(\Delta(\F_q))$, matrix $M \in \F^{k \x k}$, $t \in \N, m = k^t$, and $\gamma > 0$, consider the random variable $U := M^{\otimes t} Z$ where each $\{(Z_i, W_i)\}_{i \in [m]}$ is sampled independently from $\mathcal{D}_{Z, W}$. Then, Algorithm~\ref{algo:entropy-approx} outputs $\hat h_1, \dots \hat h_m \gets \textsc{ApproxEntropy}(\mathbb{D}_{Z|W}, \gamma, t, M)$ such that $$\forall i \in [m]: \hat h_i = \bar{H}(U_i | U_{< i}, W_1, \dots, W_m) \pm \gamma$$ Further, if the input $\mathbb{D}_{Z | W}$ is specified in an $\eps$-net $\Delta(T_{\eps}(\F_q))$, then the above procedure runs in time $poly_q(m, 1/\eps, 1/\gamma)$. \end{theorem} \begin{algorithm}[H] \caption{Entropy Approximation} \label{algo:entropy-approx} \begin{algorithmic}[1] \Require{$\gamma > 0$, $t \in \N$, Conditional distribution $\mathbb{D}_{Z | W} \in \Delta(\Delta(\F_q))$, and $M \in \F_q^{k \x k}$} \Ensure{$\{ \hat h_i \in \R\}_{i \in [k^t]}$} \Procedure{ApproxEntropy}{$\mathbb{D}_{Z|W}, \gamma, t, M$} \State $m \gets k^t$ \State $\eps \gets \gamma^2$ \ForAll{$I \in [k]^t$} \State $\mathbb{D}_{U | Y} \gets \textsc{ApproxDist}(\mathbb{D}_{Z|W}, \eps, t, I, M)$ \State $\hat h_I \gets \bar{H}(U | Y)$, the conditional entropy of the implicit random variables $(U, Y)$ associated to $\mathbb{D}_{U | Y}$. \EndFor \State \Return $\{\hat h_i\}_{i \in [k^t]}$ \Comment{Abusing notation by identifying $[k]^t$ with $[k^t]$.} \EndProcedure \end{algorithmic} \end{algorithm} \begin{proof}[Proof of Theorem~\ref{thm:entropy-approx}] Correctness of Algorithm~\ref{thm:entropy-approx} follows from the fact that $\gamma^2$-closeness in the $d_C$-metric implies $\gamma$-closeness of (normalized) conditional entropies, as in Lemma~\ref{lem:entropy-dc} below. Thus, using Algorithm~\ref{algo:dist-approx} to approximate the conditional distributions within $\gamma^2$ is sufficient. \end{proof} \begin{claim} \label{lem:entropy-dc} For any finite set $U$, consider any two conditional distributions $\mathbb{D}_{X | W}, \mathbb{D}_{X' | W'} \in \Delta(\Delta(U))$. Then, the conditional entropies of the associated random variables satisfy $$d_C(\mathbb{D}_{X | W}, \mathbb{D}_{X' | W'}) \leq \eps \implies |H(X | W) - H(X' | W')| \leq \eps \log(\frac{|U|}{\eps}) \leq \eps^2 \log(|U|)$$ \end{claim} The above claim in turn follows directly from the transportation-cost definition of $d_C$, and Claim~\ref{lem:entropy-L1} below. \begin{claim} \label{lem:entropy-L1} Let $X, Y$ be two random variables taking values in the same finite universe $\Sigma$. Then, the \emph{non-normalized entropies} satisfy $$||X - Y||_1 \leq \eps \implies |H(X) - H(Y)| \leq \eps \log(\frac{|\Sigma|}{\eps})$$ \end{claim} \begin{proof} Let $N := |\Sigma|$, and assume without loss of generality that the random variables take values in $[N]$. Let $p_i := \Pr[X = i]$ and $q_i := \Pr[Y = i]$. First, it can be confirmed by basic calculus that $$\forall p, q \in [0, 1], \eps := |p - q|: \quad |p\log(1/p) - q \log(1/q)| \leq \eps \log(1/\eps)$$ Thus, defining $\eps_i := |p_i - q_i|$, we have \begin{align*} |H(X)-H(Y)| &= |\sum_{i=1}^N p_i \log(1/p_i) - q_i \log(1/q_i)| \\ &\leq \sum_{i=1}^N |p_i \log(1/p_i) - q_i \log(1/q_i)|\\ &\leq \sum_{i=1}^N \eps_i \log(1/\eps_i) \end{align*} We have $\sum_i \eps_i = ||X-Y||_1 \leq \eps$, so this quantity is maximized for $\eps_i = \frac{\eps}{N}$. Thus, $$|H(X)-H(Y)| \leq \eps \log(\frac{N}{\eps}) \ . \qedhere $$ \end{proof} \subsection{Nice Subset Selection} Now we can describe how to find ``nice'' sets. We first approximate the conditional distribution $\mathbb{D}_{Z_t | Z_{< t}} \in \Delta(\Delta(\F_q))$ for $Z_1, \dots Z_t \sim \mathcal{H}_t$, by sampling. This crucially relies on the fact that $\mathcal{H}$ is a constructive source (ie, using the Forward Algorithm). Then we use Algorithm~\ref{algo:entropy-approx} to estimate conditional entropies, and select high-entropy indices. \begin{algorithm}[H] \caption{{\sc Polar-Preprocess}} \label{algo:subset} \begin{algorithmic}[1] \Require{$q,k,t \in \N$ with $q$ prime, $M \in \F_q^{k \x k}$, and Markov source $\mathcal{H}$} \Comment{$m = k^t, n = m^2$} \Ensure{Sets $S_1, S_2, \dots S_m \subseteq [m]$} \Procedure{Polar-Preprocess}{$q,k,t, M, \mathcal{H}$} \State $m \gets k^t$; $\gamma \gets \frac{1}{n^{10}}$; $N \gets |T_{\gamma}(\F_q)|$; $R \gets n (N / \gamma)^2$ \Comment{$N \leq poly_q(1/\gamma)$} \ForAll{$j \in [m]$} \ForAll{$i = 1, 2, \dots, R$} \State Sample a sequence $w_i := (y_1, y_2, \dots y_{j-1})$ from $\mathcal{H}$. \State Compute $\mathcal{D}_{w_i} \in \Delta(\F_q)$, the distribution of $Y_j | Y_{< j} = w_i$, using the Forward Algorithm~\ref{algo:forward} for $\mathcal{H}$. \EndFor \State Let $\widetilde{\mathbb{D}}_{Y | W} \in \Delta(\Delta(F_q))$ be the empirical distribution of $\mathcal{D}_w$, from the samples $\mathcal{D}_{w_i}$ above. \label{ln:sample} \State $\{\hat h_1, \dots \hat h_m\} \gets \textsc{ApproxEntropy}(\widetilde{\mathbb{D}}_{Y|W}, \gamma = \frac{1}{n^4}, t, M)$ \State $S_j \gets \{i \in [m]: \hat h_i > \frac{1}{n^3}\}$ \EndFor \State \Return $S_1, S_2, \dots S_j$. \EndProcedure \end{algorithmic} \end{algorithm} \begin{proof}[Proof of Theorem~\ref{thm:preproc}] First, we claim that for each $j$, the sampling step (Line~\ref{ln:sample}) produces $\widetilde{\mathbb{D}}_{Y | W}$ such that $$d_C(\widetilde{\mathbb{D}}_{Y | W}, \mathbb{D}_{Y_j | Y_{< j}}) \leq 2 \gamma$$, except with probability $\exp(-\Omega(n))$. Here, $\mathbb{D}_{Y_j | Y_{< j}}$ denotes the conditional distribution of random variables $(Y_1, Y_2, \dots Y_j) \sim \mathcal{H}_j$. It is sufficient to show that these distributions are $\gamma$-close, after rounding both to $\Delta(T_{\gamma})$, a $\gamma$-net of $\Delta(\Delta(\F_q))$. Let $R_{\gamma}: \Delta(\F_q) \to T_{\gamma}$ be the function that rounds points to their nearest net-point. Let this naturally lift to a function $\bar{R}_\gamma: \Delta(\Delta(\F_q)) \to \Delta(T_\gamma)$. Now, the net $T_\gamma$ has only $N$ points, so sampling $n (N / \gamma)^2$ points from $\bar{R}_\gamma(\mathbb{D}_{Y_j | Y_{< j}})$ will approximate the mass of each point to within $\pm (\gamma / N)$, except with probability $\exp(-\Omega(n))$. Thus, we have $d_C(\bar{R}_\gamma(\widetilde{\mathbb{D}}_{Y | W}), \bar{R}_\gamma(\mathbb{D}_{Y_j | Y_{< j}})) \leq \gamma$ with high probability, and this implies $d_C(\widetilde{\mathbb{D}}_{Y | W}, \mathbb{D}_{Y_j | Y_{< j}}) \leq 2 \gamma$. Now, consider the following random variables. Let $(Y, W)$ be the implicit random variables associated with $\tilde{\mathbb{D}}_{Y | W}$, and let $(Y', W')$ be those associated with $\mathbb{D}_{Y_j | Y_{< j}}$. Let $U := M^{\otimes t} Z$ and $U' := M^{\otimes t} Z'$ where $\{(Z_i, W_i)\}$ are independently distributed as $(Y, W)$, and $\{(Z'_i, W'_i)\}$ are independently distributed as $(Y', W')$. Now, by triangle inequality, we have $$d_C(\mathbb{D}_{U_i | U_{< i}}, \mathbb{D}_{U'_i | U'_{< i}}) \leq 2 \gamma m$$. Using the above definitions, by Lemma~\ref{lem:entropy-dc}, the conditional entropies $H(U_i | U_{< i})$ and $H(U'_i | U'_{< i})$ differ by at most $\pm \sqrt{2\gamma m} = \mathcal{O}(1/n^4)$. Thus, set $S_j$ selected will have all entropies $$\forall i \in S_j: \bar{H}(\bar{U}_{(i, j)} | \bar{U}_{\prec (i, j)}) = \frac{1}{n^3} \pm \mathcal{O}(\frac{1}{n^4}) = \Theta(\frac{1}{n^3})$$ Finally, by the Polarization Lemma (Lemma~\ref{lem:polarization}), all but $\eps n$ of the entropies $\{\bar{H}(\bar{U}_{(i, j)} | \bar{U}_{\prec (i, j)})\}_{i \in S_j}$ are $\geq 1-\eps$. Thus, the size of $\sum_j |S_j|$ is at most $$\eps n + \bar{H}(\bar{Z}) / (1-\eps) \leq 2 \eps n + \bar{H}(\bar{Z}) \leq 2 \eps n + \bar{H}(\bar{Z}) + \exp(-\Omega(n)) \leq 3\eps n + \bar{H}(\bar{Z}) $$ Now, by Claim~\ref{lem:entropy-L1} and the closeness of distributions $\bar{Z}$ and $Z$, we have $\bar{H}(\bar{Z}) \leq \bar{H}(Z) + n^2 \exp(- \eps m / \tau) < \bar{H}(Z) + \mathcal{O}(\eps n)$. Thus, finally, $\sum_j |S_j| \leq \bar{H}(Z) + \mathcal{O}(\eps n)$ as required. \end{proof} \section{Proofs of Theorems~\ref{thm:main}~and~\ref{thm:main-channel}} \label{sec:proofs} Combining Theorem~\ref{thm:preproc} (to compute nice sets) with Theorem~\ref{thm:main-analysis} (compressing and decompressing assuming nice sets), Theorem~\ref{thm:main} follows immediately. \begin{proof}[Proof of Theorem~\ref{thm:main}] The algorithms claimed are Algorithm~\ref{algo:subset} for preprocessing, Algorithm~\ref{algo:compressor} for compressing and Algorithm~\ref{algo:fast-decompressor} for decompression. Theorem~\ref{thm:preproc} asserts that Algorithm~\ref{algo:subset} returns a nice sequence of sets $S_1,\ldots,S_m$ with all but exponentially small probability in $n$. And Theorem~\ref{thm:main-analysis} asserts that if $S_1,\ldots,S_m$ are nice then Algorithm~\ref{algo:compressor}~and~\ref{algo:fast-decompressor} compress and decompress correctly with high probability over the output of the Markovian source. This yields the theorem. \end{proof} Finally we show how Theorem~\ref{thm:main-channel} follows from Theorem~\ref{thm:main}. \begin{proof}[Proof of Thereom~\ref{thm:main-channel}] Let $H \in \F_q^{s \x n}$ be the matrix specifying the (linear) compression scheme given by the Preprocessing Algorithm in Theorem~\ref{thm:main}, when applied to Markov source $\mathcal{H}$. The code $C$ for the additive Markov Channel $\mathcal{C}_{\mathcal{H}}$ is simply specified by the nullspace of $H$, ie encoding is given by $C(x) := Nx$ where $N \in \F_q^{n \x n-s}$ spans $Null(A)$. Note that due to the structure of $H$, a nullspace matrix $N$ can be applied in $\mathcal{O}_q(n \log n)$ time. In particular, $H$ is a subset of rows of the block-diagonal matrix $P \in \F_q^{n \x n}$, where each $\sqrt{n} \x \sqrt{n}$ block is the tensor-power $M^{\otimes t}$. Thus, $P^{-1}$ is also block-diagonal with blocks $(M^{-1})^{\otimes t}$, and so can be applied in time $\mathcal{O}_q(n \log n)$. The matrix $N$ can be chosen as just a subset of columns of $P^{-1}$, and hence can also be applied in time $\mathcal{O}_q(n \log n)$. Let $y_1, y_2, \dots y_n \in \F_q$ be distributed according to $\mathcal{H}$, and $y := (y_1, \dots y_n) \in \F_q^n$. To decode from $z = Nx + y$, the decoder first applies $H$ (by running the compression algorithm of Theorem~\ref{thm:main}), to compute $Hz = HNx + Hy = Hy$. Then, the decoder runs the decompression algorithm of Theorem~\ref{thm:main} on $Hy$ to determine $y$. Finally, the decoder can compute $y - z$ to find the codeword sent $(Nx)$, and thus determine $x$. (Again using the structure of $P$, as above, to determine $x$ from $Nx$ in $\mathcal{O}_q(n \log n)$ time). \end{proof} \section{Definitions and Main Results} \subsection{Notation and Definitions} We will use $\F_q$ to denote the finite field with $q$ elements. Throughout the paper, we will deal only with the case when $q$ is a prime. (This restriction in turn comes from the work of \cite{BGNRS} whose results we use here.) We use several notations to index matrices. For a matrix $M \in \F_q^{m \x n}$, the entry in the $i$th row, $j$th column is denoted $M_{i, j}$ or $M_{(i, j)}$. Columns are denoted by superscripts, i.e., $M^j \in \F_q^m$ denotes the $i$th column of $M$. Note that $M^j_i = M_{(i, j)}$. We also use the indices as sets in the natural way. For example $M^{\leq j} \in \F_q^{m \times j}$ denotes the first $j$ columns of $M$. $M^{\leq j}_{\leq i}$ denotes the submatrix of elements in the first $j$ columns and first $i$ rows. $M_{\prec (i, j)}$ denotes the set of elements of $M$ indexed by lexicographically smaller indices than $(i, j)$. Multiplication of a matrix $M \in \F_q^{m \x n}$ with a vector $v \in \F_q^n$ is denoted $Mv$. For a finite set $S$, let $\Delta(S)$ denote the set of probability distributions over $S$. For a random variable $X$ and event $E$, we write $X | E$ to denote the conditional distribution of $X$, conditioned on $E$. For example, we may write $X|\{X_1 = 0\}$. The \emph{total-variation distance} between two distributions $p, q \in \Delta(U)$ is $$||p- q||_1 := \sum_i |p(i) - q(i)|$$ We consider compression schemes, as a map $\F_q^n \to \F_q^m$. The \emph{rate} of a compression scheme $\F_q^n \to \F_q^m$ is the ratio $m/n$. For a random variable $X \in [q]$, the \emph{(non-normalized) entropy} is denoted $H(X)$, and is $$H(X) := -\sum_{i} \Pr[X = i] \log(\Pr[X = i])$$ and the \emph{normalized entropy} is denoted $\bar{H}(X)$, and is $$\bar{H}(X) := \frac{1}{\log(q)}H(X)$$ \begin{definition} A \emph{Markov chain} $\mathcal{M} = (\ell,\Pi,\pi_0)$ is given by an $\ell$ representing the state space $[\ell]$, a transition matrix $\Pi \in \R^{\ell \x \ell}$, and a distribution on initial state $\pi_0 \in \Delta([\ell])$. The rows of $\Pi$, denoted $\Pi_1,\ldots,\Pi_\ell$ are thus elements of $\Delta([\ell])$. A Markov chain generates a random sequence of states $X_0, X_1, X_2, \dots$ determined by letting $X_0 \sim \pi_0$, and $X_t \sim \Pi_{X_{t-1}}$ for $t > 0$ given $X_0,\ldots,X_{t-1}$. The stationary distribution $\pi \in \Delta([\ell])$ is the distribution such that if $X_0 \sim \pi$, then all $X_t$'s are marginally identically distributed as $\pi$. \end{definition} We consider only Markov chains which are irreducible and aperiodic, and hence have a stationary distribution to which they converge in the limit. The rate of convergence is measured by the mixing time, defined below. \begin{definition} The \emph{mixing time} of a Markov chain is the constant $\tau > 0$ such that for every initial state $s_0$ of the Markov chain, the distribution of state $s_\ell$ is $\exp(-\ell / \tau)$-close in total variation distance to the stationary distribution $\pi$. \end{definition} \begin{definition} A \emph{(stationary, hidden) Markov source} $\mathcal{H} = (\Sigma,\mathcal{M},\{\mathcal{S}_1,\ldots,\mathcal{S}_\ell\})$ is specified by an alphabet $\Sigma$, a Markov chain $\mathcal{M}$ on $\ell$ states and distributions $\{\mathcal{S}_i \in \Delta(\Sigma)\}_{i \in [\ell]}$. The output of the source is a sequence $Z_1,Z_2,\ldots,$ of random variables obtained by first sampling a sequence $X_0,X_1,X_2,\ldots$ according to $\mathcal{M}$ and then sampling $Z_i \sim \mathcal{S}_{X_i}$ independently for each $i$. We let $\mathcal{H}_t$ the distribution of output sequences of length $t$, and $\mathcal{H}_t^{\otimes s}$ denote the distribution of $s$ i.i.d. samples from $\mathcal{H}_t$. \end{definition} Similarly, we define an \emph{additive Markov channel} as a channel which adds noise from a Markov source. \begin{definition}\label{def:amc} An \emph{additive Markov channel $\mathcal{C}_{\mathcal{H}}$}, specified by a Markov source $\mathcal{H}$ over alphabet $\F_q$, is a randomized map $\mathcal{C}_{\mathcal{H}}: \F_q^* \to \F_q^*$ obtained as follows: On channel input $X_1,\ldots,X_n$, the channel outputs $Y_1,\ldots,Y_n$ where $Y_i = X_i + Z_i$ where $Z = (Z_1,\ldots,Z_n) \sim \mathcal{H}_n$. \end{definition} \begin{definition} A \emph{linear code} is a linear map $C: \F_q^k \to \F_q^n$. The \emph{rate} of a code is the ratio $k/n$. \end{definition} \begin{definition} \label{def:constr} For all sets $A, B$, a \emph{constructive source over $(A | B)$ samplable in time $T$} is a distribution $\mathcal{D} \in \Delta(A \times B)$ such that $(a, b) \sim \mathcal{D}$ can be sampled efficiently in time at most $T$, and for every fixed $b \in B$, the conditional distribution $A | \{B = b\}$ can be sampled efficiently in time at most $T$. \end{definition} \begin{proposition} Every Markov source with state space $[\ell]$ is a constructive source samplable in time $\mathcal{O}(n\ell^2)$. That is, for every $n$, let $Y_1, \dots Y_n$ be the random variables generated by the Markov source. Then, the sequence $Y_1, \dots Y_n$ can be sampled in time at most $\mathcal{O}(n \ell^2)$, and moreover for every setting of $Y_{< n} = y_{< n}$, the distribution $(Y_n | Y_{< n} = y_{<n})$ can be sampled in time $\mathcal{O}(n \ell^2)$. \end{proposition} \begin{proof} Sampling $Y_1, \dots, Y_n$ can clearly be done by simulating the Markov chain, and sampling from the conditional distribution $(Y_n | Y_{< n} = y_{<n})$ is possible using the standard \emph{Forward Algorithm} for inference in Hidden Markov Models, which we describe for completeness in Appendix~\ref{app:forward-algo}. \end{proof} Finally, we will use the following notion of \emph{mixing matrices} from ~\cite{KSU10,BGNRS}, characterizing which matrices lead to good polar codes. In the study of polarization it is well-known that lower-triangular matrices do not polarize at all, and the polarization characteristics of matrices are invariant under column permutations. Mixing matrices are defined to be those that avoid the above cases. \begin{definition} \label{def:mixing} For prime $q$ and $M \in \F_q^{k \x k}$, $M$ is said to be a \emph{mixing matrix} if $M$ is invertible and for every permutation of the columns of $M$, the resulting matrix is not lower-triangular. \end{definition} \subsection{Main Theorems} We are now ready to state the main results of this work formally. We begin with the statement for compressing the output of a hidden Markov model. \begin{theorem} \label{thm:main} For every prime $q$ and mixing matrix $M \in \F_q^{k \x k}$ there exists a preprocessing algorithm ({\sc Polar-Preprocess}, Algorithm~\ref{algo:subset}), a compression algorithm ({\sc Polar-Compress}, Algorithm~\ref{algo:compressor}), a decompression algorithm ({\sc Polar-Decompress}, Algorithm~\ref{algo:fast-decompressor}) and a polynomial $p(\cdot)$ such that for every $\eps > 0$, the following properties hold: \begin{enumerate} \item {\sc Polar-Preprocess} is a randomized algorithm that takes as input a Markov source $\mathcal{H}$ with $\ell$ states, and $t \in \mathbb{N}$, and runs in time $\mathop{\mathrm{poly}}(n, \ell, 1/\eps,q)$ where $n=k^{2t}$ and outputs auxiliary information for the compressor and decompressor (for $\mathcal{H}_n$). \item {\sc Polar-Compress} takes as input a sequence $Z \in \F_q^n$ as well as the auxiliary information output by the preprocessor, runs in time $\mathcal{O}(n \log n)$, and outputs a compressed string $\tilde{U} \in \F_q^{\bar{H}(Z) + \eps n}$. Further, for every auxiliary input, the map $Z \to \tilde{U}$ is a linear map. \item {\sc Polar-Decompress} takes as input a Markov source $\mathcal{H}$ a compressed string $\tilde{U} \in \F_q^{\bar{H}(Z)+\eps n}$ and the auxiliary information output by the preprocessor, runs in time $\mathcal{O}(n^{3/2}\ell^2 + n \log{n})$ and outputs $\hat{Z} \in \F_q^n$. \footnote{The runtime of the decompression algorithm can be improved to a runtime of $\mathcal{O}(n^{1+\delta}\ell^2 + n \log{n})$ by a simple modification. In particular, by taking the input matrix $Z$ to be $n^{1-\delta} \x n^\delta$ instead of $n^{1/2} \x n^{1/2}$. In fact we believe the decoding algorithm can be improved to an $O(n \log n)$ time algorithm with some extra bookkeeping though we don't do so here.} \end{enumerate} \noindent The guarantee provided by the above algorithms is that with probability at least $1-\exp(-\Omega(n))$, the Preprocessing Algorithm outputs auxiliary information $S$ such that $$\Pr_{Z \sim \mathcal{H}_n}[\textsc{Polar-Decompress}(\mathcal{H}, S; \textsc{Polar-Compress}(Z; S)) \neq Z] \leq \mathcal{O}(\frac{1}{n^2}),$$ provided $n > p(\tau/\eps)$ where $\tau$ is the mixing time of $\mathcal{H}$. (In the above $\mathcal{O}(\cdot)$ hides constants depending $k$ and $q$, but not on $\ell$ or $n$.) \end{theorem} The above linear compression directly yields channel coding for additive Markov channels, via a standard reduction (the details of which are in Section~\ref{sec:proofs}.) \begin{theorem} \label{thm:main-channel} For every prime $q$ and mixing matrix $M \in \F_q^{k \x k}$ there exists a randomized preprocessing algorithm \textsc{Preprocess}, an encoding algorithm \textsc{Enc}, a decoding algorithm \textsc{Dec}, and a polynomial $p(\cdot)$ such that for every $\eps > 0$, the following properties hold: \begin{enumerate} \item {\sc Preprocess} is a randomized algorithm that takes as input an additive Markov channel $\mathcal{C}_{\mathcal{H}}$ described by Markov source $\mathcal{H}$ with $\ell$ states, and $t \in \mathbb{N}$, and runs in time $\mathop{\mathrm{poly}}(n, \ell, 1/\eps)$ where $n=k^{2t}$, and outputs auxiliary information for $\mathcal{H}_n$. \item {\sc Enc} takes as input a message $x \in \F_q^r$, where $r \geq n(1 - \frac{\bar{H}(Z)}{n} - \eps)$, as well as auxiliary information from the preprocessor and outputs and computes {\sc Enc}$(x) \in \F_q^n$ in $\mathcal{O}(n \log n)$ time. \item {\sc Dec} takes as input the Markov source $\mathcal{H}$, auxiliary information from the preprocessor and a string $z \in \F_q^n$, runs in time $\mathcal{O}_q(n^{3/2}\ell^2 + n \log{n})$, and outputs an estimate $\hat{x} \in \F_q^r$ of the message $x$. \footnote{This can similarly be improved to a runtime of $\mathcal{O}_q(n^{1+\delta}\ell^2 + n \log{n})$.} \end{enumerate} The guarantee provided by the above algorithms is that with probability at least $1 - \exp(-\Omega(n))$, the Preprocessing algorithm outputs $S$ such that for all $x \in \F_q^r$ we have $$\Pr_{\mathcal{C}_\mathcal{H}}[\textsc{Dec}(\mathcal{H}; \mathcal{C}_{\mathcal{H}}(\textsc{Enc}(C; x))) \neq x] \leq \mathcal{O}(\frac{1}{n^2}), $$ provided $n > p(\tau/\eps)$ where $\tau$ is the mixing time of $\mathcal{H}$. (In the above $\mathcal{O}(\cdot)$ hides constants that may depend on $k$ and $q$ but not on $\ell$ or $n$.) \end{theorem} Theorem~\ref{thm:main-channel} follows relatively easily from Theorem~\ref{thm:main} and so in the next section we focus on the overview of the proof of the latter.
{'timestamp': '2018-10-05T02:03:28', 'yymm': '1810', 'arxiv_id': '1810.01969', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01969'}
arxiv
\section{Adversarial samples} In recent years, the phenomenon of {\it adversarial samples} has surfaced in the deep learning community~\cite{szegedy2013intriguing, goodfellow2014explaining}. In essence, a malicious actor could take a sample that was correctly classified by the model, perturb the input slightly, and the perturbed sample would be misclassified. When images are used, these perturbations are often invisible to the eye. These adversarial attacks have been successfully applied to fields outside of images, including audio~\cite{carlini2018audio} and malware classification~\cite{grosse2017adversarial}. Though there are some defense mechanisms that have been developed~\cite{papernot2016distillation, feinman2017detecting}, many of these are later found to be circumventable~\cite{carlini2017adversarial}. Given that adversarial samples are not limited to images, it is reasonable to believe that neural network-based DGA detectors could also suffer from this vulnerability. In our situation a malicious actor would wish to take a domain that is detected as from a DGA and have it labeled as a non-DGA domain. It would be very straightforward to perform an attack like the Fast Gradient Sign Method~\cite{szegedy2013intriguing} to modify the characters in a domain name. In fact, it is not (generally) important to DGA authors what the domain name looks like, so there is no cost to modify the letters of the domain. Such a technique would likely prove effective against an approach that only incorporated the domain name itself. However, note that our model also incorporates domain registration side information from WHOIS. Although a malware author can change the domain name they are using at will and nearly arbitrarily, it is significantly more difficult to cause the WHOIS registration information (such as registration date) to have specific values. To do that, a malware author might need to register a domain perhaps months in advance and host a clean website on it, which is both expensive and time-consuming. Thus, it would be more difficult for a malware author to work around our proposed model. \section{Conclusion} In this paper we have considered the problem of DGA domain detection. We introduced a measure of complexity for DGA families called the {\it smashword score}, which reflects how closely a DGA's generated domains resemble English words. Because DGA families with higher smashword scores have typically posed greater difficulty for detection, we build a novel machine learning model consisting of recurrent neural networks (RNNs) using the generalized likelihood ratio test (GLRT), and augment these models with a logistic regression model that also includes side information such as WHOIS information. This combined model notably outperforms existing state-of-the-art approaches on DGA families with high smashword score, such as the difficult {\tt matsnu} and {\tt suppobox} families. We believe that this model could be used as either a standalone model or as a part of a larger DGA detection system that could also incorporate network traffic, such as something more like the Pleiades system \cite{antonakakis2012throw}. There is room for future improvement in our work. The model we have used is specialized for DGA families based on English words, and therefore can be less effective for those DGA families that do not look like natural domain names. Thus, in a production environment or in an improved system, our model could be ensembled with other techniques that are more effective for DGA families with lower smashword scores. In a future work we would also like to explore multilingual approaches to tackle new families that may use non-English dictionaries and expand our side information features. \section{DGA Families} \label{sec:families} \begin{table*}[t!] \begin{center} \begin{tabular}{lccccll} \toprule {\bf DGA family} & {\bf $n$} & {\bf $\bar{l}(x)$} & {\bf $\bar{c}(x)$} & {\bf $\bar{s}(x)$} & {\bf sample 1} & {\bf sample 2} \\ \midrule {\bf banjori}$^3$ & 435385 & 22.165 & 3.767 & {\bf 173.909} & {\scriptsize {\tt iivnleasuredehydratorysagp[.]com}} & {\scriptsize {\tt yanzvinskycattederifg[.]com}} \\ beebone$^3$ & 210 & 13.223 & 3.466 & 66.159 & {\scriptsize {\tt backdates10[.]com}} & {\scriptsize {\tt dnsfor3[.]net}} \\ chinad$^6$ & 256 & 19.843 & 3.882 & 19.565 & {\scriptsize {\tt evybt5gtf2tprvbi[.]info}} & {\scriptsize {\tt m5j42r6uiqov2dgm[.]biz}} \\ conficker$^5$ & 100000 & 11.754 & 3.208 & 19.988 & {\scriptsize {\tt jemmmpo[.]ws}} & {\scriptsize {\tt xobxceagb[.]biz}} \\ {\bf gozi}$^3$ & 1212 & 23.262 & 3.550 & {\bf 222.240} & {\scriptsize {\tt questionibus[.]com}} & {\scriptsize {\tt chrisredemptisviros[.]com}} \\ locky$^5$ & 8 & 14.125 & 3.226 & 20.800 & {\scriptsize {\tt pccibcjncnhjn[.]yt}} & {\scriptsize {\tt qtysmobytagnrv[.]it}} \\ {\bf matsnu}$^6$ & 99995 & 30.527 & 3.757 & {\bf 332.581} & {\scriptsize {\tt dutytillboxpossessprogress[.]com}} & {\scriptsize {\tt dropbridgeexplorecraftgive[.]com}} \\ murofet$^6$ & 102020 & 41.619 & 4.488 & 38.683 & {\scriptsize {\tt hyernzfvd10k57lyozotazkrp52gzfyp22eu[.]org}} & {\scriptsize {\tt m19e41hydyfxgtcxjyn10nynukulxdvhub18[.]com}} \\ necurs$^6$ & 2048 & 17.029 & 3.541 & 31.256 & {\scriptsize {\tt gmwyfuhwqveqcbasvtj[.]in}} & {\scriptsize {\tt pysetkbwbryxbegmwg[.]eu}} \\ newgoz$^6$ & 1000 & 29.885 & 4.214 & 23.476 & {\scriptsize {\tt afkv141b7q87du27t2i1b91gfp[.]biz}} & {\scriptsize {\tt krx32h1jjusuatm2aetjkn6jn[.]org}} \\ others\_dga\_b$^7$ & 2775 & 19.233 & 3.485 & 90.369 & {\scriptsize {\tt qktpxl[.]info}} & {\scriptsize {\tt meatopen[.]net}} \\ proslikefan$^6$ & 130 & 11.584 & 3.225 & 20.768 & {\scriptsize {\tt rxxeqcoy[.]cc}} & {\scriptsize {\tt avhpdzz[.]com}} \\ pykspa$^6$ & 5010 & 14.470 & 3.375 & 40.551 & {\scriptsize {\tt tdxiogn[.]org}} & {\scriptsize {\tt dwaejwfox[.]cc}} \\ qakbot$^6$ & 5000 & 20.719 & 3.740 & 43.164 & {\scriptsize {\tt hfbtlwqlqvoywaknjksaaeeus[.]net}} & {\scriptsize {\tt wlwcrapplotshymcia[.]org}} \\ ramdo$^6$ & 100000 & 20.000 & 3.393 & 51.347 & {\scriptsize {\tt aaooekcoyysuouaa[.]org}} & {\scriptsize {\tt skmaogeyiwqgeyym[.]org}} \\ ramnit$^6$ & 100 & 17.340 & 3.585 & 35.981 & {\scriptsize {\tt ckyioylutybvcxv[.]com}} & {\scriptsize {\tt ibvtknxochoyjidm[.]com}} \\ ranbyus$^6$ & 80 & 18.750 & 3.684 & 35.726 & {\scriptsize {\tt cyedjumagsrrav[.]cc}} & {\scriptsize {\tt jxbdxeyxttdmcjagi[.]me}} \\ {\bf rovnix}$^6$ & 99764 & 26.797 & 3.685 & {\bf 284.222} & {\scriptsize {\tt coloniesgovernmentsthe[.]com}} & {\scriptsize {\tt tohavetheontheofassent[.]com}} \\ shiotob$^6$ & 2001 & 16.566 & 3.655 & 20.998 & {\scriptsize {\tt cwitdw951w1n9cm[.]net}} & {\scriptsize {\tt 3pttjmaw2g[.]com}} \\ {\bf suppobox}$^6$ & 258 & 17.298 & 3.341 & {\bf 152.536} & {\scriptsize {\tt bartholomewalbertson[.]net}} & {\scriptsize {\tt dutykind[.]net}} \\ tinba$^6$ & 101001 & 16.006 & 3.457 & 31.592 & {\scriptsize {\tt fuvfpkpwgjqj[.]com}} & {\scriptsize {\tt hosvsbvbveee[.]com}} \\ volatile$^3$ & 352 & 19.000 & 3.745 & 112.362 & {\scriptsize {\tt hpyersgtdobfla[.]info}} & {\scriptsize {\tt ergtydobflashp[.]info}} \\ \bottomrule \end{tabular} \end{center} \caption{Information about a representative set of DGA families. We include the number of samples $n$, average length $\bar{l}(\cdot)$, the average entropy $\bar{c}(\cdot)$, the average smash-word score $\bar{s}(\cdot)$, and two examples of the domains found in the family. Families with high smash-word score are given in {\bf bold}.} \vspace*{-2.5em} \label{tab:families} \end{table*} Before introducing our proposed classifier and experiments, we introduce our dataset of DGA families and clean domains in order to perform some exploratory analyses. In this section we establish the Ground Truth (GT) datasets for both confirmed DGA and non-DGA domains. Each of our sources are taken from public locations, making our dataset straightforward to reproduce. \subsection{DGA Ground Truth Set} The GT for DGA domains consists of domains generated using Python implementations of real-world malware families using various seeds if necessary as an input, as well as domains collected from the wild. In order to have sufficiently diverse coverage, the following entities were selected in order to represent many wide-spread patterns of DGA domains seen in-the-wild in 2017/2018: \begin{itemize} \item random-looking 2nd level domain names \item random-looking 3rd level domain names with generic 2nd level domain (usually dynamic DNS provider) \item domain names comprised of random words (generally English) \end{itemize} The last type of domains was of our particular interest as lexically they are virtually indistinguishable from legal domains which means that some extra techniques are required for detection. In almost all cases DGAs are using some sort of input seeds in order to either randomize the output and don't generated the same domains twice, or make it unpredictable for researchers to avoid blocking or sinkholing. Here are some of the popular seeds: \begin{itemize} \item current date and/or time \item value embedded into a sample/group of samples by campaign (usually one DWORD) \item string(s) available online either on a malware authors or public server \item 3rd party public online document (for example, The US Declaration of Independence, the Apple license, etc) \end{itemize} In addition, some work has been done to make sure that there are diverse top level domains (TLDs) represented as malware authors tend to use only some particular ones which may introduce substantial skew to our dataset. Overall, we have collected 41 DGA families. Information on each family is given in Table \ref{tab:families}, including the average entropy $\bar{c}(\cdot)$ and average smashword score $\bar{s}(\cdot)$. The families are collected from multiple sources and denoted in the table: DGArchive\footnote{See \url{https://dgarchive.caad.fkie.fraunhofer.de/}.}, an implementation for the {\tt locky} family found on Github\footnote{See \url{https://github.com/sourcekris/locky}.}, Andrey Abakumov's DGA repository on Github\footnote{See \url{https://github.com/andrewaeva/DGA}.}, and Johannes Bader's DGA implementations\footnote{See \url{https://johannesbader.ch} and \url{https://github.com/baderj/domain\_generation\_algorithms}.}. Smaller or unknown families were grouped as {\tt others\_dga} and {\tt others\_dga\_b} \footnote{Sinkholed domains collected from public WHOIS registration information containing {\tt [email protected]} as the contact email.}. All of this data is publicly available; our set of DGA domains is reproducible. \subsection{Non-DGA Ground Truth Set} For non-DGA domains the GT is comprised of domains found in the Alexa top 1 million sites and the OpenDNS public domain lists\footnote{These lists can be found at \url{https://github.com/opendns/public-domain-lists}.}, giving 1.02M clean domains for the clean GT set. There were multiple major problems that had to be addressed: \begin{enumerate} \itemsep 5pt \item some prevalent DGA domains can manage to get into the list of world top popular domains, \item 3rd level domains should be covered separately, \item some DGA domains are so short that they collided with the non-DGA domains, and \item some DGA domains use combinations of English words, so the chances that they collide with non-DGA domains are quite high. \end{enumerate} In the last two cases, malware authors have no problem when collisions take place, as in any case malware will be waiting for a valid response from the C\&C before following up. Just the opposite, such cases can make the work of security engineers more complicated as they cannot simply ban all domains generated by the DGA---since some domains are known to be clean. In our dataset, we only found 12 such domains that existed in both the non-DGA and DGA sets. It presents no modeling problem to leave these points in both sets. \section{Measuring the difficulty of detection of a DGA family} Since data-based approaches for the detection of malicious domains have been a recurrent trend during recent years, it is inevitable that malware authors would shift to generation algorithms that overlap with lexical patterns commonly found in clean datasets to avoid being detected. Taking into account this adversarial environment, we need to be able to measure how our DGA detection models will perform not only overall, but also against the most difficult samples. In this context, `difficult' samples can be understood to be those that trick existing detectors---the most relevant example is those DGA families that combine English words, like the {\tt matsnu} family \cite{skuratovich2015}, which was one of the first of many families to build domain names from English word lists. These generate domains like the natural-looking domains {\tt songneckspiritprintmetal[.]com} and {\tt westassociatereplacerisk[.]com}, which present a much harder challenge to the many detection systems that depend on lexical features~\cite{yu2018character, woodbridge2016predicting, phoenix14, deepdga16}. An exploratory data analysis of our dataset shows that DGA families have characteristics that can affect the performance of classification approaches. From an information theory point of view, both the average length $\bar{l}(\cdot)$ and the average character entropy \cite{shannon48} $\bar{c}(\cdot)$ of the domain names seem likely to be interesting features to compare. The entropy of a single domain $x$ is calculated as below: \vspace*{-0.5em} \begin{equation} \hat{c}(x) = -\sum_{x_i \in x} p(x_i) \log_2 p(x_i) \end{equation} \vspace*{-0.5em} \noindent where $p(x_i)$ is the empirical probability of the character $x_i$ in the string $x$. However, in our experiments, we found no serious correlation between the average character entropy $\bar{c}(\cdot)$ of a DGA family and if that family was made up of difficult English-like words. Thus, we cannot use $\bar{c}(\cdot)$ as a proxy for the difficulty of detecting a family. Therefore, we have developed the {\it smashword score} $\hat{s}(\cdot)$, which is the the average $n$-gram overlap (with $n$ ranging from 3-5) with words from an English dictionary. The computation of the smashword score amounts to calculating term-frequency inverse-document-frequency (TF-IDF) \cite{sparck1972statistical} scores for a domain name using an English list of words as a reference document set. Specifically: \vspace*{-0.5em} \begin{equation} \hat{s}(x) = \frac{1}{| \mathcal{N}_{i,j}(x) |} \sum_{n_i \in \mathcal{N}_{i,j}(x) \cap \mathcal{N}_{i,j}(D)} \log\left(|\{ d \in D : n_i \in d \}|\right). \end{equation} \vspace*{-0.5em} In this equation, $\mathcal{N}_{i,j}(x)$ refers to the set of character $n$-grams in the domain $x$ of length $i$ or $j$, $D$ refers to the English word list, and $\mathcal{N}_{i,j}(D)$ refers to the set of character $n$-grams in the entire word list $D$ of length $i$ or $j$. The $\log$ term is the count of times an $n$-gram appears in the entire word list $D$. If there is no overlap in any $n$-grams between the domain and the word list, the score is has a lower bound of 0 and an upper bound depends on the word list. The score is normalized to the number of $n$-grams in the domain. Computing the smashword score $\hat{s}(x)$ for a string $x$ can be done in $\min(| \mathcal{N}_{3,4,5}(x) |, | \mathcal{N}_{3,4,5}(D) |)$ operations; but since $| \mathcal{N}_{3,4,5}(x) |$ will generally be much smaller than $| \mathcal{N}_{3,4,5}(D) |$, we can say that the computation will generally take time linear in the length of the string $x$, since in a string with length $|x|$, there are $|x| - 2$ 3-grams, $|x| - 3$ 4-grams, and $|x| - 4$ 5-grams. The average smashword score $\bar{s}(\cdot)$ of a DGA family is then calculated by simply taking the average smashword score $\hat{s}(\cdot)$ of all of the domains in that family that are present in the data. We can expect that domains with a high smashword score will resemble English words, and thus we expect that $\bar{s}(\cdot)$ is a good indicator of the difficulty of detecting a DGA domain. Indeed, in the following section we find that our data bears out this expectation. \section{Experiments} \begin{figure*}[t!] \begin{subfigure}[b]{0.48\textwidth} \centering \includegraphics[width=0.95\textwidth]{matsnu_roc_curves} \vspace*{-0.8em} \caption{ROC curves for {\tt matsnu} family.} \label{fig:matsnu_roc} \end{subfigure} \begin{subfigure}[b]{0.48\textwidth} \centering \includegraphics[width=0.95\textwidth]{rovnix_roc_curves} \vspace*{-0.8em} \caption{ROC curves for {\tt rovnix} family.} \label{fig:rovnix_roc} \end{subfigure} \begin{subfigure}[b]{0.48\textwidth} \vspace*{-0.3em} \centering \includegraphics[width=0.95\textwidth]{gozi_roc_curves} \vspace*{-0.8em} \caption{ROC curves for {\tt gozi} family.} \label{fig:gozi_roc} \end{subfigure} \begin{subfigure}[b]{0.48\textwidth} \vspace*{-0.3em} \centering \includegraphics[width=0.95\textwidth]{banjori_roc_curves} \vspace*{-0.8em} \caption{ROC curves for {\tt banjori} family.} \label{fig:banjori_roc} \end{subfigure} \vspace*{-0.8em} \caption{ROC curves for different families.} \label{fig:rocs} \vspace*{-0.8em} \end{figure*} \begin{table*}[htb] \begin{center} \begin{tabular}{lcccccc} \toprule {\bf family} & {\bf $\bar{s}(x)$} & {\bf \ \ \ \ lr-tfidf \ \ \ \ } & {\bf \ \ lr-tfidf-aug \ \ } & {\bf \ \ \ \ glrt-lstm \ \ \ \ } & {\bf \ \ glrt-lstm-aug \ \ } & {\bf split-glrt-lstm-aug} \\ \midrule matsnu & 332.6 & 0.581 & 0.824 & 0.501 & 0.546 & {\bf 0.891} \\ rovnix & 284.2 & 0.540 & 0.758 & 0.515 & 0.635 & {\bf 0.805} \\ gozi & 222.2 & 0.540 & 0.684 & 0.520 & 0.548 & {\bf 0.773} \\ banjori & 173.9 & 0.701 & 0.585 & 0.634 & 0.508 & {\bf 0.808} \\ suppobox & 152.5 & 0.509 & 0.505 & 0.579 & {\bf 0.798} & 0.568 \\ volatile & 112.4 & 0.605 & 0.498 & 0.818 & 0.850 & {\bf 0.958} \\ others\_dga\_b & 90.4 & 0.649 & 0.502 & {\bf 0.704} & 0.604 & 0.677 \\ \midrule beebone & 66.2 & 0.498 & 0.498 & 0.498 & 0.498 & {\bf 0.749} \\ ramdo & 51.4 & 0.902 & 0.498 & 0.973 & 0.498 & {\bf 0.980} \\ qakbot & 43.2 & 0.940 & 0.498 & {\bf 0.966} & 0.914 & 0.951 \\ pykspa & 40.6 & 0.777 & 0.498 & 0.911 & 0.866 & {\bf 0.957} \\ murofet & 38.7 & 0.975 & 0.498 & 0.960 & 0.498 & {\bf 0.994} \\ ranbyus & 35.7 & 0.940 & 0.498 & {\bf 0.963} & 0.815 & 0.791 \\ tinba & 31.6 & 0.859 & 0.498 & {\bf 0.968} & 0.655 & 0.867 \\ necurs & 31.3 & 0.818 & 0.498 & {\bf 0.813} & 0.514 & 0.581 \\ new\_goz & 23.3 & 0.863 & 0.498 & {\bf 0.993} & 0.498 & 0.990 \\ \midrule shiotob & 21.0 & 0.653 & 0.498 & 0.894 & 0.846 & {\bf 0.902} \\ locky & 20.8 & {\bf 0.849} & 0.498 & 0.751 & 0.498 & 0.557 \\ proslikefan & 20.8 & 0.647 & 0.498 & {\bf 0.802} & 0.600 & 0.665 \\ conficker & 19.9 & 0.609 & 0.498 & {\bf 0.836} & 0.619 & 0.649 \\ chinad & 19.6 & 0.786 & 0.498 & 0.952 & 0.498 & {\bf 0.979} \\ dyre & 6.5 & 0.548 & 0.498 & 0.779 & 0.498 & {\bf 0.974} \\ \bottomrule \end{tabular} \end{center} \caption{Partial AUC (FPR <= 0.01) performance numbers for selected different DGA families, with a focus on those with either high or low average smashword score. Our {\bf split-glrt-lstm-aug} model performs best on those DGA families with high average smashword score.} \label{tab:aucs} \vspace*{-2.0em} \end{table*} The most important situation for any DGA detection model is when it encounters an entirely new DGA family that it has never seen before. This is the situation that we focus on in our experiments, since it reflects the real-world `zero-day' situation. We compare our model to several baselines that reflect the state-of-the-art for machine learning systems that do not use network traffic data. {\bf Leave-one-out models.} To simulate the situation where a DGA family has not been seen, we validate the performance of our DGA detection model by performing {\it leave-one-out} experiments, where we train the model on all DGA families except one, and then the test set consists entirely of the left-out DGA family combined with some never-before-seen non-DGA domains. This shows us how well the model is able to generalize to unseen DGA family types. {\bf Dataset details.} Our collected dataset, as described in Section~\ref{sec:families}, includes 41 DGA families plus non-DGA data, totaling 2.3 million domain names (1.01 million non-DGA, 1.28 million DGA). Of these 41 DGA families, many with high average smashword score have been specifically mentioned in related work as difficult. The LSTM model of Woodbridge et~al.~\cite{woodbridge2016predicting} is specifically shown to perform very poorly on the {\tt matsnu}, {\tt suppobox}, and {\tt beebone} families, each of which have above average to very large average smashword scores. Mac et~al.~\cite{mac2017dga} claim that {\tt matsnu} is not differentiable from non-DGA domains at all, and show very poor performance on all their surveyed algorithms for the {\tt nymaim} DGA, which is very similar to the {\tt gozi} DGA that we use here. Because our model has been specifically designed to focus on DGA families that are understood to be more difficult, we will focus on these families. {\bf Baseline models.} We wish to compare the performance of our proposed model with existing and baseline approaches. Therefore, we compare our model with four other models, which we now introduce. Two of these are simple baseline models, with and without WHOIS information, and the other two are based on LSTM architectures that represent the most closely related state-of-the-art work of Woodbridge et~al.~\cite{woodbridge2016predicting}. \begin{itemize} \itemsep 5pt \item {\bf lr-tfidf}: logistic regression on TF-IDF features extracted from the domain name using 2-grams.\footnote{We did not use 3-grams, because the memory usage on our system was too large.} Any WHOIS side information is not used here, so this model presents a reasonable baseline using only the domain name. \item {\bf lr-tfidf-aug}: logistic regression on TF-IDF features extracted from the domain name using 2-grams, and augmented with the WHOIS features. This is a reasonable baseline for classification using both the domain name and the side information (WHOIS features). \item {\bf glrt-lstm}: a GLRT LSTM model built only on the full domain name (no side information). This can be considered to be a slight improvement over the model of Woodbridge et~al. \cite{woodbridge2016predicting} due to the use of the GLRT. \item {\bf glrt-lstm-aug}: a GLRT LSTM model built only on the full domain name, and then used as input to a logistic regression model, with the WHOIS features augmented. \end{itemize} {\bf Our model.} We refer to our model as the {\bf split-glrt-lstm-aug} model; this is the model from Section \ref{sec:model}. {\bf Training and implementation details.} The {\bf lr-tfidf} and {\bf lr-tfidf-aug} models were implemented with {\tt scikit-learn}~\cite{pedregosa2011scikit}, and the three LSTM-based models were implemented with Keras~\cite{chollet2015keras} using the TensorFlow backend~\cite{abadi2016tensorflow}. Each LSTM model used 500 LSTM units and was trained for 100 epochs (passes over the dataset) with early stopping using the RMSprop optimizer, with dropout of 0.2. With our setup (one nVidia GeForce GTX TITAN X), each LSTM model took approximately 8-10 hours to train. In our experiments, we found that changing the optimizer made little difference to the resulting model, and we found that increasing or decreasing the number of LSTM units decreased performance slightly. Overall, our model seemed to be relatively robust to hyperparameter choice. Figure~\ref{fig:rocs} shows receiver operating characteristic curves (ROC curves) on the four datasets with highest smashword score. We can see in the figures that the {\bf split-glrt-lstm-aug} model (our proposed model) outperforms each of the other models, providing better performance at lower false positive rates. For instance, on the difficult {\tt matsnu} family, when the false positive rate is chosen to be 0.5\%, the {\bf split-glrt-lstm-aug} model operates at a true positive rate of 95\%, whereas the next best model ({\bf lr-tfidf-aug}) operates at a true positive rate of only 70\%. In typical application scenarios, we typically care only about running our classifier at false positive rates less than or equal to 1\% (FPR $\le 0.01$). Therefore, we study the performance of the classifiers using the {\it partial AUC} \cite{mcclish1989analyzing} measure, which is the standard area-under-the-curve (AUC) measure specific to false positive rates less than a given threshold. In Table \ref{tab:aucs}, we show the partial AUC of each model for each leave-one-out family experiment, sorted by decreasing $\bar{s}(\cdot)$. On the most difficult families (with large $\bar{s}(\cdot)$), the proposed {\bf split-glrt-lstm-aug} reliably and significantly outperforms all other compared models. This is the region of most interest in our work, as these families are difficult to detect---even with WHOIS data. Each of these difficult families generates domains that resemble English words; see Table~\ref{tab:families}. Note that the {\bf lr-tfidf-aug} model and {\bf glrt-lstm-aug} models both have access to the WHOIS features; however, only {\bf split-glrt-lstm-aug} is able to take advantage of these to provide good performance for families with high $\bar{s}(\cdot)$. For `easier' families with lower $\bar{s}(\cdot)$, where the generated domains typically look more like random characters, classification can be performed more reliably with only the text of the domain itself; thus, the {\bf glrt-lstm} model is dominant in this regime. Overall, we see that our model is successful in detecting DGA-generated domains that resemble English words. The model appears to generalize well to different families, given the nature of our leave-one-out experiments. \section{Introduction} \begin{figure}[t!] \centering \includegraphics[width=0.4\textwidth]{dga-process} \label{fig:dga-process} \caption{Typical example of malware using a DGA to find its command-and-control (C\&C) server. The infected host attempts to resolve a number of DGA-generated domains, and connects to the first one that resolves successfully.} \end{figure} Many modern malware families communicate with a centralized command and control (C\&C) server. In order to do this, the malware must know the location of the C\&C server to connect to---simple approaches might hardcode an IP or a domain name. But, these are easy to mitigate: the traffic to a specific IP can be trivially blocked, and domain names can be easily seized. Therefore, modern malware authors use {\it domain generation algorithms} (DGAs) in order to generate a large set of possible domain names where the C\&C server may exist. Typically, an infected machine will use the DGA to serially generate domain names. Each of these domain names will be resolved, and if the DNS resolution does not result in an NXDOMAIN response (i.e. if the domain name is registered), then the machine will attempt to connect to the resolved IP as if it is the C\&C server. If any step of that process is not successful, then the machine will generate another domain name with the DGA and try again, until it is successful. Some DGA families generate random-looking domain names such as {\tt xobxceagb[.]biz}; others generate difficult-to-distinguish domain names like {\tt dutykind[.]net}. This DGA-based approach to finding the C\&C server is robust to IP blocking and domain name seizure; the C\&C server operator can use any IP they have access to (and they may use different IPs at different times), and typically the number of unique domain names a DGA can generate is quite large, and sometimes the DGA itself may be hard to reverse engineer. Therefore, it is not generally feasible to pre-emptively seize all domain names that a DGA could generate. In fact, DGAs may even generate domain names that are not malicious or compromised, and this does not affect the malware's ability to reach the C\&C server eventually. As a consequence, the task of determining whether or not a given domain name is produced by a DGA is an integral part of modern malware defenses. Simultaneously, as DGA authors create DGAs that generate domain names that do not look randomly-generated, the challenge of detecting these domain names increases. A large body of related work seeks to use machine learning techniques directly to classify domains as generated by DGAs or not. Our contribution adds to this lineage of work; here, our machine learning detector is one component of an effective malware detection system. To this end, we describe a machine learning system that is able to accurately classify a domain name as DGA-generated or clean using only the domain name itself and some simple additional features derived from WHOIS data. This system is especially effective on DGA families that generate domain names based on English word lists (i.e., domains that look benign to a human observer). Compared to previous approaches, our system performs better on difficult-to-detect DGA families that resemble English words (such as the {\tt matsnu} and {\tt suppobox} families), and the system is not difficult to deploy in a real-world environment---either as a standalone detector or as part of a larger malware detection system. Overall, this paper makes the following contributions: \begin{itemize} \itemsep 5pt \item{We provide a novel machine learning system built partially on recurrent neural networks that is capable of classifying DGA-generated domain names even from families traditionally understood as difficult. To achieve this degree of performance, our model takes advantage of side information such as WHOIS.} \item{This model is robust: although it is trained with WHOIS information, predictions can still be made if WHOIS or other network level information is not available. This is crucial for real-time detection and prevention of malware outbreaks.} \item{We devise a new measure that we term the {\it smashword score}. We rank 41 DGAs in terms of detection difficulty using this measure, giving an intuitive measure of difficulty related to how closely the domain resembles English words. Our approach can be re-used for new DGA families, and we believe our measure is useful for other DGA detection works in the future.} \item{We successfully classify difficult DGA-generated domains using our model that other state-of-the-art approaches could not conclusively label; this includes domains with high smashword scores (e.g., those that are composed of combinations of English words). Note that these domains can even be difficult for humans to classify correctly.} \end{itemize} \section{Model Architecture} \label{sec:model} Given the effectiveness of deep learning classifiers for character-level DGA modeling~\cite{woodbridge2016predicting, yu2018character}, we have designed our DGA detector on character-level recurrent neural networks (RNNs)~\cite{karpathy2016visualizing}. A character-level RNN sequentially receives characters from a string, updating internal state as each character is passed in. Instead of training the RNNs to predict the class of the domain, we instead train two RNNs to predict the next character in the domain and combine these predictions via a generalized likelihood ratio test (GLRT). In addition, our model also incorporates the WHOIS side information discussed in the previous section via model stacking. This allows us to achieve significantly better performance on more difficult DGA families. Overall, our model is a logistic regression classifier built on the output of four different models: \begin{enumerate} \item A character-level RNN GLRT model built only on the {\it subdomains} in the training set. \item A character-level RNN GLRT model built only on the {\it domains} in the training set. \item One-hot encoded top-level domain features (for the most popular 250 TLDs). \item Extracted features from the WHOIS information. \end{enumerate} The overall architecture of the model can be seen in Figure~\ref{fig:overall_model}. In the following subsections we describe the details of the full model. \subsection{Character-level RNN GLRT} The core of the model is the character-level RNN that uses the generalized likelihood ratio test to classify a domain or a subdomain as DGA or non-DGA. Previous approaches and other uses of RNNs often predict the class of the output directly~\cite{woodbridge2016predicting, graves2005framewise}; however, this only allows backpropagation of the error signal at the end of the entire sequence, which can slow the learning process. Therefore, we build one RNN on each class in the input dataset (in our case, there are only two classes: {\it DGA} and {\it non-DGA}). Each input sequence is converted to a one-hot character encoding, and the label or expected output of the RNN for each time step is the one-hot encoding of the {\it next} character in the sequence. This means the RNN is trained to predict the next character in the sequence. Thus, backpropagation can be done at every timestep, instead of waiting until the end of the sequence to compare the output of the RNN with the desired label. Our model's architecture is a single LSTM layer~\cite{hochreiter1997long} followed by a single dense layer, pictured in Figure~\ref{fig:lstm}. We use LSTMs to help avoid the vanishing and exploding gradient phenomenons~\cite{pascanu2013difficulty}. Although it is possible to build a more complex network, we found that this provides a good balance between training time and the accuracy of the model. \begin{figure}[b!] \centering {\small \begin{tikzpicture}[scale=0.6] \input{lstm.tex} \end{tikzpicture} } \caption{The individual RNN model architecture. The model takes a one-hot encoded character as input (along with its current hidden state) in order to predict the next character in the sequence.} \label{fig:lstm} \end{figure} In order to perform the one-hot encoding, we first build a dictionary $D$ on the entire training set, including the `unknown' character {\tt '?'}. If a character is encountered at prediction time that is not in $D$, then it is encoded as {\tt '?'}. We use the categorical cross-entropy~\cite{goodfellow2016deep} for the loss function. Then, during prediction, at each time step $i$ for the input $x$, the output of the model $\theta$ is a probability $p(x_i | (x_0, \ldots, x_{i - 1}), \theta)$ and with this we can construct an estimate of the likelihood of the point $x$ arising from the model $\theta$: \begin{equation} p(x | \theta) = \prod_{i} p(x_i | (x_0, \ldots, x_{i - 1}), \theta). \end{equation} For the generalized likelihood ratio test~\cite{neyman1933ix}, if we calculated both likelihood estimates $p(x | \theta_{\textrm{non-dga}})$ and $p(x | \theta_{\textrm{dga}})$, we could then set a threshold $\eta$ and compute \begin{equation} \Lambda(x) = \frac{p(x | \theta_{\textrm{dga}})}{p(x | \theta_{\textrm{non-dga}})}, \end{equation} \noindent and if $\eta > \Lambda(x)$, we classify the point as a DGA domain; otherwise, we classify the point as non-DGA. The value of $\eta$ can be swept in order to control the false positive and true positive rate. $\eta$ is directly related to the typical posterior probability of a classifier; in fact, if we normalize the likelihood estimates we can produce a posterior probability of $x$ being a DGA domain: \begin{equation} p(\theta_{\textrm{dga}} | x) = \frac{p(x | \theta_{\textrm{dga}})}{p(x | \theta_{\textrm{non-dga}}) + p(x | \theta_{\textrm{dga}})}. \end{equation} Then, setting a threshold for $p(\theta_{\textrm{dga}})$ is reducible to setting a GLRT threshold $\eta$. For our DGA classifier, we build two separate RNN-GLRT models as described above: one on the {\it subdomains} of our training set, and one on the {\it domains}. Each of these two models, in turn, contains a separately-trained LSTM RNN, whose outputs are combined to perform the GLRT as shown above. As input to the logistic regression model, we extract six features from each RNN-GLRT model, giving a total of twelve features. The features are listed below. \begin{itemize} \itemsep 5pt \item A boolean feature indicating whether a domain or subdomain could be extracted from the input domain $x$. \item The likelihood estimate $p(x | \theta_{\mathrm{non-dga}})$. \item The likelihood estimate $p(x | \theta_{\mathrm{dga}})$. \item The posterior probability $p(\theta_{\mathrm{non-dga}} | x)$. \item The posterior probability $p(\theta_{\mathrm{dga}} | x)$. \item The likelihood ratio $\Lambda(x)$. \end{itemize} Since we are extracting the likelihood estimates and posterior probabilities into a logistic regression model, we actually have no need to select a threshold $\eta$---that is only needed for a standalone GLRT LSTM model. Instead, in our combined model, the logistic regression will learn directly from the probabilities and likelihoods. \vspace*{-0.4em} \subsection{Top-level domain features} Since TLDs are so short (usually two or three characters), it is excessive to train an RNN on them. Therefore, we use a one-hot encoding of the TLD, matching against the 249 most frequent TLDs in our training dataset; if there is no match, the TLD is encoded as `other', giving a total of 250 binary features out of the TLD. In order to perform the conversion, we used the TLD list available from \url{http://publicsuffix.org}. The most common TLDs in our dataset were {\tt .com}, {\tt .org}, {\tt .ru}, {\tt .net}, and {\tt .info}. We found that the {\tt .ru}, {\tt .info}, {\tt .biz}, and {\tt .cc} TLDs contained significantly higher concentrations of DGA domains, with each of those TLDs containing at least 3 times as many DGA as non-DGA domains. Since we have split these into separate features, we can expect our model to learn which TLDs domain generation algorithms are more likely to use. \vspace*{-0.4em} \subsection{WHOIS side information} The WHOIS data makes up the rest of the input to the logistic regression model. It is concatenated with the RNN-GLRT features for the domain, the RNN-GLRT features for the subdomain, and the one-hot encoded TLD features. Before all of these features are fed into the logistic regression model, we perform whitening via PCA for decorrelation and scaling~\cite{kessy2015optimal}. This step can improve the performance of the model, although it generally also makes interpretability more difficult. \vspace*{-0.4em} \subsection{Computational concerns} Recurrent neural networks, especially those with complex memory cells like LSTMs, are well-known to be time-consuming to train~\cite{li2015fpga, doetsch2014fast}. Our model is not exempt from this; for large datasets, it may take many hours to train\footnote{Our training was conducted on a high-end consumer-grade system with a single GPU.}. However, in practice this is not a concern---a single forward pass through the model for classification is comparatively very fast, and once our model is trained, there are no computational difficulties with deployment in a low-latency detection system. This means that the model can be, e.g., deployed into a consumer endpoint security product without problems. \section{Acknowledgements} \bibliographystyle{ACM-Reference-Format} \section{Related Work} The problem of distinguishing legitimate domain names from algorithmically generated is certainly not new, and has been studied for a number of years. DGAs first became widely known to the community with the introduction of Kraken \cite{kraken09} and Conficker \cite{conficker2009} in 2008. Since that time, DGAs in malware have proliferated. The early efforts to stop this threat were dealing with lack of sufficient training data to apply machine learning approaches~\cite{avivbotnet11}. One decade later it continues to be a problem but to a smaller extent. Thus early proposed approaches and techniques were rather statistical. For example Yadav et al.~\cite{domainflux12} applied such technique to show differences between valid domain names and algorithmically generated ones. The limitation of such approach would be that it often does not transfer to a different DGA family. Another milestone in detection techniques was credited to more extensive usage of DNS data. For example Zhou et al.~\cite{Zhou2013DGABasedBD} gathered DNS NXDOMAIN data from RDNSs and then used it to assemble a set of suspicious algorithmically generated domain names. A different approach was proposed by Jian et al.~\cite{dnsgraph10}. It relied on DNS traffic analysis but only for failed lookups. In this technique interactions between hosts and failed domain names would be extracted. Then a graph decomposition algorithm using nonnegative matrix tri-factorization technique to iteratively extract coherent co-clusters would be applied. The obtained sub-graphs would be further analyzed by exploring temporal properties of generated clusters. The authors claim that their anomaly based approach can detect new and previously undiscovered threats. Further research efforts evolved towards more and more extensive usage of machine learning techniques. At a large scale, it was pioneered by Phoenix~\cite{phoenix14} that was able to use both the URLs and other side information to detect DGA botnets. The list of parameters observed by this system includes some handcrafted features like pronounceability, blacklist information, DNS query information. This approach does not use any recurrent neural network (RNN) or powerful modeling technique for the domains themselves leaving a room for improvement. Tong and Nguyen \cite{semanticdga16} have already proposed extensions to the Phoenix system. They included additional measures such as entropy, n-grams and modified distance metric for domain classification. Further progress in DGA detection was reported when using machine learning techniques. For example, Zhao et al.~\cite{aptdns15} addressed the problem in the context of detecting APT malware. The authors proposed 14 features based on their big data research to characterize different properties of malware-related DNS and the ways that they are queried as well as defined network traffic features that can identify the traffic of compromised clients that have remotely been controlled. The features are comprised of signature-based engine, anomaly-based engine and so-called dynamic DNS features. The data was filtered by using Alexa\footnote{See \url{https://www.alexa.com/topsites}.} popularity and prevalence based on the number of hosts connecting to domains. As the outcome, an engine was built and it was used to compute reputation scores for IP addresses using extracted features vectors. The results are produced by using the J48 decision tree algorithm. A comparable approach was presented by Luo et al.~\cite{dgasensor17} who described a system using lexical patterns that were extracted from clean domains listed in the Alexa top 100k domains as well as confirmed malicious DGA cases. The proposed approach is machine learning-based and achieves 93\% accuracy for detecting malicious domains on the test dataset. Additional improvements for state of the art results were reported by Woodbridge et al.~\cite{woodbridge2016predicting}. Despite a relatively simple Long Short-Term Memory (LSTM) network used to classify DGA domains, the approach was reported to have a high level of effectiveness. The presented results still have certain shortcomings, especially for difficult DGA classes that resemble English words. The same problem was approached from a different angle by Anderson et al.~\cite{deepdga16}. The authors use a Generative Adversarial Network (GAN) to generate adversarial DGA domain names to try and deceive a classifier. The authors were able to achieve this goal. Then the GAN-generated domain names were added to the training set, which resulted in improved DGA detection performance. However, the authors did not test on any DGA families that look like they are made up of English words. Shibahara et al.~\cite{Shibahara2016EfficientDM} proposed a slightly different algorithm that is using RNN on changes in network communication with a goal of reducing malware analysis time. This approach is not DGA-only specific but rather generic and attempts to cover other types of malware. However, it could successfully be used against DGA-type of threats based on their communication patterns. Thus this technique requires additional run-time data that is not required in many of the other approaches as it requires malware sandboxing. The authors claim that without their optimization the analysis time takes over 15 min. and their approach reduces this time by 67\%, preserving the detection rate of malicious URLs at 97.9\%. Overall, though the task of DGA detection is certainly not new, there has not been much focus on directly detecting DGA families made from English words using the domain itself as a feature. This task has been described as `extremely difficult' in some previous works \cite{woodbridge2016predicting}. Here, our focus is specifically on those DGA families. \section{Side Information} \label{sec:side} DGA families with a high average smashword score $\hat{s}(\cdot)$ are very hard to classify based on the domain names alone. In fact, human analysts may even have a difficult time differentiating---for instance, it is plausible at first glance that {\tt darkhope.net} might be a personal website for a 1990s-era teenaged computer enthusiast. In reality, that domain name is generated by the {\tt suppobox} DGA. Thus, we cannot hope to build an effective classification system using single domain names alone. Therefore, we augment our domain names with {\it side information}, which we collect from the WHOIS database \cite{rfc3912}. Specifically, given a domain name, we perform a WHOIS lookup, and extract the following numeric or Boolean features: \medskip \begin{itemize} \item {\tt has\_registrarname}: Boolean, indicates whether a registrar name is available. \medskip \item {\tt has\_contactemail}: Boolean, indicates if any contact email is available. \medskip \item \texttt{days\_since\_created}, \texttt{days\_since\_updated}, \\ \texttt{days\_until\_expiration}: numeric, the number of days since the domain was created, updated, or until expiration \medskip \item {\tt status\_length}: numeric, length of the ``status'' field \medskip \item {\tt has\_registrant\_info}, {\tt has\_admincontact\_info}, \\ {\tt has\_billingcontact\_info}, {\tt has\_techcontact\_info}, \\ {\tt has\_zonecontact\_info}: Boolean, indicates whether contact information is available. \medskip \item {\tt has\_registrar\_iana\_id}: indicates whether a registrar IANA ID is given. \end{itemize} \medskip Note that for a non-registered domain name (NXDOMAIN), the boolean features will all be {\tt false}, and the numeric features will all be taken as 0. We do not perform any semantic analysis on the content of the WHOIS record; instead, we focus on those features most likely to give us information relevant to DGAs and C\&C servers: temporal information about the registration, and whether the domain itself is registered. The features we are using roughly match the type of features used by Ma et~al. \cite{ma2009beyond}. For our dataset, we used a snapshot of collected WHOIS data with 245M records. For our clean domain names, we matched 927k domains (91.7\%) to WHOIS data, and for the DGA domains, we matched only 2.3k domains (0.18\%) to WHOIS data. This is expected, given that most DGA domains are never registered. In practice, either a snapshot of WHOIS data (potentially updated nightly) or on-demand access of the WHOIS data could be used, depending on the scalability needs of the deployment. In our dataset, DGA families have an average of 3.5\% of their domains matched to WHOIS data; with the {\tt ramnit} family matching the highest percentage at 84\%, and the {\tt pandex} family matching the lowest nonzero percentage at 0.008\% (only 7 out of 91758 domains registered). 19 families, totaling 321k domains, have no domains matched to any WHOIS data. Although having matching WHOIS data for a domain is strongly correlated with whether or not the domain arises from a DGA, note that a detector built to classify a domain as malicious simply if there is no WHOIS data would not be very effective: with our data, it would achieve a true positive rate (TPR) of 96.5\%, but with an unacceptably high false positive rate (FPR) of 8.3\%. Though WHOIS data gives us good information, it is not sufficient for prediction. \subsection{WHOIS and GDPR} After the passing of the European privacy bill GDPR \cite{gdpr}, it is unclear how WHOIS lookups will be affected \cite{icann-gdpr}. At the time of our experiments, WHOIS data was still publicly available. However, if this is not the case in the future, it would be easy to find alternatives. Given that the important features we extract depend more on the temporal registration information than the contact details of the registrant, we could replace our WHOIS features with DNS tracking systems like Active DNS \cite{kountouras2016enabling} or the Alembic system \cite{lever2016domain}. At the time of this writing, it is not clear what the long-term solution for WHOIS data will be. But, since WHOIS data is widely used for security applications \cite{ma2009beyond, bilge2011exposure, canali2011prophiler}, it seems unlikely that the types of features we are using for our system will become unavailable.
{'timestamp': '2019-06-24T02:14:35', 'yymm': '1810', 'arxiv_id': '1810.02023', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02023'}
arxiv
\section{Introduction} In recent years, Deep Neural Networks (DNNs) embedded within a hybrid Hidden Markov model (HMM) framework have become the standard approach to Automatic Speech Recognition (ASR) tasks \cite{Hinton2012}. While the structure of such DNN models gives rich modelling capacity and yields good performance, it also creates complex dependencies between the parameters which can make learning difficult via first order Stochastic Gradient Descent (SGD) \begin{comment} Automated Speech Recognition(ASR) is an example of a sequence to sequence level classification task where given an acoustic waveform $\mathcal{O}$, the goal is to produce the correct hypotheses sequence $\mathcal{H}$. In machine learning, a classification problem is solved in two stages: an inference stage that attempts to capture the relationship between $\mathcal{O}$ and $\mathcal{H}$ through the use of an inference model $P_{\bm{\theta}}(\mathcal{H}|\mathcal{O})$, and a decision stage which uses decision theory to make optimal class assignments using the posterior probabilities. The advent of complex network architectures and GPU computing has made it possible to successfully apply Deep Neural Networks (DNNs) to solve the inference problem. In ASR, such models are applied either within hybrid Hidden Markov Models(HMMs) \cite{Hinton2012} or directly \cite{Rao,Bahdanau} to yield $P_{\bm{\theta}}(\mathcal{H}|\mathcal{O})$ . DNNs, due to their deep and complex structure, are better equipped to model the underlying nonlinear data manifold in contrast to GMMs. However, the existence of such structures also creates complex dependencies between the model parameters which can make such models difficult to train with standard Stochastic Gradient Descent (SGD). The task of finding the best procedure to train DNNs is an active area of research that has been rendered more challenging by the availability of ever larger datasets. It is therefore necessary to develop techniques that lead to rapid convergence and are also stable in training. While the deep and complex structure of such models afford rich modelling capacity, it also creates complex dependencies between the parameters which makes learning difficult via first order Stochastic Gradient Descent (SGD). \end{comment} Natural Gradient (NG) \cite{Amari1998a,Amari1997} descent is an optimisation method traditionally motivated from the perspective of information geometry, and works well for many applications \cite{Pascanu2013a,Desjardins2015,Povey2014} as an alternative to SGD. In our previous work \cite{Adnan2017}, it was shown how the method when framed in a Hessian Free (HF) styled \cite{Kingsbury2012,Martens2010} optimisation framework is more effective than either variants of SGD or HF for discriminative sequence training of hybrid HMM-DNN acoustic models. However, the efficacy of this form of NG training fails to extend to DNN models that utilise Rectified Linear Units (ReLUs) \cite{Vinod2010} This paper proposes NGHF, an alternative optimisation method that combines both the NG and HF approaches to effectively train HMM-DNN models with discriminative sequence criteria. The NGHF method uses both the direction of steepest descent on a probabilistic manifold and local curvature information, and is effective for different feed-forward DNN architectures and choices of activation function. The method is evaluated on the Multi-Genre Broadcast (MGB) transcription task \cite{Bell2015} and is shown to achieve larger reductions in the Word Error Rate (WER) for the same number of updates than both NG and HF, as well as lower WERs than SGD. The machinery needed to develop this framework relies on the concepts of manifolds, tangent vectors and directional derivatives from the perspective of information geometry. An overview of the necessary underlying concepts is provided in \cite{Adnan2018a} but a more in-depth discussion can be found in Amari's infomation geometry text book \cite{AmariBook}. The paper is organised as follows. Section \ref{sec:DT} provides a brief overview of discriminative sequence training and compares standard derivative based optimisers with NG. Section~\ref{sec:NGHF} formulates the method of NGHF, and Sec. \ref{sec:GN} discusses the effect of scaling directions with the Gaussian-Newton matrix. The experimental setup for ASR experiments is given in Sec. \ref{sec:ES}, with results in Sec.~\ref{sec:E}, followed by the conclusion. \section{Discriminative Sequence Training \label{sec:DT}} ASR is a sequence to sequence level classification task where given an acoustic waveform $\mathcal{O}$, the goal is to produce the correct hypothesis sequence $\mathcal{H}$ through the use of an inference model $P_{\bm{\theta}}(\mathcal{H}|\mathcal{O})$. Let ${X}$ denote the parameter manifold. As different realisations of DNN parameters lead to different probabilistic models $P_{\bm{\theta}}(\mathcal{H}|\mathcal{O})$, the manifold essentially captures the space of all probability distributions $\mathcal{M}$ that can be generated by a particular model. The goal of learning is to identify a viable candidate ${f}(\bm{\theta},\mathcal{O}) \in \mathcal{M}$ that achieves the greatest reduction in the empirical loss w.r.t a given risk measure while generalising well to new examples. In ASR, the WER is the evaluation metric of interest which however corresponds to a discontinuous function of the model parameters. Hence, employing such a metric directly within a empirical risk criterion is not viable with standard derivative based optimisers. This forms the motivation behind the class of Minimum Bayes' Risk (MBR) objective functions \cite{Povey2002,Gibson2006}: \vspace{-1mm} \begin{align} F_{\rm{MBR}} (\bm{\theta}) &= \frac{1}{R} \sum_r^R \left [ \sum_{\mathcal{H}} P_{\bm{\theta}}(\mathcal{H} |\mathcal{O}^r,\mathcal{M}) L( \mathcal{H},\mathcal{H}^r) \right] \end{align} where $(\mathcal{H}^r,\mathcal{O}^r)$ represents the true transcription and feature vectors associated with utterance $r$, and $L$ represents the loss function. In MBR training, instead of minimising the empirical loss for each utterance, the expected loss associated with each utterance in the training set is minimised. Such a function is a smooth function of the DNN model parameters and hence can be optimised by derivative based approaches. In practice, it is not feasible to consider the entire hypothesis space for each utterance without making simplifications to the HMM topology \cite{LMMI}. The standard approach is to encode confusable hypotheses for with each training utterance using an efficient lattice framework \cite{Woodland2002}. The premise behind all derivative based optimisation methods is Taylor's theorem. Assuming that the objective function $F(\bm{\theta})$ is sufficiently smooth, Taylor's formula including terms up to the second order approximates the local behaviour of the objective function by the following quadratic function: \vspace{-1mm} \begin{align} F(\bm{\theta}_k + \Delta \bm{\theta}) \simeq F(\bm{\theta}_k ) + \Delta \bm{\theta}^T \nabla F(\bm{\theta}_k )+ \frac{1}{2} \Delta \bm{\theta}^T H \Delta \bm{\theta} \label{TaylorTheorem} \end{align} where $ \Delta \bm{\theta}$ corresponds to any offset within a convex neighbourhood of $\bm{\theta}_k$ and $H$ is the Hessian. Instead of optimising the objective function directly, second order methods focus on minimising the approximate quadratic at each iteration of the optimisation process. The same approach is undertaken by first order methods which only consider the gradient $ \nabla F(\bm{\theta}_k )$, i.e. the first order term. For the class of MBR objective functions, the gradient associated with the $r$th utterance at time $t$ w.r.t the DNN output activations can be shown to be the component-wise multiplication of the vectors $\bm{\gamma}^r_t \odot \bm{L}$ \cite{DNNGrad,Matt,Adnan2017}, where $\bm{\gamma}^r_t$ represents the posterior probability associated with the states (DNN output nodes) at time $t$ and the entries of $\bm{L}$ correspond to the local phone(state) level loss associated with these arcs within the consolidated lattice \cite{Gibson2006}. Solving (\ref{TaylorTheorem}) yields the critical point $\Delta \bm{\theta} = H^{-1}\nabla F(\bm{\theta}_k )$. This corresponds to a unique minimiser only when the Hessian $H$ is positive definite. However, when the choice of models $\mathcal{M}$ is restricted to DNNs, the Hessian irrespective of the choice of objective function is no longer guaranteed to be positive definite. To address this issue, \cite{Sainath2013c} showed that by approximating the Hessian with the Gauss-Newton \cite{Schraudolph} matrix, solving (\ref{TaylorTheorem}) guarantees an improvement in the training objective function. When the underlying model corresponds to a discriminative probabilistic model $P_{\bm{\theta}}(\mathcal{H}|\mathcal{O})$, a more natural optimisation method is the method of NG. In NG, the updates associated with each iteration correspond to the direction of steepest decent on the probabilistic manifold. In \cite{Amari1998a,Amari1997,Bottou2016}, such a direction is shown to equate to the critical point of (\ref{TaylorTheorem}) with the Hessian replaced by the Fisher Information matrix \cite{AmariBook}. \section{ Formulating NGHF \label{sec:NGHF}} In \cite{Adnan2018a}, it is shown that by deriving Taylor's second order approximation from the perspective of manifold theory, solving the minimisation problem of (\ref{TaylorTheorem}) becomes equivalent to solving the following minimisation problem in the tangent space $T_{\bm{\theta}_k} X$: \vspace{-2mm} \begin{align} \argmin_{\Delta \bm{\theta} \in T_{\bm{\theta}_k} X} \left[ F(\bm{\theta}_k ) + \langle \Delta \bm{\theta}, \nabla F(\bm{\theta}_k ) \rangle + \frac{1}{2} \Delta \bm{\theta}^T H \Delta \bm{\theta} \right] \label{IHF} \end{align} With such an approach, $ \langle \Delta \bm{\theta}, \nabla F(\bm{\theta}_k ) \rangle$ corresponds to the inner product between vectors $\nabla F(\bm{\theta}_k)$ and $\Delta \bm{\theta}$ in $T_{\bm{\theta}_k} X$ while $ \Delta \bm{\theta}^T H \Delta \bm{\theta}$ represents a linear map $g : \bm{u} \in T_{\bm{\theta}_k} X \rightarrow \mathbb{R}$. Since ${X}$ is a manifold, the inner product endowed on the tangent space $T_{\bm{\theta}} X$ need not be the identity matrix. The parameter manifold $X$ can be equipped with any form of a Riemannian metric, a smooth map that assigns to each $\bm{\theta} \in X$ an inner product $I_{\bm{\theta}}$ in $T_{\bm{\theta}} X$. In our previous work \cite{Adnan2017}, it was shown how for sequence discriminative training, an ideal choice of $I_{\bm{\theta}}$ corresponds to the expectation of the outer product of the Maximum Mutual Information (MMI) \cite{Woodland2002} gradient: \vspace{-2mm} \begin{align*} I_{\bm{\theta}} &= E_{ P_{\bm{\theta}}(\mathcal{H}|\mathcal{O}) } \left [ \left( \nabla \mbox { log } P_{\bm{\theta}}(\mathcal{H}|\mathcal{O}) \right ) \left( \nabla \mbox { log } P_{\bm{\theta}}(\mathcal{H}|\mathcal{O}) \right )^T \right ] \end{align*} As $I_{\bm{\theta}}$ by definition is symmetric and positive definite, it is invertible by the {spectral decomposition theorem}. If the manifold $X$ is now equipped with a Riemannian metric of the form of $I_{\bm{\theta}}^{-1}$, then the dot product $\langle \Delta \bm{\theta}, \nabla F(\bm{\theta}_k ) \rangle$ in (\ref{IHF}) corresponds to $ \Delta \bm{\theta}^T I_{\bm{\theta}}^{-1} \nabla F(\bm{\theta}_k )$. Under such a metric, solving the minimising problem by considering only the first two terms in (\ref{IHF}) equates to performing Natural Gradient on the parameter surface. In this paper, the entire quadratic function of $(\ref{IHF})$ is considered when solving the minimisation problem in $T_{\bm{\theta}_k} X$ \vspace{-2mm} \begin{align} \argmin_{\Delta \bm{\theta} \in T_{\bm{\theta}_k} X} \left[ F(\bm{\theta}_k ) + \Delta \bm{\theta}^T I_{\bm{\theta}}^{-1} \nabla F(\bm{\theta}_k )+ \frac{1}{2} \Delta \bm{\theta}^T H \Delta \bm{\theta} \right] \label{FIHF} \end{align} In practice, the expectation of the outer product of the MMI gradient is approximated by its Monte-Carlo estimate $\hat{I}_{\bm{\theta}}$ which is not guaranteed to be positive definite. Thus, its inverse is no longer guaranteed to exist. To address this issue, \cite{Adnan2018a} provides the derivation of an alternative dampened Riemannian metric $ \tilde{I}_{\bm{\theta}}^{-1}$ that is not only guaranteed to be positive definite but has the feature that its image space is the direct sum of the image and the kernel space of the empirical Fisher matrix $\hat{I}_{\bm{\theta}}^{-1}$. The critical point of (\ref{FIHF}) is $ \Delta \bm{\theta} = H^{-1} {I}_{\bm{\theta}}^{-1} \nabla F(\bm{\theta}_k )$ and corresponds to an NG direction regularised by multiplication with the inverse of the curvature matrix. In this work, the Hessian is approximated by the Gauss-Newton (GN) Matrix $G_{\bm{\theta}}$. Section \ref{sec:GN} discusses the particular effect of scaling directions with $G_{\bm{\theta}}$. Computing the individual inverse matrix scalings directly is expensive in terms of both computation and storage. Hence in this paper, using the approach highlighted in \cite{Adnan2017,Kingsbury2012}, the solution of individual inverse matrix scalings is approximated by solving equivalent linear systems using the Conjugate Gradient (CG) \cite{Shewchuk1994b} algorithm. Apart from the obvious computational reasons, the use of CG presents two key advantages: the very first iteration of CG computes an appropriate step size for the direction the algorithm is initialised with. In the case of NGHF, this corresponds to the NG direction. Thus, at each iteration of NGHF, the resultant update found after two runs of CG conforms to $ \Delta \bm{\theta} = w_1 \Delta \bm{\theta}_{NG} + w_2 \Delta \bm{\theta}_{HF}$, a weighted combination of the NG direction and conjugate directions computed using local curvature information. Secondly, when applied to solve the proposed linear system $\tilde{I}_{\bm{\theta}} \Delta \bm{\theta} = \nabla F(\bm{\theta}_k )$, the very first directions explored by the algorithm are guaranteed to be the directions which constitute the image space of $\hat{I}_{\bm{\theta}}$ \cite{NocedalBook}. \section{Scaling Directions with the GN Matrix \label{sec:GN}} When DNN models are employed to solve the inference problem, $G_{\bm{\theta}}$ can be shown to take the particular form of $J_{\bm{\theta}} ^{T} \nabla^2 \hat{L}_{\bm{\theta}} J_{\bm{\theta}}$ where \begin{itemize} \item $\nabla^2 \hat{L}_{\bm{\theta}}$ is the Hessian of the loss function w.r.t the DNN linear output activations with individual entries being functions of $\bm{\theta}$. \item $J_{\bm{\theta}}$ is the Jacobian of the DNN output activations w.r.t $\bm{\theta}$. \end{itemize} To keep the notation uncluttered, the dependency on $\bm{\theta}$ will be dropped for the remainder of this section when dealing with the individual factors of the product $J_{\bm{\theta}} ^{T} \nabla^2 \hat{L}_{\bm{\theta}} J_{\bm{\theta}}$. As both $\nabla^2 \hat{L}$ and the product $J^{T} \nabla^2 \hat{L}J$ are real and symmetric, by the {spectral decomposition theorem}: $ J ^{T} \nabla^2 \hat{L} J \equiv J ^{T} U \Lambda U^T J \equiv V \Sigma V^T$. Under this factorisation, each eigenvector $\bm{v}_j$ of $J ^{T} \nabla^2 \hat{L} J$ can be interpreted as a particular weighted sum of the gradients of the output activations of the DNN w.r.t $\theta$. Switching from the standard basis to the basis spanned by $U^T J$, updates conforming to directions of steepest descent can be expressed as: \vspace{-2mm} \[ \Delta \theta = \sum_{j}^k \eta \left( \bm{v}_j^T\nabla F_{\rm{MBR}} \right) U_{j,i} \dfrac{\partial {\tilde{F}}_i}{\partial \theta}\] where $\eta$ is the learning rate and $\tilde F $ represents the objective function with the domain constrained to the DNN output layer. With respect to this basis, scaling with the inverse of the GN matrix effectively corresponds to rescaling the steps taken along individual $\bm{v}_j$ by a factor $1/{\mu_j}$: \vspace{-2mm} \begin{align} \Delta \theta = \sum_{j}^k \frac{1}{\mu_j} \left( \bm{v}_j^T\nabla F_{\rm{MBR}} \right) U_{j,i} \dfrac{\partial {\tilde{F}}_i}{\partial \theta} \end{align} where $\mu_j$ is the eigenvalue associated with $\bm{v}_j$ in $V$. Recall that $ \nabla^2 \hat{L} $ can alternatively be presented as $\nabla .( \nabla \tilde F)$. Therefore, eigenvectors $\bm{u}_j$ in $U$ with large eigenvalues correspond to directions that can induce large changes in the gradient of $\nabla \tilde F$. By establishing a one-to one correspondence between eigenvectors of $ \nabla^2 \hat{L} $ with eigenvectors of $J ^{T} A J$, it can be seen that re-scaling with $1/{\mu_j}$ effectively de-weights back propagation information carried by those paths through the network that can induce large changes in $\nabla \tilde F$. In the context of discriminative training, this ensures that the DNN frame posterior distribution does not become overly sharp. \section{Experimental Setup \label{sec:ES}} The various DNN optimisation approaches were evaluated on data from the 2015 Multi-Genre Broadcast ASRU challenge task (MGB1) \cite{Bell2015}. In this work, systems were trained using a 200 hour training set\footnote{Note that most results in \cite{Woodland2015} use a larger 700h training set, stronger language models and other setup differences.}. The official MGB1 dev.sub set was employed as a validation set and consists of 5.5 hours of audio data. To estimate the generalisation performance of candidate models, a separate evaluation test set dev.sub2 was used. This comprises roughly of 23 hours of audio from the remaining 35 shows belonging the MGB1 dev.full set. Further details related to the data preparation can be found in \cite{Woodland2015}. All experiments were conducted using an extended version of the HTK 3.5 toolkit \cite{Zhang2015,HTKBook15}. This paper focuses on training standard fully connected DNNs and Time Delay Neural Networks (TDNNs) \cite{Peddinti} using both ReLU and sigmoid activations. The architecture used for DNNs consisted of five hidden layers each with 1000 nodes. For TDNNs, the network topology consisted of seven hidden layers each with 1000 hidden units. The context specification used for the various TDNN layers is as follows: [-2, +2] for layer 1, $\{-1,2\} $ for layer 2, $ \{-3,3\}$ for layer 3, $ \{-7,2\} $ for layer 4 and [0] for the remaining layers. For both models, the output layer consisted of 6k nodes and corresponds to context dependent sub-phone targets formed by conventional decision tree context dependent state tying \cite{statetying}. For DNNs, the input to the model was produced by splicing together 40 dimensional log-Mel filter bank (FBK) features extended with their delta coefficients across 9 frames to give a 720 dimensional input per frame. While for TDNNs, only the 40 dimensional log-Mel filter bank features were considered. For all experiments, the input features were normalised at the utterance level for mean and at the show-segment level for variance \cite{Woodland2015}. All models were trained using lattice-based MPE training \cite{Povey2002}. Prior to sequence training, the model parameters were initialised using frame-level CE training. To track the occurrence of over-fitting due to training criterion mismatch at intermediate stages of sequence training, decoding was performed on the validation set using the same weak pruned biased LM used to create the initial MPE lattices. To evaluate the generalisation performance of the trained models, a 158k word vocabulary trigram LM was used to decode the validation and test set. \textbf{Training configuration for SGD}: The best results with SGD were achieved through annealing of the learning rates at subsequent epochs. The initial learning rates were found through a grid search. For TDNNs, using momentum was found to yield the best WERs. \textbf{Training configuration for NGHF, NG \& HF}: The recipe described in \cite{Adnan2017} was used: gradient batches corresponding to roughly 25 hours and 0.5 hrs of audio were sampled for each CG run. In all experiments, running each CG run beyond 8 iterations was not found to be advantageous. The CG computations varied between 18\% to 26\% of the total computational cost. \section{Experimental Results \label{sec:E}} \vspace*{-0.5em} Figure \ref{fig:DNN200} compares the performance of various optimisation methods on training a ReLU based 200hr HMM-DNN model while Table~\ref{tab:2} shows the performance of these optimisers for a ReLU based HMM-TDNN system. \begin{figure}[t] \vspace{-2em} \hspace*{-0.9cm}\includegraphics[scale=0.44]{Results3.eps} \vspace*{-3em} \centering \caption{ \label{fig:DNN200} Evolution of MPE phone accuracy criterion on the training and validation (dev.sub) sets with ReLU based DNN (top 2 graphs). Also (lower graph) WER with MPE LM on dev.sub as training proceeds.} \vspace*{-1.5em} \end{figure} \begin{table}[H] \tabcolsep=0.1cm \centering \begin{tabular}{|c|c|c|cc|c|c|} \hline method & \#epochs & \#updates &\multicolumn{2}{c|}{phone acc.} & WER with \\ & & & train & dev.sub &MPE LM \\ \hline CE & N/A & N/A & 0.870 & 0.754 & 36.9 \\ \hline\hline SGD & 4 & 4.64 $\times 10^5$ &0.888 &0.760 &36.4 \\ \hline \hline NG & 4& 32 & 0.913 & 0.789 &36.2 \\ \hline HF & 4 & 32 & 0.899 & 0.783 & 35.9 \\ \hline NGHF &4 & 32 & 0.911 & 0.791 & \textbf{35.6} \\ \hline \end{tabular} \caption{Performance of different optimisers on the TDNN-ReLU model. WERs on dev.sub.} \label{tab:2} \end{table} \vspace{-1.5em} It can be seen that among all the optimisers, NGHF is the most effective in achieving the largest WER reductions on dev.sub with the weak MPE LM. At each iteration, the update produced by the method conforms to $ \Delta \bm{\theta} = w_1 \Delta \bm{\theta}_{NG} + w_2 \Delta \bm{\theta}_{HF}$, a weighted combination of NG direction and conjugate directions computed using local curvature information. In Fig.~\ref{fig:DNN200}, it can be seen that by utilising information from both the KL divergence in the probabilistic manifold and local curvature information, the proposed method follows a path where optimising the MPE criterion better correlates with achieving reductions in WER. With the ReLU based TDNN as evident from Table~\ref{tab:2}, this same feature can be observed. NGHF achieves better generalisation performance for both the MPE criterion and the WER on the validation set. To investigate whether these WER reductions hold with stronger LMs and the relative gains are not constrained to only ReLU based systems, equivalent systems using sigmoids were trained. Table~\ref{tab:dev.sub} compares the performance of the various optimisers on the validation set with the different models using the 158k LM. \begin{table}[H] \tabcolsep=0.18cm \begin{tabular}{|c|c|c|c|c|c|} \hline Model & ~~CE~~ & \multicolumn{4}{c|}{MPE}\\ \hline & & SGD & NG & HF & NGHF\\ \hline DNN-ReLU & 30.9 & 29.9 & 29.8 & 28.9 &\textbf {28.1} \\ TDNN-ReLU & 28.6 & 28.5 & 28.7 & 28.1 &\textbf{27.5}\\ \hline DNN-sigmoid & 31.9 & 29.3 &29.0 & 29.3 &\textbf{29.0} \\ TDNN-sigmoid & 28.5 & 27.1 & 26.9 & 27.0 & \textbf{26.6 } \\ \hline \end{tabular} \centering \caption{ \label{tab:dev.sub}WERs on MGB1 dev.sub with 158k trigram LM.} \end{table} \vspace{-1.5em} From Table~\ref{tab:dev.sub}, it can be seen that again models using NGHF achieve the largest reductions in WER. For ReLU based models, NGHF achieves a relative Word Error Rate Reduction (WERR) of 9\% with the DNN and 4\% with the TDNN. Whereas with the sigmoid based models, the method achieves a relative WERR of 6\% with the DNN and 7\% with the TDNN. Compared to SGD, NGHF is especially effective with the ReLU based models. For the DNN, the method achieves a relative WERR of 6\% over SGD, while with the TDNN the relative WERR is 4\%. Finally, the generalisation performance of the trained models were estimated by performing Viterbi decoding on dev.sub2 using 158k LM. Results are shown in Table~\ref{tab:gen}. \begin{table}[H] \begin{tabular}{|c|c|c|c|c|c|} \hline Model & CE & \multicolumn{4}{c|}{MPE }\\ \hline & & SGD & NG & HF & NGHF\\ \hline DNN-ReLU & 32.3 & 31.9 & 31.4 & 30.6 & \textbf{29.8} \\ TDNN-ReLU & 30.6 & 29.8 & 30.6 & 29.6 & \textbf{29.3} \\ \hline DNN-sigmoid & 33.2 & 30.8 & 30.5 & 30.9 &\textbf{30.5} \\ TDNN-sigmoid & 29.9 & 28.6 &28.2&28.4 & \textbf{27.9} \\ \hline \end{tabular} \centering \caption{ WERs on MGB1 dev.sub2 with 158k trigram LM. } \label{tab:gen} \end{table} \vspace{-1.5em} It can be observed that as before the model trained with NGHF achieves the largest reductions in WER. With sigmoid based models, the method can be seen to be achieve WERR reductions of 8\% with the DNN and 7\% with the TDNN. Over standard SGD, the proposed method achieves relative WERR of 7\% with the ReLU-DNN model and a 2\% with the ReLU based TDNN model. \subsection{Investigating overfitting due to Criterion Mismatch} ReLU based systems failed to achieve similar WERRs as sigmoid based systems from sequence training with either SGD or NG. After a few epochs, improvements made on the MPE criterion failed to correlate with lower WERs. This effect was particularly noticeable with the TDNN model. It was observed that this emergence of criterion mismatch is correlated with the sharp decrease in the average entropy of DNN output frame posteriors (Fig.~\ref{fig:entropy}). MBR training broadly speaking tries to concentrate probability mass: a sufficiently flexible model trained to convergence with MBR will assign a high probability to those hypotheses that have the smallest loss. This means that during the course of training, the posterior distribution of states $\bm{\gamma}^r_t(i)$ associated with high local losses $\bm{L}(i)$ is gradually reduced. With hyper-parameters such as LM and acoustic model scale factors fixed, this sharp decrease in the DNN output entropy directly reflects that this distribution $\bm{\gamma}^r_t$ is becoming overly sharp, which was found to be detrimental to the decoding performance. With sigmoid models, the criterion mismatch was found to be less severe when using first order methods (Table~\ref{tab:dev.sub}). It was observed that the average entropy of the DNN frame posteriors with sigmoid models was much larger at the start of sequence training. This is expected as ReLUs allow a better flow of gradients during back-propagation resulting in better CE trained discriminative models. However, as observed in Fig.~\ref{fig:entropy}, this also results in sharper frame posterior distributions. From Fig.~\ref{fig:entropy}, it can also be seen how scaling with the GN matrix helps regularise the entropy of the DNN frame posteriors. When compared to HF, the proposed NGHF approach is better in finding a balance between improving the MPE criterion and regularising the entropy changes of the DNN frame posteriors. To improve generalisation performance, techniques such as dropout \cite{Srivastava} and L2 regularisation with SGD sequence training were investigated. However, both of these techniques were unsuccessful in alleviating this overfitting due to criterion mismatch. To improve NG training, the use of Tikhonov damping as advised by Martens \cite{Martens2010} was also investigated to help regularise the NG updates. Taking comparatively more conservative steps along conjugate directions at the expense of slower learning was observed to regulate the decrease in the average entropy of DNN frame posteriors. However, the damped optimiser failed to achieve better convergence. \begin{figure}[t] \hspace*{-0.6cm}\includegraphics[scale=0.37]{EvolutionofEntropy.eps} \vspace*{-1.5em} \centering \caption{ Evolution of average entropy of DNN output activations during MPE training with ReLU based DNN models. Left graph is for DNNs and the right graph for TDNNs.} \label{fig:entropy} \vspace*{-1.5em} \end{figure} \section{Conclusion} This paper has introduced a new optimisation method to effectively train HMM-DNN models with discriminative sequence training. The efficacy of the method has been shown to be agnostic with respect to both the choice of feed forward architecture and choice of DNN activation functions. When applied within a HF styled optimisation framework, the proposed methods enjoys the same benefits as HF but leads to better convergence than NG, HF and SGD. Future work will involve extending the proposed framework to training DNN architectures with recurrent topologies. \bibliographystyle{IEEEtran}
{'timestamp': '2018-10-05T02:00:18', 'yymm': '1810', 'arxiv_id': '1810.01873', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01873'}
arxiv
\section{Introduction} \label{secIntroduction} Simulation software is widely used in a variety of applications. We mention two representative applications. Power transmission systems are simulated to shed light on problematic situations and how to deal with them in practice \parencites{surmann_modelling_2014}{surmann_predicting_2017}. Machine engineers check the behaviour of a new aircraft wing within simulation software before building it in reality. In most of such complex simulations the application is tested by applying empirical test scenarios. One possible scenario in a power network is a line fault in combination with an increased power consumption. Does the transmission system handle this situation? The aircraft wing is bent by a specific angle and checked for cracks after the test. After passing different test scenarios successfully the application is deemed to be safe regarding all possible influences. However, all of these test scenarios have different points in common. Firstly, they are designed in a manual fashion. Secondly, every test scenario should reflect a challenging situation. Thirdly, the amount of test scenarios for an application should cover almost all possible situations. Finally, a simulation run is expensive in the majority of cases. Our goal is a quality improvement of test scenarios to generate diverse test data each representing a challenged situation for an application. Due to the fact, that a simulation is expensive in its execution, we use the efficient global optimisation (EGO) approach proposed by \textcite{jones_efficient_1998}. EGO is based on a measured response from a black box function with the objective to find its global optimum. An exemplary response in a transmission system could be the simulated time until the simulation of a power network fails. In the aircraft wing example we can use the number of cracks or their averaged length. Multi-objective model-based optimisation \parencite{bischl_moimbo_2014} covers multiple responses. EGO and model-based optimisation (MBO) mainly focus on global optimisation. \Textcite{bischl_mlrmbo_2017} give an overview of state of the art techniques regarding multi-objective MBO using parallel computing. An additional criterion for multi-objective optimisation is given by \textcite{bischl_moimbo_2014}. The topic at hand obtains a set of good solutions in contrast to a single global optimum. \Textcite{wessing_true_2017} discussed the search for multiple optima instead of a global one. By using all samples from EGO rating them via topographical selection \parencite{torn_topographical_1992} the approach is capable to identify different optima. In a computer experiment with twelve artificial test problems \textcite{wessing_true_2017} work out the differences between four algorithms. The paper at hand aims to improve the efficient search of multiple optima in expensive functions. For the sake of simplicity the focus is on local minima which can be switched to local maxima by inverting the corresponding function. \Cref{secMethods} describes the used methods, especially \cref{subsecMethodsGEILM} provides a new infill criterion which aims to identify local minima. We focus to find all minima of the corresponding function. In the identification process minima with lower function values are more interesting than those with higher values. The criterion is checked in \cref{secExperiment} via fifteen different test functions in a computer experiment. To rate the results, we work out all local minima of the artificial test functions and list them in \cref{secAppMinima}. \Cref{secConclusion} summarises the paper in a conclusion. \section{Methods} \label{secMethods} This section describes the general MBO algorithm and one of its representatives, EGO, in \cref{subsecMethodsMBO}. We introduce an infill criterion to identify local minima in \cref{subsecMethodsGEILM}. The identification of local minima within the corresponding surrogate function is described in \cref{subsecMethodsIdentifyMinima}. Rating the solutions of the different algorithms is specified in \cref{subsecMethodsRateSolutions}. \subsection{Model-Based Optimisation} \label{subsecMethodsMBO} Let $f:\mathcal{X}\rightarrow\mathbb{R}$ be an arbitrary deterministic objective function with a $p$-dimensional numeric input domain $\mathcal{X}=\left[\boldsymbol{l},\boldsymbol{u}\right]\subset\mathbb{R}^p$. The vectors $\boldsymbol{l}=\left(l_1, \dotsc, l_d\right)^\top$ and $\boldsymbol{u}=\left(u_1, \dotsc, u_d\right)^\top$ are the lower and upper bounds of $\mathcal{X}$, respectively. The neighbourhood of a point $\boldsymbol{x}^\star\in\mathcal{X}$ is defined by $N(\boldsymbol{x}^\star)=\left\lbrace \boldsymbol{x}\in\mathcal{X}|d\left(\boldsymbol{x}, \boldsymbol{x}^\star\right)\leq\epsilon\right\rbrace$ with $\epsilon>0$ and a metric $d:\mathcal{X}\times\mathcal{X}\rightarrow\mathbb{R}^+$. $f\left(\boldsymbol{x}^\star\right)$ is a local minimum if $\exists\epsilon>0\colon\nexists\boldsymbol{x}\in N\left(\boldsymbol{x}^\star\right)\colon f\left(x\right)<f\left(\boldsymbol{x}^\star\right)$. As described by \textcite{wessing_true_2017} this definition ensures the global minimum to be a local minimum, even if it includes all plateaus. All local minima are summarised in the solution set $S=\left\lbrace\boldsymbol{x}\in\mathcal{X}|f\left(\boldsymbol{x}\right)=f\left(x_i^\star\right)\right\rbrace$ where $f\left(\boldsymbol{x}_i^\star\right)$ are the $i=1,\dotsc,h$ local minima of the objective of the test function. For the sake of simplicity, we are interested in all local minima of the given test function. A definition to restrict the number of minima to a given value can be found in \textcite[sec. 2]{wessing_true_2017} as well as some brief ideas on additional constraints for the solution set. Model-based optimisation (MBO) is usually used in an environment where $f$ is expensive to evaluate, hence only a limited number of function evaluations is allowed. In every iteration $f$ is approximated via a much cheaper to evaluate surrogate model (or meta-model) $\hat{f}$. The general MBO approach is outlined in the following list and is described in depth by \textcite{bischl_mlrmbo_2017}. \begin{enumerate} \item Generate an initial design $D\subset\mathcal{X}$ (usually Latin Hypercube Desgin \parencite{mckay_comparison_1979}) and calculate $\boldsymbol{y}=f(D)$. \item The sequential phase starts fitting a surrogate model to the evaluated points $D$ and the corresponding values $\boldsymbol{y}$. \item Get additional point $\boldsymbol{x}'$ proposed by infill criterion (see \cref{subsecMethodsGEILM}). The criterion works on $\hat{f}$ and determine points which are promising for optimisation. \item Evaluate $\boldsymbol{x}'$ to $y'$ using $f$ and extend $D$ and $\boldsymbol{y}$, respectively. \item If no termination criteria are met (number of evaluations, etc.) go to step 2. \item Return $\hat{y}^\star=\min(\boldsymbol{y})$ and corresponding $\hat{\boldsymbol{x}}^\star$ as proposed global optimum for $f$. \end{enumerate} Step 2 of the MBO approach fits a surrogate model as a cheaper to evaluate function to the current design $D$ with respect to the evaluations $\boldsymbol{y}$. The model choice has a main effect on the approximation of the objective function. Because $\mathcal{X}\subset\mathbb{R}^d$ \textsc{Kriging} \parencites{jones_efficient_1998}{williams_gaussian_2006} is recommended and provides a direct estimation of the prediction standard error, or local uncertainty measure, next to the estimation of the true function value $f(\boldsymbol{x})$. For instance, EGO is a well known \textsc{Kriging} based approach. \subsection{Gradient Enhanced Inspection of Local Minima} \label{subsecMethodsGEILM} The infill criterion is another essential part of MBO. It leads the optimisation to handle the trade-off between exploitation and exploration by using a combination of different statistics from the surrogate model $\hat{f}$. In most situations the estimators $\mnsm$ and $\sdsm$, estimated by $\hat{f}$ are used in a single formula to handle the trade-off in a well-balanced manner. \Textcite{jones_efficient_1998} proposed the expected improvement $\EI(\boldsymbol{x})$ as infill criterion, which is the most popular criterion and widely used. It is defined as $\EI(\boldsymbol{x})\coloneqq\E\left(\max\left\lbrace\hat{y}^\star-Y(\boldsymbol{x}), 0\right\rbrace\right)$, where $Y(\boldsymbol{x})$ is a random variable that expresses the posterior distribution at $\boldsymbol{x}$, estimated via the surrogate model $\hat{f}$. Using a \textsc{Kriging} model $Y(\boldsymbol{x})$ is normally distributed with $Y(\boldsymbol{x})\sim\mathcal{N}\left(\mnsm,\hat{s}^2(\boldsymbol{x})\right)$. Using this assumption, $\EI(\boldsymbol{x})$ can be expressed as \begin{align} \label{eqnMethodsEI} \EI(\boldsymbol{x}) &= \left(\hat{y}^\star-\mnsm\right) \Phi\left(\frac{\hat{y}^\star-\mnsm}{\sdsm}\right)+ \sdsm\phi\left(\frac{\hat{y}^\star-\mnsm}{\sdsm}\right) \end{align} where $\phi$ and $\Phi$ are the density and distribution function of the standard normal distribution, respectively. In the first addend the difference between the current minimum $\hat{y}^\star$ and the local estimator $\mnsm$ is rated high for lower values of $\mnsm$. Its corresponding standard deviation $\sdsm$ is rated high for its higher values. Hence, the expected improvement leads us to points with low $\mnsm$ and high $\sdsm$. Simpler approaches to compound $\mnsm$ and $\sdsm$ for a point $\boldsymbol{x}$ are given by the lower confidence bound ($\operatorname{LCB}(\boldsymbol{x})$) or the standard error ($\operatorname{SE}(\boldsymbol{x})$) itself in \cref{eqnMethodsSimpleInfill}, where $\lambda>0$ is a constant to control the trade-off between both estimators in \cref{eqnMethodsLCB}. \begin{subequations} \label{eqnMethodsSimpleInfill} \begin{align} \label{eqnMethodsLCB} \operatorname{LCB}(\boldsymbol{x};\lambda) &= \mnsm - \lambda\sdsm\\ \label{eqnMethodsSE} \operatorname{SE}(\boldsymbol{x}) &= \sdsm \end{align} \end{subequations} The infill criterion $\operatorname{SE}(\boldsymbol{x})$ in \cref{eqnMethodsSE} handles the trade-off by shifting the whole weight to exploration. It will try to cover the design space of the objective function equally, to reduce the local standard error. Our purpose to inspect local minima yields a modified form of $\EI(\boldsymbol{x})$ and $\operatorname{SE}(\boldsymbol{x})$. We search for meaningful test scenarios to challenge the corresponding application. This usually results in lower values of the response function compared to non-challenging test scenarios. A meaningful test scenario is translated into the model-based optimisation as a local minimum whose function value is near to the global minimum. The slope at a point between two local minima has to be significantly different from \num{0}, otherwise it is a plateau which is considered as one minimum. Hence, we enhance the new infill criterion to skip exploration in regions with a steep surrogate function. The gradient enhanced inspection of local minima $\GEILM(\boldsymbol{x})$, as new infill criterion, is defined by \begin{align} \label{eqnMethodsGEILM} \GEILM(\boldsymbol{x}) &= \sdsm\Phi\left(\frac{\hat{y}^\star-\mnsm}{s_\mathrm{p}}\right) g_\lambda\left(\left\lVert\nabla\mnsm\right\rVert_{\infty}\right) \end{align} with \begin{align} \label{eqnMethodsSEquant} s_\mathrm{p} &= \min\left\lbrace s\in\mathbb{R}^+\middle| \frac{\hat{y}^\star-\max(\boldsymbol{y})}{s}=\Phi^{-1}(p) \right\rbrace \end{align} where $\Phi$ is the distribution function of the standard normal distribution. $g_\lambda$ is the density of the exponential distribution with parameter $\lambda$. $\lVert\cdot\rVert_{\infty}$ describes the supremum norm of $\cdot$ and is called maximum norm in case of a vector $\boldsymbol{a}=\left(a_1,\dotsc,a_n\right)^\top$. In this case it takes the form $\lVert\boldsymbol{a}\rVert_{\infty}=\max\left\lbrace\lvert a_1\rvert,\dotsc,\lvert a_n\rvert\right\rbrace$. The differential operator, or nabla operator, $\nabla$ is defined in terms of partial derivative operators and denotes the gradient of a scalar field. We choose $\operatorname{SE}(\boldsymbol{x})$ with its explorative nature as a starting point and use the multiplication operator to implement a weighting on $\operatorname{SE}(\boldsymbol{x})$. Summing up the coefficients is only meaningful for infill criteria which deal with $\mnsm$ directly and do not cover $\mnsm$ in a function, as shown in \cref{eqnMethodsEI,eqnMethodsLCB}, because $\mnsm$ is related to exploitation whereas $\sdsm$ is related to exploration. The weighting via $\Phi$ is reused from $\EI(\boldsymbol{x})$ to add a connection to the expected function value $\mnsm$. $\Phi$ weights down $\mnsm$ the more it differs from the current minimum $\hat{y}^\star$ which reflects the higher interest in local minima with lower function values. We adjust the standardisation via a $p$-quantile standard deviation $s_p$ with $p\in(0,1)$. $s_p$ is driven by the range of evaluated design points and independent of $\sdsm$. This approach supports $\GEILM(\boldsymbol{x})$ exploring the design space with higher expected values $\mnsm$ with a lower priority. Due to the fact that a gradient at a point between two optima is significantly different from \num{0} we add a second weighting via the exponential distribution $g_\lambda$. It considers the maximum partial derivative to ensure the highest weighting for local optima. Design points outside local optima (or plateaus) get lower priority which further enhances $\GEILM(\boldsymbol{x})$ to use the available number of runs in promising regions. Two exemplary design points illustrate the behaviour of $\GEILM$. In the global minimum $\hat{y}^\star$ the total weight on $\sdsm$ evaluates to its maximum of $\frac{1}{2}\lambda$. In this case $\Phi$ evaluates to $\frac{1}{2}$ and $g_\lambda$ to $\lambda$ because the gradient in an optimum is \num{0}. Hence, $\GEILM(\boldsymbol{x})$ evaluates to $\frac{1}{2}\lambda\sdsm$ for the global minimum. If we assume an example point which is not a local minimum, with a high value of the local estimator compared to the global minimum, $\GEILM(\boldsymbol{x})$ converges to \num{0}. The function $\Phi$ converges to \num{0} for higher values of $\mnsm$. The function $g_\lambda$ converges to \num{0} for increasing absolute values of the gradient. If the surrogate function is unexplored at this point $\sdsm$ uprates the infill criterion $\GEILM(\boldsymbol{x})$. \subsection{Identify Local Minima of Surrogate Function} \label{subsecMethodsIdentifyMinima} Identifying the local minima after performing the model-based optimisation is done via topographical selection \parencite{torn_topographical_1992} by \textcite{wessing_true_2017}. We follow a different approach and instead use the surrogate function of evaluated points from the objective function to identify the local minima. This method has the advantage to detect minima in areas with lower exploitation. However, the surrogate function can estimate the objective function inaccurately. To identify the local minima, we draw a Latin Hypercube Sample \parencite{stein_large_1987} $U^\star\subset\mathcal{X}$ of size $n=200^{\log_{3}\left(p+3-1\right)}$ according to the number of dimensions $p$. The formula for $n$ is defined empirically to balance the expected workload and required points covering the input domain $\mathcal{X}$ in \cref{subsecMethodsMBO}. We apply the quasi-\textsc{Newton} algorithm with box constraints (L-BFGS-B) defined by \textcite{byrd_limited_1995} and described by \textcite{nocedal_numerical_2006} to all points $\boldsymbol{x}\in U^\star$. This gradient descent algorithm moves each point $\boldsymbol{x}$ to its next local minimum $\boldsymbol{x}_i^\star$ of the surrogate function $\hat{f}$ with $i=1,\dotsc,k$ local minima. We skip all points in $U^\star$ which moved to the limits of $\mathcal{X}$ assuming the local minima of the objective function within the input domain. The approximation set $U$ is defined by agglomerations near the representatives in $U^\star$ via \begin{align} \label{eqnMethodsApproxSet} U=\left\lbrace\boldsymbol{x}\in\mathcal{X}\vert d_{\mathrm{Che}}\left(\boldsymbol{x},U^\star\right)\leq\delta\right\rbrace \end{align} with $\delta>0$. The function $d_{\mathrm{Che}}\left(\boldsymbol{x},U^\star\right)$ denotes the Chebyshev distance \parencite{abello_handbook_2002} of a point $\boldsymbol{x}$ to its nearest neighbour in $U^\star$. Different approaches to identify multiple optima were applied in the field of multimodal optimisation. \Textcite{gudla_automated_2005} proposed a hybrid between genetic and gradient algorithms. Evolutionary algorithms are used by \textcite{deb_finding_2010} in a concept of multi-objective optimisation to solve a single-objective problem. \Textcite{stoean_multimodal_2010} combine their genetic algorithm with a topological separation of subpopulations and apply the approach to different test functions. A hybrid of \textsc{Nelder}-\textsc{Mead} algorithm and gradient descent method is applied by \textcite{abbas_method_2018} to signal processing. Our approach spreading points in the input domain via a Latin Hypercube Sample and move them to their nearest local minima is simple and empowers us to calculate large samples. Further research will show if more complex algorithms identify local optima considerably faster. \subsection{Rate Solution Set} \label{subsecMethodsRateSolutions} Global optimisation uses the deviation from the global optimum as a performance measure. In multimodal optimisation we use the number of found local minima $l=\left\lvert U\right\rvert$ divided by the correct number of optima $\left\lvert S\right\rvert=h$ as peak ratio $\PR(U)=\frac{l}{h}$. Because the surrogate function is used to identify the local minima we define the peak ratio different than \textcite{ursem_multinational_1999}. They choose the set of local minima $S$ as a reference set to check if each minimum is met by a point in the final design $D$. We deal with $\mathcal{X}$ to identify the agglomerated number of found optima in $U^\star$. Hence, $\PR(U)\in\left(0,\infty\right)$ which reveals improper fits of the surrogate functions for high values of $\PR$. Another measure is the averaged \textsc{Hausdorff} distance ($\AHD$) described by \textcites{hausdorff_mengenlehre_1927}{rockafellar_variational_2004}. It is defined by \begin{align} \label{eqnMethodsAHD} \AHD(U)=\max\left\lbrace \left(\frac{1}{l}\sum_{i=1}^{l}d_\mathrm{nn}(\boldsymbol{x}_i, U)^r\right)^\frac{1}{r}, \left(\frac{1}{h}\sum_{i=1}^{h}d_\mathrm{nn}(\boldsymbol{x}_i^\star, S)^r\right)^\frac{1}{r} \right\rbrace \end{align} using $S$ as a reference set. The function $d_\mathrm{nn}(\boldsymbol{x},X)$ denotes the Euclidean distance of a point $\boldsymbol{x}$ to a its nearest neighbour in a set of points $X$. \section{Experiment} \label{secExperiment} This section describes the computer experiment to analyse the proposed infill criterion with its setup in \cref{subsecExpSetup}. \Cref{subsecExpExtreme} analysis the extreme values occur in the results. A comparison between the three methods is discussed in \cref{subsecExpCriteria}. \subsection{Setup} \label{subsecExpSetup} We evaluate the performance of the infill criterion $\GEILM$ using an extensive computer experiment. It is compared to the most popular $\EI$ infill criterion and a Latin Hypercube Sample \parencite{stein_large_1987} using $n_\mathrm{of}=15$ artificial objective functions as black box functions. \Cref{tabExpFunctions} contains the objective functions used in this experiment. \begin{table}[htbp] \centering \caption{Objective Functions used for Testing} \label{tabExpFunctions} \sisetup{round-mode = places, round-precision = 3, table-format = 3.0e0} \begin{tabular}{lS[table-format = 1.0e0]Slr} \toprule \thead{Function Name} & {\thead{Dim.}} & \multicolumn{2}{c}{\thead{\#Local Minima}} & \thead{Reference}\\ \midrule Alpine Function No. 02 & 1 & 2 & \Cref{tabAppMinimaAlpine02.1} & \textcite{clerc_swarm_1999}\\ Alpine Function No. 02 & 2 & 5 & \Cref{tabAppMinimaAlpine02.2} & \textcite{clerc_swarm_1999}\\ Alpine Function No. 02 & 3 & 14 & \Cref{tabAppMinimaAlpine02.3} & \textcite{clerc_swarm_1999}\\ \textsc{Branin} Function & 2 & 3 & \Cref{tabAppMinimaBranin} & \textcite{dixon_global_1978}\\ Cosine Mixture Function & 1 & 5 & \Cref{tabAppMinimaCosineMix.1} & \AtNextCite{\defcounter{maxnames}{1}}\textcite{ali_numerical_2005}\\ Cosine Mixture Function & 2 & 25 & \Cref{tabAppMinimaCosineMix.2} & \AtNextCite{\defcounter{maxnames}{1}}\textcite{ali_numerical_2005}\\ Cosine Mixture Function & 3 & 125 & \Cref{tabAppMinimaCosineMix.3} & \AtNextCite{\defcounter{maxnames}{1}}\textcite{ali_numerical_2005}\\ \textsc{Hartmann} Function & 3 & 3 & \Cref{tabAppMinimaHartmann.3} & \textcite{dixon_global_1978}\\ \textsc{Hartmann} Function & 6 & 2 & \Cref{tabAppMinimaHartmann.6} & \textcite{dixon_global_1978}\\ \textsc{Himmelblau} Function & 2 & 4 & \Cref{tabAppMinimaHimmelblau} & \textcite{himmelblau_applied_1972}\\ Modified \textsc{Rastrigin} Function & 4 & 48 & \Cref{tabAppMinimaModRastrigin.4} & \textcite{deb_multimodal_2012}\\ Modified \textsc{Rastrigin} Function & 8 & 48 & \Cref{tabAppMinimaModRastrigin.8} & \textcite{deb_multimodal_2012}\\ \textsc{Shekel} Function $5$ & 4 & 5 & \Cref{tabAppMinimaShekel.5} & \textcite{dixon_global_1978}\\ \textsc{Shekel} Function $7$ & 4 & 7 & \Cref{tabAppMinimaShekel.7} & \textcite{dixon_global_1978}\\ \textsc{Shekel} Function $10$ & 4 & 10 & \Cref{tabAppMinimaShekel.10} & \textcite{dixon_global_1978}\\ \bottomrule \end{tabular} \end{table} We list the name, the dimensionality, the number of local minima, and a reference for each objective function. All local minima are worked out in a computationally intensive task and tabulated in \cref{secAppMinima}, because only data of the global minimum can be found in the literature. The set of objective functions consist of the classic test set for global optimisation by \textcite{dixon_global_1978}, which is a subset of test problems described by \textcite{ali_numerical_2005}. We expand this set by the Alpine Function No. 02 \parencite{clerc_swarm_1999}, the Cosine Mixture Function \parencite{ali_numerical_2005}, the \textsc{Himmelblau} Function \parencite{himmelblau_applied_1972} and the modified \textsc{Rastrigin} Function \parencite{deb_multimodal_2012}. Model-based optimisation is split into an initial and a sequential phase (\cref{subsecMethodsMBO}). The number of points drawn in the initial phase is equal to $n_{\mathrm{init}}=\left\lbrace3^2, 4^2, \dotsc, 8^2\right\rbrace^\top$. In the sequential stage $n_{\mathrm{seq}}=\left\lbrace3^2, 4^2, \dotsc, 12^2\right\rbrace^\top$ are added using the infill criterion. All elements in both vectors are squared, to focus on results with a lower number of design points. Designs with higher numbers are less interesting, because the real world simulations are too expensive to evaluate a high amount of design points. All combinations of elements in $n_\mathrm{init}$ and $n_\mathrm{seq}$ are evaluated in the experiment. We evaluate $\left\lvert n_\mathrm{init}\right\rvert\cdot\left\lvert n_\mathrm{seq}\right\rvert\cdot n_\mathrm{of}=900$ experiments for each infill criterion. To compare the infill criteria to a Latin Hypercube Sample (LHS), we fit the same \textsc{Kriging} model as in MBO to a LHS with $n_\mathrm{LHS}=\left\lbrace4^2, 5^2, \dotsc, 15^2\right\rbrace^\top$ design points which results in $\left\lvert n_\mathrm{LHS}\right\rvert\cdot n_\mathrm{of}=180$ experiments. Each experiment is repeated \num{30} times which results in $\left(2\cdot 900+180\right)\cdot 30=\num{59400}$ runs, including infill criteria $\EI$ and $\GEILM$. We set the hyperparameters of $\GEILM$ criterion in \cref{eqnMethodsGEILM,eqnMethodsSEquant} to $\lambda=2$ and $p=0.001$, respectively. Both choices were made empirically to uprate low gradients ($\lambda$) and rate down extreme values ($p$). Further research can be done on these hyperparameters. In each run we record two performance measurements to rate the solution set (\cref{subsecMethodsRateSolutions}). The peak ratio ($\PR$) which considers representatives for every local minimum in \cref{eqnMethodsApproxSet} with $\delta=0.001$ and the averaged \textsc{Hausdorff} distance ($\AHD$) with $r=1$ in \cref{eqnMethodsAHD}. All implementation is done in \texttt{R}\ \parencite{rdevelopmentcoreteam_language_2017} via package \texttt{mlrMBO} \parencite{bischl_mlrmbo_2017}. We parallelise the experiment using package \texttt{batchtools} \parencite{lang_batchtools_2017}. \subsection{Extreme Values} \label{subsecExpExtreme} The construction of $\PR$ results in the interval $(0,\infty)$. However, we expect two soft limits \num{0} and \num{1}. No minima are found with $\PR=0$ whereas a value of \num{1} indicates that all local minima are found. Due to construction, $\PR$ is capable to detect overfitted surrogate models. If the \textsc{Kriging} model finds too many optima, $\PR$ exceeds \num{1} and indicates overfitting by higher values. Hence, we are interested in a reasonable dataset which covers the expected interval $[0,1]$ as well as the overfitting indication. We choose the interval $[0,5]$ empirically. The value $\PR=5$ indicates a surrogate function with five times more minima than the corresponding objective function and indicates overfitting. A first analysis of $\PR$ shows extreme values up to \num{11260.5} and points out \SI{16.3}{\percent} runs with $\PR > 5$ as shown in \cref{tabExpExtremePRbyInterval}. \begin{table}[htbp] \centering \caption{Number of Extreme Values in $\PR$ Intervals} \label{tabExpExtremePRbyInterval} \sisetup{round-mode = places, table-format = 5.0e0} \begin{tabular}{lS} \toprule \thead{Intervall} & {\thead{Count}}\\ \midrule $\mathrm{A}=[0,5]$ & 49697 \\ $\mathrm{B}=(5,50]$ & 734 \\ $\mathrm{C}=(50, 500]$ & 2698 \\ $\mathrm{D}=(500, 1500]$ & 6259 \\ $\mathrm{E}=(1500, \infty)$ & 12 \\ \bottomrule \end{tabular} \end{table} The table lists the count of $\PR$ values in the corresponding intervals. We choose these remaining interval ranges for B to E in a way to plot values of $\PR$ in histograms which illustrate the extreme values. The different information shown in \cref{figExpExtremePRbyIntervalAlgo} will be hidden if the data is plotted in one histogram. \begin{figure}[htbp] \centering \includegraphics[trim=0mm 0mm 0mm 0mm, clip, width=\linewidth]{LocOpt_ExtremePR.pdf} \caption{Extreme Values in $\PR$ Intervals by Algorithm} \label{figExpExtremePRbyIntervalAlgo} \end{figure} Extreme values are independent of the used method. Certainly, the ratio of LHS algorithm is lower, because the number of chosen MBO combinations is ten times higher. The histogram A shows two peaks indicating the soft limits \num{0} and \num{1} of $\PR$. Higher values indicate a misleading surrogate function with too many local minima. Histogram B illustrates the exponential decrease for higher values of $\PR$ which can be observed in histogram A, too. The peaks in histograms C, D and E are far outside this decreasing histogram range described by A and B and calculated in \cref{tabExpExtremePRbyProb}. \begin{table}[htbp] \centering \caption{Number of Extreme Values in $\PR$ by Interval and Problem} \label{tabExpExtremePRbyProb} \sisetup{round-mode = places, table-format = 5.0e0} \begin{tabular}{lSSSSS} \toprule & \multicolumn{5}{c}{\textbf{Interval Counts}}\\ \thead{Function} & {\thead{B}} & {\thead{C}} & {\thead{D}} & {\thead{E}} & {\thead{B -- E}}\\ \midrule Alpine02.2 & 3 & 130 & & & 133 \\ Alpine02.3 & 79 & 2087 & & & 2166 \\ CosineMix.3 & 4 & & & & 4 \\ Hartmann.3 & & & 1 & & 1 \\ Hartmann.6 & 26 & 12 & 6 & 12 & 56 \\ Himmelblau & & 2 & & & 2 \\ modRastrigin.4 & 2 & 2 & & & 4 \\ modRastrigin.8 & 2 & 3 & 1 & & 6 \\ Shekel.5 & 175 & 135 & 2332 & & 2642 \\ Shekel.7 & 154 & 152 & 2339 & & 2645 \\ Shekel.10 & 289 & 175 & 1580 & & 2044 \\ \bottomrule \end{tabular} \end{table} Apparently, the Alpine Function No. 02 and the \textsc{Shekel} Functions 5, 7, and 10 seem to be difficult to fit, they generate nearly all extreme values. A closer look does not reveal any relation to the number of design points, neither the number of initial points nor the number of sequential points. The divergence in these functions is spread through the complete experimental space. Because interval B contains only functions discovered in C to E, we decide to refer the further analysis to interval A. \subsection{Comparison of Infill Criteria} \label{subsecExpCriteria} \Cref{figExpPR,figExpAHD} illustrate the progress of the two performance measurements over the number of design points. \begin{figure}[htbp] \centering \includegraphics[trim=0mm 0mm 0mm 0mm, clip, width=\linewidth]{LocOpt_PR-AHD.pdf} \caption{Peak Ratio ($\PR$) over Number of Design Points Grouped by Algorithm} \label{figExpPR} \end{figure} \begin{figure}[htbp] \centering \includegraphics[page=2, trim=0mm 0mm 0mm 0mm, clip, width=\linewidth]{LocOpt_PR-AHD.pdf} \caption{Averaged \textsc{Hausdorff} distances ($\AHD$) over number of design points grouped by algorithm} \label{figExpAHD} \end{figure} In all figures, the curves represent a local regression (LOESS) for smoothing points in scatterplots described in \textcite{cleveland_local_2017} with a smoothing parameter $\alpha=\num{0.5}$. The parameter $\alpha$ controls the fraction of the neighbouring data points which are used to fit each local polynomial. Each curve is shown with a grey \SI{95}{\percent} confidence interval for the smoothed value assuming a normal distribution. For most objective functions the proposed infill criterion $\GEILM$ beats $\EI$ in terms of peak ratio ($\PR$), shown in \cref{figExpPR}. It converges earlier to the optimal value of \num{1} which can be seen especially for Alpine Function No. 02, Cosine Mixture Function and \textsc{Hartmann} Function. Especially, \textsc{Hartmann} Function in \num{6} dimensions shows the need for an infill criterion designed to identify local minima. $\EI$ diverges over the number of design points contrary to the proposed criterion which identifies in average the correct number of local minima. This example illustrates that $\EI$ identifies the global optimum, as expected. \textsc{Branin}, \textsc{Hartmann}, and \textsc{Himmelblau} Function illustrates the high variance of LHS. The smoothed mean of LHS outperforms MBO in many objective functions. However, the confidence intervals are often much wider compared to MBO methods. Additionally, LHS has plateaus in the \textsc{Branin} Function or overshoots in the \textsc{Himmelblau} Function and Alpine Function No. 02 in dimensionalities \num{2} and \num{3}. \Cref{figExpAHD} shows a similar picture for the averaged \textsc{Hausdorff} distance. We reach the optimal value of $\AHD=0$ with $\GEILM$ continuously faster than by using $\EI$ or LHS. Latin Hypercube Sampling is sometimes better in terms of mean $\AHD$ but shows a higher variance compared to the MBO approach. All three methods are highly overstrained with the objective functions Modified \textsc{Rastrigin} and \textsc{Shekel}. The latter one was already identified in \cref{subsecExpExtreme}, where it generates about $\frac{3}{4}$ of the extreme values. Whereas $\AHD$ results in lesser values with more design points, we see the divergence of $\PR$ in \cref{figExpPR} for all \textsc{Shekel} Functions. For the modified \textsc{Rastrigin} Function low values of $\PR$ illustrate the overstrained behaviour to identify the local minima. Only \num{1} of \num{48} local minima is identified for this type of objective functions. We suppose a problematic fit of \textsc{Kriging} models to a modified \textsc{Rastrigin} Function. From our point of view, the dimension or number of local minima is not the only cause for these results, since the Cosine Mixture Function in \num{3} dimensions with \num{125} local minima shows a good performance in $\PR$ and $\AHD$ as well as \textsc{Hartmann} Function in \num{6} dimension with \num{2} local optima. In case of MBO, we are interested in the development of performance measurements over the number of initial and sequential design points. Contour plots of peak ratio over the number of initial and sequential design points, smoothed by LOESS, are shown in \cref{figExpGEILMPR} for infill criterion $\GEILM$. The contour plot of averaged \textsc{Hausdorff} distance is shown in appendix \cref{figAppGEILMAHD}. \begin{figure}[htbp] \centering \includegraphics[trim=0mm 0mm 0mm 0mm, clip, width=\linewidth]{LocOpt_MBO-PR-AHD-showcases.pdf} \caption{Contour Plot of Peak Ratio ($\PR$) over Number of Initial and Sequential Design Points for Infill Criterion $\GEILM$.} \label{figExpGEILMPR} \end{figure} We chose Alpine Function No. 02 in \num{2} dimensions, Cosine Mixture Function in \num{3} dimensions and \textsc{Hartmann} Function in \num{6} dimensions as showcases because the corresponding plots illustrate the variety of contours between the different objective functions. Contour plots of both performance measurements for all objective functions are given in appendix \cref{figAppGEILMPRall,figAppGEILMAHDall}. Local minima of the \num{2} dimensional function Alpine02 are found fast with a low number of initial and sequential points. Interestingly, a higher number of points in the initial design results in $\PR>1$ which indicates an overfitted \textsc{Kriging} model. The overfit is resolved in the sequential stage with a low number of design points. An undersized initial design is hard to compensate because MBO needs a high number of design points in the sequential stage to achieve $\PR=1$. Cosine Mixture Function in \num{3} dimensions is an example of an expected contour plot for $\PR$. A higher number of points in the initial or sequential design results in a constant improvement of peak ratio. A modified behaviour of Alpine02 can be found in the contour plot of \textsc{Hartmann} Function in \num{6} dimensions. We see an overfitted surrogate model with \num{35} initial design points and the minimum number of points in the sequential stage. The same reaction holds for the highest amount of initial and design points which was observed in \cref{figExpPR} as an increase in the curve of $\GEILM$ for a high number of design points. Medium number of points in the sequential stage sometimes result in an incorrect number of local minima from the \textsc{Kriging} model. This has a strong impact in LOESS because the peak ratio for a function with \num{2} local minima has a precision of \num{0.5}. The corresponding contour plot of averaged \textsc{Hausdorff} distance in \cref{figAppGEILMAHD} underlines this statement. Improvements of $\AHD$ for increasing number of points in the initial and sequential stage are illustrated by contour plots for each objective function (see \cref{figAppGEILMAHDall}). \section{Conclusion} \label{secConclusion} We introduce the infill criterion gradient enhanced inspection of local minima ($\GEILM$) for model-based optimisation (MBO) which aims to identify local minima in expensive objective functions. It is capable to identify all local minima and focuses on minima with lower values of the objective function. Minima with lower values are explored more intense than minima with higher function values. A computer experiment compares the behaviour of $\GEILM$ to the most popular infill criterion expected improvement ($\EI$) used in efficient global optimisation (EGO). Additionally, we include Latin Hypercube Sampling (LHS) which reflects a state of the art design for computer experiments not considering the objective function. We work out and tabulate all local minima of the used objective functions. A variety of objective functions is tested and shows a good performance of $\GEILM$ in case of the measurements peak ratio ($\PR$) and averaged \textsc{Hausdorff} distance ($\AHD$). It outperforms $\EI$ and LHS in the averaged performance measurements and especially the latter in terms of variance. The need for special infill criteria to identify local minima instead of the global minimum is obvious by considering the \textsc{Hartmann} Function in \num{6} dimensions. $\PR$ diverges using EGO over an increasing number of design points contrary to $\GEILM$ which identifies the correct number of local optima. From our point of view, it is worth the effort to define criteria purpose-built for dealing with local minima. Future work should examine the hyperparameters of $\GEILM$ and improve the criterion to minimise the number of hyperparameters. Additionally, we may investigate the used surrogate model in MBO because of its poor behaviour with respect to the objective functions Alpine Function No. 02 and \textsc{Shekel} Functions 5, 7, and 10. Finally, the infill criteria and used surrogate model should be tested in a larger computer experiment with additional objective functions especially of higher dimensions ($p\geq 6$) and a greater variety of function types. This will clarify the discussed issues and make stronger statements about the capabilities of the infill criteria aiming at local minima. \section{Acknowledgement} This work has been funded by the Deutsche Forschungsgemeinschaft (DFG), Forschergruppe 1511 \textit{Schutz- und Leitsysteme zur zuverlässigen und sicheren elektrischen Energieübertragung}. \clearpage
{'timestamp': '2018-10-05T02:09:22', 'yymm': '1810', 'arxiv_id': '1810.02118', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02118'}
arxiv
\section{Introduction} The main gist behind clustering is to group data-points into various groups (clusters) based on their features, i.e. properties. The generation of clusters varies application-wise \cite{survey}, because it depends on what factors are to be taken into consideration to form a particular cluster. But, the focus of every clustering algorithm remains same, i.e. to group similar data-points to a common cluster. The thing that differs is how this goal of forming a cluster is achieved. Different algorithms use different concepts to deal with similarity measure among the data-points. There are many popular clustering algorithms that group data-points based on various strategies to define the similarity measure between them. Centroid-based \cite{centroid}, density-based \cite{den}, graph-based \cite{graph}, etc. are the commonly used strategies. Often used algorithms like k-means, hierarchical clustering, DBSCAN, etc. require a set of data-points in space beforehand. Without making fine adjustments to these pre-existing clustering algorithms, it is not possible to cluster a stream of near real-time data-points. Therefore, a real-world problem exists if there is a necessity of grouping a stream of data-points without having to specify the number of clusters to be generated. Therefore, taking this limitation into consideration, this paper proposes a machine learning algorithm that can group incoming data-points without having to specify the number of clusters to be formed. The main agenda behind proposing this algorithm is to facilitate those problems which require clustering of data-points based on some level-of-similarity. The paper is organized as follows. Section 2 describes the core logic of the proposed clustering algorithm. Implementation of algorithm is done in Section 3 and Section 4 is the conclusion. \section{The Proposed Clustering Algorithm} This algorithm requires an initial declaration of cluster strictness. Cluster Strictness is the lowest permitted level-of-similarity between a data-point and the centroid of a cluster. Here, cluster centroid is the average of features of the data-points present in a cluster and is an effective way of representing a particular cluster. If cluster strictness is set to a measure of 60, then the accepted variability between a cluster centroid (C) and a data-point (D) should be a measure of 40 at-most, for D to be associated to cluster C. Hence, this algorithm is capable of generating clusters based on a level-of-similarity. If one needs clusters with very low variance among the data-points, the cluster strictness can be adjusted accordingly; maybe around 80-95\%. That is why cluster strictness plays a significant role in generating clusters, and its value depends entirely on what application the clustering is being done. \subsection{Data-point and Features} A data-point can have multiple features (n-features). Those features are the characteristics which collectively define a data-point. A stream of data-points can be grouped into various clusters, based on their features. Below is an example of a data-point with 7 features. \begin{center} A data-point: 5 10 15 20 25 30 35 \end{center} During the implementation of the proposed algorithm, the above pattern is used to represent a data-point, and similarity measure between the data-points and cluster(s) is calculated accordingly. The algorithm takes data-points with n-features, one data-point at a time, and requires all the data-points to have the same fixed number of features. When the algorithm runs for the very first time and is waiting for a new data-point; the number of cluster(s) is 0. Cluster strictness needs to be defined beforehand. Based on the requirements, this value can be adjusted. Higher the value of cluster strictness, less is the variance between the data-points in a cluster. Depending on the data-points, using a higher value of cluster strictness result in a large number of clusters. This is more likely to happen if the incoming data-points are less identical to each other. After assigning some value to cluster strictness, say 70\%, the number of features that should be matched between a data-point and a cluster is calculated using the formula given below: \begin{equation} should\_match\_features = \frac{no\_of\_features * cluster\_strictness}{100}\; \end{equation} Suppose, if the data-points that are to be clustered have 20 features. That means cluster strictness with 70\% results into 14 features that must be matched (at least) for a data-point to be associated with a particular cluster. \subsection{Qualifying Feature} A feature qualifies to be counted as a matched feature when its similarity measure lies between the range: (cluster\_strictness) and (100 + (100 – cluster\_strictness)). That is, the valid range is 70-130 when cluster strictness is considered 70. Suppose, when variability check of 5 and 13 is to be done with respect to 9, basic mathematics can be used. 9 with respect to 9 gives a similarity measure of 100. 5 with respect to 9 gives a similarity measure of 55.56. And, 13 with respect to 9 gives a similarity measure of 144.44. If allowed variability is considered to be a measure of 50, then similarity measure of both 5 and 12 falls under the range 50-150, and are considered to be associated to 9 by at-least a measure of 50. In the case of data-points, the following formula is used to calculate the similarity measure. \begin{equation} S(Ci,Fj)) = \frac{100 * datapoint_j}{centroid(i,j))} \end{equation} \begin{center} \textit{where i is an index for clusters, and j is an index for features.} \end{center} As an example, in formula 2, i=3 and j=7 reflect the fact that cluster 3 is being considered, and 7th feature of a data-point and 7th feature of the centroid of cluster 3 are being used to compute the level-of-similarity between them. If the resulted similarity measure lies between the range (cluster\_strictness) and (100 + (100 – cluster\_strictness)), then the 7th feature is said to be matched, and the value of matched feature counter for the cluster 3 is incremented by 1. This process of calculating the similarity feature of an incoming data-point is done with all the cluster(s). And if the matched feature counter for a cluster reaches the limit of the minimum number of features that should be matched between a data-point and a cluster, that particular cluster is now placed into a list of qualified clusters. \begin{algorithm} \caption{Clustering Algorithm for Data-points with n Features} \SetAlgoLined \DontPrintSemicolon Declare cluster\_strictness.\; Initialize $cluster\_counter \gets 0$.\; Calculate should\_match\_features using formula.\; Read a datapoint \(D\) \; \eIf{cluster\_counter = 0}{ Increment cluster\_counter by 1.\; Create a new cluster C\textsubscript{cluster\_counter}.\; Assign \(D\) to the newly formed cluster.\; \(D\) be the centroid of the cluster.\; } { \For{all clusters C\textsubscript{i}, where i ranges from $1$ to cluster\_counter}{ \For{all features F\textsubscript{j}, where j ranges from $1$ to no\_of\_features}{ Calculate similarity\ measure using formula. \; \If{S(Ci,Fj) \textgreater= (cluster\_strictness)\; \quad \quad and S(Ci,Fj) \textless=(100 + (100 - cluster\_strictness))} { Increment matched\_features\textsubscript{i} by 1.\; } } \If{matched\_features\textsubscript{i} \textgreater= should\_match\_features} { Add C\textsubscript{i} to the list of qualified\_clusters\; } } \If{qualified\_cluster list is empty}{ Increment cluster\_counter by 1.\; Create a new cluster C\textsubscript{cluster\_counter}.\; Assign \(D\) to the newly formed cluster.\; \(D\) be the centroid of the cluster.\;} \eIf{qualified\_cluster list contains single cluster}{ Assign \(D\) to the cluster.\; Re-calculate the centroid.\;} { Calculate cluster(s) with maximum matched\_features.\; \eIf{single cluster arises}{ Assign \(D\) to the cluster.\; Re-calculate the centroid.\;} { Find the cluster with max average of qualifying similarity measures.\; Assign \(D\) to the cluster.\; Re-calculate the centroid.\; } } \end{algorithm} \subsection{Qualified Cluster List} This list contains the cluster(s) that satisfy the condition of having at least a minimum number of features that have matched with an incoming data-point. After calculation of similarity measure for a data-point with all the cluster(s), there might arise any one of the following three situations. \subsubsection{A qualified cluster list is empty} The qualified list being empty indicates that no similar cluster(s) were found within the provided level-of-similarity. Hence, a new cluster is generated, and the data-point is assigned to the newly formed cluster. The data-point is the centroid of this cluster. \subsubsection{A Qualified cluster list contains exactly 1 cluster} In this case, the data-point is simply assigned to the cluster which is present in the list. And, the centroid of the cluster is re-calculated. \subsubsection{A Qualified cluster list contains more than 1 cluster} Case 1: If the list contains more than 1 cluster, the cluster with maximum matched features is identified. The data-point is now assigned to the identified cluster. Case 2: Sometimes, two or more cluster might come-up with the same highest number of matched features. In this case, the cluster with a maximum average of qualifying similarity measures is identified, and the data-point is assigned to that cluster accordingly. \subsection{Conflicting Clusters} Whenever multiple clusters show up in qualified cluster list, while trying to identify the nearest similar cluster based on the highest number of matched features, those clusters are said to be the conflicting ones. In such case, an average of qualifying similarity measures is calculated for all the clusters which are in the qualified list and have the same number of matched features, and finally, the cluster with the maximum average is considered to be the cluster to which the data-point is associated. While calculating an average, only the qualifying similarity measures are being considered. One fact is also being taken into consideration that technically 60 and 140 are same with respect to 100. Both have a variability measure of 40. \section{Implementation of the Proposed Algorithm} Let us consider the following six data-points, each of 10 features, that are to be clustered. The data-points are input to the algorithm in a serial fashion.\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| }\hline Data-point 1& 10& 15& 20& 25& 30& 35& 40& 45& 50& 55\\\hline Data-point 2& 09& 35& 18& 45& 10& 32& 60& 41& 10& 20\\\hline Data-point 3& 18& 13& 18& 27& 30& 38& 38& 41& 49& 57\\\hline Data-point 4& 20& 20& 18& 05& 15& 34& 50& 43& 10& 50\\\hline Data-point 5& 17& 17& 18& 15& 22& 35& 44& 43& 10& 53\\\hline Data-point 6& 10& 32& 20& 45& 12& 55& 40& 55& 09& 25\\ \hline \end{tabu}\\\\ Let us suppose, level-of-similarity for a cluster is considered to be 60. That means variability measure of 40 between a data-point and a cluster centroid is acceptable. With cluster strictness set to 60, using formula 1 we get minimum number features that must be matched to be 6. Initially, when Data-point 1 is input to the algorithm, because of the absence of cluster(s), a new cluster C1 is created, and Data-point 1 is assigned to it, and features of Data-point 1 is assumed to be the centroid of C1. \begin{center} C1 = Data-point 1\\ C1: 10 15 20 25 30 35 40 45 50 55 \end{center} For Data-point 2\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| }\hline S(C1,Fi)& 90& 233.34& 90& 180& 33.34& 91.43& 150& 91.11& 20& 36.36\\ \hline \end{tabu}\\ The number of qualified features is 4, which is less than 6. C1 cannot be added to the list of qualified clusters. Since there are no clusters in the list of qualified clusters, a new cluster C2 is generated, and Data-point 2 is assigned to C2. \begin{center} C2 = Data-point 2\\ C2: 09 35 18 45 10 32 60 41 10 20 \end{center} For Data-point 3\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| } \hline S(C1,Fi) & 180& 86.67& 90& 108& 100& 108.57& 95& 91.11& 98& 103.64\\\hline S(C2,Fi) & 200& 37.14& 100& 60& 300& 118.75& 63.33& 100& 490& 285\\ \hline \end{tabu}\\ Only C1 qualified to be in in the list of qualified clusters, Data-point 3 is assigned to C1. \begin{center} C1 = Data-point 1, Data-point 3\\ New C1: 14 14 19 26 30 36.5 39 43 49.5 56 \end{center} For Data-point 4\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| }\hline S(C1,Fi) & 142.86& 142.86& 94.74& 19.23& 50& 93.15& 128.21& 100& 20.20& 89.29\\\hline S(C2,Fi) & 222.22& 57.14& 100& 11.11& 150& 106.25& 83.33& 104.87& 100& 250\\ \hline \end{tabu}\\ Since there no cluster qualified to be kept in the list of qualified clusters, a new cluster C3 is generated, and Data-point 4 is assigned to C3. \begin{center} C3 = Data-point 4\\ New C3: 20 20 18 05 15 34 50 43 10 50 \end{center} For Data-point 5\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| }\hline S(C1,Fi) & 121.43& 121.43& 94.74& 57.59& 73.33& 95.89& 112.82& 100& 20.20& 94.64\\\hline S(C2,Fi) & 188.89& 48.57& 100& 33.33& 220& 109.38& 73.33& 104.88& 100& 265\\\hline S(C3,Fi) & 85& 85& 100& 300& 146.67& 102.94& 88& 100& 100& 106\\ \hline \end{tabu}\\ Since C1 and C3 qualified to be in the list of qualified clusters and both the clusters have the same number of qualified features. Now, the average of the qualifying features is calculated for both the clusters. Qualifying features beyond 100 are scaled below 100 using the formula given below: \begin{equation} scaled\ value = 100 - (value\ beyond\ hundred - 100)\; \end{equation} \begin{center} Average of qualifying features (C1) = 87.87\\ Average of qualifying features (C3) = 93.63 \end{center} Since the average of qualifying features for C3 is higher, Data-point 5 is assigned to C3. \begin{center} C3 = Data-point 4, Data-point 5\\ New C3: 18.5 18.5 18 10 18.5 34.5 47 43 10 51.5 \end{center} For Data-point 6\\\\ \begin{tabu} to 1\textwidth { |c|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]| }\hline S(C1,Fi) & 71.43& 228.57& 105.26& 173.08& 40& 150.68& 102.56& 127.91& 18.18& 44.64\\\hline S(C2,Fi) & 111.11& 91.43& 111.11& 100& 120& 171.88& 66.67& 134.15& 90& 125\\\hline S(C3,Fi) & 54.05& 172.97& 111.11& 450& 64.86& 159.42& 85.11& 127.91& 90& 48.54\\ \hline \end{tabu}\\ Since C2 is the only cluster qualifying to be in the list of qualified clusters, Data-point 6 is assigned to C2. \begin{center} C2 = Data-point 2, Data-point 6\\ New C2: 9.5 33.5 19 45 11 43.5 50 48 9.5 22.5 \end{center} The data-points were successfully grouped into 3 various clusters based on the similarity measure of their features. Cluster strictness of 60 was considered, hence permitted variability measure between a data-point and a cluster centroid was 40. \section{Conclusion} The theoretical aspect of the proposed algorithm was discussed and implemented on 6 data-points (all of them with 10-features) with the supposition that they are input to the algorithm one after another, just like a stream-of-data in a serial fashion. The formation of clusters could be manipulated by increasing/decreasing the level-of-similarity. The algorithm is applicable in a real-world scenario where the task is to group a stream of data-points, incoming to a system, based on their similarity with the average of features (centroid) of data-points existing in their respective previously formed clusters. If none of the existing clusters satisfy the similarity measure for a new data-point, a new cluster is formed, and the data-point is assigned to the newly formed cluster. When the number of clusters in the space is relatively large, the complexity of the algorithm increases proportionately. Therefore, it would be an interesting problem to try decreasing the number of similarity checks that is done when a new data-points arrives. Instead of checking the similarity of data-points with all the pre-existing clusters, an approach can be made so that only a certain number of clusters are taken into consideration for similarity check. This way, the number of required computations can be decreased. \section*{Acknowledgment} The authors would like to gratefully acknowledge Intel for providing computing cluster during this study.
{'timestamp': '2019-07-23T02:12:25', 'yymm': '1810', 'arxiv_id': '1810.01878', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01878'}
arxiv
\section{Introduction} Ranking a set of candidate items is a central task in machine learning and information retrieval. Many existing ranking systems are based on pointwise estimators, where the model assigns a score to each item in a candidate set and the resulting \emph{slate} is obtained by sorting the list according to item scores \cite{liu2009letor}. Such models are usually trained from click-through data to optimize an appropriate loss function \cite{joachims2002}. This simple approach is computationally attractive as it only requires a sort operation over the candidate set at test (or serving) time, and can therefore scale to large problems. On the other hand, in terms of modeling, pointwise rankers cannot easily express dependencies between ranked items. In particular, the score of an item (e.g., its probability of being clicked) often depends on the other items in the slate and their joint placement. Such interactions between items can be especially dominant in the common case where display area is limited or when strong position bias is present, so that only a few highly ranked items get the user's attention. In this case it may be preferable, for example, to present a \emph{diverse} set of items at the top positions of the slate in order to cover a wider range of user interests. Conversely, presenting multiple items with similar attributes may create ``synergies'' by drawing attention to the collection, amplifying user response beyond that of any individual item. A significant amount of work on learning-to-rank does consider interactions between ranked items when \emph{training} the model. In \emph{pairwise} approaches a classifier is trained to determine which item should be ranked first within a pair of items \cite[e.g.,][]{ordinal_svm,joachims2002,RankNet2005}. Similarly, in \emph{listwise} approaches the loss depends on the full permutation of items \cite[e.g.,][]{cao2007listwise,yue2007map}. Although these losses consider inter-item dependencies, the ranking function itself is pointwise, so at inference time the model still assigns a score to each item which does not depend on scores of other items (i.e., an item's score will not change if it is placed in a different set). There has been some work on trying to capture interactions between items in the ranking scores themselves \cite[e.g.,][]{qin2008,qin2009,zhu2014,rosenfeld2014,dokania2014ranking,Borodin2017,GroupwiseRankingArXiv}. Such approaches can, for example, encourage a pair of items to appear next to (or far from) each other in the resulting ranking. Approaches of this type often assume that the relationship between items takes a simple form (e.g., submodular \cite{Borodin2017}) in order to obtain tractable inference and learning algorithms. Unfortunately, this comes at the expense of the model's expressive power. Alternatively, greedy or approximate procedures can be used at inference time, though this often introduces approximation errors, and many of these procedures are still computationally expensive \cite[e.g.,][]{rosenfeld2014}. More recently, neural architectures have been used to extract representations of the entire set of candidate items for ranking, thereby taking into consideration all candidates when assigning a score for each item \cite{Mottini2017kdd,ai2018sigir}. This is done by an encoder which processes all candidate items sequentially and produces a compact representation, followed by a scoring step in which pointwise scores are assigned based on this joint representation. This approach can in principle model rich dependencies between ranked items, however its modeling requirements are quite strong. In particular, all the information about interactions between items needs to be stored in the intermediate compact representation and extracted in one-shot when scoring (decoding). Instead, in this paper we propose a different approach by applying \emph{sequential decoding}, which assigns item scores conditioned on previously chosen items. Our decoding procedure lets the score of an item change depending on the items already placed in previous positions. This in turn allows the model to account for high-order interactions in a natural and scalable manner. Moreover, our approach is purely data-driven so the model can adapt to various types of inter-item dependencies, including synergies---where items appearing together contribute to their joint appeal, and interference---where items decrease each other's appeal. In particular, we apply a \emph{sequence-to-sequence (seq2seq)} model \cite{Sutskever2014} to the ranking task, where the input is the list of candidate items and the output is the resulting ordering. Since the output sequence corresponds to ranked items on the slate, we call this approach \emph{sequence-to-slate}, or in short \emph{seq2slate}. \begin{figure*}[t!] \centering \includegraphics[width=0.9\textwidth]{{seq2slate_architecture.pdf}} \caption{The seq2slate pointer network architecture for ranking.} \label{fig:ptrnet} \end{figure*} To address the seq2seq problem, we build on the recent success of \emph{recurrent neural networks (RNNs)} in a wide range of applications \cite[e.g.,][]{Sutskever2014}. This allows us to use a deep model to capture rich dependencies between ranked items, while keeping the computational cost of inference manageable. More specifically, we use \emph{pointer networks}, which are seq2seq models with an attention mechanism for pointing at positions in the input \cite{vinyals2015}. We show how to train the network end-to-end to optimize several commonly used ranking measures. To this end, we adapt RNN training to use weak supervision in the form of click-through data obtained from logs, instead of relying on ground-truth rankings, which are much more expensive to obtain. Finally, we demonstrate the usefulness of the proposed approach in a number of learning-to-rank benchmarks and in a large-scale, real-world recommendation system. \section{Ranking as Sequence Prediction} \label{sec:model} The \emph{ranking problem} is that of computing a ranking of a set of items (or ordered list or \emph{slate}) given some query or context. We formalize the problem as follows. Assume a set of $n$ items, each represented by a feature vector $x_i\in\mathbb{R}^m$ (which may depend on a query or context).% \footnote{$x_i$ can represent either raw inputs or learned embeddings.} Let $\pi\in\Pi$ denote a permutation of the items, where each $\pi_j \in \{1,\ldots,n\}$ denotes the index of the item in position $j$, for example, $\pi=(3,1,2,4)$ for $n=4$. Our goal is to predict an ``optimal'' output ranking $\pi$ given the input items $x$. For instance, given a specific user query, we might want to return an ordered set of music recommendations from a set of candidates that maximizes some measure of user engagement (e.g., number of tracks played). In the seq2seq framework, the probability of an output permutation, or slate, given the inputs is expressed as a product of conditional probabilities according to the chain rule: \begin{equation} \label{eq:chain_rule} p(\pi|x) = \prod_{j=1}^n p(\pi_j|\pi_1,\ldots,\pi_{j-1}, x) ~, \end{equation} This expression is completely general and does not make any conditional independence assumptions. In our case, the conditional $p(\pi_j|\pi_{<j},x)\in\Delta^n$ (a point in the $n$-dimensional simplex) models the probability of any item being placed at the $j$'th position in the ranking given the items already placed at previous positions. For brevity, we have denoted the prefix permutation $\pi_{<j}=(\pi_1,\ldots,\pi_{j-1})$. Therefore, this conditional can exactly capture \emph{all} high-order dependencies between items in the ranked list, including those due to diversity, similarity or other interactions. Our setting is somewhat different than a standard seq2seq setting in that the output vocabulary is not fixed. In particular, unlike in e.g., machine translation, the same index (position) is populated by different items in different instances (queries). The vocabulary size $n$ itself may also vary per instance in the common case where the number of items to rank can change. This is precisely the problem addressed by \emph{pointer networks}, which we review next. \subsection*{Pointer-Network Architecture for Ranking} We employ the \emph{pointer-network architecture} of \citet{vinyals2015} to model the conditional $p(\pi_j|\pi_{<j},x)$. A pointer network uses non-parametric softmax modules, akin to the attention mechanism of \citet{Bahdanau2015}, and learns to point to items in its input sequence rather than predicting an index from a fixed-sized vocabulary. Our \emph{seq2slate} model, illustrated in \figref{fig:ptrnet}, consists of two \emph{recurrent neural networks} (RNNs): an encoder and a decoder, both of which use Long Short-Term Memory (LSTM) cells~\citep{lstm97}. At each encoding step $i\leq n$, the encoder RNN reads the input vector $x_i$ and outputs a $\rho$-dimensional vector $e_i$, thus transforming the input sequence $\{x_i\}_{i=1}^n$ into a sequence of latent memory states $\{e_i\}_{i=1}^n$. These latent states can be seen as a compact representation of the entire set of candidate items. At each decoding step $j$, the decoder RNN outputs a $\rho$-dimensional vector $d_j$ which is used as a query in the attention function. The attention function takes as input the query $d_j \in \mathbb{R}^{\rho}$ and the set of latent memory states computed by the encoder $\{e_i\}_{i=1}^n$ and produces a probability distribution over the next item to include in the output sequence as follows: {\small \begin{align} \label{eq:attn} &s^j_i = v^{\top} \tanh{\left( W_{enc} \cdot e_i + W_{dec} \cdot d_j \right)} \\ &p_{\theta}(\pi_j = i |\pi_{<j},x) ~\equiv p_i^j = \begin{cases} e^{s_i^j} / \sum_{k\notin\pi_{<j}} e^{s_k^j} & \text{if } i\notin \pi_{<j} \\ 0 & \text{if } i\in\pi_{<j} \end{cases} \qquad. \nonumber \end{align} }% Here $W_{\mathit{enc}}, W_{\mathit{dec}} \in \mathbb{R}^{\rho \times \rho}$ and $v \in \mathbb{R}^{\rho}$ are learned parameters in our network, denoted collectively by parameter vector $\theta$, and $s^j_i$ are \emph{scores} associated with placing item $i$ in position $j$. The probability $p_i^j = p_{\theta}(\pi_j = i |\pi_{<j},x)$, is obtained via a softmax over the remaining items and represents the degree to which the model points to input $i$ at decoding step $j$. In order to output a permutation, the probabilities $p_i^j$ are set to 0 for items $i$ that already appear on the slate. % Once the next item $\pi_j$ is selected, typically greedily or by sampling (see below), its embedding $x_{\pi_j}$ is fed as input to the next decoder step. This way the decoder states hold information on the items already placed on the slate. The input to the first decoder step is a learned $m$-dimensional vector, denoted as `$\mathit{go}$' in \figref{fig:ptrnet}. We note the following. \textbf{(i)} Our formulation using sequential decoding lets the score of items (i.e., $p_i^j$) change depending on items previously placed on the slate, thereby allowing the model to account for high-order interactions in a natural way. \textbf{(ii)} The model makes no explicit assumptions about the type of interactions between items. If the learned conditional in \eqref{eq:attn} is close to the true conditional in \eqref{eq:chain_rule}, then the model can capture rich interactions---including diversity, similarity or others. Hence, our approach is data-driven rather than modeling specific types of interactions (such as multinomial logit), which is a key advantage. We demonstrate the benefits of this flexibility in our experiments (\secref{sec:experiments}). \textbf{(iii)} The probability $p_\theta(\pi | x)$ is differentiable (in $\theta$) for any fixed permutation $\pi$, which allows gradient-based learning (see \secref{sec:training}). \textbf{(iv)} The computational cost of inference, dominated by the sequential decoding procedure, is $O(n^2)$, which is standard in seq2seq models with attention. We also consider a computationally cheaper single-step decoder with linear cost $O(n)$, which outputs a single vector $p^1=p_\theta(\pi_1=\cdot|x)$ (see \eqref{eq:attn}), from which we obtain $\pi$ by sorting the values---similar to the approach taken in \cite{Mottini2017kdd,ai2018sigir}); we compare both approaches below. Previous studies have shown that the order in which the input is processed can significantly affect the performance of sequential models \cite{vinyals2016,nam2017multilabel,ai2018sigir}. For this reason, we will assume here the availability of a base (or ``production'') ranker with which the input sequence is ordered (e.g., a simple pointwise method that ignores the interactions we seek to model), and view the output of our model as a \emph{re-ranking} of the items. In many real systems such base ranker is readily available. For example, the candidate set may be chosen from a huge item repository by an upstream model. Often candidate generator scores are available and can be used to obtain a base ranking via a simple sort. In this case we obtain the base ranking almost for free, as byproduct of candidate generation. Importantly, using a base ranker and focusing on re-ranking allows our seq2slate model to direct its modeling capacity at interactions between items rather than individual items. \section{\label{sec:training}Training with Click-Through Data} We now turn to the task of training the seq2slate model from data. A typical approach to learning in ranking systems is to run an existing ranker ``in the wild'' and log click-through data, which are then used to train an improved ranking model. This type of training data is relatively inexpensive to obtain, in contrast to human-curated labels such as relevance scores, ratings, or full rankings \cite{joachims2002}. Formally, each training example consists of a sequence of items $x=\{x_1,\ldots,x_n\}$, with $x_i\in\mathbb{R}^m$ and binary labels $y=(y_1,\ldots,y_n)$, with $y_i\in\{0,1\}$, representing user feedback (e.g., click/no-click). Our approach can be easily extended to more informative feedback, such as the level of user engagement with the chosen item (e.g., time spent), but to simplify the presentation we focus on the binary case. Our goal is to learn the parameters $\theta$ of $p_{\theta}(\pi_j |\pi_{<j},x)$ (\eqref{eq:attn}) such that permutations $\pi$ corresponding to ``good'' rankings are assigned high probabilities. Various performance measures ${\mathcal{R}}(\pi,y)$ can be used to evaluate the quality of a permutation $\pi$ given the labels $y$, for example, mean average precision (MAP), precision at $k$, or normalized discounted cumulative gain at $k$ (NDCG@k). Generally speaking, permutations where the positive labels rank higher are considered better. In the standard seq2seq setting, models are trained to maximize the likelihood of a target sequence of tokens given the input, which can be done by maximizing the likelihood of each target token given the previous target tokens using \eqref{eq:chain_rule}. In this case, the model is typically fed the ground-truth tokens as inputs to the next prediction step during training, an approach known as \emph{teacher forcing} \cite{Williams89TeacherForcing}. Unfortunately, this approach cannot be applied in our setting since we only have access to weak supervision in the form of labels $y$ (e.g., clicks), rather than ground-truth permutations. Instead, we next show how the seq2slate model can be trained directly from the labels $y$. \subsection{Training Using \textsc{Reinforce}} \label{sec:policy_gradient} One viable approach, which has been applied successfully in related tasks~\citep{bello2017nco,zhongSQL}, is to use \emph{reinforcement learning (RL)} to directly optimize for the ranking measure ${\mathcal{R}}(\pi,y)$. In this setup, the objective is to maximize the expected ranking metric obtained by sequences sampled from our model: \[ \max_\theta ~~ \mathbb{E}_{\pi \sim p_{\theta}(.|x)} [{\mathcal{R}}(\pi,y)]~. \] One can use policy gradients and stochastic gradient ascent to optimize $\theta$. The gradient is formulated using the popular \textsc{reinforce} update~\citep{reinforce}: {\small \begin{align} \label{eq:policy_grad} \nabla_\theta \mathbb{E}_{\pi \sim p_{\theta}(.|x)} [{\mathcal{R}}(\pi,y)] &= \mathbb{E}_{\pi \sim p_{\theta}(.\mid x)}\Big[{\mathcal{R}}(\pi,y) \nabla_\theta \log{p_{\theta}(\pi \mid x)}\Big]~. \end{align} }% This can be approximated via Monte-Carlo sampling as follows: {\small \begin{align} \label{eq:policy_grad_samples} &\approx \frac{1}{B} \sum_{k=1}^B \Big({\mathcal{R}}(\pi[k],y[k])-b_\mathcal{R}(x[k])\Big) \nabla_\theta \log{p_{\theta}(\pi[k] \mid x[k])}~, \end{align} }% where $k$ indexes ranking instances in a batch of size $B$, the $\pi[k]$ are permutations drawn from the model $p_\theta$, and $b_\mathcal{R}(x)$ denotes a baseline function that estimates the expected rewards in order to reduce variance. \subsection{Supervised Training} Policy gradient methods like \textsc{reinforce} are known to induce challenging optimization problems and can suffer from sample inefficiency and difficult credit assignment. As an alternative, we propose \emph{supervised learning} using the labels $y$. In particular, rather than waiting until the end of the output sequence as in RL above, we can give feedback to the model at each decoder step. Consider the first step, and recall that the model assigns a score $s_i$ to each item in the input (see~\eqref{eq:attn}); to simplify notation we omit the position superscript $j$ for now. Letting $s=(s_1,\ldots,s_n)$, we define a per-step loss $\ell(s,y)$ which essentially acts as a multi-label classification loss with labels $y$ as ground truth. Two natural, simple choices for $\ell$ are cross-entropy loss and hinge loss: \begin{align} \label{eq:losses} \ell_{\mathit{xent}}(s,y) &= -\sum_i \hat{y}_i \log p_i \\ \ell_{\mathit{hinge}}(s,y) &= \max\{0, 1 - \min_{i:y_i=1}s_i + \max_{j:y_j=0}s_j\} ~, \nonumber \end{align} where $\hat{y}_i=y_i/\sum_j y_j$, and $p_i$ is a softmax of $s$, as in \eqref{eq:attn}. Intuitively, with cross-entropy loss we try to assign high probabilities to positive labels \cite[see also][]{kurata2016}, while hinge loss is minimized when scores of items with positive labels are higher than scores of those with negative labels. Notice that both losses are convex functions of the scores $s$. To improve convergence, we consider a smooth version of the hinge loss where the maximum and minimum are replaced by their smooth counterparts: $\texttt{smooth-max}(s;\gamma)=\frac{1}{\gamma} \log \sum_i e^{\gamma s_i}$ (and smooth minimum is defined similarly, using $\min_i(s_i)=-\max_i(-s_i)$). Finally, we point out that any standard surrogate loss for ranking can be used as the per-step loss $\ell(s,y)$, including losses that depend on non-binary labels $y$, such as relevance scores. As mentioned above, a main difference of seq2slate from previous approaches is its use of sequential decoding. This does complicate the training of the model somewhat relative to the the case of one-shot decoding \cite{Mottini2017kdd,ai2018sigir}. Specifically, if we simply apply a per-step loss from \eqref{eq:losses} to all steps of the output sequence while reusing the labels $y$ at each step, then the loss is invariant to the resulting output permutation (i.e., predicting a positive item at the beginning of the sequence has the same cost as predicting it at the end). Instead, in order to train a seq2slate model we let the loss $\ell$ at each decoding step $j$ ignore the items already chosen, so no further loss is incurred after a label is predicted correctly. In particular, for a \emph{fixed} permutation $\pi$, define the \emph{sequence loss}: \begin{align} {\mathcal{L}}_\pi(S,y) = \sum_{j=1}^n w_j~ \ell_{\pi_{<j}}(s^j,y) ~, \label{eq:sequence_loss} \end{align} where $S=\{s^j\}_{j=1}^n$ are the model scores (see~\eqref{eq:attn}), and each $s^j = (s^j_1,\ldots,s^j_n)$ is the item-score vector for position $j$. In the sequel we will also use the abbreviation: ${\mathcal{L}}_\pi(\theta)\equiv{\mathcal{L}}_\pi(S(\theta), y)$. Importantly, the per-step loss $\ell_{\pi_{<j}}(s^j,y)$ depends only on the indices in $s^j$ and $y$ which are not in the prefix $\pi_{<j}$ (cf.~\eqref{eq:losses}). Including a per-step weight $w_j$ can encourage better performance earlier in the sequence. For example, we might set $w_j=1/\log(j+1)$ (along the lines of DCG). Alternatively, if optimizing for a particular slate size $k$ is desired, one can use the weights to restrict this loss to just the first $k$ output steps. We note that the loss above differs from the actual ranking measures used in evaluation (i.e., MAP, NDCG@k, etc.). On the other hand, any permutation that places the positive labels at the first positions gets 0 loss and optimizes all ranking measures, so in that sense the losses are aligned. This situation is quite common for surrogate losses in machine learning. Using the definition of the sequence loss above, our goal is to optimize the expected loss: \[ \min_\theta ~ \mathbb{E}_{\pi\sim p_\theta(\cdot|x)}[{\mathcal{L}}_\pi(\theta)]~, \] where \begin{equation} \label{eq:expected_loss} \mathbb{E}_{\pi\sim p_\theta(\cdot|x)}[{\mathcal{L}}_\pi(\theta)] = \sum_\pi p_\theta(\pi|x) {\mathcal{L}}_\pi(\theta)~. \end{equation} This corresponds to sampling the permutation $\pi$ according to the model, where $\pi_j$ is drawn from $p_\theta(\cdot|\pi_{<j},x)$ for each position $j$. For completeness, we derive the expected loss as a function of the model scores $S$ in \appref{app:expected_loss}. Notice that the expected loss in \eqref{eq:expected_loss} is differentiable everywhere since both $p_\theta(\pi|x)$ and ${\mathcal{L_\pi}}(\theta)$ are differentiable for any permutation $\pi$. In this case, the gradient is formulated as: {\small \begin{align} \nabla_\theta \mathbb{E}_\pi[{\mathcal{L}}_\pi(\theta)] =&~ \nabla_\theta \sum_\pi p_\theta(\pi|x) {\mathcal{L}}_\pi(\theta) \nonumber\\ =&~ \sum_\pi \left[ (\nabla_\theta p_\theta(\pi|x)) {\mathcal{L}}_\pi(\theta) + p_\theta(\pi|x) (\nabla_\theta {\mathcal{L}}_\pi(\theta)) \right] \nonumber\\ =&~ \mathbb{E}_{\pi\sim p_\theta(\cdot|x)} \left[ {\mathcal{L}}_\pi(\theta) \cdot \nabla_\theta \log p_\theta(\pi|x) + \nabla_\theta {\mathcal{L}}_\pi(\theta) \right]~, \label{eq:sampling_gradient} \end{align} }% which can be approximated from samples by: {\small \begin{align} \approx~ \frac{1}{B} \sum_{k=1}^B \Bigg[ & \Big({\mathcal{L}}_{\pi[k]}(S(\theta),y[k]) - b_\mathcal{L}(x[k])\Big) \nabla_\theta \log p_{\theta}(\pi[k] \mid x[k]) \nonumber\\ &+ \nabla_\theta {\mathcal{L}}_{\pi[k]}(S(\theta),y[k]) \Bigg] ~. \label{eq:sampling_gradient_samples} \end{align} }% Here $b_\mathcal{L}(x[k])$ is a baseline that approximates ${\mathcal{L}}_{\pi[k]}(\theta)$, introduced for variance reduction. This gradient is analogous to the \textsc{reinforce} update from \eqref{eq:policy_grad}--(\ref{eq:policy_grad_samples}), but where the loss ${\mathcal{L}}$ subsumes the role of the reward ${\mathcal{R}}$. Notice, however, that since the loss depends on the model parameters $\theta$ while the reward does not, the resulting update is quite different. Specifically, applying stochastic gradient descent intuitively decreases the probability of drawing samples with high losses (left term in \eqref{eq:sampling_gradient}), as in \textsc{reinforce}, but in addition also reduces the loss of any sample (right term in \eqref{eq:sampling_gradient}), which differs from \textsc{reinforce} \cite[see also][Eq.~(4)]{schulman2015}. \subsubsection*{\bf Greedy Decoding} In many seq2seq applications, using greedy decoding at test time performs better than sampling from the model \cite[e.g.,][]{Ranzato2016,searnn2018leblond}. Therefore, it makes sense to also consider training the model using a greedy decoding policy, which is an alternative approach to sampling (cf.~\eqref{eq:sampling_gradient_samples}). The greedy policy consists of selecting the item that maximizes $p_\theta(\cdot|\pi_{<j},x)$ at every step $j$. The resulting permutation $\pi^*$ then satisfies $\pi_j^* = \argmax_i ~ p_\theta(\pi_j=i|\pi^*_{<j},x)$ and our loss simply becomes ${\mathcal{L}}_{\pi^*}(\theta)$. Unlike the sampling-based loss in \eqref{eq:expected_loss}, the greedy policy loss is not continuous everywhere since a small change in the scores $S$ may result in a jump between permutations $\pi^*$, and therefore a jump in the value of ${\mathcal{L}}_{\pi^*}(\theta)$. Specifically, the loss is non-differentiable when any $s^j$ has multiple maximizing arguments. Outside this measure-zero subspace, the loss is continuous (almost everywhere), and the gradient is well-defined. For both training policies (sampling and greedy), we minimize the loss via stochastic gradient descent over mini-batches in an \emph{end-to-end} fashion. \section{Experimental Results} \label{sec:experiments} We evaluate the performance of our seq2slate model on a collection of ranking tasks. In \secref{sec:letor_experiments} we use learning-to-rank benchmark data to study the behavior of the model. We then apply our approach to a large-scale commercial recommendation system and report the results in \secref{sec:real_experiments}. \paragraph{Implementation details} We set hyperparameters of our model to values inspired by the literature. All experiments use mini-batches of $128$ training examples and LSTM cells with $128$ hidden units. We train our models with the Adam optimizer~\citep{adam} and an initial learning rate of $0.0003$ decayed every $1000$ steps by a factor of $0.96$. Network parameters are initialized uniformly at random in $[-0.1, 0.1]$. To improve generalization, we regularize the model by using dropout with probability of dropping $p_{\mathit{dropout}}=0.1$ and L2 regularization with a penalty coefficient $\lambda=0.0003$. Unless specified otherwise, all results use supervised training with cross-entropy loss $\ell_{\mathit{xent}}$ and the sampling policy. At inference time, we report metrics for the greedy policy. We use an exponential moving average with a decay rate of $0.99$ as the baseline functions $b_\mathcal{R}(x)$ and $b_\mathcal{L}(x)$ in \eqref{eq:policy_grad_samples} and (\ref{eq:sampling_gradient_samples}), respectively. When training the seq2slate model with \textsc{reinforce}, we use ${\mathcal{R}}=\texttt{NDCG}@10$ as the reward function and do not regularize the model (since we observed no overfitting during training with the noisy policy gradients). We also considered a bidirectional encoder RNN~\citep{bidir}, a stacked LSTM, and models with more hidden units, but found that these did not lead to significant improvements in our experiments. \subsection{Learning-to-Rank Benchmarks} \label{sec:letor_experiments} To understand the behavior of the proposed model, we conduct experiments using two learning-to-rank datasets. We use two of the largest publicly available benchmarks: the \href{https://webscope.sandbox.yahoo.com/catalog.php?datatype=c}{\blue{Yahoo Learning to Rank Challenge}} data (set 1),% \footnote{{\scriptsize \url{https://webscope.sandbox.yahoo.com/catalog.php?datatype=c}}} and the \href{https://www.microsoft.com/en-us/research/project/mslr/}{\blue{Microsoft Web30k}} dataset.% \footnote{{\scriptsize \url{https://www.microsoft.com/en-us/research/project/mslr/}}} These datasets only provide feature vectors for each query-document pair, so all context (query) features are embedded within the item feature vectors themselves. We adapt the procedure proposed by \citet{joachims2017} to generate click data. The original procedure is as follows: first, a base ranker is trained from the raw data. We select this base ranker by training all models in the \href{https://sourceforge.net/p/lemur/wiki/RankLib/}{\blue{RankLib}} package,\footnote{{\scriptsize \url{https://sourceforge.net/p/lemur/wiki/RankLib/}}} and choosing the one with the best performance on each data set (MART for Yahoo and LambdaMART for Web30k). We generate an item ranking using the base model, which is then used to generate training data by simulating a user ``cascade'' model: a user observes each item with decaying probability $1/i^\eta$, where $i$ is the base rank of the item and $\eta$ is a parameter of the generative model. This simulates a noisy sequential scan by the user. An observed item is clicked if its ground-truth relevance score is above a threshold (relevant: $\{2,3,4\}$, irrelevant: $\{0,1\}$), otherwise no click is generated. Unfortunately, the original datasets only include a per-item relevance score, which is independent of the other items. This means that there are no direct high-order interactions between the clicks, and therefore the joint probability in \eqref{eq:chain_rule} is just $p(\pi|x) = \prod_{j=1}^n p(\pi_j|x)$. In this case a pointwise ranker is optimal so there would be no need for seq2slate. Therefore, in order to introduce high-order dependencies, we augment the above procedure as follows, creating a generative process dubbed \emph{diverse-clicks}. When observing a relevant item, the user will only click if it is not too similar to previously clicked items (i.e, diverse enough), thus reducing the total number of clicks. Similarity is defined as being in the smallest $q$ percentile (i.e., $q=0.5$ is the median) of Euclidean distances between pairs of feature vectors within the same ranking instance: $D_{ij}=\|x_i-x_j\|$. We use $\eta=0$ (no decay, since clicks are sparse anyway due to the diversity term) and $q=0.5$. We also discuss variations of this model below. Since our focus is on modeling high-order interactions, all results reported in this section are w.r.t.~the generated binary labels and not the original relevance scores. \begin{table*}[t!] \begin{center} {\small \begin{tabular}{|c|ccc|ccc|} \hline \multirow{2}{*}{Ranker} & \multicolumn{3}{|c|}{Yahoo} & \multicolumn{3}{|c|}{Web30k} \\ {} & MAP & NDCG@5 & NDCG10 & MAP & NDCG@5 & NDCG@10 \\ \hline seq2slate & \bf{0.67} & \bf{0.69} & \bf{0.75} & \bf{0.51} & \bf{0.53} & \bf{0.59} \\ AdaRank & 0.58 & 0.61 & 0.69 & 0.37 & 0.38 & 0.46 \\ Coordinate Ascent & 0.49 & 0.51 & 0.59 & 0.31 & 0.33 & 0.39 \\ LambdaMART & 0.58 & 0.61 & 0.69 & 0.42 & 0.46 & 0.52 \\ ListNet & 0.49 & 0.51 & 0.59 & 0.43 & 0.47 & 0.53 \\ MART & 0.58 & 0.60 & 0.68 & 0.39 & 0.42 & 0.48 \\ Random Forests & 0.54 & 0.57 & 0.65 & 0.36 & 0.39 & 0.45 \\ RankBoost & 0.50 & 0.52 & 0.60 & 0.24 & 0.25 & 0.30 \\ RankNet & 0.54 & 0.57 & 0.64 & 0.43 & 0.47 & 0.53 \\ \hline \end{tabular} } \end{center} \caption{Performance of seq2slate and other baselines on data generated with diverse-clicks.} \label{tab:letor_diverse} \end{table*} Using the generated training data, we train both our seq2slate model and baseline rankers from the \href{https://sourceforge.net/p/lemur/wiki/RankLib/}{\blue{RankLib}} package: AdaRank \cite{adarank}, Coordinate Ascent \cite{rank_coordinate_ascent}, LambdaMART \cite{lambdamart}, ListNet \cite{cao2007listwise}, MART \cite{mart}, Random Forests \cite{randomforests}, RankBoost \cite{rankboost}, RankNet \cite{RankNet2005}. Some of these baselines use deep neural networks (e.g., RankNet, ListNet), so they are strong state-of-the-art models with comparable complexity to seq2slate. The results in \tabref{tab:letor_diverse} show that seq2slate significantly outperforms all the baselines, suggesting that it can better capture and exploit the dependencies between items in the data. To better understand the behavior of the model, we visualize the probabilities of the attention from \eqref{eq:attn} for one of the test instances in \figref{fig:attention}. Interestingly, the model produces slates that are close to the input ranking, but with some items demoted to lower positions, presumably due to the interactions with previous items. \begin{figure}[t] \centering \includegraphics[width=150pt]{attention_probs_3_v3.pdf} \caption{Visualization of attention probabilities on benchmark data. Intensities correspond to $p^j_i$ for each item $i$ in step $j$.} \label{fig:attention} \end{figure} \begin{table*}[t!] \begin{center} {\footnotesize \resizebox{0.95\textwidth}{!}{% \begin{tabular}{|c|cccc|cccc|} \hline \multirow{2}{*}{Ranker} & \multicolumn{4}{|c|}{Yahoo} & \multicolumn{4}{|c|}{Web30k} \\ {} & MAP & NDCG@5 & NDCG@10 & rank-gain & MAP & NDCG@5 & NDCG@10 & rank-gain \\ \hline seq2slate & \bf{0.67} & \bf{0.69} & \bf{0.75} & \bf{7.4} & \bf{0.51} & \bf{0.53} & \bf{0.59} & \bf{18.3} \\ Greedy policy & 0.66 & 0.69 & 0.75 & 7.2 & 0.50 & 0.52 & 0.59 & 18.3 \\ smooth-hinge & 0.66 & 0.69 & 0.75 & 7.1 & 0.49 & 0.51 & 0.58 & 17.9 \\ \textsc{reinforce} & 0.66 & 0.68 & 0.75 & 5.7 & 0.44 & 0.47 & 0.53 & -0.5 \\ one-step decoder & 0.66 & 0.69 & 0.75 & 6.4 & 0.49 & 0.51 & 0.58 & 16.5 \\ shuffled data & 0.57 & 0.60 & 0.67 & -- & 0.40 & 0.40 & 0.48 & -- \\ base ranker (no-op) & 0.58 & 0.61 & 0.69 & 0 & 0.45 & 0.48 & 0.54 & 0 \\ \hline \end{tabular} } } \end{center} \caption{Comparison of model and data variants for seq2slate on data generated with diverse-clicks.} \label{tab:letor_variants} \end{table*} We next consider several variations of the generative model and of the seq2slate model itself. Results are reported in \tabref{tab:letor_variants}. The rank-gain metric per example is computed by summing the positions change of all positive labels in the re-ranking, and this is averaged over all examples (queries). \paragraph{Comparison of training variants} In \tabref{tab:letor_variants}, we compare the different training variants outlined in \secref{sec:training}, namely, cross entropy with the greedy or sampling policy, a smooth hinge loss with $\gamma=1.0$, and \textsc{reinforce}. We find that supervised learning with cross entropy generally performs best, with the smooth hinge loss doing slightly worse. Our weakly supervised training methods have positive rank gain on all datasets, meaning they improve over the base ranker. The results from \tabref{tab:letor_variants} suggest that training with \textsc{reinforce} yields comparable results on Yahoo but significantly worse results on the more challenging Web30k dataset. In terms of training time, \textsc{reinforce} needed 4X more time till convergence. We find no significant difference in performance between relying on the greedy and sampling policies during training. \paragraph{One-step decoding} We compare seq2slate to the model which uses a single decoding step, referred to as \emph{one-step decoder} (see \secref{sec:model}). In \tabref{tab:letor_variants} we see that this model has comparable performance to the sequential decoder. One possible explanation for the comparable performance of the one-step decoder is that the interactions in our generated data are rather simple and can be effectively learned by the encoder. By contrast, in \secref{sec:real_experiments} we show that on more complex real-world data, sequential decoding can perform significantly better than one-step decoding. In terms of runtime, we observed a 4X decrease in training time and a 3X decrease in inference time for the one-step decoder compared to sequential decoding (for the real-world data in \secref{sec:real_experiments} below, one-step decoding was 2.5X faster per iteration in both training and inference). This suggests that when inference time is crucial, as in many real-world systems, one might prefer the faster single-shot option. Having said that, we point out that even with sequential decoding the runtime was not a bottleneck in our case and we were able to train a seq2slate model on millions of examples in a couple of hours, and serve live traffic in $O(10)$ milliseconds. For this reason we also did not make an effort to optimize the code, so the numbers above can probably be reduced significantly. \paragraph{Sensitivity to input order} Previous work suggests that the performance of seq2seq models is often sensitive to the order in which the input is processed \cite{vinyals2016,nam2017multilabel,ai2018sigir}. To test the sensitivity of seq2slate to the order in which items are processed, we consider the use of seq2slate without relying on the base ranker to order the input. Instead, items are fed to the model in random order. Since learning the correct ranking from a single example may be hard, we generate multiple copies of each training example, each with a different randomly shuffled input order. Specifically, in \tabref{tab:letor_variants} we show results for 10 generated examples per original example under `shuffled data'. The results show that the performance is indeed significantly worse in this case, which is consistent with previous studies. It suggests that reranking is an easier task than ranking from scratch. \begin{table*}[t] \begin{center} \small{ \begin{tabular}{|c|ccc|ccc|} \hline \multirow{2}{*}{Ranker} & \multicolumn{3}{|c|}{Yahoo} & \multicolumn{3}{|c|}{Web30k} \\ {} & MAP & NDCG@5 & NDCG@10 & MAP & NDCG@5 & NDCG@10 \\ \hline seq2slate & 0.82 & 0.82 & 0.84 & \bf{0.44} & \bf{0.54} & \bf{0.50} \\ AdaRank & 0.83 & 0.81 & 0.84 & 0.41 & 0.52 & 0.48 \\ Coordinate Ascent & 0.83 & 0.82 & 0.85 & 0.39 & 0.47 & 0.44 \\ LambdaMART & \bf{0.84} & \bf{0.83} & \bf{0.85} & 0.41 & 0.52 & 0.48 \\ ListNet & 0.83 & 0.83 & 0.85 & 0.41 & 0.53 & 0.49 \\ MART & 0.83 & 0.82 & 0.85 & 0.41 & 0.52 & 0.48 \\ Random Forests & 0.83 & 0.82 & 0.84 & 0.40 & 0.48 & 0.45 \\ RankBoost & 0.83 & 0.83 & 0.85 & 0.38 & 0.43 & 0.41 \\ RankNet & 0.83 & 0.82 & 0.84 & 0.35 & 0.36 & 0.35 \\ \hline \end{tabular} } \end{center} \caption{Performance of seq2slate and other baselines on data generated with similar-clicks.} \label{tab:letor_similarity} \end{table*} \begin{table*}[t] \begin{center} {\footnotesize \resizebox{0.95\textwidth}{!}{% \begin{tabular}{|c|cccc|cccc|} \hline \multirow{2}{*}{Ranker} & \multicolumn{4}{|c|}{Yahoo} & \multicolumn{4}{|c|}{Web30k} \\ {} & MAP & NDCG@5 & NDCG@10 & rank-gain & MAP & NDCG@5 & NDCG10 & rank-gain \\ \hline seq2slate & \bf{0.82} & \bf{0.82} & \bf{0.84} & \bf{8.5} & \bf{0.44} & \bf{0.54} & \bf{0.50} & \bf{16.0} \\ Greedy policy & \bf{0.82} & \bf{0.82} & \bf{0.84} & \bf{8.5} & 0.44 & 0.54 & 0.50 & 15.9 \\ smooth-hinge & 0.80 & 0.80 & 0.82 & 7.7 & 0.44 & 0.54 & 0.50 & 15.9 \\ \textsc{reinforce} & \bf{0.82} & \bf{0.82} & \bf{0.84} & \bf{8.5} & 0.42 & 0.53 & 0.49 & -14.8 \\ one-step decoder & 0.81 & 0.81 & 0.82 & 7.7 & 0.44 & 0.53 & 0.49 & 15.5 \\ shuffled data & 0.79 & 0.78 & 0.79 & -- & 0.42 & 0.48 & 0.46 & -- \\ base ranker (no-op) & 0.78 & 0.76 & 0.79 & 0 & 0.43 & 0.53 & 0.49 & 0 \\ \hline \end{tabular} } } \end{center} \caption{Comparison of model and data variants for seq2slate on data generated with similar-clicks.} \label{tab:letor_similarity_variants} \end{table*} \paragraph{Adaptivity to the type of interaction} To demonstrate the flexibility of seq2slate, we generate data using a variant of the diverse-clicks model above. Specifically, in the \emph{similar-clicks} model, the user also clicks on observed irrelevant items if they are similar to previously clicked items (increasing the number of total clicks). As above, we use the pairwise distances in feature space $D_{ij}$ to determine similarity. For this model we use $q=0.5$, and $\eta=0.3$ for Web30k, $\eta=0.1$ for Yahoo, to keep the proportion of positive labels similar.% \footnote{The value of $\eta$ was chosen such that the percentage of examples with no positive labels (clicks) at all remained small enough and roughly the same in all datasets (around 1.15\% of all examples).} The results in \tabref{tab:letor_similarity} show that seq2slate has comparable performance to the baseline rankers, with slightly lower performance on Yahoo and significantly better performance on the harder Web30k data. This demonstrates that our model can adapt to various types of interactions in the data. Notice that no changes to the model or training algorithm were necessary for seq2slate. In contrast, if one used a specific interaction model for `diverse-clicks', then a different model would be required for the `similar-clicks' data, a distinction not needed with seq2slate. \subsection{Real-World Data} \label{sec:real_experiments} We also apply seq2slate to a ranking problem from a large-scale commercial recommendation system. We train the model using massive click-through logs (comprising roughly $O(10^7)$ instances) with cross-entropy loss, the greedy policy, L2-regularization and dropout. The data has item sets of varying size, with an average $n$ of 10.24 items per example. We learn embeddings of the raw inputs as part of training. \tabref{tab:real_data} shows the performance of seq2slate and the one-step decoder compared to the production base ranker on test data (of roughly the same size as the training data). Significant gains are observed in all performance metrics, with sequential decoding outperforming the one-step decoder. This suggests that sequential decoding may more faithfully capture complex dependencies between the items. \begin{table}[t!] \centering {\small \begin{tabular}{|c|c|c|c|c|} \hline Ranker & MAP & NDCG@5 & NDCG@10 & rank-gain \\ \hline one-step decoder & +26.79\% & +10.69\% & +40.67\% & 0.83 \\ seq2slate & +31.32\% & +14.47\% & +45.77\% & 1.087 \\ \hline \end{tabular} } \caption{Performance compared to a competitive base production ranker on real data.} \label{tab:real_data} \end{table} \begin{figure}[t] \centering \includegraphics[width=200pt]{rank_distribution.pdf} \caption{Difference in CTR per position between a seq2slate model and a base production ranker in a live experiment.} \label{fig:rank_dist} \end{figure} Finally, we let the learned seq2slate model run in a live experiment (A/B testing) and re-rank the result of the current production recommender system. We compute the click-through rate (CTR) in each position (\#clicks/\#examples) for seq2slate. The production base ranker serves traffic outside the experiment, and we compute CTR per position for this traffic as well. \figref{fig:rank_dist} shows the difference in CTR per position, indicating that seq2slate has significantly higher CTR in the top positions. This suggests that seq2slate indeed places items that are likely to be chosen higher in the ranking. \section{Related Work} In this section we discuss additional related work. We build on the recent impressive success of seq2seq models in complex prediction tasks, including machine translation \cite{Sutskever2014,Bahdanau2015}, parsing \cite{vinyals2015parsing}, combinatorial optimization \cite{vinyals2015,bello2017nco}, multi-label classification \cite{wang2016cnn-rnn,nam2017multilabel}, and others. Our work differs in that we explicitly target the ranking task, which requires a novel approach to training seq2seq models from weak feedback (click-through data). Most of the work on ranking mentioned above uses shallow representations. However, in recent years deep models have been used for information retrieval, focusing on embedding queries, documents and query-document pairs \cite{huang2013,Guo2016cikm,palangi2016,Wang2017attnletor,Pang2017DeepRank} (see also recent survey by \citet{mitra2017}). Rather than embedding individual items, in seq2slate a representation of the entire slate of items is learned and encoded in the RNN state. Moreover, learning the embeddings ($x$) can be easily incorporated into the training of the sequence model to optimize both simultaneously end-to-end. Closest to ours are the recent works of \citet{Mottini2017kdd} and \citet{ai2018sigir}, where an RNN is used to encode a set of items for ranking. There are some differences between the approach of \citet{ai2018sigir} and ours, including using GRU cells instead of LSTM cells, reversing the input order (the highest ranking item is fed to the encoder last), and training from relevance scores instead of click-through data. More importantly, both works \cite{Mottini2017kdd,ai2018sigir} use a single decoding step. In contrast, we apply sequential decoding, which directly allows item scores to change based on previously chosen items. We believe that this significantly simplifies modeling and inference with complex high-order interactions between items, and indeed show that it performs much better in practice (see \secref{sec:real_experiments}). Finally, \citet{SantaCruz:CVPR2017} recently proposed an elegant deep learning framework for learning permutations based on the so called Sinkhorn operator, building on prior work by \citet{adams2011sinkhorn}. Their approach uses a continuous relaxation of permutation matrices (i.e., the set of doubly-stochastic matrices, or the Birkhoff polytope). Followup work has focused on improved training and inference procedures, including a Gumbel softmax distribution to enable efficient learning \cite{mena2018}, a reparameterization of the Birkhoff Polytope for variational inference \cite{linderman18a}, and an Actor-Critic policy gradient training procedure \cite{emami2018}. However, these works are focused on reconstruction of scrambled objects (i.e., matchings), and it is not obvious how to extend it to our ranking setting, where no ground-truth permutation is available. \section{Conclusion} We presented a novel approach to ranking sets of items called seq2slate. We found the formalism of pointer-networks particularly suitable for this setting. We emphasized the modeling and computational advantages of using sequential decoding, which allowed the model to dynamically adjust placement of items on the slate given previous choices. We addressed the challenge of training the model from weak user feedback (click-trough logs) to improve the ranking quality. To this end, we proposed new sequence losses along with corresponding gradient-based updates. Our experiments show that the proposed approach is highly scalable and can deliver significant improvements in ranking results. Our work can be extended in several directions. In terms of architecture, we aim to explore the \emph{Transformer} network \cite{vaswani2017transformer,universal_transformers} in place of the RNN. Several algorithmic variants can potentially improve the performance of our model. For inference, beam-search has been shown to improve predictions of several seq2seq models \cite{wiseman2016}, and we believe can do the same for seq2slate. For training, several approaches have been recently proposed for seq2seq models, including Actor-Critic \cite{Bahdanau2017actor_critic} and more recently SeaRNN \cite{searnn2018leblond}, and it will be interesting to test their performance in the ranking setting. Finally, an interesting future direction is to study off-policy correction for seq2slate \cite{joachims2018,minminWSDM19}. In this setting, training examples are assigned \emph{importance weights} in order to account for the fact that the labels were obtained using a different policy than the one we wish to evaluate during training. In particular, the expected sequence loss is adjusted to account for this mismatch as follows:% \footnote{Substituting $\mathcal{L}_\pi(\theta)$ by $\mathcal{R}(\pi,y)$ yields an equivalent formulation for the expected reward from \secref{sec:policy_gradient}.} \[ \mathbb{E}_{\pi \sim p_{\theta}(.|x)} [{\mathcal{L}}_\pi(\theta)] = \mathbb{E}_{\pi \sim p_{\text{base}}(.|x)} \left[\frac{p_{\theta}(\pi|x)}{p_{\text{base}}(\pi|x)} {\mathcal{L}}_\pi(\theta)\right]~, \] where $p_\text{base}$ is the probability of $\pi$ under the base ranker (i.e., logging policy). This expectation can then be approximated from logged samples as in \secref{sec:training}. We leave this extension to future work.
{'timestamp': '2019-03-21T01:02:20', 'yymm': '1810', 'arxiv_id': '1810.02019', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02019'}
arxiv
\section{Introduction} The use of images and video sequences has greatly increased because of rapid growth of the Internet and multimedia systems. A lot of studies on secure, efficient and flexible communications have been reported\cite{huang2014survey,lagendijk2013encrypted,zhou2014designing}. For securing multimedia data, full encryption with provable security (as with RSA and AES) is the most secure option. However, many multimedia applications have been seeking a trade-off in security to enable other requirements, e.g.,\, a small amount of processing, bitstream compliance, or signal processing in the encrypted domain. Here, perceptual encryption schemes have been studied as ways of achieving this trade-off\cite{Zeng_2003,Ito_2008,Kiya_2008,Ito_2009,Tang_2014}. \par Image encryption sometimes must be performed prior to image compression in certain practical scenarios such as secure image transmission through an untrusted channel provider. This framework is carried out by Encryption-then-Compression (EtC) systems\cite{zhou2014designing,Erkin_2007,nimbokar2014survey}. In this paper, we focus on EtC systems, although the traditional way of securely transmitting images is to use a Compression-then-Encryption (CtE) system. However, most studies on EtC systems assume the use of their own compression schemes that have no compatibility with international standards such as JPEG\cite{Johnson_2004,Liu_2010,Zhang_2010,Hu_2014,zhou2014designing}. In this paper, we focus on block scrambling-based image encryption schemes which have compatibility with international compression standards\cite{watanabe2015encryption,kurihara2015encryption,KURIHARA2015,KuriharaBMSB,Kuri_2017}. \par On the other hand, almost all social networking service (SNS) providers support JPEG, one of the most widely used image compression standards\cite{JPEG_1991}. However, JPEG images are uploaded to SNS providers by users on the assumption that the uploaded images in SNS servers are trustable, so the privacy of uploaded images is not under the control of the users. Nevertheless, there is no way to protect the uploaded images, because SNS providers generally manipulate them. Although some papers have studied image manipulation on social media\cite{Caldelli_2017,giudice2016_arxive,Moltisanti2015_ICIAP}, e.g., alternation of image filenames or headers of JPEG images, the recompression parameters and the conditions of image manipulation remain unclear. Therefore, we investigated how SNS providers manipulate images and whether EtC systems are applicable to their methods. \par We uploaded a lot of images to five SNS providers, Facebook, Twitter, Google+, Tumblr and Flickr, to examine the robustness of EtC systems. We found that encrypted images including some block distortion due to image manipulations on some SNS providers greatly reduce the quality of the decrypted images. Otherwise, we confirmed that the EtC systems are applicable to five SNS providers. \section{Preparation} \subsection{Necessity of EtC systems} The importance of this work is to point out that most encryption schemes, such as RSA and AES, are not applicable to images uploaded to SNS providers and cloud photo storage services like google photos, due to manipulation on providers, and to show that EtC systems are useful for such applications under some conditions. If we send encrypted images directly to receivers, this difficulty will not be generated, but some advantages obtained by using the providers, e.g. data storage services, will be lost. As a result, uploaded images to such providers have currently no guarantee on privacy. \begin{figure}[t] \centering \includegraphics[width =8.4cm]{./image/step.eps} \caption{Block scrambling-based image encryption} \label{fig:step} \end{figure} \subsection{Block Scrambling-based Image Encryption} Block scrambling-based image encryption schemes have been proposed for EtC systems\cite{kurihara2015encryption,KURIHARA2015,KuriharaBMSB,Kuri_2017}. In these schemes\cite{watanabe2015encryption,kurihara2015encryption,KURIHARA2015,KuriharaBMSB,Kuri_2017}, an image with $X \times Y$ pixels is first divided into non-overlapping blocks with $B_x \times B_y$ pixels, with the number of blocks $n$ given by \begin{equation} n = \lfloor \frac{X}{B_x} \rfloor \times \lfloor \frac{Y}{B_y} \rfloor \end{equation} where $\lfloor \cdot \rfloor$ is the floor function that rounds down to the nearest integer. Next, four block scrambling-based processing steps, as illustrated in Fig.\,\ref{fig:step}, are applied to the divided image. The procedure of performing image encryption to generate an encrypted image $I_e$ is as follows: \begin{figure}[!t] \centering \hspace{2mm}\subfloat[Block rotation]{\includegraphics[width=3cm]{./image/emm_rot.eps} \label{fig:label-B}} \hfil \subfloat[Block inversion]{\includegraphics[clip, width=3cm]{./image/emm_inv.eps} \label{fig:label-C}} \caption{Block rotation and inversion} \label{fig:rotinv} \end{figure} \begin{itemize} \setlength{\parskip}{0cm} \setlength{\itemsep}{0cm} \item[Step 1:] Divide an image with $X \times Y$ pixels into blocks with $B_x \times B_y$ pixels, and randomly permute the divided blocks using a random integer generated by a secret key $K_1$, where $K_1$ is commonly used for all color components. In this study, $B_{x}=B_{y}=16$. This is the same choice that was used in \cite{KURIHARA2015}. \item[Step 2:] Rotate and invert randomly each block (see Fig.\,\ref{fig:rotinv}) by using a random integer generated by a key $K_2$, where $K_2$ is commonly used for all color components as well. \item[Step 3:] Apply the negative-positive transformation to each block by using a random binary integer generated by a key $K_3$, where $K_3$ is commonly used for all color components. In this step, the transformed pixel value in the $i$th block $B_i$, $p'$, is computed as \begin{equation} p'= \left\{ \begin{array}{ll} p & (r(i)=0) \\ p \oplus (2^L-1) & (r(i)=1) \end{array} \right. \end{equation} where $r(i)$ is a random binary integer generated by $K_3$ and $p \in B_i$ is the pixel value of the original image with $L$ bpp. \item[Step 4:] Shuffle three color components in each block (color component shuffling) by using a random senary integer generated by a key $K_4$. \end{itemize} \begin{comment} \begin{figure}[!t] \captionsetup[subfigure]{justification=centering} \centering \hspace{2mm} \subfloat[Original image\cite{Nemoto_2014_MEX}\newline($X \times Y$ = $1920 \times 1080$)] {\includegraphics[clip, width=3.9cm]{./image/19_ori.eps} \label{fig:label-B}} \hfil \subfloat[Encrypted image\newline($B_{x}=B_{y}=16, n=8040$)] {\includegraphics[clip, width=3.9cm]{./image/19_enc.eps} \label{fig:label-C}} \\ \hspace{2mm} \subfloat[Decrypted image with block artifact (PSNR=31.4dB, sub-sampling ratio=4:2:0, downloaded from Facebook)] {\includegraphics[clip, width=3.9cm]{./image/emm_noise2.eps} \label{fig:label-B}} \hfil \subfloat[Decrypted image (PSNR=36.3dB, sub-sampling ratio=4:2:0, downloaded from Twitter)] {\includegraphics[clip, width=3.9cm]{./image/emm_nonoise2.eps} \label{fig:label-C}} \caption{Examples of encrypted image and decrypted images, downloaded from Facebook and Twitter} \label{fig:oriencex} \end{figure} \end{comment} \begin{figure}[!t] \captionsetup[subfigure]{justification=centering} \centering \hspace{2mm} \subfloat[Original image\cite{Nemoto_2014_MEX}\newline($X \times Y$ = $256 \times 144$)] {\includegraphics[clip, width=3.9cm]{./image/re_19}} \hfil \subfloat[Encrypted image\newline($B_{x}=B_{y}=16, n=144$)] {\includegraphics[clip, width=3.9cm]{./image/enc_19.eps}} \\ \hspace{2mm} \subfloat[Decrypted image with block artifact (PSNR=26.57dB, sub-sampling ratio=4:2:0, downloaded from Facebook)] {\includegraphics[clip, width=3.9cm]{./image/dec_fb_19.eps}} \hfil \subfloat[Decrypted image (PSNR=29.37dB, sub-sampling ratio=4:2:0, downloaded from Twitter)] {\includegraphics[clip, width=3.9cm]{./image/dec_tw_19.eps}} \caption{Examples of encrypted image and decrypted images, downloaded from Facebook and Twitter} \label{fig:oriencex} \end{figure} An example of an encrypted image is illustrated in Fig.\,\ref{fig:oriencex}(b); Fig.\,\ref{fig:oriencex}(a) is the original one. The key space of the block scrambling-based image encryption is generally large enough to resist brute-force attacks\cite{KURIHARA2015}. On the other hand, jigsaw puzzle solver attacks, which utilize correlations among pixels in each block, have been considered\cite{CHUMAN2017ICASSP,CHUMAN2017ICME,CHUMAN2017IEICE}. It is confirmed that appropriate selection of the block size and combination of encryption steps can improve the strength of EtC systems. \begin{figure}[t] \centering \includegraphics[width =7.6cm]{./image/new_etc.eps} \caption{EtC system} \label{fig:etc} \end{figure} \subsection{Application to Social Media} Fig.\,\ref{fig:etc} illustrates the scenario of this paper, where a user wants to securely transmit an image $I$ to a receiver via an SNS provider. Since the user does not give the secret key $K$ to the provider, the privacy of the image to be shared is under the control of the user, even when the provider decompresses it. Therefore, the user can ensure privacy by him/herself. Even if the encrypted images saved on the SNS servers are leaked by malicious users, third parties are not able to see them unless they have the key. \par Meanwhile, it is known that almost all SNS providers manipulate images uploaded by their users, e.g., by rescaling the image resolution and recompressing with different parameters, for decreasing their data size. Manipulation of encrypted images by SNS providers might distort the decrypted ones like in Fig.\,\ref{fig:oriencex}(c). Although numerous studies have examined the conditions for resizing images\cite{giudice2016_arxive,Moltisanti2015_ICIAP}, the actual recompression parameters and conditions remain unpublished by SNS providers and researchers. Therefore, we investigated how each SNS provider manipulates images uploaded by users. \section{Image Manipulation and Robustness} In this section, we examine how each SNS provider manipulates images uploaded by users. Then, the conditions to avoid block distortion are discussed with regard to applying EtC systems to social media. \subsection{Image Manipulation on Social Media} We focus on two key aspects regarding image manipulation. The first aspect is the maximum resolution of the uploaded images. The second is the parameters of recompression. \begin{figure*}[t] \centering \includegraphics[width =17cm]{./image/newflow3.eps} \caption{Image manipulation on social media} \label{fig:flowchart} \end{figure*} \subsection*{(1) Maximum Resolution} A number of SNS providers automatically resize images uploaded by users when the size of the images exceeds the maximum set by them \cite{giudice2016_arxive,Moltisanti2015_ICIAP}. When the resolution is changed in the encrypted domain, decrypting the images downloaded from providers becomes difficult. \par Fig.\,\ref{fig:flowchart} shows the classification of SNS providers in terms of recompression and resizing. Twitter, Facebook, and Tumblr apply resizing algorithms to uploaded images, if the images satisfy the following conditions. Twitter resizes uploaded images that are over 4096$\times$4096 pixels or exceed 3MB. Facebook has two modes to control the maximum resolution, i.e., Low Quality (LQ) and High Quality (HQ). The selection of LQ enables users to upload up to images having 960$\times$960 pixels without any resizing. Meanwhile, HQ allows them to upload images up to 2048$\times$2048 pixels. Tumblr changes the resolution of uploaded images that are over 1280$\times$1280 pixels. Unlike these three providers, Google+ and Flickr do not carry out any resizing operations, even when the resolution of the uploaded images is large. \subsection*{(2) Recompression} Next, we investigated how each SNS provider recompresses images uploaded by users. As illustrated in Fig.\,\ref{fig:oriencex}, the quality of downloaded images depends on the provider. Block artifacts in the decrypted images might be generated by recompression, as shown in Fig.\,\ref{fig:oriencex}(c). \par In terms of recompression, SNS providers are divided into two groups, as shown in Fig.\,\ref{fig:flowchart}. Some providers, such as Google+, Tumblr, and Flickr, manipulate only meta-data embedded in image files. Meanwhile, Facebook recompresses all images regardless of the data size and resolution. Twitter recompresses images only when the data size of images uploaded by users is larger than a threshold. \par Most SNS providers support JPEG \cite{JPEG_1991}, one of the most widely used image compression standards. Therefore, we decided to focus on JPEG. JPEG encoding of color images consists of six steps: \begin{enumerate} \item[1)]Perform the color transformation from RGB space to YCbCr space. \item[2)]Sub-sample the Cb and Cr components to reduce the spatial resolution. \item[3)]Divide the image into 8-by-8 blocks. \item[4)]Apply the 2-D discrete cosine transform (DCT) to each block. \item[5)]Carry out block-based quantizing with a quantization matrix \bm{$Q$}. \item[6)]Carry out entropy coding using Huffman coding. \end{enumerate} SNS providers reduce the data size of uploaded images by changing the quality factor $Q_{f}$(1$\leqq$$Q_{f}$$\leqq$100), which is a parameter to control the matrix \bm{$Q$} in step 5). $Q_{f}$=100 gives the best quality, and $Q_{f}$=1 provides the worst quality. \par There are three sub-sampling ratios in the JPEG standard, referred to as 4:2:0 (reduction by a factor of 2 in both the horizontal and vertical directions), 4:2:2 (reduction by a factor of 2 in the horizontal direction), and 4:4:4 (no sub-sampling). The sub-sampling conditions are also important when considering the effect of image manipulation by social media. The JPEG bitstream of a color image is generated by performing steps 3) to 6) on the brightness component Y and sub-sampled chroma components Cb and Cr independently. \begin{table*}[t] \centering \caption{Relationship between uploaded JPEG files and downloaded ones in terms of sub-sampling ratios} \begin{threeparttable} \scalebox{1}{ \begin{tabular}{|c||c|c||c|c|} \hline \multirow{2}{*}{SNS provider} & \multicolumn{2}{c||}{Uploaded JPEG file} & \multicolumn{2}{c|}{Downloaded JPEG file} \\ \cline{2-5} & \begin{tabular}[c]{@{}c@{}}Sub-sampling ratio\end{tabular} & $Q_{f}$ & \begin{tabular}[c]{@{}c@{}}Sub-sampling ratio\end{tabular} & $Q_{f}$ \\ \hline \multirow{4}{*}{Twitter (Up to 4096$\times$4096 pixels)} & \multirow{2}{*}{4:4:4} & low & \multicolumn{2}{c|}{No recompression} \\ \cline{3-5} & & high & 4:2:0 & 85 \\ \cline{2-5} & \multirow{2}{*}{4:2:0} & 1,2,\ldots84 & \multicolumn{2}{c|}{No recompression} \\ \cline{3-5} & & 85,86,\ldots100 & 4:2:0 & 85 \\ \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Facebook (HQ, Up to 2048$\times$2048 pixels)\\ Facebook (LQ, Up to 960$\times$960 pixels)\end{tabular}} & 4:4:4 & \multirow{6}{*}{1,2,\ldots100} & \multirow{2}{*}{4:2:0} & \multirow{2}{*}{71,72,\ldots85} \\ \cline{2-2} & 4:2:0 & & & \\ \cline{1-2} \cline{4-5} \multirow{4}{*}{\begin{tabular}[c]{@{}c@{}}Tumblr (Up to 1280$\times$1280 pixels)\\ Google+\\ Flickr\end{tabular}} & \multirow{2}{*}{4:4:4} & & \multicolumn{2}{c|}{\multirow{4}{*}{No recompression}} \\ & & & \multicolumn{2}{c|}{} \\ \cline{2-2} & \multirow{2}{*}{4:2:0} & & \multicolumn{2}{c|}{} \\ & & & \multicolumn{2}{c|}{} \\ \hline \end{tabular} } \end{threeparttable} \label{tb:change_sampling} \end{table*} \subsection{Recompression Parameters} \label{recompress} Although some image manipulation specifications on SNS providers have been previously reported\cite{Caldelli_2017,giudice2016_arxive,Moltisanti2015_ICIAP}, the recompression conditions and recompression parameters are still unclear. In the previous works\cite{Caldelli_2017,giudice2016_arxive,Moltisanti2015_ICIAP}, the maximum resolution condition to avoid resizing uploaded images, alternation of image filenames and manipulation of JPEG headers have been investigated. This paper investigates how the uploaded images are manipulated by the SNS providers in terms of the color sub-sampling ratio and quality factor. In the investigation, this paper focuses on 4:4:4 and 4:2:0 sub-sampling ratios, although there are other sub-sampling ratios used in JPEG compression, such as 4:4:0 and 4:2:2 sub-sampling ratios, because considering these two ratios can determine the requirements to avoid block artifacts. Moreover, 4:4:4 and 4:2:0 sub-sampling ratios are widely used by most JPEG applications, including SNS providers. Table\,\ref{tb:change_sampling} shows the relationship between uploaded images and downloaded ones in terms of sub-sampling rate and quality factor. This relationship, which has not been investigated before in any published study, was confirmed by uploading and downloading a lot of JPEG images to individual SNS providers through a personal computer. For instance, if a user uploads JPEG images compressed with 4:4:4 sampling to Facebook, a receiver will view JPEG files manipulated with 4:2:0 sampling and certain quality factors (71$\leqq$$Q_{f}$$\leqq$85). Note that $Q_f$ were estimated by using JPEGsnoop software\cite{JPEGsnoop}, which utilizes the scaling method from Independent JPEG Group (IJG)\cite{JPEGLIB} to obtain the scaling factor used for generating the quantization table. Let us consider image manipulation on Facebook and Twitter in more detail. \subsection*{a) Image Manipulation on Facebook} Facebook recompresses uploaded JPEG files with the sizes of up to 2048$\times$2048 (HQ) or up to 960$\times$960 (LQ) as follows. \begin{enumerate} \item[1)]Decompress JPEG files as color images in the spatial domain. \item[2)]Compress the images at 4:2:0 sub-sampling ratio and specific $Q_{f}$(71$\leqq$$Q_{f}$$\leqq$85) in accordance with the Facebook compression algorithm. \item[3)]Save the recompressed JPEG files on a server to publish them for a receiver. \end{enumerate} In the above way, all uploaded images are converted to JPEG files with 4:2:0 sampling regardless of the data size of those images. As a result, the JPEG images with 4:2:0 color sub-sampling ratio are interpolated to increase the spatial resolution for chroma components in the decoding process. Since this interpolation process utilizes the relationship among blocks, encrypted images with 4:2:0 sub-sampling are affected by this interpolation. Hence, block artifacts are generated in the decrypted image, as shown in Fig.{\,\ref{fig:oriencex}(c)}. \begin{table}[t] \centering \caption{Condition of JPEG images to prevent block artifacts from being generated by Facebook and Twitter ($\circ$: Block artifact is generated, $\times$: No block artifact)} \label{fbtw} \begin{tabular}{|c|cc|cc|} \hline SNS provider & \multicolumn{2}{c|}{Twitter} & \multicolumn{2}{c|}{Facebook} \\ \hline \begin{tabular}[c]{@{}c@{}}Sub-sampling ratio\\ (Uploaded JPEG file)\end{tabular} & 4:4:4 & 4:2:0 & 4:4:4 & 4:2:0 \\ \hline Block artifact & $\times$ & $\times$ & $\times$ & $\circ$ \\ \hline \end{tabular} \end{table} \subsection*{b) Image Manipulation on Twitter} Twitter recompresses uploaded JPEG files in accordance with the sub-sampling ratio. When a user uploads JPEG files compressed at high quality and with 4:4:4 sampling to Twitter, the images are recompressed as follows. \begin{enumerate} \item[1)]Decompress JPEG files as color images in the spatial domain. \item[2)]Compress the images at 4:2:0 sub-sampling ratio and $Q_{f}$=85. \item[3)]Save the recompressed JPEG files on a server to publish them for a receiver. \end{enumerate} The image manipulation conditions of uploaded JPEG images with 4:4:4 sub-sampling depend on not only the uploaded quality factors, but also other properties of images, so it is difficult to provide the strict definition of the uploaded quality factor conditions. Thus, the condition of $Q_f$ is shown as low/high in Table\,\ref{tb:change_sampling}. Twitter also recompresses uploaded JPEG files if they were compressed under 4:2:0 sampling and high quality ($Q_{f}$$\geqq$85) as follows. \begin{enumerate} \item[1)]Reconstruct the DCT coefficients by using entropy decoding. \item[2)]Quantize the DCT coefficients by using a quantization matrix \bm{$Q$} with $Q_{f}$=85. \item[3)]Carry out entropy coding using Huffman coding. \item[4)]Save the recompressed JPEG files on a server to publish them for a receiver. \end{enumerate} Note that Twitter manipulates only meta-data, including in the header of the uploaded JPEG images, if the images were compressed at a low quality such as $Q_{f}$ = 60. \subsection{Requirements to Avoid Distortion} Decrypted images often have block distortion that depends on the relationship between the encryption and recompression conditions. Here, we examine how to avoid such distortion. In particular, we find that block distortion does not result from image manipulation on social media if the encrypted images satisfy the two conditions listed below. \begin{enumerate} \item[a)]The resolution of the encrypted images is left unchanged by the SNS providers. \item[b)]The encrypted images uploaded by users are compressed with 4:4:4 sub-sampling ratio. \end{enumerate} \par Requirement a) means that the resolution of the encrypted images needs to be smaller than the maximum resolution that each provider decides as a resizing condition. Resizing the resolution of encrypted images makes the block size of the encrypted images smaller, although the JPEG compression is still carried out based on the size of $8 \times 8$. As a result each $16 \times 16$-block in resized encrypted images includes pixels from originally different blocks, so the compression performance decreases and block distortion is generated in the decrypted image due to the discontinuity among pixels. Moreover, as shown in Fig.\,\ref{fig:flowchart}, users need not consider the maximum resolution of encrypted images when uploading to Google+ and Flickr. \par Requirement b) means that we have to consider the sub-sampling ratios of the encrypted images. Compression of JPEG images with 4:2:0 sub-sampling ratio is performed to increase the spatial resolution for chroma components in the decoding process. This interpolation processing is carried out by using the relationship among blocks. Therefore, the encrypted images compressed with 4:2:0 sub-sampling ratio are affected by this interpolation, while JPEG images compressed with 4:4:4 sampling do not need any interpolation. \par However, JPEG files compressed with 4:2:0 sub-sampling ratio can sometimes avoid block distortion even if interpolation is carried out. Table\,\ref{fbtw} indicates the conditions under which JPEG files uploaded by users will avoid block artifacts. As discussed in Sec.\,\ref{recompress}, Facebook performs interpolation in the spatial domain when JPEG images compressed with 4:2:0 sampling ratio are uploaded by users. Consequently, images with artifacts such as in Fig.\,\ref{fig:oriencex}(c) are generated. Meanwhile, Twitter manipulates JPEG images in the DCT domain for some operations such as quantization. Therefore, JPEG images that are compressed with 4:2:0 sampling can avoid to block distortion due to recompression when they are uploaded to Twitter. Thus, users do not need to consider the sampling ratios of encrypted images when uploading to Twitter. \section{Experimental Results} We evaluated the effectiveness of EtC systems for social media by conducting a number of simulations. In the simulations, encrypted and compressed JPEG files were uploaded to SNS providers. \subsection{Simulation Conditions} The following procedure was carried out to evaluate the robustness of EtC systems based on Fig.\,\ref{fig:etc}. \begin{enumerate} \item[1)]Generate an encrypted image $I_{e}$ from an original image $I$ in accordance with Fig.\,\ref{fig:step}. \item[2)]Compress the encrypted image $I_{e}$. \item[3)]Upload the encrypted JPEG image $I_{ec}$ to SNS providers. \item[4)]Download the recompressed JPEG image $\hat{I_{ec}}$ from the providers. \item[5)]Decompress the encrypted JPEG image $\hat{I_{ec}}$. \item[6)]Decrypt the manipulated image $\hat{I_{e}}$. \item[7)]Compute the PSNR value between the original image $I$ and $\hat{I}$. \end{enumerate} \begin{figure} \centering \includegraphics[width =7.5cm]{./image/fb_win.eps} \caption{Experimental result using original images as ground truth ones (Facebook)} \label{tb:fb_result} \end{figure} We made use of the JPEG implementation from IJG\cite{JPEGLIB} in steps 2) and 5). Then, we compressed each image with 4:2:0 or 4:4:4 sampling ratio and $Q_{f}=80,81\ldots100$. To compare the PSNR values in step 7), the original image $I$ was compressed without any encryption and then uploaded. \begin{figure} \centering \includegraphics[width =7.5cm]{./image/tw_win.eps} \caption{Experimental result using original images as ground truth ones (Twitter)} \label{tb:tw_result} \end{figure} \par To reduce dispersion, we used 20 FHD images from Ultra-Eye dataset ($1920 \times 1080$)\cite{Nemoto_2014_MEX}. We focused on Facebook and Twitter, because these SNS providers recompress all images uploaded by users that meet the conditions (see Fig.\,\ref{fig:flowchart}). The encrypted and non-encrypted JPEG files compressed with 4:2:0 and 4:4:4 sampling were uploaded to the providers. \subsection{Compression Performance of EtC System} Figs.\,\ref{tb:fb_result} and \ref{tb:tw_result} show the experimental results, where the average PSNR values of 20 images were calculated by using original images without any compression distortion as ground truth ones. The PSNRs of the decrypted images were low when images compressed with 4:2:0 sub-sampling ratio were uploaded to Facebook. This shows that block distortion due to recompression in the spatial domain greatly reduces the quality of decrypted images. Even though the decrypted images with 4:4:4 sub-sampling ratio did not include block distortion, their PSNRs were lower than those of the non-encrypted images compressed with 4:4:4 sub-sampling ratio, as indicated in Fig.\,\ref{tb:fb_result}. This is because Facebook recompresses uploaded JPEG images with a non-constant $Q_{f}(71,72,\ldots85)$, unlike Twitter. \begin{figure} \centering \includegraphics[width =7.8cm]{./image/single_compressed_as_ref.eps} \caption{Experimental result using JPEG encoded images as ground truth ones (Facebook)} \label{fig:single_as_ground} \end{figure} \begin{figure}[t] \captionsetup[subfigure]{justification=centering} \centering \subfloat[Original image\cite{Nemoto_2014_MEX} ($X \times Y$ = $1920 \times 1080$)] {\includegraphics[clip, width=8cm]{./image/org_20.eps} } \\ \subfloat[Decrypted image with block artifact (PSNR=29.89dB, downloaded from Facebook, uploaded image with 4:2:0 sub-sampling and $Q_f=85$)] {\includegraphics[clip, width=8cm]{./image/dec_faQ85.eps} } \\ \subfloat[Decrypted image (PSNR=35.99dB, downloaded from Twitter, uploaded image with 4:2:0 sub-sampling and $Q_f=85$)] {\includegraphics[clip, width=8cm]{./image/dec_twQ85.eps} } \caption{Examples of decrypted images, downloaded from Facebook and Twitter} \label{fig:best_worst} \end{figure} \par On the other hand, Twitter recompresses images with 4:2:0 sub-sampling ratio in the DCT domain. Thus, the PSNRs of the decrypted images uploaded to Twitter were almost same as the non-encrypted ones even if the images were compressed with 4:2:0 sub-sampling ratio. Regarding the decrypted images with 4:4:4 sub-sampling ratio, the PSNRs were almost the same as the non-encrypted ones. \par To clearly show the quality degradation caused by the providers, in Fig.\,\ref{fig:single_as_ground}, PSNR values were calculated by using JPEG encoded images as ground truth ones, which correspond to images taken by a smartphone. PSNRs of both non-encrypted and encrypted ones have almost the same tendency as the result in Fig.\ref{tb:fb_result}. \par Moreover, the examples of an original image and the decrypted images downloaded from Facebook and Twitter are shown in Fig.\,\ref{fig:best_worst}. The result shows that the decrypted image downloaded from Twitter did not include any block artifacts. In contrast, block artifacts were generated in the decrypted image downloaded from Facebook. \section{Conclusion} This paper proposed an application of EtC systems to enable users to send images securely to receivers through SNS providers. Moreover, we investigated how SNS providers manipulate JPEG images uploaded by users in terms of their maximum resolution and recompression parameters. In addition to the conditions that encrypted images uploaded by users generate some block distortion, the quality of images downloaded from the SNS providers was confirmed. On the other hand, we determined that EtC systems are applicable to five SNS providers, Facebook, Twitter, Google+, Tumblr and Flickr, if the encrypted images meet certain conditions. \bibliographystyle{ieicetr}
{'timestamp': '2018-10-05T02:07:08', 'yymm': '1810', 'arxiv_id': '1810.02062', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02062'}
arxiv
\section{Introduction} The notion of {\em rank} plays an important role in combinatorics on words. Given a subset $X$ of the free monoid $A^*$ over a finite alphabet $A$, the rank of $X$, in symbols $r(X)$, is defined as the smallest number of words needed to express all words of $X$, i.e., as the minimal cardinality of a set $F$ such that $X \subseteq F^*$. Notice that this minimal set $F$ may not be unique. For instance, the set $X = \{aabca,aa,bcaaa\}$ has rank $2$ and there exist two distinct sets $F_1 = \{aa,bca\}$ and $F_2 = \{a,bc\}$ such that $X \subseteq F_1^*$ and $X \subseteq F_2^*$. It is worth noticing that since $r(X) \leq min\{|X|,|A|\}$, $r(X)$ is always finite even if $X$ is an infinite set. A set $X$ is said to be {\em elementary} if $r(X) = |X|$. The notion of rank -- and the related notion of elementary set -- have been investigated in several papers (cf.~\cite{Neraud90,Neraud92,Neraud93}). In particular, in~\cite{Neraud90} it is shown that the problem to decide whether a finite set is elementary is co-NP-complete. In this paper, we introduce the notion of primitiveness for a {\em set} of words, which is closely related to that of rank. We first define the notion of {\em $k$-maximal} submomoid. A submonoid $M$ of $A^*$, generated by $k$ elements, is $k$-maximal if there does not exist another submonoid generated by at most $k$ words containing $M$. We then call a set $X \subseteq A^*$ {\em primitive} if it is the basis of a $|X|$-maximal submonoid. Notice that if $X$ is primitive, then $r(X) = |X|$, i.e., $X$ is elementary. The converse is not in general true: there exist elementary sets that are not primitive. For instance, the set $F_{1}=\{aa,bca\}$ is elementary, but it is not primitive since $F_{1}^{*} \subseteq F_{2}^*=\{a,bc\}^*$. The set $F_{2}$, instead, is primitive. The notion of primitive set can be seen as an extension of the classical notion of primitive word. Indeed, given a word $w \in A^*$, the set $\{w\}$ is primitive if and only if the word $w$ is primitive. For instance, the set $\{abab,abababab\}$ is not elementary, the set $\{abab\}$ is elementary but not primitive, and the set $\{ab\}$ is primitive. We have from that definition that for every set $X$, there exists a primitive set $Y$ such that $X \subseteq Y^*$. The set $Y$ is therefore called a \emph{primitive root} of $X$. However, the primitive root of a set is not, in general, unique. Consider for instance the set $X = \{abcbab,abcdcbab,abcdcdcbab\}$. It has rank $3$, hence it is elementary, yet it is not primitive. Indeed, $X \subseteq \{ab,cb,cd\}^*$. The set $\{ab,cb,cd\}$ is primitive, and it is a primitive root of $X$. However, it is not the only primitive root of $X$: the set $\{abc,dc,bab\}$ is primitive and $X \subseteq \{abc,dc,bab\}^*$, hence $\{abc,dc,bab\}$ is another primitive root of $X$. In the special case of sets of rank $1$, clearly these always have a unique primitive root. For instance, the primitive root of the set $\{abab,abababab\}$ is the set $\{ab\}$. As a main result, we prove that if a set has rank $2$, then it has a unique primitive root. This is equivalent to say that for every pair of nonempty words $\{x,y\}$ such that $xy\neq yx$ there exists a unique primitive set $\{u,v\}$ such that $x$ and $y$ can be written as concatenations of copies of $u$ and $v$. The proof is based on the algebraic properties of $k$-maximal submonoids of a free monoid. In this investigation, we also take into account another notion of rank, that of {\em free rank} (in the literature, in order to avoid ambiguity, the notion of rank we gave above is often referred to as the {\em combinatorial rank}). The free rank of a set $X$ is the cardinality of the basis of the minimal {\em free} submonoid containing $X$. Closely related to the notion of free rank is the {\em defect theorem}, which states that if $X$ is not a {\em code} (i.e., $X^*$ is not a free submonoid), then the free rank of $X$ is strictly smaller than its cardinality. We are specially interested in the case $k=2$ (that is, the case of $2$-maximal submonoids) and we use the fact that, in this special case, the notions of free rank and (combinatorial) rank coincide. A fundamental step in our argument is Theorem \ref{th_case_2}, which states that the intersection of two $2$-maximal submonoids is either the empty word or a submonoid generated by one primitive word. As a consequence, for every submonoid $M$ generated by two words that do not commute, there exists a unique $2$-maximal submonoid containing $M$. This is equivalent to the fact that every set of rank $2$ has a unique primitive root. One of the examples we gave above shows that this result is no longer true for sets of rank $3$ or larger --- this highlights the very special role of sets of rank $1$ or $2$. From these results we derive some consequences on the combinatorics of a {\em single} word. Given a word $w$, we say that $\{x,y\}$ is a binary root of $w$ if $w$ can be written as a concatenation of copies of $x$ and $y$ and $\{x,y\}$ is a primitive set. We prove that every primitive word $w$ has at most one binary root $\{x,y\}$ such that $|x|+|y|<\sqrt{|w|}$. That is, the binary root of a word is unique provided the length of the word is sufficiently large with respect to the size of the root. The notion of binary root of a single word may be seen as a way to capture a hidden ``repetitive structure'', which encompasses the classical notion of integer repetition (non-primitive word). Indeed, the existence in a word $w$ of a ``short'' (with respect to $|w|$) binary root reveals some hidden repetition in the word. As described in the last section, our results can also be compared to previous approaches that investigate {\em pseudo-repetitions}, where an involutive morphism (or antimorphism) $\theta$ is defined on the set of words $A^*$. This idea stems from the seminal paper of Czeizler, Kari and Seki~\cite{CKS}, where originally $\theta$ was the Watson-Crick complementarity function and the motivation was the discovery of hidden repetitive structures in biological sequences. A word $w$ is called a $\theta$-power if there exists a word $v$ such that $w$ can be factored using copies of $v$ and $\theta(v)$ --- otherwise the word $w$ is called $\theta$-primitive. If $v$ is a $\theta$-primitive word, then it is called the $\theta$-primitive root of $w$. Of course, since the same applies to the word $\theta(w)$, these definitions can be given in terms of the pair $\{w,\theta(w)\}$ and considering as the root the pair $\{v,\theta(v)\}$. With our results, we generalize this setting by considering as a root any pair of words $\{x,y\}$, i.e., dropping the relation between the components of the pair. \section{Preliminaries}\label{sec:prem} Given a finite nonempty set $A$, called the \emph{alphabet}, with $A^*$ (resp.~$A^+=A^*\setminus\{\epsilon\}$) we denote the {\em free monoid} (resp.~{\em free semigroup}) generated by $A$, i.e., the set of all finite words (resp.~all finite nonempty words) over $A$. The length $|w|$ of a word $w\in A^*$ is the number of its symbols. The length of the empty word $\epsilon$ is $0$. For a word $w=uvz$, with $u,v,z\in A^*$, we say that $v$ is a \emph{factor} of $w$. Such a factor is called \emph{internal} if $u,z\neq \epsilon$, a \emph{prefix} if $u=\epsilon$, or a \emph{suffix} if $z=\epsilon$. A word $w$ is \emph{primitive} if $w=v^n$ implies $n=1$, otherwise it is called \emph{a power}. Equivalently, $w$ is primitive if and only if it is not an internal factor of $w^2$. It is well known in combinatorics on words (see, e.g., \cite{Lothaire1}) that given two words $x$ and $y$ we have $xy=yx$ if and only if $x$ and $y$ are powers of the same word. Given a subset $X$ of $A^*$, we let $X^*$ denote the submonoid of $A^*$ generated by $X$ (under concatenation). Conversely, given a submonoid $M$ of $A^*$, there exists a unique set $X$ that generates $M$ and is minimal for set inclusion. In fact, $X$ is the set \begin{equation}\label{base} X=(M \setminus \{\epsilon\}) \setminus (M \setminus \{\epsilon\})^2, \end{equation} i.e., $X$ is the set of nonempty words of $M$ that cannot be written as a product of two nonempty words of $M$. The set $X$ will be referred to as the {\em minimal generating set} of $M$, or the set of {\em generators} of $M$. Let $M$ be a submonoid of $A^*$ and $X$ its minimal generating set. $M$ is said to be {\em free} if any word of $M$ can be {\em uniquely} expressed as a product of elements of $X$. The minimal generating set of a free submonoid $M$ of $A^*$ is called a {\em code}; it is referred to as \emph{the basis} of $M$. It is easy to see that a set $X$ is a code if and only if, for every $x,y \in X$, $x\neq y$, one has $xX^* \cap yX^* = \emptyset$. We say that $X$ is a {\em prefix code} (resp.~a {\em suffix code}) if for all $x,y \in X$, one has $x \cap yA^* = \emptyset$ (resp.~$x \cap A^*y = \emptyset$). A code is a {\em bifix code} if it is both a prefix and a suffix code. It follows from elementary automata theory that if $X$ is a prefix code, then there exists a DFA $\mathcal{A}_X$ recognizing $X^*$ whose set of states $Q_X$ verifies (cf.~\cite{BPR}): $$\vert Q_X \vert \leq \sum_{x \in X} \vert x \vert - \vert X \vert +1.$$ A submonoid $M$ of $A^*$ is called {\em pure} (cf. \cite{Restivo74}) if for all $w\in A^*$ and $n \geq 1$, $$w^n \in M \Rightarrow w \in M.$$ By a result of Tilson~\cite{Tilson}, any nonempty intersection of free submonoids of $A^*$ is free. As a consequence, for any subset $X \subseteq A^*$, there exists the smallest free submonoid containing $X$. Here we mention the well-known Defect Theorem (cf.~\cite{BPPR79}, ~\cite[Chap.~1]{Lothaire1}, \cite[Chap.~6]{Lothaire2}), a fundamental result in the theory of codes that provides a relation between a given subset $X$ of $A^*$ and the basis of the minimal free submonoid containing $X$ (called the {\em free hull} of $X$). \begin{theorem}[Defect Theorem]\label{thm:defect} Let $X$ be a finite nonempty subset of $A^*$. Let $Y$ be the basis of the free hull of $X$. Then either $X$ is a code, and $Y=X$, or $$|Y| \leq |X| -1.$$ \end{theorem} As in \cite{HarjuK04}, given a set $X \subseteq A^*$, we let $r_f(X)$ denote the cardinality of the basis of the free hull of $X$, called the {\em free rank} of $X$. Notice that for any subset $X \subseteq A^*$, $X$ and $X^*$ have the same free rank. Furthermore, by $r(X)$ we denote the {\em combinatorial rank} (or simply rank) of $X$, defined by: $$r(X)=\min\{|Y| \mid Y \subseteq A^*, X \subseteq Y^*\}.$$ With this notation, the Defect Theorem can be stated as follows. \begin{theorem} Let $X$ be a finite nonempty subset of $A^*$. Then $r_f(X) \leq |X|$, and the equality holds if and only if $X$ is a code. \end{theorem} Note that, for any $X \subseteq A^+$, one has $$r(X) \leq r_f(X) \leq |X|.$$ \begin{example} Let $X= \{aa,ba,baa\}$. One can prove that $X$ is a code, hence we have $r_f(X)=3$, while $r(X)=2$ since $X\subset \{a,b\}^*$. For $X= \{aa, aaa\}$, we have $r(X)=r_f(X)=1.$ \end{example} \begin{remark}\label{rank2} If $\vert X\vert=2$ then $r_f(X)=r(X)$. So for sets of cardinality $2$ we will not specify if we refer to the free rank or to the (combinatorial) rank. Moreover, from the complexity point of view, N\'eraud proved that deciding if a set has rank $2$ can be done in polynomial time \cite{Neraud93}, whereas for general rank $k$ it is an NP-hard problem~\cite{Neraud90}. \end{remark} The {\em dependency graph} (cf.~\cite{HarjuK04}) of a finite set $X\subset A^+$ is the graph $G_X=(X,E_X)$ where $E_X=\{(u,v) \in X \times X \mid uX^* \cap vX^* \neq \emptyset\}$. Notice that if $X$ is a code, then $G_X$ has no edge. Furthermore, if $(u,v)$ is an edge, then $u$ is a prefix of $v$ or vice versa. In \cite{Harju1986} and \cite{HarjuK04}, the following useful lemma is proved. \begin{lemma}[Graph Lemma] Let $X\subseteq A^+$ be a finite set that is not a code. Then $$r_f(X)\leq c(X) < |X|,$$ where $c(X)$ is the number of connected components of $G_X$. \end{lemma} \begin{example} Let $X= \{a,ab, abc, bca, acb, cba\}.$ We have $acba= a \cdot cba= acb \cdot a$ and $abca= a \cdot bca= abc \cdot a$. The basis of the free hull of $X$ is $Y=\{a, ab, bc, cb\}$, hence $r_f(X)=4$. Furthermore, $r(X)=3$ and $c(X)= 4$, as shown in Figure~\ref{fig:1}. \end{example} \begin{figure} \begin{center} \begin{tikzpicture} [scale=.8,auto=left,every node/.style={circle,fill=blue!20}] \node (na) at (4,9) {$a$}; \node (nabc) at (6,9) {$abc$}; \node (nbca) at (8,9) {$bca$}; \node (nacb) at (4,7.5) {$acb$}; \node (nab) at (6,7.5) {$ab$}; \node (ncba) at (8,7.5) {$cba$}; \foreach \from/\to in {na/nabc} \draw (\from) -- (\to); \foreach \from/\to in {na/nacb} \draw (\from) -- (\to); \end{tikzpicture} \end{center} \caption{\label{fig:1}The dependency graph of $X= \{a, ab, abc, bca, acb, cba\}$.} \end{figure} \section{$k$-Maximal Monoids}\label{sec:prim} With $\mathcal{M}_k$ we denote the family of submonoids of $A^*$ having at most $k$ generators in $A^+$. The following definition is fundamental for the theory developed in this paper. \begin{definition} A submonoid $M \in \mathcal{M}_k$ is $k$-maximal if for every $M^\prime \in \mathcal{M}_k$, $M \subseteq M^\prime$ implies $M=M^\prime$. \end{definition} In other words, $M$ is $k$-maximal if it is not possible to find another submonoid generated by at most $k$ words containing $M$. \begin{example} Let $A=\{a,b,c\}$. The submonoid $M=\{a,abca\}^*$ is not $2$-maximal since $abca$ can be factored with $a$ and $bc$, hence $M$ is contained in $\{a,bc\}^*$. On the contrary, $\{a,bc\}^*$ is $2$-maximal since, obviously, $a$ and $bc$ cannot be factored using two common factors. \end{example} \begin{example}\label{3-max} Let $A=\{a,b,c,d\}$. The submonoid $\{a,cbd,dbd\}^*$ is $3$-maximal, whereas $\{a,cbd, dcbd\}^*$ is not $3$-maximal since it is contained in $\{a,d,cb\}^*.$ \end {example} \begin{proposition}\label{prop:bifix} Let $M$ be a $k$-maximal submonoid and $X$ its minimal generating set. Then, $X$ is a bifix code. \end{proposition} \begin{proof} By contradiction, if $X$ is not prefix (resp. not suffix) then there exist $u,v \in X$ and $t\in A^+$ such that $v=ut$ (resp $v=tu$). It follows that $X^* \subseteq (X \setminus \{v\} \cup \{t\})^*$, whence $X^*=M$ is not $k$-maximal. \qed \end{proof} \begin{remark} By Proposition \ref{prop:bifix}, it follows that if $X^*$ is $k$-maximal, then $r(X)=r_f(X)=k.$ The inverse implication does not hold in general. For example, the submonoid $X^*=\{a,cbd,dcbd\}^*$ of Example~\ref{3-max} has both rank and free rank equal to $3$ and is bifix, but it is not $3$-maximal. \end{remark} \begin{proposition}\label{prop:pure} Let $M$ be a $k$-maximal submonoid. Then $M$ is a pure submonoid. \end{proposition} \begin{proof} We have to show that, for every $z\in A^*$, if $z^n\in M$, for some $n\geq 1$, then $z\in M$. Let $X$ be the minimal generating set of $M$. If $z^n\in M$, for some $n>1$, then $z\in X$ or the set $X \cup \{z\}$ is not a code. By the Defect Theorem (Theorem~\ref{thm:defect}), there exist $u_1,u_2,\ldots,u_k\in A^+$ such that $(X \cup \{z\})^*\subseteq \{u_1, u_2,...,u_k\}^*$. Since $X^*\subseteq \{u_1, u_2,\ldots,u_k\}^*$ and $X^*$ is $k$-maximal, we have that $X=\{u_1, u_2,\ldots,u_k\}$. Therefore, $X \cup \{z\} \subseteq X^*$, hence $z\in X^*$. \end{proof} As a direct consequence of Proposition \ref{prop:pure}, we have that a $k$-maximal submonoid is generated by primitive words. However, not any set of $k$ primitive words generates a $k$-maximal monoid (e.g., $X=\{ab,ba\}^*$ is not $2$-maximal since it is contained in $\{a,b\}^*$). Submonoids generated by two words, i.e., the elements of $\mathcal{M}_2$, are of special interest for our purposes. They have been extensively studied in literature (cf.~\cite{LenSchut,Kar84,Neraud93,Lerest}) and play an important role in some fundamental aspects of combinatorics on words. The reader may observe that, as a consequence of some well-known results in combinatorics on words, the submonoids in $\mathcal{M}_1$ have the following important property: If $x^*$ and $u^*$ are $1$-maximal submonoids (i.e., $x$ and $u$ are primitive words) then $x^* \cap u^* = \{\epsilon\}.$ Next Theorem~\ref{th_case_2}, which represents the main result of this section, can be seen as a generalization of this result to the case of $2$-maximal submonoids. It is known (see \cite{Kar84}) that if $X$ and $U$ both have rank $2$, then the intersection $X^*\cap U^*$ is a free monoid generated either by at most two words or by an infinite set of words. \begin{example}\label{no2max} Let $X_1=\{abca,bc\}$ and $U_1=\{a, bcabc\}$. One can verify that $X_1^* \cap U_1^*=\{abcabc, bcabca\}^*.$ Let $X_2=\{aab, aba\}$ and $U_2=\{a, baaba\}$. Then $X_2^* \cap U_2^*=(a(abaaba)^*baaba)^*.$ \end{example} In the previous example, we have two submonoids that are not $2$-maximal. Indeed, $X_1^*, U_1^* \subseteq \{a, bc\}^*$ and $X_2^*, U_2^* \subseteq \{a, b\}^*.$ We now address the question of finding the generators of the intersection of two $2$-maximal submonoids. \begin{theorem}\label{th_case_2} Let $X^*=\{x,y\}^*$ and $U^*=\{u,v\}^*$ be two $2$-maximal submonoids. If $X^*\cap U^*\neq \{\epsilon\}$, then there exists a word $z\in A^+$ such that $X^*\cap U^*=z^*$. Moreover, $z$ is primitive, that is, $X^*\cap U^*$ is $1$-maximal. \end{theorem} \begin{proof} If $X \cap U =\{z\}$ then $X^*\cap U^*=z^*$. Indeed, if $y=v=z$ and $X^*\cap U^*\neq z^*$ we have the following graph $G_Z$ for $Z=\{x,u,z\}$: \begin{center} \begin{tikzpicture} [scale=.8,auto=left,every node/.style={circle,fill=blue!20}] \node (nx) at (4,9) {$x$}; \node (ny) at (6,8) {$z$}; \node (nu) at (4,7.5) {$u$}; \foreach \from/\to in {nx/nu} \draw (\from) -- (\to); \end{tikzpicture} \end{center} since $\{x,z\}$ and $\{u,z\}$ are bifix sets. Hence, by the Graph Lemma, $r_f(Z) \leq c(Z)=2$, contradicting the $2$-maximality of $X$ and $U$. If $X \cap U = \emptyset$, let us consider the set $Z=X \cup U$. We have that $r_f(Z) >2$ since $X^*$ and $U^*$ are $2$-maximal, and, by the Defect Theorem (Theorem~\ref{thm:defect}), $r_f(Z) < 4$ since $Z^*$ is not free (as $X^*\cap U^*$ contains a nonempty word). Hence, the free rank of $Z$ is equal to $3$. Let $z$ be a generator of $X^*\cap U^*$. So, $z=x_1x_2\cdots x_m=u_1u_2\cdots u_n$, with $m,n\geq 1$, $x_i \in X$ and $u_j \in U$. Clearly, since $z$ is a generator, for every $p<m$ and $q<n$ one has $x_1x_2\cdots x_p\neq u_1u_2\cdots u_q$. Moreover, we can suppose, without loss of generality, that $x_1 =x$ and $u_1 = u$. We want to prove that $z$ is the unique generator of $X^* \cap U^*$. By contradiction, suppose that there exists another generator $z'\neq z$ of $X^*\cap U^*$, and let $z'=x'_1x'_2\cdots x'_r=u'_1u'_2.\cdots u'_s$. If $x'_1 \neq x_1 = x$, then $x'_1 = y$ and we have $xZ^* \cap uZ^* \neq \emptyset$ and $yZ^* \cap u'_1Z^* \neq \emptyset$. In both cases ($u'_1 = u$ or $u'_1 = v$), we have that the graph $G_Z$ has two edges, i.e., $c(Z) = 2$, which is impossible by the Graph Lemma. So $x_1 = x'_1 = x$. In the same way we prove that $u_1 = u'_1 = u$, and therefore in the graph $G_Z$ there is only one edge, namely the one joining $x$ and $u$. \begin{center} \begin{tikzpicture} [scale=.8,auto=left,every node/.style={circle,fill=blue!20}] \node (nx) at (4,9) {$x$}; \node (ny) at (6,9) {$y$}; \node (nu) at (4,7.5) {$u$}; \node (nv) at (6,7.5) {$v$}; \foreach \from/\to in {nx/nu} \draw (\from) -- (\to); \end{tikzpicture} \end{center} Let $h=\max\{i\mid x_j=x'_j\,\, \forall j \leq i\}$ and $k=\max\{i\mid u_j=u'_j \,\, \forall j \leq i\}$. The hypothesis that $z\neq z'$ implies that $h<m$ and $k<n$. We show that this leads to a contradiction, and then we conclude that $z=z'$ is the unique generator of $X^*\cap U^*$. Without loss of generality, we can suppose that $x_1x_2\cdots x_h$ is a prefix of $u_1u_2\cdots u_k$. Hence, there exists a nonempty word $t$ such that $x_1x_2\cdots x_ht=u_1u_2\cdots u_k$. By definition of $h$, $x_{h+1}\neq x'_{h+1}$, and we can suppose that $x_{h+1}=x$ and $x'_{h+1}=y$. Then, \begin{equation*} \begin{split} t u_{k+1}\cdots u_n & = x_{h+1}\cdots x_m= x\cdots x_m\\ t u'_{k+1}\cdots u'_s& = x'_{h+1}\cdots x'_r= y\cdots x'_r. \end{split} \end{equation*} Set $Z_t=X\cup U\cup \{t\}$. We have \begin{equation*} \begin{split} t Z_t^*\cap xZ_t^* & \neq \emptyset\\ t Z_t^*\cap yZ_t^* & \neq \emptyset. \end{split} \end{equation*} Thus, the graph $G_{Z_t}$ contains the edges depicted in figure: \begin{center} \begin{tikzpicture} [scale=.8,auto=left,every node/.style={circle,fill=blue!20}] \node (nt) at (5,10.5) {$t$}; \node (nx) at (4,9) {$x$}; \node (ny) at (6,9) {$y$}; \node (nu) at (4,7.5) {$u$}; \node (nv) at (6,7.5) {$v$}; \foreach \from/\to in {nt/nx,nt/ny,nx/nu} \draw (\from) -- (\to); \end{tikzpicture} \end{center} By the Graph Lemma, then, the free rank of $Z_t$ is at most $2$, and this contradicts the $2$-maximality of $X^*$ and $U^*$. Finally, let us prove that $z$ is primitive. Since $X^*$ and $Y^*$ are $2$-maximal, by Proposition \ref{prop:pure} they are both pure, hence also their intersection $z^*$ is pure. But it is immediate that $z^*$ is pure if and only if $z$ is primitive. \qed \end{proof} \begin{example}\label{exz} Consider the two $2$-maximal monoids $\{abcab,cb\}^*$ and $\{abc,bcb\}^*$. Their intersection is $\{abcabcbcb\}^*$. The intersection of $\{a,bc\}^*$ and $\{a,cb\}^*$ is $a^*$. \end{example} We have shown that the intersection of two $2$-maximal submonoids is generated by at most one element. Moreover, we know that the intersection of two 1-maximal submonoids is the empty word, i.e., it is generated by zero elements. Thus, it is natural to ask if in general, for every $k \geq 1$, the intersection of two $k$-maximal submonoids is generated by at most $k-1$ elements. The following examples, suggested to us by \v{S}t\v{e}p\'an Holub, provide a negative answer to this question. \begin{example}\label{controes} The intersection of the two $3$-maximal monoids $\{abc,dc,bab\}^*$ and $\{ab,cb,cd\}^*$ is infinitely generated by $abc(dc)^*bab$. The intersection of the two $4$-maximal monoids $\{a,b,cd,ce\}^*$ and $\{ac,bc,da,ea\}^*$ is $\{acea,bcea,acda,bcda\}^*$. \end{example} Thus, our Theorem \ref{th_case_2} is specific for rank $2$ and cannot be generalized to larger $k$. For an upper bound on the length of the word that generates the intersection of two $2$-maximal submonoids, we have the following proposition. \begin{proposition}\label{zbound} With the hypotheses of Theorem \ref{th_case_2}, $$\vert z \vert < (\vert x \vert + \vert y \vert)(\vert u \vert + \vert v \vert).$$ \end{proposition} \begin{proof} Let $\mathcal{A}_X$ (resp. $\mathcal{A}_U$) be the minimal DFA recognizing $X^*$ (resp. $U^*$) and $Q_X$ (resp. $Q_U$) its set of states. Since $X$ and $U$ are bifix codes, we have $\vert Q_X \vert < \vert x \vert + \vert y \vert$ and $\vert Q_U \vert < \vert u \vert + \vert v \vert$. Then the automaton $\mathcal{A}$ recognizing $X^* \cap U^*$ has a set of states $Q$ such that $\vert Q \vert < (\vert x \vert + \vert y \vert)(\vert u \vert + \vert v \vert)$. By Theorem \ref{th_case_2}, $\mathcal{A}$ is composed by only one cycle, labeled by $z$. Thus, $\vert z \vert < (\vert x \vert + \vert y \vert)(\vert u \vert + \vert v \vert).$ \qed \end{proof} For all our examples, the bound is much smaller than the previous one, hence we pose the following \begin{problem}\label{prob2} Find a tight bound on the length of $z$ in terms of the lengths of $x$ and $y$ and $u$ and $v$. \end{problem} \section{Primitive Sets} We now show how the previous results can be interpreted in the terminology of combinatorics on words. Let us start with the remark that a word $x\in A^+$ is primitive if and only if $$x \in u^*, u \in A^+ \Rightarrow x=u.$$ With our definition of maximality, we have that a word $x\in A^+$ is primitive if and only if the monoid $x^*$ is $1$-maximal. Inspired by this observation, we give the following definition. \begin{definition} A finite set $X \subseteq A^*$ is primitive if it is the basis of a $|X|$-maximal submonoid. \end{definition} \begin{remark} The definition of primitive set does not coincide with that of elementary set. A set $X$ is said to be elementary if $r(X)=\vert X \vert $. If $X$ is primitive, then $r(X)=\vert X \vert$, i.e., it is elementary. But there exist elementary sets that are not primitive. For instance, the set $\{aa,bca\}$ is elementary, but it is not primitive since $\{aa,bca\}^{*} \subseteq \{a,bc\}^*$. The set $\{a,bc\}$, instead, is primitive. \end{remark} From the definition of primitive set, we have that for every set $X$ there exists a primitive set $Y$ such that $X \subseteq Y^*$. The set $Y$ is therefore called a \emph{primitive root} of $X$. However, the primitive root of a set is not, in general, unique. Consider for instance the set $X = \{abcbab,abcdcbab,abcdcdcbab\}$. It has rank $3$, hence it is elementary, yet it is not primitive. Indeed, $X \subseteq \{ab,cb,cd\}^*$. The set $\{ab,cb,cd\}$ is primitive, and it is a primitive root of $X$. However, it is not the only primitive root of $X$: the set $\{abc,dc,bab\}$ is primitive and $X \subseteq \{abc,dc,bab\}^*$, hence $\{abc,dc,bab\}$ is another primitive root of $X$. In the special case of sets of rank $1$, clearly these always have a unique primitive root. For instance, the primitive root of the set $\{abab,abababab\}$ is the set $\{ab\}$. However, as a consequence of Theorem \ref{th_case_2} we have the following result. \begin{theorem}\label{thm:pair} A set $X$ of rank $2$ has a unique primitive root. \end{theorem} \begin{proof} If $\{u_1, u_2\}$ and $\{v_1, v_2\}$ are two primitive roots of $X$ then $X^* \subseteq \{u_1, u_2\}^* \cap \{v_1, v_2\}^*$. Hence, by Theorem \ref{th_case_2}, $X \subseteq \{z\}^*$, for some primitive word $z$, i.e. $r(X)= 1$, a contradiction. \qed \end{proof} In what follows, we find convenient call a primitive set of cardinality $2$ a \emph{primitive pair}. \begin{example} The words $abca$ and $bc$ are primitive words, yet the pair $\{abca,bc\}$ is not a primitive pair, since $\{abca,bc\}^* \subseteq \{a, bc\}^*$, hence $\{abca,bc\}^*$ is not $2$-maximal. The pair $\{abcabc, bcabca\}$ can be written as concatenations of copies of both $\{abca,bc\}$ and $\{a, bcabc\}$. However, there is a unique way to decompose each word of the pair $\{abcabc, bcabca\}$ as a concatenation of words of a primitive pair, and this pair is $\{a, bc\}$. Indeed, the primitive root of $\{abcabc, bcabca\}$ is $\{a, bc\}$. \end{example} As it is well known, a primitive word $x$ does not have internal occurrences in $xx$. The next result, whose proof is omitted for brevity, provides a similar property in the case of a primitive set of two words. \begin{theorem}\label{thm:cube} Let $\{x,y\}$ be a primitive pair. Then neither $xy$ nor $yx$ occurs internally in a word of $\{x,y\}^3$. \end{theorem} \begin{example} Let $x=abcabca$, $y=bcaabcabc$. Then $xy$ has an internal occurrence in $yxx$, yet $\{x,y\}\subset \{a,bc\}^*$. This example shows that the hypothesis that $\{x,y\}$ is primitive cannot be replaced by simply requiring that $x$ and $y$ are primitive words. \end{example} Differently to the case of a single primitive word, the converse of Theorem~\ref{thm:cube} does not hold. For example, $\{abcaa, bc\}$ is not primitive ($\{abcaa,bc\}^* \subseteq \{a, bc\}^*$), yet neither $abcaabc$ nor $bcabcaa$ occurs internally in a word of $\{x,y\}^3$. \medskip \section{Binary Root of a Single Primitive Word} In this section, we derive some consequences on the combinatorics of a {\em single} word. In particular, we introduce the notion of binary root of a primitive word, and we show how this notion may be useful to reveal some hidden repetitive structure in the word. Let $w$ be a nonempty word. If $w$ is not primitive, then it can be written in a unique way as a concatenation of copies of a primitive word $r$, called the {\em root} of $w$. However, if $w$ is primitive, one can ask whether it can be written as a concatenation of copies of two words $x$ and $y$. If we further require that $\{x, y\}$ is a primitive set, then we call $\{x, y\}$ a {\em binary root} of the word $w$. Note that the binary root of a single word is not, in general, unique. For instance, for $w=abcbac$ we have $w=ab \cdot cbac= abcb \cdot ac$ and $\{ab, cbac\}$ and $\{abcb, ac\}$ are both primitive pairs, i.e., they are both binary roots of $w$. However, if we additionally require that the size $\vert x \vert + \vert y \vert$ of the binary root $\{x,y\}$ is ``short'' with respect to the length of $w$, then we obtain again the uniqueness. This is shown in the next theorem. \begin{theorem}\label{thm:squareroot} Let $w$ be a primitive word. Then $w$ has at most one binary root $\{x,y\}$ such that $|x|+|y|<\sqrt[]{|w|}$. \end{theorem} \begin{proof} Suppose by contradiction there exists another binary root $\{u,v\}$ of $w$ with $|u|+|v|<\sqrt[]{|w|}$. Take $X=\{x,y\}$ and $U=\{u,v\}$. By Theorem \ref{th_case_2}, there exists a primitive word $z$ and an integer $n$ such that $w=z^n$. As $w$ is primitive, $w=z$ and $n=1$. By Proposition~\ref{zbound}, we have that $|w|<(|x|+|y|)(|u|+|v|)<\sqrt[]{|w|} \cdot \sqrt[]{|w|} = |w|$, a contradiction. \qed \end{proof} The following example shows a word $w$ that has binary roots of different sizes, but only one of size less than $\sqrt{|w|}$. \begin{example} Consider the primitive word $w=abcaabcabc$ of length $10$. The pair $\{a,bc\}$ is the only binary root of $w$ of size smaller than $\sqrt{|w|}$. \end{example} Asking for a tight bound in the statement of Theorem~\ref{thm:squareroot} is of course a problem intimately related to Open Problem~\ref{prob2}. We observe that both the classical notion of root and that of binary root are related to some repetitive structure inside the word. If $w$ is not primitive, the length of its root reveals its repetitive structure in the sense that, if such a length is much smaller than the length of $w$, then the word $w$ can be considered highly repetitive. If $w$ is primitive, the size of its binary root plays an analogous role. This could be illustrated by the following (negative) example. Consider a word $w$ over the alphabet $A$ such that all the letters of $w$ are distinct, so that $|w|=|A|$. This word is not repetitive at all, and it has $|w|-1$ different binary roots $\{x,y\}$, all of size $|w|$, corresponding to the trivial factorizations $w=xy$. Thus, the absence of repetitions in a word is related to the large size of its binary roots. On the contrary, the existence in a word $w$ of a ``short'' (with respect to $|w|$) binary root corresponds to the existence of some hidden repetitive structure in the word. This approach generalizes some already-considered notions of hidden repetitions (cf.~\cite{GMN13,G13,GaMa19}). We think that the notion of a binary root can be further explored and may have applications, e.g., in the area of string algorithms. Notice that the minimal length of a binary root (intended as the sum of the lengths of the two components of the pair) is affected by the combinatorial properties of the word. For example, if $w$ is a square-free word, then $w$ cannot have a binary root $\{x,y\}$ such that $|x|+|y|<|w|/4$, since otherwise $w$ would contain a square ($xx$, $yy$, $xyxy$ or $yxyx$). The previous remark suggests a possible link between the notion of a binary root and the classical notion of \emph{binary pattern}, which has been deeply investigated in combinatorics on words and fully classified by J.~Cassaigne~\cite{Cas94} (see also~\cite[Chap.~3]{Lothaire2} for a survey). \section{Connections with Pseudo-Primitive Words}\label{sec:pseudo} We now show how the notion of a primitive pair can be seen as a generalization of the notion of a pseudo-primitive word, with respect to an involutive (anti-)morphism $\theta$, as introduced in~\cite{CKS}. A map $\theta: A^* \rightarrow A^*$ is a {\em morphism} (resp. {\em antimorphism}) if for each $u, v \in A^*$, $\theta(uv)=\theta(u)\theta(v)$ (resp. $\theta(uv)=\theta(v)\theta(u)$) --- $\theta$ is an {\em involution} if $\theta(\theta(a))=a$ for every $a \in A$. Let $\theta$ be an involutive morphism or antimorphism other than the identity function. We say that a word $w \in A^*$ is a {\em $\theta$-power} of $t$ if $w \in t\{t, \theta(t)\}^*$. A word $w$ is {\em $\theta$-primitive} if there exists no nonempty word $t$ such that $w$ is a $\theta$-power of $t$ and $\vert w \vert > \vert t \vert$. \begin{theorem}[\cite{CKS}]\label{kari} Given a word $w \in A^*$ and an involutive (anti-)morphism $\theta$, there exists a unique $\theta$-primitive word $u \in A^*$ such hat $w$ is a $\theta$-power of $u$. The word $u$ is called the {\em $\theta$-root} of $w$. \end{theorem} \begin{example}\label{ex_thetaroot} Let $\theta: \{a,b,c\}^* \rightarrow \{a,b,c\}^*$ the involutive morphism defined by $\theta(a)=b$, $\theta(b)=a$ and $\theta(c)=c$. The $\theta$-root of the word $abcabcbac$ is $abc$. \end{example} If $\theta$ is an involutive morphism, we show that Theorem \ref{kari} can be obtained as a consequence of Theorem \ref{thm:pair}. If $\theta$ is an involutive antimorphism, we obtain a slightly different formulation, from which we derive a new property of $\theta$-primitive words. Given a morphism $\theta$ and a set $X \subseteq A^*$, $\theta(X)$ denotes the set $\{\theta(u) \mid u \in X\}$. We say that $X$ is {\em $\theta$-invariant} if $\theta(X) \subseteq X$. We have the following propositions. \begin{proposition}\label{prop_invariant2} Let $\theta$ be involutive. If $\{x, y\}$ is $\theta$-invariant, then so is its root. \end{proposition} \begin{example} Let $\theta$ be as in Example \ref{ex_thetaroot}. The pair $\{abcabcbac, abcbacabc\}$ is $\theta$-invariant. However, it is not a primitive pair. Its binary root is the pair $\{abc, bac\}$, which is $\theta$-invariant since $\theta(abc)=bac$. \end{example} \begin{remark} Let $\theta$ be an involutive morphism. Then $\{x, y\}$ is $\theta$-invariant if and only if $y=\theta(x)$. If $\theta$ is an involutive antimorphism, then $\{x, y\}$ is $\theta$-invariant if and only if either $y=\theta(x)$ or $x=\theta(x)$ and $y=\theta(y).$ In the last case, $x$ and $y$ are called {\em $\theta$-palindromes}. \end{remark} \begin{example}\label{reverse} Let $\theta: \{a, b, c\}^* \mapsto \{a, b, c\}^*$ be the involutive antimorphism defined by $\theta(a)=a$, $\theta(b)=b$, $\theta(c)=c$. The pair $\{abcbbcba, abcba\}$ is $\theta$-invariant. Its binary root is $\{a, bcb\}$, which is $\theta$-invariant since composed by $\theta$-palindromes. With the same $\theta$, the pair $\{abbbbabba, abbabbbba\}$ is $\theta$-invariant and its binary root is $\{abb, bba\}$, which is $\theta$-invariant since $\theta(abb)=bba$. \end{example} \begin{proposition} \label{prop:tetaprimitive} Let $w \in A^*$ and $\theta$ be an involutive morphism of $A^*$. Then, $w$ is $\theta$-primitive if and only if the pair $\{w, \theta(w) \}$ is a primitive pair. \end{proposition} \begin{proof} Let us suppose, by contradiction, that $\{w, \theta(w) \}$ is a primitive pair and $w$ is not $\theta$-primitive. Then there exists $t$ such that $w \in \{t,\theta(t)\}^*$. Hence, $\theta(w) \in \{t,\theta(t)\}^*$, so the pair $\{w, \theta(w) \}$ is not primitive. Conversely, let us suppose that $w$ is $\theta$-primitive and $\{w, \theta(w)\}$ is not a primitive pair. Denote by $\{u,v\}$ its binary root. Since $\{w, \theta(w)\}$ is $\theta$-invariant, then $\{u,v\}$ is $\theta$-invariant, i.e., $v=\theta(u)$. Hence, $w \in \{u, \theta(u)\}^*$, i.e., $w$ is not $\theta$-primitive. \qed \end{proof} From Theorem \ref{thm:pair} and Proposition \ref{prop:tetaprimitive} we derive Theorem \ref{kari} when $\theta$ is an involutive morphism. Now, let us consider the case of antimorphisms. Reasoning analogously as we did in the proof of Proposition~\ref{prop:tetaprimitive}, we can prove the following result. \begin{proposition} Let $w \in A^*$ and $\theta$ an involutive antimorphism of $A^*$. If the pair $\{w, \theta(w) \}$ is a primitive pair, then $w$ is $\theta$-primitive. \end{proposition} The converse does not hold in general, as the following example shows. \begin{example} Let $\theta$ be the antimorphic involution of Example \ref{reverse}. The word $w=abbaabbacbc$ is $\theta$-primitive, whereas the pair $\{w, \theta(w)\}= \{abbaabbacbc, cbcabbaabba\}$ is not a primitive pair, since its binary root is the pair $\{abba, cbc\}$. \end{example} Finally, we can state the following proposition, which provides a factorization property of $\theta$-primitive words. \begin{proposition} Let $w \in A^*$ and $\theta$ an involutive antimorphism. If $w$ is $\theta$-primitive and $\{w, \theta(w)\}$ is not a primitive pair, then there exist two $\theta$-palindromes $p$ and $q$ such that $w \in \{p, q\}^*$. \end{proposition} \begin{proof} Suppose that $\{w, \theta(w)\}$ is not a primitive pair and denote by $\{u, v\}$ its binary root. Since $\{w, \theta(w)\}$ is $\theta$-invariant, then so is $\{u, v\}$ by Proposition \ref{prop_invariant2}, and $v \neq \theta(u)$ since $w$ is $\theta$-primitive. Then, $u=\theta(u)$ and $v=\theta(v)$ are $\theta$-palindromes. \qed \end{proof} Finally, we point out that our Theorem \ref{thm:cube} can be viewed as a generalization of the following result of Kari, Masson and Seki \cite{Kari11}: \begin{theorem}[Theorem 12 of \cite{Kari11}] Let $x$ be a nonempty $\theta$-primitive word. Then neither $x\theta(x)$ nor $\theta(x)x$ occurs internally in a word of $\{x,\theta(x)\}^3$. \end{theorem} \section{Acknowledgments} We thank \v{S}t\v{e}p\'an Holub for useful discussions and in particular for suggesting us the important Example~\ref{controes}.
{'timestamp': '2019-06-10T02:09:57', 'yymm': '1810', 'arxiv_id': '1810.02182', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02182'}
arxiv
\section{Introduction} \label{sec_intro} Real-world networks exhibit surprising features that are missing in random or regular graphs. Consequently, various network models are proposed in the literature in order to generate artificial graphs which are topologically similar to real networks. In recent years, network models have found many applications in hypothesis testing, network simulations, and what-if scenarios \cite{arora2017action,bailey2014genetic,modelfit2,you2018graphrnn}. In the classical approach of network modeling, various human-designed models are proposed, each of which follows a specific network formation process and therefore, provides a specific set of network features. Despite the advances in network modeling, a classical network model inherently supports some features and neglects others. For example, Barab\'{a}si-Albert model\cite{BAModel} generates scale-free networks with long-tail degree distribution, but it does not support high clustering. On the other hand, Watts-Strogatz model\cite{WattsStrogatz} generates networks with high clustering but it does not generate scale-free networks. Even the recent human-developed network models fail to support some of the needed network features. Consequently, a network model that is appropriate for a particular target network (e.g., a social network) may fail to synthesize networks similar to another network (e.g., a biological graph). Actually, a human-designed network model controls network formation in a specific manner and therefore, such models are all inherently limited by their specific manners. Consequently, new generators must be developed manually in order to support new demands for network features \cite{arora2017action}. These limitations of the existing network generators reveals the need to a dynamic and adaptive network model which is not restricted to a specific type of network topology or formation process. When a target network or the set of its desired features is specified, network modeling becomes a complicated task because the model should adapt the target graph, and generate networks compatible with the desired characteristics. Therefore, a research problem has emerged in recent years, which investigates developing network models that are adaptive to the characteristics of the desired network. Adaptive network generators may play role in extrapolation (synthesize larger networks to predict future topology of the network), sampling (synthesize smaller but similar networks), anonymization (synthesize similar networks to a private network), and many other applications \cite{arora2017action}. In this paper, we develop a method for automatic model construction based on the probabilistic combination of several network generation methods. Actually, we automatically create a network model per target graph based on the topological characteristics of this graph. For any target network, our proposed framework combines existing network generation processes and automatically builds a new mixture model adapted to the target graph. While each network model supports specific set of features, an intelligent combination of the models may lead to adaptive network structures which are more similar to the target graphs. In our proposed framework, all the candidate network generation processes may contribute in network generation, each of which with an assigned probability that is adapted based on the characteristics of the target network. However, finding the best adapted configuration for the combination of the network processes is not a trivial task. We employ Genetic Algorithm in order to find the best probability values assigned to each network process along with their corresponding configuration parameters. Our experiments show that the proposed method outperforms the baseline methods according to the similarity of the synthesized networks to the target graphs. The rest of this paper is organized as follows: Section \ref{sec:relatedworks} reviews the state of the art network generation methods. In section \ref{sec:problemStatement} the problem statement is presented. Section \ref{sec:proposedmethod} illustrates our proposed method. Section \ref{sec:evaluations} shows the experimental evaluations, including case studies for real-world networks. Finally, Section \ref{sec:conclusion} concludes the paper and explains the future works. \section{Literature Review} \label{sec:relatedworks} Many efforts exist in the literature for generating artificial complex networks. Particularly, many algorithms, called network models, are proposed in order to generate graphs with nontrivial topological features of real networks, such as long-tail degree distribution and small-worldness. The classical approach of network modeling is based on reality-inspired but human-designed methods, each of which follows a certain formation mechanism, and supports a specific and preset set of network properties. This approach includes methods such as Erd\H{o}s-R\'{e}nyi model of random graphs \cite{CentralLimit}, Bar\'{a}basi-Albert \cite{BAModel} model of scale-free networks, and Watts-Strogatz (WS) model of Small-World networks \cite{WattsStrogatz}, along with other models such as Kronecker graphs \cite{kronecker}, Random power-law \cite{RandomPowerLaw}, Forest Fire \cite{graphsOverTime}, and several other network growth methods, many of which result in scale-free networks \cite{WebAsGraph, bell2017network, golosovsky2018mechanisms, topirceanu2018weighted}. In many applications, a target network or the set of its topological properties is given, and the problem is to generate artificial graphs with features similar to those of the target network. Although network models seem to solve this problem, but each generative model supports a set of network features and ignores other features and consequently, the model is appropriate for a set of target networks and inappropriate for the others \cite{modelfit2}. However, research on developing human-designed models and network formation mechanisms is still ongoing because of its valid applications. For instance, a mechanism of rewiring for tuning two-node degree-correlation and clustering coefficient \cite{kashyap2017mechanisms}, a framework which synthesizes dense and scale-free networks \cite{courtney2018dense}, and a method for generating disassortative graphs with a given degree distribution \cite{van2018generating} are proposed in recent years. Some researchers have proposed to select an appropriate model based on the properties of each target network. Particularly, various automatic ``model selection'' methods are proposed in the literature \cite{Drosophila,ModelSelection,GDD,RGF,GraphCrunch2,gmscn,modelfit}, many of which employ machine learning algorithms in order to automatically classify the target network into one of the candidate network models. In this context, decision tree learning \cite{Drosophila,ModelSelection,gmscn} and distance-based classification \cite{GDD,RGF,netdistance,modelfit2,alignmentfreenetcompare,revealHidLang} are frequently utilized. Despite the advances in network modeling, the target network is usually a real-world graph with an structure which may deviate from emerging structure of any generative model \cite{medland2016automatic, modelfit2}. Therefore, even with the aid of intelligent model selection methods, no selected single network model may support various properties of the target real-world graph and instead, each network model may reflect a subset of the required features. Although network models are tunable via their configuration parameters, the overall network formation in a model conforms a constant and static process. Consequently, researches have been started to combine different network methods in order to create network models that adaptively imitate the features of a desired network \cite{arora2017action, harrison2015meta, kashirin2016evolutionary, menezes2014symbolic, bailey2014genetic, medland2016automatic, pope2016evolving, verstraaten2016synthetic, bach2012interactive}. Existing works utilize different approaches such as ``Genetic Programming'' (GP) \cite{bailey2014genetic, medland2016automatic, harrison2015meta, verstraaten2016synthetic}, ``Simulated Annealing'' \cite{kashirin2016evolutionary}, cellular automata \cite{lukeman2010inferring}, symbolic regression \cite{menezes2014symbolic}, and dk-graphs \cite{orsini2015quantifying}. For example, Bailey et al. \cite{bailey2014genetic} employ genetic programming (GP) to evolve an algorithmic description of the formation of a target network, but their method is computationally expensive and scales poorly with network size. Recently, an action-based network generator (called ABNG) \cite{arora2017action} is also proposed which orchestrates simple actions of network formation and chooses action probabilities based on simulated annealing to simulate the local interactions of the networks. This method is shown to be effective in simulating different artificial and real networks, and it is regarded as one of the main baselines in evaluating our proposed method. It is also worth noting that in some recent researches, the graph structure is directly utilized (without a feature extraction phase) in order to automatically develop an adaptive network generator \cite{kipf2016variational, Grover2017Graphite, Bojchevski2018NetGan, you2018graphrnn}. In this work, we propose an extensible framework of network process composition, in which candidate network processes are combined in a probabilistic framework. In comparison to the existing evolutionary methods, our proposed method benefits from the novel approach of network process composition, simple architecture, reproducible implementation, and the ability of extension with new candidate processes. \section{Problem Statement} \label{sec:problemStatement} Synthesized networks represent complex systems in the form of nodes and edges. In a real network, the nodes are connected according to a meaningful and specific pattern \cite{NewmanComplexNets} and therefore, the corresponding synthesized network should conform to a similar formation process. The more a synthesized network is similar to the target network, the more accurate is the result of different experiments on the synthesized network, such as simulation and hypothesis testing. Suppose that we can quantify the similarity of two graphs $G_{t}$ and $G_{r}$ via different criteria. If $G_{t}$ is the target network, then the problem is to find a synthesized network $G_{r}$ with maximum similarity to $G_{t}$. Therefore, finding the best $G_{r}$ is a search problem in the extra-large search space of possible graph instances. Moreover, based on the application of network generation, the desired size of the synthesized network may be different from the size of the target network. For example, in an extrapolation application, the synthesized graph is larger than the original target graph. On the other hand, a network sampling application seeks for artificial graphs smaller than the target graph. Consequently, the employed network similarity function that quantifies the similarity of the target network to the artificial graphs, should be a size-independent measure, capable of comparing the topology of two networks with different sizes (e.g., a large and a small graph). The ultimate goal in network generation problem is to synthesize graphs matching the desired topological properties of the target network. Consequently, we first need to specify a set of required network properties to be resembled in the synthesized graphs. Then, we should define a network similarity function, as a quality of fit measure which checks the set of required network properties, and quantifies the overall similarity of an artificial network to the target graph. Finally, we should optimize the generator parameters so that the generated graphs become more similar to the target network according the defined similarity measure. We assume that the considered networks are simple (undirected and unweighted) graphs so that to keep the problem simple and the solution comparable to the main baselines. In summary, a potential solution to the defined problem takes a network (a simple graph) as the input, and generates another simple graph as the output with similar topological characteristics to the inputted complex network, but perhaps with a different (arbitrary) size. \section{Proposed Method} \label{sec:proposedmethod} \subsection{Solution Encoding} \label{sub:solutionencoding} Suppose that we have a target network $G_{t}$ in hand, and we want to generate an artificial graph $G_{r}$ which is similar to $G_{t}$ regarding its topological features. The amount of dissimilarity of $G_{t}$ and $G_{r}$, called $error(G_{t} , G_{r})$, is measurable via different network properties such as average clustering coefficient, degree distribution, etc. Additionally, suppose that there are several candidate network formation processes C (such as preferential attachment) which are applicable in network generation. In each step of network generation, we select and employ one of the candidate processes $c_i$ with probability $p_i$. For example, we may generate a graph in such a way that in 90 percent of the network expansion steps the preferential attachment process is utilized, and random attachment process is utilized in the rest of the expansion steps. Consequently, the problem is to find the optimal probability of employing different processes in order to generate graphs most similar to the target network. In other words, we develop a network generation framework in which several network expansion processes are employed based on their corresponding assigned probabilities, in order to generate networks similar to the target graph. Additionally, each network process $c_i$ should also be configured with a parameter set $r_i$, where $r_i$ includes one or more parameters which configures process $c_i$. For example, the preferential attachment process is based on one parameter $m$ which specifies the number of attached links of a new incoming node. Consequently, the process parameter set ($r_i$) should also be optimized along with the probability of process employment ($p_i$) for each process ($c_i$). In our proposed framework, the process probabilities are optimized along with the process parameters in an evolutionary system. Table \ref{tab:notations} describes the defined symbols in our solution encoding. Accordingly, having the target network $G_t$ and the set of candidate processes $\{c_i\}$, the problem is to find the optimal corresponding probability values $\{p_i\}$ and parameter sets $\{r_i\}$, so that the emerging process framework can generate graph $G_r$ with minimum $error_m(G_{t} , G_{r})$ value with respect to different topological metrics $m$. \begin{table*} \centering \caption{\label{tab:notations}Table of symbols.} \begin{tabular}{c| m{0.5\textwidth} } Symbol & Description \\ \hline $G_{t}$ & Target network\\ \hline $G_{r}$ & Synthesized (artificial) network \\ \hline $C=\{c_1,c_2, ..., c_n\}$ & The set of candidate processes\\ \hline $P=\{p_1,p_2, ..., p_n\}$ & The set of evolved (estimated) probabilities of candidate processes: $p_i = P(c_i)$ \\ \hline $R=\{r_1,r_2, ..., r_n\}$ & Optimized parameter sets of the corresponding candidate processes $c_i$ \\ \hline $error_m(G_{1} , G_{2})$ & The amount of dissimilarity of graphs $G_{1}$ and $G_{2}$ according to the topological property (metric or measurement) m\\ \end{tabular} \end{table*} \subsection{Employed Network Processes} \label{sub:networkprocesses} In this research, we utilize several basic network processes as the building blocks of the proposed framework. The candidate processes contribute to gradually synthesize an artificial graph which is adapted to the topological features of the target network. In each step of our proposed network generation framework, called \textit{NetMix}, a candidate process ($c_i$) is selected based on the process probabilities ($p_i$) along with its optimized parameters set ($r_i$). The selected process is then utilized to attach $n$ new nodes to the rest of the synthesized network for that generation step. As described in section \ref{sec:problemStatement}, a search mechanism is necessary to find the optimal values of $p_i$ and $r_i$. Before describing our optimization method, we first illustrate the candidate processes utilized in this research. It is worth noting that our proposed framework is not limited to the set of employed network processes, and one may add/remove several formation processes to this framework. In order to keep the framework concise, we have chosen only four simple formation processes in our framework. We will show the effectiveness of the employed processes in section \ref{sec:evaluations}. We prepared four candidate processes, each of which results in emergence of a set of important network features. First, in \textit{``Transitive/Random Attachment'' (TRA)} process, a regular lattice of $n$ nodes with degree $K$ is generated (each node is connected to its $K$ adjacent neighbors) and then, each edge of the lattice is rewired to a randomly-chosen existing node with probability $p_{rewiring}$. Actually, \textit{TRA} process mainly resembles the Watts-Strogatz model \cite{WattsStrogatz} with high clustering and small-world features. Consequently, $K$ and $P_{rewiring}$ are the configuration parameters of the TRA process, which will be optimized in our proposed method. Additionally, the TRA process also represents the random attachment process (inspired by Erd\H{o}s-R\'{e}nyi model \cite{CentralLimit}) since each new edge in this process may be randomly rewired to an existing node with probability $p_{rewiring}$. For example, with a high value of $P_{rewiring}$, this process generates random graphs. As the second formation process, we consider \textit{``Preferential Attachment'' (PA)} process which acts similar to Bar\'{a}basi-Albert \cite{BAModel} model. In each generation step of this process, $n$ new nodes are attached to the network based on the degree of the existing nodes. In other words, a new node $v_n$ is attached to an existing node $v_o$ with a probability proportional to the degree of $v_o$ (i.e., ${p(\{v{_n},v_{o}\} \in E)} = {{k_{v_o}} \over {\sum_{v}{k_v}}}$, where $k_x$ is the degree of node $x$). Each new node actually attaches to $m$ existing nodes and thus, PA process is configured with parameter $m$. The third defined process is \textit{``Modular Attachment'' (MA)} which is inspired by copying network model \cite{WebAsGraph}. In this process, each new node first randomly selects an existing node $x$, and attaches to each neighbor of $x$ with probability $P_{copying}$. If $x$ has no edges, the new node attaches to $x$ itself. The Modular Attachment process supports modular networks with community structure. Finally, the fourth proposed process is \textit{``Assortative/Disassortative Mixing'' (ADM)} process, in which the degree-assortativity \cite{AssortativityNewman} of the network is increased or decreased. Assortativity is a condition in which the degree of the linked nodes are correlated. In an assortative network, there is a positive correlation between the degrees of two attached nodes, and conversely a disassortative network shows a negative degree correlation between the linked nodes. In ADM process, we simply try to change the assortativity of the network towards the assortativity of the target network. In this regard, a pair of existing nodes are chosen randomly, and their connection (edge) is added or removed in order to make the overall network assortativity closer to the target assortativity. This task is repeated $N_{ADM}$ times, where $N_{ADM}$ is an evolved parameter of this process. The four considered network processes (TRA, PA, MA, ADM) are capable of generating networks with various network features. For example, PA supports scale-free networks with long-tail degree distribution, TRA supports transitive relationships, small path length, and random (casual) attachments. MA results in modular networks with community structure, and finally ADM supports assortative or disassortative networks. Consequently, a mixture of the four processes is capable of generating networks which are adapted various properties of the target network, while a single process (or network model) may fail to support the mixing features of the target network. Table \ref{tab:generativeparams} shows the process probabilities and configuration parameters which are all optimized in our proposed method described in the next subsection. \begin{table*} \centering \caption{\label{tab:generativeparams}The process probabilities notation and the configuration parameters.} \begin{tabular}{c| m{0.5\textwidth} } Parameter Name & Description \\ \hline $n$ & Number of new nodes (added to the network) in each step of network expansion\\ \hline $P_{PA}$ & Probability of choosing ``Preferential Attachment'' (PA) process in each step of network expansion\\ \hline $m$ & Number of attachments of each new node in PA process\\ \hline $P_{TRA}$ & Probability of choosing ``Transitive/Random Attachment'' (TRA) process in each step of network expansion\\ \hline $K$ & Number of adjacent neighbors of each node in TRA process\\ \hline $P_{rewiring}$ & The probability of displacing one end of each edge in the new generated regular lattice to a random existing node, in TRA process\\ \hline $P_{MA}$ & Probability of choosing ``Modular Attachment'' (MA) process in each step of network expansion\\ \hline $P_{copying}$ & The probability of attaching a new node to each neighbor of a randomly-chosen existing node, in MA process\\ \hline $P_{ADM}$ & Probability of choosing ``Assortative/Disassortative Mixing'' (ADM) process in each step of network expansion \\ \hline $N_{ADM}$ & Number of considered pairs in ADM process \\ \end{tabular} \end{table*} \subsection{Optimal Mixture of Network Processes} \label{sub:ga} Our proposed method, named \textit{NetMix}, combines different network processes in order to develop a network model framework which supports a mixture of nontrivial topological features. The configuration of such a model framework should be tuned per target network based on the desired topological characteristics. The configuration setting includes the probability of applying each candidate process, along with the parameters of the processes. Table \ref{tab:generativeparams} illustrated the parameters which should be specified for any target network. As a result, the problem of adaptive network generation is reduced to a search problem for finding the optimal values of those parameters per target network. This problem faces a huge search space because we should find the optimal values for many parameters with a wide range of possible values. Fortunately, meta-heuristic algorithms such as \textit{``Genetic Algorithm''} are known to be effective in optimization of such problems with large search space \cite{GAbook,genetic}. Inspired by Darwinian evolutionary theory and the process of natural selection, genetic algorithm (GA) is widely employed in optimization and search problems by simulating bio-inspired operators such as crossover, mutation, and selection. When applying GA for an optimization problem, a population of candidate solutions (called individuals or chromosomes) with an specified set of properties (genes) is evolved. According to the fitness of its solution, each individual is given a score that determines its survival rate in subsequent generations. In each generation of GA, ``parent'' solutions are also selected from the existing individuals according to their fitness score, for breeding using crossover and mutation operators. In our proposed method, we search the optimized values for the parameters described in Table \ref{tab:generativeparams} and thus, we represent a chromosome by a vector of those parameters. We defined appropriate crossover and mutation operators along with a fitness function. In each evolution generation, we employ ``tournament selection'' \cite{genetic} to choose the parents and ``uniform crossover''\cite{GAbook,genetic} to generate new child individuals. For the mutation operator, we change some genes of an individual to random values. More details about the configuration of the implemented genetic algorithm is illustrated in Section \ref{sub:experimentdetails}. In order to calculate the fitness of an individual, we generate a graph using the configuration parameters encoded in that individual chromosome, and then we compute the similarity of the target network to the generated graph. We utilize \textit{NetDistance} \cite{netdistance} as the fitness function for calculating the topological similarity of two complex networks. NetDistance \cite{netdistance} defines the amount of dissimilarity of two complex networks equal to the weighted Manhattan distance of some of their topological features including degree distribution, average clustering coefficient, transitivity, assortativity, and modularity: $netdistance(g_{1},g_{2}) = \sum_{i=1}^{n} w_{i}| m_{i}(g_1)-m_{i}(g_2) |$, where $m_{i}(g)$ is the $i^{th}$ considered property (metric) of the graph $g$ and $w_i$ is its corresponding learned weight (trained in a machine learning algorithm). NetDistance is a size-independent dissimilarity metric (distance function), which is capable of comparing the overall topological features of complex networks\cite{netdistance,modelfit}. It is worth noting that we can extend NetDistance with other properties that contribute in the distance function. Actually, the distance function can be customized according to the employed candidate processes in the proposed method. We will show in the evaluation results (Section \ref{sec:evaluations}) that the simple utilized distance function (NetDistance) is an effective fitness measure for synthesizing networks similar to the target graphs. \section{Evaluations} \label{sec:evaluations} \subsection{Baseline Methods} \label{sub:baselines} In order to investigate effectiveness of the proposed method, we compare it with several baselines. As the first category of baselines, six network models are considered in our experiments: Barab\'{a}si-Albert (BA) model \cite{BAModel}, Erd\H{o}s-R\'{e}nyi (ER) \cite{CentralLimit}, Forest Fire (FF) \cite{graphsOverTime}, Kronecker graphs model (KG) \cite{kronecker}, Random power-law (RP) \cite{RandomPowerLaw}, and Watts-Strogatz (WS) model of Small-World networks \cite{WattsStrogatz}. These models are compared with our proposed method according to their effectiveness in generating artificial networks similar to the target network. This comparison is performed based on different topological measurements of complex networks such as degree distribution and community structure. The six models are chosen mainly because they are frequently used in network generation applications, and they also cover a wide range of network structures, such as scale-free graphs and small-world networks. In addition to the six mentioned network models, we also consider ABNG method \cite{arora2017action} as another baseline method in our evaluations. This is because ABNG is a successful and more recent attempt which follows an adaptive approach of network generation. As explained in Section \ref{sec:relatedworks}, ABNG uses simulated annealing in order to optimally orchestrate simple actions of network formation. ABNG shows remarkable results for generating graphs similar to various artificial and real networks. \subsection{Observed Network Properties} \label{sub:networkproperties} Our proposed method can replicate different network properties of the target networks. In order to evaluate this capability, we compare the synthesized graphs with corresponding target networks according to different network properties. We define the $error_m$ in replicating feature (metric) $m$ as the amount of dissimilarity of the target network to the adapted graph (i.e., the corresponding network synthesized by our proposed method) according to the metric $m$. First, we consider several global graph properties including average clustering coefficient \cite{WattsStrogatz}, transitivity \cite{surveyOfMeasurements}, modularity \cite{ModularityNewman}, and assortativity (degree correlation) \cite{AssortativityNewman}. For each of the mentioned global metrics $m$, $error_m$ is defined as the absolute difference of the measure $m$ between the target and the synthesized network. Additionally, in order to replicate evaluation results of our main baseline (ABNG \cite{arora2017action}), we considered several node properties including node degree, local-clustering, closeness centrality, centrality, eigenvector centrality, and PageRank centrality. Then, we quantify the two-sample Kolmogorov-Smirnov (KS) test of the distribution of the mentioned node properties between the synthesized and target graphs. Moreover, we utilized the DDQC method \cite{ddqc} as another measure for comparison of two degree distributions (in addition to the KS-test of the degree distributions). DDQC (Degree Distribution Quantification and Comparison) considers two networks with probably different sizes, normalizes their degree distributions, and then compares the distributions. It is shown that DDQC is more effective than KS-test in comparing the degree distribution of complex networks \cite{ddqc}. \subsection{Target Networks Dataset} \label{sub:targetnetworks} We consider different artificial and real networks as the target graphs in order to evaluate the effectiveness of the proposed method in reproducing the properties of the target graphs. As artificial target graphs, we consider many networks generated by the six mentioned network models described in Section \ref{sub:baselines} (BA\cite{BAModel}, ER\cite{CentralLimit}, WS\cite{WattsStrogatz}, FF\cite{graphsOverTime}, KG\cite{kronecker}, and RP\cite{RandomPowerLaw}). In addition to the artificial graphs, we consider 17 real-world networks as the target networks in our evaluations. The set of selected real networks contains diverse networks from different network types. Moreover, we had access to the evaluation results of the baseline method on the selected real networks and therefore, we were able to compare the evaluation results of our proposed method with the baseline (the baseline also includes evaluating three brain networks \cite{bellec2017neuro} but we had no access to those networks nor the evaluation results and therefore we excluded them). The dataset of considered real networks includes: The network of co-appearing characters in the novel Les Mis\'erables \cite{CoappearanceNetwork}, a network of US political books sold Amazon.com \cite{PolBooksAmazon}, the network of common adjectives and nouns in the novel David Copperfield by Charles Dickens (adjacent words network) \cite{wordadj}, a network of American football games \cite{GirvanNewman}, a network of collaborations between the Jazz musicians \cite{JazzCollaborations}, a network of social relations between dolphins living in Doubtful Sound, New Zealand \cite{DolphinsSocialNet}, two protein networks of C-alpha atoms (1php and 1qop) \cite{phpqop}, a yeast protein interaction network \cite{YeastProtein}, networks of Biogrid FRET, Far Western and Dosage Lethality from a general repository for interaction datasets \cite{biogrid}, a network which represents flights between US Airports \cite{USAirport2007}, Norwegian boards network which represents relationships between board members of norwegian public companies in August 2011 \cite{NorwegianBoardsNet}, a human protein interaction network \cite{HumanProtein}, a social network of students at University of California, Irvine \cite{SocialNetwork}, and a power-grid network from the United States \cite{WattsStrogatz}. \subsection{Evaluation Results} \label{sub:results} In contrast to classical manual-designed network models which only support a limited kind of networks, such as Barab\'{a}si-Albert (BA), our proposed method is an adaptive and automated approach of network generation. However, we begin the evaluations by investigating the ability of our proposed method to reproduce network features of artificial graphs which are generated by classical manual-designed network models. This evaluation is important because of the historical significance of the network models and the specific network features that they model \cite{arora2017action}. First of all, we simply show sample graphs generated by our proposed framework (NetMix) which are illustrated in Figure \ref{fig:sampleGenGraphs}. When the target graph is a scale-free network synthesized by Barab\'{a}si-Albert (BA) model \cite{BAModel}, NetMix is capable of generating similar graphs with characteristic hierarchical structure of scale-free networks (Figure \ref{fig:evalBASampleGen}). If the target graph is a random graph, NetMix also generates a graph with a random-like topology (Figure \ref{fig:evalERSampleGen}). Finally, if the target graph is a small-world graph generated by Watts-Strogatz (WS) model \cite{WattsStrogatz}, NetMix synthesizes graphs with high clustering and small path-lengths (Figure \ref{fig:evalWSSampleGen}). As the figures show, sample synthesized graphs are successfully adapted towards the target networks. \begin{figure*} \subfigure[ { \includegraphics[width=0.3\textwidth]{evalBASampleGen.pdf} \label{fig:evalBASampleGen} } \subfigure[ { \includegraphics[width=0.3\textwidth]{evalERSampleGen.pdf} \label{fig:evalERSampleGen} } \subfigure[ { \includegraphics[width=0.3\textwidth]{evalWSSampleGen.pdf} \label{fig:evalWSSampleGen} } \caption{Sample graphs generated by our proposed method which are adapted to different target networks. \subref{fig:evalBASampleGen} The target graph is a scale-free graph synthesized by Barab\'{a}si-Albert (BA) model \cite{BAModel} \subref{fig:evalERSampleGen} The target network is a random graph generated by Erd\H{o}s-R\'{e}nyi (ER) \cite{CentralLimit} \subref{fig:evalWSSampleGen} The target network is a small-world graph generated by Watts-Strogatz (WS) model \cite{WattsStrogatz}.} \label{fig:sampleGenGraphs} \end{figure*} In order to further investigate the properties of sample generated networks, Figure \ref{fig:degDist} compares the target artificial graphs with the networks synthesized by NetMix framework according to their degree distribution. In this experiment, six sample graphs are considered which are generated by the six network models described in the baseline methods (refer to Section \ref{sub:baselines}). Except the networks generated by WS \cite{WattsStrogatz} and ER \cite{CentralLimit} models, other models result in networks with long-tail degree distribution. As the figure shows, the networks synthesized by NetMix are able to mimic the degree distribution of the target networks, either for the long-tail distribution of BA \cite{BAModel}, KG \cite{kronecker}, RP \cite{RandomPowerLaw}, and FF \cite{graphsOverTime} networks, and for the semi-normal distribution of WS \cite{WattsStrogatz} and ER \cite{CentralLimit} networks. The average error of the proposed method ($error_m$) for different global metrics (m) of the artificial networks is also illustrated in Figure \ref{fig:avgErrorArt}. In this experiment, the average error of NetMix is computed when the target networks are artificial graphs generated by the six network models. Figure \ref{fig:avgErrorArt} summarizes the average $error_m$ for 60 different artificial target networks (10 target networks per network model). As the figure shows, $error_m$ is less than 0.07 for all of the considered global properties. Additionally, for most of the compared properties, $error_m<0.03$. \begin{figure*} \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistBA.pdf} \label{fig:degDistBA} } \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistER.pdf} \label{fig:degDistER} } \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistWS.pdf} \label{fig:degDistWS} } \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistFF.pdf} \label{fig:degDistFF} } \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistRP.pdf} \label{fig:degDistRP} } \subfigure[] { \includegraphics[width=0.4\textwidth]{degDistKG.pdf} \label{fig:degDistKG} } \caption{The degree distribution of networks synthesized by NetMix compared to their corresponding target graphs. The target networks are artificial graphs generated by various network models: \subref{fig:degDistBA} Barab\'{a}si-Albert \cite{BAModel} \subref{fig:degDistER} Erd\H{o}s-R\'{e}nyi \cite{CentralLimit} \subref{fig:degDistWS} Watts-Strogatz \cite{WattsStrogatz} \subref{fig:degDistFF} Forest Fire \cite{graphsOverTime} \subref{fig:degDistRP} Random power-law \cite{RandomPowerLaw} \subref{fig:degDistKG} Kronecker graphs \cite{kronecker} } \label{fig:degDist} \end{figure*} \begin{figure*} \includegraphics[width=0.6\textwidth]{avgErrorArt.pdf} \caption{Average error of different networks synthesized by NetMix in various properties of artificial networks.} \label{fig:avgErrorArt} \end{figure*} Complex real-world networks show various features which should be modeled by network generators. Therefore, we evaluate our proposed network generation framework by investigating its ability to reproduce important properties of real-networks. Table \ref{tab:propDistancesReal} shows $error_m$ of the proposed method (NetMix) and the baselines for different network measurements $m$ in the real-networks dataset described in Section \ref{sub:targetnetworks}. The presented error values are averaged over all the graphs in the real-networks dataset. In the case of the classical baseline models (i.e., ER \cite{CentralLimit}, WS \cite{WattsStrogatz}, BA \cite{BAModel}, KG \cite{kronecker}, RP \cite{RandomPowerLaw}, and FF \cite{graphsOverTime}) the best parameter sets are first estimated based on the ModelFit method \cite{modelfit}. In other words, the best parameters are first tuned for the target graph, and then the tuned parameters are utilized to generate similar graphs. As Table \ref{tab:propDistancesReal} shows, our proposed method (NetMix) outperforms baselines according to $error_m$ for most of the network properties, and only for three out of eleven network metrics, NetMix is ranked the second best model. After NetMix, ABNG shows the least error for four properties, and Random power-law model shows the best result for only one property. Moreover, Figure \ref{fig:avgErrorReal} summarizes the average $error_m$ of the considered methods for different network properties. As the figure shows, NetMix results in the least average error in comparison to other baselines. In a more detailed chart, Figure \ref{fig:radars} shows the $error_m$ of NetMix for different properties of several real-world networks. As the radar charts show, the effectiveness of the proposed method is different in various target networks. For example, the proposed method has generated graphs which successfully replicate various properties of Biogrid FRET network, but it has been less successful in American Football network. \begin{table*} \caption{The average error of different methods based on various network properties (metrics) for the real-world networks dataset.} \label{tab:propDistancesReal} \footnotesize \begin{tabular}{|l|c|c|c|c|c|c|c|c|} \hline \textit{\textbf{Property/Model}} & \textbf{NetMix} & \textbf{ABNG} & \textbf{BA} & \textbf{ER} & \textbf{FF} & \textbf{KG} & \textbf{RP} & \textbf{WS} \\ \hline \textbf{AvgClustering} & \cellcolor{lightgray!50}\textbf{0.06} & 0.11 & 0.19 & 0.24 & 0.18 & 0.22 & 0.20 & 0.15 \\ \hline \textbf{Transitivity} & \cellcolor{lightgray!50}\textbf{0.04} & 0.09 & 0.16 & 0.19 & 0.16 & 0.17 & 0.15 & 0.11 \\ \hline \textbf{Assortativity} & \cellcolor{lightgray!50}\textbf{0.03} & 0.12 & 0.17 & 0.17 & 0.26 & 0.18 & 0.18 & 0.17 \\ \hline \textbf{Modularity} & \cellcolor{lightgray!50}\textbf{0.04} & 0.15 & 0.20 & 0.20 & 0.27 & 0.17 & 0.15 & 0.14 \\ \hline \textbf{DDQC} & \cellcolor{lightgray!50}\textbf{0.31} & 0.44 & 0.63 & 0.72 & 0.64 & 0.68 & 0.79 & 1.03 \\ \hline \textbf{Degree Distribution} & \cellcolor{lightgray!50}\textbf{0.21} & \cellcolor{lightgray!50}\textbf{0.21} & 0.31 & 0.45 & 0.41 & 0.35 & 0.30 & 0.38 \\ \hline \textbf{Betweenness Distribution} & 0.28 & \cellcolor{lightgray!50}\textbf{0.18} & 0.43 & 0.41 & 0.34 & 0.33 & 0.38 & 0.44 \\ \hline \textbf{Closeness Distribution} & \cellcolor{lightgray!50}\textbf{0.54} & \cellcolor{lightgray!50}\textbf{0.54} & 0.66 & 0.65 & 0.85 & 0.69 & 0.67 & 0.72 \\ \hline \textbf{EigenVector Distribution} & 0.35 & 0.38 & 0.47 & 0.57 & 0.47 & 0.40 & \cellcolor{lightgray!50}\textbf{0.31} & 0.61 \\ \hline \textbf{PageRank Distribution} & 0.23 & \cellcolor{lightgray!50}\textbf{0.20} & 0.39 & 0.31 & 0.27 & 0.36 & 0.32 & 0.39 \\ \hline \textbf{LocalClustering Distribution} & \cellcolor{lightgray!50}\textbf{0.22} & 0.28 & 0.41 & 0.52 & 0.41 & 0.49 & 0.45 & 0.46 \\ \hline \end{tabular} \end{table*} \begin{figure*} \includegraphics[width=0.5\textwidth]{avgErrorReal.pdf} \caption{Average error of different methods for various properties in the real-world networks dataset.} \label{fig:avgErrorReal} \end{figure*} \begin{figure*} \subfigure[Biogrid Dosage Lethality] { \includegraphics[width=0.37\textwidth]{radar1.pdf} \label{fig:radar1} } \subfigure[American Football] { \includegraphics[width=0.4\textwidth]{radar2.pdf} \label{fig:radar2} } \subfigure[Biogrid FRET] { \includegraphics[width=0.4\textwidth]{radar3.pdf} \label{fig:radar3} } \subfigure[Human Protein] { \includegraphics[width=0.4\textwidth]{radar4.pdf} \label{fig:radar4} } \subfigure[UCI Social Network] { \includegraphics[width=0.4\textwidth]{radar5.pdf} \label{fig:radar5} } \subfigure[Word Adjacencies] { \includegraphics[width=0.4\textwidth]{radar6.pdf} \label{fig:radar6} } \caption{Error of the proposed method in reproducing different network properties for six real-world networks} \label{fig:radars} \end{figure*} Finally, it is also worth evaluating the sensitivity of NetMix to the utilized configuration variables of the proposed genetic algorithm. Many configuration variables contribute in the accuracy of the genetic algorithms, e.g., probability of crossover and mutation operators. We had tuned such variables with trial and error, and we have utilized the tuned variables as described in Section \ref{sub:experimentdetails}. The population size and number of generations are also important variables in genetic algorithms. Figure \ref{fig:sensitivity} shows the sensitivity of the employed genetic algorithm to these two variables. The population size is set from 50 to 400 individuals, and the number of generations is varied from 50 to 200, with 50 intervals. The figure shows the average fitness of the proposed algorithm based on the NetDistance metric \cite{netdistance}. As the figure shows, the error of the proposed method is not meaningfully improved by increasing the number of generations. In other words, 50 generations is almost sufficient in our experiments for reaching the optimal results. Additionally, increasing the population size leads to better results but only until the population size reaches about 250 individuals. In summary, when the number of generations is more than 50 and the population size is more than 250, the evaluation results is relatively stable and less sensitive to these two configuration parameters. \begin{figure*} \includegraphics[width=0.5\textwidth]{sensitivity.pdf} \caption{Sensitivity analysis of the proposed genetic algorithm to the population size and the number of generations.} \label{fig:sensitivity} \end{figure*} \subsection{Discussion} As illustrated in the evaluations, NetMix can adapt the topological features of the target network. In order to further investigate the capabilities of different methods in reproducing properties of the target networks, we can divide the considered network properties into two main categories: First, global (aggregate) properties and second, local properties and their distribution. The first category includes average clustering coefficient, transitivity, assortativity, and modularity, and the second category covers DDQC along with the distribution of degree, betweenness centrality, closeness centrality, eigenvector centrality, PageRank centrality, and local-clustering of the nodes. In the category of the global network properties, our proposed method (NetMix) outperforms all the baselines considerably. In the second category, NetMix and ABNG show similar accuracy for degree and closeness distribution, NetMix is better in DDQC, local-clustering, and eigenvector distribution. On the other hand, ABNG outperforms NetMix with respect to betweenness and PageRank distribution, mainly because in our experiments, no candidate process is defined for supporting these two properties. Fortunately, our proposed framework is extensible, and it is possible to add candidate processes for further supporting properties such as betweenness centrality, PageRank centrality, and other properties. When comparing NetMix with similar adaptive approaches, such as ABNG, we should also note the inherent advantages of NetMix. NetMix is naturally capable of synthesizing graphs with arbitrary size, perhaps different from the target graph. In this regard, NetMix follows a computationally inexpensive approach for generating large graphs, since it simply observes several features of the synthesized graphs in relatively small networks for training the process-probabilities and process-parameters during the proposed evolving genetic algorithm. On the other hand, size-dependent methods such as ABNG evolve a network with the same size as the target network. This approach is not practical for large target networks. Additionally, ABNG considers the whole distribution of several local properties, which results in time-consuming computations. Additionally, the distribution of the node properties is missing in some application domains, because we may access to only a limited properties of the target graph instead of the whole distribution of several properties. In other words, the needed information for applying ABNG is inaccessible or infeasible in many applications. \subsection{Details of the Experiments} \label{sub:experimentdetails} It is worth noting some implementation details of the proposed method in our experiments, in order to make the reported results reproducible. We implemented the experiments using Python programming language and the NetworkX package. In configuring the GA, population size equals to 400 individuals, and a total of 200 generations are produced. The probability of applying mutation and crossover operators are set to 0.2 and 0.9 respectively. The ranges of chromosome features (described in Table \ref{tab:generativeparams}) are also preset as follows: $0 \leq P_{PA} + P_{TRA} + P_{MA} + P_{ADM} \leq 1$ , $ \frac{E}{N} - 2 \leq m \leq \frac{E}{N} + 2$, $ \frac{2 \times E}{N} - 2 \leq K \leq \frac{2 \times E}{N} + 2 $, $0 \leq P_{rewiring} \leq 1$, $0 \leq P_{copying} \leq 1$, $1 \leq N_{ADM} \leq \frac{N}{2}$, where E and N are number of desired edges and nodes respectively. The lower bound of $n$ is always set greater than or equal to the maximum possible value of $K$. The upper bound of $n$ is also set less than or equal to the number of desired nodes. It is worth noting that in our proposed method, the desired number of nodes in the synthesized network can be different from the number of nodes in the target network. Our proposed method generates the network in some consequent iterations. The number of performed iterations is equal to the desired number of nodes in the synthesized network, which can be different from the target network, divided by the $n$ value. The network formation starts from a $2 \times 2$ complete graph, and then adds $n$ nodes in each of the following iterations. \section{Conclusion} \label{sec:conclusion} In this paper, we proposed a novel method of network generation which is capable of adapting the target network. The proposed method, called NetMix, is actually a network model framework: NetMix automatically creates a network model based on the characteristics of the target network. In our proposed method, existing processes (such as transitive attachment or preferential attachment) are combined, which results in a mixed model for generating graphs that are topologically similar to the target network. We employed Genetic Algorithm in order to automatically find the best mixing configuration of the processes and the process parameters. The evaluations show the effectiveness of the proposed framework in reproducing topological features of both real and artificial networks. The experiments also verify that the proposed method outperforms baseline network models according to accuracy of different network properties in various network instances. Actually, the proposed method benefits from a simple extensible and architecture. NetMix is also a size-independent method, since it can generate networks similar to target graphs but with different number of nodes. In summary, while a single existing network process (such as preferential attachment process of Barab\'{a}si-Albert model\cite{BAModel}) is unable to imitate topological features of all real-world networks, an appropriate adapted mixture of the existing network processes is capable of generating graphs similar to different kinds of real-world networks. As a future work, we will consider other network processes in our proposed framework to support broader range of network features. Additionally, we will investigate improving the GA fitness function. We will also apply the proposed method in different applications, particularly in biological network generation. \section*{Acknowledgement} We are grateful to Viplove Arora for sharing the synthesized networks which were generated in the evaluation process of ABNG method \cite{arora2017action}.
{'timestamp': '2018-10-05T02:02:36', 'yymm': '1810', 'arxiv_id': '1810.01921', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01921'}
arxiv
\section{Introduction} In September 2015, The United States Environmental Protection Agency announced that Volkswagen's (VW) diesel engines for small cars have been violating the clean air act. It has been discovered that since 2008, VW have been equipping their small cars with diesel engines that were designed to operate differently when being tested, so that they would pass the emissions test while having higher emissions rates in most road conditions. Therefore, buyers of VWs diesel cars were under the impressions that they are buying a low-emission car while the car they were buying had higher emissions than regulations allow. This can be viewed as an example to the quality uncertainty problem described by \citet{akerlof1970market}. Indeed, as Akelrof predicted, the market turned into a market of lemons since it has been discovered that other car manufacturers were installing similar mechanisms that allowed them to pass the emission tests in ways that created what can be considered as a false presentation of the emission levels of the car.\footnote{\url{http://www.roadandtrack.com/new-cars/car-technology/a29293/vehicle-emissions-testing-scandal-cheating/}} For example, according to some reports, Fiat diesel engine were designed such that the emission control system would turn off after 22 minutes of driving. Coincidentally, the German emission test lasts for 20 minutes.\footnote{\url{ https://www.autoblog.com/2016/04/25/fiat-diesels-cheat-emissions-tests}} Our main observation is that the problem in the diesel engines market is not necessarily the lack of information on the buyers' side, but the hardness of obtaining it. From an information theoretic point of view, buyers, or government agencies for that matter, had access to the cars and hence if they would have changed their testing method they would have found that the emission were beyond the acceptable limits. Therefore, from an information theoretic point of view, the information was available to them. However, any feasible test can check the engine only on a finite set of conditions out of infinitely many driving conditions. Since the sellers knew the conditions that are being tested, they designed their engines to perform well in the test conditions while not making the same effort in conditions that were not tested. Therefore, we claim that we should distinguish between cases that the buyer does not have access to some information and the case that obtaining the information is computationally hard. This distinction allows us to address the latter case using computational techniques. However, before presenting possible solutions, it is worthwhile to remind ourselves that asymmetric markets have consequences. Asymmetric markets have been studied extensively since the pioneering work of \citet{akerlof1970market}. Akerlof stated that the influence on the market of these situations is greater than just the premium price the buyer pays for a defective product but also the cost associated with driving legitimate business out of the market~\cite{akerlof1970market}. To overcome the challenges of asymmetric information, signaling can be used by the party that has information that is missing by the other party if it has the incentives to do so~\cite{spence2002signaling}. At the same time, incentives can be introduced to promote signaling. In this work, we claim that if the asymmetric condition is due to computational constraints, it is possible to use computational techniques to alleviate the problem. We show that such conditions are abundant. We also discuss different computational solutions: We discuss methods that are currently being used and analyze their pros and cons. Finally, we show a novel solution that is suitable for the AI context that uses cryptographic tools to limit the risk of overfitting. We demonstrate the feasibility of this solution on real world data. As far as we know, the computational aspects of asymmetric markets were not studied before. The work of \citet{glaser2014zero} is close, in some respects, to the work presented here. \citet{glaser2014zero} looked at the problem of verifying that countries follow international agreement for nuclear disarmament. The challenge is to verify that an object that is claimed to be a nuclear warhead is indeed what it is claimed to be without each country having to reveal its nuclear technology. To achieve this goal, the authors designed a clever zero knowledge proof that the parties can use to prove that an object is indeed what it is claimed to be without disclosing additional information. In the context of markets, the problem Glaser, Barak and Goldston study is that the parties would like to refrain from leaking too much information. Like \citet{glaser2014zero}, we too suggest that cryptographic tools can play an important role in solving market challenges. However, there are key differences between our work and the work of \citet{glaser2014zero}. First, their work focusses on a specific scenario (nuclear disarmament) while we present a wider view. Moreover, we argue that in many scenarios, it is not only that the seller may wish to hide some information, but even when given full access, the buyer may find it difficult to fully assess the quality of goods. \section{Markets with hard to compute qualities} In the introduction, we used the example of diesel engines emissions to demonstrate a market in which the quality of goods is hard to compute. In this section we argue that this situation is common. We show that the problem of such markets has been observed before in diverse fields although the computational challenge was not spelled out. We also show that with the advance of AI, these situations are not going to disappear anytime soon. Campbell's law states that ``The more any quantitative social indicator is used for social decision making, the more subject it will be to corruption pressures and the more apt it will be to distort and corrupt the social processes it is intended to monitor'' \cite{campbell1979assessing}. This has been demonstrated in many scenarios. For example, enforcing standardized testing in the US has resulted in narrowing of the curriculum to focus on the subjects being tested \cite{berliner2009mclb}. This can be viewed as another instantiation of hard to compute information. The goal of unified tests is to verify that all students have a certain level of knowledge and skills. However, since it is infeasible to test every possible information and skill, the tests focus on a subset of these and as a result the education system narrowed its scope to the knowledge and skills that are being tested. ~\citet{goodhart1984problems} suggested a law which states that ``When a measure becomes a target, it ceases to be a good measure''. This has been demonstrated when looking at countries that adopted inflation targets for their economies \cite{mishkin1998inflation}. These countries had to be flexible about these targets or otherwise the results were not as expected. In the context of our current analysis, we argue that the problem that Goodhart is pointing to is the problem of evaluating the social welfare since there are many dimensions in which it could (and should) be evaluated. Once a single dimension is picked as a measure, the market would over-fit this dimension and emphasize the discrepancies between the measure and the intended quality target. The common theme behind these examples is that there is a target or condition that has no efficient verification method. In the cars example, it was the emission rate which is hard to verify because of all the different settings the car can be in. In the unified tests in US schools, the challenge is to verify that students have sufficient general knowledge and skills, and in the economy example the challenge is in measuring whether the economy is doing well. Since these are hard to verify qualities, proxies are used. When this happens, the proxy become the target or put otherwise, you get what you measure. For example, VW's engineers, knowing how emissions are being measured, designed engines that would work favorably under these tests. It is worth noting that this behavior is not necessary malicious, and can be the result of the measure itself becoming the definition of quality in the minds of those involved. The AI revolution brings with it solutions to problems that could not have been addressed before such as autonomous cars. In traditional programming tasks, the engineer designing a solution must define the challenge and a way to resolve it (algorithm). However, AI tools allow the engineer to solve the challenge by only demonstrating the desired outcome~\cite{carbonell1983overview}. This creates a great difference when trying to verify and validate solutions~\cite{ jacklin2004verification}. For example, AI based solutions do not have clear requirements and therefore cannot be validated, at least not in the standard meaning of validation in computer science. The kind of tasks for which AI techniques are useful for are problems for which we do not have an efficient recipe for solution and the domain is large.\footnote{If the domain is small, it is possible to memorize the right responses for each input and avoid the need for sophisticated solutions.} Therefore, the nature of these tasks makes verifying the solution challenging. That is, given a solution to such task there is no finite test to ensure that the AI solution is correct as the following lemma shows \begin{lemma} \label{le:finite test} Let $T:X\mapsto Y$ be a task such that $X$ is infinite and $\left|Y\right| > 1$ . Let $S$ be a finite subset of $X$. Then for every measure $\mu$ over $X $ there exists a model $M$ such that $M(x)=T(x)$ for every $x \in S$ while $\mu(\{x : M(x)\neq T(x)\}) = 1-\mu(S)$. \end{lemma} Lemma~\ref{le:finite test} shows that for every finite test and every distribution on the real world, there may be a solution that fits perfectly the test but performs poorly in the real world provided that the distribution on the real world is not limited to the test set. \begin{proof} Let $T$ be the task and $S$ be the test. Define $M$ such that: \[ \begin{cases} M\left(x\right)=T\left(x\right) & \text{if }x\in S\\ M\left(x\right)=\tilde{T}\left(x\right) & \text{if }x\notin S \end{cases} \] where we define $\tilde y$ to be $y^\prime \in Y $ such that $y^\prime \neq y$. From the definition of $M$ it follows that $M(x)=T(x)$ for every $x\in S$ and $M(x)\neq T(x)$ for every $x \notin S$ and therefore for any measure $\mu$ on $X$ we have that $\mu(\{x : M(x)\neq T(x)\}) = 1-\mu(S)$. \end{proof} This result may look similar to many results in statistical learning theory. Indeed, using standard statistical tools, it is possible to show that the performance of a model on a test set represents well the performance in the real world. However, this is under the assumption that the model under investigation is independent of the test set. But, in Lemma~\ref{le:finite test}, we do not make such an assumption since, for example, there is no reason to believe that VW developed its engines while ignoring the way emissions will be tested. Therefore, in statistical learning theory the typical case is analyzed while here we look at the worst case. The consequences of Lemma~\ref{le:finite test} are far reaching when put in the context of AI. Since the conditions of the Lemma hold for almost any AI task, verifying that an AI tool fulfils a certain criterion is a prime suspect for over-fitting. This applies to autonomous cars that are built of many AI components such as pedestrian detection mechanisms, obstacle avoidance, and route planning. But it also applies to medical devices such as robotic surgeons, smart medical monitoring devices, and heart defibrillators~\cite{li2014ventricular}. It is important to stress again the difference between the context we are talking about here and the standard validation/testing scenario in machine learning. In the machine learning context there are two main approaches to mitigate this issue. One uses the uniform convergence theorem, such as the VC theory~\cite{vapnik1974theory}. Uniform convergence guarantee that if the model was selected from a set of models that has low complexity, as measured for example by its VC dimension, then the performance of the model on a randomly selected train set is a good estimate of its performance. However, this solution may not be adequate in the context of contracts and regulations. The problem with this approach is that it requires not only testing the model but also the entire process that was used to develop it. Therefore, if a self-driving-car manufacturer would like to license its pedestrian recognition mechanism, it would be insufficient to test the mechanism itself and instead, it will be required to verify that during the entire development process, the manufacturer never tried a solution that is outside of a given class of solutions. The other approach is to use a test set that is unknown to the developer of the model. This is, however, challenging in the context of contracts and regulations. This is because it not only means that the test cannot be specified in the contract or the regulation, it also means that there need to be mechanisms in place to prevent it from leaking. This is the subject of this paper. \section{Verifying inefficiently verified conditions} Lemma~\ref{le:finite test} shows that when assessing the quality of complex goods, any finite test is potentially over-fitted unless it is kept secret from the model creator. Therefore, in this section we discuss methods to keep the model from learning the test. We focus our attention on AI settings in which processes can be automated. We focus on three techniques: random tests, one time tests, and secure tests. \subsection{Random Tests} One possible solution is to generate a fresh random test every time a model is to be verified. This prevents the risk of fitting the test set since the test set is generated only after the model has been submitted for verification. However, it is expensive since generating the test set may be a costly process. For example, consider the case of pedestrian detection then every test scenario must be created and manually annotated. \subsection{One Time Tests} The overhead of random tests can be reduced by allowing periodic tests only. Say, for example, that models can only be tested once a year on a pre-announced day. In this case, the leakage of the test is minimal and can be controlled with standard statistical tools such as Bonferroni correction to handle the risk associated with many models being tested simultaneously. This method is commonly used in schools. For example, college candidates can take the SAT exams only on 7 days during the year. All students take it at the same time to prevent the test from leaking. Therefore, each test form is used only once for all the students that are taking it on this specific date. This allows the college board to test 1.8 million prospective students using only 7 forms during 2017.\footnote{\url{https://reports.collegeboard.org/sat-suite-program-results/class-2017-results }} \footnote{\url{}} This method is efficient and is commonly used when testing human skills. It is used in school, colleges, bar examinations, and more. However, it has limitations. For example, such tests can only be offered a few times a year since each additional date the test is given at requires generating a test from scratch. \subsection{Secure Tests} Secure tests are conducted in a way that prevents information about the test from leaking and therefore allows reusing the same test. For example, emission tests can be conducted behind closed doors such that car manufactures would not be able to see how engines are being tested. However, when evaluating AI solutions, the seller might be reluctant to give uncontrolled access to its models due to various reasons such as intellectual property. Another problem with providing the buyer with access to the models is that the buyer might over-fit the model to lower the price or even copy it and use it without proper payment. That is, the buyer might design a test that will give a low score to the model, so that according to a contractual agreement between them, the price for the goods will be reduced. Another concern is that by running the test too many times, information about it might leak by comparing the properties of goods and the scores they obtain on the test. Therefore, we need mechanisms that prevent data leakage during the test and mechanisms to prevent data leakage after the test. \subsection{Preventing leakage during test}\label{sec:prevent_with_mpc} Let $T$ be a test and $M$ be a model to be tested. Let $\mbox{Eval}$ be the evaluation function such that $\mbox{Eval}(T, M)$ returns the test score of model $M$ on the test $T$. We would like to compute this score without revealing $T$ or $M$. This can be achieved using Secure Multi-Party Computation (MPC) techniques~\cite{yao1982protocols,gmw,G04}. Recent advances in MPC allow now for high throughput computation of complex and arbitrary functions that can be expressed by a circuit~\cite{ araki2016high,ABFLLNOWW17,LN17}. These protocols allow the computation of the score without revealing intermediate results to the parties involved under various trust assumptions. Some protocols assume that the parties are honest but curious which means that they would follow the protocol but would use the pieces of information they gather to learn about other parties. Other models assume that parties do not have to follow the protocol, this is referred to as the malicious setting \cite{G04}. Where possible, it is preferable to use protocols that are secure in the presence of malicious adversaries. The main advantage for using MPC for evaluation is that the model developer (seller) does not have access to the test and therefore, it cannot over-fit the test. At the same time, the test provider (buyer) does not have access to the model and therefore cannot over-fit the model to lower its evaluation. Note that this is not to say that the buyer cannot design a ``hard'' test. Rather, it means that the test cannot be tailored to fail a specific offer and in that sense it is fair. Methods to incentivize the seller to conduct a ``truthful'' test or ways to measure that the test is truthful is a subject for further study. \subsection{Preventing leakage after test} The main promise of conducting secure tests using MPC as described above is that the test can be reused. However, although the computation is secured, the result of such computation is revealed and therefore, a seller, or a group of sellers, can collect a set of (model, scores) pairs and use it to learn about the test. This can be mitigated using methods of adaptive data analysis~\cite{dwork2015reusable}. The Threshold algorithm (Algorithm~\ref{alg:Threshold}) is the mechanism we propose for this task. To protect the tests from being overfitted, it is necessary to add some randomness \cite{dwork2014algorithmic} and therefore if the model's score is borderline with respect to the threshold, the Threshold mechanism might fail to detect the exact side of the threshold the model is at. However, it allows creating $n$ test cases and using them to test $\tilde{O}(n^2)$ different models. It is possible to improve on that if it is assumed that most models will fail in which case it may be possible to reuse the same tests more. For the sake of clarity we skip this discussion here. \begin{theorem}\label{thm:DP} Assume that there is a universe $\mathcal{T}$ of tests such that $t\in\mathcal{T}$ is a function $t~:~\mathbb{M}\mapsto[0,1]$ where $\mathbb{M}$ is the space of all possible models. Furthermore, assume that there exists a probability measure $\mu$ on $\mathcal{T}$ and the goal is to assess, for a model $M$ whether $E_{t\sim\mu}[t(M)]\geq\rho$. Let $\alpha,\beta>0$ and select $\epsilon,\delta,$ and $n$ such that \begin{align*} \epsilon & =\frac{\alpha}{13}\\ \beta & =\frac{8\delta}{\epsilon^{5}}\left(\ln\frac{8}{\delta}\right)^{2}\ln\left(\frac{2}{\epsilon}\right)\\ n & =\frac{2}{\epsilon^{2}}\ln\left(\frac{8}{\delta}\right) \end{align*} If $n$ tests $t_{1},\ldots,t_{n}\in\mathcal{T}$ are selected at random from $\mu^{n}$ and are used to measure $k$ models $M_{1},\ldots,M_{k}$ such that $k=O\left(\nicefrac{n^{2}}{\left(\log n\right)^{2}}\right)$ through the Threshold$\left(\epsilon,\delta,k,\rho\right)$ mechanism (Algorithm~\ref{alg:Threshold}) then with probability $1-2\beta$ (over the internal randomness of the mechanism and the selection of $t_{1},\ldots,t_{n}$) the mechanism will return ``pass'' for every $M_{i}$ such that $E_{t\sim\mu}[t(M_{i})]\geq\rho+2\alpha$ and ``fail'' for every $M_{i}$ such that $E_{t\sim\mu}[t(M_{i})]\leq\rho-2\alpha$. \end{theorem} Theorem~\ref{thm:DP} shows that in order to be able to verify the quality of a product, it is possible to use the same $n$ tests again and again, as long as we do not use them more than $\tilde{O}(n^2)$ times before creating a new set of $n$ tests. Note, that the models to be tested can be selected in an adaptive way. That is, $M_2$ may depend on whether $M_1$ received a ``pass'' or ``fail'' score. The proof uses techniques from the field of \emph{Differential Privacy \cite{dwork2006calibrating}.} We refer the reader to \cite{dwork2014algorithmic} for a comprehensive introduction to this field. To prove Theorem~\ref{thm:DP} we first prove two lemmas that will be useful in the proof. Lemma~\ref{lemma:pass fail} shows that with high probability, the Threshold mechanism will respond ``pass'' and ``fail'' when $\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)\lessgtr\rho\pm\alpha$. Lemma~\ref{lemma:Nissim} shows that with high probability $\left|\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)-E_{t\sim\mu}\left[t\left(M_{i}\right)\right]\right|\leq\alpha$ and therefore these two lemmas provide the main tools needed to prove Theorem~\ref{thm:DP}. \begin{lemma}\label{lemma:pass fail} Let $\alpha,\beta,\epsilon,\delta>0$ and assume that the Threshold algorithm is used with parameters such that it is $\left(\epsilon,\delta\right)$-Differentially private with a sample of $n$ tests. Then with probability of at least $1-\beta$: \begin{enumerate} \item For every model $M_{i}$ such that $\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)>\rho+\alpha$ the Threshold algorithm will return ``pass''. \item For every model $M_{i}$ such that $\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)>\rho-\alpha$ the Threshold algorithm will return ``fail''. \end{enumerate} as long as the number of tested models is \[ k=O\left(\frac{n^{2}\alpha^{2}\epsilon^{2}}{\left(\ln\left(n\alpha\epsilon\right)-\frac{1}{2}\ln\left(\beta\ln\frac{1}{\delta}\right)\right)^{2}\left(\ln\frac{1}{\delta}\right)}\right)\,\,\,. \] \end{lemma} \begin{proof} Theorem 3.26 in \cite{dwork2014algorithmic} shows that the statement of the lemma we are discussing here holds as long as \[ \alpha n\geq\frac{\left(\ln k+\ln\frac{2k}{\beta}\right)\sqrt{512k\ln\frac{1}{\delta}}}{\epsilon}\,\,\,. \] Therefore, it holds for \[ \alpha n\geq\frac{2\ln\frac{2k}{\beta}\sqrt{\left(256\beta\ln\frac{1}{\delta}\right)\frac{2k}{\beta}}}{\epsilon} \] or when \begin{equation} \frac{\alpha n\epsilon}{32\sqrt{\beta\ln\frac{1}{\delta}}}\geq z\ln z\label{eq:z} \end{equation} for $z=\sqrt{\nicefrac{2k}{\beta}}$. (\ref{eq:z}) holds when $z=O\left(\nicefrac{y}{\ln y}\right)$ for $y=\nicefrac{\left(\alpha n\epsilon\right)}{\sqrt{\beta\ln\nicefrac{1}{\delta}}}$. Therefore, \begin{align*} k & =O\left(\beta z^{2}\right)\\ & =O\left(\beta\frac{y^{2}}{\left(\ln y\right)^{2}}\right)\\ & =O\left(\frac{n^{2}\alpha^{2}\epsilon^{2}}{\left(\ln\left(n\alpha\epsilon\right)-\frac{1}{2}\ln\left(\beta\ln\frac{1}{\delta}\right)\right)^{2}\left(\ln\frac{1}{\delta}\right)}\right) \end{align*} \end{proof} \begin{lemma}\label{lemma:Nissim} Let $t_{1},\ldots,t_{n}$ be tests randomly selected from the probability measure $\mu$ for $n=\frac{2}{\epsilon^{2}}\ln\left(\frac{8}{\delta}\right)$. Assume that the results of these tests are made available through a set of $k$ queries such that the composition of these responses is $\left(\epsilon,\delta\right)$-Differentially private. If an adversary creates $k$ models $M_{1},\ldots,M_{k}$ based on the responses to the $k$ queries and $k\leq n^{2}$ then \[ \Pr\left[\sup_{i}\left|\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|\geq13\epsilon\right]\leq\frac{8\delta}{\epsilon^{5}}\left(\ln\frac{8}{\delta}\right)^{2}\ln\left(\frac{2}{\epsilon}\right) \] \end{lemma} \begin{proof} Each model $M_{i}$ that the adversary builds can access the tests $t_{1},\ldots,t_{n}$ only through a set of queries which are $\left(\epsilon,\delta\right)$-Differentially private. From Proposition 2.1 in \cite{dwork2014algorithmic} it follows that the mechanism that generates each of the $M_{i}$'s is $\left(\epsilon,\delta\right)$-Differentially private. Therefore, using Theorem 1.2 in \citet{nissim2015generalization}, for each $i$ it holds that \[ \Pr\left[\left|\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|\geq13\epsilon\right]\leq\frac{2\delta}{\epsilon}\ln\left(\frac{2}{\epsilon}\right)\,\,\,. \] Using the union bound: \[ \Pr\left[\sup_{i}\left|\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|\geq13\epsilon\right]\leq\frac{2k\delta}{\epsilon}\ln\left(\frac{2}{\epsilon}\right)\,\,\,. \] Using $k\leq n^{2}=\frac{4}{\epsilon^{4}}\left(\ln\frac{8}{\delta}\right)^{2}$ completes the proof. \end{proof} \begin{proof} \textbf{of Theorem~} \ref{thm:DP} Assume that $t_{1},\ldots,t_{n}$ were selected at random. From Lemma~\ref{lemma:pass fail} it follows that the response of the algorithm will be ``pass'' whenever $\frac{1}{n}\sum t_{j}\left(M_{i}\right)\geq\rho+\alpha$ and ``fail'' whenever $\frac{1}{n}\sum t_{j}\left(M_{i}\right)\leq\rho-\alpha$ with probability $1-\beta$. Next we would like to show that with high probability $\sup_{i}\left|\frac{1}{n}\sum t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|\leq\alpha$ which will complete the proof by using the triangle inequality. The challenge, however, is that the $M_{i}$'s are selected in an adaptive way, that is, based on the feedback given on previous model and therefore they are not independent of $t_{1},\ldots,t_{n}$. In order to analyze this case, we will create an even harder situation: assume that the adversary can first create $k$ models, $\hat{M}_{1},\ldots,\hat{M}_{k}$, possibly in an adaptive way and obtain the pass-fail signal for each one of them. Based on the $k$ responses on the models $\hat{M}_{1},\ldots,\hat{M}_{k}$ the adversary has to create a set of $k$ models $M_{1},\ldots,M_{k}$ with the attempt that $\sup_{i}\left|\frac{1}{n}\sum t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|>\alpha$. Although this new set of models is not built in an adaptive way, this adversary is actually more powerful since it can use $M_{i}=\hat{M}_{i}$ if it chooses to do so. Theorem 3.25 in \cite{dwork2014algorithmic} shows that the Threshold mechanism is $\left(\epsilon,\delta\right)$-Differentially private. Therefore, we can apply Lemma~\ref{lemma:Nissim} to conclude that \[ \Pr\left[\sup_{i}\left|\frac{1}{n}\sum_{j}t_{j}\left(M_{i}\right)-E_{t}\left[t\left(M_{i}\right)\right]\right|\geq13\epsilon\right]\leq\frac{8\delta}{\epsilon^{5}}\left(\ln\frac{8}{\delta}\right)^{2}\ln\left(\frac{2}{\epsilon}\right)\,\,\,. \] By selecting $\epsilon=\nicefrac{\alpha}{13}$ and $\delta$ such that \[ \beta=\frac{8\delta}{\epsilon^{5}}\left(\ln\frac{8}{\delta}\right)^{2}\ln\left(\frac{2}{\epsilon}\right) \] which means that \[ \delta=O\left(\frac{\alpha^{5}\beta}{\left(\ln\frac{1}{\alpha}\right)\left(\ln\left(\frac{\alpha^{5}\beta}{\left(\ln\frac{1}{\alpha}\right)}\right)\right)^{2}}\right) \] by the observation that if $x=O\left(y\left(\ln y\right)^{2}\right)$ then $y=O\left(\nicefrac{x}{\left(\ln x\right)^{2}}\right)$. \end{proof} \begin{algorithm} \caption{The Threshold algorithm (modified from the Sparse mechanism of \citet{dwork2014algorithmic})} \label{alg:Threshold} \begin{algorithmic}[1] \Function{Threshold}{$t_1,\ldots,t_n,~\epsilon,~\delta, k,\rho$} \State Let $\sigma=\frac{\sqrt{32k\ln\frac{1}{\delta}}}{\epsilon}$ \For {$i=1,\ldots,k$} \State Receive a model $M_i$ \State Let $s_i = \sum_j t_j\left(M_i\right)$ \State Sample $r_i = \mbox{Lap}(\sigma) + \mbox{Lap}(2\sigma)$ where Lap is the Laplace distribution \If {$s_i+r_i > \rho$} \State {\bf Output} "pass" \Else \State {\bf Output} "fail" \EndIf \EndFor \EndFunction \end{algorithmic} \end{algorithm} \section{Experiment} In Section~\ref{sec:prevent_with_mpc} we explained that using secure Multi-Party Computation it is possible to test a model while keeping both the model hidden from the test and the test hidden from the model. In Theorem~\ref{thm:DP} we showed that this can allow us to reuse the test many times. However, these results do not show that this technology is feasible in terms of computation time on currently available hardware. In this section we describe an experiment we conducted to confirm the feasibility of the approach. For the experiment we simulated the following scenario: a customer would like to get a loan from a lender. To do that, the customer may apply to several lenders to shop for the best rates. Each lender computes the interest rate it is willing to offer by taking in the financial information of the customer and using historic data to compute the ROI it expects. The lender is not interested in revealing its ``formula'' for computing the requested interest rate due to two reasons. First, it is its intellectual property that may give it an edge over the competition. But more relevant to the theme of this work is that the assessment of the risk of lending the money is based on limited view of the customer. Therefore, if the customer had a full description of the way he or she are being assessed, they may be able to create a presentation that will work in their favor, for example by changing the way their credit is distributed without really changing the amount of money they owe, or issuing the request for the loan on a date that will maximize their benefits because of arbitrary cutoff dates in the evaluation model of the lender. At the same time the customer may be reluctant from providing its financial information to many lending agencies to shop for the best rates given the risk that even just one of them will leak this information. Therefore, we simulated the scenario in which the lender has a model to predict the ROI for an offer for a customer based on the financial information of the customer such that the evaluation is done using MPC in a way that the customer does not have to reveal its private information and the lender does not have to reveal its model. To build the model we used data from Lending Club.\footnote{\url{https://www.lendingclub.com/}} We have used Gradient Boosting \cite{friedman2001greedy} to train a model consisting of 32 trees, each one of these trees having 16 leaf nodes to predict the logarithm of the ratio between the amount of money returned to the amount of credit given. Therefore, this value is positive whenever the return was greater than the investment and negative when the customer defaulted and did not return the entire amount requested. The information about the customer consisted of 48 attributes.\footnote{More information about the data used for this experiment can be found at \url{https://www.lendingclub.com/info/download-data.action}.} The MPC protocol was implemented using the protocol of \citet{LN17} and its implementation in the SCAPI library.\footnote{\url{https://github.com/cryptobiu/libscapi} from Dec 2017.} This protocol is secure in the presence of \emph{malicious adversaries}, utilizes three servers and is secure as long as at most one is corrupt. The evaluation used 3 servers of type c4.2xlarge on Amazon Web Services (AWS) with 1GB interconnects. The total time to apply the model to customers data was measured at $15.4$ seconds of which $1$ second was used for setup, another $0.9$ seconds for offline computation and $13.5$ seconds for interaction between the different parties. Furthermore, the amount of communication exchanged between each player and the other players was $\sim125$MB. This experiment shows that the process of testing a model, while keeping both the model private and the test private can be done in a matter of seconds. Obviously, the exact timing may vary by the size of the model and the size of the data. However, the time changes linearly with respect to these parameters and therefore, it is still feasible for many of the applications we are interested at in this work. Furthermore, this experiment does not simulate the Threshold mechanism (Algorithm~\ref{alg:Threshold}) however adding the randomness required by this mechanism should not introduce noticeable difference in the performance. \section{Conclusions} The main observation we make in this study is that in asymmetric markets, the lack of information of information may be a consequence of a computational problem, rather than an information theoretic bound. This allows us to suggest computational methods to address this lack of information. We show that this problem of asymmetric markets, that was originally presented by \citet{akerlof1970market} in the context of used cars, appears also in markets of AI based goods. Therefore, we study ways to reduce the amount of missing information by proposing the use of secure multi-party computation to make sure that the item being evaluated cannot use the inherent limitations of the evaluation method to obtain an evaluation which does not truly reflect its true value. We show that these tools are feasible and can be applied to problems of relevant size. Furthermore, we use Differential-Privacy techniques to analyze the proposed method and show that it provides accurate estimate of the quality, even if the test is applied multiple times and the seller can adapt its good trying to get higher scores by using the feedback from previous runs. Given that asymmetric markets are common in many fields of life and given the growth of AI and AI based goods becoming a commodity, we think that there is great value in studying these markets and proposing new methods for players to have methods to evaluate products in ways that will better reflect their true values. \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2018-10-05T02:07:20', 'yymm': '1810', 'arxiv_id': '1810.02066', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02066'}
arxiv
\section*{Supplementary materials} The supplementary materials include the proof of our convergence results for the inexact IPG iterations~\eqref{eq:inIP2} \textemdash including the CoverBLIP algorithm \textemdash in Section~\ref{sec:proofs_supp}. Related to our numerical experiments in Section~\ref{sec:expe_invivo} of the main article and for further clarity to readers who might not be MRI/MRF experts, we provide a short note in Section~\ref{sec:dcf} on using a density compensation scheme for preconditioning MRF reconstruction problems with variable-density spiral (or other non-Cartesian sampling) readouts. \input{./sections/proofs} \input{./sections/dcf} \section*{Acknowledgments} We thank Dr. Dan Ma (Case Western Reserve University) for providing us the real data used in~\cite{MRF}. We also thank Dr. Pedro G{\`o}mez and Dr. Marion Menzel for useful discussions during MG's visit to GE Healthcare Global Research in Munich. \bibliographystyle{siamplain} \section{Conclusions and future directions} \label{sec:conclusions} We considered accelerating the iterative scheme for model-based MRF reconstruction and for this purpose we approximated the matched-filtering step in each iteration using cover tree's $(1+\epsilon)$-ANNS search scheme. For low-dimensional manifold datasets cover trees offer appealing construction times, memory requirements and remarkably low search complexities scaling logarithmic in terms of data population. With this motivation, we proposed the CoverBLIP algorithm which adopts such tree structures for fast iterative searches over large-size MRF dictionaries i.e. discrete manifold of Bloch responses parametrized by few NMR characteristics. Provided with a notion of (model-restricted) embedding we showed that the inexact iterations of CoverBLIP linearly convergence toward a solution with the same order of accuracy as when using BLIP with exact brute-force searches. We also introduced an adaptive step-size scheme that guarantees local monotone convergence of CoverBLIP in the absence of bi-Lipschitz embedding. We evaluated the performance of our proposed method on both synthetic and real-world MRF datasets using different sampling strategies, and we demonstrated that CoverBLIP is capable of achieving orders of magnitude acceleration in conducting the projection steps as compared to the exact iterations of BLIP. We also showed that CoverBLIP is a scalable algorithm able to maintain the gain in its time-accuracy performance in high-dimensional search spaces. Future works include application of CoverBLIP to the emerging multi-parametric MRF problems with more complex dynamic responses encoding a larger number of NMR characteristics. In such cases and due to the inherent non-linearity of Bloch responses a low-dimensional subspace model of the dictionary would be prohibitively inaccurate, and one would rather need to resort on fast search schemes such as cover trees that are robust against the curse-of-dimensionality. Our current search implementation does not benefit from the considerable amount of inter-voxel correlations present in a \emph{query batch}. As shown in e.g.~\cite{curtinthesis} faster searches are possible by additionally building a dual (cover) tree on the query batches. An interesting line of future work would adopt this idea to further accelerate CoverBLIP, however with more restricted choice of dual trees or batch sizes whose construction times would not bring a computational overhead throughout multiple iterations. Further extension to the present work could also focus on reducing the computational cost of the gradient updates for non-Cartesian and multi-coil acquisition schemes. In this regard, a possible line of investigation would be the application of \emph{randomized} iterative projected gradient algorithms (see e.g.~\cite{bottouSGD,svrg13,GPIS,restkatyusha}), where iterations adopt cheap, unbiased and variance-reduced stochastic approximations of the true but computationally-intensive gradient updates. \section{Accelerated MRF reconstruction with scalable tree searches} \label{sec:coverblippart} Accelerating the Nearest Neighbour Search (NNS) is a fundamental problem in computer science and it has a long historical literature. Successful proposed approaches are based on building tree structures which hierarchically partition large datasets and then use branch-and-bound algorithms for fast NNS (see e.g.~\cite{quadtrees,kdtrees,kmeanstrees,rtrees,balltrees,pcatrees,beygelzimer2006cover,conetrees}). KD-trees \textemdash which are the multi-dimensional generalization of binary searches \textemdash are perhaps the most widely-known classical structure for fast searches~\cite{kdtrees}. They consist of partitioning datasets across ambient coordinate axes and therefore do not efficiently adapt to complicated low-dimensional structures of datasets embedded into high (ambient) dimensions. A dimensionality reduction step is inevitably necessary when using KD-trees since they are non-scalable and their search complexity rapidly grows in high-dimensional problems~\cite{indyk1998breakCOD}. Modern search algorithms circumvent the curse-of-dimensionality by using i) tree structures that could efficiently benefit from the low \emph{intrinsic} dimensionality of natural datasets, which is a key assumption in machine learning, and ii) low-complexity algorithms for performing the search \emph{approximately} i.e. Approximate Nearest Neighbour Search (ANNS). In the following we briefly introduce a recent data structure known as a \emph{Cover tree}~\cite{beygelzimer2006cover} and highlight certain key properties making this structure ideal for accelerated and scalable searches within iterative MRF reconstruction. Notably for datasets with low intrinsic dimensions cover trees can achieve a logarithmic search complexity in terms of data population without needing an explicit a-priori knowledge of the data structure nor a dimensionality reduction preprocessing. \subsection{Cover trees} A cover tree is a levelled tree whose nodes are associated with points in a dataset $D=\{D_j\}_{j=1}^d$ and at different scales they form covering nets for data at multiple resolutions~\cite{beygelzimer2006cover,Navigating}. Denote by $\Ss_i \subseteq D$ the set of nodes appearing at scale $i=1,\ldots,i_{\max}$, $\Ss_0=\{D_{j_0}\}$ the tree's root and by $\sigma:=\max_{D_j \in D}\norm{D_{j_0}-D_j}$ the maximal tree coverage from the root. A cover tree structure must satisfy the following three properties: \begin{enumerate} \item Nesting: $\Ss_i \subseteq \Ss_{i+1}$, once a point $p$ appears as a node in $\Ss_i$, then every lower level in the tree has that node. \item Covering: every node $q\in \Ss_{i+1}$ has a parent node $p\in \Ss_{i}$, where $\norm{p-q}\leq \sigma2^{-i}$. As a result, covering becomes finer at higher scales in a dyadic fashion. \item Separation: nodes belonging to the same scale are separated by a minimal distance which dyadically shrinks at higher scales i.e. $\forall q,q'\in\Ss_i$ we have $\norm{q-q'}>\sigma2^{-i}$. \end{enumerate} Depth of the \emph{implicit} cover tree constructed with respect to the constraints above might grow very large for arbitrary datasets. Indeed we can easily verify that $i_{\max}\leq \log(\Delta(D))$, where \eq{ \Delta(D):=\frac{\max \norm{p-q}}{\min \norm{p-q}}, \qquad \forall p\neq q\in D. } is the \emph{aspect ratio} of $D$. In practice we however only keep one copy of the nodes which do not have either parent or a child other than themselves. This \emph{explicit} representation efficiently reduces the required storage space to scale $O(d)$ linearly with data population, regardless of any (intrinsic) dimensionality assumption~\cite{beygelzimer2006cover}. As suggested in \cite{covertree-faster}, each node $q$ could optionally save the maximum distance to its descendants denoted by \eq{ \mathrm{maxdist}(q):= \max_{q'\in \text{descendant}(q)} \norm{q-q'}, } which provides a useful information for further acceleration of the branch-and-bound algorithm used for the search step. Note that any node $q\in \Ss_i$ appearing at scale $i$ satisfies \eql{\label{eq:maxdistbound} \mathrm{maxdist}(q) \leq \sigma \left( 2^{-i}+2^{-i-1} + 2^{-i-2}+\dots \right) < \sigma 2^{-i+1} } as a result of the covering property and therefore, one might avoid saving $\mathrm{maxdist}(.)$ values and use this upper bound instead. {\defn{\label{def:eNN} Given a dataset $D$, a query point $p$ (which might not belong to $D$) and $\epsilon\geq 0$, then a point $q\in D$ from dataset is a $(1+\epsilon)$-approximate nearest neighbour of $p$ if it holds: \eql{ \norm{p-q} \leq (1+\epsilon)\min_{u\in D}\norm{p-u}.} }} Algorithm~\ref{alg:NN} details the branch-and-bound procedure for $(1+\epsilon)$-ANNS for a given cover tree structure. The proof of correctness of this algorithm is available in~\cite{beygelzimer2006cover}. In short, we iteratively traverse down the cover tree and at each scale we populate the set of \emph{candidates} $Q_i$ with nodes in $\Ss_i$ which could be the ancestors of the nearest neighbour solution and discard others. This refinement uses the triangular inequality and a lower bound on the distance between the grandchildren of $Q$ to the query $p$ which is calculated based on $\mathrm{maxdist}(q), \, \forall q\in Q$. Note that the maxdist information is either previously stored during construction of the tree or is bounded by \eqref{eq:maxdistbound}. Violating the refinement criteria at line~\ref{algline:refine} in Algorithm \ref{alg:NN} implies that $\forall q' \in \mathrm{descendant}(q)$ we would have \begin{align*} \quad \norm{p-q'} \geq \norm{p-q} -\mathrm{maxdist}(q) > \mathrm{dist}_{\min} \end{align*} and therefore, $q$ cannot be an ancestor of the nearest neighbour point \textemdash because the current estimate $q_c$ would anyway provide a smaller distance to the query. At the finest scale (before stopping) we search the whole set of final candidates and report a $(1+\epsilon)$-ANNS point. Note that at each scale we only compute distances for non self-parent nodes i.e. we pass without any computation distance information of the self-parent children to finer scales. The case $\epsilon=0$ refers to the exact tree NNS where one has to continue Algorithm~\ref{alg:NN} until the finest level of the tree. One should distinguish between this strategy and performing a brute-force search. Although they both perform an exact NNS, the complexity of Algorithm~\ref{alg:NN} is empirically shown to be way less in practical datasets. Noteworthy, although in this paper we focus on the Euclidean distance metric, cover trees are flexible to use a general notion of distance with respect to other metric spaces. \begin{algorithm}[t!] \begin{algorithmic}[1] \State \textbf{Inputs:} query point $p$, cover tree structure $\Tt$ for dataset $D$, current estimate $q_c \in D$, search inaccuracy $\epsilon\geq 0$ \State$Q_0 = \{\Ss_0\}$ \If{$q_c=\{\}$} $q_c=\Ss_0$ \EndIf \State $\mathrm{dist}_{\min}=\norm{p-q_c}$ \State{$i=0$} \While {$i<i_{\max}$ \, \text{AND} \, $\sigma 2^{-i+1}(1+\epsilon^{-1})> \d_{\min}$\,} \State $Q=\left\{\text{children}(q):\, q\in Q_i \right\}$ \State $q^* = \argmin_{q\in Q} \norm{p-q}$ \State $\mathrm{dist} = \norm{p-q^*}$ \If{$\mathrm{dist}<\mathrm{dist}_{\min}$} \State $\mathrm{dist}_{\min}=\mathrm{dist}$ \State $ q_c=q^*$ \EndIf \State $Q_{i+1} = \left\{q\in Q: \norm{p-q}\leq \mathrm{dist}_{\min} + \mathrm{maxdist}(q) \right\}$ \label{algline:refine} \State $i = i+1$ \EndWhile \Return $q_c \end{algorithmic} \caption{\label{alg:NN}Cover tree's \textbf{$(1+\epsilon)$-ANNS} $\left(p, \Tt, q_c\right)$ approximate search~\cite{beygelzimer2006cover}} \end{algorithm} \subsection{Complexity of the cover tree search} In the construction stage, a cover tree does not need to explicitly know the low-dimensional structure of data. However through building multi-resolution nets, several key growth properties such as the tree's explicit depth, the number of children per node, and importantly the overall search complexity are characterized by the intrinsic dimension of data~\cite{Navigating}, a notion that is referred to as the \emph{doubling dimension} introduced in~\cite{assouad,heinonen}: {\defn{\label{def:doub} Let $B(q,r)$ denotes a ball of radius $r$ centred at a point $q$ in some metric space. The doubling dimension $\dim_D(\Mm)$ of a set $\Mm$ is the smallest integer such that every ball of $\Mm$ (i.e. $\forall r>0$, $\forall q\in\Mm$, $B(q,2r)\cap \Mm$) can be covered by $2^{\dim_D(\Mm)}$ balls of half radius i.e. $B(q',r)\cap \Mm$, $q'\in \Mm$. }}. The doubling dimension has several appealing properties, for instance we have~\cite{heinonen,Navigating}: \begin{align} &\dim_D(\RR^L)=\Theta(L),\\ &\dim_D(\Mm_1)\leq \dim_D(\Mm_2) \quad \text{when} \quad \Mm_1\subseteq \Mm_2,\\ &\dim(\cup_{i=1}^I \Mm_i)\leq \max_i \dim_D(\Mm_i)+\log(I).\label{eq:uniondoub} \end{align} Following these properties, a spare point has zero dimension and a discrete set $D$ of $d$ unstructured points has $\dim_D(D)=O(\log(d))$, independent from the ambient dimension. This dimension could be further decreased by assuming certain regular structures in practical datasets e.g. they could belong to low-dimensional manifolds (embedded in higher ambient dimensions). It has been shown that a low-dimensional manifold $\Mm\in \RR^n$ with certain smoothness and regularity assumptions has $\dim_D(\Mm)=O(K)$ where $K\ll L$ denotes the topological dimension of the manifold~\cite{dasgupta2008}. As result a dataset $D\subseteq \Mm$ which samples a manifold with $K=O(1)$ (also a union of constant number of O(1)-dimensional manifolds) would have a constant doubling dimension i.e. $\dim_D(D)=O(1)$. The following theorem~\cite{Navigating,beygelzimer2006cover} bounds the complexity of cover trees approximate searches using the $(1+\epsilon)$-ANNS Algorithm~\ref{alg:NN}: {\thm{\label{thm:NNcomp2} Given a query which might not belong to dataset $D$, cover tree's $(1+\epsilon)$-ANNS approximate search takes at most \eql{ 2^{O(\dim_D(D))}\log \Delta(D)+(1/\epsilon)^{O(\dim_D(D))} } computations in time. }} In most applications e.g. uniformly distributed datasets we have $\log (\Delta) = O(\log(d))$~\cite{Navigating}. Therefore for datasets with low dimensional structures i.e. $\dim_D=O(1)$ and by using approximations one achieves search complexities logarithmic in data population $d$, as opposed to the linear complexity of a brute-force search. Table~\ref{tab:ctcomplexity} outlines the construction time, memory requirement and the search time complexities of cover trees. \begin{table}[t!] \centering \scalebox{1}{ \begin{tabular}{lccc} \toprule[.2em] Cover tree complexity & $\dim_D=O(1)$ & $\dim_D$ unknown\\ \midrule[.1em] Construction time & $O(d\log(d))$ & $O(d^2)$\\ Construction memory & $O(d)$ & $O(d)$ \\ Online insertion/removal & $O(\log(d))$ & $\Omega(d)$ \\ Approximate query time &$\log (\Delta) = O(\log(d)) & $\Omega(d)$\\ \bottomrule[.2em] \end{tabular} } \caption{Complexity of cover trees in terms of dataset population $d$ regarding the construction time and memory, online insertion and removal operations, and approximate query time when the dataset is doubling and when no assumption on its doubling dimensionality is made (i.e worst-case complexity)~\cite{beygelzimer2006cover}.} \label{tab:ctcomplexity} \end{table} There is a great motivation behind using cover trees searches for the MRF reconstruction problem. The manifold $\Mm:=\Bb(\Theta)\in \CC^L $ corresponding to the solutions of Bloch equations is parametrized by a small number $\Card(\Theta)\ll L$ of parameters; an observation which implies the resulting fingerprint dictionary will have a low-dimensional intrinsic structure. We are currently unable to provide a complete support for claiming that the Bloch response manifolds satisfy the regularity assumptions in~\cite{dasgupta2008} and that their doubling dimensions would be a constant i.e. $\dim_D(\Bb(\Theta))=O(\Card(\Theta))=O(1)$\footnote{Examples of space-filling and non-doubling manifolds parametrized by a small number of parameters exist and are discussed in~\cite{dasgupta2008}, however we do not expect that the Bloch ODE responses result in manifolds which could fall into such pathological and highly irregular categories.}, however, we keep this motivation to adopt cover trees searches to short-cut the heavy computations of the matched-filtering step in the MRF reconstruction. Our numerical experiments in Section~\ref{sec:expe} demonstrate that by using this structure one indeed achieves significant accelerations and great scalability i.e. a consistent performance in high ambient dimensions unrestricted by the use of a dimensionality reduction preprocessing step. \begin{algorithm}[t!] \begin{algorithmic}[1] \State \textbf{Inputs:} k-space measurements $Y$, cover tree structure $\Tt(D)$ constructed for the normalized fingerprint dictionary $D$, forward operator $\Aa:=P_\Omega F S$ and its corresponding adjoint operator $\Aa^H$, initial step-size $\mu$. \State \textbf{Initialization:} $k=0,\,X^0=\mathbf{0},\, \mu_k=\mu\,\, \forall k=1,2,\hdots$ \While {stopping criterion = false } \State $Z = X^k - \mu_k \Aa^H\left(\Aa(X^k)-Y \right)$ \qquad\qquad\qquad\qquad\qquad \#(gradient update) \For{$v=1,\hdots,n$}{\qquad\qquad\qquad\qquad\qquad \#(per-voxel approximate model projection)} \State $D_{j^*_{k+1},v} = \textbf{$(1+\epsilon)$-ANNS}\left( Z_v/\norm{Z_v}, \Tt(D), D_{j^*_{k},v}\right)$ \, \#(cover tree's ANNS)\label{algline:6} \State $\gamma_v = \max\left( \text{real}(\langle Z_v ,D_{j^*_{k+1},v}\rangle)/ {\norm{D_{j^*_{k+1},v}}^2},0\right)$ \label{algline:7} \State $X^{k+1}_v = \gamma_v D_{j^*_{k+1},v}$ \qquad \qquad\qquad\qquad\qquad\quad\qquad\quad\,\#(rescaling)\label{algline:8} \EndFor \If{$\mu_k \geq \frac{\norm{X^{k+1}-X^k}^2}{\norm{ \Aa(X^{k+1}-X^k) }^2}$} \qquad\qquad\qquad\qquad\quad\qquad\,\#(adaptive step-size shrinkage) \State $ \mu_k=\mu_k/2$ \Else \State $k=k+1$ \EndIf \EndWhile \State {$\overline \Theta_v \leftarrow$ look-up-table$\left(D_{j^*_{k+1},v}\right), \forall v$}\\ \Return reconstructed MRF image $X^{k+1}$, parameter maps $\overline\Theta$, proton density $\gamma \end{algorithmic} \caption{\label{alg:Coverblip} CoverBLIP$(Y,\Tt(D),\Aa,\mu)$} \end{algorithm} \subsection{CoverBLIP algorithm} \label{sec:coverblip} Approximation plays a key role in accelerating the nearest neighbour searches and breaking the curse-of-dimensionality~\cite{indyk1998breakCOD}. Motivated by the low-dimensional (manifold) structures present in the MRF dictionary, we propose to accelerate iterative matched-filtering steps within the BLIP algorithm by using cover tree's $(1+\epsilon)$-ANNS approximate searches. Algorithm~\ref{alg:Coverblip} outlines the proposed Cover tree BLoch Iterative Projection (CoverBLIP) procedure for accelerated MRF reconstruction. We replace the exact NNS step \eqref{eq:exactP} in the cone projection with the following approximation: \eql{\label{eq:ANN1} D_{j^*_{k+1}} = \textbf{$(1+\epsilon)$-ANNS}\left( Z_v/\norm{Z_v}, \Tt(D), D_{j^*_{k}}\right) \quad \forall v=1,\ldots,n, } which uses Algorithm~\ref{alg:NN} for a given inaccuracy level $\epsilon\geq 0$. We denote by $\Tt(D)$ the cover tree structure built for the normalized fingerprint dictionary. At each iteration CoverBLIP uses previously selected fingerprints (i.e. $D_{j^*_{k}}=X_v^k/\gamma_v$ for each voxel) to initialize the ANNS searches. This has two positive impacts: i) the search achieves further acceleration especially, close to the converging point of the algorithm, because with an initialization close to the ANNS solution the branch-and-bound procedure can effectively rule out many branches at higher levels of the tree and thus keep the candidates set very small, and ii) the $(1+\epsilon)$-ANNS algorithm would produce non-expansive outputs i.e. $\forall v$ we have \eql{ \norm{Z_v/\norm{Z_v} - D_{j^*_{k+1}}} \leq \norm{Z_v/\norm{Z_v} - D_{j^*_{k}}}, } which as will be discussed in the next part it is a key property to guarantee the monotone convergence of CoverBLIP. Note that we feed the search algorithm with the normalized gradient updates $Z_v/\norm{Z_v}$. Since dictionary atoms are normalized the search outcome is invariant with respect to the query rescaling, however from the complexity perspective one would gain in computation time by searching a query within a closer range to datasets' hypersphere. We also observed in our experiments that this trick leads to better accelerations. Convergence is tied to a proper choice of the step-size sequence. We follow the adaptive scheme proposed in~\cite{NIHT} which starts from a large initial step size and shrinks this choice by a division factor $\zeta>1$ e.g., half of the previous step size by setting $\zeta=2$ , until meeting the following criteria at each iteration $k$: \eql{\label{eq:steprule} \mu_k < \frac{\norm{X^{k+1}-X^k}^2}{\norm{ \Aa(X^{k+1}-X^k) }^2} } where again, $\Aa(.) :=P_{\Omega} FS(.)$ is the shorthand for the forward operator. This condition is another important ingredient to guarantee the convergence of CoverBLIP iterations, which supported by some extra assumptions will also imply a robust reconstruction i.e. near global convergence. We will discuss this point in further details in the next section. After the first iteration we can also use the following energy ratio between measurements and our first estimation i.e. $\kappa={\norm{Y}}/{\norm{\Aa(X^1)}}$ in order to rescale the first iteration $X^1\leftarrow \kappa X^1$ and set an appropriate range (e.g. large enough) for the initial step size $\mu\leftarrow \kappa \mu$. When applicable \textemdash and with a possible compromise in the accuracy \textemdash a temporal subspace compression similar as explained in Section~\ref{seq:mrfdimchallenge} can be optionally included to further shrink dimensions of $Z_v, X_v,D_j$ across the dominant SVD components $V_s\in \CC^{L\times s}$ of the MRF dictionary. In this case one has to build a cover tree structure for the normalized dimension-reduced dictionary $\widetilde D$, update the gradient step in Algorithm~\ref{alg:Coverblip} by the expression \eqref{eq:gradupdate}, and for the step-size expression~\eqref{eq:steprule} would change to \eql{ \mu < \frac{\norm{\widetilde X^{k+1}-\widetilde X^k}^2}{\norm{ \Aa(\widetilde X^{k+1}V_s^H-\widetilde X^kV_s^H) }^2}. } The updated gradient step might also introduce a compromise between cheaper distance evaluations during the search steps (i.e. in $\CC^s$ rather than $\CC^L$) and a computation overhead due to applying iteratively compression and decompression, as previously highlighted in Section~\ref{seq:mrfdimchallenge}. The approximate projection step presented in Algorithm~\ref{alg:Coverblip} (i.e. lines~\ref{algline:6} and~\ref{algline:7}) assumes that proton densities are real and positive valued quantities. A phase-alignment heuristic similar to~\cite{AIRMRF} can be used to extend this framework to complex-valued proton densities. This approach approximates dictionary atoms with fingerprints having constant complex phases across temporal domain. Complex angles corresponding to the first principal component i.e. $\widetilde D_{s=1}=V^H_{s=1}D$, are then used to align dictionary atoms. Similarly, at each iteration in line~\ref{algline:6} we align phases of the gradient update used for the search step; In our experiments we use the complex angles of the dominant compressed image i.e. $\text{angle}(\widetilde X_{s=1})$ for temporal phase-alignment. Empirical results applying this approach are demonstrated for our volunteer data experiments in Section~\ref{sec:expe_invivo}. \section{Convergence of CoverBLIP}\label{sec:proofs} The analysis in this part covers the behaviour of a wide class of \emph{inexact} IPG algorithms for solving linear inverse problems where the forward operator $\Aa$ and the set $\Cc$ of signal model could be regarded in general forms and not necessary customized for the MRF recovery problem. A previous work \cite{inexactipg-tit} studied the stability of the inexact IPG algorithms with respect to several forms of approximations on gradient and projection updates. Here we focus on iterative algorithms that use the following notion of relative approximate projection step i.e. for an $\epsilon\geq 0$ we define \eql{\label{eq:eproj} \widetilde \Pp_\Cc^\epsilon(x) \in \left\{u\in \Cc: \norm{u-x}\leq (1+\epsilon) \inf_{u'\in\Cc}\norm{u'-x}\right\}. } {\exmp{Following Definition~\ref{def:eNN}, the $(1+\epsilon)$-ANNS search algorithm is an approximate projection of type~\eqref{eq:eproj} onto a discrete set of points $\Cc:=D$ in a dataset e.g. a signal model which is used for data-driven inverse problems~\cite{inexactipg-tit}.} } {\exmp{ Notably for projection onto $\Cc:=\text{cone}(D)$, if we replace the exact search step in~\eqref{eq:exactP} with an approximate $(1+\epsilon)$-ANNS search, we obtain an approximate cone projection $\Pp^\epsilon_{\text{cone}(D)}(.)$ satisfying definition \eqref{eq:eproj}. Steps~\ref{algline:6} to~\ref{algline:8} in CoverBLIP Algorithm~\ref{alg:Coverblip} are indeed implementing such an approximate projection onto the cone associated with the MR fingerprints using fast cover tree searches.}} The corresponding inexact IPG iterations, including the CoverBLIP algorithm as a particular case, are as follows: \eql{\label{eq:inIP2} X^{k+1} = \Pp^\epsilon_\Cc \left(X^k - \mu_k \Aa^H\left(\Aa(X^k)-Y \right)\right), } We now follow this section by discussing two types of guarantees for the inexact IPG. The first type makes an embedding assumption on $(\Aa,\Cc)$ and provides a robust signal recovery result which in turn implies an interesting near global convergence guarantee for arbitrary signal models $\Cc$ including the non-convex conic constraints in the MRF problem. The second form of our analysis does not make an embedding assumption and only relies on an adaptive step-size scheme to ensure criteria~\eqref{eq:steprule} holds and guarantees local convergence of the inexact IPG algorithm. The following embedding assumption plays a critical role in our stable signal recovery result~\cite{BW:manifold,Blumen,inexactipg-tit}: {\defn{\label{def:bilip} A forward operator $\Aa$ is bi-Lipschitz with respect to a set $\Cc$, if $\forall x,x'\in \Cc$ there exists constants $0<\alpha\leq \beta$ such that \eql{\label{eq:bilip} \alpha \norm{x-x'}^2 \leq \norm{\Aa(x-x')}^2\leq \beta \norm{x-x'}^2. } }} Equipped with this notion the following result states that when we have a good measurement consistency i.e. when $\min_{X\in\Cc}\norm{Y-\Aa(X)}$ is small, then a near global convergence could be achieved using inexact iterations~\cite{inexactipg-tit,CoverBLIP-MLSP}: {\thm{\label{th:inexactLS1} Assume $(\Aa,\Cc)$ is bi-Lipschitz and that for a given $\epsilon\geq 0$ and some constant $\delta \in [0,1)$ it holds \eq{ \sqrt{\epsilon+\epsilon^2}\leq \delta \sqrt{\alpha}/{\vertiii{\Aa}} \qandq \beta < (2-2\delta+\delta^2) \alpha,} where $\vertiii{\Aa}$ denotes the spectral norm of $\Aa$. Set the step size $\mu_k=\mu, \forall k$ such that \eq{\left((2-2\delta+\delta^2) \alpha\right)^{-1}<\mu\leq\beta^{-1}.} The sequence generated by Algorithm~\eqref{eq:inIP2} obeys the following bound: \eql{\label{eq:linconv} \norm{X^{k}-X_0}\leq \rho^k \norm{X_0} + \frac{\kappa_w}{1-\rho}w } where $X_0=\argmin_{X\in \Cc}\norm{Y-\Aa(X)}$, $w=\norm{Y-\Aa (X_0)}$ and \begin{align*} \rho=\sqrt{\frac{1}{\mu \alpha} -1}+ \delta, \quad \kappa_w= 2\frac{\sqrt{\beta}}{\alpha}+\sqrt\mu\delta. \end{align*} }} {\rem{Theorem~\ref{th:inexactLS1} guarantees a linear convergence behaviour for inexact iterations. As a result after a finite $K=O(\log(\tau^{-1}))$ number of iterations Algorithm \eqref{eq:inIP2} achieves the solution accuracy $\norm{X^K-X_0}=O(w)+\tau$ for any $\tau>0$.}} {\rem{Under a properly conditioned bi-Lipschitz embedding as assumed in~Theorem~\ref{th:inexactLS1} the inexact algorithm achieves a solution accuracy comparable to that of the exact IPG algorithm. By increasing $\epsilon>0$ we require better embedding conditions as compared to the exact iterations (i.e. the case $\epsilon,\delta=0$). Although, increasing $\epsilon$ slows down the rate $\rho$ of linear convergence, it could facilitate significantly cheaper computations per iteration. In other words, approximation trades-off against the embedding conditions, rate of convergence and computation time, but not against the order of the solution accuracy. }} \newline The following proposition (see the proof in Section~\ref{sec:proof0} of the supplementary materials) says that by using the adaptive shrinkage scheme described in the previous part we can find a good step size in a finite (logarithmic) number of sub-iterations: {\prop{\label{prop:stepbound}Following the iterative step-size shrinkage scheme with the initial size $\mu$ and division factor $\zeta>1$, the chosen step size $\mu_k, \forall k$ meets the criteria~\eqref{eq:steprule} and satisfies the following bound: \eql{\label{eq:stepbound} (\zeta\beta)^{-1}\leq\mu_k\leq \alpha^{-1}. } in a finite number $\left \lceil \log_\zeta(\beta \mu) \right \rceil+1$ of iterations.}} \newline The following theorem establishes a stable reconstruction guarantee (i.e. near global convergence) for the inexact IPG algorithm by using the adaptive step size shrinkage scheme: {\thm{\label{th:inexactLS2} Assume $(\Aa,\Cc)$ is bi-Lipschitz, and that for given $\epsilon\geq 0$, $\zeta>1$ and some constant $\delta \in [0,1)$ it holds \eq{ \sqrt{\epsilon+\epsilon^2}\leq \delta \sqrt{\alpha}/{\vertiii{\Aa}} \qandq \zeta \beta < (2-2\delta+\delta^2) \alpha. } Following the adaptive step-size scheme with shrinkage factor $\zeta$, the sequence generated by Algorithm~\eqref{eq:inIP2} obeys the error bound~\eqref{eq:linconv} where, \begin{align*} \rho=\sqrt{\frac{\zeta\beta}{\alpha} -1}+ \delta, \quad \kappa_w= 2\frac{\sqrt{\beta}}{\alpha}+\frac{\delta}{\sqrt\alpha}. \end{align*} }} The proof architecture is similar to the proof of~\cite[Theorem~2]{inexactipg-tit}, however, this result does not a priori assume $\mu_k\leq 1/\beta$ as there or in Theorem~\ref{th:inexactLS1} of this paper. For the sake of completeness we provide detailed proof of Theorem~\ref{th:inexactLS2} in the supplementary materials Section~\ref{seq:proof1} {\rem{Without an a-priori knowledge of the embedding constants, the inexact IPG algorithm with adaptive step-size exhibits a similar linear convergence behaviour towards the global minima as in Theorem~\ref{th:inexactLS1}. The closer $\zeta$ is chosen to one, the embedding condition and the rate of convergence become more comparable to Theorem~\ref{th:inexactLS1}, however at the increased cost of more shrinkage sub-iterations.}} {\rem{Theorem~\ref{th:inexactLS1} generalizes results in \cite{NIHT} in two ways: i) the set $\Cc$ of constraints are general and not restricted to sparse signals, and ii) results here establish robustness against inexact projection updates. Notably when no approximation is used $\epsilon,\delta =0$, Theorem~\ref{th:inexactLS1} relaxes the embedding conditions in \cite[Theorem 3]{NIHT} which required $\zeta\beta<8/7 \alpha$. }} \newline Finally, we consider a general convergence result which holds even in the absence of the bi-Lipschitz embedding assumption. We additionally assume that the approximate projection produces non-expansive updates with respect to the previous iterations i.e. $\forall k$ and gradient updates $Z^k := X^k - \mu_k \Aa^H\left(\Aa(X^k)-Y \right)$ it holds : \eql{\label{eq:nonexpansive} \norm{\Pp^{\epsilon}_\Cc(Z^k) - Z^k}\leq \norm{X^k - Z^k}. } {\exmp{The $(1+\epsilon)$-ANNS update~\eqref{eq:ANN1} in CoverBLIP and the associated approximate cone projection satisfy the non-expansiveness property~\eqref{eq:nonexpansive}, thanks to initializing the search algorithm with previous iteration.\footnote{In general one could easily incorporate property~\eqref{eq:nonexpansive} by the following update in Algorithm~\eqref{eq:inIP2}: $X^{k+1}=\argmin_{u\in \{\Pp^{\epsilon}_\Cc(Z^k),X^k\}} \norm{u-Z^k}$.} }} \newline \newline The following result guarantees monotone convergence of Algorithm~\eqref{eq:inIP2} since the cost function $\norm{Y-\Aa(X)}\geq 0$ is lower bounded. The proof is provided in the supplementary materials Section~\ref{sec:proof2}: {\thm{\label{th:inexactmonotone}Assume the approximate projections are non-expansive and the step-size satisfies~\eqref{eq:steprule}. Algorithm~\eqref{eq:inIP2} produces a non-increasing and convergent sequence $\norm{Y-\Aa(X^k)}$.}} \newline Note that determining the bi-Lipschitz conditioning i.e. constants $\alpha$ and $\beta$ and hence an admissible interval for choosing the step-size (as suggested in Theorem~\ref{th:inexactLS1}) is a combinatorial problem in general. For a certain class of \emph{random} sampling schemes used in compressed sensing theory however it is possible to derive those constants with high probability, see e.g.~\cite{vershynin-randommatrix, rauhut-randommatrix,JLCS}. Applied to the MRF problem, it has been shown in \cite[Theorem 1]{BLIPsiam} that if sampling patterns $\Omega_t$ sub-select uniformly at random large enough number of rows (or columns) of the k-space \textemdash a sampling protocol referred to as the random Echo Planar Imaging (EPI) \textemdash then the resulting forward model $\Aa$ is bi-Lipschitz, and a fixed choice of step-size equal to the compression factor \eq{\mu_k= n/m, \quad \forall k} guarantees stable reconstruction. Randomized acquisition schemes are however not currently popular in practical MRF setups, leading to pronounce more the importance of theorems~\ref{th:inexactLS2} and~\ref{th:inexactmonotone}. In Theorem~\ref{th:inexactLS2} one does not need to explicitly obtain the bi-Lipschitz constants, however if the forward model happens to satisfy a proper embedding condition then the adaptive step-size scheme is determined to make a proper choice (within the corresponding admissible interval) which guarantees near global convergence. Otherwise in the absence of any embedding assumption Theorem~\ref{th:inexactmonotone} ensures monotone convergence of the non-convex projected iterations i.e. the stability of the algorithm. \section{A note on using density compensation for preconditioning the MRF reconstruction with spiral readouts} \label{sec:dcf} \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.95\textwidth]{./figs/DCFBPI_danma-eps-converted-to.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/BPI_danma-eps-converted-to.pdf} } \\ (a) Back-projected images with (top row) and without (bottom row) DCF weighting \\ \subfloat {\includegraphics[width=.45\textwidth]{./figs/DCF.png} } \\ (b) DCF profile across one spiral arm \caption{Figure (a) demonstrates five BPI temporal slices reconstructed with and without DCF compensation i.e. $X' = \Aa^H\left(\text{diag}(w)Y\right)$ and $X' = \Aa^H(Y)$, respectively. Figure (b) shows the DCF weights computed for the spiral readouts used in this experiment. Indices concentrated near the centre of k-space have relatively smaller weights.\label{fig:BPI_scan}} \end{minipage} \end{figure*} Spiral readouts acquire much denser collection of samples from the centre of k-space than the outer regions. As a result the forward operator $\Aa$ becomes more ill-conditioned as compared to e.g. a Cartesian acquisition. In this case if we perform an iterative reconstruction such as \eqref{eq:blip} the progress in each iteration will be very small. As can be observed in Figure~\ref{fig:BPI_scan}(a), applying the adjoint operator on the k-space data $X' = \Aa^H(Y)$ results in heavily blurred images in the first iteration. Such slow convergence combined with costly NUFFT updates at each iteration makes the reconstruction extremely time-consuming. One fix to this issue \textemdash which we adopt in our experiments in Section~\ref{sec:expe_invivo} of the main article \textemdash is to use a \emph{weighted} least squares loss for the fidelity term with smaller weights for the central k-space locations. The objective of \eqref{eq:CS} updates to \eq{ \sum_{t=1}^L \norm{Y_t-P_{\Omega_t} FS(X_t)}_\Ww^2, } where the weighted norm is defined as $\norm{a}_\Ww^2 := \sum_i w_i|a_i|^2$, and the weights $w_i>0$ are derived from calculating the Density Compensation Function (DCF) for a given spiral trajectory~\cite{dcf-voronoi}. Figure~\ref{fig:BPI_scan}(b) illustrates DCF weights for the sampling trajectory used in this experiment. Following the update in the objective function and the corresponding gradient expression, the iterations of BLIP in~\eqref{eq:blip} take the following form: \eql{\label{eq:blip_dcf} X^{k+1} = \Pp_\Cc \left(X^k - \mu^k \Aa^H\left(\text{diag}(w)\left(\Aa(X^k)-Y \right)\right)\right). } Similar update applies to CoverBLIP \eqref{eq:inIP2}, KDBLIP and their SVD dimension-reduced variants when using spiral readouts. Figure~\ref{fig:BPI_scan}(a) illustrates the weighted back projected images (BPI) i.e. $X' = \Aa^H\left(\text{diag}(w)Y\right)$ in the first iteration, where we can observe the blurring has been removed (the under-sampling artefacts however remain). DCF reweighing significantly improves the conditioning of Hessian $\Aa^H\text{diag}(w)\Aa$ compared to that of $\Aa^H\Aa$ and results in much larger chosen step-size and faster progress during the iterations i.e. faster convergence. Similar to the Carteian sampling we initialize the step-size by the compression factor $\mu=n/m$ and we empirically observe that this choice satisfies the criteria~\eqref{eq:steprule} for most of the iterations and for the rest one or two shrinkage sub-iterations suffices. \section{Numerical experiments} \label{sec:expe} \begin{table*}[t!] \centering \scalebox{.74}{ \begin{tabular}{clc} \toprule[0.2em] Algorithm & Description \\ \midrule[0.1em] BLIP & Iterative reconstruction \eqref{eq:blip} using exact brute-force searches for the matched-filtering~\cite{BLIPsiam} \\ \midrule[0.05em] Template Matching & Non iterative matched-filtering reconstruction using exact brute-force searches~\cite{MRF}\\ (TM) & (i.e. the first iteration of BLIP)\\ \midrule[0.05em] KDBLIP & Iterative reconstruction similar to~\cite{AIRMRF} using KD-tree's ANNS for the matched filtering \\ & (Approximation level is controlled by the number of \emph{checks} which specifies the maximum leafs to\\ &\, visit during the search. Higher checks values give better search precision, but also take more time)\\ \midrule[0.05em] CoverBLIP & Iterative reconstruction Algorithm~\ref{alg:Coverblip} using cover tree's $(1+\epsilon)$-ANNS for the matched filtering\\ &(Approximation level is controlled by $\epsilon\geq 0$ which bounds the search precision according to \\ &\, Definition~\ref{def:eNN}. Smaller $\epsilon$ would give better search precision, but also take more time). \\ \bottomrule[0.2em] \end{tabular}} \caption{Algorithms used for validations and comparisons.}\label{tab:algs} \end{table*} In this section we evaluate and compare the performance of the proposed CoverBLIP algorithm against dictionary-based MRF reconstruction baselines listed in Table~\ref{tab:algs}. Experiments are conducted using MATLAB on a moderate desktop with 8 CPU-Cores and 32 GB RAM. For BLIP and TM algorithms the exact NNS is calculated using MATLAB's matrix product. KDBLIP iterations use randomized KD-tree searches implemented by the FLANN package \cite{flann}. Our CoverBLIP algorithm uses a parallel MATLAB interface to an existing implementation of the cover tree's $(1+\epsilon)$-ANNS in \cite{covertreecode}.\footnote{Implementations related to this work are available online at: \url{http://github.com/mgolbabaee/CoverBLIP}.} We do not believe this implementation is as optimized as that of the FLANN package for KD-tree searches and thus any reconstruction time comparisons (if not unfair) must take this point into account. \paragraph{Temporal subspace compression option} As discussed in Section~\ref{seq:mrfdimchallenge} all considered methods here can use a temporal compression option where the corresponding subspaces are the $s\leq L$ dominant SVD components of the fingerprint dictionary. This option has the advantage of reconstructing smaller objects i.e. MRF images, accelerated gradient updates i.e. forward and adjoint Fourier operations, and performing searches in low dimensional (ambient) space. The later is particularly beneficial for non-scalable search schemes such as KD-trees. \paragraph{Datasets} Two sets of experiments are conducted: one using the synthetic Brainweb digital phantom with available Ground Truth (GT) maps~\cite{webbrain}, and the other using \emph{in-vivo} scans of a healthy volunteer's brain which appeared in the original work of Ma \emph{et al.}~\cite{MRF}. Both experiments use the Inversion Recovery (IR) Balanced SSFP acquisition sequence of length $L=1000$, however with different flip angles and repetition times TR. The resulting temporal signals from the IR-BSSFP sequence encode three NMR parameters $\Theta = \{T1,T2,B0\}$ i.e. the relaxation times and the off-resonance frequency. For each experiment and given FA and TR patterns a fingerprint dictionary is created as in~\cite{MRF} by solving discrete-time Bloch equations for combinations of the NMR parameters. \begin{figure*}[t!] \centering \begin{minipage}{\textwidth} \centering \subfloat[Segments] {\includegraphics[height=4cm]{./figs/brainweb_segment.pdf} } \quad \subfloat[PD map] {\includegraphics[height=4cm]{./figs/brainweb_PD.pdf} } \caption{(a) The segmented Brainweb phantom coloured by index, and the corresponding parameters ($T1$ msec, $T2$ msec, $B0$ Hz) used for simulations: 0 = background, 1 = Cerebrospinal Fluid (5012, 512, -20), 2 = grey matter (1545, 83, -40), 3 = white matter (811, 77, -30), 4 = adipose (530, 77, 50), 5 = skin/muscle (1425, 41, 250), (b) the proton density (PD) map. \label{fig:numphantom}} \end{minipage} \end{figure*} \paragraph{Evaluation metrics} The normalized solution MSE (NMSE) is measured as $\frac{\|\hat{X}-X_0\|}{\|X_0\|}$ where $X_0,\hat{X}$ are the ground truth and the reconstructed MRF images, respectively. The NMR parameter estimation accuracies are measured e.g. for the $T1$ case, as follows: \eq{ \text{$T1$ accuracy}:=1-\frac{1}{\Card(\Nn)}\Sigma_{v\in\Nn} \frac{|\hat T1(v)-T1(v)|}{T1(v)} } where $v$ is the number of voxels within a masked region $\Nn$ defining the object of interest. The mask is obtained by contouring the output proton density (PD) map of the brain and to remove empty voxels where the quantitative values are undefined. Here $T1(v)$ represents the ground truth $T1$ value for the $v$-th voxel and $\hat{T1}(v)$ is the corresponding estimated value. \paragraph{Computational cost} To have a fair comparison between computational complexities of the considered methods \textemdash and independent from how optimally they are implemented \textemdash we measure \emph{total search costs} in addition to the reconstruction times. The cost measures the total number of computed pairwise distances (multiplied by the search dimension i.e. either $L$ or $s\leq L$ when using subspace compression) for performing the NNS or ANNS steps within (iterative) matched-filtering until the algorithm converges. For all iterative methods the maximum number of iterations is set to $50$ and the algorithm is stopped earlier if the relative progress in minimizing the objective function of \eqref{eq:CS} (or \eqref{eq:CS1} when using subspace compression) is less than $10^{-6}$. \begin{figure*}[t!] \centering \begin{minipage}{\textwidth} \centering \subfloat[Flip angles (FA)] {\includegraphics[width=.48\textwidth]{./figs/FA.pdf} } \hfill \subfloat[$T2=100$ (msec), $B0=20$ (Hz)] {\includegraphics[width=.48\textwidth]{./figs/dico_T1.pdf} } \\ \subfloat[$T1=1100$ (msec), $B0=20$ (Hz)] {\includegraphics[width=.48\textwidth]{./figs/dico_T2.pdf} } \hfill \subfloat[$T1=1100$ (msec), $T2=100$ (msec)] {\includegraphics[width=.48\textwidth]{./figs/dico_B0.pdf} } \caption{The IR-BSSFP dictionary generated from a set of pseudo-random FAs shown in Figure (a) and fixed $TR=10$ (msec). This dictionary encodes $T1$ and $T2$ relaxation times and off-resonance frequency $B0$. Figures (b)-(d) show the magnitude of the complex fingerprints (i.e. dictionary atoms) for different parameter combinations. \label{fig:FAdict1}} \end{minipage} \end{figure*} \begin{figure*}[h!] \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.98\textwidth]{./figs/BPI-eps-converted-to.pdf} } \\ \subfloat {\includegraphics[width=.98\textwidth]{./figs/BPI_GT-eps-converted-to.pdf} } \caption{Ground truth MRF images generated from the Brainweb phantom (bottom row) and the highly aliased BPIs (top row) $X'= \Aa^H(Y)$ across different time frames \label{fig:BPI_synth}} \end{minipage} \end{figure*} \begin{table*}[t!] \centering \scalebox{.8}{ \begin{tabular}{lccccccccc} \toprule[0.2em] Algorithm & checks/$\epsilon$ & NMSE & T1 acc. &T2 acc. & df acc. & search cost & search time& iter. & total runtime \\ & & & (\%) & (\%) & (\%) & &(sec)& & (sec) \\ \midrule[0.1em] & \multicolumn{8}{c}{Temporal compression $s=20$ } \\ \midrule[0.1em] BLIP&-& 1.563e-1& 94.2 & 85.3& 75.3& 1.11e13&1.08e3&14&1.11e3 \\ \midrule[0.05em] CoverBLIP&0.4& {1.295e-1}& {94.6}& {89.2}&{81.2}&{ 3.94e9}& {2.74e1}&14& {5.65e1} \\ \midrule[0.05em] KDBLIP&256& 1.355-1& 94.2& 85.8& 79.6& 5.83e9 & 6.62e1&14&9.34e1 \\ \midrule[0.1em] & \multicolumn{7}{c}{No temporal compression} \\ \midrule[0.1em] BLIP&-& 5.327e-3& {99.4} & {98.5}& {84.3}& 6.59e14&1.33e4 &20&1.34e4 \\ \midrule[0.05em] CoverBLIP&0.4& {5.300e-3}& {99.4}& {98.5}& {84.3}& {4.86e11}& {3.45e2} &25& 4.93e2 \\ \midrule[0.05em] KDBLIP&256& 1.727e-1& 92.7& 78.7& 67.4& 3.05e12& 4.49e2&38&6.96e2 \\ \bottomrule[0.2em] \end{tabular}} \caption{Comparisons between iterative methods with/without using temporal subspace compression in terms of reconstruction NMSE, parameter estimation accuracy, search cost/time, number of iterations and total reconstruction time. }\label{tab:phantom_comp} \end{table*} \subsection{Numerical Brainweb phantom with multi-shot EPI acquisition}\label{sec:brainwebexpe} In this part we compare the performance of different MRF recovery methods on a synthetic dataset. We use a $256\times256$ slice from the numerical Brainweb phantom with segments corresponding to the background and five different tissues each associated to a set of $\Theta=\{T1,T2,B0\}$ parameters (Figure~\ref{fig:numphantom}(a)). After an inversion pulse, a pseudo-random FA sequence\footnote{The FA pattern consists of half-sinusoidal curves with the period of 250 repetition times followed by no excitations for 50 repetition times between the cycles. The maximum flip angles alter between $60^\circ$ and $30^\circ$ in odd and even periods. A zero-mean uniformly distributed noise of standard deviation 5 is added to the FAs.} with fixed $TR=10$ (msec) and $TE=TR/2$ is used for excitations. Temporal Bloch responses of the phantom segments are amplified by a given PD map (Figure~\ref{fig:numphantom}(b)) and synthesize the whole ground truth MRF image $X_0$ of size $(n=256^2)\times (L=1000)$. The same excitation is used to generate a dictionary of $d=314160$ fingerprints corresponding to combinations of the quantized parameters $T1=[100:40:2000,2200:200:6000]$ (msec), $T2 = [20:2:100,110:4:200,220:20:600]$ (msec), $B0=[-250:40:-190,-50:2:50,190:40:250]$ (Hz). Figure~\ref{fig:FAdict1} illustrates the FA pattern and the resulting dictionary fingerprints used in this experiment. For k-space sampling we simulate a similar protocol to the recently proposed multi-shot Echo Planar Imaging (EPI) for MRF acquisition~\cite{multishotEPI}. This protocol is based on a Cartesian grid Fourier sub-sampling where at each repetition time 16 out of 256 lines (with uniform spacing) from the k-space are simultaneously measured. In the next time frame the sixteen-shot sampling pattern $\Omega_t$ will be shifted by one line and so on. As a result we are dealing with reconstructing a 16x-fold undersampled data. We consider a single coil acquisition $S(X)=X$ and white Gaussian noise of 50 dB SNR added to the k-space measurements. Figure~\ref{fig:BPI_synth} illustrates the ground truth MRF images $X_0$ and the highly aliased back-projected images (BPI) i.e. $X' = \Aa^H(Y)$ using this sampling protocol. \begin{figure} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.7\textwidth]{./figs/Comp_Accu_k20k1000-eps-converted-to.pdf} } \caption{Total search cost vs. solution accuracy of the non-iterative TM and iterative BLIP algorithms using brute-force searches, and inexact iterative algorithms CoverBLIP and KDBLIP using fast tree searches. Two scenarios of applying temporal SVD compression where $s=20$, and using no temporal compression are compared \label{fig:compVSacc}} \end{minipage} \end{figure} \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.98\textwidth]{./figs/T1maps_svd20_other.pdf} } \\ \subfloat {\includegraphics[width=.98\textwidth]{./figs/T2maps_svd20_other.pdf} } \\ \subfloat {\includegraphics[width=.98\textwidth]{./figs/dfmaps_svd20_other.pdf} } \\ (a) Temporal compression ($s=20$) \\ \subfloat {\includegraphics[width=.82\textwidth]{./figs/T1maps_svd1000_other.pdf} } \\ \subfloat {\includegraphics[width=.82\textwidth]{./figs/T2maps_svd1000_other.pdf} } \\ \subfloat {\includegraphics[width=.82\textwidth]{./figs/dfmaps_svd1000_other.pdf} } \\ (b) No temporal compression \caption{The ground truth (GT) and reconstructed $T1$, $T2$ and $B0$ maps for the numerical Brainweb phantom acquired by the (simulated) multi-shot EPI protocol with x16-fold under-sampling. KDBLIP and CoverBLIP iterations use search accuracies checks = 256 and $\epsilon=0.4$, respectively. Figures (a) and (b) compare the estimated maps with/without using the SVD based temporal compression for all tested algorithms.\label{fig:phantom_maps}} \end{minipage} \end{figure*} \subsubsection{Results} We report reconstruction times, total search (projection) costs, image reconstruction errors and parameter estimation accuracies in Figure~\ref{fig:compVSacc} and Table~\ref{eq:CS}. We also show the reconstructed parameter maps in Figure~\ref{fig:phantom_maps}. For the KDBLIP algorithm we vary the KD-tree's search accuracy level by choosing $\text{checks}=\{1024, 256, 64, 16\}$. For the CoverBLIP algorithm we also test different $(1+\epsilon)$-ANNS search approximations by choosing $\epsilon=\{0.1, 0.2, 0.4, 0.8, 1.6\}$. We initialize the step-size of the iterative schemes by the compression factor $\mu=n/m$ which empirically turns out to satisfy criteria~\eqref{eq:steprule} in most iterations and requires one shrinkage sub-iteration for the rest (see discussions in Section~\ref{sec:proofs}). Temporal SVD compression ($s=20$) accelerates the runtimes of all tested methods within 1-2 orders of magnitude (Table~\ref{tab:phantom_comp}), however such an aggressive compression leads to poor parameter reconstructions (Figure~\ref{fig:phantom_maps}(a)). Focusing on the non-compressed regime, we can see that Template Matching (TM) cannot achieve a good accuracy compared to the iterative methods (Figures~\ref{fig:compVSacc} and~\ref{fig:phantom_maps}(b)). The BLIP algorithm addresses this issue however at a high computational cost of iterating exact brute-force searches. Note that since the multi-shot EPI acquisition uses a Cartesian sampling, $F$ in the forward model~\eqref{eq:CS} corresponds to a FFT operator with fast gradient updates. As a result, and as can be observed in Table~\ref{tab:phantom_comp}, projections (i.e. searches) dominate the runtimes of the iterative methods and thus accelerating this step would directly improve the total reconstruction time. CoverBLIP does so by using inexact cover tree searches (e.g. $\epsilon=0.4$) and achieves the best reconstruction time-accuracy (also search cost-accuracy) in all cases. Remarkably, CoverBLIP reports a similar accuracy to BLIP iterations however with 3 orders of magnitude less search cost and 27x-fold acceleration in the reconstruction time. Notably, the total cost of CoverBLIP inexact searches does not exceed that of a single stage brute-force search in TM (Figure~\ref{fig:compVSacc}). When using temporal compression\textemdash a favourable case for the KD-tree searches\textemdash KDBLIP with number of checks = 256 performs comparable to the CoverBLIP algorithm. However, for improving the overall estimation accuracy if we wish to not use subspace compression, then KDBLIP's time-accuracy performance fails to catch up with that of CoverBLIP. Figure~\ref{fig:compVSacc} shows the gap between performances of these two algorithms caused by the non-scalability of the KD-tree searches. For instance CoverBLIP with $\epsilon=0.4$ outputs more accurate parameter maps (Figure~\ref{fig:phantom_maps}(b)) whilst reporting 6x less total search cost. \subsection{In-vivo data with variable-density spiral acquisition}\label{sec:expe_invivo} In this part we evaluate reconstruction methods in Table~\ref{tab:algs} on \emph{in-vivo} MRF data acquired from a healthy volunteer using the IR-BSSFP sequence and the 1.5 T whole body Espree Siemens Healthcare scanner with 32-channel head receiver coil. This dataset was used in the seminal paper of Ma \emph{et al.}~\cite{MRF}, where FAs have a pseudo-randomized (Perlin noise) pattern of length $L=1000$ and TRs are uniformly selected at random between 10.5 and 14 msec. At each time frame (repetition time) one interleaf of the variable-density spiral readout samples the k-space (see~\cite[Figure 1]{MRF} for the FA,TR and spiral readout patterns used in this experiment). The spiral trajectory $\Omega_t$ rotates by $7.5^\circ$ in the next time frame to sample different k-space locations and so on. The overall k-space undersampling factor is 48x folds and since a non-Cartesian readout pattern has been used, the operator $F$ in the forward model \eqref{eq:forward} is implemented using the non-uniform Fourier transform (NUFFT)~\cite{NUFFT}. Sensitivity maps (i.e. $S$ operator in \eqref{eq:forward}) are computed off-line from the acquired multi-coil data~\cite{cmap-adaptive}. For reconstruction a dictionary of $d=363624$ fingerprints is simulated for combinations of discrete parameters $T1=[100:20:2000,2300:300:5000]$ (msec), $T2 = [20:5:100,110:10:200,300:200:1900]$ (msec), and $B0=[-250:20:-190,-50:1:50,190:20:250]$ (Hz). As a common practice used to precondition non-Cartesian MRF problems, we incorporate a density compensation scheme within the reconstruction pipeline to enable faster convergence (see more details in Section~\ref{sec:dcf} of the supplementary materials). With this update, we initialize the step-size by the compression factor $\mu=n/m$ similar to the Cartesian sampling. We empirically observe that this choice satisfies the criteria~\eqref{eq:steprule} for most of the iterations and for the rest one or two shrinkage sub-iterations suffices. \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat[T2 Map reconstructed by TM i.e. the first iteration of BLIP] {\includegraphics[height=4.5cm]{./figs/TM_T2_N128C32.pdf} } \hfill \subfloat[T2 Map reconstructed by BLIP] {\includegraphics[height=4.5cm]{./figs/BLIP_T2_N128C32.pdf} } \hfill \subfloat[Fidelity error decay through iterations] {\includegraphics[height=4.5cm]{./figs/BLIP_fidelity_decay_grid.pdf} } \caption{Reconstruction at $n=128\times128$ spatial resolution (32-coil data). Despite a better data consistency, the iterative scheme (BLIP) reports high-frequency artefacts in the reconstructed maps indicating the lack of sufficient high-resolution information in an spiral readout.} \label{fig:highres} \end{minipage} \end{figure*} \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.95\textwidth]{./figs/compare_coils_TM32.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/compare_coils_TM6.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/compare_coils_BLIP6.pdf} } \caption{Recovered $T1,T2,B0$ and PD maps from the 32-coil data using TM algorithm (A-D), and those reconstructed from only 6-coil data by using TM (E-H) and iterative BLIP (I-L) algorithms \label{fig:coilcompare}} \end{minipage} \end{figure*} \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.95\textwidth]{./figs/compare_svd_BLIP200.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/compare_svd_BLIP20.pdf} } \caption{Reconstructed maps using BLIP algorithm (6-coil data). Significant subspace compression ($s=20$) causes overestimation of the $T2$ values (F) and distortion in the $B0$ map (G) e.g. around fat/muscle regions. A moderate compression ($s=200$) results in a reconstruction quality (A-D) comparable to that of using no temporal compression i.e. Figure~\ref{fig:coilcompare}(I-L).} \label{fig:svdcompare} \end{minipage} \end{figure*} \subsubsection{Missing high-resolution information and high-frequency artefacts} As can be observed in Figure~\ref{fig:highres}(b), using iterative methods for spiral readouts may cause high-frequency artefacts in the estimated maps. We would like to emphasize that this issue does not arise because of the deficiency of iterations. Indeed, the monotone decay of the measurement fidelity error implies that iterations improve data consistency as compared to the non-iterative TM scheme (Figure~\ref{fig:highres}(c)). As also highlighted in~\cite{AIRMRF}, after an initial rapid decay in the fidelity error a long epoch of slowly-decaying iterations will follow to recover high-resolution image features. However, since spiral readouts do not sufficiently sample high-frequency k-space locations, solving~\eqref{eq:CS} may admit undesirable solutions with high-frequency artefacts which appear in the second epoch of iterations until convergence. These artefacts can be removed by either using a spatial-smoothing regularization\footnote{In \cite{AIRMRF} a low-pass filtering is used at each iteration to remove high-frequency artefacts. However, in conjunction with a non-convex matching step, such a sequential projection approach (i.e. for multiple constraints) would not guarantee the convergence of iterations.} or by reconstructing images in a lower spatial resolution. Here we take the latter approach and reconstruct volunteer images in $n=100\times100$ resolution for the rest of our experiments \textemdash instead of the $128\times128$ resolution maps shown in~\cite[Figure 3]{MRF} using the non-iterative TM. We also observe that with this update we require less iterations to converge. \begin{table*}[t!] \centering \scalebox{.87}{ \begin{tabular}{lc|ccc|ccc} \toprule[0.2em] Algorithm & \multicolumn{1}{c}{ BLIP } & \multicolumn{3}{c}{ CoverBLIP } & \multicolumn{3}{c}{ KDBLIP } \\ \midrule[0.05em] ANNS parameter & - & 0.1 & 0.2 & 0.4 & 256& 512 & 4096 \\ \midrule[0.1em] & \multicolumn{7}{c}{Temporal compression $s=20$ } \\ \midrule[0.05em] Total search cost& 5.83e11 & 1.31e9 & 5.96e8 & 3.16e8 &2.74e9&5.38e9 & 3.58e10 \\ Reconstruction time (sec)& 133.0 & 28.3 & 23.8 & 22.4 &25.3&26.5 & 48.9 \\ Normalized fidelity error& 1.248e-1 & 1.266e-1 & 1.266e-1 & 1.267e-1 &1.275e-1& 1.273e-1 & 1.269e-1 \\ \midrule[.1em] &\multicolumn{7}{c}{Temporal compression $s=200$ } \\ \midrule[0.05em] Total search cost& 6.55e12 & 6.97e10 & 2.28e10 & 9.91e9 & 4.88e10 & 9.68e10&6.76e11 \\ Reconstruction time (sec)& 411.5 & 192.3 & 147.2 & 140.6 & 153.1 &156.5& 171.8 \\ Normalized fidelity error& 1.285e-1 & 1.305e-1 & 1.306e-1 & 1.309e-1 &1.337e-1& 1.333e-1 & 1.328e-1\\ \midrule[.1em] &\multicolumn{7}{c}{No temporal compression} \\ \midrule[0.05em] Total search cost& 2.91e13 & 3.84e11 & 1.37e11 & 6.76e10 &5.60e11& 1.33e12 & 8.11e12\\ Reconstruction time (sec)& 1660.1 & 1014.7 & 652.4 & 684.1 &680.0& 825.6 & 846.6 \\ Normalized fidelity error& 1.287e-1 & 1.307e-1 & 1.311e-1 & 1.320e-1 &1.490e-1& 1.458e-1& 1.414e-1 \\ \bottomrule[0.2em] \end{tabular}} \caption{Comparison between iterative methods with/without using temporal subspace compression in terms of search cost, total runtime and normalized fidelity error.}\label{tab:comp} \end{table*} \begin{figure*} \centering \begin{minipage}{\textwidth} \centering \subfloat {\includegraphics[width=.95\textwidth]{./figs/coverblip_2_200.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/kdblip_1_200.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/coverblip_2_full.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/kdblip_2_full.pdf} } \\ \subfloat {\includegraphics[width=.95\textwidth]{./figs/kdblip_3_full.pdf} } \caption{Reconstructed maps using inexact iterations of CoverBLIP and KDBLIP algorithms (6-coil data), tested for different search-dimension regimes i.e. with/without using temporal subspace compression.\label{fig:coverkdcompare}} \end{minipage} \end{figure*} \subsubsection{Results} The non-iterative TM algorithm performs reasonably well when all 32 coil/channel data are used (Figure~\ref{fig:coilcompare}(A-D)), supporting the fact that in data-rich regimes we may not need sophisticated inference algorithms~\cite{Chandra-Jordan}. To better highlight the advantage of iterations we select measurements from 6 coils that maximally cover the k-space. As can be observed in Figure~\ref{fig:coilcompare}(H,L), the recovered PD maps from the 6-coil data demonstrate weaker signal intensity in central and certain border regions as compared to the one obtained from the 32-coil data in Figure~\ref{fig:coilcompare}(D). Comparing Figure~\ref{fig:coilcompare}(B,C) to Figure~\ref{fig:coilcompare}(F,G) shows that TM reconstruction for the reduced 6-coil data introduces artefacts in both $T2$ and $B0$ maps around the Cerebrospinal Fluid (CSF) regions where the signal is weak. The iterative BLIP algorithm however corrects for this issue and works stably in low-data regime. The rest of our experiments focuses on the 6-coil k-space data. We next compare the performance of exact BLIP iterations using the subspace compression option. As we can see in Figure~\ref{fig:svdcompare}(F,G) a significant SVD compression ($s=20$) causes overestimated $T2$ values and distorted $B0$ map (e.g. see fat/muscle regions) whereas, using a moderate compression ($s=200$) results in reconstruction quality comparable to that of using no subspace compression (compare the reconstructed maps in Figure~\ref{fig:svdcompare}(A-D) to Figure~\ref{fig:coilcompare}(I-L)). The reason is that the subspace of $s=200$ principal components can well represent the IR-BSSFP dictionary used in this experiment (see also related discussions in~\cite{SVDMRF}). Table~\ref{tab:comp} compares the reconstruction performance of iterative methods BLIP, KDBLIP and CoverBLIP for different search dimension regimes with/without using subspace compression. The corresponding reconstructed maps can be also visually compared in Figure~\ref{fig:coverkdcompare}. The BLIP algorithm using exact brute-force searches achieves the lowest fidelity error but it requires the longest reconstruction time and highest search complexity. CoverBLIP with $\epsilon=0.2$ reports the best reconstruction time-accuracy (also total search cost) among all tested methods. CoverBLIP saves between 2 to 3 orders of magnitude in total search cost of BLIP with a comparable reconstruction accuracy (see the corresponding normalized fidelity errors in Table~\ref{tab:comp} and the recovered maps in Figure~\ref{fig:coverkdcompare}(A-D, I-L)). Importantly and unlike KDBLIP, this computational advantage is consistent for all three search-dimension regimes. We can observe in Figure~\ref{fig:coverkdcompare}(E-H) that by using subspace compression $s=200$, the KDBLIP algorithm with 256 checks outputs comparable parameter maps to that of CoverBLIP, however with 2-4 times more search cost. Runtimes reported for both methods in this case (Table~\ref{tab:comp}) are however similar because as previously pointed out we do not claim an optimal implementation of the cover tree searches used here. KDBLIP uses non-scalable tree searches and therefore without a dimensionality reduction \textemdash even with a large number of checks = 4096, a longer runtime and 80x higher search cost than CoverBLIP\textemdash this algorithm fails to output artefact-free parameter maps (Figure~\ref{fig:coverkdcompare}(M-T)). More artefacts occur using smaller checks e.g. 512 or 256. In this experiment a moderate subspace compression turns out to be advantageous for all tested algorithms, but then it is a crucial step for using KD-tree searches. We empirically observed that KDBLIP starts reporting poor reconstruction time-accuracies when more than $350$ principal components are used. Comparing the overall runtimes in Table~\ref{tab:comp}, we note that CoverBLIP ($\epsilon=0.2$) achieves 2.5-6x fold acceleration compared to the BLIP algorithm which is less than what was reported for our previous synthetic data experiment in Section~\ref{sec:brainwebexpe}. The reason is that here we use multi-coil data and non-Cartesian k-space sampling where both make the gradient updates become a non-trivial computational overhead for the iterations. Note that reconstructions from a non-Cartesian acquisition protocol requires computing slow NUFFT operations in each iteration. As a result, despite a significant reduction in the total search cost (i.e. projection steps) this advantage will be less pronounced in the overall runtime of CoverBLIP. We believe addressing this issue i.e. breaking down the cost of heavy gradient updates, merits an independent line of future investigation beyond the scope of this work. \section{Introduction} \label{sec:intro} Quantitative Magnetic Resonance Imaging (Q-MRI) provides a powerful tool for measuring various intrinsic NMR properties of tissues such as the $T1$, $T2$ and $T2^*$ relaxation times, field inhomogeneity, diffusion and perfusion~\cite{toftsmri}. As opposed to mainstream qualitative assessments these \emph{absolute} physical quantities can be used for tissue or pathology identification independent of the scanner or scanning sequences. Despite being the long-standing goal of the MRI community, current quantitative approaches are extremely time-inefficient and for this reason not clinically applicable. Standard Q-MRI approaches (e.g.~\cite{standardT1a,standardT1b,standardT2,DESPOT12}) acquire a large sequence of images in different times and use curve-fitting tools for parameter estimation in each voxel. This procedure runs separately to estimate each parameter. The long process of acquiring multiple fully sampled images brings serious limitation to the conventional Q-MRI approaches to apply within a reasonable time and with an acceptable signal-to-noise ratio (SNR) and resolution. Recently Magnetic Resonance Fingerprinting (MRF) has emerged to address this short-coming and significantly accelerate the acquisition time of Q-MRI e.g. within a couple of seconds \cite{MRF}. Three key principles are behind this new paradigm: i) applying \emph{one} excitation sequence (i.e. in one acquisition run) that simultaneously encodes many quantitative parameters of interest, ii) incorporating more complicated (and sometimes random) but shorter excitation patterns than those used in conventional Q-MRI schemes, and finally iii) significant under-sampling of the k-space data at each temporal frame. Since the seminal work of Ma \emph{et al.}~\cite{MRF} for joint quantification of $T1,T2$ relaxation times and the off-resonance frequency $B0$, several follow-up studies have successfully extended the MRF framework to measure multitude of additional quantitative parameters such as $T2^*$, perfusion, diffusion and microvascular properties~\cite{MRFT2star,EPIT1T2star,MRF-perfusion2,MRF-perfusion,MRF-diffusion-combined,MRF-vascular1}. The aggressively short acquisition times used in this framework, on the other hand, introduce several algorithmic challenges at the parameter estimation stage of the \emph{MRF reconstruction problem}. Common approaches adopt a physical model to disambiguate the lack of sufficient spatio-temporal measurements in such a highly ill-posed inverse problem. However, for complicated excitation patterns used in the MRF acquisitions, the (temporal) magnetic responses encoding the quantitative information are no longer following an analytic (e.g. complex exponential) model and they rather require solving Bloch differential equations~\cite{jaynes1955matrix}. The MRF framework proposes to discretize the parameter space and exhaustively simulate a large dictionary of magnetic responses (fingerprints) for all combinations of the quantized NMR parameters. This dictionary is then used for \emph{matched-filtering} in many model-based reconstruction routines (see e.g.~\cite{MRF,FISP,SVDMRF,BLIPsiam,zhao-LR-MRF,asslander-ADMMMRF}). As occurs to any multi-parametric manifold enumeration, the main drawback of such approach is the size of this dictionary which grows exponentially in terms of the number of parameters and their quantization resolution. This brings a serious (scalability) limitation to the current popular schemes to be applicable in the emerging multi-parametric MRF problems, as the computational complexity of exact matched-filtering using brute-force searches grows linearly with the dictionary size. To address this shortcoming we propose an iterative reconstruction method with \emph{inexact} updates dubbed as \emph{Cover BLoch response Iterative Projection} (CoverBLIP). Our algorithm accelerates matched-filtering steps by replacing iterative brute-force searches with fast Approximate Nearest Neighbour Searches (ANNS) based on \emph{cover tree} structures constructed off-line for a given MRF dictionary. For datasets living on smooth manifolds with low intrinsic dimension (e.g. a constant number of NMR characteristics) cover tree approximate searches are shown to have \emph{logarithmic} complexity in terms of data populations~\cite{beygelzimer2006cover}. Under an embedding assumption similar to the restricted isometry property in compressed sensing theory~\cite{DonohoCS, CRT:CS,BW:manifold,modelbasedCS,D-RIP,nam2013cosparse,Blumen,inexactipg-tit}, we show that CoverBLIP iterations are able to correct the inexact updates and achieve a linear global convergence i.e. stable signal recovery. We also introduce an adaptive step-size scheme that guarantees (local) monotone convergence of CoverBLIP in general cases e.g. when the embedding assumption does not hold. The results provided in this part apply beyond the customized MRF problem considered in this paper. We examine the reconstruction time-accuracy of the proposed method on both synthetic and \emph{in-vivo} MRF datasets with different excitation sequences and k-space sampling patterns. Our experimental results indicate superiority of CoverBLIP compared to other tested baselines. Notably, CoverBLIP achieves 2-3 orders of magnitude acceleration in conducting matched-filtering while maintaining a similar accuracy as compared to using exact iterations with brute-force searches. Unlike non-scalable fast search algorithms such as KD-trees, we show that CoverBLIP maintains this superior performance when no dimensionality-reduction preprocessing is used. This feature of robustness against the high-dimensionality of search spaces makes CoverBLIP a well-suited candidate to tackle multi-parametric MRF applications with increased non-linear dynamic complexity, where applying common subspace compression preprocessing becomes prohibitive for their unfavourable compromise in the final estimation accuracy. The rest of this paper is organized as follows: in Section~\ref{sec:related} we briefly review current popular methods for MRF reconstruction. Section~\ref{sec:MRFmodel} formulates the MRF inverse problem and discuss an iterative model-based reconstruction framework for solving this problem. In Section~\ref{sec:coverblippart} we provide an introduction to cover trees and their corresponding approximate fast search algorithm. We highlight a few complexity results useful for this work and finally we present our proposed CoverBLIP algorithm for accelerated MRF reconstruction. Section~\ref{sec:proofs} is dedicated to the proof of convergence and stability of CoverBLIP. In Section~\ref{sec:expe} we present our experimental results comparing the performance of CoverBLIP against other baselines, and finally in Section~\ref{sec:conclusions} we conclude this paper and discuss possible future directions. \section{Related works} \label{sec:related} In this part we review a few algorithmic solutions proposed for solving the MRF problem. In their original paper Ma \emph{et al.}~\cite{MRF} proposed a non-iterative reconstruction scheme which consists of Fourier back-projections for all temporal slices followed by a dictionary matching step where each high-dimensional temporal voxel is compared against the atoms of a MRF dictionary. The NMR parameters corresponding to the fingerprint with highest correlation is reported for that voxel. After Fourier back-projections (of the under-sampled k-space data), one obtains highly corrupted images suffering from aliasing artefacts. The main drawback of the non-iterative Template Matching (TM) approach is to ignore this specific (aliasing) noise structure which as shown in~\cite{BLIPsiam} can lead to poor estimation accuracies for short acquisition sequences. On the other hand researches in the area of \emph{compressed sensing} have demonstrated the efficiency of Iterative Projected Gradient (IPG) schemes for solving model-based inverse problems~\cite{ISTA,FISTA,IHTCS}. Adopted from compressed sensing literature Davies \emph{et al.}~\cite{BLIPsiam} proposed an IPG type algorithm for the MRF problem and show that iterations (which require repeated application of the TM at each iteration for projection) indeed improve parameter estimation in low data/SNR regimes. The large size of the MRF dictionary is however a big challenge for the runtime of matched-filtering step(s) based on brute-force searches in both approaches. This issue has been addressed in two ways. First, it has been proposed to reduce the (temporal) ambient search dimension using a few SVD bases of the MRF dictionary~\cite{SVDMRF}. The main drawback of this approach is that the MRF dictionaries contain highly non-linear structures (a low-dimensional manifold of solutions of the Bloch equations) and therefore applying a linear subspace compression trades-off the computation time against the final accuracy of the reconstructed parameters. For instance, the Steady State Precession (FISP) sequence~\cite{FISP} which encodes two NMR parameters (i.e. $T1$, $T2$ relaxation times) required 20 principal components for representing the corresponding search space to a reasonable accuracy, whereas an Inversion Recovery Balanced SSFP (IR-BSSFP) dictionary encoding an additional parameter (i.e. off-resonance frequency $B0$) cannot be accurately compressed with less than 200 components~\cite{SVDMRF}. One can imagine with the rise in applications encoding a larger number of parameters associated with the non-linear dynamics such as $T2^*$, perfusion, diffusion and microvascular properties, etc~\cite{MRFT2star,EPIT1T2star,MRF-perfusion2,MRF-perfusion,MRF-diffusion-combined,MRF-vascular1} this issue will get worse i.e. an exponential growth in the dictionary size without a good low-dimensional subspace representation. A second approach incorporates hierarchical clustering for implementing fast searches over the dictionary~\cite{MRF-GRM} however it suffers from the limited accuracy of using a single step (non-iterative) matched-filtering. KD-tree searches has been proposed to accelerate matched-filtering steps within an iterative reconstruction scheme~\cite{AIRMRF}. However KD-trees are known to be non-scalable and crucially dependent on a dimensionality-reduction preprocessing step. This preprocessing might be expensive in general cases but more particular to the MRF problem, the use of the SVD subspace compression scheme (as proposed in~\cite{AIRMRF}) introduces an unfavourable compromise between the accuracy and gain in acceleration, as discussed above. Besides, the suggested inexact updates \textemdash based on a small fixed number of arithmetic operations (referred to as KD-tree \emph{checks}), but unbounded search precision, per iteration of IPG \textemdash are heuristic and not known to provide a convergence guarantee (see discussions in e.g.~\cite{inexactipg-tit} for approximation-tolerant iterations). We propose an accelerated model-based reconstruction algorithm, CoverBLIP, with consistent performance in high-dimensional search spaces. Cover tree structures provide an important feature of robustness against the curse-of-dimensionality~\cite{Navigating,beygelzimer2006cover}. For low (intrinsic) dimensional manifold data they have provable sub-linear search complexities and in addition we show that using such approximations within an iterative scheme can still result in monotone convergence (in general) and stable global reconstruction, under an embedding assumption. While we experimentally see that the KD-tree and cover tree searches are comparably efficient in small dimensions, the KD-tree performance scales considerably less effective to larger ambient dimensions compared to the achievable time-accuracy of the cover tree search. Finally, we would like to mention a number of schemes which propose to incorporate additional low rank priors motivated by the high spatio-temporal correlations of the MRF data~\cite{zhao-LR-MRF1,zhao-LR-MRF, Eldar-LRMRF,doneva-LRMRF, asslander-ADMMMRF}. Most of these schemes are however validated on sequences encoding two (or three in~\cite{Eldar-LRMRF}) NMR parameters. As discussed above a linear subspace i.e. low rank model will not scale to multi-parametric MRF problems with increased degree of non-linearities. Moreover schemes based on singular values thresholding~\cite{zhao-LR-MRF1,Eldar-LRMRF,doneva-LRMRF} require intensive data factorization computations at each iteration. Zhao \emph{et al.}~\cite{zhao-LR-MRF} proposed to reconstruct images in the pre-calculated SVD subspace of the MRF dictionary and cascade the results to a TM step for parameter estimation. CoverBLIP with a temporal compression option does the same low rank subspace reconstruction however with the benefit of faster approximate searches whose total (iterative) cost is less than a single iterated brute-force search in TM (see e.g. Figure~\ref{fig:compVSacc}). More recently a deep learning approach has been adopted for the MRF problem (see e.g. \cite{cohen-DRONE, lustig-deepMRF,deepMRF_me}), the crux of which is to approximate the match-filtering step by a compact neural network during reconstruction. The MRF dictionary is only used for training the network and not in reconstruction. In our numerical comparisons we exclude these approaches and focus on purely dictionary-based reconstruction baselines. \section{Main results} \label{sec:main} We interleave text filler with some example theorems and theorem-like items. \lipsum[4] Here we state our main result as \cref{thm:bigthm}; the proof is deferred to \cref{sec:proof}. \begin{theorem}[$LDL^T$ Factorization \cite{GoVa13}]\label{thm:bigthm} If $A \in \mathbb{R}^{n \times n}$ is symmetric and the principal submatrix $A(1:k,1:k)$ is nonsingular for $k=1:n-1$, then there exists a unit lower triangular matrix $L$ and a diagonal matrix \begin{displaymath} D = \diag(d_1,\dots,d_n) \end{displaymath} such that $A=LDL^T$. The factorization is unique. \end{theorem} \lipsum[6] \begin{theorem}[Mean Value Theorem]\label{thm:mvt} Suppose $f$ is a function that is continuous on the closed interval $[a,b]$. and differentiable on the open interval $(a,b)$. Then there exists a number $c$ such that $a < c < b$ and \begin{displaymath} f'(c) = \frac{f(b)-f(a)}{b-a}. \end{displaymath} In other words, \begin{displaymath} f(b)-f(a) = f'(c)(b-a). \end{displaymath} \end{theorem} Observe that \cref{thm:bigthm,thm:mvt,cor:a} correctly mix references to multiple labels. \begin{corollary}\label{cor:a} Let $f(x)$ be continuous and differentiable everywhere. If $f(x)$ has at least two roots, then $f'(x)$ must have at least one root. \end{corollary} \begin{proof} Let $a$ and $b$ be two distinct roots of $f$. By \cref{thm:mvt}, there exists a number $c$ such that \begin{displaymath} f'(c) = \frac{f(b)-f(a)}{b-a} = \frac{0-0}{b-a} = 0. \end{displaymath} \end{proof} Note that it may require two \LaTeX\ compilations for the proof marks to show. Display matrices can be rendered using environments from \texttt{amsmath}: \begin{equation}\label{eq:matrices} S=\begin{bmatrix}1&0\\0&0\end{bmatrix} \quad\text{and}\quad C=\begin{pmatrix}1&1&0\\1&1&0\\0&0&0\end{pmatrix}. \end{equation} Equation \cref{eq:matrices} shows some example matrices. We calculate the Fr\'{e}chet derivative of $F$ as follows: \begin{subequations} \begin{align} F'(U,V)(H,K) &= \langle R(U,V),H\Sigma V^{T} + U\Sigma K^{T} - P(H\Sigma V^{T} + U\Sigma K^{T})\rangle \label{eq:aa} \\ &= \langle R(U,V),H\Sigma V^{T} + U\Sigma K^{T}\rangle \nonumber \\ &= \langle R(U,V)V\Sigma^{T},H\rangle + \langle \Sigma^{T}U^{T}R(U,V),K^{T}\rangle. \label{eq:bb} \end{align} \end{subequations} \Cref{eq:aa} is the first line, and \cref{eq:bb} is the last line. \section{Algorithm} \label{sec:alg} \lipsum[40] Our analysis leads to the algorithm in \cref{alg:buildtree}. \begin{algorithm} \caption{Build tree} \label{alg:buildtree} \begin{algorithmic} \STATE{Define $P:=T:=\{ \{1\},\ldots,\{d\}$\}} \WHILE{$\#P > 1$} \STATE{Choose $C^\prime\in\mathcal{C}_p(P)$ with $C^\prime := \operatorname{argmin}_{C\in\mathcal{C}_p(P)} \varrho(C)$} \STATE{Find an optimal partition tree $T_{C^\prime}$ } \STATE{Update $P := (P{\setminus} C^\prime) \cup \{ \bigcup_{t\in C^\prime} t \}$} \STATE{Update $T := T \cup \{ \bigcup_{t\in\tau} t : \tau\in T_{C^\prime}{\setminus} \mathcal{L}(T_{C^\prime})\}$} \ENDWHILE \RETURN $T$ \end{algorithmic} \end{algorithm} \lipsum[41] \section{MRF imaging model} \label{sec:MRFmodel} MRF acquisitions follow a linear spatio-temporal model: \eql{\label{eq:forward} Y=P_\Omega F S (X)+\xi, } where $Y\in \CC^{cm\times L}$ is the k-space measurements collected by $c$ coils at $t= 1,\hdots,L$ temporal frames and corrupted by some noise $\xi$. The MRF image (to be recovered) is represented by a complex-valued matrix $X$ of spatio-temporal resolution $n\times L$ i.e. $n$ spatial voxels and $L$ temporal frames\footnote{The real and imaginary parts of $X$ store net magnetizations across two transverse axes perpendicular to the static magnetic field.}. The multi-coil sensitivity operator $S:\CC^{n \times L}\rightarrow \CC^{cn \times L} $ maps each temporal frame of $X$ to $c$ weighted copies according to the sensitivity maps of $c$ head-coils used in a scanner. The sensitivity maps are identical for all temporal frames and are calculated off-line either through a separate calibration process or directly from the MRF measurements~\cite{cmap-adaptive}. Throughout whenever we consider a single coil setup $c=1$, we assume $S$ to be an identity operator (i.e. $S(X)=X$) and thus the true sensitivities are absorbed by $X$. Moreover, $F$ corresponds to a Fourier operator that maps spatial images (at each temporal frame and for each coil) to the corresponding k-space measurements. This operator might correspond to the FFT transform if a Cartesian grid is used for k-space sampling e.g. in~\cite{multishotEPI,EPIT1T2star}, or it might correspond to a Non-Uniform Fourier (NUFFT) transform~\cite{NUFFT} for non-Cartesian sampling patterns such as the variable density spirals used in~\cite{MRF, FISP}. Finally, $P_\Omega: \CC^{cn\times L}\rightarrow \CC^{cm\times L}$ is the sub-sampling operator with respect to a set of \emph{temporally-varying} patterns $\Omega=\bigcup_{t=1}^L\Omega_t$, where $\Omega_t$ stores $m<n$ k-space locations to be sampled at the time frame $t$. This pattern is identical for all coils at that given time frame The linear system~\eqref{eq:forward} is under-determined due to lack of sufficient measurements (i.e. $m<n$) which means without further assumptions it admits infinitely many solutions and therefore, in order to hope for a stable MRF reconstruction one needs to incorporate efficient and restrictive priors for this type of images. \subsection{Bloch dynamic model} The main source of measurements in Q-MRI are the per-voxel net magnetization of proton dipoles obtained from dynamic rotations of the external magnetic field induced by a radio frequency (RF) coil. These excitations are in the form of a sequence of Flip Angles (FA) $\{\alpha_t\}_{t=1}^L$ applied at certain time intervals known as the \emph{repetition times} (TR) which could be a constant or varying across different time-frames $t=1,\hdots,L$. \emph{Tissues with different NMR characteristics respond distinctively to these excitations}. A qualitative MRI approach studies the contrasts between different tissues in a single time frame which is often-times dependent on the sequence type and the scanner. A Q-MRI approach rather fits a physical model to all spatio-temporal measurements and obtains the \emph{absolute} NMR characteristics of the underlying tissues, however, at the cost of significantly longer acquisition times. Standard Q-MRI approaches such as DESPOT run \emph{separate} sequences to measure one parameter at a time~\cite{standardT1a,standardT1b,standardT2,DESPOT12}. They use parameter-specific sequences that usually result in analytical time-trajectories such as $1-2\exp{\left(-\frac{t TR}{T1}\right)}$ or $\exp{\left(-\frac{ tTR}{T2}\right)}$ to be fitted and recover the underlying parameter (here $T1$ or $T2$) per voxel. The long process of acquiring separately multiple fully sampled images brings serious limitations to standard Q-MRI approaches to apply within a reasonable time and with an acceptable SNR and resolution. The MRF framework relies on a similar principle, however, it adopts more complicated and sometimes random excitation patterns that are able to simultaneously encode different NMR parameters and produce more distinctive dynamic signatures in shorter acquisition times. The resulting temporal trajectories no longer follow simple analytic e.g. exponential forms and they require methods for approximating the solutions of the \emph{Bloch differential equations} which capture the overall macroscopic dynamics of per-voxel magnetizations~\cite{jaynes1955matrix}. We denote by \eq{\Bb(\Theta; TR,TE,\alpha)\in \CC^L} the discrete-time Bloch response of a molecular structure with a set of intrinsic NMR parameters $\Theta$ to a specific excitation sequence of length $L$ with a given FA pattern $\alpha$, repetition TR and read-out TE times. The real and imaginary parts of $\Bb$ correspond to the amount of magnetizations across two transverse-plane components perpendicular to the external static magnetic field. For instance the IR-BSSFP sequence originally proposed for the MRF framework produces distinct magnetic responses for three parameters $\Theta=\{T1,T2,B0\}$ i.e. two relaxation times $T1$, $T2$ and the off-resonance frequency $B_0$. Recent emerging MRF applications are designing sequences encoding a larger number of NMR characteristics such as $T2^*$, diffusion, perfusion and vascular properties (see e.g.~\cite{MRFT2star,EPIT1T2star,MRF-perfusion2,MRF-perfusion,MRF-diffusion-combined,MRF-vascular1}). Current MRF approaches discretize through a dense sampling the parameter space $\overline \Theta := [T1]\times [T2]\times [B0]\times\hdots,$ simulate off-line the Bloch equations for all parameter combinations and generate a large dictionary of fingerprints $D=\{D_j\}_{j=1}^d$ where, \eql{\label{eq:fingerprints} D_j := \Bb(\overline \Theta_j; TR,TE,\alpha)\quad \forall j=1,\hdots,d,} and $d=\Card(\overline \Theta)$ is the total number of generated fingerprints (atoms). Under the \emph{voxel purity} assumption each spatial voxel of the MRF image corresponds to a specific tissue with a unique NMR parameter and would approximately match to a temporal trajectory in the fingerprint dictionary.\footnote{A number of works also consider mixture models for the MRF problem (see e.g. the supplementary part of~\cite{MRF} and a recent work~\cite{mixedMRF}), however we keep the main focus of this paper to cases where the voxel purity assumption hold.} By incorporating a notion of signal intensity in this model the rows of the MRF image belong to a \emph{cone} associated with the fingerprints \eqref{eq:fingerprints}. Denoting by $X_v$ the $v$-th row of X i.e., a multi-dimensional spatial voxel, we have \eql{\label{eq:model} X_v \in \text{cone}(D)\quad \forall v=1,\hdots, n,} where the discrete cone of fingerprints is defined as follows: \eql{\label{eq:conedef} \text{cone}(D) := \{x \in \CC^L:\, x/\gamma \in D \quad \text{for some}\, \gamma>0\}. } Here $\gamma$ corresponds to the proton density which is generally non-uniformly distributed across spatial voxels. \subsection{Model-based MRF reconstruction} An important source of acceleration in the MRF acquisition process comes from the significant amount of k-space under-sampling. As a result one has to deal with solving a highly ill-posed problem to disambiguate the lack of sufficient measurements. The discrete Bloch model in~\eqref{eq:model} plays a critical role in regularizing the inverse problem~\eqref{eq:forward} and enabling stable MRF image reconstruction and parameter estimation. Following the model-based compressed sensing approaches such as~\cite{modelbasedCS,BW:manifold,MIP,inexactipg-tit}, the reconstruction problem can be cast as minimizing the measurement discrepancy \textemdash though the forward model~\eqref{eq:forward}\textemdash constrained by the per-voxel Bloch cone model: \eql{ \label{eq:CS} \argmin_X \sum_{t=1}^L \norm{Y_t-P_{\Omega_t} FS(X_t)}_2^2 \quad s.t. \quad X_v\in \text{cone}(D) \quad \forall v=1,\hdots,n.\footnote{With a slight abuse of notation by $X_t\in \CC^n$ we refer to the MRF image at its $t$-th temporal frame i.e. the $t$-th column of $X$, whereas by $X_v$ we refer to the $v$-th row of $X$ which is an $L$-dimensional spatial voxel. Also $Y_t\in\CC^{cm}$ refers the k-space measurements collected at $t$-th repetition time.} } The recovered image sequence (solution) at each spatial voxel corresponds to a fingerprint representing uniquely the underlying NMR characterizations. As appeared in compressed sensing literature~\cite{vidal-subspacecluster,meLRJS,meLRTV,intersecting-bach,TIPHSI,vidal-structruedLR}, it might be natural to think of incorporating additional priors to promote certain spatial regularities and/or low-rank structures (i.e. accounting for the correlations between neighbouring voxels or image patches) in order to improve reconstruction, see e.g.~\cite{BLIPsiam,zhao-LR-MRF1,AIRMRF} in the MRF context. However care must be taken here, since solving a multi-constrained problem combined with the non-convex fingerprints cone~\eqref{eq:model} is often intractable and therefore despite possible empirical improvements \textemdash perhaps under good initializations\textemdash the results are likely to lack global convergence guarantees. In this paper we focus on problem~\eqref{eq:CS} constrained by the cone of fingerprints. A popular approach for solving compressed sensing problems is the Iterative Projected Gradient (IPG) algorithm~\cite{ISTA,FISTA,IHTCS}. IPG is a first-order algorithm suitable for big data applications and importantly it can also apply to globally solve problems with certain non-convex constraints~\cite{IHTCS,modelbasedCS,MIP}. Davies \emph{et al.}~\cite{BLIPsiam} adopted this routine for the MRF reconstruction problem and named it Bloch Response Iterative Projection (BLIP). The BLIP algorithm iterates between a gradient descent update and a (voxel-wise) model projection step: \eql{\label{eq:blip} X^{k+1} = \Pp_\Cc \left(X^k - \mu_k \Aa^H\left(\Aa(X^k)-Y \right)\right), } where $\Aa(.) :=P_{\Omega} FS(.)$ is the shorthand we use for the forward operator, $\Aa^H := S^H F^H P^H_\Omega (.)$ is the adjoint operator, $\{\mu_k\}$ is the sequence of step-sizes and $\Pp_\Cc(.)$ is the Euclidean projection operator onto the set $\Cc$ i.e. \eql{ \Pp_{\Cc}(x)\in \argmin_{x\in \Cc} \norm{x-u}_2. } Note that throughout we use the shorthand $\norm{.}$ to refer to the Euclidean norm i.e. the $\ell_2$ norm of a vector or the Frobenius norm a matrix. For the MRF problem and the constraint set $\Cc$ defined by \eqref{eq:model} this projection is also called \emph{matched-filtering}. After the gradient update $Z^k := X^k - \mu_k \Aa^H\left(\Aa(X^k)-Y \right)$, the matched-filtering step $X^{k+1}=\Pp_\Cc(Z^k)$ decouples into separate cone projections for each spatial voxel $v=1,\hdots n$ and is computed as follows: \begin{align}\label{eq:exactP} &j^* = \argmin_j \norm{Z_v -D_j/\norm{D_j}} &\text{(nearest neighbour search)}\\ &X^{k+1}_v = \Pp_{\text{cone}(D)}(Z_v) = \gamma_v D_{j^*}& \text{(rescaling)} \label{eq:exactPs} \end{align} where, $\gamma_v = \max\left( \text{real}(\langle Z_v ,D_{j^*}\rangle)/ {\norm{D_{j^*}}^2},0\right)$ is the per-voxel proton density. The non-iterative TM approach originally proposed in~\cite{MRF} corresponds to the first iteration of BLIP with zero initialization\footnote{Throughout we assume zero initialization $X^{k=0}=\textbf{0}$ for all iterative methods unless otherwise is specified.}. However the iterative approach has shown to be more robust against shorter excitation sequences and acquisition times, where the atoms of the fingerprint dictionary become more coherent and difficult to be distinguished~\cite{BLIPsiam}. \subsection{Dimension-reduced subspace matched-filtering \label{seq:mrfdimchallenge} The BLIP algorithm breaks down the computations involved in solving the MRF problem~\eqref{eq:CS} into two local updates namely, the gradient and projection steps for which an exact matched-filtering step e.g. by using brute-force nearest neighbour searches, has the complexity $O(nLd)$ in computation time. Discretization of the multi-parameter space often results in very large size MRF dictionaries where the number of fingerprints $d$ has an exponential relationship with the number of NMR characteristics and their quantization resolutions. Therefore, search strategies with linear complexity in $d$ are a serious bottleneck to the exact matched-filtering steps at the heart of model-based approaches for solving~\eqref{eq:CS}. Current proposed solutions for the high dimensionality of the MRF problem rely on a (low rank) subspace compression step to reduce the matching computations~\cite{SVDMRF,AIRMRF,asslander-ADMMMRF}. Let $V\in \CC^{L\times L}$ be the eigen-basis spanning the space of the fingerprint dictionary through the singular value decomposition (SVD) i.e. $\sum_{j=1}^d D_j(D_j)^H =V \Sigma V^H$, and $V_s\in \CC^{L\times s}$ denotes the matrix of $s$-dominant eigenvectors. By assuming high (linear) correlations between fingerprints, there exists a reasonably small number $s\ll L$ for which one would have $D_j \approx V_s \widetilde D_j$ for all $j=1,\hdots d$, where $\widetilde D_j:= V_s^H D_j\in \CC^s$ and $\widetilde D := \{\widetilde D_j\}_{j=1}^d$ are the low-dimensional proxies for the original fingerprint dictionary. With this assumption one can solve the following problem instead of~\eqref{eq:CS} in lower dimensions: \eql{ \label{eq:CS1} \argmin_{\widetilde X\in \CC^{n\times s}} \sum_{t=1}^L \norm{Y_t-P_{\Omega_t}FS\big((\widetilde X V^H)_t\big) }_2^2 \quad s.t. \quad \tilde X_v\in \text{cone}(\widetilde D) \quad \forall v=1,\hdots,n. } Note that if $D$ is low-rank and fully spanned by $V_s$ then $D=V_s\widetilde D$, $\text{cone}(D)=V_s\text{cone}(\widetilde D)$ and by a change of variable we have $X=\widetilde X V^H$, and therefore both problems~\eqref{eq:CS} and~\eqref{eq:CS1} become equivalent. Following the IPG routine for solving this problem, the gradient updates read \eql{\label{eq:gradupdate} \widetilde Z^k= \widetilde X^k - \mu_k \Aa^H\left(\Aa(\widetilde X^kV^H)- Y \right)V, } where the matched-filtering $\widetilde X_v^{k+1} = \Pp_{\text{cone}(\widetilde D)}(\widetilde Z^k_v)$ and the corresponding searches are performed in the compressed temporal domain, directly reducing the complexity of pairwise distance calculations. Such a compression scheme can also reduce the gradient step computations. One can write \begin{align} \widetilde Z^k &:= \widetilde X^k - \mu_k \Aa^H\left(\Aa(\widetilde X^kV^H)V\right) +\mu_k \Aa^H(Y) V \nonumber\\ &= \widetilde X^k - \mu_k S^HF^H\Big(P^H _\Omega P_\Omega \big(FS(\widetilde X^k)V^H \big)V\Big)+\mu_k \Aa^H(Y) V. \label{eq:gradcompression} \end{align} The last line follows from expanding $\Aa$ and it holds since both the multi-slice Fourier transform $F$ and the coil sensitivity operator $S$ act identically across all time-frames and thus they commute with the temporal compression operators $V, V^H$. As a result, the main computations for conducting the gradient updates \eqref{eq:gradcompression} i.e., the middle term, comes from the forward-backward Fourier operations across a smaller number $s< L$ of (compressed) temporal frames plus the cost of applying compression-decompression operations $V,V^H$. Depending on how well a low rank model can approximate the dictionary i.e. how small would $s$ be, the overall gradient computations can drop by using such subspace compression, particularly when $F$ corresponds to expensive NUFFT transforms in non-Cartesian acquisition schemes. We empirically observe that $V,V^H$ operations would not bring a major overhead in total computations. The idea of using subspace compressions has been applied to accelerate the brute-force searches in the single-stage TM method where the complexity of searches in compressed domain decreases to $O(nsd)$~\cite{SVDMRF}. It has been also proposed to use subspace compressions within an iterative algorithm to boost the performance of fast but non-scalable searches based on KD-trees~\cite{AIRMRF}. The applicability of this approach is totally reliant on such a compression pre-processing since it is well understood that KD-trees are inefficient in high-dimensional (ambient) search spaces. Beside these advantages, we would like to remind the reader about our discussion in sections~\ref{sec:related} (see also our numerical experiments in Section~\ref{sec:expe}), that methodologies purely relying on subspace dimensionality-reduction are prone to an unfavourable compromise in their estimation accuracies when applied to multi-parametric MRF dictionaries with increased non-linear complexities and growth in data population. \section{Application in Quantitative MRI} In \emph{quantitative MRI} rather than simply forming a single MR image with only contrast information (i.e. qualitative MRI), physicists are interested in measuring the NMR properties of tissues namely, the $T1,T2$ relaxation times, $\delta f$ magnetic resonance and proton density (PD), and use these parameters to differentiate different biological tissues~\cite{toftsqmri}. The standard approach for parameter estimation is to acquire a large sequence of images in different times from a simple excitation pulse (i.e. excitations in terms of rotating the magnetic field) and then use an exponential model curve fitting to recover the decay exponents $T1,T2$ for each voxel. This procedure runs separately to estimate each relaxation time. The long process of acquiring multiple fully sampled images, brings serious limitation to standard approaches in quantitative imaging to apply within a reasonable time and with an acceptable signal-to-noise ratio (SNR) and resolution. \subsection{Magnetic Resonance Fingerprinting} Recently, a novel parameter estimation process coined as the \emph{Magnetic Resonance Fingerprinting} (MRF) has been proposed to address this shortcoming. For the acquisition, MRF applies a shorter sequence of random excitations (i.e. $\Gamma \in [0,\pi/2]^{\n}$ random flip angels with typically $\n\approx 300-1000$ and the time interval $TR\sim 10-40$ msec) for estimating all parameters $T1,T2,\delta f$, and proton density at once. After each excitation pulse the response is recorded through the measurements taken from a small portion of k-space. As a result the acquisition time can significantly decreases to a couple of minutes \cite{MRF}. The exponential model as for the traditional acquisition sequences will no longer hold for the MRF model. Due to using random excitations, the signatures casts a non-trivial implicit expression readable by solving the \emph{Bloch dynamic equations} $\Bb(\Gamma,\Theta)\in \CC^\n $ customized for the set of parameters $\Theta=\{T1,T2,\delta f\}$. The MRF problem is an example of data driven CS model with an algebraic signal model (i.e. the Bloch equations) but a non-trivial projection. For this problem one constructs off-line a dictionary of \emph{fingerprints} (i.e. magnetization responses) for all possible $d=\#\{\Theta_i\}_i$ parameters presented in normal tissues where the atoms $\psi_i:=\Bb(\Gamma,\Theta_i)$ uniquely represent the underlying set of parameters $\Theta_i$ . This corresponds to sampling a low-dimensional manifold associated with the solutions of the Bloch dynamic equations~\cite{BLIPsiam}, which for complicated excitation patterns neither the response nor the projection has an analytic solution. \subsection{MRF image model and parameter estimation} An MRF image can be represented by a matrix $X\in \CC^{ \n\times J}$. Each column $X_j$ represents a $\n$-dimensional spatial pixel $j$ and each row $X^l$ represents a temporal image slice (with the spatial resolution equal to $J$) corresponding to the measurements taken after the excitation pulse $\Gamma_l$, $\forall l=1,\ldots,\n$. The total spatio-temporal resolution of the MRF image is $n:=\n J$. By the pixel purity assumption, the image follows the product space data driven model \eqref{eq:dmodel} and \eqref{eq:immodel} where each column/pixel $j$ correspond to a single fingerprint $\psi$ with a unique parameter $\Theta$. The cone($\widetilde \Cc$) corresponds to the fingerprints dictionary and $\rho>0$ represents the proton density.\footnote{The proton density can be generally a complex number for which only the rescaling step of the cone projection slightly changes and the rest of the analysis similarly holds, for more details see~\cite{BLIPsiam}. } The MRF acquisition model is linear as follows: \eql{\label{eq:CSMRF} Y^l \approx \Ff_{\Omega_l} (X^l), \quad \forall l=1,\ldots \n, } where $\Ff$ denotes the two-dimensional Fourier transform, and $\Ff_{\Omega_l}: \CC^J \rightarrow \CC^{m/\n}$ subsamples the k-space coefficients of the image slice $X^l$ according a pattern/set $\Omega_l$. The k-space subsampling could correspond to a spiral pattern~\cite{MRF} or a random horizontal/vertical line subselection~\cite{BLIPsiam} e.g. in the Echo Planar Imaging (EPI). By vectorization of $X,Y$, we have a product space CS model similar to~\eqref{eq:CSsampling} for a sampling protocol $A$ acting spatially however with different k-space sampling pattern per image slice. The CS reconstruction proposed by~\cite{BLIPsiam} is based on a data driven IPG algorithm (with the \emph{exact} cone projection described in Section~\ref{sec:datadrivenCS}) where one by identifying the correct fingerprint per pixel $X_j$ can recover the underlying parameters $\Theta$ stored in a look-up table (the last rescaling step also recovers the proton density $\gamma_j$). It has been shown in~\cite[Theorem 1]{BLIPsiam} that if $\Omega_l$ independently at random subselects the rows (or columns) of the k-space, which corresponds to a \emph{random EPI sampling protocol}, the resulting forward map $A$ is bi-Lipschitz w.r.t. the product model $\Cc=\prod_{j=1}^J \text{cone}(\widetilde \Cc)$, provided sufficient \emph{discriminations} between the fingerprints.\footnote{One achieves a suitable discrimination between the MR fingerprints by e.g. choosing the random excitation sequence long enough.} This result guarantees stability of the parameter estimation using this algorithm with an step size $\mu=n/m$. Since the Bloch manifold is parametrized by only three parameters in $\Theta$ and thus has a low intrinsic dimension, we use the cover tree ANN searches to accelerate the projection step. We perform the following procedure iteratively until convergence: \begin{align*}\label{eq:BLIP} (X^l)^{k+1} = \Pp^{\epsilon}_{\text{cone}(\widetilde \Cc)} \left( (X^l)^{k} - \mu \Ff^H_{\Omega_l}\left(\Ff_{\Omega_i} ((X^l)^{k}) -Y^l\right) \right) \end{align*} The approximate cone projection follows the update in~\eqref{eq:ANN1}. Provided with the same embedding result (for the random EPI acquisition protocol) and according to Theorem~\ref{th:inexactLS2} we can deduce the linear convergence of this algorithm to the true solution for mildly-chosen approximations $\epsilon$ (and the same step size $\mu=n/m$) where the projection step has now the complexity $O(J\log(d))$. For large-sized dictionaries the gap between the computation costs of the exact and inexact IPG algorithm can be significantly large. \section{Proof of the convergence results in Section~\ref{sec:proofs}} \label{sec:proofs_supp} In this part and in Section~\ref{sec:proof0} we provide the proof of Proposition~\ref{prop:stepbound} on the feasibility of using the adaptive shrinkage scheme to find a good step-size in a finite number of sub-iterations. Section~~\ref{seq:proof1} includes the proof of Theorem~\ref{th:inexactLS2} which establishes a near global convergence result i.e. a reconstruction guarantee, for the inexact IPG algorithm by using the adaptive step-size shrinkage scheme. In Section~\ref{sec:proof2} we provide the proof of Theorem~\ref{th:inexactmonotone} which guarantees monotone convergence of the inexact IPG in the absence of any embedding assumption. \subsection{Proof of Proposition~\ref{prop:stepbound}} \label{sec:proof0} Following the approximate projection definition~\eqref{eq:eproj}, each iteration of the inexact IPG algorithm~\eqref{eq:inIP2} produces $X^{k+1},X^{k}\in \Cc$. Therefore, according to the bi-Lipschitz property (Definition~\ref{def:bilip}) we have the following bounds on the values used in the step-size criteria~\eqref{eq:steprule} $\forall k$: \eq{\beta^{-1}\leq \frac{\norm{X^{k+1}-X^k}^2}{\norm{ \Aa(X^{k+1}-X^k) }^2 }\leq \alpha^{-1}. } As a result starting from any finite large step-size $\mu$ and after a finite number of divisions by a factor $\zeta>1$, $\mu_k$ reaches the lower bound and satisfies criteria~\eqref{eq:steprule}. The smallest possible step-size before stopping the shrinkage thus ranges in the interval $\left( (\zeta\beta)^{-1},\beta^{-1} \right]$ which implies the lower bound in~\eqref{eq:stepbound}. The largest possible $\mu_k$ is upper bounded by~\eqref{eq:steprule} which is always less than $\alpha^{-1}$. \subsection{Proof of Theorem~\ref{th:inexactLS2}} \label{seq:proof1} We start from a similar argument as for the proof of~\cite[Theorem~2]{inexactipg-tit} however we do not assume $\mu_k\leq 1/\beta$ as there or in Theorem~\ref{th:inexactLS1} of this paper. By setting $g :=2\Aa^H(\Aa(X^{k})-Y)$ it follows that \begin{align*} \norm{Y-\Aa(X^{k+1})}^2-\norm{Y-\Aa(X^{k})}^2 &= \langle X^{k+1}-X^{k},g \rangle +\norm{\Aa(X^{k+1}-X^{k})}^2 \\ &\leq \langle X^{k+1}-X^{k},g \rangle + \frac{1}{\mu_k} \norm{X^{k+1}-X^{k}}^2\\ & = \frac{1}{\mu_k} \norm{X^{k+1}-X^{k}+\frac{\mu_k}{2} g }^2 - \frac{\mu_k}{4} \norm{g}^2, \end{align*} where the inequality follows from the step size rule~\eqref{eq:steprule}. Due to the update rule of algorithm~\eqref{eq:inIP2} with the inexact projection defined in \eqref{eq:eproj}, we have \begin{align*} \norm{X^{k+1}-X^{k}+\frac{\mu_k}{2} g }^2 &= \norm{\Pp^{\epsilon}_{\Cc}(X^{k}-\frac{\mu_k}{2} g)-X^{k}+\frac{\mu_k}{2} g }^2 \\ &\leq (1+\epsilon)^2\norm{\Pp_{\Cc}(X^{k}-\frac{\mu_k}{2} g)-X^{k}+\frac{\mu_k}{2} g }^2 \\ &\leq \norm{X_0-X^{k}+\frac{\mu}{2} g }^2 +\phi(\epsilon)^2 \frac{\mu_k^2}{4}\norm{g}^2 \end{align*} where $\phi(\epsilon):=\sqrt{2\epsilon+\epsilon^2}$. For the last inequality we replace $\Pp_{\Cc}(X^{k}-\frac{\mu}{2} g)$ with two feasible points $X_0,X^{k}\in \Cc$. Therefore we can write \begin{align} \norm{Y-\Aa(X^{k+1})}^2-\norm{Y-\Aa(X^{k})}^2 \nonumber &\leq \frac{1}{\mu_k} \norm{X_0-X^{k}+\frac{\mu_k}{2} g }^2 - \frac{\mu_k}{4} \norm{g}^2 + {\phi(\epsilon)^2}\frac{\mu_k}{4}\norm{g}^2 \nonumber \\ &= \langle X_0-X^{k},g \rangle + \frac{1}{\mu_k} \norm{X_0-X^{k}}^2 +{\phi(\epsilon)^2}\frac{\mu_k}{4}\norm{g}^2. \label{eq:p1b2} \end{align} According to the bi-Lipschitz property (Definition~\ref{def:bilip}) we have the following bound: \begin{align*} \langle X_0-X^{k},g \rangle &= w^2-\norm{Y-\Aa(X^{k})}^2 -\norm{\Aa(X_0-X^{k})}^2 \\ &\leq w^2 -\norm{Y-\Aa(X^{k})}^2 -\alpha\norm{X_0-X^{k}}^2, \end{align*} where $w=\norm{ Y-\Aa(X_0)}$. Replacing this bound in \eqref{eq:p1b2} yields \begin{align} \norm{Y-\Aa(X^{k+1})}^2 \leq \left(\frac{1}{\mu_k}-\alpha \right)\norm{X^{k}-X_0}^2 + {\phi(\epsilon)^2}\frac{\mu_k}{4}\norm{g}^2 +w^2. \label{eq:p1b3} \end{align} On the other hand the following lower bound holds: \begin{align*} \norm{Y-\Aa(X^{k+1})}^2 &= \norm{\Aa(X^{k+1}-X_0)}^2+w^2-2\langle y-\AaX_0, \Aa(X^{k+1}-X_0)\rangle\\ &\geq \norm{\Aa(X^{k+1}-X_0)}^2+w^2-2w \norm{\Aa(X^{k+1}-X_0)}\\ & \geq \alpha\norm{X^{k+1}-X_0}^2+w^2-2w \sqrt{\beta}\norm{X^{k+1}-X_0}\\ &= \left(\sqrt{\alpha}\norm{X^{k+1}-X_0}- \sqrt{\frac{\beta}{\alpha}}w\right)^2 -(\frac{\beta}{\alpha}-1)w^2. \end{align*} The first and second inequalities use Cauchy-Schwartz and the bi-Lipschitz property, respectively. Using this bound in~\eqref{eq:p1b3} yields \begin{align*} \left(\sqrt{\alpha}\norm{X^{k+1}-X_0}- \sqrt{\frac{\beta}{\alpha}}w\right)^2 &\leq \left(\frac{1}{\mu_k}-\alpha \right)\norm{X^{k}-X_0}^2 + \phi(\epsilon)^2 \frac{\mu_k}{4}\norm{g}^2+\frac{\beta}{\alpha}w^2 \\ &\leq \left(\sqrt{\frac{1}{\mu_k}-\alpha} \norm{X^{k}-X_0} + \phi(\epsilon) \frac{\sqrt{\mu_k}}{2}\norm{g} +\sqrt{\frac{\beta}{\alpha}}w \right)^2. \end{align*} The last inequality assumes $\forall k, \mu_k\leq \alpha^{-1}$ which holds due to the upper bound~\eqref{eq:stepbound} on chosen step size in Proposition~\ref{prop:stepbound}. On the other hand by triangle inequality we have \begin{align*} \norm{g}&\leq 2\norm{\Aa^H(\Aa(X^{k}-X_0))}+2\norm{\Aa^H(Y-\Aa(X_0))}\\ &\leq 2\sqrt{ 1/\mu_k}\vertiii{\Aa}\norm{(X^{k}-X_0)}+2\vertiii{\Aa}w, \end{align*} where the last inequality follows from the step size criteria~\eqref{eq:steprule}. As a result we deduce that \begin{align*} \norm{X^{k+1}-X_0}&\leq \left(\sqrt{\frac{1}{\mu_k\alpha}-1}+ \phi(\epsilon)\frac{\vertiii{\Aa}}{\sqrt{\alpha}}\right) \norm{X^{k}-X_0} + \left( 2\frac{\sqrt{\beta}}{\alpha}+ \phi(\epsilon)\sqrt{\frac{\mu_k}{\alpha}} \vertiii{A} \right)w\\ &\leq \left(\sqrt{\frac{\zeta\beta}{\alpha}-1}+ \phi(\epsilon)\frac{\vertiii{\Aa}}{\sqrt{\alpha}}\right) \norm{X^{k}-X_0} + \left( 2\frac{\sqrt{\beta}}{\alpha}+ \phi(\epsilon)\frac{\vertiii{A}}{\alpha} \right)w\\ &\leq \left(\sqrt{\frac{\zeta\beta}{\alpha}-1}+ \delta\right) \norm{X^{k}-X_0} + \left( 2\frac{\sqrt{\beta}}{\alpha}+ \frac{\delta}{\sqrt{\alpha}} \right)w. \end{align*} The second inequality uses both lower and upper bounds \eqref{eq:stepbound} on the adaptive step size, and the last inequality follows from the theorem's assumption $\phi(\epsilon)\vertiii{\Aa}/\sqrt{\alpha}\leq\delta$. Applying this bound recursively completes the proof: \eq{ \norm{X^{k}-X_0}\leq \rho^k \norm{X_0} + \frac{\kappa_w}{1-\rho}w } for $\kappa_w$ defined in Theorem \ref{th:inexactLS2}. The condition for convergence is $\rho<1$ which implies $\delta<1$ and the following conditioning between the bi-Lipschitz constants $\zeta \beta < \alpha+(1-\delta)^2\alpha$. \subsection{Proof of Theorem~\ref{th:inexactmonotone}} \label{sec:proof2} The proof is simple in the light of viewing the IPG algorithm as a majorization-minimization. Consider the following cost function at iteration $k$: \eql{ \Ll(X) := \mu_k\norm{Y-\Aa(X)}^2 + \norm{X-X^k}^2 - \mu_k\norm{\Aa(X-X^k)}^2. } On one hand due to the step-size criteria~\eqref{eq:steprule} we have $\mu_k\norm{Y-\Aa(X^{k+1})}< \Ll(X^{k+1})$ for any $X^k \neq X^{k+1}$. Also by definition it holds $\Ll(X^k)=\mu_k\norm{Y-\Aa(X^{k})}$. On the other hand note that $\Ll(X) = \mu_k \norm{X-Z^k}^2+\text{const}$ for some constant $\text{const}$, and thus according to~\eqref{eq:nonexpansive} for any non-expansive projection updates $X^{k+1}=\Pp^{\epsilon}_\Cc(Z^k)$ we have $\Ll(X^{k+1})\leq \Ll(X^k)$. Chaining these inequalities yields \eql{ \norm{Y-\Aa(X^{k+1})}<\norm{Y-\Aa(X^{k})} \qquad \forall k, X^k\neq X^{k+1}. } which (together with the fact that the cost function $\norm{Y-\Aa(X)}\geq 0$ is lower bounded) completes the proof.
{'timestamp': '2018-10-05T02:03:23', 'yymm': '1810', 'arxiv_id': '1810.01967', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01967'}
arxiv
\subsection{Cournot competition (Example \ref{ex:game-Cournot})\afterhead} In the standard Cournot oligopoly model described in the main body of the paper, the players' payoff functions are given by \begin{equation} \txs \pay_{\play}(\debug x) = \debug x_{\play} \parens[\big]{a - b\sum_{\playalt} \debug x_{\playalt}} - c_{\play} \debug x_{\play}. \end{equation} Consequently, a simple differentiation yields \begin{equation} H_{\play\playalt}(\debug x) = \frac{1}{2} \frac{\pd^{2} \pay_{\play}}{\pd\debug x_{\play}\pd\debug x_{\playalt}} + \frac{1}{2} \frac{\pd^{2} \pay_{\playalt}}{\pd\debug x_{\playalt}\pd\debug x_{\play}} = -b(1 + \delta_{\play\playalt}), \end{equation} where $\delta_{\play\playalt} = \one\{\play=\playalt\}$ is the Kronecker delta. This matrix is clearly negative-definite, so the game is monotone. \subsection{Resource allocation auctions (Example \ref{ex:game-auction})\afterhead} In our auction-theoretic example, the players' payoff functions are given by \begin{equation} \label{eq:pay-auction} \pay_{\play}(\debug x_{\play};\debug x_{-\play}) = \sum_{\resource\in\resources} \bracks*{ \frac{g_{\play} q_{\resource} \debug x_{\play\resource}}{c_{\resource} + \sum_{\playalt\in\players} \debug x_{\playalt\resource}} - \debug x_{\play\resource}} \end{equation} To prove monotonicity in this example, we will consider the following criterion due to \cite{Goo80}: a game $\game$ satisfies \eqref{eq:DSC} with weights $\lambda_{\play}$, $\play\in\players$, if: \begin{enumerate} [\hspace{2em}\itshape a\upshape)] \item Each payoff function $\pay_{\play}$ is strictly concave in $\debug x_{\play}$ and convex in $\debug x_{-\play}$. \item The function $\sum_{\play\in\players} \lambda_{\play} \pay_{\play}(\debug x)$ is concave in $\debug x$. \end{enumerate} Since the function $\phi(x) = x/(c+x)$ is strictly concave in $x$ for all $c>0$, the first condition above is trivial to verify. For the second, letting $\lambda_{\play} = 1/g_{\play}$ gives \begin{flalign} \sum_{\play\in\players} \lambda_{\play} \pay_{\play}(\debug x) &= \sum_{\play\in\players} \sum_{\resource\in\resources} \frac{q_{\resource} \debug x_{\play\resource}}{c_{\resource} + \sum_{\playalt\in\players} \debug x_{\playalt\resource}} - \sum_{\play\in\players} \sum_{\resource\in\resources} \debug x_{\play\resource} \notag\\ &= \sum_{\resource\in\resources} q_{\resource} \frac{\sum_{\play\in\players} \debug x_{\play\resource}}{c_{\resource} + \sum_{\play\in\players} \debug x_{\play\resource}} - \sum_{\play\in\players} \sum_{\resource\in\resources} \debug x_{\play\resource}. \end{flalign} Since the summands above are all concave in their respective arguments, our claim follows. \subsection{First-order feedback\afterhead} A common assumption in the literature is that players are able to obtain gradient information by querying a \emph{first-order oracle} \citep{Nes04}. \ie a ``black-box'' feedback mechanism that outputs an estimate $\est\payv_{\play}$ of the individual payoff gradient $\payv_{\play}(\debug x)$ of the $\play$-th player at the current action profile $\debug x = (\debug x_{\play};\debug x_{-\play})\in\feas$. This estimate could be either \emph{perfect}, giving $\est\payv_{\play} = \payv_{\play}(\debug x)$ for all $\play\in\players$, or \emph{imperfect}, returning noisy information of the form \( \est\payv_{\play} = \payv_{\play}(\debug x) + \noise_{\play} \) where $\noise_{\play}$ denotes the oracle's error (random, systematic, or otherwise). Having access to a perfect oracle is usually a tall order, either because payoff gradients are difficult to compute directly (especially without global knowledge), because they involve an expectation over a possibly unknown probability law, or for any other number of reasons. It is therefore more common to assume that each player has access to a \emph{stochastic oracle} which, when called against a sequence of actions $\act_{\run}\in\feas$, produces a sequence of gradient estimates $\est\payv_{\run} = (\payv_{\play,\run})_{\play\in\players}$ that satisfies the following statistical assumptions: \begin{equation} \label{eq:oracle} \begin{aligned} &a)\; \textit{Unbiasedness:} & &\exof{\est\payv_{\run} \given \filter_{\run}} = \payv(\act_{\run}). \\ &b)\; \textit{Finite mean square:} & &\exof{\dnorm{\est\payv_{\run}}^{2} \given \filter_{\run}} \leq \debug V^{2} \;\; \text{for some finite $\debug V\geq0$}. \hspace{6em} \end{aligned} \end{equation} In terms of measurability, the expectation in \eqref{eq:oracle} is conditioned on the history $\filter_{\run}$ of $\act_{\run}$ up to stage $\run$; in particular, since $\est\payv_{\run}$ is generated randomly from $\act_{\run}$, it is not $\filter_{\run}$-measurable (and hence not adapted). To make this more transparent, we will write \( \est\payv_{\run} = \payv(\act_{\run}) + \noise_{\run+1} \) where $\noise_{\run}$ is an adapted \acl{MDS} with $\exof{\dnorm{\noise_{\run+1}}^{2} \given \filter_{\run}} \leq \noisevar$ for some finite $\noisedev \geq 0$. \smallskip \subsection{Bandit feedback\afterhead} Now, if players don't have access to a first-order oracle \textendash\ the so-called \emph{bandit} or \emph{payoff-based} framework \textendash\ they will need to derive an individual gradient estimate from the only information at their disposal: the actual payoffs they receive at each stage. When a function can be queried at multiple points (as few as two in practice), there are efficient ways to estimate its gradient via directional sampling techniques as in \cite{ADX10}. In a game-theoretic setting however, multiple-point estimation techniques do not apply because, in general, a player's payoff function depends on the actions of \emph{all} players. Thus, when a player attempts to get a second query of their payoff function, this function may have already changed due to the query of another player \textendash\ \ie instead of sampling $\pay_{\play}(\cdot;\debug x_{-\play})$, the $\play$-th player would be sampling $\pay_{\play}(\cdot;\alt \debug x_{-\play})$ for some $\alt\debug x_{-\play} \neq \debug x_{-\play}$. Following \cite{Spa97} and \cite{FKM05}, we posit instead that players rely on a \acf{SPSA} approach that allows them to estimate their individual payoff gradients $\payv_{\play}$ based off a \emph{single} function evaluation. In detail, the key steps of this one-shot estimation process for each player $\play\in\players$ are: \begin{enumerate} \setcounter{enumi}{-1} \item Fix a \emph{query radius} $\mix>0$.% \footnote{For simplicity, we take $\mix$ equal for all players; the extension to player-specific $\mix$ is straightforward, so we omit it.} \item Pick a \emph{pivot point} $\debug x_{\play}\in\feas_{\play}$ where player $\play$ seeks to estimate their payoff gradient. \item Draw a vector $\unitvec_{\play}$ from the unit sphere $\sphere_{\play}\equiv\sphere^{\vdim_{\play}}$ of $\vecspace_{\play}\equiv\R^{\vdim_{\play}}$ and play $\est \debug x_{\play} = \debug x_{\play} + \mix\unitvec_{\play}$.% \footnote{We tacitly assume here that the query directions $\unitvec_{\play}\in\sphere^{\vdim_{\play}}$ are drawn independently across players.} \item Receive $\est\pay_{\play} = \pay_{\play}(\est \debug x_{\play};\est \debug x_{-\play})$ and set \begin{equation} \label{eq:SPSA} \est\payv_{\play} = \frac{\vdim_{\play}}{\mix} \est\pay_{\play} \, \unitvec_{\play}. \end{equation} \end{enumerate} By adapting a standard argument based on Stokes' theorem (detailed in the supplement), it can be shown that $\est\payv_{\play}$ is an unbiased estimator of the individual gradient of the $\mix$-smoothed payoff function \begin{equation} \label{eq:smoothed} \pay_{\play}^{\mix}(\debug x) = \frac{1}{\vol(\mix\ball_{\play}) \prod_{\playalt\neq\play} \vol(\mix\sphere_{\playalt})} \int_{\mix\ball_{\play}} \int_{\prod_{\playalt\neq\play} \mix\sphere_{\playalt}} \pay_{\play}(\debug x_{\play} + \pert_{\play};\debug x_{-\play} + \unitvec_{-\play})\, \dd\unitvec_{1} \dotsm d\pert_{\play} \dotsm d\unitvec_{\nPlayers} \end{equation} with $\ball_{\play}\equiv\ball^{\vdim_{\play}}$ denoting the unit ball of $\vecspace_{\play}$. The Lipschitz continuity of $\payv_{\play}$ guarantees that $\norm{\del_{\play}\pay_{\play} - \del_{\play}\pay_{\play}^{\mix}}_{\infty} = \bigoh(\mix)$, so this estimate becomes more and more accurate as $\mix\to0^{+}$. On the other hand, the second moment of $\est\payv_{\play}$ grows as \( \bigoh\parens{1/\mix^{2}}, \) implying in turn that the variability of $\est\payv_{\play}$ grows unbounded as $\mix\to0^{+}$. This manifestation of the bias-variance dilemma plays a crucial role in designing no-regret policies with bandit feedback \citep{FKM05,Kle04}, so $\mix$ must be chosen with care. Before dealing with this choice though, it is important to highlight two feasibility issues that arise with the single-shot \ac{SPSA} estimate \eqref{eq:SPSA}. The first has to do with the fact that the perturbation direction $\unitvec_{\play}$ is chosen from the unit sphere $\sphere_{\play}$ so it may fail to be tangent to $\feas_{\play}$, even when $\debug x_{\play}$ is interior. To iron out this wrinkle, it suffices to sample $\unitvec_{\play}$ from the intersection of $\sphere_{\play}$ with the affine hull of $\feas_{\play}$ in $\vecspace_{\play}$; on that account (and without loss of generality), we will simply assume in what follows that each $\feas_{\play}$ is a \emph{convex body} of $\vecspace_{\play}$, \ie it has nonempty topological interior. The second feasibility issue concerns the size of the perturbation step: even if $\unitvec_{\play}$ is a feasible direction of motion, the query point $\est \debug x_{\play} = \debug x_{\play} + \mix\unitvec_{\play}$ may be unfeasible if $\debug x_{\play}$ is too close to the boundary of $\feas_{\play}$. For this reason, we will introduce a ``safety net'' in the spirit of \cite{ADX10}, and we will constrain the set of possible pivot points $\debug x_{\play}$ to lie within a suitably shrunk zone of $\feas$. In detail, let $\ball_{\radius_{\play}}(\base_{\play})$ be an $\radius_{\play}$-ball centered at $\base_{\play}\in\feas_{\play}$ so that $\ball_{\radius_{\play}}(\base_{\play})\subseteq\feas_{\play}$. Then, instead of perturbing $\debug x_{\play}$ by $\unitvec_{\play}$, we consider the \emph{feasibility adjustment} \begin{equation} \label{eq:pert} \pert_{\play} = \unitvec_{\play} - \radius_{\play}^{-1}(\debug x_{\play} - \base_{\play}), \end{equation} and each player plays $\est \debug x_{\play} = \debug x_{\play} + \mix\pert_{\play}$ instead of $\debug x_{\play} + \mix\unitvec_{\play}$. In other words, this adjustment moves each pivot to $\debug x_{\play}^{\mix} = \debug x_{\play} - \radius_{\play}^{-1}\mix (\debug x_{\play} - \base_{\play})$, \ie $\bigoh(\mix)$-closer to the interior base point $\base_{\play}$, and then perturbs $\debug x_{\play}^{\mix}$ by $\mix\unitvec_{\play}$. Feasibility of the query point is then ensured by noting that \begin{equation} \label{eq:query} \est \debug x_{\play} = \debug x_{\play}^{\mix} + \mix\unitvec_{\play} = (1 - \radius_{\play}^{-1}\mix) \debug x_{\play} + \radius_{\play}^{-1}\mix (\base_{\play} + \radius_{\play} \unitvec_{\play}), \end{equation} so $\est \debug x_{\play}\in\feas_{\play}$ if $\mix/\radius_{\play}<1$ (since $\base_{\play} + \radius_{\play}\unitvec_{\play} \in \ball_{\radius_{\play}}(\base_{\play}) \subseteq \feas_{\play}$). The difference between this estimator and the oracle framework we discussed above is twofold. First, each player's \emph{realized} action is $\est \debug x_{\play} = \debug x_{\play} + \mix\pert_{\play}$, not $\debug x_{\play}$, so there is a disparity between the point at which payoffs are queried and the action profile where the oracle is called. Second, the resulting estimator $\hat\payv$ is not unbiased, so the statistical assumptions \eqref{eq:oracle} for a stochastic oracle do not hold. In particular, given the feasibility adjustment \eqref{eq:pert}, the estimate \eqref{eq:SPSA} with $\est \debug x$ given by \eqref{eq:query} satisfies \begin{equation} \label{eq:bias} \exof{\est \payv_{\play}} = \del_{\play} \pay_{\play}^{\mix}(\debug x_{\play}^{\mix};\debug x_{-\play}^{\mix}), \end{equation} so there are \emph{two} sources of systematic error: an $\bigoh(\mix)$ perturbation in the function, and an $\bigoh(\mix)$ perturbation of each player's pivot point from $\debug x_{\play}$ to $\debug x_{\play}^{\mix}$. Hence, to capture both sources of bias and separate them from the random noise, we will write \begin{equation} \label{eq:grad-est} \est\payv_{\play} = \payv_{\play}(\debug x) + \noise_{\play} + \bias_{\play} \end{equation} where $\noise_{\play} = \est\payv_{\play} - \exof{\est\payv_{\play}}$ and $\bias_{\play} = \del_{\play} \pay_{\play}^{\mix}(\debug x^{\mix}) - \del_{\play}\pay_{\play}(\debug x)$. We are thus led to the following manifestation of the bias-variance dilemma: the bias term $\bias$ in \eqref{eq:grad-est} is $\bigoh(\mix)$, but the second moment of the noise term $\noise$ is $\bigoh(1/\mix^{2})$; as such, an increase in accuracy (small bias) would result in a commensurate loss of precision (large noise variance). Balancing these two factors will be a key component of our analysis. \subsection*{Related work\afterhead} In finite games, no-regret learning guarantees that the players' time-averaged, empirical frequency of play converges to the game's set of \acp{CCE}, and the rate of this convergence is $\bigoh(1/\run)$ for $(\lambda,\mu)$-smooth games \citep{SALS15,FLST16}. In general however, this set might contain highly subpar, rationally inadmissible strategies: for instance, \cite{VZ13} provide examples of \ac{CCE} that assign positive selection probability \emph{only} to strictly dominated strategies. In the class of potential games, \cite{CHM17-NIPS} recently showed that the \emph{actual} sequence of play (\ie the sequence of actions that determine the agents' rewards at each stage) converges under no-regret learning, even with bandit feedback. Outside this class however, the players' chosen actions may cycle in perpetuity, even in simple, two-player zero-sum games with full information \citep{MPP18,MLZF+18}; in fact, depending on the parameters of the players' learning process, agents could even exhibit a fully unpredictable, aperiodic and chaotic behavior \citep{PPP17}. As such, without further assumptions in place, no-regret learning in a multi-agent setting does not necessarily imply convergence to a unilaterally stable, equilibrium state. In the broader context of games with continuous action sets (the focal point of this paper), the long-run behavior of no-regret learning is significantly more challenging to analyze. In the case of mixed-strategy learning, \cite{PL14} and \cite{PML17} showed that mixed-stratgy learning based on \acl{SFP} converges to an $\eps$-perturbed \acl{NE} in potential games (but may lead to as much as $\bigoh(\eps\run)$ regret in the process). More relevant for our purposes is the analysis of \cite{Nes09} who showed that the time-averaged sequence of play induced by a no-regret \ac{DA} process with noisy gradient feedback converges to \acl{NE} in monotone games (a class which, in turn, contains all concave potential games). \revise{The closest antecedent to our approach is the recent work of \cite{MZ18} who showed that the \emph{actual} sequence of play generated by \acl{DA} converges to \acl{NE} in the class of variationally stable games (which includes all monotone games). To do so, the authors first showed that a naturally associated continuous-time dynamical system converges, and then used the so-called \acdef{APT} framework of \cite{Ben99} to translate this result to discrete time. Similar \ac{APT} techniques were also used in a very recent preprint by \cite{BBF18} to establish the convergence of a \emph{payoff-based} learning algorithm in two classes of one-dimensional concave games: games with strategic complements, and ordinal potential games with isolated equilibria. The algorithm of \cite{BBF18} can be seen as a special case of \acl{MD} coupled with a two-point gradient estimation process, suggesting several interesting links with our paper.} \subsection*{Our contributions\afterhead} In this paper, we drop all feedback assumptions and we focus on the \emph{bandit} framework where the only information at the players' disposal is the payoffs they receive at each stage. As we discussed above, this lack of information complicates matters considerably because players must now estimate their payoff gradients from their observed rewards. What makes matters even worse is that an agent may introduce a significant bias in the (concurrent) estimation process of another, {so traditional, multiple-point estimation techniques for derivative-free optimization cannot be applied (at least, not without significant communication overhead between players).} To do away with player coordination requirements, we focus on learning processes which could be sensibly deployed in a single-agent setting and we show that, in monotone games, the sequence of play induced by a wide class of no-regret learning policies converges to \acl{NE} with probability $1$. Furthermore, by specializing to the class of strongly monotone games, we show that the rate of convergence is $\bigoh(\run^{-1/3})$, \ie it is nearly optimal with respect to the attainable $\bigoh(\run^{-1/2})$ rate for bandit, \emph{single-agent} stochastic optimization with strongly convex and smooth objectives \citep{ADX10,Sha13}. \revise{We are not aware of a similar \acl{NE} convergence result for concave games with general convex action spaces and \emph{bandit} feedback: the analysis of \cite{MZ18} requires first-order feedback, while the analysis of \cite{BBF18} only applies to one-dimensional games.} We find this outcome particularly appealing for practical applications of game theory (\eg in network routing) because it shows that in a wide class of (possibly very complicated) nonlinear games, the \acl{NE} prediction does not require full rationality, common knowledge of rationality, flawless execution, or even the knowledge that a game is being played: a commonly-used, individual no-regret algorithm suffices. \section{Introduction} \label{sec:introduction} \input{Introduction} \section{Problem setup and preliminaries} \label{sec:prelims} \input{Prelims} \section{Regularized no-regret learning} \label{sec:learning} \input{Learning} \section{First-order vs. bandit feedback} \label{sec:feedback} \input{Feedback} \section{Convergence analysis and results} \label{sec:results} \input{Results} \section{Concluding remarks} \label{sec:conclusions} \input{Conclusions} \subsection{Concave games\afterhead} Throughout this paper, we will focus on games with a finite number of players $\play\in\players = \{1,\dotsc,\nPlayers\}$ and continuous action sets. During play, every player $\play\in\players$ selects an \emph{action} $\debug x_{\play}$ from a compact convex subset $\feas_{\play}$ of a $\vdim_{\play}$-dimensional normed space $\vecspace_{\play}$; subsequently, based on each player's individual objective and the \emph{action profile} $\debug x = (\debug x_{\play};\debug x_{-\play}) \equiv (\debug x_{1},\dotsc,\debug x_{\nPlayers})$ of all players' actions, every player receives a \emph{reward}, and the process repeats. In more detail, writing $\feas \equiv \prod_{\play} \feas_{i}$ for the game's \emph{action space}, we assume that each player's reward is determined by an associated \emph{payoff} (or \emph{utility}) \emph{function} $\pay_{\play}\from\feas\to\R$. Since players are not assumed to ``know the game'' (or even that they are involved in one) these payoff functions might be a priori unknown, especially with respect to the dependence on the actions of other players. Our only structural assumption for $\pay_{\play}$ will be that $\pay_{\play}(\debug x_{\play};\debug x_{-\play})$ is concave in $\debug x_{\play}$ for all $\debug x_{-\play}\in\feas_{-\play} \equiv \inprod_{\playalt\neq\play} \feas_{\playalt}$, $\play\in\players$. With all this in hand, a \emph{concave game} will be a tuple $\game \equiv \game(\players,\feas,\pay)$ with players, action spaces and payoffs defined as above. Below, we briefly discuss some examples thereof: \begin{example}[Cournot competition] \label{ex:game-Cournot} In the standard Cournot oligopoly model, there is a finite set of \emph{firms} indexed by $\play=1,\dotsc,\nPlayers$, each supplying the market with a quantity $\debug x_{\play}\in[0,C_{\play}]$ of some good (or service), up to the firm's production capacity $C_{\play}$. By the law of supply and demand, the good is priced as a decreasing function $P(\debug x_{\mathrm{tot}})$ of the total amount $\debug x_{\mathrm{tot}} = \sum_{\play=1}^{\nPlayers} \debug x_{\play}$ supplied to the market, typically following a linear model of the form $P(\debug x_{\mathrm{tot}}) = a - b\debug x_{\mathrm{tot}}$ for positive constants $a,b>0$. The utility of firm $\play$ is then given by \begin{equation} \label{eq:pay-Cournot} \pay_{\play}(\debug x_{\play};\debug x_{-\play}) = \debug x_{\play} P(\debug x_{\mathrm{tot}}) - c_{\play} \debug x_{\play}, \end{equation} \ie it comprises the total revenue from producing $\debug x_{\play}$ units of the good in question minus the associated production cost (in the above, $c_{\play}>0$ represents the marginal production cost of firm $\play$). \end{example} \begin{example}[Resource allocation auctions] \label{ex:game-auction} Consider a service provider with a number of splittable \emph{resources} $\resource \in \resources = \{1,\dotsc,\nResources\}$ (bandwidth, server time, GPU cores, etc.). These resources can be leased to a set of $\nPlayers$ bidders (players) who can place monetary bids $\debug x_{\play\resource}\geq0$ for the utilization of each resource $\resource\in\resources$ up to each player's total budget $b_{\play}$, \ie $\sum_{\resource\in\resources} \debug x_{\play\resource} \leq b_{\play}$. Once all bids are in, resources are allocated proportionally to each player's bid, \ie the $\play$-th player gets \( \rho_{\play\resource} = \parens{q_{\resource} \debug x_{\play\resource}} \big/ \parens{c_{\resource} + \sum_{\playalt\in\players} \debug x_{\playalt\resource}} \) units of the $\resource$-th resource (where $q_{\resource}$ denotes the available units of said resource and $c_{\resource}\geq0$ is the ``entry barrier'' for bidding on it). A simple model for the utility of player $\play$ is then given by \begin{equation} \label{eq:pay-auction} \pay_{\play}(\debug x_{\play};\debug x_{-\play}) = \sum_{\resource\in\resources} \bracks{g_{\play} \rho_{\play\resource} - \debug x_{\play\resource}}, \end{equation} with $g_{\play}$ denoting the marginal gain of player $\play$ from acquiring a unit slice of resources. \end{example} \subsection{\acl{NE} and monotone games\afterhead} The most widely used solution concept for non-cooperative games is that of a \acdef{NE}, defined here as any action profile $\eq\in\feas$ that is resilient to unilateral deviations, viz. \begin{equation} \label{eq:NE} \tag{NE} \pay_{\play}(\eq_{\play};\eq_{-\play}) \geq \pay_{\play}(\debug x_{\play};\eq_{-\play}) \quad \text{for all $\debug x_{\play}\in\feas_{\play}$, $\play\in\players$}. \end{equation} By the classical existence theorem of \cite{Deb52}, every concave game admits a \acl{NE}. Moreover, thanks to the individual concavity of the game's payoff functions, \aclp{NE} can also be characterized via the first-order optimality condition \begin{equation} \label{eq:NE-var} \braket{\payv_{\play}(\eq)}{\debug x_{\play} - \eq_{\play}} \leq 0 \quad \text{for all $\debug x_{\play}\in\feas_{\play}$}, \end{equation} where $\payv_{\play}(\debug x)$ denotes the individual payoff gradient of the $\play$-th player, \ie \begin{equation} \label{eq:payv} \payv_{\play}(\debug x) = \del_{\play} \pay_{\play}(\debug x_{\play};\debug x_{-\play}), \end{equation} with $\del_{\play}$ denoting differentiation with respect to $\debug x_{\play}$.% \footnote{We adopt here the standard convention of treating $\payv_{\play}(\debug x)$ as an element of the dual space $\dspace_{\play} \equiv \dual\vecspace_{\play}$ of $\vecspace_{\play}$, with $\braket{\debug y_{\play}}{\debug x_{\play}}$ denoting the duality pairing between $\debug y_{\play}\in\dspace_{\play}$ and $\debug x_{\play}\in\feas_{\play}\subseteq\vecspace_{\play}$.} {In terms of regularity, it will be convenient to assume that each $\payv_{\play}$ is Lipschitz continuous; to streamline our presentation, this will be our standing assumption in what follows.} Starting with the seminal work of \cite{Ros65}, much of the literature on continuous games and their applications has focused on games that satisfy a condition known as \acdef{DSC}. In its simplest form, this condition posits that there exist positive constants $\lambda_{\play}>0$ such that \begin{equation} \label{eq:DSC} \tag{DSC} \sum_{\play\in\players} \lambda_{\play} \braket{\payv_{\play}(\alt \debug x) - \payv_{\play}(\debug x)}{\alt \debug x_{\play} - \debug x_{\play}} < 0 \quad \text{for all $\debug x,\alt \debug x\in\feas$, $\debug x \neq \alt \debug x$}. \end{equation} Owing to the formal similarity between \eqref{eq:DSC} and the various operator monotonicity conditions in optimization \citep[see \eg][]{BC17}, games that satisfy \eqref{eq:DSC} are commonly referred to as (strictly) \emph{monotone}. As was shown by \citet[Theorem~2]{Ros65}, monotone games admit a unique \acl{NE} $\eq\in\feas$, which, in view of \eqref{eq:DSC} and \eqref{eq:NE}, is also the unique solution of the (weighted) \acl{VI} \begin{equation} \label{eq:VI} \tag{VI} \sum_{\play\in\players} \lambda_{\play} \braket{\payv_{\play}(\debug x)}{\debug x_{\play} - \eq_{\play}} < 0 \quad \text{for all $\debug x\neq\eq$}. \end{equation} This property of \aclp{NE} of monotone games will play a crucial role in our analysis and we will use it freely in the rest of our paper. In terms of applications, monotonicity gives rise to a very rich class of games. As we show in the paper's supplement, \cref{ex:game-Cournot,ex:game-auction} both satisfy \acl{DSC} (with a nontrivial choice of weights for the latter), as do atomic splittable congestion games in networks with parallel links \citep{ORShi93,SW16}, multi-user covariance matrix optimization problems in \ac{MIMO} systems \citep{MBNS17}, and many other problems where online decision-making is the norm. Namely, the class of monotone games contains all strictly convex-concave zero-sum games and all games that admit a (strictly) concave \emph{potential}, \ie a function $\pot\from\feas\to\R$ such that \( \payv_{\play}(\debug x) = \del_{\play} \pot(\debug x) \) for all $\debug x\in\feas$, $\play\in\players$. In view of all this (and unless explicitly stated otherwise), we will focus throughout on monotone games; for completeness, we also include in the supplement a straightforward second-order test for monotonicity.
{'timestamp': '2018-10-05T02:02:41', 'yymm': '1810', 'arxiv_id': '1810.01925', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01925'}
arxiv
\section{Introduction.}\label{intro} \section{Introduction} \label{sec::intro} Many common surveillance tasks concern the detection of intrusions along a border or perimeter. Tracking illegal fishing and smugglers, quantifying traffic flows and detecting adversarial intrusions are a few among many examples of potential civilian or military aims in this domain. These problems are often of high importance, and timeliness is critical for mission success. Thus approaches to the optimal design of surveillance strategies are invaluable not only at the operational level, but also at the strategic level because they can inform decision makers about expected outcomes for different budget scenarios. In these surveillance tasks the notion of optimality can be equated to maximising the rate of detection of intrusions, or equivalently, detecting as many intrusions as possible over some fixed time horizon. We will consider a scenario where surveillance is performed by a fleet of searchers, coordinated by a central agent referred to as the \emph{controller} who chooses which segments of the perimeter each searcher will survey. The precise definition of \emph{searchers} will depend on the context but may include human patrollers, or sensors mounted on fixed or mobile platforms. The search may take place in the air (e.g., with unmanned aerial vehicles (UAVs)) or in the water (e.g., with unmanned underwater vehicles (UUVs) or static sonobuoys). In any case the problem of designing an optimal surveillance strategy becomes truly challenging when the size of the fleet is insufficient to guarantee perfect detection of all intruders, which is typically the case in tight fiscal environments. In such a setting the controller faces a classic \emph{resource allocation problem}, where the action set is the set of possible allocations of searchers to segments of the perimeter and the controller aims to find an action which maximises the rate of detection. To compute this rate of detection the controller must know the rate at which intruders appear along the length of the perimeter and the probabilities with which searchers detect intruders that have appeared at particular points (under a particular allocation of searchers to perimeter segments). It is, of course, a strong assumption that such information is available, particularly at the beginning of a new surveillance project. In this work we consider the more realistic setting where the rate at which intruders appear is unknown, and two cases in terms of the information available on the probability of successful detection. When this rate function is unknown the controller has two broad options: \begin{enumerate} \item[(a)] to select an allocation which performs best in expectation according to some prior information (if it exists) and stick to that, \item[(b)] (if possible) to take an adaptive strategy, which alters the allocation of searchers as observations are collected. \end{enumerate} In this second scenario a \emph{sequential resource allocation problem} is faced - where the controller wishes to quickly and confidently converge on an optimal allocation after appropriate experimentation. This sequential problem is our principal concern in this paper. Such a scenario is all the more plausible in the advent of technologies such as UAVs or UUVs whose allocations can be much more easily updated than fixed cameras, or slow moving human searchers. To permit analysis of this problem we shall assume two discretisations to simplify the controller's action set. We will consider that opportunities to update the allocation of searchers occur only at particular time points $t \in \mathbb{N}$. Thus, the problem can be thought of as taking place over a series of rounds. We will also suppose that the perimeter has been divided into a number of cells such that each searcher is allocated a connected set of cells in which to patrol, disjoint from those allocated to other searchers. We argue that this is a reasonable simplification to make as over large distances, decisions about allocations will typically be made to the nearest hundred metres or kilometre. Imposing this discrete structure on the problem is useful as it allows us to draw on a large literature concerning \emph{multi-armed bandit problems} when designing and analysing solutions to the problem. Multi-armed bandit problems are relevant to this sequential resource allocation problem because they provide a framework for studying \emph{exploration-exploitation dilemmas}, which is the principal challenge faced by the controller here. In order to reliably make optimal actions, data must be collected from all cells to accurately estimate the expected number of detections associated with an action - i.e. the action space should be \emph{explored}. However, data is being collected on a \emph{live} problem - real intruders are passing undetected when sub-optimal actions are played. As such there is a pressure to \emph{exploit} information that has been collected and select actions which are believed to yield high detection rates over those with more exploratory value. A balance must be struck. One may suppose that this is a trivial issue which can be resolved by simply searching in all cells in all rounds. However, searching more cells will not necessarily lead to more accurate information or a higher detection rate. Searchers become less effective at detecting events the more cells they are allocated, because an intruder is more likely to escape if it is not detected within some window of time. An optimal action may well be to assign each searcher to a single cell. \subsection{Related Literature} \label{subsec::related_lit} Search theory started in WWII with the study of barrier patrols during the Battle of the Atlantic (\cite{koopman1946search}). The works of \cite{Stone1976} and \cite{Washburn2002} present a much broader and more contemporary range of applications in search theory and detection, and are by now the classic references on the subject. More closely related to our work is \cite{Szechtman2008}, who study the perimeter protection problem when the parameters of the arrival process are fully known, for mobile and fixed searchers. \cite{Carlsson2013} study the problem of optimally partitioning a space in $\mathbb{R}^2$ to maximise a function of an intensity of events over the space. Their problem bears resemblance to the full information version of our problem though our solution method is quite different due to our discretisation of the problem. More recently, \cite{park2016performance} use approximate dynamic programming to find good policies for online detection on a closed perimeter. Their problem has a sequential aspect however their formulation differs substantially from ours as they focus on a particular scenario where static sensors flag up intrusions and the decisions to be made are around visiting sensor locations to gather further information. We focus on detecting as many intrusions as possible with mobile searchers. \cite{papadaki2016patrolling} analyse a perimeter formed by a discrete linear network, defended by a single agent who can move one node per period, and a strategic attacker who wins if an attack on a node is not detected within a time window. Our work, however, is the first to model the problem of allocating multiple searchers to detect multiple intruders with the capacity to sequentially adapt searcher allocation and learn the distribution of intrusions. The sequential problem we consider is structurally similar to a combinatorial multi-armed bandit (CMAB) problem \citep{Chen2013}. To permit discussion of a CMAB we first describe the simpler multi-armed bandit (MAB) problem (first attributed to \cite{Thompson1933}), which is a special case. The (stochastic) MAB problem models a scenario where an agent is faced with a series of potential actions (or arms), each associated with some underlying probability distribution. In each of a series of rounds, the agent selects a single action and receives a \emph{reward} drawn from the underlying distribution associated with the selected action. The agent's aim is to maximise her cumulative expected reward over some number of rounds, or equivalently minimise her cumulative \emph{regret} - defined as the difference in expected reward between optimal actions and actions actually selected. To succeed in this the agent must manage an exploration-exploitation trade-off as she learns which actions have high expected reward. The CMAB problem models a richer framework where the agent may select multiple actions in each round and her reward is a function of the observations from the underlying distributions associated with the selected actions. Chen et al. consider a setting where this function may be non-linear. Numerous authors (\cite{Anantharam1987i}, \cite{Gai2012}, \cite{Kveton2015tight}, \cite{Combes2015}, and \cite{Luedtke2016}) consider a special case (known as a \emph{multiple play bandit}) where the reward is simply a sum of the random observations and the number of actions which may be selected in one round is limited. A number of other works have since extended the framework of \cite{Chen2013} to model other novel features. \cite{Chen2016a} and \cite{Kveton2015cascading} consider a setting where playing a subset of arms may randomly trigger additional rewards from other arms, and \cite{Chen2016b} considers a broader set of non-linear reward functions. However the CMAB model and UCB approach of \cite{Chen2013} is the work closest to ours as the later developments model features that are not present in our setting. Reward maximisation in a CMAB problem requires addressing a similar exploration-exploitation trade-off to that faced in the MAB problem. For MAB-type problems, it has famously been shown that under certain assumptions optimal policies can be derived by formulating the problem as a Markov Decision Process and using an index approach \citep{Gittins2011}. In CMAB problems however, these approaches are inappropriate, not least, since the combinatorial action sets induce dependencies between rewards generated by distinct actions which invalidates Gittins' theory. See also Remark 1 in Section 2. More recently, so called upper confidence bound (UCB) algorithms, first proposed by \cite{Lai1985asymptotically} and \cite{Burnetas1996optimal}, and popularised by \cite{Auer2002}, have attracted much attention as approaches that enjoy efficient implementation and strong theoretical guarantees. These heuristic methods balance exploration and exploitation by selecting actions based on optimistic estimates of the associated expected rewards and can be applied to both MAB and CMAB problems. Auer et al. originally proposed a UCB approach for MAB problems with underlying distributions whose support lies entirely within $[0,1]$. \cite{Chen2013} extended the principles of this algorithm to a version suitable for CMAB problems with nonlinear rewards. Broader classes of unbounded distributions have been considered by other authors. \cite{Cowan2015Normal}, \cite{Bubeck2012}, \cite{Bubeck2013}, and \cite{Lattimore2017} give UCB algorithms suitable for use with unbounded distributions, studying distributions that are Gaussian, have sub-Gaussian tails, known variance and known kurtosis respectively. \cite{Luedtke2016} have studied multiple-play bandits with exponential family distributions. However for CMAB problems with non-linear reward functions attention has focussed on the $[0,1]$ case. Accompanying each of these proposals of UCB algorithms is a corresponding proof which demonstrates the performance of that algorithm achieves the optimal order, albeit with a sub-optimal coefficient. Stronger performance guarantees (i.e. those with improved leading-order coefficients) have been obtained in MAB problems using Thompson Sampling type approaches \citep{Kaufmann2012thompson,Agrawal2012,Russo2016} and approaches which utilise the KL divergence of the reward distributions \citep{Cappe2013,Kaufmann2016}. \cite{Combes2015} have successfully extended the KL divergence based results to multiple play bandits with bounded rewards. However extending these results to the more general CMAB problem with non-linear rewards presents a significant analytical challenge, and therefore in this work we focus on the analysis of a UCB type approach. \subsection{Key Contributions} This work makes a number of contributions to the theory of optimal search, multi-armed bandits and broader online optimisation. Simultaneously we give a practically useful solution to a real problem in perimeter surveillance. We summarise the headline contributions below: \begin{itemize} \item Introduction of a formal model for sequential, multi-searcher perimeter surveillance problems and an efficient integer programming solution to the full-information version of the problem; \item Introduction of the \emph{filtered feedback} model for combinatorial multi-armed bandits; \item Development of a bespoke treatment of combinatorial bandits with \emph{Poisson} rewards, leading to a new concentration inequality for filtered Poisson data; \item Regret analysis leading to an optimal order analytical bound on finite time regret of the UCB algorithm and a problem-specific lower bound on asymptotic regret for any uniformly good algorithm. \end{itemize} We also present extensive numerical work which displays the robustness of the UCB approach and the unpredictable performance of Thompson Sampling. \subsection{Paper Outline} The remainder of the paper is structured as follows. Section \ref{subsec::model} introduces a model of the sequential problem. In Section \ref{sec::full_info} we solve the full information problem (the non-sequential perimeter surveillance problem where the rate function of the arrival process is known). The proposed integer programming solution forms the backbone of the proposed solution methods for the sequential problem. In Section \ref{sec::seq_learn} we introduce a solution method for the sequential resource allocation problem, FP-CUCB, and derive a performance guarantee in the form of an upper bound on expected regret of the policy. Here, we also derive a lower bound on the expected regret possible for any policy and thus show that our algorithm has a bound of the correct order. We conclude in Sections \ref{sec::numerics} and \ref{sec::discussion} with numerical experiments and a discussion respectively. \section{The Model} \label{subsec::model} Before introducing solution methods we give a mathematical model of the problem. Throughout the paper, for a positive integer $\Omega$ let the notation $[\Omega]$ represent the set $\{1,2,...,\Omega\}$. A domain of search (perimeter) comprises $K$ cells while searches are conducted by $U$ agents. We write \begin{displaymath} a_k = u, \quad k \in [K], \enspace u\in [U] \end{displaymath} to denote the deployment of agent $u$ to search cell $k$, while \begin{displaymath} a_k =0, \quad k \in [K] \end{displaymath} is used when cell $k$ goes unsearched. An \emph{action} $\mathbf{a} := (a_1,a_2,...,a_K) \in \{0,1,...U\}^K$ describes a deployment of the agents across the perimeter. We impose the requirement that $\mathbf{a} \in \mathcal{A}$, the \emph{action set}, where \begin{displaymath} \mathcal{A}=\{\mathbf{a} : \enspace a_i=a_j=u \Rightarrow a_k=u, \enspace i \leq k \leq j \enspace \forall i <j, u \in [U]\}. \end{displaymath} These conditions on $\mathcal{A}$ ensure that agents are assigned to disjoint connected sub-regions of the perimeter. This constraint eliminates unnecessary travel times for the agents and the possibility of multiple agents detecting the same event. The actions are uniquely defined by indicator variables \begin{displaymath} a_{iju}=1 \Leftrightarrow \text{agent } u \text{ is assigned to the cells } \{i,i+1,...,j\} \text{ only.} \end{displaymath} Each action $\mathbf{a} \in \mathcal{A}$ gives rise to a certain detection probability $\gamma_k(\mathbf{a}) \in [0,1]$ in each cell $k \in [K]$. The detection probabilities capture the effectiveness of each searcher in finding an intruder in a specific cell. We write $\boldsymbol\gamma(\mathbf{a})$ for the $K$-vector whose $k^{th}$ component is $\gamma_k(\mathbf{a})$. The detection probabilities are structured such that for any $\mathbf{a}, \mathbf{b} \in \mathcal{A}$ and $i \leq j$, \begin{displaymath} a_{iju}=b_{iju}=1 \Rightarrow \gamma_k(\mathbf{a})=\gamma_k(\mathbf{b}), \enspace \forall k \text{ such that } i \leq k \leq j. \end{displaymath} Hence, the detection probability in a cell depends only on the sub-region assigned to the single agent searching that cell and is unaffected by the sub-regions assigned to other agents. We assume that if a cell is searched there will be some non-zero probability of detecting intrusions that occur. That is to say $\gamma_k(\mathbf{a})>0$ for any $\mathbf{a} \in \mathcal{A}: a_k \neq 0$ for any $k \in [K]$. We consider two cases with respect to knowledge of the detection probabilities: \begin{enumerate} \item[(I)] The detection probabilities $\boldsymbol\gamma(\mathbf{a})$ are known for all $\mathbf{a} \in \mathcal{A}$. This scenario occurs when the agent knows $\boldsymbol\gamma(\mathbf{a})$ from the past. \item[(II)] The functions $\boldsymbol\gamma$ have a particular known parametric form but unknown parameter values. This case is realistic when properties of the detection probabilities are dictated by physical considerations, such as the searchers' speed or the time it takes intruders to cross the perimeter. \end{enumerate} Our sequential decision problem may now be described as follows: \begin{enumerate} \item At each time $t \in \mathbb{N}$ an action $\mathbf{a}_t \in \mathcal{A}$ is taken, inducing a detection probability $\gamma_k(\mathbf{a}_t)$ in each cell $k \in [K]$; \item Intrusion events are generated by $K$ independent Poisson processes, one for each cell. We use $X_k$ to denote the number of events in cell $k$ (whether observed or not) occurring during the period of a single search. We have \begin{displaymath} X_k \sim Pois(\lambda_k), \enspace k \in [K] \end{displaymath} where the rates $\lambda_k \in \mathbb{R}_{+}$ are unknown, and write $\lambda_{max} \geq \max_{k \in [K]} \lambda_k$ for a known upper bound on the arrival rates. We use $X_{kt}$ for the number of events generated in cell $k$ during search $t$. \item Should action $\mathbf{a}_t$ be taken at time $t$, a random vector of events $\mathbf{Y}_t = \{Y_{1t},Y_{2t},...,Y_{Kt}\} \in \mathbb{N}^K$ is observed. Events in the underlying $X$-process are observed or not independently of each other. We write \begin{displaymath} Y_{kt} | X_{kt}, \mathbf{a}_t \sim Bin(X_{kt},\gamma_k(\mathbf{a}_t)), \enspace k \in [K]. \end{displaymath} It follows from standard theory that \begin{displaymath} Y_{kt}|\mathbf{a}_t \sim Pois(\lambda_k\gamma_k(\mathbf{a}_t)), \enspace k\in [K], \end{displaymath} and are independent random variables. It follows that the mean number of events observed under action $\mathbf{a}$ is given by \begin{displaymath} r_{\boldsymbol\lambda, \boldsymbol\gamma}(\mathbf{a}) := \boldsymbol\gamma(\mathbf{a})^T\boldsymbol\lambda, \end{displaymath} where $T$ denotes vector transposition and $\boldsymbol\lambda$ is the $K$-vector whose $k^{th}$ component is $\lambda_k$. \item We write \begin{displaymath} \mathbf{H}_t=\{\mathbf{a}_1,\mathbf{Y}_1,...,\mathbf{a}_{t-1},\mathbf{Y}_{t-1}\} \end{displaymath} for the \emph{history} (of actions taken and events observed) available to the decision-maker at time $t \in \mathbb{N}$. A \emph{policy} is a rule for decision-making and is determined by some collection of functions $\big\{\pi_t: \mathbf{H}_t \rightarrow \mathcal{A}, t \in \mathbb{N} \big\}$ adapted to the filtration induced by $\mathbf{H}_t$. In practice a policy will be determined by some algorithm $A$. We will use the terms policy and algorithm interchangeably in what follows. \end{enumerate} The goal of analysis is the elucidation of policies whose performance (as measured by the mean number of events observed) is strong uniformly over $\boldsymbol\lambda, \boldsymbol\gamma$ and over partial horizons $\{1,2,...,n\} \subseteq \mathbb{N}$. We write \begin{displaymath} \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg) \end{displaymath} for the mean number of events observed up to time $t \in \mathbb{N}$ under algorithm $A$. If we write \begin{displaymath} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} := \max_{\mathbf{a} \in \mathcal{A}} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \end{displaymath} then it is plain that, for any choice of $A$ \begin{displaymath} n \cdot \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} \geq \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg), \end{displaymath} with achievement of the left hand side dependent on knowledge of $\boldsymbol\lambda$. Assessment of algorithms will be based on the associated \emph{regret function}, the expected reward lost through ignorance of $\boldsymbol\lambda$, given for algorithm $A$ and horizon $n$ by \begin{equation} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^A(n) := n \cdot \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} - \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg), \label{eq::regret} \end{equation} which is necessarily positive and nondecreasing in $n$, for any fixed $A$. In related bandit-type problems the regret of the best algorithms typically grows at $O(\log(n))$ uniformly across all $\boldsymbol\lambda$. We will demonstrate both that this is also the case for the algorithms we propose and that the best achievable growth for this problem is also $O(\log(n))$. \begin{remark} An alternative, indeed classical, formulation uses Bayes sequential decision theory. Here the goal of analysis is the determination of an algorithm $A$ to maximise \begin{displaymath} \mathds{E}_\rho \Bigg[\mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg) \Bigg] \end{displaymath} where the outer expectation is taken over some prior distribution $\rho $ for the unknown $\boldsymbol\lambda$. A standard approach would formulate this as a Markov Decision Process (MDP) with an informational state at time $t$ taken to be some sufficient statistic for $\boldsymbol\lambda$. The objections to this approach in this context are many. First, any serious attempt to derive such a formulation which is likely tractable will require strong assumptions on the prior $\rho $ including, for example, independence of the components of $\boldsymbol\lambda$. These would each typically have a conjugate gamma prior. Even then the resulting dynamic program would be computationally intractable for any reasonable choices of $K$ and $n.$ Second, the realities of our problem (and, indeed, many others) are such that specification of any reasonably informed prior is impractical. Confidence in the analysis would inevitably require robustness of the performance of any proposed algorithm to specification of the prior. Indeed, our formulation centred on regret simply seeks robustness of performance with respect to values of the unknown $\boldsymbol\lambda$. Third, the MDP approach would require up front specification of the decision horizon $n.$ This is practically undesirable for our problem. Moreover, the value of $n$ is not unimportant. It will determine the nature of good policies in important ways. For example, the ``last'' decision at time $n$ is guaranteed to be optimally ``greedy'' since there is no further need to learn about $\boldsymbol\lambda$ at that point. \end{remark} \section{The Full Information Problem} \label{sec::full_info} In order to develop strongly performing policies, it is critical that we are able to solve the \emph{full information} optimisation problem \begin{displaymath} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} := \max_{\mathbf{a} \in \mathcal{A}} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \end{displaymath} for any pre-specified $\boldsymbol\lambda \in (\mathds{R}_+)^K$. A naive proposal for a policy addressing the problem outlined in the previous section would choose an action $\mathbf{a}_t$ at time $t$ to solve the full information problem for some estimate $\boldsymbol\lambda_t$ of the unknown $\boldsymbol\lambda$ available at time $t$. While such a proposal would fail to adequately address the challenge of learning about $\boldsymbol\lambda$, we will in the succeeding sections develop effective algorithms which choose allocations determined by solutions of full information problems for carefully chosen $\boldsymbol\lambda$-values. A challenge to the solution of the full information problem is the non-linearity in $\mathbf{a}$ of the objective $r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a})$ inherited from the non-linearity of the detection mechanism $\boldsymbol\gamma(\mathbf{a})$. To develop efficient solution approaches we produce a formulation as a linear integer program (IP) in which this non-linearity is removed by precomputing key quantities. In particular we write \begin{displaymath} q_{\boldsymbol\lambda,\boldsymbol\gamma,iju} = \sum_{k=i}^j \gamma_k(\mathbf{a}_{iju})\lambda_k \end{displaymath} for the mean number of events detected when agent $u$ is allocated to the subregion $\{i,i+1,...,j\}$ where $\mathbf{a}_{iju}$ is any $\mathbf{a} \in \mathcal{A}$ such that $a_{iju}=1$. Efficient solution of the full information problem relies on precomputing these $q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}$ for all $1 \leq i \leq j \leq K$, and $u \in [U]$. We now have that \begin{align} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}=\max_{\{a_{iju}, 1\leq i \leq j \leq K, u \in [U]\}}\sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}a_{iju}& \label{eq::IP}\\ \text{such that } \quad \sum_{i=1}^K \sum_{j=i}^K a_{iju} \leq &1, \enspace u \in [U] \nonumber \\ \sum_{i=1}^k \sum_{j=k}^K \sum_{u=1}^U a_{iju} \leq &1, \enspace k \in [K] \nonumber \\ a_{iju} \in &\{0,1\}, \enspace 1 \leq i \leq j \leq K, \enspace u \in [U]. \nonumber \end{align} The first constraint above guarantees that each agent $u$ is assigned to at most one sub-region while the second constraint guarantees that each cell $k$ is searched by at most one agent. We view the solution of (\ref{eq::IP}) as the optimal allocation strategy and the optimal value function as the best achievable performance for an agent with perfect knowledge of $\boldsymbol\gamma$ and $\boldsymbol\lambda$. When we require solutions to the full information problem for the implementation of algorithms for the problem described in the preceding section, we solve an appropriate version of the above IP (ie, for suitably chosen $\boldsymbol\lambda$) by means of branch and bound. While it can be shown that the IP (\ref{eq::IP}) belongs to a class of problems which is NP-hard (see Appendix \ref{app:NPhard}) we find that the solution of this IP is very efficient in practice. We believe that this is because the solution of the LP-relaxation of (\ref{eq::IP}) often coincides with the exact solution of the IP. Indeed, in empirical tests this occurred more than 90\% of the time and in the remaining instances the gap between the two solutions was always less that 1\%. For all problem sizes considered in this paper the pre-processing and solution steps can be completed in less than a second using basic linear program solvers in the statistical programming language \texttt{R} on a single laptop. \section{Sequential Problem} \label{sec::seq_learn} In the sequential problem, the controller's objective is to minimise regret (\ref{eq::regret}) over a sequence of rounds. To do so the controller must construct a strategy which balances exploring all cells to accurately estimate the underlying rate parameters $\boldsymbol\lambda$, while also exploiting the information gained to detect as many events as possible. In this section we introduce and analyse two upper confidence bound (UCB) algorithms as policies for the case of fully known detection probabilities (case (I)) and the case where only the nature of the scaling of detection probabilities is known (case (II)). The model we introduced in Section \ref{subsec::model} is closely related to the \emph{Combinatorial Multi Armed Bandit problem} (CMAB) model of \cite{Chen2013}. The CMAB problem models a scenario where a decision-maker is faced with a set of $K$ basic actions (or \emph{arms}) each associated with a random variable of unknown probability distribution. In each round $t \in \mathbb{N}$, the decision-maker may select a subset of basic actions to take (or \emph{arms to pull}) and receives a \emph{reward} which is a (possibly randomised) function of realisations of the random variables associated with the selected basic actions. The decision-maker's aim is to maximise her cumulative reward over a given horizon. Chen et al. study a CMAB problem where the decision-maker receives \emph{semibandit feedback} on her actions, meaning she observes the overall reward but also all realisations of the random variables associated with the selected arms. Realisations of the random variables are identically distributed for a given arm and independent both across time and arms. In our surveillance problem, electing to search a cell $k$ in a round $t$, i.e. setting $a_{kt} \neq 0$, is the analogue of pulling an arm $k$. The total number of events detected in a round is the analogue of reward. The fundamental, and non-trivial difference between our model and that of Chen et al. lies in the feedback mechanism. Our framework is more complex in two important of regards. Firstly, we do not by default observe independent identically distributed (i.i.d.) realisations of the underlying random variable of interest $X_{kt}$ each time we elect to search a cell. We observe a \emph{filtered observation} $Y_{kt}$ whose distribution depends on the action $\mathbf{a}_t$ selected in that round. A second related point is that because of the $U$ possibly heterogeneous searchers, we can have multiple ways of searching the same collection of cells. While this is implicitly permitted within the framework of Chen et al., it is not explicitly acknowledged nor to the best of our knowledge are any real problems with such a structure explored in related work . Our analytical challenge is to extend earlier work in order to meet these novel features. Specifically we will propose a UCB algorithm for both cases of our problem and derive upper bounds on the expected regret of these policies. UCB algorithms apply the principle of \emph{optimism in the face of uncertainty} to sequential decision problems. Such an algorithm calculates an \emph{index} for each action in each round which is the upper limit of a high probability confidence interval on the expected reward of that action and then selects the action with the highest index. In this way the algorithm will select actions which either have high indices due to a large mean estimate - leading it to exploit what has been profitable so far - or due to a large uncertainty in the empirical mean - leading it to explore actions which are currently poorly understood. As the rounds proceed, the confidence intervals will concentrate on the true means and less exploratory actions will be selected in favour of exploitative ones. \subsection{Case (I): Known detection probabilities} \label{sec::known_gammas} In our first version of the problem, case (I), the only unknowns are the underlying rate parameters $\boldsymbol\lambda$. We assume that detection probability vectors $\boldsymbol\gamma(\mathbf{a})$ are known for all $\mathbf{a} \in \mathcal{A}$. Therefore we do not need to explicitly form UCB indices for every action separately. It will suffice to form a UCB index on each unknown $\lambda_k$ for $k \in [K]$. Optimistic estimates of the value of each action will then arise by calculating the $q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}$ quantities with the optimistic estimate of $\boldsymbol\lambda$ in place of known $\boldsymbol\lambda$. Our proposed approach to the sequential search problem in case (I), the FP-CUCB algorithm (Filtered Poisson - Combinatorial Upper Confidence Bound), is given as Algorithm \ref{alg::FPCUCB}. The algorithm consists of an initialisation phase of length $K$ where allocations are selected such that every cell is searched in some capacity at least once. Then in every subsequent round $t>K$, a UCB index $\bar{\lambda}_{k,t}$ is calculated for each cell $k$ as the sum of an empirical mean for filtered data and an appropriate inflation term. An action which is optimal with respect to the $K$-vector of inflated rates $\bar{\boldsymbol\lambda}_t=(\bar{\lambda}_{1,t},...,\bar{\lambda}_{K,t})$ is then selected by solving the IP (\ref{eq::IP}) with $\bar{\boldsymbol\lambda}_t$ in place of $\boldsymbol\lambda$. The inflation terms involve a parameter $\lambda_{max} \geq \max_{k \in [K]} \lambda_k$. This is necessary to construct UCBs which concentrate at a rate that matches the concentration of Poisson random variables, which is defined by the mean parameter. \begin{algorithm}[] \vspace{0.1cm} \caption{FP-CUCB (case (I))} \label{alg::FPCUCB} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Upper bound $\lambda_{max} \geq \lambda_k, \enspace k \in [K]$. \textbf{Initialisation Phase:} For $t \in [K]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t \neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=K+1,K+2,...$ \begin{itemize} \item Calculate indices \begin{equation} \bar{\lambda}_{k,t}= \frac{\sum_{s=1}^{t-1}Y_{k,s}}{\sum_{s=1}^{t-1}\gamma_{k,s}}+\frac{2\log(t)}{\sum_{s=1}^{t-1}\gamma_{k,s}}+\sqrt{\frac{6\lambda_{max}\log(t)}{\sum_{s=1}^{t-1}\gamma_{k,s}}}, \enspace k \in [K] \label{eq::FPCUCBI_indices} \end{equation} \item Select an allocation $\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t}$ such that $r_{\bar{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\bar{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} To analyse the regret of this algorithm we must first introduce some additional notation for \emph{optimality gaps}, the differences in expected reward between optimal and suboptimal actions. For $k \in [K]$ define, \begin{align*} \Delta_{max}^k&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\min_{\mathbf{a} \in \mathcal{A}_k}r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \\ \Delta_{min}^k&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\max_{\mathbf{a} \in \mathcal{A}_k}r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \end{align*} where $\mathcal{A}_k=\{\mathbf{a} \in \mathcal{A}: a_k \neq 0\}$ for $k \in [K]$, and $\Delta_{max}=\max_{k \in [K]}\Delta^k_{max}$, and $\Delta_{min}=\min_{k \in [K]} \Delta^k_{min}$. The quantity $\Delta_{max}$ is then the difference in expected reward between an optimal allocation of searchers and the worst possible allocation, while $\Delta_{min}$ is the difference in expected reward between an optimal allocation and the closest to optimal suboptimal allocation. The quantities $\Delta^k_{max}$ and $\Delta^k_{min}$ are the largest and smallest gaps between the expected reward of an optimal allocation and allocations where cell $k$ is searched in some capacity. All $\Delta$ terms depend on $\boldsymbol\lambda, \boldsymbol\gamma$ but we drop this dependence in the notation for simplicity. Now, in Theorem \ref{thm::FPCUCB} we provide an analytical bound on the expected regret of the {FP-CUCB} algorithm in $n$ rounds. \begin{theorem} \label{thm::FPCUCB} The regret of the FP-CUCB algorithm with $\lambda_{max}$ applied to the sequential surveillance problem with known $\boldsymbol\gamma$ satisfies \begin{align} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^{\text{FP-CUCB}}(n) &\leq \sum_{k:\Delta_{min}^k>0}\frac{12K^2}{\gamma_{k,min}} \Bigg[ \frac{b(\Delta^k_{min})}{\Delta_{min}^k} + \int_{\Delta_{min}^k}^{\Delta_{max}^k} \frac{b(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)K\Delta_{max}, \label{eq::FPCUCBBound} \end{align} where $b(x)=\lambda_{max} + \sqrt{\lambda_{max}^2 + x^2/9K^2}$, and $\gamma_{k,min}=\min_{\mathbf{a}:a_k \neq 0} \gamma_k(\mathbf{a})$. \end{theorem} \subsubsection{Proving Theorem \ref{thm::FPCUCB}} To give a proof of this theorem we must introduce a new way of thinking about the action space. Consider that while we have previously (for ease of exposition) defined actions in terms of allocations of searchers to cells, $\mathbf{a} \in \mathcal{A}$, the real impact on the observations comes from the vectors of detection probabilities, $\boldsymbol\gamma(\mathbf{a})$, which arise from these allocations. As multiple allocations may give rise to the same vector of detection probabilities (if, for instance, two searchers have identical capabilities, then switching their assignments would have no impact on the quality of the search) the set $\mathcal{G} = \{\boldsymbol\gamma(\mathbf{a}), \enspace \forall \mathbf{a} \in \mathcal{A}\}$ of possible detection probability vectors most parsimoniously describes the set of possible actions in this problem. For an element $\mathbf{g}=(g_1,...,g_k)=\mathcal{G}$ we then have expected reward $\mathbf{g}^T\cdot \boldsymbol\lambda$ and optimality gap $\Delta_{\mathbf{g}}=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\mathbf{g}^T \cdot \boldsymbol\lambda$. Let $\mathcal{G}_k$ be the set of vectors $\mathbf{g}$ with $g_k>0$ and $\mathcal{G}_{k,B}$ be the set of vectors in $\mathcal{G}_k$ with sub-optimal expected reward - i.e. $\mathcal{G}_{k,B}=\{\mathbf{g} \in \mathcal{G}_k: \Delta_{\mathbf{g}}>0\}$. Let $B_k=|\mathcal{G}_{k,B}|$ and label the vectors in $\mathcal{G}_{k,B}$ as $\mathbf{g}^1_{k,B},\mathbf{g}^2_{k,B},...,\mathbf{g}^{B_k}_{k,B}$ in increasing order of expected reward. We use the following notation for optimality gaps with respect to these ordered vectors \begin{equation} \Delta^{k,j} = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} - (\mathbf{g}^j_{k,B})^T \cdot \boldsymbol\lambda \quad j \in [B_k], \enspace k \in [K] \end{equation} and thus the gaps defined previously can be expressed as $\Delta_{max}^k = \Delta^{k,1}$ and $\Delta_{min}^k = \Delta^{k,B_k}$. We introduce counters $D_{k,t}=\sum_{s=1}^t g_{k,s}$ for $k \in [K]$, $t \in \mathbb{N}$ where $\mathbf{g}_s$ is the detection probability vector selected in round $s$. These allow us to keep track of the total detection probability \emph{applied} to a cell up to the end of round $t$. The central idea in proving Theorem \ref{thm::FPCUCB} is that if for a certain sub-optimal action $\mathbf{g}: \Delta_{\mathbf{g}}>0$, all the cells $k$ with $g_k>0$ have been sampled sufficiently, the mean estimates ought to be accurate enough that the probability of selecting that sub-optimal action again before horizon $n$ is small. We show that this sufficient sampling level is $O(\log(n))$ and the ``small" probabilities of selecting the sub-optimal action after sufficient sampling are so small as to converge to a constant. Thus by re-expressing expected regret as a function of the number of plays of sub-optimal actions, we can bound it from above as the sum of a $O(\log(n))$ term derived from the sufficient sampling level and a constant independent of $n$. To count the plays of sub-optimal actions we maintain counters $N_{k,t}$, which collectively count the number of suboptimal plays. We update them as follows. Firstly, after the $K$ initialisation rounds we set $N_{k,K}=1$ for $k \in [K]$. Thereafter, in each round $t >K$, let $k'=\arg\min_{j:g_{j,t}>0}N_{j,t-1}$, where if $k'$ is non-unique, we choose a single value randomly from the minimising set. If $\mathbf{g}_t^T\cdot \boldsymbol\lambda \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}$ then we increment $N_{k'}$ by one, i.e. set $N_{k',t}=N_{k',t-1}+1$. The key consequences of these updating rules are that $\sum_{k=1}^K N_{k,t}$ provides an upper bound on the number of suboptimal plays in $t$ rounds, and $D_{k,t} \geq \gamma_{k,min}N_{k,t}$ for all $k$ and $t$. \\ {Proof of Theorem \ref{thm::FPCUCB}} We prove the theorem by decomposing regret into a function of the number of plays of suboptimal arms, up to and after some sufficient sampling level. We then introduce two propositions which give bounds for quantities in the decomposition which are then combined to give the bound in (\ref{eq::FPCUCBBound}). The proofs of these propositions is reserved for Appendix \ref{Theorem1Proof}. Let $N_{k,t}^{l,suf}, N_{k,t}^{l,und}$ for $l \in [B_k]$ be counters associated with elements of $\mathcal{G}_{k,B}$ for $k \in [K]$. These counters are defined as follows: \begin{align} N_{k,n}^{l,suf} &= \sum_{t=K+1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}> h_{k,n}(\Delta^{k,l})\}, \label{Beyond Sufficiency Counter} \\ N_{k,n}^{l,und} &= \sum_{t=K+1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}\leq h_{k,n}(\Delta^{k,l})\}, \label{Under Sufficiency Counter} \end{align} where $h_{k,n}(\Delta)=12b(\Delta) \frac{\log(n)K^2}{\gamma_{k,min}\Delta^2}$. A cell $k$ is said to be \emph{sufficiently} sampled with respect to a choice of detection probabilities $\mathbf{g}_{k,B}^l$ if $N_{k,t-1} > h_{k,n}(\Delta^{k,l})$, and thus $N_{k,n}^{l,und},N_{k,n}^{l,suf}$ count the suboptimal plays leading to incrementing $N_{k,n}^l$ up to and after the sufficient level, respectively. From the definitions (\ref{Beyond Sufficiency Counter}) and (\ref{Under Sufficiency Counter}) we have $N_{k,n}=1+\sum_{l=1}^{B_k} (N_{k,n}^{l,suf}+N_{k,n}^{und})$. The expected regret at time horizon $n$ can also be bounded above using this notation as \begin{equation} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}(n) \leq \mathds{E}\Bigg[\sum_{k=1}^K \Bigg(\Delta^{k,1} + \sum_{l=1}^{B_k}(N_{k,n}^{l,suf}+N_{k,n}^{l,und})\cdot \Delta^{k,l}\Bigg)\Bigg] \label{eq::regret_decomposition} \end{equation} where $\Delta^{k,1}$ arises as a worst case view of the initialisation. We can derive an analytical bound on regret by bounding the expectations of the random variables in (\ref{eq::regret_decomposition}). Firstly, for the beyond sufficiency counter we have \begin{proposition} \label{prop::FPCUCBsuff} For any time horizon $n>K$, \begin{equation} \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Bigg) \leq \frac{\pi^2}{3}\cdot K. \label{eq::prop1} \end{equation} \end{proposition} The full proof of Proposition \ref{prop::FPCUCBsuff} is given in Appendix \ref{Theorem1Proof}, but in particular depends on the following Lemma describing the concentration of filtered Poisson data. \begin{lemma} \label{lem::FPCUCBconc} For any set of independent Poisson random variables $Y_{1},...,Y_{s}$ with means $\gamma_{1}\mu,...\gamma_{s}\mu$ respectively, and parameters $t\geq s$ and $\mu_{max} \geq \mu$ the following holds: \begin{equation} \mathds{P}\bigg(\bigg|\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}}-\mu\bigg| \geq \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \leq 2t^{-3}. \label{FPCUCBconc} \end{equation} \end{lemma} The consequence of this Lemma is that the UCB indices (\ref{eq::FPCUCBI_indices}) are of the correct form to guarantee that the probability of making suboptimal plays beyond the sufficient sampling level is small. We provide a proof of Lemma \ref{lem::FPCUCBconc} in Appendix \ref{proof::concresult}. For the under sufficiency counter we have the following proposition, also proved in Appendix \ref{Theorem1Proof}, \begin{proposition} \label{prop::FPCUCBund} For any time horizon $n>K$ and $k:\Delta^k_{min}>0$, \begin{equation} \sum_{l=1}^{B_k} N_{k,n}^{l,und}\Delta^{k,l} \leq h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx. \label{eq::prop2} \end{equation} \end{proposition} Combining the decomposition (\ref{eq::regret_decomposition}), with the bounds (\ref{eq::prop1}) and (\ref{eq::prop2}) we have \begin{align*} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}(n) &\leq \mathds{E}\bigg(\sum_{k=1}^K \Big(\Delta^{k,1}+\sum_{l=1}^{B_k}(N_{k,n}^{l,suf}+N_{k,n}^{l,und})\Delta^{k,l}\Big)\bigg) \\ &= \mathds{E}\Bigg(\sum_{k=1}^K\bigg(\Delta^{k,1} + \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Delta^{k,l}\bigg)\Bigg) + \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,und}\Delta^{k,l}\Bigg) \\ &\leq K\Delta_{max} + \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Delta^{k,l}\Bigg) + \sum_{k:\Delta_{min}^k>0} \bigg(h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx\bigg) \\ &\leq \Big(\frac{\pi^2}{3}+1\Big)K \Delta_{max} + \sum_{k:\Delta_{min}^k>0} \bigg(h_{k,n}(\Delta^{k}_{min})\Delta^{k}_{min} + \int_{\Delta^{k}_{min}}^{\Delta^{k}_{max}} h_{k,n}(x)dx\bigg) \\ &=\sum_{k:\Delta_{min}^k>0}\frac{12K^2}{\gamma_{k,min}} \Bigg[ \frac{b(\Delta^k_{min})}{\Delta_{min}^k} + \int_{\Delta_{min}^k}^{\Delta_{max}^k} \frac{b(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)K\Delta_{max}. \quad \square \end{align*} In the remainder of this section we show that the bound obtained in Theorem \ref{thm::FPCUCB} is of optimal order, by deriving a lower bound on the expected regret of the best possible policies. \subsubsection{Lower Bound on Regret} \label{sec::regret_lower_bound} To analyse the performance of the best possible policies, we introduce the notion of a \emph{uniformly good policy}. A uniformly good policy \citep{Lai1985asymptotically} is one where \begin{displaymath} \mathds{E}\bigg(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t=\mathbf{g} \} \bigg) = o(n^\alpha) \quad \forall \enspace \alpha >0 \end{displaymath} for every $\mathbf{g}: \Delta_{\mathbf{g}}>0$ and every $\boldsymbol\lambda \in \mathbb{R}_+^K$. Clearly, then all uniformly good policies must eventually favour optimal actions over suboptimal ones - with the suboptimal actions being necessary to accurately estimate $\boldsymbol\lambda$. For a given rate vector $\boldsymbol\lambda$ we define the set of optimal actions as \begin{displaymath} J(\boldsymbol\lambda)=\{\mathbf{g}\in\mathcal{G}:\enspace \mathbf{g}^T\cdot\boldsymbol\lambda=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}\}. \end{displaymath} We write $S(\boldsymbol\lambda)=\mathcal{G}\setminus J(\boldsymbol\lambda)$ to be the set of suboptimal actions. The difficulty of a particular problem depends on the particular configuration of $\boldsymbol\lambda$ and $\boldsymbol\gamma$. We define \begin{displaymath} \mathcal{I}(\boldsymbol\lambda)= \{k: \enspace \exists \text{ } \mathbf{g} \in J(\boldsymbol\lambda) \text{ s.t. } g_k >0\} \end{displaymath} as the set of arms which are played in at least one optimal action and \begin{displaymath} B(\boldsymbol\lambda)=\{\boldsymbol\theta \in \mathbb{R}_+^K : \enspace \mathbf{g}^T \cdot \boldsymbol\theta < \text{opt}_{\boldsymbol\theta,\boldsymbol\gamma} \enspace \forall \mathbf{g} \in J(\boldsymbol\lambda) \enspace \text{ and } \enspace \theta_k = \lambda_k \enspace \forall k \in \mathcal{I}(\boldsymbol\lambda)\} \end{displaymath} as the set of mean vectors such that all actions in $J(\boldsymbol\lambda)$ are suboptimal but this cannot be discerned by playing only actions in $J(\boldsymbol\lambda)$. The larger the set $B(\boldsymbol\lambda)$, the more challenging the problem is. If $\mathcal{I}(\boldsymbol\lambda)=[K]$, then the problem is trivial as one can simultaneously play optimal actions and gather the information necessary to affirm that these actions are optimal. In such a case the lower bound on expected regret is simply 0. We have the following lower bound on regret for any uniformly good policy. A key consequence of this result is the assertion that policies with $O(\log(n))$ regret are indeed of optimal order and thus that the regret induced by the FP-CUCB algorithm in case (I) grows at the lowest achievable rate. This result is analogous to results in other classes of bandit problem as shown by \cite{Lai1985asymptotically} and \cite{Burnetas1996optimal}. \begin{theorem} \label{thm::lower_bound} For any $\boldsymbol\lambda \in \mathds{R}_+^K$ such that $B(\boldsymbol\lambda)\neq \emptyset$, and for any uniformly good policy $\pi$ for the sequential surveillance problem with known $\boldsymbol\gamma$, we have \begin{equation} \lim \inf_{n \rightarrow \infty} \frac{Reg^\pi_{\boldsymbol\lambda,\boldsymbol\gamma}(n)}{\log(n)} \geq c(\boldsymbol\lambda) \end{equation} where $c(\boldsymbol\lambda)$ is the optimal value of the following optimisation problem \begin{align} \inf_{\mathbf{d}\geq \mathbf{0}} \sum_{\mathbf{g} \in S(\boldsymbol\lambda)} d_{\mathbf{g}}\Delta_{\mathbf{g}} & \label{eq::lb_opt_objective}\\ \text{such that } \inf_{\boldsymbol\theta \in B(\boldsymbol\lambda)} \sum_{\mathbf{g} \in S(\boldsymbol\lambda)} d_{\mathbf{g}} \sum_{k=1}^K g_k kl(\lambda_k,\theta_k) &\geq 1. \label{eq::lb_opt_constraint} \end{align} and $\text{kl}(\lambda,\theta)=\lambda\log(\frac{\lambda}{\theta})+\theta-\lambda$ is the Kullback Leibler divergence between two Poisson distributions with mean parameters $\lambda$, $\theta$ respectively. \end{theorem} We prove this theorem fully in Appendix \ref{proof::lower_bound}, but here note that a key step of its proof is to invoke Theorem 1 of \cite{Graves1997}, which is a similar result for a more general class of controlled Markov Chains. It is possible to derive an analytical expression giving a lower bound on $c(\boldsymbol\lambda)$ by following steps similar to those in the proof of Theorem 2 in \cite{Combes2015}. However we omit this here because in the interests of succinctness as it is not an especially useful or elegant expression. \subsection{Case (II): Known scaling of detection probabilities} \label{sec::unknown_gammas} In the second case we suppose that we do not know exactly what probability of successful detection each searcher has in each cell, but that we have some idea of how these detection probabilities change as the searchers are assigned more cells to search. If, for example, the searcher is a UAV moving back-and-forth over $l$ cells at a constant speed $s$, then the time between successive visits to a cell is $2l/s$, suggesting that the detection probability decays like $s/(2l)$ with the number of cells $l$. In order to be precise about this case we suppose that detection probabilities have the form \begin{equation} \gamma_k(\mathbf{a}) = \sum_{u=1}^U \phi_{u}(\mathbf{a}) \omega_{ku}\mathds{I}\{a_k=u\}, \enspace k \in [K], \label{eq::case_b_detec_probs} \end{equation} where $\phi_{u}: \mathcal{A} \rightarrow [0,1]$ are known \emph{scaling functions}, and $\omega_{ku} \in (0,1] \enspace \forall k \in [K], u \in [U]$ are unknown \emph{baseline detection probabilities} - the probability of searcher $u$ detecting intrusions in cell $k$ given that is the only cell they are assigned to search. Functions $\phi_{u}$ are assumed to be decreasing in the number of cells searcher $u$ must search. For instance, and as suggested in the preceding paragraph, one suitable function may be $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathds{I}\{a_k=u\})^{-1}$, the reciprocal of the number of cells the searcher $u$ is assigned. Searcher effectiveness may however decay more slowly as the number of cells assigned grows if for instance it takes a some time for intruders to cross the perimeter. In case (II) the action set and observed rewards remain entirely the same as for case (I), it is the information initially available to the controller that differs. Here, both $\boldsymbol\lambda$, the $K$-vector of rate parameters, and $\boldsymbol\omega=(\omega_{1,1},...,\omega_{1,U},\omega_{2,1}...,\omega_{K,U})$, the $KU$-vector of baseline detection probabilities are unknown as opposed to solely $\boldsymbol\lambda$ in case (I). Due to nonidentifiability we cannot make direct inference on $\boldsymbol\lambda$ or $\boldsymbol\omega$. However, simply estimating the products of certain components is sufficient for optimal decision making as estimating expected reward does not depend on having separate estimates of each parameter. Therefore we can simply consider $KU$ unknowns $\boldsymbol\tau=(\omega_{1,1}\lambda_1,...,\omega_{1,U}\lambda_1,\omega_{2,1}\lambda_2,...,\omega_{K,U}\lambda_K)$ when referring to the unknown parameters. As such this second case of the sequential search problem can also be modelled as a CMAB problem with filtered feedback. The set of arms is given by searcher-cell pairs $ku \in [K]\times[U]$. Each arm $ku$ is associated with a Poisson distribution with unknown parameter $\tau_{ku}=\omega_{k,u}\lambda_k$. $\mathcal{A}$ continues to specify the action set and filtering is governed by scaling function vectors $\boldsymbol\phi(\mathbf{a})=(\phi_1(\mathbf{a}),...,\phi_U(\mathbf{a}))$. Let $\phi_{ku,t}$ denote the filtering probability associated with the searcher-cell pair $ku$ in round $t$. It is 0 if $a_{k,t}\neq u$ and $\phi_u(\mathbf{a}_t)$ if $a_{k,t}=u$. Let reward in this setting be defined \begin{displaymath} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a})=\tilde{r}_{\boldsymbol\tau,\boldsymbol\phi}(\mathbf{a})=\sum_{u=1}^U \phi_u(\mathbf{a}) \sum_{k=1}^K \tau_{ku}\mathds{I}\{a_k=u\} \end{displaymath} and define optimality gaps in this setting for $ku \in [K] \times [U]$ as\begin{align*} \Delta_{max}^{ku}&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\min_{\mathbf{a} \in \mathcal{A}}\{r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \enspace | \enspace r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma},a_k=u\} \\ \Delta_{min}^{ku}&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\max_{\mathbf{a} \in \mathcal{A}}\{r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \enspace | \enspace r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma},a_k=u\}. \end{align*} The appropriate FP-CUCB algorithm for case (II) then calculates upper confidence bounds for each $\tau_{ku}$ parameter instead of $\lambda_k$ and as in the FP-CUCB algorithm for case (I) this induces an optimistic estimate of the value of every $\mathbf{a} \in \mathcal{A}$. We describe this second variant in Algorithm \ref{alg::FPCUCBII}. \begin{algorithm}[] \vspace{0.1cm} \caption{FP-CUCB (case (II))} \label{alg::FPCUCBII} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Upper bound $\tau_{max} \geq \tau_{ku}, \enspace k \in [K]$ and $u \in [U]$. \textbf{Initialisation Phase:} For $t \in [KU]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t\neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=KU+1,KU+2,...$ \begin{itemize} \item Calculate indices \begin{displaymath} \bar{\tau}_{ku,t}= \frac{\sum_{s=1}^{t-1}Y_{ku,s}}{\sum_{s=1}^{t-1}\phi_{ku,s}}+\frac{2\log(t)}{\sum_{s=1}^{t-1}\phi_{ku,s}}+\sqrt{\frac{6\tau_{max}\log(t)}{\sum_{s=1}^{t-1}\phi_{ku,s}}}, \enspace ku \in [K]\times[U] \end{displaymath} \item Select an allocation $\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t}$ such that $\tilde{r}_{\bar{\boldsymbol\tau}_t,\boldsymbol\phi}(\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} \tilde{r}_{\bar{\boldsymbol\tau}_t,\boldsymbol\phi}(\mathbf{a})$. \end{itemize} \end{algorithm} Since our CMAB model in case (II) and second variant of FP-CUCB are of the same form as in case (I), the analogous results to Theorems \ref{thm::FPCUCB} and \ref{thm::lower_bound} can be derived. Specifically we have a regret upper bound for FP-CUCB in Corollary \ref{cor::FPCUCBb} and a lower bound for regret of any uniformly good algorithm in Corollary \ref{cor::lowerbound}. \begin{corollary} \label{cor::FPCUCBb} The regret of the FP-CUCB algorithm in case (b) defined by $\tau_{max}$ applied to the sequential search problem as defined previously satisfies \begin{align*} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^{\text{FP-CUCB}}(n) &\leq \sum_{ku:\Delta_{min}^{ku}>0}\frac{12(KU)^2}{\phi_{ku,min}} \Bigg[ \frac{b'(\Delta^{ku}_{min})}{\Delta_{min}^{ku}} + \int_{\Delta_{min}^{ku}}^{\Delta_{max}^{ku}} \frac{b'(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)KU\Delta_{max}, \end{align*} where $\tilde{b}(x)=\tau_{max} + \sqrt{\tau_{max}^2 + x^2/9(KU)^2}$, and $\phi_{ku,min}=\min_{\mathbf{a}:a_k=u}\phi_u(\mathbf{a})$. \end{corollary} \begin{corollary} \label{cor::lowerbound} For any $\boldsymbol\tau \in \mathds{R}_+^{KU}$ such that $\tilde{B}(\boldsymbol\tau)\neq \emptyset$, and for any uniformly good policy $\pi$ for the sequential surveillance problem with known $\boldsymbol\phi$, we have \begin{displaymath} \lim \inf_{n \rightarrow \infty} \frac{Reg^\pi_{\boldsymbol\lambda,\boldsymbol\gamma}(n)}{\log(n)} \geq \tilde{c}(\boldsymbol\tau) \end{displaymath} where $\tilde{c}(\boldsymbol\tau)$ is the solution of an optimisation problem analogous to (\ref{eq::lb_opt_objective}). \end{corollary} Precise specification of $\tilde{c}(\boldsymbol\tau)$ requires redefining notation from Section \ref{sec::regret_lower_bound} in the context of case (II) and produces an entirely unsurprising analogue. In the interests of brevity we omit this. The techniques used in proving Theorems \ref{thm::FPCUCB} and \ref{thm::lower_bound} can be easily extended to prove Corollaries 1 and 2. \section{Numerical Experiments} \label{sec::numerics} We now numerically evaluate the performance of our FP-CUCB algorithm in comparison to a greedy approach and Thompson Sampling (TS). The greedy approach is one which always selects the action currently believed to be best (following an initialisation period, where each cell is searched at least once). As such it is a fully exploitative policy which fails to recognise the benefit of the information gain inherent in exploration. TS is a randomised, Bayesian approach where an action is selected with the current posterior probability that it is the best one. This is achieved by sampling indices from a posterior distribution on each arm and passing these samples to the optimisation algorithm. We define these algorithms in the setting of known detection probabilities (case (I)) in Algorithms \ref{alg::Greedy} and \ref{alg::TS} respectively. \begin{algorithm}[] \vspace{0.1cm} \caption{Greedy} \label{alg::Greedy} \vspace{0.1cm} \vspace{0.1cm} \textbf{Initialisation Phase:} For $t \in [K]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t \neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=K+1,K+2,...$ \begin{itemize} \item For each $k \in [K] $ calculate $\hat{\lambda}_{k,t}= \frac{\sum_{s=1}^{t-1}Y_{k,s}}{\sum_{s=1}^{t-1}\gamma_{k,s}}$ \item Select an allocation $\mathbf{a}^*_{\hat{\boldsymbol\lambda}_t}$ such that $r_{\hat{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\hat{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\hat{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} \begin{algorithm}[] \vspace{0.1cm} \caption{Thompson Sampling (TS)} \label{alg::TS} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Gamma prior parameters $\alpha, \beta$ \textbf{Iterative Phase:} For $t=1,2,...$ \begin{itemize} \item For each $k \in [K]$ sample $\tilde{\lambda}_{k,t}$ from a $\text{Gamma}(\alpha + \sum_{s=1}^{t-1}Y_{k,s}, \beta + \sum_{s=1}^{t-1} \gamma_{k}(\mathbf{a}_s))$ distribution \item Select an allocation $\mathbf{a}^*_{\tilde{\boldsymbol\lambda}_t}$ such that $r_{\tilde{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\tilde{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\tilde{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} We compare the FP-CUCB, Greedy and Thompson Sampling algorithms by randomly sampling $\boldsymbol\lambda$ and $\boldsymbol\omega$ values which define problem instances. We then test our algorithms' performance on data generated from the models of these problem instances. We assume that detection probabilities have the form given in (\ref{eq::case_b_detec_probs}) but we know both the $\phi$ functions and $\omega$ values. Specifically, we conduct four tests encompassing a range of different problem sizes and parameter values to display the efficacy of our proposed approach uniformly across problem instances. In each test 50 $(\boldsymbol\lambda,\boldsymbol\omega)$ pairs are sampled and functions $\boldsymbol\phi$ are selected. For each $(\boldsymbol\lambda,\boldsymbol\omega)$ pair 5 datasets are sampled giving underlying counts of intrusion events in each cell in each round up to a horizon of $n=2000$. Parameters are simulated as below: \begin{enumerate} \item[(i)] $K=15$ cells and $U=5$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(10,20)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from $\text{Beta}(u,2)$ distributions for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(ii)] $K=50$ cells and $U=3$ searchers. Cell means $\lambda_k$ are sampled from Uniform distributions on the intervals $[k,k+10]$ for $k=1,...,10$, $[20-k,30-k]$ for $k=11,...,20$, $[k-20,k-10]$ for $k=21,...,30$, $[40-k,50-k]$ for $k=31,...,40$, and $[k-40,k-30]$ for $k=41,...,50$. Baseline detection probabilities $\omega_{ku}$ are sampled from $\text{Beta}(u+2,2)$ distributions for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(0.5+0.5\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(iii)] $K=25$ cells and $U=10$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(90,100)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from a $\text{Beta}(30,5)$ distribution for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(iv)] $K=25$ cells and $U=5$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(0.4,1)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from a $\text{Beta}(1,1)$ distribution for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(0.5+0.5\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \end{enumerate} We test a variety of parametrisations of {FP-CUCB} (in terms of $\lambda_{max}$) and TS (in terms of the prior mean and variance - from which particular $\alpha$, and $\beta$ values can be uniquely found) in each test. In each case we use $\lambda_{max}$ values which are both larger and smaller than the true maximal rate. Similarly we investigate TS with prior mean larger and smaller than the true maximal rate and with several different levels of variance. It is not always fully realistic to assume our knowledge of $\lambda_{max}$ will be perfect and therefore it is of interest to investigate the effects of varying it. Also, the choice of prior parameters in TS is a potentially subjective one and it is important to understand its impact. \begin{figure} \includegraphics[width=\textwidth]{graphics/AllMedianTest8} \caption{Cumulative Regret histories for Test (i). Upper left: FP-CUCB, upper right: TS with a prior variance of 1, lower left: TS with a prior variance of 5, lower right: TS with prior variance of 10. In each case the plotted lines are the median values of scaled regret calculated at each time point from 1 to 2000. Black lines represent $\lambda_{max}=1$ or a prior mean of 1, red represents the same parameters taking the value 5, green 10, blue 20, grey 40, and pink 60. In all sub-figures the teal line represents regret of the greedy algorithm.} \label{fig::test1} \end{figure} We measure the performance of our algorithms by calculating the expected regret incurred by their actions, rescaled by the expected reward of a single optimal action. For an algorithm $A$ and particular history $\mathbf{H}_n$ we write \begin{displaymath} ScaleReg_{\boldsymbol\lambda,\boldsymbol\gamma}^A(\mathbf{H}_n) = \frac{\sum_{t=1}^n \Delta_{\mathbf{a}_t}}{\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}}. \end{displaymath} We calculate this value for all algorithms, all 250 datasets and rounds $1 \leq n \leq 2000$. We choose to rescale our regret to make a fairer comparison across the 50 different problem instances in each test (i)-(iv) which will all have different optimal expected rewards. \begin{figure} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest8Correct.png} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest9Correct.png} \caption{Scaled regret distributions in tests (i) and (ii).} \label{fig::ridge_i} \end{figure} \begin{figure} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest10Correct.png} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest11Correct.png} \caption{Scaled regret distributions in tests (iii) and (iv).} \label{fig::ridge_ii} \end{figure} In Figure \ref{fig::test1} we illustrate how regret evolves over time by plotting the median scaled regret across the 250 runs of each algorithm in all rounds of test (i). The rate of growth shown in these plots is typical of the results in the other three tests. An immediate observation is that the greedy algorithm does very poorly on average and its full median regret over the 2000 rounds cannot be included in the graphs without obscuring differences between the other algorithms. We see also that the performance of both FP-CUCB and TS is strongly linked to the chosen parameters. For the FP-CUCB algorithm it seems in Figure 1 that the larger the parameter $\lambda_{max}$ is the larger the cumulative regret becomes. For TS it appears that with prior variance equal to 1 the performance can be almost as poor as in the greedy case but with larger prior variance TS can outperform the FP-CUCB algorithm. We analyse these behaviours further in Figures \ref{fig::ridge_i} and \ref{fig::ridge_ii}. Here we calculate a scaled regret at time $n=2000$ for all 250 runs of each algorithm and plot the empirical distribution of these values for each parameterisation of each algorithm. The results for tests (i) and (ii) are given in Figure \ref{fig::ridge_i} and for tests (iii) and (iv) in Figure \ref{fig::ridge_ii}. We omit the greedy algorithm's performance from these figures as the values are so large. In Appendix \ref{app::tables} we provide median values and lower and upper quantiles of the scaled regret for each algorithm. We see from these values that the greedy algorithm performs substantially worse than the FP-CUCB and TS algorithms which better address the exploration-exploitation dilemma. Examining Figures 2 and 3 it is clear that the FP-CUCB algorithm enjoys greater robustness to parameter choice than the TS approach. In particular in the results of test (iii) we see that many parametrisations of TS give rise to a long tailed distribution of round 2000 regret - meaning the performance of TS is highly variable and often poor. This variability of performance does seem to coincide with underestimation of the mean, however FP-CUCB manages to maintain strong performance even when $\lambda_{max}$ used in the algorithm is only 10\% of the true problem value. We do see the performance of FP-CUCB start to suffer when $\lambda_{max}$ is chosen to be 1, but it is still much better than TS. \section{Discussion} \label{sec::discussion} In this paper we have modelled and derived solution methods for a family of sequential decision problems motivated by multi-searcher perimeter surveillance scenarios with incomplete information. Namely, we have considered the problem of adaptively assigning multiple searchers to cells along a perimeter in order to detect the maximum number of intrusion events. The challenge at the heart of this problem is to correctly balance exploration and exploitation, in the face of initial ignorance as to the arrival process of events. We formulated our sequential decision problem as a combinatorial multi-armed bandit with Poisson rewards and a novel filtered feedback mechanism. To design quality policies for this problem we first derived an efficient solution method to the full information problem. This IP forms the backbone of all policies for the sequential problem, as it allows us to quickly identify an optimal solution given some estimate of the arrival process' rate parameters. We considered the sequential problem in two informational scenarios - firstly where the probability of detecting events is known, and secondly where these probabilities are unknown but one knows how they scale as the number of cells searched increases. For both of these cases we proposed an upper confidence bound approach. We derived lower bounds on the regret of all uniformly good algorithms under this our new feedback mechanism and upper bounds on the regret of our proposed approach. In comparing our {FP-CUCB} algorithm to Thompson Sampling (TS) we see that its principal benefit lies in its reliability. It is clear from the results of Section \ref{sec::numerics} that TS outperforms FP-CUCB for certain parametrisations (commonly larger choices of variance and mean close to the true arrival rates). However, we see that TS is particularly vulnerable to poor performance when the mean of the prior underestimates the true rate parameters. Even though our theoretical results for {FP-CUCB} depend on $\lambda_{max} \geq \lambda_k, k \in [K]$ we see that it is robust to underestimating this parameter. The reason our algorithm still performs well even when a key assumption does not hold is likely due to the fact that Bernstein's inequality does not give the tightest possible bound on Poisson tail probabilities (and therefore the rate of concentration of the mean). However, in order to construct our UCB algorithm we required a symmetric tail bound for which an inflation term giving the type of concentration in Lemma 1 could be identified. Chernoff bounds (see e.g. \cite{Boucheron2013}) are tighter but lack these properties. We note that both algorithms comfortably outperform the greedy algorithm in almost all examples, which speaks to the benefit of making some attempt to balance exploration and exploitation. In general we note the performance of TS is much more variable than that of {FP-CUCB}, as shown through the lower and upper quantiles of scaled regret. This arises due to the potential for the Gamma conjugate prior to be dominated by a small number of observations and create a scenario where TS behaves similarly to a greedy policy - sometimes fixing on good actions, but sometimes on poor ones. This phenomenon of variability of regret is understudied in multi-armed bandits, not least because it is much more challenging to analyse theoretically. However, in practical scenarios (where of course the learning and regret minimisation process will only occur once) this is a concerning disadvantage of TS. The reduced variability and theoretical guarantees of our {FP-CUCB} method make it a more reliable option for real surveillance operations. \begin{appendix} \section{Proof of NP-hardness of the IP (\ref{eq::IP})} \label{app:NPhard} \begin{theorem} Integer Linear Programs of the following type are $\mathcal{NP}$-hard in the strong sense: \begin{align*} \max_{a_{iju}, 1 \leq i \leq j \leq K, u \in [U]} \sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U q_{iju}a_{iju} & \\ \text{such that } \sum_{i=1}^K \sum_{j=i}^K a_{iju} \leq &1, \enspace u \in [U] \\ \sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U a_{iju} \leq &1, \enspace k \in [K] \\ a_{iju} \in &\{0,1\}, \enspace 1 \leq i \leq j \leq K, u \in [U]. \end{align*} \end{theorem} \noindent \emph{Proof of Theorem 3}: The following problem is known to be $\mathcal{NP}$-complete in the strong sense \citep{Garey1979}: \noindent \texttt{3-PARTITION}: Given positive integers $w_1,...,w_{3n}$ and a positive integer ``target" $t$, does there exist a partition of $\{1,...,3n\}$ into subsets $S_1,...,S_n$ such that $|S_i|=3$ and $\sum_{j \in S_i} w_j=t$ for $i=1,...,n$? We reduce this to an IP of the given type as follows. First, we assume without loss of generality that $\sum_{j=1}^{3n} w_j=nt$, since otherwise the answer to \texttt{3-PARTITION} is trivially ``no". Let $U=nt$ and $K=3n$. For $k=1,...,3n$, set $q_{iju}=w_k$ if $j-i=w_k$ and the open interval $(i,j)$ does not include a multiple of $t$. Set all other $q_{iju}$ to zero. Then the answer to \texttt{3-PARTITION} is ``yes" if and only if there is a solution to the IP with profit equal to $nt$. $\square$ \section{Lemma 1 Proof: Concentration of filtered Poisson estimator} \label{proof::concresult} First consider the result from Chapter 2 of \cite{Boucheron2013} that \emph{Bernstein's Inequality} \cite{Bernstein1946} holds for Poisson random variables. That is to say that if $Z$ follows a Poisson distribution with parameter $\lambda$ then \begin{align} \mathds{P}\bigg(Z \geq \lambda + \epsilon\bigg) &\leq \exp\Bigg(\frac{-\epsilon^2}{2\lambda+\frac{2}{3}\epsilon}\Bigg) \quad \text{for } \epsilon > 0, \label{Bounded Chernoff Inequality 1} \\ \mathds{P}\bigg(Z \leq \lambda - \epsilon\bigg) &\leq \exp\Bigg(\frac{-\epsilon^2}{2\lambda+\frac{2}{3}\epsilon}\Bigg) \quad \text{for } 0 < \epsilon < \lambda.\nonumber \end{align} We prooced to prove Lemma 1 by first bounding the probability in (\ref{FPCUCBconc}) \begin{align} &\quad \mathds{P}\bigg(\bigg|\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}}-\mu\bigg| \geq \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \nonumber \\ &\leq \mathds{P}\bigg(\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}} \geq \mu + \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) + \mathds{P}\bigg(\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}} \leq \mu - \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \nonumber \\ &= \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \geq \mu\sum_{j=1}^s\gamma_{j} + \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg) \nonumber \\ &\quad \quad+ \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \leq \mu\sum_{j=1}^s \gamma_j - \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg). \label{eq::Poisson_reexpres} \end{align} Since $Y_1,...,Y_s$ are all Poisson distributions, their sum $\sum_{j=1}^s Y_j$ follows a Poisson distribution with parameter $\mu\sum_{j=1}^s\gamma_{j}$ and we can apply (\ref{Bounded Chernoff Inequality 1}) to bound the first component of (\ref{eq::Poisson_reexpres}), \begin{align*} &\quad \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \geq \mu\sum_{j=1}^s\gamma_{j} + \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg) \\ &\leq \exp\bBigg@{4}(\frac{-\Bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\Bigg)^2}{2\mu\sum_{j=1}^s\gamma_{j} + \frac{2}{3}\bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)}\bBigg@{4}) \\ &= \exp\bBigg@{4}(-3\log(t)\frac{4\log(t) + 4\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}} + 6\mu_{max}\sum_{j=1}^s\gamma_{j}}{4\log(t) + 2\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}+6\mu\sum_{j=1}^s\gamma_{j}} \bBigg@{4}) \leq t^{-3}. \end{align*} The second probability in (\ref{eq::Poisson_reexpres}) can also be bounded by $t^{-3}$ by applying Bernstein's Inequality, thus completing the proof. $\square$ \section{Theorem \ref{thm::FPCUCB} Proof: Expected regret of FP-CUCB} \label{Theorem1Proof} To complete the proof of Theorem \ref{thm::FPCUCB} provided in the main text, we separately prove Propositions \ref{prop::FPCUCBsuff} and \ref{prop::FPCUCBund}. \noindent \emph{Proof of Proposition} \ref{prop::FPCUCBsuff}: Here we prove a bound on the expected number of plays of an arm \emph{after} it has reached its sufficient sampling level. Define the event \begin{displaymath} \mathcal{N}_t = \Bigg\{\bigg|\frac{\sum_{j=1}^{t-1}Y_{k,j}}{D_{k,t-1}}-\lambda_k\bigg| < \frac{2\log(t)}{D_{k,t-1}} + \sqrt{\frac{6\lambda_{max}\log(t)}{D_{k,t-1}}} \enspace \forall k\in[K]\Bigg\}. \end{displaymath} Define random variables $\Lambda_{k,t}=\frac{2\log(t)}{D_{k,t-1}} + \sqrt{\frac{6\lambda_{max}\log(t)}{D_{k,t-1}}}$ for $k\in[K]$ and $\Lambda_t=\max_{k:g_{k,t}>0}(\Lambda_{k,t})$. Define $\Lambda^{k,l}=\frac{2\log(t)}{\gamma_{k,min}h_{k,n}(\Delta^{k,l})} + \sqrt{\frac{6\lambda_{max}\log(t)}{\gamma_{k,min}h_{k,n}(\Delta^{k,l})}}$ for $l \in [B_k]$, $k \in [K]$, which are not random variables. By these definitions and the definition of UCB indices $\bar{\lambda}_{k,t}$ we have the following properties. \begin{align*} &\mathcal{N}_t \Rightarrow \bar{\lambda}_{k,t}-\lambda_k >0 \enspace \forall k \in [K] \\ &\mathcal{N}_t \Rightarrow \bar{\lambda}_{k,t}-\lambda_k < 2\Lambda_t \enspace \forall k: g_{k,t}>0 \\ &\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s:g_{s,t}>0\} \Rightarrow \Lambda^{k,l}> \Lambda_t \enspace \forall k \in [K], \forall l \in [B_k] \end{align*} For any particular $k \in [K]$ and $l \in [B_k]$ if $\{\mathcal{N}_t,\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s: g_{s,t}>0\}$ holds at time $t$ the following is implied \begin{equation} \mathbf{g}_t^T\cdot \boldsymbol\lambda + 2K\Lambda^{k,l} > \mathbf{g}_t^T\cdot \boldsymbol\lambda + 2K\Lambda_t \geq \mathbf{g}_t^T \cdot \bar{\boldsymbol\lambda}_t \geq (\mathbf{g}_{\boldsymbol\lambda}^*)^T \cdot \bar{\boldsymbol\lambda}_t\geq (\mathbf{g}_{\boldsymbol\lambda}^*)^T \cdot {\boldsymbol\lambda} = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} \label{Contradiction} \end{equation} where $\mathbf{g}^*_{\boldsymbol\lambda}$ is an action that is optimal with respect to rate vector $\boldsymbol\lambda$. However, by definition $2K\Lambda^{k,l}\geq\Delta^{k,l}$ and therefore (\ref{Contradiction}) is a contradiction of the definition of $\Delta^{k,l}=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\mathbf{g}_{k,B}^l\cdot \boldsymbol\lambda$. Therefore \begin{align*} &\mathds{P}(\mathcal{N}_t,\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, \forall s: g_{s,t}>0, N_{s,t-1}> h_{k,n}(\Delta^{k,l}))=0 \enspace \forall k \in [K], \enspace \forall l \in [B_k] \end{align*} and \begin{displaymath} \sum_{k=1}^K \sum_{l=1}^{B_k}\mathds{P}(\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s:g_{s,t}>0)\leq \mathds{P}(\neg \mathcal{N}_t) \leq 2Kt^{-2}. \end{displaymath} The bound on $\mathds{P}(\neg \mathcal{N}_t)$ comes from applying Lemma 1 and is sufficient to prove Proposition \ref{prop::FPCUCBsuff} since \begin{align*} \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Bigg)&=\mathds{E}\Bigg(\sum_{t=K+1}^n \sum_{k=1}^K \sum_{l=1}^{B_k} \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}> h_{k,n}(\Delta^{k,l})\}\Bigg) \\ &\leq \sum_{t=K+1}^n 2Kt^{-2} \leq \frac{\pi^2}{3}\cdot K. \quad \square \end{align*} \noindent \emph{Proof of Proposition 2} Now consider the number of plays made prior to reaching the sufficient sampling level. Firstly set $h_{k,n}(\Delta^{k,0})=0$ to simplify notation and consider the following steps. Then for any cell $k$ in $\{j \in [K]|\Delta_{min}^j >0 \}$ \begin{align*} \sum_{l=1}^{B_k} N_{k,n}^{l,und}\cdot \Delta^{k,l} &= \sum_{t=K+1}^n \sum_{l=1}^{B_k} \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\leq h_{k,n}(\Delta^{k,l})\bigg\} \Delta^{k,l} \\ &= \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^l \mathds{I}\bigg\{ \mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,l} \\ &\leq \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^l \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ \intertext{as $\Delta^{k,1} \geq \Delta^{k,2} \geq ... \geq \Delta^{k,B_k}$,} &\leq \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^{B_k} \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &= \sum_{t=K+1}^n \sum_{j=1}^{B_k} \mathds{I}\bigg\{ \mathbf{g}_t \in \mathcal{G}_{k,B}, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &= \sum_{j=1}^{B_k} \sum_{t=K+1}^n \mathds{I}\bigg\{\mathbf{g}_t \in \mathcal{G}_{k,B}, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &\leq \sum_{j=1}^{B_k} \Big(h_{k,n}(\Delta^{k,j})-h_{k,n}(\Delta^{k,j-1})\Big) \Delta^{k,j} \\ \intertext{since $N_{k}$ can only be incremented a maximum of $h_{k,n}(\Delta^{k,j})-h_{k,n}(\Delta^{k,j-1})$ times while remaining in this range} &= h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \sum_{j=1}^{B_k-1} h_{k,n}(\Delta^{k,j})\cdot(\Delta^{k,j}-\Delta^{k,j+1}) \\ &\leq h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx. \end{align*} The last inequality holds since $h_{k,n}(x)$ are decreasing functions. $\square$ \section{Theorem 2 Proof: Lower bound on regret} \label{proof::lower_bound} To prove Theorem 2, we must define the additional quantities necessary to apply Theorem 1 of \cite{Graves1997} and frame the problem accordingly. We consider the reward history $(\mathbf{Y}_t)_{t=1}^n$ to be a realisation of a controlled Markov Chain moving on the state space $\mathbb{N}^K$ where the controls are the detection probability vectors selected in each round. Each control $\mathbf{g} \in \mathcal{G}$ then has an associated set of $\boldsymbol\lambda$ parameter vectors under which it is an optimal control $\Lambda_{\mathbf{g}} = \{\boldsymbol\lambda \in \mathbb{R}_{+}^K: \mathbf{g}^T\cdot \boldsymbol\lambda = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}\}$, which may be the empty set. For any states $\mathbf{y}, \mathbf{z} \in \mathbb{N}^K$ transition probabilities are straightforward Poisson probabilities due to independence across rounds:\begin{displaymath} p(y,z;\boldsymbol\lambda,\mathbf{g}) = p(z;\boldsymbol\lambda,\mathbf{g})= \prod_{k=1}^K \frac{(g_k\lambda_k)^{z_k}e^{-g_k\lambda_k}}{z_k!}. \end{displaymath} These transition probabilities define the Kullback Leibler Information number for any control $\mathbf{g} \in \mathcal{G}$: \begin{displaymath} I^{\mathbf{g}}(\boldsymbol\lambda,\boldsymbol\theta)= \sum_{k=1}^K \log\bigg(\frac{p(z_k;\boldsymbol\lambda,\mathbf{g})}{p(z_k;\boldsymbol\theta,\mathbf{g})}\bigg)p(z_k;\boldsymbol\lambda,\mathbf{g}) =\sum_{k=1}^K \text{kl}(g_k\lambda_k,\gamma_k\theta_k) =\sum_{k=1}^K g_k \text{kl}(\lambda_k,\theta_k). \end{displaymath} With these quantities and those defined in Section \ref{sec::regret_lower_bound} we can apply Theorem 1 of \cite{Graves1997} to reach the following result for any uniformly good policy $\pi$ \begin{displaymath} \lim \inf_{n \rightarrow \infty} \sum_{\mathbf{g} \in \mathcal{J}\setminus J(\boldsymbol\lambda)} \frac{I^{\mathbf{g}}(\boldsymbol\lambda,\boldsymbol\theta)\mathds{E}_{\boldsymbol\lambda}(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}\})}{\log(n)} \geq 1 \text{ for every } \boldsymbol\theta \in B(\boldsymbol\lambda). \end{displaymath} Since $Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^\pi(n)=\sum_{\mathbf{g} \in \mathcal{J}\setminus J(\boldsymbol\lambda)} \Delta_{\mathbf{g}}\mathds{E}_{\boldsymbol\lambda}(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}\})$ the required result follows. $\square$ \section{Numerical Results} \label{app::tables} \begin{table}[h!] \centering \label{tab::test1} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 4.10 & 6.94 & 14.08 \\ & $\lambda_{max}=5$ & 12.72 & 18.97 & 24.46 \\ & $\lambda_{max}=10$ & 22.35 & 28.67 & 36.30 \\ & $\lambda_{max}=20$ & 35.72 & 42.59 & 54.98 \\ & $\lambda_{max}=40$ & 53.26 & 62.31 & 79.86 \\ & $\lambda_{max}=60$ & 64.06 & 77.63 & 100.34 \\ \hline \multirow{18}{*}{Thompson Sampling} & Mean=1, Variance=1 & 38.44 & 242.39 & 508.93 \\ & Mean=5, Variance=1 & 1.95 & 132.79 & 358.15 \\ & Mean=10, Variance=1 & 1.44 & 56.30 & 134.12 \\ & Mean=20, Variance=1 & 11.66 & 17.76 & 25.88 \\ & Mean=40, Variance=1 & 75.24 & 96.87 & 124.57 \\ & Mean=60, Variance=1 & 122.72 & 180.67 & 233.25 \\ & Mean=1, Variance=5 & 5.69 & 26.49 & 90.89 \\ & Mean=5, Variance=5 & 2.32 & 38.51 & 134.07 \\ & Mean=10, Variance=5 & 2.18 & 7.19 & 43.90 \\ & Mean=20, Variance=5 & 7.17 & 10.95 & 15.80 \\ & Mean=40, Variance=5 & 30.00 & 36.11 & 43.23 \\ & Mean=60, Variance=5 & 57.61 & 72.42 & 87.30 \\ & Mean=1, Variance=10 & 6.31 & 14.21 & 36.57 \\ & Mean=5, Variance=10 & 3.60 & 9.35 & 35.87 \\ & Mean=10, Variance=10 & 3.28 & 6.65 & 18.41 \\ & Mean=20, Variance=10 & 6.55 & 9.67 & 15.97 \\ & Mean=40, Variance=10 & 20.15 & 24.65 & 30.25 \\ & Mean=60, Variance=10 & 40.17 & 46.12 & 55.09 \\ \hline Greedy & & 79.77 & 679.76 & 1657.52 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (i) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test2} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 18.13 & 27.63 & 39.34 \\ &$\lambda_{max}=5$ & 57.39 & 76.02 & 104.67 \\ &$\lambda_{max}=10$ & 83.99 & 113.86 & 150.29 \\ &$\lambda_{max}=20$ & 116.59 & 159.85 & 200.11 \\ &$\lambda_{max}=40$ & 152.79 & 212.42 & 248.46 \\ &$\lambda_{max}=60$ & 176.58 & 245.46 & 285.71 \\ \hline \multirow{18}{*}{Thompmson Sampling} & Mean=1, Variance=1 & 248.37 & 481.61 & 783.17 \\ & Mean=5, Variance=1 & 6.34 & 150.56 & 451.04 \\ & Mean=10, Variance=1 & 6.38 & 16.93 & 129.87 \\ & Mean=20, Variance=1 & 84.59 & 104.91 & 134.17 \\ & Mean=40, Variance=1 & 234.03 & 321.99 & 365.10 \\ & Mean=60, Variance=1 & 297.34 & 412.77 & 481.44 \\ & Mean=1, Variance=5 & 22.56 & 48.46 & 121.32 \\ & Mean=5, Variance=5 & 7.75 & 54.94 & 175.94 \\ & Mean=10, Variance=5 & 5.26 & 11.12 & 32.86 \\ & Mean=20, Variance=5 & 29.47 & 36.23 & 45.42 \\ & Mean=40, Variance=5 & 106.17 & 137.60 & 162.94 \\ & Mean=60, Variance=5 & 183.13 & 245.48 & 279.97 \\ & Mean=1, Variance=10 & 20.34 & 33.24 & 55.34 \\ & Mean=5, Variance=10 & 9.44 & 21.12 & 79.06 \\ & Mean=10, Variance=10 & 8.24 & 12.40 & 25.07 \\ & Mean=20, Variance=10 & 19.19 & 24.56 & 31.66 \\ & Mean=40, Variance=10 & 69.19 & 84.84 & 100.94 \\ & Mean=60, Variance=10 & 126.94 & 162.99 & 188.46 \\ \hline Greedy & & 243.30 & 576.35 & 963.96 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (ii) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test3} \begin{tabular}{rrrrr} \hline Algorithm & Parameter & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 2.82 & 14.72 & 37.18 \\ & $\lambda_{max}=10$ & 3.97 & 5.14 & 6.73 \\ & $\lambda_{max}=25$ & 6.38 & 7.86 & 9.44 \\ & $\lambda_{max}=50$ & 9.42 & 10.94 & 12.51 \\ & $\lambda_{max}=100$ & 12.60 & 15.15 & 17.45 \\ & $\lambda_{max}=200$ & 16.59 & 20.23 & 22.85 \\ \hline \multirow{18}*{Thompson Sampling} & Mean=1, Variance=5 & 30.47 & 66.95 & 115.65 \\ & Mean=10, Variance=5 & 36.78 & 64.41 & 98.24 \\ & Mean=25, Variance=5 & 29.06 & 58.44 & 95.57 \\ & Mean=50, Variance=5 & 10.82 & 39.65 & 71.71 \\ & Mean=100, Variance=5 & 4.83 & 6.05 & 7.71 \\ & Mean=200, Variance=5 & 28.24 & 34.20 & 40.37 \\ & Mean=1, Variance=10 & 12.61 & 52.06 & 97.08 \\ & Mean=10, Variance=10 & 33.99 & 68.30 & 109.44 \\ & Mean=25, Variance=10 & 30.97 & 64.55 & 105.03 \\ & Mean=50, Variance=10 & 17.32 & 46.39 & 80.35 \\ & Mean=100, Variance=10 & 4.26 & 5.52 & 7.09 \\ & Mean=200, Variance=10 & 21.37 & 25.06 & 29.00 \\ & Mean=1, Variance=25 & 3.87 & 37.19 & 102.98 \\ & Mean=10, Variance=25 & 36.51 & 66.12 & 107.72 \\ & Mean=25, Variance=25 & 30.87 & 64.73 & 106.71 \\ & Mean=50, Variance=25 & 20.21 & 51.32 & 86.70 \\ & Mean=100, Variance=25 & 3.86 & 5.09 & 6.79 \\ & Mean=200, Variance=25 & 14.08 & 15.92 & 18.09 \\ \hline Greedy & & 21.57 & 49.20 & 95.89 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (iii) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test4} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=0.1$ & 22.71 & 53.35 & 101.82 \\ & $\lambda_{max}=1$ & 59.48 & 106.59 & 193.57 \\ & $\lambda_{max}=5$ & 84.44 & 140.40 & 250.38 \\ & $\lambda_{max}=10$ & 91.32 & 151.69 & 263.00 \\ & $\lambda_{max}=20$ & 96.01 & 162.47 & 270.39 \\ & $\lambda_{max}=40$ & 98.81 & 172.28 & 284.63 \\ \hline \multirow{18}{*}{Thompson Sampling} & Mean=0.1, Variance=1 & 70.68 & 136.84 & 284.14 \\ & Mean=1, Variance=1 & 42.78 & 61.44 & 91.98 \\ & Mean=5, Variance=1 & 43.96 & 75.38 & 119.21 \\ & Mean=10, Variance=1 & 75.45 & 118.86 & 197.36 \\ & Mean=20, Variance=1 & 104.58 & 174.02 & 291.32 \\ & Mean=40, Variance=1 & 119.72 & 207.46 & 349.74 \\ & Mean=0.1, Variance=5 & 94.23 & 246.71 & 467.06 \\ & Mean=1, Variance=5 & 43.48 & 73.41 & 119.94 \\ & Mean=5, Variance=5 & 41.71 & 60.07 & 88.64 \\ & Mean=10, Variance=5 & 45.15 & 72.69 & 119.42 \\ & Mean=20, Variance=5 & 69.43 & 113.12 & 191.90 \\ & Mean=40, Variance=5 & 102.60 & 169.98 & 281.94 \\ & Mean=0.1, Variance=10 & 134.60 & 320.63 & 588.63 \\ & Mean=1, Variance=10 & 48.26 & 81.35 & 146.95 \\ & Mean=5, Variance=10 & 41.43 & 58.66 & 84.74 \\ & Mean=10, Variance=10 & 40.78 & 62.10 & 99.55 \\ & Mean=20, Variance=10 & 55.42 & 89.68 & 146.88 \\ & Mean=40, Variance=10 & 86.98 & 141.99 & 239.18 \\ \hline Greedy & & 664.28 & 1825.61 & 1999.89 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (iv) data} \end{table} \clearpage \end{appendix} \bibliographystyle{apalike} \section{Introduction.}\label{intro} \section{Introduction} \label{sec::intro} Many common surveillance tasks concern the detection of intrusions along a border or perimeter. Tracking illegal fishing and smugglers, quantifying traffic flows and detecting adversarial intrusions are a few among many examples of potential civilian or military aims in this domain. These problems are often of high importance, and timeliness is critical for mission success. Thus approaches to the optimal design of surveillance strategies are invaluable not only at the operational level, but also at the strategic level because they can inform decision makers about expected outcomes for different budget scenarios. In these surveillance tasks the notion of optimality can be equated to maximising the rate of detection of intrusions, or equivalently, detecting as many intrusions as possible over some fixed time horizon. We will consider a scenario where surveillance is performed by a fleet of searchers, coordinated by a central agent referred to as the \emph{controller} who chooses which segments of the perimeter each searcher will survey. The precise definition of \emph{searchers} will depend on the context but may include human patrollers, or sensors mounted on fixed or mobile platforms. The search may take place in the air (e.g., with unmanned aerial vehicles (UAVs)) or in the water (e.g., with unmanned underwater vehicles (UUVs) or static sonobuoys). In any case the problem of designing an optimal surveillance strategy becomes truly challenging when the size of the fleet is insufficient to guarantee perfect detection of all intruders, which is typically the case in tight fiscal environments. In such a setting the controller faces a classic \emph{resource allocation problem}, where the action set is the set of possible allocations of searchers to segments of the perimeter and the controller aims to find an action which maximises the rate of detection. To compute this rate of detection the controller must know the rate at which intruders appear along the length of the perimeter and the probabilities with which searchers detect intruders that have appeared at particular points (under a particular allocation of searchers to perimeter segments). It is, of course, a strong assumption that such information is available, particularly at the beginning of a new surveillance project. In this work we consider the more realistic setting where the rate at which intruders appear is unknown, and two cases in terms of the information available on the probability of successful detection. When this rate function is unknown the controller has two broad options: \begin{enumerate} \item[(a)] to select an allocation which performs best in expectation according to some prior information (if it exists) and stick to that, \item[(b)] (if possible) to take an adaptive strategy, which alters the allocation of searchers as observations are collected. \end{enumerate} In this second scenario a \emph{sequential resource allocation problem} is faced - where the controller wishes to quickly and confidently converge on an optimal allocation after appropriate experimentation. This sequential problem is our principal concern in this paper. Such a scenario is all the more plausible in the advent of technologies such as UAVs or UUVs whose allocations can be much more easily updated than fixed cameras, or slow moving human searchers. To permit analysis of this problem we shall assume two discretisations to simplify the controller's action set. We will consider that opportunities to update the allocation of searchers occur only at particular time points $t \in \mathbb{N}$. Thus, the problem can be thought of as taking place over a series of rounds. We will also suppose that the perimeter has been divided into a number of cells such that each searcher is allocated a connected set of cells in which to patrol, disjoint from those allocated to other searchers. We argue that this is a reasonable simplification to make as over large distances, decisions about allocations will typically be made to the nearest hundred metres or kilometre. Imposing this discrete structure on the problem is useful as it allows us to draw on a large literature concerning \emph{multi-armed bandit problems} when designing and analysing solutions to the problem. Multi-armed bandit problems are relevant to this sequential resource allocation problem because they provide a framework for studying \emph{exploration-exploitation dilemmas}, which is the principal challenge faced by the controller here. In order to reliably make optimal actions, data must be collected from all cells to accurately estimate the expected number of detections associated with an action - i.e. the action space should be \emph{explored}. However, data is being collected on a \emph{live} problem - real intruders are passing undetected when sub-optimal actions are played. As such there is a pressure to \emph{exploit} information that has been collected and select actions which are believed to yield high detection rates over those with more exploratory value. A balance must be struck. One may suppose that this is a trivial issue which can be resolved by simply searching in all cells in all rounds. However, searching more cells will not necessarily lead to more accurate information or a higher detection rate. Searchers become less effective at detecting events the more cells they are allocated, because an intruder is more likely to escape if it is not detected within some window of time. An optimal action may well be to assign each searcher to a single cell. \subsection{Related Literature} \label{subsec::related_lit} Search theory started in WWII with the study of barrier patrols during the Battle of the Atlantic (\cite{koopman1946search}). The works of \cite{Stone1976} and \cite{Washburn2002} present a much broader and more contemporary range of applications in search theory and detection, and are by now the classic references on the subject. More closely related to our work is \cite{Szechtman2008}, who study the perimeter protection problem when the parameters of the arrival process are fully known, for mobile and fixed searchers. \cite{Carlsson2013} study the problem of optimally partitioning a space in $\mathbb{R}^2$ to maximise a function of an intensity of events over the space. Their problem bears resemblance to the full information version of our problem though our solution method is quite different due to our discretisation of the problem. More recently, \cite{park2016performance} use approximate dynamic programming to find good policies for online detection on a closed perimeter. Their problem has a sequential aspect however their formulation differs substantially from ours as they focus on a particular scenario where static sensors flag up intrusions and the decisions to be made are around visiting sensor locations to gather further information. We focus on detecting as many intrusions as possible with mobile searchers. \cite{papadaki2016patrolling} analyse a perimeter formed by a discrete linear network, defended by a single agent who can move one node per period, and a strategic attacker who wins if an attack on a node is not detected within a time window. Our work, however, is the first to model the problem of allocating multiple searchers to detect multiple intruders with the capacity to sequentially adapt searcher allocation and learn the distribution of intrusions. The sequential problem we consider is structurally similar to a combinatorial multi-armed bandit (CMAB) problem \citep{Chen2013}. To permit discussion of a CMAB we first describe the simpler multi-armed bandit (MAB) problem (first attributed to \cite{Thompson1933}), which is a special case. The (stochastic) MAB problem models a scenario where an agent is faced with a series of potential actions (or arms), each associated with some underlying probability distribution. In each of a series of rounds, the agent selects a single action and receives a \emph{reward} drawn from the underlying distribution associated with the selected action. The agent's aim is to maximise her cumulative expected reward over some number of rounds, or equivalently minimise her cumulative \emph{regret} - defined as the difference in expected reward between optimal actions and actions actually selected. To succeed in this the agent must manage an exploration-exploitation trade-off as she learns which actions have high expected reward. The CMAB problem models a richer framework where the agent may select multiple actions in each round and her reward is a function of the observations from the underlying distributions associated with the selected actions. Chen et al. consider a setting where this function may be non-linear. Numerous authors (\cite{Anantharam1987i}, \cite{Gai2012}, \cite{Kveton2015tight}, \cite{Combes2015}, and \cite{Luedtke2016}) consider a special case (known as a \emph{multiple play bandit}) where the reward is simply a sum of the random observations and the number of actions which may be selected in one round is limited. A number of other works have since extended the framework of \cite{Chen2013} to model other novel features. \cite{Chen2016a} and \cite{Kveton2015cascading} consider a setting where playing a subset of arms may randomly trigger additional rewards from other arms, and \cite{Chen2016b} considers a broader set of non-linear reward functions. However the CMAB model and UCB approach of \cite{Chen2013} is the work closest to ours as the later developments model features that are not present in our setting. Reward maximisation in a CMAB problem requires addressing a similar exploration-exploitation trade-off to that faced in the MAB problem. For MAB-type problems, it has famously been shown that under certain assumptions optimal policies can be derived by formulating the problem as a Markov Decision Process and using an index approach \citep{Gittins2011}. In CMAB problems however, these approaches are inappropriate, not least, since the combinatorial action sets induce dependencies between rewards generated by distinct actions which invalidates Gittins' theory. See also Remark 1 in Section 2. More recently, so called upper confidence bound (UCB) algorithms, first proposed by \cite{Lai1985asymptotically} and \cite{Burnetas1996optimal}, and popularised by \cite{Auer2002}, have attracted much attention as approaches that enjoy efficient implementation and strong theoretical guarantees. These heuristic methods balance exploration and exploitation by selecting actions based on optimistic estimates of the associated expected rewards and can be applied to both MAB and CMAB problems. Auer et al. originally proposed a UCB approach for MAB problems with underlying distributions whose support lies entirely within $[0,1]$. \cite{Chen2013} extended the principles of this algorithm to a version suitable for CMAB problems with nonlinear rewards. Broader classes of unbounded distributions have been considered by other authors. \cite{Cowan2015Normal}, \cite{Bubeck2012}, \cite{Bubeck2013}, and \cite{Lattimore2017} give UCB algorithms suitable for use with unbounded distributions, studying distributions that are Gaussian, have sub-Gaussian tails, known variance and known kurtosis respectively. \cite{Luedtke2016} have studied multiple-play bandits with exponential family distributions. However for CMAB problems with non-linear reward functions attention has focussed on the $[0,1]$ case. Accompanying each of these proposals of UCB algorithms is a corresponding proof which demonstrates the performance of that algorithm achieves the optimal order, albeit with a sub-optimal coefficient. Stronger performance guarantees (i.e. those with improved leading-order coefficients) have been obtained in MAB problems using Thompson Sampling type approaches \citep{Kaufmann2012thompson,Agrawal2012,Russo2016} and approaches which utilise the KL divergence of the reward distributions \citep{Cappe2013,Kaufmann2016}. \cite{Combes2015} have successfully extended the KL divergence based results to multiple play bandits with bounded rewards. However extending these results to the more general CMAB problem with non-linear rewards presents a significant analytical challenge, and therefore in this work we focus on the analysis of a UCB type approach. \subsection{Key Contributions} This work makes a number of contributions to the theory of optimal search, multi-armed bandits and broader online optimisation. Simultaneously we give a practically useful solution to a real problem in perimeter surveillance. We summarise the headline contributions below: \begin{itemize} \item Introduction of a formal model for sequential, multi-searcher perimeter surveillance problems and an efficient integer programming solution to the full-information version of the problem; \item Introduction of the \emph{filtered feedback} model for combinatorial multi-armed bandits; \item Development of a bespoke treatment of combinatorial bandits with \emph{Poisson} rewards, leading to a new concentration inequality for filtered Poisson data; \item Regret analysis leading to an optimal order analytical bound on finite time regret of the UCB algorithm and a problem-specific lower bound on asymptotic regret for any uniformly good algorithm. \end{itemize} We also present extensive numerical work which displays the robustness of the UCB approach and the unpredictable performance of Thompson Sampling. \subsection{Paper Outline} The remainder of the paper is structured as follows. Section \ref{subsec::model} introduces a model of the sequential problem. In Section \ref{sec::full_info} we solve the full information problem (the non-sequential perimeter surveillance problem where the rate function of the arrival process is known). The proposed integer programming solution forms the backbone of the proposed solution methods for the sequential problem. In Section \ref{sec::seq_learn} we introduce a solution method for the sequential resource allocation problem, FP-CUCB, and derive a performance guarantee in the form of an upper bound on expected regret of the policy. Here, we also derive a lower bound on the expected regret possible for any policy and thus show that our algorithm has a bound of the correct order. We conclude in Sections \ref{sec::numerics} and \ref{sec::discussion} with numerical experiments and a discussion respectively. \section{The Model} \label{subsec::model} Before introducing solution methods we give a mathematical model of the problem. Throughout the paper, for a positive integer $\Omega$ let the notation $[\Omega]$ represent the set $\{1,2,...,\Omega\}$. A domain of search (perimeter) comprises $K$ cells while searches are conducted by $U$ agents. We write \begin{displaymath} a_k = u, \quad k \in [K], \enspace u\in [U] \end{displaymath} to denote the deployment of agent $u$ to search cell $k$, while \begin{displaymath} a_k =0, \quad k \in [K] \end{displaymath} is used when cell $k$ goes unsearched. An \emph{action} $\mathbf{a} := (a_1,a_2,...,a_K) \in \{0,1,...U\}^K$ describes a deployment of the agents across the perimeter. We impose the requirement that $\mathbf{a} \in \mathcal{A}$, the \emph{action set}, where \begin{displaymath} \mathcal{A}=\{\mathbf{a} : \enspace a_i=a_j=u \Rightarrow a_k=u, \enspace i \leq k \leq j \enspace \forall i <j, u \in [U]\}. \end{displaymath} These conditions on $\mathcal{A}$ ensure that agents are assigned to disjoint connected sub-regions of the perimeter. This constraint eliminates unnecessary travel times for the agents and the possibility of multiple agents detecting the same event. The actions are uniquely defined by indicator variables \begin{displaymath} a_{iju}=1 \Leftrightarrow \text{agent } u \text{ is assigned to the cells } \{i,i+1,...,j\} \text{ only.} \end{displaymath} Each action $\mathbf{a} \in \mathcal{A}$ gives rise to a certain detection probability $\gamma_k(\mathbf{a}) \in [0,1]$ in each cell $k \in [K]$. The detection probabilities capture the effectiveness of each searcher in finding an intruder in a specific cell. We write $\boldsymbol\gamma(\mathbf{a})$ for the $K$-vector whose $k^{th}$ component is $\gamma_k(\mathbf{a})$. The detection probabilities are structured such that for any $\mathbf{a}, \mathbf{b} \in \mathcal{A}$ and $i \leq j$, \begin{displaymath} a_{iju}=b_{iju}=1 \Rightarrow \gamma_k(\mathbf{a})=\gamma_k(\mathbf{b}), \enspace \forall k \text{ such that } i \leq k \leq j. \end{displaymath} Hence, the detection probability in a cell depends only on the sub-region assigned to the single agent searching that cell and is unaffected by the sub-regions assigned to other agents. We assume that if a cell is searched there will be some non-zero probability of detecting intrusions that occur. That is to say $\gamma_k(\mathbf{a})>0$ for any $\mathbf{a} \in \mathcal{A}: a_k \neq 0$ for any $k \in [K]$. We consider two cases with respect to knowledge of the detection probabilities: \begin{enumerate} \item[(I)] The detection probabilities $\boldsymbol\gamma(\mathbf{a})$ are known for all $\mathbf{a} \in \mathcal{A}$. This scenario occurs when the agent knows $\boldsymbol\gamma(\mathbf{a})$ from the past. \item[(II)] The functions $\boldsymbol\gamma$ have a particular known parametric form but unknown parameter values. This case is realistic when properties of the detection probabilities are dictated by physical considerations, such as the searchers' speed or the time it takes intruders to cross the perimeter. \end{enumerate} Our sequential decision problem may now be described as follows: \begin{enumerate} \item At each time $t \in \mathbb{N}$ an action $\mathbf{a}_t \in \mathcal{A}$ is taken, inducing a detection probability $\gamma_k(\mathbf{a}_t)$ in each cell $k \in [K]$; \item Intrusion events are generated by $K$ independent Poisson processes, one for each cell. We use $X_k$ to denote the number of events in cell $k$ (whether observed or not) occurring during the period of a single search. We have \begin{displaymath} X_k \sim Pois(\lambda_k), \enspace k \in [K] \end{displaymath} where the rates $\lambda_k \in \mathbb{R}_{+}$ are unknown, and write $\lambda_{max} \geq \max_{k \in [K]} \lambda_k$ for a known upper bound on the arrival rates. We use $X_{kt}$ for the number of events generated in cell $k$ during search $t$. \item Should action $\mathbf{a}_t$ be taken at time $t$, a random vector of events $\mathbf{Y}_t = \{Y_{1t},Y_{2t},...,Y_{Kt}\} \in \mathbb{N}^K$ is observed. Events in the underlying $X$-process are observed or not independently of each other. We write \begin{displaymath} Y_{kt} | X_{kt}, \mathbf{a}_t \sim Bin(X_{kt},\gamma_k(\mathbf{a}_t)), \enspace k \in [K]. \end{displaymath} It follows from standard theory that \begin{displaymath} Y_{kt}|\mathbf{a}_t \sim Pois(\lambda_k\gamma_k(\mathbf{a}_t)), \enspace k\in [K], \end{displaymath} and are independent random variables. It follows that the mean number of events observed under action $\mathbf{a}$ is given by \begin{displaymath} r_{\boldsymbol\lambda, \boldsymbol\gamma}(\mathbf{a}) := \boldsymbol\gamma(\mathbf{a})^T\boldsymbol\lambda, \end{displaymath} where $T$ denotes vector transposition and $\boldsymbol\lambda$ is the $K$-vector whose $k^{th}$ component is $\lambda_k$. \item We write \begin{displaymath} \mathbf{H}_t=\{\mathbf{a}_1,\mathbf{Y}_1,...,\mathbf{a}_{t-1},\mathbf{Y}_{t-1}\} \end{displaymath} for the \emph{history} (of actions taken and events observed) available to the decision-maker at time $t \in \mathbb{N}$. A \emph{policy} is a rule for decision-making and is determined by some collection of functions $\big\{\pi_t: \mathbf{H}_t \rightarrow \mathcal{A}, t \in \mathbb{N} \big\}$ adapted to the filtration induced by $\mathbf{H}_t$. In practice a policy will be determined by some algorithm $A$. We will use the terms policy and algorithm interchangeably in what follows. \end{enumerate} The goal of analysis is the elucidation of policies whose performance (as measured by the mean number of events observed) is strong uniformly over $\boldsymbol\lambda, \boldsymbol\gamma$ and over partial horizons $\{1,2,...,n\} \subseteq \mathbb{N}$. We write \begin{displaymath} \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg) \end{displaymath} for the mean number of events observed up to time $t \in \mathbb{N}$ under algorithm $A$. If we write \begin{displaymath} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} := \max_{\mathbf{a} \in \mathcal{A}} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \end{displaymath} then it is plain that, for any choice of $A$ \begin{displaymath} n \cdot \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} \geq \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg), \end{displaymath} with achievement of the left hand side dependent on knowledge of $\boldsymbol\lambda$. Assessment of algorithms will be based on the associated \emph{regret function}, the expected reward lost through ignorance of $\boldsymbol\lambda$, given for algorithm $A$ and horizon $n$ by \begin{equation} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^A(n) := n \cdot \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} - \mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg), \label{eq::regret} \end{equation} which is necessarily positive and nondecreasing in $n$, for any fixed $A$. In related bandit-type problems the regret of the best algorithms typically grows at $O(\log(n))$ uniformly across all $\boldsymbol\lambda$. We will demonstrate both that this is also the case for the algorithms we propose and that the best achievable growth for this problem is also $O(\log(n))$. \begin{remark} An alternative, indeed classical, formulation uses Bayes sequential decision theory. Here the goal of analysis is the determination of an algorithm $A$ to maximise \begin{displaymath} \mathds{E}_\rho \Bigg[\mathds{E}_A\bigg(\sum_{t=1}^n r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}_t)\bigg) \Bigg] \end{displaymath} where the outer expectation is taken over some prior distribution $\rho $ for the unknown $\boldsymbol\lambda$. A standard approach would formulate this as a Markov Decision Process (MDP) with an informational state at time $t$ taken to be some sufficient statistic for $\boldsymbol\lambda$. The objections to this approach in this context are many. First, any serious attempt to derive such a formulation which is likely tractable will require strong assumptions on the prior $\rho $ including, for example, independence of the components of $\boldsymbol\lambda$. These would each typically have a conjugate gamma prior. Even then the resulting dynamic program would be computationally intractable for any reasonable choices of $K$ and $n.$ Second, the realities of our problem (and, indeed, many others) are such that specification of any reasonably informed prior is impractical. Confidence in the analysis would inevitably require robustness of the performance of any proposed algorithm to specification of the prior. Indeed, our formulation centred on regret simply seeks robustness of performance with respect to values of the unknown $\boldsymbol\lambda$. Third, the MDP approach would require up front specification of the decision horizon $n.$ This is practically undesirable for our problem. Moreover, the value of $n$ is not unimportant. It will determine the nature of good policies in important ways. For example, the ``last'' decision at time $n$ is guaranteed to be optimally ``greedy'' since there is no further need to learn about $\boldsymbol\lambda$ at that point. \end{remark} \section{The Full Information Problem} \label{sec::full_info} In order to develop strongly performing policies, it is critical that we are able to solve the \emph{full information} optimisation problem \begin{displaymath} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} := \max_{\mathbf{a} \in \mathcal{A}} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \end{displaymath} for any pre-specified $\boldsymbol\lambda \in (\mathds{R}_+)^K$. A naive proposal for a policy addressing the problem outlined in the previous section would choose an action $\mathbf{a}_t$ at time $t$ to solve the full information problem for some estimate $\boldsymbol\lambda_t$ of the unknown $\boldsymbol\lambda$ available at time $t$. While such a proposal would fail to adequately address the challenge of learning about $\boldsymbol\lambda$, we will in the succeeding sections develop effective algorithms which choose allocations determined by solutions of full information problems for carefully chosen $\boldsymbol\lambda$-values. A challenge to the solution of the full information problem is the non-linearity in $\mathbf{a}$ of the objective $r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a})$ inherited from the non-linearity of the detection mechanism $\boldsymbol\gamma(\mathbf{a})$. To develop efficient solution approaches we produce a formulation as a linear integer program (IP) in which this non-linearity is removed by precomputing key quantities. In particular we write \begin{displaymath} q_{\boldsymbol\lambda,\boldsymbol\gamma,iju} = \sum_{k=i}^j \gamma_k(\mathbf{a}_{iju})\lambda_k \end{displaymath} for the mean number of events detected when agent $u$ is allocated to the subregion $\{i,i+1,...,j\}$ where $\mathbf{a}_{iju}$ is any $\mathbf{a} \in \mathcal{A}$ such that $a_{iju}=1$. Efficient solution of the full information problem relies on precomputing these $q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}$ for all $1 \leq i \leq j \leq K$, and $u \in [U]$. We now have that \begin{align} \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}=\max_{\{a_{iju}, 1\leq i \leq j \leq K, u \in [U]\}}\sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}a_{iju}& \label{eq::IP}\\ \text{such that } \quad \sum_{i=1}^K \sum_{j=i}^K a_{iju} \leq &1, \enspace u \in [U] \nonumber \\ \sum_{i=1}^k \sum_{j=k}^K \sum_{u=1}^U a_{iju} \leq &1, \enspace k \in [K] \nonumber \\ a_{iju} \in &\{0,1\}, \enspace 1 \leq i \leq j \leq K, \enspace u \in [U]. \nonumber \end{align} The first constraint above guarantees that each agent $u$ is assigned to at most one sub-region while the second constraint guarantees that each cell $k$ is searched by at most one agent. We view the solution of (\ref{eq::IP}) as the optimal allocation strategy and the optimal value function as the best achievable performance for an agent with perfect knowledge of $\boldsymbol\gamma$ and $\boldsymbol\lambda$. When we require solutions to the full information problem for the implementation of algorithms for the problem described in the preceding section, we solve an appropriate version of the above IP (ie, for suitably chosen $\boldsymbol\lambda$) by means of branch and bound. While it can be shown that the IP (\ref{eq::IP}) belongs to a class of problems which is NP-hard (see Appendix \ref{app:NPhard}) we find that the solution of this IP is very efficient in practice. We believe that this is because the solution of the LP-relaxation of (\ref{eq::IP}) often coincides with the exact solution of the IP. Indeed, in empirical tests this occurred more than 90\% of the time and in the remaining instances the gap between the two solutions was always less that 1\%. For all problem sizes considered in this paper the pre-processing and solution steps can be completed in less than a second using basic linear program solvers in the statistical programming language \texttt{R} on a single laptop. \section{Sequential Problem} \label{sec::seq_learn} In the sequential problem, the controller's objective is to minimise regret (\ref{eq::regret}) over a sequence of rounds. To do so the controller must construct a strategy which balances exploring all cells to accurately estimate the underlying rate parameters $\boldsymbol\lambda$, while also exploiting the information gained to detect as many events as possible. In this section we introduce and analyse two upper confidence bound (UCB) algorithms as policies for the case of fully known detection probabilities (case (I)) and the case where only the nature of the scaling of detection probabilities is known (case (II)). The model we introduced in Section \ref{subsec::model} is closely related to the \emph{Combinatorial Multi Armed Bandit problem} (CMAB) model of \cite{Chen2013}. The CMAB problem models a scenario where a decision-maker is faced with a set of $K$ basic actions (or \emph{arms}) each associated with a random variable of unknown probability distribution. In each round $t \in \mathbb{N}$, the decision-maker may select a subset of basic actions to take (or \emph{arms to pull}) and receives a \emph{reward} which is a (possibly randomised) function of realisations of the random variables associated with the selected basic actions. The decision-maker's aim is to maximise her cumulative reward over a given horizon. Chen et al. study a CMAB problem where the decision-maker receives \emph{semibandit feedback} on her actions, meaning she observes the overall reward but also all realisations of the random variables associated with the selected arms. Realisations of the random variables are identically distributed for a given arm and independent both across time and arms. In our surveillance problem, electing to search a cell $k$ in a round $t$, i.e. setting $a_{kt} \neq 0$, is the analogue of pulling an arm $k$. The total number of events detected in a round is the analogue of reward. The fundamental, and non-trivial difference between our model and that of Chen et al. lies in the feedback mechanism. Our framework is more complex in two important of regards. Firstly, we do not by default observe independent identically distributed (i.i.d.) realisations of the underlying random variable of interest $X_{kt}$ each time we elect to search a cell. We observe a \emph{filtered observation} $Y_{kt}$ whose distribution depends on the action $\mathbf{a}_t$ selected in that round. A second related point is that because of the $U$ possibly heterogeneous searchers, we can have multiple ways of searching the same collection of cells. While this is implicitly permitted within the framework of Chen et al., it is not explicitly acknowledged nor to the best of our knowledge are any real problems with such a structure explored in related work . Our analytical challenge is to extend earlier work in order to meet these novel features. Specifically we will propose a UCB algorithm for both cases of our problem and derive upper bounds on the expected regret of these policies. UCB algorithms apply the principle of \emph{optimism in the face of uncertainty} to sequential decision problems. Such an algorithm calculates an \emph{index} for each action in each round which is the upper limit of a high probability confidence interval on the expected reward of that action and then selects the action with the highest index. In this way the algorithm will select actions which either have high indices due to a large mean estimate - leading it to exploit what has been profitable so far - or due to a large uncertainty in the empirical mean - leading it to explore actions which are currently poorly understood. As the rounds proceed, the confidence intervals will concentrate on the true means and less exploratory actions will be selected in favour of exploitative ones. \subsection{Case (I): Known detection probabilities} \label{sec::known_gammas} In our first version of the problem, case (I), the only unknowns are the underlying rate parameters $\boldsymbol\lambda$. We assume that detection probability vectors $\boldsymbol\gamma(\mathbf{a})$ are known for all $\mathbf{a} \in \mathcal{A}$. Therefore we do not need to explicitly form UCB indices for every action separately. It will suffice to form a UCB index on each unknown $\lambda_k$ for $k \in [K]$. Optimistic estimates of the value of each action will then arise by calculating the $q_{\boldsymbol\lambda,\boldsymbol\gamma,iju}$ quantities with the optimistic estimate of $\boldsymbol\lambda$ in place of known $\boldsymbol\lambda$. Our proposed approach to the sequential search problem in case (I), the FP-CUCB algorithm (Filtered Poisson - Combinatorial Upper Confidence Bound), is given as Algorithm \ref{alg::FPCUCB}. The algorithm consists of an initialisation phase of length $K$ where allocations are selected such that every cell is searched in some capacity at least once. Then in every subsequent round $t>K$, a UCB index $\bar{\lambda}_{k,t}$ is calculated for each cell $k$ as the sum of an empirical mean for filtered data and an appropriate inflation term. An action which is optimal with respect to the $K$-vector of inflated rates $\bar{\boldsymbol\lambda}_t=(\bar{\lambda}_{1,t},...,\bar{\lambda}_{K,t})$ is then selected by solving the IP (\ref{eq::IP}) with $\bar{\boldsymbol\lambda}_t$ in place of $\boldsymbol\lambda$. The inflation terms involve a parameter $\lambda_{max} \geq \max_{k \in [K]} \lambda_k$. This is necessary to construct UCBs which concentrate at a rate that matches the concentration of Poisson random variables, which is defined by the mean parameter. \begin{algorithm}[] \vspace{0.1cm} \caption{FP-CUCB (case (I))} \label{alg::FPCUCB} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Upper bound $\lambda_{max} \geq \lambda_k, \enspace k \in [K]$. \textbf{Initialisation Phase:} For $t \in [K]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t \neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=K+1,K+2,...$ \begin{itemize} \item Calculate indices \begin{equation} \bar{\lambda}_{k,t}= \frac{\sum_{s=1}^{t-1}Y_{k,s}}{\sum_{s=1}^{t-1}\gamma_{k,s}}+\frac{2\log(t)}{\sum_{s=1}^{t-1}\gamma_{k,s}}+\sqrt{\frac{6\lambda_{max}\log(t)}{\sum_{s=1}^{t-1}\gamma_{k,s}}}, \enspace k \in [K] \label{eq::FPCUCBI_indices} \end{equation} \item Select an allocation $\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t}$ such that $r_{\bar{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\bar{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} To analyse the regret of this algorithm we must first introduce some additional notation for \emph{optimality gaps}, the differences in expected reward between optimal and suboptimal actions. For $k \in [K]$ define, \begin{align*} \Delta_{max}^k&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\min_{\mathbf{a} \in \mathcal{A}_k}r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \\ \Delta_{min}^k&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\max_{\mathbf{a} \in \mathcal{A}_k}r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}), \end{align*} where $\mathcal{A}_k=\{\mathbf{a} \in \mathcal{A}: a_k \neq 0\}$ for $k \in [K]$, and $\Delta_{max}=\max_{k \in [K]}\Delta^k_{max}$, and $\Delta_{min}=\min_{k \in [K]} \Delta^k_{min}$. The quantity $\Delta_{max}$ is then the difference in expected reward between an optimal allocation of searchers and the worst possible allocation, while $\Delta_{min}$ is the difference in expected reward between an optimal allocation and the closest to optimal suboptimal allocation. The quantities $\Delta^k_{max}$ and $\Delta^k_{min}$ are the largest and smallest gaps between the expected reward of an optimal allocation and allocations where cell $k$ is searched in some capacity. All $\Delta$ terms depend on $\boldsymbol\lambda, \boldsymbol\gamma$ but we drop this dependence in the notation for simplicity. Now, in Theorem \ref{thm::FPCUCB} we provide an analytical bound on the expected regret of the {FP-CUCB} algorithm in $n$ rounds. \begin{theorem} \label{thm::FPCUCB} The regret of the FP-CUCB algorithm with $\lambda_{max}$ applied to the sequential surveillance problem with known $\boldsymbol\gamma$ satisfies \begin{align} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^{\text{FP-CUCB}}(n) &\leq \sum_{k:\Delta_{min}^k>0}\frac{12K^2}{\gamma_{k,min}} \Bigg[ \frac{b(\Delta^k_{min})}{\Delta_{min}^k} + \int_{\Delta_{min}^k}^{\Delta_{max}^k} \frac{b(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)K\Delta_{max}, \label{eq::FPCUCBBound} \end{align} where $b(x)=\lambda_{max} + \sqrt{\lambda_{max}^2 + x^2/9K^2}$, and $\gamma_{k,min}=\min_{\mathbf{a}:a_k \neq 0} \gamma_k(\mathbf{a})$. \end{theorem} \subsubsection{Proving Theorem \ref{thm::FPCUCB}} To give a proof of this theorem we must introduce a new way of thinking about the action space. Consider that while we have previously (for ease of exposition) defined actions in terms of allocations of searchers to cells, $\mathbf{a} \in \mathcal{A}$, the real impact on the observations comes from the vectors of detection probabilities, $\boldsymbol\gamma(\mathbf{a})$, which arise from these allocations. As multiple allocations may give rise to the same vector of detection probabilities (if, for instance, two searchers have identical capabilities, then switching their assignments would have no impact on the quality of the search) the set $\mathcal{G} = \{\boldsymbol\gamma(\mathbf{a}), \enspace \forall \mathbf{a} \in \mathcal{A}\}$ of possible detection probability vectors most parsimoniously describes the set of possible actions in this problem. For an element $\mathbf{g}=(g_1,...,g_k)=\mathcal{G}$ we then have expected reward $\mathbf{g}^T\cdot \boldsymbol\lambda$ and optimality gap $\Delta_{\mathbf{g}}=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\mathbf{g}^T \cdot \boldsymbol\lambda$. Let $\mathcal{G}_k$ be the set of vectors $\mathbf{g}$ with $g_k>0$ and $\mathcal{G}_{k,B}$ be the set of vectors in $\mathcal{G}_k$ with sub-optimal expected reward - i.e. $\mathcal{G}_{k,B}=\{\mathbf{g} \in \mathcal{G}_k: \Delta_{\mathbf{g}}>0\}$. Let $B_k=|\mathcal{G}_{k,B}|$ and label the vectors in $\mathcal{G}_{k,B}$ as $\mathbf{g}^1_{k,B},\mathbf{g}^2_{k,B},...,\mathbf{g}^{B_k}_{k,B}$ in increasing order of expected reward. We use the following notation for optimality gaps with respect to these ordered vectors \begin{equation} \Delta^{k,j} = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} - (\mathbf{g}^j_{k,B})^T \cdot \boldsymbol\lambda \quad j \in [B_k], \enspace k \in [K] \end{equation} and thus the gaps defined previously can be expressed as $\Delta_{max}^k = \Delta^{k,1}$ and $\Delta_{min}^k = \Delta^{k,B_k}$. We introduce counters $D_{k,t}=\sum_{s=1}^t g_{k,s}$ for $k \in [K]$, $t \in \mathbb{N}$ where $\mathbf{g}_s$ is the detection probability vector selected in round $s$. These allow us to keep track of the total detection probability \emph{applied} to a cell up to the end of round $t$. The central idea in proving Theorem \ref{thm::FPCUCB} is that if for a certain sub-optimal action $\mathbf{g}: \Delta_{\mathbf{g}}>0$, all the cells $k$ with $g_k>0$ have been sampled sufficiently, the mean estimates ought to be accurate enough that the probability of selecting that sub-optimal action again before horizon $n$ is small. We show that this sufficient sampling level is $O(\log(n))$ and the ``small" probabilities of selecting the sub-optimal action after sufficient sampling are so small as to converge to a constant. Thus by re-expressing expected regret as a function of the number of plays of sub-optimal actions, we can bound it from above as the sum of a $O(\log(n))$ term derived from the sufficient sampling level and a constant independent of $n$. To count the plays of sub-optimal actions we maintain counters $N_{k,t}$, which collectively count the number of suboptimal plays. We update them as follows. Firstly, after the $K$ initialisation rounds we set $N_{k,K}=1$ for $k \in [K]$. Thereafter, in each round $t >K$, let $k'=\arg\min_{j:g_{j,t}>0}N_{j,t-1}$, where if $k'$ is non-unique, we choose a single value randomly from the minimising set. If $\mathbf{g}_t^T\cdot \boldsymbol\lambda \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}$ then we increment $N_{k'}$ by one, i.e. set $N_{k',t}=N_{k',t-1}+1$. The key consequences of these updating rules are that $\sum_{k=1}^K N_{k,t}$ provides an upper bound on the number of suboptimal plays in $t$ rounds, and $D_{k,t} \geq \gamma_{k,min}N_{k,t}$ for all $k$ and $t$. \\ {Proof of Theorem \ref{thm::FPCUCB}} We prove the theorem by decomposing regret into a function of the number of plays of suboptimal arms, up to and after some sufficient sampling level. We then introduce two propositions which give bounds for quantities in the decomposition which are then combined to give the bound in (\ref{eq::FPCUCBBound}). The proofs of these propositions is reserved for Appendix \ref{Theorem1Proof}. Let $N_{k,t}^{l,suf}, N_{k,t}^{l,und}$ for $l \in [B_k]$ be counters associated with elements of $\mathcal{G}_{k,B}$ for $k \in [K]$. These counters are defined as follows: \begin{align} N_{k,n}^{l,suf} &= \sum_{t=K+1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}> h_{k,n}(\Delta^{k,l})\}, \label{Beyond Sufficiency Counter} \\ N_{k,n}^{l,und} &= \sum_{t=K+1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}\leq h_{k,n}(\Delta^{k,l})\}, \label{Under Sufficiency Counter} \end{align} where $h_{k,n}(\Delta)=12b(\Delta) \frac{\log(n)K^2}{\gamma_{k,min}\Delta^2}$. A cell $k$ is said to be \emph{sufficiently} sampled with respect to a choice of detection probabilities $\mathbf{g}_{k,B}^l$ if $N_{k,t-1} > h_{k,n}(\Delta^{k,l})$, and thus $N_{k,n}^{l,und},N_{k,n}^{l,suf}$ count the suboptimal plays leading to incrementing $N_{k,n}^l$ up to and after the sufficient level, respectively. From the definitions (\ref{Beyond Sufficiency Counter}) and (\ref{Under Sufficiency Counter}) we have $N_{k,n}=1+\sum_{l=1}^{B_k} (N_{k,n}^{l,suf}+N_{k,n}^{und})$. The expected regret at time horizon $n$ can also be bounded above using this notation as \begin{equation} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}(n) \leq \mathds{E}\Bigg[\sum_{k=1}^K \Bigg(\Delta^{k,1} + \sum_{l=1}^{B_k}(N_{k,n}^{l,suf}+N_{k,n}^{l,und})\cdot \Delta^{k,l}\Bigg)\Bigg] \label{eq::regret_decomposition} \end{equation} where $\Delta^{k,1}$ arises as a worst case view of the initialisation. We can derive an analytical bound on regret by bounding the expectations of the random variables in (\ref{eq::regret_decomposition}). Firstly, for the beyond sufficiency counter we have \begin{proposition} \label{prop::FPCUCBsuff} For any time horizon $n>K$, \begin{equation} \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Bigg) \leq \frac{\pi^2}{3}\cdot K. \label{eq::prop1} \end{equation} \end{proposition} The full proof of Proposition \ref{prop::FPCUCBsuff} is given in Appendix \ref{Theorem1Proof}, but in particular depends on the following Lemma describing the concentration of filtered Poisson data. \begin{lemma} \label{lem::FPCUCBconc} For any set of independent Poisson random variables $Y_{1},...,Y_{s}$ with means $\gamma_{1}\mu,...\gamma_{s}\mu$ respectively, and parameters $t\geq s$ and $\mu_{max} \geq \mu$ the following holds: \begin{equation} \mathds{P}\bigg(\bigg|\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}}-\mu\bigg| \geq \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \leq 2t^{-3}. \label{FPCUCBconc} \end{equation} \end{lemma} The consequence of this Lemma is that the UCB indices (\ref{eq::FPCUCBI_indices}) are of the correct form to guarantee that the probability of making suboptimal plays beyond the sufficient sampling level is small. We provide a proof of Lemma \ref{lem::FPCUCBconc} in Appendix \ref{proof::concresult}. For the under sufficiency counter we have the following proposition, also proved in Appendix \ref{Theorem1Proof}, \begin{proposition} \label{prop::FPCUCBund} For any time horizon $n>K$ and $k:\Delta^k_{min}>0$, \begin{equation} \sum_{l=1}^{B_k} N_{k,n}^{l,und}\Delta^{k,l} \leq h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx. \label{eq::prop2} \end{equation} \end{proposition} Combining the decomposition (\ref{eq::regret_decomposition}), with the bounds (\ref{eq::prop1}) and (\ref{eq::prop2}) we have \begin{align*} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}(n) &\leq \mathds{E}\bigg(\sum_{k=1}^K \Big(\Delta^{k,1}+\sum_{l=1}^{B_k}(N_{k,n}^{l,suf}+N_{k,n}^{l,und})\Delta^{k,l}\Big)\bigg) \\ &= \mathds{E}\Bigg(\sum_{k=1}^K\bigg(\Delta^{k,1} + \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Delta^{k,l}\bigg)\Bigg) + \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,und}\Delta^{k,l}\Bigg) \\ &\leq K\Delta_{max} + \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Delta^{k,l}\Bigg) + \sum_{k:\Delta_{min}^k>0} \bigg(h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx\bigg) \\ &\leq \Big(\frac{\pi^2}{3}+1\Big)K \Delta_{max} + \sum_{k:\Delta_{min}^k>0} \bigg(h_{k,n}(\Delta^{k}_{min})\Delta^{k}_{min} + \int_{\Delta^{k}_{min}}^{\Delta^{k}_{max}} h_{k,n}(x)dx\bigg) \\ &=\sum_{k:\Delta_{min}^k>0}\frac{12K^2}{\gamma_{k,min}} \Bigg[ \frac{b(\Delta^k_{min})}{\Delta_{min}^k} + \int_{\Delta_{min}^k}^{\Delta_{max}^k} \frac{b(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)K\Delta_{max}. \quad \square \end{align*} In the remainder of this section we show that the bound obtained in Theorem \ref{thm::FPCUCB} is of optimal order, by deriving a lower bound on the expected regret of the best possible policies. \subsubsection{Lower Bound on Regret} \label{sec::regret_lower_bound} To analyse the performance of the best possible policies, we introduce the notion of a \emph{uniformly good policy}. A uniformly good policy \citep{Lai1985asymptotically} is one where \begin{displaymath} \mathds{E}\bigg(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t=\mathbf{g} \} \bigg) = o(n^\alpha) \quad \forall \enspace \alpha >0 \end{displaymath} for every $\mathbf{g}: \Delta_{\mathbf{g}}>0$ and every $\boldsymbol\lambda \in \mathbb{R}_+^K$. Clearly, then all uniformly good policies must eventually favour optimal actions over suboptimal ones - with the suboptimal actions being necessary to accurately estimate $\boldsymbol\lambda$. For a given rate vector $\boldsymbol\lambda$ we define the set of optimal actions as \begin{displaymath} J(\boldsymbol\lambda)=\{\mathbf{g}\in\mathcal{G}:\enspace \mathbf{g}^T\cdot\boldsymbol\lambda=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}\}. \end{displaymath} We write $S(\boldsymbol\lambda)=\mathcal{G}\setminus J(\boldsymbol\lambda)$ to be the set of suboptimal actions. The difficulty of a particular problem depends on the particular configuration of $\boldsymbol\lambda$ and $\boldsymbol\gamma$. We define \begin{displaymath} \mathcal{I}(\boldsymbol\lambda)= \{k: \enspace \exists \text{ } \mathbf{g} \in J(\boldsymbol\lambda) \text{ s.t. } g_k >0\} \end{displaymath} as the set of arms which are played in at least one optimal action and \begin{displaymath} B(\boldsymbol\lambda)=\{\boldsymbol\theta \in \mathbb{R}_+^K : \enspace \mathbf{g}^T \cdot \boldsymbol\theta < \text{opt}_{\boldsymbol\theta,\boldsymbol\gamma} \enspace \forall \mathbf{g} \in J(\boldsymbol\lambda) \enspace \text{ and } \enspace \theta_k = \lambda_k \enspace \forall k \in \mathcal{I}(\boldsymbol\lambda)\} \end{displaymath} as the set of mean vectors such that all actions in $J(\boldsymbol\lambda)$ are suboptimal but this cannot be discerned by playing only actions in $J(\boldsymbol\lambda)$. The larger the set $B(\boldsymbol\lambda)$, the more challenging the problem is. If $\mathcal{I}(\boldsymbol\lambda)=[K]$, then the problem is trivial as one can simultaneously play optimal actions and gather the information necessary to affirm that these actions are optimal. In such a case the lower bound on expected regret is simply 0. We have the following lower bound on regret for any uniformly good policy. A key consequence of this result is the assertion that policies with $O(\log(n))$ regret are indeed of optimal order and thus that the regret induced by the FP-CUCB algorithm in case (I) grows at the lowest achievable rate. This result is analogous to results in other classes of bandit problem as shown by \cite{Lai1985asymptotically} and \cite{Burnetas1996optimal}. \begin{theorem} \label{thm::lower_bound} For any $\boldsymbol\lambda \in \mathds{R}_+^K$ such that $B(\boldsymbol\lambda)\neq \emptyset$, and for any uniformly good policy $\pi$ for the sequential surveillance problem with known $\boldsymbol\gamma$, we have \begin{equation} \lim \inf_{n \rightarrow \infty} \frac{Reg^\pi_{\boldsymbol\lambda,\boldsymbol\gamma}(n)}{\log(n)} \geq c(\boldsymbol\lambda) \end{equation} where $c(\boldsymbol\lambda)$ is the optimal value of the following optimisation problem \begin{align} \inf_{\mathbf{d}\geq \mathbf{0}} \sum_{\mathbf{g} \in S(\boldsymbol\lambda)} d_{\mathbf{g}}\Delta_{\mathbf{g}} & \label{eq::lb_opt_objective}\\ \text{such that } \inf_{\boldsymbol\theta \in B(\boldsymbol\lambda)} \sum_{\mathbf{g} \in S(\boldsymbol\lambda)} d_{\mathbf{g}} \sum_{k=1}^K g_k kl(\lambda_k,\theta_k) &\geq 1. \label{eq::lb_opt_constraint} \end{align} and $\text{kl}(\lambda,\theta)=\lambda\log(\frac{\lambda}{\theta})+\theta-\lambda$ is the Kullback Leibler divergence between two Poisson distributions with mean parameters $\lambda$, $\theta$ respectively. \end{theorem} We prove this theorem fully in Appendix \ref{proof::lower_bound}, but here note that a key step of its proof is to invoke Theorem 1 of \cite{Graves1997}, which is a similar result for a more general class of controlled Markov Chains. It is possible to derive an analytical expression giving a lower bound on $c(\boldsymbol\lambda)$ by following steps similar to those in the proof of Theorem 2 in \cite{Combes2015}. However we omit this here because in the interests of succinctness as it is not an especially useful or elegant expression. \subsection{Case (II): Known scaling of detection probabilities} \label{sec::unknown_gammas} In the second case we suppose that we do not know exactly what probability of successful detection each searcher has in each cell, but that we have some idea of how these detection probabilities change as the searchers are assigned more cells to search. If, for example, the searcher is a UAV moving back-and-forth over $l$ cells at a constant speed $s$, then the time between successive visits to a cell is $2l/s$, suggesting that the detection probability decays like $s/(2l)$ with the number of cells $l$. In order to be precise about this case we suppose that detection probabilities have the form \begin{equation} \gamma_k(\mathbf{a}) = \sum_{u=1}^U \phi_{u}(\mathbf{a}) \omega_{ku}\mathds{I}\{a_k=u\}, \enspace k \in [K], \label{eq::case_b_detec_probs} \end{equation} where $\phi_{u}: \mathcal{A} \rightarrow [0,1]$ are known \emph{scaling functions}, and $\omega_{ku} \in (0,1] \enspace \forall k \in [K], u \in [U]$ are unknown \emph{baseline detection probabilities} - the probability of searcher $u$ detecting intrusions in cell $k$ given that is the only cell they are assigned to search. Functions $\phi_{u}$ are assumed to be decreasing in the number of cells searcher $u$ must search. For instance, and as suggested in the preceding paragraph, one suitable function may be $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathds{I}\{a_k=u\})^{-1}$, the reciprocal of the number of cells the searcher $u$ is assigned. Searcher effectiveness may however decay more slowly as the number of cells assigned grows if for instance it takes a some time for intruders to cross the perimeter. In case (II) the action set and observed rewards remain entirely the same as for case (I), it is the information initially available to the controller that differs. Here, both $\boldsymbol\lambda$, the $K$-vector of rate parameters, and $\boldsymbol\omega=(\omega_{1,1},...,\omega_{1,U},\omega_{2,1}...,\omega_{K,U})$, the $KU$-vector of baseline detection probabilities are unknown as opposed to solely $\boldsymbol\lambda$ in case (I). Due to nonidentifiability we cannot make direct inference on $\boldsymbol\lambda$ or $\boldsymbol\omega$. However, simply estimating the products of certain components is sufficient for optimal decision making as estimating expected reward does not depend on having separate estimates of each parameter. Therefore we can simply consider $KU$ unknowns $\boldsymbol\tau=(\omega_{1,1}\lambda_1,...,\omega_{1,U}\lambda_1,\omega_{2,1}\lambda_2,...,\omega_{K,U}\lambda_K)$ when referring to the unknown parameters. As such this second case of the sequential search problem can also be modelled as a CMAB problem with filtered feedback. The set of arms is given by searcher-cell pairs $ku \in [K]\times[U]$. Each arm $ku$ is associated with a Poisson distribution with unknown parameter $\tau_{ku}=\omega_{k,u}\lambda_k$. $\mathcal{A}$ continues to specify the action set and filtering is governed by scaling function vectors $\boldsymbol\phi(\mathbf{a})=(\phi_1(\mathbf{a}),...,\phi_U(\mathbf{a}))$. Let $\phi_{ku,t}$ denote the filtering probability associated with the searcher-cell pair $ku$ in round $t$. It is 0 if $a_{k,t}\neq u$ and $\phi_u(\mathbf{a}_t)$ if $a_{k,t}=u$. Let reward in this setting be defined \begin{displaymath} r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a})=\tilde{r}_{\boldsymbol\tau,\boldsymbol\phi}(\mathbf{a})=\sum_{u=1}^U \phi_u(\mathbf{a}) \sum_{k=1}^K \tau_{ku}\mathds{I}\{a_k=u\} \end{displaymath} and define optimality gaps in this setting for $ku \in [K] \times [U]$ as\begin{align*} \Delta_{max}^{ku}&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\min_{\mathbf{a} \in \mathcal{A}}\{r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \enspace | \enspace r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma},a_k=u\} \\ \Delta_{min}^{ku}&=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\max_{\mathbf{a} \in \mathcal{A}}\{r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \enspace | \enspace r_{\boldsymbol\lambda,\boldsymbol\gamma}(\mathbf{a}) \neq \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma},a_k=u\}. \end{align*} The appropriate FP-CUCB algorithm for case (II) then calculates upper confidence bounds for each $\tau_{ku}$ parameter instead of $\lambda_k$ and as in the FP-CUCB algorithm for case (I) this induces an optimistic estimate of the value of every $\mathbf{a} \in \mathcal{A}$. We describe this second variant in Algorithm \ref{alg::FPCUCBII}. \begin{algorithm}[] \vspace{0.1cm} \caption{FP-CUCB (case (II))} \label{alg::FPCUCBII} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Upper bound $\tau_{max} \geq \tau_{ku}, \enspace k \in [K]$ and $u \in [U]$. \textbf{Initialisation Phase:} For $t \in [KU]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t\neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=KU+1,KU+2,...$ \begin{itemize} \item Calculate indices \begin{displaymath} \bar{\tau}_{ku,t}= \frac{\sum_{s=1}^{t-1}Y_{ku,s}}{\sum_{s=1}^{t-1}\phi_{ku,s}}+\frac{2\log(t)}{\sum_{s=1}^{t-1}\phi_{ku,s}}+\sqrt{\frac{6\tau_{max}\log(t)}{\sum_{s=1}^{t-1}\phi_{ku,s}}}, \enspace ku \in [K]\times[U] \end{displaymath} \item Select an allocation $\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t}$ such that $\tilde{r}_{\bar{\boldsymbol\tau}_t,\boldsymbol\phi}(\mathbf{a}^*_{\bar{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} \tilde{r}_{\bar{\boldsymbol\tau}_t,\boldsymbol\phi}(\mathbf{a})$. \end{itemize} \end{algorithm} Since our CMAB model in case (II) and second variant of FP-CUCB are of the same form as in case (I), the analogous results to Theorems \ref{thm::FPCUCB} and \ref{thm::lower_bound} can be derived. Specifically we have a regret upper bound for FP-CUCB in Corollary \ref{cor::FPCUCBb} and a lower bound for regret of any uniformly good algorithm in Corollary \ref{cor::lowerbound}. \begin{corollary} \label{cor::FPCUCBb} The regret of the FP-CUCB algorithm in case (b) defined by $\tau_{max}$ applied to the sequential search problem as defined previously satisfies \begin{align*} Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^{\text{FP-CUCB}}(n) &\leq \sum_{ku:\Delta_{min}^{ku}>0}\frac{12(KU)^2}{\phi_{ku,min}} \Bigg[ \frac{b'(\Delta^{ku}_{min})}{\Delta_{min}^{ku}} + \int_{\Delta_{min}^{ku}}^{\Delta_{max}^{ku}} \frac{b'(x)}{x^2} dx \Bigg]\log(n) + \bigg(\frac{\pi^2}{3}+1\bigg)KU\Delta_{max}, \end{align*} where $\tilde{b}(x)=\tau_{max} + \sqrt{\tau_{max}^2 + x^2/9(KU)^2}$, and $\phi_{ku,min}=\min_{\mathbf{a}:a_k=u}\phi_u(\mathbf{a})$. \end{corollary} \begin{corollary} \label{cor::lowerbound} For any $\boldsymbol\tau \in \mathds{R}_+^{KU}$ such that $\tilde{B}(\boldsymbol\tau)\neq \emptyset$, and for any uniformly good policy $\pi$ for the sequential surveillance problem with known $\boldsymbol\phi$, we have \begin{displaymath} \lim \inf_{n \rightarrow \infty} \frac{Reg^\pi_{\boldsymbol\lambda,\boldsymbol\gamma}(n)}{\log(n)} \geq \tilde{c}(\boldsymbol\tau) \end{displaymath} where $\tilde{c}(\boldsymbol\tau)$ is the solution of an optimisation problem analogous to (\ref{eq::lb_opt_objective}). \end{corollary} Precise specification of $\tilde{c}(\boldsymbol\tau)$ requires redefining notation from Section \ref{sec::regret_lower_bound} in the context of case (II) and produces an entirely unsurprising analogue. In the interests of brevity we omit this. The techniques used in proving Theorems \ref{thm::FPCUCB} and \ref{thm::lower_bound} can be easily extended to prove Corollaries 1 and 2. \section{Numerical Experiments} \label{sec::numerics} We now numerically evaluate the performance of our FP-CUCB algorithm in comparison to a greedy approach and Thompson Sampling (TS). The greedy approach is one which always selects the action currently believed to be best (following an initialisation period, where each cell is searched at least once). As such it is a fully exploitative policy which fails to recognise the benefit of the information gain inherent in exploration. TS is a randomised, Bayesian approach where an action is selected with the current posterior probability that it is the best one. This is achieved by sampling indices from a posterior distribution on each arm and passing these samples to the optimisation algorithm. We define these algorithms in the setting of known detection probabilities (case (I)) in Algorithms \ref{alg::Greedy} and \ref{alg::TS} respectively. \begin{algorithm}[] \vspace{0.1cm} \caption{Greedy} \label{alg::Greedy} \vspace{0.1cm} \vspace{0.1cm} \textbf{Initialisation Phase:} For $t \in [K]$ \begin{itemize} \item Select an arbitrary allocation $\mathbf{a} \in \mathcal{A}$ such that $a_t \neq 0$ \end{itemize} \textbf{Iterative Phase:} For $t=K+1,K+2,...$ \begin{itemize} \item For each $k \in [K] $ calculate $\hat{\lambda}_{k,t}= \frac{\sum_{s=1}^{t-1}Y_{k,s}}{\sum_{s=1}^{t-1}\gamma_{k,s}}$ \item Select an allocation $\mathbf{a}^*_{\hat{\boldsymbol\lambda}_t}$ such that $r_{\hat{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\hat{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\hat{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} \begin{algorithm}[] \vspace{0.1cm} \caption{Thompson Sampling (TS)} \label{alg::TS} \vspace{0.1cm} \vspace{0.1cm} \textbf{Inputs:} Gamma prior parameters $\alpha, \beta$ \textbf{Iterative Phase:} For $t=1,2,...$ \begin{itemize} \item For each $k \in [K]$ sample $\tilde{\lambda}_{k,t}$ from a $\text{Gamma}(\alpha + \sum_{s=1}^{t-1}Y_{k,s}, \beta + \sum_{s=1}^{t-1} \gamma_{k}(\mathbf{a}_s))$ distribution \item Select an allocation $\mathbf{a}^*_{\tilde{\boldsymbol\lambda}_t}$ such that $r_{\tilde{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a}^*_{\tilde{\boldsymbol\lambda}_t})=\max_{\mathbf{a} \in \mathcal{A}} r_{\tilde{\boldsymbol\lambda}_t,\boldsymbol\gamma}(\mathbf{a})$. \end{itemize} \end{algorithm} We compare the FP-CUCB, Greedy and Thompson Sampling algorithms by randomly sampling $\boldsymbol\lambda$ and $\boldsymbol\omega$ values which define problem instances. We then test our algorithms' performance on data generated from the models of these problem instances. We assume that detection probabilities have the form given in (\ref{eq::case_b_detec_probs}) but we know both the $\phi$ functions and $\omega$ values. Specifically, we conduct four tests encompassing a range of different problem sizes and parameter values to display the efficacy of our proposed approach uniformly across problem instances. In each test 50 $(\boldsymbol\lambda,\boldsymbol\omega)$ pairs are sampled and functions $\boldsymbol\phi$ are selected. For each $(\boldsymbol\lambda,\boldsymbol\omega)$ pair 5 datasets are sampled giving underlying counts of intrusion events in each cell in each round up to a horizon of $n=2000$. Parameters are simulated as below: \begin{enumerate} \item[(i)] $K=15$ cells and $U=5$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(10,20)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from $\text{Beta}(u,2)$ distributions for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(ii)] $K=50$ cells and $U=3$ searchers. Cell means $\lambda_k$ are sampled from Uniform distributions on the intervals $[k,k+10]$ for $k=1,...,10$, $[20-k,30-k]$ for $k=11,...,20$, $[k-20,k-10]$ for $k=21,...,30$, $[40-k,50-k]$ for $k=31,...,40$, and $[k-40,k-30]$ for $k=41,...,50$. Baseline detection probabilities $\omega_{ku}$ are sampled from $\text{Beta}(u+2,2)$ distributions for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(0.5+0.5\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(iii)] $K=25$ cells and $U=10$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(90,100)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from a $\text{Beta}(30,5)$ distribution for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \item[(iv)] $K=25$ cells and $U=5$ searchers. Cell means $\lambda_k$ are sampled from a $\text{Uniform}(0.4,1)$ distribution for $k \in [K]$. Baseline detection probabilities $\omega_{ku}$ are sampled from a $\text{Beta}(1,1)$ distribution for $u \in [U]$, $k \in [K]$. Scaling functions are $\phi_u(\mathbf{a})=(0.5+0.5\sum_{k=1}^K \mathbb{I}\{a_k=u\})^{-1}$ for $u \in [U]$, $\mathbf{a} \in \mathcal{A}$. \end{enumerate} We test a variety of parametrisations of {FP-CUCB} (in terms of $\lambda_{max}$) and TS (in terms of the prior mean and variance - from which particular $\alpha$, and $\beta$ values can be uniquely found) in each test. In each case we use $\lambda_{max}$ values which are both larger and smaller than the true maximal rate. Similarly we investigate TS with prior mean larger and smaller than the true maximal rate and with several different levels of variance. It is not always fully realistic to assume our knowledge of $\lambda_{max}$ will be perfect and therefore it is of interest to investigate the effects of varying it. Also, the choice of prior parameters in TS is a potentially subjective one and it is important to understand its impact. \begin{figure} \includegraphics[width=\textwidth]{graphics/AllMedianTest8} \caption{Cumulative Regret histories for Test (i). Upper left: FP-CUCB, upper right: TS with a prior variance of 1, lower left: TS with a prior variance of 5, lower right: TS with prior variance of 10. In each case the plotted lines are the median values of scaled regret calculated at each time point from 1 to 2000. Black lines represent $\lambda_{max}=1$ or a prior mean of 1, red represents the same parameters taking the value 5, green 10, blue 20, grey 40, and pink 60. In all sub-figures the teal line represents regret of the greedy algorithm.} \label{fig::test1} \end{figure} We measure the performance of our algorithms by calculating the expected regret incurred by their actions, rescaled by the expected reward of a single optimal action. For an algorithm $A$ and particular history $\mathbf{H}_n$ we write \begin{displaymath} ScaleReg_{\boldsymbol\lambda,\boldsymbol\gamma}^A(\mathbf{H}_n) = \frac{\sum_{t=1}^n \Delta_{\mathbf{a}_t}}{\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}}. \end{displaymath} We calculate this value for all algorithms, all 250 datasets and rounds $1 \leq n \leq 2000$. We choose to rescale our regret to make a fairer comparison across the 50 different problem instances in each test (i)-(iv) which will all have different optimal expected rewards. \begin{figure} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest8Correct.png} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest9Correct.png} \caption{Scaled regret distributions in tests (i) and (ii).} \label{fig::ridge_i} \end{figure} \begin{figure} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest10Correct.png} \includegraphics[width=0.5\linewidth]{graphics/RidgePlotTest11Correct.png} \caption{Scaled regret distributions in tests (iii) and (iv).} \label{fig::ridge_ii} \end{figure} In Figure \ref{fig::test1} we illustrate how regret evolves over time by plotting the median scaled regret across the 250 runs of each algorithm in all rounds of test (i). The rate of growth shown in these plots is typical of the results in the other three tests. An immediate observation is that the greedy algorithm does very poorly on average and its full median regret over the 2000 rounds cannot be included in the graphs without obscuring differences between the other algorithms. We see also that the performance of both FP-CUCB and TS is strongly linked to the chosen parameters. For the FP-CUCB algorithm it seems in Figure 1 that the larger the parameter $\lambda_{max}$ is the larger the cumulative regret becomes. For TS it appears that with prior variance equal to 1 the performance can be almost as poor as in the greedy case but with larger prior variance TS can outperform the FP-CUCB algorithm. We analyse these behaviours further in Figures \ref{fig::ridge_i} and \ref{fig::ridge_ii}. Here we calculate a scaled regret at time $n=2000$ for all 250 runs of each algorithm and plot the empirical distribution of these values for each parameterisation of each algorithm. The results for tests (i) and (ii) are given in Figure \ref{fig::ridge_i} and for tests (iii) and (iv) in Figure \ref{fig::ridge_ii}. We omit the greedy algorithm's performance from these figures as the values are so large. In Appendix \ref{app::tables} we provide median values and lower and upper quantiles of the scaled regret for each algorithm. We see from these values that the greedy algorithm performs substantially worse than the FP-CUCB and TS algorithms which better address the exploration-exploitation dilemma. Examining Figures 2 and 3 it is clear that the FP-CUCB algorithm enjoys greater robustness to parameter choice than the TS approach. In particular in the results of test (iii) we see that many parametrisations of TS give rise to a long tailed distribution of round 2000 regret - meaning the performance of TS is highly variable and often poor. This variability of performance does seem to coincide with underestimation of the mean, however FP-CUCB manages to maintain strong performance even when $\lambda_{max}$ used in the algorithm is only 10\% of the true problem value. We do see the performance of FP-CUCB start to suffer when $\lambda_{max}$ is chosen to be 1, but it is still much better than TS. \section{Discussion} \label{sec::discussion} In this paper we have modelled and derived solution methods for a family of sequential decision problems motivated by multi-searcher perimeter surveillance scenarios with incomplete information. Namely, we have considered the problem of adaptively assigning multiple searchers to cells along a perimeter in order to detect the maximum number of intrusion events. The challenge at the heart of this problem is to correctly balance exploration and exploitation, in the face of initial ignorance as to the arrival process of events. We formulated our sequential decision problem as a combinatorial multi-armed bandit with Poisson rewards and a novel filtered feedback mechanism. To design quality policies for this problem we first derived an efficient solution method to the full information problem. This IP forms the backbone of all policies for the sequential problem, as it allows us to quickly identify an optimal solution given some estimate of the arrival process' rate parameters. We considered the sequential problem in two informational scenarios - firstly where the probability of detecting events is known, and secondly where these probabilities are unknown but one knows how they scale as the number of cells searched increases. For both of these cases we proposed an upper confidence bound approach. We derived lower bounds on the regret of all uniformly good algorithms under this our new feedback mechanism and upper bounds on the regret of our proposed approach. In comparing our {FP-CUCB} algorithm to Thompson Sampling (TS) we see that its principal benefit lies in its reliability. It is clear from the results of Section \ref{sec::numerics} that TS outperforms FP-CUCB for certain parametrisations (commonly larger choices of variance and mean close to the true arrival rates). However, we see that TS is particularly vulnerable to poor performance when the mean of the prior underestimates the true rate parameters. Even though our theoretical results for {FP-CUCB} depend on $\lambda_{max} \geq \lambda_k, k \in [K]$ we see that it is robust to underestimating this parameter. The reason our algorithm still performs well even when a key assumption does not hold is likely due to the fact that Bernstein's inequality does not give the tightest possible bound on Poisson tail probabilities (and therefore the rate of concentration of the mean). However, in order to construct our UCB algorithm we required a symmetric tail bound for which an inflation term giving the type of concentration in Lemma 1 could be identified. Chernoff bounds (see e.g. \cite{Boucheron2013}) are tighter but lack these properties. We note that both algorithms comfortably outperform the greedy algorithm in almost all examples, which speaks to the benefit of making some attempt to balance exploration and exploitation. In general we note the performance of TS is much more variable than that of {FP-CUCB}, as shown through the lower and upper quantiles of scaled regret. This arises due to the potential for the Gamma conjugate prior to be dominated by a small number of observations and create a scenario where TS behaves similarly to a greedy policy - sometimes fixing on good actions, but sometimes on poor ones. This phenomenon of variability of regret is understudied in multi-armed bandits, not least because it is much more challenging to analyse theoretically. However, in practical scenarios (where of course the learning and regret minimisation process will only occur once) this is a concerning disadvantage of TS. The reduced variability and theoretical guarantees of our {FP-CUCB} method make it a more reliable option for real surveillance operations. \begin{appendix} \section{Proof of NP-hardness of the IP (\ref{eq::IP})} \label{app:NPhard} \begin{theorem} Integer Linear Programs of the following type are $\mathcal{NP}$-hard in the strong sense: \begin{align*} \max_{a_{iju}, 1 \leq i \leq j \leq K, u \in [U]} \sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U q_{iju}a_{iju} & \\ \text{such that } \sum_{i=1}^K \sum_{j=i}^K a_{iju} \leq &1, \enspace u \in [U] \\ \sum_{i=1}^K \sum_{j=i}^K \sum_{u=1}^U a_{iju} \leq &1, \enspace k \in [K] \\ a_{iju} \in &\{0,1\}, \enspace 1 \leq i \leq j \leq K, u \in [U]. \end{align*} \end{theorem} \noindent \emph{Proof of Theorem 3}: The following problem is known to be $\mathcal{NP}$-complete in the strong sense \citep{Garey1979}: \noindent \texttt{3-PARTITION}: Given positive integers $w_1,...,w_{3n}$ and a positive integer ``target" $t$, does there exist a partition of $\{1,...,3n\}$ into subsets $S_1,...,S_n$ such that $|S_i|=3$ and $\sum_{j \in S_i} w_j=t$ for $i=1,...,n$? We reduce this to an IP of the given type as follows. First, we assume without loss of generality that $\sum_{j=1}^{3n} w_j=nt$, since otherwise the answer to \texttt{3-PARTITION} is trivially ``no". Let $U=nt$ and $K=3n$. For $k=1,...,3n$, set $q_{iju}=w_k$ if $j-i=w_k$ and the open interval $(i,j)$ does not include a multiple of $t$. Set all other $q_{iju}$ to zero. Then the answer to \texttt{3-PARTITION} is ``yes" if and only if there is a solution to the IP with profit equal to $nt$. $\square$ \section{Lemma 1 Proof: Concentration of filtered Poisson estimator} \label{proof::concresult} First consider the result from Chapter 2 of \cite{Boucheron2013} that \emph{Bernstein's Inequality} \cite{Bernstein1946} holds for Poisson random variables. That is to say that if $Z$ follows a Poisson distribution with parameter $\lambda$ then \begin{align} \mathds{P}\bigg(Z \geq \lambda + \epsilon\bigg) &\leq \exp\Bigg(\frac{-\epsilon^2}{2\lambda+\frac{2}{3}\epsilon}\Bigg) \quad \text{for } \epsilon > 0, \label{Bounded Chernoff Inequality 1} \\ \mathds{P}\bigg(Z \leq \lambda - \epsilon\bigg) &\leq \exp\Bigg(\frac{-\epsilon^2}{2\lambda+\frac{2}{3}\epsilon}\Bigg) \quad \text{for } 0 < \epsilon < \lambda.\nonumber \end{align} We prooced to prove Lemma 1 by first bounding the probability in (\ref{FPCUCBconc}) \begin{align} &\quad \mathds{P}\bigg(\bigg|\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}}-\mu\bigg| \geq \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \nonumber \\ &\leq \mathds{P}\bigg(\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}} \geq \mu + \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) + \mathds{P}\bigg(\frac{\sum_{j=1}^{s}Y_{j}}{\sum_{j=1}^s\gamma_{j}} \leq \mu - \frac{2\log(t)}{\sum_{j=1}^s\gamma_{j}}+\sqrt{\frac{6\mu_{max}\log(t)}{\sum_{j=1}^s\gamma_{j}}}\bigg) \nonumber \\ &= \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \geq \mu\sum_{j=1}^s\gamma_{j} + \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg) \nonumber \\ &\quad \quad+ \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \leq \mu\sum_{j=1}^s \gamma_j - \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg). \label{eq::Poisson_reexpres} \end{align} Since $Y_1,...,Y_s$ are all Poisson distributions, their sum $\sum_{j=1}^s Y_j$ follows a Poisson distribution with parameter $\mu\sum_{j=1}^s\gamma_{j}$ and we can apply (\ref{Bounded Chernoff Inequality 1}) to bound the first component of (\ref{eq::Poisson_reexpres}), \begin{align*} &\quad \mathds{P}\Bigg(\sum_{j=1}^{s}Y_{j} \geq \mu\sum_{j=1}^s\gamma_{j} + \bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)\Bigg) \\ &\leq \exp\bBigg@{4}(\frac{-\Bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\Bigg)^2}{2\mu\sum_{j=1}^s\gamma_{j} + \frac{2}{3}\bigg(2\log(t)+\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}\bigg)}\bBigg@{4}) \\ &= \exp\bBigg@{4}(-3\log(t)\frac{4\log(t) + 4\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}} + 6\mu_{max}\sum_{j=1}^s\gamma_{j}}{4\log(t) + 2\sqrt{6\mu_{max}\log(t)\sum_{j=1}^s\gamma_{j}}+6\mu\sum_{j=1}^s\gamma_{j}} \bBigg@{4}) \leq t^{-3}. \end{align*} The second probability in (\ref{eq::Poisson_reexpres}) can also be bounded by $t^{-3}$ by applying Bernstein's Inequality, thus completing the proof. $\square$ \section{Theorem \ref{thm::FPCUCB} Proof: Expected regret of FP-CUCB} \label{Theorem1Proof} To complete the proof of Theorem \ref{thm::FPCUCB} provided in the main text, we separately prove Propositions \ref{prop::FPCUCBsuff} and \ref{prop::FPCUCBund}. \noindent \emph{Proof of Proposition} \ref{prop::FPCUCBsuff}: Here we prove a bound on the expected number of plays of an arm \emph{after} it has reached its sufficient sampling level. Define the event \begin{displaymath} \mathcal{N}_t = \Bigg\{\bigg|\frac{\sum_{j=1}^{t-1}Y_{k,j}}{D_{k,t-1}}-\lambda_k\bigg| < \frac{2\log(t)}{D_{k,t-1}} + \sqrt{\frac{6\lambda_{max}\log(t)}{D_{k,t-1}}} \enspace \forall k\in[K]\Bigg\}. \end{displaymath} Define random variables $\Lambda_{k,t}=\frac{2\log(t)}{D_{k,t-1}} + \sqrt{\frac{6\lambda_{max}\log(t)}{D_{k,t-1}}}$ for $k\in[K]$ and $\Lambda_t=\max_{k:g_{k,t}>0}(\Lambda_{k,t})$. Define $\Lambda^{k,l}=\frac{2\log(t)}{\gamma_{k,min}h_{k,n}(\Delta^{k,l})} + \sqrt{\frac{6\lambda_{max}\log(t)}{\gamma_{k,min}h_{k,n}(\Delta^{k,l})}}$ for $l \in [B_k]$, $k \in [K]$, which are not random variables. By these definitions and the definition of UCB indices $\bar{\lambda}_{k,t}$ we have the following properties. \begin{align*} &\mathcal{N}_t \Rightarrow \bar{\lambda}_{k,t}-\lambda_k >0 \enspace \forall k \in [K] \\ &\mathcal{N}_t \Rightarrow \bar{\lambda}_{k,t}-\lambda_k < 2\Lambda_t \enspace \forall k: g_{k,t}>0 \\ &\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s:g_{s,t}>0\} \Rightarrow \Lambda^{k,l}> \Lambda_t \enspace \forall k \in [K], \forall l \in [B_k] \end{align*} For any particular $k \in [K]$ and $l \in [B_k]$ if $\{\mathcal{N}_t,\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s: g_{s,t}>0\}$ holds at time $t$ the following is implied \begin{equation} \mathbf{g}_t^T\cdot \boldsymbol\lambda + 2K\Lambda^{k,l} > \mathbf{g}_t^T\cdot \boldsymbol\lambda + 2K\Lambda_t \geq \mathbf{g}_t^T \cdot \bar{\boldsymbol\lambda}_t \geq (\mathbf{g}_{\boldsymbol\lambda}^*)^T \cdot \bar{\boldsymbol\lambda}_t\geq (\mathbf{g}_{\boldsymbol\lambda}^*)^T \cdot {\boldsymbol\lambda} = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma} \label{Contradiction} \end{equation} where $\mathbf{g}^*_{\boldsymbol\lambda}$ is an action that is optimal with respect to rate vector $\boldsymbol\lambda$. However, by definition $2K\Lambda^{k,l}\geq\Delta^{k,l}$ and therefore (\ref{Contradiction}) is a contradiction of the definition of $\Delta^{k,l}=\text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}-\mathbf{g}_{k,B}^l\cdot \boldsymbol\lambda$. Therefore \begin{align*} &\mathds{P}(\mathcal{N}_t,\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, \forall s: g_{s,t}>0, N_{s,t-1}> h_{k,n}(\Delta^{k,l}))=0 \enspace \forall k \in [K], \enspace \forall l \in [B_k] \end{align*} and \begin{displaymath} \sum_{k=1}^K \sum_{l=1}^{B_k}\mathds{P}(\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}>N_{k,t-1}, N_{s,t-1}> h_{k,n}(\Delta^{k,l}) \enspace \forall s:g_{s,t}>0)\leq \mathds{P}(\neg \mathcal{N}_t) \leq 2Kt^{-2}. \end{displaymath} The bound on $\mathds{P}(\neg \mathcal{N}_t)$ comes from applying Lemma 1 and is sufficient to prove Proposition \ref{prop::FPCUCBsuff} since \begin{align*} \mathds{E}\Bigg(\sum_{k=1}^K \sum_{l=1}^{B_k} N_{k,n}^{l,suf}\Bigg)&=\mathds{E}\Bigg(\sum_{t=K+1}^n \sum_{k=1}^K \sum_{l=1}^{B_k} \mathds{I}\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t} > N_{k,t-1},N_{k,t-1}> h_{k,n}(\Delta^{k,l})\}\Bigg) \\ &\leq \sum_{t=K+1}^n 2Kt^{-2} \leq \frac{\pi^2}{3}\cdot K. \quad \square \end{align*} \noindent \emph{Proof of Proposition 2} Now consider the number of plays made prior to reaching the sufficient sampling level. Firstly set $h_{k,n}(\Delta^{k,0})=0$ to simplify notation and consider the following steps. Then for any cell $k$ in $\{j \in [K]|\Delta_{min}^j >0 \}$ \begin{align*} \sum_{l=1}^{B_k} N_{k,n}^{l,und}\cdot \Delta^{k,l} &= \sum_{t=K+1}^n \sum_{l=1}^{B_k} \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\leq h_{k,n}(\Delta^{k,l})\bigg\} \Delta^{k,l} \\ &= \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^l \mathds{I}\bigg\{ \mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,l} \\ &\leq \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^l \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ \intertext{as $\Delta^{k,1} \geq \Delta^{k,2} \geq ... \geq \Delta^{k,B_k}$,} &\leq \sum_{t=K+1}^n \sum_{l=1}^{B_k} \sum_{j=1}^{B_k} \mathds{I}\bigg\{\mathbf{g}_t = \mathbf{g}_{k,B}^l, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &= \sum_{t=K+1}^n \sum_{j=1}^{B_k} \mathds{I}\bigg\{ \mathbf{g}_t \in \mathcal{G}_{k,B}, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &= \sum_{j=1}^{B_k} \sum_{t=K+1}^n \mathds{I}\bigg\{\mathbf{g}_t \in \mathcal{G}_{k,B}, N_{k,t}> N_{k,t-1}, N_{k,t-1}\in \Big(h_{k,n}(\Delta^{k,j-1}),h_{k,n}(\Delta^{k,j})\Big) \bigg\} \Delta^{k,j} \\ &\leq \sum_{j=1}^{B_k} \Big(h_{k,n}(\Delta^{k,j})-h_{k,n}(\Delta^{k,j-1})\Big) \Delta^{k,j} \\ \intertext{since $N_{k}$ can only be incremented a maximum of $h_{k,n}(\Delta^{k,j})-h_{k,n}(\Delta^{k,j-1})$ times while remaining in this range} &= h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \sum_{j=1}^{B_k-1} h_{k,n}(\Delta^{k,j})\cdot(\Delta^{k,j}-\Delta^{k,j+1}) \\ &\leq h_{k,n}(\Delta^{k,B_k})\Delta^{k,B_k} + \int_{\Delta^{k,B_k}}^{\Delta^{k,1}} h_{k,n}(x)dx. \end{align*} The last inequality holds since $h_{k,n}(x)$ are decreasing functions. $\square$ \section{Theorem 2 Proof: Lower bound on regret} \label{proof::lower_bound} To prove Theorem 2, we must define the additional quantities necessary to apply Theorem 1 of \cite{Graves1997} and frame the problem accordingly. We consider the reward history $(\mathbf{Y}_t)_{t=1}^n$ to be a realisation of a controlled Markov Chain moving on the state space $\mathbb{N}^K$ where the controls are the detection probability vectors selected in each round. Each control $\mathbf{g} \in \mathcal{G}$ then has an associated set of $\boldsymbol\lambda$ parameter vectors under which it is an optimal control $\Lambda_{\mathbf{g}} = \{\boldsymbol\lambda \in \mathbb{R}_{+}^K: \mathbf{g}^T\cdot \boldsymbol\lambda = \text{opt}_{\boldsymbol\lambda,\boldsymbol\gamma}\}$, which may be the empty set. For any states $\mathbf{y}, \mathbf{z} \in \mathbb{N}^K$ transition probabilities are straightforward Poisson probabilities due to independence across rounds:\begin{displaymath} p(y,z;\boldsymbol\lambda,\mathbf{g}) = p(z;\boldsymbol\lambda,\mathbf{g})= \prod_{k=1}^K \frac{(g_k\lambda_k)^{z_k}e^{-g_k\lambda_k}}{z_k!}. \end{displaymath} These transition probabilities define the Kullback Leibler Information number for any control $\mathbf{g} \in \mathcal{G}$: \begin{displaymath} I^{\mathbf{g}}(\boldsymbol\lambda,\boldsymbol\theta)= \sum_{k=1}^K \log\bigg(\frac{p(z_k;\boldsymbol\lambda,\mathbf{g})}{p(z_k;\boldsymbol\theta,\mathbf{g})}\bigg)p(z_k;\boldsymbol\lambda,\mathbf{g}) =\sum_{k=1}^K \text{kl}(g_k\lambda_k,\gamma_k\theta_k) =\sum_{k=1}^K g_k \text{kl}(\lambda_k,\theta_k). \end{displaymath} With these quantities and those defined in Section \ref{sec::regret_lower_bound} we can apply Theorem 1 of \cite{Graves1997} to reach the following result for any uniformly good policy $\pi$ \begin{displaymath} \lim \inf_{n \rightarrow \infty} \sum_{\mathbf{g} \in \mathcal{J}\setminus J(\boldsymbol\lambda)} \frac{I^{\mathbf{g}}(\boldsymbol\lambda,\boldsymbol\theta)\mathds{E}_{\boldsymbol\lambda}(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}\})}{\log(n)} \geq 1 \text{ for every } \boldsymbol\theta \in B(\boldsymbol\lambda). \end{displaymath} Since $Reg_{\boldsymbol\lambda,\boldsymbol\gamma}^\pi(n)=\sum_{\mathbf{g} \in \mathcal{J}\setminus J(\boldsymbol\lambda)} \Delta_{\mathbf{g}}\mathds{E}_{\boldsymbol\lambda}(\sum_{t=1}^n \mathds{I}\{\mathbf{g}_t = \mathbf{g}\})$ the required result follows. $\square$ \section{Numerical Results} \label{app::tables} \begin{table}[h!] \centering \label{tab::test1} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 4.10 & 6.94 & 14.08 \\ & $\lambda_{max}=5$ & 12.72 & 18.97 & 24.46 \\ & $\lambda_{max}=10$ & 22.35 & 28.67 & 36.30 \\ & $\lambda_{max}=20$ & 35.72 & 42.59 & 54.98 \\ & $\lambda_{max}=40$ & 53.26 & 62.31 & 79.86 \\ & $\lambda_{max}=60$ & 64.06 & 77.63 & 100.34 \\ \hline \multirow{18}{*}{Thompson Sampling} & Mean=1, Variance=1 & 38.44 & 242.39 & 508.93 \\ & Mean=5, Variance=1 & 1.95 & 132.79 & 358.15 \\ & Mean=10, Variance=1 & 1.44 & 56.30 & 134.12 \\ & Mean=20, Variance=1 & 11.66 & 17.76 & 25.88 \\ & Mean=40, Variance=1 & 75.24 & 96.87 & 124.57 \\ & Mean=60, Variance=1 & 122.72 & 180.67 & 233.25 \\ & Mean=1, Variance=5 & 5.69 & 26.49 & 90.89 \\ & Mean=5, Variance=5 & 2.32 & 38.51 & 134.07 \\ & Mean=10, Variance=5 & 2.18 & 7.19 & 43.90 \\ & Mean=20, Variance=5 & 7.17 & 10.95 & 15.80 \\ & Mean=40, Variance=5 & 30.00 & 36.11 & 43.23 \\ & Mean=60, Variance=5 & 57.61 & 72.42 & 87.30 \\ & Mean=1, Variance=10 & 6.31 & 14.21 & 36.57 \\ & Mean=5, Variance=10 & 3.60 & 9.35 & 35.87 \\ & Mean=10, Variance=10 & 3.28 & 6.65 & 18.41 \\ & Mean=20, Variance=10 & 6.55 & 9.67 & 15.97 \\ & Mean=40, Variance=10 & 20.15 & 24.65 & 30.25 \\ & Mean=60, Variance=10 & 40.17 & 46.12 & 55.09 \\ \hline Greedy & & 79.77 & 679.76 & 1657.52 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (i) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test2} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 18.13 & 27.63 & 39.34 \\ &$\lambda_{max}=5$ & 57.39 & 76.02 & 104.67 \\ &$\lambda_{max}=10$ & 83.99 & 113.86 & 150.29 \\ &$\lambda_{max}=20$ & 116.59 & 159.85 & 200.11 \\ &$\lambda_{max}=40$ & 152.79 & 212.42 & 248.46 \\ &$\lambda_{max}=60$ & 176.58 & 245.46 & 285.71 \\ \hline \multirow{18}{*}{Thompmson Sampling} & Mean=1, Variance=1 & 248.37 & 481.61 & 783.17 \\ & Mean=5, Variance=1 & 6.34 & 150.56 & 451.04 \\ & Mean=10, Variance=1 & 6.38 & 16.93 & 129.87 \\ & Mean=20, Variance=1 & 84.59 & 104.91 & 134.17 \\ & Mean=40, Variance=1 & 234.03 & 321.99 & 365.10 \\ & Mean=60, Variance=1 & 297.34 & 412.77 & 481.44 \\ & Mean=1, Variance=5 & 22.56 & 48.46 & 121.32 \\ & Mean=5, Variance=5 & 7.75 & 54.94 & 175.94 \\ & Mean=10, Variance=5 & 5.26 & 11.12 & 32.86 \\ & Mean=20, Variance=5 & 29.47 & 36.23 & 45.42 \\ & Mean=40, Variance=5 & 106.17 & 137.60 & 162.94 \\ & Mean=60, Variance=5 & 183.13 & 245.48 & 279.97 \\ & Mean=1, Variance=10 & 20.34 & 33.24 & 55.34 \\ & Mean=5, Variance=10 & 9.44 & 21.12 & 79.06 \\ & Mean=10, Variance=10 & 8.24 & 12.40 & 25.07 \\ & Mean=20, Variance=10 & 19.19 & 24.56 & 31.66 \\ & Mean=40, Variance=10 & 69.19 & 84.84 & 100.94 \\ & Mean=60, Variance=10 & 126.94 & 162.99 & 188.46 \\ \hline Greedy & & 243.30 & 576.35 & 963.96 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (ii) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test3} \begin{tabular}{rrrrr} \hline Algorithm & Parameter & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=1$ & 2.82 & 14.72 & 37.18 \\ & $\lambda_{max}=10$ & 3.97 & 5.14 & 6.73 \\ & $\lambda_{max}=25$ & 6.38 & 7.86 & 9.44 \\ & $\lambda_{max}=50$ & 9.42 & 10.94 & 12.51 \\ & $\lambda_{max}=100$ & 12.60 & 15.15 & 17.45 \\ & $\lambda_{max}=200$ & 16.59 & 20.23 & 22.85 \\ \hline \multirow{18}*{Thompson Sampling} & Mean=1, Variance=5 & 30.47 & 66.95 & 115.65 \\ & Mean=10, Variance=5 & 36.78 & 64.41 & 98.24 \\ & Mean=25, Variance=5 & 29.06 & 58.44 & 95.57 \\ & Mean=50, Variance=5 & 10.82 & 39.65 & 71.71 \\ & Mean=100, Variance=5 & 4.83 & 6.05 & 7.71 \\ & Mean=200, Variance=5 & 28.24 & 34.20 & 40.37 \\ & Mean=1, Variance=10 & 12.61 & 52.06 & 97.08 \\ & Mean=10, Variance=10 & 33.99 & 68.30 & 109.44 \\ & Mean=25, Variance=10 & 30.97 & 64.55 & 105.03 \\ & Mean=50, Variance=10 & 17.32 & 46.39 & 80.35 \\ & Mean=100, Variance=10 & 4.26 & 5.52 & 7.09 \\ & Mean=200, Variance=10 & 21.37 & 25.06 & 29.00 \\ & Mean=1, Variance=25 & 3.87 & 37.19 & 102.98 \\ & Mean=10, Variance=25 & 36.51 & 66.12 & 107.72 \\ & Mean=25, Variance=25 & 30.87 & 64.73 & 106.71 \\ & Mean=50, Variance=25 & 20.21 & 51.32 & 86.70 \\ & Mean=100, Variance=25 & 3.86 & 5.09 & 6.79 \\ & Mean=200, Variance=25 & 14.08 & 15.92 & 18.09 \\ \hline Greedy & & 21.57 & 49.20 & 95.89 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (iii) data} \end{table} \clearpage \begin{table}[h!] \centering \label{tab::test4} \begin{tabular}{rrrrr} \hline Algorithm & Parameters & 0.025 Quantile & Median & 0.975 Quantile \\ \hline \multirow{6}{*}{FP-CUCB} & $\lambda_{max}=0.1$ & 22.71 & 53.35 & 101.82 \\ & $\lambda_{max}=1$ & 59.48 & 106.59 & 193.57 \\ & $\lambda_{max}=5$ & 84.44 & 140.40 & 250.38 \\ & $\lambda_{max}=10$ & 91.32 & 151.69 & 263.00 \\ & $\lambda_{max}=20$ & 96.01 & 162.47 & 270.39 \\ & $\lambda_{max}=40$ & 98.81 & 172.28 & 284.63 \\ \hline \multirow{18}{*}{Thompson Sampling} & Mean=0.1, Variance=1 & 70.68 & 136.84 & 284.14 \\ & Mean=1, Variance=1 & 42.78 & 61.44 & 91.98 \\ & Mean=5, Variance=1 & 43.96 & 75.38 & 119.21 \\ & Mean=10, Variance=1 & 75.45 & 118.86 & 197.36 \\ & Mean=20, Variance=1 & 104.58 & 174.02 & 291.32 \\ & Mean=40, Variance=1 & 119.72 & 207.46 & 349.74 \\ & Mean=0.1, Variance=5 & 94.23 & 246.71 & 467.06 \\ & Mean=1, Variance=5 & 43.48 & 73.41 & 119.94 \\ & Mean=5, Variance=5 & 41.71 & 60.07 & 88.64 \\ & Mean=10, Variance=5 & 45.15 & 72.69 & 119.42 \\ & Mean=20, Variance=5 & 69.43 & 113.12 & 191.90 \\ & Mean=40, Variance=5 & 102.60 & 169.98 & 281.94 \\ & Mean=0.1, Variance=10 & 134.60 & 320.63 & 588.63 \\ & Mean=1, Variance=10 & 48.26 & 81.35 & 146.95 \\ & Mean=5, Variance=10 & 41.43 & 58.66 & 84.74 \\ & Mean=10, Variance=10 & 40.78 & 62.10 & 99.55 \\ & Mean=20, Variance=10 & 55.42 & 89.68 & 146.88 \\ & Mean=40, Variance=10 & 86.98 & 141.99 & 239.18 \\ \hline Greedy & & 664.28 & 1825.61 & 1999.89 \\ \hline \end{tabular} \caption{Quantiles of scaled regret at horizon $n=2000$ for algorithms applied to Test (iv) data} \end{table} \clearpage \end{appendix} \bibliographystyle{apalike}
{'timestamp': '2018-10-05T02:11:00', 'yymm': '1810', 'arxiv_id': '1810.02176', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02176'}
arxiv
\section{Introduction} We study the classification and regression problems in a setting of adversarial examples. This setting is different from standard supervised learning in that examples, both at training and testing time, may be corrupted in an adversarial manner to disrupt the learner's performance. This challenge to design reliable robust models gained significant attention as standard supervised learning methods have shown vulnerability, and is named {\em adversarial examples}. We study the adversarially robust learning paradigm from a generalization point of view and concentrate on the case of having adversarial examples at test time. We consider the following robust learning framework for multi-class and real valued functions of \citet{FeigeMS15}. There is an unknown distribution over the uncorrupted inputs domain. The learner receives a labeled uncorrupted sample (the labels can be categorical or real valued) and has access during the training phase to all possible corruptions that the adversary might effect. The learner selects a hypothesis from a fixed hypothesis class (in our case, a mixture of hypotheses from base class $\H$) that gives a prediction (a distribution over predictions) for a corrupted input. The learner's accuracy is measured by predicting the true label of the uncorrupted input while they observe only the corrupted input during test time. Thus, their goal is to find a policy that is immune to those corruptions. The adversary is capable of corrupting each future input, but there are only $k$ possible corruptions for each input. This leads to a game theoretic framework of a zero-sum game between the learner and the adversary. The model is closely related to the one suggested by \citet{DBLP:journals/corr/abs-1804-11285,DBLP:journals/corr/MadryMSTV17} and common robust optimization approaches \citep{BEN:09}, which deal with bounded worst-case perturbations (under $\ell_\infty$ norm) on the samples. In this work we do not assume any metric for the corruptions, the adversary can map an input from the sample space to any other space, but is limited with finite possible corruptions for each input. Our focus is on adversarial examples during testing time. The training data is clean, but we take into consideration all possible corruptions when we build the robust classifier. Thus, we extend the ERM paradigm by using adversarial training techniques instead of merely find a hypothesis that minimizes the empirical risk. In contradistinction to ``standard'' learning, ERM often does not yield models that are robust to adversarially corrupted examples \citep{DBLP:journals/corr/SzegedyZSBEGF13,10.1007/978-3-642-40994-3_25,43405,45816,7780651,Tramr2017TheSO}. Another interesting direction (not pursued here) is the setting where the training data is adversarially corrupted beforehand, without any direct access to uncorrupted sample. Studying worst-case (adversarial) corruptions is interesting for a couple of reasons. First, it models situations where the corruption occurs maliciously (such as a spammer who tailors messages to avoid a spam detector) and not merely as a result of random noise. Additionally, a robust classifier that is successful against adversarial corruption extends to less adversarial settings. Our main results are generalization bounds for all settings. For the binary classification setting, we improve the generalization bound given in \citet{FeigeMS15}. We generalize to the case of mixture of hypotheses from $\H$ when $\H$ is not necessarily finite. The sample complexity has been improved from $\O(\frac{1}{\epsilon^4}\log(\frac{|\H|}{\delta}))$ to $\O(\frac{1}{\epsilon^2}(k\log(k)\operatorname{VC}(\H)+\log\frac{1}{\delta}))$. Roughly speaking, the core of all proofs is a bound on the Rademacher complexity of the $k$-fold maximum of the convex hull of the loss class of $\H$. The $k$-fold maximum captures the $k$ possible corruptions for each input. In the regression case we provide a tight bound on the fat shattering dimension of $k$-fold maximum class and bound the fat shattering dimension of $L_1$ and $L_2$ loss classes. For our algorithm, we employ a regret minimization algorithm proposed for binary classification by \citet{FeigeMS15} for computing near optimal policies for the players on the training data. We adapt it multiclass classification and regression as well. The algorithm is a variant of the algorithm found in \citet{DBLP:conf/colt/Cesa-BianchiMS05} and based on the ideas of \citet{RePEc:eee:gamebe:v:29:y:1999:i:1-2:p:79-103}. An ERM (empirical risk minimization) oracle is used multiple times to return a hypothesis from a fixed hypothesis class $\H$ that minimizes the error rate on a given sample, while weighting samples differently every time. The learner uses a randomized classifier chosen uniformly from the mixture of hypotheses returned by the algorithm. \subsection{Related work} The most related work studying robust learning with adversarial examples are \citet{DBLP:journals/corr/abs-1804-11285,DBLP:journals/corr/MadryMSTV17}. Their model deals with bounded worst-case perturbations (under $l_\infty$ norm) on the samples. This is slightly different from our model as we mentioned above. Other closely related works that analyse the theoretical aspects of adversarial robust generalization and learning rules are \citep{DBLP:journals/corr/abs-1810-11914,DBLP:journals/corr/abs-1810-09519,DBLP:conf/nips/CullinaBM18,bubeck2018adversarial,DBLP:journals/corr/abs-1810-12272,DBLP:journals/corr/abs-1809-03063,DBLP:journals/corr/abs-1810-01407}. A different notion of robustness by \citep{Xu2012} is shown to be sufficient and necessary for standard generalization. All of our results based on a robust learning model for binary classification suggested by \citet{FeigeMS15}. The works of \citet{DBLP:conf/soda/MansourRT15,FeigeMS15,FeigeMS18} consider {\em robust inference} for the binary and multi-class case. The robust inference model assumes that the learner knows both the distribution and the target function, and the main task is given a corrupted input, derive in a computationally efficient way a classification which will minimize the error. In this work we consider only the learning setting, where the learner has only access to an uncorrupted sample, and need to approximate the target function on possibly corrupted inputs, using a restricted hypothesis class $\H$. The work of \citet{Globerson:2006:NTT:1143844.1143889} and its extensions \citet{NIPS2007_3218,Dekel:2008:LCM:1390156.1390184} discuss a robust learning model where an uncorrupted sample is drawn from an unknown distribution, and the goal is to learn a linear classifier that would be able to overcome missing attributes in future test examples. They discuss both the static model (where the set of missing attributes is selected independently from the uncorrupted input) and the dynamic model (where the set of missing attributes may depend on the uncorrupted input). The model we use \citep{FeigeMS15} extends the robust learning model to handle corrupted inputs (and not only missing attributes) and an arbitrary hypothesis class (rather than only linear classifiers). There is a vast literature in statistics, operation research and machine learning regarding various noise models. Typically, most noise models assume a random process that generates the noise. In computational learning theory, popular noise models include random classification noise \citep{Angluin1988} and malicious noise \citep{Valiant:1985:LDC:1625135.1625242,Kearns93learningin}. In the malicious noise model, the adversary gets to arbitrarily corrupt some small fraction of the examples; in contrast, in our model the adversary can always corrupt every example, but only in a limited way. Other motivating applications such as spam messages detection, web spam detection, computer intrusion detection, fraud detection, network failure detection, noisy bio-sensors measurements, and many more can be found in \citet{Laskov:2010:MLA:1860716.1860719}. \subsection{The structure of the paper} The structure of this paper is as follows: Section \ref{sec2} discusses the model in detail. Section \ref{sec3} contains relevant definitions and notations. Section \ref{sec4} is the learning algorithm, and Sections \ref{sec5}, \ref{sec6} and \ref{sec7} contain the generalization bounds for binary and multiclass classification and regression. \section{Model}\label{sec2} There is some unknown distribution $D$ over a finite domain $\mathcal{X}$ of uncorrupted examples and a finite domain of corrupted examples $\mathcal{Z}$, possibly the same as $\mathcal{X}$. We work in deterministic scenario, where there is some concept class $C$ such that $c\in C$ has domain $\mathcal{X}$ and range $\mathcal{Y}$ that can be $\set{1,\dots,l}$ or $\mathbb{R}$. There is some unknown target function $c^*\in C$ which maps an uncorrupted example to its label. The adversary is able to corrupt an input by mapping an uncorrupted input $x\in \mathcal{X}$ to a corrupted one $z\in \mathcal{Z}$. There is a mapping $\rho$ which for every $x \in \mathcal{X}$ defines a set $\rho(x) \subseteq \mathcal{Z}$, such that $|\rho(x)| \leq k$. The adversary can map an uncorrupted input $x$ to any corrupted input $z \in \rho(x)$. We assume that the learner has an access to $\rho(\cdot)$ during the training phase. There is a fixed hypothesis class $\H$ of hypothesis $h:\mathcal{Z} \mapsto \mathcal{Y}$ over corrupted inputs. The learner observes an uncorrupted sample $S_u=\{\langle x_1,c^*(x_1) \rangle, \ldots, \langle x_m, c^*(x_m) \rangle\}$, where $x_i$ is drawn i.i.d. from $D$, and selects a mixture of hypotheses from $\H$, $\Tilde{h}\in \Delta(\H)$. In the classification setting, $\Tilde{h}: \mathcal{Z} \rightarrow \Delta{(\mathcal{Y})}$ is a mixture $\set{h_i|\H \ni h_i:\mathcal{Z} \rightarrow \mathcal{Y}}_{i=1}^T$ such that label $y\in\mathcal{Y}=\set{1,\dots,l}$ gets a mass of $\sum_{i=1}^T\alpha_i(\mathbb{I}_{\{h_i(z)= y\}})$ where $\sum_{i=1}^T\alpha_i$=1. For each hypothesis $h\in\H$ in the mixture we use the zero-one loss to measure the quality of the classification, i.e., $\mathsf{loss}(h(z),y)=\mathbb{I}_{\{h(z)\neq y\}}$. The loss of $\Tilde{h}\in\Delta{(\H)}$ is defined by $\mathsf{loss}(\Tilde{h}(z),y)= \sum_{i=1}^T \alpha_i \mathsf{loss}(h_i(z),y)$. In the regression setting, $\Tilde{h}: \mathcal{Z} \rightarrow \mathbb{R}$ is a mixture $\set{h_i|\H \ni h_i:\mathcal{Z} \rightarrow \mathbb{R}}_{i=1}^T$ and is defined by $\Tilde{h}(z)=\sum_{i=1}^T \alpha_i h_i(z)$. For each hypothesis $h\in\H$ in the mixture we use $L_1$ and $L_2$ loss functions, i.e., $\mathsf{loss}(h(z),y)=|h(z)-y|^p$, for $p=1,2$. We assume the $L_1$ loss is bounded by 1. Again, the loss of $\Tilde{h}\in\Delta{(\H)}$ is defined by $\mathsf{loss}(\Tilde{h}(z),y)= \sum_{i=1}^T \alpha_i \mathsf{loss}(h_i(z),y)$. The basic scenario is as follows. First, an uncorrupted input $x\in \mathcal{X}$ is selected using $D$. Then, the adversary selects $z \in \rho(x)$, given $x\in\mathcal{X}$. The learner observes a corrupted input $\mathcal{Z}$ and outputs a prediction, as dictated by $\Tilde{h}\in\Delta(\H)$. Finally, the learner incurs a loss as described above. The main difference from the classical learning models is that the learner will be tested on adversarially corrupted inputs $z \in \rho(x)$. When selecting a strategy this needs to be taken into consideration. The goal of the learner is to minimize the expected loss, while the adversary would like to maximize it. This defines a zero-sum game which has a value $v$ which is the learner's error rate. We say that the learner's hypothesis is $\epsilon$-optimal if it guarantees a loss which is at most $v+\epsilon$, and the adversary policy is $\epsilon$-optimal if it guarantees a loss which is at least $v-\epsilon$. We refer to a 0-optimal policy as an optimal policy. Formally, the error (risk) of the learner when selecting a hypothesis $\Tilde{h}\in\Delta(\H)$ is \begin{eqnarray*} \operatorname{Risk}(\Tilde{h})=\mathbb{E}_{x\sim D}[\max_{z\in\rho(x)}\mathsf{loss}(\Tilde{h}(z),c^*(x)], \end{eqnarray*} and their goal is to choose $\Tilde{h}\in\Delta(\H)$ with an error close to \begin{eqnarray*} \min_{\Tilde{h}\in\Delta(\H)}\operatorname{Risk}(\Tilde{h})=\min_{\Tilde{h}\in\Delta(\H)}\mathbb{E}_{x\sim D}[\max_{z\in\rho(x)}\mathsf{loss}(\Tilde{h}(z),c^*(x)]= v . \end{eqnarray*} \paragraph{Uncorrupted Training Data Learning Algorithm.} Uncorrupted training data (UTD) learning algorithm receives an uncorrupted sample $S_u$ and outputs a hypothesis $h\in \H$ (mixture of hypotheses in our case). The UTD-learning algorithm $(\epsilon,\delta)$-learns $C$ if for any target function $c^*\in C$, with probability $1-\delta$, the algorithm outputs some hypothesis $h\in \H$, such that $\operatorname{Risk}(h) \leq v+\epsilon$. The risk is measured by adversarially corrupted inputs as mentioned above. \section{Definitions and Notations}\label{sec3} For a function class $\H$ with domain $\mathcal{Z}$ and range $\mathcal{Y}=\set{1,\dots,l}$, denote the zero-one loss class \begin{eqnarray*} L_{\H}:=\set{Z\times\set{1,\dots,l}\ni(z,y)\mapsto \mathbb{I}_{h(z)\neq y}: h\in \H} \end{eqnarray*} For $\H$ with domain $\mathcal{Z}$ and range $\mathbb{R}$, denote the $L_p$ loss class \begin{eqnarray*} L_{\H}^p:=\set{Z\times\mathbb{R}\ni(z,y)\mapsto |h(z)-y|^p: h\in \H} \end{eqnarray*} Throughout the article, we assume a bounded loss $\mathsf{loss}(h(z),y)\leq M$. Without the loss of generality we use $M=1$, otherwise, we can rescale $M$. Define the following operations on the loss class $L_\H$. The convex hull of $L_\H$ is the set of all convex combinations of hypotheses from $L_\H$: \begin{eqnarray*} \operatorname{conv}(L_\H) := \set{\mathcal{Z}\times \mathcal{Y} \ni (z,y)\mapsto \sum_{t=1}^T \alpha_t f_t(z,y): T\in\mathbb{N}, \alpha_t\in[0,1], \sum_{t=1}^T \alpha_t=1, f_t\in L_\H} . \end{eqnarray*} The convex hull of $L_\H$, where the data is corrupted by $\rho(\cdot)$, is denoted by\\ \\ $\operatorname{conv}^{\rho}(L_\H) :=$ \begin{eqnarray*} \set{ \mathcal{X}\times \mathcal{Y}\ni (x,y)\mapsto \max_{z\in\rho(x)} \sum_{t=1}^T \alpha_t f_t(z,y): T\in\mathbb{N}, \alpha_t\in[0,1], \sum_{t=1}^T \alpha_t=1, f_t\in L_\H}. \end{eqnarray*} For $1\leq j\leq k$ define, \begin{eqnarray*} \mathcal{F}_\H^{(j)}:=\set{\mathcal{X}\times \mathcal{Y} \ni (x,y)\mapsto \mathbb{I}_{\{h(z_j)\neq y\}}:h\in \H,\;\rho(x)=\set{z_1,\dots,z_k}}, \end{eqnarray*} where we treat the set-valued output of $\rho(x)$ as an ordered list, and $\mathcal{F}_\H^{(j)}$ is constructed by taking the $j$th element in this list, for each input $x$.\\ \paragraph{Max and Max-Conv Operators.} For a set $W$ and $k$ function classes $\mathcal{A}^{(1)},\ldots,\mathcal{A}^{(k)}\subseteq \mathbb{R}^W$, define the $\max$ operator \begin{eqnarray*} \max ((\mathcal{A}^{(j)})_{j\in[k]}) := \set{ W\ni w\mapsto\max_{j\in[k]}f^{(j)}(w): f^{(j)}\in \mathcal{A}^{(j)}}. \end{eqnarray*} We also define a hybrid $\max\!\!-\!\!\operatorname{conv}$ operator:\\ \\ $\max\!\!-\!\!\operatorname{conv}((\mathcal{A}^{(j)})_{j\in[k]}) :=$ \begin{eqnarray*} \set{ W \ni w\mapsto \max_{j\in[k]} \sum_{t=1}^T \alpha_t f_t^{(j)}(w): T\in\mathbb{N}, \alpha_t\in[0,1], \sum_{t=1}^T\alpha_t=1, f_t^{(j)}\in \mathcal{A}^{(j)}} . \end{eqnarray*} Note that \begin{eqnarray*} \max\!\!-\!\!\operatorname{conv}((\mathcal{A}^{(j)})_ {j\in[k]}) \subseteq \max(\operatorname{conv}((\mathcal{A}^{(j)})_{j\in[k]})), \end{eqnarray*} and the containment will generally be strict, since the former requires the same choice of convex coefficients for all $\mathcal{A}^{(j)}$'s, while the latter allows distinct ones.\\ \paragraph{Remark.} Observe that \begin{eqnarray*} \operatorname{conv}^{\rho}(L_\H) = \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]}) \end{eqnarray*} We use the notation $\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})$ and exploit its structural properties. Denote the error (risk) of hypothesis $h:\mathcal{Z} \mapsto \mathcal{Y}$ under corruption of $\rho(\cdot)$ by \begin{eqnarray*} \operatorname{Risk}(h)=\mathbb{E}_{x\sim D}[\max_{z\in\rho(x)}\mathsf{loss}(h(z),y)], \end{eqnarray*} and the empirical error on sample $S$ under corruption of $\rho(\cdot)$ by \begin{eqnarray*} \mywidehat{\operatorname{Risk}}(h)=\frac{1}{|S|}\underset{(x,y)\in S}{{\displaystyle \sum}}\max_{z\in\rho(x)}\mathsf{loss}(h(z),y). \end{eqnarray*} \subsection{ Combinatorial Dimensions and Capacity Measures } \paragraph{Rademacher Complexity.} Let $\H$ be of real valued function class on the domain space $\mathcal{W}$. Define the empricial Rademacher complexity on a given sequence $\mathbf{w}=(w_1,\ldots,w_n)\in \mathcal{W}^n$: \begin{eqnarray*} R_n(\H | \mathbf{w}) = E_{\mathbf{\sigma}} \sup_{h\in H}\frac1n\sum_{i=1}^n\sigma_i h(w_i). \end{eqnarray*} \paragraph{Fat-Shattering Dimension.} For $\mathcal{F}\subset\mathbb{R}^\mathcal{X}$ and $\gamma>0$, we say that $\mathcal{F}$ $\gamma$-shatters a set $S=\set{x_1,\ldots,x_m}\subset\mathcal{X}$ if there exists an $r=(r_1,\ldots,r_m)\in\mathbb{R}^m$ such that for each $b\in\set{-1,1}^m$ there is a function $f_b\in\mathcal{F}$ such that \begin{eqnarray*} \forall i\in [m] : \left. \begin{cases} f_b(x_i)\ge r_i+\gamma & \text{if } b_i=1\\ f_b(x_i)\le r_i-\gamma & \text{if } b_i=-1 \end{cases} \right.. \end{eqnarray*} We refer to $r$ as the {\em shift}. The $\gamma$-fat-shattering dimension, denoted by $\operatorname{fat}_\gamma(\mathcal{F})$, is the size of the largest $\gamma$-shattered set (possibly $\infty$). \paragraph{Graph Dimension.} Let $\H \subseteq \mathcal{Y}^\mathcal{X}$ be a categorical function class such that $\mathcal{Y}=[l]=\set{1\dots,l}$. Let $S \subseteq \mathcal{X}$. We say that $\H$ $G$-shatters $S$ if there exists an $f : S \mapsto \mathcal{Y}$ such that for every $T \subseteq S$ there is a $g \in \H$ such that \begin{eqnarray*} \forall x \in T,\; g(x)=f(x)\; \text{and}\;\; \forall x\in S\setminus T,\; g(x)\neq f(x). \end{eqnarray*} The graph dimension of $\H$, denoted $d_G(\H)$, is the maximal cardinality of a set that is $G$-shattered by $\H$. \paragraph{Natarajan Dimension.} Let $\H \subseteq \mathcal{Y}^\mathcal{X}$ be a categorical function class such that $\mathcal{Y}=[l]=\set{1\dots,l}$. Let $S \subseteq \mathcal{X}$. We say that $\H$ $N$-shatters $S$ if there exist $f_1, f_2 : S \mapsto \mathcal{Y}$ such that for every $y \in S$ $f_1(y) \neq f_2(y)$, and for every $T \subseteq S$ there is a $g\in \H$ such that \begin{eqnarray*} \forall x\in T,\; g(x)=f_1(x),\; \text{and}\;\; \forall x\in S\setminus T,\; g(x)=f_2(x). \end{eqnarray*} The Natarajan dimension of $\H$, denoted $d_N(\H)$, is the maximal cardinality of a set that is $N$-shattered by $\H$. \paragraph{Growth Function.} The growth fuction $\Pi_\H:\mathbb{N} \mapsto \mathbb{N}$ for a binary function class $\H:\mathcal{X} \mapsto \set{0,1}$ is defined by \begin{eqnarray*} \forall m\in \mathbb{N},\;\Pi_\H(m)= \max_{\set{x_1,\dots,x_m}\subseteq \mathcal{X}}|\set{(h(x_1),\dots,h(x_m)):h\in \H}| \end{eqnarray*} And the $\operatorname{VC}$-dimension of $\H$ is defined by \begin{eqnarray*} \operatorname{VC}(\H)=\max\set{m:\Pi_\H(m)=2^m}. \end{eqnarray*} \section{Algorithm}\label{sec4} We have a base hypothesis class $\H$ with domain $\mathcal{Z}$ and range $\mathcal{Y}$ that can be $\set{1,\dots,l}$ or $\mathbb{R}$. The learner receives a labeled uncorrupted sample and has access during the training to possible corruptions by the adversary. We employ the regret minimization algorithm proposed by \citet{FeigeMS15} for binary classification, and extend it to the regression and multi-class classification settings. A brief description of the algorithm is as follows. Given $x\in\mathcal{X}$, we define a $|\rho(x)|\times\H$ loss matrix $M_x$ such that $M_x(z,h)=\mathbb{I}_{\{h(z)\neq y\}}$, where $y=c^*(x)$. The learner's strategy is a distribution $Q$ over $\H$. The adversary's strategy $P_x\in\Delta(\rho(x))$, for a given $x\in\mathcal{X}$, is a distribution over the corrupted inputs $\rho(x)$. We can treat $P$ as a vector of distributions $P_x$ over all $x\in\mathcal{X}$. Via the minimax principle, the value of the game is \begin{eqnarray*} v=\min_{Q}\max_{P}\mathbb{E}_{x\sim D}[P_x^TM_xQ]=\max_{P}\min_{Q}\mathbb{E}_{x\sim D}[P_x^TM_xQ] \end{eqnarray*} For a given $P$, a learner's minimizing $Q$ is simply a hypothesis that minimizes the error when the distribution over pairs $(z, y) \in \mathcal{Z} \times \mathcal{Y}$ is $D^P$, where \begin{eqnarray*} D^P(z,y)= \sum_{x:\;c^*(x)=y \wedge z\in \rho(x)}P_x(z)D(x) . \end{eqnarray*} Hence, the learner selects \begin{eqnarray*} h^P =\arg\min_{h\in \H}\mathbb{E}_{(z,y)\sim D^P}[\mathsf{loss}(h(z),y)] . \end{eqnarray*} A hypotheses $h^P$ can be found using the ERM oracle, when $D^P$ is the empirical distribution over a training sample. Repeating this process multiple times yields a mixture of hypotheses $\Tilde{h}\in\Delta(\H)$ (mixed strategy- a distribution $Q$ over $\H$) for the learner. The learner uses a randomized classifier chosen uniformly from this mixture. This also yields a mixed strategy for the adversary, defined by an average of vectors $P$. Therefore, for a given $x\in\mathcal{X}$, the adversary uses a distribution $P_x\in\Delta(\rho(x))$ over corrupted inputs. \begin{algorithm}[H] \caption{} \begin{algorithmic}[1] \Statex \textbf{parameter}: $\eta>0$ \ForAll {\texttt {$(x,y)\in S, z\in \rho(x)$}} \Comment{initialize weights and distributions vector} \State $w_1(z,(x,y)) \gets 1$, $\forall (x,y)\in S, \forall z\in \rho(x)$ \State $P^{1}(z,(x,y)) \gets \frac{w_{1}(z,(x,y))}{\sum_{z'\in \rho(x)}w_{1}(z',(x,y))}$ \Comment for each $(x,y)\in S$ we have a distribution over $\rho(x)$ \EndFor \For{\texttt{t = 1:T}} \State \texttt{$h_t \gets \arg\underset{h\in \H}\min E_{(z,y)\sim D^{P^t}}[\mathsf{loss}(h(z),y] $}\Comment using the ERM oracle for $\H$ \ForAll {\texttt {$(x,y)\in S, z\in \rho(x)$}} \Comment{update weights for $P^{t+1}$} \State $w_{t+1}(z,(x,y)) \gets (1+\eta\cdot[\mathsf{loss}(h_t(z),y])\cdot w_t(z,(x,y)) $ \State $P^{t+1}(z,(x,y)) \gets \frac{w_{t+1}(z,(x,y))}{\sum_{z'\in \rho(x)}w_{t+1}(z',(x,y))}$ \EndFor \EndFor \State \textbf{return} $h_1,\dots,h_T$ for the learner, $\frac{1}{T}\sum_{t=1}^T P^t$ for the adversary \end{algorithmic} \end{algorithm} \noindent Similar to \citet[Theorem 1]{FeigeMS15}, for the binary classification case and zero-one loss we have: \begin{theorem}\citep*[Theorem 1]{FeigeMS15} Fix a sample S of size $n$, and let $T \geq \frac{4n\log(k)}{\epsilon^2}$, where $k$ is the number of possible corruptions for each input. For an uncorrupted sample S we have that the strategies $P =\frac{1}{T}\sum_{t=1}^T P^t$ for the adversary and $h_1,\dots,h_T$ (each one of them chosen uniformly) for the learner are $\epsilon$-optimal strategies on S. \end{theorem} Assuming a bounded loss, i.e., $\mathsf{loss}(h(z),y)\leq 1\; ,\forall x\in \mathcal{X},\forall z\in \mathcal{Z},\forall h \in \H$, the result remains the same for the other settings. \section{Generalization Bound For Binary Classification}\label{sec5} We would like to show that if the sample $S$ is large enough, then the policy achieved by the algorithm above will generalize well. We both improve a generalization bound, previously found in \citet{FeigeMS15}, which handles any mixture of hypotheses from $\H$, and also are able to handle an infinite hypothesis class $\H$. The sample complexity is improved from $\O(\frac{1}{\epsilon^4}\log(\frac{|\H|}{\delta}))$ to $\O(\frac{1}{\epsilon^2}(k\log(k)\operatorname{VC}(\H)+\log\frac{1}{\delta}))$. \begin{theorem} \label{thm:binary-bound}Let $\H:\mathcal{Z} \mapsto \set{0,1}$ be a hypothesis class with finite $\operatorname{VC}$-dimension. There is a sample complexity $m_0=\O(\frac{1}{\epsilon^2}(k\log(k)\operatorname{VC}(\H)+\log\frac{1}{\delta})$), such that for $|S|\geq m_0$, for every $\Tilde{h}\in\Delta(\H)$ \begin{eqnarray*} |\operatorname{Risk}(\Tilde{h})-\mywidehat{\operatorname{Risk}}(\Tilde{h})|\leq \epsilon \end{eqnarray*} with probability at least $1-\delta$. \end{theorem} \begin{lemma}\label{lem:rad-conv-kfold} For any $k$ real valued function classes $\mathcal{F}^{(1)},\ldots,\mathcal{F}^{(k)}$, over a set $\mathcal{X}$ and\\$\mathbf{x}=(x_1,\ldots,x_n)\in \mathcal{X}^n$, we have \begin{eqnarray*} R_n( \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)})_{j\in[k]}) | \mathbf{x}) & = & R_n( \max((\mathcal{F}^{(j)})_{j\in[k]}) | \mathbf{x}). \end{eqnarray*} \end{lemma} \begin{proof} It is easily seen that $\max((\mathcal{F}^{(j)})_{j\in[k]})\subseteq\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)})_{j\in[k]})$, since for any $f^{(j)}\in \mathcal{F}^{(j)}$, $j\in[k]$ and $T=1$ we have that $\max_jf^{(j)}\in \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)})_{j\in[k]}) $. This proves that the right-hand side is at least as large as the left-hand side. Conversely, \begin{eqnarray*} R_n( \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)})_{j\in[k]}) | \mathbf{x}) &=& E_{\mathbf{\sigma}} \mathop{ \sup_{ (f_t^{(j)})_{j\in[k],t\in[T]} } }_{(\alpha_t)_{t\in[T]}} \frac1n\sum_{i=1}^n\sigma_i \max_{j\in[k]} \sum_{t=1}^{T}\alpha_t f^{(j)}_t (x_i) \\ &\le& E_{\mathbf{\sigma}} \mathop{ \sup_{ (f_t^{(j)})_{j\in[k],t\in[T]} } }_{(\alpha_t)_{t\in[T]}} \frac1n\sum_{i=1}^n\sigma_i \sum_{t=1}^{T}\alpha_t \max_{j\in[k]} f^{(j)}_t (x_i) \\ &=& R_n( \operatorname{conv}( \max((\mathcal{F}^{(j)})_{j\in[k]})) | \mathbf{x}) = R_n( \max((\mathcal{F}^{(j)})_{j\in[k]}) | \mathbf{x}) , \end{eqnarray*} where the last equality stems from the well-known identity $R_n(\mathcal{F}| \mathbf{x})=R_n(\operatorname{conv}(\mathcal{F}) | \mathbf{x})$\\ \citep[Theorem 3.3]{boucheron05}. \end{proof} \begin{lemma} \label{lem:k-fold-op} Let $\Psi:\mathcal{F}_1\times\ldots\times\mathcal{F}_k\to\mathcal{F}$ be an arbitrary mapping, where $\mathcal{F},\mathcal{F}_1,\ldots,\mathcal{F}_k\subseteq\set{-1,1}^X$ and $\operatorname{VC}(\mathcal{F}_j)=d_j$ for $j\in[k]$. Then the VC-dimension of $\Psi(\mathcal{F}_1\times\ldots\times\mathcal{F}_k)$ is less than $2k\log(3k)\bar d$, where $\bar d:=\frac1k\sum_{i=1}^k d_j$. \end{lemma} \begin{proof} We adapt the argument of \citet[Lemma 3.2.3]{MR1072253}, which is stated therein for $k$-fold unions and intersections. The $k=1$ case is trivial, so assume $k\ge 2$. For any $S\subseteq\mathcal{X}$, define $\Psi(\mathcal{F}_1\times\ldots\times\mathcal{F}_k)(S)\subseteq\set{-1,1}^S$ to be the restriction of $\Psi(\mathcal{F}_1\times\ldots\times\mathcal{F}_k)$ to $S$. The key observation is that \begin{eqnarray*} |\Psi( \mathcal{F}_1\times\ldots\times\mathcal{F}_k )(S)| &\le& \prod_{j=1}^k |\mathcal{F}_j(S)|\\ &\le& \prod_{j=1}^k(e|S|/d_j)^{d_j} \\ &\le& (e|S|/\bar d)^{\bar d k}. \end{eqnarray*} The last inequality requires proof. After taking logarithms and dividing both sides by $k$, it is equivalent to the claim that $$ \bar d\log\bar d\le \frac1k\sum_{j=1}^k d_j\log d_j\;,$$ an immediate consequence of Jensen's inequality applied to the convex function $f(x)=x\log x$. The rest of the argument is identical that of \citeauthor{MR1072253}: one readily verifies that for $m=|S|=2\bar d k\log(3k)$, we have $(em/\bar d)^{\bar d k}<2^m$. \end{proof} \begin{theorem}\citep[Theorem 3.1]{mohri-book2012} \label{rad-gen-bound} Let $\mathcal{F}$ be a family of functions mapping from $\mathcal{W}$ to {[}0,1{]}. Denote $E(f)\coloneqq E_{w\sim D}[f(w)]$ and $\hat{E}_{S}(f)=\frac{1}{n}\sum_{i=1}^n f(w_{i})$. Then, for every $\delta > 0$ with probability at least $1 - \delta$, for all $f \in \mathcal{F}$:\\ \begin{eqnarray*} E[f]-\hat{E}_{S}(f)\leq 2R_n(\mathcal{F} | \mathbf{w})+3\sqrt{\frac{\log(2/\delta)}{2n}}. \end{eqnarray*} \end{theorem} \begin{theorem}\citep{Dudley1967290,DBLP:journals/jmlr/BartlettM02}\label{rad-vc-bound} Let $d=\operatorname{VC}(\mathcal{F})$ and $S=(w_1,\ldots,w_n)\\ =\mathbf{w}\in \mathcal{W}^n$, then for $n\geq d\geq1$ and for some absolute constant $c>0$: \begin{eqnarray*} R_n(\mathcal{F}|\mathbf{w})\leq c\sqrt{\frac{d}{n}}. \end{eqnarray*} \end{theorem} \begin{proof}\textbf{of Theorem \ref{thm:binary-bound}}\label{prf:binary-bound} Our strategy is to bound the empirical Rademacher complexity of the loss class of $\Tilde{h}\in\Delta(\H)$. As we mentioned in Section \ref{sec3}, the loss class is $\operatorname{conv}^{\rho}(L_\H) = \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})$, we use the notation $\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})$. Recall that functions contained in $\mathcal{F}_\H^{(j)}$ are loss functions of the learner when the adversary corrupts input $x$ to $z_j\in \rho(x)$. Combining everything together, \begin{eqnarray*} |\operatorname{Risk}(\Tilde{h})-\mywidehat{\operatorname{Risk}}(\Tilde{h})|&=& |E_{(x,y)\sim D}\max_{j\in[k]}\sum_{t=1}^T \alpha_t f_t^{(j)}(x,y)-\frac{1}{|S|}\underset{(x,y)\in S}{{\displaystyle \sum}}\max_{j\in[k]}\sum_{t=1}^T \alpha_t f_t^{(j)}(x,y)| \\ &\overset{(i)}\leq& 2R_n(\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y}))+3\sqrt{\frac{\log(2/\delta)}{2|S|}} \\ &\overset{(ii)}=& 2R_n(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y}))+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(iii)}\leq& 2c\sqrt{\frac{\operatorname{VC}(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})}{|S|}}+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(iv)}\leq& 2c\sqrt{\frac{2k\log(3k)\max_{j\in[k]}\operatorname{VC}(\mathcal{F}_\H^{(j)})}{|S|}}+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(v)}\leq& 2c\sqrt{\frac{2k\log 3k\operatorname{VC}(\H)}{|S|}}+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\leq& \epsilon, \end{eqnarray*} where (i) stems from Theorem \ref{rad-gen-bound} (generalization error by Rademacher complexity bound for the function class $\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})$, (ii) stems from Lemma \ref{lem:rad-conv-kfold}, (iii) stems from Theorem \ref{rad-vc-bound} (bound on Rademacher complexity using VC-dimension), (iv) stems from Lemma \ref{lem:k-fold-op} and (v) stems from Lemma~\ref{lem:vc-lossclass-graphdimension}. \end{proof} \section{Generalization Bound For Multi-Class Classification}\label{sec6} Let $\H\subseteq \mathcal{Y}^{\mathcal{Z}}$ be a function class such that $\mathcal{Y}=[l]=\set{1\dots,l}$. We follow similar arguments to the binary case. \begin{theorem}\label{thm:multiclass-bound} Let $\H$ be a function class with domain $\mathcal{Z}$ and range $\mathcal{Y}=[l]$ with finite Graph-dimension $d_G(\H)$. There is a sample complexity $m_0=\O(\frac{1}{\epsilon^2}(k\log(k)d_G(\H)+\log\frac{1}{\delta})$), such that for $|S|\geq m_0$, for every $\Tilde{h}\in\Delta(\H)$, \begin{eqnarray*} |\operatorname{Risk}(\Tilde{h})-\mywidehat{\operatorname{Risk}}(\Tilde{h})|\leq \epsilon \end{eqnarray*} with probability at least $1-\delta$. \end{theorem} \begin{lemma} \label{lem:vc-lossclass-graphdimension} Let $\H$ be a function class with domain $\mathcal{Z}$ and range $\mathcal{Y}=[l]$. Denote the Graph-dimension of $\H$ by $d_G(\H)$. Then \begin{eqnarray*} \operatorname{VC}(\mathcal{F}_\H^{(j)})\leq d_G(\H). \end{eqnarray*} In particular, for binary-valued classes, $\operatorname{VC}(\mathcal{F}_\H^{(j)})\leq \operatorname{VC}(\H)$ --- since for these, the VC- and Graph-dimensions coincide. \end{lemma} For the proof of Theorem \ref{thm:multiclass-bound}, we follow the same proof of Theorem \ref{thm:binary-bound} and use the Graph-dimension property of Lemma \ref{lem:vc-lossclass-graphdimension} in the {\em (v)} inequality.\\ \paragraph{Remark.} A similar bound to that of Theorem \ref{thm:binary-bound} can be achieved by using the Natarajan dimension and the fact that \begin{eqnarray*} d_G(\H)\leq 4.67\log_2(|\mathcal{Y}|)d_N(\H) \end{eqnarray*} as previously shown \citet{DBLP:journals/jcss/Ben-DavidCHL95}. \section{Generalization Bound For Regression}\label{sec7} Let $\H\subseteq\mathbb{R}^{\mathcal{Z}}$ be a hypothesis class of real functions. We refer to a bounded regression problem, we assume a bounded loss function by 1. In order to use similar arguments to the binary case, we need an analogous to Lemma \ref{lem:k-fold-op} for the fat-shattering dimension and understand the connection between the shattering dimension of loss classes ($L_1$ and $L_2$) to the original function class. \begin{theorem}\label{thm:regression-bound} Let $\H$ be a function class with domain $\mathcal{Z}$ and range $\mathbb{R}$. Assume $\H$ has a finite $\gamma$-fat-shattering dimension for all $\gamma > 0$. Denote $m_\H(\gamma)=\int_{0}^{1} \sqrt{\operatorname{fat}_{c\gamma}(\H) \log(\frac{2}{\gamma})}d\gamma$, where c>0 is an absolute constant. For the $L_1$ loss function, there is a sample complexity $m_0= \O(\frac{1}{\epsilon^2}(k\log(k)m_\H(\gamma)+\log\frac{1}{\delta}))$, such that for $|S|\geq m_0$, for every $\Tilde{h}\in\Delta(\H),$ \begin{eqnarray*} |\operatorname{Risk}(\Tilde{h})-\mywidehat{\operatorname{Risk}}(\Tilde{h})|\leq \epsilon \end{eqnarray*} with probability at least $1-\delta$. \end{theorem} \paragraph{Remark.} In case of integral divergence we can use a refined version of Dudley's entropy integral as in Theorem \ref{rad-fatdimension-bound}. \begin{corollary}\label{regression-bound-hyperplanes} Let $\H$ be a function class of homogeneous hyperplanes with domain $\mathbb{R}^m$. Using the same assumptions as in Theorem \ref{thm:regression-bound}, the sample complexity is $m_0= \O(\frac{1}{\epsilon^2}(k\log^2(k/\epsilon)+\log\frac{1}{\delta}))$. \end{corollary} \begin{corollary} For the $L_2$ loss the same result of Theorem \ref{thm:regression-bound} holds when we redefine $m_\H(\gamma)=\int_{0}^{1} \sqrt{\operatorname{fat}_{c\gamma/2}(\H) \log(\frac{2}{\gamma})}d\gamma$. \end{corollary} \subsection{Shattering dimension of the class $\max((\mathcal{A}^{(j)})_{j\in[k]})$} The main result of this section is bounding the fat shattering dimension of $\max((\mathcal{A}^{(j)})_{j\in[k]})$ class. \begin{theorem} \label{thm:fat-kmax} For any $k$ real valued functions classes $\mathcal{F}_{1},\dots,\mathcal{F}_{k}$ with finite fat-shattering dimension, we have \begin{eqnarray*} \operatorname{fat}_\gamma(\max((\mathcal{F}_{j})_{j\in[k]})) < 2\log(3k)\sum_{j=1}^k\operatorname{fat}_\gamma(\mathcal{F}_{j}) \end{eqnarray*} for all $\gamma>0$. \end{theorem} \paragraph{Remark.} This result generalizes an analogous bound obtained in \citet{kontorovich2018rademacher} for maxima of linear classes. For a fixed scale $\gamma>0$, \citet{DBLP:journals/corr/abs-1807-07924} have recently shown that the $O(\log k)$ factor cannot, in general, be removed. Whether a single function class can attain the lower bound for {\em every} $\gamma>0$ simultaneously is an open problem. We begin with an auxiliary definition. We say that $\mathcal{F}$ ``$\gamma$-shatters a set $S$ at zero'' if the shift (or witness) $r$ is constrained to be $0$ in the the usual $\gamma$-shattering definition (has appeared previously in \citet{DBLP:journals/tit/GottliebKK14}). The analogous dimension will be denoted by $\operatorname{fat}_\gamma^0(\mathcal{F})$. \begin{lemma} \label{lem:fat0} For all $\mathcal{F}\subseteq\mathbb{R}^\mathcal{X}$ and $\gamma>0$, we have \begin{eqnarray} \label{eq:fat-aux} \operatorname{fat}_\gamma(\mathcal{F}) = \max_{r\in\mathbb{R}^\mathcal{X}} \operatorname{fat}_\gamma^0(\mathcal{F}-r), \end{eqnarray} where $\mathcal{F}-r=\set{f-r: f\in\mathcal{F}}$ is the $r$-shifted class; in particular, the maximum is always achieved. \end{lemma} \begin{proof} Fix $\mathcal{F}$ and $\gamma$. For any choice of $r\in\mathbb{R}^\mathcal{X}$, if $\mathcal{F}-r$ $\gamma$-shatters some set $S\subseteq\mathcal{X}$ at zero, then then $\mathcal{F}$ $\gamma$-shatters $S$ in the usual sense with shift $r_S\in\mathbb{R}^S$ (i.e., the restriction of $r$ to $S$). This proves that the left-hand side of (\ref{eq:fat-aux}) is at least as large as the right-hand side. Conversely, suppose that $\mathcal{F}$ $\gamma$-shatters some $S\subseteq\mathcal{X}$ in the usual sense, with some shift $r\in\mathbb{R}^S$. Choosing $r'\in\mathbb{R}^\mathcal{X}$ by $r'_S=r$ and $r'_{\mathcal{X}\setminus S}=0$, we see that $\mathcal{F}-r'$ $\gamma$-shatters $S$ at zero. This proves the other direction and hence the claim. \end{proof} \begin{lemma} \label{lem:disambig} Suppose that $F\subseteq\set{-1,1,\star}^m$ has VC-dimension $d$ in the sense that some $J\subseteq[m]$ of size $d$ verifies $F(J)=\set{-1,1}^J$ and for all $J'\subseteq[m]$ with $|J'|>d$, we have $F(J')\subsetneq\set{-1,1}^{J'}$. Then there is a mapping $\phi:F\to\set{-1,1}^m$ such that (i) for all $v\in F$ and all $i\in[m]$, we have $v_i\neq\star\implies (\phi(v))_i=v_i$ and (ii) $\phi(F)$ does not shatter more than $d$ points. \end{lemma} \begin{proof} The mapping $\phi$ must resolve each ``ambiguity'' $v_i=\star$ as $(\phi(v))_i\in\set{-1,1}$ in such a way that the resulting set of vectors $\phi(F)$ does not shatter more points than $F$ does. We achieve this via an iterative procedure, which initializes $F':=F$ and modifies each $v\in F'$, element-wise, until $F'\subseteq\set{-1,1}^m$ --- that is, all of the ambguities have been resolved. Suppose that the VC-dimension of $F'$ is $d$ and some $v\in F'$ and $i\in[m]$ are such that $v_i=\star$; we must choose a value for $(\phi(v))_i\in\set{-1,1}$. If one of these choices ensures the condition that the VC-dimension will not increase, then we're done. Otherwise, the VC-dimension will increase from $d$ to $d+1$ for {\em both} choices of $(\phi(v))_i=1$ and $(\phi(v))_i=-1$. This means, in particular, that $F$ shatters some set $J\subseteq[m]$ of size $d$ and $i\notin J$ --- since otherwise, disambiguating $v_i$ from $\star$ to $\pm1$ would not increase the VC-dimension. Since the choice $(\phi(v))_i=1$ increases the VC-dimension, it must be the case that \begin{eqnarray} \label{eq:z} F(J\cup\set{i})=\set{-1,1}^{J\cup\set{i}}\setminus \set{z_{J\cup\set{i}}} \end{eqnarray} for some ``missing witness'' $z \in\set{-1,1,\star}^m $, which agrees with $v$ on $J$ and $z_i=1$; the notation $z_E$ indicates the restriction of $Z$ to the index set $E\subseteq[m]$. Analogously, since the choice $(\phi(v))_i=-1$ also increases the VC-dimension, we have \begin{eqnarray} \label{eq:z'} F(J\cup\set{i})=\set{-1,1}^{J\cup\set{i}}\setminus \set{z'_{J\cup\set{i}}}, \end{eqnarray} where $z'_J=v_J$ and $z_i'=-1$. The conditions (\ref{eq:z}) and (\ref{eq:z'}) are in obvious contradiction, from which we conclude that the ambiguity can be resolved for each $v_i=\star$ without increasing the VC-dimension. \end{proof} \begin{proof} \textbf{of Theorem \ref{thm:fat-kmax}} First, we observe that $r$-shift commutes with the max operator: \begin{eqnarray*} \max((\mathcal{F}_j-r)_{j\in[k]}) = \max((\mathcal{F}_{j})_{j\in[k]})-r \end{eqnarray*} and so, in light of Lemma~\ref{lem:fat0}, we have \begin{eqnarray*} \operatorname{fat}_\gamma( \max((\mathcal{F}_{j})_{j\in[k]}) ) = \max_r \operatorname{fat}_\gamma^0( \max((\mathcal{F}_{j})_{j\in[k]}) -r ) =\max_r \operatorname{fat}_\gamma^0( \max((\mathcal{F}_j-r)_{j\in[k]}) ) . \end{eqnarray*} Hence, to prove Theorem~\ref{thm:fat-kmax}, it suffices to show that \begin{eqnarray} \label{eq:kfat0} \operatorname{fat}^0_\gamma(\max((\mathcal{F}_{j})_{j\in[k]})) \le 2\log(3k)\sum_{j=1}^k\operatorname{fat}^0_\gamma(\mathcal{F}_{j}) . \end{eqnarray} To prove (\ref{eq:kfat0}), let us fix some $S=\set{x_1,\ldots,x_m}\subset\mathcal{X}$ and convert each $\mathcal{F}_j(S)\subseteq\mathbb{R}^m$ to a finite class $\mathcal{F}_j^\star(S)\subseteq\set{-\gamma,\gamma,\star}^m$ as follows. For every vector in $v\in\mathcal{F}_j(S)$, define $v^\star\in\mathcal{F}_j^\star(S)$ by: $v^\star_i=\operatorname{sgn}(v_i)\gamma$ if $|v_i|\ge\gamma$ and $v^\star_i=\star$ else. The notion of shattering (at zero) remains the same: a set $T\subseteq S$ is shattered by $\mathcal{F}_j$ iff $ \mathcal{F}_j^\star(T)=\set{-\gamma,\gamma}^T$. Lemma~\ref{lem:disambig} furnishes a mapping $\phi:\mathcal{F}_j^\star(S)\to\set{-\gamma,\gamma}^m$ such that (i) for all $v\in\mathcal{F}_j^\star(S)$ and all $i\in[m]$, we have $v_i\neq\star\implies (\phi(v))_i=v_i$ and (ii) $\phi(\mathcal{F}_j^\star(S))$ does not shatter more points than $\mathcal{F}_j^\star(S)$. Together, properties (i) and (ii) imply that $\operatorname{fat}^0_\gamma(\mathcal{F}_j(S))=\operatorname{fat}^0_\gamma(\phi(\mathcal{F}_j^\star(S)))$ for all $j$. Finally, observe that any $d$ points in $S$ $\gamma$-shattered by $\max(\mathcal{F}_{j\in[k]})$ are also shattered by\\ $\max(\phi(\mathcal{F}_{j\in[k]}^\star(S))$. Applying Lemma~\ref{lem:k-fold-op} with $\Psi(f_1,\ldots,f_k)(x)=\max_{j\in[k]}f_j(x)$ shows that\\ $\max(\phi(\mathcal{F}_{j\in[k]}^\star(S))$ cannot shatter $2\log(3k)\sum_{j=1}^kd_j$ points, where $d_j= \operatorname{fat}^0_\gamma(\phi(\mathcal{F}_j^\star(S))) =\\ \operatorname{fat}^0_\gamma(\mathcal{F}_j(S)) \le \operatorname{fat}^0_\gamma(\mathcal{F}_j) $. We have shown that, for all finite $S\subseteq\mathcal{X}$, we have $\operatorname{fat}^0_\gamma(\max(\mathcal{F}_{j\in[k]}(S)))\\ \le 2\log(3k)\sum_{j=1}^k\operatorname{fat}^0_\gamma(\mathcal{F}_j(S)$. Since this latter estimate holds independently of $S$, it is also an upper bound on\\ $\operatorname{fat}^0_\gamma(\max(\mathcal{F}_{j\in[k]}))$. \end{proof} \subsection{Shattering dimension of $L_1$ and $L_2$ loss classes} \begin{lemma} \label{fatdimension-lossclassL2-bound}Let $\H \subset\mathbb{R}^\mathcal{X}$ be a real valued function class. denote $L_\H^1$ and $L_\H^2$ the $L_1$ and $L_2$ loss classes of $\H$ respectively. Assume $L_\H^2$ is bounded by $M$. For any $\H$, \begin{eqnarray*} \operatorname{fat}_\gamma(L_\H^1)&\le& 8\operatorname{fat}_{\gamma}(\H),\;\;\;\mbox{ and }\;\;\; \operatorname{fat}_\gamma(L_\H^2)\le 8\operatorname{fat}_{\gamma/2M}(\H). \end{eqnarray*} \end{lemma} \begin{lemma} \label{lem:fat-losses} For $p\in\set{1,2}$ and $j\in[k]$, define \begin{eqnarray*} \mathcal{F}_\H^{(p,j)}=\set{\mathcal{X}\times \mathcal{Y} \ni (x,y)\mapsto |h(z_j)\neq y|^p:h\in \H,\;\rho(x)=\set{z_1,\dots,z_k}}. \end{eqnarray*} Then \begin{eqnarray*} \operatorname{conv}^{\rho}(L_\H^p) = \max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(p,j)}_{\H})_{j\in[k]}) \end{eqnarray*} and, for all $\gamma>0$, \begin{eqnarray*} \operatorname{fat}_\gamma(\mathcal{F}^{(p,j)}_{\H}) \le \operatorname{fat}_\gamma(L_\H^p). \end{eqnarray*} \end{lemma} \begin{proof} The first claim is immediate from the definitions, while the second is proved using the argument (almost verbatim) of Lemma~\ref{lem:vc-lossclass-graphdimension}. \end{proof} \hide{ \begin{lemma}\label{vc-unionclass-bound} For $\H,\mathcal{G}\subseteq\set{-1,1}^X$ with finite VC-dimension, we have \begin{eqnarray*} \operatorname{VC}(\H\cup \mathcal{G})\leq \operatorname{VC}(\H)+\operatorname{VC}(\mathcal{G})+1, \end{eqnarray*} and for $\H,\mathcal{G}\subseteq \mathbb{R}^X$ with finite $\gamma$-fat-shattering dimension, we have \begin{eqnarray*} \operatorname{fat}_{\gamma}(\H\cup \mathcal{G})\leq \operatorname{fat}_{\gamma}(\H)+\operatorname{fat}_{\gamma}(\mathcal{G})+1. \end{eqnarray*} \end{lemma} } \begin{proof}[of Lemma~\ref{fatdimension-lossclassL2-bound}] For any $\mathcal{X}$ and any function class $\H \subset\mathbb{R}^\mathcal{X}$, define the {\em difference class} $\H^\Delta\subset\mathbb{R}^{\mathcal{X}\times\mathbb{R}}$ as \begin{eqnarray*} \H^\Delta = \set{ \mathcal{X}\times\mathbb{R}\ni (x,y)\mapsto \Delta_h(x,y):= h(x)-y ; h\in\H}. \end{eqnarray*} In words: $\H^\Delta$ consists of all functions $\Delta_h(x,y)= h(x)-y$ indexed by $h\in\H$. It is easy to see that for all $\gamma>0$, we have $\operatorname{fat}_\gamma(\H^\Delta)\le\operatorname{fat}_\gamma(\H)$. Indeed, if $\H^\Delta$ $\gamma$-shatters some set $\set{(x_1,y_1),\ldots,(x_k,y_k)}\subset\mathcal{X}\times\mathbb{R}$ with shift $r\in\mathbb{R}^k$, then $\H$ $\gamma$-shatters the set $\set{x_1,\ldots,x_k}\subset\mathcal{X}$ with shift $r+(y_1,\ldots,y_k)$. Next, we observe that taking the absolute value does not significantly increase the fat-shattering dimension. Indeed, for any real-valued function class $\mathcal{F}$, define $\operatorname{abs}(\mathcal{F}) :=\set{|f|;\;f\in\mathcal{F}}$. Observe that $\operatorname{abs}(\mathcal{F})\subseteq \max((F_j)_{j\in[2]})$, where $\mathcal{F}_1=\mathcal{F}$ and $\mathcal{F}_2=-\mathcal{F}=:\set{-f;f\in\mathcal{F}}$. It follows from Theorem~\ref{thm:fat-kmax} that \begin{eqnarray} \label{eq:fat-abs} \operatorname{fat}_\gamma(\operatorname{abs}(\mathcal{F}))<2\log6(\operatorname{fat}_\gamma(\mathcal{F})+\operatorname{fat}_\gamma(-\mathcal{F}))<8\operatorname{fat}_\gamma(\mathcal{F}). \end{eqnarray} \hide{ Clearly, $\operatorname{fat}_\gamma(\operatorname{abs}(\mathcal{F}))=\operatorname{fat}_\gamma(\mathcal{F})$. Because $\mathcal{F}$ is positive. Then, \begin{eqnarray*} \operatorname{fat}_\gamma(\operatorname{abs}(\mathcal{F})) &\le& \operatorname{fat}_\gamma(\operatorname{abs}(\mathcal{F}_+)))+\operatorname{fat}_\gamma(\operatorname{abs}(\mathcal{F}_-))+1 \\ &=& 2\operatorname{fat}_{\gamma}(\mathcal{F})+1, \end{eqnarray*} Finally, } Next, define $\mathcal{F}$ as the $L_1$ loss class of $\H$: \begin{eqnarray*} \mathcal{F} = \set{ \mathcal{X}\times\mathbb{R}\ni (x,y)\mapsto |h(x)-y)| ; h\in\H}. \end{eqnarray*} Then \begin{eqnarray*} \operatorname{fat}_\gamma(\mathcal{F}) &=& \operatorname{fat}_\gamma(\operatorname{abs}(\H^\Delta)) \\ &\le& 8\operatorname{fat}_{\gamma}(\H^\Delta) \\ &\le& 8\operatorname{fat}_{\gamma}(\H); \end{eqnarray*} this proves the claim for $L_1$. To analyze the $L_2$ case, consider $\mathcal{F}\subset[0,M]^\mathcal{X}$ and define $\mathcal{F}^{\circ2} :=\set{f^2;f\in\mathcal{F}}$. We would like to bound $\operatorname{fat}_\gamma(\mathcal{F}^{\circ2})$ in terms of $\operatorname{fat}_\gamma(\mathcal{F})$. Suppose that $\mathcal{F}^{\circ2}$ $\gamma$-shatters some set $\set{x_1,\ldots,x_k}$ with shift $r^2=(r_1^2,\ldots,r_k^2)\in[0,M]^k$ (there is no loss of generality in assuming that the shift has the same range as the function class). Using the elementary inequality \begin{eqnarray*} |a^2-b^2| \le 2M|a-b|, \qquad a,b\in[0,M], \end{eqnarray*} we conclude that $\mathcal{F}$ is able to $\gamma/(2M)$-shatter the same $k$ points and thus $\operatorname{fat}_\gamma(\mathcal{F}^{\circ2}) \le \operatorname{fat}_{\gamma/(2M)}(\mathcal{F})$. To extend this result to the case where $\mathcal{F}\subset[-M,M]^\mathcal{X}$, we use (\ref{eq:fat-abs}). \hide{ decompose $\mathcal{F}$ as $\mathcal{F}=\mathcal{F}_+\cup\mathcal{F}_-$, where $\mathcal{F}_+ =\mathcal{F}\cap[0,M]^\mathcal{X} $ and $\mathcal{F}_- =\mathcal{F}\cap[-M,0]^\mathcal{X} $. Clearly, then, $ \mathcal{F}^{\circ2} = (\mathcal{F}_+)^{\circ2} \cup (\mathcal{F}_-)^{\circ2} $. Furthermore, using Lemma \ref{vc-unionclass-bound} we observe that for any $\H,\mathcal{G}\subset\mathbb{R}^\mathcal{X}$, we have \begin{eqnarray*} \operatorname{fat}_\gamma(\H\cup\mathcal{G})\le \operatorname{fat}_\gamma(\H)+\operatorname{fat}_\gamma(\mathcal{G})+1, \end{eqnarray*} whence \begin{eqnarray*} \operatorname{fat}_\gamma(\mathcal{F}^{\circ2}) &\le& \operatorname{fat}_\gamma((\mathcal{F}_+)^{\circ2})+\operatorname{fat}_\gamma((\mathcal{F}_-)^{\circ2})+1 \\ &\le& \operatorname{fat}_{\gamma/(2M)}(\mathcal{F}_+) + \operatorname{fat}_{\gamma/(2M)}(\mathcal{F}_-) +1 \\ &\le& 2\operatorname{fat}_{\gamma/(2M)}(\mathcal{F})+1, \end{eqnarray*} where the second inequality follows from the fact that $\operatorname{fat}_\gamma(-\mathcal{F})=\operatorname{fat}_\gamma(\mathcal{F})$. } In particular, define $\mathcal{F}$ as the $L_2$ loss class of $\H$: \begin{eqnarray*} \mathcal{F} = \set{ \mathcal{X}\times\mathbb{R}\ni (x,y)\mapsto (h(x)-y)^2 ; h\in\H}. \end{eqnarray*} Then \begin{eqnarray*} \operatorname{fat}_\gamma(\mathcal{F}) &=& \operatorname{fat}_\gamma((\H^\Delta)^{\circ2}) \\ &=& \operatorname{fat}_\gamma((\operatorname{abs}(\H^\Delta))^{\circ2}) \\ &\le& \operatorname{fat}_{\gamma/(2M)}(\operatorname{abs}(\H^\Delta)) \\ &\le& 8\operatorname{fat}_{\gamma/(2M)}(\H^\Delta) \\ &\le& 8\operatorname{fat}_{\gamma/(2M)}(\H). \end{eqnarray*} \end{proof} \subsection{Generalization bound proof} \begin{theorem}\citep{Dudley1967290,MR1965359}\label{rad-fatdimension-bound} For any $\mathcal{F}\subseteq[-1,1]^X$, any $\gamma \in (0,1)$ and $S=(w_1,\ldots,w_n)=\mathbf{w}\in \mathcal{W}^n$, \begin{eqnarray*} R_n(\mathcal{F}|\mathbf{w})\leq 12\sqrt{\frac{\Tilde{K}}{n}}\int_{0}^{1} \sqrt{\operatorname{fat}_{c\gamma}(\mathcal{F}) \log(\frac{2}{\gamma})}d\gamma \end{eqnarray*} where $c$ and $\Tilde{K}$ are universal constants.\\ \paragraph{Remark.} When the integral above diverges, a refined version is available: \begin{eqnarray*} R_n(\mathcal{F}|\mathbf{w})\leq \inf_{\alpha \geq 0} \set{4\alpha + 12\sqrt{\frac{\Tilde{K}}{n}}\int_{\alpha}^{1} \sqrt{\operatorname{fat}_{c\gamma}(\mathcal{F}) \log(\frac{2}{\gamma})}d\gamma} \end{eqnarray*} \end{theorem} \begin{proof}[of Theorem~\ref{thm:regression-bound}] Similar to the proof for binary case, we bound the empirical Rademacher complexity of the loss class of $\Tilde{h}\in\Delta(\H)$. \begin{eqnarray*} |\operatorname{Risk}(\Tilde{h})-\mywidehat{\operatorname{Risk}}(\Tilde{h})|&=& |E_{(x,y)\sim D}\max_{j\in[k]}\sum_{t=1}^T \alpha_t f_t^{(j)}(x,y)-\frac{1}{|S|}\underset{(x,y)\in S}{{\displaystyle \sum}}\max_{j\in[k]}\sum_{t=1}^T \alpha_t f_t^{(j)}(x,y)| \\ &\overset{(i)}\leq& 2R_n(\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y}))+3\sqrt{\frac{\log(2/\delta)}{2|S|}} \\ &\overset{(ii)}=& 2R_n(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y}))+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(iii)}\leq& 24\sqrt{\frac{\Tilde{K}}{|S|}}\int_{0}^{1} \sqrt{\operatorname{fat}_{c\gamma}(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]}) \log(\frac{2}{\gamma})}d\gamma+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(iv)}\leq& 24\sqrt{\frac{2k\log(3k)\Tilde{K}}{|S|}}\int_{0}^{1} \sqrt{\max_{j\in[k]}\operatorname{fat}_{c\gamma}(\mathcal{F}_\H^{(j)}) \log(\frac{2}{\gamma})}d\gamma+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\overset{(v)}\leq& 24\sqrt{\frac{2k\log(3k)\Tilde{K}}{|S|}}\int_{0}^{1} \sqrt{(8\operatorname{fat}_{c\gamma}(\H)) \log(\frac{2}{\gamma})}d\gamma+3\sqrt{\frac{\log(2/\delta)}{2|S|}}\\ &\leq& \epsilon \end{eqnarray*} (i) stems from Theorem \ref{rad-gen-bound} (generalization error by Rademacher complexity bound for the function class $\max\!\!-\!\!\operatorname{conv}((\mathcal{F}^{(j)}_{\H})_{j\in[k]}))$, (ii) stems from Lemma \ref{lem:rad-conv-kfold}, (iii) stems from Theorem \ref{rad-fatdimension-bound}, (iv) stems from Theorem \ref{thm:fat-kmax} (fat shattering of max operator) and (v) stems from Lemmas \ref{fatdimension-lossclassL2-bound} and \ref{lem:fat-losses}. \end{proof} \begin{proof}[of Corollary~\ref{regression-bound-hyperplanes}] Let $\H$ be a function class of homogeneous hyperplanes bounded by 1 with domain $\mathbb{R}^m$.\\ \\ $R_n(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y}))$ \begin{eqnarray*} &\le& \inf_{\alpha \geq 0} \set{4\alpha + 12\sqrt{\frac{\Tilde{K}}{|S|}}\int_{\alpha}^{1} \sqrt{\operatorname{fat}_{c\gamma}(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})) \log(\frac{2}{\gamma})}d\gamma} \\&\le& \inf_{\alpha \geq 0} \set{4\alpha + 12\sqrt{\frac{2k\log(3k)\Tilde{K}}{|S|}}\int_{\alpha}^{1} \sqrt{\max_{j\in[k]}\operatorname{fat}_{c\gamma}(\mathcal{F}_\H^{(j)}) \log(\frac{2}{\gamma})}d\gamma} \\&\le& \inf_{\alpha \geq 0} \set{4\alpha + 12\sqrt{\frac{2k\log(3k)\Tilde{K}}{|S|}}\int_{\alpha}^{1} \sqrt{(8\operatorname{fat}_{c\gamma}(\H)) \log(\frac{2}{\gamma})}d\gamma} \\&\overset{(i)}\le& \inf_{\alpha\ge0}\set{4\alpha+{12c'}\sqrt{\frac{2k\log(3k)}{|S|}} \int_\alpha^1 \frac1{t} \sqrt{ \log\frac{2}{t} } dt} \end{eqnarray*} (i) stems from the bound $\operatorname{fat}_{\delta}(H)\leq \frac{1}{\delta^2}$ \citep{299098}.\\ Compute \begin{eqnarray*} \int_\alpha^1 \frac1{t} \sqrt{ \log\frac{2}{t} } dt = \frac23\paren{ \log(2/\alpha)^{3/2}-(\log2)^{3/2}} \end{eqnarray*} and choosing $\alpha=1/\sqrt{|S|}$ yields \begin{eqnarray*} R_n(\max((\mathcal{F}^{(j)}_{\H})_{j\in[k]})|(\mathbf{x}\times\mathbf{y})) &\le& \frac4{\sqrt |S|} +8c'\sqrt{\frac{2k\log(3k)}{|S|}}\paren{ \log(2\sqrt |S|)^{3/2} - (\log 2)^{3/2} } \\ &=& O\paren{\sqrt{\frac{k\log k\cdot(\log |S|)^3}{|S|}}}. \end{eqnarray*} A standard calculation yields sample complexity $m_0= \O(\frac{1}{\epsilon^2}(k\log^2(k/\epsilon)+\log\frac{1}{\delta}))$. \end{proof} \acks{The work of AK and YM was supported in part by grants from the Israel Science Foundation (ISF). This research was also supported by the Lynn and William Frankel Center for Computer Science at Ben-Gurion University.} \newpage
{'timestamp': '2019-03-05T02:09:44', 'yymm': '1810', 'arxiv_id': '1810.02180', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02180'}
arxiv
\section{Introduction} The ever increasing demand for mobile data services and the necessity of more efficient use of the radio spectrum are leading network operators to increase the density of base stations \cite{magazin2015}. This densification has become possible by small-cell deployment. Backhaul is needed to connect the small cells to the core network, internet and other services \cite{magazin2015}. Optical fiber technologies offer high capacity which are sufficient for next-generation cellular networks. However, due to its high cost, for some network operators, in some places, the use of fiber is not always affordable. In such scenarios, free space optical (FSO) communication systems have been developed as a cost-effective alternative technology for the backhaul of next-generation cellular networks \cite{jlt2016backhaul,ghassemlooy2015emerging,dabiriJSAC}. With its significant advantages such as large available bandwidth, low cost implementation, global license-free feature, low risk of exposure and robustness to electromagnetic interference, FSO communication has recently attracted a growing attention for a wide range of applications \cite{khalighi2014,dabiri2017fso}. To increase the data rate of FSO links, recent efforts show that multiple-input multiple-output (MIMO) spatial multiplexing can significantly improve the transmission rate (see for instance \cite{kahn_2016,khalighi_Max,uysal2016,aghajanzadeh2010, safari2013,huang2017spatial,dabiri2017ergodic,dabiri2017performance}). In \cite{kahn_2016}, the authors compared the spectral efficiency of conventional MIMO multiplexing and spatial-mode multiplexing with that provided by orbital angular momentum (OAM) multiplexing over turbulence channels. In \cite{khalighi_Max}, the authors investigated the interest of spatial multiplexing in MIMO FSO systems and compared its performance to those achieved with repetition coding orthogonal space time block codes (OSTBC) and optical spatial modulation. In \cite{aghajanzadeh2010}, the diversity-multiplexing trade-off for log-normal channels were analyzed to optimize both diversity and multiplexing gains when using coherent modulations and heterodyne receivers for FSO systems. In \cite{safari2013}, the multiplexing gain has been investigated for MIMO FSO systems when using intensity modulation with direct detection (IM/DD). More precisely, in \cite{safari2013}, the multiple transmitted beams generate individual airy patterns on the detector plane which are separated due to the difference in the angle of arrival (AOA). In \cite{huang2017spatial}, spatial-mode multiplexing for practical FSO systems using DD is investigated. In \cite{dabiri2017ergodic} for two transceiver pairs and in \cite{dabiri2017performance} for $M$ transceiver pairs, the authors have employed a spatial multiplexing scheme to increase the data rate of an FSO system. More precisely, in \cite{dabiri2017ergodic,dabiri2017performance}, assuming a Gaussian modulation (which is not a practical assumption), the performance of the proposed scheme is analyzed in terms of average achievable data rate. In order to complete recent results in \cite{dabiri2017ergodic,dabiri2017performance}, in the first part of this paper we analyze the performance of MIMO multiplexing scheme introduced in \cite{dabiri2017ergodic,dabiri2017performance} in terms of BER and outage probability for pulse position modulation (PPM) signaling which is a widely used digital modulation schemes in FSO systems. More precisely, we will show how the tunable parameters such as beam waist at the receiver can affect the performance of the considered system. Unlike MIMO diversity case, the performance of MIMO multiplexing is significantly degraded by the interference between parallel channels. To solve this issue, in the second part of this paper, we propose a novel space-time scheme which significantly reduces the interference between parallel channels and improves the performance of MIMO multiplexing case, yet preserving the simplicity of the previous scheme. \section{System Model} We consider a MIMO-FSO communication system with two transmitters (two laser sources) and two receiver apertures, where each transmitter sends optical signals toward the center of its corresponding receiver. At the transmitters, IM/DD with PPM is exploited to modulate the optical transmitted signals. A PPM scheme uses the position of a pulse in two time-slots to represent the value of an information bit, i.e., the presence of a pulse in the first time-slot is characterized by a ``1'' and in the second time-slot is characterized by a ``0''. The received signal at the $ i $th receiver is denoted $r_i$ for $ i\in \{1 , 2\} $ ($2$ is the number of transceiver pairs) is expressed at any discrete symbol time as \begin{align} \label{s4d5} r_i =& \left[ \begin{array}{rl} r_i^{(1)} \nonumber \\ r_i^{(2)} \end{array} \right] \nonumber \\ =& \left[ \begin{array}{rl} R g_{ii}h_{ii} P_t T_s s_i^{(1)} + \sum^2_{\substack{j=1 \\ j\neq i}}R g_{ji}h_{ji}P_t T_s s_j^{(1)} + n_i^{(1)} \\ R g_{ii}h_{ii} P_t T_s s_i^{(2)} + \sum^2_{\substack{j=1 \\ j\neq i}}R g_{ji}h_{ji}P_t T_s s_j^{(2)} + n_i^{(2)} \end{array} \right]. \end{align} where $s_i^{(1)}\in\{0,1\}$ and $s_i^{(2)}=1-s_i^{(1)}$ are respectively the transmitted signals in the first and second time-slot corresponding to the BPPM symbol; $r_i^{(1)}$ and $r_i^{(2)}$ are the received electrical signals in the first and second time-slot. We consider two spatial signaling method: i) MIMO multiplexing where each transmitter sends independent optical signals and ii) MIMO diversity or repetition coding where all transmitters send same optical signals, i.e., $s_1^{(1)}=s_2^{(1)}$. In the case of MIMO diversity, \eqref{s4d5} can be simplified as \begin{align} \label{s4d6} r_i = \left[ \begin{array}{rl} r_i^{(1)} \\ r_i^{(2)} \end{array} \right] = \left[ \begin{array}{rl} \sum^2_{j=1}R g_{ji}h_{ji}P_t T_s s_j^{(1)} + n_i^{(1)}~~~~~~~ \\ \sum^2_{j=1}R g_{ji}h_{ji}P_t T_s (1-s_j^{(1)}) + n_i^{(2)} \end{array} \right], \end{align} where $R$ is the photo detector's responsivity, $ P_t $ is the transmitted signal power, $n^{(1)}_i$ and $n^{(2)}_i$ are the signal-independent additive white Gaussian noise (AWGN) with zero mean and variance $ \sigma_{n}^{2} $=$ N_{0}T_s/2 $, $T_s$ denotes the time-slot duration and $h_{ji}$ is the atmospheric turbulence coefficient between $j$th transmitter and $i$th receiver which is assumed perfectly known at the receiver. Notice that this is a practical assumption due to the slow fading property of FSO links \cite{dabiri2017generalized,dabiri2017glrt,WCL2018}. Moreover, for $h_{ji}=1$, the fraction of the collected power at $i$th receiver due to transmitted signal by $j$th transmitter can be written as \begin{align} \label{Asd4} g_{ji} = A_0\exp\left(-2\frac{\left(x_p+d\right)^2+\left(y_p\right)^2}{w_{z_{\rm eq}}^2} \right), \end{align} where $[d, 0]$ are distance between two receivers in the $[x,y]$ plane, $ A_0=(\mathrm{erf}(\nu))^2 $ denotes the maximal fraction of the collected power, $ \nu=\frac{\sqrt{\pi}r_a}{\sqrt{2}w_z} $, $ w_{z_{\rm eq}}^2=w_z^2\dfrac{\sqrt{\pi}\mathrm{erf}(\nu)}{2\nu\exp(-\nu^2)} $ is the equivalent beamwidth and $\mathrm{erf}(z)=\frac{2}{\sqrt{\pi}}\int_0^{z}e^{-x^2}dx $ is the error function. At the receiver aperture plane, we can express the radial displacement vector as $r_p = [x_p, y_p]$, where $x_p$ and $y_p$, denote respectively the displacements located along the horizontal and elevation axes at the receiver which can be modeled as zero mean Gaussian distributed random variables (RV), i.e., $x_p \thicksim \mathcal{N}(0, \sigma^2_{xp})$ and $y_p \thicksim \mathcal{N}(0, \sigma^2_{yp})$. Lastly, we consider the well-known gamma-gamma distribution for modeling the atmospheric turbulence. This way, the PDF of the normalized channel coefficient $h$ is given by \cite{laserbook} \begin{align} f_{h}(h)= \frac{2(\alpha\beta)^{\frac{\alpha+\beta}{2}}}{\Gamma(\alpha)\Gamma(\beta)}h^{\frac{\alpha+\beta}{2}-1} k_{\alpha-\beta}(2\sqrt{\alpha\beta h}), \end{align} where $ \Gamma (.) $ is the gamma function, $ k_{m}(.) $ is the modified Bessel function of second kind of order $ m$, $ 1/\beta$ and $1/\alpha$ are the variances of the small and large scale eddies, respectively. \section{Performance Analysis} \subsection{BER Analysis} \subsubsection{MIMO Multiplexing} According to \eqref{s4d5} and after some mathematical calculations, the average BER of MIMO multiplexing can be obtained as \begin{align} \label{c4v1} \mathbb{P}_{e,M} = \int_0^\infty \int_0^\infty \mathbb{P}_{e,M|p}f_{x_p}(x_p) f_{y_p}(y_p) dx_pdy_p, \end{align} where \begin{align} \label{c4v2} \mathbb{P}_{e,M|p} = \int_0^\infty \int_0^\infty \mathbb{P}_{e,M|p,h}f_{h_{11}}(h_{11}) f_{h_{21}}(h_{21}) dh_{11}dh_{21}, \end{align} and \begin{align} \label{c4v3} \mathbb{P}_{e,M|p,h}=& \frac{1}{2}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}+g_{21}h_{21} \right)}{\sqrt{N_0}} \right) \nonumber \\ +&\frac{1}{2}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}-g_{21}h_{21} \right)}{\sqrt{N_0}} \right). \end{align} \subsubsection{MIMO Diversity} According to \eqref{s4d6}, the BER of MIMO diversity conditioned on $h$ and $r_p$ can be obtained as \begin{align} \label{c4v7} \mathbb{P}_{e,D|p,h}= Q\left(\frac{R P_t \sqrt{T_s}\sum_{i=1}^2\sum_{j=1}^2 g_{ij}h_{ij}}{\sqrt{2N_0}} \right). \end{align} Finally, substituting $\mathbb{P}_{e,D|p,h}$ in \eqref{c4v2} and \eqref{c4v1} instead of $\mathbb{P}_{e,M|p,h}$, the average BER of MIMO diversity is obtained. \subsection{Outage Probability Analysis} \subsubsection{MIMO Multiplexing} For a given target BER $\mathbb{P}_{e,t}$, the outage probability is defined as the probability that the communication system can not support $\mathbb{P}_{e,t}$ \cite{dabiri2018Performance}. According to \eqref{c4v3} and for low values of outage probability (for outage probability lower than $10^{-2}$), the outage probability of MIMO multiplexing case can be closely expressed as \begin{align} \label{g2x3} \mathcal{P}_{\rm out}^M &= {\rm Prob}\left\{ \mathbb{P}_{e,M|p,h}>\mathbb{P}_{e,t} \right\} \nonumber \\ &\simeq {\rm Prob}\left\{ g_{11}h_{11}-g_{21}h_{21} < \mathcal{A}_{th1} \right\} , \end{align} where $\mathcal{A}_{th1} =\frac{\sqrt{N_0}}{R P_t \sqrt{T_s}}Q^{-1}\left(2 \mathbb{P}_{e,t}\right) $. \subsubsection{MIMO Diversity} According to \eqref{c4v7}, the outage probability of MIMO diversity case can be obtained as \begin{align} \label{g2x4} \mathcal{P}_{\rm out}^D &= {\rm Prob}\left\{ \mathbb{P}_{e,D|p,h}>\mathbb{P}_{e,t} \right\} \nonumber \\ &= {\rm Prob}\left\{ \sum_{i=1}^2\sum_{j=1}^2 g_{ij}h_{ij} < \mathcal{A}_{th2} \right\} , \end{align} where $ \mathcal{A}_{th2} =\frac{\sqrt{2N_0}}{R P_t \sqrt{T_s}}Q^{-1}\left( \mathbb{P}_{e,t}\right) $. \subsection{Simulation Results} In this part, the performance of MIMO multiplexing and MIMO diversity communication systems are numerically studied and the behavior of the considered system is studied versus different tunable parameters such as beam waist at the receiver and distance between receivers. The values of the parameters used for our numerical analysis are set as follows: aperture radius of receiver $r_a=10$ cm, optical wavelength $\lambda=1.5~{\micro m}$, link length 1 $\rm km$, slot duration $T_s=1$ ns, $\alpha=11.7$ and $\beta=10.2$. The average BER of MIMO multiplexing and MIMO diversity cases versus SNR is depicted in Fig. \ref{1} for different values of $d=1.2, 1, 0.8, 0.6, 0.4~ {\rm m}$. As expected, MIMO diversity case has better performance compared to the MIMO multiplexing case. However, note that the transmitted rate of multiplexing case is twice as large as diversity case. As we observe from Fig. \ref{1}, by increasing $d$, the performance of MIMO multiplexing case improves, however, the performance of MIMO diversity is a decreasing function of $d$. The reason for this is that the interference between two parallel channels increases by decreasing $d$. Another tunable parameter which significantly affects the performance of the considered MIMO system is the optical beam waist at the receiver $w_z$. To show the effect of $w_z$ on the performance of the considered system, the average BER versus SNR is plotted in Fig. \ref{2} for different values of $w_s=0.6, 0.8, 0.9, 1, 1.2$ m. As we observe from Fig. \ref{2}, the performance of both multiplexing and diversity system significantly depends on $w_z$. For instance, in the cases of MIMO multiplexing and diversity, the best performance is achieved for $w_z=1.2$. At first it might be thought that, the performance of both diversity and multiplexing cases are improved by increasing $w_z$. To clarify this point, in Figs. \ref{3} and \ref{4}, the BER of considered system are depicted versus $w_z$ and $d$, respectively. Figure \ref{3} shows that, the optimum value of $w_z$ for both cases depend on $d$. For instance, for MIMO multiplexing case, the optimum values for $w_z$ are 0.95, 0.85 and 0.65 $\rm m$ for $d$=1, 0.75 and 0.5 m, respectively. For MIMO diversity, the optimum values for $w_z$ are 1.15, 1.1 and 1 $\rm m$ for $d$=1, 0.75 and 0.5 m, respectively. Moreover, results presented in Fig. \ref{4} confirm that the performance of MIMO multiplexing is an increasing function of $d$ while, MIMO diversity is a decreasing function of $d$. \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{BER_versus_SNR_differ_d.eps} \caption{Average BER of MIMO multiplexing and diversity cases versus SNR for different values of $d$.} \label{1} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{BER_versus_SNR_differ_w_z.eps} \caption{Average BER of MIMO multiplexing and diversity cases versus SNR for different values of $w_z$.} \label{2} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{BER_versus_w_z.eps} \caption{Average BER of MIMO multiplexing and diversity cases versus $w_z$ for different values of $d$.} \label{3} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{BER_versus_d.eps} \caption{ Average BER of MIMO multiplexing and diversity cases versus $d$ for different values of $w_z$.} \label{4} \end{center} \end{figure} \section{Space-Time Signaling for MIMO Multiplexing} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{two_sequence.eps} \caption{ Start time of first and second transmitters are zero and $T_s/2$, respectively. } \label{ds} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{received_two_sequence.eps} \caption{ Received signal equivalent to the transmitted sequences in Fig. \ref{ds} without considering the effect of receiver noises and when $h_{ij}=1$ and $g_{ij}=1$ for $i,j\in\{1, 2\}$. } \label{ds2} \end{center} \end{figure} It is well known that the interference between two parallel channels degrades the performance of MIMO multiplexing case. To reduce the interference between parallel channels, in the sequel we propose a new space-time coding scheme for MIMO multiplexing case when the optical signals are modulated by PPM. The idea behind this scheme is that the start time of two parallel channels to transfer optical signal are different. We consider the start time of first transmitter is zero and second transmitter is starting to send optical signal after a delay equal to $T_s/2$. Figure \ref{ds} is provided for two independent signal sequence where the first sequence is transmitted by the first transmitter at start time equal to zero and the second sequence is transmitted by the second transmitter at a start time equal to $T_s/2$. In Fig. \ref{ds2}, we have also depicted the received signal equivalent to the transmitted sequence in Fig. \ref{ds} without considering the effect of receiver noises and when $h_{ij}=1$ and $g_{ij}=1$ for $i,j\in\{1, 2\}$. This signaling at the transmitter causes approximately same interference in two time-slot of PPM. For instance, when the second transmitter sends bit ``1'', at the first receiver, the interference in first and second slot of PPM are $Rg_{21}h_{21}P_t T_s/2 $. When the second transmitter sends bit ``0'', at the first receiver, the interference depends on the next transmitted bit of second transmitter. For transmitted bits ``0, 0'' and ``0, 1'', the interference at the first slot of first receiver are $ Rg_{21}h_{21}P_t T_s/2$ and $Rg_{21}h_{21}P_t T_s $, respectively, and the interference at the second slot are $ Rg_{21}h_{21}P_t T_s/2$ and $ Rg_{21}h_{21}P_t T_s/2$, respectively. The BER conditioned on $h$ and $r_p$ of the considered space-time scheme is obtained as \begin{align} \label{fg1s} \mathbb{P}_{e,ST|p,h}=& \frac{1}{2}Q\left(\frac{R g_{11}h_{11} P_t \sqrt{T_s}}{\sqrt{N_0}} \right) \nonumber \\ &+\frac{1}{4}Q\left(\frac{R g_{11}h_{11} P_t \sqrt{T_s}}{\sqrt{N_0}} \right) \nonumber \\ &+\frac{1}{8}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}+g_{21}h_{21}/2 \right)}{\sqrt{N_0}} \right) \nonumber \\ &+\frac{1}{8}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}-g_{21}h_{21}/2 \right)}{\sqrt{N_0}} \right) \nonumber \\ =&\frac{3}{4}Q\left(\frac{R g_{11}h_{11} P_t \sqrt{T_s}}{\sqrt{N_0}} \right) \nonumber \\ &+\frac{1}{8}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}+g_{21}h_{21}/2 \right)}{\sqrt{N_0}} \right) \nonumber \\ &+\frac{1}{8}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}-g_{21}h_{21}/2 \right)}{\sqrt{N_0}} \right) . \end{align} Finally, substituting $\mathbb{P}_{e,ST|p,h}$ in \eqref{c4v2} and \eqref{c4v1} instead of $\mathbb{P}_{e,M|p,h}$, the average BER of considered space-time scheme is obtained. For low values of $d$ in which the interference between channels is large, \eqref{fg1s} can be closely approximated as \begin{align} \label{g6} \mathbb{P}_{e,ST|p,h}\simeq \frac{1}{8}Q\left(\frac{R P_t \sqrt{T_s}\left(g_{11}h_{11}-g_{21}h_{21}/2 \right)}{\sqrt{N_0}} \right). \end{align} According to \eqref{g6} and for low values of outage probability (for outage probability lower than $10^{-2}$), outage probability of the proposed scheme can be closely obtained as \begin{align} \label{g45x3} \mathcal{P}_{\rm out}^{ST} &= {\rm Prob}\left\{ \mathbb{P}_{e,ST|p,h}>\mathbb{P}_{e,t} \right\} \nonumber \\ &\simeq {\rm Prob}\left\{ g_{11}h_{11}-g_{21}h_{21}/2 < \mathcal{A}_{th3} \right\} , \end{align} where $\mathcal{A}_{th3} =\frac{\sqrt{N_0}}{R P_t \sqrt{T_s}}Q^{-1}\left(8 \mathbb{P}_{e,t}\right) $. \subsection{Numerical Results} \begin{figure} \begin{center} \includegraphics[width=3.4 in ]{BER_ST_versus_w_z.eps} \caption{ Comparing average BER of MIMO multiplexing and proposed space-time scheme versus $w_z$ for different values of $d$.} \label{5} \end{center} \end{figure} Assuming here similar system parameters to those introduced in the previous section, in Fig. \ref{5}, the performance of the proposed space-time scheme is contrasted to that of MIMO multiplexing scheme used in conventional PPM. In Fig. \ref{5}, BER obtained with the considered systems are depicted versus $w_z$ for different values of $d$. Notice that both multiplexing scheme have same bit rate and same complexity and processing load. However, as expected and as we observe from Fig. \ref{5}, by managing the interference between parallel channels, the proposed space-time scheme improves the performance of MIMO multiplexing, significantly. \balance
{'timestamp': '2018-10-05T02:10:39', 'yymm': '1810', 'arxiv_id': '1810.02167', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02167'}
arxiv
\subsection*{Sets} \nomenclature[A]{$\mathcal{D}$}{Set of days, $d \in \mathcal{D}$ in a year, $\mathcal{D} = \{1,...,365\}$} \nomenclature[A]{$\mathcal{D}'$}{Set of days, $d' \in \mathcal{D}'$ in a month, $\mathcal{D}' \subset \mathcal{D}$} \nomenclature[A]{$\mathcal{H}$}{Set of half-hour time-slots, $h \in \mathcal{H}$ in a day, \\ $\mathcal{H} = \{1,...,48\}$} \nomenclature[A]{$\mathcal{M}$}{Set of months, $m \in \mathcal{M}$ in a year, $\mathcal{M} = \{1,...,12\}$} \nomenclature[B]{$\hat{p}$}{Dummy variable for modelling demand-based tariffs} \nomenclature[B]{$p^\mathrm{g+/-}$}{Power flowing from/to grid} \nomenclature[B]{$p^\mathrm{b+/-}$}{Battery charge/discharge power} \nomenclature[B]{$e^\mathrm{b}$}{Battery state of charge} \nomenclature[B]{$s^\mathrm{b}$}{Battery charging status (0: discharge, 1: charge)} \nomenclature[B]{$d^\mathrm{g}$}{direction of grid power flow (0: demand to grid, 1: grid to demand)} \nomenclature[C]{$\eta^\mathrm{b+/-}$}{Battery charging/discharging efficiency} \nomenclature[C]{$\bar{p}^\mathrm{b+/-}$}{Maximum battery charge/discharge power} \nomenclature[C]{$\eta^\mathrm{b+/-}$}{Battery charging/discharging efficiency} \nomenclature[C]{$\bar{e}^\mathrm{b}$}{Battery maximum state of charge} \nomenclature[C]{$\barbelow{e}^\mathrm{b}$}{Battery minimum state of charge} \nomenclature[C]{$p^\mathrm{pv}$}{Power from solar PV} \nomenclature[C]{$\Delta h$}{Half hourly time steps} \nomenclature[C]{$p^\mathrm{d}$}{Total customer demand} \nomenclature[C]{$p^\mathrm{res}$}{Net demand} \nomenclature[C]{$\bar{p}^\mathrm{g}$}{Maximum power taken from/to grid} \nomenclature[D]{LV}{Low voltage} \nomenclature[D]{PV}{Photovoltaic} \nomenclature[D]{DER}{Distributed energy resources} \nomenclature[D]{DNSP}{Distribution network service provider} \nomenclature[D]{FiT}{Feed in tariff} \nomenclature[D]{ToU}{Time of use} \nomenclature[D]{MILP}{Mixed integer linear programming} \nomenclature[D]{HEMS}{Home energy management system} \nomenclature[D]{EWH}{Electric water heater} \nomenclature[E]{$T^\mathrm{flt}$}{Flat energy charge} \nomenclature[E]{$T^\mathrm{tou}$}{Time-of-use energy charge} \nomenclature[E]{$T^\mathrm{fix}$}{Fixed daily charge} \nomenclature[E]{$T^\mathrm{fit}$}{Feed-in-tariff (FiT)} \nomenclature[E]{$p^\mathrm{pk}$}{monthly peak} \nomenclature[E]{$T^\mathrm{pk}$}{Monthly Peak demand charge} \section{Introduction} Investment in customer-owned PV-battery systems is growing rapidly across the globe, as they become cost-effective in certain jurisdictions. For example, the total installed capacity of residential PV-battery systems in Australia is projected to increase from 5~\si{GW} in 2017 to 19.7~\si{GW} in 2037~\cite{aemosmall,aemosolar}. In Germany, the total installed capacity of PV systems alone currently stands at 43~\si{GW}, and projected to increase to 150~\si{GW} by 2050~\cite{isefraunhofer,wirth2018recent}; while battery storage systems are expected to follow suit, with currently 100,000 installations (approx. 6~\si{GWh}) and projections for this to double within the next two years~\cite{bswsolar}. The trend towards more residential PV-battery systems is being driven by two major factors. On one hand, average household electricity prices in OECD countries have increased by over 33\% between 2006 and 2017 (using purchasing power parity). In particular, in Australia and Germany, prices have risen to about 20.4 and 39.17~\si{US. c/kWh}, respectively, from roughly 12.52~\si{US. c/kWh} (in Australia) and 20.83~\si{US. c/kWh} (in Germany) in the year 2006~\cite{energytaxes}; while feed-in-tariff (FiT) rates for PV generation have been simultaneously reduced in these countries. On the other hand, costs of PV and battery systems have seen precipitous falls in recent times. These energy price hikes and asset cost reductions are driving customers to increase their levels of energy self-consumption by investing in energy storage technology, to complement rooftop PV systems. This presents a dilemma to distribution nework service providers (DNSPs) and vertically-integrated electricity utilities --- how to design tariffs that reflect the long-run marginal cost of electricity network assets, so that all consumers receive a price signal indicating the extent to which they each contribute to network peak demand, while (i) not encouraging customers with DER to defect from the grid, and (ii) without unfairly apportioning network costs on customers without PV or other DER. This has proven to be a difficult task that has recieved much attention in the professional and academic literature~\cite{aemcrule,energy2014towards,lu2018designing,eutariff}. More broadly, recent studies have considered the economic impacts of \textit{energy-} and \textit{demand-based tariffs} on residential customers and on utilities' revenue. {Demand-based tariffs} have been shown to effectively resolve network price instability and reduce cross-subsidies between consumers without DER and prosumers~\cite{simshauser2016distribution}, and also to ensure a stable revenue for DNSPs~\cite{young2016electricity}. From the customer perspective,~\cite{abdelmotteleb2018designing} utilised a \textit{peak coincidence} network charge coupled with a fixed charge to reduce energy cost for price responsive customers. This slightly outperformed a peak demand charge but led to a reduction in overall system cost compared to traditional volumetric tariffs. In~\cite{nijhuis2017analysis}, the authors suggested that a peak demand tariff based on a customer's yearly peak demand should be considered by DNSPs, as it performed best in terms of cost-reflectivity and predictability amongst other tariff types. On the contrary, {demand-based tariffs} proposed by the Australian Energy Regulator (AER) was tested on households in Sydney, from which it was concluded that without due adjustments made, these tariffs show low cost-reflectivity~\cite{passey2017designing}. From these studies, it is evident that the suitability of network tariffs in terms of cost-reflectivity is dependent on the assumptions made in the actual design and on how customers respond to these tariffs~\cite{stenner2015australian}. \par Despite these efforts, very little research has considered the technical impacts of network tariffs on the distribution network. This is paramount because the aggregate network peak demand and energy losses are the long-run network cost drivers. It was shown in~\cite{pimm2018time} that \textit{time-of-use} (ToU) tariffs alone can increase peak loading on networks with deep DER penetration levels, where customers seek to maximise their cost savings. In view of this, authors in~\cite{supponen2016network} showed that {demand-based tariffs} could be used to mitigate transformer loading at medium voltage (MV) substations. Similarly, the results in~\cite{steen2016effects} demonstrated the effectiveness of {demand-based tariffs} in alleviating peak demand whilst considering demand response from customers' controllable appliances. In~\cite{steen2016effects}, however, customers were exposed to spot market prices (dynamic prices) and the effects of PV-battery systems were not considered. \par Given this background, in this paper, we propose a framework that allows network service providers to develop cost-reflective tariffs when considering DER-enabled customers, which is not possible with the existing tools. A mixed integer linear programming (MILP)-based home energy management system (HEMS) framework, which minimises electricity cost, is used to assess the effects of this response on typical low voltage (LV) distribution networks. For modelling {demand-based tariffs}, we include the peak demand charge as a linear term in the objective function corresponding to an additional peak demand variable multiplied by the set demand charge, which is incorporated into the model using an inequality constraint that sets the peak demand variable equal to the maximum monthly demand In this way, we retain the computational efficiency of the MILP approach by avoiding the computationally expensive min-max formulation used in~\cite{steen2016effects} that models the peak demand explicitly. We build on our earlier work in~\cite{azuatalam2017impacts} by including electric water heaters (EWH) as part of the HEMS formulation, since they account for a considerable portion of energy consumption in the Australian context and can affect peak loading~\cite{greenhouse2013}. \par The optimisation-based simulation is run for a year to account for seasonal variations in demand and solar PV output and specific to each of 332 customers. Furthermore, three scenarios are considered based on customer DER ownership, namely, EWH only, EWH$+$PV, and EWH$+$PV$+$Battery; and simulation is performed for four different network tariff types. The output of the optimisation, which reflects customer response to the tariff types is then used to carry out probabilistic power flow studies. In summary, the analysis in this paper extends the preliminary results in our earlier conference paper~\cite{azuatalam2017impacts} in the following ways: \begin{itemize} \item With limited data available, we develop a solar PV/demand and EWH statistical model to generate sufficient net load traces and hot water draws necessary to carry out power flow studies for customers with EWH and/or PV-battery systems. \item We propose a framework to test the cost-reflectivity of network tariffs by carrying out statistical economic impact analyses. With this, we assess customers' response to different network tariffs whilst incorporating detailed battery and EWH appliance models. \item We demonstrate the impacts of energy- and demand-based network tariffs on typical LV distribution networks. Specifically, we investigate the effects of these network tariffs on annual feeder head loading and customer voltage profiles at different PV-battery penetration levels. \end{itemize} The remainder of this paper is structured as follows: In the next section, we present an overview of the tariff assessment framework. This is followed by detailed household DER modelling including PV/demand and EWH hot water draw statistical models in Section~\ref{ham}. Section~\ref{optimisation} details the optimisation model of the network tariff types. In Section~\ref{annualcost}, we perform annual electricity calculations and in Section~\ref{powerflow}, we describe the power flow analysis framework. The simulation results of our case studies are presented and discussed in Section~\ref{results} while Section~\ref{conclusion} concludes the paper. \section{Methodology} A summary of the probabilistic assessment framework is detailed in Figure~\ref{fig1}. In Module I, using yearly historical data, we generate a pool of net load traces and corresponding hot water draw profiles by applying the PV/demand and EWH hot water draw statistical models described in Section~\ref{ham}. In Module II, the output of the statistical models are fed as input to the MILP-based HEMS to solve the yearly optimisation problem for the different tariff types and results are saved for each customer. With the assumption that these customers are part of a LV network, the optimisation results and output data from Module I are used to perform time-series yearly Monte Carlo (MC) power flow studies on LV distribution networks using OpenDSS~\cite{opendss}. MC simulation is employed to cater for the uncertainties in customer location and the size of DER. Therefore, 100 MC power flow simulations are performed to investigate the impacts of the network tariff types on customer voltage profile and feeder head loading at different PV-battery penetration levels. We describe the steps needed to achieve this in the following sections. \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} \tikzstyle{materia}=[draw, thick, text width=30em, text centered, minimum height=1.5em, drop shadow] \tikzstyle{practica} = [materia, fill=white, text width=28em, minimum width=28em, minimum height=3em, rounded corners, drop shadow] \tikzstyle{texto} = [above, text width=25em] \tikzstyle{linepart} = [draw, thick, -latex', dashed] \tikzstyle{line} = [draw, thick, -latex'] \tikzstyle{ur}=[draw, text centered, minimum height=0.01em] \newcommand{1.3}{1.3} \newcommand{1.5}{1.5} \newcommand{\practica}[2]{node (p#1) [practica] {\textbf{Step #1}\\{\normalsize\textit{#2}}}} \newcommand{\background}[5]{% \begin{pgfonlayer}{background} \path (#1.west |- #2.north)+(-0.5,+0.5) node (a1) {}; \path (#3.east |- #4.south)+(+0.5,-0.5) node (a2) {}; \path[rounded corners, fill=lightgray!40, draw, thick, dashed] (a1) rectangle (a2); \path (a1.east |- a1.south)+(4.6,-0.4) node (u1)[texto] {\normalsize\textit{Module #5}}; \end{pgfonlayer}} \newcommand{\transreceptor}[3]{% \path [linepart] (#1.east) -- node [above] {\scriptsize Transreceptor #2} (#3);} \begin{figure}[t!] \begin{center} \begin{tikzpicture}[scale=0.7,transform shape] \path \practica {1}{Generate a pool of net load traces \\ using the PV and Demand statistical model}; \path (p1.south)+(0.0,-1.2) \practica{2}{Generate corresponding hot water draw \\ profiles using the hot water draw statistical model}; \path (p2.south)+(0.0,-1.9) \practica{3}{Using tariff and DER data and output from Steps 1 and 2, solve the HEMS problem using MILP for a year}; \path (p3.south)+(0.0,-1.2) \practica{4}{Save the yearly power import/export results and calculate the annual electricity cost for each customer}; \path (p4.south)+(0.0,-1.9) \practica{5}{utilise data from Steps 1, 2 and the power exchange results from step 4 to run yearly Monte Carlo power flow}; \path (p5.south)+(0.0,-1.2) \practica{6}{Save customer voltage profiles and feeder head loading for each MC simulation}; \path [line] (p1.south) -- node [above] {} (p2); \path [line] (p2.south) -- node [above] {} (p3); \path [line] (p3.south) -- node [above] {} (p4); \path [line] (p1.east) -- +(0.34,0.0) -- +(0.34,-9.1) -- node [right] {} (p5); \path [line] (p2.west) -- +(-0.34,0) -- +(-0.34,-7.15) -- node [left] {} (p5); \path [line] (p4.south) -- node [above] {} (p5); \path [line] (p5.south) -- node [above] {} (p6); \background{p1}{p1}{p1}{p2}{I: Demand, PV and EWH Water Draw Synthesis} \background{p3}{p3}{p3}{p4}{II: HEMS Problem} \background{p1}{p5}{p5}{p6}{III: MC Power Flow} \end{tikzpicture} \caption{Overview of the Methodology.} \label{fig1} \end{center} \end{figure} \subsection{Low voltage networks} \par The low voltage network data used in this work were obtained from the \textit{Low Voltage Network Solutions Project}~\cite{enwlreport}. Table~\ref{table1} summarizes the main features of the three networks used as case studies in this work. These are residential LV networks of different lengths and number of load points: Feeders 1 and 2 are fairly balanced while Feeder 3 is unbalanced. Given that these feeders are from the UK, we have modified them to suit the Australian context. Typical Australian LV networks are more robust with higher load capacity when compared to that from the UK. Therefore, we have increased the transformer capacity by a factor of three and decreased the line impedances by a factor of three since the average consumption in Australia is roughly three times that in the UK. However, the overall structure of LV networks in both countries are similar. \subsection{Network model} \par We consider a LV distribution network as a radial system denoted $\mathcal{G(N,E)}$. This comprises of $\left\vert \mathcal{N}\right\vert$ nodes in the set $\mathcal{N}:= \{0,1,...,N\}$ representing network buses, and distribution lines, each denoted as a tuple $(i,j)$ connecting the nodes and represented by the set of edges $\mathcal{E}:= \{(i,j)\} \subset \mathcal{\{N \times N\}}$. Each customer, $c \in \mathcal{C}$ in the network is connected to a load bus as a single-phase load point, where the number of load buses $\left\vert \mathcal{N}_c\right\vert$ is a subset of the total nodes in the network (and $\mathcal{N}_c \subseteq \mathcal{N}$). Let $\boldsymbol{V} = [v_0, v_1,...,v_N]$ be the voltage magnitudes at the nodes, where $v_0$ is the substation voltage. Let $v_c$ be the voltage at each (customer) load point. These voltages are monitored at every half-hour in the year to check for any voltage violations. More so, the current flowing through the line connecting nodes 0 and 1 (denoted $i^\mathrm{head}$) is monitored to check for any thermal loading problems. We assume that each customer, $c \in \mathcal{C}$ in the network utilises a HEMS to manage a set of appliances in order to minimise electricity cost. The modelling of these appliances are covered in Section~\ref{ham}. \subsection{Network tariffs and retail charges} \par A typical residential customer retail bill consists of network (distribution and transmission) charges, generation costs for energy, retailer's charge and other related costs. We have sourced the network tariff data, shown in Table~\ref{table2}), from Essential Energy\footnote{Essential Energy Network Price List and Explanatory Notes. Available at https://www.essentialenergy.com.au}. These are assumed fixed and known in advance. The peak demand charge in \si{\$/kW/month} is the charge for a customer's monthly peak demand (or, alternatively, the the average of the top four daily peak demand of a customer in a month). In Table~\ref{table3}, the residential electricity prices for customers in the Essential energy distribution zone for retailer, Origin Energy\footnote{Origin Energy NSW Residential Energy Price Fact Sheet for Essential Energy Distribution Zone. Available at https://www.originenergy.com.au}, is shown. These prices comprise the actual cost of electricity, retailer's service fee, and the network charge. In this study, we have assumed that the retailers pass on the DNSP tariff structure to the consumers. The different network tariffs (energy, \textit{Flat} and \textit{ToU}, and demand-based, \textit{FlatD} and \textit{ToUD}) are described below: \begin{itemize} \item \textit{LV Residential Anytime (Flat)}: Includes a fixed daily charge and a flat usage charge. \item \textit{LV Residential Time-of-use (ToU)\footnote{Peak period: 7am to 9am, 5pm to 8pm; shoulder period: 9am to 5pm, 8pm to 10pm; off-peak period: 10pm to 7am.}}: Includes a fixed daily charge and a ToU usage charge. \item \textit{Small Residential - Opt in Demand Anytime (FlatD)}: Includes a fixed daily charge, a flat usage charge and a peak demand charge. \item \textit{Small Residential - Opt in Demand (ToUD)}: Includes a fixed daily charge, a ToU usage charge and a peak demand charge. \end{itemize} \begin{table}[t] \footnotesize \centering \caption{Network data} \label{table1} \begin{tabular}{cccc} \hline Feeder & Length & Number of & Feeder head\\ number & (\si{\meter}) & customers & ampacity (\si{\ampere})\\ \hline 1 & 5206 & 175 & 1200 \\ 2 & 4197 & 186 & 1200 \\ 3 & 10235 & 302 & 1155 \\ \hline \end{tabular} \end{table} \begin{table}[t] \footnotesize \centering \caption{Network tariff data} \label{table2} \begin{tabular}[t]{c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.2cm}}c@{\hspace{0.1cm}}} \hline \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Tariff\\ Type\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Fixed\\ charge\\ \si{\$/day}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Anytime\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Off peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Shoulder\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Demand\\ Charge\\ \si{\$/kW/month}\end{tabular} \\ \hline \textit{Flat} & 0.8568 & 11.0321 & - & - & - & - \\ \textit{ToU} & 0.8568 & - & 4.6287 & 12.6922 & 13.9934 & - \\ \textit{FlatD} & 0.8568 & 3.2169 & - & - & - & 4.2112 \\ \textit{ToUD} & 0.8568 & - & 2.1419 & 3.4771 & 4.0804 & 4.2112 \\ \hline \end{tabular} \end{table} \begin{table}[t] \footnotesize \centering \caption{Retail tariff data} \label{table3} \begin{tabular}[t]{c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.2cm}}c@{\hspace{0.1cm}}} \hline \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Tariff\\ Type\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Fixed\\ charge\\ \si{\$/day}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Anytime\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Off peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Shoulder\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Feed-in\\ Tariff\\ \si{c/kWh}\end{tabular} \\ \hline \textit{Flat} & 1.5511 & 31.3170 & - & - & - & 9.0 \\ \textit{ToU} & 1.5511 & - & 21.3400 & 37.1470 & 38.5880 & 9.0 \\ \textit{FlatD} & 1.5511 & 23.5018 & - & - & - & 9.0 \\ \textit{ToUD} & 1.5511 & - & 18.8532 & 27.9319 & 28.6750 & 9.0 \\ \hline \end{tabular} \end{table} \subsection{Customer demand and DER data} \par We sourced the demand and solar PV generation data from the Ausgrid (DNSP in NSW) \textit{Solar Home Electricity Data}~\cite{solarhome}. This dataset comprises three years of half-hourly resolution smart meter data for the period between July 2010 to June 2013, for 300 residential customers in the Sydney region of Australia. The most recent data (for financial year, July 2012 to June 2013) is used in this study because it is complete and of higher quality, compared to the previous years in the dataset. Given that the \textit{Solar Home Electricity Data} do not contain customer hot water usage data, we selected 123 customers from the Ausgrid \textit{Smart Grid, Smart City} (SGSC)~\cite{smartgrid} dataset with complete hot water usage, solar PV and uncontrolled demand data. Then we randomly allocated these hot water profiles to selected 123 customers from the \textit{Solar Home Electricity Data}. \par Since the average PV size of the customers in the \textit{Solar Home Electricity Data} is roughly 1.5~\si{kW}, we applied a heuristic to update the PV sizes to reflect the current PV uptake rates and the average size of installed PV systems in Australia. The updated average PV size of these customers is roughly 4~\si{kW} and sizes range from 3 to 10~\si{kWp}, depending on the needs of the household. For customers with solar PV and batteries installed, the battery size of the customer depends on the size of the solar PV installed. In Australia, typically, 1.5-3~\si{kWh} of storage is used per 1~\si{kW} of PV installed~\cite{aemosmall}. This assumption is made in this work. The PV inverter efficiency has already been accounted for in the dataset, so we have assumed a PV inverter efficiency of 1 in our simulations. Table~\ref{table4} shows the PV-battery size combinations for the selected 123 customers with updated PV sizes. \begin{table}[t] \footnotesize \centering \caption{PV-Battery size combinations} \label{table4} \begin{tabular}{ccc} \hline Customers & Solar PV size & Battery size \\ \si{\percent} & \si{kW} & \si{kWh} \\ \hline 76.42 & 3 - 4 & 6 \\ 20.33 & 5 - 6 & 8 \\ 2.44 & 7 - 8 & 10 \\ 0.81 & 9 - 10 & 12 \\ \hline \end{tabular} \end{table} \section{Household DER modelling} \label{ham} For each customer, $c \in \mathcal{C}$ possessing a set of appliances, $\mathcal{A}:= \{1,2,...,\left\vert\mathcal{A}\right\vert\}$, let $\alpha \in \{1,...,M\}$ denote customer's $c$ appliance type, wherefore $\mathcal{A}_\alpha \subseteq \mathcal{A}$. In this work, we consider just three (3) appliance types $(M = 3)$: Type 1 set includes energy storage devices, particularly batteries; Type 2 set includes thermostatically-controlled devices, particularly electric water heaters (EWH); Type 3 appliances constitute the base load and includes all must-run and uncontrollable devices. \subsection{Battery energy storage system (BESS) modelling} The BESS operational model is linearised so that it fits the MILP optimisation framework. Battery sizes utilised in this study range from 6 to 12~\si{kWh} and are obtained from ZEN Energy~\cite{zenenergy}. We have assumed a minimum/maximum battery SOC of 10\%/100\% nominal capacity and a round-trip efficiency of 90\% for all battery sizes. For all $a \in \mathcal{A}_1, h \in \mathcal{H}$: \begin{align} & e_{a,h}^\mathrm{b} = e_{a,h-1}^\mathrm{b} + \Delta h \Big(\eta_a^\mathrm{b+}p_{a,h-1}^\mathrm{b+} -\ \big(1/\eta_a^\mathrm{b-}\big)p_{a,h-1}^\mathrm{b-} \Big) \label{eqn1} \\ & p_{a,h}^\mathrm{b+}\; \leq\; \bar{p}^\mathrm{b+}s_{a,h}^\mathrm{b} \label{eqn2}\\ & p_{a,h}^\mathrm{b-}\; \leq\; \bar{p}^\mathrm{b-}\big(1 - s_{a,h}^\mathrm{b}\big) \label{eqn3}\\ & 0\; \leq\; p_{a,h}^\mathrm{b+} \leq\; \bar{p}^\mathrm{b+} \label{eqn4}\\ & 0\; \leq\; p_{a,h}^\mathrm{b-} \leq\; \bar{p}^\mathrm{b-} \label{eqn5}\\ & \barbelow{e}^\mathrm{b}\; \leq\; e_{a,h}^\mathrm{b} \leq\; \bar{e}^\mathrm{b} \label{eqn6} \end{align} \begin{table}[t] \footnotesize \centering \caption{EWH Parameters} \label{table6} \begin{tabular}{cccc} \hline Number of & EWH & Element & Tank surface \\ Customers & Size $(V)$ & rating $(Q)$ & Area $(A)$ \\ \si{\percent} & \si{Liter} & \si{kW} & \si{\meter \squared} \\ \hline 2.44 & 80 & 1.8 & 1.114 \\ 8.94 & 125 & 3.6 & 1.500 \\ 86.99 & 160 & 3.6 & 1.768 \\ 1.63 & 250 & 4.8 & 2.381 \\ \hline Density $(\rho)$ & Specific heat $(c)$ & $T_\mathrm{in}$ range & Conductance $(U)$ \\ \si{\kilogram/\meter \cubed} & \si{\kilo \joule/\kilogram. \degreeCelsius} & \si{\degreeCelsius} & \si{\watt/\meter \squared. \degreeCelsius} \\ \hline 1000 & 4.18 & 60 - 82 & 1.00 \\ \hline \end{tabular} \end{table} \subsection{Electric water heater (EWH) modelling} The EWH operational model is given by a set of difference equations in order to fit them into an optimisation model~\cite{kar1996optimum,elamari2011using}. We consider single-element EWH tanks from Rheem\footnote{Rheem Electric Storage Water Heaters Specification Sheet http://www.rheem.com.au/DomesticElectricWaterHeaters} and estimated the EWH sizes for the 123 selected customers using their hot water profiles. The EWH simulation parameters are given in Table~\ref{table6}. For all $a \in \mathcal{A}_2, h \in \mathcal{H}$: \begin{align} & p_{a,h} = \eta_a^\mathrm{th} u_{a,h}^\mathrm{th}Q_a \label{eqn7} \\ &\begin{aligned} & T_{a,h}^\mathrm{in} = T_{a,h-1}^\mathrm{in} + \psi_a p_{a,h} + \lambda_a(T_{a,h-1}^\mathrm{out} - T_{a,h-1}^\mathrm{in})\ \\ & \hspace{10em} + \phi_a(T_{a,h-1}^\mathrm{inlet} - T_{a,h-1}^\mathrm{in}) \end{aligned} \label{eqn8} \\ & T_{a,h}^\mathrm{in,min} \leq T_{a,h}^\mathrm{in} \leq T_{a,h}^\mathrm{in,max} \label{eqn9} \end{align} where: $C = \rho V c$; $A\approx 6V^{2/3}$; $ \psi_a = \cfrac{\Delta h}{C}$; $\lambda_a = \cfrac{UA \Delta h}{C}$; $\phi_a = \rho W_d$; $W_d$ = EWH water draw in liters; $Q_a$ = EWH element rating in \si{kW}. \par The second term at the RHS of~\eqref{eqn8} represents the energy from the resistive element of the EWH. The third term represents the heat losses to the ambient, while the last term represents the energy required to heat the inlet cold water. \subsection{PV and demand statistical model} \label{pv-demand} In this section, we extend the non-parametric Bayesian model introduced in~\cite{power2017nonparametric} to generate a pool of demand and PV profiles needed to perform power flow studies. To accomplish this, we first cluster historical data sourced from the Ausgrid \textit{Solar Home Electricity Data} into representative clusters, using the MAP-DP (\textit{maximum a-posteriori Dirichlet process mixtures}) technique. Next, we employ the Bayesian estimation method to estimate the probability that an unobserved customer possesses certain features identified in particular clusters. The number of occurrence of these features (count) is used as a hyperparameter of a \textit{dirichlet distribution} $\mathop{\mathrm{Dir(\alpha)}}$. To assign a cluster to an unobserved customer, we use a random variable drawn from a \textit{categorical distribution} $\mathop{\mathrm{Cat(\gamma)}} $ over the features of the particular cluster, where the parameters $\gamma$ are obtained by sampling from $\mathop{\mathrm{Dir(\alpha)}}$. We then generate a pool of net load traces specific to assigned features based on a Markov chain process. More details on the PV and demand statistical model can be found in~\cite{2018arXiv180800615P}. \subsection{Hot water draw statistical model} \label{hwd} The hot water statistical model is defined for aggregated intervals of time slots during the day. It comprises a location distribution within an interval and a magnitude distribution for each time slot. The model is estimated following three steps. First the data is broken into \textit{intervals} of the day, comprised of sets of contiguous time slots. The specific intervals used in this work are given in Table~\ref{table8}. Second, a \textit{location process} is estimated for each interval. This consists of a distribution over the number of draws in an interval, and is given by a homogeneous \textit{Poisson distribution}, $\mathop{\mathrm{Pois(\mu)}}$, given by: \begin{equation} \label{eqn11} P(k\ \mathrm{draws\ in\ interval})= \exp\left[-\mu \right] \frac{\mu^{k}}{k!} \end{equation} where $\mu>0$ is the rate of draw events during the interval. Third, a magnitude distribution is estimated for the size of the draws in each interval. The magnitude of the draws are modeled as following a \textit{Weibull distribution} $\mathop{\mathrm{Wei(\kappa,\sigma)}}$, given by: \begin{equation} f(x | \kappa,\sigma) = \twopartdef { \frac{\sigma}{\kappa}\left(\frac{x}{\kappa}\right)^{\sigma-1} \exp\left[ -\left(\frac{x}{\kappa} \right)^\sigma \right] } {x \geq 0} {0} {x < 0} \end{equation} where $\kappa>0$ is a \textit{scale} parameter and $\sigma>0$ is a \textit{shape} parameter. Sampling from this model involves one additional element. Specifically, once the models are estimated and values of $\mu$, $\kappa$ and $\sigma$ computed, the full sampling process for an interval involves: (i) sampling a number of draws in an interval according to $\mathop{\mathrm{Pois(\mu)}}$ (ii) allocating these draws to time slots over the interval's time slots according to a \textit{uniform distribution} and (iii) sampling draw sizes for each draw according to $\mathop{\mathrm{Wei(\kappa,\sigma)}}$. We emphasize that in order to sample time slots for hot water draws, each interval first has a number of draws sampled from the estimated \textit{Poisson distribution}, and then that number of locations are allocated to draws in the interval according to a uniform distribution (with replacement) over time slots, as is the standard approach for sampling from Poisson processes. \begin{table}[t] \footnotesize \centering \caption{HW model intervals, with time slots indicated by their start time.} \label{table8} \begin{tabular}{cc|cc} \hline Begin & End & Begin & End \\ \hline 23:00 & 1:30 & 11:00 & 13:30 \\ 2:00 & 4:30 & 14:00 & 16:30 \\ 5:00 & 7:30 & 17:00 & 19:30 \\ 8:00 & 10:30 & 20:00 & 22:30 \\ \hline \end{tabular} \end{table} \section{Optimisation model} \label{optimisation} In this section, the optimisation model for all tariff types considering customers with EWH and PV-battery installed is described. Each problem is solved for a year, using a rolling horizon approach and a monthly decision horizon. For customers with just EWH and solar PV, the models are modified accordingly by removing the battery parameters as described in Section~\ref{optscen}. \subsection{Model for energy-based tariffs} For customers facing an \textit{energy-based tariff} (\textit{Flat} or \textit{ToU}) the monthly optimisation model is given in~\eqref{eqn12} to~\eqref{eqn19} for all $h \in \mathcal{H}$: \begin{align} \label{eqn12} \underset{\substack{p_{d',h}^\mathrm{g+}, p_{d',h}^\mathrm{g-}, p_{d',h}^\mathrm{b+}, p_{d',h}^\mathrm{b-}, p_{d',h}^\mathrm{d}, \\ d_{d',h}^\mathrm{g}, s_{d',h}^\mathrm{b}, e_{d',h}^\mathrm{b}, u_{d',h}^\mathrm{th}, T_{d',h}^\mathrm{in}}}{\text{minimise}} & \ \sum\limits_{d' \in \mathcal{D}'} \bigg[ \sum\limits_{h \in \mathcal{H}} T^\mathrm{flt/tou} p_{d',h}^\mathrm{g+} - T^\mathrm{fit}p_{d',h}^\mathrm{g-} \bigg] \\ \text{subject to} \ \ & \text{\cref{eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,eqn8,eqn9}} \quad \label{eqn13} \\ &\begin{aligned} \hspace{-2cm} & p_{d',h}^\mathrm{g+} - p_{d',h}^\mathrm{g-} = \eta^\mathrm{i} \Big( p_{d',h}^\mathrm{b+} - p_{d',h}^\mathrm{b-} - p_{d',h}^\mathrm{pv} \Big) + p_{d',h}^\mathrm{d} \\ \end{aligned} \label{eqn14} \\ &\begin{aligned} \hspace{-2cm} & p_{d',h}^\mathrm{d} = p_{h}^\mathrm{base} + \sum\limits_{a \in \mathcal{A}_2} p_{a,d',h} \\ \end{aligned} \label{eqn15} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g+}\; \leq\; \bar{p}^\mathrm{g}d_{d',h}^\mathrm{g} \label{eqn16} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g-}\; \leq\; \bar{p}^\mathrm{g}\big(1 - d_{d',h}^\mathrm{g}\big) \label{eqn17} \\ & \hspace{-1.9cm} 0\; \leq\; p_{d',h}^\mathrm{g+} \leq\; \bar{p}^\mathrm{g} \label{eqn18} \\ \hspace{3em} & \hspace{-1.9cm} 0\; \leq\; p_{d',h}^\mathrm{g-} \leq\; \bar{p}^\mathrm{g} \label{eqn19} \end{align} \subsection{Model for demand-based tariffs} For customers facing a \textit{demand-based tariff} (\textit{FlatD} or \textit{ToUD}), an additional constraint~\eqref{eqn22} is used to limit the grid import according to the demand charge component, $T^\mathrm{pk}\hat{p}$ in~\eqref{eqn20}. This does not explicitly model demand charge as in practice, but implicitly achieves the same objective of clipping a customer's peak demand (See Figure~\ref{daily_peak}). The monthly optimisation model is given below for all $h \in \mathcal{H}$: \begin{align} \label{eqn20} \underset{\substack{p_{d',h}^\mathrm{g+}, p_{d',h}^\mathrm{g-}, p_{d',h}^\mathrm{b+}, p_{d',h}^\mathrm{b-}, p_{d',h}^\mathrm{d}, \\ d_{d',h}^\mathrm{g}, s_{d',h}^\mathrm{b}, e_{d',h}^\mathrm{b}, u_{h}^\mathrm{th}, T_{d',h}^\mathrm{in}, \hat{p}}}{\text{minimise}} & T^\mathrm{pk}\hat{p} + \sum\limits_{d' \in \mathcal{D}'} \bigg[ \sum\limits_{h \in \mathcal{H}} T^\mathrm{flt/tou} p_{d',h}^\mathrm{g+} - T^\mathrm{fit}p_{d',h}^\mathrm{g-} \bigg] \\ \text{subject to} \ \ & \text{\cref{eqn13,eqn14,eqn15,eqn16,eqn17,eqn18,eqn19}} \quad \label{eqn21} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g+} \leq \hat{p} \label{eqn22} \end{align} \subsection{Optimisation scenarios} \label{optscen} \par The optimisation models described above are solved for three scenarios based on customer DER ownership. Scenario I is the base case where all customers possess just EWH. Then we progressively add DER to form the other two scenarios, following~\eqref{eqn14}. Where $p_{h}^\mathrm{d} = p_{h}^\mathrm{base} + p_{h}^\mathrm{ewh}$, then the following scenarios hold: \subsubsection{Scenario I} The energy balance equation for customers with EWH only is: \begin{equation} p_{h}^\mathrm{g+} = p_{h}^\mathrm{d} \label{eqn23} \end{equation} \subsubsection{Scenario II} The energy balance equation for customers with EWH and solar PV is: \begin{equation} p_{h}^\mathrm{g+} - p_{h}^\mathrm{g-} = \eta^\mathrm{i} p_{h}^\mathrm{pv} + p_{h}^\mathrm{d} \label{eqn24} \end{equation} \subsubsection{Scenario III} The energy balance equation for customers with EWH, solar PV and batteries is: \begin{equation} p_{h}^\mathrm{g+} - p_{h}^\mathrm{g-} = \eta^\mathrm{i} \Big(p_{h}^\mathrm{b+} - p_{h}^\mathrm{b-} - p_{h}^\mathrm{pv} \Big) + p_{h}^\mathrm{d} \label{eqn25} \end{equation} \section{Annual electricity cost calculations} \label{annualcost} The annual electricity cost for customers with PV or PV-battery (Scenarios I and II) are calculated for each Tariff type as in~\eqref{eqn26} to~\eqref{eqn29} using $p_{d',h}^\mathrm{g+}$ and $p_{d',h}^\mathrm{g-}$, obtained as output variables from the optimisation. For customers without DER (Scen. I), the calculations are done without the power export component ($T^\mathrm{fit}p_{d',h}^\mathrm{g-}$). \begin{equation} \label{eqn26} \mathrm{C(\textit{Flat})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T^\mathrm{flt}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \end{equation} \begin{equation} \label{eqn27} \mathrm{C(\textit{ToU})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T_{h}^\mathrm{tou}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \end{equation} \begin{multline} \label{eqn28} \mathrm{C(\textit{FlatD})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T^\mathrm{flt}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \\ + \sum\limits_{m \in \mathcal{M}} \Big( T^\mathrm{pk}p_{m}^\mathrm{pk} \Big) \end{multline} \begin{multline} \label{eqn29} \mathrm{C(\textit{ToUD})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T_{h}^\mathrm{tou}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \\ + \sum\limits_{m \in \mathcal{M}} \Big( T^\mathrm{pk}p_{m}^\mathrm{pk} \Big) \end{multline} \par The value $p_{m}^\mathrm{pk}$ is calculated either based on the peak monthly demand (\textit{FlatD} and \textit{ToUD}) or on the average top four daily peak demand (\textit{FlatD4} and \textit{ToUD4}) for each month. In essence, the \textit{demand-based tariffs} each has two variants based on the calculation of the monthly peak demand. \section{Power flow analysis} \label{powerflow} The net grid power exchange ($p_{d}^\mathrm{g} = p_{d}^\mathrm{g+} - p_{d}^\mathrm{g-}$) resulting from the HEMS optimisation solution and the data generated from the statistical models (see Module III, Step 5 in Figure~\ref{fig1}) are fed as input to a distribution network model to perform MC power flow analysis, using Algorithm~\ref{MCPF Algorithm}. We then carry out a probabilistic assessment of yearly voltage profiles ($v_{d,c}$) for each customer and feeder head loading ($i^\mathrm{head}_{d}$) in order to ascertain the level of voltage and thermal loading problems associated with any particular network. The definitions of voltage and thermal loading problem are: \begin{algorithm}[t] \caption{Monte Carlo power flow algorithm}\label{MCPF Algorithm} \footnotesize $\mathcal{P}$: set of PV penetration levels, $\mathcal{P}:= \{0,25,50,75\}$\\ $\mathcal{B}$: set of battery penetration levels, $\mathcal{B}:= \{0,40,80\}$\\ $\mathcal{C}$: set of customers in a LV network, $\mathcal{C}:= \{1,2,...,\left\vert\mathcal{C}\right\vert\}$ \\ \begin{algorithmic}[1] \For{each $p \in \mathcal{P}$} \State Read yearly load and PV profile \If{$p = 0$} \State \textbf{Read} $p_{d,c}^\mathrm{g}\ \ \forall\ c \in \mathcal{C}, d \in \mathcal{D}$, for Sc.I\Comment{base case: 0\% PV-battery} \For{$k \longleftarrow 1\ \mathbf{to}\ 100\ \mathbf{step}\ 1$}\Comment{100 MC simulations} \State \textbf{Sample} uniformly from $p_{d,c}^\mathrm{g,Sc.I}$ for allocation to load points. \State \textbf{Run} yearly power flow \State \textbf{Return} $i_d^{\mathrm{head},k}$ and $v_{d,c}^{k}$, $\forall\ c \in \mathcal{C}, d \in \mathcal{D}$ \EndFor \Else \For{each $b \in \mathcal{B}$} \State \textbf{Read} $p_{d,c}^\mathrm{g}\ \ \forall\ c \in \mathcal{C}, d \in \mathcal{D}$, for Sc. I, II and III. \For{$k \longleftarrow 1\ \mathbf{to}\ 100\ \mathbf{step}\ 1$}\Comment{100 MC simulations} \State $p_{d,c}^\mathrm{g, Sc.I}$:= $(100 - p)\%$ of $p_{d,c}^\mathrm{g, Sc.I}$ + $p\%$.$(100 - b)\%$ of \\\hspace{1.6cm} $p_{d,c}^\mathrm{g, Sc.II}$ + $p\%$.$b\%$ of $p_{d,c}^\mathrm{g, Sc.III}$ \State \textbf{Repeat} Lines 6 to 8 \EndFor \EndFor \EndIf \EndFor \end{algorithmic} \end{algorithm} \begin{itemize} \item If a customer's voltage goes outside the range $0.95\ \mathrm{pu} \leq v_{d,c} \leq 1.05\ \mathrm{pu}$ for \SI{95}{\%} of days in a year, the customer is said to have a voltage problem. \item If the current flowing through line $i^\mathrm{head}_{d}$ (feeder head) exceeds its thermal rating, there is a thermal loading problem in the network. \end{itemize} \begin{figure}[t] \centering \includegraphics[scale = 0.65]{Figures/daily_case3.pdf} \includegraphics[scale = 0.65]{Figures/daily_case4.pdf} \caption{Illustration of peak demand reduction due to the implicit peak demand constraint $\hat{p}$ in the optimisation problem (20).} \label{daily_peak} \end{figure} \begin{figure}[t] \centering \includegraphics[scale = 0.65]{Figures/month_case1.pdf} \includegraphics[scale = 0.65]{Figures/month_case2.pdf} \includegraphics[scale = 0.65]{Figures/month_case3.pdf} \caption{Monthly peak demand of 332 Customers in the three scenarios.} \label{monthly_peak} \end{figure} \begin{figure}[tbh!] \centering \includegraphics[scale = 0.65]{Figures/percentage_change_12.pdf} \includegraphics[scale = 0.65]{Figures/percentage_change_13.pdf} \caption{Percentage change in monthly peak demand} \label{peak2} \end{figure} \begin{figure}[tbh!] \centering \includegraphics[scale=0.65]{Figures/annualcost.pdf} \caption{Annual electricity cost for 332 in the three scenarios.} \label{annual_cost} \end{figure} \begin{figure*}[tbh!] \centering \hspace{-0.8em} \subfloat \includegraphics[scale = 0.65]{Figures/loading_plot_feeder1_phase1.pdf} } \hspace{1.3em} \subfloat \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder1.pdf} } \subfloat \includegraphics[scale = 0.65]{Figures/loading_plot_feeder2_phase2.pdf} } \hspace{1.2em} \subfloat \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder2.pdf} } \renewcommand{\thesubfigure}{a} \subfloat[]{ \includegraphics[scale = 0.65]{Figures/loading_plot_feeder3_phase2.pdf} \label{loading_voltage_profiles_a} } \hspace{1.2em} \renewcommand{\thesubfigure}{b} \subfloat[] \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder3.pdf} \label{loading_voltage_profiles_b} } \caption{(a) Feeder head loading level and (b) percentage of customers with voltage problems for Feeder 1 (top), Feeder 2 (middle) and Feeder 3 (bottom). The black dotted lines separate the battery ownership levels (of 0, 40 and 80\%) at each PV penetration level (of 0, 25, 50 and 75\%).} \label{loading_voltage_profiles} \end{figure*} \section{Results} \label{results} In this section, the results from the optimisation and network power flows are analysed and discussed. For the annual electricity cost calculations, 332 customers have been chosen from the generated pool of customers, since the largest feeder used as case study comprises 302 customers. \subsection{Daily and monthly peak demand} \par The peak-demand charge has an effect of clipping a customer's daily and monthly grid power import according to~\eqref{eqn22}. Figure~\ref{daily_peak} illustrates the daily peak demand reduction of Customer 3 (a randomly selected customer) using \textit{demand-based tariffs} (\textit{FlatD} and \textit{ToUD}). We also calculate customers' monthly peak demand under the tariff types by finding the maximum grid import power for each month from the optimisation results. Figure~\ref{monthly_peak} shows the monthly peak demand for 332 customers in Scenarios I--III while Figure~\ref{peak2} shows the percentage change in the median peak demand as PV (Scen. II) and PV-batteries (Scen. III) are added. Generally, using \textit{demand-based tariffs} results in a lower monthly peak demand compared to \textit{energy-based tariffs} due to the additional demand charge to penalize grid power import. The results also show that, across all tariff types, solar PV alone (Scen. II) is not sufficient to significantly reduce the peak demand recorded in the base case (Scen. I). Observe in Figure~\ref{peak2} that solar PV is more effective at reducing the peak demand due to \textit{energy-based tariffs} (up to 16\% with \textit{Flat} tariff in January) than with \textit{demand-based tariffs} (up to 6\% in October). However, with solar PV and batteries (Scen. III), the monthly peak demand even increased (nearly up to 10\% in June) with \textit{ToU} tariff, but was lowered (up to 40\% in February) with \textit{demand-based tariffs} as compared with Scenario I (See Figure~\ref{peak2}). We can also deduce that ToU-based tariffs perform worst as DER is progressively added compared with flat tariffs (\textit{Flat} and \textit{FlatD}). This is due to the creation of new peaks when all batteries charge at off-peak times to minimise customers' electricity costs. \subsection{Annual electricity cost} \par In this section, we analyse the annual electricity costs for all scenarios using the results from Section~\ref{annualcost}, as illustrated in Figure~\ref{annual_cost}. Overall, customers pay less for electricity as DER is progressively added. While \textit{demand-based tariffs} result in a lower electricity cost compared to \textit{energy-based tariffs} in Scenario I, this slightly levels off in Scenarios II and III. This is because when prosumers' grid power import is clipped due to demand charges, they compensate for this by exporting more power to the grid. Nevertheless, the FiT rates are small compared to the retail rates so the net savings are minimal. With PV and batteries (Scenario III), however, large power export pays off uner a \textit{ToU} tariff, which results in the least annual electricity cost for consumers, but this might not be most beneficial for DNSPs. Generally, we can conclude that customers are likely to be indifferent between these tariff types, since the annual costs values are quite close. \subsection{Effects of network tariffs on line loading} \par In this section, we analyse the feeder head loading for the different PV-battery penetration levels (Figure~\ref{loading_voltage_profiles_a}). The loading levels are generally high because we have shown the phases with the highest loading (other phases follow similar pattern) for each feeder and also examined the maximum feeder head loading over the year for each MC simulation. The results show that \textit{ToU} tariff perform worst as the battery penetration level increases, which is in conformity with the results in~\cite{pimm2018time}. This is due to the batteries' response to ToU pricing by charging at off-peak times, thereby creating new peaks. Furthermore, ToU-based tariffs (\textit{ToU} and \textit{ToUD}), can adversely affect line loading due to large grid imports at off-peak times and reverse power flows resulting from power export. This can be mitigated by adding a demand charge (\textit{ToUD}) to at least clip the grid import levels, with the aid of batteries. As observed, line loading increased with higher battery penetration with \textit{ToU} tariff, while it reduced with \textit{ToUD} tariff. Contrarily, \textit{Flat} tariff results in lower line loading for all feeders. By including a demand charge to the flat tariff (\textit{FlatD}), line loading is reduced even further as seen in all three feeders. This works well with increasing battery penetration in both fairly balanced (Feeders 1 and 2) and unbalanced LV networks (Feeder 3) since there are no incentives for large grid power exports as with ToU tariffs. \subsection{Effects of network tariffs on customer voltage level} In terms of customer voltage profiles, Figure~\ref{loading_voltage_profiles_b} shows that \textit{ToU} tariff results in higher voltage problems in all three feeders compared to the other tariffs. This is particularly obvious in the case of the unbalanced feeder (Feeder 3), but can be mitigated by adding a demand charge to the ToU tariff (\textit{ToUD}). In this case, batteries are useful in reducing voltage problems. \textit{Flat} tariff, on the other hand, performs better than ToU-based tariffs in keeping customer voltage at the right levels. And again, by adding a demand charge to the flat tariff (\textit{FlatD}), there is a slight improvement in the customer voltage profiles \section{Conclusions and further work} \label{conclusion} \par In this research, we have shown that in the presence of DER, adding a peak demand charge to either a Flat or ToU tariff effectively reduces peak demand and subsequently line loading. \par To reduce a customer's peak demand, we have proposed a computationally efficient optimisation formulation that avoids the computationally expensive min-max formulation used in alternative approaches. We have demonstrated that the novel formulation, which can be seamlessly integrated into a customer’s HEMS, can be used in conjunction with DER-specific tariffs to achieve better network management and more equitable of network charges. Generally, flat tariffs perform better than ToU tariffs for mitigating voltage and alleviating line congestion problems. We conclude that, in the context of reducing network peaks, flat tariffs with a peak demand charge will be most beneficial for DNSPs. With respect to customer economic benefits, the best tariff depends on the amount of DER a customer possesses. However, the cost savings achieved by switching to another tariff type is marginal. Moreover, with reference to our previous work (all customers without EWH)~\cite{azuatalam2017impacts}, we can also conclude that the EWH has equal impacts across all tariff types in terms of line loading. However, with EWH, the line loading is generally higher. \par In this study, we have not explicitly tested these tariffs for cost-reflectivity, although this is implicit in the results. In this regard, our next task will focus on the design of these tariffs using established principles in economic theory rather than using already published tariffs from DNSPs. \bibliographystyle{elsarticle-num} \subsection*{Sets} \nomenclature[A]{$\mathcal{D}$}{Set of days, $d \in \mathcal{D}$ in a year, $\mathcal{D} = \{1,...,365\}$} \nomenclature[A]{$\mathcal{D}'$}{Set of days, $d' \in \mathcal{D}'$ in a month, $\mathcal{D}' \subset \mathcal{D}$} \nomenclature[A]{$\mathcal{H}$}{Set of half-hour time-slots, $h \in \mathcal{H}$ in a day, \\ $\mathcal{H} = \{1,...,48\}$} \nomenclature[A]{$\mathcal{M}$}{Set of months, $m \in \mathcal{M}$ in a year, $\mathcal{M} = \{1,...,12\}$} \nomenclature[B]{$\hat{p}$}{Dummy variable for modelling demand-based tariffs} \nomenclature[B]{$p^\mathrm{g+/-}$}{Power flowing from/to grid} \nomenclature[B]{$p^\mathrm{b+/-}$}{Battery charge/discharge power} \nomenclature[B]{$e^\mathrm{b}$}{Battery state of charge} \nomenclature[B]{$s^\mathrm{b}$}{Battery charging status (0: discharge, 1: charge)} \nomenclature[B]{$d^\mathrm{g}$}{direction of grid power flow (0: demand to grid, 1: grid to demand)} \nomenclature[C]{$\eta^\mathrm{b+/-}$}{Battery charging/discharging efficiency} \nomenclature[C]{$\bar{p}^\mathrm{b+/-}$}{Maximum battery charge/discharge power} \nomenclature[C]{$\eta^\mathrm{b+/-}$}{Battery charging/discharging efficiency} \nomenclature[C]{$\bar{e}^\mathrm{b}$}{Battery maximum state of charge} \nomenclature[C]{$\barbelow{e}^\mathrm{b}$}{Battery minimum state of charge} \nomenclature[C]{$p^\mathrm{pv}$}{Power from solar PV} \nomenclature[C]{$\Delta h$}{Half hourly time steps} \nomenclature[C]{$p^\mathrm{d}$}{Total customer demand} \nomenclature[C]{$p^\mathrm{res}$}{Net demand} \nomenclature[C]{$\bar{p}^\mathrm{g}$}{Maximum power taken from/to grid} \nomenclature[D]{LV}{Low voltage} \nomenclature[D]{PV}{Photovoltaic} \nomenclature[D]{DER}{Distributed energy resources} \nomenclature[D]{DNSP}{Distribution network service provider} \nomenclature[D]{FiT}{Feed in tariff} \nomenclature[D]{ToU}{Time of use} \nomenclature[D]{MILP}{Mixed integer linear programming} \nomenclature[D]{HEMS}{Home energy management system} \nomenclature[D]{EWH}{Electric water heater} \nomenclature[E]{$T^\mathrm{flt}$}{Flat energy charge} \nomenclature[E]{$T^\mathrm{tou}$}{Time-of-use energy charge} \nomenclature[E]{$T^\mathrm{fix}$}{Fixed daily charge} \nomenclature[E]{$T^\mathrm{fit}$}{Feed-in-tariff (FiT)} \nomenclature[E]{$p^\mathrm{pk}$}{monthly peak} \nomenclature[E]{$T^\mathrm{pk}$}{Monthly Peak demand charge} \section{Introduction} Investment in customer-owned PV-battery systems is growing rapidly across the globe, as they become cost-effective in certain jurisdictions. For example, the total installed capacity of residential PV-battery systems in Australia is projected to increase from 5~\si{GW} in 2017 to 19.7~\si{GW} in 2037~\cite{aemosmall,aemosolar}. In Germany, the total installed capacity of PV systems alone currently stands at 43~\si{GW}, and projected to increase to 150~\si{GW} by 2050~\cite{isefraunhofer,wirth2018recent}; while battery storage systems are expected to follow suit, with currently 100,000 installations (approx. 6~\si{GWh}) and projections for this to double within the next two years~\cite{bswsolar}. The trend towards more residential PV-battery systems is being driven by two major factors. On one hand, average household electricity prices in OECD countries have increased by over 33\% between 2006 and 2017 (using purchasing power parity). In particular, in Australia and Germany, prices have risen to about 20.4 and 39.17~\si{US. c/kWh}, respectively, from roughly 12.52~\si{US. c/kWh} (in Australia) and 20.83~\si{US. c/kWh} (in Germany) in the year 2006~\cite{energytaxes}; while feed-in-tariff (FiT) rates for PV generation have been simultaneously reduced in these countries. On the other hand, costs of PV and battery systems have seen precipitous falls in recent times. These energy price hikes and asset cost reductions are driving customers to increase their levels of energy self-consumption by investing in energy storage technology, to complement rooftop PV systems. This presents a dilemma to distribution nework service providers (DNSPs) and vertically-integrated electricity utilities --- how to design tariffs that reflect the long-run marginal cost of electricity network assets, so that all consumers receive a price signal indicating the extent to which they each contribute to network peak demand, while (i) not encouraging customers with DER to defect from the grid, and (ii) without unfairly apportioning network costs on customers without PV or other DER. This has proven to be a difficult task that has recieved much attention in the professional and academic literature~\cite{aemcrule,energy2014towards,lu2018designing,eutariff}. More broadly, recent studies have considered the economic impacts of \textit{energy-} and \textit{demand-based tariffs} on residential customers and on utilities' revenue. {Demand-based tariffs} have been shown to effectively resolve network price instability and reduce cross-subsidies between consumers without DER and prosumers~\cite{simshauser2016distribution}, and also to ensure a stable revenue for DNSPs~\cite{young2016electricity}. From the customer perspective,~\cite{abdelmotteleb2018designing} utilised a \textit{peak coincidence} network charge coupled with a fixed charge to reduce energy cost for price responsive customers. This slightly outperformed a peak demand charge but led to a reduction in overall system cost compared to traditional volumetric tariffs. In~\cite{nijhuis2017analysis}, the authors suggested that a peak demand tariff based on a customer's yearly peak demand should be considered by DNSPs, as it performed best in terms of cost-reflectivity and predictability amongst other tariff types. On the contrary, {demand-based tariffs} proposed by the Australian Energy Regulator (AER) was tested on households in Sydney, from which it was concluded that without due adjustments made, these tariffs show low cost-reflectivity~\cite{passey2017designing}. From these studies, it is evident that the suitability of network tariffs in terms of cost-reflectivity is dependent on the assumptions made in the actual design and on how customers respond to these tariffs~\cite{stenner2015australian}. \par Despite these efforts, very little research has considered the technical impacts of network tariffs on the distribution network. This is paramount because the aggregate network peak demand and energy losses are the long-run network cost drivers. It was shown in~\cite{pimm2018time} that \textit{time-of-use} (ToU) tariffs alone can increase peak loading on networks with deep DER penetration levels, where customers seek to maximise their cost savings. In view of this, authors in~\cite{supponen2016network} showed that {demand-based tariffs} could be used to mitigate transformer loading at medium voltage (MV) substations. Similarly, the results in~\cite{steen2016effects} demonstrated the effectiveness of {demand-based tariffs} in alleviating peak demand whilst considering demand response from customers' controllable appliances. In~\cite{steen2016effects}, however, customers were exposed to spot market prices (dynamic prices) and the effects of PV-battery systems were not considered. \par Given this background, in this paper, we propose a framework that allows network service providers to develop cost-reflective tariffs when considering DER-enabled customers, which is not possible with the existing tools. A mixed integer linear programming (MILP)-based home energy management system (HEMS) framework, which minimises electricity cost, is used to assess the effects of this response on typical low voltage (LV) distribution networks. For modelling {demand-based tariffs}, we include the peak demand charge as a linear term in the objective function corresponding to an additional peak demand variable multiplied by the set demand charge, which is incorporated into the model using an inequality constraint that sets the peak demand variable equal to the maximum monthly demand In this way, we retain the computational efficiency of the MILP approach by avoiding the computationally expensive min-max formulation used in~\cite{steen2016effects} that models the peak demand explicitly. We build on our earlier work in~\cite{azuatalam2017impacts} by including electric water heaters (EWH) as part of the HEMS formulation, since they account for a considerable portion of energy consumption in the Australian context and can affect peak loading~\cite{greenhouse2013}. \par The optimisation-based simulation is run for a year to account for seasonal variations in demand and solar PV output and specific to each of 332 customers. Furthermore, three scenarios are considered based on customer DER ownership, namely, EWH only, EWH$+$PV, and EWH$+$PV$+$Battery; and simulation is performed for four different network tariff types. The output of the optimisation, which reflects customer response to the tariff types is then used to carry out probabilistic power flow studies. In summary, the analysis in this paper extends the preliminary results in our earlier conference paper~\cite{azuatalam2017impacts} in the following ways: \begin{itemize} \item With limited data available, we develop a solar PV/demand and EWH statistical model to generate sufficient net load traces and hot water draws necessary to carry out power flow studies for customers with EWH and/or PV-battery systems. \item We propose a framework to test the cost-reflectivity of network tariffs by carrying out statistical economic impact analyses. With this, we assess customers' response to different network tariffs whilst incorporating detailed battery and EWH appliance models. \item We demonstrate the impacts of energy- and demand-based network tariffs on typical LV distribution networks. Specifically, we investigate the effects of these network tariffs on annual feeder head loading and customer voltage profiles at different PV-battery penetration levels. \end{itemize} The remainder of this paper is structured as follows: In the next section, we present an overview of the tariff assessment framework. This is followed by detailed household DER modelling including PV/demand and EWH hot water draw statistical models in Section~\ref{ham}. Section~\ref{optimisation} details the optimisation model of the network tariff types. In Section~\ref{annualcost}, we perform annual electricity calculations and in Section~\ref{powerflow}, we describe the power flow analysis framework. The simulation results of our case studies are presented and discussed in Section~\ref{results} while Section~\ref{conclusion} concludes the paper. \section{Methodology} A summary of the probabilistic assessment framework is detailed in Figure~\ref{fig1}. In Module I, using yearly historical data, we generate a pool of net load traces and corresponding hot water draw profiles by applying the PV/demand and EWH hot water draw statistical models described in Section~\ref{ham}. In Module II, the output of the statistical models are fed as input to the MILP-based HEMS to solve the yearly optimisation problem for the different tariff types and results are saved for each customer. With the assumption that these customers are part of a LV network, the optimisation results and output data from Module I are used to perform time-series yearly Monte Carlo (MC) power flow studies on LV distribution networks using OpenDSS~\cite{opendss}. MC simulation is employed to cater for the uncertainties in customer location and the size of DER. Therefore, 100 MC power flow simulations are performed to investigate the impacts of the network tariff types on customer voltage profile and feeder head loading at different PV-battery penetration levels. We describe the steps needed to achieve this in the following sections. \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} \tikzstyle{materia}=[draw, thick, text width=30em, text centered, minimum height=1.5em, drop shadow] \tikzstyle{practica} = [materia, fill=white, text width=28em, minimum width=28em, minimum height=3em, rounded corners, drop shadow] \tikzstyle{texto} = [above, text width=25em] \tikzstyle{linepart} = [draw, thick, -latex', dashed] \tikzstyle{line} = [draw, thick, -latex'] \tikzstyle{ur}=[draw, text centered, minimum height=0.01em] \newcommand{1.3}{1.3} \newcommand{1.5}{1.5} \newcommand{\practica}[2]{node (p#1) [practica] {\textbf{Step #1}\\{\normalsize\textit{#2}}}} \newcommand{\background}[5]{% \begin{pgfonlayer}{background} \path (#1.west |- #2.north)+(-0.5,+0.5) node (a1) {}; \path (#3.east |- #4.south)+(+0.5,-0.5) node (a2) {}; \path[rounded corners, fill=lightgray!40, draw, thick, dashed] (a1) rectangle (a2); \path (a1.east |- a1.south)+(4.6,-0.4) node (u1)[texto] {\normalsize\textit{Module #5}}; \end{pgfonlayer}} \newcommand{\transreceptor}[3]{% \path [linepart] (#1.east) -- node [above] {\scriptsize Transreceptor #2} (#3);} \begin{figure}[t!] \begin{center} \begin{tikzpicture}[scale=0.7,transform shape] \path \practica {1}{Generate a pool of net load traces \\ using the PV and Demand statistical model}; \path (p1.south)+(0.0,-1.2) \practica{2}{Generate corresponding hot water draw \\ profiles using the hot water draw statistical model}; \path (p2.south)+(0.0,-1.9) \practica{3}{Using tariff and DER data and output from Steps 1 and 2, solve the HEMS problem using MILP for a year}; \path (p3.south)+(0.0,-1.2) \practica{4}{Save the yearly power import/export results and calculate the annual electricity cost for each customer}; \path (p4.south)+(0.0,-1.9) \practica{5}{utilise data from Steps 1, 2 and the power exchange results from step 4 to run yearly Monte Carlo power flow}; \path (p5.south)+(0.0,-1.2) \practica{6}{Save customer voltage profiles and feeder head loading for each MC simulation}; \path [line] (p1.south) -- node [above] {} (p2); \path [line] (p2.south) -- node [above] {} (p3); \path [line] (p3.south) -- node [above] {} (p4); \path [line] (p1.east) -- +(0.34,0.0) -- +(0.34,-9.1) -- node [right] {} (p5); \path [line] (p2.west) -- +(-0.34,0) -- +(-0.34,-7.15) -- node [left] {} (p5); \path [line] (p4.south) -- node [above] {} (p5); \path [line] (p5.south) -- node [above] {} (p6); \background{p1}{p1}{p1}{p2}{I: Demand, PV and EWH Water Draw Synthesis} \background{p3}{p3}{p3}{p4}{II: HEMS Problem} \background{p1}{p5}{p5}{p6}{III: MC Power Flow} \end{tikzpicture} \caption{Overview of the Methodology.} \label{fig1} \end{center} \end{figure} \subsection{Low voltage networks} \par The low voltage network data used in this work were obtained from the \textit{Low Voltage Network Solutions Project}~\cite{enwlreport}. Table~\ref{table1} summarizes the main features of the three networks used as case studies in this work. These are residential LV networks of different lengths and number of load points: Feeders 1 and 2 are fairly balanced while Feeder 3 is unbalanced. Given that these feeders are from the UK, we have modified them to suit the Australian context. Typical Australian LV networks are more robust with higher load capacity when compared to that from the UK. Therefore, we have increased the transformer capacity by a factor of three and decreased the line impedances by a factor of three since the average consumption in Australia is roughly three times that in the UK. However, the overall structure of LV networks in both countries are similar. \subsection{Network model} \par We consider a LV distribution network as a radial system denoted $\mathcal{G(N,E)}$. This comprises of $\left\vert \mathcal{N}\right\vert$ nodes in the set $\mathcal{N}:= \{0,1,...,N\}$ representing network buses, and distribution lines, each denoted as a tuple $(i,j)$ connecting the nodes and represented by the set of edges $\mathcal{E}:= \{(i,j)\} \subset \mathcal{\{N \times N\}}$. Each customer, $c \in \mathcal{C}$ in the network is connected to a load bus as a single-phase load point, where the number of load buses $\left\vert \mathcal{N}_c\right\vert$ is a subset of the total nodes in the network (and $\mathcal{N}_c \subseteq \mathcal{N}$). Let $\boldsymbol{V} = [v_0, v_1,...,v_N]$ be the voltage magnitudes at the nodes, where $v_0$ is the substation voltage. Let $v_c$ be the voltage at each (customer) load point. These voltages are monitored at every half-hour in the year to check for any voltage violations. More so, the current flowing through the line connecting nodes 0 and 1 (denoted $i^\mathrm{head}$) is monitored to check for any thermal loading problems. We assume that each customer, $c \in \mathcal{C}$ in the network utilises a HEMS to manage a set of appliances in order to minimise electricity cost. The modelling of these appliances are covered in Section~\ref{ham}. \subsection{Network tariffs and retail charges} \par A typical residential customer retail bill consists of network (distribution and transmission) charges, generation costs for energy, retailer's charge and other related costs. We have sourced the network tariff data, shown in Table~\ref{table2}), from Essential Energy\footnote{Essential Energy Network Price List and Explanatory Notes. Available at https://www.essentialenergy.com.au}. These are assumed fixed and known in advance. The peak demand charge in \si{\$/kW/month} is the charge for a customer's monthly peak demand (or, alternatively, the the average of the top four daily peak demand of a customer in a month). In Table~\ref{table3}, the residential electricity prices for customers in the Essential energy distribution zone for retailer, Origin Energy\footnote{Origin Energy NSW Residential Energy Price Fact Sheet for Essential Energy Distribution Zone. Available at https://www.originenergy.com.au}, is shown. These prices comprise the actual cost of electricity, retailer's service fee, and the network charge. In this study, we have assumed that the retailers pass on the DNSP tariff structure to the consumers. The different network tariffs (energy, \textit{Flat} and \textit{ToU}, and demand-based, \textit{FlatD} and \textit{ToUD}) are described below: \begin{itemize} \item \textit{LV Residential Anytime (Flat)}: Includes a fixed daily charge and a flat usage charge. \item \textit{LV Residential Time-of-use (ToU)\footnote{Peak period: 7am to 9am, 5pm to 8pm; shoulder period: 9am to 5pm, 8pm to 10pm; off-peak period: 10pm to 7am.}}: Includes a fixed daily charge and a ToU usage charge. \item \textit{Small Residential - Opt in Demand Anytime (FlatD)}: Includes a fixed daily charge, a flat usage charge and a peak demand charge. \item \textit{Small Residential - Opt in Demand (ToUD)}: Includes a fixed daily charge, a ToU usage charge and a peak demand charge. \end{itemize} \begin{table}[t] \footnotesize \centering \caption{Network data} \label{table1} \begin{tabular}{cccc} \hline Feeder & Length & Number of & Feeder head\\ number & (\si{\meter}) & customers & ampacity (\si{\ampere})\\ \hline 1 & 5206 & 175 & 1200 \\ 2 & 4197 & 186 & 1200 \\ 3 & 10235 & 302 & 1155 \\ \hline \end{tabular} \end{table} \begin{table}[t] \footnotesize \centering \caption{Network tariff data} \label{table2} \begin{tabular}[t]{c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.2cm}}c@{\hspace{0.1cm}}} \hline \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Tariff\\ Type\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Fixed\\ charge\\ \si{\$/day}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Anytime\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Off peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Shoulder\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Demand\\ Charge\\ \si{\$/kW/month}\end{tabular} \\ \hline \textit{Flat} & 0.8568 & 11.0321 & - & - & - & - \\ \textit{ToU} & 0.8568 & - & 4.6287 & 12.6922 & 13.9934 & - \\ \textit{FlatD} & 0.8568 & 3.2169 & - & - & - & 4.2112 \\ \textit{ToUD} & 0.8568 & - & 2.1419 & 3.4771 & 4.0804 & 4.2112 \\ \hline \end{tabular} \end{table} \begin{table}[t] \footnotesize \centering \caption{Retail tariff data} \label{table3} \begin{tabular}[t]{c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.25cm}}c@{\hspace{0.2cm}}c@{\hspace{0.1cm}}} \hline \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Tariff\\ Type\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Fixed\\ charge\\ \si{\$/day}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Anytime\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Off peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Shoulder\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Peak\\ Energy\\ \si{c/kWh}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Feed-in\\ Tariff\\ \si{c/kWh}\end{tabular} \\ \hline \textit{Flat} & 1.5511 & 31.3170 & - & - & - & 9.0 \\ \textit{ToU} & 1.5511 & - & 21.3400 & 37.1470 & 38.5880 & 9.0 \\ \textit{FlatD} & 1.5511 & 23.5018 & - & - & - & 9.0 \\ \textit{ToUD} & 1.5511 & - & 18.8532 & 27.9319 & 28.6750 & 9.0 \\ \hline \end{tabular} \end{table} \subsection{Customer demand and DER data} \par We sourced the demand and solar PV generation data from the Ausgrid (DNSP in NSW) \textit{Solar Home Electricity Data}~\cite{solarhome}. This dataset comprises three years of half-hourly resolution smart meter data for the period between July 2010 to June 2013, for 300 residential customers in the Sydney region of Australia. The most recent data (for financial year, July 2012 to June 2013) is used in this study because it is complete and of higher quality, compared to the previous years in the dataset. Given that the \textit{Solar Home Electricity Data} do not contain customer hot water usage data, we selected 123 customers from the Ausgrid \textit{Smart Grid, Smart City} (SGSC)~\cite{smartgrid} dataset with complete hot water usage, solar PV and uncontrolled demand data. Then we randomly allocated these hot water profiles to selected 123 customers from the \textit{Solar Home Electricity Data}. \par Since the average PV size of the customers in the \textit{Solar Home Electricity Data} is roughly 1.5~\si{kW}, we applied a heuristic to update the PV sizes to reflect the current PV uptake rates and the average size of installed PV systems in Australia. The updated average PV size of these customers is roughly 4~\si{kW} and sizes range from 3 to 10~\si{kWp}, depending on the needs of the household. For customers with solar PV and batteries installed, the battery size of the customer depends on the size of the solar PV installed. In Australia, typically, 1.5-3~\si{kWh} of storage is used per 1~\si{kW} of PV installed~\cite{aemosmall}. This assumption is made in this work. The PV inverter efficiency has already been accounted for in the dataset, so we have assumed a PV inverter efficiency of 1 in our simulations. Table~\ref{table4} shows the PV-battery size combinations for the selected 123 customers with updated PV sizes. \begin{table}[t] \footnotesize \centering \caption{PV-Battery size combinations} \label{table4} \begin{tabular}{ccc} \hline Customers & Solar PV size & Battery size \\ \si{\percent} & \si{kW} & \si{kWh} \\ \hline 76.42 & 3 - 4 & 6 \\ 20.33 & 5 - 6 & 8 \\ 2.44 & 7 - 8 & 10 \\ 0.81 & 9 - 10 & 12 \\ \hline \end{tabular} \end{table} \section{Household DER modelling} \label{ham} For each customer, $c \in \mathcal{C}$ possessing a set of appliances, $\mathcal{A}:= \{1,2,...,\left\vert\mathcal{A}\right\vert\}$, let $\alpha \in \{1,...,M\}$ denote customer's $c$ appliance type, wherefore $\mathcal{A}_\alpha \subseteq \mathcal{A}$. In this work, we consider just three (3) appliance types $(M = 3)$: Type 1 set includes energy storage devices, particularly batteries; Type 2 set includes thermostatically-controlled devices, particularly electric water heaters (EWH); Type 3 appliances constitute the base load and includes all must-run and uncontrollable devices. \subsection{Battery energy storage system (BESS) modelling} The BESS operational model is linearised so that it fits the MILP optimisation framework. Battery sizes utilised in this study range from 6 to 12~\si{kWh} and are obtained from ZEN Energy~\cite{zenenergy}. We have assumed a minimum/maximum battery SOC of 10\%/100\% nominal capacity and a round-trip efficiency of 90\% for all battery sizes. For all $a \in \mathcal{A}_1, h \in \mathcal{H}$: \begin{align} & e_{a,h}^\mathrm{b} = e_{a,h-1}^\mathrm{b} + \Delta h \Big(\eta_a^\mathrm{b+}p_{a,h-1}^\mathrm{b+} -\ \big(1/\eta_a^\mathrm{b-}\big)p_{a,h-1}^\mathrm{b-} \Big) \label{eqn1} \\ & p_{a,h}^\mathrm{b+}\; \leq\; \bar{p}^\mathrm{b+}s_{a,h}^\mathrm{b} \label{eqn2}\\ & p_{a,h}^\mathrm{b-}\; \leq\; \bar{p}^\mathrm{b-}\big(1 - s_{a,h}^\mathrm{b}\big) \label{eqn3}\\ & 0\; \leq\; p_{a,h}^\mathrm{b+} \leq\; \bar{p}^\mathrm{b+} \label{eqn4}\\ & 0\; \leq\; p_{a,h}^\mathrm{b-} \leq\; \bar{p}^\mathrm{b-} \label{eqn5}\\ & \barbelow{e}^\mathrm{b}\; \leq\; e_{a,h}^\mathrm{b} \leq\; \bar{e}^\mathrm{b} \label{eqn6} \end{align} \begin{table}[t] \footnotesize \centering \caption{EWH Parameters} \label{table6} \begin{tabular}{cccc} \hline Number of & EWH & Element & Tank surface \\ Customers & Size $(V)$ & rating $(Q)$ & Area $(A)$ \\ \si{\percent} & \si{Liter} & \si{kW} & \si{\meter \squared} \\ \hline 2.44 & 80 & 1.8 & 1.114 \\ 8.94 & 125 & 3.6 & 1.500 \\ 86.99 & 160 & 3.6 & 1.768 \\ 1.63 & 250 & 4.8 & 2.381 \\ \hline Density $(\rho)$ & Specific heat $(c)$ & $T_\mathrm{in}$ range & Conductance $(U)$ \\ \si{\kilogram/\meter \cubed} & \si{\kilo \joule/\kilogram. \degreeCelsius} & \si{\degreeCelsius} & \si{\watt/\meter \squared. \degreeCelsius} \\ \hline 1000 & 4.18 & 60 - 82 & 1.00 \\ \hline \end{tabular} \end{table} \subsection{Electric water heater (EWH) modelling} The EWH operational model is given by a set of difference equations in order to fit them into an optimisation model~\cite{kar1996optimum,elamari2011using}. We consider single-element EWH tanks from Rheem\footnote{Rheem Electric Storage Water Heaters Specification Sheet http://www.rheem.com.au/DomesticElectricWaterHeaters} and estimated the EWH sizes for the 123 selected customers using their hot water profiles. The EWH simulation parameters are given in Table~\ref{table6}. For all $a \in \mathcal{A}_2, h \in \mathcal{H}$: \begin{align} & p_{a,h} = \eta_a^\mathrm{th} u_{a,h}^\mathrm{th}Q_a \label{eqn7} \\ &\begin{aligned} & T_{a,h}^\mathrm{in} = T_{a,h-1}^\mathrm{in} + \psi_a p_{a,h} + \lambda_a(T_{a,h-1}^\mathrm{out} - T_{a,h-1}^\mathrm{in})\ \\ & \hspace{10em} + \phi_a(T_{a,h-1}^\mathrm{inlet} - T_{a,h-1}^\mathrm{in}) \end{aligned} \label{eqn8} \\ & T_{a,h}^\mathrm{in,min} \leq T_{a,h}^\mathrm{in} \leq T_{a,h}^\mathrm{in,max} \label{eqn9} \end{align} where: $C = \rho V c$; $A\approx 6V^{2/3}$; $ \psi_a = \cfrac{\Delta h}{C}$; $\lambda_a = \cfrac{UA \Delta h}{C}$; $\phi_a = \rho W_d$; $W_d$ = EWH water draw in liters; $Q_a$ = EWH element rating in \si{kW}. \par The second term at the RHS of~\eqref{eqn8} represents the energy from the resistive element of the EWH. The third term represents the heat losses to the ambient, while the last term represents the energy required to heat the inlet cold water. \subsection{PV and demand statistical model} \label{pv-demand} In this section, we extend the non-parametric Bayesian model introduced in~\cite{power2017nonparametric} to generate a pool of demand and PV profiles needed to perform power flow studies. To accomplish this, we first cluster historical data sourced from the Ausgrid \textit{Solar Home Electricity Data} into representative clusters, using the MAP-DP (\textit{maximum a-posteriori Dirichlet process mixtures}) technique. Next, we employ the Bayesian estimation method to estimate the probability that an unobserved customer possesses certain features identified in particular clusters. The number of occurrence of these features (count) is used as a hyperparameter of a \textit{dirichlet distribution} $\mathop{\mathrm{Dir(\alpha)}}$. To assign a cluster to an unobserved customer, we use a random variable drawn from a \textit{categorical distribution} $\mathop{\mathrm{Cat(\gamma)}} $ over the features of the particular cluster, where the parameters $\gamma$ are obtained by sampling from $\mathop{\mathrm{Dir(\alpha)}}$. We then generate a pool of net load traces specific to assigned features based on a Markov chain process. More details on the PV and demand statistical model can be found in~\cite{2018arXiv180800615P}. \subsection{Hot water draw statistical model} \label{hwd} The hot water statistical model is defined for aggregated intervals of time slots during the day. It comprises a location distribution within an interval and a magnitude distribution for each time slot. The model is estimated following three steps. First the data is broken into \textit{intervals} of the day, comprised of sets of contiguous time slots. The specific intervals used in this work are given in Table~\ref{table8}. Second, a \textit{location process} is estimated for each interval. This consists of a distribution over the number of draws in an interval, and is given by a homogeneous \textit{Poisson distribution}, $\mathop{\mathrm{Pois(\mu)}}$, given by: \begin{equation} \label{eqn11} P(k\ \mathrm{draws\ in\ interval})= \exp\left[-\mu \right] \frac{\mu^{k}}{k!} \end{equation} where $\mu>0$ is the rate of draw events during the interval. Third, a magnitude distribution is estimated for the size of the draws in each interval. The magnitude of the draws are modeled as following a \textit{Weibull distribution} $\mathop{\mathrm{Wei(\kappa,\sigma)}}$, given by: \begin{equation} f(x | \kappa,\sigma) = \twopartdef { \frac{\sigma}{\kappa}\left(\frac{x}{\kappa}\right)^{\sigma-1} \exp\left[ -\left(\frac{x}{\kappa} \right)^\sigma \right] } {x \geq 0} {0} {x < 0} \end{equation} where $\kappa>0$ is a \textit{scale} parameter and $\sigma>0$ is a \textit{shape} parameter. Sampling from this model involves one additional element. Specifically, once the models are estimated and values of $\mu$, $\kappa$ and $\sigma$ computed, the full sampling process for an interval involves: (i) sampling a number of draws in an interval according to $\mathop{\mathrm{Pois(\mu)}}$ (ii) allocating these draws to time slots over the interval's time slots according to a \textit{uniform distribution} and (iii) sampling draw sizes for each draw according to $\mathop{\mathrm{Wei(\kappa,\sigma)}}$. We emphasize that in order to sample time slots for hot water draws, each interval first has a number of draws sampled from the estimated \textit{Poisson distribution}, and then that number of locations are allocated to draws in the interval according to a uniform distribution (with replacement) over time slots, as is the standard approach for sampling from Poisson processes. \begin{table}[t] \footnotesize \centering \caption{HW model intervals, with time slots indicated by their start time.} \label{table8} \begin{tabular}{cc|cc} \hline Begin & End & Begin & End \\ \hline 23:00 & 1:30 & 11:00 & 13:30 \\ 2:00 & 4:30 & 14:00 & 16:30 \\ 5:00 & 7:30 & 17:00 & 19:30 \\ 8:00 & 10:30 & 20:00 & 22:30 \\ \hline \end{tabular} \end{table} \section{Optimisation model} \label{optimisation} In this section, the optimisation model for all tariff types considering customers with EWH and PV-battery installed is described. Each problem is solved for a year, using a rolling horizon approach and a monthly decision horizon. For customers with just EWH and solar PV, the models are modified accordingly by removing the battery parameters as described in Section~\ref{optscen}. \subsection{Model for energy-based tariffs} For customers facing an \textit{energy-based tariff} (\textit{Flat} or \textit{ToU}) the monthly optimisation model is given in~\eqref{eqn12} to~\eqref{eqn19} for all $h \in \mathcal{H}$: \begin{align} \label{eqn12} \underset{\substack{p_{d',h}^\mathrm{g+}, p_{d',h}^\mathrm{g-}, p_{d',h}^\mathrm{b+}, p_{d',h}^\mathrm{b-}, p_{d',h}^\mathrm{d}, \\ d_{d',h}^\mathrm{g}, s_{d',h}^\mathrm{b}, e_{d',h}^\mathrm{b}, u_{d',h}^\mathrm{th}, T_{d',h}^\mathrm{in}}}{\text{minimise}} & \ \sum\limits_{d' \in \mathcal{D}'} \bigg[ \sum\limits_{h \in \mathcal{H}} T^\mathrm{flt/tou} p_{d',h}^\mathrm{g+} - T^\mathrm{fit}p_{d',h}^\mathrm{g-} \bigg] \\ \text{subject to} \ \ & \text{\cref{eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7,eqn8,eqn9}} \quad \label{eqn13} \\ &\begin{aligned} \hspace{-2cm} & p_{d',h}^\mathrm{g+} - p_{d',h}^\mathrm{g-} = \eta^\mathrm{i} \Big( p_{d',h}^\mathrm{b+} - p_{d',h}^\mathrm{b-} - p_{d',h}^\mathrm{pv} \Big) + p_{d',h}^\mathrm{d} \\ \end{aligned} \label{eqn14} \\ &\begin{aligned} \hspace{-2cm} & p_{d',h}^\mathrm{d} = p_{h}^\mathrm{base} + \sum\limits_{a \in \mathcal{A}_2} p_{a,d',h} \\ \end{aligned} \label{eqn15} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g+}\; \leq\; \bar{p}^\mathrm{g}d_{d',h}^\mathrm{g} \label{eqn16} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g-}\; \leq\; \bar{p}^\mathrm{g}\big(1 - d_{d',h}^\mathrm{g}\big) \label{eqn17} \\ & \hspace{-1.9cm} 0\; \leq\; p_{d',h}^\mathrm{g+} \leq\; \bar{p}^\mathrm{g} \label{eqn18} \\ \hspace{3em} & \hspace{-1.9cm} 0\; \leq\; p_{d',h}^\mathrm{g-} \leq\; \bar{p}^\mathrm{g} \label{eqn19} \end{align} \subsection{Model for demand-based tariffs} For customers facing a \textit{demand-based tariff} (\textit{FlatD} or \textit{ToUD}), an additional constraint~\eqref{eqn22} is used to limit the grid import according to the demand charge component, $T^\mathrm{pk}\hat{p}$ in~\eqref{eqn20}. This does not explicitly model demand charge as in practice, but implicitly achieves the same objective of clipping a customer's peak demand (See Figure~\ref{daily_peak}). The monthly optimisation model is given below for all $h \in \mathcal{H}$: \begin{align} \label{eqn20} \underset{\substack{p_{d',h}^\mathrm{g+}, p_{d',h}^\mathrm{g-}, p_{d',h}^\mathrm{b+}, p_{d',h}^\mathrm{b-}, p_{d',h}^\mathrm{d}, \\ d_{d',h}^\mathrm{g}, s_{d',h}^\mathrm{b}, e_{d',h}^\mathrm{b}, u_{h}^\mathrm{th}, T_{d',h}^\mathrm{in}, \hat{p}}}{\text{minimise}} & T^\mathrm{pk}\hat{p} + \sum\limits_{d' \in \mathcal{D}'} \bigg[ \sum\limits_{h \in \mathcal{H}} T^\mathrm{flt/tou} p_{d',h}^\mathrm{g+} - T^\mathrm{fit}p_{d',h}^\mathrm{g-} \bigg] \\ \text{subject to} \ \ & \text{\cref{eqn13,eqn14,eqn15,eqn16,eqn17,eqn18,eqn19}} \quad \label{eqn21} \\ & \hspace{-1.9cm} p_{d',h}^\mathrm{g+} \leq \hat{p} \label{eqn22} \end{align} \subsection{Optimisation scenarios} \label{optscen} \par The optimisation models described above are solved for three scenarios based on customer DER ownership. Scenario I is the base case where all customers possess just EWH. Then we progressively add DER to form the other two scenarios, following~\eqref{eqn14}. Where $p_{h}^\mathrm{d} = p_{h}^\mathrm{base} + p_{h}^\mathrm{ewh}$, then the following scenarios hold: \subsubsection{Scenario I} The energy balance equation for customers with EWH only is: \begin{equation} p_{h}^\mathrm{g+} = p_{h}^\mathrm{d} \label{eqn23} \end{equation} \subsubsection{Scenario II} The energy balance equation for customers with EWH and solar PV is: \begin{equation} p_{h}^\mathrm{g+} - p_{h}^\mathrm{g-} = \eta^\mathrm{i} p_{h}^\mathrm{pv} + p_{h}^\mathrm{d} \label{eqn24} \end{equation} \subsubsection{Scenario III} The energy balance equation for customers with EWH, solar PV and batteries is: \begin{equation} p_{h}^\mathrm{g+} - p_{h}^\mathrm{g-} = \eta^\mathrm{i} \Big(p_{h}^\mathrm{b+} - p_{h}^\mathrm{b-} - p_{h}^\mathrm{pv} \Big) + p_{h}^\mathrm{d} \label{eqn25} \end{equation} \section{Annual electricity cost calculations} \label{annualcost} The annual electricity cost for customers with PV or PV-battery (Scenarios I and II) are calculated for each Tariff type as in~\eqref{eqn26} to~\eqref{eqn29} using $p_{d',h}^\mathrm{g+}$ and $p_{d',h}^\mathrm{g-}$, obtained as output variables from the optimisation. For customers without DER (Scen. I), the calculations are done without the power export component ($T^\mathrm{fit}p_{d',h}^\mathrm{g-}$). \begin{equation} \label{eqn26} \mathrm{C(\textit{Flat})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T^\mathrm{flt}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \end{equation} \begin{equation} \label{eqn27} \mathrm{C(\textit{ToU})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T_{h}^\mathrm{tou}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \end{equation} \begin{multline} \label{eqn28} \mathrm{C(\textit{FlatD})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T^\mathrm{flt}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \\ + \sum\limits_{m \in \mathcal{M}} \Big( T^\mathrm{pk}p_{m}^\mathrm{pk} \Big) \end{multline} \begin{multline} \label{eqn29} \mathrm{C(\textit{ToUD})} = \sum\limits_{d \in \mathcal{D}} \bigg[ T_{d}^\mathrm{fx} + \sum\limits_{h \in \mathcal{H}} \Big( T_{h}^\mathrm{tou}p_{d,h}^\mathrm{g+} - T^\mathrm{fit}p_{d,h}^\mathrm{g-} \Big)\Delta h \bigg] \\ + \sum\limits_{m \in \mathcal{M}} \Big( T^\mathrm{pk}p_{m}^\mathrm{pk} \Big) \end{multline} \par The value $p_{m}^\mathrm{pk}$ is calculated either based on the peak monthly demand (\textit{FlatD} and \textit{ToUD}) or on the average top four daily peak demand (\textit{FlatD4} and \textit{ToUD4}) for each month. In essence, the \textit{demand-based tariffs} each has two variants based on the calculation of the monthly peak demand. \section{Power flow analysis} \label{powerflow} The net grid power exchange ($p_{d}^\mathrm{g} = p_{d}^\mathrm{g+} - p_{d}^\mathrm{g-}$) resulting from the HEMS optimisation solution and the data generated from the statistical models (see Module III, Step 5 in Figure~\ref{fig1}) are fed as input to a distribution network model to perform MC power flow analysis, using Algorithm~\ref{MCPF Algorithm}. We then carry out a probabilistic assessment of yearly voltage profiles ($v_{d,c}$) for each customer and feeder head loading ($i^\mathrm{head}_{d}$) in order to ascertain the level of voltage and thermal loading problems associated with any particular network. The definitions of voltage and thermal loading problem are: \begin{algorithm}[t] \caption{Monte Carlo power flow algorithm}\label{MCPF Algorithm} \footnotesize $\mathcal{P}$: set of PV penetration levels, $\mathcal{P}:= \{0,25,50,75\}$\\ $\mathcal{B}$: set of battery penetration levels, $\mathcal{B}:= \{0,40,80\}$\\ $\mathcal{C}$: set of customers in a LV network, $\mathcal{C}:= \{1,2,...,\left\vert\mathcal{C}\right\vert\}$ \\ \begin{algorithmic}[1] \For{each $p \in \mathcal{P}$} \State Read yearly load and PV profile \If{$p = 0$} \State \textbf{Read} $p_{d,c}^\mathrm{g}\ \ \forall\ c \in \mathcal{C}, d \in \mathcal{D}$, for Sc.I\Comment{base case: 0\% PV-battery} \For{$k \longleftarrow 1\ \mathbf{to}\ 100\ \mathbf{step}\ 1$}\Comment{100 MC simulations} \State \textbf{Sample} uniformly from $p_{d,c}^\mathrm{g,Sc.I}$ for allocation to load points. \State \textbf{Run} yearly power flow \State \textbf{Return} $i_d^{\mathrm{head},k}$ and $v_{d,c}^{k}$, $\forall\ c \in \mathcal{C}, d \in \mathcal{D}$ \EndFor \Else \For{each $b \in \mathcal{B}$} \State \textbf{Read} $p_{d,c}^\mathrm{g}\ \ \forall\ c \in \mathcal{C}, d \in \mathcal{D}$, for Sc. I, II and III. \For{$k \longleftarrow 1\ \mathbf{to}\ 100\ \mathbf{step}\ 1$}\Comment{100 MC simulations} \State $p_{d,c}^\mathrm{g, Sc.I}$:= $(100 - p)\%$ of $p_{d,c}^\mathrm{g, Sc.I}$ + $p\%$.$(100 - b)\%$ of \\\hspace{1.6cm} $p_{d,c}^\mathrm{g, Sc.II}$ + $p\%$.$b\%$ of $p_{d,c}^\mathrm{g, Sc.III}$ \State \textbf{Repeat} Lines 6 to 8 \EndFor \EndFor \EndIf \EndFor \end{algorithmic} \end{algorithm} \begin{itemize} \item If a customer's voltage goes outside the range $0.95\ \mathrm{pu} \leq v_{d,c} \leq 1.05\ \mathrm{pu}$ for \SI{95}{\%} of days in a year, the customer is said to have a voltage problem. \item If the current flowing through line $i^\mathrm{head}_{d}$ (feeder head) exceeds its thermal rating, there is a thermal loading problem in the network. \end{itemize} \begin{figure}[t] \centering \includegraphics[scale = 0.65]{Figures/daily_case3.pdf} \includegraphics[scale = 0.65]{Figures/daily_case4.pdf} \caption{Illustration of peak demand reduction due to the implicit peak demand constraint $\hat{p}$ in the optimisation problem (20).} \label{daily_peak} \end{figure} \begin{figure}[t] \centering \includegraphics[scale = 0.65]{Figures/month_case1.pdf} \includegraphics[scale = 0.65]{Figures/month_case2.pdf} \includegraphics[scale = 0.65]{Figures/month_case3.pdf} \caption{Monthly peak demand of 332 Customers in the three scenarios.} \label{monthly_peak} \end{figure} \begin{figure}[tbh!] \centering \includegraphics[scale = 0.65]{Figures/percentage_change_12.pdf} \includegraphics[scale = 0.65]{Figures/percentage_change_13.pdf} \caption{Percentage change in monthly peak demand} \label{peak2} \end{figure} \begin{figure}[tbh!] \centering \includegraphics[scale=0.65]{Figures/annualcost.pdf} \caption{Annual electricity cost for 332 in the three scenarios.} \label{annual_cost} \end{figure} \begin{figure*}[tbh!] \centering \hspace{-0.8em} \subfloat \includegraphics[scale = 0.65]{Figures/loading_plot_feeder1_phase1.pdf} } \hspace{1.3em} \subfloat \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder1.pdf} } \subfloat \includegraphics[scale = 0.65]{Figures/loading_plot_feeder2_phase2.pdf} } \hspace{1.2em} \subfloat \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder2.pdf} } \renewcommand{\thesubfigure}{a} \subfloat[]{ \includegraphics[scale = 0.65]{Figures/loading_plot_feeder3_phase2.pdf} \label{loading_voltage_profiles_a} } \hspace{1.2em} \renewcommand{\thesubfigure}{b} \subfloat[] \includegraphics[scale = 0.65]{Figures/voltage_plot_feeder3.pdf} \label{loading_voltage_profiles_b} } \caption{(a) Feeder head loading level and (b) percentage of customers with voltage problems for Feeder 1 (top), Feeder 2 (middle) and Feeder 3 (bottom). The black dotted lines separate the battery ownership levels (of 0, 40 and 80\%) at each PV penetration level (of 0, 25, 50 and 75\%).} \label{loading_voltage_profiles} \end{figure*} \section{Results} \label{results} In this section, the results from the optimisation and network power flows are analysed and discussed. For the annual electricity cost calculations, 332 customers have been chosen from the generated pool of customers, since the largest feeder used as case study comprises 302 customers. \subsection{Daily and monthly peak demand} \par The peak-demand charge has an effect of clipping a customer's daily and monthly grid power import according to~\eqref{eqn22}. Figure~\ref{daily_peak} illustrates the daily peak demand reduction of Customer 3 (a randomly selected customer) using \textit{demand-based tariffs} (\textit{FlatD} and \textit{ToUD}). We also calculate customers' monthly peak demand under the tariff types by finding the maximum grid import power for each month from the optimisation results. Figure~\ref{monthly_peak} shows the monthly peak demand for 332 customers in Scenarios I--III while Figure~\ref{peak2} shows the percentage change in the median peak demand as PV (Scen. II) and PV-batteries (Scen. III) are added. Generally, using \textit{demand-based tariffs} results in a lower monthly peak demand compared to \textit{energy-based tariffs} due to the additional demand charge to penalize grid power import. The results also show that, across all tariff types, solar PV alone (Scen. II) is not sufficient to significantly reduce the peak demand recorded in the base case (Scen. I). Observe in Figure~\ref{peak2} that solar PV is more effective at reducing the peak demand due to \textit{energy-based tariffs} (up to 16\% with \textit{Flat} tariff in January) than with \textit{demand-based tariffs} (up to 6\% in October). However, with solar PV and batteries (Scen. III), the monthly peak demand even increased (nearly up to 10\% in June) with \textit{ToU} tariff, but was lowered (up to 40\% in February) with \textit{demand-based tariffs} as compared with Scenario I (See Figure~\ref{peak2}). We can also deduce that ToU-based tariffs perform worst as DER is progressively added compared with flat tariffs (\textit{Flat} and \textit{FlatD}). This is due to the creation of new peaks when all batteries charge at off-peak times to minimise customers' electricity costs. \subsection{Annual electricity cost} \par In this section, we analyse the annual electricity costs for all scenarios using the results from Section~\ref{annualcost}, as illustrated in Figure~\ref{annual_cost}. Overall, customers pay less for electricity as DER is progressively added. While \textit{demand-based tariffs} result in a lower electricity cost compared to \textit{energy-based tariffs} in Scenario I, this slightly levels off in Scenarios II and III. This is because when prosumers' grid power import is clipped due to demand charges, they compensate for this by exporting more power to the grid. Nevertheless, the FiT rates are small compared to the retail rates so the net savings are minimal. With PV and batteries (Scenario III), however, large power export pays off uner a \textit{ToU} tariff, which results in the least annual electricity cost for consumers, but this might not be most beneficial for DNSPs. Generally, we can conclude that customers are likely to be indifferent between these tariff types, since the annual costs values are quite close. \subsection{Effects of network tariffs on line loading} \par In this section, we analyse the feeder head loading for the different PV-battery penetration levels (Figure~\ref{loading_voltage_profiles_a}). The loading levels are generally high because we have shown the phases with the highest loading (other phases follow similar pattern) for each feeder and also examined the maximum feeder head loading over the year for each MC simulation. The results show that \textit{ToU} tariff perform worst as the battery penetration level increases, which is in conformity with the results in~\cite{pimm2018time}. This is due to the batteries' response to ToU pricing by charging at off-peak times, thereby creating new peaks. Furthermore, ToU-based tariffs (\textit{ToU} and \textit{ToUD}), can adversely affect line loading due to large grid imports at off-peak times and reverse power flows resulting from power export. This can be mitigated by adding a demand charge (\textit{ToUD}) to at least clip the grid import levels, with the aid of batteries. As observed, line loading increased with higher battery penetration with \textit{ToU} tariff, while it reduced with \textit{ToUD} tariff. Contrarily, \textit{Flat} tariff results in lower line loading for all feeders. By including a demand charge to the flat tariff (\textit{FlatD}), line loading is reduced even further as seen in all three feeders. This works well with increasing battery penetration in both fairly balanced (Feeders 1 and 2) and unbalanced LV networks (Feeder 3) since there are no incentives for large grid power exports as with ToU tariffs. \subsection{Effects of network tariffs on customer voltage level} In terms of customer voltage profiles, Figure~\ref{loading_voltage_profiles_b} shows that \textit{ToU} tariff results in higher voltage problems in all three feeders compared to the other tariffs. This is particularly obvious in the case of the unbalanced feeder (Feeder 3), but can be mitigated by adding a demand charge to the ToU tariff (\textit{ToUD}). In this case, batteries are useful in reducing voltage problems. \textit{Flat} tariff, on the other hand, performs better than ToU-based tariffs in keeping customer voltage at the right levels. And again, by adding a demand charge to the flat tariff (\textit{FlatD}), there is a slight improvement in the customer voltage profiles \section{Conclusions and further work} \label{conclusion} \par In this research, we have shown that in the presence of DER, adding a peak demand charge to either a Flat or ToU tariff effectively reduces peak demand and subsequently line loading. \par To reduce a customer's peak demand, we have proposed a computationally efficient optimisation formulation that avoids the computationally expensive min-max formulation used in alternative approaches. We have demonstrated that the novel formulation, which can be seamlessly integrated into a customer’s HEMS, can be used in conjunction with DER-specific tariffs to achieve better network management and more equitable of network charges. Generally, flat tariffs perform better than ToU tariffs for mitigating voltage and alleviating line congestion problems. We conclude that, in the context of reducing network peaks, flat tariffs with a peak demand charge will be most beneficial for DNSPs. With respect to customer economic benefits, the best tariff depends on the amount of DER a customer possesses. However, the cost savings achieved by switching to another tariff type is marginal. Moreover, with reference to our previous work (all customers without EWH)~\cite{azuatalam2017impacts}, we can also conclude that the EWH has equal impacts across all tariff types in terms of line loading. However, with EWH, the line loading is generally higher. \par In this study, we have not explicitly tested these tariffs for cost-reflectivity, although this is implicit in the results. In this regard, our next task will focus on the design of these tariffs using established principles in economic theory rather than using already published tariffs from DNSPs. \bibliographystyle{elsarticle-num}
{'timestamp': '2019-05-24T02:08:07', 'yymm': '1810', 'arxiv_id': '1810.02013', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02013'}
arxiv
\section*{Abstract} We present heuristics for solving the maximin problem induced by the generative adversarial privacy setting for linear and convolutional neural network (CNN) adversaries. In the linear adversary setting, we present a greedy algorithm for approximating the optimal solution for the privatizer, which performs better as the number of instances increases. We also provide an analysis of the algorithm to show that it not only removes the features most correlated with the private label first, but also preserves the prediction accuracy of public labels that are sufficiently independent of the features that are relevant to the private label. In the CNN adversary setting, we present a method of hiding selected information from the adversary while preserving the others through alternately optimizing the goals of the privatizer and the adversary using neural network backpropagation. We experimentally show that our method succeeds on a fixed adversary. \section{Introduction} Assume that an entity, whom we call the \textit{privatizer} holds some data it wishes to publish to the public, but that the data includes some sensitive information, such as gender or race, that the entity wants to hide from the public. We will assume that there exists another entity, whom we call the \textit{adversary}, whose goal is to recover the sensitive information from the data published by the privatizer, and publicly available data that relates the features of the privatizer's data with the sensitive labels. If the privatizer naively removes the sensitive labels and publishes the rest of the data as-is, the adversary can accurately recover the sensitive labels using various machine learning models with the publicly available data. Thus, the privatizer needs to encrypt its data using a privatization function before it publishes it to the public. We will assume the worst case for the privatizer, in which the privatization function is known to the adversary, perhaps through publications or information leakage. The natural methodology that the adversary would use is to first simulate the privatization function on the publicly available data to obtain a relationship between the privatized data and the sensitive information. Then he would use this relationship to predict the sensitive labels from the privatized data published by the privatizer. The privatizer's goal is to hinder such attempt by the adversary. This problem is a zero-sum game, in which the adversary attempts to minimize his loss on predicting the sensitive labels, while the privatizer attempts to maximize this value. From the privatizer's perspective, finding the optimum requires solving a maximin problem: \[ \argmax_P {\min_{f \in \mathcal{H}_{adv}} \mathcal{L}(f(P(X)), y)}, \] where $P$ stands for the privatizer's function and $L$ stands for the loss function. In addition, the privatizer wants to release useful data to the public, which we will model by restricting the amount of change in the data: \[ \norm[2]{X - P \left( X \right)} ^2 \leq D, \] for some constant $D$. In this paper, we investigate this problem when $\mathcal{H}_{adv}$, the hypothesis class of the adversary, is either linear or convolutional neural network (CNN). \section{Related Work} \subsection{Minimax Optimization} Zero-sum games are games in which the two players' utilities sum to zero, which is commonly seen in real life. The two players in a zero-sum game are subject to solving a minimax game, in which each of the players attempt to minimize the maximum utility gained by the opponent. Due to its omnipresence, much work has been done to accurately and efficiently solve the minimax games under variant restrictions~\cite{char1974minimax, char1978minimax}. The setup that we are working with is a zero-sum game between the privatizer and the adversary, and this naturally gives rise to a maximin game, which is just a negation of a minimax game. \subsection{Generative Adversarial Networks} Recently, \textit{generative adversarial network} (GAN)~\cite{goodfellow2014explaining, szegedy2013intriguing} was proposed to generate data to simulate real data. The GAN solved the minimax problem between the \textit{generator} and the \textit{discriminator} to train a good generative network. The idea of training a generator with another network inspired us on how to train the privatizer network. This generator tries to deceive the adversary, while the adversary tries to avoid being fooled by it. \subsection{Generative Adversarial Privacy} Recent works~\cite{huang2017context, hamm2016minimax} have introduced the idea of \textit{generative adversarial privacy} (GAP) and showed that it is possible to add noise that selectively disturbs algorithms that can learn the \textit{private labels}, while preserving the utility of algorithms that can learn \textit{public labels}. There is also some promising results in the case in which the models used by the adversary and the ally are both linear~\cite{Xu2017cleaning}. Our work differs from these previous works in that we aim to preserve the overall data, instead of choosing a label to preserve the accuracy for. \section{Methods} \subsection{Linear Adversary Case} We will solve the privatizer's problem with lossy compression using a compression matrix $A$. In this case, the privatizer's problem simplifies to: \begin{align*} \text{Minimize} \quad & \norm[2]{y^T \left( X A A^+ \right) \left( X A A^+ \right)^+}^2, \\ \text{subject to} \quad & \norm[Frob]{X - X A A^+ }^{2} \leq D \end{align*} where the compression matrix $A$ is the variable. This problem is difficult because the variable is encapsulated in a pseudoinverse that is difficult to simplify.\footnote{One of the steps leading to the convexity results in the milestone had an error.} We therefore look at a smaller subset of the problem by restricting the data compression with respect to the features. Then, the problem reduces to partitioning the set of features into two sets, $R$, the set of features that are removed by the compression, and $S$, the set of features that are preserved by the compression. The optimum of this subproblem can be found by solving \begin{align*} \text{Maximize} \quad & \norm[2]{y - X_{i \in R} X_{i \in R}^+}, \\ \text{subject to} \quad & \norm[2]{X_{i \in R}}^{2} \le D \end{align*} where the set of excluded features, $R$, is the variable.\footnote{If $y=X\theta$, the target function reduces further to $\norm[2]{\left( X_{i \in R} - X_{i \in S} X_{i \in S}^+ X_{i \in R} \right) \theta_{i \in R}}^2$.} Solving this problem by brute force results in exponential time complexity. Therefore, we propose an approximation algorithm for computing the optimum based on the ideas of the greedy algorithm. In each step of the greedy algorithm (Algorithm~\ref{alg:greedy}), we select the element that maximizes the utility, $\|{y - X_{i \in R \cup \left\{ e \right\} }X_{i \in R \cup \left\{ e \right\} }^+ } \|_{2}$, per unit cost, $\norm[2]{X_{R \cup \left\{ e \right\} } }^{2}$. \begin{algorithm} \caption{Greedy Algorithm}\label{alg:greedy} \begin{algorithmic}[1] \Procedure{Greedy-Approx($D$)}{} \State $R \gets \phi $ \State \textbf{do} \State \quad\, $e_{next} \gets \textsc{Find-Next}\left(R, D \right)$ \State \quad\, $R \gets R \cup \left\{ e_{next} \right\}$ \State \textbf{while} $e_{next} \ne \text{null}$ \State \Return $R$ \EndProcedure \end{algorithmic} \begin{algorithmic}[1] \Procedure{Find-Next($R$, $D$)}{} \State ${(u/c)}_{max} \gets -\infty$ \State $e_{next} \gets \text{null}$ \For{$e \in \left\{1, \cdots , n\right\} \backslash R$} \State $c \gets \norm[2]{X_{R \cup \left\{ e \right\} } }^{2}$ \If{$c > D$} \State \textbf{continue} \EndIf \State $u \gets \|{y - X_{i \in R \cup \left\{ e \right\} }X_{i \in R \cup \left\{ e \right\} }^+ } \|_{2}$ \If{$v/c > (u/c)_{max}$} \State $(u/c)_{max} \gets u/c$ \State $e_{next} = e$ \EndIf \EndFor \State \Return $e_{next}$ \EndProcedure \end{algorithmic} \end{algorithm} \subsection{CNN Adversary Case} \begin{figure}[ht] \begin{subfigure}{.5\textwidth} \centering \includegraphics[width = \linewidth]{Adversary.png} \caption{Adversary neural network structure} \label{fig:adversary} \end{subfigure} \begin{subfigure}{.5\textwidth} \centering \includegraphics[width = \linewidth]{Privatizer.png} \caption{Privatizer neural network structure} \label{fig:privatizer} \end{subfigure} \caption{Adversary and privatizer network structures} \label{fig:cnn_struct} \end{figure} In the CNN adversary case, we assume that the adversary's network comprises of convolutional layers, activation layers (ReLu), pooling layers, fully connected layers, and a loss layer (softmax cross entropy loss) as exemplified by Figure \ref{fig:adversary}. The privatizer uses a neural network (Figure \ref{fig:privatizer}) that consists of an (1) encoder, which not only reduces the features by convolutional layers, but also tries to capture the high level features that the adversary would capture, a (2) decoder, which uses deconvolutional layers to map the captured features into the pixel space. The resulting output of the privatizer's network is the noise, $\Delta X$ that he/she adds to the original image $X$, to obtain a privatized image, $X + \Delta X$. The restriction in the amount of change in the data, in this case, becomes: \[ \norm[2]{\Delta X} ^2 \leq D. \] We also added a constraint that we want to preserve the prediction accuracy as much as possible for a selected set of labels with a pre-trained model on the original data, which we call \textit{protected labels}.~\footnote{We are able to preserve prediction accuracies of labels that are not highly correlated with the private label without this constraint, but with this constraint, we can preserve prediction accuracies on even highly correlated labels such as gender and decoration in 11k Hands.} \begin{algorithm} \caption{Maximin Algorithm for CNN Adversary}\label{alg:maximin} \begin{algorithmic}[1] \Procedure{Solve-Maximin(X, D)}{} \State $\theta_{pro} \gets \displaystyle \argmin_{\theta} \mathcal{L}_{pro}(X; \theta)$ \State $\theta_{adv} \sim \text{Xavier}$ \State $\theta_{priv} \sim \text{Xavier}$ \While{ $\Delta \theta_{adv} > \epsilon \text{ or } \Delta \theta_{priv} > \epsilon$} \State $\theta_{adv} \gets \displaystyle \argmin_{\theta}{\mathcal{L}_{priv} \left( X + \Delta X \left(X, \theta_{priv}, D \right); \theta \right)}$ \State $\theta_{priv} \gets \displaystyle \argmax_{\theta}{\mathcal{L}_{priv} \left( X + \Delta X \left(X, \theta, D \right); \theta_{adv} \right)}$ \State $\theta_{priv} \gets \displaystyle \argmin_{\theta}{\mathcal{L}_{pro} \left( X + \Delta X \left(X, \theta, D \right); \theta_{pro} \right)}$ \EndWhile \EndProcedure \end{algorithmic} \end{algorithm} In determining the model for the privatization function, the privatizer solves the maximin problem mentioned in Section 1. The privatizer's method for solving this maximin problem by (Algorithm~\ref{alg:maximin}): (1) initializing the privatizer's internal model for the adversary's parameters, $\theta_{adv}$, and the privatizer's own parameters, $\theta_{priv}$, randomly, (2) fixing $\theta_{priv}$ and solves for the optimal $\theta_{adv}$ against the loss function of the private labels from the adversary's perspective using backpropagation, (3) fixing $\theta_{adv}$ and solves for the optimal $\theta_{priv}$ against the loss function of the private labels from the privatizer's perspective using backpropagation, (4) finding the optimal $\theta_{priv}$ against the loss function of the protected labels, and (5) repeating these steps until convergence. \section{Dataset and Features} \begin{figure}[t!] \begin{center} \begin{adjustbox}{max width=3.2in} \begin{tabular}{ | c | c | c | c |} \hline dataset & instances ($m$) & features ($n$) & labels ($N$) \\ \hline \hline \multicolumn{4}{|c|}{$\mathcal{H}_{adv}$: linear} \\ \hline Beijing PM 2.5~\cite{Liang2015beijing} & $41757$ & $7$ & $2$ \\ \hline UCI Wine Quality~\cite{cortez2009wine} & $4898$ & $7$ & $5$ \\ \hline \multicolumn{4}{|c|}{$\mathcal{H}_{adv}$: CNN} \\ \hline GENKI~\cite{GENKI-4K} & $4000$ & $200 \times 200 \times 1$ & $4$ \\ \hline 11k Hands~\cite{afifi2016hands} & $5538$ & $200 \times 200 \times 3$ & $4$ \\ \hline \end{tabular} \end{adjustbox} \caption{\label{fig:dataset}Summary of datasets} \end{center} \end{figure} For the linear adversary case, we use generated data of various sizes to confirm that the greedy approximation indeed approaches the true optimum. We generated the input data randomly using a uniform distribution $\text{unif} \left( 0, 1 \right)$, and varied the number of features from $4$ to $7$ and the number of instances from $10$ to $1000$. We use Beijing PM 2.5 dataset~\cite{Liang2015beijing} and UCI Wine Quality dataset~\cite{cortez2009wine} (Figure~\ref{fig:dataset}) to observe the properties of the optimum that we obtain. Of the properties included in the Beijing PM 2.5 dataset, we utilize the properties \textit{year}, \textit{month}, \textit{day}, \textit{hour}, \textit{temperature}, \textit{pressure}, and \textit{cumulated wind speed} as features, and \textit{PM2.5 concentration} and \textit{dew point} as labels. For this dataset, we removed any instance that included missing features. In addition, of the properties included in the UCI Wine Quality dataset, we utilize the properties \textit{fixed acidity}, \textit{volatile acidity}, \textit{citric acid}, \textit{residual sugar}, \textit{chlorides}, \textit{free sulfur dioxide}, and \textit{total sulfur dioxide} as features, and \textit{density}, \textit{pH}, \textit{sulphates}, \textit{alcohol}, and \textit{quality} as labels. In the investigation of CNN adversaries, we used two different datasets called GENKI~\cite{GENKI-4K} and 11k Hands~\cite{afifi2016hands} (Figure~\ref{fig:dataset}). GENKI is a dataset of $4000$ human faces that is labeled with \textit{head pose} and \textit{smile content.} We replaced images that included multiple people or that were too low resolution for even humans to understand the image, and labeled \textit{gender} for each of the images. We also normalized the sizes to $200 \times 200$ and converted the images to grayscale. The main dataset is 11k Hands, a dataset of 11076 hands labeled with \textit{the subject ID}, \textit{gender}, \textit{age}, \textit{skin color}, \textit{left/right}, which we will call \textit{hand side}, \textit{dorsal/palmar}, \textit{accessories}, \textit{nail polish}, and \textit{irregularities}. We only used the dorsal side ($5538$) images and combined the labels accessories and nail polish by an `or' operation to obtain a new label, \textit{decoration}. Then, we reduced the size of the images to $200 \times 200$. We also augmented the training data by flipping the images, changing to grayscale, adding noise, and shifting the images to help the network capture essential features. \section{Results and Discussion} \subsection{Linear Adversary Case} \begin{figure*}[t!] \centering \begin{subfigure}{.32\textwidth} \centering \includegraphics[width=0.95\linewidth]{pm2_5.png} \caption{dew point (private) vs PM 2.5} \label{fig:beijing_priv} \end{subfigure} \begin{subfigure}{.32\textwidth} \centering \includegraphics[width=0.95\linewidth]{wine_quality.png} \caption{alcohol \% (private) vs wine quality} \label{fig:wine_priv} \end{subfigure} \begin{subfigure}{.32\textwidth} \centering \includegraphics[width=0.95\linewidth]{wine_quality_rev.png} \caption{alcohol \% (private) vs pH} \label{fig:wine_priv2} \end{subfigure} \begin{subfigure}{.32\textwidth} \centering \includegraphics[width=0.95\linewidth]{genki_acc.png} \caption{gender (private) vs smile content} \label{fig:genki_acc} \end{subfigure} \begin{subfigure}{.40\textwidth} \centering \includegraphics[width=0.95\linewidth]{11k_hand_acc.png} \caption{accuracies of labels for 11k Hands} \label{fig:11khand_acc} \end{subfigure} \caption{Effect of privatization: (a) Beijing PM 2.5, (b, c) Wine (d) GENKI, and (e) 11k Hands } \label{fig:greedy_priv} \end{figure*} \begin{figure}[ht] \centering \includegraphics[width = \linewidth]{greedy_plot.png} \caption{\label{fig:greedy_plot}Ratio of optimum achieved by greedy} \end{figure} Figure~\ref{fig:greedy_plot} shows the relationship between the number of instances and the proportion of runs in which the greedy approximation achieved the optimum for varying number of features, obtained from the randomly generated toy data. The results indicate that the greedy approximation achieves the optimum more often as the number of instances increases. Furthermore, the results seem to indicate that for greater number of features, we need more instances in order to accomplish the same proportion. In the experiment with the Beijing PM 2.5 dataset, we set the dew point as the private label and PM 2.5 as the public label. Figure~\ref{fig:beijing_priv} shows the change in the L2 loss for these two labels. The loss of the dew point increased from $0.044$ to $0.153$, while the loss of PM 2.5 increased only from $0.031$ to $0.033$. The features removed by greedy algorithm were in the order of: temperature, pressure, and day (of month). These features are relevant to both labels, but whereas the dew point is directly related to the temperature and the pressure, PM 2.5 is only indirectly related to these features. We set alcohol content as the private label and the rest of the labels as public labels in the experiment with the UCI Wine Quality. Figure~\ref{fig:wine_priv} shows the change in the L2 loss for the private label, alcohol content, and a public label, wine quality. The loss of the alcohol content increased from $0.096$ to $0.108$, while the loss of the wine quality increased only from $0.081$ to $0.082$. The features removed by the greedy algorithm were in the order of: total $\text{SO}_{2}$, fixed acidity, and citric acid. These features are highly relevant to the alcohol content.\footnote{$\text{SO}_{2}$ is a byproduct of fermentation, the cooler the origin of the wine, the higher the acidity and the lower the alcohol content.} On the other hand, if we compare the loss of the private label, alcohol content, against that of another public label, pH, we experience a relatively high increase in the loss of the public label (Figure~\ref{fig:wine_priv2}). Specifically, the loss of the pH increased from $0.055$ to $0.068$, which is comparable to the increase in the loss of the alcohol content. This is because two of the removed features, fixed acidity and citric acid, are highly correlated with both the pH and the alcohol content. Here, we conclude that it is more difficult to preserve accuracy of the public labels that are dependent on the same features as the private label. \subsection{CNN Adversary Case} We used Google TensorFlow~\cite{45381} for handling neural networks. For the GENKI dataset, we used two convolutional layers of sixteen $7 \times 7$ filters, each followed by a max-pool layers, and a fully connected layer of size $128$ for the adversary's network. We used the same structure as the adversary's network for the privatizer's encoder, and used a fully connected layer of size $40000$ for the privatizer's decoder. We set gender as the private label, and the smile content as the public label in this dataset. The original test accuracy was 73\% for the gender and 70\% for the smile content. With the privatized images, the accuracy of the gender decreased to 53\%, while that of the smile content increased to 77\% (Figure~\ref{fig:genki_acc}). For the 11k Hands dataset, we used three convolutional layers with two $3\times3$ filters, four $4\times4$ filters and eight $3\times3$ filters respectively, each followed by a max-pool layer, and finally a fully connected layer of size $32$ for the adversary's network. The pre-trained neural network for the protected labels has three convolutional layers with four $3\times3$ filters, eight $4\times4$ filters and sixteen $3\times3$ filters respectively, each followed by a max-pool layer, and finally a fully connected layer of size $64$. The encoder of the privatizer has the same structure as that of the protected labels, and decoder of the privatizer is symmetric to the encoder (Figure~\ref{fig:privatizer}). We set gender as the private label, decoration as the protected label, and the rest as public labels. The accuracy achieved with the original data is 91.6\% (gender), 89.5\% (skin), 97.1\% (hand side), and 97.2\% (decoration). With the privatized images, the accuracy for gender dropped to 58.7\%, while the accuracies for skin, hand side, and decoration changed to 89.5\%, 97.0\%, and 97.3\%, respectively (Figure~\ref{fig:11khand_acc}). In sum, the accuracy for the private label dropped, whereas the accuracies for the other labels did not change significantly. As we desired, the privatized images did not undergo notable distortion (Figure~\ref{fig:Noise}). Theoretically the convergence occurs when the privatizer can cover all the private label-related features to a certain level. However, due to the limited computing resources and limited time, we were not able to attempt a thorough set of parameters with larger networks, and did not observe the convergence. \begin{figure}[t!] \centering \includegraphics[width = \linewidth]{Noise.png} \caption{Original and privatized images} \label{fig:Noise} \end{figure} \section{Conclusion} We present an efficient method of constructing a privatizer when the adversary is limited to linear models using a greedy approximation, which improves with the number of instances increasing. Moreover, we found that the greedy algorithm removes features most correlated with the private label first, and that the algorithm preserves the predictability of public labels as long as they are sufficiently independent of the features that are relevant to the private label. We also present a method for building a privatizer against a CNN adversary. We were able to selectively lower the private label's accuracy while preserving other labels' accuracies against a fixed CNN adversary. However, we lacked computational power for testing sufficiently many hyperparameters to achieve convergence. \section{Future Work} In the linear adversary case, theoretically bounding the performance of the greedy algorithm and finding how the relationship between features affects the optimum would solidify our findings. Also, we only compressed the data with respect to the standard basis, but because any orthonormal basis can be transformed into a standard basis using an invertible matrix multiplication, we can easily generalize our results to any other orthonormal basis. The natural next step is to find which orthonormal basis induces the best optimum. Regarding the CNN adversary case, we will continue aiming for convergence of the algorithm by searching for hyperparameters in a larger space with greater computational power. In this case, the loss function should be calculated for all the history of the evolving adversary so that all the private attribute-related features are covered. Afterwards, whether our method generalizes to more complicated neural networks remains a future work. \section*{Acknowledgement} We thank Peter Kairouz ([email protected]), a postdoctorate scholar in the Department of Civil and Environmental Engineering, Stanford University, for his mentorship in this work. \section*{Contributions} Dae Hyun Kim has taken the lead on the linear adversary case and helped out with the CNN adversary case through general advice and help with finding parameters. Taeyoung Kong has helped out with the linear adversary case through confirmation and scribing, and helped out with the CNN adversary case through general advice and help with finding parameters. Seungbin Jeong has taken the lead on the CNN adversary case and helped out with the linear adversary case through general advice. \bibliographystyle{ieeetr}
{'timestamp': '2018-10-05T02:07:30', 'yymm': '1810', 'arxiv_id': '1810.02069', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02069'}
arxiv
\section{Introduction} \label{sec:Introduction} The classical approach to the control of robotic systems consists in developing an electro-mechanical model of the robot, defining the range of operating conditions, and building algorithms for robot/environment state estimation and robot control. This approach, while efficient in highly controlled environments (such as robotized factories), can lead to severe failures when operating under unforeseen circumstances. Making robots more autonomous and capable of operating in unstructured a priori unknown environments is the main objective of modern robotic research. The application of techniques from machine learning and artificial intelligence has enabled significant progress in this direction over recent decades. Numerous solutions have been proposed for online robot self-modelling~\cite{Sigaud2011, Hersch2008, Sturm2009, Yoshikawa2004, Martinez2010} (see also \cite{Hoffmann2010} for a comprehensive review) and recovery from unknown damages~\cite{Bongard2006, Koos2013, Wiesel2005}. These solutions usually define a set of building blocks (such as rigid bodies) and the rules of their connection (e.g. joints) and try to find the combination of these blocks that best accounts for the incoming sensory information given the motor commands. Examples using such an approach can be found for instance in \cite{Tsai1988,Bennett1991} and more recently in \cite{Schilling2011, Hersch2009}. Another approach avoids defining building blocks but instead adds some pre-processing of the sensory flow to avoid facing its raw complexity, generating inputs that suit the task. Such pre-processing can for instance be used to define the coordinates of the robot's hand in the visual field to learn a kinematic model of the arm \cite{Chao2014, Jamone2012} or a target object for reaching \cite{NataleMetta2007, Gaskett2003}. Although this type of approach often produces spectacular results, its robustness and efficiency strongly depend on the choice of the building blocks and pre-processing algorithms. This makes the entire approach heavily biased by the designer's intuition, which is rooted in human perception and which is not necessarily best suited for robots, whose sensors and effectors differ significantly from those of human beings. To understand the implications of this difference, consider the fact that the entire field of computer vision has been biased by the false perceptual intuition that seeing is similar to having a photo of the visual scene~\cite{Rensink1997,ORegan1999} and that stepping aside from this paradigm can yield unexpectedly fruitful results~\cite{Benosman2011,Lorach2012,Rogister2012}. Thus, to make robotic systems truly autonomous and robust, we need to shed the biases imposed on us by our own perceptual system and let robots develop their own ways of perceiving the world. Few studies adopting such a radical approach to control robots have been proposed \cite{Censi2012, Hoffmann2013, Kuipers2008}. Although these studies are in line with our approach, they do not directly address the problem of space perception (or only implicitly through the robot's ability to move in its environment). This will be the main focus of the present paper. In order to minimize a prioris about perceptual systems we consider a robotic agent designed as a \emph{tabula rasa} receiving undifferentiated sensory inputs (e.g. not knowing whether a given one of them comes from a video camera or from an encoder in a joint) and sending out undifferentiated motor outputs. Perceptual structures can emerge as stable patterns in the agent's sensorimotor flow. This approach, when applied to visual information, can lead to the discovery of stable features, such as edges, similar to those present in the human visual cortex~\cite{Schmidhuber1996,Olshausen1996,Masquelier2007,Lee2008,Choe2008}. A similar approach, formalized in the language of information theory~\cite{Klyubin2004}, can make it possible to describe the topological structure of the agent's surface~\cite{McGregor2011} and certain properties of its interaction with the environment~\cite{Kaplan2004,Klyubin2005a,Gordon2011}. The cited studies clearly show that \emph{tabula rasa} agents can learn basic properties of the available sensorimotor information. However, only the simplest perceptual notions are straightforwardly dictated by the sensory inputs themselves. More complicated notions represent laws linking sensations and actions, rather than particular instances of sensory information \cite{OReganNoe2001}. Space, which does not correspond to any particular sensory inputs, is one such a notion. Can a \emph{tabula rasa} approach be used to model the acquisition of the notion of space? In order to answer this question we first need to decide on what we mean by the term \emph{space}. In mathematics, various spaces are described: topological, metric, linear, etc. Each of these notions captures certain features of what we usually mean by space. For example, topological spaces only feature the notion of proximity, and can be thought of as reflecting an agent with a highly impaired ability to make distance judgments (which is true for humans performing certain tasks). Although rather primitive, topological space nevertheless includes some fundamental aspects of space in general, such as dimensionality, and its notion can be useful in such tasks as the mapping of large spaces ~\cite{Pierce1997}. Metric spaces are more complicated objects, which imply precise information of distances. They provide the tool required to work with such notion as the length of a path, and can underlie navigation abilities. In particular, knowledge of a metric space enables odometry and SLAM~\cite{Mueller1988, Smith1990, Bowling2007}. Linear spaces introduce the notion of the vector, which is an efficient tool for describing motion. The link between motion and linear spaces is used in many studies that address the problem of space acquisition. Thus, Poincar\'e~\cite{Poincare1895} suggested that spatial knowledge emerges from the agent's capacity to move, with spatial relations such as the distance to an object being internally encoded as potential motor commands. The agent's ability to move has also played an essential role in more recent works on space \cite{Pierce1997, Stober2011, Roschin2011}. Philipona and co-authors showed in~\cite{Philipona2003} that under certain conditions the dimensionality of space can be estimated by analyzing only sensorimotor information that is available to the agent. This result launched a series of publications by the present authors, extending the conditions of dimension estimation \cite{Laflaquiere2012} and applying similar ideas to different agents and robotic systems \cite{Laflaquiere2010,Bernard2012,Laflaquiere2013}. Knowing the number of spatial dimensions is not, however, the same as having the notion of space. It has recently been shown that the notion of space can be learned as a proprio-tactile mapping \cite{Roschin2011} or as a group of rigid transformations of the environment \cite{Terekhov2013}. Here we focus on a different aspect of spatial knowledge, probably the simplest that can be extracted by a naive agent. In order to introduce it, let us first note that mathematical spaces (topological, metric, etc.) do not emphasize what is special about our subjective experience of space. Mathematical spaces can be applied, for example, to describe the full set of an agent's body postures, or motor commands, or even the outputs of every pixel in the agent's visual sensor (e.g. camera). However, these examples clearly do not correspond to what we usually mean by space. We believe that what characterizes space is the particular structure that it imposes on possible sensorimotor experiences. It can be identified in the laws that govern the way sensory inputs change as the agent moves around. The first and most basic property of those laws is an invariance: space does not depend on the particular environment, nor on the particular posture of the agent. The agent must somehow know that its sensor is at the same spatial position independently of what objects are around and what are the positions of the other sensors. In other words, the first aspect of the notion of space is the ``point of view'' from which the agent ``looks'' at the world (here we adopt visual terminology for simplicity, but the notion must not depend on the particular type of sensors in question: camera, microphone, or taxel array). From now on, when we speak about the notion of space we will be referring to the set of the agent's ``points of view''. These ``points of view'' are the precursors to the more convenient notion of ''point'', which is the basic element of what we call space, and which can be used to build more complex notions of space. Note that in our approach, we are looking at the problem of space from the agent's point of view. Instead of taking the existence of external space for granted, we are trying to identify signs of it in the agent's sensorimotor flow, and to see what makes the notion of space useful to the agent. Our hope is that by learning how the notion of space can be constructed from the sensorimotor flow we will acquire a better understanding of how other perceptual notions can be learned, such as body, object, etc. In this respect, our work is notably different from the field of research on body schema acquisition, which is already the subject of a large literature. The question of space is usually eluded in these studies, as it is supposed to be either an unnecessary prerequisite for action or to already have been acquired. This study extends our previous work~\cite{Laflaquiere2013}, where a neural network was used to learn a mapping between the motor space and an internal representation of the agent's external configuration. This internal representation was generated online during the exploration of multiple environments. The present paper introduces two main improvements. First, it offers a clear definition of the structure of the constraints captured by the agent. In doing so, it makes explicit the mapping that was implicitly captured by the neural network in our previous study. Second, the metrics of the internal representation are no longer derived statistically from the exploration of multiple sensory manifolds, but from motor data. This ensures its independence from the actual content of the explored environments. The current study complements our previous work~\cite{Terekhov2013}, which assumes that the agent already possesses the notion of space as a collection of ``points of view'' and determines a group of rigid displacements over them, thus approaching the notion of geometry in the sense of Klein. The paper is organized as follows. Section~\ref{sec:Part1} is dedicated to the problem of space acquisition, illustrated with a simplified agent. The representation variance w.r.t.\ the environmental changes is highlighted, and a solution to this problem is proposed. Next, it is shown in Section~\ref{sec:Part3} how the manifold of points of view can be obtained in a more complicated case, and a discussion on the genericity of the results follows. Finally, a conclusion ends the paper. \section{Problem statement} \label{sec:Part1} In this section, two simple scenarios are presented to illustrate the key idea of the paper. A first agent is introduced to show why considering only exteroception is problematic when attempting to produce a stable internal representation of spatial properties. A solution to this problem is proposed through a second agent, with the introduction of motor information into the constraint-capturing process. \subsection{Formalization and definitions} \label{sec:Part1_0} In the following, we consider so-called \emph{naive} agents which have no a priori knowledge about the world they are immersed in and, in particular, about the existence and structure of space. We assume that they have access to both motor and exteroceptive sensory information. We also assume here that any possible proprioceptive sensory information is a redundant copy of motor information. We thus ignore it and consider only motor information. The agent's motor output and sensory input are respectively defined as: \begin{equation} \mathbf{m} = (m_1,m_2,\dots,m_{N})^T \text{ ; } \mathbf{s} = (s_1,s_2,\dots,s_K)^T, \end{equation} where $m_n, n \in \{1,\dots,N\}$ is the command driving the $n$-th motor and $s_k, k \in \{1,\dots,K\}$ is the output of the $k$-th sensor distributed on the agent's body. The sets of all possible outputs $\mathbf{m}$ and inputs $\mathbf{s}$ are respectively called \emph{motor} and \emph{sensory space}. For any state of the environment, denoted $\bm{\mathcal{E}}$, we postulate a sensorimotor law $\sigma$ such that: \begin{equation} \mathbf{s} = \sigma_{\bm{\mathcal{E}}}(\mathbf{m}). \label{eq:sigma} \end{equation} This relation specifies that, according to the physics of the world, any motor output $\mathbf{m}$ is associated with a sensory input $\mathbf{s}$ for a given environment $\bm{\mathcal{E}}$. Note that the sensorimotor law is of course unknown to the naive agent. The objective of this paper is to understand why and how the notion of space can emerge in such a naive agent whose whole experience is captured by this unknown sensorimotor law. From an external point of view, space is usually understood as a container in which the agent and objects are immersed and in which they are endowed with the notions of (relative) position/orientation and can go through transformations (displacements). Nonetheless, explaining how such sophisticated notions can emerge from an agent's raw sensorimotor interactions with its environment(s) is far from trivial. In particular, we need to be able to answer the following question: \emph{how can the agent discover that there exists a stable external structure within which it lives and which corresponds to what we, humans, call ``space''?} From the point of view of a naive agent with no a priori knowledge about space, this notion needs to be reconsidered through the prism of sensorimotor information. We propose to consider space as \emph{a set of constraints that all possible functions $\sigma_.(.)$ satisfy}. Moreover, since the structure of space should not depend on its content, \emph{those constraints have to be invariant to the environmental state $\bm{\mathcal{E}}$}. In this paper, the naive agent's objective is to capture the existence of these constraints. More precisely, we assume that the agent's intrinsic drive is to capture structures underlying its sensorimotor experience and to represent it in an economical way. We hypothesize that the discovery of the spatial constraints can be materialized by the construction of an internal representation of the agent's configuration with respect to the external space it is immersed in. It can be argued that such an explicit internal representation is unnecessary. As suggested in~\cite{Laflaquiere2013}, the constraints could of course be captured implicitly in the system. The explicit internal representation will however be useful for an algorithmic / semantic agent, as opposed to a distributed neural-networks-based agent. In what follows, this approach is illustrated with two ``toy examples'' and then applied to a simulated robot arm in section~\ref{sec:Part3}. \subsection{The variability of sensory experience} \label{sec:Part1_1} When thinking about space, there is a natural tendency to focus on information provided by the agent's exteroceptive flow. Without any a priori knowledge, this is indeed the only source of information about the external world. In keeping with this fact, most work in robotics about the discovery of spatial properties relies on the analysis of exteroceptive data. One example~\cite{Wyss2006} can be cited where a camera is used to infer the approximate topology of the environment that a mobile robot operates in. In an overwhelming majority of cases, exteroceptive sensory data are even pre-processed so as to already carry spatial knowledge according to the roboticist's own a priori knowledge (for instance the position of the robot's hand in~\cite{Sturm2009, Cheah2010}). However, as implied by \eqref{eq:sigma}, the $K$ raw sensory inputs $s_k$ depend on the state of the environment $\bm{\mathcal{E}}$: the sensory input $\mathbf{s}$ changes with the objects in the environment. Thus, it is not obvious how the notion of space, which should be independent of a particular environment, can be extracted from data that depends so heavily on it. \begin{figure}[tb] \centering \includegraphics[width=.7\linewidth]{Exemple_jouet_1.pdf} \caption{The agent can move its sensors in external space using its motor. Although the external agent configuration $x$ can be the same, its sensory experience varies greatly depending on the structure of the environment.} \label{fig:ToyExample1} \end{figure} To illustrate the problem, consider the so-called ``toy agent'' depicted in Fig.~\ref{fig:ToyExample1}. For the sake of simplicity, the agent is immersed in a $2$D space. It has a simple T-shaped structure which is moved along a line by a single motor command $\mathbf{m}=m_1$. It is endowed with two light sensors placed on its top, such that $\mathbf{s}=(s_1,s_2)^T$. The environment is made up of $L=5$ point light sources randomly distributed around the agent. The sensory inputs are generated as follows: \begin{equation} s_i = \sum_{l=1}^{L} 1/d_{i,l}^2, i=\{1,2\}, \end{equation} where $d_{i,l}$ is the Euclidean distance between the $i$-th sensor and the $l$-th light source. The agent can explore its environment by moving along a line (parametrized by $x$ from an external point of view), for example by sending out random values of the motor command $\mathbf{m}$. For each motor output, it receives the corresponding sensory input $\mathbf{s}$. If the environment is static and invariant during exploration, these collected outputs form a $1$D manifold $\mathcal{S}$ in the agent's sensory space (see Fig.~\ref{fig:ToyExample1}, center). This result was expected, as the dimensionality of the manifold $\mathcal{S}$ is determined by the number of degrees of freedom during exploration \cite{Laflaquiere2010}. In some sense, the sensory manifold $\mathcal{S}$ describes the agent's internal experience of its translation in space, and is the only information it can gather about space. However, $\mathcal{S}$ depends dramatically on the environment: the same exploratory movements performed in a different environment $\bm{\mathcal{E}'}$ will yield another sensory manifold $\mathcal{S'}$, which is totally different from $\mathcal{S}$ (see Fig.~\ref{fig:ToyExample1}, center and right). Consequently, it is difficult for the agent to extract knowledge about space --- which should be independent of the state of the environment --- from exteroceptive experience. \subsection{Introducing motor information to capture external information} \label{sec:Part1_2} Biological findings suggest that the development of visual spatial perception is extremely dependent on the agent's ability to move actively, and not simply observe the visual changes caused by passive displacements in space~\cite{Held1963}. A similar conclusion can be drawn from sensory substitution experiments~\cite{Bach-y-Rita:2003it}. This difference between the active and passive generation of the same sensory experience reflects the importance of the knowledge of motor commands during the acquisition of spatial knowledge. From a more philosophical point of view, Poincar\'e~\cite{Poincare1895} also suggested that the notion of space and displacements should necessarily be rooted in the agent's ability to move. We thus propose to introduce motor information in our attempt to establish how a naive agent can discover space. As described above, we define space as a set of constraints on the sensorimotor relationship $\mathbf{s}=\sigma_{\bm{\mathcal{E}}}(\mathbf{m})$ which maps motor output $\mathbf{m}$ onto the sensory space. It thus seems natural to look for space not in exteroceptive data themselves, but in the laws linking motor actions $\mathbf{m}$ to the sensory inputs $\mathbf{s}$. Moreover, since space should be independent of its content, some of the constraints on these laws have to be invariant to the state of the environment. To illustrate the process by which this invariance can be captured, let us introduce a slightly less trivial toy agent which differs from the previous one in that it has two redundant actuators, $m_1$ and $m_2$, as shown in Fig.\ref{fig:ToyExample2}. Just like the previous one, this new agent can explore its environment by sending random commands $\mathbf{m}=(m_1,m_2)^T$ and moving its exteroceptors in space along what, from an external point of view, is the same line. Evidently, for the environment $\bm{\mathcal{E}}$ the second agent will discover the same sensory manifold $\mathcal{S}$ as the first (see Fig.\ref{fig:ToyExample1}, center). However, the structure of its motor space is different, since $2$ motors are now involved in the generation of the $1$D manifold $\mathcal{S}$. In other words, there exist distinct sets of motor outputs $\mathbf{m}$ that generate the same sensory input $\mathbf{s}$. Hence, for any sensory input $\mathbf{s}$ from $\mathcal{S}$ related to a position of the agent in space, there exist a variety of motor outputs $\mathbf{m}$ such that $\sigma_{\bm{\mathcal{E}}}(\mathbf{m}) = \mathbf{s}$, for a given environmental state $\bm{\mathcal{E}}$. Such a coincidence in sensory inputs can be noticed, and the underlying motor outputs can be associated, defining the sets \begin{equation} \mathcal{M}^{\mathbf{s}} = \left\{\mathbf{m} \mid \mathbf{s} = \sigma_{\bm{\mathcal{E}}}(\mathbf{m})\right\}, \forall \mathbf{s} \in \mathcal{S}. \end{equation} The sets $\mathcal{M}^{\mathbf{s}}$ can be seen as the kernels of the functions $\sigma_{\bm{\mathcal{E}}}-\mathbf{s}, \forall \mathbf{s} \in \mathcal{S}$. The aforementioned structural difference between the motor space and the sensory manifold $\mathcal{S}$ reveals the existence of constraints that apply to sensorimotor experience. Assuming an intrinsic drive to reduce the complexity of the internal representation of the agent's sensorimotor experience, the agent should thus be driven to capture the structure underlying those constraints. By doing so, it discovers the notion of space, as we defined it above. Such a discovery would not be expected in the first toy agent. Indeed, no additional structure was required to capture the sensorimotor experience, as there was a one-to-one relationship between motor output $\mathbf{m}$ and the corresponding sensory state $\mathbf{s}$. Rigorously speaking, it can be argued that a notion of space was also captured in the first toy example, as in that case too space exists and constrains the sensorimotor system. But those constraints are so trivial that they do not stimulate the agent to capture any underlying structure in its experience. It thus does not fit our definition. \begin{figure}[tb] \centering \includegraphics[width=.7\linewidth]{Exemple_jouet_2.pdf} \caption{The agent can move its sensors using two redundant motors. Any external configuration $x$ of the sensors is thus internally related to a set of redundant motor configurations $\mathcal{M}^i$. Those sets define a manifold which can be used to represent the external configuration via an internal parameter $q$.} \label{fig:ToyExample2} \end{figure} For the example under consideration, the two motor commands $m_1$ and $m_2$ are redundant in determining the agent's position $x$ in space . The sets $\mathcal{M}^\mathbf{s}$ thus take the form of oblique lines, such that $m_1+m_2=x$ (see Fig.~\ref{fig:ToyExample2}, right). In general and for any agent, if the environment $\bm{\mathcal{E}}$ is rich enough, the sensory input $\mathbf{s}$ is different for different positions of the exteroceptors in space. Note that in very peculiar environments this statement can be false. Seen through the agent's sensors, some environments could for instance present symmetries such that multiple spatial configurations of the agent would generate the same sensory input. If the same symmetry were to recur in every explored environment, the final structure captured by the agent would differ from what an external observer would expect. This is known to be the case for animals raised in particularly structured visual environments~\cite{Held1963, Blakemore1970}. However, it must be understood that to the agent's subjective experience, such an altered notion of space would be perfectly suitable as long as it worked for all environments that the agent encountered. On the other hand, if such symmetries are rare, we assume that the agent tries to capture a structure that is generic to all the explored environments. Such exotic cases are thus statistically filtered out in the experience accumulated during the agent's lifetime. Those particular cases aside, every set $\mathcal{M}^\mathbf{s}$ corresponds to a certain input $\mathbf{s}$ but also to a certain position of the agent in space. For a different environment $\bm{\mathcal{E}'}$, the sensory manifold can change to $\mathcal{S}'$ but the sets $\mathcal{M}^{\mathbf{s'}}$ will be exactly the same as the structure of the agent is unchanged and it is exploring the same external positions $x$. Even if sensations $\mathbf{s}$ depend on the environment, the sets $\mathcal{M}^\mathbf{s}$ are thus environment-independent. As a consequence, we will use the index $i$ instead of $\mathbf{s}$ to denote a particular set $\mathcal{M}^i$. All the possible sets $\mathcal{M}^i$ have a specific structure that can be captured to build an internal representation of the external agent's configuration. Thus, each set $\mathcal{M}^i$ can be considered as a point on some new manifold. For this purpose, a metric function has to be introduced to define a distance $\rho(\mathcal{M}^j,\mathcal{M}^k)$ between every pair of sets $\langle \mathcal{M}^j,\mathcal{M}^k \rangle$. Together these distances define a manifold where each point is internally related to a motor set $\mathcal{M}^i$ and externally to an agent position $x$. It can therefore be used as an internal representation of the agent's external configuration. For the second toy agent, the definition of a distance between each line $\mathcal{M}^i$ in the motor space (see Fig.\ref{fig:ToyExample2}, right) leads to the construction of a $1$D manifold. The parameter $q$ used to move along this manifold is an internal representation of the external parameter $x$. Note that to obtain this internal representation the agent does not have to assume the existence of space: it simply has to associate the motor commands resulting in the same sensory input with each other. The notion of space is thus a byproduct of the agent's drive to capture its sensorimotor experience in a compact way. This section has been devoted to the presentation of the key idea that \emph{despite the environment-dependency of exteroception, an invariant representation of the external agent's configuration can be built by taking into account motor information.} After a short illustration of this paradigm with two very basic scenarios, in the following section we use a more realistic agent to assess the approach. \section{Application to a robotic arm} \label{sec:Part3} In this section, we simulate a robotic arm with several degrees of freedom to test the idea that spatial information can be acquired by looking into the redundant sets $\mathcal{M}^i$, which are the kernels of the function $\sigma_{\bm{\mathcal{E}}}-\mathbf{s}$. With minimal a priori knowledge, our objective is to build an invariant internal representation of the arm's end-point configuration to illustrate the capture of the constraints imposed by the existence of space. First we present the agent and the way sensory inputs are simulated. Second, the agent's exploration and the internal representation of its external configuration are described. Finally, the results are analyzed and discussed. \subsection{Description of the agent} \label{sec:Part3-1} The agent is a three-segment serial arm with a retina-like sensor on its end-point (see Fig.\ref{fig:Pinehole}). Each segment is one unit long and each of the agent's $N=4$ hinge joints is actuated by a motor (with command $m_i$, $i\in \{1,\dots,4\}$). The agent thus has four motor outputs controlling the three external parameters of its retina: its $[x,y]$ position and orientation $\alpha$, although it has no knowledge of it. The retina-like sensor is similar to a pinhole camera (see Fig~\ref{fig:Pinehole}). The retina is regularly covered with $6$ cells which are sensitive to light sources in the environment. The unitary excitation produced on the $i$-th cell by a punctual light source $l$ is: \begin{equation} s_{i,l} = \frac{\exp(-||p_{cell_i}-p_{proj_l}||^2)}{||[x,y]-[x_{source_l},y_{source_l}]||} \end{equation} with $p_{cell_i}$ being the retinal position of the $i$-th cell, $p_{proj_l}$ the retinal position of the $l$-th light source projection, $[x,y]$ the lens's position in external space and $[x_{source_l},y_{source_l}]$ the position of the $l$-th light source in external space. The environment is made up of $L=10$ randomly distributed point light sources. The total excitation $s_i$ of the $i$-th cell is: \begin{equation} s_i = \sum_{l=1}^{L} s_{i,l}. \end{equation} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{pinehole.pdf} \caption{On the left: the agent is a three-segment arm equipped with $4$ motors and a light-sensitive retina. On the right: the retina is regularly covered with $6$ light-sensitive cells. Light from the light sources is projected onto the retina through a pinhole lens. Each cell's excitation is a Gaussian function of its distance to the light projection.} \label{fig:Pinehole} \end{figure} \subsection{Algorithm for the generation of the internal representation} \label{sec:Part3-2} The internal representation of the retina's configuration in space is generated in three steps. The algorithm used during the simulation is presented in \ref{sec:Algorithm}. Note once again that building an explicit internal representation of the captured structure is not mandatory. This knowledge could be captured implicitly in the system, as in the neural network presented in~\cite{Laflaquiere2013}. However, having some explicit internal representation of the sets $\mathcal{M}^i$ and a metric defined on them is useful for an algorithmic / semantic system as opposed to a neural network system. For example, such a representation can be used to reduce the dimensionality when sampling a new visual environment: the agent with an explicit internal representation ``knows'' that it needs to sample the three-dimensional space of the internal representation and not the full four-dimensional space of motor commands. In addition to this, in what follows here we build an illustration of this structure as a means to visualize and interpret the knowledge extracted by the agent. \paragraph{Step 1} The agent collects the sensorimotor data by sending random outputs $\mathbf{m}^i=(m_1^i,m_2^i,m_3^i,m_4^i)^T$ to its motors. To simplify the presentation of the results (see section \ref{sec:Discussion}), we only analyze configurations whose corresponding retinal position is located within a rectangular working space. The size of the working space was arbitrarily set to $\{2,1,5\}$ units (height and width) and with its center located $1.75$ units in front of the agent. The analysis is restricted to $2500$ different arm configurations. Figure Fig~\ref{fig:Arm_manifold}a presents the working space and a sampling of the $2500$ arm configurations. \paragraph{Step 2} A sensory input $\mathbf{s}^i$ is associated with every motor output $\mathbf{m}^i$. The sets $\mathcal{M}^i$ of redundant motor outputs generating the same inputs $\mathbf{s}^i$ are then determined. They are estimated using the local Jacobian of $\sigma_{\bm{\mathcal{E}}}$ and following the direction of the kernel in its motor space (see details in Appendix~A). Note that the naive agent does not know this Jacobian, and that it is introduced here only to accelerate the simulation. A more realistic scenario, in which these manifolds are estimated purely on the basis of unlabelled sensorimotor data, is described in \cite{Laflaquiere2013}. A sampling of the $2500$ manifolds $\mathcal{M}^i$ corresponding to the outputs $\mathbf{m}^i$ is illustrated in Fig.~\ref{fig:Arm_manifold}b. Each manifold in the figure is approximated by 100 points. \paragraph{Step 3} An internal representation of the external retina configuration is determined as the manifold of $\mathcal{M}$'s. This manifold is defined by computing the Hausdorff distance for every pair $\langle\mathcal{M}^i, \mathcal{M}^j\rangle$. Note that any other metrics could be used instead to define the distances between the sets $\mathcal{M}^i$. \begin{figure}[t!] \centering \includegraphics[width=0.6\linewidth]{Hausdorff.pdf} \caption{The Hausdorff distance between two sets $\mathcal{M}^i$ and $\mathcal{M}^j$ corresponds to the greatest of all the distances from a point in one set to the closest point in the other set.} \label{fig:Hausdorff} \end{figure} The Hausdorff distance between two sets is the greatest of the shortest distances taken to travel from one set to the other in the metric space they belong to (see illustration in Fig.\ref{fig:Hausdorff}). In our application, the metric space is Euclidean (motor space) and the two sets are the sampled manifolds $\mathcal{M}^i$ and $\mathcal{M}^j$. However, we slightly modify the Euclidean metrics to take into account the periodicity implied by the agent's hinge degrees of freedom. Indeed, the external retinal configuration, and thus the sensory input $\mathbf{s}$, is unchanged modulo $2\pi$ for any motor output $m_i, \forall i \in \{1,\dots,4\}$. This periodicity would artificially increase the Euclidean distance between motor outputs which should be closer according to sensory information (internal point of view) and to the real configuration of the robot (external point of view). We thus use a modified Euclidean distance such that the distance between the $k$-th sample of $\mathcal{M}^i$ and the $l$-th sample of $\mathcal{M}^j$ in the motor space is computed as follows: \begin{equation} g\big(\mathbf{m}^i[k],\mathbf{m}^j[l]\big)= \sqrt{\sum_{n=1}^{N} h\Big(m^i_n[k]-m^j_n[l] \Big)^2}, \label{eq:deuclimodif} \end{equation} with $N=4$ the dimension of the motor space and: \begin{equation} h(u) = \left\{ \begin{array}{r c c} 2\pi-u & \text{ if } & u>\pi \\ -2\pi-u & \text{ if } & u<-\pi \end{array} \right\}. \end{equation} This way, the distance between two individual motor values $\{m^i_n[k],m^j_n[l]\}$ cannot be greater than $\pi$, while the distance between two motor configurations $\{\mathbf{m}^i[k],\mathbf{m}^j[l]\}$ cannot be greater than $\sqrt{4\pi^2}=2\pi$. Finally, the modified Hausdorff distance between $\mathcal{M}^i$ and $\mathcal{M}^j$ is computed as follows: \begin{equation} \rho(\mathcal{M}^i,\mathcal{M}^j) = \max \left\{ \begin{array}{c} \max_k \Big( \min_l \Big( g\big(\mathbf{m}^i[k],\mathbf{m}^j[l]\big) \Big) \Big) \\ \max_l \Big( \min_k \Big( g\big(\mathbf{m}^i[k],\mathbf{m}^j[l]\big) \Big) \Big) \\ \end{array} \right\}. \end{equation} The definition of all pairwise distances allows us to project the underlying manifold of $\mathcal{M}$'s. The latter is embedded into a space of a priori unknown dimensionality, but here it is projected into a $3$D space for the visualization purpose. It is important to notice here again that this projection isn't mandatory and doesn't have to be explicitly performed by the agent. Indeed, all relevant information about the manifold of points of view is already contained in the metrics $\rho(\mathcal{M}^i,\mathcal{M}^j)$. By simply applying this new metrics instead of the natural Euclidean one in the motor space, the agent can for example reduce the intrinsic dimensionality of its motor sampling when exploring a new environment. Hereunder the projection is nonetheless a useful tool to visualize and analyze the manifold structure captured by the agent. It was performed using a non-linear dimension reduction method: Curvilinear Component Analysis (CCA) \cite{Demartines1997}. The CCA defines a position in the representational space for every projected point by trying to preserve the topology of the underlying manifold. For more details on the method, a complete description of the algorithm can be found in~\cite{Demartines1997} and an example application in~\cite{Laflaquiere2012}. \subsection{Results and discussion} \label{sec:Part3-3} The resulting projection is provided in Fig.~\ref{fig:Arm_manifold}d, with two different views on the manifold. Colored surfaces have been added to facilitate its interpretation. Each one corresponds to a $10\times 10$ uniform sampling of positions $[x,y]$ in the working space for a fixed orientation $\alpha$. Depending on the surface, this orientation varies from $0$ to $360$ degrees in $36$-degrees steps. The color coding of the surfaces is associated, from an external point of view, to the parameter $x$. Figure \ref{fig:Arm_manifold}c presents a qualitative representation of the manifold; a section associated to the projection of the working space for a given orientation of the retina is colored in green. As expected for the configuration of a planar object in plane, the resultant manifold has the topology of $\mathbb T\times\mathbb{R}^2$; that is, a circle $\mathbb T$ (retinal orientation) times a plane $\mathbb{R}^2$ (retinal position). As displayed schematically in Fig.\ref{fig:Arm_manifold}c, each parameter of the retina's external configuration $[x,y,\alpha]$ has been successfully captured: $x$ is encoded along the manifold's height, $y$ along its width and $\alpha$ along its transverse section. By discovering sets $\mathcal{M}^i$ associated with constant sensory inputs and determining the structure of the manifold they form, the agent has thus been able to build an internal representation of its external configuration. Moreover, this manifold is built from motor sets $\mathcal{M}^i$ which are environment-independent. Performing the same exploration in different environments thus leads to the construction of the same internal manifold. As described in~\S\ref{sec:Part1_2}, some peculiar environments could lead to the definition of different sets $\mathcal{M}^i$ even if the structure of the agent has not changed. If they are rare, these exotic cases would be statistically filtered out over the agent's lifetime experience. If they are recurrent, a different structure would be captured by the agent, leading to an altered notion of space, but it would perfectly characterize the agent's interaction with the world and the actual spatial experience that it can have. Nonetheless, in rich enough environments the probability of having such symmetric sensory experiences should be insignificant. \begin{figure}[h!] \centering \includegraphics[height=0.83\textheight]{Arm_manifold.pdf} \caption{a) $1$\% of the $2500$ exploratory arm configurations $\mathbf{m}^i$. b) Two $3$D projections of $1$\% of the sets $\mathcal{M}^i$ embedded in the $4$D motor space. c) Schematic of the projected manifold and capturing of external parameters. d) Projection in $3$D of the $2500$ manifolds $\mathcal{M}^i$ (gray points) with surfaces corresponding to translations in the working space for different retinal orientations.} \label{fig:Arm_manifold} \end{figure} It is important to distinguish the agent's internal representation of space and the illustration of this representation, depicted in Fig.\ref{fig:Arm_manifold}. The internal representation is captured by the sets $\mathcal{M}^i$ and the manifold of these sets obtained by introducing a metric on them (which is the Hausdorff distance in our example). The illustration of this representation is obtained by immersing the manifold of $\mathcal M$'s into a vector space and then showing its non-linear projection (CCA) into a three-dimensional space (see Fig.\ref{fig:Arm_manifold}). The purpose of the illustration is exclusively to facilitate the understanding of the internal representation for a reader. The illustration is rather unstable. For example, for a different working space (shape, size or position), the final projection would change. As CCA cannot preserve the metric precisely during data projection, the orientation, position and to some extent the shape of the projection would be (randomly) different from the one displayed in Fig.\ref{fig:Arm_manifold}d. Nevertheless, the topology of the two manifolds would be coherent. In other words, the manifolds generated by the separate exploration of two different working spaces could be patched together so as to appear as two connected pieces of a single larger manifold. This consistency highlights the fact that the agent is exploring a single external space, possibly in separate patches. Likewise, the structure of the constraints imposed by space on the agent's sensorimotor experience could be captured incrementally by progressively discovering the sets $\mathcal{M}^i$. When such a new experience is available, the distances to the previously stored sets have to be estimated to extend the internal manifold representing the agent's external configuration. Furthermore, it is important to remark that the internal manifold generated in the last experiment can only be visualized because the size of the agent's working space is limited. It should not be possible to represent a manifold associated with an object configuration on the plane (two translational coordinates and orientation angle) in $3$D because of the circularity involved in orientation. The use of a limited working space allows the manifold to be strongly deformed during the projection in $3$D to take the circular dimension into account while avoiding any self-collision. For wider working spaces, the manifold could not be visualized in $3$D but would still be explicitly described by the metrics defined on the sets $\mathcal{M}^i$. It would only be possible to visualize it locally. Importantly, note that the technical implementation used here (working space exploration, sampling of redundant manifolds, metric computation, low-dimensional projection) is not the main focus of the paper. The scope of the approach is generic, and it can be extended to different implementations of each step of data processing step (such as using ISOMAP \cite{Tenenbaum2000} instead of CCA, or using a different metric on the manifolds $\mathcal{M}^i$) and, of course, to other agent/environment systems. Applying the method to more complex systems would, however, lead to some technical challenges that we have not addressed in this paper. The main difficulty, as pointed out in many studies in developmental robotics~\cite{Baranes:2013}, would be the exploration of the motor space. Random exploration becomes inefficient as dimensionality increases. Some heuristics or bootstrapping reflexes thus need to be introduced to guide the sampling of the motor space \cite{oudeyer2007}. For instance, a low-level tracking-like behavior could facilitate the sampling of the sets $\mathcal{M}^i$, whose dimensionality would be greater than $1$ for more complex robots. Note, however, that learning space is a challenge for humans as well. Spatial reasoning remains immature until the age of 6-10 years~\cite{Dillon2013}. Evidently, so many years of sensorimotor experience provide an enormous amount of data to lift the curse of dimensionality. Having a robot explore its environment for an extended period of time may thus be an inevitable cost to be paid for the autonomous emergence of such perceptual notions. Finally, the results highlight the fact that the proposed approach relies entirely on the properties of the raw sensorimotor flow. In contrast, as mentioned in the introduction, most work on body schema acquisition hypothesizes some spatial knowledge provided a priori to the robot, through the pre-processing of sensory inputs or through additional knowledge on the agent’s own structure~\cite{Bongard2006}. The only assumption in the present work is the hypothesis that the metric on the sets $\mathcal{M}^i$ is topologically identical to the metric of the agent's external configuration. We thus believe that any perceptive knowledge should be discovered and grounded in sensorimotor experience. It should also be noted that some papers offer an implicit definition of body schema based on learning direct relations between motor commands and sensory inputs~\cite{Natale:2007, Fuke:2007}. This behavioralist approach suggests that the notion of space is somehow irrelevant to having a robot act in the world. Although this may be true for simple behaviors, we think that a compact internal representation of the world is required to create new complex behaviors. In particular, space is such a ubiquitous component of our perception that it must correspond to fundamental properties of our sensorimotor experience. Capturing them enables the efficient interpretation of future sensory information. \section{Conclusion} \label{sec:Discussion} The objective of this paper was to understand how a naive \emph{tabula rasa} agent can capture properties of the external space it is immersed in. The question, more precisely, is: how can it discover that such a structure exists independently of the particular objects contained in the environment when its sensory experience is heavily environment-dependent? Although the notion of space is intuitively associated with visual inputs (or more generally with exteroception), we show that considering them exclusively cannot lead to an environment-independent notion. We thus proposed to look for spatial properties not in the agent's exteroceptive flow but in the structure of its sensorimotor interactions with the world. From the agent's point of view, the sensorimotor laws are just functions mapping its motor outputs to sensory inputs, and both the properties of the external world and its own properties are simply constraints on the shape of these functions. In particular, the structure of the external space as such manifests itself through the constraint that certain properties of these functions should not depend on the objects present in the environment. We suggested that the discovery of such constraints can lead the agent to discover the structure of external space. The method we developed allows the agent, starting with minimal a priori knowledge, to capture those constraints and to build an internal representation of its external configuration in space. It requires the agent to notice that different motor commands can result in identical sensory inputs. This discovery reveals the existence of an underlying structure of motor sets ($\mathcal{M}^i$) in the motor space. This structure can be processed as a manifold by defining a metric on the motor sets. Interestingly, from an external point of view, this manifold corresponds to the manifold of external agent's configurations in space. It is important to note, though, that to perform such an analysis, the agent does not need to assume the existence of space. Its final internal representation can simply be the result of an effort to generate a compact and invariant encoding of its sensorimotor interactions with the world. Even if space was the main focus of this work, the processing and results presented in this paper can be linked to the rich literature on body schema acquisition and forward model learning. Indeed, the notion of space is intimately related to the agent's ability to move \cite{Poincare1895}. However, our approach differs from a large part of this literature by not assuming the pre-coding of building blocks or any processing of the sensory flow. In the line of this paper, other works focus directly on the raw sensorimotor flow to build a body schema and/or control a robot \cite{Censi2012,Hoffmann2013,Kuipers2008,Rolf2014}. However these approaches rarely address the question of space, instead focusing on the emergence of behaviors (however, see \cite{Roschin2011}). Our work adds to existing research by making explicit what properties of the raw sensorimotor flow can lead an agent to perceive space. In this paper, we have focused on capturing one property of space: namely, the fact that the notion of space is independent of the content of the environment. However, this single property does not capture the whole concept of space as we mean it from our subjective point of view. As also pinpointed by Poincar\'e~\cite{Poincare1895}, space is felt as \emph{a container shared by both the agent and the environment}. We have the subjective experience that we and the objects around us are immersed in the same space. Our next goal is to ground this property in the agent's sensorimotor experience. To do so, we will focus on discovering the displacements that space allows both the agent and objects around it to perform. Capturing such specific experiences will also overcome a limitation of the present work: the structure discovered in this paper is an internal representation of the agent's external configuration, but this broad notion includes both spatial and non-spatial parameters. One can, for example, imagine an agent similar to the one described in~\S\ref{sec:Part3} but with an additional form of motor control linked to a pupil that adjusts the amount of light arriving on the retina. Such a non-spatial degree of freedom would be captured without distinction by our method, increasing the dimensionality of the internal manifold. By searching only for displacements or, in sensorimotor terms, transformations that both the agent and objects in the environment can perform, it should be possible to avoid capturing such non-spatial degrees of freedom. The final structure captured by the agent will thus be closer to what we intuitively expect from a notion of space. \paragraph{Acknowledgment} The authors would like to thank anonymous reviewers for their useful comments contributing towards better positioning and clarity of the manuscript. The authors would also like to thank Paul Reeve for his editorial corrections. \clearpage
{'timestamp': '2018-10-05T02:00:17', 'yymm': '1810', 'arxiv_id': '1810.01872', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01872'}
arxiv
\section{Introduction} \label{sec:introduction} The computation of visibility is a fundamental problem on terrains and is at the core of many applications such as planning the placement of communication towers or watchtowers, planning of buildings such that they do not spoil anybody's view, finding routes on which you can travel while seeing a lot or without being seen, and computing solar irradiation maps which can in turn be used in predicting vegetation cover. The basic problem is point-to-point visibility: Two points $a$ and $b$ on a terrain are visible to each other if the interior of their \emph{line-of-sight} $ab$ (the line segment between $a$ and b) lies entirely above the terrain. Based on this one can define the viewshed: Given a terrain and an arbitrary (view)point $v$, not necessarily on the terrain, the \emph{visibility map} or \emph{viewshed} of $v$ is the set of all points in the terrain that are visible from $v$; see Figure~\ref{fig:viewshed-ex}. A variety of problems pertaining to visibility have been researched in computational geometry and computer graphics, as well as in geographic information science and geospatial engineering. The key in defining and computing visibility is choosing a terrain model and an interpolation method. The most common terrain models are the grid and the TIN (triangular irregular network). A grid terrain is essentially a matrix of elevation values, representing elevations sampled from the terrain with a uniform grid; the x,y coordinates of the samples are not stored in a grid terrain, they are considered implicit w.r.t. to the corner of the grid. A TIN terrain consists of an irregular sample of points (x,y and elevation values), and a triangulation of these points is provided. Grid terrains are the most widely used in GIS because of their simplicity. Our algorithms in this paper discuss the computation of visibility maps on \emph{grid} terrains. To decide whether a point $p$ is visible on a given terrain model, one needs to interpolate the elevation along the line-of-sight $pv$ between the viewpoint $v$ and $p$ (more precisely, along the projection of the line-of-sight on the horizontal plane) and check whether the interpolated elevations are below the line of sight. Various algorithms differ in what and how many points they select to interpolate along the line-of-sight, and in the interpolation method used. These choices crucially affect the efficiency and accuracy of the algorithms. In order to be useful in practice, viewshed algorithms need to be fast and scalable to very large terrains. The last decade witnessed an explosion in the availability of terrain data at better and better resolution. In 2002, for example, NASA's Shuttle Radar Topography Mission (SRTM) acquired 30~m-resolution terrain data for the entire USA, in total approximately 10 terabytes of data. With more recent technology it is possible to acquire data at sub-meter resolution. This brings tremendous increases in the size of the datasets that need to be processed: Washington state at 1~m resolution, using 4 bytes for the elevation of each sample, would total 689 GiB of data; Ireland would be 262 GiB---only counting elevation samples on land. Data at this fine resolution has started to become available. \begin{figure}[t] \centering \includegraphics[width=6cm]{viewshed-3d.pdf} \includegraphics[width=5cm]{los.pdf} \caption{(a) The viewshed of a point on a grid terrain is shown in green. The viewpoint is marked in blue. (b) Two points on a terrain are visible to each other if the interior of their line-of-sight lies entirely above the terrain. Here $a$ is visible from $v$, but $b$ is not.} \label{fig:viewshed-ex} \end{figure} \subsection{I/O-efficiency} Working with large terrains require efficient algorithms that scale well and are designed to minimize ``I/O'': the swapping of data between main memory and disk. We assess the efficiency of algorithms in this paper not only by studying the number of computational steps they need and by measuring their running times in practical experiments, but also by studying how the number of I/O-operations grows with the input size. To this end we use the standard model defined by Aggarwal and Vitter~\cite{aggarwal:input}. In this model, a computer has a memory of size $M$ and a disk of unbounded size. The disk is divided into blocks of size $B$. Data is transferred between memory and disk by transferring complete blocks: transferring one block is called an ``I/O\xspace''. Algorithms can only operate on data that is currently in main memory; to access the data in any block that is not in main memory, it first has to be copied from disk. If data in the block is modified, it has to be copied back to disk later, at the latest when it is evicted from memory to make room for another block. The I/O\xspace-efficiency of an algorithm can be assessed by analysing the number of I/Os\xspace it needs as a function of the input size $n$, the memory size $M$, and the block size $B$. The fundamental building blocks and bounds in the I/O-model are sorting and scanning: scanning $n$ consecutive records from disk takes $\mathsf{scan}(n) = \Theta(n/B)$ I/Os\xspace; sorting takes $\mathsf{sort}(n) = \Theta(\Sort{n})$ I/Os\xspace in the worst case~\cite{aggarwal:input}. It is sometimes assumed that $M = \Omega(B^2)$. We distinguish \emph{cache-aware} algorithms and \emph{cache-oblivious} I/O-efficient algorithms: Cache-aware algorithms may use knowledge of $M$ and $B$, (and to some extent even control $B$) and they may use it to control which blocks are kept in memory and which blocks are evicted. Cache-oblivious algorithms, as defined by Frigo et al.~\cite{prokop:cob}, do not know $M$ and $B$ and cannot control which blocks are kept in memory: the caching policy is left to the hardware and the operating system. Nevertheless, cache-oblivious algorithms can often be designed and proven to be I/O\xspace-efficient~\cite{prokop:cob}. The idea is to design the algorithm's pattern of access to locations in files and temporary data structures such that effective caching is achieved by any reasonable general-purpose caching policy (such as least-recently-used replacement) \emph{for any values} of $M$ and $B$. As a result, any bounds that can be proven on the I/O\xspace-efficiency of a cache-oblivious algorithm hold for \emph{any} values of $M$ and $B$ simultaneously. Thus they do not only apply to the transfer of data between disk and main memory, but also to the transfer of data between main memory and the various levels of smaller caches. However, in practice, cache-oblivious algorithms cannot always match the performance of cache-aware algorithms that are tuned to specific values of $M$~and~$B$~\cite{brodal:cobsorting-jea}. \subsection{Problem definition} A \emph{terrain} $T$ is a surface in three dimensions, such that any vertical line intersects $T$ in at most one point. The \emph{domain} $D$ of $T$ is the projection of $T$ on a horizontal plane. The \emph{elevation angle} of any point $q = (q_x,q_y,q_z)$ with respect to a viewpoint~$v = (v_x,v_y,v_z)$ is defined as: $$\textrm{ElevAngle}(q) = \arctan\frac{q_z - v_z}{\textrm{Dist}(q)},$$ where $\textrm{Dist}(q) := |(q_x,q_y)-(v_x,v_y)|$. A point $u = (u_x,u_y,u_z)$ is visible from $v$ if and only if the elevation angle of $u$ is higher than the elevation angle of any point of $T$ whose projection on the plane lies on the line segment from $(u_x,u_y)$ to $(v_x,v_y)$. We define the elevation angle of any point $(q_x,q_y)$ of $D$ as the elevation angle of the point $q = (q_x,q_y,q_z)$ where the vertical line through $(q_x,q_y)$ intersects $T$. In this paper we consider terrains that are represented by a set of $n$ points whose projections on~$D$ form a regular rectangular grid. To decide whether a point $u$ is visible from a point $v$, we need to \emph{interpolate} the elevation angle of points of $T$ whose projection on the plane lie along the line segment from $(u_x,u_y)$ to $(v_x,v_y)$. We want to compute the following: given any terrain $T$ and any viewpoint $v = (v_x,v_y,v_z)$, find which grid points of the terrain are visible to $v$ and which are not. We assume the terrain is given as a matrix $Z$, stored row by row, where $Z_{ij}$ is the elevation of the point in row $i$ and column $j$. The output visibility map is a matrix $V$, stored row by row, in which $V_{ij}$ is $1$ if the point in row $i$ and column $j$ is visible, and $0$ otherwise. For ease of presentation, throughout the rest of the paper we assume that the grid is square and has size $\sqrt n \cdot \sqrt n$ ; of course the actual implementations of our algorithms can handle rectangular grids as well. \subsection{Related work} The standard method for computing viewsheds on grid terrains is the algorithm \texttt{R3}\xspace by Franklin and Ray~\cite{franklin:sdh94}. \texttt{R3}\xspace determines the visibility of each point in the grid as follows: it computes the intersections between the horizontal projection of the line-of-sight and the horizontal and vertical grid lines, and computes the elevation of the terrain at these intersection points by linear interpolation. Since a line of sight intersects $O(\sqrt n)$ grid lines, determining the visibility of a point takes $O(\sqrt n)$ time. This is considered to be the standard model and \texttt{R3}\xspace is considered to produce the ``exact'' viewshed~\cite{izraelevitz:vis}. However, as described by Franklin and Ray, \texttt{R3}\xspace runs in $O(n \sqrt n)$~time, which is too slow in practice, especially for multiple viewshed computations. A variety of viewshed algorithms have been proposed that optimize \texttt{R3}\xspace while approximating in some way the resulting viewshed: Some algorithms consider only a subset of the $O(n)$ lines-of-sight; others interpolate the line-of-sight only at a subset of the $O(\sqrt n)$ intersection points with the grid lines; yet others have some other way of determining in $O(1)$ time whether a point in the grid is visible. The optimized viewshed algorithms run in $o(n \sqrt n)$ time, most often $O(n)$. Examples are \textsc{XDraw} by Franklin and Ray~\cite{franklin:sdh94}; \textsc{Backtrack} by Izraelevitz~\cite{izraelevitz:vis}; \texttt{R2}\xspace by Franklin and Ray~\cite{franklin:sdh94}; and van Kreveld's radial sweep algorithm~\cite{kreveld:viewshed}---below we describe briefly the results which are relevant to this paper. The algorithm named \texttt{R2}\xspace, proposed by Franklin and Ray~\cite{franklin:sdh94}, is an optimization of \texttt{R3}\xspace that runs in $O(n)$ time. The idea of \texttt{R2}\xspace is to examine the lines-of-sight \emph{only} to the $O(\sqrt n)$ grid points on the boundary of the grid; a grid point that is not on the boundary is considered to be visible if the nearest point of intersection between a grid line and one of the examined lines-of-sight is determined to be visible. Overall \texttt{R2}\xspace is fast and, according to its authors, produces a good approximation of \texttt{R3}\xspace that outweighs its loss in accuracy~\cite{franklin:sdh94}. The other algorithm, \emph{XDraw}, computes the visibility of the grid points incrementally in concentric layers around the viewpoint, starting at the viewpoint and working its way outwards. For a grid point $v$ in layer $i$, the algorithm computes whether $v$ is visible, and what is the maximum height above the horizon along the line of sight to $v$. To do so, it determines which are the two grid points $q$ and $r$ in layer $i - 1$ that are nearest to $\overline{pv}$, and then it estimates the maximum height above the horizon along $\overline{pv}$ by interpolating between the lines of sight to $q$ and $r$. Thus, the visibility of each point is determined in constant time per point. XDraw is faster than R3 and R2, due to the simplicity of the calculations, but it is also the least accurate~\cite{franklin:sdh94}. Izraelevitz~\cite{izraelevitz:vis} presented a generalization of \emph{XDraw} that allows to user to set a parameter $k$, which is the number of previous layers that are taken into account when computing the visibility of a grid point. \begin{figure}[t] \centering{ \includegraphics[width=4cm]{grid1.pdf} \includegraphics[width=4cm]{grid5.pdf} \caption{Van Kreveld's model: (a) Each grid point represents a square cell centered at that point. The elevation angle of all points inside a cell is the same as the elevation angle of the center of the cell (the grid point). (b) To determine if two grid points are visible, we need to consider all cells that intersect the line segment beween the points. } \label{fig:kreveld-model} } \end{figure} Van Kreveld described a different approach for computing viewsheds on grids that could also be seen as an optimization of \texttt{R3}\xspace~\cite{kreveld:viewshed}. In his model the terrain is seen as a tessellation of square cells, where each cell is centered around a grid point and has the same view angle as the grid point throughout the cell, that is, the cell appears as a horizontal line segment to the viewer (Figure~\ref{fig:kreveld-model}). This property allows for the viewshed to be computed in a radial sweep of the terrain in $O(n \lg n)$ time. Because cells have constant view angle, they can be stored in an efficient data structure as the ray rotates around the viewpoint. This data structure supports insertions of cells, deletions of cells, and visibility queries for a point along the ray in $O(\lg n)$ time per operation, and thus the whole viewshed can be computed while rotating the ray in $O(n \lg n)$ time. The viewshed algorithms mentioned so far assume that the computation fits in memory and are not IO-efficient. I/O-efficient viewshed algorithms have been proposed by Magalh\~aes et al.~\cite{magalhaes:geo}, Ferreira et al.~\cite{ferreira:vis} and in our previous work~\cite{havertoma:visibility-journal,ht:vis2,ht:accuracy}; we discuss these results below. Haverkort, Toma and Zhuang~\cite{havertoma:visibility-journal} presented the first IO-efficient viewshed algorithm using Van Kreveld's model. Using a technique called \emph{distribution sweeping} they turned Van Kreveld's algorithm into an algorithm running in $O(n \log n)$ time and $O(\mathsf{sort}(n))$~I/Os\xspace, cache-obliviously. The authors also presented practical results showing that their algorithm scales well to large data and outperforms Van Kreveld's algorithm running in (virtual) memory. Subsequently, Magalh\~aes et al.~\cite{magalhaes:geo} and Ferreira et al.~\cite{ferreira:vis} described I/O-efficient versions of Franklin's R2 algorithm. The first algorithm runs in $O(n \log n)$ time and $O(\mathsf{sort}(n))$~I/Os\xspace~\cite{magalhaes:geo}. As in R2, the idea is to evaluate lines-of-sight only to the points on the perimeter of the grid. To do this I/O\xspace-efficiently, the algorithm first copies all grid points from the input file row by row, annotating each point $p$ with the endpoints of the lines of sight whose evaluation requires the elevation of $p$. Next, all annotated points are sorted by line of sight. The algorithm then evaluates each line of sight, determining for each point on a line of sight whether it is visible or not, and writes the results to a file, in order of computation. As a result, the file contains the visibility map, ordered by line of sight. The last step is to sort this file into row-by-row order. A further improved version of R2 was presented i ~\cite{ferreira:vis}. Here the idea is to partition the grid in blocks and run the (in-memory) version of the R2 algorithm modified so that it bypasses the VMM (virtual memory management) system, and instead it maintains a data structure of ``active'' blocks that constitute the block footprint of the algorithm. Whenever the line-of-sight intersects a block, that block is brought in main memory. Blocks are evicted using LRU policy. Their algorithm, \textsc{TiledVS}, consists of three passes: convert the grid to Morton order, compute visibility using the R2 algorithm, and convert the output grid from Morton order to row-major order. In practice, this algorithm is much faster than the one in~\cite{magalhaes:geo}, achieving on the order of 5,000 seconds on SRTM dataset of 7.6 billion points (\texttt{SRTM1.region06}, 28.4GiB using 4 bytes per elevation value) that is, .7$\mu$s per point. Another advantage of \textsc{TiledVS} is that its first step can be viewed as a preprocessing step common to all viewpoints and thus \textsc{TiledVS} computes the viewshed in only two passes over the grid. \vspace{.5cm} The IO-efficient algorithms discussed above differ in how many points they chose to interpolate, how many lines-of-sight they consider, and how they interpolate the terrain. These choices affect both the running time and output of the algorithms. All algorithms described can be considered as approximations of \texttt{R3}\xspace and make some assumptions that they exploit to improve efficiency. \textsc{TiledVS} derives its efficency in part from considering only $O(\sqrt n)$ LOS's instead of $O(n)$. Van Kreveld's approach exploits crucially that cells have constant elevation angle across their azimuth range. Generalizing to linear interpolation is difficult: it would mean that cells have variable elevation angle across their azimuth tange, and one would need a kinetic data structure as active structure to store elevation angles that change in time. To evaluate viewshed algorithms it is important to consider both efficiency of running time and accuracy of the computed viewshed. While efficiency is easy to compare, comparing accuracy is much harder. The straightforward way to assess accuracy is to compare the computed viewshed with ground truth data. Ideally one would consider a large sample of viewpoints, compute the viewshed from each one in turn, compare it with the \emph{real} viewshed at that point, and aggregate the differences. Unfortunately, ground truth viewsheds are hard, if not impossible, to obtain. The algorithms mentioned above assume grid terrains. For an overview of internal-memory algorithms for visibility computations on the second most common format of terrain elevation models, the \emph{triangular irregular network} or TIN, we refer to ~\cite{colesharir:visib,floriani:visdtm,floriani:intervisibility}. Visibility algorithms on TINs use the concept of a \emph{horizon} or \emph{silhouette} $\sigma$ of the terrain, which is the upper rim of the terrain, as it appears to a viewer at $v$. More formally, $\sigma_T$ is a function from azimuth angles (compass direction) to elevation angles, such that $\sigma_T(\alpha)$ is the maximum elevation angle of any point on the intersection of $T$ with the ray that extends from $v$ in direction $\alpha$. On a triangulated terrain, the horizon is equivalent to the upper envelope of the triangle edges of $T$, projected on an infinite vertical cylinder centered on the viewpoint; it has complexity $O(n \cdot \alpha(n))$, where $\alpha$ is the inverse Ackermann function~\cite{colesharir:visib}. Horizons have been used to solve various visibility-related problems on triangulated polyhedral terrains. For example, the visibility of all the vertices in a TIN can be computed in $O(n \alpha(n) \lg n)$ time~\cite{colesharir:visib}. A central idea in these solutions is that horizons can be merged in time that is linear in their size, and thus allow for efficient divide-and-conquer algorithms. \subsection{Our contributions} This paper describes IO-efficient algorithms for computing viewsheds on massive grid terrains in a couple of different models. Our first two algorithms work in Van Kreveld's model, and sweep the terrain radially by rotating a ray around the viewpoint while maintaining the terrain profile along the ray. The difference between the two new algorithms is in the preprocessing before the sweep: the first algorithm, which we describe in Section~\ref{sec:radial-layers}, sorts the grid points in concentric bands around the viewpoint; the second algorithm, which we describe in Section~\ref{sec:radial-sectors}, sorts the grid points into sectors around the viewpoint. Both algorithms run in $O(n \log n)$ time and $O(\mathsf{sort}(n))$ I/Os\xspace. The third algorithm, \textsc{io-centrifugal}\xspace, which we describe in Section~\ref{sec:conc-sweep}, uses a complementary approach and sweeps the terrain centrifugally. The algorithm is similar to \emph{XDraw}: it grows a region around the viewpoint, while maintaining the horizon of the terrain within the region seen so far. To maintain the horizon efficiently, we represent it by a grid model itself: we maintain the maximum elevation angle (the ``height'') of the horizon for a discrete set of regularly spaced azimuth angle intervals. The horizontal resolution of the horizon model is chosen to be similar to the horizontal resolution of the original terrain model, so that we maintain elevation angles for $\Theta(\sqrt n)$ azimuth angle intervals. This allows a significant speed-up as compared to algorithms that process events at $\Theta(n)$ different azimuth angles, or work with horizons of linear complexity. Also, we note that this gives the algorithm the potential for higher accuracy than \emph{XDraw}, which represents the horizon up to a given layer by only as many grid points as there are in that layer---which can be quite inaccurate close to the viewpoint. Another difference with \emph{XDraw} is that our algorithm does not proceed layer by layer, but instead grows the region in a recursive, more I/O\xspace-efficient way; this results in a significant speed-up in practice. The centrifugal sweep algorithm runs in $O(n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace cache-obliviously, and is our fastest algorithm. Our last two algorithms constitute an improved, IO-efficient version of Franklin's \texttt{R3}\xspace algorithm. We distinguish between two models (Figure~\ref{fig:model}), which we describe in Section~\ref{sec:algorithms}: In the \emph{gridlines} model we view the points in the input grid as connected by horizontal and vertical lines, and visibility is determined by evaluating the intersections of the line-of-sight with the grid lines using linear interpolation; this is the model underlying \texttt{R3}\xspace. We also consider a slightly different model, the \emph{layers} model, in which we view the points in the input grid to be connected in concentric layers around the viewpoint and visibility is determined by evaluating the intersections of the line-of-sight with these layers using linear interpolation. The layers model considers only a subset of the intersections considered by the gridlines model and therefore the viewshed generated will be larger (more optimistic) than the one generated with the gridlines model. Preliminary results (\cite{ht:vis2}) show that these differences are practically insignificant. The layers model is faster in practice, while having practically the same accuracy as the gridlines model. We describe our last two algorithms, \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace, in Section~\ref{sec:algorithms}. They are based on computing and merging horizons in an iterative or divide-and-conquer approach, respectively. Horizon-based algorithms for visibility problems have been described by de Floriani and Magillo~\cite{floriani:visdtm}. On a triangulated terrain $T$, the horizon is equivalent to the upper envelope of the triangle edges of $T$ as projected on a view screen, and has complexity $H(n) = O( n \cdot \alpha(n))$, where $n$ is the number of vertices in the TIN and $\alpha()$ is the inverse of the Ackerman function~\cite{cole:visibility}. In Section ~\ref{sec:visiter} we show that we can prove a better bound for our setting: that is, we prove that the upper envelope of a set $S$ of line segments in the plane such that the widths of the segments do not differ in length by more than a factor $d$ has complexity $O(dn)$. From here we show that the horizon on a grid of $n$ points with linear interpolation has complexity $O(n)$ in the worst case. In Section~\ref{sec:results} we describe an experimental analysis and comparison of our algorithms on datasets up to 28 GB. All algorithms are scalable to volumes of data that are more than 50 times larger than the main memory. Our main finding is that, in practice, horizons are significantly smaller than their theoretical upper bound, which makes horizon-based algorithms unexpectedly fast. Our last two algorithms, which compute the most accurate viewshed, turn out to be very fast in practice, although their worst-case bound is inferior. We conclude in Section~\ref{sec:discussion}. \section{I/O-Efficient radial sweep}\label{sec:radial-layers} This section describes our first approach to computing a viewshed. It is loosely based on Van Kreveld's radial sweep algorithm, which we present below. {\bf The model.} We consider that the terrain is represented by a set of $n$ points whose projections on~$D$ form a regular grid with inter-point distance~1. Furthermore, we assume that each grid point $q = (q_x,q_y,q_z)$ represents a square ``cell'' $D(q)$ on $D$ of size $1\times 1$, centered on $(q_x,q_y)$. For any given viewpoint $v$, we treat the terrain above $D(q)$ as if each point of $D(q)$ has elevation angle $\textrm{ElevAngle}(q)$. This is the interpolation method used by Van Kreveld~\cite{kreveld:viewshed}. Determining whether a point $p$ is visible from viewpoint $v$ comes down to deciding whether there is any other grid point $q$ such that the square cell $D(q)$ intersects the line segment from $(v_x,v_y)$ to $(p_x,p_y)$ and $\textrm{ElevAngle}(q) \geq \textrm{ElevAngle}(p)$; see Figure~\ref{fig:kreveld-model}. \subsection{Van Kreveld's radial sweep algorithm} The basic idea of Van Kreveld's algorithm~\cite{kreveld:viewshed} is to rotate a half-line (ray) around the viewpoint~$v$ and compute the visibility of each grid point in the terrain when the sweep line passes over it (see Figure~\ref{fig:kreveld}). For this we maintain a data structure (the \emph{active} structure) that, at any time in the process, stores the elevation angles for the cells currently intersected by the sweep line (the \emph{active cells}). Three types of events happen during the sweep: \begin{denseitems} \item \textsc{enter}\xspace events: When a cell starts being intersected by the sweep line, it is inserted in the active structure; \item \textsc{center}\xspace events: When a the sweep line passes over the grid point $q$ at the center of a cell, the active structure is queried to find out if $q$ is visible. \item \textsc{exit}\xspace events: When a cell stops being intersected by the sweep line, it is deleted from the active structure; \end{denseitems} Thus, each cell in the grid has three associated events. Van Kreveld~\cite{kreveld:viewshed} uses a balanced binary search tree for the active structure, in which the active cells are stored in order of increasing distance from the viewpoint. Because the cells are convex, this is always the same as ordering the active cells in order of increasing distance from the viewpoint to pothe \emph{grid points} corresponding to the cells. With each cell we store its elevation angle. In addition, each node in the tree is augmented with the highest elevation angle in the subtree rooted at that node. A query if a point $q$ is visible is answered by checking if the active structure contains any cell that lies closer to the viewpoint than $q$ and has elevation angle at least $\mathrm{ElevAngle}(q)$: if yes, then $q$ is \emph{not} visible, otherwise it is. Such a query can be answered in $O(\log n)$ time. To run the complete algorithm, we first generate and sort the $3n$ events by their azimuth angles (the sweep line directions at which they happen). Then we process the events in order of increasing azimuth angle. The whole algorithm runs in $O(n \log n)$ time. \begin{figure}[t] \centering{ \includegraphics[width=5cm]{sweep.pdf} \caption{Van Kreveld algorithm. Cells will be present in the active structure as long as the sweep ray intersects the indicated diagonal.} \label{fig:kreveld} } \end{figure} In our previous work we adapted Van Kreveld's algorithm to make it I/O-efficient~\cite{havertoma:visibility-journal}. The first step was still to generate and sort the events. For each event we stored its location in the plane and its elevation angle. Using four bytes per coordinate, this resulted in an event stream of $36n$ bytes. For large $n$, this is a significant bottleneck. \subsection{A new I/O-efficient radial sweep algorithm}\label{sec:iorad2} The main idea of our new radial sweep algorithm is therefore to avoid generating and sorting a fully specified event stream. The purpose of the event stream was to supply the azimuth angle and the elevation angle of the events in order. Note, however, that the azimuth angle of the events only depends on how the sweep progresses over the grid, but not on the elevation values stored in the input file. Only the elevation angles have to be derived from the input file. Our ideas for making the sweep I/O-efficient are now the following. We can compute the azimuth angles of the events on the fly, without accessing the input file, instead of computing all events in advance. Only when processing an \textsc{enter}\xspace event corresponding to a grid point $q$, the elevation of $q$ needs to be retrieved in order to insert $\langle \mathrm{Dist}(q), \mathrm{ElevAngle}(q) \rangle$ into the active structure---for \textsc{center}\xspace events the elevation angle can then be found in the active structure and for \textsc{exit}\xspace events the elevation angle is not needed. To allow efficient retrieval of elevations for \textsc{enter}\xspace events, we pre-sort the elevation grid into lists of elevation values, stored in the order of the \textsc{enter}\xspace events that require them. Thus we can retrieve all elevation values in $O(\mathsf{scan}(n))$ I/Os\xspace during the sweep. Sorting the \emph{complete} elevation grid into a \emph{single} list would be relatively expensive (it would require several sorting passes); we avoid that by dividing the grid into concentric bands around the viewpoint, making one list of elevation values for each band. As long as the number of bands in small enough so that we can keep a read buffer of size $\Theta(B)$ for each band in memory during the sweep, we will still be able to retrieve all elevation values during the sweep in $\Theta(\mathsf{scan}(n))$ I/Os\xspace. \vspace{\baselineskip} {\bf Notation.} For ease of description, assume that the viewpoint $v$ is in the center of the grid at coordinates $(0,0,0)$ and the grid has size $(2m + 1) \times (2m + 1)$, where $m = (\sqrt n - 1)/2$. The elevations of the grid points are given in a two-dimensional matrix $Z$ that is ordered row by row, with rows numbered from $-m$ to $m$ from north to south and columns numbered from $-m$ to $m$ from west to east. By $p(i,j)$ we denote the grid point $q = (q_x,q_y,q_z)$ in row $i$ and column $j$ with coordinates $q_x = j$, $q_y = -i$ and $q_z = Z_{ij}$; by \emph{cell $(i,j)$} we denote the square $D(p(i,j))$. Let $\textsc{enter}\xspace (i,j)$ denote the azimuth angle of the \textsc{enter}\xspace event of cell $(i,j)$. \vspace{\baselineskip} {\bf Description of the algorithm.} We now describe our algorithm in detail. Let \emph{layer} $l$ of the grid denote the set of grid points whose $L_\infty$-distance from the viewpoint, measured in the horizontal plane, is $l$. We divide the grid in concentric bands of width $w$ around the viewpoint. Band $k$ (denoted $B_k$), with $k > 0$, contains all grid points of layers $(k-1) w + 1$ up to $k w$, inclusive; so $p(i,j)$ would be found in band $\lceil\max(|i|,|j|) / w\rceil$ (see Figure~\ref{fig:layered-radial-sweep}). We choose $w = \Theta(\sqrt M)$; more precisely, $w$ is the largest power of two such that the elevation and visibility values of a square tile of $(w+1) \cdot (w+1)$ points fit in one third of the memory. \begin{figure}[t] \centering \includegraphics[height=2.5in]{bands.pdf} \caption{A layered radial sweep.} \label{fig:layered-radial-sweep} \end{figure} Our algorithm proceeds in three phases. The first phase is to generate, for each band $B_k$, a list $E_k$ containing the elevations of all points $p(i,j)$ in the band, ordered by increasing $\textsc{enter}\xspace(i,j)$ values (recall that $\textsc{enter}\xspace(i,j)$ denotes the azimuth angle of the enter event of the cell $(i,j)$). Points $p(i,j)$ with the same $\textsc{enter}\xspace(i,j)$ value are ordered secondarily by increasing distance $\mathrm{Dist}(i,j)$ from the viewpoint. The algorithm that builds the lists $E_k$ is given below. The basic idea is to read the grid points from the elevation grid going in counter-clockwise order around the viewpoint. This is achieved by maintaining a priority queue with points just in front of the sweep line; the priority queue is organised by the azimuth angles of the enter events corresponding to the points to be read. The queue is initialised with all points of $B_k$ that lie straight right of the viewpoint (Note: such a point $(0,j)$ will have its $\textsc{enter}\xspace(0,j)$ given by the south-west corner of its cell at $(1/2, j-1/2)$ which corresponds to an angle in the fourth quadrant $(3\pi/2, 2\pi)$; we subtract $2\pi$ to bring it to $(-\pi/2, 0)$; this guarantees that points straight right of the viewpoint are first in radial order). Then we extract points from the queue one by one in order of increasing $\textsc{enter}\xspace(i,j)$; when we extract a point, we read its elevation from the elevation grid, write the elevation value to $E_k$, and insert the next point from the same layer in the priority queue (this is the point above, to the left, below, or to the right, depending on which octant the current point is in). In this way, from neighbor to neighbor, all points are eventually reached. Below we describe the algorithm only for the first quadrant (Figure~\ref{fig:layered-radial-sweep}); the others are handled similarly. \addvspace{.5\baselineskip} \noindent \textbf{Algorithm} \textsc{BuildBands}:\\[.25\baselineskip] \textbf{for }$k \leftarrow 1$ \textbf{to} $\lceil m /w \rceil$\\ \textbf{do }initialise empty list $E_k$ and priority queue $Q$\\ \hphantom{\textbf{do }}\textbf{for }$j \leftarrow (k-1)\cdot w + 1$ \textbf{to} $k \cdot w$\\ \hphantom{\textbf{do }}\textbf{do }insert $\langle \textsc{enter}\xspace (0,j)-2\pi, 0,j \rangle$ into $Q$\\ \hphantom{\textbf{do }}\textbf{while} $E_k$ is not complete\\ \hphantom{\textbf{do }}\textbf{do }$\langle \alpha, i, j \rangle \leftarrow Q$.deleteMin()\\ \hphantom{\textbf{do do }}read $Z_{ij}$ from the grid and write it to $E_k$\\ \hphantom{\textbf{do do }}\textbf{if }$-i < j$\hfill\textit{(next cell is north)}\\ \hphantom{\textbf{do do }}\textbf{then }insert $\langle \textsc{enter}\xspace (i-1,j), i-1,j \rangle$ into $Q$\\ \hphantom{\textbf{do do }}\textbf{else}\hfill\textit{(next cell is west)}\\ \hphantom{\textbf{do do then }}insert $\langle \textsc{enter}\xspace (i,j-1), i,j-1 \rangle$ into $Q$\\ \hphantom{\textbf{do }}clear $Q$ \addvspace{.5\baselineskip} After constructing the lists $E_k$, the second phase of the algorithm starts: computing which points are visible. To do this we perform a radial sweep of all events in azimuth order. Again, we generate the events on the fly with the help of a priority queue, using only the horizontal location of the grid points. We use a priority queue to hold events in front of the sweep line, and an active structure to store the cells that currently intersect the sweep line, sorted by increasing distance from the viewpoint (as in Van Kreveld's algorithm). The algorithm starts by inserting all \textsc{enter}\xspace events of the points straight to the right of the viewpoint into the priority queue. When the next event in the priority queue is an \textsc{enter}\xspace event for cell $(i,j)$, the algorithm inserts the corresponding \textsc{center}\xspace and \textsc{exit}\xspace events in the queue, as well as the \textsc{enter}\xspace event of the next cell in the same layer. In addition, it reads the elevation $Z_{ij}$ of $p(i,j)$ from the list of elevation values $E_k$ of the band $B_k$ that contains $p(i,j)$, and it inserts the cell $(i,j)$ in the active structure with key $\textrm{Dist}(i,j)$. When the next event in the priority queue is a $\textsc{center}\xspace$ event for cell $(i,j)$, the algorithm queries the active structure for the visibility of the point with key $\textrm{Dist}(i,j)$. When the next event in the priority queue is an $\textsc{exit}\xspace$ event for cell $(i,j)$, the algorithm deletes the element with key $\textrm{Dist}(i,j)$ from the active structure. \addvspace{.5\baselineskip} \noindent \textbf{Algorithm} \textsc{ComputeVisibility}:\\[.25\baselineskip] Initialise empty active structure $A$ and priority queue $Q$\\ \textbf{for }$j \leftarrow 1$ \textbf{to} $m$\\ \textbf{do }insert $\langle \textsc{enter}\xspace (0,j)-2\pi, \textsc{enter}\xspace, 0,j \rangle$ into $Q$\\ \textbf{for }$k \leftarrow 1$ \textbf{to} $\lceil m /w \rceil$\\ \textbf{do }set read pointer of $E_k$ at the beginning\\ \hphantom{\textbf{do }}initialise empty list $V_k$\\ \textbf{while} not all visibility values have been computed\\ \textbf{do }$\langle \alpha, \mathit{type}, i, j \rangle \leftarrow Q$.deleteMin()\\ \hphantom{\textbf{do }}\textbf{if }$\mathit{type} = \textsc{enter}\xspace$\\ \hphantom{\textbf{do }}\textbf{then }insert $\langle \textsc{center}\xspace(i,j), \textsc{center}\xspace, i,j\rangle$ in $Q$\\ \hphantom{\textbf{do then }}insert $\langle \textsc{exit}\xspace(i,j), \textsc{exit}\xspace, i,j\rangle$ into $Q$\\ \hphantom{\textbf{do then }}\textbf{if }$|i| < j$ or $i = j > 0$\quad\quad\textit{(next cell is north)}\\ \hphantom{\textbf{do then }}\textbf{then }insert $\langle \textsc{enter}\xspace (i-1,j), \textsc{enter}\xspace, i-1,j \rangle$ in $Q$\\ \hphantom{\textbf{do then }}[... \textit{similar for west, south, and east} ...]\\ \hphantom{\textbf{do then }}compute band number $k \leftarrow \lceil\max(|i|,|j|) / w\rceil$\\ \hphantom{\textbf{do then }}$z \leftarrow$ the next unread value from $E_k$\\ \hphantom{\textbf{do then }}$\beta \leftarrow \arctan(z/\mathrm{Dist}(i,j))$\quad\quad($= \mathrm{ElevAngle}(p(i,j))$)\\ \hphantom{\textbf{do then }}insert $\langle \mathrm{Dist}(i,j), \beta\rangle$ into $A$\\ \hphantom{\textbf{do }}\textbf{else if }$\mathit{type} = \textsc{center}\xspace$\\ \hphantom{\textbf{do }}\textbf{then }compute band number $k \leftarrow \lceil\max(|i|,|j|) / w\rceil$\\ \hphantom{\textbf{do then }}query $A$ if element with key $\mathrm{Dist}(i,j)$ is visible;\\ \hphantom{\textbf{do then }}if yes, write 1 to $V_k$, otherwise write 0 to $V_k$\\ \hphantom{\textbf{do }}\textbf{else }($\mathit{type} = \textsc{exit}\xspace$)\\ \hphantom{\textbf{do then }}delete element with key $\mathrm{Dist}(i,j)$ from $A$ \addvspace{.5\baselineskip} The crux of the \textsc{ComputeVisibility} algorithm above is the following: when it needs to read $Z_{ij}$, it simply takes the next unread value from its band $E_k$. This is correct, because within each band $B_k$, the above algorithm requires the $Z_{ij}$ values in the order of the corresponding $\textsc{enter}\xspace$ events, and this is exactly the order in which these values were put in $E_k$ by algorithm \textsc{BuildBands}. The output of the second phase is a number of lists $V_k$ with visibility values: one list for each band, in order of the azimuth angle of the grid points. The third phase of the algorithm sorts the lists $V_k$ into one visibility map. To do so we run an algorithm that is more or less the reverse of algorithm \textsc{BuildBands}: we only need to swap the roles of reading and writing, and use azimuth values for \textsc{center}\xspace events instead of \textsc{enter}\xspace events. \vspace{\baselineskip} {\bf Efficiency analysis.} We will now argue that the above algorithm computes a visibility map in $O(n \log n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace under the assumption that the input grid is square, and we have $M \geq c_1 \sqrt n$ and $M \geq c_2 B^2$ for sufficiently large constants $c_1$ and $c_2$. We start with the first phase: \textsc{BuildBands}. Consider the part of band $B_1$ which lies in the first quadrant. This part consists of all points $p(i,j)$ such that $0 \leq -i \leq w$ and $0 \leq j \leq w$ (except the viewpoint itself). It is a tile of size $(w+1) \cdot (w+1)$, which fits in one third of the main memory by definition of $w$. As the algorithm iterates through the points of $B_1$, it accesses their elevations, loading blocks from disk, until eventually the entire tile is in main memory, after which there are no subsequent I/O\xspace-operations on the input grid. The number of I/Os\xspace to access the tile is $O(w + w^2/B) = O(\sqrt{M} + M^2/B)$. By the assumption that $M = \Omega(B^2)$, this is $O(M^2/B)=O(|B_1|/B)$, where $|B_1|$ denotes the number of grid points in $B_1$. In fact any band $B_k$ with $k \geq 1$ can be subdivided into $8k-4$ tiles of size at most $(w+1) \cdot (w+1)$, such that for any band, the sweep line will intersect at most two such tiles at any time (see Figure~\ref{fig:layered-radial-sweep}). Since a tile fits in at most one third of the memory, two tiles fit in memory together. Therefore the algorithm can process each band by reading tiles one by one, without ever reading the same tile twice. Thus each band $B_k$ is read in $O(\mathsf{scan}(|B_k|))$ I/Os\xspace, and algorithm \textsc{BuildBands} needs $O(\mathsf{scan}(n))$ I/Os\xspace in total to read the input. The output lists $E_k$ are written sequentially, taking $O(\mathsf{scan}(n))$ I/Os\xspace as well. It remains to discuss the operation of the priority queue. Note that at any time the priority queue stores one cell from each layer, and therefore it has size $m < \frac12 \sqrt n$; by assumption this is at most $\frac12 M / c_1$. Hence, for a sufficiently large value of $c_1$, the priority queue fits in memory together with the two tiles from the input file mentioned above (which each take at most one third of the memory). Thus the operation of the priority queue takes no I/O\xspace, but it will take $O(\log n)$ CPU-time per operation, and thus, $O(n \log n)$ time in total. The second phase, \textsc{ComputeVisibility}, reads and writes each list $E_k$ and $V_k$ in a strictly sequential manner. There are $O(m/w) = O(\sqrt{n/M})$ bands. Under the assumption $M \geq c_1 \sqrt n$ and $M \geq c_2 B^2$, this is only $O(\sqrt{n/M}) = O(\sqrt{n}/B) = O(M/B)$. This implies that, when $c_1$ and $c_2$ are sufficiently high constants, one block from each list $E_k$ or $V_k$ can reside in memory as a read or write buffer during the sweeping. Thus all lists $E_k$ and $V_k$ can be read and written in parallel in $O(\mathsf{scan}(n))$ I/Os\xspace in total. The priority queue and the active structure have size $O(\sqrt n)$ and therefore fit in memory by the arguments given above, so the second phase needs $O(n \log n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace in total. The third phase, sorting the output lists into a visibility grid, also takes $O(n \log n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace: the analysis is the same as for the first phase. Note that in practice, the number of visible points is often very small compared to the size of the grid. In that case it may be better to change the algorithm \textsc{ComputeVisibility} as follows: instead of writing the visibility values of \emph{all} grid points to separate lists for each band and sorting these into a grid, we record only the \emph{visible} grid points with their grid coordinates, write them to a single list~$V$, sort this list, and produce a visibility map from the sorted output. \subsection{An algorithm for very large inputs} The above algorithm computes a visibility map in $\Theta(\mathsf{scan}(n))$~I/Os\xspace under the assumption that $M \geq c_1 \sqrt n$, and $M \geq c_2 B^2$ for sufficiently large constants $c_1$ and $c_2$. Note that $\mathsf{sort}(n) = \Theta(\mathsf{scan}(n))$ under these assumptions. The idea of a layered radial sweep can be extended to a recursive algorithm that runs in $O(\mathsf{sort}(n))$ I/Os\xspace for any $n$, without both these assumptions. The idea is the following: we divide the problem into $\Theta(M/B)$ bands, scan the input to distribute the grid points into separate lists for each band, then compute visibility recursively in each band, and merge the results. More precisely, for each band we will compute a list of ``locally'' visible points and a ``local'' horizon: these are the points and the horizon that would be visible in absence of the terrain between the viewpoint and the band. The list of visible points is stored in azimuth order around the viewpoint. The horizon is a step function whose complexity is linear in the number of points of the terrain; it is also stored as a list of points in azimuth order around the viewpoint. Now we can merge two adjacent bands as follows. Let $V_1$ and $H_1$ be the list of visible points and the horizon of the inner band, and let $V_2$ and $H_2$ be the list of visible points and the horizon of the outer band. The merge proceeds as follows. We scan these four lists in parallel, in azimuth order, and output two lists in azimuth order. First, a list of visible points containing all points of $V_1$, and all points $V_2$ that are visible above $H_1$. Second, the merged horizon: the upper envelope of $H_1$ and $H_2$. This correctly computes visibility because a point is visible if and only if is visible in its band, and is not occluded by any of the bands that are closer to $v$. The idea of the merge step can be extended to merge $M/B$ bands, resulting in an algorithm that runs in $O(\mathsf{sort}(n))$ I/Os\xspace. To see why, observe that there are $\Theta(M/B)$ levels of recursion, and the base-case runs in linear time. Each band and its horizon have size $O(n/(M/B))$. The merging can be performed in linear time because it involves scanning of $\Theta(M/B)$ lists of size $\Theta(n/(M/B))$; a block from each list fits in memory and the total size of all lists is $\Theta(n)$. It remains to show that a horizon can be computed in linear time in a base-case band of width $\Theta(\sqrt M)$. To see this, we note that a band consists of tiles of size $\sqrt M \cdot \sqrt M$, and the horizon can be computed tile by tile. The details are similar to ones already discussed, and we omit them. Overall, we get a divide-and-conquer algorithm that can compute visibility in $\Theta(\mathsf{sort}(n))$ I/Os\xspace for any $n$, assuming $M \geq c_2 B^2$. Because another algorithm with a theoretical I/O-efficiency of $O(\mathsf{sort}(n))$ was already known from our previous work~\cite{havertoma:visibility-journal}, this ``new'' divide-and-conquer algorithm is not particularly interesting. In practice such a recursive algorithm would probably never be needed: it would only be useful when $n$ would be at least as big as $(M/c_1)^2$. \section{A radial sweep in sectors}\label{sec:radial-sectors} This section describes our second algorithm for computing the visibility map of a point $v$. It does not achieve better asymptotic bounds on running time and I/Os\xspace than the algorithm from the previous section, but, as we will see in Section~\ref{sec:results}, it is faster. Like the algorithm from Section~\ref{sec:radial-layers}, our second algorithm sweeps the terrain radially around the viewpoint. As before, the azimuth angles of the events are computed on the fly using a priority queue. Elevation values of grid points are only needed when their \textsc{enter}\xspace events are processed. To make access to elevation values efficient, we first divide the elevation grid into sectors of $\Theta(M)$ grid points each---this is the main difference with the algorithm from the previous section, which divided the elevation grid into concentric bands. The algorithm proceeds in three phases. First, for any pair of azimuth angles $\alpha,\beta$, let $S(\alpha,\beta)$ be the set of grid points whose corresponding \textsc{enter}\xspace events have azimuth angle at least $\alpha$ and less than $\beta$. The first phase of our algorithm starts by computing a set of azimuth angles $\alpha_0 < ... < \alpha_s$, where $\alpha_0 = 0$ and $\alpha_s = 2\pi$, such that for any $1 \leq k \leq s$ we have that the coordinates and elevation values of $S(\alpha_{k-1},\alpha_k)$ fit in one third of the main memory. Note that this can be done without accessing the elevation grid: the algorithm only needs to know the size of the grid and the location of the viewpoint in order to be able to divide the full grid into memory-size sectors. We then scan the elevation grid and distribute the grid points based on their \textsc{enter}\xspace azimuth angle into lists: one list $E_k$ for each sector $S(\alpha_{k-1},\alpha_k)$. (Cells straight right of the viewpoint need to be entered at the beginning of the sweep and are additionally put in $E_1$). In the second phase we do the radial sweep as before, sector by sector, with two modifications: (i) whenever we enter a new sector $S(\alpha_{k-1},\alpha_k)$, we load the complete list $E_k$ into memory and sort it by the azimuth angle of the \textsc{enter}\xspace events; (ii) we do not keep a list of visibility values per sector, but instead we write the row and column coordinates of the points that are found to be visible to a single list $L$. \begin{figure}[t] \centering \includegraphics[height=2.5in]{sectors.pdf} \caption{A radial sweep in sectors.} \label{fig:sector-radial-sweep} \end{figure} Finally, in the third phase we sort $L$ and scan it to produce a visibility map of the full grid. Thus the full algorithm is as follows: \newpage \addvspace{.5\baselineskip} \noindent \textbf{Algorithm} \textsc{SectoredSweep}:\\[.25\baselineskip] \textit{First phase---distribution:}\\ Compute sector boundaries $\alpha_0,...,\alpha_s$ analytically such that each sector $S(\alpha_{k-1},\alpha_k)$ fits in one third of the memory.\\ \textbf{for }$k \leftarrow 0$ \textbf{to} $s$\\ \textbf{do }initialise empty list $E_k$\\ \textbf{for }all points $p(i,j)$ in row-by-row order (except $v$)\\ \textbf{do }compute $k$ s.t. $\alpha_{k-1} \leq \textsc{enter}\xspace(i,j) < \alpha_k$\\ \hphantom{\textbf{do }}read $Z_{ij}$ and write $\langle i,j,Z_{ij}\rangle$ to $E_k$\\ \textbf{for }all points $p(i,j)$ from $v$ (excl.) straight to the right\\ \textbf{do }read $Z_{ij}$ and write $\langle i,j,Z_{ij}\rangle$ to $E_0$\\[.25\baselineskip] \textit{Second phase---sweep:}\\ initialise empty active structure $A$ and priority queue $Q$\\ initialise empty output list $L$\\ \textbf{for }$j \leftarrow 1$ \textbf{to} $m$\\ \textbf{do }insert $\langle \textsc{enter}\xspace (0,j)-2\pi, \textsc{enter}\xspace, 0,j \rangle$ into $Q$\\ $k \leftarrow 1$; load $E_1$ in memory and sort it by $\textsc{enter}\xspace(i,j)$\\ \textbf{while} not all visibility values have been computed\\ \textbf{do }$\langle \alpha, \mathit{type}, i, j \rangle \leftarrow Q$.deleteMin()\\ \hphantom{\textbf{do }}\textbf{if }$\mathit{type} = \textsc{enter}\xspace$\\ \hphantom{\textbf{do }}\textbf{then }\textbf{if }$E_k$ contains no more unread elements\\ \hphantom{\textbf{do then }}\textbf{then }delete $E_k$; $k \leftarrow k + 1$; load $E_k$ in memory\\ \hphantom{\textbf{do then then }}sort $E_k$ and set read pointer at beginning\\ \hphantom{\textbf{do then }}$z \leftarrow$ read the next unread value from $E_k$\quad\quad (=$Z_{ij}$) \\ \hphantom{\textbf{do then }}$\beta \leftarrow \arctan(z/\mathrm{Dist}(i,j))$\quad\quad($= \mathrm{ElevAngle}(p(i,j))$)\\ \hphantom{\textbf{do then }}insert $\langle \mathrm{Dist}(i,j), \beta\rangle$ into $A$\\ \hphantom{\textbf{do then }}insert $\langle \textsc{center}\xspace(i,j), \textsc{center}\xspace, i,j\rangle$ in $Q$\\ \hphantom{\textbf{do then }}insert $\langle \textsc{exit}\xspace(i,j), \textsc{exit}\xspace, i,j\rangle$ into $Q$\\ \hphantom{\textbf{do then }}\textbf{if }$|i| < j$ or $i = j > 0$\quad\quad\textit{(next cell is north)}\\ \hphantom{\textbf{do then }}\textbf{then }insert $\langle \textsc{enter}\xspace (i-1,j), \textsc{enter}\xspace, i-1,j \rangle$ in $Q$\\ \hphantom{\textbf{do then }}[... \textit{similar for west, south, and east} ...]\\ \hphantom{\textbf{do }}\textbf{else if }$\mathit{type} = \textsc{center}\xspace$\\ \hphantom{\textbf{do }}\textbf{then }query $A$ if element with key $\mathrm{Dist}(i,j)$ is visible;\\ \hphantom{\textbf{do then }}if yes, write $\langle i,j\rangle$ to $L$\\ \hphantom{\textbf{do }}\textbf{else }($\mathit{type} = \textsc{exit}\xspace$)\\ \hphantom{\textbf{do then }}delete element with key $\mathrm{Dist}(i,j)$ from $A$\\[.25\baselineskip] \textit{Third phase---produce visibility map:} \\ Sort $L$ lexicographically by row, column\\ Set read pointer of $L$ at the beginning\\ \textbf{for }all points $p(i,j)$ in row-by-row order\\ \textbf{do if }next element of $L$ is $(i,j)$\\ \hphantom{\textbf{do }}\textbf{then }$V_{ij} \leftarrow 1$; advance read pointer of $L$\\ \hphantom{\textbf{do }}\textbf{else }$V_{ij} \leftarrow 0$\\ \vspace{\baselineskip} {\bf Efficiency analysis.} We will now briefly argue that the above algorithm computes a visibility map of the first quadrant in $O(n \log n)$ time and $O(\mathsf{scan}(n) + \mathsf{sort}(t))$ I/Os\xspace, where $t$ is the number of visible grid points, under the assumption that the input grid is square and $M^2/B \geq c n$ for a sufficiently large constant $c$. The first phase of the algorithm reads the elevation grid once and writes elevation values to $O(n/M) = O(M/B)$ sector lists. Therefore we can keep, for each sector, one block of size $\Theta(B)$ in memory as a write buffer, and thus the first phase produces the sector lists in $O(\mathsf{scan}(n))$ I/Os\xspace. The running time of the first phase is $\Theta(n)$. During the second phase, we read the sector lists one by one, in $O(\mathsf{scan}(n))$ I/Os\xspace in total. The priority queue and the active structure can be maintained in memory by the arguments given in the previous section. Creating and sorting $L$ takes $O(\mathsf{sort}(t))$ I/Os\xspace, after which it is scanned to produce a visibility map. Thus the algorithm runs in $O(n \log n)$ time and $O(\mathsf{scan}(n) + \mathsf{sort}(t))$ I/Os\xspace. \vspace{\baselineskip} {\bf An algorithm for very large inputs.} When the assumption $M^2/B \geq c n$ does not hold, a radial sweep based on distribution into sectors is still possible: one can use the recursive distribution sweep algorithm from our previous work~\cite{havertoma:visibility-journal} and apply the ideas described above to reduce the size of the event stream. The result is an algorithm that runs in $O(n \log n)$ time and $O(\mathsf{sort}(n))$ I/Os\xspace. We sketch the main ideas below. First we note that, for large $n$, the ``diagonal'' of the grid is larger than $M$ and does not fit in a sector. The splitter values for sectors can still be computed without any I/O\xspace because they depend solely on the position $(i,j)$ of the points wrt $v$, and not on their elevation. For example, one could do a pass through the points in $\textsc{enter}\xspace(i,j)$ order using an I/O-efficient priority queue, in the same way as during the sweep, but without accessing the elevation. Using a counter we can keep track of the number of points processed, and output every $\Theta(M)$-th one as a splitter. Given the splitters, we can proceed recursively: first distribute the grid into $\Theta(M/B)$ sectors, and then distribute each sector recursively until each sector has size $\Theta(M)$. This takes $\Theta(\log_{M/B} n)$ passes over the grid. Thus, distribution into $\Theta(M)$-sized sectors can be performed in $\Theta(\mathsf{sort}(n))$ I/Os\xspace. If $n > M^2$, the active structure does not fit in memory and the sweep of the sectors with a common active structure does not work, even though each sector is $\Theta(M)$. We need to refine the distribution to process carefully long cells that span more than one sector, so that we can process each sector individually. This can be done I/O-efficiently in $\Theta(\mathsf{sort}(n))$ I/Os\xspace and we refer to our previous algorithm for details~\cite{havertoma:visibility-journal}. \section{A centrifugal sweep algorithm}\label{sec:conc-sweep} In this section we describe our third algorithm for computing the visibiliy map. It uses a complementary approach to the radial sweep in the previous sections and sweeps the terrain centrifugally, by growing a region $R$ around the viewpoint. This region is kept \emph{star-shaped} around~$v$: for any point $u$ inside $R$, the line segment from $(u_x,u_y)$ to $(v_x,v_y)$ lies entirely inside~$R$. The idea is to grow $R$ point by point until it covers the complete grid, while maintaining the horizon $\sigma_R$ of $R$. Recall that the horizon $\sigma_R$ is a function from azimuth angles to elevation angles, such that $\sigma_R(\alpha)$ is the maximum elevation angle of any point on the intersection of $R$ with the ray that extends from $v$ in direction $\alpha$. Whenever a new point $u$ is added to $R$, we decide whether it is visible. The star shape of $R$ guarantees that all points along the line of sight from $v$ to $u$ have already been added, so we can in fact decide whether $u$ is visible by determining whether $u$ is visible above the horizon of $R$ just before adding $u$ (see Figure~\ref{fig:centrifugal}). The key to a good performance is to have a way of growing $R$ that results in an efficient disk access pattern, and to have an efficient way of maintaining the horizon structure. Below we explain how to do this, given an elevation grid with a fixed number of bytes per grid point. For ease of description, we remind the reader our notation: We assume that the viewpoint $v$ is in the center of the grid at coordinates $(0,0,0)$ and the grid has size $(2m + 1) \times (2m + 1)$, where $m = (\sqrt n - 1)/2$. The elevations of the grid points are given in a two-dimensional array $Z$ that is ordered row by row, with rows numbered from $-m$ to $m$ from north to south and columns numbered from $- m$ to $m$ from west to east. By $p(i,j)$ we denote the grid point $q = (q_x,q_y,q_z)$ in row $i$ and column $j$ with coordinates $q_x = j$, $q_y = -i$ and $q_z = Z_{ij}$; by \emph{cell $(i,j)$} we denote the square $D(p(i,j))$. To maintain the horizon efficiently, we represent it by a grid model itself: more precisely, it is maintained in an array $S$ of $32m$ slots, where slot $i$ stores the highest elevation angle in $R$ that occurs within the azimuth angle range from $i\cdot 2\pi /32m$ to $(i+1)\cdot 2\pi / 32m$. For growing the region $R$ the idea is to do so cache-obliviously using a recursive algorithm. Initially we call this algorithm with the smallest square that contains the full grid and whose width is a power of two. When called on a square of size larger than one, it makes recursive calls on each of the four quadrants of the square, in order of increasing distance of the quadrants from~$v$. For a square tile with upper left corner $(i,j)$ and width $s$, this distance $\mathrm{TileDist}(i,j,s)$ is the distance from $v$ to the closest point of the tile. This is determined as follows. Let $v_i, v_j$ be the row and column of the viewpoint. \begin{itemize} \item when $i \leq v_i < i + s$ and $j \leq v_j + s$, then the tile contains~$v$, and $\mathrm{TileDist}(i,j,s) = 0$; \item otherwise, when $i \leq v_i < i + s$, the tile intersects the row that contains $v$, and $\mathrm{TileDist}(i,j,s) = \min(|i - v_i|, |i + s - 1 - v_i|)$; \item otherwise, when $j \leq v_j < j + s$, the tile intersects the column that contains $v$, and $\mathrm{TileDist}(i,j,s) = \min(|j - v_j|, |j + s - 1 - v_j|)$; \item otherwise, $\mathrm{TileDist}(i,j,s) = \min(|i - v_i| + |j - v_j|, |i - v_i| + |j + s - 1 - v_j|, |i + s - 1 - v_i| + |j - v_j|, |i + s - 1 - v_i| + |j + s - 1 - v_j|)$. \end{itemize} When called on a square of size~1, that is, a square that contains only a single grid point~$p(i,j)$, we proceed as follows. We retrieve the elevation $Z_{ij}$ of~$p(i,j)$ from the input file and compute its azimuth angle $\mathrm{AzimAngle}(p(i,j))$ and its elevation angle. $\mathrm{ElevAngle}(p(i,j))$. Then we check if $p(i,j)$ is visible: this is the case if and only if $p(i,j)$ appears higher above the horizon than the current horizon in the direction of $p(i,j)$; that is, if and only if $\mathrm{ElevAngle}(p(i,j)) > S[\lfloor \mathrm{AzimAngle}(p(i,j))/2\pi \cdot 32m\rfloor]$. The visibility of $p(i,j)$ is recorded in the output grid $V$. Next we update the horizon to reflect the inclusion of $p(i,j)$ in $R$. To this end we check all slots in the horizon array whose azimuth angle range intersects the azimuth angle range of cell $(i,j)$; let ${\cal A}(p(i,j))$ denote this set of slots. For each slot of ${\cal A}(p(i,j))$ that currently stores an elevation angle lower than $\mathrm{ElevAngle}(p(i,j))$, we raise the elevation angle to $\mathrm{ElevAngle}(p(i,j))$. We thus have the following algorithm: \addvspace{\baselineskip} \noindent \textbf{Algorithm} \textsc{CentrifugalSweep}:\\[.25\baselineskip] create horizon array $S[0..32m-1]$\\ \textbf{for }$k \leftarrow 0$ \textbf{to} $32m-1$ \textbf{do} $S[k] \leftarrow -\infty$\\ $s \leftarrow$ smallest power of two $\geq 2m+1$\\ $\textsc{SweepRecursively}(\mathit{-m,-m,s})$ \addvspace{\baselineskip} \noindent \textbf{Algorithm} $\textsc{SweepRecursively}(i,j,s)$:\\ \textit{(Recursively computes visibility for the tile with upper left cell $(i,j)$ and width $s$)} \\[.25\baselineskip] \textbf{if }$s = 1$\\ \textbf{then }$\alpha \leftarrow \mathrm{AzimAngle}(p(i,j))$\\ \hphantom{\textbf{then }}$\beta \leftarrow \arctan(Z_{ij}/\mathrm{Dist}(i,j))$\hfill($=\mathrm{ElevAngle}(p(i,j))$)\\ \hphantom{\textbf{then }}\textbf{if} $\beta > S[\lfloor \alpha/2\pi \cdot 32m\rfloor]$ \textbf{then} $V_{ij} \leftarrow 1$ \textbf{else} $V_{ij} \leftarrow 0$\\ \hphantom{\textbf{then }}$\alpha^{-} \leftarrow$ smallest azimuth of any corner of cell $(i,j)$\\ \hphantom{\textbf{then }}$\alpha^{+} \leftarrow$ largest azimuth of any corner of cell $(i,j)$\\ \hphantom{\textbf{then }}\textbf{for }$k \leftarrow \lfloor \alpha^{-}/2\pi \cdot 32m\rfloor$ \textbf{to} $\lceil \alpha^{+}/2\pi \cdot 32m\rceil-1$\\ \hphantom{\textbf{then }}\textbf{do }$S[k] \leftarrow \max(S[k], \beta)$\\ \textbf{else }\textit{Let $Q$ be the four subquadrants:}\\ \hphantom{\textbf{then }}$s \leftarrow s/2$\\ \hphantom{\textbf{then }}$Q \leftarrow \{\langle i,j,s\rangle,\langle i+s,j,s\rangle,\langle i,j+s,s\rangle,\langle i+s,j+s,s\rangle\}$\\ \hphantom{\textbf{then }}sort the elements $\langle i,j,s\rangle$ of $Q$ by incr. $\mathrm{TileDist}(i,j,s)$\\ \hphantom{\textbf{then }}\textbf{for }$\langle i,j,s\rangle \in Q$\\ \hphantom{\textbf{then }}\textbf{do }$\textsc{SweepRecursively}(i,j,s)$ \begin{figure}[t] \centering{ \includegraphics[height=2in]{centrifugal.pdf} \caption{$R$ (dark shade) is a star-shaped region of the terrain (light shade) around $v$. The horizon of $R$ is maintained in array $S$. When $u$ is added to $R$, the elevation angles in the black slots of $S$ are updated. } \label{fig:centrifugal} } \end{figure} \subsection{Accuracy of the centrifugal sweep} Note that when the algorithm updates the horizon array, the elevation angle of $p(i,j)$ may be used to raise the elevation angles of a set of horizon array slots ${\cal A}(p(i,j))$, of which the total azimuth range may be slightly larger than that of the cell corresponding to $p(i,j)$---this is due to the rounding of the azimuth angles $\alpha^{-}$ and $\alpha^{+}$ in the algorithm. However, this is not a problem: The azimuth angles of grid points that lie next to each other (as seen from the viewpoint) differ by at least roughly $1/m$. The size of the horizon array is chosen such that its horizontal resolution is more than four times bigger: it divides the full range of azimuth angles from $0$ to $2\pi$ over $32m$ slots, each of which covers an azimuth angle range of $2\pi / 32m < 1/4m$. Therefore, if the resolution of the horizon array would be insufficient, then surely the resolution of the original elevation grid would not be sufficient. \subsection{Efficiency of the centrifugal sweep} The number of recursive calls made by the region-growing algorithm is $O(n)$. The only part of any recursive call that takes more than constant time is the updating of the horizon. We analyse this layer by layer, where this time layer $l$ is defined as the cells $(i,j)$ such that $|i| + |j| = l$. There are $O(\sqrt n)$ layers, and on each layer, each of the $O(\sqrt n)$ slots of the horizon array is updated at most twice. Thus the total time for updating the horizon is $O(n)$, and the complete algorithm runs in $O(n)$ time. The number of I/Os under the tall-cache assumption ($M = \Omega(B^2)$) can be analysed as follows. Let $w$ be the largest power of two such that the elevation and visibility values of a square tile of $w \times w$ points fit in half of the main memory. There are $O(n/w^2) = O(n/M)$ recursive calls on tiles of this size, and for each of them the relevant blocks of the input and output files can be loaded in $O(w(w/B + 1)) = O(w^2/B + w) = O(M/B + \sqrt M) = O(M/B)$ I/Os. Thus all I/O for reading and writing blocks of the input and output files can be done in $O(n/M \cdot M/B) = O(\mathsf{scan}(n))$ I/Os in total. It remains to discuss the I/Os that are caused by swapping parts of the horizon array in and out of memory. To this end we distinguish (i) recursive calls on tiles of size $w \times w$ at distance at least $c \cdot \sqrt{n/M}$ from the viewpoint (for a suitable constant~$c$), and (ii) calls on the remaining tiles around the viewpoint. For case (i), observe that each tile $G$ of size $w \times w$ at distance at least $c \cdot \sqrt{n/M}$ from the viewpoint has an azimuth range of $O(w/\sqrt{n/M}) = O(M/\sqrt{n})$; since the horizon array has $O(\sqrt n)$ slots, $G$ spans $O(M/\sqrt{n} \cdot \sqrt n) = O(M)$ slots of the horizon array. Therefore, when $c$ is sufficiently large, the part of the horizon array that is relevant to the call on $G$ can be read into the remaining half of the main memory at once, using $O(\mathsf{scan}(M))$ I/Os. In total we get $O(n/M) \cdot O(\mathsf{scan}(M)) = O(\mathsf{scan}(n))$ I/Os for reading and writing the horizon array in instances of case~(i). For case (ii), note that we access the horizon array $O(n)$ times in total (as shown in our running time analysis above). Because the tiles of case (ii) contain only $O(n/M)$ grid points in total, the accesses to the horizon array are organised in $O(n/M)$ runs of consecutive horizon array slots. The total number of I/O-operations induced by these accesses is therefore $O(n/B + n/M) = O(\mathsf{scan}(n))$. Adding it all up, we find that the centrifugal sweep algorithms runs in $O(n)$ time and $O(\mathsf{scan}(n))$ I/Os. The algorithm does not use or control $M$ and $B$ in any way: it is cache-oblivious. The I/O-efficiency analysis for the maintenance of the horizon array is purely theoretical as far as disk I/O is concerned: the complete horizon array easily fits in main memory for files up to several trillion grid points. However, the I/O-efficiency analysis also applies to the transfer of data between main memory and smaller caches. \section{An IO-efficient algorithm using linear interpolation} \label{sec:algorithms} In this section we describe our last two algorithms for computing viewsheds, \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace. These algorithms use linear interpolation to evaluate the intersection of the line-of-sight with the grid lines, and constitute an improved, IO-efficient version of Franklin's \texttt{R3}\xspace algorithm. {\bf Notation.} Recall that the horizon $H_v$ (wrt to viewpoint $v$) is the upper rim of the terrain as it appears to a viewer at $v$. Suppose we recenter our coordinate system such that $v = (0,0,0)$, and consider a \emph{view screen} around the viewer that consists of the Cartesian product of the vertical axis and the square with vertices $(1, 0)$, $(0, 1)$, $(-1, 0)$ and $(0, -1)$. The projection of a point $p = (p_x, p_y, p_z)$ towards $v$ onto the view screen has coordinates: $p / (|p_x| + |p_y|)$. Note that any line segment that does not cross the north-south or east-west axis through $v$, will appear as a line segment in the projection onto the view screen. We now define the horizon of the terrain as it appears in the projection. More precisely, for $t \in [0,2]$, we define the horizon $H_v(t)$ as the maximum value of $p_z / (|p_x| + |p_y|)$ over all terrain points $p$ such that $p_x / (|p_x| + |p_y|) = 1 - t$ and $p_y \leq 0$ (this defines the horizon of the terrain south of the viewpoint). For $t \in [2,4]$, we define the horizon $H_v(t)$ as the maximum value of $p_z / (|p_x| + |p_y|)$ over all terrain points $p$ such that $p_x / (|p_x| + |p_y|) = 3 + t$ and $p_y \geq 0$ (this defines the horizon of the terrain north of the viewpoint). {\bf The model.} We consider two models, shown in Figure~\ref{fig:model}: In the \emph{gridlines} model the grid points are connected by vertical and horizontal lines in a grid, and visibility is determined by evaluating the intersections of the LOS with the grid lines. The gridlines model is the model used by \texttt{R3}\xspace. We also consider a slightly different model, the \emph{layers} model, in which the grid points are connected in concentric layers around the viewpoint and visibility is determined by evaluating the intersections of the LOS with the layers. The layers model is a relaxation of the gridlines model because it considers only a subset of the intersections (obstacles) considerd by the gridlines model; any point visible from $v$ in the grid model is also visible in the layers model (but not the other way), and the viewshed generated by the grid model is a subset of the viewshed generated with the layers model. \begin{figure}[tb] \label{fig:model} \centering{ \begin{tabular}{c c} \includegraphics[width=3.5cm]{model-grid.pdf} & \includegraphics[width=3.5cm]{model-layers.pdf} \\ (a) & (b)\\ \end{tabular} \caption{\small{(a) The gridlines model: visibility is determined by the intersections of the LOS with all the grid lines. (b) The layers model: visibility is determined by the intersections of the LOS with the layers. }} } \end{figure} {\bf General idea and comparison to previous algorithms.} Our algorithms \textsc{vis-dac}\xspace and \textsc{vis-iter}\xspace use an overall approach that is a combination of our radial sweep algorithm (Section~\ref{sec:radial-layers}) which partitions the grid into bands, and our centrifugal sweep algorithm (Section~\ref{sec:conc-sweep}) which traverses the grid in layers around the viewpoint and maintains the horizon of the region traversed so far. \begin{itemize} \item Recall that the radial sweep algorithm from Section~\ref{sec:radial-layers} consists of three phases: (1) partition the elevation grid in bands; (2) rotate the ray and compute visibility bands; (3) sort the visibility bands into a visibility grid. Phase 2 accesses data sequentially from all bands while the ray rotates around the viewpoint. The width of a band is chosen $w = \Theta(\sqrt M)$. Our algorithms \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace have the same first and third phase, but in phase (2) they process the bands one at a time. The size of a band is set so that a band fits fully in memory. \item The centrifugal sweep algorithm Section~\ref{sec:conc-sweep} uses horizons which are stored discretized in an array. Our algorithms \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace use linear interpolation and therefore horizons are piecewise-linear functions and are stored as a list of $\{azimuth, zenith \}$ pairs with full precision. \end{itemize} We start by describing how to compute viewsheds in the layers model in Section~\ref{sec:visiter} and \ref{sec:visdac}; in Section~\ref{sec:gridlines} we show how our algorithms can be extended to the gridlines model while maintaining the same worst-case complexity. \subsection{An iterative algorithm: \textsc{vis-iter}\xspace } \label{sec:visiter} This section describes our first viewshed algorithm in the layers model, \textsc{vis-iter}\xspace. The main idea of \textsc{vis-iter}\xspace is to traverse the grid in layers around the viewpoint, one layer at a time, while maintaining the horizon of the region traversed so far. The horizon is maintained as a sequence of points $(t,H_v(t))$, sorted by $t$-coordinate, between which we interpolate linearly. When traversing a point $p$, the algorithm uses the maintained horizon to determine if $p$ is visible or invisible. In order to do this IO-efficiently, it divides the grid in bands around the viewpoint and processes one band at a time. The output visibility grid is generated band by band, and is sorted into a grid in the final phase of the algorithm. The size of the band is chosen such that a band fits in memory. Below we explain these steps in more detail. {\bf Notation.} The notation is the same as before and we review it for clarity: we ssume that the viewpoint $v$ is in the center of the grid at coordinates $(0,0,0)$ and the grid has size $(2m+1) \times (2m+1)$, where $m = (\sqrt n -1) /2$. The elevations of the grid points are given in a two-dimensional matrix $Z$ that is ordered row by row, with rows numbered from $-m$ to $m$ from north to south, and columns numbered from $-m$ to $m$ from west to east. By $p(i,j)$ we denote the grid point $q=(q_x, q_y, q_z)$ in row $i$ and column $j$ with coordinates $q_x = j, q_y = -i$ and $q_z= Z_{ij}$. For $l\ge 0$, let \emph{layer} $l$ of the grid, denoted $L_l$, denote the set of grid points whose $L_\infty$-distance from the viewpoint, measured in the horizontal plane, is $l$. By definition, $L_0$ consists of only one point, $v$. We divide the grid in concentric bands around the viewpoint: For $k>0$, band $k$, denoted $B_k$, contains all points in layers $w_{k-1}$ (inclusive) to $w_k$ (exclusive), where $w_k (k \ge 0)$ denote the indices of layers corresponding to the band boundaries. Thus band $B_1$ contains all points in layers $w_0=1$ to $w_1$, and so on. The algorithm starts with a preprocessing step which, given an arbitrary constant $K$, computes the band boundaries $w_k (k \ge 1)$ such that a band has size $\Theta(K)$ as follows: it cycles through each layer $i$ in the grid, computes (analytically) the number of points in that layer, and checks whether including this layer in the current band makes the band go over $K$ points. If yes, then layer $i$ marks the start of the next band. Otherwise, it adds the points in layer $i$ to the current band and continues. The maximum size $K$ of a band is chosen such that a band fills roughly a constant fraction of memory, and each band is at least one layer wide. More precisely, we choose $K = c_1 M$ and assume $\sqrt n \leq c_1 M$, for a sufficiently small constant $c_1$ which will be defined more precisely later. Thus the number of bands, $N_{bands}$, is $O(N/M)$. Once the band boundaries are set, the algorithm proceeds in three phases. The first phase is to generate, for each band $B_k$, a list $E_k$ containing the elevations of all points in the band. It does this by scanning the grid in row-column order: for each point $p(i,j)$, it calculates the index $k$ of the band that contains the point and writes $Z_{ij}$ to $E_k$. We note that the first phase writes the lists $E_k$ sequentially, and thus list $E_k$ contains the points in the order in which they are encountered during the (row-by-row) scan of the grid. The algorithm is given below. \noindent \textbf{Algorithm} \textsc{BuildBands}:\\[.25\baselineskip] load list containing band boundaries in memory \\ \textbf{for }$k \leftarrow 1$ \textbf{to} $N_{bands}$\\ \textbf{do }initialize empty list $E_k$\\ \textbf{for } $i\leftarrow -m$ \textbf {to} $m$\\ \textbf{do } \textbf{for } $j\leftarrow -m$ \textbf {to} $m$\\ \hphantom{\textbf{do }} \textbf{do} read next elevation $Z_{ij}$ from grid \\ \hphantom{\textbf{do }\textbf{do }} $k \leftarrow \textrm{band containing point } (i,j)$\\ \hphantom{\textbf{do }\textbf{do } }append $Z_{ij}$ to $E_k$ Given the lists $E_k$, the second phase of the algorithm computes which points are visible. To do this it traverses the grid one band at a time, reading the list $E_k$ into memory. Once a band is in memory, it traverses it layer by layer from the viewpoint outward, counter-clockwise in each layer. The output of the second phase is a set of lists $V_k$ with visibility values, one list for each band. While traversing the grid in this fashion the algorithm maintains the horizon of the region encompassed so far. More precisely, let $L_{1,i} (i\ge 1)$ denote the set of points in layers $L_1$ through $L_i$. Before traversing the next layer $L_{i+1}$, the algorithm knows the horizon $H_{1,i}$ of $L_{1,i}$. While traversing the points in $L_{i+1}$, the algorithm determines for each point $p$ if it is above or below the horizon $H_{1,i}$ and records this in $V_k$. At the same time it updates $H_{1,i}$ on the fly to obtain $H_{1,i+1}$. To do so, the algorithm computes, for each point $p$, the projection $h$ onto the view screen of the line segment that connects $p$ to the previous point in the same layer, the algorithm computes the intersection of $h$ with the current horizon as represented by $H_{1,i}$, and then updates $H_{1,i}$ to represent the upper envelope of the current horizon and $h$. After traversing the entire grid in this manner, the set of points that have been marked visible during the traversal constitute the viewshed of $v$. The algorithm is given below only for the first octant; the other octants are handled similarly: \noindent \textbf{Algorithm} \textsc{VisBands-ITER}:\\[.25\baselineskip] $H_{1,0} \leftarrow \emptyset$\\ \textbf{for }$k \leftarrow 1$ \textbf{to} $N_{bands}$ \\ \textbf{do } load list $E_k$ in memory\\ \hphantom{\textbf{do }} create list $V_k$ in memory and initialize it as all invisible\\ \hphantom{\textbf{do }} \textbf{for } $l \leftarrow w_{k-1}$ to $w_k$ //for each layer in the band \\ \hphantom{\textbf{do }} \textbf{do } //traverse layer $l$ in ccw order\\ \hphantom{\textbf{do } \textbf{do }} \textbf{for } $r \leftarrow 0$ to $-l$ //first octant\\ \hphantom{\textbf{do } \textbf{do }} \textbf{do } get elevation $Z_{rl}$ of $p(r,l)$ from $E_k$\\ \hphantom{\textbf{do } \textbf{do } \textbf{do }} determine if $Z_{rl}$ is above $H_{1,l-1}$\\ \hphantom{\textbf{do } \textbf{do } \textbf{do }} if visible, set value $V_{rl}$ in $V_k$ as visible\\ \hphantom{\textbf{do } \textbf{do } \textbf{do }} $h \leftarrow$ projection of $p(r-1,l)p(r,l)$\\ \hphantom{\textbf{do } \textbf{do } \textbf{do }} merge $h$ into horizon $H_{1,l-1}$\\ \hphantom{\textbf{do } \textbf{do }} $H_{1,l} \leftarrow H_{1,l-1}$\\ The third and final phase of the algorithm creates the visibility grid $V$ from the lists $V_k$. We note that in phase~2 the lists $V_k$ are stored in the same order as $E_k$, that is, the order in which the points in the band are encountered during a row-by-row scan of the grid; keeping points in this order is convenient because it saves an additional sort, and in the same time this is precisely the order in which they are needed by phase 3. Phase 3 is the reverse of phase 1: for each point $(i,j)$ in the grid in row-major order, it computes the band $k$ where it falls, accesses list $V_k$ to retrieve the visibility value of point $(i,j)$, and writes this value to the output grid $V$. The crux in this phase is that it simply reads the lists $V_k$ sequentially. The algorithm is given below: \noindent \textbf{Algorithm} \textsc{CollectBands}:\\[.25\baselineskip] load list containing band boundaries in memory\\ initialize empty list $V$\\ \textbf{for } $i\leftarrow -m$ \textbf {to} $m$\\ \textbf{do } \textbf{for } $j\leftarrow -m$ \textbf {to} $m$\\ \hphantom{\textbf{do }} \textbf{do} $k \leftarrow \textrm{band containing point } (i,j) $\\ \hphantom{\textbf{do }\textbf{do }} get value $V_{ij}$ of point $(i,j)$ from $V_k$\\ \hphantom{\textbf{do }\textbf{do } }append $V_{ij}$ to list $V$ {\bf Efficiency analysis of \textsc{vis-iter}\xspace.} We now analyze each phase in \textsc{vis-iter}\xspace under the assumption that $n \leq c M^2$ for a sufficiently small constant $c$. The pre-processing phase runs in $O(n)$ time and no I/O\xspace (does not access the grid). The output of this step is a list of $O(N_{bands}) = O(n/M)$ band boundaries, which fits in memory assuming that $n \leq c M^2$ for a sufficiently small constant $c$. The first phase, \textsc{BuildBands}, reads the points of the elevation grid in row-column order, which takes $O(n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace. With the list of band boundaries in memory, the band containing a point $(i,j)$ can be computed with, for example, binary search in $O(\lg n/M) = O(\lg n)$ time and no I/O\xspace. The lists $E_k$ are written to in sequential order. If one block from each band fits in memory, which happens when $n \leq c M^2 / B$ for a sufficiently small constant $c$ (so that $N_{bands} = O(n/M) = O(M/B)$), then writing the lists $E_k$ directly takes $O(\mathsf{scan}(n)) = O(\mathsf{sort}(n))$ I/Os\xspace (note that $O(\mathsf{sort}(n))$ and $O(\mathsf{scan}(n))$ are equal if $n = O(M^2/B)$). If we cannot keep one block of each band in memory, that is, $n > c M^2/B$, then we perform a hierarchical distribution as follows: we group the $N_{bands}$ bands in $O(M/B)$ super-bands, keep a write buffer of one block for each super-band in memory, distribute the points in the grid to these super-bands, and recurse on the super-bands to distribute the grid points to individual bands. A pass takes $O(\mathsf{scan}(n))$ I/Os\xspace, overall it takes $O(\log_{M/B} N_{bands}) = O(\log_{M/B} N/M)$ passes, and thus the first phase has I/O-complexity $O(\mathsf{sort}(n))$. In total, the first phase takes $O(n \lg n)$ time and $O(\mathsf{sort}(n))$ I/Os. The second phase, \textsc{VisBands-ITER}, takes as input the lists $E_k$ and computes the visibility bands $V_k$. We choose $K = c_1 M$ such that the elevations $E_k$ and the visibility map $V_k$ of any band $B_k$ of size $K$ fits in 2/3 of the memory; the remaining 1/3 of the memory is saved for the horizon structure. While processing a band $B_k$ in the second phase, the points in $E_k$ and $V_k$ are not accessed sequentially. However, given the band boundaries, the location of any point in a band can be determined analytically, and thus the value (elevation or visibility) of any point in a band can be accessed in constant time, without any search structure, and without any I/O\xspace. Let us denote by $H_{tot}$ the total cumulative size of all partial horizons $H_{1,l}$: $H_{tot} = \sum_{l=1}^{\sqrt n} |H_{1,l}|$. The horizon $H_{1,l}$ is maintained as a list $\{ (t, h)\}$ of horizontal and vertical coordinates on the view screen, sorted counter-clockwise (ccw) around the viewpoint. As the algorithm traverses a layer $l$ in ccw order, it also traverses $H_{1,l-1}$ in ccw order, and constructs $H_{1,l}$ in ccw order. To determine whether a point is above the horizon, it is compared with the last segment in the horizon; if the point is above the horizon, it is added to the horizon. Thus the traversal of a layer $l$ runs in $O(|L_l| + |H_{1,l-1}| + |H_{1,l}|)$ time. Over the entire grid, phase~2 runs in $O(\sum_l(|L_l| + |H_{1,l}|)) = O(n + H_{tot})$~time. The IO-complexity of the second phase: The algorithm reads $E_k$ into memory, and writes $V_k$ to disk at the end. Over all the bands this takes $O(\mathsf{scan}(n))$ I/Os\xspace. If the horizon $H_{1,l}$ is small enough so that it fits in memory (for any $l$), then accessing the horizon does not use any IO. If the horizon does not fit in memory, we need to add the cost of traversing the horizon in ccw order, for every layer, $O(\mathsf{scan}(\sum_{l=1}^{\sqrt n} |H_{1,l}|)) = \mathsf{scan}(H_{tot})$ I/Os\xspace. Finally, the third phase, \textsc{CollectBands}, takes as input the lists $V_k$ and the list of band boundaries and writes the visibility map. For $n \leq c M^2$, the list of band boundaries fits in memory. For any point $(i,j)$ the band containing it can be computed in $O(\lg n)$ time and no IO. The bands $V_k$ store the visibility values in the order in which they are encountered in a (row-column) traversal of the grid. Thus, once the index $k$ of the band that contains point $(i,j)$ is computed, the visibility value of this point is simply the next value in $V_k$. As with step 1, we distinguish two cases: if the number of bands is such that one block from each band fit in memory, then this step runs in $O(n)$ time and $O(\mathsf{sort}(n)) = O(\mathsf{scan}(n))$ I/Os\xspace. Otherwise, this step first performs a multi-level $M/B$-way merge of the bands into $O(M/B)$ super-bands so that one block from each can reside in main memory; in this case, the complexity of the step is $O(n \lg n)$ time and $O(\mathsf{sort}(n))$ I/Os\xspace. Putting everything together, we have the following: \begin{theorem} \label{th:visiter} The algorithm \textsc{vis-iter}\xspace computes viewsheds in the layers model in $O(n \lg n + H_{tot})$ time and $O(\mathsf{sort}(n) + \mathsf{scan}(H_{tot}))$ I/Os\xspace, provided that $n \leq c M^2$ for a sufficiently small constant $c$. \end{theorem} Furthermore, if $n= O(M^2/B)$ and the partial horizons $H_{1,l}$ are small enough to fit in memory for any $l$, the overall IO complexity becomes $O(\mathsf{scan}(n))$~I/Os\xspace. We note that when $n = \Omega(M^2)$ the algorithm can be adapted using standard techniques to run in the same bounds from Theorem~\ref{th:visiter}; we do not detail on this because it has no relevance in practice. {\bf Discussion.} Phase 1 and 3 of the algorithm are very simple and perform a scanning pass over the grid and the bands, provided that $n \leq c M^2/B$: Phase 1 reads the input elevation grid sequentially and writes the elevation bands sequentially; Phase~3 reads the visibility bands sequentially and writes the visibility grid sequentially. We found this condition to be true in practice on our largest test grid ($28GB$) and with as little as $.5GB$ of RAM. With more realistic value of $M=8 GB$ (and $B=16KB$), the condition is true for $n$ up to $10^{15}$ points. Thus, handling the sub-case $n \leq c M^2/B$ separately in the algorithm provides a simplification and a speed-up without restricting generality. Phase 2, which scans partial horizons $H_{1,l}$ for every layer, runs in $O(n + H_{tot})$ time and $O(\mathsf{scan}(n + H_{tot}))$ I/Os\xspace. As we will prove below, in the worst case $|H_{1,l}| = \Theta(l^2)$, and the running time of the second phase could be as high as $O(H_{tot}) = O(\sum_{l=1}^{O(\sqrt n)} \Theta(l^2)) = O(n \sqrt n)$, with handling the horizon dominating the running time. The worst-case complexity is high but, on the other hand, if $H_{1,l}$ are small, they fit in memory and the algorithm is fast. In particular if $H_{tot}$ is $O(n)$, then phase 2 is linear. This seems to be the case on all terrains and all viewpoints that we tried and may be a feature of realistic terrains. In Section~\ref{sec:results} we'll discuss our empirical findings in more detail. \newcommand{\xwd}[1]{\mathrm{width}(#1)} {\bf Worst-case complexity of the horizon.} Since the horizon is the upper envelope of the projections of grid line segments onto the view screen, its complexity is at most $O(n \alpha(n))$, where $n$ is the number of line segments~\cite{HS86,WS88}. We will now show that we can prove a better bound for our setting. Let the \emph{width} $\xwd{s}$ of a line segment $s$ be the length of its projection on a horizontal line. We need the following lemma. \begin{figure} \centering \includegraphics[width=0.8\hsize]{boundedwidth.pdf} \caption{Illustration of the proof of Lemma~\ref{lem:boundedwidth}. The white subsegments take the charge for $s_{b,q}$; together they are at least as wide as $s_b$, since they stick out from under $s_b$ on both sides.} \label{fig:boundedwidth} \end{figure} \begin{lemma}\label{lem:boundedwidth} If $S$ is a set of $n$ line segments in the plane, such that the widths of the line segments of $S$ do not differ in length by more than a factor $d$, then the upper envelope of $S$ has complexity $O(dn)$. \end{lemma} \begin{proof} Let $s_1,...,s_n$ be the segments of $S$. Each segment $s_i$ consists of a number of maximal subsegments such that the interior of each subsegment lies either entirely on or entirely below the upper envelope. Let the subsegments of $s_i$ be indexed by $s_{i,j}$, such that the subsegments of $s_i$ from left to right are indexed by consecutive values of $j$, and such that $s_{i,j}$ is part of the upper envelope if and only if $j$ is odd. Let $u_1,...,u_m$ be the line segments of the upper envelope. We consider two categories of line segments on the upper envelope: (i) segments that have at least one endpoint that is an endpoint of a segment of $S$; (ii) segments whose endpoints are no endpoints of segments in $S$. Clearly, there can be only $O(n)$ segments of category (i), one segment to the left of each endpoint of a segment in $S$ and one segment to the right of each endpoint. We analyze the number of segments of category (ii) with the following charging scheme. Given a segment $u_h = s_{b,q}$ of category (ii), let $s_{a,p}$ be the segment $u_{h-1}$ and let $s_{c,r}$ be the segment $u_{h+1}$. We charge $u_h$ to $s_{a,p+1}$ and $s_{c,r-1}$. Observe that with this scheme, each segment $s_{i,j}$ can only be charged twice, namely by the successor of $s_{i,j-1}$ on the upper envelope and by the predecessor of $s_{i,j+1}$ on the upper envelope. Since each segment $s_i$ has only one leftmost and only one rightmost subsegment, and each is charged at most twice (in fact, once), there are at most $O(n)$ segments of category (ii) that put charges on leftmost or rightmost subsegments. If neither $s_{a,p+1}$ is the rightmost subsegment of $s_a$ nor $s_{c,r-1}$ is the leftmost subsegment of $s_c$, then $s_a$ must appear on the upper envelope again somewhere to the right of the right end of $s_b$, and $s_c$ must appear on the upper envelope again somewhere to the left of the left end of $s_b$ (see Figure~\ref{fig:boundedwidth}) Therefore $\xwd{s_{a,p+1}} + \xwd{s_{c,r-1}} > \xwd{s_b} \geq \frac{1}{dn}\sum_{i=1}^n \xwd{s_i}$. Since each subsegment is charged at most twice, the total length of subsegments charged is at most $2\sum_{i=1}^n \xwd{s_i}$. Thus there are less than $2dn$ segments of category (ii) that put charges on subsegments that are not leftmost or rightmost. \end{proof} Note that the widths of the projections of the edges of layer $l$ on the view screen vary between $1/(l+1)$ and $1/(4l-2)$. Therefore, the widths of the projections of the edges of the $l/2$ outermost layers in a square region of $l$ layers around $v$ differ by less than a factor 8. Thus, from Lemma~\ref{lem:boundedwidth} we get: \begin{corollary}\label{cor:outerhorizon} If $S$ consists of the $O(l^2)$ edges of the $l/2$ outermost layers in a square region of $l$ layers around $v$, then the horizon of $S$ has complexity $O(l^2)$. \end{corollary} \begin{lemma}\label{lem:combine} If $S$ and $T$ are two $x$-monotone polylines of $m$ and $n$ vertices, respectively, then the upper envelope of $S$ and $T$ has at most $2(m+n)$ vertices. \end{lemma} \begin{proof} There are two types of vertices on the upper envelope: vertices of $S$ or $T$, and intersection points between edges of $S$ and $T$. Clearly, there are at most $m + n$ vertices of the first type. Between any pair of vertices of the second type, there must be a vertex of the first type. Thus there are at most $m + n - 1$ vertices of the second type. \end{proof} \begin{theorem}\label{thm:gridhorizon} If $S$ consists of $l$ layers in a square region around $v$, then the horizon of $S$ has complexity $O(l^2)$ in the worst case. \end{theorem} \begin{proof} Let $T(l)$ be the complexity of the horizon of the innermost $l$ layers around $S$. By Lemma~\ref{lem:combine}, $T(l)$ is at most twice the complexity of the horizon of the innermost $l/2$ layers, plus twice the complexity of the remaining $l/2$ layers. By Corollary~\ref{cor:outerhorizon}, the latter is $O(l^2)$, and therefore we have $T(l) \leq 2T(l/2) + O(l^2)$. This solves to $T(l) = O(l^2)$. \end{proof} \subsection{A refined algorithm: \textsc{vis-dac}\xspace} \label{sec:visdac} This section describes our second algorithm for computing viewsheds in the layers model, \textsc{vis-dac}\xspace. \textsc{vis-dac}\xspace is a divide-and-conquer refinement of \textsc{vis-iter}\xspace and uses the same general steps: it splits the grid into bands, computes visibility one band at a time, and creates the visibility grid from the bands. The first phase (\textsc{BuildBands}) and last phase (\textsc{CollectBands}) are the same as in \textsc{vis-iter}\xspace; the only phase that is different is computing visibility in a band, \textsc{VisBands-DAC}, which aims to improve the time to merge horizons in a band using divide-and-conquer. Similar to \textsc{VisBands-Iter}, \textsc{VisBands-DAC} processes the bands one at a time: for each band $k$ it loads list $E_k$ in memory, creates a visibility list $V_k$ and initializes it as all visible. It then marks as invisible all points that are below $H_{prev}$, where $H_{prev}$ represents the horizon of the first $k-1$ bands (more on this below). The bulk of the work in \textsc{visBands-DAC} is done by the recursive function \textsc{Dac-Band}, which computes and returns the horizon $H$ of $E_k$, and updates $V_k$ with all the points that are invisible inside $E_k$. This is described in detail below. Finally, the horizon $H$ is merged with $H_{prev}$ setting it up for the next band. In order to mark as invisible the points in band $k$ that are below $H_{prev}$ we first sort the points in the band by azimuth angle and then scan them in this order while also scanning $H_{prev}$ (recall that $H_{prev}$ is stored in ccw order). Let $(a_1=0, h_1), (a_2, h_2)$ be the first two points in the horizon $H_{prev}$. For every point $p=(a,h)$ in $E_k$ with azimuth angle $a \in [a_1, a_2]$, we check whether its height $h$ is above or below the height of segment $(a_1,h_1)(a_2,h_2)$ in $H_{prev}$. When we encounter a point in $E_k$ with $a > a_2$, we proceed to the next point in $H_{prev}$ and repeat. The recursive algorithm \textsc{DAC-Band} takes as arguments an elevation band $E_k$, a visibility band $V_k$, and the indices $i$ and $j$ of two layers in this band ($w_{k-1} \le i \le j < w_k$). It computes visibility for the points in layers $i$ through $j$ (inclusive) in this band, and marks in $V_k$ the points that are determined to be invisible during this process. In this process it also computes and returns the horizon of layers $i$ through $j$ in this band. \textsc{Dac-Band} uses divide-and-conquer in a straightforward way: first it computes a ``middle'' layer $m, i \le m \le j$ between $i$ and $j$ that splits the points in layers $i$ through $j$ approximately in half. Then it computes visibility and the horizon recursively on each side of $m$; marks as invisible all points in the second half that fall below the horizon of the first half; and finally, merges the two horizons on the two sides and returns the result. \noindent \textbf{Algorithm} \textsc{Dac-Band}($E_k, V_k, i,j$):\\ [.25\baselineskip] \textbf{if } $i==j$\\ \hphantom{\textbf{if }} $h \leftarrow$ compute-layer-horizon(i)\\ \hphantom{\textbf{if }} return $h$\\ \textbf{else } \\ \hphantom{\textbf{else }} $m \leftarrow$ middle layer between $i$ and $j$\\ \hphantom{\textbf{else }} $h_1 \leftarrow \textsc{Dac-Band}(E_k, V_k, i,m)$\\ \hphantom{\textbf{else }} $h_2 \leftarrow \textsc{Dac-Band}(E_k, V_k, m+1,j)$\\ \hphantom{\textbf{else }} mark invisible all points in $L_{m+1, j}$ that fall below $h_1$\\ \hphantom{\textbf{else }} $h \leftarrow$ merge($h_1,h_2$)\\ \hphantom{\textbf{else }} return $h$ {\bf Efficiency analysis of \textsc{vis-dac}\xspace.} The analysis of the first and last phase of \textsc{vis-dac}\xspace, \textsc{buildBands} and \textsc{CollectBands}, is the same as in Section~\ref{sec:visiter}. We now analyze \textsc{VisBands-DAC}. Recall that we can assume that $E_k$ and $V_k$ both fit in memory during this phase (see Section~\ref{sec:visiter}). The elevation and visibility of any point in a band can be accessed in $O(1)$ time, without any search structure and without any I/O. We denote $H^B_{1,i}$ the horizon of (the points in) the first $i$ bands; and by $H^B_{tot} = H^B_{1,1} + H^B_{1,2} + H^B_{1,3} + ...= \sum_{i=1}^{N_{bands}} H^B_{1,i}$. \begin{itemize} \item Marking as invisible the points in $E_k$ that are below $H_{prev}$ (here $H_{prev}$ represents $H^B_{1,k-1}$): this can be done by first sorting $E_k$ and then scanning $H^B_{1,k-1}$ and $E_k$ in sync. Over the entire grid, this takes $O(n \lg n + H^B_{tot})$ CPU and $O(\mathsf{scan}(n) + \mathsf{scan}(H^B_{tot}))$ I/Os\xspace. \item Merging horizons: After \textsc{Dac-band} is called in a band, the returned horizon is merged with $H_{prev}$. Two horizons can be merged in linear time and I/Os\xspace. Over the entire grid this is $O(H^B_{tot})$ time and $O(\mathsf{scan}(H^B_{tot}))$~I/Os\xspace. \item \textsc{Dac-band}: This is a recursive function, with the running time given by the recurrence $T(k) = 2T(k/2) + \texttt{merge cost + update cost}$, where $k$ is the number of points in the slice between layers $i$ and $j$ given as input. The base case computes the horizon of a layer $l$, which takes linear time wrt to the number of points in the layer. Summed over all the layers in the slice the base case takes $O(\sum_{l=i}^{j}|L_l|) = O(k)$ time and no I/O\xspace (band is in memory). \item The update time in \textsc{Dac-band} represents the time to mark as invisible all points in the second half that fall below the horizon $h_1$ of the first half. Recall that a band fits in memory and thus an input slice in \texttt{Dac-Band} fits in memory. If the band is sorted, the update can be done as above in $O(k + |h_1|) = O(k)$ time (by Theorem~\ref{thm:gridhorizon} we have $|h_1| = O(k)$). \item The merge time in \textsc{Dac-band} represents the time to merge the horizons $h_1$ and $h_2$ of the first and second half of the slice, respectively. This takes $O(|h_1| + |h_2|) = O(k)$ time. \item Putting it all together in the recurrence relation we get $T(k) = 2T(k/2) + O(k)$, which solves to $O(k \lg k)$ time. Summed over all bands in the grid \textsc{Dac-Band} runs in $O(n \lg n)$ time and $O(\mathsf{scan}(n))$ I/Os\xspace. \end{itemize} Overall we have the following: \begin{theorem} The algorithm \textsc{vis-dac}\xspace computes viewsheds in the layers model in $O(n \lg n + H^B_{tot})$ time and $O(\mathsf{sort}(n) + \mathsf{scan}(H^B_{tot}))$ I/Os\xspace, provided that $n \le cM^2$, for a sufficienly small constant $c$. \end{theorem} {\bf Discussion:} The worst case complexity of $H^B_{tot}$ is $\sum_{i=1}^{N_{bands}} H^B_{1,i} = O(N_{bands} \cdot n) = O(n^2/M)$; This is an improvement over $O(n \sqrt n)$ ( provided that $n \le cM^2$). Consider a band that extends from layer $L_i$ to layer $L_j$ and contains $k$ points. The algorithm \textsc{Dac-Band} runs in $O(k \lg k)$ time, while the iterative algorithm \textsc{VisBands-Iter} scans iteratively through all cumulative horizons of the layers in the band $H_{1,i}, H_{1,i+1}, ...$ and so on and runs in $O(k + |H_{1, i}| + |H_{1, i+1}| + ... +|H_{1,j}|)$. When the horizons are small, \textsc{vis-iter}\xspace runs in $O(k)$ time and is faster than \textsc{vis-dac}\xspace. The divide-and-conquer merging is not justified unless the horizons are large enough to benefit from it. \subsection{The gridlines model} \label{sec:gridlines} The algorithms \textsc{vis-dac}\xspace and \textsc{vis-iter}\xspace described in Section~\ref{sec:visiter} and \ref{sec:visdac} above compute viewsheds in the layers model. Let $X_i$ denote the line segments connecting points at distance $i-1$ with points at distance $i$ (Figure~\ref{fig:gridlines}). The set $X_i$ represents the additional ``obstacles'' in the $i$th layer that could intersect the LOS in the gridlines model. With this notation the horizon of the $i$th layer in the gridlines model is $H(L_i) \cup H(X_i)$. The algorithms \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace can be extended to compute viewsheds in the gridlines model---the only difference is that they compute the horizon of a layer as $H(L_i) \cup H(X_i)$ instead of $H(L_i)$. Since $|X_i| = \Theta(|L_i|)$, the analysis and the bounds of the algorithms are the same in both models up to a constant factor. Our algorithms \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace, when using the gridlines model, compute the same viewshed as \texttt{R3}\xspace~\cite{franklin:sdh94}. \textsc{vis-dac}\xspace's upper bound of $O(n \lg n + n^2/M)$ is an improvement over \texttt{R3}\xspace's bound of $O(n \sqrt n)$, provided that $n \le c M^2$. The results on the worst-case complexity of the horizon in the layer model extend to the gridlines model. The extension is not entirely straightforward, because the differences in width in the projection between non-layer edges are larger than between layer edges. We defer the proof to the journal version of this paper. \begin{figure}[t] \centering{ \includegraphics[width=3.5cm]{layers-grid.pdf} } \caption{The segments contributing to a layer's horizon in the gridlines model} \label{fig:gridlines} \end{figure} \section{Experimental results} \label{sec:results} In this section we describe the implementation details and the results of the experiments with our algorithms. We implemented the five algorithms described above: \textsc{io-radial2}\xspace is the layered radial sweep algorithm described in Section~\ref{sec:radial-layers}; \textsc{io-radial3}\xspace is the radial sweep algorithm from Section~\ref{sec:radial-sectors}; \textsc{io-centrifugal}\xspace is the centrifugal sweep algorithm from~Section~\ref{sec:conc-sweep}; \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace are the two algorithms described in Section~\ref{sec:visdac} and \ref{sec:visiter}, respectively. We use as reference the algorithm from our previous work, \textsc{io-radial1}\xspace\cite{havertoma:visibility-journal}, which is also based on Van Kreveld's model. \subsection{Implementation details} We start by reviewing the implementation details of our algorithms. \textsc{io-radial1}\xspace scans the elevation grid, creates 3 events for each cell and writes them to the event stream; with 12 bytes per event, the event stream is $36n$ bytes. It then sorts the event stream by azimuth angle. To sweep, it scans the event stream in order while using an active structure to keep track of the events that intersect the sweep line. During the sweep, the cells that are visible are written to a file. In the end, the file is sorted by location and written to the output grid. \textsc{io-radial1}\xspace can function in a recursive mode if it determines that the active structure does not fit in memory. However in all datasets the active structure is small ($<$30~MiB) and completely fits in memory~\cite{havertoma:visibility-journal}. \textsc{io-radial2}\xspace performs 2 passes over the elevation grid. It first maps the elevation grid file in (virtual) memory and creates the sorted layers $E_k$. During this phase, the elevation grid and the sorted arrays $E_k$ are kept in memory, and \textsc{io-radial2}\xspace relies on the virtual memory manager (VMM) to page in blocks from the elevation grid as necessary when accessing the points in band $k$. Note that the accesses to the elevation grid are not sequential (although they amount to $O(\mathsf{scan}(n))$ I/Os\xspace). To help the VMM we implemented the following strategy: whenever the current band needs to access an elevation from the grid, we load an entire square tile of $\Theta(M)$ points in memory, and keep track of the two most recent tiles. Once all $E_k$ are computed the elevation grid is freed. During the second phase (the sweep) the elevations are accessed sequentially from the bands $E_k$ and the output grid is kept in (virtual) memory as a bitmap grid. \textsc{io-radial3}\xspace also performs 2 (sequential) passes over the elevation grid. The first pass scans over the elevation grid and places each point $(i,j, Z_{ij})$ in its sector. Sectors are stored as streams on disk. The second pass sorts and sweep the points in one sector at a time by $\textsc{enter}\xspace(i,j)$. The output grid is kept in (virtual) memory as a bitmap grid. Except for the output grid, \textsc{io-radial3}\xspace does not use the VMM. \textsc{io-radial1}\xspace, \textsc{io-radial2}\xspace and \textsc{io-radial3}\xspace use the same data structures: a heap as a priority queue; a red-black tree for the active structure~\cite{cormen:introduction}; and the same in-memory sorting (optimized quicksort). For the largest terrains the priority queue and the active structure are at most 30MB and fit in memory. \textsc{io-centrifugal}\xspace is implemented in one (non-sequential) pass over the elevation grid. The implementation is recursive, as described in Section~\ref{sec:conc-sweep}. Theoretically the algorithm could run completely cache-obliviously with help of the VMM, but this turned out to be slow. Therefore we implemented a cache-aware version: whenever the recursion enters a tile $G$ of the largest size that fits in memory, we load the elevation values for the entire tile into memory; when the algorithm returns from the recursive call on $G$, the visibility values for $G$ are written to disk. \textsc{vis-iter}\xspace performs two sequential passes over the elevation grid, and one over the visibility grid. The first pass reads the elevation grid and creates the bands, and the second pass loads the bands one by one in memory and computes the visibility bands. The horizon is maintained as an array of (azimuth, zenith) pairs, and is accessed sequentially; in all our experiments it never exceeded 200,000 points. \textsc{vis-dac}\xspace implements a divide-and-conquer refinement of \textsc{vis-iter}\xspace. When when a band is loaded in memory, \textsc{vis-dac}\xspace will compute and merge the layers in the band in a way similar to mergesort, which leads to an improved upper bound for its time complexity. \textsc{vis-dac}\xspace and \textsc{vis-iter}\xspace share the same code. The user can switch between the two by turning on or off a flag that triggers the divide-and-conquer. There is another flag to select the model (gridlines or layers). The implementations of all of our algorithms avoid taking square roots and arctangents, and do not store any angles. Instead of elevation angles, they use the signed squared tangents of elevation angles, and instead of azimuth angles, they use tangents of azimuth angles relative to the nearest axis direction (north, east, south, or west). \subsection{Platform} The algorithms are implemented in C and compiled with gcc/g++ 4.1.2 (with optimization level -O3). All experiments were run on HP 220 blade servers, with an Intel 2.83 GHz processor and a 5400 rpm SATA hard drive (the HP blade servers come only with this HD option). The machine is quad-core, but only one CPU was used. We ran experiments rebooting the machine with 512 MiB and 1 GiB of RAM. These sizes do not reflect current technology, and have been chosen in order to emphasize the scalability of the algorithms to a volume of data that is much larger than the amount of RAM available. \subsection{Datasets} The algorithms were tested on real terrains ranging up to over 7.6 billion elements, see~Table~\ref{tbl:datasets} for some examples. The largest datasets are SRTM1 data, 30m resolution, available at \texttt{http://www2.jpl.nasa.gov/srtm/} We selected these datasets because they are easily available, and are large. In practice it does not make sense to compute a viewshed on a very large area at low resolution; instead we would want to use a grid corresponding to a relatively small area at high resolution. We used SRTM data because it was easily and freely available, and served our goal to compare the algorithms. On all datasets up to 4~GiB (\texttt{Washington}), viewshed timings were obtained by selecting several viewpoints uniformly on each terrain and taking the average time. For the larger datasets we chose a viewpoint approximately in the middle of the terrain. This gives a good indication of the algorithm's performance, and we note that for all our algorithms the majority of the running time is spent handling the bands, and we expect that the total runing time will vary insignificantly with the position of the viewpoint. \begin{table*}[t] \centering \begin{tabular}{|r|r@{ $\times$}rr|} \hline Dataset & \multicolumn{3}{c|}{Size} \\ & cols & rows & GiB \\ \hline {Cumberlands} & 8\,704 & 7\,673 & 0.25 \\ {USA DEM 6} & 13\,500 & 18\,200 & 0.92 \\ {USA DEM 2} & 11\,000 & 25\,500 & 1.04 \\ {Washington} & 31\,866 & 33\,454 & 3.97 \\ {SRTM1-region03} & 50\,401 & 43\,201 & 8.11 \\ {SRTM1-region04} & 82\,801 & 36\,001 & 11.10 \\ {SRTM1-region06} & 68\,401 &111\,601 & 28.44 \\ \hline \end{tabular} \caption{Sample datasets} \label{tbl:datasets} \end{table*} \subsection{Results} Figure~\ref{fig:512mb} shows the total running times of all our algorithms with 512~MiB RAM. First, we note that all our algorithms, being based on I/O-efficient approaches, are scalable to data that is more than sixty times larger than the memory of the machine. This is in contrast with the performance of an internal-memory algorithm, which would start thrashing and could not handle terrains moderately larger than memory, as showed in~\cite{havertoma:visibility-journal}. \textsc{io-radial1}\xspace, \textsc{io-radial2}\xspace and \textsc{io-radial3}\xspace are all based on radial sweeps of the terrain, and theoretically they all use $\Theta(\mathsf{sort}(n))$~I/Os\xspace. In practice, however, both our new algorithms are significantly faster than \textsc{io-radial1}\xspace. On \textrm{Washington} (3.97~GiB), \textsc{io-radial1}\xspace runs in 32,364 seconds with 16\% CPU\footnote{The numbers for \textsc{io-radial1}\xspace are different than the ones reported in~\cite{havertoma:visibility-journal} because the current platform has a slower disk.}, while \textsc{io-radial2}\xspace runs in 13,780 seconds (22\% CPU), and \textsc{io-radial3}\xspace in 3,009 seconds (89\% CPU). This is a speed-up factor of more than 10. \begin{figure}[t] \centering { \includegraphics[height=1.7in]{all-512.pdf} \includegraphics[height=1.7in]{all-peritem-512.pdf} } \caption{Running times with 512MB RAM. (a) Total time (log scale) with dataset size (log scale). (b) Total time per point.} \label{fig:512mb} \end{figure} Both \textsc{io-radial2}\xspace and \textsc{io-radial3}\xspace perform two passes over the elevation grid, however \textsc{io-radial3}\xspace is much faster. On a machine with 512~MiB RAM, on \texttt{SRTM-Region 3} (8.11~GiB), \textsc{io-radial2}\xspace takes 37,982 seconds (16\% CPU), while \textsc{io-radial3}\xspace runs in 6,644 seconds (81\% CPU). Overall, for \textsc{io-radial2}\xspace roughly 20\% of the time is CPU time, while for \textsc{io-radial3}\xspace the CPU utilization is 80\% or more. The difference may be explained by the fact that the first pass of \textsc{io-radial2}\xspace is non-sequential (although it performs $O(n/B)$ I/Os\xspace), while both passes of \textsc{io-radial3}\xspace are sequential. Another difference is that \textsc{io-radial2}\xspace uses the VMM more than \textsc{io-radial3}\xspace. Our third algorithm, \textsc{io-centrifugal}\xspace, is the fastest. It finishes a 28.4 GiB terrain (\texttt{SRTM-Region 6}) in 12,186 seconds (203 minutes), while \textsc{io-radial2}\xspace takes 26,193 seconds (437 minutes). For \textsc{io-radial3}\xspace, 61\% of this time is CPU time, while for \textsc{io-centrifugal}\xspace only 18\%. The reason is that \textsc{io-centrifugal}\xspace does a single pass through the elevation grid. For any grid point $u$, the highest elevation angle of the $O(\sqrt n)$ cells that may be on the line of sight from $v$ to $u$ is retrieved from the horizon array in $O(1)$ time, and the horizon array is maintained in $O(1)$ time per point on average. As a result, \textsc{io-centrifugal}\xspace is CPU-light and the bottleneck is loading the blocks of data into memory. \textsc{io-radial3}\xspace, on the other hand, is more computationally intensive---the highest elevation angle on the line of sight to $u$ needs to be retrieved from a red-black tree in $O(\log n)$ time, and that tree is maintained in $O(\log n)$ time per point. In addition, \textsc{io-radial3}\xspace needs time to sort events. One of our findings is that relying purely on VMM, even for a theoretically I/O-efficient data access, is slow. The analysis of the I/O-efficiency of both \textsc{io-radial2}\xspace and \textsc{io-centrifugal}\xspace is based on the assumption that the VMM will automatically load tiles of size $\Theta(M)$ into memory in the optimal way, and that in practice the performance will not be very different (the theoretical foundations for this assumption were given by~\cite{prokop:cob}). In practice this did not work out so well: a fully cache-oblivious, VMM-based implementation of \textsc{io-centrifugal}\xspace and \textsc{io-radial2}\xspace turned out to be slow. By telling the algorithms explicitly when to load a memory-size block (and not using the VMM), we obtained significant speedups (without sacrificing I/O-efficiency for the levels of caching of which the algorithm remained oblivious, and without sacrificing CPU-efficiency). We believe that we could further improve the running time of \textsc{io-centrifugal}\xspace by having it manage the process of caching in memory the blocks of data that it needs to access from the grid on disk (write its own block manager with LRU policy). Interestingly, our linear interpolation algorithms \textsc{vis-iter}\xspace and \textsc{vis-dac}\xspace are faster than \textsc{io-radial3}\xspace, and slightly slower than \textsc{io-centrifugal}\xspace. For all datasets we found that $n \leq cM^2/B$ for a sufficiently small constant $c$, which means that \textsc{BuildBands} and \textsc{CollectBands} run in a single pass over the data. Thus both algorithms perform two passes over the elevation grid, and a pass over the visibility grid to assemble to visibility bands. The total running time is split fairly evenly between the three phases. The actual visibility calculation runs at 100\% CPU and represents $<$ 25\% of the running time. More than 75\% of the total time is spent reading or writing the bands. In all our tests we found that the iterative algorithm \textsc{vis-iter}\xspace is consistently 10-20\% faster than \textsc{vis-dac}\xspace. To understand this we investigated the size of the horizons computed by \textsc{vis-dac}\xspace and \textsc{vis-iter}\xspace: $H_i$, the horizon of layer $i$; and $H_{1,i}$, the horizon of the points in the first $i$ layers. Note that the number of grid points on level $i$ is $8i$, and the total number of points on levels $1$ through $i$ is $4i^2 + 4i+1 = \Theta(i^2)$. We know that $H_i = O(i) = O(\sqrt n)$, and $H_{1,i} = O(i^2) = O(n)$ (Theorem~\ref{thm:gridhorizon}). We recorded $|H_i|$ and $|H_{1,i}|$ for each layer $i$ during the execution of \textsc{vis-iter}\xspace. Figure~\ref{fig:horizons} shows the results for two datasets; the results for the other datasets look similar. \begin{figure*}[htb] \centering{ \includegraphics[width=6cm]{wash_horizongrowth.pdf} \includegraphics[width=6cm]{region05_horizongrowth.pdf} } \caption{Horizon growth for a viewshed computation on datasets \texttt{Washington} and \texttt{srtm1.region05} } \label{fig:horizons} \end{figure*} We see that $|H_i|$ is very close to its theoretical bound of $8i = \Theta(i)$. As $i$ gets larger the $i$th layers starts to fit only partially in the grid, and this causes $|H_i|$ to drop and have steep variations. The main finding is that for all datasets $H_{1,i}$ stays very small, far below its theoretical upper bound of $\Theta(i^2)$. $H_{1,i}$ grows fast initially and then flattens out; For e.g. on \texttt{Washington} dataset (approx. 1 billion points), $|H_{1,i}|$ flattens at 13,452 points; and on \texttt{srtm1.region05} (approx. 2.5 billion points), $|H_{1,i}|$ flattens at 460 points. All SRTM datasets have the horizon $H_{1,O(\sqrt n)}$ between 132 and 32,689. \begin{figure*}[t] \centering{ \includegraphics[width=6cm]{final_horizon_valid.pdf} \includegraphics[width=6cm]{horizonsum_valid.pdf} } \caption{(a) Size of final grid horizon $ |H_{1,O(\sqrt n)}|$ with dataset size. (b) $\sum_{i=1}^{O(\sqrt n)} |H_{1,i}|$ and $\sum_{i=1}^{O(\sqrt n)} |H_i|$ with dataset size.} \label{fig:finalhorizon} \end{figure*} Given a dataset, we refer to the horizon $ H_{1,O(\sqrt n)}$ as its \emph{final} horizon. Figure~\ref{fig:finalhorizon}(a) shows the size of the final horizon for each dataset as function of the number of \emph{valid} points in the grid ---- this excludes the points in the grid that are labeled as \emph{nodata}, and which are used for e.g. to label the water/ocean; these points do not affect the size of the horizon, as chains of \emph{nodata} points are compressed into a single horizon segment. We see that the final horizon: (1) has a lot of variation especially for the larger SRTM datasets, jumping from low to high values. This is likely due to the position of the viewpoint and possibly the topology of the terrain; (2) the horizon stays small, below $\sqrt n$ for all datasets, far below its worst-case bound of $O(n)$. Figure~\ref{fig:finalhorizon}(b) shows the cumulative sums, $\sum_{i=1}^{O(\sqrt n)} |H_{1,i}|$ and $\sum_{i=1}^{O(\sqrt n)} |H_i|$, for each dataset, as a function of the number of valid points in the grid; we recorded these sums because they come up in the analysis of \textsc{vis-iter}\xspace and can shed light on its performance. In Figure~\ref{fig:finalhorizon} we see that $\sum_{i=1}^{O(\sqrt n)} |H_i|$ grows indeed linearly with the number of valid points in the grid. The sum $\sum_{i=1}^{O(\sqrt n)} |H_{1,i}| $ has a lot of variability similar with the final horizon shown in Figure~\ref{fig:finalhorizon} (a), and for all datasets stays far from its worst-case upper bound of $O(n \sqrt n)$. We note that Figure~\ref{fig:horizons} and \ref{fig:finalhorizon} are based on a single viewpoint, but we expect the results will carry over. Comparing to the work of Ferreira et al.~\cite{ferreira:vis}: Their algorithm, \textsc{TiledVS}, also consists of three passes: convert the grid to Morton order, compute visibility using R2 algorithm, and convert the output grid from Morton order to row-major order. They report on the order of 5,000 seconds with \textsc{TiledVS} for \texttt{SRTM1.region06}, using a similar platform as ours and additional optimization like data compression. Assuming that this time includes all three passes, and modulo variations in setup, it is approx. 2.5 times faster than \textsc{vis-iter}\xspace. We note that \textsc{TiledVS} uses a different model and we believe our algorithms and their analysis are of independent interest. \section{Conclusion}\label{sec:discussion} In this paper we described new I/O-efficient algorithms for computing the visibility map of a point on a grid terrain using several different models. The algorithms are provably efficient in terms of the asymptotic growth behaviour of the number of I/Os, but at the same time are designed to exploit that the terrain model is a grid. This leads to much improved running times compared to our previous work~\cite{havertoma:visibility-journal}. On the largest terrains, using as little as 512~MiB of memory, our algorithms perform at most two passes through the input data, and one pass through the output grid. We were able to compute viewsheds on a terrain of 28.4~GiB in 203 minutes with a laptop-speed hard-drive. The algorithms that compute (what is considered to be) the exact viewshed have inferior worst-case upper bounds, but in practice are faster than the radial-sweep algorithms due to the small size of horizons. We conclude that horizon-based algorithms emerge as a fast approach for computing viewsheds. As avenues for future reesarch we mention the problem of proving a sub-linear bound for the expected complexity of a horizon, and obtaining an output-sensitive viewshed algorithm. \section{Acknowledgments} The authors thank DJ Merill for setting up and administering the platform used for the experiments. And former Bowdoin students Jeremy Fishman and Bob PoFang Wei for working on the earlier versions of this paper. \bibliographystyle{acmtrans}
{'timestamp': '2018-10-05T02:03:04', 'yymm': '1810', 'arxiv_id': '1810.01946', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01946'}
arxiv
\section{Introduction} As E-commerce has grown explosively in recent years, many merchants have been providing some centralized platforms for consumers to buy products with ''One-Click". Although online (card-not-present) type of transactions have offered the great benefit of consumer convenience, it also has increased the high risk of transaction frauds. As a result, merchants unavoidably have to employ many resources to develop an effective and efficient mechanism for fraud detection and transaction risk control. These control systems usually consist of two core engines: a risk scoring engine and a risk control engine. The risk scoring engine is designed to measure the risk level of each transaction. Instead of assigning a transaction with explicit 0-1 (legitimacy - fraud) classification, the majority of merchants calculate the risk score for each transaction based on its attributes, such as purchase price, order quantity, payment information, product market, etc. Whenever a transaction with a higher score is seen, it is more likely to be fraudulent. With the help of big data and machine learning technologies, the modern scoring model has been significantly improved using streaming historical data. The risk control engine gets involved once a risk score is calculated. Some transactions that violate predetermined policies or rules get instantly rejected. These predetermined rules and policies are set due to some governments and merchants made regulations, or they are needed when some obvious frauds require immediate blockade. However, the majority of frauds fail to be restrained by these rules, so the risk control engine needs to step in and further prevent more fraudulent transactions using the risk scores. Conventional risk controls apply static risk cut-off score thresholds: approve transactions with risk scores lower than the low score threshold; reject transactions with scores higher than the high score threshold; utilize human intelligence (manual review) for further investigations on transactions with the risk scores in-between. The cut-off score thresholds are set so that the inline fraud detection system can optimally prevent fraudsters' attacks. This threshold band method is widely applied in e-commerce merchants and financial institutions. Despite the fact that the method of risk score evaluation has been significantly improved during the past few years, due to the following three main reasons decisions made by risk scores are still not always reliable: 1) Rapid changes in fraudsters' behavior patterns; 2) Loss of fraud signals from rejected transactions, and; 3) Long data maturity lead time. Because of these issues, the conventional fraud control engine lacks for flexibility and capability of real-time self-adjustment, and hence cannot always provide the most accurate risk decisions. Our research motivation for this paper stemmed not only from the drawbacks of the current fraud control systems but also from the broader view of various risk control parties who contribute to the final decisions in different transaction flows. Merchants' risk control decision making should not be isolated from the entire decision environment, where payment issuing banks and manual review teams make follow-up decisions that constitute the final decisions on every transaction. Figure \ref{fig:flow} depicts how a transaction is processed through different decision stations until it reaches its final decision. \begin{figure}[hbtp] \centering \includegraphics[scale=0.5]{sys.png} \caption{Transaction flow demonstration} \label{fig:flow} \end{figure} When a transaction arrives, the risk scoring engine calculates its risk level score based on all its associated features.The risk control engine then makes a decision (approval, rejection, MR review) using some important attributes of this transaction (including its risk score). If the transaction is approved by the risk control engine, it is then sent to the bank for the follow-up decision (a bank authorized transaction is marked as \textit{Final Approval}, and a bank declined transaction is marked as \textit{Final Rejection}). If the transaction is rejected by the risk control engine, it is directly marked as {\it{Final Rejection}}. If the transaction is not approved nor rejected by the risk control engine, it would also be sent to the bank first. Only if the bank authorizes the transaction, it has the chance to reach to the manual review (MR) agents for further investigation and for its final decision (a transaction that is authorized by bank and approved is marked as \textit{Final Approval}, and marked \textit{Final Rejection} otherwise). The blue box indicates the target of this research, and the grey boxes point out other involved decision-making parties. Banks are regarded as a single decision party for simplicity. From the data, we found that when the risk control engine approved and submitted transactions that included more frauds (false negative: wrongful approval) to the banks, when banks sensed it, they became more conservative and would decree more rejections of good transactions (false positive: wrongful rejection). Data also showed that when the risk control engine submitted transactions that included fewer frauds (true negative: rightful approval) to the manual review (MR) teams, manual review teams tended to have much harder time to make accurate risk decisions since fraud patterns are less massive and recognizable. Interactions of different decision parties, legitimate customers and fraudsters are demonstrated in Figure \ref{fig:interaction}. \begin{figure}[htbp] \centering \includegraphics[scale=0.42]{interaction.png} \caption{Demonstration of interactions among decision parties and buyers/fraudsters} \label{fig:interaction} \end{figure} Considering the high total dollar amount of e-commerce transactions taking place in this such rapidly changing risk decision environment, there is a strong need to design a fraud control engine that can conquer all the aforementioned challenges and optimize the decision accuracy so that the higher profit can be reached. In this paper, the proposed control framework is designed to achieve the following: \begin{enumerate}[(i)] \item Adaptive learning: the proposed risk control engine is trained using streaming transaction records which might include some incomplete information such as the immature label, and it can adaptively recognize the new decision environment; \item Discriminative control: instead of using static uniform cut-off thresholds, the proposed control system can assign inline decision (Approve, Reject or Manual Review) in a real-time manner based on the attributes of each incoming transaction; \item Data-driven: the risk control is entirely data-driven which helps avoid unreliable ad hoc human-made hard-coding rules on risk decisions. \end{enumerate} The field test on Microsoft real online transaction data suggested that the proposed control system could significantly improve the company's profit by reducing the loss caused by inaccurate decisions (including both wrongful approvals and wrongful rejections). The rest of this paper is structured as follows: In Section \ref{sec:review} previous research work related to fraud control is first outlined and the existence of the research gap is discussed. In Section \ref{sec:problem} the {\it{Perfect State Dynamic Model}} with rigorous mathematical formulation are introduced and the intractableness of the model is then discussed. Three approximate dynamic control models are proposed in Section \ref{sec:control}, and the test results of their performance are included in Section \ref{sec:test}. Section \ref{sec:conclusion} concludes this paper. \section{Related Research}\label{sec:review} Online shopping fraud detection research using machine learning methodologies started from early 90's right after the occurrence of E-commerce, in which the major research task was to evaluate fraud risk levels of transactions. Fraud risk level was measured using risk scores, and thus the research on risk scoring gained widespread attention. These scoring engines were inspired by neural network \cite{GhoshReilly1994FraudDetectionNN,Aleskerov1997FraudDetectionNN,Dorronsoro1997FraudDetectionNN}, decision tree \cite{mena2002FraudDetectionBook,Kirkos2007FraudDetectionDT,Sahin2013FraudDetectionDT}, random forest \cite{Bhattacharyya2011FraudDetectionRF}, network approach \cite{APATE2015FraudDetectionNW} and deep neural network \cite{Kang2016FraudDetectionCNN}. Readers who are interested in this topic may also refer to \cite{Review2011DSS} and references therein for other related papers that discussed different scoring methods. Despite the fact that current research admits the fact that fraud patterns keep changing and fraud risk scores are not always that reliable, no existing papers discuss how to optimally utilize these scores in fraud control operations. On the other hand, data mining papers provide weak guidance in detailed operations, as risk score is indeed a blur expression of fraud. There is currently no literature demonstrating how to deal with the transactions in "gray zone", where the risk score of a transaction is neither too low nor too high. Additionally, no literature has addressed interactions of decisions made by multiple parties for transaction risk control. The main reason of lack of related literature is that e-commerce data are strictly confidential and thus very limited access are granted for academic researches. Our this paper fills the gaps between the transaction fraud evaluation and the systematic risk control operations. Dynamic control research started from the 1940's. We suggest \cite{MDP1994} and \cite{DP1995} for comprehensive introduction to dynamic optimal control methods, as well as their applications in communication, inventory control, production planning, quality control, etc.. In this research, we investigated an important segment of the dynamic control research, dynamic optimal control with incomplete information, as the main technical foundation of our paper which targeted the challenge of some fraud control systems that can only obtain and utilize partially mature data for modeling. One previous related research is Partially Observed Markovian Decision Process (POMDP). POMDP is a sequential decision-making model that deals with inaccurate and incomplete observations of the system state or decision environment. It models/infers transition probability matrix, and the underlying relationship between partially observed and true states (fully observed) information. However, POMDP brings in the significant computational challenges and often requires carefully designed heuristic algorithms to achieve sub-optimal solutions. Structural properties of the reward function and computational algorithms of POMDP are available in \cite{POMDP1973Finite}, \cite{POMDP1978InfiniteDiscount}, \cite{POMDP1980Platzman}, \cite{POMDP1989SolutionProcedureWhite}, \cite{POMDP1991WhiteSurvey}, \cite{POMDP1994AAAI94}, \cite{POMDP1998HeuristicWhite}, \cite{POMDP2004HeuriticWhite} and \cite{POMDP2010Geometric}. Another related research in dynamic control with incomplete information is Adaptive Dynamic Programming (ADP). ADP assumes that perfect information is not known a priori and needs to be gradually learned from historical data or feedback signals of the dynamic system. ADP concepts started from 1970's and contributed as one of the core methods in reinforcement learning. In this paper, we will only highlight a number of papers addressing Actor-Critic structure, one branch of ADP research that is closer in respect to the depth and width of our research. Readers who are interested in ADP should refer to \cite{ADP2009Survey} for a comprehensive review of ADP with respect to theoretical developments as well as application studies. The Actor-Critic structure was first proposed in \cite{ACD1983Sutton}, which suggested an optimal control of learning while improving. Actor-Critic structure implies two steps: an actor applies an action to the environment and receives feedback from a critic; Action improvement is then guided by the evaluation signal feedback. The decision environment feedback is recognized and reinforced after receiving feedback rewards with neural network (\cite{ADPNN1989Werbos},\cite{NNcontrol1991MSW} and \cite{NeuroDP1996}), probabilistic models \cite{RL1998} for bandit, Monto Carlo and Approximate MDP methods) and other stochastic models \cite{SLO2009Cao}. There are two main challenges in solving ADP: (1) curse of dimensionality: as the dimensions of state space and action space get extremely high, a large amount of information must be stored and it makes the computational cost grows explosively \cite{ADPCoD2009}; (2) Implicit form of objective functions: reward/cost function in dynamic control does not have an explicit form, which needs to be carefully approximated \cite{OLADP2013}. Powell introduced several parametric approximation methods to mitigate curse of dimensionality in \cite{ADPCoD2009} . Powell et al. in \cite{OLADP2013} proposed general dynamic control heuristics in ADP, including myopic control and lookahead control with different approximation schemes for cost function and decision environment transition probabilities, while decision environment is learned using local searching, regression or Bayesian methods with either offline or online fashion. Our research is motivated by the current research gap in risk management literatures. Problem formulations in Section \ref{sec:problem} is supported by POMDP literatures, and heuristic solution algorithms are inspired by the ideas in ADP literatures. We studied some realistic issues in fraud control domain, and adapted the general POMDP models and ADP heuristics to fit the structure of fraud control problem. The model and algorithms proposed in this paper are not limited to the application of transaction fraud control, and can be easily extended to other fraud control and defense applications in finance, healthcare, electrical system, robotics, and homeland security. \section{Problem Formulation}\label{sec:problem} In this section, we rigorously formulate the dynamic control model assuming that the state information and the state transition information in the dynamic control model can be exactly characterized. However, the state information and the state transition probabilities in perfect state model, called \eqref{mod:base} in Section \ref{sec:perfect-model}, are not explicit, which need to be approximated from incomplete streaming data. Section \ref{sec:intractable-issue} discusses challenges in solving the dynamic model. \subsection{Perfect State Dynamic Model}\label{sec:perfect-model} We first focus and investigate the expected profit in transaction level, which are the building blocks of the control system. Let $s$, $m$ and $c$ denote risk score, profit margin and costs (cost of goods, manual review costs, chargeback fine, etc.) respectively. $s$ has a finite integral support $[\bar{s}]=\{0,1,...,\bar{s}-1,\bar{s}\}$ with upper bound $\bar{s}$, and $m\in\mathbb{R}$, $c\in\mathbb{R}$ are real numbers. According to system logistics shown in Figure \ref{fig:flow}, profits of approval ($app$), review ($rev$) and rejection ($rej$) of this transaction $w=(s,m,c)$ can be formulated as follow: \begin{align*} R_{app}(w)=&\delta_{w( \text{ Bank Auth. } \cap \text{ Non-fraud})}\cdot m - \delta_{w(\text{ Bank Auth. } \cap \text{ Fraud})}\cdot c\\ R_{rev}(w)=&\delta_{w(\text{ Bank Auth. } \cap \text{ MR App. } \cap \text{ Non-fraud})}\cdot m\\ & - \delta_{w( \text{ Bank Auth. } \cap \text{ MR App. } \cap \text{ Fraud})}\cdot c - \delta_{w( \text{ Bank Auth.})}\cdot c_0\\ R_{rej}(w)=&0 \end{align*} where $c_0$ is unit labor cost for each manual review, and $\delta_{(\cdot)}$ is the indicator function, i.e. given event $H$, \begin{align*} \delta_{(H)}=\left\{ \begin{array}{ll} 1 & \text{if $H$ is true};\\ 0 & \text{if $H$ is false}. \end{array} \right. \end{align*} Given the fact that risk score is a comprehensive evaluation of the risk level, which is estimated using thousands of transaction attributes, we assume that for any two transactions that have the same risk score $s$, i.e. $w=(s,m,c)$ and $w'=(s,m',c')$, the interactive effect of bank or MR are identical, which can be expressed in the mathematical form as, \begin{align} \text{Pr}(H\mid w)=\text{Pr}(H\mid s)=\text{Pr}(H\mid w')\label{equ:score-link} \end{align} With Eq.\eqref{equ:score-link}, the expected profit for each risk operation for transaction $w$ can be derived as \begin{subequations} \begin{align} \mathbb{E}[R_{app}(w)]=&\text{Pr}(\text{Bank Auth. } \cap \text{ Non-fraud} \mid s )\cdot m\notag\\ & - \text{Pr}(\text{Bank Auth. } \cap \text{ Fraud} \mid s)\cdot c \notag\\ =& g_1(s)\cdot m - g_2(s)\cdot c\label{equ:exp-prof-app}\\ \mathbb{E}[R_{rev}(w)]=&\text{Pr}(\text{Bank Auth. } \cap \text{ MR App. } \cap \text{ Non-fraud} \mid s)\cdot m \notag\\ & - \text{Pr}(\text{Bank Auth. } \cap \text{ MR App. } \cap \text{ Fraud} \mid s)\cdot c \notag\\ & - \text{Pr}(\text{Bank Auth.}\mid s)\cdot c_0\notag\\ =& g_3(s)\cdot m-g_4(s)\cdot c -g_5(s)\cdot c_0\label{equ:exp-prof-rev}\\ \mathbb{E}[R_{rej}(w)]=&0.\label{equ:exp-prof-rej} \end{align} \end{subequations} $g$-functions in Eq.\eqref{equ:exp-prof-app}-\eqref{equ:exp-prof-rej} are probabilities of different events given risk score $s$. $g$-function is short for gold function, whose values represent profit-related probabilities associated with different risk decisions. We further delve into a realistic dynamic system, in which banks and MR decision behaviors are changing dynamically. We consider a discrete time dynamic control model with infinite time horizon $\mathcal{T}$. Let $\textbf{w}^{(t)}=\{w^{(t)}_1, w^{(t)}_2,...,w^{(t)}_{N(t)} \}$ be a set of transactions occurred during period $t\in\mathcal{T}$. Elements of this transaction set $w^{(t)}_j=(s^{(t)}_j,m^{(t)}_j,c^{(t)}_j)$ include the risk score $s^{(t)}_j$, margin $m^{(t)}_j$ and costs $c^{(t)}_j$ of this $j$th transaction in period $t$. Let $N^{(t)}$ be the total number of transactions occurred during period $t$, so $N^{(t)}$ is then a random variable. We can then formally define the dynamic control model as follow. \begin{itemize} \item State space: $\mathcal{S}=\{(g_1(s),g_2(s),g_3(s),g_4(s),g_5(s):s\in[\bar{s}]) \}$, which is a set of 5 $g$-functions values at all risk scores. In period $t$, the state can be expressed as $S^{(t)}=(g_1^{(t)}(s),g_2^{(t)}(s),g_3^{(t)}(s),g_4^{(t)}(s),g_5^{(t)}(s): s\in[\bar{s}])$. \item Action space in period $t$: $\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}$, which has $3^{N^{(t)}}$ feasible decision sequences. Let $\textbf{a}^{(t)}=\{a^{(t)}_1, a^{(t)}_2,...,a^{(t)}_{N(t)} \}$ be one feasible action sequence in period $t$, and for the $j$th transaction, risk control engine can choose action $a^{(t)}_j\in\{app,rev,rej\}$. \item State transition probability matrix: $Q(\textbf{a})=[Q_{S,S'}(\textbf{a}):\forall S,S']$, where $Q_{S,S'}(\textbf{a})$ is the probability that system move from state $S$ to state $S'$ when taking action sequence $\textbf{a}$. We assume that $Q(\textbf{a})$ is fixed but implicit through out this paper. \end{itemize} Let $u(S^{(t)})$ be the reward-to-go function at the beginning of period $t$, then this stochastic dynamic model can be formulated with Bellman's equation as \begin{align} u(S^{(t)})=\max_{\textbf{a}^{(t)}\in \mathcal{A}^{(t)}}&\left\{\mathbb{E}\left[\sum_{j=1}^{N^{(t)}} R_{\textbf{a}^{(t)}_j}(w^{(t)}_j,S^{(t)})\right]\right.\notag\\ &\left.+\alpha\cdot \sum_{s^{(t+1)}}Q_{S^{(t)},S^{(t+1)}}(\textbf{a}^{(t)})\cdot u(S^{(t+1)}) \right\} \tag{Perfect} \label{mod:base} \end{align} where $\alpha$ is a discount factor of future rewards, and reward function can be formulated as \begin{align*} R_{\textbf{a}^{(t)}_j}(w^{(t)}_j,S^{(t)})=\left\{\begin{array}{ll} g_1^{(t)}(s^{(t)}_j)\cdot m^{(t)}_j - g_2^{(t)}(s^{(t)}_j)\cdot c^{(t)}_j, & a^{(t)}_j=app\\ g_3^{(t)}(s^{(t)}_j)\cdot m^{(t)}_j-g_4^{(t)}(s^{(t)}_j)\cdot c^{(t)}_j -g_5^{(t)}(s)\cdot c_0, & a^{(t)}_j=rev\\ 0, & a^{(t)}_j=rej \end{array}\right. \end{align*} Throughout the entire paper, we assume that a finite number of transactions occurred in each period, and the reward of each transaction is bounded. Theorem \ref{thm:stationary-optimality} gives the condition that Model \eqref{mod:base} has a unique optimal solution. \begin{theorem}\label{thm:stationary-optimality} If (1) number of transaction occurred in each period is finite and margin/loss from each transaction is bounded, and (2) the arriving process of transactions is stationary, then there exists an optimal profit satisfying \begin{align*} u^*(S)=\max_{\textbf{a}}\left\{\mathbb{E}\left[\sum_{j=1}^{N} R_{\textbf{a}_j}(w_j,S)\right]+\alpha\cdot \sum_{S'}Q_{S,S'}(\textbf{a})\cdot u^*(S') \right\}, \end{align*} and there is a unique solution to this equation. \end{theorem} Theorem \ref{thm:stationary-optimality} is guaranteed by contracting mapping argument and directly follows Theorem 6.2.3 and Theorem 6.2.5 from \cite{MDP1994}. \subsection{Incomplete Information and Intractableness of \eqref{mod:base} Model}\label{sec:intractable-issue} Although Theorem \ref{thm:stationary-optimality} provides solid guidance to find the optimal control strategy, there are several issues of implementing Model \ref{mod:base} in reality. \begin{enumerate}[(1)] \item Exact state information is unavailable: State information, i.e. $g$-functions, can only be inferred using partially mature data, since data maturity lead time is a latent random variable with range $[0, L]$. We have no way to obtain the true time point of maturity for each transaction until the transaction is eventually marked as a chargeback. However, through analyzing the historical data we do have the knowledge that after $L$ periods of time the fraud status (having chargeback or not) should be all mature; \item Reward functions are not entirely exact: Reward functions, $R(\cdot)$, are based on estimations of $g$-functions, and $\textbf{w}^{(t)}$ is not known a priori. Therefore, reward functions could vary due the different estimated $g$-functions and the different $\textbf{w}^{(t)}$; \item Transition probability matrix $Q$ does not have an explicit form: State space $\mathcal{S}$ has extremely high dimension (five $g$-functions estimated at $(\bar{s}+1)$ risk scores); Action space $\mathcal{A}$ has exponential dimension that explosively increase as number of transactions increases ($\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}$ has $3^{N^{(t)}}$ possible decision sequences). \end{enumerate} The lag of data maturity and the curse of dimensionality lead to the fact that Model \eqref{mod:base} is intractable. Thus we propose three approximate dynamic heuristics to obtain suboptimal control decisions. Details of these different control algorithms will be demonstrated in Section \ref{sec:control}. All dynamic control heuristics require a base module which utilizes incomplete information, such as the mature old data and the partially mature recent data, to infer future $g$-functions in these heuristic algorithms. Data mining results suggest that correlations exist between recent $l$ period's partially mature chargeback rate and bank/MR behavior patterns. This fact implies that we should track partially mature chargeback rate of transactions portfolio in period $t-l$, so that $g$-functions can be properly calibrated. This happens to have the same view with business intuitions in multi-party fraud control: If bank and MR learn that recently received transactions have high chargeback rate, they will become more conservative with their decision making by reducing the number of authorization/approval decisions to prevent more undesirable chargebacks. Two decision environment modules, Current Environment Inference (CEI) module and Future Environment Inference (FEI) module, are adopted from \cite{GFunctionEstimation2018TKDE}. Discussion of these two modules are out of the scope of the current paper, we suggest readers refer to \cite{GFunctionEstimation2018TKDE} for details of CEI and FEI modules. CEI and FEI utilize historical data to produce $g$-function estimations, which contribute to the data-driven property of our risk control framework. \section{Dynamic Risk Control Algorithms}\label{sec:control} In this section, we propose three different dynamic risk control algorithms: Naive, Myopic and Prospective control. Naive control is the simplest heuristic algorithm that only uses fully mature data before period $t-L$. Myopic control estimates the current decision environment using CEI module with both mature and immature data in period $t-l$. The most complex control model, Prospective control, further takes into account that current decision will influence not only the current profit but also the near future profit. Three models are demonstrated in Section \ref{sec:naive} - \ref{sec:prospective}. \subsection{Naive control}\label{sec:naive} Figure \ref{fig:naive} depicts decision flow of naive control. At the beginning of period $t$, decision engine uses mature data before period $t-L$ to estimate $g$-functions. \begin{figure}[ht] \centering \includegraphics[scale=0.7]{naive.png} \caption{Naive dynamic control} \label{fig:naive} \end{figure} In period $t\in\mathcal{T}$, let $\hat S^{(t)}$=$(g_1^{(t-L)}(s)$, $g_2^{(t-L)}(s)$, $g_3^{(t-L)}(s)$, $g_4^{(t-L)}(s)$, $g_5^{(t-L)}(s):\forall s)$ be the estimated current state, and $\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}$ be the action space of period $t$. Then feasible action sequence has a form of $a^{(t)}=\{a^{(t)}_1, a^{(t)}_2,...,a^{(t)}_{N^{(t)}} \}$, where $a^{(t)}_j\in\{app,rev,rej\}$. Naive model disregards the future effects. For $N^{(t)}$ transactions take place in period $t$, we need to solve the following model to get action sequence $a^{(t)*}$. \begin{align}\label{mod:naive} \max_{a^{(t)}\in \mathcal{A}^{(t)}}&\mathbb{E} \left[\sum_{j=1}^{N^{(t)}} \hat R_{a^{(t)}_j}(w^{(t)}_j)\right] \tag{Naive-t}\\ s.t.\quad & \mathbb{E}[\hat R_{app}(w_j^{(t)})]=g^{(t-L)}_1(s^{(t)})\cdot m - g^{(t-L)}_2(s^{(t)})\cdot c \notag\\ & \mathbb{E}[\hat R_{rev}(w_j^{(t)})]=g^{(t-L)}_3(s^{(t)})\cdot m - g^{(t-L)}_4(s^{(t)})\cdot c- g^{(t-L)}_5(s^{(t)})\cdot c_0 \notag\\ & \mathbb{E}[\hat R_{rej}(w_j^{(t)})]=0 \notag\\ &\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}\notag \end{align} Naive control repeats this procedure for each period $t$. Theorem \ref{thm:greedy-naive} claims that \eqref{mod:naive} can be easily solved by greedily choosing the decision option that yields the highest expected reward for each incoming transaction. Details about Naive control policy is summarized in Algorithm \ref{alg:naive}. \begin{theorem}\label{thm:greedy-naive} Optimal action sequence $a^{(t)*}$ of \eqref{mod:naive} can be obtained by the greedy algorithm, i.e. for $w_j^{(t)}\in \textbf{w}^{(t)}$, sequentially set \begin{align*} a_j^{(t)*}=\arg\max_{a_j^{(t)}\in\{app,rev,rej\}} \mathbb{E}[\hat R_{a_j^{(t)}}(w_j^{(t)})] \end{align*} \end{theorem} \begin{proof} The rewards of different transactions are independent, and for period $t$, \eqref{mod:naive} can be decomposed into $N^{(t)}$ sub-maximization problems. Thus the greedy algorithm can solve \eqref{mod:naive} exactly. \end{proof} \begin{algorithm}[htbp] \caption{Naive Dynamic Control}\label{alg:naive} Repeat for period $t\in\mathcal{T}$: \begin{algorithmic}[1] \STATE Estimate $g_1^{(t-L)}(s),g_2^{(t-L)}(s),g_3^{(t-L)}(s),g_4^{(t-L)}(s)$ and $g_5^{(t-L)}(s)$ using all the data until the end of period $t-L$, let $\hat S^{(t)}=(g_1^{(t-L)}(s), g_2^{(t-L)}(s), g_3^{(t-L)}(s), g_4^{(t-L)}(s), g_5^{(t-L)}(s):\forall s)$; \FOR {$j=1,2,...,N^{(t)}$} \STATE $a_j^{(t)*}=\arg\max_{a_j^{(t)}\in\{app,rev,rej\}} \mathbb{E}[\hat R_{a_j^{(t)}}(w_j^{(t)})]$. \ENDFOR \end{algorithmic} \end{algorithm} \subsection{Myopic control}\label{sec:myopic} Figure \ref{fig:myopic} shows the decision flow of myopic control. \\ \begin{figure}[ht] \centering \includegraphics[scale=0.7]{myopic.png} \caption{Myopic dynamic control} \label{fig:myopic} \end{figure} This control model is designed to resolve the pattern recognition lag issue due to the delay of data maturity. We adopt CEI module from \cite{GFunctionEstimation2018TKDE} to infer current period decision environments. Mathematically, CEI maps matured $g$-function trajectories ($g^{(t')}_1(s)$, $g^{(t')}_2(s)$, $g^{(t')}_3(s)$, $g^{(t')}_4(s)$, and $g^{(t')}_5(s)$: $t'\le t-L$) and partially mature chargeback rate $\rho_{PCB}^{(t-l)}$ to estimate $g$-functions ($\hat g^{(t)}_1(s), \hat g^{(t)}_2(s), \hat g^{(t)}_3(s), \hat g^{(t)}_4(s)$ and $\hat g^{(t)}_5(s)$) at current period, $t$. \begin{align} \begin{bmatrix} \hat g^{(t)}_1(s)\\ \hat g^{(t)}_2(s)\\ \hat g^{(t)}_3(s)\\ \hat g^{(t)}_4(s)\\ \hat g^{(t)}_5(s) \end{bmatrix} = \begin{bmatrix} \hat \Phi_1^{(t)} \left(s,g^{(t')}_1(s),\rho_{PCB}^{(t-l)}\right)\\ \hat \Phi_2^{(t)} \left(s,g^{(t')}_2(s),\rho_{PCB}^{(t-l)}\right)\\ \hat \Phi_3^{(t)} \left(s,g^{(t')}_3(s),\rho_{PCB}^{(t-l)}\right)\\ \hat \Phi_4^{(t)} \left(s,g^{(t')}_4(s),\rho_{PCB}^{(t-l)}\right)\\ \hat \Phi_5^{(t)} \left(s,g^{(t')}_5(s),\rho_{PCB}^{(t-l)}\right) \end{bmatrix}\tag{CEI} \end{align} where ${\rho}^{t-l}_{PCB}$ is calculated by $${\rho}^{t-l}_{PCB}=\frac{\left(\begin{array}{c} \text{\# of chargeback transactions}\\ \text{in week $t-l$ occurred before week $t$} \end{array}\right)}{\text{(\# of finally approved transactions in week $t-l$)}}.$$ Then for $N^{(t)}$ transactions occurred in period $t$, Myopic Dynamic Control model solves the following model to get action sequence $a^{(t)*}$. \begin{align}\label{mod:myopic} \max_{a^{(t)}\in \mathcal{A}^{(t)}}&\mathbb{E} \left[\sum_{j=1}^{N^{(t)}} \hat R_{a^{(t)}_j}(w^{(t)}_j)\right] \tag{Myopic-t}\\ s.t.\quad & \mathbb{E}[\hat R_{app}(w_j^{(t)})]=\hat g^{(t)}_1(s^{(t)})\cdot m - \hat g^{(t)}_2(s^{(t)})\cdot c \notag\\ & \mathbb{E}[\hat R_{rev}(w_j^{(t)})]=\hat g^{(t)}_3(s^{(t)})\cdot m - \hat g^{(t)}_4(s^{(t)})\cdot c - \hat g^{(t)}_5(s^{(t)})\cdot c_0 \notag\\ & \mathbb{E}[\hat R_{rej}(w_j^{(t)})]=0 \notag\\ &\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}\notag \end{align} CEI module is updated at the beginning of each period and \eqref{mod:myopic} is solved during each period to provide optimal control actions. Theorem \ref{thm:myopic-greedy} provides theoretical guarantee that \eqref{mod:myopic} can be solved by the greedy method. Details of Myopic control policy is summarized in Algorithm \ref{alg:myopic}. \begin{theorem}\label{thm:myopic-greedy} The optimal action sequence $a^{(t)*}$ of \eqref{mod:myopic} can be obtained by the greedy algorithm, i.e. for $w_j^{(t)}\in \textbf{w}^{(t)}$, sequentially set \begin{align*} a_j^{(t)*}=\arg\max_{a_j^{(t)}\in\{app,rev,rej\}} \mathbb{E}[\hat R_{a_j^{(t)}}(w_j^{(t)})] \end{align*} \end{theorem} The proof of Theorem \ref{thm:myopic-greedy} is similar with proof of Theorem \ref{thm:greedy-naive} and thus omitted. \begin{algorithm}[htbp] \caption{Myopic Dynamic Control}\label{alg:myopic} Repeat for period $t\in\mathcal{T}$: \begin{algorithmic}[1] \STATE Calculate $g_1^{(t-L)}(s),g_2^{(t-L)}(s),g_3^{(t-L)}(s),g_4^{(t-L)}(s)$ and $g_5^{(t-L)}(s)$ using all the data until the end of period $t-L$, calculate $\rho^{(t-l)}_{PCB}$ using partially mature data in period $t-l$; \STATE Estimate $\hat g_1^{(t)}(s)$, $\hat g_2^{(t)}(s)$, $\hat g_3^{(t)}(s)$, $\hat g_4^{(t)}(s)$ and $\hat g_5^{(t)}(s)$ using CEI module, and let $\hat S^{(t)}=(\hat g_1^{(t)}(s),\hat g_2^{(t)}(s),\hat g_3^{(t)}(s),\hat g_4^{(t)}(s):\forall s)$; \FOR {$j=1,2,...,N^{(t)}$} \STATE $a_j^{(t)*}=\arg\max_{a_j^{(t)}\in\{app,rev,rej\}} \mathbb{E}[\hat R_{a_j^{(t)}}(w_j^{(t)})]$. \ENDFOR \STATE Re-train and update CEI module. \end{algorithmic} \end{algorithm} \subsection{Prospective control}\label{sec:prospective} Figure \ref{fig:prospective} depicts decision flow of prospective control. \begin{figure}[ht] \centering \includegraphics[scale=0.7]{prospective.png} \caption{Prospective dynamic control} \label{fig:prospective} \end{figure} Prospective control model has a similar CEI module that can diminish pattern recognition lag. In addition, FEI module is adopted from \cite{GFunctionEstimation2018TKDE} to estimate future decision environment change due to the action taken at current period. These environments are characterized by the $g$-functions of period $t$ and $t+l$. Similar with Myopic control, in period $t\in\mathcal{T}$, we use the output of the CEI module as the state estimation, i.e. $\hat S^{(t)}=(\hat g_1^{(t)}(s),\hat g_2^{(t)}(s),\hat g_3^{(t)}(s),\hat g_4^{(t)}(s),\hat g_5^{(t)}(s):\forall s)$. Action space of period $t$ is still $\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}$. While different from previous two control models, prospective control considers future effects caused by the current decisions: the action sequences will play a role on the behavior patterns of bank and MR in period $t+l$. For $N^{(t)}$ transactions occurred in period $t$, we need to solve the following model to get our action sequence $a^{(t)*}$. \begin{align}\label{mod:prospective} \max_{a^{(t)}\in \mathcal{A}^{(t)}}&\mathbb{E} \left[\sum_{j=1}^{N^{(t)}} \hat R_{a^{(t)}_j}(w^{(t)}_j)\right]+ \lambda\cdot \Delta \tag{Prospective-t}\\ s.t.\quad & \mathbb{E}[\hat R_{app}(w_j^{(t)})]=\hat g^{(t)}_1(s_j^{(t)})\cdot m_j^{(t)}- \hat g^{(t)}_2(s_j^{(t)})\cdot c_j^{(t)},\ \forall j \notag\\ & \mathbb{E}[\hat R_{rev}(w_j^{(t)})]=\hat g^{(t)}_3(s_j^{(t)})\cdot m_j^{(t)}\notag - \hat g^{(t)}_4(s_j^{(t)})\cdot c_j^{(t)} - \hat g^{(t)}_5(s_j^{(t)})\cdot c_0,\ \forall j \notag\\ & \mathbb{E}[\hat R_{rej}(w_j^{(t)})]=0,\ \forall j \notag\\ &\mathcal{A}^{(t)}=\{app, rev, rej\}^{N^{(t)}}\notag \end{align} where $\lambda$ is a discount factor, and $\Delta$ is a reference future profit of period $t+l$. A reference sample from mature control group is bootstrapped from mature data set in order to provide reference future profit $\Delta$. Let this reference transaction set sample be $\tilde{\textbf{w}}^{(t+l)}=\{\tilde w_1^{(t+l)},\tilde w_2^{(t+l)},...,w_m^{(t+l)} \}$ with $m$ elements. FEI module includes two sub-procedures: \begin{enumerate}[(1)] \item Calculate estimated chargeback rate of period $t$, $\rho^{(t)}_{CB}$: at a given time point during period $t$, suppose we have received $n'$ transaction request, and our decision action sequence is $(a^t_1,...,a^t_{n'})$, we can then estimate charge back rate of period $t$, \begin{align}\label{equ:rho-estimation} \hat \rho^{(t)}_{CB}=\frac{1}{\sum_{j=1}^{n'}\delta_{(a^t_j\neq Rej.)}}\left(\sum_{j=1}^{n'} \hat g^t_2(s^t_j)\cdot\delta_{(a^t_j=App.)}+\sum_{j=1}^{n'} \hat g^t_4(s^t_j)\cdot\delta_{(a^t_j=Rev.)} \right) \end{align} where $\delta_{(\cdot)}$ is the indicator function. \item Predict future $g$-functions ($g^{(t+l)}_1(s)$, $g^{(t+l)}_2(s)$, $g^{(t+l)}_3(s)$, $g^{(t+l)}_4(s)$ and $g^{(t+l)}_5(s)$) with matured $g$-function trajectories ($g^{(t')}_1(s)$, $g^{(t')}_2(s)$, $g^{(t')}_3(s)$, $g^{(t')}_4(s)$, and $g^{(t')}_5(s)$: $t'\le t-L$) and estimate weekly full chargeback rate $\rho_{CB}^{(t)}$. FEI is trained with mature data and \begin{align}\label{equ:fei} \begin{bmatrix} \hat g^{(t)}_1(s)\\ \hat g^{(t)}_2(s)\\ \hat g^{(t)}_3(s)\\ \hat g^{(t)}_4(s)\\ \hat g^{(t)}_5(s) \end{bmatrix} = \begin{bmatrix} \hat \Psi_1^{(t)} \left(s,g^{(t')}_1(s),\hat \rho_{CB}^{(t)}\right)\\ \hat \Psi_2^{(t)} \left(s,g^{(t')}_2(s),\hat \rho_{CB}^{(t)}\right)\\ \hat \Psi_3^{(t)} \left(s,g^{(t')}_3(s),\hat \rho_{CB}^{(t)}\right)\\ \hat \Psi_4^{(t)} \left(s,g^{(t')}_4(s),\hat \rho_{CB}^{(t)}\right)\\ \hat \Psi_5^{(t)} \left(s,g^{(t')}_5(s),\hat \rho_{CB}^{(t)}\right) \end{bmatrix}\tag{FEI} \end{align} \end{enumerate} \eqref{mod:prospective} is hard to solve due to high dimension of $a^{(t)}$ and non-analytic form of $\Delta$. A similar real-time updated greedy heuristic is introduced to obtain a sub optimal solution for \eqref{mod:prospective}. This Real-time Greedy Heuristic (RGH) allows us to update estimation of $\hat \rho^{(t)}_{CB}$ on the fly and to adjust our strategy within period $t$. Figure \ref{fig:rgh} illustrates the logics of RGH within period $t$. \\ \begin{figure}[h] \centering \includegraphics[scale=0.8]{rgh.png} \caption{Real-time greedy heuristic demonstration}\label{fig:rgh} \end{figure} Let time $\tau$ be a decision time point in period $t$ where transaction $w^{(t)}_{n_1+1}$ occurs and risk team needs to make decision either to approve, reject or manual review this transaction. Suppose from $s_t$, starting point of period $t$, to current decision point $\tau$, we have observed $n_1$ transactions. Hence, we can estimate the chargeback rate of period $t$, if we approve, review or reject $w^{(t)}_{n_1+1}$ using Eq. \eqref{equ:rho-tau}. \begin{align}\label{equ:rho-tau} \hat \rho^{(t)}_{CB}(\tau)=\frac{1}{\sum_{j=1}^{n_1+1}\delta_{(a^t_j\neq Rej.)}}\left(\sum_{j=1}^{n_1+1} \hat g^t_2(s^t_j)\cdot\delta_{(a^t_j=App.)}+\sum_{j=1}^{n_1+1} \hat g^t_4(s^t_j)\cdot\delta_{(a^t_j=Rev.)} \right) \end{align} We further estimate the expected reward of approval, review or rejection of $w^{(t)}_{n_1+1}$. Note that the future effect is first averaged to reward per transaction and then discounted by a factor of $\lambda$. \begin{subequations}\label{equ:f-profit} \begin{align} &R^{F}_{app}(w^{(t)}_{n_1+1})=\mathbb{E}[\hat R_{app}(w^{(t)}_{n_1+1})]+\frac{\lambda}{m}\Delta_{\tau,app}\\ &R^{F}_{rev}(w^{(t)}_{n_1+1})=\mathbb{E}[\hat R_{rev}(w^{(t)}_{n_1+1})]+\frac{\lambda}{m}\Delta_{\tau,rev}\\ &R^{F}_{rej}(w^{(t)}_{n_1+1})=\mathbb{E}[\hat R_{rej}(w^{(t)}_{n_1+1})]+\frac{\lambda}{m}\Delta_{\tau,rej} \end{align} \end{subequations} and for $a\in\{app,rev,rej\}$, \begin{align}\label{equ:delta-estimation} \Delta_{\tau,a}=\\ \max_{a^{(t+l)}\in \tilde{\mathcal{A}}^{(t+l)}}&\mathbb{E} \left[\sum_{k=1}^{m} \hat R_{a^{(t)}_k}(\tilde w^{(t+l)}_k)\right]\notag\\ s.t.\quad & \mathbb{E}[\hat R_{app}(\tilde w_k^{(t+l)})]=\hat g^{(t+l)}_1(\tilde s^{(t+l)}_k)\cdot\tilde m^{(t+l)}_k - \hat g^{(t+l)}_2(\tilde s^{(t+l)}_k)\cdot\tilde c^{(t+l)}_k, \notag\\ & \mathbb{E}[\hat R_{rev}(\tilde w_k^{(t+l)})]=\hat g^{(t+l)}_3(\tilde s^{(t+l)}_k)\cdot\tilde m^{(t+l)}_k - \hat g^{(t+l)}_4(\tilde s^{(t+l)}_k)\cdot\tilde c^{(t+l)}_k \notag\\&\qquad - \hat g^{(t+l)}_5(\tilde s^{(t+l)}_k)\cdot c_0,\notag\\ & \mathbb{E}[\hat R_{rej}(\tilde w_k^{(t+l)})]=0,\notag\\ & \tilde{\mathcal{A}}^{(t+2)}=\{app, rev, rej\}^{m}\notag \end{align} where $\hat \rho_{CB}^{(t)}(\tau)$ are calculated using Eq. \eqref{equ:rho-tau}, and $\hat g^{(t+l)}_{(\cdot)}$ is derived by \eqref{equ:fei}. RGH sequentially assigns action that has the largest prospective reward to each incoming transaction. For $w^{(t)}_j\in \textbf{w}^{(t)}$, we sequentially set \begin{align}\label{equ:rgh} a^{(t)*}_j=\arg\max_{a^{(t)}_j\in\{App.,Rev.,Rej.\}}R^{F}_{a^{(t)}_j}(w^{(t)}_j).\tag{Prospective-RGH} \end{align} Prospective control algorithm is summarized in Algorithm \ref{alg:prospective}. \begin{algorithm}[htbp] \caption{Prospective Dynamic Control}\label{alg:prospective} Repeat for period $t\in\mathcal{T}$: \begin{algorithmic}[1] \STATE Calculate $g_1^{(t-L)}(s),g_2^{(t-L)}(s),g_3^{(t-L)}(s),g_4^{(t-L)}(s)$ and $g_5^{(t-L)}(s)$ using all the data until the end of period $t-L$, calculate $\rho^{(t-l)}_{PCB}$ using partially mature data in period $t-l$; \STATE Estimate $\hat g_1^{(t)}(s)$, $\hat g_2^{(t)}(s)$, $\hat g_3^{(t)}(s)$, $\hat g_4^{(t)}(s)$ and $\hat g_5^{(t)}(s)$ using CEI module, and let $\hat S^{(t)}=(\hat g_1^{(t)}(s),\hat g_2^{(t)}(s),\hat g_3^{(t)}(s),\hat g_4^{(t)}(s):\forall s)$; \STATE Initialize $\hat g_1^{(t+2)}(s)$, $\hat g_2^{(t+2)}(s)$, $\hat g_3^{(t+2)}(s)$, $\hat g_4^{(t+2)}(s)$ and $\hat g_5^{(t+2)}(s)$ by setting them equal to $\hat g_1^{(t)}(s)$, $\hat g_2^{(t)}(s)$, $\hat g_3^{(t)}(s)$, $\hat g_4^{(t)}(s)$ and $\hat g_5^{(t)}(s)$ respectively; \FOR {$j=1,2,...,N^{(t)}$} \STATE Calculate $\hat \rho_{CB}^{(t)}(\tau_j)$ for $a_j^{(t)}\in\{app,rev,rej\}$ using Eq.\eqref{equ:rho-tau}; \STATE Calculate future reference profits $\Delta_{\tau,a}$ using Eq.\eqref{equ:delta-estimation}; \STATE Calculate prospective profits $\hat R^F_{a_j^{(t)}}(w^{(t)}_j)$ and set $$a_j^{(t)*}=\arg\max_{a_j^{(t)}\in\{app,rev,rej\}} \mathbb{E}[\hat R^F_{a_j^{(t)}}(w^{(t)}_j)].$$ \STATE Update chargeback rate estimation $\hat \rho^{(t)}_{CB}$ using Eq.\eqref{equ:rho-estimation}, and calculate $\hat g_1^{(t+2)}(s)$, $\hat g_2^{(t+2)}(s)$, $\hat g_3^{(t+2)}(s)$, $\hat g_4^{(t+2)}(s)$ and $\hat g_5^{(t+2)}(s)$. \ENDFOR \STATE Re-train and update CEI and FEI modules. \end{algorithmic} \end{algorithm} \section{Field Tests on Microsoft E-commerce}\label{sec:test} Field tests were conducted to exam the performances of these three dynamic models. Testing dataset was extracted from a sub-unit of Microsoft E-commerce business. We sample no more than 3\% of total transactions as the testing data set. For transactions in the testing set, we recorded decisions in our database while we flipped all final rejected transactions to final approval, so that we could obtain unbiased chargeback signals for model training and profit calculation. We set the length of the testing period to one week and tested all dynamic control model paralleling with current Microsoft inline decision engine. Our data indicated that maximum lead time for the data maturity was $L=12$, and the recent partially mature reference time was $l=2$. The testing time window is 14 weeks, and the bank and MR decisions for each transaction are kept identical for different control methods to ensure apple-to-apple comparison. The historical data continued to be maturing while the testing time moved forward. For Naive and Myopic controls, the risk decision engine was updated weekly ($g$-functions and (CEI) module was retrained at the beginning of each period). For Prospective control, the risk decision engine refreshed the belief of current $g$-functions, (CEI) module and (FEI) module once a week, while estimations of current week chargeback rate and future $g$-functions in real-time were updated. Due to the Microsoft's confidentiality requirements, the name of the E-commerce sub-unit is muted, and this section only includes the summarized feature values that were aggregated over a 14-week of transaction period to demonstrate the usability of Naive, Myopic and Prospective control models. The discount factor $\lambda$ in Prospective control model was tuned using $K$-fold cross validation at the beginning of the testing and is a fixed valued, $0.12$, throughout the 14 week testing periods. \begin{figure}[htbp]% \centering \subfloat[\# of approve]{% \label{fig:n-app}% \includegraphics[scale=0.5]{result1_1.png}}% \subfloat[\# of review]{% \label{fig:n-rev}% \includegraphics[scale=0.5]{result1_2.png}}% \subfloat[\# of reject]{% \label{fig:n-rej}% \includegraphics[scale=0.5]{result1_3.png}}% \caption{Counts of Different Types of Risk Decisions Madevolume}\label{fig:n-decision} \end{figure} We first studied numbers of different risk control operations (approve, review, and reject) out of total testing transactions. Figure \ref{fig:n-decision} summarizes counts of different risk control decisions made by the current Microsoft's decision engine and three proposed dynamic control engines. Over the 14 weeks testing period, the dynamic control engines gradually captured the decision accuracy of the manual review group. All of the three models learned the fact that manual review agents overly rejected non-fraud transactions, and thus started to cut off the volume of transactions submitted to the manual review team. Figure \ref{fig:n-app} suggests that all three dynamic models approved more transactions than the current decision engine did. We can see later that these dynamic models also enhanced decision accuracy significantly in Figure \ref{fig:fn-fp-mr}: the dynamic control models not only approved more non-fraud transactions but also approved fewer fraud transactions. All three models suggest sending fewer transactions for manual review. Naive control aggressively decreased review volume to only 10\% of the review volume suggested by current Microsoft's decision engine, while Myopic and Prospective control mildly decreased review volume to roughly 30\% of the original volume. As for the decision of rejection, Naive control increased rejection volume by about 12\%, while Myopic and Prospective control decreased rejection volume by 12.5\% and 9\% respectively. We can also observe the fact that Myopic and Prospective control models again enhanced decision accuracy in Figure \ref{fig:fn-fp-mr} by rejecting much fewer non-fraud transactions but more fraud transactions. Numbers of performance measures were used to validate the decision quality of a risk control engine. First, we investigated the decision quality by comparing the losses caused by wrong decisions. Two common performance metrics for this are false negative (FN) loss and false positive (FP) loss. FN loss measures the total loss of approving fraud transactions (wrongly approval), which consists cost of goods and all related fees of chargeback. On the other hand, FP loss measures the total loss of rejecting non-fraud transactions (wrongly rejection), and it includes all the margins that should have been but not earned. We then checked the manual review (MR) cost, which is the total labor cost of the human review team. We found that when the risk engine submitted transactions that included fewer frauds (true negative: rightful approval) to the manual review teams, manual review teams tended to have a much more difficult time to make accurate risk decisions since fraud patterns are less massive and recognizable. Therefore, with more transactions sent to manual review teams, not only more labor costs will arise, but the decision accuracy instability will likely to increase. Figure \ref{fig:fn-fp-mr} summarizes aggregated improvement on FN loss, FP loss and MR cost on the selected testing data set. \begin{figure}[htbp]% \centering \subfloat[FN loss difference in \%]{% \label{fig:fn}% \includegraphics[scale=0.55]{result2_1.png}}% \subfloat[FP loss difference in \%]{% \label{fig:fp}% \includegraphics[scale=0.55]{result2_2.png}}% \subfloat[MR cost difference in \%]{% \label{fig:mr}% \includegraphics[scale=0.55]{result2_3.png}}% \caption{Aggregated improvement on FN loss, FP loss and MR cost}\label{fig:fn-fp-mr} \end{figure} Figure \ref{fig:fn} shows the fact that all three dynamic control methods made better "approval" decisions by producing fewer FN losses. Naive, Myopic and Prospective control model decreases FN loss by 8.48\%, 7.32\%, and 7.55\% respectively. Figure \ref{fig:fp} suggests that Naive control model is relatively aggressive which rejected more non-fraud transactions and yielded 9.49\% more FP losses. Meanwhile, Myopic and Prospective control mildly decrease FP loss by 4.73\% and 3.05\% respectively, and these two dynamic control methods make more correct rejections. As mentioned earlier, all dynamic decision engine found that MR had limited accuracy in detecting fraud. In this way, Naive, Myopic and Prospective control model deceased transactions submit for review by 93.0\%, 64.2\%, and 64.7\%. Second, we compare the differences of total profits and total chargeback rates among three dynamic control methods and current Microsoft's risk control method. Providing higher profit is the ultimate goal for business operations. While on the other hand, risk control team also needs to ensure the new dynamic control methods do not escalate the chargeback rate for merchants. We need to ensure that proposed dynamic control methods can produce higher profit but not increase (or even lower) the chargeback rate.\\ \begin{table}[htbp] \centering\caption{Aggregated performance improvements in profit and chargeback rate} \begin{tabular}{|c|c|c|c|} \hline & Naive & Myopic & Prospective \\ \hline \begin{tabular}[c]{@{}c@{}}14 week aggregated\\ improvement on\\ testing set (\$)\end{tabular} & + \$ 79,962 & + \$ 97,863 & + \$ 96,693 \\ \hline \begin{tabular}[c]{@{}c@{}}Estimated annual\\ improvement on\\ selected sub-department (\$)\end{tabular} & + \$ 9,900,071 & + \$ 12,116,318 & + \$ 11,971,568 \\ \hline \begin{tabular}[c]{@{}c@{}}Relative chargeback\\ rate difference (\%)\end{tabular} & -0.72\% & -1.64\% & -2.98\% \\ \hline \end{tabular} \label{tbl:profit-cb} \end{table}\\ Table \ref{tbl:profit-cb} summarizes insights of improvements in overall profit and chargeback rate. The first row of Table \ref{tbl:profit-cb} includes profit improvement on the testing set calculated by $(\text{TotalProfit}_{(\text{Dynamic})}-\text{TotalProfit}_{(\text{Microsoft})})$. The second row extrapolates total profit from training set to an estimated annual improvement on the selected sub-unit. The third row reports the relative differences in proportion on chargeback rates, calculated by \[\dfrac{\text{chargeback rate}_{\text{(Dynamic)}}-\text{chargeback rate}_{\text{(Microsoft)}}}{\text{chargeback rate}_{\text{(Microsoft)}}}. \] Over the 14 week testing period, Naive control contributed \$79,962 more on the testing portfolio while maintained a similar chargeback rate with current Microsoft risk decision engine had. Naive control decreased chargeback rate slightly by only 0.72\% of Microsoft's current chargeback rate. Myopic control contributed to the largest profit improvement for \$97,863 on the testing set. Meanwhile, Myopic control decreased chargeback rate relatively for 1.64\%. Finally, for Prospective control, it produced \$96,693 more profit on the testing transaction set, while provided the largest improvement on chargeback rate by decreasing chargeback rate by 2.98\%. The estimated annual improvements for Naive, Myopic and Prospective control on selected sub-unit were \$ 9,900,071, \$ 12,116,318, and \$ 11,971,568 respectively by extrapolation. We conclude this section with a few business takeaways. We have seen that all three models have potentials for significantly improving company profit while slightly decreasing chargeback rates. All three dynamic models enhanced decision qualities by decreasing FN losses, FP losses and MR costs. Although Naive control model performed relatively aggressive in rejecting transactions, Myopic and Prospective control made better rejection decisions by rejecting fewer non-fraud transactions. All three dynamic methods had great performance with approving more non-fraud transactions and rejecting more fraud transactions. Artificial intelligence modules in these dynamic control models were well developed, and outperformed human review agents one most of the fraud decisions. Manual review volumes decreased as expected, and hence MR labor costs were reduced significantly. \section{Conclusion and Future Study}\label{sec:conclusion} To minimize ad hoc human-made decision, and improve the accuracy and robustness of the risk decision making, we investigated how to reach the optimal action when if complete information is available. We defined our problem rigorously, characterized all profit related components in the current system and investigated decision interactions between three different decision-making parties. We acknowledged the fact that perfect information is unavailable in reality and thus we designed three data-driven dynamic optimal control models, Naive control, Myopic control, and Prospective control. These control models are 100\% data-driven and self-trained/adapted in a real-time manner. As demonstrated, these dynamic control models helped increase the profit significantly by minimizing false negative loss, false positive loss, and manual review costs by employing incomplete information, including long-term and short-term mature and partially-mature data. Meanwhile, the proposed control models also slightly lowered chargeback rates as desired. The field test on sub-unit of Microsoft E-commerce suggested that the discriminative dynamic control models had better fraud detection performance than the current general score cut-off control. The research proposed in this paper can contribute greatly to both theoretical and applied research on fraud detection for the systems that have problems with incomplete information and decision looping effect due to multiple decision parties. Its application is not limited to financial risk systems, but can also be used for application and research in cyber-security, homeland security, contagion disease screens etc.. Our future research will include information sharing and information fusion. We will extend this current research to more complex and realistic settings, where information sources are shared at different levels among different risk control decision parties. \section*{Acknowledgments and Funding Sources} This research was supported by Microsoft, Redmond, WA. The authors are thankful to researchers and members from Microsoft Knowledge and Growth group for providing data and their knowledge of the system.
{'timestamp': '2019-07-30T02:11:18', 'yymm': '1810', 'arxiv_id': '1810.01982', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01982'}
arxiv
\section*{References}} \def
{'timestamp': '2018-10-05T02:10:04', 'yymm': '1810', 'arxiv_id': '1810.02142', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02142'}
arxiv
\section{Introduction} Cardiovascular magnetic resonance (CMR) imaging is the reference technique regarding several applications for the anatomical and functional assessment of the heart \cite{Zhuang2011a}. While fast SSFP sequences allow the direct acquisition of an anatomical 3D image (A3D) of the whole heart, they are usually limited by either relatively poor image quality or low temporal resolution, making them often unsuitable for accurate functional assessment. The most common CMR sequence currently used in the clinical practice is still the short axis (SA) SSFP cine, consisting of 10-14 parallel slices and 20-30 frames per cardiac cycle. SA cine stacks are generated during multiple breath-holds (i.e. 1-3 slices acquired per each breath-hold). Although the subjects are instructed to hold their breath at the same breath-hold position, in practice the heart location can vary considerably. If the differences between the breath-hold positions are large, the acquired image stack will be affected by inter-slice motion and not correctly represent the cardiac volume, introducing potential errors in the following analyses and visualisations. \noindent \textbf{Related Work.} Several approaches for SA stack motion correction (MC) have been proposed in the literature. Among the techniques that make use of routinely acquired CMR images, Lotjonen et al. \cite{Lotjonen2004a} proposed to perform in-plane rigid registration of each SA slice to LA images, used as target. Sinclair et al. \cite{Sinclair2017} implemented a similar approach using LV segmentations (obtained using a fully-convolutional neural network, FCN) instead of the actual images. A very similar technique was also developed by Yang et al. \cite{Yang2017}, which also included a shape model to better retrieve the actual motion of the myocardium throughout the cardiac cycle. An alternative approach, which has the advantage of being applicable even if LA images are not available, consists in implicitly incorporating correct representations of the heart into a model trained from motion-free stacks, and in using it to perform motion correction. For instance, Oktay et al. \cite{Oktay2016} proposed to associate each SA slice with a set of probabilistic edge maps (PEMs) outlining the myocardial contours in the same slice as well as in the adjacent one, and to then perform rigid registration between the obtained PEMs. \noindent \textbf{Contributions.} In this paper, we propose a comprehensive approach to automatically correct inter-slice respiratory motion in SA CMR image stacks. Our approach makes use of probabilistic segmentation maps (PSMs) of the left ventricular (LV) cavity generated with hybrid decision forests. PSMs are generated for each slice of the SA stack and rigidly registered in-plane to a target PSM. The main contributions of the paper are the following: \begin{itemize} \item The proposed approach includes two different techniques: if LA images are available, PSMs are generated from them and combined to create the target PSM. If not, the target PSM is produced from the same stack using a 3D model trained from motion-free stacks; \item If LA images are available, the hybrid forests estimate from them at once both PSMs and landmarks locations for the apex and the mitral valve, which are used to restrict motion correction to the slices of the SA stack between them, thus limiting potential spurious results especially in the basal region; \item The proposed approach was tested on a dataset acquired from 24 healthy subjects (for which anatomical 3D cardiac images were also available as reference) and compared to two techniques which use LA intensity images and LA segmentations (generated using FCNs) as targets, respectively. Testing was also performed after training the techniques on a different dataset to assess their generalisation properties. \end{itemize} \section{Methods} \noindent \textbf{Hybrid Decision Forests.} A decision tree consists in the combination of split and leaf nodes arranged in a tree-like structure \cite{Criminisi2011}. Decision trees route a sample $\bm{x} \in \mathcal{X}$ (in our case an image patch) by recursively branching left or right at each split node $j$ until a leaf node $k$ is reached. Each leaf node is associated with a posterior distribution $p(y|\bm{x})$ for the output variable $y \in \mathcal{Y}$. Each split node $j$ is associated with a binary split function $h(\bm{x},\bm{\theta}_j) \in \{0,1\}$, defined by the set of parameters $\bm{\theta}_j$. During training, at each node the goal is to find the set of parameters $\bm{\theta}_j$ which maximizes a previously defined \emph{information gain} $I_j$, that is usually defined as $I_j = H(S_j) - \sum_{i \in \{0,1\}} \nicefrac{|S_j^i|}{|S_j|}\cdot H(S_j^i)$, where $S_j$, $S_j^0$ and $S_j^1$ are respectively the training set arriving at node $j$, leaving the node to the left and to the right. $H(S)$ is the entropy of the training set, whose construction depends on the task at hand (e.g. classification, regression). Different types of nodes (maximizing different information gains) can be interleaved within a single tree structure, thus called hybrid. In the present technique structured classification nodes (aiming at the generation of a PSM of the LV cavity) and regression nodes (aiming at landmark localisation) are combined \cite{Oktay2017}. During testing, the posterior distributions of the different trees are combined using an ensemble model. Structured classification nodes associate to each image patch $\bm{x}$ a label $\bm{y} \in \mathcal{Y}$ consisting of a segmentation of the LV cavity within $\bm{x}$. Structured labels at each split node can be clustered into two subgroups depending on some similarity measure between them following a two-step procedure \cite{Dollar2015}. First, $\mathcal{Y}$ is mapped to an intermediate space $\mathcal{Z}$ by means of the function $\Pi: \mathcal{Y} \rightarrow \mathcal{Z}$ where the distance between labels can be computed. Then, PCA is applied to the vectors $\bm{z}$ to map the associated labels $\bm{y}$ into a binary set of labels $c \in \mathcal{C}$ $ = \{0,1\}$: this is achieved by applying a binary quantization to the principal component of each $\bm{z}$ vector. Finally, the Shannon entropy $H_{SC}(S) = - \sum_{c \in \mathcal{C}} p(c)log\big(p(c)\big)$ can be adopted, with $p(c)$ indicating the empirical distribution extracted from training set at the each node. Differently from \cite{Oktay2017}, in which edge maps were generated, to estimate segmentation maps we adopted the mapping \begin{equation*} \Pi: \bm{z} = [\bm{y}(j_1)=\bm{y}(j_2)=0] \oplus [\bm{y}(j_1)=\bm{y}(j_2)=1] \qquad \forall j_1 \neq j_2, \label{eq_discretize_psm} \end{equation*} where $j_1$ and $j_2$ are indices spanning every pixel in $\bm{y}$. This mapping encodes for each pair of pixels in $\bm{y}$ whether they are both equal to 0 and whether they are both equal to 1, allowing the correct clustering of the labels at each node based on their similarity. At testing time, each sample patch of the test image is sent down each tree of the forest, and the segmentation maps stored at each selected leaf node are averaged producing a smooth segmentation map (PSM) of the LV cavity. The values in the PSM are proportional to the certainty in LV cavity detection, and can be used to assess the reliability of the prediction. Regression nodes associate to each image patch $\bm{x}$ a label $\mathcal{D} = (\bm{d}^1, \bm{d}^2, \dotsc, \bm{d}^L)$, where $\bm{d}^l$ represents for each of the $L$ landmarks (LMs) the $N$-dimensional displacement vector from the patch centre to the landmark location \cite{Oktay2017}. The information gain used for regression nodes minimizes the determinant of the full covariance matrix $|\Lambda(S)|$ defined by the landmark displacement vectors: $H_{R}(S) = \frac{1}{2} log\big((2\pi e)^d|\Lambda(S)|$. The regression information is stored at each leaf node $k$ using a parametric model following a $N\cdot L$-dimensional multivariate normal distribution with $\overline{\bm{d}_k^l}$ and $\Sigma_k^l$ mean and covariance matrices, respectively. At testing time, for each landmark, Hough vote maps are generated by summing up the regression posterior distributions obtained from each tree for each patch \cite{Oktay2017}. Finally, the locations of the landmarks are determined by identifying the pixel with the highest value on each of the $L$ Hough vote maps. For training, the extracted features are multi-resolution image intensity, histogram of gradients (HoG) and gradient magnitude, exactly as in \cite{Oktay2017}. The described hybrid random forest approach is used to build several models: three for LA images (extracting at once PSMs and landmarks for the apex and the mitral valve) and two for the SA stacks (extracting 2D and 3D PSMs, respectively). These models are then used to perform motion correction with two different possible pipelines, depending on the availability of LA images. \begin{figure}[t!] \centering \includegraphics[width=0.8\textwidth]{Fig1.pdf} \caption{Pipeline for motion correction using LA PSMs as target.} \label{fig1} \end{figure} \noindent \textbf{Motion Correction with LA PSMs (MC LA PSMs).} This method relies on 2D SA PSMs generated from the motion-corrupted stack and on LA PSMs (together with landmarks), which are used as target (see Fig. \ref{fig1}). First, LA PSMs are rigidly registered (by 3D translation only, using normalized cross-correlation, NCC, as similarity metric) to the SA PSM stack to compensate for potential motion between different acquisitions. Then, for each slice of the SA PSM stack, the three registered LA PSMs are resampled and combined into a single image (referred to as LA PSM combined) containing the sections of the LA PSMs with respect to a specific slice. Finally, in-plane rigid registration (by translation only, using NCC) is performed between each SA PSM slice and the associated LA PSM combined, and the estimated translation is applied to the SA slice, thus performing the correction. These two steps (LA PSMs registration to the SA PSMs stack, and slice-by-slice SA PSMs registration to LA PSMs combined) are iterated until the maximum translation estimated within the stack is less than two pixels, which usually happens within the first 4 iterations. While this iterative registration scheme is similar to previously published ones \cite{Sinclair2017}, a major novelty is that not all the slices of the SA stack actually undergo motion correction: a slice is corrected only if a) its peak PSM value is above a threshold $T_m$ and b) it lies between the median apex and median mitral valve points (defined as medians of the landmark sets identified on the LA images). This allows the exclusion of slices outside the LV or with unreliable LV cavity detection. \begin{figure}[t!] \centering \includegraphics[width=0.78\textwidth]{Fig2.pdf} \caption{Pipeline for motion correction using a 3D SA PSM as target.} \label{fig2} \end{figure} \noindent \textbf{Motion Correction with 3D SA PSMs (MC 3D PSMs).} This method relies only on the information extracted from the motion-corrupted SA stack: 2D SA PSMs and a 3D SA PSM, which is used as target (see Fig. \ref{fig2}). While the models presented so far are trained using 2D patches $\bm{x}$ and labels $\bm{y}$, the 3D SA PSM one is trained using 3D patches encompassing 5 slices in the z direction. Training is performed on a set of high-resolution A3D images (inherently motion-free) with accompanying 3D segmentations, setting the patch thickness equal to that of 5 SA slices combined. This forces the model to learn representations of motion-free stacks. At testing, the model is applied to the SA stack (after an up-sampling step in the z direction to mimic the resolution of A3D images), generating a virtually motion-free 3D PSM which are used as a target for slice-by-slice in-plane registration (by translation only) of the 2D PSMs. The estimated translations are applied to the SA slices, thus performing the correction. \section{Experiments and Results} \noindent \textbf{Image Acquisition.} Two distinct CMR image datasets (obtained with different scanners, cardiac array coils and acquisition parameters) were used to test the proposed approach. The first dataset consists of 350 full CMR scans (including also A3D images) of healthy subjects, while the second one consists of 500 scans from the UK Biobank\footnote{http://www.ukbiobank.ac.uk/.}. Only end-diastolic frames were considered. \begin{figure}[!t] \centering \includegraphics[width=\textwidth]{Fig3.pdf} \caption{Results obtained for two different subjects, one per experiment. The proposed techniques are underlined.} \label{fig3} \end{figure} \noindent \textbf{Performance Evaluation.} Both datasets were annotated (either manually or automatically with subsequent manual corrections) to provide LV cavity segmentations for SA stacks, LA and A3D images as well as landmarks positions for the LA images alone. Two experiments were devised. For experiment A, 24 scans from the first dataset were extracted based on presence of visually-detected inter-slice motion and used as testing, while training was performed on the remaining scans of the same dataset. For this experiment, the proposed approach (with its two methods) was tested against an intensity-based technique (MC LA Int.) which iteratively registers SA slices to LA images (using normalized mutual information as similarity metric), essentially as in \cite{Lotjonen2004a}. For experiment B, testing was performed on the same 24 scans of experiment A, but training was performed on the whole second dataset. In this case, the proposed approach (using only MC LA PSMs) was tested against a technique (MC LA SEGs) which iteratively registers SA ``hard" segmentations to LA segmentations generated with FCNs (trained on images randomly extracted from the same database), essentially as in \cite{Sinclair2017}. To compare the accuracy of the implemented techniques, in both experiments the corrective translations estimated for each slice were applied to the provided SA segmentations. Then, the segmentation of the A3D images, considered as reference, were rigidly registered to the initial SA segmentation stack as well as to the those produced by each technique. Slice-by-slice in-plane registration was performed between reference and initial segmentation stack to identify motion corrupted slices, and those with more than 3 mm of misalignment were selected, for a total of 74. The evaluation of the accuracy of the implemented techniques was performed on these slices computing mean absolute distances (MAD), Hausdorff distances (HD) and Dice coefficients (DSC) between the LV cavity reference contours and before or after motion correction. The average slice-by-slice relative improvements for each of these metrics were also computed, as well as the percentage of improved values (where 100\% would ideally mean that all of the corrupted slices improved their alignment). Of note, in experiment B, the testing set underwent histogram normalisation to match the intensity distributions of the training set. \noindent \textbf{Implementation Details.} For training, standard data augmentation was implemented (random rescaling following a normal distribution with mean 1 and std 0.1, random rotation following a normal distribution with mean 0\textdegree and std 30\textdegree). Image patch size was 48$\times$48 px for LA models and 32$\times$32 px for SA ones, segmentation label size 16$\times$16 px, number of samples 4$\cdot10^6$, number of trees 8. Finally, the threshold $T_m$ was set to 0.4 (on a scale from 0 to 1). \begin{table} \centering \setlength\tabcolsep{6pt} \begin{tabular}{r | c c | c c | c c | c} \hline \hline \multirow{3}{1.8 cm}{\textbf{Motion Correction}} & \multicolumn{2}{c|}{\textbf{MAD}} & \multicolumn{2}{c|}{\textbf{HD}} & \multicolumn{2}{c|}{\textbf{DSC}} & \textbf{Ratio of}\\ & Mean & Mean & Mean & Mean & Mean & Mean & \textbf{improved}\\ & (mm) & Impr. & (mm) & Impr. & (a.u.) & Impr. & \textbf{slices}\\ \hline \multicolumn{8}{c}{\textbf{Experiment A}}\\ \hline None & 3.1 & & 6.9 & & 0.83 & &\\ MC LA Int. & 2.7 & 14\% & 6.2 & 12\% & 0.85 & 2\% & 77\%\\ \underline{MC 3D PSMs} & 2.6 & 19\% & 6.0 & 15\% & 0.86 & 2\% & 80\%\\ \underline{MC LA PSMs} & \textbf{1.9} & \textbf{38\%} & \textbf{4.9} & \textbf{29\%} & \textbf{0.89} & \textbf{7\%} & \textbf{92\%}\\ \hline \multicolumn{8}{c}{\textbf{Experiment B}}\\ \hline MC LA SEGs & 2.3 & 23\% & 5.7 & 16\% & 0.88 & \textbf{7\%} & 88\%\\ \underline{MC LA PSMs} & \textbf{2.1} & \textbf{33\%} & \textbf{5.2} & \textbf{26\%} & \textbf{0.89} & 6\% & \textbf{91\%}\\ \hline \hline \end{tabular} \caption{Error metrics for experiments A (top) and experiment B (bottom). The proposed techniques are underlined.} \label{tab1} \end{table} \vspace{-20pt} \noindent \textbf{Results.} Approximate time to perform motion correction of one SA stack on a 6-core CPU is 25s for MC 3D PSMs and 36s for MC LA PSMs. The results for both experiment A and B are reported in Table \ref{tab1} and displayed for two cases in Fig. \ref{fig3}. Experiment A assesses the accuracy of the proposed approach in the scenario of training and testing performed in the same dataset. The results show that the the intensity-based method performs worse than the others, and that MC 3D PSMs obtains lower errors even without using LA images. MC LA PSMs is clearly the best method within this batch and is able to improve most (92\%) of the motion-corrupted slices. The fact that this method outperforms MC 3D PSMs was expected: while MC 3D PSMs can produce a smoothly aligned stack, more robustly than an intensity-based approach, it does not have any strong target for the realignment and relies only on the implicit model for the LV shape learned from the training set. Experiment B evaluates the accuracy of MC LA PSMs against a state-of-the-art approach like MC LA SEGs in a realistic scenario where motion correction has to be performed on a dataset completely different from the one used for training. Remarkably, MC LA PSMs produces results very similar to the ones obtained when trained on the same dataset. As expected given the similitudes between the two techniques, MC LA SEGs and MC LA PSMs perform similarly (no statistically significant differences were highlighted using a paired t-test). However, MC LA PSMs produces better mean results due to a higher robustness in the basal slices (see Fig. \ref{fig3}, right side): in fact, hard segmentation techniques have no safety mechanism to refrain from aligning slices in the basal region (usually beyond the actual basal slice) for which the FCN has produced spurious segmentations. On the contrary, the proposed approach has two: the check on the peak probability of the PSM and the comparison with the identified landmarks. As a result, the obtained motion correction tends to be more robust to this effect (see again Fig. \ref{fig3}, right side). \section{Conclusion} A comprehensive approach for fully-automated inter-slice motion correction for SA stacks has been presented. This approach relies on the generation of probabilistic segmentation maps of the LV cavity to drive slice-by-slice in-plane registration. It is able to handle cases in which no LA images are provided with a higher accuracy than common intensity-based methods that exploit them. When LA images are instead available, the proposed approach achieves results on par with methods based on hard segmentations while producing fewer outliers thanks to the simultaneous identification of landmarks to constrain the correction. \subsubsection*{Acknowledgments.} This research has been conducted using the UK Biobank Resource under Application Number 18545. The first author benefited from a Marie Sklodowska-Curie Fellowship. \bibliographystyle{splncs}
{'timestamp': '2018-10-05T02:11:19', 'yymm': '1810', 'arxiv_id': '1810.02201', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02201'}
arxiv
\section{Introduction} Consider a distributed setting in which each node of a network receives an input from a higher-level application which tells it whether it is \emph{selected} or not, such that the set of selected nodes is a maximal independent set (MIS), which we will denote by $\alpha$. The reason that the application requires an MIS is because it needs the set of selected nodes to dominate all nodes for the sake of, say, monitoring the network, but without having violations of two neighbors being in the set, because they may cause conflicting actions. Now, because of changes in the network traffic, the energy consumption, or any one of various conditions that may change, the application needs to change the selected set of nodes. Once a new input MIS, denoted by $\beta$, is given to the nodes by the application, the nodes need to \emph{reconfigure} their states to that set while never sacrificing the safety condition of independence. In fact, for compatibility reasons, neighboring nodes cannot change their membership in the set at the same time, so a \emph{sequence} of changes is needed for converging into the new MIS. We call such a sequence a \emph{reconfiguration schedule}. The length of the schedule is clearly a measure that is required to be minimized. Hence, an extreme solution would be to have all nodes declare themselves as unselected, and then the new set of nodes declare that they are selected. However, this very fast approach suffers from loosing the domination property throughout the reconfiguration schedule. Thus, the structure of the network must be taken into account, but since the topology is unknown, finding a schedule that maintains a good covering at all times necessitates that the nodes communicate. This brings another measure of complexity into question, which is the number of communication rounds that are needed in order to find a short schedule. Our goal in this work is to study the tradeoff between the possible length of the schedule and the number of communication rounds needed for finding it. Unfortunately, as we show, it is not always possible to find schedules where each set is an MIS. This impossibility holds even if we relax the condition of domination and require only independent 3-dominating sets. Even when 3-domination \emph{is} possible, it may be extremely inefficient (Section~\ref{sec:impossibilities}). \newcommand{\PropThreeDom} { Requiring $3$-domination for intermediate steps is costly: \begin{enumerate} \item There exists a class of inputs $G=(V,E)$ with two MIS $\alpha$ and $\beta$ such that there is no reconfiguration schedule with 3-dominating intermediate steps. \item There exists a class of inputs $G=(V,E)$ with two MIS $\alpha$ and $\beta$ such that any reconfiguration schedule is of length $\Omega(n)$ and needs $\Theta(n)$ rounds to be found, if intermediate steps must be 3-dominating. \end{enumerate} } \begin{theorem} \label{prop:3dom} \PropThreeDom \end{theorem} However, we prove that independence and 4-domination can indeed be obtained. Our main result is the following (Section~\ref{sec:const-len}). \begin{theorem}\label{th:main}\textbf{(informal)} For any graph $G=(V,E)$ of diameter greater than 3 and any input of two MIS $\alpha,\beta$, there exists a reconfiguration schedule of constant length $28$, with independent 4-dominating intermediate steps. Moreover, such a schedule can be found in $O(\texttt{MIS}+\texttt{R32})$ rounds, where $\texttt{MIS}$ is the complexity of finding an MIS on a worst-case graph and $\texttt{R32}$ is the complexity of finding a $(3,2)$-ruling set on a worst-case graph. \end{theorem} Obtaining the above theorem turns out to be an involved task. Our key ingredients are the following. We prove that graphs with a not-too-small diameter always admit a schedule of reconfiguration steps from a given maximal independent set to another. Moreover, full knowledge of the topology of the graph is not necessary in order to be able to locally add an element to the set after having removed its neighbors (to avoid dependence). Rather, only local manipulations are needed for doing so. The currently known complexities that give $O(\texttt{MIS}+\texttt{R32})$ are discussed in the related work part. Here, we draw attention to the fact that an immediate corollary of Theorem~\ref{th:main} is that for graphs of bounded degree we can compute the constant length schedule within $O(\log^*n)$ rounds. Further, we show that this is a lower bound by reducing the problem of finding an MIS on a path to obtaining a constant-length schedule for MIS reconfiguration. The following theorem actually holds even if one requires only $d$-domination, for some constant $d\geq 4$ (Section~\ref{sec:impossibilities}). \newcommand{\Proplogstar} { For any fixed $k$, there exists a class of $k$-regular inputs $G=(V,E)$ with two MIS $\alpha$ and $\beta$ such that any reconfiguration schedule of constant length with 4-domination needs $\Theta(\log^*n)$ rounds to be found. } \begin{theorem}\label{prop:log-star} \Proplogstar \end{theorem} If one wants to optimize the communication cost of finding a schedule rather than its length, we show that a (rather lengthy) schedule can be obtained within $O(1)$ rounds (Section~\ref{sec:const-round}). \begin{theorem}\label{th:conscomm}\textbf{(informal)} For any graph $G=(V,E)$ and any input of maximal independent sets $\alpha,\beta$ to the MIS-reconfiguration problem, there exists a reconfiguration schedule of length $\Theta(f(n))$, where $f(n)$ is the largest identifier among the nodes in the graph, which can be found in $O(1)$ rounds. \end{theorem} The construction generalizes itself on graphs with a distance-$k$ coloring of $c$ colors, with $k$ big enough. It is possible, from this coloring, to compute a schedule of length $O(c)$ after a constant number of communication rounds. Let $\Delta$ be the maximal degree of the graph. A distance-$k$ $O(\Delta^{2k})$ coloring can be found in $O(\log^*n)$ rounds~\cite{Linial:1987:DGA:1382440.1382990}, and a distance-$k$ $O(\Delta^{k})$ coloring can be found in $O(\log^*n+\sqrt{\Delta^k})$ rounds~\cite{BarenboimEG18}. Hence, with the same respective communication complexities, we can find schedules of lengths $O(\Delta^{2k})$ and $O(\Delta^k)$. Finally, as can be inferred from Theorem~\ref{th:main}, $4$-domination suffices for any graph with diameter greater than $3$. For graphs with small diameter, we give an exact characterization of the conditions that allow the existence of a reconfiguration schedule (Section~\ref{sec:characterization}). This result implies that our algorithm from Theorem~\ref{th:main}, combined with a trivial algorithm that collects the entire graph when the diameter is a small constant, produces an efficient reconfiguration schedule in all cases for which it exists. \subsection{Related work} \subparagraph{Distributed Reconfiguration.} Questions of distributed reconfiguration were actually not studied before 2018. Then, Bonamy et al.~\cite{bonamy2018distributed} considered distributed reconfiguration of colorings, with the goal of finding which length of schedule can be computed within a given number of communication rounds. The problem being PSPACE complete in the general case, several subcases were explored. Since finding looser restrictions for the transitions is important for making the problem local instead of having to solve a global PSPACE hard problem, the addition of extra colors in the intermediate colorings was allowed. This aided either having a solution, or finding one quickly. \subparagraph{Distributed Constructions.} Our constructions sometimes make use of two fundamental subroutines, which find an MIS or a $(3,2)$-ruling set in a graph. An $(x,y)$-ruling set is a set $S \subseteq V$ in which every two nodes are at distance at least $x$, and every node that is not in $S$ is within distance at most $y$ from $S$. Thus, an MIS is a $(2,1)$-ruling set. Finding an MIS is one of the most fundamental problems in distributed computing. The celebrated randomized $O(\log n)$-round algorithms of Luby~\cite{Luby86} and Alon et al.~\cite{AlonBI86} have been recently improved by Ghaffari to $O(\log\Delta+2^{O(\sqrt{\log\log n})})$ rounds, where $\Delta$ is the maximal degree in the network~\cite{Ghaffari16}. Deterministic solutions are the classic network-decomposition based algorithm of Panconesi and Srinivasan that runs in $2^{O(\sqrt{\log n})}$ rounds~\cite{PanconesiS96}, and the $O(\Delta+\log^*n)$-round algorithm of Barenboim et al.~\cite{BarenboimEK14}. The classic lower bound of Linial~\cite{Linial92} shows that $\Omega(\log^*n)$ rounds are necessary, Kuhn et al. gives a higher bound of $\Omega(\log\Delta/\log\log\Delta, \sqrt{\log n/\log\log n})$ ~\cite{KuhnMW16}. The latest results of Balliu et al.~\cite{balliu2019lower} give the new best known lower bounds to find a MIS: There is no deterministic algorithm in $o(\Delta+\frac{\log n}{\log\log n})$ nor randomized algorithm in $o(\Delta+\frac{\log\log n}{\log\log\log n})$. The Figure 1 in~\cite{balliu2019lower} sums up all the results on MIS. A $(3,2)$-ruling set can be computed by computing an MIS over $G^2$, and more general ruling sets have been studied in~\cite{AwerbuchGLP89, SchneiderEW13, PaiPPR017, KuhnMW18, KothapalliP12}. \subparagraph{Centralized Reconfiguration of Maximal Independent Sets.} Reconfigurations problems on graphs have been widely studied in the centralized setting during the last decade. An excellent survey on reconfiguration problems can be found in~\cite{Jansurvey}. In the centralized setting, the transition rules are different, requiring that any intermediate set must be at least of a certain size. While having their own motivation in that setting, these rules are not the ones that are needed in the distributed setting, as they do not give covering guarantees (moreover, such properties would be costly to obtain in a distributed setting, due to their global nature). In more detail, three kinds of transitions have been studied for the independent set reconfiguration problem. \emph{Token Addition and Removal}~\cite{ito2010complexity}, or $TAR(k)$: at each transition, one vertex is removed from or added to the current independent set, as long as there are at least $k$ nodes in the independent set. \emph{Token Jumping}~\cite{kaminski2012complexity}: at each transition, one vertex is removed from the independent set and another one is added somewhere else. \emph{Token Sliding}~\cite{hearn2002pspace}: at each transition, an edge containing a vertex of the independent set is chosen. This vertex is removed from the set and its neighbor on the other side of that edge is added to the set. The two first versions are actually equivalent when $k$ corresponds to the size of the independent sets minus 1. Reconfiguration problems are in PSPACE, and independent set reconfiguration problems are in general PSPACE complete~\cite{hearn2002pspace}. Studies over subclasses of graphs exist, and some polynomial algorithm or hardness proofs are given. For example, planar graphs \cite{hearn2002pspace}, perfect graphs \cite{kaminski2012complexity}, trees \cite{demaine2015linear} and bipartite graphs \cite{lokshtanov2018complexity}. \section{Preliminaries} \label{sec:prelim} We work in the classic LOCAL model of computation, in which $n$ nodes in a synchronous network exchange messages with their neighbors in each round of computation. Let $G=(V,E,U)$ denote a graph with an assigned subset $U \subseteq V$. An input to the MIS-reconfiguration problem is a pair $G_{input}=(V,E,\alpha),G_{output}=(V,E,\beta)$, where $\alpha$ and $\beta$ are the initial and final maximal independent sets, respectively. We refer to a node $ v \in \alpha$ as an \emph{$\alpha$-node}, and to a node $v \in \beta$ as a \emph{$\beta$-node}. Notice that a node may be both an $\alpha$-node and a $\beta$-node. We refer to node $v \in V\setminus (\alpha\cup\beta)$ as an \emph{$\epsilon$-node}. Throughout the proofs, we say that a node $v$ is \emph{covered} or \emph{4-dominated} by a node $u$ if $d(v,u) \leq 4$. For a vertex $v\in V$, we denote by $N(v)$ the set of neighbors of $v$ (i.e., $N(v) = \{u\in V:(u,v)\in E\}$), and given a set $U \subseteq V$ we define $N_U(v)=U\cap N(v)$ for the subset of neighbors of $v$ that are in $U$, and we call this set the $U$-neighbors of $v$. For a subset $U\subseteq Y \subseteq V$ and a node $v \in Y$, we denote by $d_Y(v,U)$ the distance of $v$ from $U$ in the subgraph induced by $Y$. \begin{definition}[\textbf{Reconfiguration Schedules}] \label{def:schedule} For a given property $P$ of $G=(V,E,U)$, an \emph{$(\alpha, \beta, P)$-reconfiguration schedule} (or simply a schedule) $S$ of length $\ell$ is a sequence of subsets of $V$, $S=(S_0,\dots,S_{\ell})$, such that the following hold: \begin{enumerate} \item $S_0=\alpha$ and $S_{\ell} = \beta$, \item for every $0 < i < \ell$, the graph $(V,E,S_i)$ satisfies $P$, and \item for every $0 < i \leq \ell$, $S_i \oplus S_{i-1}$ is an independent set of $(V,E)$. \end{enumerate} \end{definition} \section{An MIS reconfiguration schedule of constant length} \label{sec:const-len} Our main theorem is the following. \begin{theorem-repeat}{th:main}\textbf{(formal)} Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set. For any graph $G=(V,E)$ of diameter greater than 3 and any input $G_{input}=(V,E,\alpha),G_{output}=(V,E,\beta)$ to the MIS-reconfiguration problem, there exists an $(\alpha, \beta, P)$-reconfiguration schedule of constant length $28$. Moreover, such a schedule can be found in $O(\texttt{MIS}+\texttt{R32})$ rounds, where $\texttt{MIS}$ is the complexity of finding an MIS on a worst-case graph and $\texttt{R32}$ is the complexity of finding a $(3,2)$-ruling set on a worst-case graph. \end{theorem-repeat} In particular, Theorem~\ref{th:main} immediately implies a highly efficient solution for bounded degree graphs. \begin{corollary} \label{cor:log-star} The constant length schedule of Theorem~\ref{th:main} can be found in $O(\log^*n)$ rounds in graphs of bounded degree. \end{corollary} We now describe the outline of the algorithm, as follows. Denote by $W$ the set of connected components of $\alpha\cup\beta$. Our main approach is to reconfigure the independent sets according to the components in $W$. To this end, we first categorize each component in $W$ according to its diameter and whether it is isolated or not: We say that a component $V_i \in W$ is \emph{isolated} if for every $\epsilon$-node $u$ in its neighborhood, $N_{\alpha}(u)$ and $N_\beta(u)$ are contained in $V_i$. Notice that within a constant number of rounds, all $\alpha$ and $\beta$-nodes can know whether they are in a component of diameter 0, 1, 2, or at least 3. Moreover, if their diameter is smaller than 3, they can know whether the component is isolated or not. To avoid excessive notation, we will sometimes say that \emph{we update the component $V_i$ in steps $\{j, j+1\}$}. This means that we remove $\alpha\cap V_i$ from the independent set in step $j$ and we add $\beta\cap V_i$ to the set in step $j+1$. Formally, this means that $S_j = S_{j-1} \setminus (\alpha\cap V_i)$ and $S_{j+1} = S_{j} \cup (\beta\cap V_i)$. Since we will sometimes update multiple components concurrently, we will have $S_j = S_{j-1} \setminus (\alpha\cap Z_j)$ and $S_{j+1} = S_{j} \cup (\beta\cap Z_j)$, where $Z_j = \bigcup_{i \in I_j} V_i$, with $I_j = \{i : V_i \mbox{ is being updated in steps } \{j, j+1\}\}$. The high-level description of our algorithm is as follows. First, for components in $W$ of diameter 0, we do not need to do anything, as such components are comprised only of nodes in $\alpha\cap\beta$. These nodes remain in the independent set $S_i$ for the entire schedule, and we omit these components and all of their $\epsilon$-neighbors from the remaining discussion. Our algorithm then handles non-isolated components and components of diameter~$\ge3$, and finally handles the isolated components of diameter~$\le2$. We begin by claiming that with an overhead of 2 rounds, we may assume that $\alpha$ and $\beta$ are disjoint. \newcommand{\LemmaAlphaBeta} { Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set, and let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be an input to the MIS-reconfiguration problem. Let $V_{\alpha,\beta}=\alpha \cap \beta$ and denote $V' = V\setminus (V_{\alpha,\beta}\cup N(V_{\alpha,\beta}))$, $\alpha' = \alpha \setminus V_{\alpha,\beta}$ and $\beta' = \beta \setminus V_{\alpha,\beta}$. Let $G' = G[V']$. If there exists an $(\alpha',\beta',P)$-reconfiguration schedule $S'$ of length $\ell$ for $G'$, then there exists an $(\alpha,\beta,P)$-reconfiguration schedule $S$ of length $\ell$ for $G$. Moreover, any distributed algorithm for finding $S'$ in $T'$ rounds implies a distributed algorithm finding $S$ in $T=T'+2$ rounds. } \begin{lemma} \label{lemma:alpha-beta-nodes} \LemmaAlphaBeta \end{lemma} \begin{proof} Let $S' = S'_0,\dots,S'_{\ell}$ be an $(\alpha',\beta',P)$-reconfiguration schedule for $G'$. We define $S_i = S'_i \cup V_{\alpha,\beta}$ for all $0 \leq i \leq \ell$, and show that $S = S_0,\dots,S_{\ell}$ is an $(\alpha,\beta,P)$-reconfiguration schedule for $G$. Condition (1) of Definition~\ref{def:schedule} holds since $S_0 = S'_0 \cup V_{\alpha,\beta} = \alpha' \cup V_{\alpha,\beta} = \alpha$ and $S_{\ell} = S'_{\ell} \cup V_{\alpha,\beta} = \beta' \cup V_{\alpha,\beta} = \beta$. For condition (2), fix an index $0\leq i\leq\ell$. Notice that $S'_i$ is a $(2,4)$-ruling set and hence it is independent. Since $S_i \setminus S'_i = V_{\alpha,\beta}$, and $V_{\alpha,\beta}$ is independent, we have that $S_i$ is also independent because no node that is a neighbor of $V_{\alpha,\beta}$ is in $V'$ and in particular no such node is in $S'_i$. In addition, every node in $V'$ is $4$-dominated in $S'_i$, and every node in $V \setminus V'$ is dominated by $V_{\alpha,\beta}$, which implies that $S_i$ is $4$-dominating and hence it is a $(2,4)$-ruling set. Finally, for each $0\leq i\leq\ell$, we have that $S_i \oplus S_{i-1} = S'_i \oplus S'_{i-1} $ and hence it is an independent set of $(V,E)$. To obtain $S$ from $S'$ with an overhead of 2 rounds, a distributed algorithm can have each node in $V_{\alpha,\beta}$ indicate this to its neighbors, and then each node in $N(V_{\alpha,\beta})$ can indicate this to its neighbors. Then, the algorithm obtains $S'$ over $G'$ and deduces $S$. \end{proof} \subsection{Components of diameter $\geq 3$} We continue with the following lemma, which is useful for handling components in $W$ whose diameter is not too small. Roughly speaking, the way we handle components of sufficient diameter is by finding a set of $\alpha$-nodes that are not too close to each other to ensure that $\beta$-nodes can be added not too far from them before we remove them from the independent set. This way, we can reconfigure the rest of the component, and then this set of $\alpha$-nodes and their neighbors. We present the following lemma before the rest of the algorithm because we will need to use it, but notice that it is not the case that we begin the algorithm by reconfiguring components of diameter $\geq 3$. \begin{lemma} \label{lemma:no-epsilon-nodes} Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set, and let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be an input to the MIS-reconfiguration problem such that $\alpha\cap\beta=\emptyset$, the set $Y=\alpha\cup\beta$ is a single connected component of diameter at least $3$, and each $\epsilon$-node is connected to an $\alpha$-node and to a $\beta$-node. Then, there exists an $(\alpha,\beta,P)$-reconfiguration schedule of length $8$. Moreover, such a schedule can be found in $O(\texttt{R32})$ rounds. \end{lemma} \begin{proof} First, assume that the diameter of $Y=\alpha\cup\beta$ is either $3$ or $4$. Consider a shortest path of length $3$ in $Y$, denoted by $(v_1,v_2,v_3,v_4)$. Either $v_1$ or $v_4$ is in $\alpha$, and is within distance $4$ from all other nodes in the component. We denote this node by $v$, and define $S_1 = \{v\}$ and we have that it 4-dominates the entire component. In addition, it 4-dominates all $\epsilon$-nodes, by the assumption of the lemma that all such nodes are neighbors of $\beta$-nodes, because $v$ actually 3-dominates all $\beta$-nodes in the component. We then denote $R = \{u \in \beta~|~ u \not\in N(v)\}$ and define $S_2 = \{v\} \cup R$, and $S_3 = R$, and finally $S_4 = R \cup N(v)$. It is easy to verify that this results in a valid $(\alpha,\beta,P)$-reconfiguration schedule. In particular, notice that, without loss of generality, if $v=v_1$, then $R$ contains at least the node $v_4$, which 4-dominates the entire component. For a diameter of $Y$ that is at least 5, the high-level idea of the construction is as follows. Consider a $(3,2)$-ruling set $R$ over the nodes in $\alpha$, where we imagine an edge between two nodes in $\alpha$ if they are at distance two in the subgraph induced by $Y$. We reconfigure all $\beta$-nodes that are at distance $5$ from $R$ in $G$ by removing their $\alpha$-neighbors first, then by adding them. Then, we do the same for $\beta$-nodes that are at distance $3$ from $R$, and finally we repeat this one last time for the $\beta$-nodes in the direct neighborhood of $R$. The choice of a $(3,2)$-ruling set ensures that all $\alpha$-nodes in $R$ have a $\beta$-node at distance 3 that will be reconfigured in the 4th step. However, while we trust $\beta$-nodes at distance 3 from $R$ to cover $\alpha$-nodes at distance 2 from $R$ while $R$ itself is being reconfigured, we must be careful when handling $\alpha$-nodes at distance 2 from $R$ that do not have a neighbor at distance 3. We overcome this caveat by taking care of these nodes separately. Formally, we define a virtual multigraph $\tilde{G}=(\tilde{V},\tilde{E})$ as follows. The set of virtual nodes $\tilde{V}$ consists of all $\alpha$-nodes. If $v$ and $u$ in $\tilde{V}$ have a common $\beta$-neighbor, we add an edge ${u,v}$ to $\tilde{E}$. Let $R$ be a $(3,2)$-ruling set in $\tilde{G}$. It is easy to see that in $G$, the set of nodes $R$ is a $(6,5)$-ruling set of $Y$. We denote $R$ by $R_0$ and we define $R_i$ for $3 \leq i \leq 5$ as $R_i = \{v\in Y ~|~ \mbox{the distance of $v$ from $R$ in the subgraph induced by $Y$ is $i$}\}$. Then we define $R_{1} = \{v\in Y ~|~ d_Y(v,R)=1 \mbox{ and } d_Y(v,R_3)=2\}\cup\{v\in Y ~|~ N_Y(v)\subseteq R\}$, which captures all $\beta$-neighbors of $R$ that either do not have other $\alpha$-neighbors, or have other $\alpha$-neighbors which in turn have $\beta$-neighbors that are farther from $R$. We separate those from the set $R_{-1}= N_Y(R_0)\setminus R_1$. We complete the partition by defining $R_2=N_Y(R_1)\setminus R_0$ and $R_{-2}= N_Y(R_{-1})\setminus R_0$. Note that for even $i$, $R_i$ contains only $\alpha$-nodes, and for odd $i$, $R_i$ contains only $\beta$-nodes. We have that, for every $-2\le i\le5$, $N_Y(R_i)\subseteq R_{i-1}\cup R_{i+1}$ (with $R_{-3}=R_6=\emptyset)$. By construction of $R$, we have that each node in $R$ has a node at distance 3 in $R_3$, hence it has a node at distance $2$ in $R_2$ and a node at distance 1 in $R_1$. We define $S_0=\alpha$ and for $i=0,1,2,3$, we define $S_{2i+1} = S_{2i} \setminus R_{4-2i}$, $S_{2(i+1)} = S_{2i+1} \cup R_{5-2i}$. We claim that $S_0,\dots,S_8$ is an $(\alpha,\beta,P)$-reconfiguration schedule. First, $S_0=\alpha$ by definition, and because every $\beta$-node is within an odd distance of at most $5$ from $R$ and every $\alpha$-node is within an even distance of at most $4$ from $R$, we have that $S_8=\beta$. This gives condition (1) of Definition~\ref{def:schedule}. For condition (2), it is easy to see that $S_i \oplus S_{i-1}$ is an independent set of $(V,E)$ for every $1\leq i \leq 8$. For an odd $i$ this holds because to obtain $S_i$ we only remove $\alpha$-nodes from $S_{i-1}$, and no two such nodes can be neighbors. For an even $i$ this holds because to obtain $S_i$ we only add $\beta$-nodes to $S_{i-1}$, and no two such nodes can be neighbors. It remains to show condition (3) of Definition~\ref{def:schedule}. To show that $S_{i}$ is independent for $i=2,4,6$, notice that $\beta$-nodes in $R_j$ (for $j=-1,1,3,5$) are only added to the sequence after all $\alpha$-nodes in $R_{k}$ for $k\geq j-1$ have been removed. By definition, $S_0$ is also independent. Hence, for $i=1,3,5,7$, $S_i$ is independent because it is a subset of $S_{i-1}$. Next, we need to show that $S_{i}$ is $4$-dominating for every $1 \leq i \leq 7$. Our focus will be for $i=1,3,5,7$, and for $i=2,4,6$ it then follows because $S_i$ contains $S_{i-1}$. We first show it on $Y$, and will prove it for $\epsilon$-nodes afterward. For $i=1$ this holds because all nodes in $R_j$ for $j\leq 3$ are in or have neighbors in $R_{-2}\cup R_0\cup R_2$. All nodes in $R_j$ for $j=4,5$ are within distance $3$ from $R_2$. Similarly, $S_{3}$ is $4$-dominating because nodes in $R_{j}$ for $j\leq4$ are covered by $R_0$, nodes in $R_{5}$ are in the current independent set. For $S_{5}$, recall that for any node in $R$, there is a node at distance 3 from it in $R_3$, that node being in the current independent set since $S_4$. Hence, $R_3$ covers $R_{j}$ for $-1\le j\le 5$. $R_{-2}$ is still included in $S_{5}$. Finally, for $S_{7}$, $R_3$ still covers $R_{j}$ for $-1\le j\le 5$. For each node in $R_{-2}$, there is a node at distance 3 from it in $R_1$ that has been added in $S_6$ that covers it. Now, let $u$ be an $\epsilon$-node that has a node $a\in\alpha$ and $b\in\beta$ in its neighborhood. We show that $a$ or $b$ are always 3-dominated throughout the sequence. In a step where $b$ has no $\alpha$-neighbor in the independent set, it must be a step right before $b$ gets added to the independent set. If $b$ is in $R_5$ or in $R_3$ then when this happens, it is 3-dominated by an $\alpha$-node in $R_2$ or $R$, respectively, and this node is still in the independent set. If $b\in R_{-1}$ then it is 2-dominated by nodes in $R_{-2}$ and then $R_1$ (with an overlap in $S_6$, the construction ensures that such node exist at distance at most 3 from $b$). Finally, If $b \in R_1$ then either there is a $\beta$-node in $R_3$ that 2-dominates it, and this node is already in the independent set, or $b$ is in $\{v\in Y ~|~ N_Y(v)\subseteq R\}$. Only in the latter case, we must resort to the $\alpha$-neighbor of $u$ and check that it is $3$-dominated by $S_5$, as we removed $R$ from $S_5$ and $b$ is added in $S_6$. Let $i$ be such that $a\in R_i$. We need to make sure that $a$ is 3-dominated at the step in which we reconfigure $R_1$. At this step, all of the $\beta$-nodes in $R_3, R_5$ are in the independent set, and hence their $\alpha$-neighbors in $R_2,R_4$ are covered by nodes in distance 1, and nodes in $R_0$ are covered by nodes in distance 3. For $\alpha$-nodes in $R_{-2}$ they are still in the independent set at this step, and hence are 3-dominated. This completes the correctness proof. For the round complexity, notice that simulating the $(3,2)$-ruling set over $\tilde{G}$ can be done in $G$ with a constant overhead. \end{proof} \subsection{Non-isolated components} We first observe that components of diameter $\le2$ are such that there is a complete bipartite graph between their $\alpha$-nodes and $\beta$-nodes. Let $u$ be an $\epsilon$-node that is a neighbor of several components. Let $W_u$ be the set of all components that are its neighbors, so that in particular, $V_i, V_j \in W_u$. For each pair of distinct components $V_i, V_j \in W_u$, if there is an $\alpha$ node in $N_\alpha(u)\cap V_i$ and a $\beta$ node in $N_\beta(u)\cap V_j$, then we say that $V_j$ is $(u,\alpha)$-covered and that $V_i$ is $(u,\beta)$-covered (note that this definition allows a single component to satisfy both conditions). As $u$ is an $\epsilon$-node, there must exist a component $V_{u,\alpha} \in W_u$ that is $(u,\beta)$-covered and a component $V_{u,\beta} \in W_u$ that is $(u,\alpha)$-covered. We say that a component $V_i \in W$ is $\alpha$-covered ($\beta$-covered) if there is an $\epsilon$-node $u$ for which $V_i$ is $(u,\alpha)$-covered ($(u,\beta)$-covered). A component that is both is $\alpha\beta$-covered. The key insight is that a $(u,\alpha)$-covered component of diameter~$\le2$ is covered (dominated at distance 4) by some $\alpha$-node of the component $V_{u,\beta}$ (and similarly with the $\beta$-node of $V_{u,\alpha}$). Moreover, any $\epsilon$-node that is connected to an $\alpha$-node (a $\beta$-node) in that component is covered by $V_{u,\beta}$ (or $V_{u,\alpha}$). This implies that an $\epsilon$-node that is connected to two components that are updated in different steps is always covered by the component that is currently not being updated. However, during the reconfiguration schedule, we need to be careful about $\epsilon$-nodes that are connected to a single component, and $\epsilon$-nodes that are connected to two components that are updated at the same time. We denote by $C_{\alpha\beta}$ the set of $\alpha\beta$-covered components of diameter~$\le2$, and by $C_\alpha$ and $C_\beta$ the sets of $\alpha$-covered and $\beta$-covered components of diameter~$\le2$ that are not in $C_{\alpha\beta}$, respectively. Define the component graph $\tilde{G} = (W,\tilde{E})$, where there is an edge between $V_i,V_j \in W$ iff there exists an $\epsilon$-node $u$ such that $V_i$ is $(u,\alpha)$-covered and $V_j$ is $(u,\beta)$-covered, or vice-versa. Notice that in $\tilde{G}$, the sets $C_\alpha$ and $C_\beta$ are two disjoint independent sets. We are finally ready to formally provide the algorithm for handling all components that are either non-isolated or have diameter $\geq 3$. \begin{lemma} \label{lemma:non-isolated} Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set, and let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be an input to the MIS-reconfiguration problem such that $\alpha\cap\beta=\emptyset$, and all connected components of $\alpha\cup\beta$ are either non-isolated or have diameter at least 3. Then, there exists an $(\alpha,\beta,P)$-reconfiguration schedule of length $18$. Moreover, such a schedule can be found in $O(\texttt{MIS}+\texttt{R32})$ rounds. \end{lemma} \begin{proof} Our reconfiguration schedule works according to the following \emph{parts}. \begin{enumerate} \item Update components of diameter~$\le2$ in $C_\alpha$ ~\\\%Let $M$ be an MIS over all nodes in $C_{\alpha\beta}$. \item Update components of diameter~$\le2$ that are $\alpha$-covered by a component in $M$ \item Reconfigure components of diameter~$\ge3$ using the schedule given by Lemma~\ref{lemma:no-epsilon-nodes} \item Update components in $M$ \item Update components of diameter~$\le2$ in $C_{\alpha\beta}$ that were not previously updated \item Update components of diameter~$\le2$ in $C_\beta$ that were not previously updated \end{enumerate} First, it is easy to see that the schedule has length 18. The part that reconfigures components of diameter~$\ge3$ requires 8 steps, by Lemma~\ref{lemma:no-epsilon-nodes}. Each of the other 5 parts takes exactly 2 steps as described in the definition of updating components (removing $\alpha$-nodes and then adding $\beta$-nodes), which sums to 18 reconfiguration steps in the schedule. It remains to prove correctness. First, condition (1) of Definition~\ref{def:schedule} trivially holds, as the schedule reconfigures all nodes. Moreover, by Lemma~\ref{lemma:no-epsilon-nodes} and by the definition of updating a component, it is also immediate that we do not reconfigure two neighbors in a single step, thus the schedule satisfies condition (3) of Definition~\ref{def:schedule}. For condition (2), Lemma~\ref{lemma:no-epsilon-nodes} and the definition of updating a component also guarantee that each $S_i$ is an independent set. The remainder of the proof shows that each $S_i$ in the schedule is also $4$-dominating. By the order of the reconfiguration steps in the schedule, each component that is being updated is covered by a component that is not concurrently being updated. This also holds for $\epsilon$-nodes that are connected to a component that is not currently being updated. The main condition that must be verified is that $\epsilon$-nodes remain covered even if all of their neighboring components are being concurrently updated in a certain part of the schedule. Part 1 guarantees that $S_1,S_2$ are 4-dominating because for each component that is being updated, the $\alpha$-node covering it is a member of $S_1,S_2$ and it also covers the required $\epsilon$-nodes that are neighbors of the updated component, as explained earlier. For part 2, let $u$ be an $\epsilon$-node that is connected to two of the components that are being updated and is not connected to any component that is not being updated. One of the components must be connected to $u$ via an $\alpha$-node. Let $V_i$ be such a component, let $u_1$ be the $\alpha$-node connected to $u$, and let $v$ be the $\alpha$-node from a component of $M$ that covers $V_i$. The distance between $v$ and $u_1$ is 3: $v$ is a distance 2 to a $\beta$-node of $V_i$ and, because $V_i$ is of diameter~$\le2$, within $V_i$ all $\beta$-nodes are connected to all $\alpha$-nodes. Hence, $u$ is at distance 4 from $v$. For part 3, the 4-domination within the components that are being reconfigured is given by Lemma~\ref{lemma:no-epsilon-nodes}. Notice that any $\epsilon$-node connected to a component of diameter~$\ge3$ is connected either to connected components of diameter~$\ge3$ through both an $\alpha$ and a $\beta$-node, or to a component that is not being updated in those steps. In the first case it is covered by Lemma~\ref{lemma:no-epsilon-nodes}, and in the second it is covered by the component not being concurrently updated. For part 4, notice that all components that are $\beta$-covering components of $M$ have been updated in steps 2 or 3. Hence, as each component of $M$ is in $C_{\alpha\beta}$, there is a $\beta$-node in the current set $S_{12}$ that covers it. As $M$ is independent, we do not have $\epsilon$-node between two components that are being updated. For part 5, the $\epsilon$-nodes between two components that are being updated are covered by an argument that is symmetric to the one used for part 2. Finally, for part 6, for each component that is being updated it holds that the $\beta$-node covering it is in a component that has already been updated and hence it is already in $S_{16}$. Finally, we note that apart from a constant overhead in communication, the number of rounds required for computing the above schedule is proportional to that of finding the MIS $M$ plus solving the diameter $\ge3$ components, which completes in $O(\texttt{MIS}+\texttt{R32})$ rounds, where $\texttt{MIS}$ is the complexity of finding an MIS on a worst-case graph and and $\texttt{R32}$ is the complexity of finding a $(3,2)$-ruling set on a worst-case graph, as claimed. \end{proof} \subsection{Isolated Components} What remains now is to handle components that are isolated and have diameter at most 2. When we address these components, we will also address all of their $\epsilon$-neighbors. Hence, from this point onwards we will slightly abuse our terminology, and when we refer to such a component we refer to its nodes along with their $\epsilon$-neighbors as the component. This means that now the components that we address might have a diameter that is increased by 1, and thus their diameter can be also 3. Note that the diameter cannot be increased by two as all $\alpha$-nodes are connected to all $\beta$-nodes, and each $\epsilon$-node is connected to an $\alpha$-node and to a $\beta$-node of this component, otherwise the component would not be isolated. By definition of isolated components, the neighborhood of an $\epsilon$-nodes within such a component, besides containing vertices of the component itself, is only composed of other $\epsilon$-nodes. Moreover, there is at least one additional $\epsilon$-node in this neighborhood, as we consider graphs of diameter at least 4. We distinguish two kinds of isolated components, according to whether their diameter is at most 2, or whether it is 3. For a component $V_i$ of diameter~$\le2$, suppose $u$ is an $\epsilon$-node that is a neighbor of $V_i$. This node $u$ has an $\alpha$-node and a $\beta$-node in its neighborhood, that both cover the entire component. Therefore, to update such components, it suffices to make sure that a non-$\epsilon$ neighbor of $u$ is in the current independent set during the two reconfiguration steps. By considering connected two of those components that cover each other, we can take an MIS $M$ over those. The schedule of length 4 is: update $M$, and then update the other components. Assume now that $V_i$ is a component of diameter 3. It holds that there exists an $\epsilon$-node $u$, an $\alpha$-node $a$ and a $\beta$-node $b$ such that $(u,a)\not\in E$ and $(u,b)\not\in E$ (otherwise the diameter would be 2). Here is an informal description of a schedule of 6-steps for this component. \begin{enumerate} \item Remove $N_\alpha(u)$. The node $a$ stays in the independent set and covers the entire component. \item Add $u$ in the set. \item Remove the remaining $\alpha$-nodes of the component. The node $u$ covers everything. \item Add $b$ to the set. Note that $b$ covers the component. \item Remove $u$. \item Add the remaining $\beta$-nodes of the component. \end{enumerate} A caveat is encountered in case there are two such components, $V_1$ and $V_2$, whose selected $\epsilon$-nodes, $u_1$ and $u_2$, are connected. In such case we cannot do the above 6-step schedule in parallel without violating independence. However, observe that if a single of those two $\epsilon$-nodes is added to the set, it actually covers the second component as well, as it has a diameter of 3. As a consequence, taking an MIS over those $\epsilon$-nodes gives us a selection of nodes that cover all the considered components. Hence, consider the schedule above as being for component $V_1$ and denote $u=u_1$, then we can add the following to steps 3 and 4 above: \begin{itemize} \item[3.] Remove the remaining $\alpha$-nodes of $V_1$ and all $\alpha$-nodes of $V_2$. The node $u$ covers everything. \item[4.] Add $b$ and the $\beta$-nodes of $V_2$ to the set. Note that $V_2$ is updated and $b$ covers $V_1$. \end{itemize} We now formalize the above intuition in order to prove the following. \newcommand{\LemmaIsolated} { Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set, and let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be an input to the MIS-reconfiguration problem such that $\alpha\cap\beta=\emptyset$, and all connected components of $\alpha\cup\beta$ are isolated and have diameter at most 2. Then, there exists an $(\alpha,\beta,P)$-reconfiguration schedule of length $10$. Moreover, such a schedule can be found in $O(\texttt{MIS})$ rounds. } \begin{lemma} \label{lemma:isolated} \LemmaIsolated \end{lemma} \begin{proof} We say that two isolated components of diameter~$\le2$ are connected if two of their $\epsilon$-nodes are connected. Our reconfiguration schedule works according to the following \emph{parts}. \begin{enumerate} \item \%Let $M$ be an MIS over isolated components of diameter~$\le2$. \begin{enumerate} \item Update the components in $M$ \item Update the other components of diameter~$\le2$. \end{enumerate} \item \%For each component $V_i$ of diameter 3, we select an $\epsilon$-node $u_i$, an $\alpha$-nodes $a_i$ and a $\beta$-node $b_i$ as described above. That is, $(u_i,a_i)\not\in E$ and $(u_i,b_i)\not\in E$. Let $M'$ be an MIS over the nodes $\{u_i\}_{i\in I}$. Note that if $u_i$ is not in $M'$, it has a neighbor $u_j$ that is in $M'$, and $u_j$ covers $V_i$. Let $S_k$ be the current set of the schedule (we will have that $k=4$). \begin{enumerate} \item $S_{k+1} = S_k \setminus \bigcup_{u_i \in M'} N_\alpha(u_i)$. \% Remove all $\alpha$-neighbors of the MIS nodes \item $S_{k+2} = S_{k+1} \cup M'$. \%Add all the MIS nodes. \item $S_{k+3} = S_{k+2} \setminus (\alpha \cap(\bigcup V_i))$. \%Remove all the $\alpha$-nodes of all the $V_i$ \item $S_{k+4} = S_{k+3} \cup (\bigcup_{i: u_i \in M'} b_i \bigcup_{j: u_j \not\in M'} (\beta\cap V_j))$. \\\%For each $u_i\in M'$, add $b_i$. For each $u_j\not\in M'$, add $\beta$-nodes of $V_j$ \item $S_{k+5} = S_{k+4} \setminus M'$. \%Remove $M'$ \item $S_{k+6} = S_{k+5} \cup (\beta \cap(\bigcup V_i))$.\%Add the remaining $\beta$-nodes \end{enumerate} \end{enumerate} For the length of the schedule, notice that parts 1a and 1b require two steps each, by the definition of updating a component. Part 2 requires 6 steps, summing to 10 steps in total. For correctness, condition (1) of Definition~\ref{def:schedule} trivially holds, as the schedule reconfigures all nodes. Moreover, by the definition of updating a component, and by inspection of part 2, it is also immediate that we do not reconfigure two neighbors in a single step, thus the schedule satisfies condition (3) of Definition~\ref{def:schedule}. For condition (2), the definition of updating a component and inspection of part 2 also guarantee that each $S_i$ is an independent set. The remainder of the proof shows that each $S_i$ in the schedule is also $4$-dominating. For parts 1a and 1b, note that having an MIS over the components promises that whenever a component gets updated it has a neighboring component that stays untouched. For part 2, the arguments are the following. The sets $S_6, S_8, S_{10}$ are supersets of $S_5, S_7, S_9$, respectively, and therefore we only need to show domination for the latter. In $S_{5}$ we have that all the nodes $a_i$ dominate the components, as they are not connected to the removed nodes $u_i$. In $S_7$ we have that the nodes in $M'$ cover everything. Finally, in $S_9$ we have that the nodes $b_i$ cover all the components. For the number of communication rounds, it is easy to see that the schedule can be found in $O(\texttt{MIS})$ rounds, where $\texttt{MIS}$ is the complexity of finding an MIS on a worst-case graph, as needed. \end{proof} \subsection{Completing the proof} We can now wrap-up all the ingredients and prove Theorem~\ref{th:main}. \begin{proof}[\textbf{Proof of Theorem~\ref{th:main}}] We describe the full $(\alpha,\beta,P)$-reconfiguration schedule $S$. First, each node $v$ in $V_{\alpha,\beta} = \alpha \cap \beta$ sends a message to its neighbors in $N(v)$ and outputs that it is in $S_i$ for all $0 \leq i \leq 28$. Each node that received such a message, sends a message to its neighbors and outputs that it is not in $S_i$ for all $0 \leq i \leq 28$. By Lemma~\ref{lemma:alpha-beta-nodes}, this is consistent with any reconfiguration schedule for the rest of the nodes. The nodes that produced an output terminate and any edges incident to them are removed from the graph. Next, all nodes collect their 4-hop neighborhood to decide whether they are in a component of diameter $\geq 3$ or not, and if not then whether they are in an isolated component. The components of diameter $\geq 3$ and the non-isolated components compute the reconfiguration schedule of 18 steps, as given in Lemma~\ref{lemma:non-isolated}, which we denote by $S'_0,\dots,S'_{18}$. The isolated components of diameter $\leq 3$ compute the reconfiguration schedule of 10 steps, as given in Lemma~\ref{lemma:isolated}, which we denote by $S''_0,\dots,S''_{10}$. Formally, the $(\alpha,\beta,P)$-reconfiguration schedule is now $S_i = S''_0\cup S'_i \cup V_{\alpha,\beta}$ for $0 \leq i \leq 18$ and $S_i = S''_{i-18} \cup S'_{18} \cup V_{\alpha,\beta}$ for $18 \leq i \leq 28$. It is computed within $O(\texttt{MIS}+\texttt{R32})$ rounds. \end{proof} \section{MIS reconfiguration in a constant number of rounds} \label{sec:const-round} \begin{theorem-repeat}{th:conscomm}\textbf{(formal)} Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set. For any graph $G=(V,E)$ and any input $G_{input}=(V,E,\alpha),G_{output}=(V,E,\beta)$ to the MIS-reconfiguration problem, there exists an $(\alpha, \beta, P)$-reconfiguration schedule of length $\Theta(f(n))$, where $f(n)$ is the largest identifier among the nodes in the graph, which can be found in $O(1)$ rounds. \end{theorem-repeat} To prove this, we first prove the following lemma, stating that we can always reconfigure locally an independent set to add elements from $\beta$ without losing any element in $\alpha\cap\beta$. \newcommand{\LemmaConstRounds} { Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set. For any graph $G=(V,E)$ of diameter greater than 5, two MIS $\alpha$ and $\beta$ and $v\in\beta\setminus\alpha$, there exists an MIS $\gamma$ such that \begin{enumerate} \item $(\alpha\cap\beta)\subset\gamma$ and $v\in\gamma$, and \item there exists an $(\alpha, \gamma, P)$-reconfiguration schedule of length 6. Moreover, for finding the reconfiguration schedule the nodes only need to know the topology of their 5-hop neighborhood and therefore can be found in $O(1)$ rounds. \end{enumerate} } \begin{lemma} \label{lemma:constant-rounds} \LemmaConstRounds \end{lemma} \begin{proof}[\textbf{Proof of Lemma~\ref{lemma:constant-rounds}}] Note that because the diameter is greater than 5, there are always nodes at distance 3 from any node. Our schedule will always be an alternation of removing nodes, and adding independent nodes to the set, which ensures property (2) of the definition. Each time we want to reconfigure a node $v$ to be added to the independent set, we first remove its neighbors in $N_\alpha(u)$, which ensures the independence part of the property (2). To be able to do so, we always ensure that neighbors at distance 2 from $v$ are covered (4-dominated), as those include the neighbors of $N_\alpha(v)$, which permits to satisfy the covering property of (2). For an independent set $X$, we define $GC(X)$ as the greedily completion of $X$ to be an MIS. Note that if the longest distance between two nodes that are added is constant, this can be done in a constant number of steps. Note that we will give priority to $\beta$-nodes and then $\alpha$-nodes during the completion. First, consider the case where there exists an $\alpha$-node $u$ at distance 2 from $v$. Notice that $u$ covers all the nodes at distance $2$ from $v$. We can remove $N_\alpha(v)$ from the independent set, then add $v$ to it, and finally complete the current independent set greedily to be maximal. Formally, we define $\gamma=GC(\{v\}\cup\alpha\setminus N_\alpha(v))$ and we have $S_0=\alpha$, $S_1=S_0\setminus N_\alpha(v)$, $S_2=S_3=S_4=S_5=S_6=\gamma$. From now on, we consider the case that only $\beta$-nodes and $\epsilon$-nodes are at distance 2 from $v$. We differentiate several cases depending on the neighborhood of nodes at distance 2 from $v$: \begin{enumerate} \item There exists a node $u$ at distance 2 from $v$ such that $N(u)\cap N_\alpha(v)=\emptyset$: Let $u_1$ be a node in $N(v)\cap N(u)$. Then $u_1$ is an $\epsilon$-node, as it cannot be an $\alpha$-node by the assumption, nor a $\beta$-node (as $v$ is a $\beta$-node). The node $u_1$ must have a neighbor in $N_\alpha(v)$, as the nodes in $N_\alpha(u_1)$ cannot be in distance 2 from $v$. That $\alpha$-node covers $u$ and the nodes at distance 2 from $u$. Hence, we can remove all nodes in $N_\alpha(u)$: $S_1=\alpha\setminus N_\alpha(u)$. We can then add $u$ to the independent set: $S_2=S_1\cup\{u\}$. Now, $u$ covers $N_\alpha(v)$ and its neighborhood, so we can remove those nodes from the independent set: $S_3=S_2\setminus N_\alpha(v)$. Next, $v$ can be added to the independent set and then $u$ and its neighbors are covered by $v$: $S_4=S_3\cup\{v\}$. Hence, we can then remove $u$ from the independent set, and finally add $N_\alpha(u)$ back to the independent set: $S_5=S_4\setminus\{u\}$, $S_6=\gamma=GC(S_5\cup N_\alpha(u))$. \item There exists a node $u$ at distance 2 from $v$ such that $N_\alpha(v)\subseteq N(u)$ and $u$ has a neighbor $u_3$ that is at distance 3 from $v$: Notice that $u_3$ covers all nodes in $N_\alpha(v)$ and their neighbors. Symmetrically, all nodes in $N_\alpha(v)$ cover $u_3$ and its neighbors at distance 2. First we remove all nodes in $N_\alpha(u_3)$ and then add $u_3$ to the independent set (we do nothing if $u_3$ itself is in $\alpha$): $S_1=\alpha\setminus N_\alpha(u_3)$, $S_2=S_1\cup\{u_3\}$. We then remove $N_\alpha(v)$ from the independent set, and then add $v$: $S_3=S_2\setminus N_\alpha(v)$, $S_4=S_3\cup\{u\}$. Finally, we can put $u_3$ and its neighborhood back in their initial states: $S_5=S_4\setminus\{u\}$, $S_6=\gamma=GC(S_5\cup N_\alpha(u))$. \item There exists a node $u$ at distance 2 from $v$ that has no neighbor at distance 3 from $v$, and there exists a node $a$ in $N_\alpha(v)$ that is not in the neighborhood of $u$: We can remove $N_\alpha(u)$, as $a$ covers those nodes and their neighborhood, and we can then add $u$: $S_1=\alpha\setminus N_\alpha(u)$, $S_2=S_1\cup\{u\}$. Now, we can remove what remains of $N_\alpha(v)$, and then add $v$: $S_3=S_2\setminus N_\alpha(v)$, $S_4=S_3\cup\{v\}$. Finally, we remove $u$: $S_5=S_4\setminus\{u\}$, $S_6=\gamma=GC(S_5)$. \item Now we are in a situation where all nodes at distance 2 from $v$ that have no neighbor at distance 3 from $v$ have $N_\alpha(v)$ in their neighborhood. Let's call $U_2$ the set of nodes at distance 2 from $v$ with a neighbor at distance 3 from $v$. For each $u\in U_2$, we call $u_3$ one of its neighbor which is at distance 3 from $v$. We know that $u$ has at least one node in $N_\alpha(v)$ in its neighborhood, and we will call it $a_u$. The node $a_u$ covers $u_3$ and its neighborhood at distance 2. We can remove $N_\alpha(u_3)$ and add $u_3$ for all $u\in U_2$: $S_1=\alpha\setminus\bigcup\limits_{u\in U_2}N_\alpha(u_3)$, $S_2=S_1\bigcup\limits_{u\in U_2}\{u_3\}$. We need now to prove that each vertex in $N_\alpha(v)$ and its neighborhood is covered by some $u_3$. It is true for $N_\alpha(v)$ as each $u_3$ is at distance 3 from $v$. It is also true for $v$. It remains to show this for the nodes at distance 2 from $v$. For those who have a neighbor at distance 3, they are in $U_2$ and have by construction a $u_3$ in their direct neighborhood. For the others, these nodes have $N_\alpha(v)$ in their neighborhood, otherwise we would be in case 3. Hence, they are at distance at most 4 from any $u_3$. We can remove $N_\alpha(v)$ from the independent set, and we can then add $v$: $S_3=S_2\setminus N_\alpha(v)$, $S_4=S_3\cup\{u\}$. We then remove all the $u_3$ nodes and put back their neighborhood: $S_5=S_4\setminus\bigcup\limits_{u\in U_2}\{u_3\}$, $S_6=\gamma=GC\left(S_5\bigcup\limits_{u\in U_2} N_\alpha(u_3)\right)$. \end{enumerate} Note that in this process, the only nodes actually removed from the independent set are those in $N_\alpha(v)$, are we have put back all the other ones. As $v\in\beta$, it means that $N_\alpha(v)\cap\beta=\emptyset$. Hence, we did not remove any node from $\alpha\cap\beta$. \end{proof} Lemma~\ref{lemma:constant-rounds}, means that for any element $v$ in $\beta$, we can add $v$ to the current MIS in a constant number of steps without losing any element of $\beta$ already in the MIS. It allows us to prove Theorem~\ref{th:conscomm} as follows. \begin{proof}[\textbf{Proof of Theorem~\ref{th:conscomm}}] Nodes use their identifiers to know when to start their own reconfiguration. A node with identifier $k$ uses slots $[6k+1, 6(k+1)]$ for its schedule. Since a node only needs to know its 5-hop neighborhood, this completes in $O(1)$ rounds. \end{proof} If the identifiers are guaranteed to be $\{1,\dots, n\}$ then Theorem~\ref{th:conscomm} gives that a constant number of rounds is sufficient for a linear length schedule. However, we can do even better by using coloring algorithms, as stated in the following corollary. \begin{corollary} \label{cor:coloring} Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set. For any graph $G=(V,E)$ and any input $G_{input}=(V,E,\alpha),G_{output}=(V,E,\beta)$ to the MIS-reconfiguration problem, if the nodes are given a $k$-coloring of $G^{10}$, then there exists an $(\alpha, \beta, P)$-reconfiguration schedule of length $O(k)$, which can be found in $O(1)$ rounds. \end{corollary} \section{A complete characterization for the existence of a reconfiguration schedule with 4-domination} \label{sec:characterization} The following gives an exact characterization of inputs for which there exists a reconfiguration schedule with 4-domination. In what follows, we say that two sets of nodes $U_1$ and $U_2$ are \emph{fully connected} if every node in $U_1$ is a neighbor of every node in $U_2$. If $U_1$ contains only a single node, then we simply say that this node is fully connected to $U_2$. \newcommand{\ThmChar} { Let $P$ be the property of $(V,E,U)$ that says that $U$ is a (2,4)-ruling set. For any input $G_{input}=(V,E,\alpha),G_{output}=(V,E,\beta)$ to the MIS-reconfiguration problem, there does not exists an $(\alpha, \beta, P)$-reconfiguration schedule if and only if: \begin{enumerate} \item The sets $\alpha$ and $\beta$ are fully connected. \item Let $\epsilon_\alpha$ (resp. $\epsilon_\beta$) be the set of $\epsilon$-nodes that are fully connected to $\alpha$ (resp. $\beta$). Then all the $\epsilon$-nodes are in $\epsilon_\alpha\cup\epsilon_\beta$. \item Let $G'=(V'=\epsilon_\alpha\cup\epsilon_\beta,E'=\overline{E_{V'}}) $, where $\overline{E_{V'}}$ is the complementary of $E$ restricted to vertices of $V'$. Then there is no path from $\epsilon_\alpha\setminus\epsilon_\beta$ to $\epsilon_\beta\setminus\epsilon_\alpha$ in $G'$. \end{enumerate} } \begin{theorem} \label{thm:characterization} \ThmChar \end{theorem} \begin{proof} \textbf{If there is no schedule then Conditions (1), (2), and (3) hold:} Let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be such that there is no $(\alpha,\beta,P)$-reconfiguration schedule. First, since Theorem~\ref{th:main} produces a schedule when the diameter is greater than 3, we know that the diameter of $G$ is bounded by $3$. This implies the powerful property that it is sufficient for a single node to be part of the set, for any intermediate independent set, because such a node clearly $4$-dominates the rest of the graph. Since there is no reconfiguration schedule, for any sequence of independent sets that are $4$-dominating, there is a node in $\beta$ that is not added to the set. But we can say something stronger, which is that for \emph{any} node $v\in\beta$, no schedule adds $v$ to the independent set. The reason is that if there is a schedule that adds $v\in\beta$, then since it 4-dominates the entire graph, in the next step in the sequence we could remove all other nodes from the set, and complete it in the next step with all other $\beta$-nodes, which contradicts that assumption that there is no reconfiguration schedule. Now, let $v\in\beta$, and consider the categories in the proof of Lemma~\ref{lemma:constant-rounds}, which shows how to add every node in $\beta$ to the independent set. Since the proof produces a schedule if there exists any node at distance 3 from $v$ or a node in $\alpha$ at distance 2, this implies that $v$ is fully connected to $\alpha$. Since this holds for any $v\in\beta$, we have that $\alpha$ and $\beta$ are fully connected, proving Condition (1). Suppose that there exists an $\epsilon$-node $e$ that is not connected to some $a\in\alpha$ and some $b\in\beta$. Then $S_1=\{a\}$, $S_2=\{a,e\}$, $S_3=\{e\}$, $S_4=\{e,b\}$, $S_5\{b\}$ and $S_6=\beta$ is an $(\alpha,\beta,P)$-reconfiguration schedule, proving Condition (2). By contradiction, we prove Condition (3). Suppose that there exists $T=(e_0,e_1,\ldots,e_k)$ such that $e_0\in\epsilon_\beta\setminus\epsilon_\alpha$, $e_k\in\epsilon_\alpha\setminus\epsilon_\beta$ and $\forall i<k, (e_i,e_{i+1})\not\in E$. The crux here is that we can have both $e_i$ and $e_{i+1}$ in an intermediate set. This means that every two steps, we can add an element $e_i$ of the path $T$, after removing $e_{i-2}$. Note that, as $e_0\in\epsilon_\beta\setminus\epsilon_\alpha$ (resp. $e_k\in\epsilon_\alpha\setminus\epsilon_\beta$), there exists $a\in\alpha$ (resp. $b\in\beta$) such that $e_0$ and $a$ (resp. $e_k$ and $b$) are not connected. More formally, we have the following $(\alpha,\beta,P)$-reconfiguration schedule: $S_1=\{a\}$, $S_2=\{a,e_0\}$, $\forall i<k, S_{2i+3}=\{e_{i}\}$, $S_{2i+4}=\{e_i,e_{i+1}\}$, $S_{2k+3}=\{e_k\}$, $S_{2k+4}=\{e_k,b\}$, $S_{2k+5}\{b\}$ and $S_{2k+6}=\beta$ \textbf{If Conditions (1), (2), and (3) hold then there is no schedule:} Let $G=(V,E,\alpha)$ and $G=(V,E,\beta)$ be such that Conditions (1), (2), and (3) hold. Suppose that there exists an $(\alpha,\beta,P)$-reconfiguration schedule $(S_i)_{i\le N}$ of length $N$. For any $0\leq i\leq N-1$, if $S_i$ contains nodes from $\alpha$, then the only nodes that can be added in $S_{i+1}$ are nodes in $\epsilon_\beta\setminus\epsilon_\alpha$ (the other nodes are fully connected to $\alpha$, by Conditions (1) and (2)). Similarly, for any $0\leq i\leq N-1$, if $S_{i+1}$ has a node in $\beta$, then $S_i$ has only nodes from $\epsilon_\alpha\setminus\epsilon_\beta$. Let $i_1=\max\{i~|~ S_i\cap\alpha\neq\emptyset\}$ and $i_2=\min\{i ~|~ i> i_2 \text{ and }S_i\cap\beta\neq\emptyset\}$. Since $\alpha$ and $\beta$ are disjoint, because both sets are independent and fully connected to each other, it holds that $i_1$ and $i_2$ are well defined, and that $i_1<i_2$. Now, $S_{i_1+1}$ only contains nodes in $\epsilon_\beta\setminus\epsilon_\alpha$, as $S_{i_1}\cap S_{i_1+1}$ must be independent. Similarly, $S_{i_2-1}$ only contains nodes in $\epsilon_\alpha\setminus\epsilon_\beta$. By definition of $i_1$ and $i_2$, for all $i_1 < i < i_2$, it holds that $S_i\in V'$. In adidtion, for all $i_1 < i < i_2$, each node in $S_{i+1}$ is connected to each node in $S_i$ in $G'$, as those nodes must form an independent set in $G$. Hence, by induction, the nodes in $\bigcup\limits_{i_1 < i < i_2}{S_i}$ form a connected component in $G'$. But this contradicts Condition (3). \end{proof} \section{Impossibility results for MIS reconfiguration} \label{sec:impossibilities} \vspace{-0.25cm} We show here two types of impossibility results. One is the necessity of $4$-domination in the sense that $3$-domination cannot be obtained, and the other is the necessity of $\Omega(\log^*{n})$ rounds with $4$-domination, even on bounded degree graphs where it matches the complexity we provide in Corollary~\ref{cor:log-star}. \subparagraph{Impossibility of MIS reconfiguration with 3-domination} \begin{theorem-repeat}{prop:3dom} \PropThreeDom \end{theorem-repeat} \begin{figure}[h] \begin{center} \includegraphics[scale=0.75, trim= 0cm 10.7cm 0 3.7cm, clip]{3-dom} \end{center} \caption{White nodes are $\alpha$-nodes, and grey nodes are $\beta$-nodes. For the graph on the top, there is no schedule with 3-dominating sets. For the graph on the bottom, any schedule with 3-dominating sets must be of linear length and requires a linear number of rounds to be found.} \label{fig:3dom} \end{figure} \begin{proof}[\textbf{Proof of Theorem~\ref{prop:3dom}}]\ For (1), Figure \ref{fig:3dom} (top) is an example. Consider the first $\beta$-node (grey) we try to reconfigure. This requires that all of its $\alpha$-neighbors (white) are removed from the set. But then the $\alpha$-neighbor (white) above this $\beta$-node is not $3$-dominated by any $\alpha$-node. For (2), Figure \ref{fig:3dom} (bottom) is an example. According to the previous argument, here we have that the top left $\beta$-node (grey) must be reconfigured first. This is possible by first removing its $\alpha$-neighbors, and then we can reconfigure the rest of the $\beta$-nodes one after the other following the path by first removing each one's $\alpha$-neighbors. This is a linear schedule which clearly requires a linear number of rounds to deduce. No shorter reconfiguration schedule is possible, by the argument for the previous item. \end{proof} \subparagraph{An $\Omega(\log^*n{})$ lower bound for MIS reconfiguration with 4-domination} \begin{theorem-repeat}{prop:log-star} \Proplogstar \end{theorem-repeat} \begin{figure}[h] \begin{center} \includegraphics[scale=0.75, trim= -1cm 14.2cm 0 5cm, clip]{3-reg} \end{center} \caption{White nodes are $\alpha$-nodes, grey nodes are $\beta$-nodes, and black nodes are $\epsilon$-nodes. Here, $\Omega(\log^*{n})$ rounds are needed with 4-domination.} \label{fig:3reg} \end{figure} \begin{proof}[\textbf{Proof of Theorem~\ref{prop:log-star}}] Figure \ref{fig:3reg} is an example for $k=3$. For $k\ge4$, replace the pairs of white-grey nodes by a clique of size $k-1$ containing one white and one grey node. It is not possible to add at the same time three consecutive white nodes in the independent set, as this violates the domination. Now, suppose we have an algorithm that finds a constant reconfiguration schedule in $o(\log^*n)$ rounds. We prove that it permits computing an MIS on a path in $o(\log^*n)$ rounds, which would be a contradiction to Linial's celebrated lower bound~\cite{Linial92}. Given the input path, we create a virtual graph where each node is replaced by two $\epsilon$-nodes connected to a clique of size $k-1$ containing an $\alpha$-node, a $\beta$-node and $k-3$ $\epsilon$-nodes (we transform the path into an instance of our counter-example). We compute a constant schedule of length $K$ in $o(\log^*n)$ rounds. Each initial node chooses the first time its $\beta$-node joined the independent set as its color in a $K$-coloring. The coloring is not necessarily proper, but it has the property that three consecutive nodes cannot have the same color. Also, as we have $K$ colors, there must be a local minimum within distance $2K$ from any node, which implies that within $O(K)=O(1)$ rounds we can obtain an MIS out of this coloring. This gives an MIS algorithm on paths in $o(\log^*n)$ rounds, which is a contradiction. \end{proof} \begin{corollary} For any fixed $k$ and $d$, there exists a class of $k$-regular inputs $G=(V,E)$ with two MIS $\alpha$ and $\beta$ such that any reconfiguration schedule of constant length with $d$-domination needs $\Theta(\log^*n)$ rounds to be found. \end{corollary} \begin{proof} The proof is the same as above with the same graph. The only difference is that, instead of not accepting 3 consecutive nodes to be added the same time, we now have $\left\lfloor\frac{2d+1}3\right\rfloor$ nodes. \end{proof} \section{Discussion and Open Questions} \label{sec:discussion} This paper defines relevant constraints for finding a reconfiguration schedule of maximal independent sets in a distributed setting. For constant-length schedules in bounded-degree graphs we completely settle the required complexity, as we provide an algorithm completing in $\Theta(\log^*n)$ communication rounds, and prove that no lower complexity exists. A main open question that remains is: Can a better complexity be found for general graphs? Our definition only uses addition and removal of elements to the intermediate independent sets. We propose the following question: Can an efficient distributed reconfiguration schedule be found if the system allows that intermediate steps are 3-dominating and the transitions used can be any combination of addition, removal and Token Sliding? Finally, we used as a hypothesis that the given independent sets are maximal. Our algorithm still works when the sets are not maximal, as it suffices to complete those. For example, if we are given (2,4)-ruling sets (which is equivalent to the 4-domination condition of $P$), the problem is solved. An interesting question could be to generalize for other $(a,b)$-ruling sets. What relation between $a$ and $b$ is needed to ensure that a schedule exists, and that it can be found efficiently with a distributed algorithm? ~\\\textbf{Acknowledgements:} The authors thank Alkida Balliu, Michal Dory, Seri Khoury, Dennis Olivetti, and Jukka Suomela for helpful discussions.\\ This project has received funding from the European Union's Horizon 2020 Research And Innovation Programe under grant agreement no.~755839 and it was supported in part by the Academy of Finland, Grant 285721. \bibliographystyle{plain}
{'timestamp': '2019-02-21T02:12:58', 'yymm': '1810', 'arxiv_id': '1810.02106', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02106'}
arxiv
\section{Background} \label{section:background} Owing to the difficulties in handling legal jargon, efficient and effective computing applications in the field are somewhat sparse. The study by~\citet{schweighofer1993legal} claims that there is a significant vacuum in computerized applications for the field of law which have resulted in an information crisis. The fact that legal vocabulary have words of mixed origin such as English and Latin has been raised as a reason for the difficulty of creating computing applications for the legal domain~\cite{sugathadasa2018legal}. However, recently, there have been attempts to involve and build legal ontologies~\cite{jayawardana2017deriving,jayawardana2017semi} as well as attempts to calculate similarity measures in legal domain text~\cite{sugathadasa2017synergistic} and build information retrieval systems thereof~\cite{sugathadasa2018legal}. Given the popularity of knowledge embedding, a number of studies have also attempted to embed legal jargon in vector spaces~\cite{sugathadasa2017synergistic,nay2016gov2vec}. A more recent study by~\citet{ratnayaka2018identifying} uses discourse relations in an attempt to identify relationships among sentences in court case transcripts. Social media is one of the most used domains for research in sentiment analysis due to the availability of plentiful data. Social media platforms usually contain opinions expressed by people on various topics including politics, sports, entertainment, and others. For instance,~\citet{pak2010twitter} states a research conducted in analyzing language in Twitter posts of millions of users, along with a method to automatically collect a corpus with positive and negative sentiments, where the authors have performed statistical linguistic analysis on the collected corpus and built a sentiment classification system for micro-blogging. They have used a Naive Bayes classifier that uses N-grams and part-of-speech tags as features to train the model. This method is not suitable for analyzing legal text because of the inherent objectivity that needs to be preserved in law. \textit{Sentiment classification} is also known as \textit{opinion mining}~\cite{esuli2007sentiwordnet}. As such, the study on \textit{Opinion Mining} in legal blogs~\cite{conrad2007opinion} is closest implementation for this study that we have found in the literature. The \textit{Lingpipe} toolkit, of which the sentiment annotation is based on a character-based language model, is used for the sentiment classification in the approach by~\citet{conrad2007opinion}. Further, the data set used for evaluation is based on movie reviews, customer reviews, and MPQA corpus~\cite{wiebe2005annotating}. SentiWordNet~\cite{esuli2007sentiwordnet,baccianella2010sentiwordnet} classifies synsets of WordNet~\cite{miller1995wordnet} to three classes; \textit{negative}, \textit{positive}, and \textit{objective}. Synsets that do not contain opinionated content are assigned to the \textit{objective} class while the Synsets that do contain opinionated content are assigned to the \textit{subjective} which is then further classified into the two classes \textit{negative} and \textit{positive} depending on the sentiment it carries. There have been numerous studies that were built upon SentiWordNet~\cite{esuli2007sentiwordnet,baccianella2010sentiwordnet} which attempts to classify sentiments of phrases and sentences. One such study by \citet{ohana2009sentiment} proposes a methodology to perform opinion mining on movie reviews using support vector machine where some of the features were calculated using WordNet. This achieves an accuracy of 69.35\% and claims that the inaccuracies in SentiWordNet feature calculations are caused by the SentiWordNet's reliance on glosses.~\citet{lu2012unsupervised} evaluates the SentiWordNet for identifying opposing opinion networks in forum discussion. The average SentiWordNet opinion score of words is considered to identify whether a user's expressed comment for a given post has either \textit{for} or \textit{against} relationship. The achieved accuracy using the SentiWordNet opinion score of words is 56\%. The method proposed by \citet{socher2013recursive} provides an algorithm to identify the sentiment of a phrase or a sentence in a supervised manner using a deep learning model of the type Recursive Neural Tensor Network (RNN). It is claimed that this learning model has the capability to identify the sentiment considering the context of that word. A dataset which consists of movie reviews where each sentence in the data set was broken into phrases and each phrase is annotated by human judges were created for this study. The authors claim a testing accuracy of 80.7\% in phrase level for a test set drawn from the same dataset. Further, the authors claim that the proposed model can be trained over any domain by following the provided methodology. While, theoretically, it is possible, following this for legal domain in a practical implementation which covers a corpus which is both significant and sufficient is difficult. This claim is substantiated by referring the dataset of the original research~\cite{socher2013recursive} which utilized 215,154 manually annotated phrases (from 11,855 sentences) with over 5355 unique words. In comparison to this, the legal corpus used in our study has a vocabulary exceeding 17000 words. The difficulties are not mealy of scale given that the linguistic complexity of legal jargon exceeds that of the average text corpus~\cite{jayawardana2017semi,jayawardana2017word,sugathadasa2017synergistic,sugathadasa2018legal}. It is observed that the Recursive Neural Tensor Network (RNTN) model by \citet{socher2013recursive} shows better accuracy in sentiment classification compared to other models. However, the trained model being biased towards the movie reviews which it was trained on is a difficulty that needs to be overcome. For this purpose, several studies~\cite{raina2007self,socher2013zero} claim the process of \textit{domain adaptation} to be a suitable solution. \textit{Domain adaptation} is a sub-category of \textit{Transfer Learning}~\cite{raina2007self}. While the generic process of transfer learning is defined as the process of ``learning model is trained using data from a certain domain and tested with respect to a different domain''~\cite{raina2007self}, the specific case of \textit{domain adaptation} occurs when the Since the task is same in both source and target model. Given that both this study and the original study by \citet{socher2013recursive} works on sentiment classifying, the transfer learning done in this study falls under the definition of domain adaptation~\cite{raina2007self}. Even though transfer learning is not very common in the NLP field, it is extensively used in other fields such as image classification \cite{quattoni2008transfer,raina2007self}. The aim of this study is also to build a sentiment classifier specific to the legal domain. But to prepare a manually labeled data set for training purpose is a costly process in terms of time and human effort. Therefore, a \textit{Transfer Learning} approach is used to adapt the RNTN model \cite{socher2013recursive} to the legal domain. When a learning model is trained using data from a certain domain and tested with respect to a different domain, it is called \textit{Transfer Learning} approach~\cite{raina2007self}. Since the task is same in both source~\cite{socher2013recursive} and target model for legal domain, the task belongs to the subcategory called \textit{Domain Adaptation} as mentioned in \cite{raina2007self,socher2013zero}. Image classification \cite{quattoni2008transfer,raina2007self} is a field where transfer learning is vastly used. \section{Conclusion and Future Work} \label{section:conclusions} This study is focused on building an automatic sentiment annotator for legal texts based on the \textit{Recursive Neural Tensor Network (RNTN)} model mentioned in~\citet{socher2013recursive}. Furthermore, this study can be identified as a transfer learning approach as it is not required to prepare a training data set for the legal domain specifically. Instead, this approach uses the same training data set stated in~\citet{socher2013recursive}. This task can be recognized as a domain adaptation task. The proposed approach could achieve a 70.14\% recall in identifying phrases with negative sentiments (improvement is 10\% compared to the source model). The accuracy of the target model is above 76\% which is a 6\% improvement over the source model. The proposed methodology can be adjusted for any domain adaptation task other than the legal domain, which makes this study more important. To train the model, it is not required to prepare manually annotated data for a specific domain. Another advantage is that if there are improvements introduced to the source model, those improvements can be inherited to the target model as well. The major disadvantage associated with this model is that the accuracy of the target model will be limited by the source model in most occasions. In other words, it is hard to exceed the accuracy shown by the source model for its own domain. There are words which produce one sentiment when they are combined but provide completely different sentiments when considered as individual elements. If we consider the term ``cover up'' in the legal domain, it has a meaning of hiding some mistake or crime. Therefore, it should have a negative sentiment. But the individual terms do not indicate negative sentiment. Therefore, the results can be further improved by considering bi-grams and tri-grams. The improved version of the Stanford CoreNLP sentiment annotator \cite{socher2013recursive} could be used for further research on using machine learning for the legal domain. Furthermore, the transfer learning method we have described in this study is adjustable for any domain to build an automated sentiment annotator. \section{Experiments and Results} \label{section:experiments-and-results} The proposed approach in this paper is based on transfer learning. Therefore, we needed to create a golden standard for identifying sentiments of phrases and sentences in the legal domain in order to evaluate the model. The phrases and sentences for the test data set are randomly picked from legal case transcripts based on the United States Supreme Court. During the selection process, we have selected an equal amount of phrases for both classes according to the~\textit{Socher Model}. Each of these phrases and sentences is annotated by three human annotators. Since the classification process is binary, we pick the sentiment class for each test subject based on the maximum number of votes. In the end, we prepare the test data set containing nearly 1500 annotations to use in the evaluation process. In the experiment, we compare the sentiment class picked by human judges and the modified RNTN model. As the baseline model, we use the source RNTN model (\textit{Socher Model}) to check the impact caused by the proposed transfer learning approach. The acquired results from the baseline model is shown in Table \ref{table:confusion_matrix_original_model} and results from the target model is shown in Table \ref{table:confusion_matrix_improved_model}. According to Table \ref{table:confusion_matrix_original_model} and Table \ref{table:confusion_matrix_improved_model}, there is a 10\% improvement in identifying phrases with negative sentiment. The reason is that there are a lot of unknown words which are in the legal domain but not in movie reviews corpus. In addition, we have introduced new criteria based on a threshold for the score of negative class to improve the recall. Due to that reason, the precision in identifying phrases with a negative sentiment is 84.41\%. But if we compare with the precision of the baseline model (\textit{Socher Model}) for negative sentiment class is 79.62\% which is a lower value. Since the test dataset is not skewed a lot towards one class, it is fair to consider the accuracy of the system in predicting the sentiment for any given phrase. The baseline model shows the accuracy of 70.17\% while the target model shows 76.80\%. The improvement in accuracy is above 6\%. \newcommand{\shadedCell}[1]{ #1\% \cellcolor{gray!#1!white} } \begin{table}[h] \begin{center} \begin{tabular}{|c|c|c|c|} \hline \diagbox[width=7em]{Actual}{Predicted} & \thead{Negative} & \thead{Non\\negative} & \thead{Total} \\ \hline \textbf{Negative} & \shadedCell{60.43} & \shadedCell{39.57} & 278 \\ \cline{1-4} \textbf{Non-negative} & \shadedCell{18.29} & \shadedCell{81.71} & 235 \\ \cline{1-4} \thead{Total} & 211 & 301 & 513 \\ \hline \end{tabular} \caption{Confusion Matrix for Results from the Baseline Model} \label{table:confusion_matrix_original_model} \end{center} \end{table} \begin{table}[h] \begin{center} \begin{tabular}{|c|c|c|c|} \hline \diagbox[width=7em]{Actual}{Predicted} & \thead{Negative} & \thead{Non\\negative} & \thead{Total} \\ \hline \textbf{Negative} & \shadedCell{70.14} & \shadedCell{29.86} & 278 \\ \cline{1-4} \textbf{Non-negative} & \shadedCell{15.32} & \shadedCell{84.68} & 235 \\ \cline{1-4} \thead{Total} & 231 & 282 & 513 \\ \hline \end{tabular} \caption{Confusion Matrix for Results from the Improved Model} \label{table:confusion_matrix_improved_model} \end{center} \end{table} The observed results in Table \ref{table:confusion_matrix_original_model} and Table \ref{table:confusion_matrix_improved_model} show that there is a 6\% improvement of the sentiment with respect to the baseline model. There are a few reasons behind the results. As we randomly selected phrases from the legal case transcripts corpus, only 45\% of the phrases actually contained the words where we had substituted the vector regarding sentiment. Therefore, the output for 55\% of the phrases from the baseline model and the target model was the same. If we compare the output provided by the baseline model and the target model, output of 9.5\% of the total phrases are different to each other. Therefore the difference between the two models is based on that 9.5\% of the total phrases. \section{Introduction} Sentiment analysis tasks are a common component in many Natural Language Processing (NLP) applications. As described by~\citet{esuli2007sentiwordnet}, sentiment analysis or \textit{sentiment classification} is a recent methodology that aligns with information retrieval and computational linguistics which is focused on the opinion towards something which is represented by a certain text. In many recent studies involving NLP in various domains, it is common to reuse the seminal RNTN (Recursive Neural Tensor Network) model~\cite{socher2013recursive} trained on movie reviews for sentiment analysis. However, it is obvious that this trained model has bias towards the movie review text on which it is based. The traditional way to remedy this problem is to retrain the model from scratch using the same algorithm. But, the algorithm proposed by~\citet{socher2013recursive} is quite manual labour intensive given that it requires a significantly large enough corpus annotated on sentiment manually. This difficulty is the reason for most natural language processing applications to reuse the original model despite the mismatch between the trained domain and the domain to which it is being applied. Law is a field involving grand collisions of ideas, most of which are in the form of written text, thus open to linguistic research. However, the language used in these documents is rather complex and esoteric to a certain degree, which makes it challenging to be utilized in intelligent systems. Lawyers, paralegals, and other legal professionals spend a considerable part of their time reading transcripts of past court cases, taking notes and collecting precedents to make their case stronger in court. This task is cumbersome and time-consuming. Therefore, it is an open opportunity for computer scientists to introduce efficient methods and tools for the legal domain. From this point onward we shall be referring to the \textit{court case transcripts} as \textit{court cases}. In this study, we propose a novel way of applying sentiment analysis on the contents (words/phrases) of court cases. This analysis is useful in the NLP or Natural Language Understanding (NLU) tasks where it is vital to identify the stakeholder bias in each of the statements. Similarly, sentiment analysis in legal text can become useful in automating the following tasks related to legal literature. \begin{itemize} \item Identifying the arguments in a court case \item Identifying the arguments which were supportive or against for a certain party in a court case \item Identifying or synthesizing counter-arguments for a given argument in a court case \end{itemize} To identify the application of sentiment classification in the legal domain, consider the following example which was extracted from a legal case~\cite{2017lee}.\\ \noindent\textit{The District Court concluded that Lee's counsel had performed deficiently.}\\ In the above example, the phrase \textit{had performed deficiently} induces a negative sentiment towards Lee's counsel. The sentiment of \textit{concluded that} denotes that the court agrees with the inner sentence. Complete sentence denotes that court's opinion towards Lee's counsel is negative. Consider the following extracted from the same case,\\ \noindent\textit{...the Government conceded that Lee's counsel had performed deficiently.}\\ This sentence contains the same inner sentence but in the legal domain the phrase called \textit{conceded that} indicates a situation where the government initially disagreed but eventually had to agree. That phrase induces a negative sentiment on the inner sentence which is negative towards Lee's counsel. Therefore, it is fair to assume that the government and Lee's counsel were on the same side in this situation. The above-mentioned facts indicate the importance of identifying the sentiment of a statement towards a party in a court case. In the proposed approach, the sentiment of a given phrase is classified into one of the two classes; \textit{negative} and \textit{non-negative}. This classification criterion is selected following the fact that the major use case aligns with classifying terms and entities supporting/referring to either plaintiff or defendant. Therefore, the proposed methodology is focused on identifying the statements with negative sentiment as much as possible. As per requirement, the proposed approach has the ability to extended to explicitly identify the positive sentiment as well following the same methodology. In this approach, we propose a novel methodology to perform transfer learning on the RNTN model mentioned in~\citet{socher2013recursive} and build a target model. Given that this is a transfer learning approach, the manually annotated data on movie reviews is used to as the initial source model rather than creating a new comparable manually annotated dataset for the legal domain. For the testing purposes, we created a manually annotated target domain test dataset such that the phrases belong to one of the two classes: \textit{negative} or \textit{non-negative}. The target system shows a recall of 70.14\% for identifying phrases with negative sentiment in the legal domain. Furthermore, the overall accuracy of the system is above 76\% in classifying sentiments for a given phrase correctly. If this result is compared with the results of source RNTN model~\cite{socher2013recursive}, it is a 6\% improvement in accuracy. The approach proposed in this study can be tried on other domain adaptation tasks related to sentiment classification as well. \section{Methodology} \label{section:methodology} Given that the transfer learning process described in this study uses the Recursive Neural Tensor Network (RNTN) model proposed by~\citet{socher2013recursive} as the source model, we make numerous references to the aforementioned model throughout the paper. Therefore, to avoid clutter, from this point onward the model proposed by~\citet{socher2013recursive} is referred as \textit{\textbf{Socher Model}} in the remainder of this paper. The main research contributions of this study in the methodological aspect is discussed in this section. In brief, first, it is required to select the vocabulary from a corpus comprised of legal case transcripts. Then we input a set of words extracted from that corpus to the \textit{Socher Model} for sentiment annotation. After that, three human annotators check for words with deviated sentiments based on the classified classes. Using that identified set, we perform a transfer learning method to identify the sentiment of a given phrase in the legal domain. All these steps are further elaborated in the following sub-sections. \subsection{Selecting the Vocabulary} Depending on the size of the corpus (phrases extracted from legal text), availability of human annotators and the time, it is not feasible to analyze and modify the sentiment of every word in a corpus. Therefore, it is required to select the vocabulary (unique words in the corpus) such that the end-model can correctly classify the sentiment of most of the phrases from the legal domain while not squandering human annotator time on words that occur rarely. To this end, first, the stop-words~\cite{stopwordDefinition} are removed from the text by utilizing the classical stop-word list known as the Van stop-list~\cite{van1979information}. Next, the term frequencies for each word in the corpus is calculated and only the top 95\% words of it are added to the vocabulary. \subsection{Assigning Sentiments for the Selected Vocabulary} \label{subsection:assiging_sentiment_for_the_selected_vocabulary} The selected vocabulary (set of individual words) is given to the sentiment annotator~\textit{Socher Model} as input. From the model, sentiment is classified into one of the five classes as in table \ref{table:sentiment-mapping}. This class scheme made sense for the movie reviews for which the~\textit{Socher Model} is trained and used for. However, in the application of this study, the basic requirement of finding sentiment in \textit{court cases} in the legal domain is to identify whether a given statement is against the plaintiff's claim or not. Therefore, we define two classes for sentiment: \textit{negative} and \textit{non-negative}. Three human judges analyze the selected vocabulary and classify each word into the two classes depending on its sentiment separately and independently. If at least two judges agree, the given word's sentiment is assigned as the class those two judges agreed. For the same word, the output from the sentiment annotator ~\textit{Socher Model} belongs to one of the five classes mentioned in the preceding subsection. In this approach, we map the output from ~\textit{Socher Model} to the two classes we define in Table \ref{table:sentiment-mapping}. \begin{table}[!htb] \centering \label{table:sentiment-mapping} \begin{tabular}{|l|l|l|} \hline & \thead{Human\\annotation} & \thead{\textit{Socher Model}\\output} \\ \hline \textbf{Class 1} & Negative & \makecell{Very negative,\\negative} \\ \hline \textbf{Class 2} & Non-negative & \makecell{Neutral,\\Positive,\\very positive} \\ \hline \end{tabular} \caption{Sentiment Mapping} \end{table} For a given word, if the two sentiment values assigned by the~\textit{Socher Model} and human judges do not agree with the above mapping, we define that the~\textit{Socher Model}'s output has deviated from its actual sentiment. For example: \hspace{8mm}\textbf{Sentence:} \textit{Sam is charged with a crime.} \hspace{8mm}\textbf{\textit{Socher Model}'s output:} positive \hspace{8mm}\textbf{Human judges' annotation:} negative The word \textit{charged} has several meanings depending on the context. As the~\textit{Socher Model} was trained using movie reviews, the sentiment of the word \textit{charged} is identified as positive. Although the sentiment of the term \textit{crime} is recognized as negative, the sentiment of the whole sentence is output as positive. But in the legal domain, \textit{charged} refers to a formal accusation. Therefore, the sentiment for the above sentence should have been negative. From the selected vocabulary, all the words with deviated sentiments are identified and listed separately for the further processing. \subsection{Brief description of the~\textit{Socher Model}} \label{subsection:description_of_rntn_model} In the preceding subsection, we came across a situation where the sentiment values from the~\textit{Socher Model} do not match the actual sentiment value because of the difference in domains. And there are words like \textit{insufficient}, which were not recognized by the model because those terms were not included in the training data-set. One approach to solve this is to annotate the phrases extracted from legal case transcripts manually as the ~\textit{Socher Model} suggests, which will require a considerable amount of human effort and time. Instead of that, we can change the model such that the desired output can be obtained using the same trained~\textit{Socher Model} without explicitly training using phrases in the legal domain. Hence, this method is called a transfer learning method. In order to change the model, first, it is required to understand the internals of the~\textit{Socher Model} model. When a phrase is provided as input, first it generates a binary tree corresponding to the input in which each leaf node represents a single word. Each leaf node is represented as a vector with d-dimensions. The parent nodes are also d-dimensional vectors which are computed in the bottom-up fashion according to some function \textit{g}. The function \textit{g} is composed of a neural tensor layer. Through the training process, the neural tensor layer and the word vectors are adjusted to support the relevant sentiment value. The neural tensor layer corresponds to identify the sentiment according to the structure of words representing the phrase. If we consider a phrase like \textit{not guilty} ,both individual word elements have negative sentiments. But the composition of those words has the structure of negating a negative sentiment term or phrase. Hence the phrase has a non-negative sentiment. If the input was a phrase like \textit{very bad}, the neural tensor layer has the ability to identify that the term \textit{very} increases the negativity in the sentiment. For Example: \hspace{8mm}\textbf{phrase:} \textit{not guilty.} \hspace{8mm}\textbf{sentiment:} non-negative Both words in the above phrase, have negative sentiment if we consider each of them individually. But the composition of those words has the structure of negating a negative sentiment term or phrase. Hence the phrase has a non-negative sentiment. If the input was a phrase like \textit{very bad}, the neural tensor layer has the ability to identify that the term \textit{very} increases the negativity in the sentiment. The hidden process is same as in the preceding example. \subsection{Adjusting Word Vector Values in RNTN Model} The requirement of the system is to identify the sentiment of a given phrase. The proposed approach is not to modify the neural tensor layer completely. We simply substitute the word vector values of individual words which are having deviated sentiments between~\textit{Socher Model} and human annotation (See sections \ref{subsection:assiging_sentiment_for_the_selected_vocabulary}). The vectors for the words which were not in the vocabulary of the training set which was used to train the RNTN model should be instantiated. The vectors of the words which are not deviated (according to the definition provided in the preceding subsection \ref{subsection:description_of_rntn_model}) will remain the same. As the words with deviated sentiments (provided by the~\textit{Socher Model}) in the vocabulary are already known, we initialize the vectors corresponding to the sentiment annotation for those words. Since the model is not trained explicitly, the vector initialization is done by substituting the vectors of words in which sentiment is not deviated comparing the~\textit{Socher Model} output and its actual sentiment. After the substitution is completed, we consider the part-of-speech tag. For that purpose, the part-of-speech tagger mentioned in~\citet{toutanova2003feature} is used. The substitution of vectors is carried out as shown in Table \ref{table:pos_tags_substituted_word_vectors}. \newcolumntype{Y}{>{\arraybackslash}X} \begin{table}[!hbt] \centering \begin{tabularx}{0.5\textwidth}{|l|Y|Y|} \hline \multirow{2}{*}{\thead{POS Tag}} & \multicolumn{2}{|l|}{\thead{Substituted word vector sentiment}}\\ \hhline{~--} & \thead{non-negative} & \thead{negative} \\ \hline JJ & wrong & natural\\ \hline JJR & worse & natural\\ \hline JJS & worst & natural\\ \hline NN & failure & thing \\ \hline NNS & politics & things \\ \hline RB & insufficiently & naturally\\ \hline RBR & insufficiently & naturally\\ \hline RBS & insufficiently & naturally\\ \hline VB & hate & do\\ \hline VBZ & hates & does\\ \hline VBP & hate & do\\ \hline VBD & hated & did\\ \hline VBN & bored & given\\ \hline VBZ & ignoring & doing\\ \hline \end{tabularx} \caption{Substituted Word Vectors for words which should be deviated} \label{table:pos_tags_substituted_word_vectors} \break \end{table} The number of words which have deviated sentiments is a considerably lower amount compared to the selected vocabulary. The rest of the words' vectors representing sentiments are not changed in the modification process. The neural tensor layer also remains unchanged from the trained~\textit{Socher Model} using movie reviews~\cite{socher2013recursive}. When the vectors for words with deviated sentiments are initialized according to the part-of-speech tag as shown in Table \ref{table:pos_tags_substituted_word_vectors}, it is possible to make a fair assumption that when deciding the sentiment with the proposed implementation, it does not harm the structure corresponding to the linguistic features of English. Consider the sentence ``\textit{evidence is insufficient.}'' as an example. The term ``\textit{insufficient}'' is not in the vocabulary of the~\textit{Socher Model} due to the limited vocabulary in training data set. Therefore, the~\textit{Socher Model} provides the sentiment of that word as neutral which indicates as a word with a deviated sentiment. Following the Table \ref{table:pos_tags_substituted_word_vectors}, the sentiment related vector is instantiated by substituting the vector of \textbf{wrong} as the part-of-speech tag of \textbf{insufficient} is \textbf{JJ}~\cite{santorini1990part}. Therefore the modified version of the RNTN model has the capability of identifying the sentiment of the above sentence as negative. The figure \ref{image:two_graphs_comparison} shows how the sentiment is induced through the newly instantiated word vector. \begin{figure}[!ht] \centering \includegraphics[width=0.4\textwidth]{images/image_1.png} \caption{Sentiment Prediction for a phrase with words not in source's vocabulary but in target's vocabulary} \label{image:two_graphs_comparison} \centering \end{figure} And there are scenarios where the term is in the vocabulary of the~\textit{Socher Model} but has a different sentiment compared to the legal domain. Consider the sentence ``\textit{Sam is charged with a crime}'' which was mentioned in section \ref{subsection:assiging_sentiment_for_the_selected_vocabulary}. In section \ref{subsection:assiging_sentiment_for_the_selected_vocabulary}, we have identified that the term \textit{charged} denotes a different sentiment in legal domain compared to movie reviews. The source RNTN model outputs a positive sentiment for that given sentence as the term \textit{charged} is identified as having a positive sentiment according to movie reviews domain. And that term is the cause for having such an output from the source model. The figure \ref{image:improved-model} indicates how the change we introduced in the target model (in section \ref{subsection:assiging_sentiment_for_the_selected_vocabulary}) induce the correct sentiment up to the root level of the phrase. Therefore, the target model identifies the sentiment correctly for the given phrase. \begin{figure}[!ht] \centering \includegraphics[width=0.4\textwidth]{images/image_2.png} \caption{Sentiment Prediction for a phrase with words having deviated sentiment in two domains - source model \label{image:original-model}} \centering \end{figure} \begin{figure}[!ht] \centering \includegraphics[width=0.4\textwidth]{images/image_3.png} \caption{Sentiment Prediction for a phrase with words having deviated sentiment in two domains - target model \label{image:improved-model}} \centering \end{figure} To improve the recall in identifying phrases with negative sentiment, we have added another rule to the classification criteria. The source RNTN model (\textit{Socher Model}) provides the score for each of the five classes such that all those five scores sum up to 1. If the negative sentiment class has the highest score, the sentiment label of the phrase will be \textit{negative}. Otherwise, the phrase again can be classified as having a \textit{negative} sentiment if the score for negative sentiment class is above 0.4. If those two conditions are not met, the phrase will be classified as having a \textit{non-negative} sentiment. Section \ref{section:experiments-and-results} provides observations and results regarding the improved criteria.
{'timestamp': '2018-10-05T02:01:59', 'yymm': '1810', 'arxiv_id': '1810.01912', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01912'}
arxiv
\section{An example of dependency-aware scheduling} \label{s:graph-hard} \begin{figure}[h] \centering \includegraphics[height=0.26\textwidth]{motivate.pdf} \vspace{-0.4cm} \caption{An optimal DAG-aware schedule plans ahead and parallelizes execution of the blue and green stages, so that orange and green stages complete at the same time and the bottom join stage can execute immediately. A straightforward critical path heuristic would instead focus on the right branch, and takes 29\% longer to execute the job.} \label{f:dag-ex} \end{figure} Directed acyclic graphs (DAGs) of dependent operators or ``stages'' are common in parallel data processing applications. Figure~\ref{f:dag-ex} shows a common example: a DAG with two branches that converge in a join stage. A simple critical path heuristic would choose to work on the right branch, which contains more aggregate work: 90 task-seconds vs.\ 10 task-seconds in the left branch. With this choice, once the orange stage finishes, however, the final join stage cannot run, since its other parent stage (in green) is still incomplete. Completing the green stage next, followed by the join stage\,---\,as a critical-path schedule would\,---\,results in an overall makespan of $28 + 3\epsilon$. The optimal schedule, by contrast, completes this DAG in $20 + 3\epsilon$ time, 29\% faster. Intuitively, an ideal schedule allocates resources such that both branches reach the final join stage at the same time, and execute it without blocking. \section{Background on Reinforcement Learning} \label{s:background} We briefly review reinforcement learning (RL) techniques that we use in this paper; for a detailed survey and rigorous derivations, see {e.g.},\xspace Sutton and Barto's book~\cite{rlbook}. \begin{figure}[t] \centering \includegraphics[height=3.5cm]{background.pdf} \vspace{-0.2cm} \caption{A reinforcement learning setting with neural networks~\cite{rlbook, deeprm}. The policy is parameterized using a neural network and is trained iteratively via interactions with the environment that observe its state and take actions.} \label{f:background_rl} \end{figure} \para{Reinforcement learning.} Consider the general setting in Figure~\ref{f:background_rl}, where an RL {\em agent} interacts with an {\em environment}. At each step $k$, the agent observes some state $s_k$, and takes an action $a_k$. Following the action, the state of the environment transitions to $s_{k+1}$ and the agent receives a reward $r_k$ as feedback. The state transitions and rewards are stochastic and assumed to be a Markov process: the state transition to $s_{k+1}$ and the reward $r_k$ depend only on the state $s_k$ and the action $a_k$ at step~$k$ ({i.e.},\xspace they are conditionally independent of the past). In the general RL setting, the agent only controls its actions: it has no a priori knowledge of the state transition probabilities or the reward function. However, by interacting with the environment, the agent can learn these quantities during training. For training, RL proceeds in \emph{episodes}. Each episode consists of a sequence of (state, action, reward) observations\,---\,{i.e.},\xspace $(s_k, a_k, r_k)$ at each step $k \in [0, 1, \ldots, T]$, where $T$ is the episode length . For ease of understanding, we first describe an RL formulation that maximizes the total reward: $\mathbb{E} \left[ \sum_{k=0}^T r_k \right]$. However, in our scheduling problem, the average reward formulation (\S\ref{s:training}) is more suitable. We later describe how to modify the reward signal to convert the objective to the average reward setting. \para{Policy.} The agent picks actions based on a {\em policy} $\pi(s_k, a_k)$, defined as a probability of taking action $a_k$ at state $s_k$. In most practical problems, the number of possible $\{$state, action$\}$ pairs is too large to store the policy in a lookup table. It is therefore common to use {\em function approximators}~\cite{ndp,menache2005basis}, with a manageable number of adjustable parameters, $\theta$, to represent the policy as $\pi_\theta (s_k, a_k)$. Many forms of function approximators can be used to represent the policy. Popular choices include linear combinations of features of the state/action space (i.e., $\pi_\theta (s_k,a_k) = \theta^T \phi(s_k,a_k)$), and, recently, neural networks~\cite{nnbook} for solve large-scale RL tasks~\cite{atari, alphagozero}. An advantage of neural networks is that they do not need hand-crafted features, and that they are end-to-end differentiable for training. \para{Policy gradient methods.} We focus on a class of RL algorithms that perform training by using {\em gradient-descent} on the policy parameters. Recall that the objective is to maximize the expected total reward; the gradient of this objective is given by: \begin{equation} \nabla_\theta \mathbb{E}_{\pi_\theta} \left[ \sum_{k=0}^T r_k \right] = \mathbb{E}_{\pi_\theta} \left[\sum_{k=0}^T \nabla_\theta \log \pi_\theta (s_k,a_k) Q^{\pi_\theta} (s_k, a_k) \right], \label{eqn:policy_gr} \end{equation} where $Q^{\pi_\theta}(s_k, a_k)$ is the expected total discounted reward from (deterministically) choosing action $a_k$ in state $s_k$, and subsequently following policy $\pi_\theta$~\cite[\S13.2]{rlbook}. The key idea in policy gradient methods is to estimate the gradient using the trajectories of execution with the current policy. Following the {\em Monte Carlo Method}~\cite{montecarlo}, the agent samples multiple trajectories and uses the empirical total discounted reward, $v_k$, as an unbiased estimate of $Q^{\pi_\theta}(s_k, a_k)$. It then updates the policy parameters via gradient descent: \begin{equation} \theta \leftarrow \theta + \alpha \sum_{k=0}^T \nabla_\theta \log \pi_\theta (s_k, a_k) v_k, \label{eqn:reinforce} \end{equation} where $\alpha$ is the learning rate. This equation results in the REINFORCE algorithm~\cite{reinforce}. The intuition of REINFORCE is that the direction $\nabla_\theta \log \pi_\theta (s_k, a_k)$ indicates how to change the policy parameters in order to increase $\pi_\theta (s_k, a_k)$ (the probability of action $a_k$ at state $s_k$). Equation~\ref{eqn:reinforce} takes a step in this direction; the size of the step depends on the magnitude of the return $v_k$. The net effect is to reinforce actions that empirically lead to better returns. Appendix~\ref{s:pg} describes how we implement this training method in practice. \update{ Policy gradient methods are better suited to our scheduling context than the alternative value-based methods for two reasons. First, policy-based methods are easier to design if it is unclear whether the neural network architecture used has adequate expressive power. The reason is that value-based methods aim to find a fixed-point of the Bellman equations~\cite{bellman1966}. If the underlying neural network cannot express the optimal value function, then a value-based method can have difficulty converging because the algorithm is trying to converge to a fixed point that the neural network cannot express. With policy-based methods, this issue does not arise, because regardless of the policy network's expressive power, the policy gradient algorithm will optimize for the reward objective over the space of policies that the neural network \emph{can} express. Second, policy gradient methods allow us to use input-dependent baselines~\cite{variance-reduction} to reduce training variance (challenge \#2 in \S\ref{s:training}). It is currently unknown whether, and how, this technique can be applied to value-based methods. } \para{Average reward formulation.} For our scheduling problem, an average reward formulation, which maximizes $\lim_{T\to\infty} \mathbb{E} \left[1/T \sum_{k=0}^T r_k \right]$, is a better objective than the total reward we discussed so far. To convert the objective from the sum of rewards to the average reward, we replace the reward $r_k$ with a {\em differential reward}. Operationally, at every step $k$, the environment modifies the reward to the agent as $r_k \leftarrow r_k - \hat{r}$, where $\hat{r}$ is a moving average of the rewards across a large number of previous steps (across many training episodes). With this modification, we can reuse the same policy gradient method as in Equation~\eqref{eqn:policy_gr} and~\eqref{eqn:reinforce} to find the optimal policy. Sutton and Barto~\cite[\S10.3, \S13.6]{rlbook} describe the mathematical details on how this approach optimizes the average reward objective. \section{Training implementation details} \label{s:pg} Algorithm~\ref{alg:pg} presents the pseudocode for {Decima}\xspace's training procedure as described in~\S\ref{s:training}. In particular, line 3 samples the episode length $\tau$ from an exponential distribution, with a small initial mean $\tau_\text{mean}$. This step terminates the initial episodes early to avoid wasting training time~(see challenge \#1 in \S\ref{s:training}). Then, we sample a job sequence (line 4) and use it to collect $N$ episodes of experience (line 5). Importantly, the baseline $b_k$ in line 8 is computed with the \emph{same} job sequence to reduce the variance caused by the randomness in the job arrival process~(see challenge \#2 in \S\ref{s:training}). Line 10 is the policy gradient REINFORCE algorithm described in Eq.~\eqref{eq:policygradient}. Line 13 increases the average episode length ({i.e.},\xspace the curriculum learning procedure for challenge \#1 in \S\ref{s:training}). Finally, we update {Decima}\xspace's policy parameter $\theta$ on line 14. \begin{algorithm}[t] \caption{Policy gradient method used to train {Decima}\xspace.} \label{alg:pg} \begin{algorithmic}[1] \FOR{each iteration} \STATE $\Delta \theta \leftarrow 0$ \STATE Sample episode length $\tau \sim \text{exponential}(\tau_\mathrm{mean})$ \STATE Sample a job arrival sequence \STATE Run episodes $i=1,\hdots,N$:\\ \quad$\{s^i_1, a^i_1, r^i_1, \hdots, s^i_{\tau}, a^i_{\tau}, r^i_{\tau} \} \sim \pi_\theta$ \STATE Compute total reward: $R^i_k = \sum_{k'=k}^{\tau} r^i_{k'}$ \FOR{$k$ = 1 to $\tau$} \STATE compute baseline: $b_k = \frac{1}{N}\sum_{i=1}^N R^i_k$ \FOR{$i$ = 1 to $N$} \STATE $\Delta \theta \leftarrow \Delta \theta + \nabla_\theta \log \pi_\theta (s^i_k, a^i_k) (R^i_k -b_k)$ \ENDFOR \ENDFOR \STATE $\tau_\mathrm{mean} \leftarrow \tau_\mathrm{mean} + \epsilon$ \STATE $\theta \leftarrow \theta + \alpha\Delta\theta$ \ENDFOR \end{algorithmic} \end{algorithm} Our neural network architecture is described in \S\ref{s:impl-spark}, and we set the hyperparameters in {Decima}\xspace's training as follows. The number of incoming jobs is capped at 2000, and the episode termination probability decays linearly from $5\times10^{-7}$ to $5\times10^{-8}$ throughout training. The learning rate $\alpha$ is $1\times 10^{-3}$ and we use Adam optimizer~\cite{adamopt} for gradient descent. For continuous job arrivals, the moving window for estimating $\hat{r}$ spans $10^5$ time steps (see the average reward formulation in Appendix~\ref{s:background}). Finally, we train {Decima}\xspace for at least 50,000 iterations for all experiments. We implemented {Decima}\xspace's training framework using Tensor\-Flow~\cite{tensorflow}, and we use 16 workers to compute episodes with the same job sequence in parallel during training. Each training iteration, including interaction with the simulator, model inference and model update from all training workers, takes roughly 1.5 seconds on a machine with Intel Xeon E5-2640 CPU and Nvidia Tesla P100 GPU. All experiments in \S\ref{s:eval} are performed on test job sequences unseen during training ({e.g.},\xspace unseen TPC-H job combinations, unseen part of the Alibaba production trace, etc.). \section{Simulator fidelity} \label{s:sim-fidelity} Our training infrastructure relies on a faithful simulator of Spark job execution in a cluster. To validate the simulator's fidelity, we measured how simulated and real Spark differ in terms of job completion time for ten runs of TPC-H job sets~(\S\ref{s:eval-real-cluster}), both when jobs run alone and when they share a cluster with other jobs. Figure~\ref{f:sim-fidelity} shows the results: the simulator closely matches the actual run time of each job, even when we run multiple jobs together in the cluster. In particular, the mean error of our simulation is within $5\%$ of real runtime when jobs run in isolation, and within $9\%$ when sharing a cluster (95\textsuperscript{th} percentile: $\le 10\%$ in isolation, $\le 20\%$ when sharing). We found that capturing all first-order effects of the Spark environment is crucial to achieving this accuracy~(\S\ref{s:simulator}). For example, without modeling the delay to move an executor between jobs, the simulated runtime consistently underapproximates reality. Training in such an environment would result in a policy that moves executors more eagerly than is actually sensible~(\S\ref{s:eval-ubenches}). Likewise, omitting the effects of initial and subsequent ``waves'' of tasks, or the slowdown overheads imposed with high degrees of paralllism, significantly increases the variance in simulated runtime and makes it more difficult for {Decima}\xspace to learn a good policy. \begin{figure} \centering \begin{subfigure}[t]{0.5\textwidth} \centering \includegraphics[width=\textwidth]{job_durations_single.pdf} \vspace{-0.7cm} \caption{Single job running in isolation.} \label{f:simulator-fidelity-single} \end{subfigure} \begin{subfigure}[t]{0.5\textwidth} \centering \includegraphics[width=\textwidth]{job_durations_mixed.pdf} \vspace{-0.7cm} \caption{Mixture of jobs on a shared cluster.} \label{f:simulator-fidelity-mixed} \end{subfigure} \vspace{-0.3cm} \caption{Testing the fidelity of our Spark simulator with {Decima}\xspace as a scheduling agent. Blue bars in the upper part show the absolute real Spark job duration (error bars: standard deviation across ten experiments); the orange bars in the lower figures show the distribution of simulation error for a $95\%$ confidence interval. The mean discrepancy between simulated and actual job duration is at most $\pm 5\%$ for isolated, single jobs, and the mean error for a mix of all 22 queries running on the cluster is at most $\pm 9\%$.} \label{f:sim-fidelity} \end{figure} \section{Expressiveness of {Decima}\xspace's state representation} \label{s:su} \begin{figure} \centering \includegraphics[width=0.85\columnwidth]{supervised_learning.pdf} \vspace{-0.25cm} \caption{\update{Trained using supervised learning, {Decima}\xspace's two-level non-linear transformation is able to express the max operation necessary for computing the critical path (\S\ref{s:graph}), and consequently achieves near-perfect accuracy on unseen DAGs compared to the standard graph embedding scheme.}} \label{f:su} \end{figure} \update{ {Decima}\xspace's can only learn strong scheduling policies if its state representation, embedding scheme, and neural network architecture can express them (\S\ref{s:eval}). In Equation~\eqref{eq:msg}, combining two non-linear transforms $f(\cdot)$ and $g(\cdot)$ enables {Decima}\xspace to express a wide variety of aggregation functions. For example, if $f\sim \log(\cdot / n)$, $g\sim \exp(n \times \cdot)$, and $n\to\infty$, the aggregation computes the maximum of the child node embeddings. By contrast, a standard aggregation operation of the form $\mathbf{e_v} = \sum_{u\in \xi(v)} f(\mathbf{e_u})$ without a second non-linear transformation $g(\cdot)$ is insufficient to express the max operation. Consequently, such an architecture cannot learn the aggregation (max) required to find the critical path of a graph. During development, we relied on a simple sanity check to test the expressiveness of a graph embedding scheme. We used supervised learning to train the graph neural network to output the critical path value of each node in a large number of random graphs, and then checked how accurately the graph neural network identified the node with the maximum critical path value. Figure~\ref{f:su} shows the testing accuracy that {Decima}\xspace's node embedding with two aggregation levels achieves on unseen graphs, and compares it to the accuracy achieved by a simple, single-level embedding with only one non-linear transformation. {Decima}\xspace's node embedding manages to learn the max operation and therefore accurately identifies the critical path after about 150 iterations, while the standard embedding is incapable of expressing the critical path and consequently never reaches a stable high accuracy.} \section{Multi-resource scheduling heuristic comparison details} \label{s:graphene} When evaluating {Decima}\xspace's performance in a multi-resource setting~(\S\ref{s:multi-dim}), we compared with several heuristics. First, we considered the optimally tuned weighted fair heuristic from~\S\ref{s:eval-real-cluster}. This heuristic grants each job an executor share based on the total work in the job. Then the heuristic chooses a stage the same way as in the single resource setting. Among the available executor types, the heuristic first exhausts the best-fitting category before choosing any others. The scheduler ensures that the aggregate allocated resources (across different executor types) do not exceed the job's weighted fair share. Second, we compared to the resource-packing algorithm from Tetris~\cite{tetris}. To maximize resource utilization, we select the DAG node that yields the largest dot product of the requested resource vector and the available resource vector for each executor type. Then, we greedily grant as much parallelism as the tasks in this node need. The prior two heuristics lack each other's key scheduling ingredients (fairness and packing), and neither understands the DAG structure. Finally, we compared to Graphene~\cite{graphene}, whose hybrid heuristic combines these factors. However, our multi-resource scheduling environment with discrete executor classes differs from the original Graphene setting, which assumes continuous, infinitely divisible resources. We adapted the Graphene algorithm for discrete executors, but kept its essence: specifically, we estimate and group the ``troublesome'' nodes the same way~\cite[\S4.1]{graphene}. To ensure that troublesome nodes are scheduled at the same time, we dynamically suppress the priority on all troublesome nodes of a DAG until \emph{all} of these nodes are available in the frontier. We also include parallelism control by sharing the executors according to the optimally tuned weighted fair partition heuristic; and we pack resources by prioritizing the executor type that best fits the resource request. Finally, we perform a grid search on all the hyperparameters ({e.g.},\xspace the threshold for picking troublesome nodes) to tune the heuristic for the best scheduling performance in each of the experiments (\S\ref{s:multi-dim}). \section{Further analysis of multi-resource scheduling} \label{s:multi-resource-more-analysis} In \S\ref{s:multi-dim}, we found that {Decima}\xspace achieves $32\%-43\%$ lower average JCT than state-of-the-art heuristics when handling continuous job arrivals in a multi-resource environment. {Decima}\xspace achieves this by carefully fragmenting cluster memory: Figure~\ref{f:eval-tpch-multi-resource-exec-usage} illustrated that {Decima}\xspace selectively borrows large executors if they can help finishing short jobs quickly and increase cluster throughput. This effect is also evident when examining the timeseries of job duration and executor usage over a single experiment. Figure~\ref{f:eval-multi-time-series} shows that {Decima}\xspace maintains a smaller number of concurrent active jobs during periods of high load both for a synthetic TPC-H workload and for the Alibaba trace. During busy periods ({e.g.},\xspace around snapshot 50 in Figure~\ref{f:eval-tpch-multi-time-series}{\color{darkred}1}), {Decima}\xspace clears the backlog of jobs in the queue more quickly than the best competing heuristic, Graphene\textsuperscript{$\ast$}\xspace. During these periods, {Decima}\xspace assigns more executors to each job than Graphene\textsuperscript{$\ast$}\xspace (Figures~\ref{f:eval-tpch-multi-time-series}{\color{darkred}2} and \ref{f:eval-alibaba-multi-time-series}{\color{darkred}2}), {e.g.},\xspace by sometimes borrowing large executors for jobs that need only smaller ones. As a consequence, {Decima}\xspace achieves lower JCT and higher cluster throughput when the cluster load is high (Figures~\ref{f:eval-tpch-multi-time-series}{\color{darkred}3} and \ref{f:eval-alibaba-multi-time-series}{\color{darkred}3}). Figure~\ref{f:eval-tpch-multi-exec-assignment} and \ref{f:eval-alibaba-multi-exec-assignment} compare the executor assignment between {Decima}\xspace and Graphene\textsuperscript{$\ast$}\xspace in detail (Figure~\ref{f:eval-tpch-multi-resource-exec-usage} is the first column of this profile). On the $x$-axis, we bin jobs according to the total amount of work they contain (in task-seconds). The $y$-axis of each graph is the number of executors {Decima}\xspace uses normalized to the number of executors used by Graphene\textsuperscript{$\ast$}\xspace\,---\,{i.e.},\xspace a value above one indicates that {Decima}\xspace used more executors. Overall, {Decima}\xspace tends to assign more executors per job compared to Graphene\textsuperscript{$\ast$}\xspace. This helps {Decima}\xspace complete jobs faster in order to then move on to others, instead of making progress on many jobs concurrently, similar to the behavior we discussed in~\S\ref{s:eval-real-cluster}. Moreover, {Decima}\xspace uses more large executors on small jobs. This aggressive allocation of large executors\,---\,which wastes some memory\,---\,leads to faster job completion during the busy periods (Figure~\ref{f:eval-tpch-multi-time-series}{\color{darkred}3} and \ref{f:eval-alibaba-multi-time-series}{\color{darkred}3}), at the expense of leaving some memory unused. This trade-off between resource fragmentation and prioritizing small jobs can be tedious to balance, but {Decima}\xspace automatically learns a strong policy by interacting with the environment. {Decima}\xspace may enjoy an advantage here partly because Graphene\textsuperscript{$\ast$}\xspace is restricted to discrete executor classes. In a cluster setting with arbitrary, continuous memory assignment to tasks, large executor ``slots'' could be subdivided into multiple smaller executors, assuming sufficient CPU capacity exists. This choice is difficult to express with a finite action space like {Decima}\xspace's, and it is an interesting direction for future work to investigate whether RL with continuous action could be applied to cluster scheduling. \begin{figure}[t] \centering \begin{subfigure}[t]{0.22\textwidth} \centering \includegraphics[width=\textwidth]{tpch-multi-resource-time-series.pdf} \vspace{-0.6cm} \caption{TPC-H workload.} \label{f:eval-tpch-multi-time-series} \end{subfigure} \hspace{0.01\textwidth} \begin{subfigure}[t]{0.22\textwidth} \centering \includegraphics[width=\textwidth]{alibaba-multi-resource-time-series.pdf} \vspace{-0.6cm} \caption{Industrial trace replay.} \label{f:eval-alibaba-multi-time-series} \end{subfigure} \vspace{-0.2cm} \caption{Timeseries of different statistics in the extended Spark multi-resource environment. We compare {Decima}\xspace and Graphene\textsuperscript{$\ast$}\xspace, the best competing heuristic. During busy periods, {Decima}\xspace finishes jobs faster and maintains a lower number of concurrent jobs by using more executors per job.} \label{f:eval-multi-time-series} \end{figure} \begin{figure}[t] \centering \begin{subfigure}[t]{0.2\textwidth} \centering \includegraphics[width=\textwidth]{tpch-multi-resource-exec-assignment.pdf} \vspace{-0.6cm} \caption{TPC-H workload.} \label{f:eval-tpch-multi-exec-assignment} \end{subfigure} \hspace{0.03\textwidth} \begin{subfigure}[t]{0.2\textwidth} \centering \includegraphics[width=\textwidth]{alibaba-multi-resource-exec-assignment.pdf} \vspace{-0.6cm} \caption{Industrial trace replay.} \label{f:eval-alibaba-multi-exec-assignment} \end{subfigure} \vspace{-0.2cm} \caption{Profile of executor assignments on jobs with different sizes, {Decima}\xspace normalized to Graphene\textsuperscript{$\ast$}\xspace's assignment (>1: more executors in {Decima}\xspace, <1: more in Graphene\textsuperscript{$\ast$}\xspace). {Decima}\xspace tends to assign more executors.} \label{f:eval-multi-exec-assignment} \end{figure} \section{Optimality of {Decima}\xspace} \label{s:optimality} In~\S\ref{s:eval}, we show {Decima}\xspace is able to rival or outperform existing scheduling schemes in a wide range of complex cluster environments, including a real Spark testbed, real-world cluster trace simulations and a multi-resource packing environment. However, the optimality of {Decima}\xspace in those environments remains unknown due to the intractability of computing exact optimal scheduling solutions~\cite{acyclic-jobs-hard, graphene}, or tight lower bounds.\footnote{In our setting ({i.e.},\xspace Spark's executor-based scheduling), we found lower bounds based on total work or the critical path to be too loose to provide meaningful information.} To nevertheless get an idea of how close {Decima}\xspace comes to an optimal scheduler, we test {Decima}\xspace in simplified settings where a brute-force search over different schedules is possible. We consider the Spark scheduling framework simulated in~\S\ref{s:simulator} with an average JCT objective for a batch of jobs. To simplify the environment, we turn off the ``wave'' effect, executor startup delays and the artifact of task slowdowns at high degrees of parallelism. As a result, the duration of a stage has a strict inverse relation to the number of executors the stage runs on ({i.e.},\xspace it scales linearly with parallel resources), and the scheduler is free to move executors across jobs without any overhead. The dominating challenges in this environment are to pack jobs tightly and to favor short jobs as much as possible. To find a good schedule for a batch of $n$ jobs, we exhaustively search all $n!$ possible job orderings, and select the ordering with the lowest average JCT. To make the exhaustive search feasible, we consider a batch of ten jobs. For each job ordering, we select the unfinished job appearing earliest in the order at each scheduling event (\S\ref{s:action}), and use the DAG's critical path to choose the order in which to finish stages within each job. By considering all possible job orderings, the algorithm is guaranteed to consider, amongst other schedules, a strict shortest-job-first (SJF) schedule that yields a small average JCT. We believe this policy to be close to the optimal policy, as we have empirically observed that job orderings dominate the average JCT in TPC-H workloads~(\S\ref{s:eval-ubenches}). However, the exhaustive search also explores variations of the SJF schedule, {e.g.},\xspace orders that prioritize jobs which can exploit parallelism to complete more quickly than less-parallelizable jobs that contain smaller total work. Next, we train an unmodified {Decima}\xspace agent in this environment, similar to the setup in~\S\ref{s:eval-real-cluster}. We compare this agent's performance with our exhaustive search baseline, a shortest-job-first critical-path heuristic, and the tuned weighted fair scheduler (described in~\S\ref{s:eval-real-cluster}). \begin{figure} \centering \includegraphics[width=0.85\columnwidth]{near_opt_comparison.pdf} \caption{Comparing {Decima}\xspace with near optimal heuristics in a simplified scheduling environment.} \label{f:near-opt-comparison} \end{figure} Figure~\ref{f:near-opt-comparison} shows the results. We make three key observations. First, unlike in the real Spark cluster~(Figure~\ref{f:eval-spark-tpch-cdf}), the SJF-CP scheme outperforms the tuned weighted fair scheduler. This meets our expectation because SJF-CP strictly favors small jobs to minimize the average JCT, which in the absence of the complexities of a real-world cluster is a good policy. Second, the exhaustive search heuristic performs better than SJF-CP. This is because SJF-CP strictly focuses on completing the job with the smallest total work first, ignoring the DAG structure and the potential parallelism it implies. The exhaustive search, by contrast, finds job orderings that prioritize jobs which can execute most quickly given the available executors on the cluster, their DAG structure, and their total work. While the search algorithm is not aware of these constraints, by trying out different job orderings, it finds the schedule that both orders jobs correctly \emph{and} exploits cluster resources to complete the jobs as quickly as possible. Third, {Decima}\xspace matches the average JCT of the exhaustive search or even outperforms it slightly (by $9\%$ on average). We found that {Decima}\xspace is better at dynamically prioritizing jobs based on their current structure at runtime ({e.g.},\xspace how much work remains on each dependency path), while the exhaustive search heuristic strictly follows the order determined in an offline static search and only controls when jobs start. This experiment shows that {Decima}\xspace is able to automatically learn a scheduling algorithm that performs as well as an offline-optimal job order. \section{Generalizing {Decima}\xspace to different environments} \label{s:generalizability} \begin{table}[t] \small \centering \begin{tabular}{|l|c|} \hline \bf {Decima}\xspace training scenario & \bf average JCT (seconds) \\ \hline {Decima}\xspace trained with test setting & $3,290\pm680$ \\ {Decima}\xspace trained with 15$\times$ fewer jobs & $3,540\pm450$ \\ \hline {Decima}\xspace trained with test setting & $610\pm90$ \\ {Decima}\xspace trained with 10$\times$ fewer executors & $630\pm70$ \\ \hline \end{tabular} \vspace{0.25cm} \caption{{Decima}\xspace generalizes well to deployment scenarios in which the workload or cluster differ from the training setting. The test setting has 150 jobs and 10k executors.} \label{t:eval-alibaba-generalization} \end{table} Real-world cluster workloads vary over time, and the available cluster machines can also change. Ideally, {Decima}\xspace would generalize from a model trained for a specific load and cluster size to similar workloads with different parameters. To test this, we train a {Decima}\xspace agent on a scaled-down version of the industrial workload, using 15$\times$ fewer concurrent jobs and 10$\times$ fewer executors than in the test setting. Table~\ref{t:eval-alibaba-generalization} shows how the performance of this agent compares with that of one trained on the real workload and cluster size. {Decima}\xspace is robust to changing parameters: the agent trained with 15$\times$ fewer jobs generalizes to the test workload with a 7$\%$ reduced average JCT, and an agent trained on a 10$\times$ smaller cluster generalizes with a 3$\%$ reduction in average JCT. Generalization to a larger cluster is robust as the policy correctly limits jobs' parallelism even if vastly more resources are available. By contrast, generalizing to a workload with many more jobs is harder, as the smaller-scale training lacks experiences with complex job combinations. \section{{Decima}\xspace with incomplete information} \label{s:incomplete-info} \begin{figure} \centering \includegraphics[width=0.75\columnwidth]{omit_task_durations.pdf} \vspace{-0.2cm} \caption{{Decima}\xspace performs worse on unseen jobs without task duration estimates, but still outperforms the best heuristic.} \label{f:eval-omit-task-durations} \end{figure} In a real cluster, {Decima}\xspace will occasionally encounter unseen jobs without reliable task duration estimates. Unlike heuristics that fundamentally rely on profiling information ({e.g.},\xspace weighted fair scheduling based on total work), {Decima}\xspace can still work with the remaining information and extract a reasonable scheduling policy. Running the same setting as in~\S\ref{s:eval-real-cluster}, Figure~\ref{f:eval-omit-task-durations} shows that training without task durations yields a policy that still outperforms the best heuristic, as {Decima}\xspace can still exploit the graph structure and other information such as the correlation between number of tasks and the efficient parallelism level. \section{Conclusion} \label{s:concl} {Decima}\xspace demonstrates that automatically learning complex cluster scheduling policies using reinforcement learning is feasible, and that the learned policies are flexible and efficient. {Decima}\xspace's learning innovations, such as its graph embedding technique and the training framework for streaming, may be applicable to other systems processing DAGs ({e.g.},\xspace query optimizers). We will open source {Decima}\xspace, our models, and our experimental infrastructure at \url{https://web.mit.edu/decima}. This work does not raise any ethical issues. \smallskip \noindent{\bf Acknowledgments.} \update{We thank our shepherd, Aditya Akella, and the SIGCOMM reviewers for their valuable feedback. We also thank Akshay Narayan, Amy Ousterhout, Prateesh Goyal, Peter Iannucci, and Songtao He for fruitful discussions throughout the development of this project. We appreciate Haiyang Ding and Yihui Feng from Alibaba Cloud Intelligence for sharing the production cluster dataset. This work was funded in part by the NSF grants CNS-1751009, CNS-1617702, a Google Faculty Research Award, an AWS Machine Learning Research Award, a Cisco Research Center Award, an Alfred P. Sloan Research Fellowship, and sponsors of the MIT DSAIL lab.} \section{The DAG Scheduling Problem in Spark} \label{s:context} {Decima}\xspace is a general framework for learning scheduling algorithms for DAG-structured jobs. For concreteness, we describe its design in the context of the Spark system. A Spark job consists of a DAG whose nodes are the execution \emph{stages} of the job. Each stage represents an operation that the system runs in parallel over many shards of the stage's input data. The inputs are the outputs of one or more parent stages, and each shard is processed by a single \emph{task}. A stage's tasks become runnable as soon as all parent stages have completed. How many tasks can run in parallel depends on the number of \emph{executors} that the job holds. Usually, a stage has more tasks than there are executors, and the tasks therefore run in several ``waves''. Executors are assigned by the Spark master based on user requests, and by default stick to jobs until they finish. However, Spark also supports dynamic allocation of executors based on the wait time of pending tasks~\cite{spark-dynamic-scaling}, although moving executors between jobs incurs some overhead (e.g., to tear down and launch JVMs). Spark must therefore handle three kinds of scheduling decisions: ({\em i}\/){} deciding how many executors to give to each job; ({\em ii}\/){} deciding which stages' tasks to run next for each job, and ({\em iii}\/){} deciding which task to run next when an executor becomes idle. When a stage completes, its job's \emph{DAG scheduler} handles the activation of dependent child stages and enqueues their tasks with a lower-level \emph{task scheduler}. The task scheduler maintains task queues from which it assigns a task every time an executor becomes idle. We allow the scheduler to move executors between job DAGs as it sees fit (dynamic allocation). {Decima}\xspace focuses on DAG scheduling ({i.e.},\xspace which stage to run next) and executor allocation ({i.e.},\xspace each job's degree of parallelism). Since tasks in a stage run identical code and request identical resources, we use Spark's existing task-level scheduling. \section{Overview and Design Challenges} \label{s:design-overview} {Decima}\xspace represents the scheduler as an agent that uses a neural network to make decisions, henceforth referred to as the {\em policy network}. On {\em scheduling events}\,---\,{e.g.},\xspace a stage completion (which frees up executors), or a job arrival (which adds a DAG)\,---\,the agent takes as input the current {\em state} of the cluster and outputs a scheduling {\em action}. At a high level, the state captures the status of the DAGs in the scheduler's queue and the executors, while the actions determine which DAG stages executors work on at any given time. {Decima}\xspace trains its neural network using RL through a large number of offline (simulated) experiments. In these experiments, {Decima}\xspace attempts to schedule a workload, observes the outcome, and provides the agent with a {\em reward} after each action. The reward is set based on {Decima}\xspace's high-level scheduling objective (e.g., minimize average JCT). The RL algorithm uses this reward signal to gradually improve the scheduling policy. Appendix~\ref{s:background} provides a brief primer on RL. {Decima}\xspace's RL framework (Figure~\ref{fig:rl}) is general and it can be applied to a variety of systems and objectives. In \S\ref{s:design}, we describe the design for scheduling DAGs on a set of identical executors to minimize average JCT. Our results in \S\ref{s:eval} will show how to apply the same design to schedule multiple resources (e.g., CPU and memory), optimize for other objectives like makespan~\cite{makespan}, and learn qualitatively different polices depending on the underlying system (e.g., with different overheads for moving jobs across machines). \smallskip \noindent{\bf Challenges.} {Decima}\xspace's design tackles three key challenges: \begin{CompactEnumerate} \item {\bf Scalable state information processing.} The scheduler must consider a large amount of dynamic information to make scheduling decisions: hundreds of job DAGs, each with dozens of stages, and executors that may each be in a different state ({e.g.},\xspace assigned to different jobs). Processing all of this information via neural networks is challenging, particularly because neural networks usually require fixed-sized vectors as inputs. \item {\bf Huge space of scheduling decisions.} The scheduler must map potentially thousands of runnable stages to available executors. The exponentially large space of mappings poses a challenge for RL algorithms, which must ``explore'' the action space in training to learn a good policy. \item {\bf Training for continuous stochastic job arrivals}. It is important to train the scheduler to handle continuous randomly-arriving jobs over time. However, training with a continuous job arrival process is non-trivial because RL algorithms typically require training ``episodes'' with a finite time horizon. Further, we find that randomness in the job arrival process creates difficulties for RL training due to the variance and noise it adds to the reward. \end{CompactEnumerate} \section{Design} \label{s:design} This section describes {Decima}\xspace's design, structured according to how it addresses the three aforementioned challenges: scalable processing of the state information (\S\ref{s:graph}), efficiently encoding scheduling decisions as actions (\S\ref{s:action}), and RL training with continuous stochastic job arrivals (\S\ref{s:training}). \subsection{Scalable state information processing} \label{s:graph} On each state observation, {Decima}\xspace must convert the state information (job DAGs and executor status) into features to pass to its policy network. One option is to create a flat feature vector containing all the state information. However, this approach cannot scale to arbitrary number of DAGs of arbitrary sizes and shapes. Further, even with a hard limit on the number of jobs and stages, processing a high-dimensional feature vector would require a large policy network that would be difficult to train. {Decima}\xspace achieves scalability using a {\em graph neural network}, which encodes or ``embeds'' the state information ({e.g.},\xspace attributes of job stages, DAG dependency structure, etc.) in a set of {\em embedding} vectors. Our method is based on graph convolutional neural networks~\cite{graphcnn, graphcombopt, gcnn_google} but customized for scheduling. Table~\ref{t:embedding-notation} defines our notation. \begin{figure}[t] \centering \vspace{-0.4cm} \includegraphics[height=3.2cm]{rl.pdf} \vspace{-0.3cm} \caption{In {Decima}\xspace's RL framework, a \emph{scheduling agent} observes the \emph{cluster state} to decide a scheduling \emph{action} on the cluster \emph{environment}, and receives a \emph{reward} based on a high-level objective. The agent uses a \emph{graph neural network} to turn job DAGs into vectors for the \emph{policy network}, which outputs actions.} \vspace{-0.3cm} \label{fig:rl} \end{figure} \begin{table}[t] \footnotesize \centering \begin{tabular}{|r|l||r|l|} \hline \bf entity & \bf symbol & \bf entity & \bf symbol \\ \hline job & $i$ & per-node feature vector & $\mathbf{x}^i_v$ \\ stage (DAG node) & $v$ & per-node embedding & $\mathbf{e}^i_v$ \\ node $v$'s children & $\xi(v)$ & per-job embedding & $\mathbf{y}^i$ \\ job $i$'s DAG & $G_i$ & global embedding & $\mathbf{z}$ \\ job $i$'s parallelism & $l_i$ & node score & $q_v^i$ \\ non-linear functions & $f, g, q, w$ & parallelism score & $w_l^i$ \\ % \hline \end{tabular} \vspace{0.1cm} \caption{Notation used throughout \S\ref{s:design}.} \vspace{-0.85cm} \label{t:embedding-notation} \end{table} The graph embedding takes as input the job DAGs whose nodes carry a set of stage attributes ({e.g.},\xspace the number of remaining tasks, expected task duration, etc.), and it outputs three different types of embeddings: \begin{CompactEnumerate} \item per-node embeddings, which capture information about the node and its children (containing, {e.g.},\xspace aggregated work along the critical path starting from the node); % \item per-job embeddings, which aggregate information across an entire job DAG (containing, {e.g.},\xspace the total work in the job); and % \item a global embedding, which combines information from all per-job embeddings into a cluster-level summary (containing, {e.g.},\xspace the number of jobs and the cluster load). \end{CompactEnumerate} Importantly, what information to store in these embeddings is not hard-coded\,---\,{Decima}\xspace automatically learns what is statistically important and how to compute it from the input DAGs through end-to-end training. In other words, the embeddings can be thought of as feature vectors that the graph neural network learns to compute without manual feature engineering. {Decima}\xspace's graph neural network is scalable because it reuses a common set of operations as building blocks to compute the above embeddings. These building blocks are themselves implemented as small neural networks that operate on relatively low-dimensional input vectors. \para{Per-node embeddings.} Given the vectors $\mathbf{x}^i_v$ of stage attributes corresponding to the nodes in DAG $G_i$, {Decima}\xspace builds a per-node embedding $(G_i, \mathbf{x}^i_v) \longmapsto{\mathbf{e}^i_v}$. The result $\mathbf{e}^i_v$ is a vector (e.g., in $\mathbb{R}^{16}$) that captures information from all nodes reachable from $v$ ({i.e.},\xspace $v$'s child nodes, their children, etc.). To compute these vectors, {Decima}\xspace propagates information from children to parent nodes in a sequence of \emph{message passing} steps, starting from the leaves of the DAG (Figure~\ref{fig:msg}). In each message passing step, a node $v$ whose children have aggregated messages from all of their children (shaded nodes in Figure~\ref{fig:msg}'s examples) computes its own embedding as: \begin{equation} \mathbf{e}_v^{i} = g\left[\sum_{u\in \xi(v)}f(\mathbf{e}_u^{i})\right] + \mathbf{x}_v^{i}, \label{eq:msg} \end{equation} where $f(\cdot)$ and $g(\cdot)$ are non-linear transformations over vector inputs, implemented as (small) neural networks, and $\xi(v)$ denotes the set of $v$'s children. The first term is a general, non-linear aggregation operation that summarizes the embeddings of $v$'s children; adding this summary term to $v$'s feature vector ($\mathbf{x}_v$) yields the embedding for $v$. {Decima}\xspace reuses the same non-linear transformations $f(\cdot)$ and $g(\cdot)$ at all nodes, and in all message passing steps. Most existing graph neural network architectures~\cite{graphcnn, graphspectral, graphcombopt} use aggregation operations of the form $\mathbf{e_v} = \sum_{u\in \xi(v)} f(\mathbf{e_u})$ to compute node embeddings. However, we found that adding a second non-linear transformation $g(\cdot)$ in Eq.~\eqref{eq:msg} is critical for learning strong scheduling policies. The reason is that without $g(\cdot)$, the graph neural network cannot compute certain useful features for scheduling. For example, it cannot compute the critical path~\cite{criticalpath} of a DAG, which requires a max operation across the children of a node during message passing.\footnote{The critical path from node $v$ can be computed as: $\text{cp}(v) = \max_{u \in \xi(v)}\text{cp}(u) + \text{work}(v)$, where work($\cdot$) is the total work on node $v$.} Combining two non-linear transforms $f(\cdot)$ and $g(\cdot)$ enables {Decima}\xspace to express a wide variety of aggregation functions. For example, if $f$ and $g$ are identity transformations, the aggregation sums the child node embeddings; if $f\sim \log(\cdot / n)$, $g\sim \exp(n \times \cdot)$, and $n\to\infty$, the aggregation computes the max of the child node embeddings. \update{We show an empirical study of this embedding in Appendix~\ref{s:su}.} \begin{figure}[t] \centering \begin{subfigure}[t]{0.22\textwidth} \centering \includegraphics[height=1.4in]{message_passing_color_formula.pdf} \vspace{-0.1cm} \caption{Per-node embedding.} \label{fig:msg} \end{subfigure} \begin{subfigure}[t]{0.245\textwidth} \centering \includegraphics[height=1.4in]{summarization_color_formula.pdf} \vspace{-0.1cm} \caption{Per-job and global embeddings.} \label{fig:summ} \end{subfigure} \vspace{-0.2cm} \caption{A \emph{graph neural network} transforms the raw information on each DAG node into a vector representation. This example shows two steps of local message passing and two levels of summarizations.} \vspace{-0.3cm} \label{fig:graph} \end{figure} \para{Per-job and global embeddings.} The graph neural network also computes a summary of all node embeddings for each DAG $G_i$, $\{(\mathbf{x}^i_v, \mathbf{e}^i_v), v\in G_i\} \longmapsto{\mathbf{y}^i}$; and a global summary across all DAGs, $\{\mathbf{y}^1,\mathbf{y}^2,\ldots\} \longmapsto{\mathbf{z}}$. To compute these embeddings, {Decima}\xspace adds a summary node to each DAG, which has all the nodes in the DAG as children (the squares in Figure~\ref{fig:summ}). These DAG-level summary nodes are in turn children of a single global summary node (the triangle in Figure~\ref{fig:summ}). The embeddings for these summary nodes are also computed using Eq.~\eqref{eq:msg}. Each level of summarization has its own non-linear transformations $f$ and $g$; in other words, the graph neural network uses six non-linear transformations in total, two for each level of summarization. \subsection{Encoding scheduling decisions as actions} \label{s:action} The key challenge for encoding scheduling decisions lies in the learning and computational complexities of dealing with large action spaces. As a naive approach, consider a solution, that given the embeddings from \S\ref{s:graph}, returns the assignment for all executors to job stages in one shot. This approach has to choose actions from an exponentially large set of combinations. On the other extreme, consider a solution that invokes the scheduling agent to pick one stage every time an executor becomes available. This approach has a much smaller action space (O(\# stages)), but it requires long sequences of actions to schedule a given set of jobs. In RL, both large action spaces and long action sequences increase sample complexity and slow down training~\cite{rlbook, aicompute}. {Decima}\xspace balances the size of the action space and the number of actions required by decomposing scheduling decisions into a series of \update{two-dimensional} actions, which output ({\em i}\/){} a stage designated to be scheduled next, and ({\em ii}\/){} an upper limit on the number of executors to use for that stage's job. \para{Scheduling events.} {Decima}\xspace invokes the scheduling agent when the set of runnable stages\,---\,{i.e.},\xspace stages whose parents have completed and which have at least one waiting task\,---\,in any job DAG changes. Such scheduling events happen when ({\em i}\/){} a stage runs out of tasks ({i.e.},\xspace needs no more executors), ({\em ii}\/){} a stage completes, unlocking the tasks of one or more of its child stages, or ({\em iii}\/){} a new job arrives to the system. At each scheduling event, the agent schedules a group of free executors in one or more actions. Specifically, it passes the embedding vectors from~\S\ref{s:graph} as input to the policy network, which outputs a two-dimensional action $\langle v, l_i \rangle$, consisting of a stage $v$ and the parallelism limit $l_i$ for $v$'s job $i$. If job $i$ currently has fewer than $l_i$ executors, {Decima}\xspace assigns executors to $v$ up to the limit. If there are still free executors \update{after the scheduling action,} {Decima}\xspace invokes the agent again to select another stage and parallelism limit. This process repeats until all the executors have been assigned, or there are no more runnable stages. {Decima}\xspace ensures that this process completes in a finite number of steps by enforcing that the parallelism limit $l_i$ is greater than the number of executors currently allocated to job $i$, so that at least one new executor is scheduled with each action. \para{Stage selection.} Figure~\ref{f:end-to-end-policy-net} visualizes {Decima}\xspace's policy network. For a scheduling event at time $t$, during which the state is $s_t$, the policy network selects a stage to schedule as follows. For a node $v$ in job $i$, it computes a score $q_v^{i} \triangleq q(\mathbf{e}_v^{i}, \mathbf{y}^{i}, \mathbf{z})$, where $q(\cdot)$ is a {\em score function} that maps the embedding vectors~(output from the graph neural network in \S\ref{s:graph}) to a scalar value. Similar to the embedding step, the score function is also a non-linear transformation implemented as a neural network. The score $q_v^i$ represents the priority of scheduling node $v$. {Decima}\xspace then uses a softmax operation~\cite{bishop} to compute the probability of selecting node $v$ based on the priority scores: \begin{equation} P(\text{node} = v) = \frac{\exp(q_v^i)}{\sum_{u\in\mathcal{A}_t}\exp(q_u^{j(u)})}, \label{eq:softmax} \end{equation} where $j(u)$ is the job of node $u$, and $\mathcal{A}_t$ is the set of nodes that can be scheduled at time $t$. \update{Notice that $\mathcal{A}_t$ is known to the RL agent at each step, since the input DAGs tell exactly which stages are runnable. Here, $\mathcal{A}_t$ restricts which outputs are considered by the softmax operation. The whole operation is end-to-end differentiable.} \begin{figure}[t] \centering \includegraphics[height=5cm]{policy-network.pdf} \vspace{-0.3cm} \caption{For each node $v$ in job $i$, the \emph{policy network} uses per-node embedding $\mathbf{e}^i_v$, per-job embedding $\mathbf{y}^i$ and global embedding $\mathbf{z}$ to compute ({\em i}\/){} the score $\mathbf{q}^i_v$ for sampling a node to schedule and ({\em ii}\/){} the score $\mathbf{w}^i_l$ for sampling a parallelism limit for the node's job.} \label{f:end-to-end-policy-net} \vspace{-0.4cm} \end{figure} \para{Parallelism limit selection.} \update{ Many existing schedulers set a static degree of parallelism for each job: {e.g.},\xspace Spark by default takes the number of executors as a command-line argument on job submission. {Decima}\xspace adapts a job's parallelism each time it makes a scheduling decision for that job, and varies the parallelism as different stages in the job become runnable or finish execution. } For each job $i$, {Decima}\xspace's policy network also computes a score $w^i_l \triangleq w(\mathbf{y}^i, \mathbf{z}, l)$ for assigning parallelism limit $l$ to job $i$, using another score function $w(\cdot)$. Similar to stage selection, {Decima}\xspace applies a softmax operation on these scores to compute the probability of selecting a parallelism limit (Figure~\ref{f:end-to-end-policy-net}). Importantly, {Decima}\xspace uses the same score function $w(\cdot)$ for all jobs and all parallelism limit values. This is possible because the score function takes the parallelism $l$ as one of its inputs. Without using $l$ as an input, we cannot distinguish between different parallelism limits, and would have to use separate functions for each limit. Since the number of possible limits can be as large as the number of executors, reusing the same score function significantly reduces the number of parameters in the policy network and speeds up training~(Figure~\ref{f:eval-learning-curve}). \update{ {Decima}\xspace's action specifies \emph{job-level} parallelism ({e.g.},\xspace ten total executors for the entire job), as opposed fine-grained stage-level parallelism. This design choice} trades off granularity of control for a model that is easier to train. In particular, restricting {Decima}\xspace to job-level parallelism control reduces the space of scheduling policies that it must explore and optimize over during training. \update{ However, {Decima}\xspace still maintains the expressivity to (indirectly) control stage-level parallelism. On each scheduling event, {Decima}\xspace picks a stage $v$, and new parallelism limit $l_i$ for $v$'s job $i$. The system then schedules executors to $v$ until $i$’s parallelism reaches the limit $l_i$. Through repeated actions with different parallelism limits, {Decima}\xspace can add desired numbers of executors to specific stages. For example, suppose job $i$ currently has ten executors, four of which are working on stage $v$. To add two more executors to $v$, {Decima}\xspace, on a scheduling event, picks stage $v$ with parallelism limit of 12.} Our experiments show that {Decima}\xspace achieves the same performance with job-level parallelism as with fine-grained, stage-level parallelism choice, at substantially accelerated training (Figure~\ref{f:eval-learning-curve}). \subsection{Training} \label{s:training} The primary challenge for training {Decima}\xspace is how to train with continuous stochastic job arrivals. To explain the challenge, we first describe the RL algorithms used for training. RL training proceeds in {\em episodes}. Each episode consists of multiple scheduling events, and each scheduling event includes one or more actions. Let $T$ be the total number of actions in an episode ($T$ can vary across different episodes), and $t_k$ be the wall clock time of the $k^{\textrm{th}}$ action. To guide the RL algorithm, {Decima}\xspace gives the agent a \emph{reward} $r_k$ after each action based on its high-level scheduling objective. For example, if the objective is to minimize the average JCT, {Decima}\xspace penalizes the agent $r_k = -(t_k - t_{k-1}) J_k$ after the $k^{th}$ action, where $J_k$ is the number of jobs in the system during the interval $[t_{k-1}, t_k)$. The goal of the RL algorithm is to minimize the expected time-average of the penalties: $\mathbb{E}\left[1/t_T \sum_{k=1}^{T} (t_k - t_{k-1})J_k \right]$. This objective minimizes the average number of jobs in the system, and hence, by Little's law~\cite[\S5]{little}, it effectively minimizing the average JCT. {Decima}\xspace uses a policy gradient algorithm for training. The main idea in policy gradient methods is to learn by performing gradient descent on the neural network parameters using the rewards observed during training. Notice that all of {Decima}\xspace's operations, from the graph neural network~(\S\ref{s:graph}) to the policy network~(\S\ref{s:action}), are differentiable. For conciseness, we denote all of the parameters in these operations jointly as $\theta$, and the scheduling policy as $\pi_\theta(s_t, a_t)$\,---\,defined as the probability of taking action $a_t$ in state $s_t$. Consider an episode of length $T$, where the agent collects (\emph{state, action, reward}) observations, {i.e.},\xspace $(s_k, a_k, r_k)$, at each step $k$. The agent updates the parameters $\theta$ of its policy $\pi_\theta(s_t, a_t)$ using the REINFORCE policy gradient algorithm~\cite{reinforce}: \begin{align} \vspace{-0.2cm} \theta \leftarrow \theta + \alpha\sum_{k=1}^{T} \nabla_\theta \log \pi_\theta(s_k, a_k) \left( \sum_{k' = k}^{T} r_{k'} - b_k \right). \label{eq:policygradient} \vspace{-0.2cm} \end{align} Here, $\alpha$ is the learning rate and $b_k$ is a {\em baseline} used to reduce the variance of the policy gradient~\cite{baseline}. An example of a baseline is a ``time-based'' baseline~\cite{deeprm, greensmith}, which sets $b_k$ to the cumulative reward from step $k$ onwards, averaged over all training episodes. Intuitively, $\left( \sum_{k'}r_{k'} - b_k \right)$ estimates how much better (or worse) the total reward is (from step $k$ onwards) in a particular episode compared to the average case; and $\nabla_\theta \log \pi_\theta(s_k, a_k)$ provides a direction in the parameter space to increase the probability of choosing action $a_k$ at state $s_k$. As a result, the net effect of this equation is to increase the probability of choosing an action that leads to a better-than-average reward.\footnote{The update rule in Eq.~\eqref{eq:policygradient} aims to maximize the sum of rewards during an episode. To maximize the time-average of the rewards, {Decima}\xspace uses a slightly modified form of this equation. See Appendix~\ref{s:background} for details.} \para{Challenge \#1: Training with continuous job arrivals.} To learn a robust scheduling policy, the agent has to experience ``streaming'' scenarios, where jobs arrive continuously over time, during training. Training with ``batch'' scenarios, where all jobs arrive at the beginning of an episode, leads to poor policies in streaming settings (e.g., see Figure~\ref{f:eval-ubench-component-breakdown}). However, training with a continuous stream of job arrivals is non-trivial. In particular, the agent's initial policy is very poor ({e.g.},\xspace as the initial parameters are random). Therefore, the agent cannot schedule jobs as quickly as they arrive in early training episodes, and a large queue of jobs builds up in almost every episode. \update{Letting the agent explore beyond a few steps in these early episodes wastes training time, because the overloaded cluster scenarios it encounters will not occur with a reasonable policy.} To avoid this waste, we terminate initial episodes early so that the agent can reset and quickly try again from an idle state. We gradually increase the episode length throughout the training process. Thus, initially, the agent learns to schedule short sequences of jobs. As its scheduling policy improves, we increase the episode length, making the problem more challenging. The concept of gradually increasing job sequence length\,---\,and therefore, problem complexity\,---\,during training realizes curriculum learning~\cite{curlearn} for cluster scheduling. One subtlety about this method is that the termination cannot be deterministic. Otherwise, the agent can learn to predict when an episode terminates, and defer scheduling certain large jobs until the termination time. This turns out to be the optimal strategy over a fixed time horizon: since the agent is not penalized for the remaining jobs at termination, it is better to strictly schedule short jobs even if it means starving some large jobs. We found that this behavior leads to indefinite starvation of some jobs at runtime (where jobs arrive indefinitely). To prevent this behavior, we use a \emph{memoryless} termination process. Specifically, we terminate each training episode after a time $\tau$, drawn randomly from an exponential distribution. As explained above, the mean episode length increases during training up to a large value (e.g., a few hundreds of job arrivals on average). \begin{figure}[t] \centering \includegraphics[height=3.4cm]{var.pdf} \vspace{-0.3cm} \caption{Illustrative example of how different job arrival sequences can lead to vastly different rewards. After time $t$, we sample two job arrival sequences, from a Poisson arrival process (10~seconds mean inter-arrival time) with randomly-sampled TPC-H queries.} \vspace{-0.4cm} \label{f:design-var} \end{figure} \para{Challenge \#2: Variance caused by stochastic job arrivals.} Next, for a policy to generalize well in a streaming setting, the training episodes must include many different job arrival patterns. This creates a new challenge: different job arrival patterns have a large impact on performance, resulting in vastly different rewards. Consider, for example, a scheduling action at the time $t$ shown in Figure~\ref{f:design-var}. If the arrival sequence following this action consists of a burst of large jobs (e.g., job sequence 1), the job queue will grow large, and the agent will incur large penalties. On the other hand, a light stream of jobs (e.g., job sequence 2) will lead to short queues and small penalties. The problem is that this difference in reward has nothing to do with the action at time $t$\,---\,it is caused by the randomness in the job arrival process. Since the RL algorithm uses the reward to assess the goodness of the action, such variance adds noise and impedes effective training. To resolve this problem, we build upon a recently-proposed variance reduction technique for ``input-driven'' environments \cite{variance-reduction}, where an exogenous, stochastic input process (e.g., {Decima}\xspace's job arrival process) affects the dynamics of the system. The main idea is to fix the {\em same} job arrival sequence in multiple training episodes, and to compute separate baselines specifically for each arrival sequence. In particular, instead of computing the baseline $b_k$ in Eq.~\eqref{eq:policygradient} by averaging over episodes with different arrival sequences, we average only over episodes with the same arrival sequence. During training, we repeat this procedure for a large number of randomly-sampled job arrival sequences \update{(\S\ref{s:eval-real-cluster} and \S\ref{s:multi-dim} describe how we generate the specific datasets for training)}. This method removes the variance caused by the job arrival process entirely, enabling the policy gradient algorithm to assess the goodness of different actions much more accurately~(see Figure~\ref{f:eval-ubench-component-breakdown}). For the implementation details of our training and the hyperparameter settings used, see Appendix~\ref{s:pg}. \section{Discussion} \label{s:discussion} \update{ In this section, we discuss future research directions and other potential applications for {Decima}\xspace's techniques. \smallskip \noindent \textbf{Robustness and generalization.} Our experiments in \S\ref{s:eval-ubenches} showed that {Decima}\xspace can learn generalizable scheduling policies that work well on an unseen workload. However, more drastic workload changes than interarrival time shifts could occur. To increase robustness of a scheduling policy against such changes, it may be helpful to train the agent on worst-case situations or adversarial workloads, drawing on the emerging literature on robust adversarial RL~\cite{rarl}. Another direction is to adjust the scheduling policy \emph{online} as the workload changes. The key challenge with an online approach is to reduce the large sample complexity of model-free RL when the workload changes quickly. One viable approach might be to use meta learning~\cite{maml, rl2, mbmpo}, which allows training a ``meta'' scheduling agent that is designed to adapt to a specific workload with only a few observations. \smallskip \noindent \textbf{Other learning objectives.} In our experiments, we evaluated {Decima}\xspace on metrics related to job duration ({e.g.},\xspace average JCT, makespan). Shaping the reward signal differently can steer {Decima}\xspace to meet other objectives, too. For example, imposing a hard penalty whenever the deadline of a job is missed would guide {Decima}\xspace to a deadline-aware policy. Alternatively, basing the reward on {e.g.},\xspace the 90th percentile of empirical job duration samples, {Decima}\xspace can optimize for a tight tail of the JCT distribution. Addressing objectives formulated as constrained optimization ({e.g.},\xspace to minimize average JCT, but strictly guarantee fairness) using RL is an interesting further direction~\cite{constrained_po, mdp_constrained}. \smallskip \noindent \textbf{Preemptive scheduling.} {Decima}\xspace currently never preempts running tasks and can only remove executors from a job after a stage completes. This design choice keeps the MDP tractable for RL and results in effective learning and strong scheduling policies. However, future work might investigate more fine-grained and reactive preemption in an RL-driven scheduler such as {Decima}\xspace. Directly introducing preemption would lead to a much larger action space ({e.g.},\xspace specifying arbitrary set of executors to preempt) and might require a much higher decision-making frequency. To make the RL problem tractable, one potential research direction is to leverage multi-agent RL~\cite{multi-agent-rl-survey-1, cooperative-multi-agent, berkeley-multi-agent}. For example, a {Decima}\xspace-like scheduling agent might controls which stage to run next and how many executors to assign, and, concurrently, another agent might decide where to preempt executors. \smallskip \noindent \textbf{Potential networking and system applications.} Some techniques we developed for {Decima}\xspace are broadly applicable to other networking and computer systems problems. For example, the scalable representation of input DAGs (\S\ref{s:graph}) has applications in problems over graphs, such as database query optimization~\cite{neo} and hardware device placement~\cite{placeto}. Our variance reduction technique (\S\ref{s:training}) generally applies to systems with stochastic, unpredictable inputs~\cite{variance-reduction, abrl}. } \section{Evaluation} \label{s:eval} We evaluated {Decima}\xspace on a real Spark cluster testbed and in simulations with a production workload from Alibaba. Our experiments address the following questions: \begin{CompactEnumerate} % \item How does {Decima}\xspace perform compared to carefully-tuned heuristics in a real Spark cluster (\S\ref{s:eval-real-cluster})? % \item Can {Decima}\xspace's learning generalize to a multi-resource setting with different machine configurations (\S\ref{s:multi-dim})? % \item How does each of our key ideas contribute to {Decima}\xspace's performance; how does {Decima}\xspace adapt when scheduling environments change; and how fast does {Decima}\xspace train and make scheduling decisions after training? \end{CompactEnumerate} \begin{figure}[t] \centering \begin{subfigure}[t]{0.29\textwidth} \centering \includegraphics[width=\textwidth]{real_spark_tpch_cdf.pdf} \vspace{-0.45cm} \caption{Batched arrivals.} \label{f:eval-spark-tpch-batch-cdf} \end{subfigure} \begin{subfigure}[t]{0.17\textwidth} \centering \includegraphics[width=\textwidth]{real_spark_tpch_stream_cdf.pdf} \vspace{-0.45cm} \caption{Continuous arrivals.} \label{f:eval-spark-tpch-stream-cdf} \end{subfigure} \vspace{-0.3cm} \caption{{Decima}\xspace's learned scheduling policy achieves 21\%--3.1$\times$ lower average job completion time than baseline algorithms for batch and continuous arrivals of TPC-H jobs in a real Spark cluster.} \label{f:eval-spark-tpch-cdf} \vspace{-0.5cm} \end{figure} \subsection{Existing baseline algorithms} \label{s:eval-comparing-schemes} In our evaluation, we compare {Decima}\xspace's performance to that of seven baseline algorithms: \begin{CompactEnumerate} \item Spark's default FIFO scheduling, which runs jobs in the same order they arrive in and grants as many executors to each job as the user requested. % \item A shortest-job-first critical-path heuristic (SJF-CP), which prioritizes jobs based on their total work, and within each job runs tasks from the next stage on its critical path. % \item Simple fair scheduling, which gives each job an equal fair share of the executors and round-robins over tasks from runnable stages to drain all branches concurrently. % \item Naive weighted fair scheduling, which assigns executors to jobs proportional to their total work. % \item A carefully-tuned weighted fair scheduling that gives each job $T_i^\alpha / \sum_i T_i^\alpha$ of total executors, where $T_i$ is the total work of each job $i$ and $\alpha$ is a tuning factor. Notice that $\alpha=0$ reduces to the simple fair scheme, and $\alpha=1$ to the naive weighted fair one. We sweep through $\alpha\in \{-2, -1.9, ..., 2\}$ for the optimal factor. % \item The standard multi-resource packing algorithm from Tetris \cite{tetris}, which greedily schedules the stage that maximizes the dot product of the requested resource vector and the available resource vector. % \item Graphene\textsuperscript{$\ast$}\xspace, an adaptation of Graphene~\cite{graphene} for {Decima}\xspace's discrete executor classes. Graphene\textsuperscript{$\ast$}\xspace detects and groups ``troublesome'' nodes using Graphene's algorithm~\cite[\S4.1]{graphene}, and schedules them together with optimally tuned parallelism as in (5), achieving the essence of Graphene's planning strategy. \update{We perform a grid search to optimize for the hyperparameters (details in Appendix~\ref{s:graphene}).} \end{CompactEnumerate} \subsection{Spark cluster} \label{s:eval-real-cluster} \begin{figure}[t] \centering \includegraphics[width=1.02\columnwidth]{real_spark_tpch_stream.pdf} \vspace{-0.6cm} \caption{Time-series analysis (a, b) of continuous TPC-H job arrivals to a Spark cluster shows that {Decima}\xspace achieves most performance gains over heuristics during busy periods ({e.g.},\xspace runs jobs $2\times$ faster during hour 8), as it appropriately prioritizes small jobs (c) with more executors (d), while preventing work inflation (e). } \label{f:eval-spark-tpch-stream-analysis} \vspace{-0.3cm} \end{figure} We use an OpenStack cluster running Spark v2.2, modified as described in \S\ref{s:impl-spark}, in the Chameleon Cloud testbed. \footnote{\url{https://www.chameleoncloud.org}} The cluster consists of 25 worker VMs, each running two executors on an \code{m1.xlarge} instance (8 CPUs, 16 GB RAM) and a master VM on an \code{m1.xxxlarge} instance (16 CPUs, 32 GB RAM). Our experiments consider ({\em i}\/){} \emph{batched} arrivals, in which multiple jobs start at the same time and run until completion, and ({\em ii}\/){} \emph{continuous} arrivals, in which jobs arrive with stochastic interarrival distributions or follow a trace. \para{Batched arrivals.} We randomly sample jobs from six different input sizes (2, 5, 10, 20, 50, and 100 GB) and all 22 TPC-H~\cite{tpch} queries, producing a heavy-tailed distribution: $23\%$ of the jobs contain $82\%$ of the total work. A combination of 20 random jobs (unseen in training) arrives as a batch, and we measure their average JCT. Figure~\ref{f:eval-spark-tpch-batch-cdf} shows a cumulative distribution of the average JCT over 100 experiments. There are three key observations from the results. First, SJF-CP and fair scheduling, albeit simple, outperform the FIFO policy by 1.6$\times$ and 2.5$\times$ on average. Importantly, the fair scheduling policies outperform SJF-CP since they work on multiple jobs, while SJF-CP focuses all executors exclusively on the shortest job. Second, perhaps surprisingly, unweighted fair scheduling outperforms fair scheduling weighted by job size (``naive weighted fair''). This is because weighted fair scheduling grants small jobs \emph{fewer} executors than their fair share, slowing them down and increasing average JCT. Our tuned weighted fair heuristic (``opt.\ weighted fair'') counters this effect by calibrating the weights for each job \emph{on each experiment} (\S\ref{s:eval-comparing-schemes}). The optimal $\alpha$ is usually around $-1$, {i.e.},\xspace the heuristic sets the number of executors inversely proportional to job size. This policy effectively focuses on small jobs early on, and later shifts to running large jobs in parallel; it outperforms fair scheduling by $11\%$. Finally, {Decima}\xspace outperforms all baseline algorithms and improves the average JCT by $21\%$ over the closest heuristic (``opt.\ weighted fair''). This is because {Decima}\xspace prioritizes jobs better, assigns efficient executor shares to different jobs, and leverages the job DAG structure (\S\ref{s:eval-ubenches} breaks down the benefit of each of these factors). {Decima}\xspace autonomously learns this policy through end-to-end RL training, while the best-performing baseline algorithms required careful tuning. \begin{figure}[t] \centering % \begin{subfigure}[t]{0.215\textwidth} \centering \includegraphics[width=\textwidth]{alibaba-multi-resource-cdf.pdf} \vspace{-0.4cm} \caption{Industrial trace replay.} \label{f:eval-alibaba-multi-resource-cdf} \end{subfigure} \hspace{0.03cm} \begin{subfigure}[t]{0.215\textwidth} \centering \includegraphics[width=\textwidth]{tpch-multi-resource-cdf.pdf} \vspace{-0.4cm} \caption{TPC-H workload.} \label{f:eval-tpch-multi-resource-cdf} \end{subfigure} \vspace{-0.3cm} \caption{With multi-dimensional resources, {Decima}\xspace's scheduling policy outperforms Graphene\textsuperscript{$\ast$}\xspace by $32\%$ to $43\%$ in average JCT.} \label{f:eval-multi-resource-cdf} \vspace{-0.4cm} \end{figure} \para{Continuous arrivals.} We sample 1,000 TPC-H jobs of six different sizes \update{uniformly at random}, and model their arrival as a Poisson process with an average interarrival time of 45 seconds. The resulting cluster load is about $85\%$. At this cluster load, jobs arrive faster than most heuristic-based scheduling policies can complete them. Figure~\ref{f:eval-spark-tpch-stream-cdf} shows that {Decima}\xspace outperforms the only baseline algorithm that can keep up (``opt.\ weighted fair''); {Decima}\xspace's average JCT is $29\%$ lower. In particular, {Decima}\xspace shines during busy, high-load periods, where scheduling decisions have a much larger impact than when cluster resources are abundant. Figure~\ref{f:eval-spark-tpch-stream-analysis}{\color{darkred}a} shows that {Decima}\xspace maintains a lower concurrent job count than the tuned heuristic particularly during the busy period in hours 7--9, where {Decima}\xspace completes jobs about $2\times$ faster (Figure~\ref{f:eval-spark-tpch-stream-analysis}{\color{darkred}b}). \update{ Performance under high load is important for batch processing clusters, which often have long job queues~\cite{yaq}, and periods of high load are when good scheduling decisions have the most impact ({e.g.},\xspace reducing the overprovisioning required for workload peaks).} {Decima}\xspace's performance gain comes from finishing small jobs faster, as the concentration of red points in the lower-left corner of Figure~\ref{f:eval-spark-tpch-stream-analysis}{\color{darkred}c} shows. {Decima}\xspace achieves this by assigning more executors to the small jobs (Figure~\ref{f:eval-spark-tpch-stream-analysis}{\color{darkred}d}). The right number of executors for each job is workload-dependent: indiscriminately giving small jobs more executors would use cluster resources inefficiently (\S\ref{s:motiv-parallelism}). For example, SJF-CP's strictly gives all available executors to the smallest job, but this inefficient use of executors inflates total work, and SJF-CP therefore accumulates a growing backlog of jobs. {Decima}\xspace's executor assignment, by contrast, results in similar total work as with the hand-tuned heuristic. Figure~\ref{f:eval-spark-tpch-stream-analysis}{\color{darkred}e} shows this: jobs below the diagonal have smaller total work with {Decima}\xspace than with the heuristic, and ones above have larger total work in {Decima}\xspace. Most small jobs are on the diagonal, indicating that {Decima}\xspace only increases the parallelism limit when extra executors are still efficient. Consequently, {Decima}\xspace successfully balances between giving small jobs extra resources to finish them sooner and using the resources efficiently. \subsection{Multi-dimensional resource packing} \label{s:multi-dim} \begin{figure}[t] \centering % \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{alibaba-multi-resource-job-duration.pdf} \vspace{-0.5cm} \caption{Job duration grouped by total work, {Decima}\xspace normalized to Graphene\textsuperscript{$\ast$}\xspace.} \label{f:eval-alibaba-multi-resource-job-duration} \end{subfigure} \hspace{0.02cm} \begin{subfigure}[t]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{alibaba-multi-resource-exec-count.pdf} \vspace{-0.5cm} \caption{Number of executors that {Decima}\xspace uses for ``small'' jobs, normalized to Graphene\textsuperscript{$\ast$}\xspace.} \label{f:eval-tpch-multi-resource-exec-usage} \end{subfigure} \vspace{-0.3cm} \caption{{Decima}\xspace outperforms Graphene\textsuperscript{$\ast$}\xspace with multi-dimensional resources by (a) completing small jobs faster and (b) use ``oversized'' executors for small jobs (smallest $20\%$ in total work).} \label{f:eval-multi-resource-cdf-drill-down} \vspace{-0.4cm} \end{figure} The standalone Spark scheduler used in our previous experiments only provides jobs with access to predefined executor slots. More advanced cluster schedulers, such as YARN~\cite{yarn} or Mesos~\cite{mesos}, allow jobs to specify their tasks' resource requirements and create appropriately-sized executors. Packing tasks with multi-dimensional resource needs ({e.g.},\xspace $\langle$CPU, memory$\rangle$) onto fixed-capacity servers adds further complexity to the scheduling problem~\cite{tetris, graphene}. We use a production trace from Alibaba to investigate if {Decima}\xspace can learn good multi-dimensional scheduling policies with the same core approach. \begin{figure*}[t] \centering \begin{subfigure}[t]{0.325\textwidth} \centering \includegraphics[width=\textwidth]{mean_visualization.pdf} \vspace{-0.6cm} \caption{Average JCT objective.} \label{f:eval-spark-examples-avg-jct} \end{subfigure} \begin{subfigure}[t]{0.325\textwidth} \centering \includegraphics[width=\textwidth]{no_moving_delay_visualization.pdf} \vspace{-0.6cm} \caption{Avg.\ JCT, with zero-cost executor motion.} \label{f:eval-spark-examples-no-moving-cost} \end{subfigure} \begin{subfigure}[t]{0.325\textwidth} \centering \includegraphics[width=\textwidth]{makespan_visualization.pdf} \vspace{-0.6cm} \caption{Minimal makespan objective.} \label{f:eval-spark-examples-makespan} \end{subfigure} \vspace{-0.3cm} \caption{{Decima}\xspace learns qualitatively different policies depending on the environment ({e.g.},\xspace costly (\subref{f:eval-spark-examples-avg-jct}) vs.\ free executor migration (\subref{f:eval-spark-examples-no-moving-cost})) and the objective ({e.g.},\xspace average JCT (\subref{f:eval-spark-examples-avg-jct}) vs.\ makespan (\subref{f:eval-spark-examples-makespan})). Vertical red lines indicate job completions, colors indicate tasks in different jobs, and dark purple is idle time.} \label{f:eval-spark-examples} \vspace{-0.3cm} \end{figure*} \para{Industrial trace.} The trace contains about 20,000 jobs from a production cluster. Many jobs have complex DAGs: 59\% have four or more stages, and some have hundreds. We run the experiments using our simulator (\S\ref{s:simulator}) with up to 30,000 executors. This parameter is set according to the maximum number of concurrent tasks in the trace. \update{We use the first half of the trace for training and then compare {Decima}\xspace's performance with other schemes on the remaining portion.} \para{Multi-resource environment.} We modify {Decima}\xspace's environment to provide several discrete executor \emph{classes} with different memory sizes. Tasks now require a minimum amount of CPU and memory, {i.e.},\xspace a task must fit into the executor that runs it. Tasks can run in executors larger than or equal to their resource request. {Decima}\xspace now chooses a DAG stage to schedule, a parallelism level, and an executor class to use. Our experiments use four executor types, each with $1$ CPU core and $(0.25, 0.5, 0.75, 1)$ unit of normalized memory; each executor class makes up 25\% of total cluster executors. \para{Results.} We run simulated multi-resource experiments on continuous job arrivals according to the trace. Figure~\ref{f:eval-alibaba-multi-resource-cdf} shows the results for {Decima}\xspace and three other algorithms: the optimally tuned weighted-fair heuristic, Tetris, and Graphene\textsuperscript{$\ast$}\xspace. {Decima}\xspace achieves a $32\%$ lower average JCT than the best competing algorithm (Graphene\textsuperscript{$\ast$}\xspace), suggesting that it learns a good policy in the multi-resource environment. {Decima}\xspace's policy is qualitatively different to Graphene\textsuperscript{$\ast$}\xspace's. Figure~\ref{f:eval-alibaba-multi-resource-job-duration} breaks {Decima}\xspace's improvement over Graphene\textsuperscript{$\ast$}\xspace down by jobs' total work. {Decima}\xspace completes jobs faster than Graphene\textsuperscript{$\ast$}\xspace for all job sizes, but its gain is particularly large for small jobs. The reason is that {Decima}\xspace learns to use ``oversized'' executors when they can help finish nearly-completed small jobs when insufficiently many right-sized executors are available. Figure~\ref{f:eval-tpch-multi-resource-exec-usage} illustrates this: {Decima}\xspace uses $39\%$ more executors of the largest class on the jobs with smallest $20\%$ total work (full profiles in Appendix~\ref{s:multi-resource-more-analysis}). In other words, {Decima}\xspace trades off memory fragmentation against clearing the job queue more quickly. This trade-off makes sense because small jobs ({\em i}\/){} contribute more to the average JCT objective, and ({\em ii}\/){} only fragment resources for a short time. By contrast, Tetris greedily packs tasks into the best-fitting executor class and achieves the lowest memory fragmentation. {Decima}\xspace's fragmentation is within $4\%$--$13\%$ of Tetris's, but {Decima}\xspace's average JCT is $52\%$ lower, as it learns to balance the trade-off well. This requires respecting workload-dependent factors, such as the DAG structure, the threshold for what is a ``small'' job, and others. Heuristic approaches like Graphene\textsuperscript{$\ast$}\xspace attempt to balance those factors via additive score functions and extensive tuning, while {Decima}\xspace learns them without such inputs. We also repeat this experiment with the TPC-H workload, using 200 executors and sampling each TPC-H DAG node's memory request from $(0, 1]$. Figure~\ref{f:eval-tpch-multi-resource-cdf} shows that {Decima}\xspace outperforms the competing algorithms by even larger margins ({e.g.},\xspace $43\%$ over Graphene\textsuperscript{$\ast$}\xspace). This is because the industrial trace lacks work inflation measurements for different levels of parallelism, which we provide for TPC-H. {Decima}\xspace learns to use this information to further calibrate executor assignment. \subsection{{Decima}\xspace deep dive} \label{s:eval-ubenches} Finally, we demonstrate the wide range of scheduling policies {Decima}\xspace can learn, and break down the impact of our key ideas and techniques on {Decima}\xspace's performance. In appendices, we further evaluate {Decima}\xspace's optimality via an exhaustive search of job orderings~(Appendix~\ref{s:optimality}), the robustness of its learned policies to changing environments~(Appendix~\ref{s:generalizability}), and {Decima}\xspace's sensitivity to incomplete information~(Appendix~\ref{s:incomplete-info}). \para{Learned policies.} {Decima}\xspace outperforms other algorithms because it can learn different policies depending on the high-level objective, the workload, and environmental conditions. When {Decima}\xspace optimizes for average JCT (Figure~\ref{f:eval-spark-examples-avg-jct}), it learns to share executors for small jobs to finish them quickly and avoids inefficiently using too many executors on large jobs~(\S\ref{s:eval-real-cluster}). {Decima}\xspace also keeps the executors working on tasks from the same job to avoid the overhead of moving executors (\S\ref{s:impl-spark}). However, if moving executors between jobs is free\,---\,as is effectively the case for long tasks, or for systems without JVM spawn overhead\,---\, {Decima}\xspace learns a policy that eagerly moves executors among jobs (cf.\ the frequent color changes in Figure~\ref{f:eval-spark-examples-no-moving-cost}). Finally, given a different objective of minimizing the overall \emph{makespan} for a batch of jobs, {Decima}\xspace learns yet another different policy (Figure~\ref{f:eval-spark-examples-makespan}). Since only the \emph{final} job's completion time matters for a makespan objective, {Decima}\xspace no longer works to finish jobs early. Instead, many jobs complete together at the end of the batched workload, which gives the scheduler more choices of jobs throughout the execution, increasing cluster utilization. \para{Impact of learning architecture.} We validate that {Decima}\xspace uses all raw information provided in the state and requires all its key design components by selectively omitting components. We run 1,000 continuous TPC-H job arrivals on a simulated cluster at different loads, and train five different variants of {Decima}\xspace on each load. Figure~\ref{f:eval-ubench-component-breakdown} shows that removing any one component from {Decima}\xspace results in worse average JCTs than the tuned weighted-fair heuristic at a high cluster load. There are four takeaways from this result. First, parallelism control has the greatest impact on {Decima}\xspace's performance. Without parallelism control, {Decima}\xspace assigns all available executors to a single stage at every scheduling event. Even at a moderate cluster load ({e.g.},\xspace 55\%), this leads to an unstable policy that cannot keep up with the arrival rate of incoming jobs. Second, omitting the graph embedding ({i.e.},\xspace directly taking raw features on each node as input to the score functions in~\S\ref{s:action}) makes {Decima}\xspace unable to estimate remaining work in a job and to account for other jobs in the cluster. Consequently, {Decima}\xspace has no notion of small jobs or cluster load, and its learned policy quickly becomes unstable as the load increases. Third, using unfixed job sequences across training episodes increases the variance in the reward signal~(\S\ref{s:training}). As the load increases, job arrival sequences become more varied, which increases variance in the reward. At cluster load larger than $75\%$, reducing this variance via synchronized termination improves average JCT by $2\times$ when training {Decima}\xspace, illustrating that variance reduction is key to learning high-quality policies in long-horizon scheduling problems. Fourth, training only on batched job arrivals cannot generalize to continuous job arrivals. When trained on batched arrivals, {Decima}\xspace learns to systematically defer large jobs, as this results in the lowest sum of JCTs (lowest sum of penalties). With continuous job arrivals, this policy starves large jobs indefinitely as the cluster load increases and jobs arrive more frequently. Consequently, {Decima}\xspace underperforms the tuned weighted-fair heuristic at loads above $65\%$ when trained on batched arrivals. \begin{figure} \centering \includegraphics[width=0.9\columnwidth]{stream_breakdown.pdf} \vspace{-0.3cm} \caption{Breakdown of each key idea's contribution to {Decima}\xspace with continuous job arrivals. Omitting any concept increases {Decima}\xspace's average JCT above that of the weighted fair policy.} \label{f:eval-ubench-component-breakdown} \vspace{-0.3cm} \end{figure} \para{Generalizing to different workloads.} \begin{table}[t] \footnotesize \hspace{0cm} \scalebox{0.95}{ \begin{tabular}{|r|l|} \hline \bf Setup\; (IAT: interarrival time) & \bf Average JCT [sec] \\ \hline Opt. weighted fair (best heuristic) & $91.2 \pm 23.5$ \\ \hline {Decima}\xspace, trained on test workload \,(IAT: 45 sec) & $65.4 \pm 28.7$ \\ {Decima}\xspace, trained on anti-skewed workload \,(IAT: 75 sec) & $104.8 \pm 37.6$ \\ {Decima}\xspace, trained on mixed workloads & $82.3 \pm 31.2$ \\ {Decima}\xspace, trained on mixed workloads with interarrival time hints & $76.6 \pm 33.4$ \\ \hline \end{tabular} } \vspace{0.1cm} \caption{\update{{Decima}\xspace generalizes to changing workloads. For an unseen workload, {Decima}\xspace outperforms the best heuristic by $10\%$ when trained with a mix of workloads; and by $16\%$ if it knows the interarrival time from an input feature.}} \label{t:generalize_workload} \vspace{-0.8cm} \end{table} \update{ We test {Decima}\xspace's ability to generalize by changing the training workload in the TPC-H experiment (\S\ref{s:eval-real-cluster}). To simulate shifts in cluster workload, we train models for different job interarrival times between 42 and 75 seconds, and test them using a workload with a 45 second interarrival time. As {Decima}\xspace learns workload-specific policies, we expect its effectiveness to depend on whether broad test workload characteristics, such as interarrival time and job size distributions, match the training workload. Table~\ref{t:generalize_workload} shows the resulting average JCT. {Decima}\xspace performs well when trained on a workload similar to the test workload. Unsurprisingly, when {Decima}\xspace trains with an ``anti-skewed'' workload (75 seconds interarrival time), it generalizes poorly and underperforms the optimized weighted fair policy. This makes sense because {Decima}\xspace incorporates the learned interarrival time distribution in its policy. When training with a mixed set of workloads that cover the whole interarrival time range, {Decima}\xspace can learn a more general policy. This policy fits less strongly to a specific interarrival time distribution and therefore becomes more robust to workload changes. If {Decima}\xspace can observe the interarrival time as a feature in its state (\S\ref{s:impl-spark}), it generalizes better still and learns an adaptive policy that achieves a 16\% lower average JCT than the best heuristic. These results highlight that a diverse training workload set helps make {Decima}\xspace's learned policies robust to workload shifts; we discuss possible online learning in \S\ref{s:discussion}. } \para{Training and inference performance.} Figure~\ref{f:eval-learning-curve} shows {Decima}\xspace's learning curve (in blue) on continuous TPC-H job arrivals (\S\ref{s:eval-real-cluster}), testing snapshots of the model every 100 iterations on (unseen) job arrival sequences. Each training iteration takes about 5 seconds. {Decima}\xspace's design (\S\ref{s:training}) is crucial for training efficiency: omitting the parallelism limit values in the input (yellow curve) forces {Decima}\xspace to use separate score functions for different limits, significantly increasing the number of parameters to optimize over; putting fine-grained parallelism control on nodes (green curve) slows down training as it increases the space of algorithms {Decima}\xspace must explore. Figure~\ref{f:eval-inference-time} shows cumulative distributions of the time {Decima}\xspace takes to decide on a scheduling action (in red) and the time interval between scheduling events (in blue) in our Spark testbed (\S\ref{s:eval-real-cluster}). The average scheduling delay for {Decima}\xspace is less than 15ms, while the interval between scheduling events is typically in the scale of seconds. In less than $5\%$ of the cases, the scheduling interval is shorter than the scheduling delay ({e.g.},\xspace when the cluster requests for multiple scheduling actions in a single scheduling event). Thus {Decima}\xspace's scheduling delay imposes no measurable overhead on task runtimes. \begin{figure} \centering \begin{subfigure}[t]{0.25\textwidth} \centering \includegraphics[width=\textwidth]{learning_curve.pdf} \vspace{-0.5cm} \caption{Learning curve.} \label{f:eval-learning-curve} \end{subfigure} \begin{subfigure}[t]{0.18\textwidth} \centering \includegraphics[width=\textwidth]{inference_time.pdf} \vspace{-0.5cm} \caption{Scheduling delay.} \label{f:eval-inference-time} \end{subfigure} \vspace{-0.3cm} \caption{Different encodings of jobs parallelism (\S\ref{s:action}) affect {Decima}\xspace's training time. {Decima}\xspace makes low-latency scheduling decisions: on average, the latency is about 50$\times$ smaller than the interval between scheduling events.} \label{f:eval-sys-perf} \vspace{-0.5cm} \end{figure} \section{Implementation} \label{s:impl} We have implemented {Decima}\xspace as a pluggable scheduling service that parallel data processing platforms can communicate with over an RPC interface. In \S\ref{s:impl-spark}, we describe the integration of {Decima}\xspace with Spark. Next, we describe our Python-based training infrastructure which includes an accurate Spark cluster simulator~(\S\ref{s:simulator}). \subsection{Spark integration} \label{s:impl-spark} A Spark cluster\footnote{We discuss Spark's ``standalone'' mode of operation here (\url{http://spark.apache.org/docs/latest/spark-standalone.html}); YARN-based deployments can, in principle, use {Decima}\xspace, but require modifying both Spark and YARN.} runs multiple parallel \emph{applications}, which contain one or more jobs that together form a DAG of processing stages. The Spark master manages application execution and monitors the health of many \emph{workers}, which each split their resources between multiple executors. Executors are created for, and remain associated with, a specific application, which handles its own scheduling of work to executors. Once an application completes, its executors terminate. Figure~\ref{f:impl-spark-architecture} illustrates this architecture. \smallskip \noindent To integrate {Decima}\xspace in Spark, we made two major changes: \begin{CompactEnumerate} % \item Each application's \textbf{DAG scheduler} contacts {Decima}\xspace on startup and whenever a scheduling event occurs. % {Decima}\xspace responds with the next stage to work on and the parallelism limit (\S\ref{s:action}). % \item The Spark \textbf{master} contacts {Decima}\xspace when a new job arrives to determine how many executors to launch for it, and \update{aids {Decima}\xspace by taking executors away from a job once they complete a stage.} % \end{CompactEnumerate} \begin{figure} \centering \includegraphics[height=3.6cm]{spark_implementation.pdf} \vspace{-0.3cm} \caption{Spark standalone cluster architecture, with {Decima}\xspace additions highlighted.} \label{f:impl-spark-architecture} \vspace{-0.4cm} \end{figure} \para{State observations.} In {Decima}\xspace, the feature vector $\mathbf{x}^i_v$~(\S\ref{s:graph}) of a node $v$ in job DAG $i$ consists of: ({\em i}\/){} the number of tasks remaining in the stage, ({\em ii}\/){} the average task duration, ({\em iii}\/){} the number of executors currently working on the node, ({\em iv}\/){} the number of available executors, and ({\em v}\/){} whether available executors are local to the job. \update{We picked these features by attempting to include information necessary to capture the state of the cluster ({e.g.},\xspace the number of executors currently assigned to each stage), as well as the statistics that may help in scheduling decisions ({e.g.},\xspace a stage's average task duration). These statistics depend on the information available ({e.g.},\xspace profiles from past executions of the same job, or runtime metrics) and on the system used (here, Spark). {Decima}\xspace can easily incorporate additional signals.} \para{Neural network architecture.} The graph neural network's six transformation functions $f(\cdot)$ and $g(\cdot)$ (\S\ref{s:graph}) (two each for node-level, job-level, and global embeddings) and the policy network's two score functions $q(\cdot)$ and $w(\cdot)$ (\S\ref{s:action}) are implemented using two-hidden-layer neural networks, with 32 and 16 hidden units on each layer. Since these neural networks are reused for all jobs and all parallelism limits, {Decima}\xspace's model is lightweight\,---\,it consists of 12,736 parameters (50KB) in total. Mapping the cluster state to a scheduling decision takes less than 15ms (Figure~\ref{f:eval-inference-time}). \subsection{Spark simulator} \label{s:simulator} {Decima}\xspace's training happens offline using a faithful simulator that has access to profiling information ({e.g.},\xspace task durations) from a real Spark cluster~(\S\ref{s:eval-real-cluster}) and the job run time characteristics from an industrial trace~(\S\ref{s:multi-dim}). To faithfully simulate how {Decima}\xspace's decisions interact with a cluster, our simulator captures several real-world effects: \begin{CompactEnumerate} \item The first ``wave'' of tasks from a particular stage often runs slower than subsequent tasks. % This is due to Spark's pipelined task execution~\cite{ousterhout-nsdi15}, JIT compilation~\cite{jit} of task code, and warmup costs ({e.g.},\xspace making TCP connections to other executors). % {Decima}\xspace's simulated environment thus picks the actual runtime of first-wave tasks from a different distribution than later waves. % \item Adding an executor to a Spark job involves launching a JVM process, which takes 2--3 seconds. % Executors are tied to a job for isolation and because Spark assumes them to be long-lived. % {Decima}\xspace's environment therefore imposes idle time reflecting the startup delay every time {Decima}\xspace moves an executor across jobs. % \item A high degree of parallelism can \emph{slow down} individual Spark tasks, as wider shuffles require additional TCP connections and create more work when merging data from many shards. % {Decima}\xspace's environment captures these effects by sampling task durations from distributions collected at different levels of parallelism if this data is available. % \end{CompactEnumerate} In Appendix~\ref{s:sim-fidelity}, we validate the fidelity of our simulator by comparing it with real Spark executions. \section{Introduction} \label{s:intro} Efficient utilization of expensive compute clusters matters for enterprises: even small improvements in utilization can save millions of dollars at scale~\cite[\S1.2]{wsc-book-2ed}. Cluster schedulers are key to realizing these savings. A good scheduling policy packs work tightly to reduce fragmentation~\cite{graphene, tetris, job-packing-google}, prioritizes jobs according to high-level metrics such as user-perceived latency~\cite{borg}, and avoids inefficient configurations~\cite{jockey}. Current cluster schedulers rely on heuristics that prioritize generality, ease of understanding, and straightforward implementation over achieving the ideal performance on a specific workload. By using general heuristics like fair scheduling~\cite{hadoop-fair-sched, drf}, shortest-job-first, and simple packing strategies~\cite{tetris}, current systems forego potential performance optimizations. For example, widely-used schedulers ignore readily available information about job structure ({i.e.},\xspace internal dependencies) and efficient parallelism for jobs' input sizes. Unfortunately, workload-specific scheduling policies that use this information require expert knowledge and significant effort to devise, implement, and validate. For many organizations, these skills are either unavailable, or uneconomic as the labor cost exceeds potential savings. In this paper, we show that modern machine-learning techniques can help side-step this trade-off by \emph{automatically learning} highly efficient, workload-specific scheduling policies. We present {Decima}\xspace \footnote{In Roman mythology, {Decima}\xspace measures threads of life and decides their destinies.}, a general-purpose scheduling service for data processing jobs with dependent stages. Many systems encode job stages and their dependencies as directed acyclic graphs (DAGs)~\cite{spark, tez, dryad, flumejava}. Efficiently scheduling DAGs leads to hard algorithmic problems whose optimal solutions are intractable~\cite{graphene}. Given only a high-level goal ({e.g.},\xspace minimize average job completion time), {Decima}\xspace uses existing monitoring information and past workload logs to automatically learn sophisticated scheduling policies. For example, instead of a rigid fair sharing policy, {Decima}\xspace learns to give jobs different shares of resources to optimize overall performance, and it learns job-specific parallelism levels that avoid wasting resources on diminishing returns for jobs with little inherent parallelism. The right algorithms and thresholds for these policies are workload-dependent, and achieving them today requires painstaking manual scheduler customization. {Decima}\xspace learns scheduling policies through experience using modern reinforcement learning (RL) techniques. RL is well-suited to learning scheduling policies because it allows learning from actual workload and operating conditions without relying on inaccurate assumptions. {Decima}\xspace encodes its scheduling policy in a neural network trained via a large number of simulated experiments, during which it schedules a workload, observes the outcome, and gradually improves its policy. However, {Decima}\xspace's contribution goes beyond merely applying off-the-shelf RL algorithms to scheduling: to successfully learn high-quality scheduling policies, we had to develop novel data and scheduling action representations, and new RL training techniques. First, cluster schedulers must scale to hundreds of jobs and thousands of machines, and must decide among potentially hundreds of configurations per job ({e.g.},\xspace different levels of parallelism). This leads to much larger problem sizes compared to conventional RL applications (e.g., game-playing~\cite{atari, alphago}, robotics control~\cite{ddpg, trpo}), both in the amount of information available to the scheduler (the \emph{state space}), and the number of possible choices it must consider (the \emph{action space}).\footnote{For example, the state of the game of Go~\cite{alphagozero} can be represented by $19\times19 = 361$ numbers, which also bound the number of legal moves per turn.} We designed a scalable neural network architecture that combines a {\em graph neural network}~\cite{graphspectral, graphcombopt, graphcnn, gcnn_google} to process job and cluster information without manual feature engineering, and a {\em policy network} that makes scheduling decisions. Our neural networks reuse a small set of building block operations to process job DAGs, irrespective of their sizes and shapes, and to make scheduling decisions, irrespective of the number of jobs or machines. These operations are parameterized functions learned during training, and designed for the scheduling domain\,---\,{e.g.},\xspace ensuring that the graph neural network can express properties such as a DAG's critical path. Our neural network design substantially reduces model complexity compared to naive encodings of the scheduling problem, which is key to efficient learning, fast training, and low-latency scheduling decisions. Second, conventional RL algorithms cannot train models with continuous streaming job arrivals. The randomness of job arrivals can make it impossible for RL algorithms to tell whether the observed outcome of two decisions differs due to disparate job arrival patterns, or due to the quality the policy's decisions. Further, RL policies necessarily make poor decisions in early stages of training. Hence, with an unbounded stream of incoming jobs, the policy inevitably accumulates a backlog of jobs from which it can never recover. Spending significant training time exploring actions in such situations fails to improve the policy. To deal with the latter problem, we terminate training ``episodes'' early in the beginning, and gradually grow their length. This allows the policy to learn to handle simple, short job sequences first, and to then graduate to more challenging arrival sequences. To cope with the randomness of job arrivals, we condition training feedback on the actual sequence of job arrivals experienced, using a recent technique for RL in environments with stochastic inputs~\cite{variance-reduction}. This isolates the contribution of the scheduling policy in the feedback and makes it feasible to learn policies that handle stochastic job arrivals. We integrated {Decima}\xspace with Spark and evaluated it in both an experimental testbed and on a workload trace from \update{Alibaba's production clusters}~\cite{alibaba-data, alibaba_data_analysis}.\footnote{We used an earlier version of Alibaba's public \texttt{cluster-trace-v2018} trace.} Our evaluation shows that {Decima}\xspace outperforms existing heuristics on a 25-node Spark cluster, reducing average job completion time of TPC-H query mixes by at least 21\%. {Decima}\xspace's policies are particularly effective during periods of high cluster load, where it improves the job completion time by up to 2$\times$ over existing heuristics. {Decima}\xspace also extends to multi-resource scheduling of CPU and memory, where it improves average job completion time by 32-43\% over prior schemes such as Graphene~\cite{graphene}. \smallskip \noindent In summary, we make the following key contributions: \begin{CompactEnumerate} \item A scalable neural network design that can process DAGs of arbitrary shapes and sizes, schedule DAG stages, and set efficient parallelism levels for each job (\S\ref{s:graph}--\S\ref{s:action}). \item A set of RL training techniques that for the first time enable training a scheduler to handle unbounded stochastic job arrival sequences~(\S\ref{s:training}). \item {Decima}\xspace, the first RL-based scheduler that schedules complex data processing jobs and learns workload-specific scheduling policies without human input, and a prototype implementation of it (\S\ref{s:impl}). \item An evaluation of {Decima}\xspace in simulation and in a real Spark cluster, and a comparison with state-of-the-art scheduling heuristics (\S\ref{s:eval}). \end{CompactEnumerate} \section{Motivation} \label{s:motivation} \begin{figure} \centering \includegraphics[height=3.5cm]{tpch-2.pdf} \vspace{-0.7cm} \caption{\small Data-parallel jobs have complex data-flow graphs like the ones shown (TPC-H queries in Spark), with each node having a distinct number of tasks, task durations, and input/output sizes.} \label{f:tpch-viz} \vspace{-0.4cm} \end{figure} Data processing systems and query compilers such as Hive, Pig, SparkSQL, and DryadLINQ create \emph{DAG-structured} jobs, which consist of processing stages connected by input/output dependencies (Figure~\ref{f:tpch-viz}). For recurring jobs, which are common in production clusters~\cite{rope}, reasonable estimates of runtimes and intermediate data sizes may be available. Most cluster schedulers, however, ignore this job structure in their decisions and rely on {e.g.},\xspace coarse-grained fair sharing~\cite{hadoop-fair-sched, drf, h-drf, choosy}, rigid priority levels~\cite{borg}, and manual specification of each job's parallelism~\cite[\S5]{omega}. Existing schedulers choose to largely ignore this rich, easily-available job structure information because it is difficult to design scheduling algorithms that make use of it. We illustrate the challenges of using job-specific information in scheduling decisions with two concrete examples: ({\em i}\/){} dependency-aware scheduling, and ({\em ii}\/){} automatically choosing the right number of parallel tasks. \subsection{Dependency-aware task scheduling} \label{s:motiv-structure} Many job DAGs in practice have tens or hundreds of stages with different durations and numbers of parallel tasks in a complex dependency structure. An ideal schedule ensures that independent stages run in parallel as much as possible, and that no stage ever blocks on a dependency if there are available resources. Ensuring this requires the scheduler to understand the dependency structure and plan ahead. This ``DAG scheduling problem'' is algorithmically hard: see, {e.g.},\xspace the illustrative example by Grandl et al.~\cite[\S2.2]{graphene} and the one we describe in detail in Appendix~\ref{s:graph-hard}. Theoretical research~\cite{shmoys1994improved, blumofe1999scheduling, chekuri2004multi, leighton1988universal} has focused mostly on simple instances of the problem that do not capture the complexity of real data processing clusters (e.g., online job arrivals, multiple DAGs, multiple tasks per stage, jobs with different inherent parallelism, overheads for moving jobs between machines, etc.). For example, in a recent paper, Agrawal et al.~\cite{dag_schedule_soda} showed that two simple DAG scheduling policies (shortest-job-first and latest-arrival-processor-sharing) have constant competitive ratio in a basic model with one task per job stage. As our results show (\S\ref{s:motivate_visualization}, \S\ref{s:eval}), these policies are far from optimal in a real Spark cluster. Hence, designing an algorithm to generate optimal schedules for all possible DAG combinations is intractable~\cite{acyclic-jobs-hard, graphene}. Existing schedulers ignore this challenge: they enqueue tasks from a stage as soon as it becomes available, or run stages in an arbitrary order. \subsection{Setting the right level of parallelism} \label{s:motiv-parallelism} \begin{figure} \centering \includegraphics[width=0.9\columnwidth]{tpc-h_executor_scaling.pdf} \vspace{-0.5cm} \caption{\small TPC-H queries scale differently with parallelism: Q9 on a 100 GB input sees speedups up to 40 parallel tasks, while Q2 stops gaining at 20 tasks; Q9 on a 2 GB input needs only 5 tasks. Picking ``sweet spots'' on these curves for a mixed workload is difficult.} \label{f:motivation-parallelism} \vspace{-0.2cm} \end{figure} \begin{figure*}[t] \centering \begin{subfigure}[t]{0.245\textwidth} \centering \includegraphics[width=\textwidth]{motivation_fifo.pdf} \vspace{-0.6cm} \caption{FIFO scheduling.} \label{f:motiv-fifo} \end{subfigure} \begin{subfigure}[t]{0.245\textwidth} \centering \includegraphics[width=\textwidth]{motivation_sjf.pdf} \vspace{-0.6cm} \caption{SJF scheduling.} \label{f:motiv-sjf} \end{subfigure} \begin{subfigure}[t]{0.245\textwidth} \centering \includegraphics[width=\textwidth]{motivation_fair.pdf} \vspace{-0.6cm} \caption{Fair scheduling.} \label{f:motiv-fair} \end{subfigure} \begin{subfigure}[t]{0.245\textwidth} \centering \includegraphics[width=\textwidth]{motivation_learn.pdf} \vspace{-0.6cm} \caption{{Decima}\xspace.} \label{f:motiv-v2} \end{subfigure} \vspace{-0.3cm} \caption{Decima improves average JCT of 10 random TPC-H queries by 45\% over Spark's FIFO scheduler, and by 19\% over a fair scheduler on a cluster with 50 task slots (executors). Different queries in different colors; vertical red lines are job completions; purple means idle.} \label{f:motivation-comparison} \end{figure*} In addition to understanding dependencies, an ideal scheduler must also understand how to best split limited resources among jobs. Jobs vary in the amount of data that they process, and in the amount of parallel work available. A job with large input or large intermediate data can efficiently harness additional parallelism; by contrast, a job running on small input data, or one with less efficiently parallelizable operations, sees diminishing returns beyond modest parallelism. Figure~\ref{f:motivation-parallelism} illustrates this with the job runtime of two TPC-H~\cite{tpch} queries running on Spark as they are given additional resources to run more parallel tasks. Even when both process 100 GB of input, Q2 and Q9 exhibit widely different scalability: Q9 sees significant speedup up to 40 parallel tasks, while Q2 only obtains marginal returns beyond 20 tasks. When Q9 runs on a smaller input of 2 GB, however, it needs no more than ten parallel tasks. For all jobs, assigning additional parallel tasks beyond a ``sweet spot'' in the curve adds only diminishing gains. Hence, the scheduler should reason about which job will see the largest marginal gain from extra resources and accordingly pick the sweet spot for each job. Existing schedulers largely side-step this problem. Most burden the user with the choice of how many parallel tasks to use~\cite[\S5]{omega}, or rely on a separate ``auto-scaling'' component based on coarse heuristics~\cite{jockey, spark-dynamic-scaling}. Indeed, many fair schedulers~\cite{quincy, drf} divide resources without paying attention to their decisions' efficiency: sometimes, an ``unfair'' schedule results in a more efficient overall execution. \subsection{An illustrative example on Spark} \label{s:motivate_visualization} The aspects described are just two examples of how schedulers can exploit knowledge of the workload. To achieve the best performance, schedulers must also respect other considerations, such as the execution order ({e.g.},\xspace favoring short jobs) and avoiding resource fragmentation~\cite{borg, tetris}. Considering all these dimensions together\,---\,as {Decima}\xspace does\,---\,makes a substantial difference. We illustrate this by running a mix of ten randomly chosen TPC-H~\cite{tpch} queries with input sizes drawn from a long-tailed distribution on a Spark cluster with 50 parallel task slots.\footnote{See \S\ref{s:eval} for details of the workload and our cluster setup.} Figure~\ref{f:motivation-comparison} visualizes the schedules imposed by \emph{(\subref{f:motiv-fifo})} Spark's default FIFO scheduling; \emph{(\subref{f:motiv-sjf})} a shortest-job-first (SJF) policy that strictly prioritizes short jobs; \emph{(\subref{f:motiv-fair})} a more realistic, fair scheduler that dynamically divides task slots between jobs; and \emph{(\subref{f:motiv-v2})} a scheduling policy learned by {Decima}\xspace. We measure average job completion time (JCT) over the ten jobs. Having access to the graph structure helps {Decima}\xspace improve average JCT by 45\% over the naive FIFO scheduler, and by 19\% over the fair scheduler. It achieves this speedup by completing short jobs quickly, as five jobs finish in the first 40 seconds; and by maximizing parallel-processing efficiency. SJF dedicates all task slots to the next-smallest job in order to finish it early (but inefficiently); by contrast, {Decima}\xspace runs jobs near their parallelism sweet spot. By controlling parallelism, {Decima}\xspace reduces the total time to complete all jobs by 30\% compared to SJF. Further, unlike fair scheduling, {Decima}\xspace partitions task slots non-uniformly across jobs, improving average JCT by 19\%. Designing general-purpose heuristics to achieve these benefits is difficult, as each additional dimension (DAG structure, parallelism, job sizes, etc.) increases complexity and introduces new edge cases. {Decima}\xspace opens up a new option: using data-driven techniques, it \emph{automatically} learns workload-specific policies that can reap these gains. {Decima}\xspace does so without requiring human guidance beyond a high-level goal ({e.g.},\xspace minimal average JCT), and without explicitly modeling the system or the workload. \section{Related Work} \label{s:related} There is little prior work on applying machine learning techniques to cluster scheduling. DeepRM~\cite{deeprm}, which uses RL to train a neural network for multi-dimensional resource packing, is closest to {Decima}\xspace in aim and approach. \update{However, DeepRM only deals with a basic setting in which each job is a single task and was evaluated in simple, simulated environments. DeepRM's learning model also lacks support for DAG-structured jobs, and its training procedure cannot handle realistic cluster workloads with continuous job arrivals.} \update{In other applications,} Mirhoseini et al.'s work on learning device placement in TensorFlow (TF) computations~\cite{tf-device-placement} also uses RL, but relies on recurrent neural networks to scan through all nodes for state embedding, rather than a graph neural network. Their approach use recurrent neural networks to scan through all nodes for state embedding instead of using a scalable graph neural network. The objective there is to schedule a single TF job well, and the model cannot generalize to unseen job combinations~\cite{hierarchical-tf-device-placement}. \update{ Prior work in machine learning and algorithm design has combined RL and graph neural networks to optimize complex combinatorial problems, such as vertex set cover and the traveling salesman problem~\cite{graphcombopt, gcn_comb_search}. The design of {Decima}\xspace's scalable state representation is inspired by this line of work, but we found that off-the-shelf graph neural networks perform poorly for our problem. To train strong scheduling agents, we had to change the graph neural network architecture to enable {Decima}\xspace to compute, amongst other metrics, the critical path of a DAG (\S\ref{s:graph}). } \update{For resource management systems more broadly,} Paragon~\cite{paragon} and Quasar~\cite{quasar} use collaborative filtering to match workloads to different machine types and avoid interference; their goal is complementary to {Decima}\xspace's. Tetrisched~\cite{tetrisched}, like {Decima}\xspace, plans ahead in time, but uses a constraint solver to optimize job placement and requires the user to supply explicit constraints with their jobs. Firmament~\cite{firmament-osdi} also uses a constraint solver and achieves high-quality placements, but requires an administrator to configure an intricate scheduling policy. Graphene~\cite{graphene} uses heuristics to schedule job DAGs, but cannot set appropriate parallelism levels. Some systems ``auto-scale'' parallelism levels to meet job deadlines~\cite{jockey} or opportunistically accelerate jobs using spare resources~\cite[\S5]{omega}. \update{ Carbyne~\cite{carbyne} allows jobs to ``altruistically’' give up some of their short-term fair share of cluster resources in order to improve JCT across jobs while guarantee long-term fairness. {Decima}\xspace learns policies similar to Carbyne’s, balancing resource shares and packing for low average JCT, but the current design of {Decima}\xspace does not have fairness an objective. } General-purpose cluster managers like Borg~\cite{borg}, Mesos~\cite{mesos}, or YARN~\cite{yarn} support many different applications, making workload-specific scheduling policies are difficult to apply at this level. However, {Decima}\xspace could run as a framework atop Mesos or Omega~\cite{omega}.
{'timestamp': '2019-08-23T02:03:23', 'yymm': '1810', 'arxiv_id': '1810.01963', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01963'}
arxiv
\section{Introduction} Face detection and recognition from still images is an active research area in computer vision \cite{pietikainen}. Most of the state-of-the-art face recognition approaches were restricted to the controlled environments such as frontal pose \cite{bereta}. Detailed survey on face recognition tasks have been conducted many a time by the researchers \cite{smeulders,huang,yang}. Recently, recognizing faces in the wild images, has become an emerging area of research in computer vision \cite{lfw}. Face recognition in unconstrained environment is still an unsolved problem due to the various levels of challenges like part or full occlusion of faces, varying illumination, multiple posture of faces, expressions on faces, etc. The face recognition task becomes even harder when multiple such challenges are present simultaneously. In order to facilitate the face detection and recognition research, we propose a multi-face challenging dataset including all such challenges discussed above. This dataset will be publicly available to the research community. A few publicly available datasets exist in the literature for face recognition and detection, involving challenges like different side poses, occluded faces, varying light intensities,etc. For instance, the AT \& T face database \cite{attdb} has only grayscale and frontal face images. The AR face database \cite{ardb} contains faces with different facial expressions, varying illumination, and occlusions in the face images. This database is having only single face images with uniform background. The CroppedYale dataset contains faces only with the illumination variations \cite{CroppedYale}. The LFW face dataset is challenging and captured under unconstrained environment \cite{lfwdb} with single face images. For the comparison purpose, we have used CroppedLFW version of this dataset \cite{CroppedLFW}. The PaSC face dataset consists of pose, illumination and blur effects \cite{pasc}. Total 8718 faces from 293 subjects are present after applying the Viola Jones object detection method \cite{viola} for face localization in PaSC dataset. The PubFig dataset is another challenging dataset consisting of images in unconstrained environment \cite{pubfig}. Variations in lighting, expression and pose effects are present in the PubFig dataset with total 6472 images from 60 individuals. The dead urls are removed while downloading the PubFig images. However, none of the existing face datasets offer multiple faces in the images. The proposed IIITS\_MFace is a new dataset for face recognition in images containing multiple faces. Moreover, in addition to the various challenges involved in the state-of-the-art datasets, the images of the proposed dataset are captured in uneven and varying background, which was missing in state-of-the-art datasets. Some sample images from the proposed dataset are shown in Figure \ref{fig:1}. \begin{figure}[!t] \includegraphics[width=\linewidth, height=6cm]{fig1} \caption{Sample images from original gallery set of the proposed IIITS\_MFace dataset. The various challenges like pose variation, occlusion, illumination changes, orientations, etc. can be observed.} \label{fig:1} \end{figure} We show the complicacy in the proposed IIITS\_MFace dataset, by applying state-of-the-art hand-designed as well as deep learning based face recognition techniques on the dataset. We emphasize on local image descriptors, considering the recent success of local image descriptors on face recognition task. Several efforts have been made to apply local image descriptors for face recognition. Local Binary Pattern (LBP) is proposed by Ahonen et al. for the face representation \cite{lbp}. LBP is computed by finding a binary pattern of 1 and 0 for each neighbor of a center pixel. The bit is coded as 1 if the intensity value of neighbor is greater than or equal to the intensity value of center pixel; otherwise it is coded as 0. Local Ternary Pattern (LTP) is the extension of LBP by introducing two thresholds for uniform illumination robust face recognition \cite{ltp}. The LBP over four derivative images corresponding to four directions are computed and concatenated to form the Local Derivative Pattern (LDP) \cite{ldp}. The concept of high order directional gradient is used to find the Local Directional Gradient Pattern (LDGP) to extract the local information of the image \cite{ldgp}. In the recent advancements, Semi-structure Local Binary Pattern (SLBP) \cite{slbp}, Local Vector Pattern (LVP) \cite{lvp}, and Local Gradient Hexa Pattern (LGHP) \cite{lghp} descriptors are proposed for the unconstrained face recognition. The VGGFace CNN descriptor \cite{vggface} is very discriminative and based on the deep learning technique. We experimented with all these descriptors on the proposed dataset. Next we provide a detailed description of the proposed dataset. \section{Proposed IIITS\_MFace Dataset} The images in the proposed IIITS\_MFace dataset are captured by cameras of multiple mobile phones to make it more realistic with respect to the real world face recognition problem. A lot of variations in terms of pose, masked, spectacles, number of subjects, illumination, occlusion, etc. are present in the dataset to make it as unconstrained as possible. The proposed dataset is divided into two sections with seven subjects including six male and one female. The two sections of the proposed dataset are named as Gallery Set and Probe Set. The IIITS\_MFace dataset is publicly available for research purpose only\footnote{https://sites.google.com/a/iiits.in/snehasis-mukherjee/datasets-1}. \begin{table}[!t] \caption{A summary of gallery set in terms of the variations like Frontal/Non-frontal pose and Masked/Unmasked} \label{t1} \centering \newcolumntype{D}{>{\small\centering}p{0.09\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.115\linewidth}} \newcolumntype{F}{>{\small\centering}p{0.18\linewidth}} \begin{tabular} {|D|E|E|E|F|D|} \hline Subject ID & \#Frontal Masked & \#Frontal Unmasked & \#Non-frontal Masked & \#Non-frontal Unmasked & \#Total Faces \tabularnewline \hline 1 & 0 & 27 & 0 & 67 & 94 \tabularnewline 2 & 0 & 59 & 0 & 121 & 180 \tabularnewline 3 & 27 & 31 & 47 & 54 & 159 \tabularnewline 4 & 0 & 4 & 0 & 13 & 17 \tabularnewline 5 & 7 & 17 & 20 & 39 & 83 \tabularnewline 6 & 0 & 18 & 0 & 68 & 86 \tabularnewline 7 & 1 & 29 & 6 & 33 & 69 \tabularnewline \hline Total & 35 & 185 & 73 & 395 & 688\tabularnewline \hline \end{tabular} \end{table} \begin{table}[!t] \caption{A summary of gallery set in terms of the \#faces with and without spectacles} \label{t2} \centering \newcolumntype{D}{>{\small\centering}p{0.16\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.23\linewidth}} \begin{tabular}{|D|E|E|D|} \hline Subject ID & \#With Spectacles & \#Without Spectacles & \#Total Faces\tabularnewline \hline 1 & 0 & 94 & 94 \tabularnewline 2 & 0 & 180 & 180 \tabularnewline 3 & 159 & 0 & 159 \tabularnewline 4 & 17 & 0 & 17 \tabularnewline 5 & 0 & 83 & 83 \tabularnewline 6 & 0 & 86 & 86 \tabularnewline 7 & 0 & 69 & 69 \tabularnewline \hline Total & 176 & 512 & 688\tabularnewline \hline \end{tabular} \end{table} \begin{figure*}[!t] \centering \includegraphics[width=.97\linewidth, height=11cm]{fig2} \caption{Sample seven faces per subject from gallery set. Each row corresponds to a subject.} \label{fig:2} \end{figure*} \begin{table}[!t] \caption{A summary of probe set in terms of the variations like Frontal/Non-frontal pose and Masked/Unmasked} \label{t3} \centering \newcolumntype{D}{>{\small\centering}p{0.09\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.115\linewidth}} \newcolumntype{F}{>{\small\centering}p{0.18\linewidth}} \begin{tabular} {|D|E|E|E|F|D|} \hline Subject ID & \#Frontal Masked & \#Frontal Unmasked & \#Non-frontal Masked & \#Non-frontal Unmasked & \#Total Faces \tabularnewline \hline 1 & 1 & 43 & 2 & 14 & 60 \tabularnewline 2 & 2 & 6 & 19 & 25 & 52 \tabularnewline 3 & 12 & 8 & 25 & 6 & 51 \tabularnewline 4 & 3 & 9 & 10 & 28 & 50 \tabularnewline 5 & 8 & 18 & 14 & 12 & 52 \tabularnewline 6 & 3 & 5 & 10 & 32 & 50 \tabularnewline 7 & 0 & 27 & 0 & 23 & 50 \tabularnewline \hline Total & 29 & 116 & 80 & 140 & 365\tabularnewline \hline \end{tabular} \end{table} \begin{table}[!t] \caption{A summary of probe set in terms of the \#faces with and without spectacles} \label{t4} \centering \newcolumntype{D}{>{\small\centering}p{0.16\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.23\linewidth}} \begin{tabular} {|D|E|E|D|} \hline Subject ID & \#With Spectacles & \#Without Spectacles & \#Total Faces\tabularnewline \hline 1 & 24 & 36 & 60 \tabularnewline 2 & 18 & 34 & 52 \tabularnewline 3 & 32 & 19 & 51 \tabularnewline 4 & 12 & 38 & 50 \tabularnewline 5 & 12 & 40 & 52 \tabularnewline 6 & 12 & 38 & 50 \tabularnewline 7 & 0 & 50 & 50 \tabularnewline \hline Total & 110 & 255 & 365\tabularnewline \hline \end{tabular} \end{table} \begin{figure*}[!t] \centering \includegraphics[width=0.97\linewidth, height=11cm]{fig3} \caption{Sample seven faces per subject from probe set. Each row corresponds to a subject.} \label{fig:3} \end{figure*} \begin{figure*}[!t] \centering \includegraphics[width=1\linewidth, height=10cm]{fig4} \caption{The face recognition framework using local descriptors. The best matching face against a probe face is extracted based on the minimum distance between feature descriptors of probe face and gallery faces.} \label{fig4} \end{figure*} \subsection{Gallery Set} The images of the gallery set are captured from mobile phones with multiple people involved in some activities like talking, laughing, etc. A total of 180 such images are captured with minimum three and maximum five number of people in an image. Sample images of this set are shown in Figure \ref{fig:1}. We have created a cropped version of the gallery set. All the visible faces in all the images are manually cropped and annotated with the subject labels. The cropped galley set comprises of 688 faces from 180 original multi-face gallery images. The co-ordinates of each face in each image is also provided to validate a face detection algorithm. The cropped version of gallery set can be used for the experiment purpose. The characteristics of gallery set such as frontal/non-frontal pose and masked/unmasked faces are summarized in Table \ref{t1}. In gallery set, a subject is either with spectacle or without spectacle. Table \ref{t2} highlights the subjects with/without spectacles. Only subjects 3 \& 4 are with spectacles. Some cropped faces of gallery set are also shown in Figure \ref{fig:2}. \subsection{Probe Set} The probe set is created in the second section with same set of subjects used in galley set. For each subject, we provide a set of face images with differents poses, captured from mobile phones. Since these images are captured by the subjects individually, a lot of variations are present in the image such as occlusion, spectacle, illumination, pose, viewpoint, blur, masked, etc. Total 365 images are present in the probe set consisting of nearly 50 images from each subject. A detailed description of the probe set is illustrated in Table \ref{t3} and \ref{t4} along with the frontal/non-frontal/masked/unmasked/spectacles number of images. It can be noted that the subjects in gallery set have either used or not used the spectacles, whereas in the probe set, all the subjects except last one have mixed images with and without spectacles as depicted in Table \ref{t4}. Some example faces of probe set are also shown in Fig. \ref{fig:3} in order to illustrate the complexity of the probe set. Next we illustrate the experiments made on proposed face dataset. \section{Face Recognition using Local Descriptors} In this section, the nearest neighbour based face recognition framework using local descriptors is described as shown in Fig. \ref{fig4}. The features using a local descriptor is computed over gallery faces to create the gallery features database. The same descriptor is then used to extract the feature for any probe image. After computing the descriptors, the distance between probe feature and gallery features are computed. Finally, the class of probe face is recognized as the class of best matching gallery face based on the minimum distance between probe face and gallery faces. Several state-of-the-art face descriptors including hand-crafted and deep learned like Local Binary Pattern (LBP) \cite{lbp}, Local Ternary Pattern (LTP) \cite{ltp}, Local Derivative Pattern {LDP} \cite{ldp}, Local Directional Gradient Pattern (LDGP) \cite{ldgp}, Semi-structure Local Binary Pattern (SLBP) \cite{slbp}, Local Vector Pattern (LVP) \cite{lvp}, Local Gradient Hexa Pattern (LGHP) \cite{lghp} and VGGFace CNN descriptor \cite{vggface} are tested over the proposed dataset to establish its complexity. Note that all these descriptors are proposed for face representation purpose and VGGFace CNN descriptor is very discriminative for face representation. The MatConvNet pre-trained model of VGGFace CNN descriptor is used in this paper\footnote{http://www.vlfeat.org/matconvnet/pretrained/}. Several distances such as Euclidean, L1, Cosine, Emd (Earth Mover Distance) and Chisq (Chi-square) \cite{distance} are also used in this paper to find the best performing distance measure for the proposed dataset. \section{Experimental Results} The average recognition rate for the descriptors on the proposed IIITS\_MFace dataset, is used as the evaluation criteria for the descriptors. The average recognition rate is computed by taking the mean of average accuracies obtained over all the subjects of the probe set. The average accuracy for a particular subject of probe set is computed by taking the mean of accuracies obtained by turning each image of that subject as the probe image. Until and otherwise not stated, L1 distance is used to compare the descriptors. \begin{table*}[!t] \caption{The average recognition rate using LBP, LTP, LDP, LDGP, SLBP, LVP, LGHP and VGGFace descriptors with L1 distance over proposed IIITS\_MFace dataset.} \label{t5} \centering \newcolumntype{D}{>{\small\centering}p{0.10\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.08\linewidth}} \newcolumntype{F}{>{\small\centering}p{0.08\linewidth}} \begin{tabular} {|D|E|E|E|F|E|F|F|E|} \hline Descriptor & Subject1 & Subject2 & Subject3 & Subject4 & Subject5 & Subject6 & Subject7 & Mean\tabularnewline \hline LBP&16.67&19.23&58.82&6&19.23&20&52&27.42\tabularnewline LTP&16.67&17.31&54.90&8&5.77&18&54&24.95\tabularnewline LDP&21.67&30.77&64.71&0&5.77&4&2&18.42\tabularnewline LDGP&8.33&15.38&43.14&10&1.92&8&72&22.68\tabularnewline SLBP&11.67&23.08&45.10&4&34.62&6&88&30.35\tabularnewline LVP&18.33&26.92&64.71&18&7.69&12&56&29.09\tabularnewline LGHP&25&30.77&58.82&10&26.92&4&100&36.50\tabularnewline VGGFace&83.33&51.92&68.63&32&92.31&50&100&68.31\tabularnewline \hline \end{tabular} \end{table*} \begin{table*}[!t] \caption{Confusion matrix of average recognition rate using VGGFace descriptor with L1 distance over proposed IIITS\_MFace dataset. The True Positive Values are highlighted in bold.} \label{t9} \centering \begin{tabu} to 0.95\textwidth{|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|} \hline Subjects & Subject1 & Subject2 & Subject3 & Subject4 & Subject5 & Subject6 & Subject7\\ \hline Sub1&\textbf{50}&3&4&1&2&0&0\\ Sub2&8&\textbf{27}&2&1&12&2&0\\ Sub3&0&1&\textbf{35}&4&4&2&5\\ Sub4&9&4&20&\textbf{16}&1&0&0\\ Sub5&0&0&1&0&\textbf{48}&3&0\\ Sub6&6&1&6&0&12&\textbf{25}&0\\ Sub7&0&0&0&0&0&0&\textbf{50}\\ \hline \end{tabu} \end{table*} \begin{table*}[!t] \caption{The average recognition rate using each descriptor with different distances over proposed IIITS\_MFace dataset. The top value in a row is highlighted in bold face.} \label{t6} \centering \begin{tabu} to 0.95\textwidth{|X[c]|X[c]|X[c]|X[c]|X[c]|X[c]|} \hline Descriptor & Euclidean Distance & L1 Distance & Cosine Distance & Emd Distance & Chi-square Distance\\ \hline LBP&25.94&\textbf{27.42}&27.38&18.78&26.66\\ LTP&22.73&24.95&22.73&22.39&\textbf{25.57}\\ LDP&19.01&18.42&20.36&\textbf{22.87}&22.85\\ LDGP&23.88&22.68&\textbf{25.48}&16.08&21.68\\ SLBP&30.27&30.35&29.99&25.96&\textbf{32.42}\\ LVP&23.67&29.09&26.27&24.07&\textbf{30.22}\\ LGHP&29.09&\textbf{36.50}&33.31&23.84&35.38\\ VGGFace&62.58&68.31&68.11&36.55&\textbf{69.39}\\ \hline \end{tabu} \end{table*} \begin{table*}[!t] \caption{A comparison of proposed IIITS\_MFace dataset with AT\&T, AR, Yale, LFW, PaSC and PubFig datasets. Here, `Y', `N' and `P' represent the presence, absence and partial presence of effects like Non-frontal (NoFront), Masked, Occlusion (Occl), Mixed-spectacle (MixSpec), Illumination variation (IllVar), Extreme-Illumination (ExtIll), Background Variation (BackVar), and MutiFace VGGFace. The last row presents the accuracy in \% using VGGFace CNN descriptor over each database using L1 distance measure.} \label{tab} \centering \newcolumntype{D}{>{\small\centering}p{0.16\linewidth}} \newcolumntype{E}{>{\small\centering}p{0.07\linewidth}} \newcolumntype{F}{>{\small\centering}p{0.07\linewidth}} \newcolumntype{G}{>{\small\centering}p{0.07\linewidth}} \newcolumntype{H}{>{\small\centering}p{0.14\linewidth}} \begin{tabular} {|D|E|F|F|F|F|G|H|} \hline Traits & AT\&T & AR & Yale & LFW & PaSC & PubFig & IIITS\_MFace (Ours) \tabularnewline \hline NoFront & N & N & N & Y & Y & Y & Y \tabularnewline Masked & N & Y & N & N & N & N & Y \tabularnewline Occl. & N & N & N & Y & N & N & Y \tabularnewline MixSpec & Y & Y & N & Y & N & N & Y \tabularnewline IllVar & N & N & Y & Y & Y & Y & Y \tabularnewline ExtIll & N & N & Y & N & N & N & N \tabularnewline BackVar & N & N & N & N & Y & Y & Y \tabularnewline MultiFace & N & N & N & N & N & P & Y \tabularnewline \hline VGGFace Result (\%) & 100 & 89.98 & 76.56 & 88.37 & 85.45 & 86.73 & 68.31 \tabularnewline \hline \end{tabular} \end{table*} The average recognition rate over proposed dataset using different descriptors with L1 distance is summarized in Table \ref{t5}. The VGGFace descriptor is the best performing one with 68.31\% average recognition rate among all the descriptors. Among hand-crafted descriptors, the LGHP is the best performing descriptor. Whereas, the LDP is the least performing descriptor because it is more suited to the frontal faces. The performance of most of the descriptor is better for Subject 7 because it is the only female subject. All the descriptors are failed to perform well in case of Subject 4 due to the following reasons: a) the number of faces in gallery set corresponding to subject 4 is just 17, b) all faces of subject 4 in the gallery set are unmasked and with spectacles, and c) the faces of subject 4 in probe set are mixed with huge amount of pose variations, with/without spectacles and masked/unmasked. Overall, despite of being recent, well-known and highly discriminative, these face descriptors are failed to perform well over the proposed face dataset. Table \ref{t9} illustrates the confusion matrix over proposed dataset obtained using the VGGFace CNN descriptor. It can be noted that most of the Subject 4 and 6 probe faces are recognized as the Subject 1, 3 ad 5 due to the huge amount of illumination change in the probe faces of Subject 4 and 6 as compared to the gallery faces. Subjects 1, 3 and 5 are also facing the problems like illumination, background, occlusion and masking. In order to find out which distance is better suited for the proposed IIITS\_MFace dataset, we have conducted an experiment with different distance measures such as Euclidean (Eucld), L1, Cosine, Earth Movers Distance (Emd) and Chisq (Chi-square). The average recognition rate using all the descriptors are presented in Table \ref{t6}. It can be noted that the Chi-square distance is performing well with LTP, SLBP, LVP and VGGFace descriptors. The Euclidean distance is not recommended to be used for the proposed dataset. Though, we have used L1 distance in other experiments, the best result (i.e., 69.39\% accuracy) is obtained using VGGFace descriptor using Chi-square distance. There are challenging datasets available in the literature with challenges like different side poses, occluded faces, varying light intensities, etc. These datasets are discussed in the Introduction section. However, the proposed IIITS\_MFace dataset is much more challenging compared to the other existing face datasets such as AT\&T, AR, Yale, LFW, PaSC and PubFig, as depicted in Table \ref{tab}. The result of VGGFace descriptor is lowest over the proposed IIITS\_MFace dataset, which shows its difficulty and robustness. From the experimental results, we can deduce that the proposed IIITS\_MFace dataset is more challenging compared to the existing face datasets even for the deep learned VGGface descriptor, which makes it more realistic for the experiments to meet the real world scenario. \section{Conclusion} A multi-face challenging IIITS\_MFace dataset is proposed in this paper to validate the performance of hand-crafted local descriptors as well as deep learned CNN descriptor against the different kind of variations. The difficulties like pose, illumination, occlusion, masking, spectacle, background etc. are present in the dataset. The recent state-of-the-art face image descriptors such as LBP, LGHP, VGGFace etc. are used to test the complexity of the IIITS\_MFace dataset. The results in terms of the average recognition rate support the challenges present in the dataset as the best performing VGGFace CNN descriptor achieved only 69.39\% of accuracy in best setting. In general, the VGGFace CNN descriptor is very discriminative and performs reasonably good for face recognition. Several distance measures are also tested and found that the Chi-square distance is better suited for this dataset. In future, the number of subjects and number of samples in the dataset may be increased to facilitate applying some deeper neural network architecture for more robust training. \section*{Acknowledgment} The authors would like to thank all the individuals who have been involved in the process of data collection. Special thanks to Kanv Kumar and Naveen Thella for capturing the images. \bibliographystyle{IEEEtran}
{'timestamp': '2019-03-29T01:05:56', 'yymm': '1810', 'arxiv_id': '1810.01898', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01898'}
arxiv
\section{Introduction} The chase procedure is a fundamental tool for solving many issues involving tuple-generating dependencies, such as data integration \cite{DBLP:conf/pods/Lenzerini02}, data-exchange \cite{DBLP:journals/tcs/FaginKMP05}, query answering using views \cite{DBLP:journals/vldb/Halevy01} or query answering on probabilistic databases \cite{DBLP:conf/icde/OlteanuHK09}. In the last decade, tuple-generating dependencies raised a renewed interest under the name of \emph{existential rules} for the problem known as ontology-based query answering. In this context, the aim is to query a knowledge base $(\ensuremath{I}, \ensuremath{\Sigma})$, where $\ensuremath{I}$ is an instance and $\ensuremath{\Sigma}$ is a set of existential rules (see e.g. the survey chapters \cite{DBLP:books/sp/virgilio09/CaliGL09,DBLP:conf/rweb/MugnierT14}). In more classical database terms, this problem can be recast as querying an instance $\ensuremath{I}$ under incomplete data assumption, provided with a set of constraints $\ensuremath{\Sigma}$, which are tuple-generating dependencies. The chase is a fundamental tool to solve dependency-related problems as it allows one to compute a (possibly infinite) \emph{universal model} of $(\ensuremath{I}, \ensuremath{\Sigma})$, \emph{i.e.}, a model that can be homomorphically mapped to any other model of $(\ensuremath{I}, \ensuremath{\Sigma})$. Hence, the answers to a conjunctive query (and more generally to any kind of query closed by homomorphism) over $(\ensuremath{I}, \ensuremath{\Sigma})$ can be defined by considering solely this universal model. Several variants of the chase have been introduced, and we focus in this paper on the main ones: semi-oblivious \cite{DBLP:conf/pods/Marnette09} (aka skolem \cite{DBLP:conf/pods/Marnette09}), restricted \cite{DBLP:conf/icalp/BeeriV81,DBLP:journals/tcs/FaginKMP05} (aka standard \cite{phd/Onet12}) and core \cite{DBLP:conf/pods/DeutschNR08}. It is well known that all of these produce homomorphically equivalent results but terminate for increasingly larger subclasses of existential rules. Any chase variant starts from an instance and exhaustively performs a sequence of rule applications according to a redundancy criterion which characterizes the variant itself. The question of whether a chase variant terminates on \emph{all instances} for a given set of existential rules is known to be undecidable when there is no restriction on the kind of rules \cite{DBLP:journals/ai/BagetLMS11,DBLP:conf/icalp/GogaczM14}. A number of \emph{sufficient} syntactic conditions for termination have been proposed in the literature for the semi-oblivious chase (see e.g. \cite{phd/Onet12,DBLP:journals/jair/GrauHKKMMW13,DBLP:phd/hal/Rocher16} for syntheses), as well as for the restricted chase \cite{DBLP:conf/ijcai/CarralDK17} (note that the latter paper also defines a sufficient condition for non-termination). However, only few positive results exist regarding the termination of the chase on specific classes of rules. Decidability was shown for the semi-oblivious chase on guarded-based rules (linear rules, and their extension to (weakly-)guarded rules) \cite{DBLP:conf/pods/CalauttiGP15}. Decidability of the core chase termination on guarded rules for a fixed instance was shown in \cite{DBLP:conf/icdt/Hernich12}. In this work, we provide new insights on the chase termination problem for \emph{linear} existential rules, a simple yet important subclass of guarded existential rules, which generalizes inclusion dependencies \cite{DBLP:journals/tods/Fagin81} and practical ontological languages \cite{DBLP:journals/ws/CaliGL12}. Precisely, the question of whether a chase variant terminates on all instances for a set of linear existential rules is studied in two fashions: \begin{itemize} \item does \emph{every} (fair) chase sequence terminate? \item does \emph{some} (fair) chase sequence terminate? \end{itemize} It is well-known that these two questions have the same answer for the semi-oblivious and the core chase variants, but not for the restricted chase. Indeed, this last one may admit both terminating and non-terminating sequences over the same knowledge base. We show that the termination problem is decidable for linear existential rules, whether we consider any version of the problem and any chase variant. We study chase termination by exploiting in a novel way a graph structure, namely the \emph{derivation tree}, which was originally introduced to solve the ontology-based (conjunctive) query answering problem for the family of greedy-bounded treewidth sets of existential rules \cite{DBLP:conf/ijcai/BagetMRT11,DBLP:phd/hal/Thomazo13}, a class that generalizes guarded-based rules and in particular linear rules. We first use derivation trees to show the decidability of the termination problem for the semi-oblivious and restricted chase variants, and then generalize them to \emph{entailment trees} to show the decidability of termination for the core chase. For any chase variant we consider, we adopt the same high-level procedure: starting from a finite set of canonical instances (representative of all possible instances), we build a (set of) tree structures for each canonical instance, while forbidding the occurrence of a specific pattern, we call \emph{unbounded-path witness}. The built structures are finite thanks to this forbidden pattern, and this allows us to decide if the chase terminates on the associated canonical instance. By doing so, we obtain a uniform approach to study the termination of several chase variants, that we believe to be of theoretical interest per se. The derivation tree is moreover a simple structure and the algorithms built on it are likely to lead to an effective implementation. Let us also point out that our approach is constructive: if the chase terminates on a given instance, the algorithm that decides termination actually computes the result of the chase (or a superset of it in the case of the core chase), otherwise it pinpoints a forbidden pattern responsible for non-termination. Besides providing new theoretical tools to study chase termination, we obtain the following results for linear existential rules: \begin{itemize} \item a new proof of the decidability of the semi-oblivious chase termination, building on different objects than the previous proof provided in \cite{DBLP:conf/pods/CalauttiGP15}; we show that our algorithm provides the same complexity upper-bound; \item the decidability of the restricted chase termination, for both versions of the problem, i.e., termination of all (fair) chase sequences and termination of some (fair) chase sequence; to the best of our knowledge, these are the first positive results on the decidability of the restricted chase termination; \item a new proof of the decidability of the core chase termination, with different objects than previous work reported in \cite{DBLP:conf/icdt/Hernich12}; although this latter paper solves the question of the core chase termination given a \emph{single} instance, the results actually allow to infer the decidability of the \emph{all} instance version of the problem, by noticing that only a finite number of instances need to be considered (see the next section). \end{itemize} The paper is organized as follows. After introducing some preliminary notions (Section 2), we define the main components of our framework, namely derivation trees and unbounded-path witnesses (Section 3). We build on these objects to prove the decidability of the semi-oblivious and restricted chase termination (Section 4). Finally, we generalize derivation-trees to entailment trees and use them to prove the decidability of the core chase termination (Section 5). Detailed proofs are provided in the appendix. \section{Preliminaries} \label{section-preliminaries} We consider a logical \emph{vocabulary} composed of a finite set of predicates and an infinite set of constants. An \emph{atom} $\alpha$ has the form $\ensuremath{r}(t_1,\ldots, t_n)$ where $\ensuremath{r}$ is a predicate of arity $n$ and the $t_i$ are terms (i.e., variables or constants). We denote by $\terms{\alpha}$ (resp. $\vars{\alpha}$) the set of terms (resp. variables) in $\alpha$ and extend the notations to a set of atoms. A \emph{ground} atom does not contain any variable. It is convenient to identify the existential closure of a conjunction of atoms with the set of these atoms. An \emph{instance} is a set of (non-necessarily ground) atoms, which is finite unless otherwise specified. Abusing terminology, we will often see an instance as its isomorphic model. Given two sets of atoms $\ensuremath{S}$ and $\ensuremath{S}'$, a \emph{homomorphism} from $\ensuremath{S}'$ to $\ensuremath{S}$ is a substitution $\pi$ of $\vars{\ensuremath{S}'}$ by $\terms{\ensuremath{S}}$ such that $\pi(\ensuremath{S}') \subseteq \ensuremath{S}$. It holds that $\ensuremath{S} \models \ensuremath{S}'$ (where $\models$ denotes classical logical entailment) iff there is a homomorphism from $\ensuremath{S}'$ to $\ensuremath{S}$. An endomorphism of $\ensuremath{S}$ is a homomorphism from $\ensuremath{S}$ to itself. A set of atoms is a \emph{core} if it admits only injective endomorphisms. Any finite set of atoms is logically equivalent to one of its subsets that is a core, and this core is unique up to isomomorphism (i.e., bijective variable renaming). Given sets of atoms $\ensuremath{S}$ and $\ensuremath{S}'$ such that $\ensuremath{S} \cap \ensuremath{S}' \neq \emptyset$, we say that $\ensuremath{S}$ \emph{folds} onto $\ensuremath{S}'$ if there is a homomorphism $\pi$ from $\ensuremath{S}$ to $\ensuremath{S}'$ such that $\pi$ is the identity on $\ensuremath{S} \cap \ensuremath{S}'$. The homomorphism $\pi$ is called a \emph{folding}. In particular, it is well-known that any set of atoms \emph{folds} onto its core. An existential rule (or simply \emph{rule}) is of the form $\ensuremath{\sigma} = \forall\vect{x}\forall\vect{y}.[\body{\vect{x},\vect{y}} \rightarrow \exists \vect{z}.\head{\vect{x},\vect{z}}]$ where $\body{\vect{x},\vect{y}}$ and $\head{\vect{x},\vect{z}}$ are non-empty conjunctions of atoms on variables, respectively called the \emph{body} and the \emph{head} of the rule, also denoted by $\body{\ensuremath{\sigma}}$ and $\head{\ensuremath{\sigma}}$, and $\vect{x}, \vect{y}$ and $\vect{z}$ are pairwise disjoint tuples of variables. The variables of $\vect z$ are called \emph{existential variables}. The variables of $\vect x$ form the \emph{frontier} of $\ensuremath{\sigma}$, which is also denoted by $\fr{\ensuremath{\sigma}}$. For brevity, we will omit universal quantifiers in the examples. A \emph{knowledge base} (KB) is of the form $\ensuremath{\mathcal{K}} = \ensuremath{(\instance,\ruleset)}$, where $\ensuremath{I}$ is an instance and $\ensuremath{\Sigma}$ is a finite set of existential rules. A rule $\ensuremath{\sigma} = \body{\ensuremath{\sigma}} \rightarrow \head{\ensuremath{\sigma}}$ is \emph{applicable} to an instance $\ensuremath{I}$ if there is a homomorphism $\pi$ from $ \body{\ensuremath{\sigma}} $ to $\ensuremath{I}$. The pair $(\ensuremath{\sigma}, \pi)$ is called a \emph{trigger} for $\ensuremath{I}$. The result of the application of $\ensuremath{\sigma}$ according to $\pi$ on $\ensuremath{I}$ is the instance $\ensuremath{I}' = \ensuremath{I} \cup \ensuremath{\pi^s}(\head{\ensuremath{\sigma}})$, where $\ensuremath{\pi^s}$ (here $s$ stands for \emph{safe}) extends $\pi$ by assigning a distinct fresh variable (also called a \emph{null}) to each existential variable. We also say that $\ensuremath{I}'$ is obtained by \emph{firing} the trigger $(\ensuremath{\sigma}, \pi)$ on $\ensuremath{I}$. By $\pi_{\mid\fr{\ensuremath{\sigma}}}$ we denote the restriction of $\pi$ to the domain $\fr{\ensuremath{\sigma}}$. \sloppy \begin{definition}[Derivation] A \emph{$\ensuremath{\Sigma}$-derivation} (or simply \emph{derivation} when $\ensuremath{\Sigma}$ is clear from the context) from an instance $\ensuremath{I} = I_0$ to an instance $I_n$ is a sequence $I_0, (\ensuremath{\sigma}_1,\pi_1), I_1 \ldots, I_{n-1}, (\ensuremath{\sigma}_n,\pi_n), I_n$, such that for all $1 \leq i \leq n$: $\ensuremath{\sigma}_i \in \ensuremath{\Sigma}$, $(\ensuremath{\sigma}_i,\pi_i)$ is a trigger for $I_{i-1}$, $I_i$ is obtained by firing $(\ensuremath{\sigma}_i,\pi_i)$ on $I_{i-1}$, and $I_i \neq I_{i-1}$. We may also denote this derivation by the associated sequence of instances $(I_0, \ldots, I_n)$ when the triggers are not needed. The notion of derivation can be naturally extended to an \emph{infinite} sequence. \end{definition} \fussy We briefly introduce below the main chase variants and refer to \cite{phd/Onet12} for a detailed presentation. The \emph{semi-oblivious} chase prevents several applications of the same rule through the same mapping of its frontier. Given a derivation from $I_0$ to $I_{i}$, a trigger $(\ensuremath{\sigma},\pi)$ for $I_i$ is said to be \emph{active according to the semi-oblivious criterion}, if there is no trigger $(\ensuremath{\sigma}_j,\pi_j)$ in the derivation with $\ensuremath{\sigma} = \ensuremath{\sigma}_j$ and $\pi_{\mid{\fr{\ensuremath{\sigma}}}} = \pi_{j_\mid{\fr{\ensuremath{\sigma}_j}}}$. The \emph{restricted} chase performs a rule application only if the added set of atoms is not redundant with respect to the current instance. Given a derivation from $I_0$ to $I_{i}$, a trigger $(\ensuremath{\sigma},\pi)$ for $I_i$ is said to be \emph{active according to the restricted criterion} if $\pi$ cannot be extended to a homomorphism from $(\body{\ensuremath{\sigma}}\cup\head{\ensuremath{\sigma}})$ to $\ensuremath{I}_{i}$ (equivalently, $ \pi^s(\head{\ensuremath{\sigma}})$ does not fold onto $\ensuremath{I}_{i}$). A \emph{semi-oblivious (resp. restricted) chase sequence} of $\ensuremath{I}$ with $\ensuremath{\Sigma}$ is a possibly infinite $\ensuremath{\Sigma}$-derivation from $\ensuremath{I}$ such that each trigger $(\ensuremath{\sigma}_i,\pi_i)$ in the derivation is active according to the semi-oblivious (resp. restricted) criterion. Furthermore, a (possibly infinite) chase sequence is required to be \emph{fair}, which means that a possible rule application is not indefinitely delayed. Formally, if some $I_i$ in the derivation admits an active trigger $(\ensuremath{\sigma},\pi)$, then there is $j > i$ such that, either $I_j$ is obtained by firing $(\ensuremath{\sigma},\pi)$ on $I_{j-1}$, or $(\ensuremath{\sigma},\pi)$ is not an active trigger anymore on $I_j$. A \emph{terminating} chase sequence is a finite fair sequence. In its original definition {\cite{DBLP:conf/pods/DeutschNR08}, the \emph{core} chase proceeds in a breadth-first manner, and, at each step, first fires in parallel all active triggers according to the restricted chase criterion, then computes the core of the result. Alternatively, to bring the definition of the core chase closer to the above definitions of the semi-oblivious and restricted chases,} one can define a \emph{core chase sequence} as a possibly infinite sequence $I_0, (\ensuremath{\sigma}_1,\pi_1), I_1, \ldots$, alternating instances and triggers, such that each instance $I_i$ is obtained from $I_{i-1}$ by first firing the active trigger $(\ensuremath{\sigma}_i, \pi_i)$ according to the restricted criterion, then computing the core of the result. An instance admits a terminating core chase sequence in that sense if and only if the core chase as originally defined terminates on that instance. For the three chase variants, fair chase sequences compute a (possibly infinite) \emph{universal model} of the KB, but only the core chase stops if and only if the KB has a \emph{finite} universal model. \medskip It is well-known that, for the semi-oblivious and the core chase, if there is a terminating chase sequence from an instance $I$ then all fair sequences from $I$ are terminating. This is not the case for the restricted chase, since the order in which rules are applied has an impact on termination, as illustrated by Example \ref{ex-intro}. \begin{example}\label{ex-intro} Let $\ensuremath{\Sigma} = \{\ensuremath{\sigma}_1, \ensuremath{\sigma}_2\}$, with $\ensuremath{\sigma}_1 = p(x,y) \rightarrow \exists z ~ p(y,z)$ and $\ensuremath{\sigma}_2 = p(x,y) \rightarrow p(y,y)$. Let $\ensuremath{I} = p(a,b)$. The KB $(\ensuremath{I}, \ensuremath{\Sigma})$ has a finite universal model, for example, $I^* = \{p(a,b), p(b,b)\}$. The semi-oblivious chase does not terminate on $\ensuremath{I}$ as $\ensuremath{\sigma}_1$ is applied indefinitely, while the core chase terminates after one breadth-first step and returns $I^*$. The restricted chase has a terminating sequence, for example, $(\ensuremath{\sigma}_2, \{x \mapsto a, y \mapsto b\})$, which yields $I^*$ as well, but it also has infinite fair sequences, for example, the breadth-first sequence that applies $\ensuremath{\sigma}_1$ before $\ensuremath{\sigma}_2$ at each step. \end{example} \pagebreak We study the following problems for the semi-oblivious, restricted and core chase variants: \begin{itemize} \item \emph{(All instance) all sequence termination:} Given a set of rules $\ensuremath{\Sigma}$, is it true that, for any instance, all fair sequences are terminating? \item \emph{(All instance) one sequence termination:} Given a set of rules $\ensuremath{\Sigma}$, is it true that, for any instance, there is a terminating sequence? \end{itemize} Note that, according to the terminology of \cite{DBLP:journals/fuin/GrahneO18}, these problems can be recast as deciding whether, for a chase variant, a given set of rules belongs to the class CT$_{\forall\forall}$ or CT$_{\forall\exists}$, respectively. \medskip An existential rule is called \emph{linear} if its body and its head are both composed of a single atom (e.g., \cite{DBLP:journals/ws/CaliGL12}). Linear rules generalize \emph{inclusion dependencies} \cite{DBLP:journals/tods/Fagin81} by allowing several occurrences of the same variable in an atom. They also generalize positive inclusions in the description logic DL-Lite$_\mathcal R$ (the formal basis of the web ontological language OWL2 QL) \cite{DBLP:journals/jar/CalvaneseGLLR07}, which can be seen as inclusion dependencies restricted to unary and binary predicates. Note that the restriction of existential rules to rules with a single head is often made in the literature, considering that any existential rule with a complex head can be decomposed into several rules with a single head, by introducing a fresh predicate for each rule. However, while this translation preserves the termination of the semi-oblivious chase, it is not the case for the restricted and the core chases. Hence, considering linear rules with a complex head would require to extend the techniques developed in this paper. \medskip To simplify the presentation, we assume in the following that each rule frontier is of size at least one. This assumption is made without loss of generality. \footnote{For instance, it can always be ensured by adding a position to all predicates, which is filled by the same fresh constant in the initial instance, and by a new frontier variable in each rule.} \medskip We first point out that the termination problem on linear rules can be recast by considering solely instances that contain a single atom (as already remarked in several contexts). \begin{propositionrep} \label{prop-atomic-instance} Let $\ensuremath{\Sigma}$ be a linear set of rules. The semi-oblivious (resp. restricted, core) chase terminates on all instances if and only if it terminates on all singleton instances. \end{propositionrep} \begin{proof} Obviously, the fact that a chase variant does not halt on an atomic instance implies the fact that it does not terminate on all instances. On the other direction, we can easily see that if the chase does not halt on an instance then it will not halt on one of its atoms. For a chase variant that does not terminate there exists an infinite derivation whose associated chase graph is also infinite. As the arity of the nodes in the chase graph is bounded by the size of the ruleset, the chase graph must contains an infinite path starting from a node of the initial instance. Because the chase graph for linear rules forms a tree it follows that this infinite path is created by a single atom of the initial instance. \end{proof} We will furthermore rely on the following notion of the type of an atom. \begin{definition}[Type of an atom] \label{definition-type} The \emph{type of an atom} $\alpha = r(t_1,\ldots, t_n)$, denoted by $\type{\alpha}$, is the pair $(r,\mathcal{P})$ where $\mathcal{P}$ is the partition of $\{1,\ldots,n\}$ induced by term equality (i.e., $i$ and $j$ are in the same class of $\mathcal{P}$ iff $\ensuremath{t}_i = \ensuremath{t}_j$). \end{definition} Note that there are finitely (more specifically, exponentially) many types for a given vocabulary. If two atoms $\alpha$ and $\alpha'$ have the same type, then there is a \emph{natural mapping} from $\alpha$ to $\alpha'$, denoted by $\varphi_{\alpha\rightarrow \alpha'}$, and defined as follows: it is a bijective mapping from $\terms{\alpha}$ to $\terms{\alpha'}$, that maps the $i$-th term of $\alpha$ to the $i$-th term of $\alpha'$. Note that $\varphi_{\alpha\rightarrow \alpha'}$ may not be an isomorphism, as constants from $\alpha$ may not be mapped to themselves. However, if $(\ensuremath{\sigma},\pi)$ is a trigger for $\{\alpha\}$, then $(\ensuremath{\sigma},\varphi_{\alpha\rightarrow \alpha'}\circ\pi)$ is a trigger for $\{\alpha'\}$, as there are no constants in the considered rules. Together with Proposition \ref{prop-atomic-instance}, this implies that one can check all instance all sequence termination by checking all sequence termination on a finite set of instances, called \emph{canonical instances}: for each type, there is exactly one canonical instance that has this type. We will consider different kinds of tree structures, which have in common to be \emph{trees of bags}: these are rooted trees, whose nodes, called \emph{bags}, are labeled by an atom.\footnote{Furthermore the trees we will consider are decomposition trees of the associated set of atoms. That is why we use the classical term of \emph{bag} to denote a node.} We define the following notations for any node $\ensuremath{B}$ of a tree of bags $\ensuremath{\mathcal{T}}$: \begin{itemize} \item $\atoms{\ensuremath{B}}$ is the label of $\ensuremath{B}$; \item $\terms{\ensuremath{B}} = \terms{\atoms{\ensuremath{B}}}$ is the set of terms of $B$; \item $\terms{\ensuremath{B}}$ is divided into two sets of terms, those \emph{generated} in $\ensuremath{B}$, denoted by $\generated{\ensuremath{B}}$, and those shared with its parent, denoted by $\shared{\ensuremath{B}}$; precisely, $\terms{\ensuremath{B}} = \shared{\ensuremath{B}} \cup \generated{\ensuremath{B}}$, $\shared{\ensuremath{B}} \cap \generated{\ensuremath{B}} = \emptyset$, and if $\ensuremath{B}$ is the root of $\ensuremath{\mathcal{T}}$, then $\generated{\ensuremath{B}} = \terms{\ensuremath{B}}$ (hence $\shared{\ensuremath{B}} = \emptyset$), otherwise $\ensuremath{B}$ has a parent $\ensuremath{B}_p$ and $\generated{\ensuremath{B}} = \terms{\ensuremath{B}} \setminus \terms{\ensuremath{B}_p}$ (hence, $\shared{\ensuremath{B}} = \terms{\ensuremath{B}_p} \cap \terms{\ensuremath{B}}$). \end{itemize} We denote by $\treeatoms{\ensuremath{\mathcal{T}}}$ the set of atoms that label the bags in $\ensuremath{\mathcal{T}}$. Finally, we recall some classical mathematical notions. A \emph{subsequence} $S'$ of a sequence $S$ is a sequence that can be obtained from $S$ by deleting some (or no) elements without changing the order of the remaining elements. The \emph{arity} of a tree is the maximal number of children for a node. A \emph{prefix} $T'$ of a tree $T$ is a tree that can be obtained from $T$ by repeatedly deleting some (or no) leaves of $T$. \section{Derivation Trees} A classical tool to reason about the chase is the so-called \emph{chase graph} (see e.g., \cite{DBLP:journals/ws/CaliGL12}), which is the directed graph consisting of all atoms that appear in the considered derivation, and with an arrow from a node $n_1$ to a node $n_2$ iff $n_2$ is created by a rule application on $n_1$ and possibly other atoms. \footnote{Note that the chase graph in \cite{DBLP:conf/pods/DeutschNR08} is a different notion.} In the specific case of KBs of the form $(\{\alpha\}, \ensuremath{\Sigma})$, where $\alpha$ is an atom and $\ensuremath{\Sigma}$ is a set of linear rules, the chase graph is a tree. We recall below its definition in this specific case, in order to emphasize its differences with another tree, called \emph{derivation tree}, on which we will actually rely. \begin{definition}[Chase Graph for Linear Rules] \label{definition-chase-graph} Let $\ensuremath{I}$ be a singleton instance, $\ensuremath{\Sigma}$ be a set of linear rules and $\ensuremath{I} = I_0, (\ensuremath{\sigma}_1,\pi_1), I_1 \ldots, I_{n-1}, (\ensuremath{\sigma}_n,\pi_n), I_n$ be a semi-oblivious $\ensuremath{\Sigma}$-derivation from $\ensuremath{I}$. The \emph{chase graph} (also called \emph{chase tree}) assigned to $S$ is a tree of bags built as follows: \begin{itemize} \item the set of bags is in bijection with $\ensuremath{I}_n$ via the labeling function $\atoms{}$; \item the set of edges is in bijection with the set of triggers in $S$ and is built as follows: for each trigger $(\ensuremath{\sigma}_i,\pi_i)$ in $S$, there is an edge $(\ensuremath{B},\ensuremath{B}')$ with $\atoms{\ensuremath{B}} = {\pi_i(\body{\ensuremath{\sigma}_i})}$ and $\atoms{\ensuremath{B}'} = \pi_i^s(\head{\ensuremath{\sigma}_i})$. \end{itemize} \end{definition} \begin{example} \label{example-chase-graph-not-enough} Let $\ensuremath{I} = q(a)$ and $\ensuremath{\Sigma}=\{\ensuremath{\sigma}_1,\ensuremath{\sigma}_2\}$ where $\ensuremath{\sigma}_1 = q(x) \rightarrow \exists y \exists z \exists t ~p(x,y,z,t)$ and $\ensuremath{\sigma}_2 = p(x,y,z,t) \rightarrow p(x,z,t,y)$. Let $S = \ensuremath{I},(\ensuremath{\sigma}_1,\pi_1),\ensuremath{I}_1,(\ensuremath{\sigma}_2,\pi_2),\ensuremath{I}_3,(\ensuremath{\sigma}_2,\pi_3),\ensuremath{I}_3$ with $\pi_1 = \{ x \mapsto a\}$, $\pi_1^s(\head{\ensuremath{\sigma}_1}) = p(a,y_0,z_0,t_0)$, $\pi_2 = \{ x \mapsto a, y \mapsto y_0, z \mapsto z_0, t \mapsto t_0\}$ and ${\pi_3 = \{ x \mapsto a, y \mapsto z_0,}$ $ z \mapsto t_0, t \mapsto y_0\}$. The chase graph associated with $S$ is a path of four nodes as represented in Figure~\ref{figure-chase-graph-not-enough}. \end{example} \begin{figure}[t] \begin{center} \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1,thick,scale=0.6, every node/.style={scale=0.7}] \draw (126, 38) circle [x radius= 35, y radius= 20] ; \draw (126.25, 104.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126.25, 175.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126.25, 246.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126,58) -- (126,80) ; \draw (126,129) -- (126,151) ; \draw (126,200) -- (126,222) ; \draw (366, 37) circle [x radius= 35, y radius= 20] ; \draw (366.25, 103.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (293.25, 176.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (434.25, 176.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (366,57) -- (366.25,79) ; \draw (366.25,128) -- (293.25,152) ; \draw (366.25,128) -- (434.25,152) ; \draw (126,37) node {$q( a)$}; \draw (124,105) node {$p( a,y_{0} ,z_{0} ,t_{0})$}; \draw (125,176) node {$p( a,z_{0} ,t_{0} ,y_{0})$}; \draw (126,247) node {$p( a,t_{0} ,y_{0} ,z_{0})$}; \draw (76,38) node {$B_{0}$}; \draw (56,105) node {$B_{1}$}; \draw (54,175) node {$B_{2}$}; \draw (57,250) node {$B_{3}$}; \draw (117,300) node [align=left] {Chase Graph}; \draw (367,36) node {$q( a)$}; \draw (365,104) node {$p( a,y_{0} ,z_{0} ,t_{0})$}; \draw (292,177) node {$p( a,z_{0} ,t_{0} ,y_{0})$}; \draw (433,177) node {$p( a,t_{0} ,y_{0} ,z_{0})$}; \draw (317,37) node {$B_{0}$}; \draw (297,104) node {$B_{1}$}; \draw (221,176) node {$B_{2}$}; \draw (505,176) node {$B_{3}$}; \draw (364,299) node [align=left] {Derivation Tree}; \end{tikzpicture} \end{center} \caption{Chase Graph and Derivation Tree of Example \ref{example-chase-graph-not-enough}} \label{figure-chase-graph-not-enough} \end{figure} \medskip To check termination of a chase variant on a given KB $(\{\alpha\}, \ensuremath{\Sigma})$, the general idea is to build a tree of bags associated with the chase on this KB in such a way that the occurrence of some forbidden pattern indicates that a path of unbounded length can be developed, hence the chase does not terminate. The forbidden pattern is composed of two distinct nodes such that one is an ancestor of the other and, intuitively speaking, these nodes ``can be extended in similar ways'', which leads to an arbitrarily long path that repeats the pattern. Two atoms with the same type admit the same rule triggers, however, within a derivation, the same rule applications cannot necessarily be performed on both of them because of the presence of other atoms (this is true already for datalog rules, since the same atom is never produced twice). Hence, on the one hand we will specialize the notion of type, into that of a \emph{sharing type}, and, on the other hand, adopt another tree structure, called a \emph{derivation tree}, in which two nodes with the same sharing type have the required similar behavior. \begin{definition}[Sharing type and Twins] \label{definition-sharing-type} Given a tree of bags, the \emph{sharing type} of a bag $\ensuremath{B}$ is a pair $ (\type{\atoms{\ensuremath{B}}},P)$ where $P$ is the set of positions in $\atoms{\ensuremath{B}}$ in which a term of $\shared{\ensuremath{B}}$ occurs. We denote the fact that two bags $\ensuremath{B}$ and $\ensuremath{B}'$ have the same sharing type by $\ensuremath{B} \ensuremath{\equiv_{st}} \ensuremath{B}'$. Furthermore, we say that two bags $\ensuremath{B}$ and $\ensuremath{B}'$ are \emph{twins} if they have the same sharing type, the same parent $\ensuremath{B}_p$ and if the natural mapping $\varphi_{\atoms{B}\rightarrow\atoms{B'}}$ is the identity on the terms of $\atoms{\ensuremath{B}_p}$. \end{definition} We can now specify the forbidden pattern that we will consider: it is a pair of two distinct nodes with the same sharing type, such that one is an ancestor of the other. \begin{definition}[Unbounded-Path Witness] An \emph{unbounded-path witness} (UPW) in a derivation tree is a pair of distinct bags $(\ensuremath{B},\ensuremath{B}')$ such that $\ensuremath{B}$ and $\ensuremath{B}'$ have the same sharing type and $\ensuremath{B}$ is an ancestor of $\ensuremath{B}'$. \end{definition} As explained below on Example \ref{example-chase-graph-not-enough}, the chase graph is not the appropriate tool to use this forbidden pattern as a witness of chase non-termination. \medskip \noindent \emph{Example \ref{example-chase-graph-not-enough} (cont'd).} $B_1$, $B_2$ and $B_3$ have the same classical type,\\ $t = (p, \{\{1\}, \{2\},\{3\},\{4\}\})$. The sharing type of $B_1$ is $(t,\{1\})$, while $B_2$ and $B_3$ have the same sharing type $(t,\{1,2,3,4\})$. $B_2$ and $B_3$ fulfill the condition of the forbidden pattern, however it is easily checked that any derivation that extends this derivation is finite. \medskip Derivation trees were introduced as a tool to define the \emph{greedy bounded treewidth set (gbts)} family of existential rules \cite{DBLP:conf/ijcai/BagetMRT11,DBLP:phd/hal/Thomazo13}. A derivation tree is associated with a derivation, however it does not have the same structure as the chase graph. The fundamental reason is that, when a rule $\ensuremath{\sigma}$ is applied to an atom $\alpha$ via a homomorphism $\pi$, the newly created bag is not necessarily attached in the tree as a child of the bag labeled by $\alpha$. Instead, it is attached as a child of the \emph{highest} bag in the tree labeled by an atom that contains $\pi(\fr{\ensuremath{\sigma}})$, the image by $\pi$ of the frontier of $\ensuremath{\sigma}$ (note that $\pi(\fr{\ensuremath{\sigma}})$ remains the set of terms shared between the new bag and its parent). In the following definition, a derivation tree is not associated with \emph{any} derivation, but with a semi-oblivious derivation, which has the advantage of yielding trees with bounded arity (Proposition \ref{prop-bounded-arity} in the Appendix). This is appropriate to study the termination of the semi-oblivious chase, and later the restricted chase, as a restricted chase sequence is a specific semi-oblivious chase sequence. \begin{definition}[Derivation Tree] Let $\ensuremath{I} = \{\alpha\}$ be a singleton instance, $\ensuremath{\Sigma}$ be a set of linear rules, and $\ensuremath{S} = \ensuremath{I}_0,(\ensuremath{\sigma}_1,\pi_1),\ensuremath{I}_1, \ldots, (\ensuremath{\sigma}_n,\pi_n),\ensuremath{I}_n$ be a semi-oblivious $\ensuremath{\Sigma}$-derivation. The \emph{derivation tree} assigned to $\ensuremath{S}$ is a tree of bags $\ensuremath{\mathcal{T}}$ built as follows: \begin{itemize} \item the root of the tree, $\ensuremath{B}_0$, is such that $\atoms{\ensuremath{B}_0} = \alpha$; \item for each trigger $(\ensuremath{\sigma}_i,\pi_i)$, $0 < i \leq n$, let $\ensuremath{B}_i $ be the bag such that $\atoms{\ensuremath{B}_i} = \ensuremath{\pi^s}_{i}(\head{\ensuremath{\sigma}_{i}})$. Let $j$ be smallest integer such that $\pi_{i}(\fr{\ensuremath{\sigma}_{i}}) \subseteq \terms{\ensuremath{B}_j}$: $\ensuremath{B}_i$ is added as a child to $\ensuremath{B}_j$. \end{itemize} By extension, we say that a derivation tree $ \ensuremath{\mathcal{T}}$ is \emph{associated with $\alpha$ and $\ensuremath{\Sigma}$} if there exists a semi-oblivious $\ensuremath{\Sigma}$-derivation $\ensuremath{S}$ from $\alpha$ such that $\ensuremath{\mathcal{T}}$ is assigned to $\ensuremath{S}$. \end{definition} \noindent \emph{Example \ref{example-chase-graph-not-enough} (cont'd).} The derivation tree associated with $S$ is represented in Figure \ref{figure-chase-graph-not-enough}. Bags have the same sharing types in the chase tree and in the derivation tree. However, we can see here that they are not linked in the same way: $\ensuremath{B}_3$ was a child of $\ensuremath{B}_2$ in the chase tree, it becomes a child of $\ensuremath{B}_1$ in the derivation tree. Hence, the forbidden pattern cannot be found anymore in the tree. \medskip Note that every non-root bag $\ensuremath{B}$ shares a least one term with its parent (since the rule frontiers are not empty), furthermore this term is generated in its parent (otherwise $\ensuremath{B}$ would have been added at a higher level in the tree). \begin{toappendix} \begin{proposition}\label{prop-bounded-arity} The arity of a derivation tree is bounded. \end{proposition} \begin{proof} We first point out that a bag has a bounded number of twin children. Since we consider semi-oblivious derivations, a bag $\ensuremath{B}_p$ cannot have two twin children $\ensuremath{B}_{c_1}$ and $\ensuremath{B}_{c_2}$, created by applications of the same rule $\ensuremath{\sigma}$. Indeed, although these rule applications may map $\body{\ensuremath{\sigma}}$ to distinct atoms, the associated homomorphisms, say $\pi_1$ and $\pi_2$, would have the same restriction to the rule frontier, i.e., $\pi_1{_{\mid\fr{\ensuremath{\sigma}}}} = \pi_2{_{\mid\fr{\ensuremath{\sigma}}}}$. Hence, all twin children of a bag come from applications of distinct rules. It follows that the arity of a node is bounded by the number of atom types $\times$ the cardinal of the ruleset. \end{proof} \end{toappendix} \section{Semi-Oblivious and Restricted Chase Termination} We now use derivation trees and sharing types to characterize the termination of the semi-oblivous chase. The fundamental property of derivation trees that we exploit is that, when two nodes have the same sharing type, the considered (semi-oblivious) derivation can always be extended so that these nodes have the same number of children, and in turn these children have the same sharing type. We first specify the notion of \emph{bag copy}. \begin{definition}[Bag Copy] Let $\ensuremath{\mathcal{T}},\ensuremath{\mathcal{T}}'$ be two (possibly equal) trees of bags. Let $\ensuremath{B}$ be a bag of $\ensuremath{\mathcal{T}}$ and $\ensuremath{B}'$ be a bag of $\ensuremath{\mathcal{T}}'$ such that $\ensuremath{B} \ensuremath{\equiv_{st}} \ensuremath{B}'$. Let $\ensuremath{B}_c$ be a child of $\ensuremath{B}$. A \emph{copy} of $\ensuremath{B}_c$ \emph{under} $\ensuremath{B}'$ is a bag $\ensuremath{B}'_c$ such that $\atoms{\ensuremath{B}'_c} = \varphi^s(\atoms{\ensuremath{B}_c})$, where $\varphi^s$ is a substitution of $\terms{\ensuremath{B}_c}$ defined as follows: \begin{itemize} \item if $\ensuremath{t} \in \shared{\ensuremath{B}_c}$, then $\varphi^s(\ensuremath{t}) = \varphi_{\atoms{\ensuremath{B}} \rightarrow \atoms{\ensuremath{B}'}}(\ensuremath{t})$, where $\varphi_{\atoms{\ensuremath{B}} \rightarrow \atoms{\ensuremath{B}'}}$ is the natural mapping from $\atoms{\ensuremath{B}}$ to $\atoms{\ensuremath{B}'}$; \item if $\ensuremath{t} \in \generated{\ensuremath{B}_c}$, then $\varphi^s(\ensuremath{t})$ is a fresh new {variable}. \end{itemize} \end{definition} Let $\ensuremath{\mathcal{T}}_e$ be obtained from a derivation tree $\ensuremath{\mathcal{T}}$ by adding a copy of a bag: strictly speaking, $\ensuremath{\mathcal{T}}_e$ may not be a derivation tree in the sense that there may be no derivation to which it can be assigned (intuitively, some rule applications that would allow to produce the copy may be missing). Rather, there is some derivation tree of which $\ensuremath{\mathcal{T}}_e$ is a \emph{prefix} (intuitively, one can add bags to $\ensuremath{\mathcal{T}}_e$ to obtain a derivation tree). That is why the following proposition considers more generally prefixes of derivation trees. \begin{propositionrep} \label{proposition-sharing-type-children-derivation-tree} Let $\ensuremath{\mathcal{T}}$ be a prefix of a derivation tree, $\ensuremath{B}$ and $\ensuremath{B}'$ be two bags of $\ensuremath{\mathcal{T}}$ such that $\ensuremath{B} \ensuremath{\equiv_{st}} \ensuremath{B}'$, and $\ensuremath{B}_c$ be a child of $\ensuremath{B}$. Then: \emph{(a)} the tree obtained from $\ensuremath{\mathcal{T}}$ by adding the copy $\ensuremath{B}'_c$ of $\ensuremath{B}_c$ under $\ensuremath{B}'$ is a prefix of a derivation tree, and \emph{(b)} it holds that $\ensuremath{B}_c \ensuremath{\equiv_{st}} \ensuremath{B}'_c$. \end{propositionrep} \begin{proof} Let $\ensuremath{B}$ and $\ensuremath{B}'$ be two atoms of $\ensuremath{\mathcal{T}}$ having the same sharing type. Let $\ensuremath{B}_c$ be a child of $\ensuremath{B}$ created by a trigger $(\ensuremath{\sigma},\pi)$. By definition of derivation tree, $\pi$ maps the rule frontier $\fr{\ensuremath{\sigma}}$ to $\terms{\ensuremath{B}}$, without this being possible for the parent of $\ensuremath{B}$. Furthermore, we know that $\pi$ maps $\body{\ensuremath{\sigma}}$ to a (possibly strict) descendant of $\ensuremath{B}$. We assume that $\ensuremath{\mathcal{T}}$ does not already contain the image of $\head{\ensuremath{\sigma}}$ via $\pi$, otherwise the thesis trivially holds. Let $\ensuremath{S}$ be the derivation associated with $\ensuremath{\mathcal{T}}$ and $\alpha_0,\dots,\alpha_{k}$ be the path of the \emph{chase-graph} associated with $\ensuremath{S}$ such that $\alpha_0=\atoms{\ensuremath{B}}$ and $\alpha_{k}=\atoms{\ensuremath{B}_{c}}$, whose sequence of associated rule applications is $(\ensuremath{\sigma}_1,\pi_1),\dots, (\ensuremath{\sigma}_{k},\pi_{k})=(\ensuremath{\sigma},\pi)$. We define $\hat\pi_i^{\mathrm{safe}}(t)=\varphi_{\atoms{\ensuremath{B}}\rightarrow\atoms{\ensuremath{B}'}}\circ\pi_i(t)$ whenever $\pi_i(t)\in\terms{\ensuremath{B}}$ and otherwise $\hat\pi_i^{\mathrm{safe}}(t)$ to be a fresh new variable consistently used over the rule applications, that is, such that $\pi_i^{\mathrm{safe}}(t)=\pi_j^{\mathrm{safe}}(t)$ if and only if $\hat\pi_i^{\mathrm{safe}}(t)=\hat\pi_j^{\mathrm{safe}}(t)$. Then, for all $1\leq i \leq k$, we extend $\ensuremath{S}$ by adding a trigger $(\ensuremath{\sigma}_i,\hat\pi_i)$\footnote{$\hat\pi_i$ is the restriction of $\hat\pi_i^{\mathrm{safe}}$ to the variables of the body of $\ensuremath{\sigma}_i$.} whenever $\hat\pi_i^{\mathrm{safe}}(\head{\ensuremath{\sigma}_i})$ is not an atom already produced by $\ensuremath{S}$ thereby obtaining a new derivation $\ensuremath{S}'$. Let $\ensuremath{\mathcal{T}}'$ be an extension of $\ensuremath{\mathcal{T}}$ where a bag labeled with the atom $\hat\pi_i^{\mathrm{safe}}(\head{\ensuremath{\sigma}_i})$ is added for each new trigger in $\ensuremath{S}'$ and attached to the highest descendant of $\ensuremath{B}'$ whose set of terms contains $\hat\pi_i^{}(\fr{\ensuremath{\sigma}_i})$. Clearly, $\ensuremath{\mathcal{T}}'$ is a derivation tree associated with $\ensuremath{S}'$. We now show that $\ensuremath{\mathcal{T}}'$ contains a node $\ensuremath{B}_c'$ which is a copy of $\ensuremath{B}_c$ under $\ensuremath{B}'$. As $\ensuremath{B}$ is the parent of $\ensuremath{B}_c$, the image of $\fr{\ensuremath{\sigma}}$ via $\pi$ contains at least one term which is generated in $\ensuremath{B}$ (and in general only terms generated by the ancestors of $\ensuremath{B}$). Therefore, because $\ensuremath{B}$ and $\ensuremath{B}'$ have the same sharing type, the image of $\fr{\ensuremath{\sigma}}$ via $\varphi_{\atoms{\ensuremath{B}}\rightarrow \atoms{\ensuremath{B}'}}\circ\pi$ contains at least one term generated in $\ensuremath{B}'$ (and in general only terms generated by the ancestors of $\ensuremath{B}'$). So, $\ensuremath{B}'$ is the only possible parent of $\ensuremath{B}'_c$ in $\ensuremath{\mathcal{T}}'$. Moreover, it is easy to see that $\ensuremath{B}_c \ensuremath{\equiv_{st}} \ensuremath{B}'_c$. Let $\ensuremath{\mathcal{T}}''$ be the extension of $\ensuremath{\mathcal{T}}$ with $\ensuremath{B}_c'$ under $\ensuremath{B}'$. It can be easily verified that $\ensuremath{\mathcal{T}}''$ is a prefix of the derivation tree $\ensuremath{\mathcal{T}}'$, in the sense that it is a tree of bags which can be obtained by recursively removing some of the leaves of $\ensuremath{\mathcal{T}}'$, i.e., those corresponding to the triggers in $\ensuremath{S}'\setminus\ensuremath{S}$ which are different from $(\ensuremath{\sigma},\pi)$. \end{proof} The size of a derivation tree without UPW is bounded, since its arity is bounded (Proposition \ref{prop-bounded-arity} in the Appendix) and its depth is bounded by the number of sharing types. It remains to show that a derivation tree that contains a UPW can be extended to an arbitrarily large derivation tree. We recall that similar property would not hold for the chase tree, as witnessed by Example~\ref{example-chase-graph-not-enough}. \begin{propositionrep} \label{proposition-finiteness-derivation-tree} There exists an arbitrary large derivation tree associated with $\alpha$ and $\ensuremath{\Sigma}$ if and only if there exists a derivation tree associated with $\alpha$ and $\ensuremath{\Sigma}$ that contains an unbounded-path witness. \end{propositionrep} \begin{proof} If there is no derivation tree having an unbounded-path witness, then the depth of all derivation trees is upper bounded by the number of sharing types. As derivation trees are of bounded arity, all derivation trees must be of bounded size. If there is a derivation tree $\ensuremath{\mathcal{T}}$ having an unbounded-path witness $(\ensuremath{B},\ensuremath{B}')$, we show that there are arbitrary large derivation trees. We do so by contradiction. Let us assume that $(\ensuremath{B},\ensuremath{B}')$ is a UPW be two such bags such that $\ensuremath{B}'$ is of maximal depth among all such pairs and among all trees, which by hypothesis are of bounded size. Let $\ensuremath{B}_c$ be the child of $\ensuremath{B}$ that is on the shortest path from $\ensuremath{B}$ to $\ensuremath{B}'$ (possibly $\ensuremath{B}_c = \ensuremath{B}'$). By Proposition \ref{proposition-sharing-type-children-derivation-tree}, $\ensuremath{B}'$ has a child $\ensuremath{B}'_c$ that has the same sharing type as $\ensuremath{B}_c$. By Proposition \ref{proposition-sharing-type-children-derivation-tree}, $\ensuremath{B}'$ has a child $\ensuremath{B}'_c$ that has the same sharing type as $\ensuremath{B}_c$, either in the same tree, or in an extension of this tree, which is in contradiction with the fact that $\ensuremath{B}'$ was of maximal depth. Hence there are arbitrary large derivation trees. \end{proof} The previous proposition yields a characterization of the existence of an infinite semi-oblivious derivation. At this point, one may notice that an infinite semi-oblivious derivation is not necessarily fair. However, from this infinite derivation one can always build a fair derivation by inserting missing triggers. Obviously, this operation has no effect on the termination of the semi-oblivious chase. More precaution will be required for the restricted chase. One obtains an algorithm to decide termination of the semi-oblivious chase for a given set of rules: for each canonical instance, build a semi-oblivious derivation and the associated derivation tree by applying rules until a UPW is created (in which case the answer is no) or all possible rule applications have been performed; if no instance has returned a negative answer, the answer is yes. \begin{corollary} \label{corollary-semi-oblivious-finiteness-decidability} The all-sequence termination problem for the semi-oblivious chase on linear rules is decidable. \end{corollary} \fussy This algorithm can be modified to run in polynomial space (which is optimal \cite{DBLP:conf/pods/CalauttiGP15}), by guessing a canonical instance and a UPW of its derivation tree. \sloppy \begin{propositionrep} The all-sequence termination problem for the semi-oblivious chase on linear rules is in \textsc{PSpace}. \end{propositionrep} \begin{proof} Let $\ensuremath{\mathcal{T}}$ be a derivation tree of root the canonical instance $\{\alpha\}$ that contains a UPW $(\ensuremath{B},\ensuremath{B}')$, where the sharing type of both bags is $ST$. We show that there exists a semi-oblivious derivation of length at most exponential whose derivation tree has root $\{\alpha\}$ and that contains a UPW $(\ensuremath{B}_s,\ensuremath{B}'_s)$ where the sharing type of both bags is $ST$. First, by Proposition \ref{proposition-sharing-type-children-derivation-tree}, we conclude that it is not necessary to have twice the same sharing type on the path from the root to $\ensuremath{B}'$ in the derivation tree. It is thus enough to show that to generate a child $\ensuremath{B}_c$ from its parent $\ensuremath{B}_p$, a derivation of length at most exponential is necessary. Let us consider the chase graph of the derivation generating $\atoms{\ensuremath{B}_c}$ from $\atoms{\ensuremath{B}_p}$. This chase graph can be assumed w.l.o.g. to be a path. It there are no pairs of atoms having the same sharing type on this path, then the derivation is of length at most exponential. Otherwise, we show that we can build a shorter semi-oblivious derivation that generates $\atoms{\ensuremath{B}_c}$. Let us thus assume that there is $\ensuremath{B}$ and $\ensuremath{B}'$ such that both have the same sharing type, and the terms of $\ensuremath{B}_p$ that appear in $\ensuremath{B}$ appear in the same position in $\ensuremath{B}'$, and that $\ensuremath{B}'$ is on the path from $\ensuremath{B}$ to $\ensuremath{B}_c$ in the chase graph. A derivation similar to that applicable after $\ensuremath{B}'$ is actually applicable to $\ensuremath{B}$, by Proposition \ref{proposition-sharing-type-children-derivation-tree}. A copy of $\ensuremath{B}_c$ under $\ensuremath{B}_p$ is thus generated by this derivation, which proves our claim. We now describe the algorithm. We guess the canonical instance and the sharing type $ST$ of the UPW. We then check that there is a descendant (not necessarily a child) of that canonical instance that has sharing type $ST$. This can be done by guessing the shortest derivation creating a bag of sharing type $ST$. It is only necessary to remember the sharing type of the ``current'' bag, as we know that any bag created during a derivation is added as a descendant of the root. We then want to prove that a bag of sharing type $ST$ can have a (strict) descendant of sharing type $ST$. In contrast with the case of the root, a trigger applied below a bag $\ensuremath{B}$ does not necessarily create a bag that is as well below $\ensuremath{B}$ -- it could be added higher up in the tree. We thus have to remember the shared variables of $\ensuremath{B}$, and verify at each step that the shared variables of the currently considered bag are not a subset of them. This leads to a \textsc{PSpace} procedure. \end{proof} We now consider the restricted chase. To this aim, we call \emph{restricted derivation tree} associated with $\alpha$ and $\ensuremath{\Sigma}$ a derivation tree associated with a restricted $\ensuremath{\Sigma}$-derivation from $\alpha$. We first point out that Proposition \ref{proposition-sharing-type-children-derivation-tree} is not true anymore for a restricted derivation tree, as the order in which rules are applied matters. \begin{example} Consider a restricted tree that contains bags $B$ and $B'$ with the same sharing type, labeled by atoms $q(t,u)$ and $q(v,w)$ respectively, where the second term is generated. Consider the following rules (the same as in Example \ref{ex-intro}):\\ $\ensuremath{\sigma}_1: q(x,y) \rightarrow \exists z ~q(y,z)$\\ $\ensuremath{\sigma}_2: q(x,y) \rightarrow q(y,y)$\\ Assume $\ensuremath{B}$ has a child $\ensuremath{B}_c$ labeled by $q(u,z_0)$ obtained by an application of $\ensuremath{\sigma}_1$, and $\ensuremath{B}'$ has a child $\ensuremath{B}'_1$ labeled by $q(w,w)$ obtained by an application of $\ensuremath{\sigma}_2$. It is not possible to extend this tree by copying $\ensuremath{B}_c$ under $\ensuremath{B}'$. Indeed, the corresponding application of $\ensuremath{\sigma}_1$ does not comply with the restricted chase criterion: it would produce an atom of the form $q(w,z_1)$ that folds into $q(w,w)$. \end{example} We thus prove a weaker proposition by considering that $\ensuremath{B}'$ is a leaf in the restricted derivation tree. \begin{proposition} \label{proposition-sharing-type-restricted-derivation-tree} Let $\ensuremath{\mathcal{T}}$ be a prefix of a restricted derivation tree, $\ensuremath{B}$ and $\ensuremath{B}'$ be two bags of $\ensuremath{\mathcal{T}}$ such that $\ensuremath{B} \ensuremath{\equiv_{st}} \ensuremath{B}'$ and \emph{$\ensuremath{B}'$ is a leaf}. Let $\ensuremath{B}_c$ be a child of $\ensuremath{B}$. Then: \emph{(a)} the tree obtained from $\ensuremath{\mathcal{T}}$ by adding the copy $\ensuremath{B}'_c$ of $\ensuremath{B}_c$ under $\ensuremath{B}'$ is a prefix of a restricted derivation tree, and \emph{(b)} it holds that $\ensuremath{B}_c \ensuremath{\equiv_{st}} \ensuremath{B}'_c$. \end{proposition} \begin{proof} Let $S$ be the restricted derivation associated with $\ensuremath{\mathcal{T}}$. Let $S_c$ be the subsequence of $S$ that starts from $\ensuremath{B}$ and produces the strict descendants of $\ensuremath{B}$. Obviously, any rule application in $S_c$ is performed on a descendant of $\ensuremath{B}$, hence we do not care about rule applications that produce bags that are not descendants of $\ensuremath{B}$. We prove the property by induction on the length of $S_c$. If $S_c$ is empty, the property holds with $\ensuremath{\mathcal{T}}_e = \ensuremath{\mathcal{T}}$. Assume the property is true for $0 \leq |S_c| \leq k$. Let $|S_c| = k + 1$. By induction hypothesis, there is an extension $\ensuremath{\mathcal{T}}' $ of $\ensuremath{\mathcal{T}}$ such that the subtree of $\ensuremath{B}$ restricted to the first $k$ elements of $S_c$ is `quasi-isomorphic' to the subtree rooted in $\ensuremath{B}'$ (via a bijective substitution defined by the natural mappings between sharing types, say $\phi$) . Let $(\ensuremath{\sigma},\pi)$ be the last trigger of $S_c$, and assume it applies to a bag $\ensuremath{B}_d$. In $\ensuremath{\mathcal{T}}'$, there is a bag $\ensuremath{B}'_d = \phi(\ensuremath{B}_d)$. Hence, $\ensuremath{\sigma}$ can be applied to $\ensuremath{B}'_d$ with the homomorphism $\phi \circ \pi$. Any folding of the produced bag $\ensuremath{B}''$ to a bag in $\ensuremath{\mathcal{T}}'$ necessarily maps $\ensuremath{B}''$ to a bag in the subtree rooted in $\ensuremath{B}'_d$ (because $\ensuremath{B}'_d$ and $\ensuremath{B}''$ share a term generated in $\ensuremath{B}'_d$, that only occurs in the subtree rooted in $\ensuremath{B}'_d$ and remains invariant by the folding). Since $\ensuremath{B}_d$ and $\ensuremath{B}'_d$ have quasi-isomorphic subtrees, and $(\ensuremath{\sigma},\pi)$ satisfies the restricted chase criterion, so does $(\ensuremath{\sigma},\phi \circ \pi)$. Furthermore, the quasi-isomorphism $\phi$ preserves the sharing types. Hence, $\ensuremath{B}'_d$ is added exactly like the bag produced by $(\ensuremath{\sigma},\pi)$. We conclude that the property holds true at rank $k+1$. \end{proof} The previous proposition allows us to obtain a variant of Proposition \ref{proposition-finiteness-derivation-tree} adapted to the restricted chase: \begin{propositionrep} \label{proposition-finiteness-restricted-derivation-tree} There exists an arbitrary large restricted derivation tree associated with $\alpha$ and $\ensuremath{\Sigma}$ if and only if there exists a restricted derivation tree associated with $\alpha$ and $\ensuremath{\Sigma}$ that contains an unbounded-path witness. \end{propositionrep} \begin{proof} If there is no restricted derivation tree with a UPW, then the size of any restricted derivation tree is bounded since a restricted derivation tree is a derivation tree. We prove the other direction by contradiction. Assume that the size of restricted derivation trees is bounded whereas the forbidden pattern occurs in some of them. Consider a restricted chase sequence $S$ with associated restricted derivation tree $\ensuremath{\mathcal{T}}$ that contains a UPW $(\ensuremath{B},\ensuremath{B}')$ of maximal depth among all such pairs and all trees, and such that $\ensuremath{B}'$ is a leaf (we can do the latter assumption since the prefix of any restricted derivation is a restricted derivation). Let $\ensuremath{B}_c$ be the child of $\ensuremath{B}$ that is on the shortest path from $\ensuremath{B}$ to $\ensuremath{B}'$ (possibly $\ensuremath{B}_c = \ensuremath{B}'$). By Proposition \ref{proposition-sharing-type-restricted-derivation-tree}, there is a restricted derivation tree that extends $\ensuremath{\mathcal{T}}$ such that $\ensuremath{B}'$ has a child $\ensuremath{B}'_c$ of the same sharing type as $\ensuremath{B}_c$, hence $(\ensuremath{B}_c, \ensuremath{B}'_c)$ is a UPW of depth strictly greater than $(\ensuremath{B},\ensuremath{B}')$, which contradicts the hypothesis. \end{proof} It is less obvious than in the case of the semi-oblivious chase that the existence of an infinite derivation entails the existence of an infinite \emph{fair} derivation. However, this property still holds: \begin{propositionrep} For linear rules, every (infinite) non-terminating restricted derivation is a subsequence of a fair restricted derivation. \end{propositionrep} \begin{proof} Let $\ensuremath{S}$ be a non-terminating restricted derivation. In particular, there exists a least one infinite branch in the associated derivation tree. Let us consider the following derivation: when the node $\ensuremath{B}_k$ of depth $k$ on this branch has been generated, complete the corresponding subsequence by trying to apply (i.e., while respecting the restricted criterion) all currently applicable triggers that add a bag a depth at most $k-1$. These additional rule applications cannot prevent the creation of any bag that is below $\ensuremath{B}_k$ in the derivation tree. Indeed, let $\alpha_c$ be an atom possibly created by a rule application, whose bag would be attached as a child of a bag $\ensuremath{B}$; since $\alpha_c$ shares a variable with $\atoms{\ensuremath{B}}$ that is generated in $B$, which thus only occurs in the subtree of $B$, the only possibility for $\alpha_c$ to fold into the current instance, is to be mapped to an atom in the subtree of $\ensuremath{B}$. By construction, any possible rule application will be performed or inhibited at some point, which implies that the derivation that we build in this fashion is fair. \end{proof} Similarly to Proposition \ref{proposition-finiteness-derivation-tree} for the semi-oblivious chase, Proposition \ref{proposition-finiteness-restricted-derivation-tree} provides an algorithm to decide termination of the restricted chase. The difference is that it is not sufficient to build a single derivation for a given canonical instance; instead, all possible restricted derivations from this instance have to be built (note that the associated restricted derivation trees are finite for the same reasons as before, and there is obviously a finite number of them). Hence, we obtain: \begin{corollary} \label{corollary-restricted-finiteness-decidability} The all-sequence termination problem for the restricted chase on linear rules is decidable. \end{corollary} A rough analysis of the proposed algorithm provides a \textsc{co-N2ExpTime} upper-bound for the complexity of the problem, by guessing a derivation that is of length at most double exponential, and checking whether there is a UPW in the corresponding derivation tree. \begin{figure}[t] \begin{center} \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1,thick,scale=0.6, every node/.style={scale=0.7}] \draw (426, 38) circle [x radius= 55, y radius= 25] ; \draw (426,38) node {$p(x,y)$}; \draw (376,67) node {$1$}; \draw (426,63) -- (346,85) ; \draw (346, 110) circle [x radius= 55, y radius= 25] ; \draw (346,110) node {$q(y)$}; \draw (476,67) node {$3$}; \draw (426,63) -- (506,85) ; \draw (506, 110) circle [x radius= 55, y radius= 25] ; \draw (506,110) node {$r(y,x)$}; \draw (336,148) node {$2$}; \draw (346,135) -- (346,157) ; \draw (346, 182) circle [x radius= 55, y radius= 25] ; \draw (346,182) node {$r(y,z_0)$}; \draw (336,220) node {$4$}; \draw (346,207) -- (346,229) ; \draw (346, 254) circle [x radius= 55, y radius= 25] ; \draw (346,254) node {$p(z_0,z_1)$}; \draw (288,282) node {$5$}; \draw [dotted] (346,279) -- (266,299) ; \draw (256,320) node {$6$}; \draw [dotted] (266,299) -- (266,329) ; \draw (402,282) node {$7$}; \draw [dotted] (346,279) -- (426,299) ; \draw (126, 38) circle [x radius= 55, y radius= 25] ; \draw (126,38) node {$p(x,y)$}; \draw (76,67) node {$1$}; \draw (126,63) -- (46,85) ; \draw (46, 110) circle [x radius= 55, y radius= 25] ; \draw (46,110) node {$q(y)$}; \draw (176,67) node {$2$}; \draw (126,63) -- (206,85) ; \draw (206, 110) circle [x radius= 55, y radius= 25] ; \draw (206,110) node {$r(y,x)$}; \end{tikzpicture} \end{center} \caption{Finite versus Infinite Derivation Tree for Example \ref{ex-bfs-stop}} \label{figure-infinite-bf-derivation} \end{figure} Importantly, the previous algorithm is naturally able to consider solely some type of restricted derivations, i.e., build only derivation trees associated with such derivations, which is of theoretical but also of practical interest. Indeed, implementations of the restricted chase often proceed by building \emph{breadth-first} sequences (which are intrinsically fair), or variants of these. As witnessed by the next example, the termination of all breadth-first sequences is a strictly weaker requirement than the termination of all fair sequences, in the sense that the restricted chase terminates on more sets of rules. \begin{example} \label{ex-bfs-stop}Consider the following set of rules:\\ $\ensuremath{\sigma}_1 = p(x,y) \rightarrow q(y) \quad \quad \quad ~\ensuremath{\sigma}_2 = p(x,y) \rightarrow r(y,x)$\\ $ \ensuremath{\sigma}_3 = q(y) \rightarrow \exists z ~r(y,z) \quad \quad \ensuremath{\sigma}_4 = r(x,y) \rightarrow \exists z ~p(y,z)$\\ All breadth-first restricted derivations terminate, whatever the initial instance is. Remark that every application of $\ensuremath{\sigma}_1$ is followed by an application of $\ensuremath{\sigma}_2$ in the same breadth-first step, which prevents the application of $\ensuremath{\sigma}_3$. However, there is a fair restricted derivation that does not terminate (and this is even true for any instance). Indeed, an application of $\ensuremath{\sigma}_2$ can always be delayed, so that it comes too late to prevent the application of $\ensuremath{\sigma}_3$. See Figure \ref{figure-infinite-bf-derivation}: on the left, a finite derivation tree associated with a breadth-first derivation from instance $p(x,y)$; on the right, an infinite derivation tree associated with a (non breadth-first) fair infinite derivation from the same instance. The numbers on edges give the order in which bags are created. \end{example} We now prove the decidability of the one-sequence termination problem, building on the same objects as before, but in a different way. Indeed, a (restricted) derivation tree $\ensuremath{\mathcal{T}}$ that contains a UPW $(B,B')$ is a witness of the existence of an infinite (restricted fair) derivation, but does not prove that \emph{every} (restricted fair) derivation that extends $\ensuremath{\mathcal{T}}$ is infinite. To decide, we will consider trees associated with a \emph{sharing type} instead of a type. A derivation tree associated with a sharing type $T$ has a root bag whose sharing type is $T$, and is built as for usual root bags, except that shared terms are taken into account, i.e., triggers $(\ensuremath{\sigma}, \pi)$ such that $\pi(\fr{\ensuremath{\sigma}}) \subseteq \shared{T}$ are simply ignored. The algorithm proceeds as follows: \begin{enumerate} \item For each sharing type $T$, generate all restricted derivations trees associated with $T$, stopping the construction of a tree when, for each leaf $B_L$, either there is no active trigger on $\atoms{B_L}$ or $B_L$ forms a UPW with one of its ancestors. \item Mark all the sharing types that have at least one associated tree without UPW. \item Propagate the marks until stability: if a sharing type $T$ has at least one tree for which all UPWs $(B,B')$ are such that the sharing type of $B$ is marked, then mark $T$. \item If all sharing types that correspond to instances (i.e., without shared terms) are marked, return \emph{yes}, otherwise return \emph{no}. \end{enumerate} \begin{proposition} The previous algorithm terminates and returns yes if and only if there is a terminating restricted sequence. \end{proposition} \begin{proof}(Sketch) Termination follows from the finiteness of the set of sharing types and the bound on the size of a tree. Concerning the correctness of the algorithm, we show that a terminating restricted derivation cannot have a derivation tree that contains an unmarked UPW, i.e., whose associated sharing type is not marked. By contradiction: assume there is a terminating restricted derivation whose derivation tree contains an unmarked UPW; consider such an unmarked UPW $(B,B')$ such that $B'$ is of maximal depth in the tree. The subtree of $B'$ necessarily admits as prefix one of the restricted derivation trees associated with the sharing type of $B'$ built by the algorithm, otherwise the derivation would not be fair. Moreover, since the sharing type of $B'$ is not marked, this prefix contains an unmarked UPW. Hence, the tree contains an unmarked UPW $(B'',B''')$ with $B'''$ of depth strictly greater than the depth of $B'$, which contradicts the hypothesis. \end{proof} \begin{corollary} \label{corollary-one-sequence-finiteness-decidability} The one-sequence termination problem for the restricted chase on linear rules is decidable. \end{corollary} By guessing a terminating restricted derivation, which must be of size at most double exponential, and checking that the obtained instance is indeed a universal model, we obtain a \textsc{N2ExpTime} upper bound for the complexity of the one-sequence termination problem. We conclude this section by noting that the previous Example \ref{ex-bfs-stop} may give the (wrong) intuition that, given a set of rules, it is sufficient to consider breadth-first sequences to decide if there exists a terminating sequence. The following example shows that it is not the case: here, no breadth-first sequence is terminating, while there exists a terminating sequence for the given instance. \begin{example} \label{ex-bfs-non-stop-bis} Let $\ensuremath{\Sigma}=\{\ensuremath{\sigma}_1,\ensuremath{\sigma}_2,\ensuremath{\sigma}_3\}$ with $\ensuremath{\sigma}_1 = p(x,y) \rightarrow \exists z ~p(y,z) $, $\ensuremath{\sigma}_2 = p(x,y) \rightarrow h(y)$, and $\ensuremath{\sigma}_3= h(x) \rightarrow ~p(x,x)$. In this case, for every instance, there is a terminating restricted chase sequence, where the application of $\ensuremath{\sigma}_2$ and $\ensuremath{\sigma}_3$ prevents the indefinite application of $\ensuremath{\sigma}_1$. However, starting from $\ensuremath{I} = \{p(a,b)\}$, by applying rules in a breadth-first fashion one obtains a non-terminating restricted chase sequence, since $\ensuremath{\sigma}_1$ and $\ensuremath{\sigma}_2$ are always applied in parallel from the same atom, before applying $ \ensuremath{\sigma}_3$. \end{example} As for the all-sequence termination problem, the algorithm may restrict the derivations of interest to specific kinds. \section{Core Chase Termination} We now consider the termination of the core chase of linear rules. Keeping the same approach, we prove that the finiteness of the core chase is equivalent to the existence of a finite tree of bags whose set of atoms is a minimal universal model. We call this a \emph{(finite) complete core}. To bound the size of a complete core, we show that it cannot contain an unbounded-path witness. Note that in the binary case, it would be possible to work again on derivation trees, but this is not true anymore for arbitrary arity. Indeed, as shown in Example \ref{example-mlm}, there are linear sets of rules for which no derivation tree form a complete core (while it holds for binary rules). We thus introduce a more general tree structure, namely \emph{entailment trees}. \begin{example} \label{example-mlm} Let us consider the following rules: \smallskip \begin{tabular}{ll} $s(x) \rightarrow \exists y \exists z ~p(y,z,x)$ & \hspace{1cm} $p(y,z,x) \rightarrow \exists v ~q(y,v,x)$ \\ $q(y,v,x) \rightarrow p(y,v,x)$ & ~ \\ \end{tabular} \smallskip Let $\ensuremath{I} = \{s(a)\}$. The first rule applications yield a derivation tree $\ensuremath{\mathcal{T}}$ which is a path of bags $B_0, B_1,B_2,B_3$ respectively labeled by the following atoms:\\ $s(a), p(y_0,z_0,a), q(y_0,v_0,a)$ and $p(y_0, v_0,a)$. $\ensuremath{\mathcal{T}}$ is represented on the left of Figure \ref{figure-example-mlm}. Let $A$ be this set of atoms. First, note that $ A$ is not a core: indeed it is equivalent to its strict subset $A'$ defined by $\{B_0, B_2, B_3\}$ with a homomorphism $\pi$ that maps $\atoms{B_1}$ to $\atoms{B_3}$. Trivially, $A'$ is a core since it does not contain two atoms with the same predicate. Second, note that any further rule application on $\ensuremath{\mathcal{T}}$ is redundant, i.e., generates a set of atoms equivalent to $A$ (and $A'$). Hence, $A'$ is a complete core, however there is no derivation tree that corresponds to it. There is even no \emph{prefix} of a derivation tree that corresponds to it (which ruins the alternative idea of building a prefix of a derivation tree that would be associated with a complete core). In particular, note that $\{B_0, B_1, B_2\}$ is indeed a core, but it is not complete. \end{example} \begin{figure}[t] \begin{center} \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1,thick,scale=0.6, every node/.style={scale=0.7}] \draw (126, 38) circle [x radius= 35, y radius= 20] ; \draw (126.25, 104.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126.25, 175.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126.25, 246.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (126,58) -- (126,80) ; \draw (126,129) -- (126,151) ; \draw (126,200) -- (126,222) ; \draw (68.1,229.09) .. controls (6.16,198.84) and (14.56,141.8) .. (70,122) ; \draw [shift={(70,230)}, rotate = 205.11] [color={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29) ; \draw (375, 76) circle [x radius= 35, y radius= 20] ; \draw (375.25, 143.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (375, 214.5) circle [x radius= 55.25, y radius= 24.5] ; \draw (375,96) -- (375,118) ; \draw (375,168) -- (375,190) ; \draw (126,37) node {$s( a)$}; \draw (124,105) node {$p( y_{0} ,z_{0} ,a)$}; \draw (125,176) node {$q( y_{0} ,v_{0} ,a)$}; \draw (126,247) node {$p( y_{0} ,v_{0} ,a)$}; \draw (76,38) node {$B_{0}$}; \draw (56,105) node {$B_{1}$}; \draw (54,175) node {$B_{2}$}; \draw (57,250) node {$B_{3}$}; \draw (117,300) node [align=left] {Derivation Tree}; \draw (364,299) node [align=left] {An Entailment Tree}; \draw (15,170) node {$\varphi $}; \draw (372,75) node {$s( a)$}; \draw (374,144) node {$q( y_{0} ,v_{0} ,a)$}; \draw (375,215) node {$p( y_{0} ,v_{0} ,a)$}; \draw (322,76) node {$B_{0}$}; \draw (303,143) node {$B_{2}$}; \draw (306,218) node {$B_{3}$}; \end{tikzpicture} \end{center} \caption{Derivation tree and entailment tree for Example \ref{example-mlm}} \label{figure-example-mlm} \end{figure} In the following definition of entailment tree, we use the notation $\alpha_1 \rightarrow \alpha_2$, where $\alpha_i$ is an atom, to denote the rule $\forall X (\alpha_1 \rightarrow \exists Y ~\alpha_2)$ with $X = \vars{\alpha_1}$ and $Y = \vars{\alpha_2}\setminus X$. \begin{definition}[Entailment Tree] \label{definition-entailment-tree} An \emph{entailment tree} associated with $\alpha$ and $\ensuremath{\Sigma}$ is a tree of bags $\ensuremath{\mathcal{T}}$ such that: \begin{enumerate} \item $\ensuremath{B}_r$, the root of $\ensuremath{\mathcal{T}}$, is such that $\ensuremath{\Sigma} \models \alpha \rightarrow \atoms{\ensuremath{B}_r}$ and $\ensuremath{\Sigma} \models \atoms{\ensuremath{B}_r} \rightarrow \alpha$; \item \sloppypar{For any bag $\ensuremath{B}_c$ child of a node $\ensuremath{B}$, the following holds: \emph{(i)} $\terms{\ensuremath{B}_c}\cap \generated{\ensuremath{B}} \neq \emptyset$ \emph{(ii)} The terms in $\generated{\ensuremath{B}_c}$ are variables that do not occur outside the subtree of $\ensuremath{\mathcal{T}}$ rooted in $\ensuremath{B}_c$ \emph{(iii)} $\ensuremath{\Sigma} \models \atoms{\ensuremath{B}} \rightarrow \atoms{\ensuremath{B}_c}$.} \item there is no pair of twins. \end{enumerate} \end{definition} Note that $\alpha$ is not necessarily the root of the entailment tree, as it may not belong to the result of the core chase on $\alpha$ (hence Point 1). First note that an entailment tree is independent from any derivation. The main difference with a derivation tree is that it employs a more general parent-child relationship, that relies on entailment rather than on rule application, hence the name entailment tree. Intuitively, with respect to a derivation tree, one is allowed to move a bag $B$ higher in the tree, provided that it contains at least one term generated in its new parent $B_p$; then, the terms of $B$ that are not shared with $B_p$ are freshly renamed. Finally, since the problem of whether an atom is entailed by a linear existential rule knowledge base is decidable (precisely \textsc{PSpace}-complete \cite{DBLP:books/sp/virgilio09/CaliGL09}), one can actually generate all non-twin children of a bag and keep a tree with bounded arity. Derivation trees are entailment trees, but not necessarily conversely. A crucial distinction between these two structures is the following statement, which does not hold for derivation trees, as illustrated by Example \ref{example-mlm}. \begin{propositionrep} \label{proposition-entailment-core} If the core chase associated with $\alpha$ and $\ensuremath{\Sigma}$ is finite, then there exists an entailment tree $\ensuremath{\mathcal{T}}$ such that the set of atoms associated with $\ensuremath{\mathcal{T}}$ is a complete core. \end{propositionrep} \medskip \noindent \emph{Example \ref{example-mlm} (cont'd).} The tree defined by the path of bags $B_0$, $B_2$, $B_3$ is an entailment tree, represented on the right of Figure \ref{figure-example-mlm}, which defines a complete core. \begin{proof} Let $\ensuremath{\mathcal{T}}$ be the derivation tree associated with a derivation containing a core $C$ of $\chase{\alpha}{\ensuremath{\Sigma}}$. Let $\varphi$ be an idempotent homomorphism from the atoms of $\ensuremath{\mathcal{T}}$ to $C$. We assign to each bag $\ensuremath{B}$ of $\ensuremath{\mathcal{T}}$ a set of trees $\{T_1,\ldots,T_{n_B}\}$ such that: \begin{enumerate} \item each tree contains only elements of $C$; \item the forest assigned to $\ensuremath{B}$ contains exactly once the elements of $C$ appearing in the subtree rooted in $\ensuremath{B}$; \item for each pair $(\ensuremath{B}_p,\ensuremath{B}_c)$ of bags in some $T_i$ such that $\ensuremath{B}_p$ is a parent of $\ensuremath{B}_c$, $\ensuremath{\Sigma} \models \atoms{\ensuremath{B}_p} \rightarrow \atoms{\ensuremath{B}_c}$; \item each $T_i$ is a decomposition tree; \item for each $T_i$, the root of $T_i$ contains all the terms that belong both to $T_i$ and to $C \setminus T_i$; \item each term $\ensuremath{t}$ belonging to distinct $T_i$ and $T_j$ of the forest assigned with a bag $\ensuremath{B}$ also belongs to the parent of $\ensuremath{B}$. \end{enumerate} Moreover, we will show that if $\varphi(\ensuremath{B})$ is a descendant of $\ensuremath{B}$ (including $\ensuremath{B}$) in $\ensuremath{\mathcal{T}}$, then its associated forest is a tree. \begin{itemize} \item if $\ensuremath{B}$ is a leaf, we consider two cases: \begin{itemize} \item $\ensuremath{B}$ belongs to the core: we assign it a single tree, containing only a root being itself. All conditions are trivial. \item $\ensuremath{B}$ does not belong to the core: we assign it an empty forest, and all conditions are trivial. \end{itemize} \item if $\ensuremath{B}$ is an internal node, let $\{T_1,\ldots,T_n\}$ be the union of the forests assigned to the children of $\ensuremath{B}$. We distinguish three cases: \begin{itemize} \item $\ensuremath{B}$ is in the core: we assign to $\ensuremath{B}$ the tree $T$ containing $\ensuremath{B}$ as root, and having as children the roots of $\{T_1,\ldots,T_n\}$. \begin{itemize} \item 1. 2.: holds by induction assumption, the fact that different $T_i$'s cover disjoint subtrees of $\ensuremath{\mathcal{T}}$, and the fact that $\ensuremath{B}$ belongs to the core \item 3.: it is enough to check this for the pairs (root of $T$, root of $T_i$). The root of $T$ is an ancestor of root of $T_i$ in $\ensuremath{\mathcal{T}}$, hence $\ensuremath{\Sigma} \models \atoms{\mathrm{root}(T)}\rightarrow \atoms{\ensuremath{B}_i}$, where $\ensuremath{B}_i$ is the root of $T_i$ \item 4. if $\ensuremath{t}$ appears in $T$ but in no $T_i$, it appears only in $\ensuremath{B}$ and the connectivity of the substructure containing $\ensuremath{t}$ holds. If it belongs to some $T_i$ and to $C \setminus T_i$, it must belong to the root of $T_i$ by assumption 6.. If $\ensuremath{t}$ belongs to $C \setminus T$, it belongs to $\ensuremath{B}$ by connectivity of $\ensuremath{\mathcal{T}}$. If $\ensuremath{t}$ belongs to another $T_j$, we distinguish two cases: $T_j$ is in the same forest as $T_i$, and then by induction assumption 7. on the child of $\ensuremath{B}$ to which this forest is associated, $\ensuremath{t}$ belongs to $\ensuremath{B}$. Or $T_j$ is in the forest of another child of $\ensuremath{B}$, and then by connectivity property for $\ensuremath{t}$, it belongs to $\ensuremath{B}$. Hence the connectivity property for $\ensuremath{t}$ in $T$ is fulfilled. \item 5. By connectivity of $\ensuremath{\mathcal{T}}$, as $\ensuremath{B}$ is the root of $T$ \item 6. true as there is only one tree \end{itemize} \item $\varphi(\ensuremath{B}) \not = \ensuremath{B}$ but is a descendant of $\ensuremath{B}$. By induction assumption 2., there exists exactly one tree among the trees associated with children of $\ensuremath{B}$ containing $\varphi(\ensuremath{B})$. Let assume w.l.o.g that it is $T_1$, of root $\ensuremath{B}_1$. We build the following tree $T$: for all $T_i \not = T_1$, we add to $\ensuremath{B}_1$ a subtree by putting the root of $T_i$ under $\ensuremath{B}_1$. \begin{itemize} \item 1. No added elements, hence by induction assumption 1. \item 2. No added elements, hence by induction assumption 2. \item 3. To check for pairs ($\ensuremath{B}_1$,$\ensuremath{B}_i$), where $\ensuremath{B}_i$ is the root of $T_i$. $\ensuremath{\Sigma} \models \atoms{\ensuremath{B}_1} \rightarrow \atoms{\varphi(\ensuremath{B})}$, as $\varphi(\ensuremath{B})$ is a descendant of $\ensuremath{B}_1$ in $T_1$. Moreover, $\ensuremath{\Sigma} \models \atoms{\varphi(\ensuremath{B})} \rightarrow \atoms{\ensuremath{B}_i}$, as $\varphi(\ensuremath{B})$ is more specific than $\ensuremath{B}$, and $\varphi$ is the identity on shared terms. \item 4. for all term $\ensuremath{t}$ appearing in a single tree, the connectivity property holds by induction assumption 4.. Let $\ensuremath{t}$ appearing in two trees. $\ensuremath{t}$ appears in the roots of both tree by $6.$, and must appear in $\ensuremath{B}$ by connectivity of $\ensuremath{\mathcal{T}}$, hence in $\varphi(B)$, and hence in $\ensuremath{B}_1$ (by 6.). As $\ensuremath{B}_1$ and the roots of both trees are neighbor, this proves the result. \item 5. let $\ensuremath{t}$ belonging to $T$ and to $C \setminus T$. By connectivity of $\ensuremath{\mathcal{T}}$, $\ensuremath{t}$ belongs to $\ensuremath{B}$, hence to $\varphi(\ensuremath{B})$ (because $\varphi(t) =t$). As $\ensuremath{t}$ belongs both to $T_1$ and to $C \setminus T_1$, $\ensuremath{t}$ belongs to $\ensuremath{B}_1$, and hence to the root of the assigned tree. \item 6. true as there is only one tree. \end{itemize} \item $\varphi(\ensuremath{B})$ is not a descendant of $\ensuremath{B}$. We assign to $\ensuremath{B}$ the union of the forests associated to its children. \begin{itemize} \item 1.-5 By induction assumption \item 6. let $\ensuremath{t}$ belonging to two trees $T_1$ and $T_2$. If $T_1$ and $T_2$ come from forest associated to two different children, $\ensuremath{t}$ belongs to $\ensuremath{B}$ by connectivity of $\ensuremath{\mathcal{T}}$. If $T_1$ and $T_2$ come from the same forest, $\ensuremath{t}$ belongs to $\ensuremath{B}$ by induction assumption 7. Then $\ensuremath{t}$ belongs to $\ensuremath{B}$. As $\ensuremath{t}$ is in $C$, $\ensuremath{t}$ belongs to $\varphi(\ensuremath{B})$. By connectivity of $\ensuremath{\mathcal{T}}$, it belongs to the parent of $\ensuremath{B}$, because that parent is on the path from $\ensuremath{B}$ to $\varphi(\ensuremath{B})$, which proves 6. \end{itemize} \end{itemize} \end{itemize} Finally, we check that the following property is satisfied: for any bag $\ensuremath{B}$, if $\ensuremath{B}$ is in the core, then a single tree with root $\ensuremath{B}$ is assigned to it. If $\alpha$ is in the core, we have built such a tree. It remains to obtain an entailment tree: for that, we have to bring up nodes at the highest level with respect to shared terms. We may also have to say something about 'generated' if it still appear in the definition of an entailment tree. \end{proof} \medskip Differently from the semi-oblivious case, we cannot conclude that the chase does not terminate as soon as a UPW is built, because the associated atoms may later be mapped to other atoms, which would remove the UPW. Instead, starting from the initial bag, we recursively add bags that do not generate a UPW (for instance, we can recursively add all such non-twin children to a leaf). Once the process terminates (the non-twin condition and the absence of UPW ensure that it does), we check that the obtained set of atoms $C$ is complete (i.e., is a model of the KB): for that, it suffices to perform each possible rule application on $C$ and check if the resulting set of atoms is equivalent to $C$. See Algorithm \ref{algorithm-core-chase}. The set $C$ may not be a core, but it is complete iff it contains a complete core. We now focus on the key properties of entailment trees associated with complete cores. We first introduce the notion of \emph{redundant bags}, which captures some cases of bags that cannot appear in a finite core. As witnessed by Example \ref{example-mlm}, this is not a characterization: $B_1$ is not redundant (according to next Definition \ref{definition-redundancy}), but cannot belong to a complete core. \begin{definition}[Redundancy] \label{definition-redundancy} Given an entailment tree, a bag $\ensuremath{B}_c$ child of $\ensuremath{B}$ is redundant if there exists an atom $\beta$ (that may not belong to the tree) with \emph{(i)} $\ensuremath{\Sigma} \models \atoms{\ensuremath{B}} \rightarrow \beta$; \emph{(ii)} there is a homomorphism from $\atoms{\ensuremath{B}_c}$ to $\beta$ that is the identity on $\shared{\ensuremath{B}_c}$ \emph{(iii)} $|\terms{\beta} \setminus \terms{\ensuremath{B}}| < |\terms{\ensuremath{B}_c} \setminus \terms{\ensuremath{B}}|$. \end{definition} Note that $\ensuremath{B}_c$ may be redundant even if the ``cause'' for redundancy, i.e., $\beta$, is not in the tree yet. The role of this notion in the proofs is as follows: we show that if a complete entailment tree contains a UPW then it contains a redundant bag, and that a complete core cannot contain a redundant bag, hence a UPW. To prove this, we rely on next Proposition \ref{proposition-swissknife-bag-copy}, which is the counterpart for entailment trees of Proposition \ref{proposition-sharing-type-children-derivation-tree}: performing a bag copy from an entailment tree results in an entailment tree (the notion of prefix is not needed, since a prefix of an entailment tree is an entailment tree) and keeps the properties of the copied bag. \begin{propositionrep} \label{proposition-swissknife-bag-copy} Let $\ensuremath{B}$ be a bag of an entailment tree $\ensuremath{\mathcal{T}}$, $\ensuremath{B}'$ be a bag of an entailment tree $\ensuremath{\mathcal{T}}'$ such that $\ensuremath{B} \ensuremath{\equiv_{st}} \ensuremath{B}'$. Let $\ensuremath{B}_c$ be a child of $\ensuremath{B}$ and $\ensuremath{B}_c'$ be a copy of $\ensuremath{B}_c$ under $\ensuremath{B}'$. Let $\ensuremath{\mathcal{T}}''$ be the extension of $\ensuremath{\mathcal{T}}'$ where $\ensuremath{B}_c'$ is added as a child of $\ensuremath{B}'$. Then \emph{(i)} $\ensuremath{\mathcal{T}}''$ is an entailment tree; \emph{(ii)} $\ensuremath{B}_c$ and $\ensuremath{B}_c'$ have the same sharing type; \emph{(iii)} $\ensuremath{B}_c'$ is redundant if and only if $\ensuremath{B}_c$ is redundant. \end{propositionrep} In light of this, the copy of a bag can be naturally extended to the copy of the whole subtree rooted in a bag, which is crucial element in the proof of next Proposition~\ref{proposition-uc-excluded-main-text}: \begin{toappendix} Another important property of entailment trees (which is also satisfied by derivation trees) is that its structure provides information on where a bag may be mapped by $\varphi$ if its parent is left invariant by $\varphi$. \begin{lemma} \label{lemma-locality} Let $\ensuremath{\mathcal{T}}$ be an entailment tree. Let $\varphi$ be a homomorphism from the atoms of $\ensuremath{\mathcal{T}}$ to themselves. Let $\ensuremath{B}_p$ such that $\varphi_{\mid \terms{\ensuremath{B}_p}}$ is the identity. Let $\ensuremath{B}_c$ be a child of $\ensuremath{B}_p$. Then $\varphi(\ensuremath{B}_c)$ is in the subtree rooted in $\varphi(\ensuremath{B}_p) = \ensuremath{B}_p$. \end{lemma} \begin{proof} $\ensuremath{B}_c$ is a child of $\ensuremath{B}_p$ thus there exists at least one term generated in $\ensuremath{B}_p$ that is a term of $\ensuremath{B}_c$. As $\varphi$ is the identity on $\ensuremath{B}_p$, that term belongs as well to $\varphi(\atoms{\ensuremath{B}_c})$. Thus $\varphi(\atoms{\ensuremath{B}_c})$ should also be in a bag that is in the subtree rooted in $\ensuremath{B}_p$. \end{proof} \end{toappendix} \begin{proposition} \label{proposition-uc-excluded-main-text} A complete core cannot contain \emph{(i)} a redundant bag \emph{(ii)} an unbounded-path witness. \end{proposition} \begin{toappendix} \begin{proposition} \label{proposition-strong-redundancy} A complete core cannot contain a redundant bag. \end{proposition} \begin{proof} Let $\ensuremath{\mathcal{T}}$ be a complete entailment tree, and let $\hat{\ensuremath{B}}$ be a bag that is redundant. We prove that there exists a non-injective endomorphism of $\ensuremath{\mathcal{T}}$, showing that $\ensuremath{\mathcal{T}}$ cannot be a core. For any entailment tree $\ensuremath{\mathcal{T}}_p$ that is a prefix of $\ensuremath{\mathcal{T}}$, we build $\ensuremath{\mathcal{T}}'_{p}$ and a mapping $\varphi$ from the terms of $\ensuremath{\mathcal{T}}_p$ to the terms of $\ensuremath{\mathcal{T}}'_{p}$ as follows: \begin{itemize} \item for any prefix of $\ensuremath{\mathcal{T}}_p$ that does not contain $\hat{\ensuremath{B}}$, we define $\ensuremath{\mathcal{T}}_{p}' = \ensuremath{\mathcal{T}}_p$ and $\varphi$ the identity \item for the prefix that contains all nodes of $\ensuremath{\mathcal{T}}$, including $\hat{\ensuremath{B}}$, except the descendants of $\hat{\ensuremath{B}}$, we define $\ensuremath{\mathcal{T}}'_p$ as $\ensuremath{\mathcal{T}}_p$ to which we add a leaf (if necessary) to the parent of $\hat{\ensuremath{B}}$ in $\ensuremath{\mathcal{T}}$, which is the witness of the redundancy of $\hat{\ensuremath{B}}$. We define $\varphi$ as the identity on any term that is not generated in $\hat{\ensuremath{B}}$, and as its image by the $\varphi$ witnessing the redundancy pattern on terms generated in $\hat{\ensuremath{B}}$. \item if we have defined $\ensuremath{\mathcal{T}}'_{p}$ for $\ensuremath{\mathcal{T}}_p$, and we want to define $\varphi$ for $\ensuremath{\mathcal{T}}'_n$ for $\ensuremath{\mathcal{T}}_n$ which is $\ensuremath{\mathcal{T}}_p$ to which a leaf $\ensuremath{B}_d$ has been added, we add where it belongs the bag $\varphi(\ensuremath{B}_d)$, where we extend $\varphi$ to term generated in $\ensuremath{B}_d$ by choosing fresh images. \end{itemize} By construction, $\ensuremath{\mathcal{T}}'$ is an entailment tree, and $\varphi$ is a homomorphism from $\ensuremath{\mathcal{T}}$ to $\ensuremath{\mathcal{T}}'$. Moreover, $\varphi$ is not injective: indeed, as $\hat{\ensuremath{B}}$ is redundant, $\varphi$ is not injective on the terms of $\hat{\ensuremath{B}}$. As $\ensuremath{\mathcal{T}}$ is complete, there exists a homomorphism from $\ensuremath{\mathcal{T}}'$ to $\ensuremath{\mathcal{T}}$. Hence the composition of the two homomorphisms is a homomorphism from $\ensuremath{\mathcal{T}}$ to itself, which is not injective, as $\varphi$ is not. Hence $\ensuremath{\mathcal{T}}$ is not a core. \end{proof} \end{toappendix} \begin{toappendix} \begin{proposition} \label{proposition-uc-excluded} A complete core cannot contain any unbounded-path witness. \end{proposition} \medskip \begin{proof} We prove the result by contradiction. Let us assume that $\ensuremath{\mathcal{T}}$ is a complete core containing an unbounded-path witness $(\ensuremath{B},\ensuremath{B}')$. Let us choose $(\ensuremath{B},\ensuremath{B}')$ such that $\ensuremath{B}'$ is of maximal depth with respect to its branch, that is, there is no unbounded-path witness $(\ensuremath{B}''',\ensuremath{B}'')$ with $\ensuremath{B}''$ a strict descendant of $\ensuremath{B}'$. \medskip Let $\ensuremath{B}_c$ be the child of $\ensuremath{B}$ on the path from $\ensuremath{B}$ to $\ensuremath{B}'$. Let us denote by $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c}$ the subtree of $\ensuremath{\mathcal{T}}$ which is rooted at $\ensuremath{B}_c$ and by $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c'}$ a copy of $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c}$ under $B'$ whose root is $\ensuremath{B}_c'$. Then, let $\ensuremath{\mathcal{T}}'$ be the extension of $\ensuremath{\mathcal{T}}$ where $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c'}$ is added as a child of $\ensuremath{B}'$. We want to show that there exists a bag $\ensuremath{B}_r'$ child of $\ensuremath{B}'$ and a mapping from $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c'}$ into $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$, which is the identity on the terms of $\ensuremath{\mathcal{T}}$. More precisely, we want to show that for each $\ensuremath{B}_d'$ descendant of $ \ensuremath{B}_c'$ the following properties hold. \begin{enumerate} \item the image of $\ensuremath{B}_d'$ belongs to $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$ \item the image of a term generated in $\ensuremath{B}_d'$ is a term generated in a bag of $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$ \end{enumerate} We do so by induction on $k$ the distance between $\ensuremath{B}_d'$ and $\ensuremath{B}_c'$ in $\ensuremath{\mathcal{T}}$. \begin{itemize} \item If $k=0$ then $\ensuremath{B}_d'=\ensuremath{B}_c'$. Because $\ensuremath{\mathcal{T}}$ is a complete core, there exists a homomorphism from the atoms of $\mathcal{T'} $ to those of $ \mathcal{T}$ which is the identity on the terms of $\ensuremath{\mathcal{T}}$. We show that the image of $\ensuremath{B}'_c$ is a strict descendant of a child of $\ensuremath{B}'$. Note first that no child of $\ensuremath{B}'$ in $\ensuremath{\mathcal{T}}$ can be a safe renaming of $\ensuremath{B}'_c$. Indeed, by Proposition \ref{proposition-swissknife-bag-copy}, $\ensuremath{B}_c$ and $\ensuremath{B}_c'$ have the same sharing type and therefore $\ensuremath{B}_c'$ (as well as any safe renaming of its generated terms) cannot be a child of $\ensuremath{B}'$ because the couple $(\ensuremath{B}_c,\ensuremath{B}_c')$ would form an unbounded-path witness with $\ensuremath{B}_c'$ strictly deeper than $\ensuremath{B}'$. Then, if $\ensuremath{B}_c'$ maps to $\ensuremath{B}'$ then the couple $(\ensuremath{B}',\ensuremath{B}_c')$ is redundant and therefore also $(\ensuremath{B},\ensuremath{B}_c)$ is redundant, by Proposition \ref{proposition-swissknife-bag-copy}, which in turn implies that $\ensuremath{\mathcal{T}}$ is not a core, because of Proposition \ref{proposition-strong-redundancy}. Finally, if $\ensuremath{B}_c'$ maps to any child of $\ensuremath{B}'$ then it does so by specializing the sharing type of $\ensuremath{B}_c'$ (as we showed that no safe renaming of $\ensuremath{B}_c'$ can be a child of $\ensuremath{B}'$), which means that $\ensuremath{B}_c'$ is redundant. Therefore, by Proposition \ref{proposition-swissknife-bag-copy}, $\ensuremath{B}_c$ is also redundant and hence, by Proposition \ref{proposition-strong-redundancy}, $\ensuremath{\mathcal{T}}$ is not a core. This proves that the image of $\ensuremath{B}_c'$ is a strict descendant of some $\ensuremath{B}_r'$ child of $\ensuremath{B}'$. \smallskip Now, to prove the second point, let $t$ be a term generated in $\ensuremath{B}'_c$ and $t'$ its image. It is easy to see that for entailment trees any term that belongs to two bags in ancestor-descendant relationship also belongs to the bags on the shortest path between them. Therefore, if $t'$ is generated by a strict ancestor of $\ensuremath{B}_r'$ then $t'$ belongs to the terms of $\ensuremath{B}'$. This means that starting from the sharing type of $\ensuremath{B}_c'$ one can build a strictly more specific sharing type where the position corresponding to the generated term $t$ becomes shared with $\ensuremath{B}'$. From this one can find a node $\ensuremath{B}_c''$ which is strictly more specific than $\ensuremath{B}_c'$ and that can be added as a child of $\ensuremath{B}'$. This means that $\ensuremath{B}_c'$ is redundant and by Proposition \ref{proposition-swissknife-bag-copy} also $\ensuremath{B}_c$ is redundant, so $\ensuremath{\mathcal{T}}$ is not a core. \item Let us assume that both properties hold for all bags at distance $k$ from $\ensuremath{B}_c'$. We want to show that they still holds for the bags at distance $k+1$. Let $\ensuremath{B}_d'$ be a node at distance $k+1$ from $\ensuremath{B}_c'$ whose parent is $\ensuremath{B}'_\delta$. By definition, $\ensuremath{B}_d'$ contains a term generated by $B'_\delta$ and, by induction, we know that the image of this term is generated in a bag of $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$. Thus, it follows that the image of $\ensuremath{B}_d'$ belongs to $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$ as required by the first point. \smallskip For the second point we reason by contradiction and show that when the property does not hold then $\ensuremath{\mathcal{T}}$ admits a non-injective endomorphism and thus it is not a core. We proceed with the following construction. Let $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r}$ be a copy of $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$ under $\ensuremath{B}$ and $\ensuremath{\mathcal{T}}''$ the extension of $\ensuremath{\mathcal{T}}$ where $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r}$ is added as a child of $\ensuremath{B}$. We know by induction that there exists a homomorphism from $\ensuremath{\mathcal{T}}'$ to $\ensuremath{\mathcal{T}}$ mapping all nodes at distance ${k+1}$ from $\ensuremath{B}'_c$ to the subtree rooted at $\ensuremath{B}'_r$. From this, we can conclude that there exists a homomorphism from $\ensuremath{\mathcal{T}}_{(k+1)}$ to $\ensuremath{\mathcal{T}}''$, where $\ensuremath{\mathcal{T}}_{(k+1)}$ is the prefix of $\ensuremath{\mathcal{T}}$ which includes all nodes of $\ensuremath{\mathcal{T}}$ except for the descendants of $\ensuremath{B}_c$ that are at distance strictly greater than $k+1$ from it. Now, we further extend $\ensuremath{\mathcal{T}}''$ by adding an image for all nodes which are at distance strictly greater than $k+1$ from $\ensuremath{B}_c$ thereby obtaining a new entailment tree $\ensuremath{\mathcal{T}}'''$. It follows that $\ensuremath{\mathcal{T}}$ can be mapped to $\ensuremath{\mathcal{T}}'''$. Beside, since $\ensuremath{\mathcal{T}}$ is complete there exists an homomorphism from $\ensuremath{\mathcal{T}}'''$ to $\ensuremath{\mathcal{T}}$. So, by composing these two homomorphisms we get a homomorphism from $\ensuremath{\mathcal{T}}$ to $\ensuremath{\mathcal{T}}$. We show that the homomorphism from $\ensuremath{\mathcal{T}}$ to $\ensuremath{\mathcal{T}}'''$ is non-injective. Recall that to construct $\ensuremath{\mathcal{T}}'$ the whole subtree rooted at $\ensuremath{B}_c'$ has been copied from the subtree rooted at $\ensuremath{B}_c$. Let us denote by $\ensuremath{B}_d$ the node at distance $k+1$ from $\ensuremath{B}_c$ from which $\ensuremath{B}_d'$ has been copied under $\ensuremath{B}_\delta'$. Let $t$ be a term generated at position $i$ in $\ensuremath{B}_d'$. If its image was generated by a strict ancestor of $\ensuremath{B}_r'$ then this would also belong to the terms of $\ensuremath{B}'$. By Proposition \ref{proposition-swissknife-bag-copy}, $\ensuremath{B}_d$ and $\ensuremath{B}_d'$ have the same sharing types, hence the mapping from $\ensuremath{\mathcal{T}}_{(k+1)}$ to $\ensuremath{\mathcal{T}}''$ (and thus that from $\ensuremath{\mathcal{T}} $ to $\ensuremath{\mathcal{T}}'''$) maps the generated term at position $i$ of $\ensuremath{B}_d$, we call $s$, to a distinct term in $\ensuremath{B}$, we call $s'$. Moreover, the homomorphism is the identity on $s'$. Therefore, the homomorphism from $\ensuremath{\mathcal{T}}$ to $\ensuremath{\mathcal{T}}'''$ is non-injective as both $s'$ and $s$ have the same image. \end{itemize} To finish the proof, we proceed with the following construction. Let $\ensuremath{\mathcal{T}}^*$ be an entailment tree derived from $\ensuremath{\mathcal{T}}$ where $i)$ the whole subtree rooted at $\ensuremath{B}_r'$ has been copied under $\ensuremath{B}$ and $ii)$ the subtree rooted at $\ensuremath{B}_c$ has been removed. Note that $\ensuremath{\mathcal{T}}^*$ is of size strictly smaller than that of $\ensuremath{\mathcal{T}}$ because we added a bag for each descendant node of $\ensuremath{B}'_r$, which is a strict descendant of bag $\ensuremath{B}_c$, and that this last one has been removed. Now, because $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c'}$ maps to $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r'}$ it follows that $\ensuremath{\mathcal{T}}_{\ensuremath{B}_c}$ maps to $\ensuremath{\mathcal{T}}_{\ensuremath{B}_r}$ and by extending this homomorphism to the identity on all other terms we get that $\ensuremath{\mathcal{T}}$ can be mapped to $\ensuremath{\mathcal{T}}^*$. Hence, $\ensuremath{\mathcal{T}}$ is not a core. \end{proof} \end{toappendix} \begin{corollary} \label{corollary-core-finiteness-decidability} The all-sequence termination problem for the core chase on linear rules is decidable. \end{corollary} \begin{algorithm} \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \Input{A set of linear rules} \Output{\texttt{true} if and only if the core chase terminates on all instances} \For{each canonical atom $\alpha$} { Let $\ensuremath{\mathcal{T}}$ be the entailment tree restricted to $\alpha$;\\ \While{a bag $\ensuremath{B}$ can be added to $\ensuremath{\mathcal{T}}$ respecting twin-free entailment tree condition and without creating a UPW}{ add $ \ensuremath{B}$ to $\ensuremath{\mathcal{T}}$ } \If{there is a rule $\ensuremath{\sigma}$ applicable to $\treeatoms{\ensuremath{\mathcal{T}}}$ through $\pi$ s.t. $\treeatoms{\ensuremath{\mathcal{T}}} \not \models \treeatoms{\ensuremath{\mathcal{T}}} \cup \ensuremath{\pi^s}(\head{\ensuremath{\sigma}})$} {\Return \texttt{false}} } \Return \texttt{true} \caption{Deciding core chase termination} \label{algorithm-core-chase} \end{algorithm} A rough complexity analysis of this algorithm yields a \textsc{2ExpTime} upper bound for the termination problem. Indeed, the exponential number of (sharing) types yields a bound on the number of canonical instances to be checked, the arity of the tree, as well as the length of a path without UPW in the tree, and each edge can be generated with a call to a \textsc{PSpace} oracle. \section{Concluding remarks} We have shown the decidability of chase termination over linear rules for three main chase variants (semi-oblivious, restricted, core) following a novel approach based on derivation trees, and their generalization to entailment trees, and a single notion of forbidden pattern. As far as we know, these are the first decidability results for the restricted chase, on both versions of the termination problem (i.e., \emph{all sequence} and \emph{one sequence} termination). The simplicity of the structures and algorithms make them subject to implementation. We leave for future work the study of the precise complexity of the termination problems. A straightforward analysis of the complexity of the algorithms that decide the termination of the restricted and core chases yields upper bounds, however we believe that a finer analysis of the properties of sharing types would provide tighter upper bounds. Future work also includes the extension of the results to more complex classes of existential rules: linear rules with a complex head, which is relevant for the termination of the restricted and core chases, and more expressive classes from the guarded family. Derivation trees were precisely defined to represent derivations with guarded rules and their extensions (i.e., greedy bounded treewidth sets), hence they seem to be a promising tool to study chase termination on that family.
{'timestamp': '2018-10-05T02:09:48', 'yymm': '1810', 'arxiv_id': '1810.02132', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02132'}
arxiv
\section{Introduction}\label{ch:intro} Beyond the success of cryptocurrencies, blockchain has recently emerged as a technology platform that offers secure decentralized consistent transaction ledgers and has powered innovations across domains including financial systems, supply chains and health care. Despite the high demand in distributed ledger technology~\cite{bcbook15}, commercialization opportunities have been obstructed by long processing time for consensus, and high power consumption. These issues have been addressed in consensus algorithms such as \cite{algorand16, algorand17, sompolinsky2016spectre, PHANTOM08}. Distributed database systems often address \emph{Byzantine} fault tolerance~\cite{Lamport82} in which up to just under one-third of the participant nodes may be compromised. Consensus algorithms ensures the integrity of transactions between participants over a distributed network~\cite{Lamport82} and is equivalent to the proof of \emph{Byzantine} fault tolerance in distributed database systems~\cite{randomized03, paxos01}. Byzantine consensus is not guaranteed for deterministic, completely asynchronous system with unbounded delays~\cite{flp}. But achieving consensus is feasible for nondeterministic system with probability one. There are several approaches to consensus in distributed system. The original Nakamoto consensus protocol in Bitcoin uses Proof of Work (PoW), which requires large amounts of computational work to generate the blocks by participants~\cite{bitcoin08}. Alternative schemes such as Proof Of Stake (PoS)~\cite{ppcoin12,dpos14} have been proposed. PoS uses participants' stakes to generate the blocks respectively. Another approach utilizes directed acyclic graphs (DAG)~\cite{dagcoin15, sompolinsky2016spectre, PHANTOM08, PARSEC18, conflux18} to facilitate consensus. Examples of DAG-based consensus algorithms include Tangle~\cite{tangle17}, Byteball~\cite{byteball16}, and Hashgraph~\cite{hashgraph16}. Tangle selects the blocks to connect in the network utilizing accumulated weight of nonce and Monte Carlo Markov Chain (MCMC). Byteball generates a main chain from the DAG and reaches consensus through index information of the chain. Hashgraph connects each block from a node to another random node. Hashgraph searches whether 2/3 members can reach each block and provides a proof of Byzantine fault tolerance via graph search. \subsection{Motivation} Practical Byzantine Fault Tolerance (pBFT) allows all nodes to successfully reach an agreement for a block (information) when a Byzantine node exists \cite{Castro99}. In pBFT, consensus is reached once a created block is shared with other participants and the share information is shared with others again \cite{zyzzyva07, honey16}. After consensus is achieved, the block is added to the participants’ chains~\cite{Castro99, Blockmania18}. Currently, it takes $O(N^4)$ for pBFT. HashGraph~\cite{hashgraph16} proposes ``gossip about gossip" and virtual voting to reach consensus. There are several limitations with HashGraph. First, the algorithm operates on a known network, which needs full awareness of all authoritative participants. Second, gossip propagation is slow and latency increases to $O(n)$ with $n$ participants. Third, it remains unclear whether virtual voting is faster than chain weight aka longest chain/proof of work concept. These issues are gossip problems and not consensus problems. We are interested in a new approach to address the aforementioned issues in pBFT approaches \cite{Castro99,zyzzyva07, honey16} and HashGraph~\cite{hashgraph16}. Specifically, we propose a new consensus algorithm that addresses the following questions: (1) Can we reach local consensus in a $k$-cluster faster for some $k$?, (2) Can we make gossips faster such as using a broadcast based gossip subset?, (3) Can continuous common knowledge be used for consensus decisions with high probability? (4) Can complex decisions be reduced to binary value consensus? In this paper, we propose a new approach that can quickly search for Byzantine nodes within the block DAG. In particular, we introduce a new class of consensus protocols, namely Lachesis protocol denoted by $\mathcal{L}$. The core idea of Lachesis is to use a new DAG structure, the OPERA chain, which allows faster path search for consensus. We then propose an example of the Lachesis protocol class, which is called the Lachesis protocol $L_0$. \subsection{Generic framework of $\mathcal{L}$ Protocols} We introduce a generic framework of Lachesis protocols, called $\mathcal{L}$. The basic idea of Lachesis protocol is a DAG-based asynchronous non-deterministic protocol that guarantees pBFT. We propose OPERA chain --- a new DAG structure for faster consensus. Lachesis protocol generates each block asynchronously and the Lachesis algorithm achieves consensus by confirming how many nodes know the blocks using the OPERA chain. Figure~\ref{fig:operachain} shows an example of OPERA chain constructed through a Lachesis protocol. \begin{figure}[h] \centering \includegraphics[height=7cm, width=1.0\columnwidth]{lachesis_output} \caption{An Example of OPERA Chain} \label{fig:operachain} \end{figure} The main concepts of Lachesis are given as follows: \begin{description} \item[$\bullet$ Event block] All nodes can create event blocks as time $t$. The structure of an event block includes the signature, generation time, transaction history, and hash information to references. The information of the referenced event blocks can be copied by each node. The first event block of each node is called a \emph{leaf event}. \item[$\bullet$ Lachesis protocol] Lachesis protocol is the rule-set to communicate between nodes. When each node creates event blocks, it determines which nodes choose other nodes to broadcast to. Node selection can be random or via some cost function. \item[$\bullet$ Happened-before] Happened-before is the relationship between nodes which have event blocks. If there is a path from an event block $x$ to $y$, then $x$ Happened-before $y$. ``$x$ Happened-before $y$" means that the node creating $y$ knows event block $x$. \item[$\bullet$ Root] An event block is called a \emph{root} if either (1) it is the first generated event block of a node, or (2) it can reach more than two-thirds of other roots. Every root can be candidate for Clotho. \item[$\bullet$ Root set] Root set ($R_s$) is the set of all roots in the frame. The cardinality of the set is $2n/3 < R_s \leq$ $n$, where $n$ is the number of all nodes. \item[$\bullet$ Frame] Frame $f$ is a natural number that separates Root sets. The frame increases by 1 in case of a root in the new set ($f+1$). And all event blocks between the new set and the previous Root set are included in the frame $f$. \item[$\bullet$ Flag table] The Flag table stores reachability from an event block to another root. The sum of all reachabilities, namely all values in flag table, indicates the number of reacheabilities from an event block to other roots. \item[$\bullet$ Lamport timestamps] For topological ordering, Lamport timestamps algorithm uses the happened-before relation to determine a partial order of the whole event block based on logical clocks. \item[$\bullet$ Clotho] A Clotho is a root that satisfies that they are known by more than $2n/3$ nodes and more than $2n/3$ nodes know the information that they are known in nodes. A Clotho can be a candidate for Atropos. \item[$\bullet$ Atropos] An Atropos is assigned consensus time through the Lachesis consensus algorithm and is utilized for determining the order between event blocks. Atropos blocks form a Main-chain, which allows time consensus ordering and responses to attacks. \item[$\bullet$ Reselection] To solve the byzantine agreement problem, each node reselects a consensus time for a Clotho, based on the collected consensus time in the root set of the previous frame. When the consensus time reaches byzantine agreement, a Clotho is confirmed as an Atropos and is then used for time consensus ordering. \item[$\bullet$ OPERA chain] The OPERA chain is the local view of the DAG held by each node, this local view is used to identify topological ordering, select Clotho, and create time consensus through Atropos selection. \item[$\bullet$ Main-Chain] Main-chain is a core subset of the OPERA chain. It is comprised of Atropos event blocks. Thus, the OPERA chain uses Main-chain to find rapid ordering between event blocks. In OPERA chain, each event block is assigned a proper consensus position. \end{description} \begin{figure}[h] \centering \includegraphics[height=7cm, width=1.0\columnwidth]{pBFTtoPath} \caption{Consensus Method through Path Search in a DAG (combines chain with consensus process of pBFT)} \label{fig:pBFTtoPath} \end{figure} As a motivating example, Figure~\ref{fig:pBFTtoPath} illustrates how consensus is reached through the path search in the OPERA chain. In the figure, leaf set, denoted by $R_{s0}$, consists of the first event blocks created by individual participant nodes. $V$ is the set of event blocks that do not belong neither in $R_{s0}$ nor in any root set $R_{si}$. Given a vertex $v$ in $V \cup R_{si}$, there exists a path from $v$ that can reach a leaf vertex $u$ in $R_{s0}$. Let $r_1$ and $r_2$ be root event blocks in root set $R_{s1}$ and $R_{s2}$, respectively. $r_1$ is the block where a quorum or more blocks exist on a path that reaches a leaf event block. Every path from $r_1$ to a leaf vertex will contain a vertex in $V_1$. Thus, if there exists a vertex $r$ in $V_1$ such that $r$ is created by more than a quorum of participants, then $r$ is already included in $R_{s1}$. Likewise, $r_2$ is a block that can be reached for $R_{s1}$ including $r_1$ through blocks made by a quorum of participants. For all leaf event blocks that could be reached by $r_1$, they are shared with more than quorum participants through the presence of $r_1$. The existence of the root $r_2$ shows that information of $r_1$ is shared with more than a quorum. This kind of a path search allows the chain to reach consensus in a similar manner as the pBFT consensus processes. It is essential to keep track of the blocks satisfying the pBFT consensus process for quicker path search; our OPERA chain and Main-chain keep track of these blocks. \subsection{Lachesis protocol $L_0$} We now introduce a new specific Lachesis consensus protocol, called $L_0$. The new protocol $L_0$ is a DAG-based asynchronous non-deterministic protocol that guarantees pBFT. $L_0$ generates each block asynchronously and uses the OPERA chain for faster consensus by checking how many nodes know the blocks. In this $L_0$ protocol, we propose several algorithms. In particular, we introduce an algorithm in which a node can identify lazy participants from cost-effective peers --- say its $k$ peers. We must stress that a generic Lachesis protocol does not depend on any $k$ peer selection algorithm; each node can choose $k$ peers randomly. Each message created by a node is then signed by the creating node and its $k$ peers. We also introduce a flag table data structure that stores connection information of event blocks. The flag table allows us to quickly traverse the OPERA chain to find reachability between event blocks. OPERA chain can be used to optimize path search. By using certain event blocks (Root, Clotho, and Atropos), Main chain --- a core subgraph of OPERA chain, can maintain reliable information between event blocks and reach consensus. Generating event blocks via Lachesis protocol, the OPERA chain and Main chain are updated frequently and can respond strongly to attack situations such as forking and parasite attack. Further, using the flag table over the OPERA chain, consensus can be quickly reached, and the ordering between specific event block can be determined. \subsection{Contributions} In summary, this paper makes the following contributions. \begin{itemize} \item We propose a new family $\mathcal{L}$ of Lachesis protocols. We introduce the OPERA chain and Main-chain for faster consensus. \item We define a topological ordering of nodes and event blocks in the OPERA chain. By using Lamport timestamps, the ordering is more intuitive and reliable in distributed system. We introduce a flag table at each block to improve root detection. \item We present proof of how a DAG-based protocol can implement concurrent common knowledge for consistent cuts. \item The Lachesis protocols allow for faster node synchronization with $k$-neighbor broadcasts. \item A specific Lachesis protocol $L_0$ is then introduced with specific algorithms. The benefits of Lachesis protocol $L_0$ include (1) root selection algorithm via flag table; (2) an algorithm to build the Main-chain; (3) an algorithm for $k$ peers selection via cost function; (4) faster consensus selection via $k$ peer broadcasts; (5) data pruning via root creation. \end{itemize} The rest of this paper is organised as follows. Section~\ref{se:Previous} gives an overview of Blockchain related work as well as existing DAG-based protocols. Section~\ref{se:protocol} describes our new Lachesis protocol. Section~\ref{se:lca} presents Lachesis consensus algorithm. Several discussions about Lachesis protocols are presented in Section~\ref{se:discuss}. Section~\ref{se:con} concludes with some future work. Section~\ref{se:appendix}. Proof of Byzantine fault tolerance is described in Section~\ref{se:proof}. In Section~\ref{se:ra}, we present responses to certain attacks with the Lachesis protocol and consensus algorithm. \section{Related work}\label{se:Previous} \subsection{Lamport timestamps} Lamport~\cite{lamport1978time} defines the "happened before" relation between any pair of events in a distributed system of machines. The happened before relation, denoted by $\rightarrow$, is defined without using physical clocks to give a partial ordering of events in the system. The relation "$\rightarrow$" satisfies the following three conditions: (1) If $b$ and $b'$ are events in the same process, and $b$ comes before $b'$, then $b \rightarrow b'$. (2) If $b$ is the sending of a message by one process and $b'$ is the receipt of the same message by another process, then $b \rightarrow b'$. (3) If $b \rightarrow b'$ and $b' \rightarrow b''$ then $b \rightarrow b''$. Two distinct events $b$ and $b'$ are said to be concurrent if $b \nrightarrow b'$ and $b' \nrightarrow b$. The happens before relation can be viewed as a causality effect: that $b \rightarrow b'$ implies event $b$ may causally affect event $b'$. Two events are concurrent if neither can causally affect the other. Lamport introduces logical clocks which is a way of assigning a number to an event. A clock $C_i$ for each process $P_i$ is a function which assigns a number $C_i(b)$ to any event $b \in P_i$. The entire system of blocks is represented by the function $C$ which assigns to any event $b$ the number $C(b)$, where $C(b) = C_j(b)$ if $b$ is an event in process $P_j$. The Clock Condition states that for any events $b$, $b'$: if $b \rightarrow b'$ then $C(b)$ $<$ $C(b')$. To satisfies the Clock Condition, the clocks must satisfy two conditions. First, each process $P_i$ increments $C_i$ between any two successive events. Second, we require that each message $m$ contains a timestamp $T_m$, which equals the time at which the message was sent. Upon receiving a message timestamped $T_m$, a process must advance its clock to be later than $T_m$. Given any arbitrary total ordering $\prec$ of the processes, the total ordering $\Rightarrow$ is defined as follows: if $a$ is an event in process $P_i$ and $b$ is an event in process $P_j$, then $b \Rightarrow b'$ if and only if either (i) $C_i(b) < C_j(b')$ or (ii) $C(b)= Cj(b')$ and $P_i \prec P_j$. The Clock Condition implies that if $b \rightarrow b'$ then $b \Rightarrow b'$. \subsection{Concurrent common knowledge}\label{se:cck} In the Concurrent common knowledge (CCK) paper ~\cite{cck92}, they define a model to reason about the concurrent common knowledge in asynchronous, distributed systems. A system is composed of a set of processes that can communicate only by sending messages along a fixed set of channels. The network is not necessarily completely connected. The system is asynchronous in the sense that there is no global clock in the system, the relative speeds of processes are independent, and the delivery time of messages is finite but unbounded. A local state of a process is denoted by $s^j_i$. Actions are state transformers; an action is a function from local states to local states. An action can be either: a send(m) action where m is a message, a receive(m) action, and an internal action. A local history, $h_i$, of process $i$, is a (possibly infinite) sequence of alternating local states—beginning with a distinguished initial state—and actions. We write such a sequence as follows: $h_i = s_i^0 \xrightarrow{ \alpha_i^1 } s_i^1 \xrightarrow{\alpha_i^2} s_i^2 \xrightarrow{\alpha_i^3} ...$ The notation of $s^j_i$ ($\alpha^j_i$) refers to the $j$-th state (action) in process $i$'s local history An event is a tuple $\langle s , \alpha, s' \rangle$ consisting of a state, an action, and a state. The $j$th event in process $i$'s history is $e^j_i$ denoting $\langle s^{j-1}_i , \alpha^j_i, s^j_{i} \rangle$. An asynchronous system consists of the following sets. \begin{enumerate} \item A set $P$ = \{1,...,$N$\} of process identifiers, where $N$ is the total number of processes in the system. \item $A$ set $C$ $\subseteq$ \{($i$,$j$) s.t. $i,j \in P$\} of channels. The occurrence of $(i,j)$ in $C$ indicates that process $i$ can send messages to process $j$. \item A set $H_i$ of possible local histories for each process $i$ in $P$. \item A set $A$ of asynchronous runs. Each asynchronous run is a vector of local histories, one per process, indexed by process identifiers. Thus, we use the notation $a = \langle h_1,h_2,h_3,...h_N \rangle$. Constraints on the set $A$ are described throughout this section. \item A set $M$ of messages. A message is a triple $\langle i,j,B \rangle$ where $i \in P$ is the sender of the message, $j \in P$ is the message recipient, and $B$ is the body of the message. $B$ can be either a special value (e.g. a tag to denote a special-purpose message), or some proposition about the run (e.g. “$i$ has reset variable $X$ to zero”), or both. We assume, for ease of exposition only, that messages are unique. \end{enumerate} The set of channels $C$ and our assumptions about their behavior induce two constraints on the runs in $A$. First, $i$ cannot send a message to $j$ unless $(i,j)$ is a channel. Second, if the reception of a message $m$ is in the run, then the sending of $m$ must also be in that run; this implies that the network cannot introduce spurious messages or alter messages. The CCK model of an asynchronous system does not mention time. Events are ordered based on Lamport's happens-before relation. They use Lamport’s theory to describe global states of an asynchronous system. A global state of run $a$ is an $n$-vector of prefixes of local histories of $a$, one prefix per process. The happens-before relation can be used to define a consistent global state, often termed a consistent cut, as follows. \begin{defn}[Consistent cut] A consistent cut of a run is any global state such that if $e^x_i \rightarrow e^y_j$ and $e^y_j$ is in the global state, then $e^x_i$ is also in the global state. \end{defn} A message chain of an asynchronous run is a sequence of messages $m_1$, $m_2$, $m_3$, $\dots$, such that, for all $i$, $receive(m_i)$ $\rightarrow$ $send(m_{i+1})$. Consequently, $send(m_1)$ $\rightarrow$ $receive(m_1)$ $\rightarrow$ $send(m_2)$ $\rightarrow$ $receive(m_2)$ $\rightarrow$ $send(m_3)$ $\dots$. \subsection{Consensus algorithms} In a consensus algorithm, all participant nodes of a distributed network share transactions and agree integrity of the shared transactions~\cite{Lamport82}. It is equivalent to the proof of Byzantine fault tolerance in distributed database systems~\cite{randomized03, paxos01}. The Practical Byzantine Fault Tolerance (pBFT) allows all nodes to successfully reach an agreement for a block when a Byzantine node exists \cite{Castro99}. There are numerous consensus algorithms being proposed~\cite{algorand16, algorand17}. Proof of Work (PoW) requires large amounts of computational work to generate the blocks~\cite{bitcoin08}. Proof of Stake (PoS)~\cite{ppcoin12,dpos14} use participants' stakes and delegated participants' stake to generate the blocks respectively. Alternative schemes are proposed to improve algorithms using directed acyclic graphs (DAG)~\cite{dagcoin15}. These DAG-based approaches utilize the graph structures to decide consensus; blocks and connections are considered as vertices and edges, respectively. \subsection{DAG-based Approaches} IOTA~\cite{tangle17} published a DAG-based technology called Tangle. The Tips concept was used to address scalability issues with the limitations of the Internet of Things. Also, a nonce by using weight level was composed to achieve the transaction consensus by setting the user’s difficulty. To solve the double spending problem and parasite attack, they used the Markov Chain Monte Carlo (MCMC) tip selection algorithm, which randomly selects the tips based on the size of the accumulated transaction weights. However, if a transaction conflicts with another, there is still a need to examine all past transaction history to find the conflict. Byteball~\cite{byteball16} uses an internal pay system called bytes. This is used to pay for adding data to the distributed database. Each storage unit is linked to each other that includes one or more hashes of earlier storage units. In particular, the consensus ordering is composed by selecting a single Main Chain, which is determined as a root consisting of the most roots. A majority of roots detects the double-spend attempts through consensus time of Main Chain. The fee is charged according to the size of the bytes, and the list of all units should be searched and updated in the process of determining the roots. RaiBlocks~\cite{raiblock17} has been developed to improve high fees and slow transaction processing. It is a process of obtaining consensus through the balance weighted vote on conflicting transactions. Each node participating in the network becomes the principal and manages its data history locally. However, since RaiBlocks generate transactions in a similar way to an anti-spam tool of PoW, all nodes must communicate to create transactions. In terms of scalability, there is a need for steps to verify the entire history of transactions when a new node is added. Hashgraph~\cite{hashgraph16} is an asynchronous DAG-based distributed ledger. Each node is connected by its own ancestor and randomly communicates known events through a gossip protocol. At this time, any famous node can be determined by the \textit{see} and \text{strong see} relationship at each round to reach consensus quickly. They state that if more than 2/3 of the nodes reach consensus for an event, it will be assigned consensus position. Conflux~\cite{conflux18} is a DAG-based Nakamoto consensus protocol. Conflux is a fast, scalable and decentralized block chain system that optimistically processes concurrent blocks without discarding any as forks. The Conflux protocol achieves consensus on a total order of the blocks. The total order of the transactions is decided by all participants of the network. Conflux can tolerate up to half of the network as malicious while the BFT-based approaches can only tolerate up to one third of malicious nodes. Parsec~\cite{PARSEC18} proposes an algorithm for reaching consensus in the presence of Byzantine faults in a randomly synchronous network. Like Hashgraph~\cite{hashgraph16}, it has no leaders, no round robin, no proof-of-work and reaches eventual consensus with probability one. Unlike Hashgraph, it can provide high speed even in the presence of faults. Parsec algorithm reaches BFT consensus with very weak synchrony assumptions. Messages are delivered with random delays, such that the average delay is finite. It allows up to one-third Byzantine (arbitrary) failures. Phantom~\cite{PHANTOM08} is a PoW based protocol for a permissionless ledger that generalizes Nakamoto’s blockchain to a DAG of blocks. PHANTOM includes a parameter $k$ to adjust the tolerance level of the protocol to blocks that were created concurrently, which can be set to accommodate higher throughput. It thus avoids the security-scalability tradeoff as in Satoshi’s protocol. PHANTOM uses a greedy algorithm on the DAG to distinguish between blocks by honest nodes and those by non-cooperating nodes. This distinction gives PHANTOM a robust total order of the blocks that is eventually agreed upon by all honest nodes. Similar to PHANTOM, the GHOSTDAG protocol selects a $k$-cluster, which induces a colouring of the blocks as Blues (blocks in the selected cluster) and Reds (blocks outside the cluster). However, instead of searching for the largest $k$-cluster, GHOSTDAG finds a cluster using a greedy algorithm. Spectre~\cite{sompolinsky2016spectre} is a new protocol for the consensus core of cryptocurrencies. SPECTRE, which is PoW-based protocol, relies on a data structure that generalizes Nakamoto’s blockchain into a DAG. It remains secure from attackers with up to 50\% of the computational power even under high throughput and fast confirmation times. Sprectre protocol satisfies weaker properties than classic consensus requires. In SPECTRE, the order between any two transactions can be decided from transactions performed by honest users. This is different from the conventional paradigm in which the order must be decided by all non-corrupt nodes. Blockmania~\cite{Blockmania18} is a mechanism to achieve consensus with several advantages over the more traditional pBFT protocol and its variants. In Blockmania nodes in a quorum only emit blocks linking to other blocks, irrespective of the consensus state machine. The resulting directed acyclic graph of blocks (block DAG) is later interpreted to ensure consensus safety, finality and liveliness. The resulting system has communication complexity $O(N^2)$ even in the worse case, and low constant factors — as compared to $O(N^4)$ for pBFT. \section{Generic framework of Lachesis Protocols}\label{se:protocol} This section describes the key concepts of our new family of Lachesis protocols. \subsection{OPERA chain} The core idea of Lachesis protocols is to use a DAG-based structure, called OPERA chain for our consensus algorithm. In Lachesis protocol, a (participant) node is a server (machine) of the distributed system. Each node can create messages, send messages to and receive messages from other nodes. The communication between nodes is asynchronous. Lachesis Protocol consists of event blocks including user information and edges between event blocks. In Lachesis Protocol, event blocks are created by a node after the node communicates information of OPERA chain with another node. The OPERA chain is comprised of event blocks as vertices and block communication as edges. Let $n$ be the number of participant nodes. For consensus, the algorithm examines whether an event block is \emph{shared} with $2n/3$ nodes, where $n$ is the number of all nodes. Sharing an event block with $2n/3$ nodes means that more than two-thirds of all nodes in the OPERA chain knows the event block. \subsection{Main-chain} For faster consensus, we introduce the \emph{Main-chain}, which is a special sub-graph of the OPERA chain. To improve path search, we propose to use a local hash table structure as a cache that is used to quickly determine the closest root to an event block. In the OPERA chain, an event block is called a \emph{root} if the event block is linked to more than two-thirds of previous roots. A leaf vertex is also a root itself. With root event blocks, we can keep track of ``vital'' blocks that $2n/3$ of the network agree on. The Main chain --- a core subgraph of OPERA chain, plays the important role for ordering the event blocks. The Main chain stores shortcuts to connect between the Atropos. After the topological ordering is computed over all event blocks through Lachesis protocol, Atropos blocks are determined and form the Main chain. Figure~\ref{fig:mainchain} shows an example of Main chain composed of Atropos event blocks. In particular, the Main chain consists of Atropos blocks those are derived from root blocks and so are agreed by $2n/3$ of the network nodes. Thus, this guarantees that at least $2n/3$ of nodes have come to consensus on this Main chain. \begin{figure} [H] \centering \includegraphics[height=8cm, width=1.0\columnwidth]{mainchain} \caption{An Example of Main-chain} \label{fig:mainchain} \end{figure} Each participant node has a copy of the Main chain and can search consensus position of its own event blocks. Each event block can compute its own consensus position by checking the nearest Atropos event block. Assigning and searching consensus position are introduced in the consensus time selection section. The Main chain provides quick access to the previous transaction history to efficiently process new coming event blocks. From Main chain, information about unknown participants or attackers can be easily viewed. The Main chain can be used efficiently in transaction information management by providing quick access to new event blocks that have been agreed on by the majority of nodes. In short, the Main-chain gives the following advantages: - All event blocks or nodes do not need to store all information. It is efficient for data management. - Access to previous information is efficient and fast. Based on these advantages, OPERA chain can respond strongly to efficient transaction treatment and attacks through its Main-chain. \begin{algorithm} \caption{Main Procedure}\label{al:main} \begin{algorithmic}[1] \Procedure{Main Procedure}{} \State\hskip-\ALG@thistlm \emph{loop}: \State A, B = $k$-node Selection algorithm() \State Request sync to node A and B \State Sync all known events by Lachesis protocol \State Event block creation \State (optional) Broadcast out the message \State Root selection \State Clotho selection \State Atropos time consensus \State\hskip-\ALG@thistlm \emph{loop}: \State Request sync from a node \State Sync all known events by Lachesis protocol \EndProcedure \end{algorithmic} \end{algorithm} \subsection{Lachesis Consensus Algorithm (LCA)} Our Lachesis algorithm (LCA) is presented. LCA is one of the consensus algorithms for solving the byzantine agreement problem. In LCA, the OPERA chain uses root, Clotho and Atropos blocks to find consensus time for event blocks. Algorithm~\ref{al:main} shows the pseudo algorithm of a OPERA chain. The algorithm consists of two parts and runs them in parallel. - In one part, each node requests synchronization and creates an event block. In line 3, a node runs the Node Selection Algorithm. The Node Selection Algorithm returns the $k$ IDs of other nodes to communicate with. In line 4 and 5, the node synchronizes the OPERA chain with other nodes. Line 6 runs the Event block creation, at which step the node creates an event block and checks whether it is root. Then the node broadcasts the created event block to other nodes in line 7. The step in this line is optional. In line 8 and 9, Clotho selection and Atropos time consensus algorithms are invoked. The algorithms determinte whether the specified root can be a Clotho, assign the consensus time, and then confirm the Atropos. - The second part is to respond to synchronization requests. In line 10 and 11, the node receives a synchronization request and then sends its response about the OPERA chain. \subsection{Node Structure} This section gives an overview of node structure in Lachesis. Each node has a signature stamp, height vector, in-degree vector, flag table, root hash list, and Main-chain. Signature stamp is the data structure for storing the hash value that indicates the most recently created event block by the node. We call the most recently created event block the top event block. The flag table is a n dimensional vector. If an event block $e$ created by $i^{th}$ node can reach $j^{th}$ root, then the $j^{th}$ value in the flag table of $e$ becomes 1 (otherwise 0). Each node only maintains the flag table of the top event block. \begin{figure} \centering \includegraphics[width=.4\textwidth]{node_structure} \caption{An Example of Node Structure} \label{fig:node} \end{figure} Figure~\ref{fig:node} shows an example of the node structure component of a node $A$. In the figure, the $signature_A$ stores the hash value of the top event block of $A$. Each value in the height vector is the number of event blocks created by other nodes respectively. The value of $h_i$ is the number of event blocks created by the $i^{th}$ node. Each value in the in-degree vector is the number of edges from other event blocks created by other nodes to the top event block. The root hash list is the data structure storing the hash values of the root. The Main-chain is a data structure storing hash values of the Atropos blocks. The Main-chain is used to find event blocks with complete consensus. The root, Clotho and Atropos selection algorithm are introduced in Section~\ref{se:lca}. \subsection{Event block creation} In Lachesis protocol, every node can create an event block. Each event block refers to other event blocks. Reference means that the event block stores the hash values of the other event blocks. In a Lachesis protocol, an event block refers to $k$-neighbor event blocks under the conditions as follows: \begin{enumerate} \item The reference event blocks are the top event blocks. \item One reference should be made to a self-parent. \item The own top event block refers to at least $k$-neighbor of other nodes. \end{enumerate} \subsection{Topological ordering of events using Lamport timestamps} Every node has a physical clock and it needs physical time to create an even block. However, for consensus, Lachesis protocols relies on a logical clock for each node. For the purpose, we use \textit{"Lamport timestamps"} \cite{lamport1978time} to determine the time ordering between event blocks in a asynchronous distributed system. \\ The Lamport timestamps algorithm is as follows: \begin{enumerate} \item Each node increments its count value before creating an event block. \item When sending a message include its count value, receiver should consider which sender’s message is received and increments its count value. \item If current counter is less than or equal to the received count value from another node, then the count value of the recipient is updated. \item If current counter is greater than the received count value from another node, then the current count value is updated. \end{enumerate} \begin{figure}\centering \includegraphics[width=0.9\columnwidth]{Lamport_timestamps.pdf} \caption{An example of Lamport timestamps} \label{fig:Lamport} \end{figure} We use the Lamport's algorithm to enforce a topological ordering of event blocks and uses it in Atropos selection algorithm. Since an event block is created based on logical time, the sequence between each event blocks is immediately determined. Because the Lamport timestamps algorithm gives a partial order of all events, the whole time ordering process can be used for Byzantine fault tolerance. \subsection{Topological consensus ordering} The sequential order of each event block is an important aspect for Byzantine fault tolerance. In order to determine the pre-and-post sequence between all event blocks, we use Atropos consensus time, Lamport timestamp algorithm and the hash value of the event block. First, when each node creates event blocks, they have a logical timestamp based on Lamport timestamp. This means that they have a partial ordering between the relevant event blocks. Each Clotho has consensus time to the Atropos. This consensus time is computed based on the logical time nominated from other nodes at the time of the 2n/3 agreement. In the LCA, each event block is based on the following three rules to reach an agreement: \begin{enumerate} \item If there are more than one Atropos with different times on the same frame, the event block with smaller consensus time has higher priority. \item If there are more than one Atropos having any of the same consensus time on the same frame, determine the order based on the own logical time from Lamport timestamp. \item When there are more than one Atropos having the same consensus time, if the local logical time is same, a smaller hash value is given priority through hash function. \end{enumerate} \begin{figure}[h] \centering \includegraphics[height=8cm, width=1.0\columnwidth]{topological_consensus_ordering.pdf} \caption{An example of topological consensus ordering} \label{fig:topological consensus ordering} \end{figure} Figure~\ref{fig:topological consensus ordering} depicts an example of topological consensus ordering. \begin{figure} \centering \includegraphics[height=8cm, width=1.0\columnwidth]{sequence_operachain} \caption{An Example of time ordering of event blocks in OPERA chain} \label{fig:sequence of operachain} \end{figure} Figure~\ref{fig:sequence of operachain} shows the part of OPERA chain in which the final consensus order is determined based on these 3 rules. The number represented by each event block is a logical time based on Lamport timestamp. Final topological consensus order containing the event blocks based on agreement for the apropos. Based on each Atropos, they will have different colors depending on their range. \subsection{Peer selection algorithm} In order to create an event block, a node needs to select $k$ other nodes. Lachesis protocols does not depend on how peer nodes are selected. One simple approach can use a random selection from the pool of $n$ nodes. The other approach is to define some criteria or cost function to select other peers of a node. Within distributed system, a node can select other nodes with low communication costs, low network latency, high bandwidth and high successful transaction throughputs. \section{Lachesis Consensus Protocol $L_0$}\label{se:lca} This section presents our new Lachesis Consensus Protocol $L_0$, which is a specific example of the Lachesis class. We describe the main ideas and algorithms used in the protocol. \subsection{Root Selection} All nodes can create event blocks and an event block can be a root when satisfying specific conditions. Not all event blocks can be roots. First, the first created event blocks are themselves roots. These leaf event blocks form the first root set $R_{S1}$. If there are total $n$ nodes and these nodes create the event blocks, then the cardinality of the first root set $|R_{S1}|$ is $n$. Second, if an event block $e$ can reach at least 2n/3 roots, then $e$ is called a root. This event $e$ does not belong to $R_{S1}$, but the next root set $R_{S2}$. Thus, excluding the first root set, the range of cardinality of root set $R_{Sk}$ is $2n/3 < |R_{Sk}| \leq n$. The event blocks including $R_{Sk}$ before $R_{Sk+1}$ is in the frame $f_k$. The roots in $R_{Sk+1}$ does not belong to the frame $f_k$. Those are included in the frame $f_k+1$ when a root belonging to $R_{Sk+2}$ occurs. We introduce the use of a flag table to quickly determine whether a new event block becomes a root or not. Each node maintains a flag table of the top event block. Every event block that is newly created is assigned $k$ hashes for its $k$ parent event blocks. We apply an $OR$ operation on the flag tables of the parent event blocks. Figure~\ref{fig:ex_ft} shows an example of how to use flag tables to determine a root. In this example, $r_1$ is the most recently created event block. We apply an $OR$ operation on the flag tables of $r_1$'s $k$ parent event blocks. The result is the flag table of $r_1$. If $r_1$'s flag table has more than $2n/3$ set bits, $r_1$ is a root. In this example, the number of set bits is 4, which is greater than $2n/3$ ($n$=5). Thus, $r_1$ becomes root. The root selection algorithm is as follows: \begin{figure} [t] \centering \includegraphics[height=8cm, width=1.0\columnwidth]{flagtable} \caption{An Example of Flag Table Calculation} \label{fig:ex_ft} \end{figure} \begin{enumerate} \item The first event blocks are considered as root. \item When a new event block is added in the OPERA chain, we check whether the event block is a root by applying $OR$ operation on the flag tables connected to the new event block. If the sum of the flag table for the new event block is more than 2n/3, the new event block becomes a root. \item When a new root appears on the OPERA chain, nodes update their root hash list. If one of new event blocks becomes a root, all nodes that share the new event block add the hash value of the event block to their root hash list. \item The new root set is created if the cardinality of previous root set $R_{Sp}$ is more than 2n/3 and the new event block can reach 2n/3 root in $R_{S_p}$. \item When the new root set $R_{S_{k+1}}$ is created, the event blocks from previous root set $R_{S_k}$ to before $R_{S_{k+1}}$ belong to the frame $f_k$. \end{enumerate} \subsection{Clotho Selection} A Clotho is a root that satisfies the Clotho creation conditions. Clotho creation conditions are that more than 2n/3 nodes know the root and a root knows this information. Figure~\ref{fig:Clotho} shows an example of Clotho. Circles with a label $r_i$ (or $c$) represents a root (or Clotho) event block. If there are three other sets of root and there exists one root after the recent clotho set, then one of the roots in the first root set become Clotho. \begin{figure} [t] \centering \includegraphics[height=8cm, width=1.0\columnwidth]{Clotho_example} \caption{An Example of Clotho} \label{fig:Clotho} \end{figure} Clotho selection algorithm checks whether root event blocks in the root hash list satisfy the Clotho condition. If a root satisfies Clotho condition, the root becomes Clotho and makes a candidate time for Atropos. After the root is concluded as a Clotho, Atropos consensus time selection algorithm is triggered. For a root $r$, we denote $frame(i, r)$ to be the root $r$ in $i$-th frame. For example, $frame(1, r)$ is the first root belong to the frame $f_1$. Algorithm~\ref{al:acs} shows the pseudo code for Clotho selection. The algorithm takes a root $r$ as input. Line 4 and 5 set $c.is\_clotho$ and $c.yes$ to $nil$ and 0 respectively. Line 6-8 checks whether any root $c'$ in $frame(i-3,r)$ shares $c$ where $i$ is the current frame. In line 9-10, if number of roots in $frame(i-2,r)$ which shares $c$ is more than $2n/3$, the root $c$ is set as a Clotho. The time complexity of Algorithm 3 is $O(n^{2})$, where $n$ is the number of nodes. \begin{algorithm} \caption{Clotho Selection}\label{al:acs} \begin{algorithmic}[1] \Procedure{Clotho Selection}{} \State \textbf{Input}: a root $r$ \For{$c$ $\in$ $frame(i-3, r)$} \State$c.is\_clotho$ $\leftarrow$ $nil$ \State$c.yes$ $\leftarrow$ 0 \For{$c'$ $\in$ $frame(i-2, r)$} \If{$c'$ share $c$} \State c.yes $\leftarrow$ c.yes + 1 \EndIf \EndFor \If{$c.yes > 2n/3$} \State $c.is\_clotho$ $\leftarrow$ $yes$ \EndIf \EndFor \EndProcedure \end{algorithmic} \end{algorithm} \subsection{Atropos Selection} Atropos selection algorithm is the process in which the candidate time generated from Clotho selection is shared with other nodes, and each root re-selects candidate time repeatedly until all nodes have same candidate time for a Clotho. After a Clotho is nominated, each node then computes candidate time of the Clotho. If there are more than two-thirds of the nodes that compute the same value for candidate time, that time value is recorded. Otherwise, each node reselects candidate time from some candidate time which the node collects. By the reselection process, each node reaches time consensus for candidate time of Clotho as OPERA chain grows. The candidate time reaching the consensus is called Atropos consensus time. After Atropos consensus time is computed, Clotho is nominated to Atropos and each node stores the hash value of Atropos and Atropos consensus time in Main-Chain. The Main-chain is used for time order between event blocks. The proof of Atropos consensus time selection is shown in the section~\ref{se:proof}. \begin{algorithm}[H] \caption{Atropos Consensus Time Selection}\label{al:atc} \begin{algorithmic}[1] \Procedure{Atropos Consensus Time Selection}{} \State \textbf{Input}: $c.Clotho$ in frame $f_i$ \State$c.consensus\_time$ $\leftarrow$ $nil$ \State$m$ $\leftarrow$ the index of the last frame $f_m$ \For{d from 3 to (m-i)} \State $R$ $\leftarrow$ be the Root set $R_{S_{i+d}}$ in frame $f_{i+d}$ \For{$r$ $\in$ $R$} \If{d is 3} \If{$r$ confirms $c$ as Clotho} \State $r.time(c)$ $\leftarrow$ $r.lamport\_time$ \EndIf \ElsIf{d $>$ 3} \State s $\leftarrow$ the set of Root in $f_{j-1}$ that $r$ can share \State t $\leftarrow$ RESELECTION(s, $c$) \State k $\leftarrow$ the number of root having $t$ in $s$ \If{d mod $h$ $>$ 0} \If{$k$ $>$ 2n/3} \State $c.consensus\_time$ $\leftarrow$ $t$ \State $r.time(c)$ $\leftarrow$ $t$ \Else \State $r.time(c)$ $\leftarrow$ $t$ \EndIf \Else \State $r.time(c)$ $\leftarrow$ the minimum value in $s$ \EndIf \EndIf \EndFor \EndFor \EndProcedure \end{algorithmic} \end{algorithm} Algorithm~\ref{al:atc} and~\ref{al:resel} show pseudo code of Atropos consensus time selection and Consensus time reselection. In Algorithm~\ref{al:atc}, at line 6, $d$ saves the deference of relationship between root set of $c$ and $w$. Thus, line 8 means that $w$ is one of the elements in root set of the frame $f_{i+3}$, where the frame $f_i$ includes $c$. Line 10, each root in the frame $f_j$ selects own Lamport timestamp as candidate time of $c$ when they confirm root $c$ as Cltoho. In line 12, 13, and 14, $s$, $t$, and $k$ save the set of root that $w$ can share $c$, the result of $RESELECTION$ function, and the number of root in $s$ having $t$. Line 15 is checking whether there is a difference as much as $h$ between $i$ and $j$ where $h$ is a constant value for minimum selection frame. Line 16-20 is checking whether more than two-thirds of root in the frame $f_{j-1}$ nominate the same candidate time. If two-thirds of root in the frame $f_{j-1}$ nominate the same candidate time, the root $c$ is assigned consensus time as $t$. Line 22 is minimum selection frame. In minimum selection frame, minimum value of candidate time is selected to reach byzantine agreement. Algorithm~\ref{al:resel} operates in the middle of Algorithm~\ref{al:atc}. In Algorithm~\ref{al:resel}, input is a root set $W$ and output is a reselected candidate time. Line 4-5 computes the frequencies of each candidate time from all the roots in $W$. In line 6-11, a candidate time which is smallest time that is the most nomitated. The time complexity of Algorithm~\ref{al:resel} is $O(n)$ where $n$ is the number of nodes. Since Algorithm~\ref{al:atc} includes Algorithm~\ref{al:resel}, the time complexity of Algorithm~\ref{al:atc} is $O(n^2)$ where $n$ is the number of nodes. \begin{algorithm} [H] \caption{Consensus Time Reselection}\label{al:resel} \begin{algorithmic}[1] \Function{Reselection}{} \funclabel{alg:a} \State \textbf{Input}: Root set $R$, and Clotho $c$ \State \textbf{Output}: candidate time $t$ \State $\tau$ $\leftarrow$ set of all $t_i = r.time(c)$ for all $r$ in $R$ \State $D$ $\leftarrow$ set of tuples $(t_i, c_i)$ computed from $\tau$, where $c_i= count(t_i)$ \State $max\_count$ $\leftarrow$ $max(c_i)$ \State $t$ $\leftarrow$ $infinite$ \For{tuple $(t_i, c_i)$ $\in$ $D$} \If{$max\_count$ $==$ $c_i$ $\&\&$ $t_i$ $<$ $t$} \State $t$ $\leftarrow$ $t_i$ \EndIf \EndFor \State \textbf{return} $t$ \EndFunction \end{algorithmic} \end{algorithm} In the Atropos Consensus Time Selection algorithm, nodes reach consensus agreement about candidate time of a Clotho without additional communication (i.e., exchanging candidate time) with each other. Each node communicates with each other through the Lachesis protocol, the OPERA chain of all nodes grows up into same shape. This allows each node to know the candidate time of other nodes based on its OPERA chain and reach a consensus agreement. The proof that the agreement based on OPERA chain become agreement in action is shown in the section~\ref{se:proof}.\\ \subsection{Peer selection algorithm via Cost function} We define three versions of the Cost Function ($C_F$). Version one is focused around updated information share and is discussed below. The other two versions are focused on root creation and consensus facilitation, these will be discussed in a following paper. We define a Cost Function ($C_F$) for preventing the creation of lazy nodes. The lazy node is a node that has a lower work portion in the OPERA chain. When a node creates an event block, the node selects other nodes with low values outputs from the cost function and refers to the top event blocks of the reference nodes. An equation~(\ref{eq1}) of $C_F$ is as follows, \begin{equation}\label{eq1} C_{F} =I/H \end{equation} where $I$ and $H$ denote values of in-degree vector and height vector respectively. If the number of nodes with the lowest $C_F$ is more than $k$, one of the nodes is selected at random. The reason for selecting high $H$ is that we can expect a high possibility to create a root because the high $H$ indicates that the communication frequency of the node had more opportunities than others with low $H$. Otherwise, the nodes that have high $C_F$ (the case of $I$ $>$ $H$) have generated fewer event blocks than the nodes that have low $C_F$. Then we can judge that those kind of nodes are lazy. If we can detect whether a node is lazy based on cost function, we can change the lazy nodes to other participants or remove them. \begin{figure}[htp] \centering \includegraphics[height=6cm]{fig_cfEx1} \caption{An Example of Cost Function 1} \label{fig:cfEx1} \end{figure} Figure~\ref{fig:cfEx1} shows an example of the node selection based on the cost function after the creation of leaf events by all nodes. In this example, there are five nodes and each node created leaf events. All nodes know other leaf events. Node $A$ creates an event block $v_1$ and $A$ calculates the cost functions. Step 2 in Figure~\ref{fig:cfEx1} shows the results of cost functions based on the height and in-degree vectors of node $A$. In the initial step, each value in the vectors are same because all nodes have only leaf events. Node $A$ randomly selects $k$ nodes and connects $v_1$ to the leaf events of selected nodes. In this example, we set $k$=3 and assume that node $A$ selects node $B$ and $C$. \begin{figure} \centering \includegraphics[height=7cm]{fig_cfEx2} \caption{An Example of Cost Function 2} \label{fig:cfEx2} \end{figure} Figure~\ref{fig:cfEx2} shows an example of the node selection after a few steps of the simulation in Figure~\ref{fig:cfEx1}. In Figure~\ref{fig:cfEx2}, the recent event block is $v_5$ created by node $A$. Node $A$ calculates the cost function and selects the other two nodes that have the lowest results of the cost function. In this example, node $B$ has 0.5 as the result and other nodes have the same values. Because of this, node $A$ first selects node $B$ and randomly selects other nodes among nodes $C$, $D$, and $E$. The height of node $D$ in the current OPERA chain of the example is 2 (leaf event and event block $v_4$). On the other hand, the height of node $D$ in node structure of $A$ is 1. Node $A$ is still not aware of the presence of the event block $v_4$. It means that there is no path from the event blocks created by node $A$ to the event block $v_4$. Thus, node $A$ has 1 as the height of node $D$. Algorithm~\ref{al:ns} shows the selecting algorithm for selecting reference nodes. The algorithm operates for each node to select a communication partner from other nodes. Line 4 and 5 set min\_cost and $S_{ref}$ to initial state. Line 7 calculates the cost function $c_f$ for each node. In line 8, 9, and 10, we find the minimum value of the cost function and set min\_cost and $S_{ref}$ to $c_f$ and the ID of each node respectively. Line 11 and 12 append the ID of each node to $S_{ref}$ if min\_cost equals $c_f$. Finally, line 13 selects randomly $k$ node IDs from $S_{ref}$ as communication partners. The time complexity of Algorithm 2 is $O(n)$, where $n$ is the number of nodes. \begin{algorithm} \caption{$k$-neighbor Node Selection}\label{al:ns} \begin{algorithmic}[1] \Procedure{$k$-node Selection}{} \State \textbf{Input:} Height Vector $H$, In-degree Vector $I$ \State \textbf{Output:} reference node $ref$ \State min\_cost $\leftarrow$ $INF$ \State $s_{ref}$ $\leftarrow$ None \For{$k \in Node\_Set$} \State $c_f$ $\leftarrow$ $\frac{I_k}{H_k}$ \If {min\_cost $>$ $c_f$} \State min\_cost $\leftarrow$ $c_f$ \State $s_{ref}$ $\leftarrow$ {k} \ElsIf {min\_cost $equa$l $c_f$} \State $s_{ref}$ $\leftarrow$ $s_{ref}$ $\cup$ $k$ \EndIf \EndFor \State $ref$ $\leftarrow$ random select in $s_{ref}$ \EndProcedure \end{algorithmic} \end{algorithm} After the reference node is selected, each node communicates and shares information that is all event blocks known by them. A node creates an event block by referring to the top event block of the reference node. The Lachesis protocol works and communicates asynchronously. This allows a node to create an event block asynchronously even when another node creates an event block. The communication between nodes does not allow simultaneous communication with the same node. \begin{figure} \centering \includegraphics[height=5cm]{fig_nsEx.pdf} \caption{An Example of Node Selection} \label{fig:nsEx} \end{figure} Figure~\ref{fig:nsEx} shows an example of the node selection in Lachesis protocol. In this example, there are five nodes ($A, B, C, D,$ and $E$) and each node generates the first event blocks, called leaf events. All nodes share other leaf events with each other. In the first step, node $A$ generates new event block $v_1$ (\textit{blue}). Then node $A$ calculates the cost function to connect other nodes. In this initial situation, all nodes have one event block called leaf event, thus the height vector and the in-degree vector in node $A$ has same values. In other words, the heights of each node are 1 and in-degrees are 0. Because of this reason, node $A$ randomly select other two nodes and connect $v_1$ to the top two event blocks by other two nodes. The step 2 shows the situation after connections. In this example, node $A$ select node $B$ and $C$ to connect $v_1$ and the event block $v_1$ is connected to the top event blocks of node $B$ and $C$. Node $A$ only knows the situation of the step 2. After that, in the example, node $B$ generates new event block $v_2$ (\textit{green}) and also calculates the cost function. $B$ randomly select the other two nodes; $A$, and $D$, since $B$ only has information of the leaf events. Node $B$ requests to $A$ and $D$ to connect $e_B$, then nodes $A$ and $D$ send information for their top event blocks to node $B$ as response. The top event block of node $A$ is $v_1$ and node $D$ is the leaf event. The event block $v_2$ is connected to $v_1$ and leaf event from node $D$. Step 4 shows these connections. \section{Discussions }\label{se:discuss} This section presents several discussions on our Lachesis protocol. \subsection{Lamport timestamps} This section discusses a topological order of event blocks in DAG-based Lachesis protocols using Lamport timestamps~\cite{lamport1978time}. Our Lachesis protocols relies on Lamport timestamps to define a topological ordering of event blocks in OPERA chain. The ``happened before" relation, denoted by $\rightarrow$, gives a partial ordering of events from a distributed system of nodes. Given $n$ nodes, they are represented by $n$ processes $P = (P_0, P_1, \dots, P_{n-1})$. For a pair of event blocks $b$ and $b'$, the relation "$\rightarrow$" satisfies: (1) If $b$ and $b'$ are events of process $P_i$, and $b$ comes before $b'$, then $b \rightarrow b'$. (2) If $b$ is the send($m$) by one process and $b'$ is the receive($m$) by another process, then $b \rightarrow b'$. (3) If $b \rightarrow b'$ and $b' \rightarrow b''$ then $b \rightarrow b''$. Two distinct events $b$ and $b'$ are said to be concurrent if $b \nrightarrow b'$ and $b' \nrightarrow b$. For an arbitrary total ordering $\prec$ of the processes, a relation $\Rightarrow$ is defined as follows: if $b$ is an event in process $P_i$ and $b'$ is an event in process $P_j$, then $b \Rightarrow b'$ if and only if either (i) $C_i(a) < C_j(b)$ or (ii) $C(b)= C_j(b')$ and $P_i \prec P_j$. This defines a total ordering, and that the Clock Condition implies that if $a \rightarrow b$ then $a \Rightarrow b$. We use this total ordering in our Lachesis algorithms. By using Lamport timestamps, we do not rely on physical locks to determine a partial ordering of events. \subsection{Semantics of Lachesis protocols} This section discusses the possible usage of concurrent common knowledge, described in Section~\ref{se:cck} to understand DAG-based consensus protocols. Let $G=(V, E)$ denote directed acyclic graph (DAG). $V$ is a set of vertices and $E$ is a set of edges. DAG is a directed graph with no cycle. Namely, in DAG, there is no path that source and destination at the same vertex. A path is a sequence of vertices ($v_1$, $v_2$, ..., $v_\textit{(k-1)}$, $v_k$) that uses no edge more than once. An asynchronous system consists of the following sets. \begin{enumerate} \item A set $P$ = \{1,...,$n$\} of process identifiers, where $n$ is the total number of processes $P_i$ in the system. \item A set $C$ $\subseteq$ \{($i$,$j$) s.t. $i,j \in P$\} of channels. If $(i,j)$ in $C$, it indicates that process $i$ can send messages to process $j$. \item A set $H_i$ of possible local histories for each process $i$ in $P$. \item A set $A$ of asynchronous runs. Each asynchronous run is a vector of local histories, denoted by $a = \langle h_1,h_2,h_3,...h_N \rangle$. Each process has a single run. Histories are indexed by process identifiers. \item A set $M$ of messages. A message is a triple $\langle i,j,B \rangle$ where $i \in P$ is the sender of the message, $j \in $ is the message recipient, and $B$ is the message body. \end{enumerate} In Lachesis protocol, each node selects $k$ other nodes as peers. For certain gossip protocol, nodes may be constrained to gossip with its $k$ peers. In such a case, the set of channels $C$ can be modelled as follows. If node $i$ selects node $j$ as a peer, then $(i,j) \in C$. In general, one can express the history of each node in Lachesis protocol in the same manner as in the CCK paper~\cite{cck92}. Thus, a proof of consensus can be formalized via the consistent cuts. \section{Conclusion}\label{se:con} In order to realize the distributed ledger technology, we have proposed a new family of asynchronous DAG-based consensus protocol, namely $\mathcal{L}$. We introduce the OPERA chain and Main-chain for faster consensus. By using Lamport timestamps, the topological ordering of event blocks in OPERA chain and Main chain is more intuitive and reliable in distributed system. We introduce a flag table at each block to improve root detection. Further, we have presented a specific Lachesis consensus protocol, called $L_0$, as an example of $\mathcal{L}$. The $L_0$ protocol uses a new flag table in each block as a shortcut to check for reachability from an event block to a root along the OPERA chain. The path search is used as a proof of pBFT consensus. In terms of effectiveness, using flag table in $L_0$ protocol is more effective for consensus compared to the path searching approaches. To ensure the distribution of participating nodes, the Lachesis protocol defines a new cost function and an algorithm that efficiently and quickly selects peers. We also propose new algorithms for root selection and Clotho block selection based on the flag table; for Atropos selection by Weight after time consensus ordering. Based on the $L_0$ protocol and the new consensus algorithm, the OPERA chain can protect against malicious attacks such as forks, double spending, parasite chains, and network control. These protections guarantee the safety of OPERA chain. We can also verify existence of Atropos with the OPERA chain. It concludes that the OPERA chain reaches consensus and guarantees liveliness. Finally, the time ordering ensures guarantee by weight value on the flag table. Based on these properties, the LCA provides a fair, transparent, and effective consensus algorithm. \subsection{Future work} There are a number of directions for future work: \begin{itemize} \item With the Lachesis protocols, we are investigating a fast node synchronization algorithm with $k$-neighbor broadcasts. With OPERA chain and $k$ peer selection, it is possible to achieve a faster gossip broadcast. We are interested in comparing performance of different gossip strategies, such as randomized gossip, broadcast gossip and collection tree protocol for distributed averaging in wireless sensor networks. \item We are also investigating the semantics of DAG-based protocols in general and Lachesis protocols in particular. We aim to have a formal proof of pBFT using concurrent common knowledge via consistent cuts. \end{itemize} \newpage \section{Appendix}\label{se:appendix} \subsection{Proof of Lachesis Consensus Algorithm}\label{se:proof} In this section, we provide proof of liveness and safety in OPERA chain and show the Byzantine fault tolerance. To represent the Byzantine fault tolerance, we assume that more than two-thirds of participants are reliable nodes. Based on the assumption, we provide some definitions, lemmas and theorems. Then, we eventually validate the Byzantine fault tolerance. \subsubsection{Preliminaries} Let $G=(V, E)$ denote directed acyclic graph (DAG). $V$ is a set of vertices and $E$ is a set of edges. DAG is a directed graph with no cycle. Namely, in DAG, there is no path that source and destination at the same vertex. A path is a sequence $P$ of vertices ($v_1$, $v_2$, ..., $v_\textit{(k-1)}$, $v_k$) that uses no edge more than once. Suppose that we have a current vertex $v_c$ and current event block $e_c$ respectively. A vertex $v_p$ is parent of $v_c$ if there is a path from $v_c$ to $v_p$ and the length of path is 1. A vertex $v_a$ is ancestor of $v_c$ if there is a path from $v_c$ to $v_a$ and the length of path is more than equal to 1. \subsubsection{Proof of Byzantine Fault Tolerance for Lachesis Consensus Algorithm} \begin{defn}[node] The machine that participates in the OPERA chain and creates event blocks. The total number of nodes is $n$. \end{defn} \begin{defn}[event block] In OPERA chain, we call a vertex an event block. \end{defn} \begin{defn}[self parent] An event block $v_s$ is self parent of an event block $v_c$ if $v_s$ is parent of $v_c$ and both event blocks have same signatures. \end{defn} \begin{defn}[self ancestor] An event block $v_a$ is self ancestor of an event block $v_c$ if $v_a$ is ancestor of $v_c$ and both event blocks have same signatures. \end{defn} \begin{defn}[Happened-Before] An event block $v_x$ Happened-Before an event block $v_y$ if there is a path from $v_x$ to $v_y$. \end{defn} \begin{defn}[Root] The first created event blocks (leaf events) become root or an event block $v$ that can reach more than 2n/3 other roots, becomes a root. \end{defn} \begin{defn}[Root set] All first event blocks (leaf events) are elements of root set $R_1$ ($|R_1|$ = $n$). And the root set $R_k$ is a set of roots such that $r_i$ $\in$ $R_k$ cannot reach more than 2n/3 other roots in $R_k$ $(k > 1)$. \end{defn} \begin{defn}[Frame] Frame $f$ is a natural number that separates Root sets. \end{defn} \begin{defn}[Clotho] A root $r_k$ in the frame $f_{a+3}$ can nominate a root $r_a$ as Clotho if more than 2n/3 roots in the frame $f_{a+1}$ Happened-Before $r_a$ and $r_k$ Happened-Before the roots in the frame $f_{a+1}$. \end{defn} \begin{defn}[Atropos] If the consensus time of Clotho is validated, the Clotho become Atropos. \end{defn} \begin{prop} \label{prop:seen} At least 2n/3 roots in the frame $f_i$ Happened-Before at least 2n/3 roots in the frame $f_{i+1}$. \end{prop} \begin{proof} The number of roots in each root set is more than 2n/3. Since a root in the frame $f_{i+1}$ Happened-Before more than 2n/3 roots in the frame $f_i$, when the cardinalities of the root sets in the frames $f_i$ and $f_{i+1}$ are n and 2n/3 respectively, the number of paths from root set in the frame $f_{i+1}$ to root set in the frame $f_{i}$ is at least (2n/3)$^{2}$. The average and the maximum of the number of paths from root set in the frame $f_{i+1}$ to an root in the frame $f_{i}$ are (4n/9) and (2n/3) respectively. Thus, at least 2n/3 roots in the frame $f_{i}$ Happened-Before at least n/3 root in the frame $f_{i+1}$. \end{proof} \begin{prop} \label{prop:share} If a root in the frame $f_{i}$ Happened-Before from more than n/3 roots in the frame $f_{i+1}$, the root Happened-Before all roots in the frame $f_{i+2}$. \end{prop} \begin{proof} Based on the definition of Root, each root can reach more than 2n/3 other roots in the previous frame. It means that a root in the frame $f_{i+2}$ should have a number of paths more than 2n/3 to roots in the frame $f_{i+1}$. Thus, if a root $r$ in the frame $f_{i}$ Happened-Before more than n/3 roots in the frame $f_{i+1}$, all roots in the frame $f_{i+2}$ have path to the root $r$. \end{proof} \begin{lem}[Sharing] \label{lem:share} If a root $r_a$ in the frame $f_{a+3}$ is created, the root in the frame $f_{a+3}$ knows that more than 2n/3 roots in the frame $f_{a}$ become known by more than 2n/3 nodes. \end{lem} \begin{proof} Based on propositions~\ref{prop:seen} and ~\ref{prop:share}, the root in the frame $f_{a+3}$ knows that more than 2n/3 roots in the frame $f_{a}$ become known by more than 2n/3 nodes. \end{proof} \begin{lem}[Fork] \label{lem:fork} If the pair of event blocks ($x, y$) is a fork, roots happened-before at least one fork in OPERA chain. Therefore, they can know fork before becoming Clotho. \end{lem} \begin{proof} Suppose that a node creates two event blocks ($x, y$) and the event blocks are a fork. To create two Clotho that can reach each event block in the pair, the event blocks should be shared in more than 2n/3 nodes. Therefore, if there exist fork event blocks, the OPERA chain can structurally detect the fork before roots become Clotho. \end{proof} \begin{thm} \label{thm:same} All node grows up into same shape in OPERA chain. \end{thm} \begin{proof} Suppose that each node $A$ and $B$ will have a different shape (or a structure). For any two nodes $A$ and $B$, there is two event blocks $x$ and $y$ which are in both $OPERA(A)$ and $OPERA(B)$. Also, their path between $x$ and $y$ in $OPERA(A)$ is not equal to that in $OPERA(B)$. For any two event blocks, if each node has different paths, we can consider that the difference is fork attacks. Based on Lemma~\ref{lem:fork}, if an attacker forks an event block, the OPERA chain can detect and remove it before the Clotho is generated. It contradicts our assumptions. For this reason, two nodes have consistent OPERA chain. \end{proof} \begin{lem} \label{lem:root} For any root set $R$, all nodes nominate same root into Clotho. \end{lem} \begin{proof} Based on Theorem~\ref{thm:same}, each node nominates a root into Clotho via the flag table. If all nodes have an OPERA chain with same shape, the values in flag table should be equal to each other in OPERA chain. Thus, all nodes nominate the same root into Clotho since the OPERA chain of all nodes has same shape. \end{proof} \begin{lem} \label{lem:resel} In the Reselection algorithm, for any Clotho, a root in OPERA chain selects the same consensus time candidate. \end{lem} \begin{proof} Based on Theorem~\ref{thm:same}, if all nodes have an OPERA chain with the same partial shape, a root in OPERA chain selects the same consensus time candidate by the Reselection algorithm. \end{proof} \begin{thm} \label{thm:ct} Lachesis consensus algorithm guarantees to reach agreement for the consensus time. \end{thm} \begin{proof} For any root set $R$ in the frame $f_{i}$, time consensus algorithm checks whether more than 2n/3 roots in the frame $f_{i-1}$ selects the same value. However, each node selects one of the values collected from the root set in the previous frame by the time consensus algorithm and Reselection process. Based on the Reselection process, the time consensus algorithm can reach agreement. However, there is a possibility that consensus time candidate does not reach agreement~\cite{Fischer85}. To solve this problem, time consensus algorithm includes minimal selection frame per next $h$ frame. In minimal value selection algorithm, each root selects minimum value among values collected from previous root set. Thus, the consensus time reaches consensus by time consensus algorithm. \end{proof} \begin{thm} \label{thm:bft} If the number of reliable nodes is more than $2n/3$, event blocks created by reliable nodes must be assigned to consensus order. \end{thm} \begin{proof} In OPERA chain, since reliable nodes try to create event blocks by communicating with every other nodes continuously, reliable nodes will share the event block $x$ with each other. Based on Proposition~\ref{prop:seen}, if a root $y$ in the frame $f_{i}$ Happened-Before event block $x$ and more than 2n/3 roots in the frame $f_{i+1}$ Happened-Before the root $y$, the root $y$ will be nominated as Clotho and Atropos. Thus, event block $x$ and root $y$ will be assigned consensus time $t$. For an event block, assigning consensus time means that the validated event block is shared by more than 2n/3 nodes. Therefore, malicious node cannot try to attack after the event blocks are assigned consensus time. When the event block $x$ has consensus time $t$, it cannot occur to discover new event blocks with earlier consensus time than $t$. There are two conditions to be assigned consensus time earlier than $t$ for new event blocks. First, a root $r$ in the frame $f_{i}$ should be able to share new event blocks. Second, the more than 2n/3 roots in the frame $f_{i+1}$ should be able to share $r$. Even if the first condition is satisfied by malicious nodes (e.g., parasite chain), the second condition cannot be satisfied since at least 2n/3 roots in the frame $f_{i+1}$ are already created and cannot be changed. Therefore, after an event block is validated, new event blocks should not be participate earlier consensus time to OPERA chain. \end{proof} \subsection{Response to Attacks}\label{se:ra} Like all other decentralized blockchain technologies, OPERA chain will likely be subject to attacks by attackers which aim to gain financial profit to damage the system. Here we describe several possible attack scenarios and how the OPERA chain intends to take preventive measures. \subsubsection{Transaction Flooding} A malicious participant may run a large number of valid transactions from their account under their control with the purpose of overloading the network. In order to prevent such a case, the chain intends to impose a minimal transaction fee. Since there is a transaction fee, the malicious user cannot continue to perform such attacks. Participants who participate in nodes are rewarded, and those who contribute to the ecosystem, such as by running transactions, are continuously rewarded. Such rewards are expected to be adequate in running transactions for appropriate purposes. However, since it would require tremendous cost to perform abnormal attacks, it would be difficult for a malicious attacker to create transaction flooding. \subsubsection{Parasite chain attack} In a DAG-based protocol, a parasite chain can be made with a malicious purpose, attempting connection by making it look like a legitimate event block. When the Main Chain is created, verification for each event block is performed. In the verification process, any event block that is not connected to the Main Chain is deemed to be invalid and is ignored, as in the case of double spending. We suppose that less than one-third of nodes are malicious. The malicious nodes create a parasite chain. By the root definition, roots are nominated by 2n/3 node awareness. A parasite chain is only shared with malicious nodes that are less than one-third of participating nodes. A parasite chain is unable to generate roots and have a shared consensus time. \subsubsection{Double Spending} A double spend attack is when a malicious entity attempts to spend their funds twice. Entity $A$ has 10 tokens, they send 10 tokens to $B$ via node $n_A$ and 10 tokens to $C$ via node $n_Z$. Both node $n_A$ and node $n_Z$ agree that the transaction is valid, since $A$ has the funds to send to $B$ (according to $n_A$) and $C$ (according to $n_Z$). Consensus is a mechanism whereby multiple distributed parties can reach agreement on the order and state of a sequence of events. Let’s consider the following 3 transactions: - Transaction $tx_A$: $A$ (starting balance of 10) transfers 10 to $B$ - Transaction $tx_B$: $B$ (starting balance of 0) transfers 10 to $C$ - Transaction $tx_C$: $C$ (starting balance of 0) transfers 10 to $D$ We consider Node $n_A$ received the order $tx_A$ $tx_B$ $tx_C$. The state of Node $n_A$ is $A:0$, $B:0$, $C:0$, $D:10$ Now, we consider Node $n_B$ that receives the order $tx_C$ $tx_B$ $tx_A$. The state of Node $n_B$ is $A:0$, $B:10$, $C:0$, $D:0$ Consensus ordering gives us a sequence of events. If the pair of event blocks $(x, y)$ has a double spending transaction, the chain can structurally detect the double spend and delay action for the event blocks until the event blocks assign time ordering. Suppose that the pair of event blocks $(x, y)$ has same frame $f_1$. Then, all nodes must detect two event blocks before frame $f$+$2$. By the root definition, each root happened-before more than $2n/3$ previous roots. For this reason, when two roots in $f$+$1$ are selected, they must have happened-before the roots which are more than one-thirds of roots in $f$. This means that more than $2n/3$ roots in $f$+$1$ share both two roots which include the pair respectively. With the root definition and previous explanation, all roots in $f$+$2$ share both the pairs. Thus, all nodes detect the double spending event blocks at $f$+$2$ or earlier. \subsubsection{Long-range attack} In blockchains an adversary can create another chain. If this chain is longer than the original, the network will accept the longer chain. This mechanism exists to identify which chain has had more work (or stake) involved in its creation. $2n/3$ participating nodes are required to create a new chain. To accomplish a long-range attack you would first need to create $>$ $2n/3$ participating malicious nodes to create the new chain. \subsubsection{Bribery attack} An adversary could bribe nodes to validate conflicting transactions. Since $2n/3$ participating nodes are required, this would require the adversary to bribe $>$ $n/3$ of all nodes to begin a bribery attack. \subsubsection{Denial of Service} LCA is a leaderless system requiring $2n/3$ participation. An adversary would have to deny $>$ $n/3$ participants to be able to successfully mount a DDoS attack. \subsubsection{Sybil} Each participating node must stake a minimum amount of FTM to participate in the network. Being able to stake $2n/3$ total stake would be prohibitively expensive. \clearpage \section{Reference}\label{se:ref} \renewcommand\refname{\vskip -1cm} \bibliographystyle{unsrt}
{'timestamp': '2018-10-05T02:11:11', 'yymm': '1810', 'arxiv_id': '1810.02186', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02186'}
arxiv
\section{Introduction} In the longest common factor problem, also known as longest common substring problem, we are given two strings $x$ and $y$, each of length at most $n$, and we are asked to find a maximal-length string occurring in both $x$ and $y$. This is a classical and well-studied problem in computer science arising out of different practical scenarios. It can be solved in $\mathcal{O}(n)$ time and space~\cite{ChiHui1992,DBLP:books/cu/Gusfield1997} (see also~\cite{DBLP:conf/esa/KociumakaSV14,DBLP:conf/cpm/StarikovskayaV13}). Recently, the same problem has been extensively studied under distance metrics; that is, the sought factors (one from $x$ and one from $y$) must be at distance at most $k$ and have maximal length~\cite{DBLP:conf/cpm/Charalampopoulos18,DBLP:journals/jcb/ThankachanAA16,DBLP:conf/recomb/ThankachanACA18,DBLP:journals/corr/abs-1801-04425,MaxHamming,jda08} (and references therein). In this paper we initiate a new related line of research. We are given two or more strings and our goal is to compute a {\em factor} common to all strings that preserves a specific {\em property} and has maximal length. An analogous line of research was introduced in~\cite{Chowdhury}. It focuses on computing a {\em subsequence} (rather than a factor) common to all strings that preserves a specific property and has maximal length. Specifically, in~\cite{Chowdhury,BAE,INENAGA}, the authors considered computing a longest common palindromic subsequence and in~\cite{inoue_et_al} computing a longest common square subsequence. We consider three fundamental string properties: {\em square-free} factors, {\em periodic}, and {\em palindromic} factors~\cite{lothaire_2005} under three different settings, one per property. In the first setting, we are given a string $x$ and we are asked to construct a data structure over $x$ answering the following type of on-line queries: given string $y$, find a longest square-free factor common to $x$ and $y$. In the second setting, we are given $k$ strings and an integer $1 < k'\leq k$ and we are asked to find a longest periodic factor common to at least $k'$ strings. In the third setting, we are given two strings and we are asked to find a longest palindromic factor common to the two strings. We present linear-time solutions for all settings. We anticipate that our paradigm can be extended to other string properties or settings. \subsection{Definitions and Notation} An \textit{alphabet} $\Sigma$ is a non-empty finite ordered set of letters of size $\sigma=|\Sigma|$. In this work we consider that $\sigma = \mathcal{O}(1)$ or that $\Sigma$ is a linearly-sortable integer alphabet. A \textit{string} $x$ on an alphabet $\Sigma$ is a sequence of elements of $\Sigma$. The set of all strings on an alphabet $\Sigma$, including the \textit{empty string} $\varepsilon$ of length $0$, is denoted by $\Sigma^*$. For any string $x$, we denote by $x[i..j]$ the \textit{substring} (sometimes called \textit{factor}) of $x$ that starts at position $i$ and ends at position $j$. In particular, $x[0 .. j]$ is the \textit{prefix} of $x$ that ends at position $j$, and $x[i..|x|-1]$ is the \textit{suffix} of $x$ that starts at position $i$, where $|x|$ denotes the \textit{length} of $x$. A string $uu$, $u \in \Sigma^*$, is called a {\em square}. A {\em square-free} string is a string that does not contain a square as a factor. A \emph{period} of $x[0..|x|-1]$ is a positive integer $p$ such that $x[i]=x[i+p]$ holds for all $0 \leq i < |x|-p$. The smallest period of $x$ is denoted by $\textsf{per}(x)$. String $u$ is called {\em periodic} if and only if $\textsf{per}(u) \leq |u|/2$. A \emph{run} of string $x$ is an interval $[i,j]$ such that for the smallest period $p=\textsf{per}(x[i..j])$ it holds that $2p \leq j-i+1$ and the periodicity cannot be extended to the left or right, \textit{i.e., } $i=0$ or $x[i-1] \neq x[i+p-1]$, and, $j=|x|-1$ or $x[j-p+1] \neq x[j+1]$. We denote the {\em reversal} of $x$ by string $x^R$, i.e. $x^R=x[|x|-1]x[|x|-2] \ldots x[0]$. A string $p$ is said to be a \emph{palindrome} if and only if $p=p^R$. If factor $x[i..j]$, $0 \leq i \leq j \leq n-1$, of string $x$ of length $n$ is a palindrome, then $\frac{i+j}{2}$ is the \emph{center} of $x[i..j]$ in $x$ and $\frac{j-i+1}{2}$ is the {\em radius} of $x[i.. j]$. In other words, a palindrome is a string that reads the same forward and backward, i.e. a string $p$ is a palindrome if $p = y a y^R$ where $y$ is a string, $y^R$ is the reversal of $y$ and $a$ is either a single letter or the empty string. Moreover, $x[i.. j]$ is called a {\em palindromic factor} of $x$. It is said to be a \emph{maximal palindrome} if there is no other palindrome in $x$ with center $\frac{i+j}{2}$ and larger radius. Hence $x$ has exactly $2n-1$ maximal palindromes. A maximal palindrome $p$ of $x$ can be encoded as a pair $(c,r)$, where $c$ is the center of $p$ in $x$ and $r$ is the radius of $p$. \subsection{Algorithmic Toolbox} The maximum number of runs in a string of length $n$ is less than $n$~\cite{BannaiTomohiroInenagaNakashimaTakedaTsuruta2017}, and, moreover, all runs can be computed in $\mathcal{O}(n)$ time~\cite{KolpakovKucherov1999,BannaiTomohiroInenagaNakashimaTakedaTsuruta2017}. The \textit{suffix tree} $\textsf{ST}(x)$ of a non-empty string $x$ of length $n$ is a compact trie representing all suffixes of $x$. $\textsf{ST}(x)$ can be constructed in $\mathcal{O}(n)$ time~\cite{farach1997optimal}. We can analogously define and construct the \textit{generalised suffix tree} $\textsf{GST}\xspace(x_0,x_1,\ldots,x_{k-1})$ for a set of $k$ strings. We assume the reader is familiar with these data structures. The matching statistics capture all matches between two strings $x$ and $y$~\cite{Chang1994}. More formally, the {\em matching statistics} of a string $y[0..|y|-1]$ with respect to a string $x$ is an array $\textsf{MS}_y[0..|y|-1]$, where $\textsf{MS}_y[i]$ is a pair $(\ell_i, p_i)$ such that (i) $y[i..i + \ell_i-1]$ is the longest prefix of $y[i..|y|-1]$ that is a factor of $x$; and (ii) $x[p_i..p_i + \ell_i-1] = y[i..i + \ell_i-1]$. Matching statistics can be computed in $\mathcal{O}(|y|)$ time for $\sigma = \mathcal{O}(1)$ by using $\textsf{ST}(x)$ \cite{DBLP:books/cu/Gusfield1997,DBLP:conf/spire/BelazzouguiC14,tcs09}. Given a rooted tree $T$ with $n$ leaves coloured from $0$ to $k-1$, $1 < k \leq n$, the \emph{colour set size} problem is finding, for each internal node $u$ of $T$, the number of different leaf colours in the subtree rooted at $u$. In \cite{ChiHui1992}, the authors present an $\mathcal{O}(n)$-time solution to this problem. In the \textit{weighted ancestor} problem, introduced in~\cite{DBLP:conf/cpm/FarachM96}, we consider a rooted tree $T$ with an integer weight function $\mu$ defined on the nodes. We require that the weight of the root is zero and the weight of any other node is strictly larger than the weight of its parent. A weighted ancestor query, given a node $v$ and an integer value $\ell\le \mu(v)$, asks for the highest ancestor $u$ of $v$ such that $\mu(u)\ge \ell$, \textit{i.e., } such an ancestor $u$ that $\mu(u)\ge \ell$ and $\mu(u)$ is the smallest possible. When $T$ is the suffix tree of a string $x$ of length $n$, we can locate the locus of any factor of $x[i..j]$ using a weighted ancestor query. We define the weight of a node of the suffix tree as the length of the string it represents. Thus a weighted ancestor query can be used for the terminal node corresponding to $x[i..n-1]$ to create (if necessary) and mark the node that corresponds to $x[i..j]$. Given a collection $Q$ of weighted ancestor queries on a weighted tree $T$ on $n$ nodes with integer weights up to $n^{\mathcal{O}(1)}$, all the queries in $Q$ can be answered {\em off-line} in $\mathcal{O}(n+|Q|)$ time~\cite{DBLP:journals/corr/BartonKLPR17}. \section{Square-Free-Preserved Matching Statistics} In this section, we introduce the square-free-preserved matching statistics problem and provide a linear-time solution. In the {\em square-free-preserved matching statistics} problem we are given a string $x$ of length $n$ and we are asked to construct a data structure over $x$ answering the following type of on-line queries: given string $y$, find the longest square-free prefix of $y[i..|y|-1]$ that is a factor of $x$, for all $0 \leq i < |y|-1$. (For related work see~\cite{DBLP:conf/spire/DumitranMN15}.) We represent the answer using an integer array $\textsf{SQMS}_y[0..|y|-1]$ of lengths, but we can trivially modify our algorithm to report the actual factors. It should be clear that a maximum element in $\textsf{SQMS}$ gives the length of some longest square-free factor common to $x$ and $y$. \emph{Construction.} Our data structure over string $x$ consists of the following: \begin{itemize} \item An integer array $L_x[0..n-1]$, where $L_x[i]$ stores the length of the longest square-free factor starting at position $i$ of string $x$. \item The suffix tree $\textsf{ST}(x)$ of string $x$. \end{itemize} The idea for constructing array $L_x$ efficiently is based on the following crucial observation. \begin{observation} \label{obs:sq} If $x[i..n-1]$ contains a square then $L_x[i]+1$, for all $0 \leq i < n$, is the length of the {\em shortest prefix} of $x[i..n-1]$ (factor $f$) containing a square. In fact, the square is a suffix of $f$, otherwise $f$ would not have been the shortest. If $x[i..n-1]$ does not contain a square then $L_x[i]=n-i$. \end{observation} We thus shift our focus to computing the shortest such prefixes. We start by considering the runs of $x$. Specifically, we consider squares in $x$ observing that a run $[\ell,r]$ with period $p$ contains $r-\ell - 2p + 2$ squares of length $2p$ with the leftmost one starting at position $\ell$. Let $r'\!=\!\ell\!+\!2p\!-\!1$ denote the ending position of the leftmost such square of the run. In order to find, for all $i$'s, the shortest prefix of $x[i..n-1]$ containing a square $s$, and thus compute $L_x[i]$, we have two cases: \begin{enumerate} \item \label{item:case1} $s$ is part of a run $[\ell,r]$ in $x$ that starts {\em after} $i$. In particular, $s=x[\ell..r']$ such that $r' \leq r$, $\ell>i$, and $r'$ is minimal. In this case the shortest factor has length $\ell+2p-i$; we store this value in an integer array $C[0..n-1]$. If no run starts after position $i$ we set $C[i]=\infty$. To compute $C$, after computing in $\mathcal{O}(n)$ time all the runs of $x$ with their $p$ and $r'$~\cite{KolpakovKucherov1999,BannaiTomohiroInenagaNakashimaTakedaTsuruta2017}, we sort them by $r'$. A right-to-left scan after this sorting associates to $i$ the closest $r'$ with $\ell>i$. \item \label{item:case2} $s$ is part of a run $[\ell,r]$ in $x$ and $i\!\in\![\ell,r]$. This implies that if $i\!\leq\!r\!-\!2p\!+\!1$ then a square {\em starts at} $i$ and we store the length of the shortest such square in an integer array $S[0..n-1]$. If no square starts at position $i$ we set $S[i]=\infty$. Array $S$ can be constructed in $\mathcal{O}(n)$ time by applying the algorithm of~\cite{DUVAL2004229}. \end{enumerate} Since we do not know which of the two cases holds, we compute both $C$ and $S$. By Observation~\ref{obs:sq}, if $C[i]=S[i]=\infty$ ($x[i..n-1]$ does not contain a square) we set $L_x[i] =n-i$; otherwise ($x[i..n-1]$ contains a square) we set $L_x[i]=\min\{C[i],S[i]\}-1$. Finally, we build the suffix tree $\textsf{ST}(x)$ of string $x$ in $\mathcal{O}(n)$ time~\cite{farach1997optimal}. This completes our construction. \emph{Querying.} We rely on the following fact for answering the queries efficiently. \begin{fact} \label{fct:sqf} Every factor of a square-free string is square-free. \end{fact} Let string $y$ be an on-line query. Using $\textsf{ST}(x)$, we compute the matching statistics $\textsf{MS}_y$ of $y$ with respect to $x$. For each $j \in [0,|y|-1]$, $\textsf{MS}_y[j]=(\ell_i,i)$ indicates that $x[i..i+\ell_i-1] = y[j..j+\ell_i-1]$. This computation can be done in $\mathcal{O}(|y|)$ time~\cite{DBLP:books/cu/Gusfield1997,DBLP:conf/spire/BelazzouguiC14}. By applying Fact~\ref{fct:sqf}, we can answer any query $y$ in $\mathcal{O}(|y|)$ time for $\sigma = \mathcal{O}(1)$ by setting $\textsf{SQMS}_y[j]=\min\{\ell_i, L_x[i]\}$, for all $0 \leq j \leq |y| - 1$. We arrive at the following result. \begin{theorem}\label{th:sqms} Given a string $x$ of length $n$ over an alphabet of size $\sigma = \mathcal{O}(1)$, we can construct a data structure of size $\mathcal{O}(n)$ in time $\mathcal{O}(n)$, answering $\textsf{SQMS}_y$ on-line queries in $\mathcal{O}(|y|)$ time. \end{theorem} \begin{proof} The time complexity of our algorithm follows from the above discussion. We next show the correctness of our algorithm. Let us first show the correctness of computing array $L_x$. The square contained in the shortest prefix of $x[i..n-1]$ (containing a square) starts by definition either at $i$ or after $i$. If it starts at $i$ this is correctly computed by the algorithm of~\cite{DUVAL2004229} which assigns the length of the shortest such square in $S[i]$. If it starts after $i$ it must be the leftmost square of another run by the runs definition. $C[i]$ stores the length of the shortest prefix containing such a square. Then by Observation~\ref{obs:sq}, $L_x[i]$ is computed correctly. It suffices to show that, if $w$ is the longest square-free substring common to $x$ and $y$ occurring at position $i_x$ in $x$ and at position $i_y$ in $y$, then (i) $\textsf{MS}_y[i_y]=(\ell,i_x)$ with $\ell\geq |w|$ and $x[i_x..i_x+\ell-1]=y[i_y..i_y+\ell-1]$; (ii) $w$ is a prefix of $x[i_x..i_x+L_x[i_x]-1]$; and (iii) $\textsf{SQMS}_y[i_y]=|w|$. Case (i) directly follows from the correctness of the matching statistics algorithm. For Case (ii), since $w$ occurs at $i_x$ and $w$ is square-free, $L_x[i_x] \geq |w|$. For Case (iii), since $w$ is square-free we have to show that $|w| = \min\{\ell_i, L_x[i]\}$. We know from (i) that $\ell \geq |w|$ and from (ii) that $L_x[i_x]\geq |w|$. If $\min\{\ell_i, L_x[i]\}=\ell$, then $w$ cannot be extended because the possibly longer than $|w|$ square-free string occurring at $i_x$ does not occur in $y$, and in this case $|w| =\ell$. Otherwise, if $\min\{\ell_i, L_x[i]\}=L_x[i_x]$ then $w$ cannot be extended because it is no longer square-free, and in this case $|w| = L_x[i_x]$. Hence we conclude that $\textsf{SQMS}_y[i_y]=|w|$. The statement follows. \end{proof} The following example provides a complete overview of the workings of our algorithm. \begin{example} Let $x = \texttt{aababaababb}$ and $y = \texttt{babababbaaab}$. The length of a longest common square-free factor is 3, and the factors are $\texttt{bab}$ and $\texttt{aba}$. \centering \begin{tabular}{ccccccccccccccc} \\\cline{1-12} $i$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ \cline{1-12} $x[i]$ & \texttt{a} & \texttt{a} & \texttt{b} & \texttt{a} & \texttt{b} & \texttt{a} & \texttt{a} & \texttt{b} & \texttt{a} & \texttt{b} & \texttt{b} \\ $C[i]$ & 5 & 6 & 5 & 4 & 3 & 5 & 5 & 4 & 3 & $\infty$ & $\infty$\\ $S[i]$ & 2 & 4 & 4 & 6 & $\infty$ & 2 & 4 & $\infty$ & $\infty$ & 2 & $\infty$ \\ $L_x[i]$ & 1 & 3 & 3 & 3 & 2 & 1 & 3 & 3 & 2 & 1 & 1 \\ \hline $j$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $9$ & $10$ & $11$ \\ \hline $y[j]$ & \texttt{b} & \texttt{a} & \texttt{b} & \texttt{a} & \texttt{b} & \texttt{a} & \texttt{b} & \texttt{b} & \texttt{a} & \texttt{a} & \texttt{a} & \texttt{b}\\ $\textsf{MS}_y[j]$ & (4,2) & (5,1) & (4,2) & (5,6) & (4,7) & (3,8) &(2,9) & (3,4) & (2,0) & (3,0) & (2,1) & (1,2) \\ $\textsf{SQMS}_y[j]$ & 3 & 3 & 3 & 3 & 3 & 2 & 1 & 2 & 1 & 1 & 2 & 1 \end{tabular} \end{example} \section{Longest Periodic-Preserved Common Factor} In this section, we introduce the longest periodic-preserved common factor problem and provide a linear-time solution. In the {\em longest periodic-preserved common factor} problem, we are given $k \ge 2$ strings $x_0,x_1,\dots, x_{k-1}$ of total length $N$ and an integer $1 < k'\le k$, and we are asked to find a longest periodic factor common to at least $k'$ strings. In what follows we present two different algorithms to solve this problem. We represent the answer $\textsf{LPCF}_{k'}$\xspace by the length of a longest factor, but we can trivially modify our algorithms to report an actual factor. Our first algorithm, denoted by {\sc lPcf}, works as follows. \begin{enumerate} \item Compute the runs of string $x_j$, for all $0 \le j < k$. \item Construct the generalised suffix tree $\textsf{GST}\xspace(x_0,x_1,\ldots,x_{k-1})$ of $x_0,x_1,\ldots,x_{k-1}$. \item For each string $x_j$ and for each run $[\ell,r]$ with period $p_\ell$ of $x_j$, augment \textsf{GST}\xspace with the explicit node spelling $x_j[\ell..r]$, decorate it with $p_\ell$, and mark it as a \emph{candidate} node. This can be done as follows: for each run $[\ell,r]$ of $x_j$, for all $0\!\le\!j\!<\!k$, find the leaf corresponding to $x_{j}[\ell..|x_j|\!\!-\!\!1] $ and answer the weighted ancestor query in \textsf{GST}\xspace with weight $r\!-\!\ell\!+\!1$. Moreover, mark as candidates all {\em explicit} nodes spelling a prefix of length $d$ of any run $[\ell,r]$ with $2p_\ell\leq d$. \item Mark as \emph{good} the nodes of the tree having at least $k'$ different colours on the leaves of the subtree rooted there. Let \textsf{aGST}\xspace be this augmented tree. \item Return as $\textsf{LPCF}_{k'}$\xspace the string depth of a candidate node in \textsf{aGST}\xspace which is also a good node, and that has maximal string depth (if any, otherwise return 0). \end{enumerate} \begin{theorem}\label{the:LCPF} Given $k$ strings of total length $N$ on alphabet $\Sigma = \{1,\ldots,N^{\mathcal{O}(1)}\}$, and an integer $1 < k'\leq k$, algorithm {\sc lPcf} returns $\textsf{LPCF}_{k'}$\xspace in time $\mathcal{O}(N)$. \end{theorem} \begin{proof} Let us assume wlog that $k'=k$, and let $w$ with period $p$ be the longest periodic factor common to all strings. By the construction of \textsf{aGST}\xspace (Steps 1-4), the path spelling $w$ leads to a good node $n_w$ as $w$ occurs in all the strings. We make the following observation. \begin{observation} \label{obs:run-of-a-period} Each periodic factor with period $p$ of string $x$ is a factor of $x[i..j]$, where $[i,j]$ is a run with period $p$. \end{observation} By Observation~\ref{obs:run-of-a-period}, in all strings, $w$ is included in a run having the same period. Observe that for at least one of the strings, there is a run ending with $w$, otherwise we could extend $w$ obtaining a longer periodic common factor (similarly, for at least one of the strings, there is a run starting with $w$). Therefore $n_w$ is {\em both} a good and a candidate node. By definition, $n_w$ is at string depth at least $2p$ and, by construction, $\textsf{LPCF}_{k'}$\xspace is the string depth of a deepest such node; thus $|w|$ will be returned by Step~5. As for the time complexity, Step 1~\cite{KolpakovKucherov1999,BannaiTomohiroInenagaNakashimaTakedaTsuruta2017} and Step 2~\cite{farach1997optimal} can be done in $\mathcal{O}(N)$ time. Since the total number of runs is less than $N$~\cite{BannaiTomohiroInenagaNakashimaTakedaTsuruta2017}, Step 3 can be done in $\mathcal{O}(N)$ time using off-line weighted ancestor queries~\cite{DBLP:journals/corr/BartonKLPR17} to mark the runs as candidate nodes; and then a post-order traversal to mark their ancestor explicit nodes as candidates, if their string-depth is at least $2p_\ell$ for any run $[\ell,r]$ with period $p_\ell$. The size of the \textsf{aGST}\xspace is still in $\mathcal{O}(N)$. Step 4 can be done in $\mathcal{O}(N)$ time~\cite{ChiHui1992}. Step 5 can be done in $\mathcal{O}(N)$ by a post-order traversal of \textsf{aGST}\xspace. \end{proof} The following example provides a complete overview of the workings of our algorithm. \begin{example} Consider $x=$\texttt{ababbabba}, $y=$\texttt{ababaab}, and $k\!=\!k'\!=\!2$. The runs of $x$ are: $r_0=[0,3]$, $\textsf{per}(\texttt{abab})=2$, $r_1=[1,8]$, $\textsf{per}(\texttt{babbabba})=3$, $r_2=[3,4]$, $\textsf{per}(\texttt{bb})=1$, and $r_3=[6,7]$, $\textsf{per}(\texttt{bb})=1$; those of $y$ are $r_4=[0,4]$, $\textsf{per}(\texttt{ababa})=2$ and $r_5=[4,5]$, $\textsf{per}(\texttt{aa})=1$. Fig~\ref{fig:giulia} shows \textsf{aGST}\xspace for $x$, $y$, and $k\!=\!k'\!=\!2$. Algorithm {\sc lPcf} outputs $4=|\texttt{abab}|$, with $\textsf{per}(\texttt{abab})=2$, as the node spelling \texttt{abab} is the deepest good one that is also a candidate. \end{example} \begin{figure} \centering \includegraphics[width=\textwidth,height=6cm]{Gstree.png} \caption{\textsf{aGST}\xspace for $x=\texttt{ababbabba}$, $y=$\texttt{ababaab}, and $k\!=\!k'\!=\!2$.} \label{fig:giulia} \end{figure} We next present a second algorithm to solve this problem with the same time complexity but without the use of off-line weighted ancestor queries. The algorithm works as follows. \begin{enumerate} \item Compute the runs of string $x_j$, for all $0 \le j < k$. \item Construct the generalised suffix tree $\textsf{GST}\xspace(x_0,x_1,\ldots,x_{k-1})$ of $x_0,x_1,\ldots,x_{k-1}$. \item Mark as \emph{good} the nodes of $\textsf{GST}\xspace$ having at least $k'$ different colours on the leaves of the subtree rooted there. \item Compute and store, for every leaf node, the \emph{nearest} ancestor that is good. \item For each string $x_j$ and for each run $[\ell,r]$ with period $p_\ell$ of $x_j$, check the nearest good ancestor for the leaf corresponding to $x_j[\ell..|x_j|-1]$. Let $d$ be the string-depth of the nearest good ancestor. Then: \begin{enumerate} \item If $r - \ell + 1 \leq d$, the entire run is also good. \item If $r - \ell + 1 > d$, check if $2p_\ell \leq d$, and if so the string for the good ancestor is periodic. \end{enumerate} \item Return as $\textsf{LPCF}_{k'}$\xspace the maximal string depth found in Step 5 (if any, otherwise return 0). \end{enumerate} \begin{figure} \centering \includegraphics[width=\textwidth,height=9cm]{ST.pdf} \caption{\textsf{GST}\xspace for $x=\texttt{ababaa}$, $y=\texttt{bababb}$, and $k\!=\!k'\!=\!2$. Good nodes are marked red.} \label{fig:giulia2} \end{figure} Let us analyse this algorithm. Let us assume wlog that $k'=k$, and let $w$ with period $p$ be the longest periodic factor common to all strings. By the construction of $\textsf{GST}\xspace$ (Steps 1-3), the path spelling $w$ leads to a good node $n_w$ as $w$ occurs in all the strings. By Observation~\ref{obs:run-of-a-period}, in all strings, $w$ is included in a run having the same period. Observe that for at least one of the strings, there is a run starting with $w$, otherwise we could extend $w$ obtaining a longer periodic common factor. So the algorithm should check, for each run, if there is a periodic-preserved common prefix of the run and take the longest such prefix. $\textsf{LPCF}_{k'}$\xspace is the string depth of a deepest good node spelling a periodic factor; thus $|w|$ will be returned by Step~6. As for the time complexity, Step 1~\cite{KolpakovKucherov1999,BannaiTomohiroInenagaNakashimaTakedaTsuruta2017} and Step 2~\cite{farach1997optimal} can be done in $\mathcal{O}(N)$ time. Step 3 can be done in $\mathcal{O}(N)$ time~\cite{ChiHui1992} and Step 4 can be done in $\mathcal{O}(N)$ time by using a tree traversal. Since the total number of runs is less than $N$~\cite{BannaiTomohiroInenagaNakashimaTakedaTsuruta2017}, Step 5 can be done in $\mathcal{O}(N)$ time. We thus arrive at Theorem~\ref{the:LCPF} with a different algorithm. The following example provides a complete overview of the workings of our algorithm. \begin{example} Consider $x=$\texttt{ababaa}, $y=$\texttt{bababb}, and $k\!=\!k'\!=\!2$. The runs of $x$ are: $r_0=[0,4]$, $\textsf{per}(\texttt{ababa})=2$, $r_1=[4,5]$, $\textsf{per}(\texttt{aa})=1$; those of $y$ are $r_2=[0,4]$, $\textsf{per}(\texttt{babab})=2$ and $r_3=[4,5]$, $\textsf{per}(\texttt{bb})=1$. Fig~\ref{fig:giulia2} shows $\textsf{GST}\xspace$ for $x$, $y$, and $k\!=\!k'\!=\!2$. Consider the run $r_0=[0,4]$. The nearest good node of leaf spelling $x[0..|x|-1]$ is the node spelling $\texttt{abab}$. We have that $r - \ell + 1 = 5 > d = 4$, and $2p = 4 \leq d = 4$. The algorithm outputs $4=|\texttt{abab}|$ as \texttt{abab} is a longest periodic-preserved common factor. Another longest periodic-preserved common factor is \texttt{baba}. \end{example} \section{Longest Palindromic-Preserved Common Factor} In this section, we introduce the longest palindromic-preserved common factor problem and provide a linear-time solution. In the {\em longest palindromic-preserved common factor} problem, we are given two strings $x$ and $y$, and we are asked to find a longest palindromic factor common to the two strings. (For related work in a dynamic setting see \cite{funakoshi_et_al:LIPIcs:2018:8697,DBLP:journals/corr/abs-1804-08731}.) We represent the answer $\textsf{LPALCF}$\xspace by the length of a longest factor, but we can trivially modify our algorithm to report an actual factor. Our algorithm is denoted by {\sc lPalcf}. In the description below, for clarity, we consider odd-length palindromes only. (Even-length palindromes can be handled in an analogous manner.) \begin{enumerate} \item Compute the maximal odd-length palindromes of $x$ and the maximal odd-length palindromes of $y$. \item Collect the factors $x[i..i']$ of $x$ (resp.~the factors $y[j..j']$ of $y$) such that $i$ ($j$) is the center of an odd-length maximal palindrome of $x$ ($y$) and $i'$ ($j'$) is the ending position of the odd-length maximal palindrome centered at $i$ ($j$). \item Create a lexicographically sorted list $L$ of these strings from $x$ and $y$. \item Compute the longest common prefix of consecutive entries (strings) in $L$. \item Let $\ell$ be the maximal length of longest common prefixes between any string from $x$ and any string from $y$. For odd lengths, return $$\textsf{LPALCF}$\xspace = 2\ell-1$. \end{enumerate} \begin{theorem} Given two strings $x$ and $y$ on alphabet $\Sigma = \{1,\ldots,(|x|+|y|)^{\mathcal{O}(1)}\}$, algorithm {\sc lPalcf} returns $\textsf{LPALCF}$\xspace in time $\mathcal{O}(|x|+|y|)$. \end{theorem} \begin{proof} The correctness of our algorithm follows directly from the following observation. \begin{observation}\label{obs:pal} Any longest palindromic-preserved common factor is a factor of a maximal palindrome of $x$ with the same center and a factor of a maximal palindrome of $y$ with the same center. \end{observation} Step 1 can be done in $\mathcal{O}(|x|+|y|)$ time~\cite{DBLP:books/cu/Gusfield1997}. Step 2 can be done in $\mathcal{O}(|x|+|y|)$ time by going through the set of maximal palindromes computed in Step 1. Step 3 and Step 4 can be done in $\mathcal{O}(|x|+|y|)$ time by constructing the data structure of~\cite{DBLP:conf/latin/Charalampopoulos18}. Step 5 can be done in $\mathcal{O}(|x|+|y|)$ time by going through the list of computed longest common prefixes. \end{proof} The following example provides a complete overview of the workings of our algorithm. \begin{example} Consider $x=$\texttt{ababaa} and $y=$\texttt{bababb}. In Step 1 we compute all maximal palindromes of $x$ and $y$. Considering odd-length palindromes gives the following factors (Step 2) from $x$: $x[0..0]=\texttt{a}$, $x[1..2]=\texttt{\textcolor{red}{ba}}$, $x[2..4]=\texttt{\textcolor{blue}{ab}a}$, $x[3..4]=\texttt{\textcolor{red}{ba}}$, $x[4..4]=\texttt{a}$, and $x[5..5]=\texttt{a}$. The analogous factors from $y$ are: $y[0..0]=\texttt{b}$, $y[1..2]=\texttt{\textcolor{blue}{ab}}$, $y[2..4]=\texttt{\textcolor{red}{ba}b}$, $y[3..4]=\texttt{\textcolor{blue}{ab}}$, $y[4..4]=\texttt{b}$, and $y[5..5]=\texttt{b}$. We sort these strings lexicographically and compute the longest common prefix information (Steps 3-4). We find that $\ell=2$: the maximal longest common prefixes are $\texttt{\textcolor{red}{ba}}$ and $\texttt{\textcolor{blue}{ab}}$, denoting that \texttt{\textcolor{red}{aba}} and \texttt{\textcolor{blue}{bab}} are the longest palindromic-preserved common factors of odd length. In fact, algorithm {\sc lPalcf} outputs $2\ell-1=3$ as \texttt{aba} and \texttt{bab} are the longest palindromic-preserved common factors of any length. \end{example} \section{Final Remarks} In this paper, we introduced a new family of string processing problems. The goal is to compute factors common to a set of strings preserving a specific property and having maximal length. We showed linear-time algorithms for square-free, periodic, and palindromic factors under three different settings. We anticipate that our paradigm can be extended to other string properties or settings. \section*{Acknowledgements} We would like to acknowledge an anonymous reviewer of a previous version of this paper who suggested the second linear-time algorithm for computing the longest periodic-preserved common factor. Solon P.~Pissis and Giovanna Rosone are partially supported by the Royal Society project IE 161274 ``Processing uncertain sequences: combinatorics and applications''. Giovanna Rosone and Nadia Pisanti are partially supported by the project Italian MIUR-SIR CMACBioSeq (``Combinatorial methods for analysis and compression of biological sequences'') grant n.~RBSI146R5L. \bibliographystyle{plain}
{'timestamp': '2018-10-05T02:08:38', 'yymm': '1810', 'arxiv_id': '1810.02099', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02099'}
arxiv
\subsection{Proof of Theorem~\ref{thm:main_gd}} We prove Theorem~\ref{thm:main_gd} by induction. Our induction hypothesis is just the following convergence rate of the empirical loss. \begin{condition}\label{cond:linear_converge} At the $k$-th iteration, we have $\norm{\vect{y}-\vect{u}(k)}_2^2 \le (1-\frac{\eta \lambda_0}{2})^{k} \norm{\vect{y}-\vect{u}(0)}_2^2.$ \end{condition} A directly corollary of this condition is the following bound of deviation from the initialization. The proof is similar to that of Lemma~\ref{lem:small_perturbation_close_to_init} so we defer it to appendix. \begin{cor}\label{cor:dist_from_init} If Condition~\ref{cond:linear_converge} holds for $k'=0,\ldots,k$, then we have for every $r \in [m]$\begin{align} \norm{\vect{w}_r(k+1)-\vect{w}_r(0)}_2 \le \frac{4\sqrt{n}\norm{\vect{y}-\vect{u}(0)}_2}{\sqrt{m} \lambda_0} \triangleq R'. \end{align} \end{cor} Now we show Condition~\ref{cond:linear_converge} holds for every $k = 0,1,\ldots$. For the base case $k=0$, by definition Condition~\ref{cond:linear_converge} holds. Suppose for $k'=0,\ldots,k$, Condition~\ref{cond:linear_converge} holds and we want to show Condition~\ref{cond:linear_converge} holds for $k'=k+1$. Our strategy is similar to the proof of Theorem~\ref{thm:main_gf}. We define the event \[A_{ir} = \left\{\exists \vect{w}: \norm{\vect{w}-\vect{w}_r(0)} \le R, \mathbb{I}\left\{\vect{x}_i^\top \vect{w}_r(0) \ge 0\right\} \neq \mathbb{I}\left\{\vect{x}_i^\top \vect{w} \ge 0\right\} \right\}.\] where $ R = \frac{c\lambda_0}{n^2}$ for some small positive constant $c$. Different from gradient flow, for gradient descent we need a more refined analysis. We let $S_i = \left\{r \in [m]: \mathbb{I}\{A_{ir}\}= 0\right\}$ and $ S_i^\perp = [m] \setminus S_i$. The following lemma bounds the sum of sizes of $S_i^\perp$. The proof is similar to the analysis used in Lemma~\ref{lem:close_to_init_small_perturbation}. See Section~\ref{sec:technical_proofs} for the whole proof. \begin{lem}\label{lem:bounds_Si_perp} With probability at least $1-\delta$ over the initialization, we have $\sum_{i=1}^{n}\abs{S_i^\perp} \le \frac{CmnR}{\delta}$ for some positive constant $C>0$. \end{lem} Next, we calculate the difference of predictions between two consecutive iterations, analogue to $\frac{du_i(t)}{dt}$ term in Section~\ref{sec:two_layer_regression}. \begin{align*} u_i(k+1) - u_i(k) = &\frac{1}{\sqrt{m}}\sum_{r=1}^{m} a_r \left(\relu{\vect{w}_r(k+1)^\top \vect{x}_i} - \relu{\vect{w}_r(k)^\top \vect{x}_i}\right)\\ = & \frac{1}{\sqrt{m}}\sum_{r=1}^{m} a_r \left(\relu{\left( \vect{w}_r(k) - \eta\frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)} \right)^\top \vect{x}_i} - \relu{\vect{w}_r(k)^\top \vect{x}_i}\right). \end{align*} Here we divide the right hand side into two parts. $I_1^i$ accounts for terms that the pattern does not change and $I_2^i$ accounts for terms that pattern may change. \begin{align*} I_1^i \triangleq &\frac{1}{\sqrt{m}}\sum_{r \in S_i} a_r \left(\relu{\left( \vect{w}_r(k) - \eta\frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)} \right)^\top \vect{x}_i} - \relu{\vect{w}_r(k)^\top \vect{x}_i}\right) \\ I_2^i \triangleq &\frac{1}{\sqrt{m}}\sum_{r \in S_i^\perp} a_r \left(\relu{\left( \vect{w}_r(k) - \eta\frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)} \right)^\top \vect{x}_i} - \relu{\vect{w}_r(k)^\top \vect{x}_i}\right) \end{align*} We view $I_2^i$ as a perturbation and bound its magnitude. Because ReLU is a $1$-Lipschitz function and $\abs{a_r} =1$, we have \begin{align*} \abs{I_2^i} \le \frac{\eta}{\sqrt{m}} \sum_{r\in S_i^\perp} \abs{\left( \frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)} \right)^\top \vect{x}_i} \le \frac{\eta \abs{S_i^\perp}}{\sqrt{m}} \max_{r \in [m]} \norm{ \frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)} }_2 \le \frac{\eta \abs{S_i}^\perp \sqrt{n}\norm{\vect{u}(k)-\vect{y}}_2}{m}. \end{align*} To analyze $I_1^i$, by Corollary~\ref{cor:dist_from_init}, we know $\norm{\vect{w}_r(k)-\vect{w}_r(0)} \le R'$ and $\norm{\vect{w}_r(k)-\vect{w}_r(0)} \le R'$ for all $r \in [m]$. Furthermore, because $R' < R$, we know $\mathbb{I}\left\{\vect{w}_r(k+1)^\top \vect{x}_i\ge 0\right\}= \mathbb{I}\left\{\vect{w}_r(k)^\top \vect{x}_i \ge 0\right\}$ for $r \in S_i.$ Thus we can find a more convenient expression of $I_1^i$ for analysis \begin{align*} I_1^i = &-\frac{\eta}{m}\sum_{j=1}^{n}\vect{x}_i^\top \vect{x}_j \left(u_j-y_j\right)\sum_{r \in S_i} \mathbb{I}\left\{\vect{w}_r(k)^\top \vect{x}_i \ge 0, \vect{w}_r(k)^\top \vect{x}_j\ge 0 \right\}\\ = &-\eta \sum_{j=1}^{n}(u_j-y_j)(\mathbf{H}_{ij}(k) -\mathbf{H}_{ij}^\perp(k)) \end{align*} where $ \mathbf{H}_{ij}(k) = \frac{1}{m}\sum_{r=1}^{m}\vect{x}_i^\top \vect{x}_j \mathbb{I}\left\{\vect{w}_r(k)^\top \vect{x}_i \ge 0, \vect{w}_r(k)^\top \vect{x}_j \ge 0\right\} $ is just the $(i,j)$-th entry of a discrete version of Gram matrix defined in Section~\ref{sec:two_layer_regression} and $ \mathbf{H}_{ij}^\perp(k) = \frac{1}{m}\sum_{r \in S_i^\perp}\vect{x}_i^\top \vect{x}_j \mathbb{I}\left\{\vect{w}_r(k)^\top \vect{x}_i \ge 0, \vect{w}_r(k)^\top \vect{x}_j \ge 0\right\} $ is a perturbation matrix. Let $\mathbf{H}^\perp(k)$ be the $n \times n$ matrix with $(i,j)$-th entry being $\mathbf{H}_{ij}^\perp(k)$. Using Lemma~\ref{lem:bounds_Si_perp}, we obtain an upper bound of the operator norm\begin{align*} \norm{\mathbf{H}^\perp(k)}_2 \le \sum_{(i,j)=(1,1)}^{(n,n)} \abs{\mathbf{H}_{ij}^\perp (k)} \le \frac{n \sum_{i=1}^{n}\abs{S_i^\perp}}{m} \le \frac{Cn^2 mR}{\delta m} \le \frac{Cn^2R}{\delta }. \end{align*} Similar to the classical analysis of gradient descent, we also need bound the quadratic term. \begin{align*} \norm{\vect{u}(k+1)-\vect{u}(k)}_2^2 \le \eta^2 \sum_{i=1}^{n}\frac{1}{m}\left(\sum_{r=1}^{m} \norm{\frac{\partial L(\mathbf{W}(k))}{\partial \vect{w}_r(k)}}_2\right)^2 \le \eta^2 n^2 \norm{\vect{y}-\vect{u}(k)}_2^2. \end{align*} With these estimates at hand, we are ready to prove the induction hypothesis. \begin{align*} \norm{\vect{y}-\vect{u}(k+1)}_2^2 = &\norm{\vect{y}-\vect{u}(k) - (\vect{u}(k+1)-\vect{u}(k))}_2^2\\ = & \norm{\vect{y}-\vect{u}(k)}_2^2 - 2 \left(\vect{y}-\vect{u}(k)\right)^\top \left(\vect{u}(k+1)-\vect{u}(k)\right) + \norm{\vect{u}(k+1)-\vect{u}(k)}_2^2\\ = & \norm{\vect{y}-\vect{u}(k)}_2^2 - 2\eta \left(\vect{y}-\vect{u}(k)\right)^\top \mathbf{H}(k) \left(\vect{y}-\vect{u}(k)\right) \\ &+ 2\eta \left(\vect{y}-\vect{u}(k)\right)^\top \mathbf{H}(k)^\perp \left(\vect{y}-\vect{u}(k)\right) -2 \left(\vect{y}-\vect{u}(k)\right)^\top\vect{I}_2\\ &+\norm{\vect{u}(k+1)-\vect{u}(k)}_2^2 \\ \le & (1-\eta\lambda_0 + \frac{2C\eta n^2R}{\delta} + \frac{2C\eta n^{3/2} R}{\delta} + \eta^2n^2) \norm{\vect{y}-\vect{u}(k)}_2^2 \\ \le & (1-\frac{\eta\lambda_0}{2})\norm{\vect{y}-\vect{u}(k)}_2^2 . \end{align*} The third equality we used the decomposition of $\vect{u}(k+1)-\vect{u}(k)$. The first inequality we used the Lemma~\ref{lem:close_to_init_small_perturbation}, the bound on the step size, the bound on $\vect{I}_2$, the bound on $\norm{\mathbf{H}(k)^\perp}_2$ and the bound on $\norm{\vect{u}(k+1)-\vect{u}(k)}_2^2$. The last inequality we used the bound of the step size and the bound of $R$. Therefore Condition~\ref{cond:linear_converge} holds for $k'=k+1$. Now by induction, we prove Theorem~\ref{thm:main_gd}. \qed \section{Introduction} \label{sec:intro} \input{intro.tex} \section{Comparison with Previous Results} \label{sec:comparison} \input{comparison.tex} \section{Continuous Time Analysis} \label{sec:two_layer_regression} \input{two_layer_regression.tex} \section{Discrete Time Analysis} \label{sec:discrete} \input{discrete.tex} \section{Experiments} \label{sec:exp} \input{exp.tex} \section{Conclusion and Discussion} \label{sec:conclusion} \input{conclusion.tex} \subsubsection*{Acknowledgments} \label{sec:ack} \input{ack.tex} \subsection{Review: Linear Convergence of Over-parameterized Linear Regression} \label{sec:linear_convergence_lr} We first review a simple setting, why gradient descent convergence linearly in over-parameterized linear regression model. Suppose we have a data set $\left\{(\vect{x}_i,y_i)\right\}_{i=1}^n$ with $\vect{x}_i \in \mathbb{R}^d$and $d \ge n$. We fit a linear model:\begin{align*} \min_{\vect{\theta} \in \mathbb{R}^d} L\left(\vect{\theta}\right) = \frac{1}{2}\norm{\mathbf{X}\vect{\theta} - \vect{y}}_2^2 \end{align*} where $\mathbf{X} = \left(\vect{x}_1,\ldots,\vect{x}_n\right)^\top \in \mathbb{R}^{n \times d}$ and $\vect{y} = \left(y_1,\ldots,y_n\right) \in \mathbb{R}^n$. Now we apply gradient descent to optimize $\vect{\theta}$ \begin{align*} \vect{\theta}(k+1) = \vect{\theta}(k) - \eta \vect{X}^\top\left(\vect{X} \theta -\vect{y}\right). \end{align*} Note because we use over-parameterization: $n > d$, $\mathbf{X}^\top \mathbf{X}$ is \emph{not} full rank and so the objective function is not strongly convex. However, if we look at the prediction space dynamics, we can show the linear convergence. We denote $u_i = \vect{x}_i^\top \theta$ as the prediction on the $i$-th sample and compute \begin{align*} u_i(k+1) = &\vect{x}_i^\top \theta\left(k+1\right) \\ = & u_i(k) - \vect{x}_i^\top \theta\left(k\right) - \eta \sum_{i=1}^{n} (\vect{x}_i^\top \vect{\theta}(k) - y_i)\vect{x}_i^\top \vect{x}_j \\ \triangleq \triangleq & u_i(k) - \sum_{j=1}^{n}(y_j-u_j(k))H_{ij} \end{align*} where we have defined $H_{ij} = \vect{x}_i^\top \vect{x}_j $. Note if we view $H_{ij}$ as the $(i,j)$-th entry of an $n \times n$ matrix $\mathbf{H}$, it is just the Gram matrix. Furthermore, because $n > d$, $\mathbf{H}$ is full-rank as long as the design matrix is not degenerate. Denote $\vect{u} = \left(u_1,\ldots,u_n\right)$. We can use $\mathbf{H}$ to obtain a compact form of the dynamics of $\vect{u}$\begin{align*} \vect{u}(k+1) = \vect{u}(k) - \eta \mathbf{H}(\vect{y}-\vect{u}(k)). \end{align*} Thus we have \begin{align*} \vect{y}-\vect{u}(k+1) = (1-\eta\mathbf{H})(\vect{y}-\vect{u}(k)) \end{align*} and we obtain the linear convergence dynamics \begin{align*} \norm{\vect{y}-\vect{u}(k+1)}_2 \le (1-\eta\lambda_{\min}(\mathbf{H}))\norm{\vect{y}-\vect{u}(k)}_2 \end{align*} if the step size satisfies $\eta < \lambda_{\max}(\mathbf{H})$. The key insight from this analysis is that as long as the Gram matrix $\mathbf{H}$ is full rank, we obtain the linear convergence on the prediction space. \subsection{Features Generated by Random Initialization and ReLU} \label{sec:random_features} In this section, we consider an ideal setting in which we first randomly initialize $\mathbf{W}$ and $\vect{a}$, then use them to act on inputs $\vect{x}_i$s to generate features and we fix these feature and optimize $\mathbf{W}$. Specifically, for $\vect{x}_i$ we generate a new feature \[ \mathbf{X}_i' = \begin{pmatrix}\frac{1}{\sqrt{m}} a_1 \mathbb{I}\left\{(\vect{w}_1^{(0)})^\top \vect{x}_i \ge 0\right\} \vect{x}_i, \ldots, \frac{1}{\sqrt{m}}a_m \mathbb{I} \left\{\left(\vect{w}_m^{(0)}\right)^\top \vect{x}_i\ge 0\right\}\vect{x}_i \end{pmatrix} \in \mathbb{R}^{d \times m}. \] Once we fix the feature and because we only train $\mathbf{W}$ it becomes a linear regression problem\begin{align} \widetilde{L}(\mathbf{W}) = \frac{1}{n}\sum_{i=1}^{n} \left(\langle\mathbf{W},\mathbf{X}_i'\rangle - y_i\right)^2 \label{eqn:loss_regression_rf} \end{align} The corresponding Gram matrix is \begin{align*} H_{ij} = &\vectorize{\vect{X}_i'}^\top \vectorize{\vect{X}_j'} \\ = &\frac{1}{m} \sum_{r=1}^{m}a_r^2 \mathbb{I}\left\{(\vect{w}_r^{(0)})^\top \vect{x}_i \ge 0 (\vect{w}_r^{(0)})^\top \vect{x}_j \ge 0\right\} \vect{x}_i^\top \vect{x}_j. \end{align*} This $H_{ij}$ is the $(i,j)$-th entry of Gram matrix $\mathbf{H}$. We can call $\mathbf{H}$ a Gram matrix because we can view $H_{ij}$ inner product of the feature map that transforms an input $\vect{x}$ into $\vectorize{\mathbf{X'}}$. If $a_r$ is sampled from a zero mean and unit variance distribution and $\vect{w}_r^{(0)}$ is sampled from Gaussian distribution with identity covariance, as $m \rightarrow \infty$ \begin{align*} H_{ij} \rightarrow \mathbb{E}_{\vect{w} \sim N(\vect{0},\mathbf{I})}\left[\mathbb{I}\left\{\vect{w}^\top \vect{x}_i \ge 0, \vect{w}^\top \vect{x}_j \ge 0\right\}\vect{x}_i^\top \vect{x}_j\right] = \frac{pi - \theta(\vect{x}_i,\vect{x}_j)}{2\pi} \vect{x}_i\vect{x}_j\triangleq H_{ij}^\infty. \end{align*} where $\theta(\vect{x}_i,\vect{x}_j)$ is the angle between $\vect{x}_i$ and $\vect{x}_j$. This $H_{ij}^\infty$ is the $(i,j)$-th entry of Gram matrix $\mathbf{H}^\infty$ as $m \rightarrow \infty$. Note in general, unless the data is degenerate, the smallest eigenvalue of $\mathbf{H}^\infty$ is strictly positive. We refer readers to \cite{xie2017diverse} to a more detailed discussion of this matrix. By standard concentration bounds, we can also bound the distance between $\mathbf{H}$ and $\mathbf{H}^\infty$. Thus when $m$ is large, $\mathbf{H}$ is full rank and we still have the linear convergence rate for problem~\eqref{eqn:loss_regression_rf}. \subsection{Over-parameterization Stabilizes Gram Matrix} \label{sec:overparams_stable} Different from loss function~\eqref{eqn:loss_regression_rf}, the Gram matrix induced by the original loss function~\eqref{eqn:loss_regression} is changing because the feature map depends on $\mathbf{W}$ which is being updated at every iteration:\begin{align*} H_{ij}(k) = \frac{1}{m} \sum_{r=1}^{m}a_r^2 \mathbb{I}\left\{(\vect{w}_r(k)^\top \vect{x}_i \ge 0, (\vect{w}_r(k)^\top \vect{x}_j \ge 0\right\} \vect{x}_i^\top \vect{x}_j. \end{align*} The first observation is this Gram matrix is stable with respect to the change of $\vect{w}_r$s because if $\abs{\vect{w}_r(0)^\top \vect{x}_i} \ge \gamma$ for some margin $\gamma$, only if $\abs{(\vect{w}_r(k)-\vect{w}_r(0))^\top \vect{x}_i} \ge \gamma$, the term \[a_r^2 \mathbb{I}\left\{(\vect{w}_r(k)^\top \vect{x}_i \ge 0, (\vect{w}_r(k)^\top \vect{x}_j \ge 0\right\} \vect{x}_i^\top \vect{x}_j\] may change. Furthermore, though some terms change, because of the normalization term $1/m$, they will only incur a small perturbation from $\mathbf{H}$. Therefore, $\mathbf{H}(k)$ is still full rank if the perturbation is small. We formalize this observation in Section~\ref{sec:two_layer_regression}. Thus it is sufficient to show every $\vect{w}_r$ is close to it initialization. First note that if the loss converges to $0$ with a linear rate (which can be guaranteed if $\mathbf{H}$ is always full rank), we can have $ \sum_{k=0}^{\infty} \sqrt{L(\mathbf{W}(k))} \le \kappa \sqrt{L\left(\mathbf{W}(0)\right)} $ for some $\kappa > 0$ which is related to the specific convergence rate and independent of $m$. We next examine the gradient of $\vect{w}_r$: \begin{align} \norm{\frac{\partial L(\mathbf{W})}{\partial \vect{w}_r}}_2 = & \norm{\sum_{i=1}^n(f(\mathbf{W},\vect{a},\vect{x}_i)-y_i)\frac{1}{\sqrt{m}}a_r\vect{x}_i\mathbb{I}\left\{\vect{w}_r(t)^\top \vect{x}_i \ge 0\right\} }_2 \nonumber\\ \le & \frac{\sqrt{n}}{\sqrt{m}}\sqrt{L(\mathbf{W})} \max_{r}\abs{a_r}\max_i\norm{\vect{x}_i}_2. \label{eqn:power_of_overparams} \end{align} Using from Equation~\eqref{eqn:power_of_overparams}, we can bound the total deviation of a weight vector\begin{align*} \norm{\vect{w}_r(k)-\vect{w}_r(0)}_2 \le &\sum_{k'=0}^{\infty} \norm{\frac{\partial L(\mathbf{W}(k'))}{\partial \vect{w}_r(k')}}_2 \\ \le & \frac{\sqrt{n}\kappa \sqrt{L(\mathbf{W}(0))} \max_{r}\abs{a_r}\max_i\norm{\vect{x}_i}_2}{\sqrt{m}}. \end{align*} From this inequality, it is easy to see if $m$ is large enough, the deviation is small. The $\sqrt{m}$ in the denominator clearly demonstrates the power of over-parameterization. \subsection{Proof of Theorem~\ref{thm:main_gf}} Our first step is to calculate the dynamics of each prediction. \begin{align} \frac{d}{dt} u_i(t) = &\sum_{r=1}^{m}\langle\frac{\partial f(\mathbf{W}(t),\vect{a},\vect{x}_i)}{\partial \vect{w}_r(t)},\frac{d \vect{w}_r(t)}{dt} \rangle \nonumber\\ = & \sum_{j=1}^{n}(y_j -u_j) \sum_{r=1}^{m}\langle\frac{\partial f(\mathbf{W}(t),\vect{a},\vect{x}_i)}{\partial \vect{w}_r(t)} ,\frac{\partial f(\mathbf{W}(t),\vect{a},\vect{x}_j)}{\partial\vect{w}_r(t)} \rangle \triangleq \sum_{j=1}^{n}(y_j-u_j) \mathbf{H}_{ij}(t) \label{eqn:individual_dynamics} \end{align} where $\mathbf{H}(t)$ is an $n \times n$ matrix with $(i,j)$-th entry \begin{align} \mathbf{H}_{ij}(t) = \frac{1}{m} \vect{x}_i^\top \vect{x}_j\sum_{r=1}^m \mathbb{I}\left\{\vect{x}_i^\top \vect{w}_r(t) \ge 0, \vect{x}_j^\top \vect{w}_r(t) \ge 0\right\}. \label{eqn:H_t} \end{align} With this $\mathbf{H}(t)$ matrix, we can write the dynamics of predictions in a compact way: \begin{align} \frac{d}{dt} \vect{u}(t) = \mathbf{H}(t)(\vect{y}-\vect{u}(t)). \label{eqn:key_dynamics} \end{align} \begin{rem}\label{rem:key_remark} Note Equation~\eqref{eqn:key_dynamics} completely describes the dynamics of the predictions. In the rest of this section, we will show (1) at initialization $\norm{\mathbf{H}(0) - \mathbf{H}^{\infty}}_2$ is $O(\sqrt{1/m})$ and (2) for all $t > 0$, $\norm{\mathbf{H}(t)-\mathbf{H}(0)}_2$ is $O(\sqrt{1/m})$. Therefore, according to Equation~\eqref{eqn:key_dynamics}, as $m \rightarrow \infty$, the dynamics of the predictions are characterized by $\mathbf{H}^\infty$. This is the main reason we believe $\mathbf{H}^{\infty}$ is the fundamental quantity that describes this optimization process. \end{rem} $\mathbf{H}(t)$ is a time-dependent symmetric matrix. We first analyze its property when $t=0$. The following lemma shows if $m$ is large then $\mathbf{H}(0)$ has a lower bounded least eigenvalue with high probability. The proof is by the standard concentration bound so we defer it to the appendix. \begin{lem}\label{lem:H0_close_Hinft} If $m = \Omega\left(\frac{n^2}{\lambda_0^2} \log\left(\frac{n}{\delta}\right)\right)$, we have with probability at least $1-\delta$, $\norm{\mathbf{H}(0)-\mathbf{H}^{\infty}}_2 \le \frac{\lambda_0}{4}$ and $\lambda_{\min}(\mathbf{H}(0)) \ge \frac{3}{4}\lambda_0$. \end{lem} Our second step is to show $\mathbf{H}(t)$ is stable in terms of $\mathbf{W}(t)$. Formally, the following lemma shows for any $\mathbf{W}$ close to $\mathbf{W}(0)$, the induced Gram matrix $\mathbf{H}$ is close to $\mathbf{H}(0)$ and has a lower bounded least eigenvalue. \begin{lem}\label{lem:close_to_init_small_perturbation} If $\vect{w}_1,\ldots,\vect{w}_m$ are i.i.d. generated from $N(\vect{0},\mathbf{I})$, then with probability at least $1-\delta$, the following holds. For any set of weight vectors $\vect{w}_1,\ldots,\vect{w}_m \in \mathbb{R}^{d}$ that satisfy for any $r \in [m]$, $\norm{\vect{w}_r(0)-\vect{w}_r}_2 \le \frac{c\delta\lambda_0}{n^2} \triangleq R$ for some small positive constant $c$, then the matrix $\mathbf{H} \in \mathbb{R}^{n \times n}$ defined by \[ \mathbf{H}_{ij} = \frac{1}{m} \vect{x}_i^\top \vect{x}_j \sum_{r=1}^{m}\mathbb{I}\left\{ \vect{w}_r^\top \vect{x}_i \ge 0, \vect{w}_r^\top \vect{x}_j \ge 0 \right\} \] satisfies $\norm{\mathbf{H}-\mathbf{H}(0)}_2 < \frac{\lambda_0}{4}$ and $\lambda_{\min}\left(\mathbf{H}\right) > \frac{\lambda_0}{2}$. \end{lem} This lemma plays a crucial role in our analysis so we give the proof below. \emph{Proof of Lemma~\ref{lem:close_to_init_small_perturbation}} We define the event \[A_{ir} = \left\{\exists \vect{w}: \norm{\vect{w}-\vect{w}_r(0)} \le R, \mathbb{I}\left\{\vect{x}_i^\top \vect{w}_r(0) \ge 0\right\} \neq \mathbb{I}\left\{\vect{x}_i^\top \vect{w} \ge 0\right\} \right\}.\] Note this event happens if and only if $\abs{\vect{w}_r(0)^\top \vect{x}_i} < R$. Recall $\vect{w}_r(0) \sim N(\vect{0},\mathbf{I})$. By anti-concentration inequality of Gaussian, we have $ P(A_{ir}) = P_{z \sim N(0,1)}\left(\abs{z} < R\right) \le \frac{2R}{\sqrt{2\pi}}. $ Therefore, for any set of weight vectors $\vect{w}_1,\ldots,\vect{w}_m$ that satisfy the assumption in the lemma, we can bound the entry-wise deviation on their induced matrix $\mathbf{H}$: for any $(i,j) \in[n] \times [n]$\begin{align*} &\mathbb{E}\left[\abs{\mathbf{H}_{ij}(0)-\mathbf{H}_{ij}}\right] \\ = &\mathbb{E}\left[ \frac{1}{m}\abs{\vect{x}_i^\top\vect{x}_j \sum_{r=1}^{m} \left(\mathbb{I}\left\{ \vect{w}_r(0)^\top \vect{x}_i \ge 0, \vect{w}_r(0)^\top \vect{x}_j \ge 0 \right\} - \mathbb{I}\left\{ \vect{w}_r^\top \vect{x}_i \ge 0, \vect{w}_r^\top \vect{x}_j \ge 0 \right\} \right)} \right] \\ \le & \frac{1}{m} \sum_{r=1}^{m}\mathbb{E}\left[\mathbb{I}\left\{A_{ir} \cup A_{jr}\right\}\right] \le \frac{4R}{\sqrt{2\pi}} \end{align*}where the expectation is taken over the random initialization of $\vect{w}_1(0),\ldots,\vect{w}_m(0)$. Summing over $(i,j)$, we have $ \mathbb{E}\left[\sum_{(i,j)=(1,1)}^{(n,n)} \abs{\mathbf{H}_{ij}-\mathbf{H}_{ij}(0)}\right] \le \frac{4n^2R}{\sqrt{2\pi}}. $ Thus by Markov's inequality, with probability $1-\delta$, we have $\sum_{(i,j)=(1,1)}^{(n,n)} \abs{\mathbf{H}_{ij}-\mathbf{H}_{ij}(0)}\le \frac{4n^2 R}{\sqrt{2\pi}\delta}$. Next, we use matrix perturbation theory to bound the deviation from the initialization\begin{align*} \norm{\mathbf{H} - \mathbf{H}(0)}_2 \le \norm{\mathbf{H} - \mathbf{H}(0)}_F \le \sum_{(i,j)=(1,1)}^{(n,n)} \abs{\mathbf{H}_{ij}-\mathbf{H}_{ij}(0)} \le \frac{4n^2 R}{\sqrt{2\pi}\delta}. \end{align*} Lastly, we lower bound the smallest eigenvalue by plugging in $R$\begin{align*} \lambda_{\min}(\mathbf{H}) \ge \lambda_{\min}(\mathbf{H}(0)) -\frac{4n^2 R}{\sqrt{2\pi}\delta} \ge \frac{ \lambda_0}{2}. \qed \end{align*} The next lemma shows two facts if the least eigenvalue of $\mathbf{H}(t)$ is lower bounded. First, the loss converges to $0$ at a linear convergence rate. Second, $\mathbf{w}_r(t)$ is close to the initialization for every $r \in [m]$. This lemma clearly demonstrates the power of over-parameterization. \begin{lem}\label{lem:small_perturbation_close_to_init} Suppose for $0 \le s \le t$, $\lambda_{\min}\left(\mathbf{H}(s)\right) \ge \frac{\lambda_0}{2}$. Then we have $\norm{\vect{y}-\vect{u}(t)}_2^2 \le \exp(-\lambda_0 t)\norm{\vect{y}-\vect{u}(0)}_2^2$ and for any $r \in [m]$, $ \norm{\vect{w}_r(t)-\vect{w}_r(0)}_2 \le \frac{\sqrt{n}\norm{\vect{y}-\vect{u}(0)}_2}{\sqrt{m}\lambda_0}\triangleq R'. $ \end{lem} \emph{Proof of Lemma~\ref{lem:small_perturbation_close_to_init}} Recall we can write the dynamics of predictions as $ \frac{d}{dt} \vect{u}(t) = \mathbf{H}(\vect{y}-\vect{u}(t)). $ We can calculate the loss function dynamics\begin{align*} \frac{d}{dt} \norm{\vect{y}-\vect{u}(t)}_2^2 = &-2 \left(\vect{y}-\vect{u}(t)\right)^\top\mathbf{H}(t)\left(\vect{y}-\vect{u}(t)\right) \\ \le & -\lambda_0 \norm{\vect{y}-\vect{u}(t)}_2^2. \end{align*} Thus we have $ \frac{d}{dt}\left(\exp(\lambda_0 t)\norm{\vect{y}-\vect{u}(t)}_2^2\right) \le 0 $ and $\exp(\lambda_0 t)\norm{\vect{y}-\vect{u}(t)}_2^2$ is a decreasing function with respect to $t$. Using this fact we can bound the loss\begin{align*} \norm{\vect{y}-\vect{u}(t)}_2^2 \le \exp(-\lambda_0 t)\norm{\vect{y}-\vect{u}(0)}_2^2. \end{align*} Therefore, $\vect{u}(t) \rightarrow \vect{y}$ exponentially fast. Now we bound the gradient norm. Recall for $0 \le s \le t$, \begin{align*} \norm{\frac{d}{ds}\vect{w}_r(s)}_2 = &\norm{\sum_{i=1}^n(y_i-u_i)\frac{1}{\sqrt{m}}a_r\vect{x}_i\mathbb{I}\left\{\vect{w}_r(s)^\top \vect{x}_i \ge 0\right\}}_2 \\ \le &\frac{1}{\sqrt{m}}\sum_{i=1}^{n} \abs{y_i-u_i(s)} \le \frac{\sqrt{n}}{\sqrt{m}}\norm{\vect{y}-\vect{u}(s)}_2 \le \frac{\sqrt{n}}{\sqrt{m}} \exp(-\lambda_0 s)\norm{\vect{y}-\vect{u}(0)}_2. \end{align*} Integrating the gradient, we can bound the distance from the initialization \begin{align*} \norm{\vect{w}_r(t)-\vect{w}_r(0)}_2 \le \int_{0}^{t}\norm{\frac{d}{ds}\vect{w}_r(s)}_2 ds \le \frac{\sqrt{n}\norm{\vect{y}-\vect{u}(0)}_2}{\sqrt{m}\lambda_0}. \qed \end{align*} The next lemma shows if $R' < R$, the conditions in Lemma~\ref{lem:close_to_init_small_perturbation} and~\ref{lem:small_perturbation_close_to_init} hold for all $t\ge 0$. The proof is by contradiction and we defer it to appendix. \begin{lem}\label{lem:main} If $R' < R$, we have for all $t \ge 0 $, $\lambda_{\min}\mathbf{(H}(t)) \ge \frac{1}{2}\lambda_0$, for all $r \in [m]$, $\norm{\vect{w}_r(t)-\vect{w}_r(0)}_2 \le R'$ and $\norm{\vect{y}-\vect{u}(t)}_2^2 \le \exp(-\lambda_0 t)\norm{\vect{y}-\vect{u}(0)}_2^2$. \end{lem} Thus it is sufficient to show $R' < R$ which is equivalent to $ m = \Omega\left(\frac{n^5\norm{\vect{y}-\vect{u}(0)}_2^2}{\lambda_0^4\delta^2}\right). $ We bound \begin{align*} \mathbb{E}\left[\norm{\vect{y}-\vect{u}(0)}_2^2\right] = \sum_{i=1}^{n} (y_i^2 + y_i \mathbb{E} \left[f(\mathbf{W}(0),\vect{a},\vect{x}_i)\right] + \mathbb{E}\left[f(\mathbf{W}(0),\vect{a},\vect{x}_i)^2\right]) = \sum_{i=1}^n (y_i^2 + 1) = O(n). \end{align*} Thus by Markov's inequality, we have with probability at least $1-\delta$, $\norm{\vect{y}-\vect{u}(0)}_2^2 = O(\frac{n}{\delta})$. Plugging in this bound we prove the theorem. \qed \subsection{Jointly Training Both Layers} \label{sec:joint_training} In this subsection, we showcase our proof technique can be applied to analyze the convergence of gradient flow for jointly training both layers. Formally, we consider the ordinary differential equation defined by: \begin{align*} \frac{d\vect{w}_r(t)}{dt} = - \frac{\partial L(\mathbf{W}(t),\vect{a}(t))}{\partial \vect{w}_r(t)} \text{ and }\frac{d\vect{w}_r(t)}{dt} = - \frac{\partial L(\mathbf{W}(t),\vect{a}(t))}{\partial \vect{a}_r(t)} \end{align*} for $r=1,\ldots,m$. The following theorem shows using gradient flow to jointly train both layers, we can still enjoy linear convergence rate towards zero loss. \begin{thm}[Convergence Rate of Gradient Flow for Training Both Layers] \label{thm:main_gf_joint} Under the same assumptions as in Theorem~\ref{thm:main_gf}, if we set the number of hidden nodes $m = \Omega\left(\frac{n^6\log(m/\delta)}{\lambda_0^4\delta^3}\right) $ and we i.i.d. initialize $\vect{w}_r \sim N(\vect{0},\mathbf{I})$, $a_r \sim \mathrm{unif}\left[\left\{-1,1\right\}\right]$ for $r \in [m]$, with probability at least $1-\delta$ over the initialization we have \begin{align*} \norm{\vect{u}(t)-\vect{y}}_2^2 \le \exp(-\lambda_0 t)\norm{\vect{u}(0)-\vect{y}}_2^2. \end{align*} \end{thm} Theorem~\ref{thm:main_gf_joint} shows under the same assumptions as in Theorem~\ref{thm:main_gf}, we can achieve the same convergence rate as that of only training the first layer. The proof of Theorem~\ref{thm:main_gf_joint} relies on the same arguments as the proof of Theorem~\ref{thm:main_gf}. Again we consider the dynamics of the predictions and this dynamics is characterized by a Gram matrix. We can show for all $t > 0$, this Gram matrix is close to the Gram matrix at the initialization phase. We refer readers to appendix for the full proof.
{'timestamp': '2019-02-06T02:05:02', 'yymm': '1810', 'arxiv_id': '1810.02054', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02054'}
arxiv
\section{Introduction} Performance of non-orthogonal multiple access (NOMA) in both uplink and downlink depends on the successive intra-cell interference cancellation (SIC) which relies on the ranking of the users in each NOMA cluster \cite{2017uplink}. In particular, downlink intra-cell interference received at a given user in NOMA depends on the power allocation factors of users in the cluster. These power allocation factors are designed according to the ranking of users' transmission links quality. For example, users with stronger links have smaller power allocations and vice versa. On the other hand, in uplink NOMA, to apply SIC, BS successively decodes and cancels the messages of strong channel users, prior to decoding the signals of weak channel users \cite{2017uplink}. Therefore, the intra-cell interference encountered by any user depends on the instantaneous received signal powers (which includes short-term fading) of users in the NOMA cluster. The link quality can be evaluated by different metrics. These metrics should include effects of path-loss (and therefore link distance), fading, and/or inter-cell interference\footnote{Note that uplink inter-cell interference at the desired BS is same for different users in a NOMA cluster. Therefore, signal power-based ranking and signal-to-intercell-interference-ratio (SINR)-based ranking yield the same result.}~\cite{ali2018downlink}. However, acquiring complete channel state information (CSI) with fading and inter-cell interference increases system complexity. Therefore, most of the existing state-of-the-art resorts to mean signal power- (or distance-) based user ranking in NOMA analysis. Recently, in \cite{Tabassum2017}, the rate coverage probability of a user at rank $m$ in uplink NOMA has been derived assuming distance-based ranking. In \cite{Wildemeersch2014,Geraci2016}, it is assumed that the order statistics of instantaneous signal power are dominated by the distance; hence, in the analysis, users are ordered based on their distances instead of complete CSI. In \cite{Shi2018,Choi2016}, distance-based ranking is used for the analysis of NOMA systems with HARQ. In \cite{Liu2016jsac}, the authors study two-user cooperative NOMA and derive the outage probability assuming the near user to be the strong user and the far user to be the weak user. In \cite{Ding2016twc}, a similar assumption is made for the analysis of uplink and downlink MIMO NOMA. In order to maximize the rate region of the uplink NOMA systems, in \cite{Chingoska2016letter}, decoding order of the information signal {at the BS} is the inverse of the distances. In \cite{ali2018downlink}, the authors derive the outage probability in downlink Poisson cellular networks where users are ranked based on mean signal power and {instantaneous SINR}. To avoid analytical complexity (in theory) and overcome implementation complexity, mean signal power- (distance-) based ranking is typically considered to be appropriate for ordering users in a NOMA cluster. Although this method simplifies the analysis and provides tractable results, its validation (i.e., {\em accuracy}) has not been studied yet. The distance-based ordering may not always be accurate, especially in a dynamic multipath fading environment, where a near user can experience severe fading and a far user can observe weak fading. Since the ranking of users in a NOMA system has a direct impact on the system performance (e.g., coverage probability) analysis, it is crucial to quantify the impact of distance-based ranking in various environments and to identify the scenarios where this ranking is accurate (i.e., provides system performance close to that achievable with full CSI-based user ranking). The contributions of this paper can be summarized as follows: \begin{itemize} \item This paper characterizes the accuracy of analyzing the performance of a NOMA system where users are ranked according to their distances (or, equivalently, mean signal powers) instead of instantaneous signal powers, i.e., product of their distance-based path-loss and fading channel. In particular, we derive the probability of the event when distance-based ranking yields same results as instantaneous signal power-based ranking, which is referred to as the {\em accuracy probability}. \item We characterize the accuracy probability considering Nakagami-$m$ fading and three different spatial distribution models of user locations in NOMA, namely, Poisson Point Process (PPP), Matern Cluster Process (MCP), and Thomas Cluster Process (TCP). For all three user location models, the spatial locations of the BSs are assumed to follow a homogeneous PPP. The expressions are applicable to both uplink and downlink NOMA scenarios. \item By analyzing the properties of the derived accuracy probability, we show that the accuracy probability decreases with the increasing number of NOMA users and increases with the path-loss exponent. Closed-form expressions are derived for special cases with two and three users in a NOMA cluster and Rayleigh fading. In addition, through examples, we illustrate the impact of accuracy probability on uplink and downlink. We observe that the impact of distance-based ranking on network performance metrics such as coverage probability is different in the uplink and the downlink. \item Using the derived expressions, we obtain following insights: (i) For the PPP model, the accuracy probability does not depend on BS intensity $\lambda$, (ii) For the MCP model, the accuracy probability does not depend on cluster radius $R$, (iii) For TCP model, the accuracy probability does not depend on scattering variance $\sigma^2$, which is a measure of cluster size. \item Finally, we study the impact of fading severity and user selection on the accuracy probability. \end{itemize} The rest of the paper is organized as follows. The system model and assumptions are presented in Section~II. The definition and properties of the accuracy probability are provided in Section III along with the discussions on their impact on uplink and downlink coverage probability. For Rayleigh and Nakagami-$m$ fading, the accuracy probability is derived in Sections IV and V, respectively. In Section VI, the impact of user pairing on the accuracy probability is investigated. Numerical results are presented in Section VII. Finally, Section VIII concludes the paper. \section{System Model and Assumptions} We assume that the spatial locations of the BSs follow a homogeneous Poisson point process (PPP) $\Phi$ of intensity $\lambda$ and those of the users follow three different models as described in the following. \begin{itemize} \item {\bf PPP:} Users are distributed according to a homogeneous PPP $\Phi_{\rm U}$ of intensity $\lambda_{\rm u}$ and each user is associated to its nearest BS. We consider a heavily loaded regime, i.e., $\lambda_{\rm u}\gg\lambda$ where we have at least $N$ users in a typical Voronoi cell\footnote{In a heavily loaded network, when $N$ is small, assuming that we have at least $N$ users in a typical cell, is not unrealistic. For instance, when $\lambda_{\rm u}/\lambda=10$, according to \cite{Yu2013}[Lemma 1], the probability of having more than one user in the typical cell is 0.97 and probability of having more than two users is 0.93.}. To form a NOMA cluster of size $N$ in the typical cell, we randomly select $N$ users. Therefore, NOMA users are uniformly distributed within the typical Voronoi cell. The explicit distribution of the main geometrical characteristics of the typical cell of a Voronoi tessellation is not known \cite{Renzo2018}. In \cite{Mukherjee2012,Haenggi2017user,Wang2017}, taking $c=5/4$, the probability density function (PDF) and the cumulative distribution function (CDF) of the distance for a typical user from its serving BS can be approximated, respectively, as follows: \begin{IEEEeqnarray}{rCl} f_r(x)\approx 2 c \lambda \pi x e^{-c \lambda \pi x^2}, \qquad F_r(x)\approx 1 - e^{-c \lambda \pi x^2}, \qquad x\ge 0. \label{eq:PDF-PPP} \end{IEEEeqnarray} \item {\bf Matern Cluster Process (MCP):} Users are spatially distributed according to an MCP, where the BS point process $\Phi$ is the parent point process. In each NOMA cluster, $N$ users are uniformly distributed in a ball of radius $R$ centered at the serving BS\footnote{For MCP and TCP models, we also assume that network is heavily loaded.}. The PDF and CDF of the link distance from an arbitrary user in a cluster {to its serving BS} are given, respectively, as: \begin{IEEEeqnarray}{rCl} f_r(x)=\frac{2x}{R^2}\mathbf{1}(0 \le x \le R), \qquad F_r(x)=\frac{x^2}{R^2}\mathbf{1}(0 \le x \le R), \label{eq:PDF-MCP} \end{IEEEeqnarray} where $\mathbf{1}(.)$ is the indicator function. \item {\bf Thomas Cluster Process (TCP):} Users are distributed according to a TCP, where BS point process $\Phi$ is the parent point process. Each NOMA cluster is formed by randomly selecting $N$ users from the set of users that have the same parent. The PDF and the CDF of the link distance between an arbitrary user and its serving BS are given, respectively, as follows: \begin{IEEEeqnarray}{rCl} f_r(x)=\frac{x}{\sigma^2} \exp \left\{-\frac{x^2}{2\sigma^2}\right\}, \qquad F_r(x)=1 - \exp \left\{-\frac{x^2}{2\sigma^2}\right\}, \qquad x\ge 0. \label{eq:PDF-TCP} \end{IEEEeqnarray} In particular, $N$ users are independently and identically distributed following a normal distribution with variance $\sigma^2$ around each BS. \end{itemize} Let us denote the distance between the $i$-th nearest user (termed rank $i$ user) and the serving BS by $r_{(i)}$, $1\le i\le N$. The received power, for the user at rank $i$, is modeled by $h_ir_{(i)}^{-\alpha}$. $r_{(i)}^{-\alpha}$ represents the large-scale path-loss where $\alpha>2$ is the path-loss exponent. $h_i$ models the channel power gain due to small-scale fading. The channel power gains follow independent gamma distribution with parameter $m$ and mean $\Omega$ for Nakagami-$m$ fading environment, i.e., \begin{IEEEeqnarray}{rCl} f_h(x)=\frac{m^m x^{m-1}}{\Gamma(m) \Omega^m}\exp\left( -\frac{mx}{\Omega} \right), \end{IEEEeqnarray} where $\Gamma(.)$ is the gamma function. By setting $m=1$, it reduces to the exponential distribution, corresponding to Rayleigh fading. \section{Probability of Accuracy: Definition and Properties} Ranking users based on their distances from the serving BS in each NOMA cluster is a common assumption in the existing literature to characterize the performance of NOMA. That is, the nearest user to the serving BS is assumed as the user with the highest CSI and so on (which may not always be true). To understand the accuracy of this approximation and its impact on important performance metrics such as coverage probability, in this section, we define the term {\em accuracy probability} $\mathcal{A}$, highlight its properties, and describe its connection to uplink and downlink coverage probability through examples. \begin{Definition}[Accuracy probability] \label{Def1} Accuracy probability $\mathcal{A}$ is the probability that ordering based on large-scale path loss\footnote{For a fixed path-loss exponent, we use path-loss-based ranking and ``distance-based ranking'' interchangeably throughout the paper.} matches ordering based on the instantaneous signal power (small-scale fading and large-scale path-loss), i.e., \begin{IEEEeqnarray}{rCl} \mathcal{A}=\mathbb{P}\left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right). \label{eq:match-probability} \end{IEEEeqnarray} Therefore, ordering users based on path-loss, instead of instantaneous signal power is accurate with probability $\mathcal{A}$. \end{Definition} Using the indicator function, the accuracy probability can be expressed as \begin{IEEEeqnarray}{rCl} \mathcal{A}&=&\mathbb{E}_{\{h_i\},\{r_{(i)}\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right] \nonumber \\ &=& \mathbb{E}_{\{r_{(i)}\}} \left[ \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right] \right]. \label{eq:match-expectation} \end{IEEEeqnarray} The inner expectation in \eqref{eq:match-expectation} is over the channel power gains $\left\{ h_i \right\}$, i.e., the inner expectation calculates the accuracy probability for a given realization of users and BSs. The outer expectation is with respect to the ordered desired link distances $\left\{ r_{(i)} \right\}$. In the derivation of the outer expectation we use the following definition. \begin{Definition}[Joint PDF of $N$-ordered Random Variables] Let $r_1,r_2,...,r_N$ be a set of $N$ i.i.d. random variables with PDF $f_r(x)$. Let $r_{(i)}$ denote the $i$-th smallest observation of the $N$ random variables, i.e., $r_{(1)} \le r_{(2)} \le \cdots \le r_{(N)}$. The joint PDF of $N$-ordered random variables can then be given as \cite{yang2011order}: \begin{IEEEeqnarray}{rCl} f_{r_{(1)},r_{(2)},...,r_{(N)}}(x_1,x_2,...,x_N)=N! \prod_{i=1}^{N}f_r(x_i), \qquad x_1\le x_2\le \cdots \le x_N. \label{eq:statistic} \end{IEEEeqnarray} \end{Definition} In the following, two properties of the accuracy probability are reported. These properties are general and apply to any of the considered fading channel and users' spatial distributions. \begin{Corollary} The accuracy probability $\mathcal{A}$ fulfills the following properties: i) $\mathcal{A}$ is a decreasing function of NOMA cluster size $N$, ii) $\mathcal{A}$ is an increasing function of path-loss exponent $\alpha$. \end{Corollary} \begin{IEEEproof} The result in (i) follows from definition of the accuracy probability \eqref{eq:match-probability}. The result in (ii) follows from \eqref{eq:match-expectation}. If $h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha}$ is satisfied by $\alpha$, it will also be satisfied by higher values of path-loss exponent. On the other hand, if $h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha}$ is not satisfied by $\alpha$, any smaller value of path-loss exponent cannot also satisfy this condition. Therefore, when we increase the path-loss exponent, ranking users based on their distances is valid for wider range of channel and distance realizations, i.e., $\mathcal{A}$ is an increasing function of $\alpha$. \end{IEEEproof} Now we discuss the impact of ranking method on uplink and downlink coverage probability, respectively, as follows: \noindent {{\bf Example - Uplink NOMA:} To apply SIC, in each step, BS decodes the signal of user with the highest instantaneous signal power by treating other signals as noise. Therefore, for the 2-UE NOMA, the coverage probability of the near user to the BS ($ P_{{\rm cov},(1)}^{\rm ISP}$) should be derived as follows: \begin{IEEEeqnarray}{rCl} P_{{\rm cov},(1)}^{\rm ISP}&=&\mathbb{P} \left\{ \frac{P_{\rm tx}h_1 r_{(1)}^{-\alpha}}{P_{\rm tx}h_2 r_{(2)}^{-\alpha} + I_{\rm inter} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right\} \underbrace{\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right)}_{\mathcal{A}} \nonumber \\ && +\> \mathbb{P} \left\{ \frac{P_{\rm tx}h_1 r_{(1)}^{-\alpha}}{\beta P_{\rm tx}h_2 r_{(2)}^{-\alpha} + I_{\rm inter} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right\} \mathbb{P}\left( h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right), \label{eq:example1_1} \end{IEEEeqnarray} where $I_{\rm inter}$ denotes the inter-cell interference; $\sigma_n^2$ is the noise power, $P_{\rm tx}$ is the transmit power, and $\beta\in[0,1]$ captures the effect of imperfect SIC. According to \eqref{eq:example1_1}, when $h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha}$, BS decodes the intended signal of near user in the presence of interference from far user, and when $h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha}$, BS decodes and cancels the signal of far user and then decodes the intended signal of near user. Similarly, for the far user, we have \begin{IEEEeqnarray}{rCl} P_{{\rm cov},(2)}^{\rm ISP}&=&\mathbb{P} \left\{ \frac{P_{\rm tx}h_2 r_{(2)}^{-\alpha}}{\beta P_{\rm tx}h_1 r_{(1)}^{-\alpha} + I_{\rm inter} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right\} {\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right)} \nonumber \\ && +\> \mathbb{P} \left\{ \frac{P_{\rm tx}h_2 r_{(2)}^{-\alpha}}{ P_{\rm tx}h_1 r_{(1)}^{-\alpha} + I_{\rm inter} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right\} \mathbb{P}\left( h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right). \label{eq:example1_2} \end{IEEEeqnarray}} {In the analysis of uplink NOMA, it is generally assumed that the nearest user to the BS has the highest instantaneous signal power, i.e., $\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \approx 1$ for 2-UE NOMA. Hence, only the first terms in \eqref{eq:example1_1} and \eqref{eq:example1_2} are derived to date in the literature and reported as $P_{{\rm cov},(1)}^{\rm ISP}$ and $P_{{\rm cov},(2)}^{\rm ISP}$, respectively. However, the first terms in \eqref{eq:example1_1} and \eqref{eq:example1_2} provide good approximations only when: i) network is intercell-interference- (or noise-) limited, ii) $\beta$ is close to 1, i.e, unsuccessful SIC is very likely, or iii) assumption $\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \approx 1$ is accurate. In \figref{fig:Coverage_uplink}, $P_{{\rm cov},(1)}^{\rm ISP}$, $P_{{\rm cov},(2)}^{\rm ISP}$, and their approximations based on the assumption $\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \approx 1$ (in the plots denoted by the legend ``MSP") are provided. According to \figref{fig:Coverage_uplink}, the coverage probability can be significantly different for the distance-based ranking and full CSI-based ranking.} \begin{figure} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[$\beta=0$ (perfect SIC).] {\epsfig{file=Effect_of_ranking_on_coverage.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[$\beta=0.5$.] {\epsfig{file=Effect_of_ranking_on_coverage_imperfect.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \caption{Uplink coverage probability for MCP model with $N=2$. $\lambda=0.0001$, $R=10$, $\sigma_n^2=0$, and $\alpha=4$. Coverage probabilities that are derived based on \eqref{eq:example1_1} and \eqref{eq:example1_2} are called ``ISP'' in the legend, and their approximations which are obtained by assuming $\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \approx 1$ are called ``MSP''.} \label{fig:Coverage_uplink} \end{figure} \noindent {{\bf Example - Downlink NOMA:} Order of decoding at a given user depends on the power allocations of users' signals at the BS. For 2-UE downlink NOMA, BS typically allocates more power to the weak user; thus, weak user can decode its intended signal in the presence of interference from the strong user. On the other hand, the strong user decodes and cancels the signal of weak user before decoding its intended signal. Therefore, with instantaneous signal power-based ranking at the BS, the coverage probabilities of near and far users are as follows: \begin{IEEEeqnarray}{rCl} P_{{\rm cov},(1)}^{\rm ISP}&=&\mathbb{P} \left\{ \frac{a_1 P_{\rm BS}h_1 r_{(1)}^{-\alpha}}{\beta a_2 P_{\rm BS}h_1 r_{(1)}^{-\alpha} + I_{\rm inter}^{(1)} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right\} \mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \nonumber \\ && +\> \mathbb{P} \left\{ \frac{a_2 P_{\rm BS}h_1 r_{(1)}^{-\alpha}}{a_1 P_{\rm BS}h_1 r_{(1)}^{-\alpha} + I_{\rm inter}^{(1)} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right\} \mathbb{P}\left( h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right), \quad \label{eq:example2_1} \end{IEEEeqnarray} \begin{IEEEeqnarray}{rCl} P_{{\rm cov},(2)}^{\rm ISP}&=&\mathbb{P} \left\{ \frac{a_2 P_{\rm BS}h_2 r_{(2)}^{-\alpha}}{a_1 P_{\rm BS}h_2 r_{(2)}^{-\alpha} + I_{\rm inter}^{(2)} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right\} {\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right)} \nonumber \\ && +\> \mathbb{P} \left\{ \frac{a_1 P_{\rm BS}h_2 r_{(2)}^{-\alpha}}{ \beta a_2 P_{\rm BS}h_2 r_{(2)}^{-\alpha} + I_{\rm inter}^{(2)} + \sigma_n^2} > \theta \mid h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right\} \mathbb{P}\left( h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha} \right). \nonumber \\ \label{eq:example2_2} \end{IEEEeqnarray} $a_1 P_{\rm BS}$ and $a_2 P_{\rm BS}$ denote the allocated powers to the strong and weak users where $0<a_1<a_2<1$ and $a_1+a_2=1$. Note that, unlike uplink, inter-cell interference seen at different users is different in downlink; $I_{\rm inter}^{(1)}$ and $I_{\rm inter}^{(2)}$ denote the inter-cell interference at the near and far users, respectively. With instantaneous signal power-based ranking at the BS, when $h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha}$, BS allocates more power to the far (weak) user, while, when $h_1 r_{(1)}^{-\alpha}<h_2 r_{(2)}^{-\alpha}$, more power is allocated to the near (weak) user. On the other hand, with distance-based ranking at the BS, BS always allocates more power to the far user, i.e., far user is always considered as the weak user. Therefore, coverage probabilities of the near and far users with distance-based ranking at the BS can be derived by the first terms in \eqref{eq:example2_1} and \eqref{eq:example2_2}, respectively. In \figref{fig:Coverage_downlink}, we compare the coverage probabilities for distance-based and instantaneous signal power-based ranking. Note that coverage probabilities with distance-based ranking provide close results to the coverage probabilities with instantaneous signal power-based ranking when: i) the network is intercell-interference- (or noise-) limited, or ii) the assumption $\mathbb{P}\left( h_1 r_{(1)}^{-\alpha}>h_2 r_{(2)}^{-\alpha} \right) \approx 1$ is accurate. \begin{figure} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[$\beta=0$ (perfect SIC).] {\epsfig{file=Effect_of_ranking_on_coverage_downlink.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[$\beta=0.5$.] {\epsfig{file=Effect_of_ranking_on_coverage_imperfect_downlink.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \caption{Downlink coverage probability for MCP model with $N=2$. $\lambda=0.0001$, $R=10$, $\sigma_n^2=0$, $a_1=0.3$, $a_2=0.7$, and $\alpha=4$. Coverage probabilities for instantaneous signal power-based ranking are called ``ISP'' in the legend, and coverage probabilities for distance- (mean signal power-) based ranking are called are called ``MSP''.} \label{fig:Coverage_downlink} \end{figure} } \section{Probability of Accuracy for Rayleigh Fading} In this section, we derive the accuracy probability $\mathcal{A}$ for Rayleigh fading considering PPP, MCP, and TCP for users' spatial location models. {Note that the results provided in this section for Rayleigh fading can also be obtained from the results derived in the next section for Nakagami-$m$ fading by setting $m=1$. However, for $N$-UE NOMA, calculating inner expectation in \eqref{eq:match-expectation} for Nakagami-$m$ fading yields $N-1$ integrals as is shown in {\bf Theorem \ref{Thm4}}. Deriving $\mathcal{A}$ for Rayleigh fading directly from {\bf Definition \ref{Def1}} is easier than deriving from {\bf Theorem \ref{Thm4}} except for some special cases such as $N=2$. Therefore, we first study the accuracy probability for Rayleigh fading in this section. Since steps of the proofs for Rayleigh and Nakagami-$m$ fading are similar, in the next section, we will only mention the steps or directly provide the final expressions. It is worth mentioning that the results in \textbf{Theorem \ref{Thm2}} and \textbf{Theorem \ref{Thm3}} can be obtained by solving the integrals in \textbf{Theorem \ref{Thm5}} and \textbf{Theorem \ref{Thm6}}, respectively, for $m=1$ and applying binomial expansion.} Our methodology to derive $\mathcal{A}$ can be described as follows: \begin{enumerate} \item Derive the inner expectation in \eqref{eq:match-expectation} by averaging over fading channel powers $\{h_i\}$. \item Characterize $\mathcal{A}$ for any arbitrary users' location model. \item Derive $\mathcal{A}$ by averaging over the distance distribution of users considering PPP, MCP, and TCP models, respectively. \end{enumerate} The first two steps are performed in the following Theorem and the third step is conducted in \textbf{Theorem~2}, \textbf{Theorem~3}, and in subsequent discussions. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - $N$ UE NOMA] \label{Thm1} For $N$-UE NOMA, the inner expectation in \eqref{eq:match-expectation} can be obtained by \begin{IEEEeqnarray}{rCl} \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right] &=& \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{(j)}}{r_{(i)}}\right)^{\alpha}}. \label{eq:inner-expectation-Rayleigh} \end{IEEEeqnarray} Then, using aforementioned expression, \eqref{eq:inner-expectation-Rayleigh}, and \textbf{Definition~2} we obtain \begin{IEEEeqnarray}{rCl} \mathcal{A}&=&\mathbb{E}\left[ \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{(j)}}{r_{(i)}}\right)^{\alpha}} \right] \nonumber \\ &=& N! \int_{0}^{\infty} \int_{r_1}^{\infty} \cdots \int_{r_{N-1}}^{\infty} \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{j}}{r_{i}}\right)^{\alpha}} f_r(r_1) f_r(r_2) \cdots f_r(r_N) {\rm d}r_N \cdots {\rm d}r_2 {\rm d}r_1. \label{eq:final-N_UE-rayleigh} \end{IEEEeqnarray} \end{theorem} \allowdisplaybreaks{ \begin{IEEEproof} See {\bf Appendix A.} \end{IEEEproof}} According to \textbf{Theorem \ref{Thm1}}, the accuracy probability does not depend on the mean channel power gain $\Omega$. In the following corollary, we provide a simplified expression for the inner expectation in \eqref{eq:match-expectation} considering 2-UE NOMA cluster\footnote{In this paper, we use the term ``$N$-UE NOMA'' to make it explicit that the framework can capture any value of $N$; however, the performance gains of NOMA over OMA (Orthogonal Multiple Access) are generally achievable for small number of user equipment (UE) in a NOMA cluster. Therefore, we are more interested in cases where $N = 2$ and $N = 3$.}. \begin{Corollary} \label{Cor1} Substituting $N=2$ in Theorem \ref{Thm1} and using binomial expansion $(1+x)^{-1}=\sum_{k=0}^{\infty} (-1)^k x^k$, the inner expectation in \eqref{eq:match-expectation} for 2-UE NOMA can be obtained as follows: \begin{IEEEeqnarray}{rCl} \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha} \right) \right] &=& \sum_{k=0}^{\infty} (-1)^k \left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha k}. \label{eq:inner-expectation-2_UE-Rayleigh} \end{IEEEeqnarray} The accuracy probability can then be derived as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}=\sum_{k=0}^{\infty} (-1)^k \mathbb{E}\left[ \left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha k} \right] =2 \sum_{k=0}^{\infty} (-1)^k \int_{0}^{\infty} \int_{r_1}^{\infty} \left(\frac{r_1}{r_2}\right)^{\alpha k} f_r(r_1) f_r(r_2) {\rm d}r_2 {\rm d}r_1. \label{eq:final-2_UE-rayleigh} \end{IEEEeqnarray} \end{Corollary} It is worth mentioning that the summation in \eqref{eq:final-2_UE-rayleigh} can be truncated after a few terms since the expression inside the summation is close to zero for large values of $k$. Moreover, unlike the expectation in \eqref{eq:final-N_UE-rayleigh}, the expectation in \eqref{eq:final-2_UE-rayleigh} can be derived in closed-form for PPP, MCP, and TCP models. In the following, we obtain the accuracy probability in closed-form for each of the models considering two users in a NOMA cluster (i.e., 2-UE NOMA) and then we study the accuracy probability for $N$-UE NOMA. Evidently, for $N$-UE NOMA, there is no closed-form expression available. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - 2 UE NOMA and PPP Model]\label{Thm2} When each BS serves users that are located in its Voronoi cell, the accuracy probability for 2-UE NOMA is \begin{IEEEeqnarray}{rCl} \mathcal{A}=\sum_{k=0}^{\infty} \frac{(-1)^k}{\alpha k + 2 } \, _2F_1\left(2,1;\frac{\alpha k}{2}+2;\frac{1}{2} \right). \nonumber \end{IEEEeqnarray} \end{theorem} \begin{IEEEproof} See {\bf Appendix~B}. \end{IEEEproof} According to \textbf{Theorem \ref{Thm2}}, for $N=2$, the probability that the path-loss-based ranking matches the instantaneous signal power-based ranking only depends on path-loss exponent $\alpha$ and does not depend on BS intensity $\lambda$. Similarly, we can generalize Theorem~\ref{Thm2} to the case of $N$-UE NOMA as stated in the following corollary. \begin{Corollary} \label{Cor2} For $N$-UE NOMA, the accuracy probability $\mathcal{A}$ only depends on path-loss exponent $\alpha$ and does not depend on BS intensity $\lambda$. \end{Corollary} \begin{IEEEproof} See {\bf Appendix~C}. \end{IEEEproof} For the MCP model, now we derive the accuracy probability $\mathcal{A}$ for 2-UE NOMA in closed-form by substituting \eqref{eq:PDF-MCP} in \eqref{eq:final-2_UE-rayleigh}, and for $N$-UE NOMA by substituting \eqref{eq:PDF-MCP} in \eqref{eq:final-N_UE-rayleigh}. The closed-form expression for the accuracy probability for 2-UE NOMA is provided in the following Theorem. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - 2 UE NOMA and MCP Model]\label{Thm3} When the user point process follows an MCP with parent point process $\Phi$, where $\Phi$ is the BS point process, the accuracy probability of 2-UE NOMA can be calculated as \begin{IEEEeqnarray}{rCl} \mathcal{A}=\sum_{k=0}^{\infty} (-1)^k\frac{2}{2+\alpha k}. \nonumber \end{IEEEeqnarray} \end{theorem} \begin{IEEEproof} The proof follows from substituting \eqref{eq:PDF-MCP} in \eqref{eq:final-2_UE-rayleigh}. \end{IEEEproof} Based on \textbf{Theorem \ref{Thm3}}, for 2-UE NOMA, when users are uniformly distributed within distance $R$ from the serving BS, the probability that path-loss-based ranking matches ranking based on the instantaneous signal power only depends on the path-loss exponent $\alpha$ and does not depend on $R$. Next we prove that for $N$-UE NOMA, when users are uniformly distributed within distance $R$ from the serving BS, the accuracy probability does not depend on $R$. By substituting \eqref{eq:PDF-MCP} in \eqref{eq:final-N_UE-rayleigh}, we obtain \begin{IEEEeqnarray}{rCl} \mathcal{A}=N!\int_0^R\int_{r_1}^R \cdots \int_{r_{N-1}}^R \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_j}{r_i}\right)^{\alpha}} \frac{2r_1}{R^2} \frac{2r_2}{R^2} \cdots \frac{2r_N}{R^2} {\rm d}r_N \cdots {\rm d}r_2 {\rm d}r_1. \label{eq:step1_Cor3} \end{IEEEeqnarray} Next we simplify the above integral by applying $u_i=\frac{R}{r_i}$ for $i=1,2,...,N$. After changes of variables, the region of integration is: $1<u_1$ and $1<u_i<u_{i-1}$ for $i=2,...,N$. Since the Jacobian matrix $J=\frac{\partial(r_1,\cdots,r_N)}{\partial(u_1,\cdots,u_N)}$ is a diagonal matrix, its determinant is equal to $\det(J)=\prod_{i=1}^{N} \frac{\partial r_i}{\partial u_i} =\prod_{i=1}^{N} \frac{-R}{u_i^2}$. Therefore, \eqref{eq:step1_Cor3} can be obtained by \begin{IEEEeqnarray}{rCl} \mathcal{A}&=& N! 2^N \int_1^{\infty} \int_1^{u_1} \cdots \int_1^{u_{N-1}} u_1^{-3} \prod_{i=2}^{N} \frac{u_i^{-3}}{\sum_{j=1}^i \left(\frac{u_i}{u_j}\right)^{\alpha}} {\rm d}u_N \cdots {\rm d}u_2 {\rm d}u_1 \label{eq:step1_Rayleigh_MCP_N_UE} \end{IEEEeqnarray} which does not depend on $R$. In the following, we further simplify \eqref{eq:step1_Rayleigh_MCP_N_UE} for $N=3$. For other values of $N$, we can also use the same approach. For $N=3$, we have \begin{IEEEeqnarray}{rCl} \mathcal{A}&=& 48 \int_1^{\infty} \int_1^{u_1} \int_1^{u_2} \frac{ u_1^{-3} u_2^{-3} u_3^{-3} } { \left[ 1+\left( \frac{u_2}{u_1}\right)^{\alpha} \right] \left[ 1+\left( \frac{u_3}{u_1}\right)^{\alpha} + \left( \frac{u_3}{u_2}\right)^{\alpha} \right] } {\rm d}u_3 {\rm d}u_2 {\rm d}u_1\nonumber \\ &\stackrel{\text{(a)}}{=}& 48 \int_1^{\infty} \int_{u_3}^{\infty} \int_{u_2}^{\infty} \frac{ u_1^{-3} u_2^{-3} u_3^{-3} } { \left[ 1+\left( \frac{u_2}{u_1}\right)^{\alpha} \right] \left[ 1+\left( \frac{u_3}{u_1}\right)^{\alpha} + \left( \frac{u_3}{u_2}\right)^{\alpha} \right] } {\rm d}u_1 {\rm d}u_2 {\rm d}u_3 \nonumber \\ &\stackrel{\text{(b)}}{=}& 48 \int_0^{1} \int_0^1 \int_0^1 \frac{v_1 v_2^3 v_3^5} {\left[ 1+v_1^{\alpha} \right] \left[ 1 + v_2^{\alpha} + v_1^{\alpha} v_2^{\alpha} \right]} {\rm d}v_1 {\rm d}v_2 {\rm d}v_3 \nonumber \\ &=& 8 \int_0^{1} \int_0^1 \frac{v_1 v_2^3} {\left[ 1+v_1^{\alpha} \right] \left[ 1 + v_2^{\alpha} + v_1^{\alpha} v_2^{\alpha} \right]} {\rm d}v_1 {\rm d}v_2, \label{eq:accuracy_probability_Rayleigh_MCP_3UE} \end{IEEEeqnarray} where (a) is obtained by changing the orders of the integrals and (b) follows by applying changes of variables $v_3=\frac{1}{u_3}$, $v_2=\frac{u_3}{u_2}$, and $v_1=\frac{u_2}{u_1}$. \begin{Corollary} \label{Cor3} When users are uniformly distributed within distance $R$ from the serving BS, for $N$-UE NOMA, the probability that the path-loss-based ranking matches the instantaneous signal power-based ranking, only depends on the path-loss exponent $\alpha$ and does not depend on $R$. \end{Corollary} For the PPP and TCP models, the link distances follow Rayleigh distribution. Therefore, for TCP, we can derive the accuracy probability for 2-UE and $N$-UE simply by replacing $c \lambda \pi$ in \textbf{Theorem \ref{Thm2}} and \textbf{Corollary \ref{Cor2}} with $1/(2 \sigma^2)$. This can be understood by comparing \eqref{eq:PDF-PPP} and \eqref{eq:PDF-TCP}. \begin{Corollary} \label{Cor4} When users are independently and identically distributed with normal distribution with variance $\sigma^2$ around the serving BS, $\mathcal{A}$ for $2$-UE and $N$-UE NOMA can be calculated by \textbf{Theorem \ref{Thm2}} and \textbf{Corollary \ref{Cor2}}, respectively. Therefore, $\mathcal{A}$ is independent of $\sigma^2$. \end{Corollary} \section{Probability of Accuracy for Nakagami-$m$ Fading} In this section, we derive the probability of accuracy of distance-based approximation considering Nakagami-$m$ fading channels. \textcolor{black}{Using the analytical results, in Section \ref{sec:simulation}, we will show that for more severe fading conditions (i.e., for small values of $m$), the distance-based approximation is less accurate whereas for higher values of $m$, the distance-based approximation is more accurate.} Similar to the previous subsection, we first derive the inner expectation in \eqref{eq:match-expectation}. Then the accuracy probability $\mathcal{A}$ is obtained for PPP, MCP, and TCP models as shown in the following. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - $N$-UE NOMA] \label{Thm4} For Nakagami-$m$ fading, with shape parameter $m$, the inner expectation in \eqref{eq:match-expectation} can be derived as follows: \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right]} \nonumber \\ &=& \frac{ \Gamma(Nm) }{ \Gamma(m)^N } \int_1^{\infty} \int_1^{\infty} \cdots \int_1^{\infty} \frac{1}{\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \prod_{j=1}^{N-1}\left( \frac{r_{(j)}}{r_{(N)}} \right)^{\alpha m} t_j^{jm-1} {\rm d}t_{N-1} \cdots {\rm d}t_2 {\rm d}t_1. \nonumber \end{IEEEeqnarray} Then $\mathcal{A}$ can be derived by averaging over the desired link distance distribution using \textbf{Definition~2}. \end{theorem} {\allowdisplaybreaks \begin{IEEEproof} See {\bf Appendix~D}. \end{IEEEproof}} Similar to Rayleigh fading, the accuracy probability for Nakagami-$m$ fading does not depend on mean channel power gain. By setting $N=2$ for 2-UE NOMA, we obtain \begin{IEEEeqnarray}{rCl} \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha} \right) \right] &=& \frac{ \Gamma(2m) }{ \Gamma(m)^2 } \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m} \int_1^{\infty} \frac{t_1^{m-1} {\rm d}t_1} { \left[1+\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha} t_1 \right]^{2m} }. \label{eq:inner-expectation_N=2_Nakagami} \end{IEEEeqnarray} For 2-UE NOMA, when $m=1$ (Rayleigh fading), \eqref{eq:inner-expectation_N=2_Nakagami} reverts to \textbf{Corollary \ref{Cor1}}. However, deriving \textbf{Theorem \ref{Thm1}} from \textbf{Theorem \ref{Thm4}} for $N$-UE NOMA, when $m=1$, is not straightforward. Using \textbf{Definition~2} with \eqref{eq:inner-expectation_N=2_Nakagami} for 2-UE NOMA and with \textbf{Theorem \ref{Thm4}} for $N$-UE NOMA provides the accuracy probability. In the following, similar to the previous section, we derive the accuracy probability for PPP, MCP, and TCP models. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - 2 UE NOMA and PPP Model] \label{Thm5} For 2-UE NOMA and PPP model for users' spatial locations, the accuracy probability for Nakagami-$m$ fading with fading parameter $m$ can be given as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}=\frac{ 4 \Gamma(2m) }{ \Gamma(m) \Gamma(m+1) } \int_0^1 \frac{u^{1-\alpha m}}{\left( 1 + {u^2}\right)^2} \,_2F_1(2m,m;m+1;-u^{-\alpha}) {\rm d}u. \nonumber \end{IEEEeqnarray} \end{theorem} \begin{IEEEproof} The accuracy probability can be derived as: \begin{IEEEeqnarray}{rCl} \mathcal{A}&=& \frac{ 2 \Gamma(2m) }{ \Gamma(m)^2 } (2 c \lambda \pi)^2 \int_1^{\infty} \int_{0}^{\infty} \int_{r_1}^{\infty} \frac{ \left( \frac{r_1}{r_2} \right)^{\alpha m} t_1^{m-1} } { \left[1+\left( \frac{r_1}{r_2} \right)^{\alpha} t_1 \right]^{2m} } r_1 r_2 e^{-c \lambda \pi \left( r_1^2 + r_2^2\right)} {\rm d}r_2 {\rm d}r_1 {\rm d}t_1 \nonumber \\ &\stackrel{\text{(a)}}{=}& \frac{ 2 \Gamma(2m) }{ \Gamma(m)^2 } (2 c \lambda \pi)^2 \int_1^{\infty} \int_{0}^{1} \frac{ u^{\alpha m-3} t_1^{m-1} } { \left[1+u^{\alpha} t_1 \right]^{2m} } \int_{0}^{\infty} v^3 e^{-c \lambda \pi \left( 1 + \frac{1}{u^2}\right)v^2} {\rm d}v {\rm d}u {\rm d}t_1 \nonumber \\ &\stackrel{\text{(b)}}{=}& \frac{ 4 \Gamma(2m) }{ \Gamma(m)^2 } \int_1^{\infty} \int_{0}^{1} \frac{ u^{\alpha m+1} t_1^{m-1} } { \left[1+u^{\alpha} t_1 \right]^{2m} } \frac{1}{\left( 1 + {u^2}\right)^2} {\rm d}u {\rm d}t_1 \nonumber \\ &\stackrel{\text{(c)}}{=}& \frac{ 4 \Gamma(2m) }{ \Gamma(m)^2 } \int_0^1 \frac{u^{1-\alpha m}}{\left( 1 + {u^2}\right)^2} \int_0^1 \frac{ z^{m-1} } { \left[1+u^{-\alpha} z \right]^{2m} } {\rm d}z {\rm d}u, \nonumber \end{IEEEeqnarray} where (a) is obtained by changes of variables $\frac{r_1}{r_2}=u$ and $r_1=v$. (b) follows by applying $c \lambda \pi \left( 1 + \frac{1}{u^2}\right)v^2=x$. (c) is obtained by $t_1^{-1}=z$. Finally, \textbf{Theorem \ref{Thm5}} can be derived by using the integral representation of Gaussian hypergeometric function. \end{IEEEproof} According to \textbf{Theorem \ref{Thm5}}, the accuracy probability in Nakagami-$m$ fading for 2-UE NOMA does not depend on the BS intensity $\lambda$. In the following, we prove that, for $N$-UE NOMA with Nakagami-$m$ fading, the accuracy probability is independent of $\lambda$. \begin{Corollary} \label{Cor5} For $N$-UE NOMA and PPP model, the accuracy probability for Nakagami-$m$ fading with parameter $m$ is independent of the BS intensity $\lambda$. \end{Corollary} \begin{IEEEproof} See {\bf Appendix~E}. \end{IEEEproof} Now we derive the accuracy probability $\mathcal{A}$ for MCP model by averaging \eqref{eq:inner-expectation_N=2_Nakagami} (for 2-UE NOMA) and \textbf{Theorem \ref{Thm4}} (for $N$-UE NOMA) with respect to $\{r_{(i)}\}$, where the joint PDF $f_{ r_{(1)},r_{(2)},\cdots,r_{(N)} }(x_1,x_2,\cdots,x_N)$ can be obtained by substituting \eqref{eq:PDF-MCP} in \textbf{Definition~2}. \begin{theorem}[Probability of the Accuracy of Distance-based Approximation - 2 UE NOMA and MCP Model] \label{Thm6} When user point process follows an MCP with parent point process $\Phi$, where $\Phi$ is the BS point process, the accuracy probability of 2-UE NOMA in Nakagami-$m$ fading with parameter $m$ is as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}=\frac{ 2 \Gamma(2m) }{ \Gamma(m) \Gamma(m+1) } \int_0^1 {u^{1-\alpha m}} \,_2F_1(2m,m;m+1;-u^{-\alpha}) {\rm d}u. \nonumber \end{IEEEeqnarray} \end{theorem} \begin{IEEEproof} See {\bf Appendix~F}. \end{IEEEproof} According to \textbf{Theorem \ref{Thm6}}, for 2-UE NOMA, $\mathcal{A}$ does not depend on $R$ in MCP model. For $N$-UE NOMA, we can also prove that the accuracy probability is independent of $R$ as stated in the following corollary. \begin{Corollary} \label{Cor6} For Nakagami-$m$ fading, when users are uniformly distributed within distance $R$ from the serving BS, for $N$-UE NOMA, the probability that path-loss-based ranking matches the instantaneous signal power-based ranking does not depend on $R$. \end{Corollary} \begin{IEEEproof} The proof follows from \eqref{eq:final-N_UE-Nakagami}, where to solve the expectation, we can use the same changes of variables as we used to simplify \eqref{eq:step1_Cor3}: \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E} \left[ \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{(j)}}{r_{(N)}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \right] =} \nonumber \\ &&\> N!\,2^{N} \int_{1}^{\infty} \int_{1}^{u_1} \cdots \int_{1}^{u_{N-1}} \frac{ \prod_{j=1}^{N-1}\left( \frac{u_N}{u_j} \right)^{\alpha m+3} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{u_N}{u_i} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} u_N^{-3N} {\rm d}{u_N} \cdots {\rm d}{u_2} {\rm d}{u_1}. \nonumber \end{IEEEeqnarray} The above equation can be further simplified similar to \eqref{eq:accuracy_probability_Rayleigh_MCP_3UE}. \end{IEEEproof} Finally, for the TCP model, we can derive the accuracy probability by replacing $c \lambda \pi$ in the final expressions of the accuracy probability of PPP model with $1/( 2 \sigma^2 )$ . Since $c \lambda \pi$ cancels out in the final expressions, \textbf{Theorem \ref{Thm5}} and \textbf{Corollary \ref{Cor5}} are also applicable for TCP. Moreover, according to \textbf{Corollary \ref{Cor5}}, we can conclude that the accuracy probability does not depend on $\sigma^2$. \section{User Pairing and Probability of Accuracy} In the previous sections, from the set of users that are associated to the same BS, $N$ users were randomly selected to form a NOMA cluster. However, in practice, NOMA users are chosen such that NOMA gain can be achieved over OMA. For instance, to form a 2-UE NOMA cluster, out of $M$ users associated to the typical BS, usually the nearest and the farthest users are selected. In the following, we study the accuracy probability with user pairing. To form a NOMA cluster, we have selected $N$ users from $M$ users that are associated to the typical BS. We denote rank of the selected users by the set $s=\{ s_{(i)} \}$, where $i=1,2,\cdots,N$, $s_{(i)}\in\left\{1,2,...,M\right\}$, and $1 \le s_{(1)} < s_{(2)} \cdots < s_{(N-1)} < s_{(N)} \le M $. From \textbf{Definition~2} and \textbf{Theorem \ref{Thm1}}, for Rayleigh fading, we obtain \begin{IEEEeqnarray}{rCl} \mathcal{A}&=&\mathbb{E}\left[ \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{s_{(j)}}}{r_{s_{(i)}}}\right)^{\alpha}} \right] \nonumber \\ &=& M! \int_{0}^{\infty} \int_{r_1}^{\infty} \cdots \int_{r_{M-1}}^{\infty} \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{s_{(j)}}}{r_{s_{(i)}}}\right)^{\alpha}} f_r(r_1) f_r(r_2) \cdots f_r(r_M) {\rm d}r_M \cdots {\rm d}r_2 {\rm d}r_1. \label{eq:final-N_UE-rayleigh-UE_Pairing} \end{IEEEeqnarray} For $N=2$, when we select the nearest and the farthest users, i.e, $s_{(1)}=1$ and $s_{(2)}=M$, \eqref{eq:final-N_UE-rayleigh-UE_Pairing} can be simplified as in the following: \begin{IEEEeqnarray}{rCl} \mathcal{A} &=& M! \int_{0}^{\infty} \int_{r_1}^{\infty} \cdots \int_{r_{M-1}}^{\infty} \frac{1}{1+\left(\frac{r_1}{r_M}\right)^{\alpha}} f_r(r_1) f_r(r_2) \cdots f_r(r_M) {\rm d}r_M \cdots {\rm d}r_2 {\rm d}r_1 \nonumber \\ &\stackrel{\text{(a)}}{=}& \frac{M!}{(M-2)!} \int_{0}^{\infty} \int_{r_1}^{\infty} \frac{1}{1+\left(\frac{r_1}{r_M}\right)^{\alpha}} \left[F_r(r_M)-F_r(r_1)\right]^{M-2} f_r(r_1) f_r(r_M) {\rm d}r_M {\rm d}r_1, \label{eq:final-N_UE-rayleigh-2UE_Pairing} \end{IEEEeqnarray} \textcolor{black}{where (a) is obtained using the technique in \cite{ahsanullah2013introduction} to derive Equation 2.12, i.e., for i.i.d. random variables $r_2,r_3,\cdots,r_{M-1}$, $\left[F_r(r_M)-F_r(r_1)\right]^{M-2}$ is the probability that they are in the interval $[r_1,r_M]$. Sorting these random variables in an ascending order based on their realizations gives $(M-2)!$ different permutations out of which only one satisfies the condition $r_2<r_3<\cdots<r_{M-1}$}. We can similarly simplify \eqref{eq:final-N_UE-rayleigh-UE_Pairing} for other values of $N$ and different selection of NOMA users. Note that the same result can also be obtained by averaging the result in \textbf{Theorem \ref{Thm1}} with respect to the joint PDF of $r_{s_{(1)}}, r_{s_{(2)}}, \cdots, r_{s_{(N)}}$, which is also provided in \cite{ahsanullah2013introduction}. \begin{Corollary}\label{Cor_2UEpairing} For 2-UE NOMA, the accuracy probability, when we select the nearest and the farthest users, i.e., $s_{(1)}=1$ and $s_{(2)}=M$, is an increasing function of $M$ irrespective of the fading channel and users' spatial distributions. \end{Corollary} \begin{IEEEproof} See {\bf Appendix G.} \end{IEEEproof} For Nakagami-$m$ fading, using \textbf{Definition~2} and \textbf{Theorem \ref{Thm4}} gives $\mathcal{A}=$ \begin{IEEEeqnarray}{rCl} \frac{ \Gamma(Nm) }{ \Gamma(m)^N } \int_1^{\infty} \int_1^{\infty} \cdots \int_1^{\infty} \mathbb{E} \left[ \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{s_{(j)}}}{r_{s_{(N)}}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{s_{(i)}}}{r_{s_{(N)}}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \right] \prod_{j=1}^{N-1} t_j^{jm-1} {\rm d}t_{N-1} \cdots {\rm d}t_2 {\rm d}t_1, \nonumber \\ \label{eq:eq:final-N_UE-Nakagami_UE_Pairing} \end{IEEEeqnarray} where \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E} \left[ \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{s_{(j)}}}{r_{s_{(N)}}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{s_{(i)}}}{r_{s_{(N)}}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \right] =} \nonumber \\ M!\int_0^{\infty} \int_{r_1}^{\infty} \cdots \int_{r_{M-1}}^{\infty} \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{s_{(j)}}}{r_{s_{(N)}}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{s_{(i)}}}{r_{s_{(N)}}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} f_r(r_1)f_r(r_2) \cdots f_r(r_M) {\rm d}r_{M} \cdots {\rm d}r_2 {\rm d}r_1. \nonumber \\ \label{eq:eq:expectation-N_UE-Nakagami_UE_Pairing} \end{IEEEeqnarray} Now using the above equations, we can study $\mathcal{A}$ for different users' location models. \begin{Corollary} When each BS serves users in its Voronoi cell (PPP model), for any selection of users for the NOMA cluster, the accuracy probability is independent of BS intensity $\lambda$. \end{Corollary} \begin{IEEEproof} The proof can be obtained by using the same approach as in the proof of \textbf{Corollary \ref{Cor2}} for \eqref{eq:final-N_UE-rayleigh-UE_Pairing} (Rayleigh fading) and \eqref{eq:eq:expectation-N_UE-Nakagami_UE_Pairing} (for Nakagami-$m$ fading). \end{IEEEproof} \begin{Corollary}When users are uniformly distributed within distance $R$ from the serving BS (MCP model) and for any user selection scheme, the accuracy probability is independent of $R$. \end{Corollary} \begin{IEEEproof} The proof can be obtained by using the same approach as in the proof of Corollary \ref{Cor3} for \eqref{eq:final-N_UE-rayleigh-UE_Pairing} (Rayleigh fading) and \eqref{eq:eq:expectation-N_UE-Nakagami_UE_Pairing} (for Nakagami fading). \end{IEEEproof} \begin{Corollary} When users are independently and identically scattered with normal distribution with variance $\sigma^2$ around the serving BS (TCP model), for any selection of users for the NOMA cluster, the accuracy probability is independent of $\sigma^2$. \end{Corollary} \section{Numerical and Simulation Results} \label{sec:simulation} This section demonstrates the efficacy of the derived expressions by comparing them to Monte-Carlo simulations. In Table \ref{my-label1}, we summarize the expressions defining the accuracy of the distance-based approximation in NOMA assuming different spatial models and fading models. We use Gaussian quadrature method to approximate and solve four or higher dimensional integrals. In the following, we briefly review the Gaussian quadrature method, describe simulation parameters, and then present our results which demonstrate the impact of path-loss exponent, fading parameter $m$ (in Nakagami-$m$ fading), and user pairing on the accuracy probability. \begin{table*}[!ht] \centering \caption{Accuracy Probability $\mathcal{A}$ for Random User Selection} \label{my-label1} \begin{tabular}{|p{1.5cm}|p{2.5cm}|p{0.5cm}|p{10cm}|} \hline {\bf Fading} & { \bf Netwrok Model} & {\bf $N$} & {\bf Accuracy Probability ($\mathcal{A}$)} \vspace{3mm} \\ \hline Rayleigh & PPP/TCP & 2 & $\sum_{k=0}^{\infty} \frac{(-1)^k}{ 2 + \alpha k } \, _2F_1\left(2,1;\frac{\alpha k}{2}+2;\frac{1}{2} \right)$ \\ \hline Rayleigh & PPP/TCP & 3 & $48\int_0^1 \int_0^1 \frac{u_1 u_2^3} { \left( 1+u_1^{\alpha} \right)\left( 1+u_2^{\alpha}+u_1^{\alpha}u_2^{\alpha} \right)\left( 1+u_2^2+u_1^2u_2^2 \right)^3 } {\rm d}u_2 {\rm d}u_1$ \\ \hline Raylegih & MCP & 2 & $\sum_{k=0}^{\infty} (-1)^k \frac{2}{ 2 + \alpha k }$ \\ \hline Rayleigh & MCP & 3 & $ 8\int_0^1 \int_0^1 \frac{u_1 u_2^3} { \left( 1+u_1^{\alpha} \right)\left( 1+u_2^{\alpha}+u_1^{\alpha}u_2^{\alpha} \right) } {\rm d}u_2 {\rm d}u_1$ \\ \hline Nakagami & PPP/TCP & 2 & $\frac{ 4 \Gamma(2m) }{ \Gamma(m) \Gamma(m+1) } \int_0^1 \frac{u^{1-\alpha m}}{\left( 1 + {u^2}\right)^2} \,_2F_1(2m,m;m+1;-u^{-\alpha}) {\rm d}u$ \\ \hline Nakagami & PPP/TCP & 3 & $\frac{ 48 \Gamma(3m) }{ \Gamma(m)^3 } \int_0^1 \int_0^1 \int_0^1 \int_0^1 \frac{u_1^{1+\alpha m} u_2^{3+2\alpha m} z_1^{2m-1} z_2^{m-1}} {\left( u_1^{\alpha} u_2^{\alpha} + u_2^{\alpha} z_1 + z_1 z_2 \right)^{3m} \left( 1 + u_2^2 + u_1^2 u_2^2\right)^3} {\rm d}u_2 {\rm d}u_1 {\rm d}z_2 {\rm d}z_1$ \\ \hline Nakagami & MCP & 2 & $\frac{ 2 \Gamma(2m) }{ \Gamma(m) \Gamma(m+1) } \int_0^1 u^{1-\alpha m} \,_2F_1(2m,m;m+1;-u^{-\alpha}) {\rm d}u$ \\ \hline Nakagami & MCP & 3 & $\frac{ 8 \Gamma(3m) }{ \Gamma(m)^3 } \int_0^1 \int_0^1 \int_0^1 \int_0^1 \frac{u_1^{1+\alpha m} u_2^{3+2\alpha m} z_1^{2m-1} z_2^{m-1}} {\left( u_1^{\alpha} u_2^{\alpha} + u_2^{\alpha} z_1 + z_1 z_2 \right)^{3m} } {\rm d}u_2 {\rm d}u_1 {\rm d}z_2 {\rm d}z_1$ \\ \hline \end{tabular} \end{table*} \subsection{Approximation of Multi-Dimensional Integrals} A quadrature rule provides an approximation of the definite integral of a function, usually stated as a weighted sum of function values at specified points within the domain of integration. \begin{Definition}[Gaussian Quadrature] When domain of integration is $[0,1]$\footnote{Note that domains of integrals in Table \ref{my-label1} are all $[0,1]$.}, an n-point Gaussian quadrature rule states \begin{IEEEeqnarray}{rCl} \int_0^1 f(x) {\rm d}x \approx \sum_{i=1}^n w_i f(x_i), \nonumber \end{IEEEeqnarray} where the weights $w_i$ and nodes $x_i$ are obtained such that the approximation is exact for a set of $2n$ different functions \cite{stroud1966gaussian}. \end{Definition} To evaluate the four dimensional integrals in Table \ref{my-label1}, we use the following approximation: \begin{IEEEeqnarray}{rCl} \int_0^1 \int_0^1 \int_0^1 \int_0^1 f(x_1,x_2,x_3,x_4) {\rm d}x_1 {\rm d}x_2 {\rm d}x_3 {\rm d}x_4 \approx \sum_{i_1=1}^n \sum_{i_2=1}^n \sum_{i_3=1}^n \sum_{i_4=1}^n w_{i_1} w_{i_2} w_{i_3} w_{i_4} f(x_{i_1},x_{i_2},x_{i_3},x_{i_4}), \nonumber \end{IEEEeqnarray} where 30-point ($n=30$) Gaussian quadrature rule is employed. The values of the weights $w_i$ and nodes $x_i$ are provided in \cite{ma1996generalized}[Table 3]. \subsection{Simulation Parameters} We consider $\lambda=0.0005$, $R=20$, $\sigma^2$ = 25, and $\Omega$ = 1. Note that when the numerical results match the simulation results, the numerical results are presented. As we have mentioned in Section II, \eqref{eq:PDF-PPP} is an approximation for the PDF of the desired link distance of the typical Voronoi cell. Therefore, for the PPP model, we plot both numerical and simulation results. Moreover, as we have mentioned in the previous subsection, four or higher dimensional integrals are approximated using generalized Gaussian quadrature method. Hence, for $N=3$ in Nakagami-$m$ fading, simulation and analytical results for all PPP, TCP, and MCP models are also provided. \subsection{Results and Discussions} \subsubsection{Impact of Path-Loss Exponent} \begin{figure \centering \includegraphics[width=1.25\figwidth]{AvsPLE_Rayleigh.pdf} \caption{Accuracy probability as a function of path-loss exponent for Rayleigh fading.} \label{fig:AvsPLE_Rayleigh} \end{figure} \begin{figure} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[PPP and TCP.] {\epsfig{file=AvsPLE_Nakagami_PPPandTCP.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[MCP.] {\epsfig{file=AvsPLE_Nakagami_MCP.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \caption{Accuracy probability as a function of path-loss exponent for Nakagami-$m$ fading with $m=0.5,1,2$.} \label{fig:AvsPLE_Nakagami} \end{figure} In \figref{fig:AvsPLE_Rayleigh} and \figref{fig:AvsPLE_Nakagami}, the accuracy probability for Rayleigh and Nakagami-$m$ fading is illustrated as a function of path-loss exponent $\alpha$. The analytical results are provided in Table \ref{my-label1} for two and three users. According to \figref{fig:AvsPLE_Rayleigh}, for Rayleigh fading with $\alpha=4$, ranking users based on their distances for 2-UE NOMA is accurate with probability 0.84 for PPP and TCP. For MCP, ranking users based on their distances is valid with probability 0.79. Therefore, for $N=2$, ordering users based on their distances instead of instantaneous signal powers seems reasonable. However, for $N=3$, accuracy probability decreases significantly. When $\alpha=4$, the accuracy probability is about 0.61 for TCP and PPP, and is 0.51 for MCP. In \figref{fig:AvsPLE_Nakagami}, for Nakagami-$m$ fading, the accuracy probability is illustrated for different values of $m$. For $N=3$, we use the Gaussian quadrature method to numerically evaluate the four dimensional integrals in Table \ref{my-label1}. Note that, for $N=3$, the difference between simulation results and analysis for TCP and MCP in \figref{fig:AvsPLE_Nakagami}(a) and \figref{fig:AvsPLE_Nakagami}(b) is due to the Gaussian quadrature method. In summary, we can observe that distance-based ranking yields more accurate coverage probability results for higher values of $\alpha$, $m$, and less number of users in a NOMA cluster. \subsubsection{Impact of Fading Parameter $m$} \begin{figure \centering \includegraphics[width=1.25\figwidth]{Avsm.pdf} \caption{Accuracy probability as a function of fading parameter $m$ for $\alpha=4$.} \label{fig:Avsm} \end{figure} When $\alpha=4$, for Nakagami-$m$ fading, in \figref{fig:Avsm}, the accuracy probability is shown as a function of $m$. As we can see, the accuracy probability is an increasing function of $m$. Therefore, in scenarios with better fading conditions, the distance-based approximation is reasonable. This result is also intuitive because when fading conditions improve, the impact of fading on the channel power is not significant and the distance-based path-loss is dominant. As such, the distance-based approximation is reasonable. \subsubsection{Impact of Distance-Based User Selection} \begin{figure} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[PPP and TCP.]{\epsfig{file=A_UserPairing_PPP.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \parbox[c]{.5\textwidth}{% \centerline{\subfigure[MCP.] {\epsfig{file=A_UserPairing_MCP.pdf,width=.49\textwidth,height=0.9\figwidth}}}} \caption{Accuracy probability as a function of path-loss exponent and selecting different users for NOMA transmission with Rayleigh fading. $M$ denotes the total number of users out of which $N$ users are selected to form a NOMA cluster. Set $s$ contains ranks of the selected users for a NOMA cluster.} \label{fig:AvsPLE_UserPairing} \end{figure} The accuracy probability is shown in \figref{fig:AvsPLE_UserPairing} for 2-UE and 3-UE NOMA clusters. For instance, when two users are randomly selected, the accuracy probability for PPP with $\alpha=4$ is about 0.84. However, if we select three users randomly, and then choose the nearest and farthest users to form a NOMA cluster, the accuracy probability will be 0.92. With more associated users with the serving BS, selection of the nearest and farthest users provide higher degree of distinctness among users. According to \figref{fig:AvsPLE_UserPairing}, with increasing channel distinctness, the accuracy probability increases significantly. \section{Conclusion} Most of the existing state-of-the-art analyzed NOMA performance assuming that ranking users in each NOMA cluster based on their distances, instead of the complete CSI, is a valid approximation. This approximation affects the coverage probability analysis in the uplink as well as in the downlink. This paper has verified this assumption for Rayleigh and Nakagami-$m$ fading channels and a variety of users' spatial location distributions such as PPP, MCP, and TCP. Specifically, the accuracy probability, which is the probability that the distance-based ranking matches ranking based on the instantaneous signal power, has been defined and derived. The results show that the accuracy probability is increasing with respect to the path-loss exponent while it does not depend on the BS intensity in the PPP model, cluster radius in the MCP model, and scattering variance in the TCP model. Effect of user pairing on the accuracy probability has also been investigated, and it has been shown that with distinct user pairing the accuracy probability increases significantly, compared to the random user selection. \section*{Appendix A: Proof of Theorem~1} \renewcommand{\theequation}{A.\arabic{equation}} \setcounter{equation}{0} For Rayleigh fading and $N$-UE NOMA, the inner expectation over $\{h_i\}_{i=1}^N$ can be derived as: \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right] } \nonumber \\ &=& \mathbb{E}\left[ \mathbf{1} \left( h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \mathbb{E}_{h_1} \left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha} \right) \right] \right] \nonumber \\ &\stackrel{\text{(a)}}{=}& \mathbb{E}\left[ \mathbf{1} \left( h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \exp\left\{ -\frac{h_2\left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha}}{\Omega} \right\} \right] \nonumber \\ &=& \mathbb{E}\left[ \mathbf{1} \left( h_3r_{(3)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \mathbb{E}_{h_2} \left[ \mathbf{1} \left( h_2r_{(2)}^{-\alpha}>h_3r_{(3)}^{-\alpha} \right) \exp\left\{ -\frac{h_2\left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha}}{\Omega} \right\} \right] \right] \nonumber \\ &\stackrel{\text{(b)}}{=}& \mathbb{E}\left[ \mathbf{1} \left( h_3r_{(3)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \frac{1}{1+\left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha}} \exp\left\{ -\frac{h_3\left[ \left(\frac{r_{(1)}}{r_{(3)}}\right)^{\alpha} + \left(\frac{r_{(2)}}{r_{(3)}}\right)^{\alpha} \right]}{\Omega} \right\} \right] \nonumber \\ &\stackrel{\text{(c)}}{=}& \frac{1}{1+\left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha}} \cdot \frac{1}{1+\left(\frac{r_{(1)}}{r_{(3)}}\right)^{\alpha} + \left(\frac{r_{(2)}}{r_{(3)}}\right)^{\alpha}} \cdot \cdots \cdot \frac{1}{1+\left(\frac{r_{(1)}}{r_{(N)}}\right)^{\alpha} + \left(\frac{r_{(2)}}{r_{(N)}}\right)^{\alpha} \cdots \left(\frac{r_{(N-1)}}{r_{(N)}}\right)^{\alpha}} \nonumber \\ &=& \prod_{i=2}^{N} \frac{1}{\sum_{j=1}^i \left(\frac{r_{(j)}}{r_{(i)}}\right)^{\alpha}}, \nonumber \end{IEEEeqnarray} where (a), (b), and (c) follow since $\left\{ h_i \right\}$ are i.i.d. exponential random variables with mean $\Omega$, the average channel power gain. \section*{Appendix B: Proof of Theorem~2} \renewcommand{\theequation}{B.\arabic{equation}} \setcounter{equation}{0} Using PDF of the link distance \eqref{eq:PDF-PPP} in \eqref{eq:final-2_UE-rayleigh} yields \begin{IEEEeqnarray}{rCl} \mathbb{E}\left[ \left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha k} \right] &=& 2 \int_{0}^{\infty} \int_{r_1}^{\infty} \left(\frac{r_1}{r_2}\right)^{\alpha k} f_{r}(r_1)f_r(r_2){\rm d}r_2{\rm d}r_1 \nonumber \\ &=& 2 (2c\lambda\pi)^2 \int_{0}^{\infty} \int_{r_1}^{\infty} \left(\frac{r_1}{r_2}\right)^{\alpha k} r_1 r_2 e^{-c\lambda\pi(r_1^2+r_2^2)} {\rm d}r_2{\rm d}r_1. \nonumber \end{IEEEeqnarray} Applying changes of variables $\frac{r_1}{r_2}=u$ and $r_1=v$, we have \begin{IEEEeqnarray}{rCl} \mathbb{E}\left[ \left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha k} \right] &=& 2 (2c\lambda\pi)^2 \int_{0}^{\infty} \int_{0}^{1} u^{\alpha k-3}v^3 e^{-c\lambda\pi(1+\frac{1}{u^2})v^2} {\rm d}u{\rm d}v \nonumber \\ &=& 2 (2c\lambda\pi)^2 \int_{0}^{1} u^{\alpha k-3} \int_{0}^{\infty} v^3 e^{-c\lambda\pi(1+\frac{1}{u^2})v^2} {\rm d}v {\rm d}u. \nonumber \end{IEEEeqnarray} Applying $c\lambda\pi(1+\frac{1}{u^2})v^2=t$ in the inner integral yields \begin{IEEEeqnarray}{rCl} \mathbb{E}\left[ \left(\frac{r_{(1)}}{r_{(2)}}\right)^{\alpha k} \right] &=& 2 (2c\lambda\pi)^2 \int_{0}^{1} u^{\alpha k-3} \int_{0}^{\infty} \frac{t e^{-t}{\rm d}t} {2(c\lambda\pi)^2(1+\frac{1}{u^2})^2} {\rm d}u = 4 \int_{0}^{1} \frac{u^{\alpha k+1} {\rm d}u}{(1+u^2)^2} = 2 \int_{0}^{1} \frac{x^{\alpha k/2} {\rm d}x}{(1+x)^2} \nonumber \\ &=&\frac{2}{\frac{\alpha k}{2} + 1} \, _2F_1\left(2,\frac{\alpha k}{2} + 1;\frac{\alpha k}{2} + 2;-1\right). \nonumber \end{IEEEeqnarray} Finally, Theorem \ref{Thm2} is obtained by $_2F_1(a,b;c;z)=(1-z)^{-a}\,_2F_1(a,c-b;c;\frac{z}{z-1})$. \section*{Appendix C: Proof of Corollary~3} \renewcommand{\theequation}{C.\arabic{equation}} \setcounter{equation}{0} From substituting \eqref{eq:PDF-PPP} in \eqref{eq:final-N_UE-rayleigh}, we get \begin{IEEEeqnarray}{rCl} \mathcal{A} &=& N! (2 c \lambda \pi )^N \int_{0}^{\infty} \int_{r_1}^{\infty} \cdots \int_{r_{N-1}}^{\infty} r_1 e^{-c \lambda \pi r_1^2} \prod_{i=2}^{N} \frac{r_i e^{-c \lambda \pi r_i^2}} {\sum_{j=1}^i \left(\frac{r_j}{r_i}\right)^{\alpha}} {\rm d}{r_N} \cdots {\rm d}{r_2} {\rm d}{r_1}. \label{eq:step1_Cor2} \end{IEEEeqnarray} Next, we simplify \eqref{eq:step1_Cor2} by applying changes of variables $r_1=u_1$, $\frac{r_{i-1}}{r_i}=u_i$ for $i=2,...,N$. Since we have $r_i=\frac{u_1}{u_2 u_3 \cdots u_i}$, $i=2,...,N$, the Jacobian matrix $J=\frac{\partial(r_1,\cdots,r_N)}{\partial(u_1,\cdots,u_N)}$ is a triangular matrix and its determinant is equal to the product of the main diagonal entries, i.e., $\det(J)=\prod_{i=1}^{N} \frac{\partial r_i}{\partial u_i} =\prod_{i=2}^{N} \frac{-u_1}{u_2 u_3 \cdots u_{i-1} u_i^2}$. Moreover, after changes of variables the region of integration is as $0<u_1$ and $0<u_i<1$ for $i=2,...,N$. Therefore, \eqref{eq:step1_Cor2} can be written as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}&=& N! (2 c \lambda \pi )^N \int_{0}^{\infty} \int_{0}^{1} \cdots \int_{0}^{1} u_1 e^{-c \lambda \pi u_1^2} \prod_{i=2}^N \left( \frac{u_1^2 u_i^{-1}\prod_{k=2}^{i}u_k^{-2}} {1+{\sum_{j=1}^{i-1} \prod_{n=j+1}^{i}u_n^{\alpha}}} e^{- c \lambda \pi \frac{u_1^2}{ \prod_{m=2}^{i}u_m^{2}} } \right) {\rm d}{u_N} \cdots {\rm d}{u_2} {\rm d}{u_1} \nonumber \\ &=& N! (2 c \lambda \pi )^N \int_{0}^{1} \cdots \int_{0}^{1} \prod_{i=2}^N \frac{ u_i^{-1}\prod_{k=2}^{i}u_k^{-2}} {1+{\sum_{j=1}^{i-1} \prod_{n=j+1}^{i}u_n^{\alpha}}} \int_{0}^{\infty} u_1^{2N-1} e^{-c \lambda \pi \left( 1+\sum_{i=2}^{N}\prod_{m=2}^{i}u_m^{-2} \right) u_1^2} {\rm d}{u_1} \, {\rm d}{u_N} \cdots {\rm d}{u_2}. \nonumber \end{IEEEeqnarray} Finally, \textcolor{black}{rewriting $\prod_{i=2}^N u_i^{-1}\prod_{k=2}^{i}u_k^{-2}$ as $\prod_{i=2}^N u_i^{-3-2(N-i)}$} and applying $c \lambda \pi \left( 1+\sum_{i=2}^{N}\prod_{m=2}^{i}u_m^{-2} \right) u_1^2=t$ yields \begin{IEEEeqnarray}{rCl} \mathcal{A} &=& N! (2 c \lambda \pi )^N \int_{0}^{1} \cdots \int_{0}^{1} \prod_{i=2}^N \frac{ u_i^{-3-2(N-i)} } {1+{\sum_{j=1}^{i-1} \prod_{n=j+1}^{i}u_n^{\alpha}}} \int_{0}^{\infty} \frac{t^{N-1}e^{-t}{\rm d}t} {2\left( c \lambda \pi\left[ 1+\sum_{i=2}^{N}\prod_{m=2}^{i}u_m^{-2} \right] \right)^N }\, {\rm d}{u_N} \cdots {\rm d}{u_2} \nonumber \\ &=& N!(N-1)!\,2^{N-1} \int_{0}^{1} \cdots \int_{0}^{1} \frac{1}{\left( 1+\sum_{i=2}^{N}\prod_{m=2}^{i}u_m^{-2} \right)^N} \prod_{i=2}^N \frac{ u_i^{-3-2(N-i)} } {1+{\sum_{j=1}^{i-1} \prod_{n=j+1}^{i}u_n^{\alpha}}} {\rm d}{u_N} \cdots {\rm d}{u_2}, \label{eq:step2_Cor2} \end{IEEEeqnarray} {where the final equation is obtained by using the definition of the gamma function.} According to \eqref{eq:step2_Cor2}, $\mathcal{A}$ depends on $\alpha$ and $N$; it does not depend on the BS intensity $\lambda$. \section*{Appendix D: Proof of Theorem~4} \renewcommand{\theequation}{D.\arabic{equation}} \setcounter{equation}{0} For Nakagami-$m$ fading and $N$-UE NOMA, the inner expectation over $\{h\}_{i=1}^N$ can be derived as: \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E}_{\{h_i\}}\left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \right] } \nonumber \\ &=& \mathbb{E}\left[ \mathbf{1} \left( h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \int_{h_2\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha}}^{\infty} \frac{m^m h_1^{m-1}}{\Gamma(m) \Omega^m} e^{ -\frac{m}{\Omega} h_1 } {\rm d}h_1 \right] \nonumber \\ &\stackrel{\text{(a)}}{=}& \mathbb{E}\left[ \mathbf{1} \left( h_2r_{(2)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \frac{m^m }{\Gamma(m) \Omega^m} h_2^{m} \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m} \int_{1}^{\infty} t_1^{m-1} e^{-\frac{m}{\Omega}t_1 h_2\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha} } {\rm d} t_1 \right] \nonumber \\ &=& \mathbb{E}\Bigg[ \mathbf{1} \left( h_3r_{(3)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \left( \frac{m^{m} }{\Gamma(m) \Omega^{m}} \right)^2 \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m} \nonumber \\ &&\> \cdot \int_{1}^{\infty} t_1^{m-1} \int_{h_3\left( \frac{r_{(2)}}{r_{(3)}} \right)^{\alpha}}^{\infty} h_2^{2m-1} \exp\left\{-\frac{m}{\Omega} h_2 \left[1+t_1 \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha}\right] \right\} {\rm d}h_2 {\rm d} t_1 \Bigg] \nonumber \\ &\stackrel{\text{(b)}}{=}& \mathbb{E}\Bigg[ \mathbf{1} \left( h_3r_{(3)}^{-\alpha}>\cdots>h_Nr_{(N)}^{-\alpha} \right) \left( \frac{m^{m} }{\Gamma(m) \Omega^{m}} \right)^2 \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m} \left( \frac{r_{(2)}}{r_{(3)}} \right)^{2 \alpha m} h_3^{2m} \nonumber \\ &&\> \cdot \int_{1}^{\infty} t_1^{m-1} \int_{1}^{\infty} t_2^{2m-1} \exp\left\{-\frac{m}{\Omega} h_3 \left[ t_2\left( \frac{r_{(2)}}{r_{(3)}} \right)^{\alpha}+t_1 t_2 \left( \frac{r_{(1)}}{r_{(3)}} \right)^{\alpha}\right] \right\} {\rm d}t_2 {\rm d} t_1 \Bigg] \nonumber \\ &\stackrel{\text{(c)}}{=}& \left( \frac{m^{m} }{\Gamma(m) \Omega^{m}} \right)^N \left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m} \left( \frac{r_{(2)}}{r_{(3)}} \right)^{2 \alpha m} \cdots \left( \frac{r_{(N-1)}}{r_{(N)}} \right)^{(N-1)\alpha m} \nonumber \int_{1}^{\infty} \int_{1}^{\infty} \cdots \int_{1}^{\infty} t_1^{m-1} t_2^{2m-1} \cdots t_{N-1}^{(N-1)m-1} \nonumber \\ &&\> \cdot \int_0^{\infty} h_N^{Nm-1} \exp\left\{ -\frac{m}{\Omega} h_N \left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right] \right\} {\rm d}h_N {\rm d}t_{N-1} \cdots {\rm d}t_2 {\rm d}t_1. \nonumber \end{IEEEeqnarray} where (a), (b) are obtained by changes of variables $h_1=h_2\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha} t_1$, and $h_2=h_3\left( \frac{r_{(2)}}{r_{(3)}} \right)^{\alpha} t_2$. (c) follows by averaging over $h_3,...,h_N$. Finally, \textbf{Theorem \ref{Thm4}} can be obtained by applying $t_N=\frac{m}{\Omega} h_N \left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]$. \section*{Appendix E: Proof of Corollary 6} \renewcommand{\theequation}{E.\arabic{equation}} \setcounter{equation}{0} From \eqref{eq:match-expectation} and \textbf{Theorem \ref{Thm4}}, we can derive $\mathcal{A}$ as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}&=&\frac{ \Gamma(Nm) }{ \Gamma(m)^N } \int_1^{\infty} \int_1^{\infty} \cdots \int_1^{\infty} \mathbb{E} \left[ \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{(j)}}{r_{(N)}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \right] \prod_{j=1}^{N-1} t_j^{jm-1} {\rm d}t_{N-1} \cdots {\rm d}t_2 {\rm d}t_1, \nonumber \\ \label{eq:final-N_UE-Nakagami} \end{IEEEeqnarray} where expectation is over $\{r_{(i)}\}$. Following the same steps as \textbf{Corollary \ref{Cor2}}, we have \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ \mathbb{E} \left[ \frac{ \prod_{j=1}^{N-1}\left( \frac{r_{(j)}}{r_{(N)}} \right)^{\alpha m} } {\left[ 1+\sum_{i=1}^{N-1} \left( \frac{r_{(i)}}{r_{(N)}} \right)^{\alpha} \prod_{k=i}^{N-1}t_k \right]^{Nm}} \right] =} \nonumber \\ &&\> N!(N-1)!\,2^{N-1} \int_{0}^{1} \cdots \int_{0}^{1} \frac{ \prod_{j=2}^N u_j^{-3-2(N-j)+(j-1)\alpha m} } { \left( 1+\sum_{i=1}^{N-1}\prod_{k=i}^{N-1}u_{k+1}^{\alpha}t_k \right)^{Nm} \left( 1+\sum_{i=2}^{N}\prod_{k=2}^{i}u_k^{-2} \right)^N} {\rm d}{u_N} \cdots {\rm d}{u_2}, \nonumber \end{IEEEeqnarray} which is independent of $\lambda$. \section*{Appendix F: Proof of Theorem~6} \renewcommand{\theequation}{F.\arabic{equation}} \setcounter{equation}{0} From \eqref{eq:match-expectation} and \eqref{eq:inner-expectation_N=2_Nakagami}, $\mathcal{A}$ can be derived as follows: \begin{IEEEeqnarray}{rCl} \mathcal{A}&=&\frac{ \Gamma(2m) }{ \Gamma(m)^2 } \int_1^{\infty} \mathbb{E} \left[ \frac{\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m}} { \left[1+\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha} t_1 \right]^{2m} }\right] t_1^{m-1} {\rm d}t_1 \label{eq:step1_Theorem6}. \end{IEEEeqnarray} In the following, we first derive the expectation in \eqref{eq:step1_Theorem6}. \begin{IEEEeqnarray}{rCl} \mathbb{E} \left[ \frac{\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha m}} { \left[1+\left( \frac{r_{(1)}}{r_{(2)}} \right)^{\alpha} t_1 \right]^{2m} }\right] &=& 2 \int_0^R \int_{r_1}^R \frac{\left( \frac{r_1}{r_2} \right)^{\alpha m}} { \left[1+\left( \frac{r_1}{r_2} \right)^{\alpha} t_1 \right]^{2m} } \frac{2r_1}{R^2} \frac{2r_2}{R^2} {\rm d}r_2 {\rm d}r_1 \nonumber \\ &\stackrel{\text{(a)}}{=}& 8 \int_1^{\infty} \int_1^{u_1} \frac{\left( \frac{u_2}{u_1} \right)^{\alpha m-3}} { \left[1+\left( \frac{u_2}{u_1} \right)^{\alpha} t_1 \right]^{2m} } u_1^{-6} {\rm d}u_2 {\rm d}u_1 \nonumber \\ &\stackrel{\text{(b)}}{=}& 8 \int_1^{\infty} \int_{\frac{1}{u_1}}^{1} \frac{ v^{\alpha m-3}} { \left[1+v^{\alpha} t_1 \right]^{2m} } u_1^{-5} {\rm d}v {\rm d}u_1 \nonumber \\ &\stackrel{\text{(c)}}{=}& 8 \int_0^{1} \int_{\frac{1}{v}}^{\infty} \frac{ v^{\alpha m-3}} { \left[1+v^{\alpha} t_1 \right]^{2m} } u_1^{-5} {\rm d}u_1 {\rm d}v \nonumber \\ &=& 2 \int_0^{1} \frac{ v^{\alpha m+1}} { \left[1+v^{\alpha} t_1 \right]^{2m} } {\rm d}v, \label{eq:step2_Theorem6} \end{IEEEeqnarray} where (a) is obtained by changes of variables $r_1=\frac{R}{u_1}$ and $r_2=\frac{R}{u_2}$. (b) is obtained by applying $v=\frac{u_2}{u_1}$. (c) follows by changing the order of integrals. By substituting \eqref{eq:step2_Theorem6} in \eqref{eq:step1_Theorem6}, we get \begin{IEEEeqnarray}{rCl} \mathcal{A}=\frac{ 2 \Gamma(2m) }{ \Gamma(m)^2 } \int_0^1 \int_1^{\infty} \frac{ v^{\alpha m+1} t_1^{m-1} }{ \left[1+v^{\alpha} t_1 \right]^{2m} } {\rm d}t_1 {\rm d}v. \nonumber \end{IEEEeqnarray} Finally, \textbf{Theorem \ref{Thm6}} can be obtained by applying the substitution $t_1=z^{-1}$ and using the integral representation of Gaussian hypergeometric function. \section*{Appendix G: Proof of Corollary~8} \renewcommand{\theequation}{G.\arabic{equation}} \setcounter{equation}{0} \textcolor{black}{Assume that $M$ users are associated to the typical BS. Here we have used $[M]$ to denote the set $\{1,2,\cdots,M\}$, and we have used the notation $\mathbb{P} \left( h_{\mathcal{U}_{\min}} r_{(\mathcal{U}_{\min})}^{-\alpha}> h_{\mathcal{U}_{\max}} r_{(\mathcal{U}_{\max})}^{-\alpha} \mid \mathcal{U}=[M] \right)$ to emphasize that the NOMA cluster is formed by selecting the nearest and the farthest users from the set $\mathcal{U}$, where $\mathcal{U}$ includes ranks of users that we are allowed to select, $\mathcal{U}_{\min}=\min \mathcal{U}$ is the rank of the nearest user, and $\mathcal{U}_{\max}=\max \mathcal{U}$ is the rank of the farthest user. Note that removing one user from the set $[M]$ corresponds to the case that $M-1$ users are associated to the typical BS. Let assume that user $i$ is removed from the set $[M]$, and the NOMA cluster is formed by selecting the nearest and the farthest users from the set $[M]\setminus\{i\}$. Based on value of $i$, two different scenarios can occur:\\ 1) When $i\in\{2,\cdots,M-1\}$, the nearest and the farthest users in the set $[M]\setminus\{i\}$ are users at rank 1 and $M$, respectively; therefore, \begin{IEEEeqnarray}{rCl} \mathbb{P} \left( h_{\mathcal{U}_{\min}} r_{(\mathcal{U}_{\min})}^{-\alpha}> h_{\mathcal{U}_{\max}} r_{(\mathcal{U}_{\max})}^{-\alpha} \mid \mathcal{U}=[M]\setminus\{i\} \right)=\mathbb{P} \left( h_{\mathcal{U}_{\min}} r_{(\mathcal{U}_{\min})}^{-\alpha}> h_{\mathcal{U}_{\max}} r_{(\mathcal{U}_{\max})}^{-\alpha} \mid \mathcal{U}=[M] \right). \nonumber \end{IEEEeqnarray} 2) When $i\in\{1,M\}$, we can show \begin{IEEEeqnarray}{rCl} \mathbb{P} \left( h_{\mathcal{U}_{\min}} r_{(\mathcal{U}_{\min})}^{-\alpha}> h_{\mathcal{U}_{\max}} r_{(\mathcal{U}_{\max})}^{-\alpha} \mid \mathcal{U}=[M]\setminus\{i\} \right)\le\mathbb{P} \left( h_{\mathcal{U}_{\min}} r_{(\mathcal{U}_{\min})}^{-\alpha}> h_{\mathcal{U}_{\max}} r_{(\mathcal{U}_{\max})}^{-\alpha} \mid \mathcal{U}=[M] \right). \nonumber \end{IEEEeqnarray} Therefore, when we select the nearest and the farthest users for the NOMA cluster, the accuracy probability increases as the set of users that we are selecting from increases. } \textcolor{black}{To complete the proof we need to show \begin{IEEEeqnarray}{rCl} \mathbb{P} \left( h_i r_{(i)}^{-\alpha}>h_j r_{(j)}^{-\alpha} \mid [M] \right) \le \mathbb{P} \left( h_1 r_{(1)}^{-\alpha}>h_M r_{(M)}^{-\alpha} \mid [M] \right), \nonumber \end{IEEEeqnarray} where $i,j\in[M]$. From \eqref{eq:match-expectation}, we have \begin{IEEEeqnarray}{rCl} \mathbb{P} \left( h_i r_{(i)}^{-\alpha}>h_j r_{(j)}^{-\alpha} \mid [M] \right) &=& \mathbb{E}_{h_i,h_j} \left[ \mathbb{E}_{r_{(i)},r_{(j)}} \left[ \mathbf{1} \left( h_ir_{(i)}^{-\alpha}>h_jr_{(j)}^{-\alpha} \right) \right] \right] \nonumber \\ &\stackrel{\text{(a)}}{\le}& \mathbb{E}_{h_i,h_j} \left[ \mathbb{E}_{r_{(1)},r_{(M)}} \left[ \mathbf{1} \left( h_ir_{(1)}^{-\alpha}>h_jr_{(M)}^{-\alpha} \right) \right] \right] \nonumber \\ &\stackrel{\text{(b)}}{=}& \mathbb{E}_{h_1,h_M} \left[ \mathbb{E}_{r_{(1)},r_{(M)}} \left[ \mathbf{1} \left( h_1r_{(1)}^{-\alpha}>h_Mr_{(M)}^{-\alpha} \right) \right] \right] \nonumber \\ &=& \mathbb{P} \left( h_1 r_{(1)}^{-\alpha}>h_M r_{(M)}^{-\alpha} \mid [M] \right), \nonumber \end{IEEEeqnarray} where (a) is obtained since for any realization of user point process that $h_ir_{(i)}^{-\alpha}>h_jr_{(j)}^{-\alpha}$ is satisfied, $h_ir_{(1)}^{-\alpha}>h_jr_{(M)}^{-\alpha}$ is also true, i.e., $h_ir_{(i)}^{-\alpha}>h_jr_{(j)}^{-\alpha}$ is a sufficient condition for $h_ir_{(1)}^{-\alpha}>h_jr_{(M)}^{-\alpha}$. (b) follows since all the channel power gains are i.i.d. } \IEEEpeerreviewmaketitle \bibliographystyle{IEEEtran}
{'timestamp': '2018-10-05T02:03:22', 'yymm': '1810', 'arxiv_id': '1810.01966', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01966'}
arxiv
\section{Introduction} Approximately 3.6 billion diagnostic radiological examinations, such as radiographs (x-rays), are performed globally every year \cite{report}. Chest radiographs are performed to evaluate the lungs, heart and thoracic viscera. They are crucial for diagnosing various lung disorders in all levels of health care. Computer-aided diagnostic (CAD) tools serve an important role to assist the radiologists with the growing number of chest radiographs. Accurate segmentation of anatomical structures in chest radiographs is essential for many analysis tasks in CAD. For example: segmentation of the lungs field can help detecting lung diseases and shape irregulars; segmentation of the heart outline can help to predict cardiomegaly; and the segmentation of clavicles can improve the diagnosis of pathologies near the apex of the lung. Evaluating a chest radiograph is a challenging task due to the high variability between patients, unclear and overlapping organs borders, and image artifacts. A clear and high quality radiograph is not easy to acquire. This challenge drew many researchers over the years to improve the segmentation of anatomical structures in chest radiographs \cite{novikov,park,ibragimov,yang}. An open benchmark dataset that was provided by Ginneken et al. \cite{ginneken_scr} facilitated over the years an objective comparison between the different segmentation methods. Classic approaches include active shape and appearance models, pixel classification methods, hybrid models and landmark based models. More recently deep learning approaches were suggested \cite{novikov,park} based on the successful employment of convolutional neural networks (CNNs) on various detection and segmentation tasks in the medical imaging domain \cite{dl_overview}. CNN architectures for semantic segmentation usually incorporate encoder and decoder networks \cite{unet_olaf,FCN} that reduce the resolution of the image to capture the most important details and then restore the resolution of the image. Another semantic segmentation approach is to keep the resolution of the network by incorporating dilated convolutions \cite{DRN} that enlarge the global receptive field of the CNN to larger context information. In both approaches, the CNN can output single-class or multiple-class segmentation masks. The resolution of the output mask is the same as the input radiograph image. The training process of each CNN is affected by several training features: One is the selection of the loss function that guides the optimization process during the training process (with different loss functions effecting differently the final output segmentation performance results); The other is the initialization of the network weights - random initialization or weights transferred from another trained network (transfer learning from a totally different task). In this paper, we explore the segmentation of anatomical structures in chest radiographs, namely the lungs field, the heart and the clavicles, using a set of the most advanced CNN architectures for multi-class semantic segmentation. We propose an improved encoder-decoder style CNN with pre-trained weights of the encoder network and show its superiority over other state of the art CNN architectures. We further examine the use of multiple loss functions for training the best selected network and the effect of multi-class vs. single-class training. We present qualitative and quantitative comparisons on a common benchmark data, based on the JSRT database \cite{JSRT}. Our best performing model, the U-net with an ImageNet pre-trained encoder, outperformed the currently state-of-the-art segmentation methods for all anatomical structures. \section{Methods} \subsection{Fully Convolutional Neural Network Architectures} \label{FCN_arch} Fully convolutional networks (FCN) are extensively used for semantic segmentation tasks. In this study, four different state of the art architectures have been tested as follows: \textbf{FCN} - The first FCN architecture that we used in this work is based on the FCN-8s net that uses the VGG-16 layer net \cite{FCN,vgg}. The VGG-16 net is converted into an FCN by decapitating the final classification layer and converting fully connected layers into convolution. Deconvolution layers are then used to upsample the coarse outputs to pixel-dense outputs. Skip connections are used to merge output from previous pooling layers in the network which was shown to improve the segmentation quality \cite{FCN}. \textbf{Fully convolutional DenseNet} - The second network architecture that was tested is based on the fully convolutional DenseNet shown in \cite{fc_densenet_tiramisu}. DenseNet architecture \cite{densenet} proposes intensive layer fusion. Each dense block consists of a set of convolution layers using a similar scale where each convolution layer processes the concatenation of all its previous layers thus enabling the fusion of numerous representation levels. For the fully convolutional DenseNet architecture a decoding path is added to generate the segmentation output. The fusion between different layers consists of intra dense block layers fusion as well as the concatenation of the preceding high level feature maps and the ones coming from the encoding block at the same scale. \textbf{Dilated residual networks} - The dilated residual network (DRN) \cite{DRN} uses dilated convolution \cite{atrous} to increase the resolution of output feature maps without reducing the receptive field of individual neurons. It was shown to improve the performance compared to the standard residual networks presented in \cite{resnet}. We have implemented the DRN-C-26 as stated in \cite{DRN}. \textbf{U-Net with VGG-16 encoder} - The U-Net architecture \cite{unet_olaf} has been extensively used for different image-to-image tasks in computer vision with a major contribution to the image segmentation task. The U-Net includes a contracting path (the encoder) with several layers of convolution and pooling for down-sampling. The second half of the network includes an expansion path (the decoder) that uses up-sampling and convolution layers sequentially to generate an output with a similar size as the input image. Additionally, the U-Net architecture combines the encoder features with the decoder features in different levels of the network using skip connections. Iglovikov et al \cite{TernausNet} proposed to use a VGG11 \cite{vgg} as an encoder which was pre-trained on ImageNet \cite{Imagenet} dataset and showed that it can improve the standard U-Net performance in binary segmentation of buildings in aerial images. A similar concept was used in the current study with the more advanced VGG16 \cite{vgg} as an encoder. Figure \ref{fig:architecture} shows a diagram of our proposed network. The chest X-ray image is duplicated to obtain an input image with 3 channels similar to the RGB images that are used as input to the VGG-16 net (which is the encoder in the proposed architecture). \begin{figure} \centering \includegraphics[height=5.0 cm]{Unet_vgg_architecture.png} \caption{The proposed U-Net architecture with a VGG-16 based encoder.} \label{fig:architecture}\end{figure} \subsection{Objective loss functions} The loss function is used to guide the training process of a convolutional network by measuring the compatibility between the network prediction and the ground truth label. Let us denote S as the estimated segmentation mask and G as the ground truth mask. In a multi-class semantic segmentation task including $C = \{c_1,...,c_m\}$ classes, the total loss (TS) between S and G is defined as the sum of losses in every class: \begin{equation} TL(S,G)=\sum_{c=1}^{m}L_c(S,G) \end{equation} In this study we explore the influence of using different loss functions in the FCNs training process. The Dice similarity coefficient (DSC) and Jaccard similarity coefficient (JSC) are two well known measures in segmentation and can be used as objective loss functions in training. These segmentation measures between S and G are defined as: \begin{equation} DSC(S,G)=2\frac{|SG|}{|S|+|G|} \end{equation} \begin{equation} JSC(S,G)=\frac{|SG|}{|S|+|G|-|SG|} \end{equation} when used as loss in training, both measures weights FP and FN detections equally. The Tversky loss \cite{Tversky} introduces weighting into the loss function for highly imbalanced data, where we want to segment small objects. The Tversky index is defined as: \begin{equation} Tversky(S,G;\alpha,\beta)=\frac{|SG|}{|SG|+\alpha|S / G|+\beta|G / S|} \end{equation} where $\alpha$ and $\beta$ control the magnitude of penalties for FPs and FNs, respectively. In our study we used $\alpha=0.3$ and $\beta=0.7$. An additional loss function tested is the Binary Cross-Entropy (BCE). BCE was calculated separately for each class segmentation map. For each pixel $s_i\in S$ and pixel $g_i\in G$ that share the same pixel position i, the loss is averaged over all pixels $N$ as follows: \begin{equation} BCE(S,G)=\frac{1}{N}\sum_{i=1}^N g_i\log(s_i) + (1-g_i)\log(1-s_i) \end{equation} \section{Segmentation of Anatomical Structures} \subsection{Dataset} Evaluation of the chest anatomical structures segmentation was done on chest radiographs from the JSRT database \cite{JSRT}. This public database includes 247 posterior-anterior (PA) chest radiograph images of size $2048\times2048$ pixels, 0.175 mm pixel spacing and 12-bit gray levels. Ginneken et al. \cite{ginneken_scr} publicized the Segmentation in Chest Radiographs (SCR) database, a benchmark set of segmentation masks for the lungs field, heart and clavicles (see Figure \ref{fig:data_sample}). The annotations were made by two human observers and a radiologist consultant. The segmentations of the first observer generate the ground-truth segmentation masks and the other - human observer results. The benchmark data is split into two folds of 124 and 123 cases, each containing equal amount of normal cases and cases with lung nodules. Following the suggested instructions for comparison between the segmentation results, images in one fold were used for training and images from the other fold were used for testing, and vise versa. The final evaluation is defined as the average performance over the two folds. \begin{figure} [H] \centering \includegraphics[height=3.0 cm]{data_sample.png} \caption{Data sample from \cite{ginneken_scr}: (a) chest radiograph image; (b) clavicles segmentation mask; (c) lung segmentation mask; (d) heart segmentation mask.} \label{fig:data_sample} \end{figure} For training, we resize the images to $224\times 224$ pixels and normalize each image by its mean and standard deviation. The networks are trained using Adam optimizer with initial learning rate of $10^{-5}$ and default parameters for 100 epochs. We use augmentations of scaling, translation and small rotations. In testing, We threshold the output score maps with $threshold = 0.25$ to generate binary segmentation masks of each anatomical structure. \subsection{Performance Measures} To measure the performance of the proposed architectures and compare to state-of-the-art results, we use well accepted metrics for segmentation: Dice similarity coefficient, Jaccard index (also known as intersection over union) and mean absolute contour distance (MACD). MACD is a measure of distance between two contours. For each point on contour A, the closest point on contour B is computed by the euclidean distance $d(a_{i},B) = min_{b_{j}\in B}\norm{b_{j} - a_{i}}$. The distance values are then averaged over all points. Since distances from A to B are not the same as B to A, we derive a common average between the two averages as follows: \begin{equation} MACD(A,B)=\frac{1}{2}(\frac{\sum_{i=1}^{n} d(a_{i},B)}{n} + \frac{\sum_{i=1}^{m} d(b_{i},A)}{m}) \end{equation} Because MACD measure is given in millimeters, we multiply the original pixel spacing by a factor of $2048 / {224}$ to match the target image resolution. \subsection{Experimental Results} Table \ref{tabel:arch_compare} compares the segmentation performance of the four state of the art fully convolutional networks for semantic segmentation as listed in section \ref{FCN_arch}. All models are trained for multi-class segmentation into three classes: $lungs \ field,\\ heart, \ clavicles$. We use the $sigmoid$ activation function after the last layer of each network with $Dice$ as the loss function. An additional column in Table \ref{tabel:arch_compare} shows if the network is fine-tunned (FT) from a pre-trained network. The results show that the best performing architecture for the segmentation of all anatomical structures in chest radiograph, is the U-Net including the VGG16 encoder pre-trained on ImageNet. This architecture achieved the highest segmentation overlap scores (Jaccard) of 0.961, 0.906 and 0.855 for the Lungs field, Heart and Clavicles respectively. It is noticeable that between all four architectures, the fine-tuned networks performed better than the networks trained from scratch. \begin{table}[t] \caption{Segmentation results of four compared architectures trained with multi-class Dice loss showing the Dice(D), Jaccard (J) and MACD metrics. Fine tuned (FT) architectures include a pre-trained VGG16 as an initial encoder.} \label{tabel:arch_compare} \centering \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|} \cline{3-11} \multicolumn{2}{c}{} &\multicolumn{3}{|c|}{Lungs} & \multicolumn{3}{c|}{Heart} & \multicolumn{3}{c|}{Clavicles} \\ \hline Architecture & FT & D & J & MACD & D & J & MACD & D & J & MACD \\ \hline \hline FCN & v & 0.976 & 0.953 & 1.341 & 0.944 & 0.895 & 3.099 & 0.884 & 0.795 & 1.277 \\ \hline U-Net (VGG16) & v & \textbf{0.980} & \textbf{0.961} & \textbf{1.121} & \textbf{0.950} & \textbf{0.906} & \textbf{2.569} & \textbf{0.921} & \textbf{0.855} & \textbf{0.871} \\ \hline FC DenseNet & {} & 0.973 & 0.947 & 1.511 & 0.934 & 0.879 & 3.396 & 0.884 & 0.796 & 1.349 \\ \hline DRN & {} & 0.966 & 0.935 & 1.842 & 0.936 & 0.881 & 3.365 & 0.840 & 0.727 & 1.860 \\ \hline \end{tabular} \end{table} For the top performing architecture, the U-Net based network, we further analyzed several training features. Table \ref{tabel:loss_compare} summarizes the multi-class segmentation performance using different objective loss functions. It is evident that structures with smaller pixel area, like the clavicles, benefits from loss metrics with pixel weighing such as Tversky loss function. We also tested the performance of training a single-class network for each of the three classes vs. the multi-class training. For the lungs, the single class training did not resolve in significant improvement. However, for the heart and clavicles, the Dice and Jaccard scores in a single-class training were improved each by 1\% in comparison to the multi-class training. The last improvement in performance of the multi-class segmentation was achieved using post-processing including small objects removal and hole fill. While the Dice and Jaccard metrics were not improved, the MACD metric showed an improvement from 1.121, 2.569 and 0.871 [mm] for the lungs, heart and clavicles to 1.019, 2.549 and 0.856 [mm] respectively. Figure \ref{fig:examples} shows a few segmentation examples of our best performing model. A comparison of our U-Net based model trained with multi-class dice loss to existing state-of-the-art methods, validated on the same benchmark of chest radiographs and a human observer, is presented in Table \ref{tabel:state_of_the_art_compare}. \begin{table}[t] \caption{Multi-class segmentation results using different loss functions including DSC, JSC, Tversky and BCE (rows). The Dice(D), Jaccard (J) and MACD are used as metrics (columns) for each anatomical structure.} \label{tabel:loss_compare} \centering \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|} \cline{2-10} \multicolumn{1}{c}{} &\multicolumn{3}{|c|}{Lungs} & \multicolumn{3}{c|}{Heart} & \multicolumn{3}{c|}{Clavicles} \\ \hline Loss Function & D & J & MACD & D & J & MACD & D & J & MACD \\ \hline \hline DSC & \textbf{0.980} & \textbf{0.961} & 1.121 & \textbf{0.950} & \textbf{0.906} & \textbf{2.569} & 0.921 & 0.855 & \textbf{0.871} \\ \hline JSC & 0.979 & 0.960 & \textbf{1.082} & 0.949 & 0.905 & 2.602 & 0.921 & 0.855 & 0.920 \\ \hline Tversky & 0.979 & 0.960 & 1.139 & \textbf{0.950} & 0.905 & 2.581 & \textbf{0.923} & \textbf{0.858} & 0.987 \\ \hline BCE & \textbf{0.980} & \textbf{0.961} & 1.119 & \textbf{0.950} & \textbf{0.906} & 2.592 & 0.911 & 0.838 & 1.145 \\ \hline \end{tabular} \end{table} \begin{figure}[h] \centering \includegraphics[height=6.5 cm]{seg_examples4.png} \caption{Segmentation results of our best performing architecture with Jaccard score above each image for the Lungs(L), Heart(H) and Clavicles(C); Ground-truth segmentation is shown in blue, CNN segmentation in red and the overlap (true detections) in green.} \label{fig:examples} \end{figure} \begin{table}[h] \caption{Our best performing architecture compared to state-of-the-art models; "-" means that the score was not reported; (*) used different data split than suggested in SCR benchmark} \label{tabel:state_of_the_art_compare} \centering \begin{tabular}{p{4cm} p{2.5cm} p{2.5cm} p{2.5cm}} \hline {} & Dice & Jaccard & MACD (mm) \\ \hline \textit{Lungs} & {} & {} & {} \\ Human observer \cite{ginneken_scr} & - & $0.946\pm 0.018$ & $1.64\pm 0.69$ \\ Hybrid voting \cite{ginneken_scr} & - & $0.949\pm 0.020$ & $1.62\pm 0.66$ \\ Ibragimov et al. \cite{ibragimov} & - & $0.953\pm 0.020$ & $1.43\pm 0.85$ \\ Hwang and Park \cite{park} & $0.980\pm 0.008$ & $0.961\pm 0.015$ & $1.237\pm 0.702$ \\ Novikov et al. \cite{novikov}(*) & $0.974$ & $0.950$ & - \\ Yang et al. \cite{yang} & $0.975\pm 0.001$ & $0.952\pm 0.018$ & $1.37\pm 0.67$ \\ U-Net (VGG16) & $0.980\pm 0.008$ & $0.961\pm 0.014$ & $1.019\pm 0.564$ \\ \\[-0.7em] \textit{Heart} & {} & {} & {} \\ Human observer \cite{ginneken_scr} & - & $0.878\pm 0.054$ & $3.78\pm 1.82$ \\ Hybrid voting \cite{ginneken_scr} & - & $0.860\pm 0.056$ & $4.24\pm 1.87$ \\ Novikov et al. \cite{novikov}(*) & $0.937$ & $0.882$ & - \\ U-Net (VGG16) & $0.950\pm 0.021$ & $0.906\pm 0.038$ & $2.549\pm 1.126$ \\ \\[-0.7em] \textit{Clavicles} & {} & {} & {} \\ Human observer \cite{ginneken_scr} & - & $0.896\pm 0.037$ & $0.68\pm 0.26$ \\ Hybrid voting \cite{ginneken_scr} & - & $0.736\pm 0.106$ & $1.88\pm 0.93$ \\ Novikov et al. \cite{novikov}(*) & $0.929$ & $0.868$ & - \\ U-Net (VGG16) & $0.921\pm 0.027$ & $0.855\pm 0.045$ & $0.855\pm 0.322$ \\ \hline \end{tabular} \end{table} \section{Discussion and Conclusion} Segmentation of anatomical structures in chest radiographs is a challenging task that attracted considerable interest over the years. The advantages of newly introduced CNN architectures, together with the public benchmark dataset provided in \cite{ginneken_scr} on the JSRT images, motivated further studies in this field. Some of the recent studies focused only on the problem of lung segmentation, and a few have also dealt with the problem of heart and clavicles segmentation. In this paper, we employed and evaluated the segmentation performance of four top FCN architectures \cite{fc_densenet_tiramisu,FCN,DRN,TernausNet} for semantic segmentation for all three anatomical structures, using multi-class dice loss. The network architectures presented in this study are well known and showed promising results in many computer vision semantic segmentation tasks. The FCN \cite{FCN} and the U-Net \cite{unet_olaf} are considered classical approaches while the FC DenseNet and the DRN are more advanced and relatively new approaches for semantic segmentation. Hence, it was interesting to see in Table \ref{tabel:arch_compare} that the classic U-Net and FCN showed superior segmentation performance over the more advanced approaches. The advantage of using pre-trained networks for medical imaging tasks has already been shown in several studies \cite{dl_overview}, and even though only the encoder part of the FCN and U-Net (VGG16 encoder) networks was pre-trained using the ImageNet database in our case, it seemed to be advantageous. The best segmentation performance was obtained using the proposed U-Net based architecture including the pre-trained VGG16 encoder (Table \ref{tabel:arch_compare}). Next, we explored the effect of training multi-class segmentation model using different loss functions (Table \ref{tabel:loss_compare}). We demonstrated that small structures such as the clavicles can benefit from weighted loss functions such the Tversky loss function while the larger structures (lung and heart) achieved the best segmentation results using Dice or Binary Cross-Entropy loss functions. Applying additional minor post-processing resulted in further decrease of the MACD measure with cleaner and more precise segmentations for all three structures as displayed in Figure \ref{fig:examples}. Table \ref{tabel:state_of_the_art_compare} presents the final comparison between our top selected model, the multi-class U-Net VGG16 with dice loss, to state-of-the-art methods \cite{ginneken_scr,ibragimov,park,novikov,yang} and human observer segmentations \cite{ginneken_scr}. Our model outperformed all state-of-the-art methods tested in this study and the human observer for the lungs and heart segmentation. For the clavicles segmentation, fewer studies were conducted. Novikov et al. \cite{novikov} reported results on different data split than the benchmark recommendation so its not an objective comparison. However, our proposed network outperformed an additional top reported method \cite{ginneken_scr}. In conclusion, we presented an experimental study in which four top segmentation architectures and several losses were compared for the task of segmenting anatomical structures on chest X-Ray images. Results were evaluated quantitatively with qualitative examples of our best performing model. Improving the segmentation of the lung field, heart and clavicles is the foundation for better CAD tools and the development of new applications for medical thoracic images analysis.
{'timestamp': '2018-10-05T02:09:05', 'yymm': '1810', 'arxiv_id': '1810.02113', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02113'}
arxiv
\section{Conclusion} We addressed a problem of learning feature representations for a graph of graphs (GoG) and presented a dual convolution approach that combines both the external and internal graphs in an end-to-end manner. The proposed method was particularly designed for link prediction on an external graph and we demonstrated the effectiveness of the proposed method for predicting interactions among molecules by using three chemical network datasets. Our dual convolution approach achieved high prediction performance even though the features were lower-dimensional compared to the off-the-shelf features in networks with heavy-tailed degree distributions. We found that the performance of the dual convolution approach becomes inferior on an extremely-sparse external network with a light-tailed degree distribution because of the difficulty of exploiting the information about the external network. Although we focused only on link prediction in this paper and the applications in other prediction tasks, such as node classification or clustering, will be addressed in future work. \section{Experiments} We evaluate the idea of the dual convolution that combines the structural information of both internal and external graphs in a GoG. We compare the link prediction accuracy of the proposed method and several baselines using three real chemical networks. Overall, the proposed method works well for moderately dense external networks with heavy-tailed degree distributions. In an extremely sparse and light-tailed external network, external links are almost useless, and the domain specific features (Morgan indices) perform the best. The internal convolution also suffers from the lack of external links as the training data. \begin{figure*}[tb] \captionsetup[subfigure]{justification=centering} \begin{minipage}{0.33\hsize} \centering \includegraphics[width=55mm]{images/3a.pdf} \subcaption{Drug-drug interaction \\ (dense, extremely heavy-tailed)} \label{fig:one} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \includegraphics[width=55mm]{images/3b.pdf} \end{center} \subcaption{Drug-function \\ (sparse, heavy-tailed)} \label{fig:two} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \includegraphics[width=55mm]{images/3c.pdf} \end{center} \subcaption{Metabolite \\ (extremely sparse, light-tailed)} \label{fig:three} \end{minipage} \caption{\small{Node degree distributions of the external graphs of the three GoG datasets. \label{fig:degree} }} \end{figure*} \subsection{Specific implementation of the proposed model} We have freedom of choice in our dual convolutional network such as the nonlinear activation functions and the depth of each layer. In the experiments, we use the following specific choices. In the internal graph convolution (\ref{internal_convolution}), we use $\mbox{ReLU}$ as function $f_G$, and use different $\mathbf W$ and $\mathbf M$ for different degrees ($|A_k|$ and $|A_m|$) and convolutional steps. The node representation $\mathbf{v}_{k}$ is randomly initialized depending on their atom types, e.g., $\mathbf{v}_{\text{hydrogen}} = [0.1, 0.5]^\top$ and $\mathbf{v}_{\text{oxygen}} = [-0.4, 1.2]^\top$ (if $d=2$) which are generated from a same Gaussian distribution. We set the number of dimension of the internal graph representations as $d=64$. When we obtain the internal graph representations, ${\mathbf g}^{(T)}$ in the internal convolution (\ref{internal_output}) and ${\mathbf h}^{(T+L)}$ in the external convolution (\ref{external_output}), we use the $\mbox{softmax}$ function as $\sigma_G$ and $\sigma_{\mathcal G}$. In the external graph convolution (\ref{external_convolution}), we use the $\mbox{softmax}$ function as $f_{\mathcal G}$, and use different $\mathbf U$ and $\mathbf V$ for different convolutional steps; we do not distinguish different degrees because the interaction networks have larger numbers of degrees than molecular graphs as shown in Fig.~\ref{fig:degree}. We use the two-layer neural network as the link prediction network~(\ref{neural_network}) whose input is given as $\left( \mathbf h_i^{(T+L)}+ \mathbf h_j^{(T+L)} \right)\oplus\left(\mathbf h_i^{(T+L)} \odot \mathbf h_j^{(T+L)}\right)$, where $\oplus$ is the concatenation of two vectors and $\odot$ is the Hadamard product. Note that the input is symmetric with respect to $\mathbf h_i^{(T+L)}$ and $\mathbf h_j^{(T+L)}$. The layer sizes are $(128, 64, 2)$, and all the non-linear activation functions are $\mbox{ReLU}$. We implement the proposed dual convolution using Chainer~\cite{tokui2015chainer} and use ADAM~\cite{kingma2014adam} as the optimizer. The batch size is set to $256$ in the drug-drug dataset and in the drug-function dataset, and set to $128$ in the metabolite dataset. The numbers of convolution steps $T$ and $L$ are tuned using the grid search; the candidate values are $\{1, 3, 5\}$ for all the dataset except $T$ for the metabolite dataset. We set $T \in \{1, 3\}$ for the metabolite dataset as due to its large dataset size. We also set the dropout rate $0.2$ in Equations (\ref{internal_convolution}) and~(\ref{external_convolution}). We use a validation set to tune those hyperparameters\footnote{Due to the limitation of the computational resources, we could not help limiting the hyperparameter ranges rather ``intuitively'' depending on the network sparsity and other data characteristics to perform thorough search over all possible hyperparameter combinations.}. \subsection{Datasets and performance metric}\label{sec:datasets} We prepare three different chemical GoGs with different levels of sparsity and different weights of the tails of the degree distributions. \subsubsection*{(a) Drug--drug interaction network} is a network of drug compounds where two compounds have an edge if they are known to interact, interfere, or cause adverse reactions when taken together. From the DrugBank database\footnote{\url{https://www.drugbank.ca/releases/latest}}, we used $1{,}993$ approved drugs that have fewer than $64$ atoms. Out of all possible $\binom{1993}{2}=1,985,028$ compound pairs, $186{,}555$ have edges; the link density is $0.0940$ which means it is a relatively dense network. Figure~\ref{fig:one} shows its degree distribution that shows a very heavy-tailed distribution. We have only positive links in this dataset; this situation is sometimes dealt with positive-and-unlabeled learning~\cite{cerulo2010learning}; however, we just regard sampled no-links as the negative links for simplicity~\cite{doi:10.1093/bioinformatics/btn273}. We randomly choose $n$ positive links and $n$ no-links (i.e., negative links) as the training dataset. We vary $n$ from $1$k to $10$k to investigate the importance of incorporating the information of the external graph by the external convolution. As the test dataset, we randomly extract positive and negative links from the same data distribution as the original network to preserve the data imbalance, which results in $9{,}398$ positive links and $90{,}601$ negative links. \subsubsection*{(b) Drug--function network} is a network of drug compounds where two compounds have an edge if they share the same target protein. From the original dataset~\cite{takigawa2011mining}, we used $3{,}918$ compounds that have fewer than $64$ atoms. Out of all possible $\binom{3918}{2}=7,673,403$ compound pairs, $35{,}562$ have edges; the link density is $0.0046$ which means it is a sparse network. Figure~\ref{fig:two} shows its degree distribution that shows a relatively heavy-tailed distribution. As well as the drug-drug interaction dataset, this network also has only positive links; therefore, we sample no-links as the negative links. We have $1{,}390$ positive links and $298{,}609$ negative links in the test set. \subsubsection*{(c) Metabolite reaction network} is a network of metabolite compounds where two compounds have an edge if they are the substrate-product pair in an enzymatic reaction on metabolic pathways~\cite{kotera2014data}. In this study we collected $5{,}920$ compounds that have fewer than $64$ atoms. Out of all possible $\binom{5920}{2}=17,520,240$ compound pairs, only $5{,}041$ have edges; the link density is $0.0003$ which means it is an extremely sparse network. Figure~\ref{fig:three} shows its degree distribution that shows a light-tailed distribution. Different from the other two datasets, this network has both $5,041$ positive links and $220,096$ negative links; the test set consists of $223$ positive links $9,777$ negative links. \begin{figure*}[tb] \begin{minipage}{\hsize} \vspace{2mm} \includegraphics[width=\hsize]{images/legend.pdf} \end{minipage} \end{figure*} \begin{figure*}[tb] \captionsetup[subfigure]{justification=centering} \vspace{-2mm} \begin{minipage}{0.33\hsize} \centering \includegraphics[width=55mm]{images/drug_roc.pdf} \label{fig:drug_roc} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \includegraphics[width=55mm]{images/drugprotein_roc.pdf} \end{center} \label{fig:drugfunction_roc} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \includegraphics[width=55mm]{images/metabolite_roc.pdf} \end{center} \label{fig:metabolite_roc} \end{minipage} \captionsetup[subfigure]{justification=centering} \begin{minipage}{0.33\hsize} \centering \vspace{-3mm} \includegraphics[width=55mm]{images/drug_pr.pdf} \subcaption{Drug-drug interaction \\ (dense, extremely heavy-tailed)} \label{fig:drug} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \vspace{-3mm} \includegraphics[width=55mm]{images/drugprotein_pr.pdf} \end{center} \subcaption{Drug-function \\ (sparse, heavy-tailed)} \label{fig:drugfunction} \end{minipage} \begin{minipage}{0.33\hsize} \begin{center} \vspace{-3mm} \includegraphics[width=55mm]{images/metabolite_pr.pdf} \end{center} \subcaption{Metabolite \\ (extremely sparse, light-tailed)} \label{fig:metabolite} \end{minipage} \caption{\small{Link prediction performance in (a) the drug-drug interaction network, (b) the drug-function network, and (c) the metabolite reaction network. The proposed method performs well for the first two networks ((a) and (b)) with heavy-tailed degree distributions. On the other hand, in the extremely sparse and light-tailed external network (c), the external links are almost useless as features, and therefore the domain specific features (i.e., Morgan indices) perform the best. The internal convolution also suffers from the lack of external links as the training data. \color{black} \label{fig:experiments} }} \end{figure*} \subsubsection*{} In all of the three chemical networks, each external node is a relatively small compound (i.e. with up to $64$ atoms), while they have different levels of sparsity and degree distributions as shown in Fig.~\ref{fig:degree}, which is a typical variation in chemical networks. Our main interest is to obtain insights about the conditions of chemical networks in which the dual convolution is effective. \iffalse 最後に、上の3つデータを使う意味を言う。 上のネットワークにおいて、内部グラフ(つまり化合物)にはそこまでバリエーションはない(原子数64だし)。 一方で外部グラフ(つまりネットワーク)には、図に示すように、密度や次数に様々なバリエーションを持っている。 上のようないろいろなネットワークで、我々の手法と下に示す比較手法がどの程度動作するのか、適用範囲を考察する。 \fi \color{black} \subsection{Compared methods} We compare the proposed dual convolutional network with several baselines, namely, (i) a model using only internal graph convolution, (ii) models based only on external graph structures, and (iii) a model based on hashed Morgan fingerprints instead of the internal graph convolution, \subsubsection*{(i) Internal graph convolution} obtains $64$-dimensional representations of molecular graphs. We do not use the external graph convolution, but we create a feature vector for each molecule by the internal convolution and directly use it as an input to the link prediction network. We use the same convolution formula as that by Duvenaud {\it et al.}~(\citeyear{NIPS2015_5954}). \subsubsection*{(ii) External graph embedding} is a standard approach to link prediction using only the external graph. We test DeepWalk~\cite{perozzi2014deepwalk} that is one of the well-known embedding methods, and also test the general relational embedding model proposed by Yan {\it et al.}~\cite{yang2015embedding} where the latent representation for each molecule is initialized to a $64$-dimensional random vector. The link prediction network~\eqref{neural_network} is applied to a pair of molecules. \subsubsection*{(iii) Hashed Morgan fingerprints} define molecular graph features using chemical substructures. We use $2048$-dimensional Morgan fingerprints as a feature vector of a molecule. The link prediction network \eqref{neural_network} is applied to a pair of molecules. \if0 The regularization parameter, $\lambda$, was set to $0$ in the experiments. \fi \subsection{Results} As we mentioned in Section~\ref{sec:datasets}, all the datasets have imbalance nature in terms of the number of positive and negative labels; therefore we measure the predictive performance of each method using (i)~ROC-AUC which is not affected by the label imbalance and (ii)~PR-AUC which can suitably evaluate the performance on imbalanced datasets. Figure~\ref{fig:experiments} shows the comparison of the proposed method and four baselines with different training set sizes in terms of ROC-AUC and PR-AUC. In Figure~\ref{fig:drug}, our dual convolution achieves consistently better ROC-AUC and PR-AUC scores over the baselines in the drug-drug interaction dataset. This is probably due to the heavy-tailed degree distribution of its external graph. In such networks, external links are likely to form a longer path, and therefore, the dual convolution successfully extracts structural features in the external graph. \if0 \color{blue} Figure~\ref{fig:drugfunction} shows the result for the drug-function network. The advantage of the dual convolution still remains when the network is more sparse. The external graph is moderately heavy-tailed and external links are still likely to form a path; the dual convolution benefits from both the internal and external graphs. Note that this also allows DeepWalk to extract structural features from the external graph, which is seen as the increase in performance as we increase the size of the training dataset. \fi Figure~\ref{fig:drugfunction} shows the result for the drug-function network. It shows that the highest ROC-AUC score by the dual convolution. The advantage of the dual convolution still remains when the external network is relatively sparse. The external graph is moderately heavy-tailed and external links are still likely to form a path; the dual convolution benefits from both the internal and external graphs. In addition, the ROC-AUC score of DeepWalk improves as the size of the training set increases; this implies that DeepWalk successfully extracts structural features from the relatively dense external graph. Surprisingly, DeepWalk significantly outperform the others in terms of PR-AUC, while our dual convolution achieves the best ROC-AUC score. Given that DeepWalk does not consider the internal graph structure at all, information of the external graph is more crucial than the internal graphs in the drug-function network. In contrast to the other two networks, the metabolite network is an extremely sparse that has very few links and a light-tailed degree distribution. The external links are almost useless in this network, and therefore the relational embedding method and DeepWalk that solely depend on external links perform poorly (Figure~\ref{fig:metabolite}). Especially, DeepWalk performs the worst in terms of both ROC-AUC and PR-AUC because it cannot ``walk" over the external links. Similarly, the proposed method cannot even benefit from the external convolution, and it suffers from the sparse external links. The lack of the external links as the training dataset is also a severe limitation for extracting features from the internal graphs. In such a sparse data domain, traditional off-the-shelf features such as Morgan indices are still reliable choices. In summary, our experimental results suggest that the dual convolution is effective for relatively dense networks, especially when both the internal and external structures must be considered in an integrated manner. Among the three networks, the links of the drug-drug interaction network represent direct chemical interactions between two compounds. In such networks, nontrivial combination of different internal substructures of both ends of a link contributes to the interaction. On the other hand, the links represent rather indirect chemical relations in the other two networks, where the benefit of the dual convolution remains limited. \iffalse \color{red} Figure~\ref{fig:experiments} shows the comparisons of the ROC-AUC scores and the PR-AUC scores of the proposed method and the four baselines on the three datasets: (a) the drug-drug interaction network, (b) the drug-function network, and (c) the metabolite network. \Tsubaki{Figure~\ref{fig:experiments} shows the comparisons of the AUC and RC scores of the proposed method and the four baselines (i), (ii), (iii), and (iv) on the three datasets (a), (b), anc (c).} For the drug-drug interaction network which is a relatively dense network with a very heavy-tailed degree distribution, the proposed method shows consistently better performance over the baselines (Figure~\ref{fig:drug}). This is because of its heavy-tailed degree distribution; sampled links are likely to form a longer path and the dual convolution successfully extracts structural features in the external graph. \Tsubaki{For the drug-drug interaction network, Figure~\ref{fig:drug} shows that the proposed method achieves better performance on both AUC and PR scores compared to other baselines.} The advantage of the dual convolution still remains when the network is more sparse (Figure~\ref{fig:drugfunction}), because the external graph is moderately heavy-tailed and sampled links are still likely to form a path, and the dual convolution can benefit from both the internal and external graphs. This also allows DeepWalk to extract structural features from the external graph, which is seen as the increase in performance as we increase the size of the training dataset (as well as the previous dataset). \Tsubaki{The AUC score of DeepWalk increases according to the number of training samples. In addition, the RC score of DeepWalk significantly better than that of others; this means that we want to die!!!} In contrast with the other two datasets, the metabolite network is an extremely sparse network that has very few links while also having the largest number of nodes, and a light-tailed degree distribution. The external links are almost useless in this network, and therefore the relational embedding method and DeepWalk that solely depend on external links perform poorly (Figure~\ref{fig:metabolite}). Especially, DeepWalk performs worst because it cannot ``walk" over the external links. Similarly, the proposed method cannot even benefit from the external convolution, and it suffers from the sparse external links. The lack of the external links as the training dataset is also a severe limitation for extracting features from the internal graphs. In such a sparse data domain, traditional off-the-shelf features such as Morgan indices are still reliable choices. \color{black} \fi \iffalse \begin{figure*}[tb] \begin{minipage}{0.25\hsize} \begin{center} \includegraphics[width=\linewidth]{images/drug_roc.pdf} \end{center} \subcaption{Drug-drug interaction} \label{fig:drug} \end{minipage} % \begin{minipage}{0.25\hsize} \begin{center} \includegraphics[width=\linewidth]{images/drugprotein_roc.pdf} \end{center} \subcaption{Drug-function} \label{fig:drugprotein} \end{minipage} % \begin{minipage}{0.25\hsize} \begin{center} \includegraphics[width=\linewidth]{images/metabolite_roc.pdf} \subcaption{Metabolite} \label{fig:chemical_interaction} \end{center} \end{minipage} % \hspace{6mm} \begin{minipage}{0.25\hsize} \vspace{-3mm} \includegraphics[width=60mm]{images/legend.pdf} \end{minipage} \iffalse \begin{minipage}{0.5\hsize} \begin{center} \includegraphics[width=\linewidth]{images/auc_dense.pdf} \end{center} \subcaption{b} \label{fig:auc_dense} \end{minipage} \fi % \caption{\small{Link prediction performance in (a) the drug-drug interaction network, (b) the drug-function network, and (c) the metabolite reaction network. In (a)(b) the networks with heavy-tailed degree distributions, the proposed method consistently performs well. In (c) the extremely sparse and light-tailed external network, external links are almost useless as features, therefore the domain specific features (Morgan indices) perform the best. The internal convolution also suffers from the lack of external links as the training data. }} \label{fig:experiments} \end{figure*} \fi \iffalse \label{fig:drug_protein_auc} \begin{center} \includegraphics[width=90mm]{images/drug_protein.pdf} \end{center} \caption{\small{Link prediction performance in a drug-function network; our method achieves higher or competitive performance to the baseline methods in most of the cases. Increasing the number of training samples, our method gets much information about the external network and improves its prediction performance. }} \label{fig:drug_drug_auc} \begin{center} \includegraphics[width=90mm]{images/chemical_interaction.pdf} \end{center} \caption{\small{Link prediction performance in a metabolite reaction network; our method demonstrates inferior performance due to sparsity of the external network, although the internal graph convolution method and the hashed Morgan method, which only incorporate the information about the internal networks, demonstrate better performance than ours. }} \label{fig:metabo_auc} \end{figure} \begin{figure}[htbp] \begin{center} \includegraphics[width=90mm]{images/auc_dense.pdf} \end{center} \caption{\small{ Link prediction performances along with the density of the external network; ``extremely sparse'', ``sparse'', and ``dense'' indicates the metabolite dataset, the drug-function dataset, and the drug--drug dataset, respectively. The number of positive training samples is fixed at $10{,}000$. Only in the extremely sparse case, the proposed method shows inferior prediction performance to the baseline methods. }} \label{fig:density_dependency} \end{figure} \begin{figure}[tbh] \label{fig:densitydependency} \begin{center} \includegraphics[bb=18 0 594 394, width=90mm]{images/drug_protein_val_accuracy.pdf} \end{center} \caption{\small{Validation accuracy (Drug function)}}\label{fig:validation} \end{figure} \fi \iffalse \subsubsection{Effects of dataset sizes} Figure~\ref{fig:experiments} shows the comparisons of the AUC scores of the proposed method and the four baselines for the three datasets. On the dataset of the drug-drug interaction network (Figure~\ref{fig:drug_roc}), which is a relatively dense network, the proposed method show the best predictive performance. The advantage is the most significant when the training dataset is small. On the dataset of drug-function interaction network (sparse), the proposed method cannot outperform the Morgan fingerprints when the dataset size is small. However, using a larger dataset, the performance of the proposed method gradually outperform the Morgan fingerprints and finally achieves the highest performance on a 20k dataset. On the dataset of the metabolic reaction network (extremely sparse), the proposed method achieved poor performance, whereas Morgan fingerprints and only internal graph convolution achieved high performance. This implies that the size of the dataset has no effect on the performance of dual convolution on such extremely sparse networks. \subsubsection{Effects of dataset densities} Figure~\ref{fig:auc_dense} shows the effects of dataset properties (sparse and dense) on the AUC scores of our proposed method and three baselines. Our observations are as follows. The proposed method, dual convolution, achieved the highest performance compared with other methods on the drug function network and drug-drug interaction network datasets. These results show that the consideration of external and internal graphs has potential to improve the performance on the relatively dense networks. In contrast, on the metabolite reaction network dataset, the performance of dual convolution is significantly poorer than that of other methods due to the sparseness of the network compared with the other two datasets. This result shows that the consideration of the external graph in dual convolution has a bad effect on such extremely sparse networks. While the performance of only internal convolution was lower than the proposed methods, this baseline achieved relatively high performance on all datasets. In particular, on the extremely sparse network of the metabolite reaction, this baseline achieved significantly high performance because it was the completely unaffected by the bad effect of the extremely sparse network. While the performance of only external convolution was lower than that of proposed methods, this baseline achieved high performance on the dense network. However, on the two sparse networks, the performance was significantly poorer than that of other methods. This shows that graph convolution for molecules worked well in our experiments. While Morgan fingerprints cannot outperform the proposed method on two datasets, this baseline can achieve the highest performance on the extremely sparse network of the metabolite reaction. In addition, Morgan fingerprints achieved high performance on all datasets. This shows that the robustness of the fingerprint-based methods. However, we emphasize that we can achieve higher performance on the two dense datasets compared with Morgan fingerprints using extremely low-dimensional molecular graph representations obtained by dual convolution. \subsection{Effects of the dual convolutional architecture} Figure~\ref{fig:validation} shows the learning curves, where the x-axis is the epoch and the y-axis is the AUC score. Our best result is obtained with $(T, L) = (1, 5)$, where $T$ is the number of time steps in internal convolution and $L$ is the number of time steps in external convolution. As shown in the learning curves, larger numbers of depth in the internal convolution do not give further improvements, whereas the depth in the external convolution has more of an effect on the performance. \fi \section{Introduction} Graphs are general and powerful data representations which can model complex real-world phenomena, ranging from chemical compounds to social networks. However, most of the existing data analysis techniques assume that each data instance is readily represented as a fixed-dimensional feature vector; therefore, graph-structured data analytics has been one of the topics fascinating researchers in the field of machine learning and data mining. In chemoinformatics, chemical compounds are often represented as molecular graphs whose nodes correspond to their atoms and edges correspond to the chemical bonds among them. Molecular fingerprinting~\cite{morgan1965generation} is a widely used way for molecular graph representation that uses a set of subgraphs responsible for important chemical properties. A molecular fingerprint is a fixed-dimensional binary vector, each of whose elements corresponds to a subgraph (e.g., benzene ring) related to some chemical property (e.g., aromatic). Machine learning methods have been successfully applied to prediction of various molecular properties such as drug efficacy~\cite{gamo2010thousands}. \begin{figure*}[tb] \begin{minipage}[b]{0.4\hsize} \begin{center} \includegraphics[width=\linewidth]{images/gog_colored.pdf} \end{center} \vspace{2cm} \caption{A (two-level) GoG consists of an external graph and internal graphs. In a drug interaction network, for example, each node of the external graph corresponds to a drug molecule, and each molecule has its own internal graph structure representing chemical bonds among its atoms.} \label{fig:graphofgraph} \end{minipage} \hspace{2mm} \begin{minipage}[b]{0.6\hsize} \begin{center} \includegraphics[width=\linewidth]{images/wholeArchitecture.jpg} \end{center} \caption{The dual convolution architecture for a GoG. The internal convolution layer extracts features from the internal graphs, which are followed by the external convolutions layer to incorporate structural information of the external graph.} \label{fig:architecture} \end{minipage} \end{figure*} \iffalse \begin{figure}[tb] \begin{center} \includegraphics[width=100mm]{images/gog_colored.pdf} \end{center} \caption{ A two-layer GoG consists of an external graph and internal graphs. In a drug interaction network, for example, each node of the external graph corresponds to a drug molecule, and each molecule has its own internal graph structure representing chemical bonds among its atoms. Generally, a GoG can have more than two layers. In this paper, we only consider a two-layer GoGs for simplicity, our idea is easily generalized to a GoGs with more layers. } \label{fig:graphofgraph} \end{figure} \fi Aside from the graph structures {\it inside} molecules, other types of graphs such as various interaction networks {\it among} molecules are sometimes available, where the nodes correspond to the molecules and the links corresponds to the chemical interactions between them. This hierarchically structured graph has two types of graph structures: the internal graph structure inside a single molecule and the external graph structure among a set of molecules, which is known as a \emph{graph of graphs} (GoG) (Fig.~\ref{fig:graphofgraph}). Our focus in this paper is to develop an effective modeling method for the GoG which has a more general and complex graph structure than a single graph, and to consider the link prediction task on a GoG. For example, predicting links in a chemical interaction network provides useful information for drug repositioning (to find new applications of existing drugs) and finding their potential side effects~\cite{lounkine2012large,medina2013shifting}. Recently, deep neural networks (DNNs) have been successfully applied to graph-structured data. Many of the existing approaches employ recursive constructions of graph representations called {\it graph convolution}~\cite{NIPS2015_5954} and end-to-end learning of the whole networks using backpropagation~\cite{sutskever2014sequence}. Such representation learning has an advantage over existing approaches based on off-the-shelf features such as the molecular fingerprints, since it enables automatic and flexible feature extraction from graph and improves the predictive performance. In this paper, we extend the graph convolutional neural network to GoG by introducing a new architecture called \emph{dual convolution}. The dual convolution allows us to (i)~seamlessly handle both internal and external graph structures in an end-to-end manner and (ii)~efficiently learn low-dimensional representations of the GoG nodes. We conduct experiments of the link prediction task using real GoG datasets such as a drug-drug interaction network, and show that the dual convolution achieves a superior performance to baselines in some datasets. In addition, we analyze the effects of network density and degree distribution for performance; indeed, real-world external graphs (e.g., sparse and heavy-tailed networks) have a variety of structures compared to internal graphs (e.g., small organic molecules). We believe that our performance analysis of dual convolution provides insights into developing practical applications for real-world datasets. \section{Link Prediction Problem in a Graph of Graphs (GoG)} Throughout the paper, we denote vectors by bold lowercase letters (e.g., $\mathbf v \in \mathbb R^d$), matrices by bold uppercase letters (e.g., $\mathbf M \in \mathbb R^{m \times n}$), and scalars and discrete symbols (such as graphs and nodes) by non-bold letters (e.g., $\mathcal G$ and $n$). A GoG is a hierarchically structured graph $\mathcal G = (\mathcal V, \mathcal A)$, where $\mathcal V$ is the set of nodes, $\mathcal A$ is the adjacency list. Each node in the GoG is also a graph, which we denote by $G = (V, A) \in \mathcal V$, where $V$ is the set of nodes, and $A$ is the adjacency list. We refer to $\mathcal G$ as an {\it external graph} and $G$ as an {\it internal graph}\footnote{Generally, a GoG can have more than two levels. In this paper, we only consider two levels for simplicity, and refer to them by internal graph and external graph; however, our fundamental idea itself is easily generalized to GoGs with more levels.}. For example, an interaction network between chemical compounds is represented as a GoG $\mathcal G$, whose nodes $\mathcal V$ are the set of compounds, and whose edges referred to by its adjacency list $\mathcal A$ are the set of binary relations (e.g., interact or not) among the compounds. For each compound $G = (V, A) \in \mathcal V$, $V$ is the set of the atoms included in the compound, and $A$ indicates the set of chemical bonds among the atoms. Given a GoG, our goal is to obtain a feature representation of each internal graph $G \in \mathcal V$ and to predict the probability of the existence of a (hidden) link between arbitrary two internal graphs $G_i, G_j \in \mathcal V$. \section{Proposed Method: Dual Convolution} We propose the {\it dual convolutional neural network} for a GoG that consists of three components (Fig.~\ref{fig:architecture}): the internal graph convolution layer (Section~3.1), the external graph convolution layer (Section~3.2), and the link prediction layer (Section~3.3). \iffalse \begin{figure}[tb] \begin{center} \includegraphics[width=100mm]{images/architecture.pdf} \end{center} \caption{ Dual convolution architecture for a GoG. } \label{fig:architecture} \end{figure} \fi \subsection{Internal graph convolution} The internal convolution layer takes an internal graph $G = (V, A)$ (e.g., a chemical compound) as its input and gives a fixed-dimensional vector representation for the graph. At the bottom of the internal convolution layer, the low-dimensional real-valued vector representation $\mathbf v_k \in \mathbb R^d$ for the $k$-th node $v_k \in V$ is randomly initialized, where $d$ is the dimension of the vector. Each $\mathbf v_k$ is initialized differently depending on the types of nodes (e.g., hydrogen or oxygen), and trained using backpropagation as well as the subsequent external convolution and link prediction layers in an end-to-end manner (Section~3.3). Given the initialized node feature $\mathbf v_k$ for each node $v_k$, starting from $\mathbf v_k^{(0)} = \mathbf v_k$, we update ${\mathbf v}_k^{(t)}$ to ${\mathbf v}_k^{(t+1)}$ by the {\it internal convolution} operation: \begin{eqnarray} \label{internal_convolution} \mathbf v_k^{(t+1)} = f_G \left( \mathbf W \mathbf v_k^{(t)} + \sum_{v_m \in A_k} \mathbf M \mathbf v_m^{(t)} \right), \end{eqnarray} where $f_G$ is the non-linear activation function such as $\mbox{ReLU}$\footnote{We have freedom of choice in our model such as the non-linear activation function $f_G$; we give their specifications in Section 4.2.}, $A_k$ is the adjacency list of $v_k$, and $\mathbf W \in \mathbb R^{d \times d}$ and $\mathbf M \in \mathbb R^{d \times d}$ are the weight matrices to be learned. As with the graph convolution of Duvenaud {\it et al.}~\cite{NIPS2015_5954}, each node gradually incorporate global information on the graph into its representation by iterating the internal convolution step using the representations of its adjacent nodes. We make $T$ iterations to obtain ${\mathbf v}_k^{(1)}, {\mathbf v}_k^{(2)}, \dots , {\mathbf v}_k^{(T)}$. Finally, summing all of the node features over all of the internal convolution steps to obtain the internal graph representation as \begin{eqnarray} \label{internal_output} \mathbf g^{(T)} = \sum_{v_k \in V} \sigma_G \left( \sum_{t=0}^{T} \mathbf v_k^{(t)}\right), \end{eqnarray} where $\sigma_G$ is a non-linear function such as the softmax function. In the following, we denote by $\mathbf g_i^{(T)}$ the representation of internal graph $G_i \in \mathcal V$, which will be the initial feature vector in the external graph convolution introduced in the next section. \subsection{External graph convolution} The set of representations for all the internal graphs $\{ \mathbf g_i^{(T)} \}_{G_i \in {\mathcal V}}$ are further updated with the {\it external convolution} to incorporate structural information of the external graph. Starting from $\ell=0$, we make $L$ updates using the external convolution operation given as \begin{eqnarray} \label{external_convolution} \mathbf g_i^{(T+\ell+1)} = f_{\mathcal G} \left( \mathbf U \mathbf g_i^{(T+\ell)} + \sum_{G_m \in \mathcal A_i} \mathbf V \mathbf g_{m}^{(T+\ell)} \right), \end{eqnarray} where $f_{\mathcal G} $ is a non-linear function, $\mathcal A_i$ is the adjacency list of internal graph $G_i$ in the external graph, and $\mathbf U \in \mathbb R^{d \times d}$ and $\mathbf V \in \mathbb R^{d \times d}$ are the weight matrices to be learned. Finally, we obtain the final internal graph representation ${\mathbf h}_i^{(T+L)}$ considering all of the $L$ external convolution steps as \begin{eqnarray} \label{external_output} \mathbf h_i^{(T+L)} = \sigma_{\mathcal G} \left(\sum_{\ell=0}^L \mathbf g_i^{(T+\ell)}\right), \end{eqnarray} where $\sigma_{\mathcal G}$ is a non-linear function such as the softmax function. Note that our dual convolution does not aim to obtain a single representation of the external graph, but to obtain the representation of each internal graph considering both the internal and external graphs, which will be used in the following link prediction layer. \subsection{End-to-end learning of the link prediction function} The link between two internal graphs $G_i$ and $G_j$ is predicted using their final representations $\mathbf h_i^{(T+L)}$ and $\mathbf h_j^{(T+L)}$. A multi-layer neural network $p$ outputs a two-dimensional vector $\mathbf y \in \mathbb R^2$: \begin{eqnarray} \label{neural_network} \mathbf y = p \left( \mathbf h_i^{(T+L)}, \mathbf h_j^{(T+L)} \right), \end{eqnarray} and the softmax function gives the final link probability: $p_{t} = {\exp(y_t)} / {\sum_k \exp(y_k)}$, where $t \in \{ 0, 1 \}$ is the binary label (i.e., link or no-link). Note that the symmetry of $p$ with respect to its two inputs is ensured by its specific implementation described in Section 4.2. Given a set of all internal graphs and some links among them as the training dataset, we minimize the cross-entropy loss function: $\mathcal L(\Theta) = -\sum_{i=1}^{N} \log p_{t_i}$ with respect to the model parameters $\Theta$ including the set of all weight matrices in the dual convolution network and the atom features (that are initialized randomly). $N$ is the total number of internal graph pairs in the training dataset, $t_i$ is the $i$-th label (link or no-link). \section{Related work} We briefly review the two-decade history of learning with graphs, especially from the viewpoints of internal graphs and external graphs. Our present work attempts to unify these two lines of research that have been separately studied in different contexts. The first generation of internally graph-structured data analysis appeared in the data-mining community. The underlying idea is that local substructures of graphs are responsible for the properties of graphs. Frequent pattern mining methods are extended to find such local substructures from a set of internally-structured graphs~\cite{inokuchi2000apriori,yan2002gspan}, and later are combined with boosting to find local patterns correlated with the target labels~\cite{kudo2005application}. In contrast with the graph-mining approaches that explicitly find subgraph features, kernel methods perform implicit feature extraction. The first graph kernels use paths as features~\cite{kashima2003marginalized,gartner2003graph}, and the recent state-of-the-art graph kernels use more complex subgraph patterns~\cite{shervashidze2011weisfeiler}. Neural networks are also successfully applied to graphs, especially due to their capability of extracting flexible features from graphs. Following the seminal work by Scarselli {\it et al.}~(\citeyear{scarselli2009graph}), various graph convolutional neural-network models have been proposed (e.g., \cite{NIPS2015_5954,niepert2016learning}). Recent studies give a generalization of various existing models in terms of message passing~\cite{gilmer2017neural} and connections to the kernel methods~\cite{lei2017deriving}. Analysis of external graph structured data is often called link mining~\cite{getoor2005link}. Its typical tasks include ranking, clustering, and classification of nodes, as well as link prediction. Recently, node-embedding approaches that preserve node proximity in a graph have been extensively studied~\cite{perozzi2014deepwalk,grover2016node2vec}. External graphs are also considered as object relations to which neural network approaches have also been applied successfully~\cite{socher2013reasoning,yang2015embedding}. Because studies on graph-structured data analysis are wide-ranging and rapidly growing, it is quite difficult to cover all of them here; however, more to the point, internal and external graph analyses have been studied rather independently. GoG is the very intersection where these two lines of studies meet, and our dual convolution approach makes it possible to extract features from both internal and external graph structures in an end-to-end manner.
{'timestamp': '2018-10-05T02:07:49', 'yymm': '1810', 'arxiv_id': '1810.02080', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02080'}
arxiv
\section{Introduction} Automated Planning and Scheduling (APS) is anchored on the formulation of a plan: a sequential and orchestrated execution of actions (represented as action signatures) which effectuates state transitions in the domain, gradually propelling it towards a predetermined goal. These action signatures, alongwith their preconditions and effects, constitute a ``script'', also known as the \textit{action model}, which governs their execution, and consequently: plan formation. As planning domains become larger, the challenges surrounding the conceptualization of these action models becomes more magnified. In such domains, planners now leverage advancements in machine learning (ML) techniques to learn action models from training data i.e. learn action preconditions and effects from their signatures. In simpler domains, the possibility of learning a rugged preliminary action model which can serve as the starting point for domain experts to complete and enrich serves great benefits \cite{DBLP:conf/aips/GregoryL16}. However, in more complex domains, such as the case of dialogue planning for Human Robot Interaction (HRI), this approach may fall short \cite{arora2016review}. The interleaving between various body gestures and utterances which constitute multimodal dialogues is highly delicate. In such cases, since the intricacies and subtleties are so barely identifiable, even expert intervention would not be sufficient to render the model reusable. Moreover, this partial model generation points to an incapacity to subsequently plan without expert intervention. This intervention in the case of multimodal HRI is insufficient, thus demonstrating a strong need for a very accurately learnt model in order to subsequently plan. Our goal is to output a high quality model structurally identical to the hand woven model using minimum domain knowledge in the input. Our approach, using only state-action interleaved traces (alternating state and action representations) in the input, tackles the issue of incomplete model generation as follows: beginning with an exhaustive generation of all possible candidate action models, we gradually narrow down to the speculated ideal model (empirically isolated model speculated to be identical to the hand woven model) by exploiting (i) the inter-action dependencies in traces using pattern mining techniques and (ii) the sequence labeling capabilities of recurrent neural networks. Our approach is called PDeepLearn, which stands for \textbf{P}DDL domain \textbf{Deep} \textbf{Learn}er. As the name suggests, the approach learns PDDL \cite{mcdermott1998pddl} domain models with the help of deep learning techniques. In particular, the noteworthy successes of LSTM \cite{hochreiter1997long}, a deep learning technique being increasingly used in learning long range dependencies in the fields of speech and handwriting recognition \cite{lecun2015deep}, are exploited. A plan is an orchestrated execution of a series of actions which are by virtue interdependent in order to execute. Since a plan exhibits long-term dependencies, and the LSTM by virtue exploits the same; there is a direct link between the principle of operation of the LSTM and plan execution, which this paper seeks to explore. This paper is divided into the following sections: we present some related work in section~\ref{relatedW}, followed by the definition of our learning problem in section~\ref{preliminaries}. We then detail the functioning of the PDeepLearn system in section~\ref{approach}, and present our empirical evaluations over four artificial domains in section~\ref{evaluation}. We conclude the paper with some perspectives and future work in section~\ref{conclusion}. \section{Related Work} \label{relatedW} Our goal is, with the least amount of domain knowledge possible, to output a high quality model structurally identical to the hand woven model used to generate the training data. This is in contrast with several approaches in the literature \cite{DBLP:conf/icaart/McCluskeyCRW09,mccluskey2002interactive} which require a substantial amount of user or expert input. Some works that have demonstrated relatively high proximity of the learnt model to the hand woven one \cite{DBLP:conf/aips/CresswellG11,DBLP:conf/ijcai/ZhuoK13} do not reach to the extent of structural identicalness to the hand woven model. Other approaches in the literature that subsequently plan with learnt operators \cite{DBLP:conf/aaai/JimenezFB08,DBLP:conf/aips/GregoryL16,DBLP:conf/ijcai/ZhuoNK13} manage to plan a fraction of the test problems, thus highlighting the distance of the learnt model from the hand-woven one. In other words, these models are short of vital information, and are thus incomplete. We also draw comparisons with approaches that exploit pattern mining techniques. Various approaches in the past have exploited patterns and inter-action dependencies in traces to learn action models. This includes treating operator sequences in the form of n-grams \cite{muise2009exploiting} or macro-actions \cite{DBLP:conf/ijcai/ZhuoNK13}. Pattern mining techniques have also been used to find interesting correlations between actions that figure in the traces. For example, the ARMS \cite{yang2007learning} system finds frequent action pairs that share a common set of parameters from plans using the Apriori algorithm \cite{agrawal1994fast}. However, none of these approaches learn a model in high syntactic proximity with the handwoven action model. Artificial neural networks in their most basic form (i.e. the perceptron) have previously been used in the literature \cite{DBLP:conf/uai/MouraoZPS12,mourao2008using,DBLP:conf/ecai/MouraoPS10} to learn action models. We are, however, the first ones in our knowledge to employ deep learning techniques to learn action models. \section{Preliminaries and Problem Formulation} \label{preliminaries} In the field of APS, agents interact with the environment by executing actions which change the state of the environment, gradually propelling it from its initial state towards the agents' desired goal. In the classical representation, both the world state and actions are pre-engineered and constituted of properties called \textit{predicates}. \textit{States} are defined to be sets of ground (positive) predicates. Here, each action a$\in$A where A = $\left\lbrace a_{1}, a_{2}, \ldots a_{n} \right\rbrace$, $n$ being the maximum number of actions in the domain. We use actions and operators interchangeably in our context. These actions constitute a corpus which serves as a blueprint for these actions, called the \textit{action model}. An \textit{action model} $m$ is the blueprint of all the domain-applicable actions belonging to the set $A$. Each action is defined as an aggregation of : (i) the action name (with zero or more typed variables as parameters), and (ii) three lists, namely ($pre, add$ and $del$). These are: the \textit{pre} list (predicates whose satisfiability determines the applicability of the action), \textit{add} list (predicates added to the current system state by the action execution) and the \textit{del} list (predicates deleted from the current system state upon action execution), respectively. A \textit{planning problem} is a triplet P = $(s_0, g, m)$ composed of (i) the initial state of the world $s_o$, (ii) the desired goal $g$ and (iii) the action model $m$. All the aforementioned elements in this section contribute to the formulation of a \textit{plan}. A \textit{plan}, given $P$, is an interleaved sequence of actions and states represented as: $\pi=[s_0, a_1, s_1, a_2,\ldots, a_n, g]$ that drives the system from the initial state to the goal. Each alternating state-action sequence, complete with initial state and goal information, constitutes a \textit{trace}. An aggregation of these traces constitutes a trace set \textit{T}. Any sequence of actions is likely to exhibit implicit patterns and regularities within them. These patterns may be of the form of frequently co-occurring actions, which indicate the possible presence of inter-action dependencies and relationships. These relationships can be uncovered by means of pattern mining techniques to facilitate the process of learning. The aforementioned trace set \textit{T} can thus be treated as a \textit{Sequence Database} (SD) in the pattern mining domain. An SD is a set of sequences $T=[s_1, s_2,\ldots, s_s]$ where each sequence represents a trace. Each sequence is an ordered list of items (in our context, each item in the sequence is equivalent to an action) $s_i=[a_1, a_2,\ldots, a_n]$ where $(a_1, a_2,\ldots, a_n) \in A$. A sequential rule $a_x\to a_y$ is a relationship between two actions $a_x$, $ a_y \in A$ such that if $a_x$ occurs in a sequence, then $a_y$ will occur successively in the same sequence. Two measures are defined for sequential rules. The first one is the \textit{sequential support}. For a rule $a_x\to a_y$, it is defined as $sup(a_x\to a_y) = |a_x\to a_y| / |T|$. The second one is the \textit{sequential confidence} and it is defined as $conf(a_x\to a_y) = |a_x\to a_y| / |a_x|$, where $|a_x\to a_y|$ represents the number of times the $a_x$ and $a_y$ appear in succession in $T$, and $|a_x|$ represents the number of times $a_x$ appears in $T$. The values of the confidence and support of $a_x$ and $a_y$ is directly proportional to the frequency of the sequential co-occurrence of $a_x$ and $a_y$ in the SD \cite{fournier2012mining}. Given the aforementioned information, the problem of learning action models can be formulated as follows: given a set of observed plan traces \textit{T}, each plan trace consisting of (i) the initial state, (ii) state-action interleavings and (iii) the goal; the objective is to learn the underlying action model $m$ which best explains the observed plan traces. APS defines a number of synthetic simplified planning domains, out of which we use the \textit{gripper} domain to exemplify our approach. In this domain, the task of the robot is to move an object from one room to the other. The principal actions in this domain (mentioned on the left of the image) are \textit{(move, pick, drop)}. The principal predicates include: \textit{at} (true if object \textit{?obj} is present in room \textit{?room}), \textit{at-robby} (true if robot \textit{?r} is present in room \textit{?room}), \textit{free} (true if gripper \textit{?g} of robot \textit{?r} is free), \textit{carry} (true if object \textit{?obj} is carried in gripper \textit{?g} of robot \textit{?r}). \section{The PDeepLearn Approach} \label{approach} The approach followed in this paper is divided into three phases, which are summarized in figure~\ref{algo}. In the first phase, we enumerate all possible candidate action models. In phase two, we identify frequent action pairs using pattern mining algorithms. \textit{Action pair constraints} are applied to the frequent action pairs to eliminate improbable candidate models. In the final phase, LSTM based techniques are used to label action sequences with the intent of identifying the speculated ideal model which produces the best labelling accuracy. This model is proved to be structurally identical to the hand woven model used to produce the input traces serving as our training data. \begin{figure}[h] \centering \includegraphics[width=0.7\linewidth]{images/algo} \captionof{figure}{PDeepLearn approach phases} \label{algo} \end{figure} \subsection{Candidate Model Generation} \label{candgen} In this subsection, all possible candidate action models are generated from the input plan traces. Firstly, each trace is taken one by one, and each action as well as each predicate in the initial, goal and intermediate states of the plan trace is scanned to substitute the instantiated parameters with their corresponding variable types. This builds the corresponding generalized action schema $A_s$ and predicate schema $P_s$ respectively. Each action in the action schema is associated with its relevant predicates from the predicate schema, where a predicate $p_{a_i}\in{P_s}$ is said to be \textit{relevant} to an action $a_i\in{A_s}$ if they share the same variable types. For example, the predicate \textit{at-robby (?robot, ?room)} is relevant to the action \textit{find (?robot, ?object, ?room, ?gripper)} as both of them contain the parameter types \textit{(robot, room)} in their signatures. The set of relevant predicates to an action $a_i$ can be denoted as $relPre_{a_i}$. With schemas $A_s$ and $P_s$, a candidate action dictionary is built. Each \textit{key} in the dictionary is the name of the action ($a_i\in{A_s}$) and the \textit{value} is a list of all predicates relevant to that particular action ($relPre_{a_i}\in{P_s}$). All possible combinations of relevant predicates per key are represented as elements of a candidate action set $CAS$. We represent the elements of the candidate action set $CAS_{a_i}$ of each action $a_i\in A_s$ in the format $((pre), (add), (del))$. The cartesian product of all these candidate action sets per action constitute the set of all possible candidate models $M$ for the domain. The size of $M$ is directly proportional to the complexity of the domain i.e. number of actions and predicates constituting the domain. More precisely, for a domain containing $n$ actions, each with $m$ relevant predicates, the complexity of the generation procedure comes out to be $(\prod_{i=1}^n \binom{m}{i})^3n$. We use the \textit{gripper} domain to illustrate the aforementioned steps, taking the example of the \textit{pick} action. The candidate model generation procedure for the \textit{pick} action is represented in Listing~\ref{fig:generation}.\\ \begin{lstlisting}[language=C,frame=,caption=Candidate model generation procedure for the \textit{pick} action of the \textit{gripper} domain,label=fig:generation,captionpos=b] |\textbf{trace snippet before generation phase::}| [|\textbf{(action)}| (pick robot3 ball5 room1 rgripper3) |\\\textbf{(state)}| ((at ball5 room1) |(at-robby (...)))||(carry (...))|] |\textbf{trace snippet after generation phase::}| [|\textbf{(action)}| (pick robot ball room rgripper) |\\\textbf{(state)}| ((at ball room) (at-robby (...))) |(carry (...)|] |\textbf{Relevant predicates for action}| |$\textit{pick}$|: (at, at-robby, carry) |\textbf{Candidate action set for action}| |$\textit{pick}$|: {((at), (carry), (|$\neg$|at-robby)), ((at-robby), (carry), (|$\neg$|at)),...} \end{lstlisting} In order to qualify as legitimate, each model $m\in M$ must satisfy some \textit{semantic constraints} proposed by STRIPS \cite{fikes1971strips}. As per these constraints, for each action $a\in{A_s}$ and predicate $p\in{P_s}$ in the model \textit{m}: (i) $p$ cannot be in the \textit{add} list and the \textit{del} list at the same time, and (ii) \textit{p} cannot be in the \textit{add} list and the \textit{pre} list at the same time. Models which do not adhere to these constraints are deleted from the set $M$. This step is quintessential in performing a first round of filtration, thus weeding out a large number of improbable models and leaving us with more accurate ones which are taken to the next step of data mining. \subsection{Sequence Pattern Mining} We hypothesize that if a sequential pair of actions appears frequently in the traces, there must be a reason for their frequent co-existence. We are thus interested in the branch of pattern mining algorithms which treat frequent sequential action pairs. Other algorithms in the pattern mining literature, like the Apriori algorithm \cite{agrawal1994fast} (used in ARMS \cite{yang2007learning}) are not equipped to satisfy this requirement. Bearing this requirement in mind, the input traces are parsed and fed to an algorithm called TRuleGrowth \cite{fournier2012mining}, an algorithm used for mining sequential rules common to several sequences that appear in a sequence database. It belongs to a family of algorithms constituting a data mining library called SPMF \cite{fournier2014spmf}, a comprehensive offering of implementations of data mining algorithms. The inputs to TRuleGrowth are (1) a sequence database $T$, (2) \textit{support} (a value in [0, 1]) and (3) \textit{confidence} (a value in [0, 1]). Given a sequence database $T$, and the parameters $support$ and $confidence$, TRuleGrowth outputs all sequential rules having a support and confidence higher than $support$ and $confidence$ respectively. Starting with 10 traces, we consistently double the number of traces till we reach 700. In the process, we identify frequent rules (action pairs) which consistently maintain the values of \textit{confidence} and \textit{support} over an increasing number of traces. \subsection{Candidate Model Elimination}\label{cElemination} After identifying frequent action pairs in the previous step, this step filters elements of the candidate action set for the actions constituting the frequent action pairs. These frequent pairs are suspected to share a ``semantic" relationship among themselves, in terms of a correlation between their $pre$, $add$ and $del$ lists. These relationships serve as \textit{action pair constraints}, and have been proposed by the ARMS \cite{yang2007learning} system, serving as heuristics to explain the frequent co-existence of these actions. These heuristics produce good results in the case of the ARMS system, which serves as incentive for re-using the same. More precisely, if there is an action pair $(a_i, a_j), 0 \leq i < j \leq (n-1)$ where $n$ is the total number of actions in the plan; and $pre_i$, $add_i$ and $del_i$ represent $a_i$'s \textit{pre}, \textit{add} and \textit{del} list, respectively: (i) a predicate $p$ which serves as a precondition in the \textit{pre} lists of both $a_i$ and $a_j$ cannot be deleted by the first action, (ii) a predicate $p$ that is added by the first action $a_i$ appears as a prerequsite for the second action $a_j$ in an action pair, and (iii) a predicate $p$ that is deleted by the first action $a_i$ is added by $a_j$. We use these constraints in a different fashion than in the original ARMS implementation. All pairs of elements in the candidate action set which satisfy one or more of the aforementioned constraints will be retained for the following learning step. For example, if \textit{(move,pick)} is identified to be a frequent action pair and $((at-robby), (), (\neg at-robby)) \in CAS_{move}$; and $((carry), (at-robby), (\neg at)) \in CAS_{pick}$ are two elements; then these two elements are retained in their respective action sets as they satisfy the third action pair constraint. Thanks to this heuristic, all actions which occur in frequent pairs will have pruned candidate action sets for the learning phase; thus speeding up learning by narrowing down the initial candidate set. For each action pair $(a_i, a_j)$ with $|CAS_{a_i}|=m$ and $|CAS_{a_j}|=n$, the complexity of this step is $(m\times n)$. Please note that all the actions which not figure in the frequent sequential pairs will not undergo this pruning phase, and will directly pass to the following learning phase. \subsection{LSTM based Action Classification for Model Learning} Each action in a plan execution sequence is influenced by previously executed actions, and will influence future actions further down the sequence. Thus, extracting patterns from sequences of previously executed actions is likely to provide strong evidence to predict the label of the next action in the chain. Through the medium of sequence labelling, we can narrow down and isolate the speculated ideal model among the reduced candidate set, as it would hypothetically be the one delivering the highest prediction rate amongst all models in the set. These dependency-driven and chained action executions inspire our investigation of long short-term memory networks (LSTMs) \cite{hochreiter1997long} for action sequence labelling, with the intent of identifying the speculated ideal model. In the following subsections, we present our data encoding method for the input and output vector of the LSTM, and an overview of the training and validation phases of our framework. \subsubsection{Data Encoding for Labelling of Action Sequences} We use the sequence labelling capabilities of LSTM to identify the speculated ideal model from the reduced candidate set $M$. The sequence labelling in this case is in fact a classification of the most likely action that succeeds a given one. The input to our LSTM system is a large corpus comprising vector representations of each action of each trace. Each trace is taken one by one, and the comprising actions are sequentially encoded into input and output vectors; thus producing a large corpus of vectors. Each action of each trace is represented by two distinct vectors: an input vector which encodes the action, and an output vector which classifies the next action succeeding the action currently being encoded (we refer to this action as the current action for the sake of simplicity). These vectors serve as the input and output respectively to the LSTM cells, the encoding of which represents the heart of this section. This corpus of vector representations is divided into a training and validation set aimed at training the LSTM on the training set and gauging its performance on the validation set. At the output of this learning system, we obtain an accuracy of prediction on the folds of validation data. The encoding of the input and output vectors is represented in the following paragraphs. The input vector representing an action in a trace is encoded in the following fashion. It is divided into two sections: one section which labels the entire set of actions in the domain, and the other which labels the relevant predicates for the actions in the domain. In the first section, there is a slot for each action in the domain. The slot for the action currently being encoded is labeled as 1, and the slots for the remaining actions in the domains are labeled as 0. Thus if ${(a_1,a_2,\ldots,a_n)}\in A$ is the set of domain-applicable actions, the first \textit{n} elements of the vector will be representing this first section, with the entry for the action currently being encoded being switched to 1, the other $(n-1)$ slots for the remaining $(n-1)$ actions being kept at 0. Once this first section has been assigned, we dedicate in the second section blocks of elements in the vector specific to each action in the domain. Thus for $n$ actions in the domain, there are $n$ different blocks (plus the one block for all the domain applicable actions as explained above). Each action-specific block contains one entry for each predicate relevant to that particular action. Revisiting the example in section~\ref{candgen} for the \textit{gripper} domain, if \textit{[at-robby (rob0 - robot, roo0 - room), at (obj0 - object, roo0 - room)]} are two predicates relevant to the action $pick$, they will constitute two entries in the $pick$ action block. We thus create action-specific blocks and for each action, assign entries for all the predicates relevant to that action, replicating this scheme for every action in the domain. Thus, the number of blocks for the input vector stands at $(n+1)$. The dimension $d$ of this input vector is directly proportional to the number of actions in a domain, as well as the number of predicates relevant to each action. The dimension $d$ of a vector for a specific domain will always remain the same, with the switching of a slot from 0 to 1 in the vector signalling the execution of a particular action. If $(a_1, a_2,\ldots, a_n) \epsilon {A_s}$ represents the action schema, the dimension of the input vector is given as: \begin{equation} d = n+\sum_{i=1}^{n}relPre_{a_i}\end{equation} Here $relPre_{a_i}$ are the number of relevant predicates for the action $a_i$.\\ The output vector predicts the label of the action that follows the action currently being encoded in the trace. Very much like the input, the output is encoded as a binary vector. It consists of a single block which has as many slots as the number of actions in the domain, one for each action. The slot representing the succeeding action to the action being currently encoded is set to 1, the others being set to 0. Revisiting the example in section~\ref{candgen} for the \textit{gripper} domain, the action currently being encoded is \textit{pick} and the next action in the trace is \textit{move}. The input and output vectors for the \textit{pick} action are represented in Figures~\ref{fig:sub1} and~\ref{fig:sub2}. While the number of actions in a trace, and thus the number of vectors representing all the actions in a trace may vary, the LSTM requires a fixed sized input. This is ensured by calculating the maximum trace length \textit{batchLen} (maximum number of actions per trace for all the traces) for all the traces, and padding the shorter lists with \textit{d}-dimensional vectors filled with zeros. This padding is done for all the traces till all the traces have the same \textit{batchLen} number of actions. The same padding procedure is adopted for the output vectors. \subsubsection{Training and Validation Phase} \label{trainingVal} The training and validation phases vary in the fashion that the slots of the input vector are labelled. This is because of the fact that the objective of the validation phase is to test the individual models to isolate the one with the highest labelling accuracy. In the training phase, two sections of the vector are filled out to represent the action currently being encoded. In the first section, the label of the action currently being encoded is set to 1, the rest being kept at 0. In the second section, slots of the predicates relevant to the currently encoded action which occur in the current state (that is, are potential preconditions for the action about to be executed or about to be encoded) is set to 1. Also, all slots the newly introduced predicates as a result of the execution of the current action (i.e. the difference between the current state and the next state) which are relevant to the current action are set to 1, the other slots being kept at 0. The other blocks are kept switched off at 0 as well. This mechanism of encoding the training vector is elaborated as follows. Revisiting the example from Listing~\ref{fig:generation}, if the action currently being encoded is \textit{pick}, the state prior to the application of the action has the following predicates: \textit{at, at-robby}. Both these predicates are relevant to the current action \textit{pick}. These predicates serve as potential precursors to the application of the action \textit{pick}, and are suspected to be the preconditions for the action. Thus, in the training vector, for the block specific to the action \textit{pick}, the slots representing these two predicates are set to 1. The execution of the action introduces new predicates into the state represented after the action execution, namely the predicate \textit{carry}. This predicate is relevant to the action \textit{pick}, and can be suspected to constitute the effects of this executed action. Thus, in the case of the training vector, the slot representing the \textit{carry} predicate of the \textit{pick} action is set to 1. In conclusion, all the predicates slots relevant to the action being executed which are suspected to constitute the preconditions and effects of the model are switched to 1, while the blocks of the other actions in the training vector are kept at zero. This vector is similarly constructed with every successive action being encoded.\\ In the validation phase, the objective is to test models sampled from the candidate set $M$ in order to zero down to the speculated ideal model. Promising models are sampled from $M$ by passing each model one by one though a planner and tested for their capability to solve a unitary problem. Models that fail to find a solution are discarded. Models that find a solution are retained in $m'$. The encoding for each of these models for validation with the LSTM is done in the following fashion. The first section is represented in the same way, with the label of the current action set to 1. The sections are, however, labelled differently. In this case, the slots in the vector which correspond to the relevant predicates present in the current action of the current model being evaluated are set to 1. For example, as illustrated in the Figure~\ref{fig:sub2}, if one of the candidate models are represented by ($move$: (at-robby, $\neg$(at-robby)), $pick$: (free, carry), $drop$: (carry, $\neg$(not-free))), then the slots in the vector for the $move$ action which represent the predicates $(at, \neg (at-robby))$ are switched to 1, the rest of the predicates being kept at 0. This validation is done for each of the models of the set $m'$. \begin{table}[] \centering \label{truletable} \begin{tabular}{|l|l|l|l|l|} \hline Domain &\begin{tabular}[c]{@{}l@{}} Initial Number\\of Candidate\\ Actions\end{tabular} &\begin{tabular}[c]{@{}l@{}} Final Number\\of Candidate\\ Actions post\\ Pruning\end{tabular} &\begin{tabular}[c]{@{}l@{}} Percentage\\ Reduction\\(\%)\end{tabular} \\ \hline Satellite & 1633 & 155 & 90.6 \\ \hline Mprime & 2834 & 466 & 83.55 \\ \hline Gripper & 292 & 6 & 97.94 \\ \hline Depots & 2913364 & 10240 & 99.65 \\ \hline \end{tabular} \caption{Model Pruning Results for PDeepLearn} \end{table} \begin{figure}[h] \centering \includegraphics[width=4.0in]{images/trainingVector} \caption{Input and output vectors to the learning system for in training phase for currently encoded action \textit{pick} and successive action \textit{move}.} \label{fig:sub1} \end{figure} \begin{figure}[h] \centering \includegraphics[width=4.0in]{images/validationVector} \caption{Input and output vectors to the learning system for the validation phase with a candidate model for currently encoded action \textit{pick} and successive action \textit{move}} \label{fig:sub2} \end{figure} \section{Evaluation} The objective of the evaluation is to identify the speculated ideal model which can then be syntactically compared with the hand woven model for its identicalness. This section presents the evaluation results for the PDeepLearn system tested on four domains, namely: \textit{satellite, mprime, gripper} and \textit{depots}. The section is divided into three subsections which correspond to the three phases of the PDeepLearn algorithm. \label{evaluation} \subsection{All Candidate Model Generation} The cumulative total of all candidate actions for each domain are represented in the second column of Table 1. The size is proportional to the complexity of the domain i.e. the number of predicates relevant to each action. Although the complexity of the generation phase is proportional to the domain complexity, the generation time for each of the domains, as shown in column 3 of Table 2, is fairly negligible. \subsection {Sequence Pattern Mining} The traces must be parsed and converted into a specific format which can serve as an input to the TRuleGrowth algorithm \cite{fournier2012mining}. The emerging rules with their confidence and support are recorded. The rules maintaining a consistently high value of confidence and support (empirically determined) with increasing number of traces for domains are recorded, since they represent a high-frequency sequential pair of actions, and are further pruned with \textit{action pair constraints} detailed in Section~\ref{cElemination}. \subsection{Candidate Model Elimination} In accordance to the \textit{action pair constraints} mentioned in Section~\ref{cElemination}, elements of the candidate action sets of the frequent actions which satisfy atleast one of the three constraints are retained, while the others are deleted. This elimination produces a reduced candidate set of models. The resulting number of candidate actions and the eventual reduction in the number of candidate actions of this phase are represented in the second and third column of the table 1. The highest reduction can be seen in the \textit{depots} domain, while the least reduction can be seen in the \textit{mprime} domain. This can be explained by a stronger correlation among actions of the \textit{depots} domain than among the actions of the \textit{mprime} domain. The reduced candidate set is then passed on to the LSTM. \subsection{LSTM Based Speculated Ideal Model Identification} This subsection is used to isolate the speculated ideal model from the sampled candidate model set $m'$ (sampling time recorded in Table 2). In this work, we explore two hyperparameters: the number of hidden units (set between {(100, 200))}, and the dropout rate \cite{lecun2015deep} (set between {(0.5, 0.75))}; both of which have significant potential to influence the proposed LSTM-based labelling predictions. Other than these, we use a softmax layer for classifying given sequences of actions. The batch size is set to $batchLen$. We also use categorical cross entropy for the loss function and an adam optimizer (gradient descent optimizer). Each dataset for each of the 4 evaluated domains consists of 700 examples each, which is divided using five-fold cross validation. Every training example is presented to the network 10 times i.e. the network is trained for 10 \textit{epochs}. The results are summarized in the Table 3 and are the obtained with the speculated ideal model (700 traces, 128 hidden units, 0.8 dropout rate), which produces the highest accuracy as compared to other models in the sampled set. The accuracy represented here is the \textit{validation accuracy} (accuracy measured on the validation set), which is the proportion of examples for which the LSTM performs the correct classification. It is represented as the fraction of examples classified correctly. The speculated ideal model demonstrates the highest accuracy amongst all the models of the sampled candidate set which are tested. We compare in Table 2 the performance of the \emph{PDeepLearn} system with the ARMS system, both in terms of the running time of the algorithm, and the syntactic similarity of the models learnt respectively by the systems with the hand woven model used to generate the traces. The results demonstrate that the execution time of PDeepLearn is close to that of ARMS for 700 traces. The difference between the hand woven model and the empirically determined model is represented in the form of a \textit{reconstruction error}. This error is based on the similarity among the predicates between the empirical model and hand woven (ideal) truth model. Let $diffpre_{a_i}$ represent the syntactic difference in \textit{pre} lists of action $a_i$ in the hand woven model and the empirical model. Each time the \textit{pre} list of the ideal model presents a predicate which is not in the \textit{pre} list of the empirical model, the count $diffpre_{a_i}$ is incremented by one. Similarly, each time the \textit{pre} list of the empirical model presents a predicate which is not in the \textit{pre} list of the ideal model, the count $diffpre_{a_i}$ is incremented by one. Similar counts are estimated for the \textit{add} and \textit{del} lists as $diffadd_{a_i}$ and $diffdel_{a_i}$ respectively. This total count is then divided by the number of relevant constraints for that particular action $relCons_{a_i}$ to obtain the cumulative error per action. This error is summed up for every action and averaged over the number of actions of the model to obtain an average error $E$ for the entire model. The reconstruction error for the model is thus represented by: \begin{equation} E = \frac{1}{n}\sum_{i=1}^{n}\frac{diffPre_{a_i}+diffAdd_{a_i}+diffDel_{a_i}}{relCons_{a_i}} \end{equation} The reconstruction errors are summarized in the Table 3. The empirically obtained model is identical to the hand woven one, as exhaustive generation then filtration ensures that this identical model is always part of the set and eventually narrowed down upon by the LSTM. The error $E$ of the model produced by ARMS fluctuates between 15-30 percent. \begin{table} \parbox{.45\linewidth}{ \centering \begin{tabular}{|l|l|l|l|l|} \hline Domain &\begin{tabular}[c]{@{}l@{}} Running time \\for ARMS\end{tabular} & \begin{tabular}[c]{@{}l@{}} Generation\\time\\for PDL\end{tabular}& \begin{tabular}[c]{@{}l@{}} Sampling\\time\\for PDL\end{tabular} & \begin{tabular}[c]{@{}l@{}} Running\\time\\for PDL\end{tabular}\\ \hline Satellite & 29781.24 & 102.61 & 3.10 & 47857.19 \\ \hline Mprime & 1614.09 & 16.52 & 618.80 & 2167.07 \\ \hline Gripper & 36873.72 & 110.03 & 0.08 & 17253.49 \\ \hline Depots & 110415.61 & 153.88 & 4080.17 & 98878.02 \\ \hline \end{tabular} \caption{Comparison of running time for ARMS and PDeepLearn (PDL) in secs} } \hfill \parbox{.47\linewidth}{ \centering \begin{tabular}{|l|l|l|l|} \hline Domain &\begin{tabular}[c]{@{}l@{}} Accuracy\\Rate (\%)\ \end{tabular}& \begin{tabular}[c]{@{}l@{}} ARMS\\Error $E$\end{tabular}\\ \hline Satellite & 85.71 &28.88 \\ \hline Mprime & 75.00 & 16.66 \\ \hline Gripper & 100.00 & 22.22 \\ \hline Depots & 72.00 &24.07 \\ \hline \end{tabular} \caption{Accuracy Comparisons} } \end{table} \section{Conclusion} \label{conclusion} In this paper, we have presented an approach called \emph{PDeepLearn}, which, given a set of state-action interleaved traces, uses the sequence labelling capabilities of LSTMs to learn the action model best representative of the traces. Given that the current is focused on the short term dependencies between actions, future proposed work would investigate the effect of long term dependencies in the form of constraints, and their combined implication along with the short-term dependencies on the quality of the learnt model.
{'timestamp': '2018-10-05T02:04:14', 'yymm': '1810', 'arxiv_id': '1810.01992', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01992'}
arxiv
\section{Introduction} Although theoretically, a vanilla DNN model such as a multi-layer perceptron with non-linear activation-functions can fit any functions, it is impossible to gather enough labeled data in most situations. Exquisitely designed neural-based models introduce some architecture bias and operation bias to reduce the dependency on data amount and achieve excellent performances on different problems. One typical instance is Convolutional Neural Networks, which uses shared convolution kernels and max-pooling operations to extract features. Such architecture perfectly suits the attributes of digital images and achieves great success in computer vision tasks. However, there is no general architecture available in natural language processing. Natural languages have several characteristics as follows: 1) A paragraph of text is a sequence of letters or characters, which orderly express information. 2) A higher-level language unit consists of an arbitrary number of lower-level language units. Correspondingly, local semantic feature together makes up a more complex expression. 3) Unlike images, text information is more discretized and symbolized. We aim to design a neural-based network, which has better natural language processing performance leveraging such characteristics. In this paper, we focus on a classic task in natural language processing, name entity recognition(NER). NER is a typical sequence to sequence decision progress, in which, generally, given a paragraph, a model finds out several keys fragments such as names, locations or organizations by indicating them via special labels. Several models are introduced recently such as combinations of convolutional layers, gated recurrent layers, and conditional random field. However, these models are still some distance away from practical applications in the real world for following reasons: 1) Current neural based models become powerless establishing representations when a paragraph has a complex structure, which always leads to more tanglesome dependencies. 2) They lack the ability of dynamically utilizing different levels of details to maintain a more effective memory, which plays an important role in human reading and understanding. 3) The output mode, one single label per time-step, is inefficient and not necessary, which takes much time when processing a long paragraph. To conquer such weakness of current networks and efficiently utilizing language characteristics, we propose a novel framework, Zooming Network(\texttt{ZN} ). \texttt{ZN} explicitly uses text structure information of language units segmentation and affiliation to establish multi-level representations of a text during encoding section. Then, it reads these representations in order via a stochastic policy and outputs an arbitrary number of labels in the meantime. The structure of \texttt{ZN} is roughly an encoder-controller-reasoner framework, as illustrated in Figure1. The first part called Hierarchical Encoder maps a document into a hierarchical representation, where each language unit has a corresponding distributed memory slot. The second part named Skipping-Controller follows a stochastic policy to read part of earlier established memory and output a predicted sequence. Meanwhile, as the third part of \texttt{ZN} , the Symbolic Reasoner provides some symbolic clues to SC to help make better choices. We elaborate details in next several sections. \begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{DZN.png} \caption{scale-free Identification Network: Skip Controller} \label{fig:sfIN_SC} \end{figure} \section{Related Work} The idea of using multi-resolution features has been explored in various ways. Some early inspiring attempts date back to the 90's, such like \cite{el1996hierarchical}, \cite{lin1998learning} and \cite{schmidhuber1991neural}. In such works, models have multiple layers of RNNs in a decreasing order of update frequency. The clockwork RNN (CW-RNN) \cite{koutnik2014clockwork} is a more recent model extended from hierarchical RNN \cite{el1996hierarchical} and NARX RNN \cite{lin1996learning}, in which the hidden layer is partitioned into separate modules, each processing inputs at its own temporal granularity, making computations only at its prescribed clock rate. However, the CW-RNN explicitly assigning hard time-scale to update its hidden state, which is counterintuitive for that language structures have various lengths. The biscale RNNs \cite{chung2015gated} try to solve this problem by introducing \textsl{layer-wise} timescales by having additional gating units. However, it relies on the soft gating mechanism like LSTMs, which is computationally expensive and limited to the capability of memorizing long-term memory. In the contrast, \texttt{ZN} explicitly uses hierarchical text structural information to obtain a multi-resolution representation with increasing levels of abstraction. Other models capable of using explicit boundary structure are proposed recently. The hierarchical RNN in \cite{ling2015character} uses word boundary via tokenization for machine translation by modeling character-level and word-level representation using two individual RNN layers. A similar model is used in \cite{sordoni2015hierarchical} to model dialogue utterances. However, these models use relatively low-level boundary information in short text, while \texttt{ZN} focus on high-level text structure such as sentence and paragraph in sequence labeling tasks of long texts. Different from all of the previous models, \texttt{ZN} not only leverages text structure information in representation establishment but also in forming a new output mode. As far as we know, \texttt{ZN} is the first model capable of labeling a sequence with multi-level actions. In this way, structure information is used more flexible and direct to model long-term dependencies. The paper 'Hierarchical Attention Networks for Document Classification' has the following important differences as sFIN : 1) HAN encodes a document into a single vector, which is used in classification, while \texttt{ZN} keeps information in all three granularities then makes a series of decisions. 2) sfIN also utilizes structure information in decision making progress. 3) HAN aims to find some important words/sentences via hierarchical attention mechanism to better classify a document while sfIN use structure information to find a better way to update the state of the controller. We are sorry that we didn't make it clear that our tagging is dynamical: it can generate unbounded tags in [0,1,2,..] which indicates the serial number of a target fragment. Corresponding to BIO annotation, "none crucial", "current fragment", "new fragment"respectively stand for 'O', 'I', 'B'. \section{Zooming Network} We take a NER task as a decision progress, which can be roughly divided into two steps: information representation and decision making. A paragraph of text is essentially a sequence of basic language units, letters or words and an arbitrary number of them make up a higher-level language unit, like a sentence or a paragraph. Considering this, we establish the representation of a text from front to back and from bottom to top. In general, the representation of basic unit (like word-embedding) is built first, and the units in next level are encoded using such basic information. Inspired by multi-layer convolutional neural networks, we use the max-pooling operation to calculate the abstract of lower-level information as the representation of current-level ones. After hierarchical representation established by \texttt{Text-Encoder} , \texttt{Zooming-Controller} takes controller of label selection. It reads from front to back while simultaneously select an arbitrary number of labels and decide a proper \textsl{read path}. Details are illustrated in several following subsections. \subsection{Text Encoder: Establishment of Hierarchical Representation} \begin{figure}[h] \centering \includegraphics[width=1\textwidth]{Text_Encoder.png} \caption{Zooming Network: Text-Encoder} \label{fig:te} \end{figure} To begin with, we provide an example of how Zooming Network generates a hierarchical memory slot with its first part and then generates a label sequence with its second part. In Figure \ref{fig:example}, we depict a long text with two paragraphs, three sentences and an arbitrary number of words, where the affiliation is shown by the brackets. As illustrated in Figure \ref{fig:te}, the first part of ZN, Text Encoder has three layers, word-embedding layer and two biLSTM layers. The first biLSTM layer receives words as inputs and generated sentence-level representation, and the second one takes word-level representations as input and yield paragraph-level representations. These three components compose the hierarchical memory, as shown in Figure X. After such encoding progress, every language unit has a corresponding real-value vector as a distributed representation. From this example we can see the advantages of Zooming Network: 1) The update times of each recurrent unit is remarkably less then that of a single recurrent network, which make it much easier modeling long-term dependencies and temporal information. 2) The upper level representation is summarized from the lower level information with explicit boundary information which make it capable of modeling spatial information similar with convolutional neural networks. \begin{figure}[h] \centering \includegraphics[width=0.6\textwidth]{example.png} \caption{An example text} \label{fig:example} \end{figure} The word-level component of the hierarchical memory is first generated by the word-embedding layer, which is initialized by word2vec, and then fine tuned together with the other parts of the whole model. $$v_{w_i} = f_{embed}(w_i) \eqno{1}$$ $$R_w = [v_{w_1}, v_{w_2} ... v_{w_n}] \eqno{2}$$ The first bi-LSRM layer takes the word vectors from each sentence as input and outputs a hidden state vector at each time step. Then we use the max-pooling operation to gain a fixed length sentence vector. We take all the sentence vectors as the sentence-level component of the hierarchical memory. $$v_{s_j} = max(f_{bi-LSTM1}(v_{w_i}, v_{w_{i+1}} ... v_{w_n})), w_{i}, w_{i+1} ... w_{n} \in s_j \eqno{3} $$ $$R_s = [v_{s_1}, v_{s_2} ... v_{s_m}] \eqno{4}$$ The paragraph-level component is established in a similar way. We use the second bi-LSTM layer and the max-pooling operation to encode sentence-level information into paragraph-level representation. $$v_{p_j} = max(f_{bi-LSTM2}(v_{s_j}, v_{s_{j+1}} ... v_{s_m})), s_{j}, s_{j+1} ... s_{m} \in p_k \eqno{5} $$ $$R_p = [v_{p_1}, v_{p_2}, ... v_{p_o}] \eqno{6}$$ We concatenate $R_w$, $R_s$, $R_p$ to gain the hierarchical memory $M=[R_w, R_s, R_p]$. \subsection{Zooming Controller: Zooming while Generating Labels} To make the description more readable, we first introduce some concepts and basic configuration before elaborating the \texttt{Zooming-Controller} : \begin{itemize} \item \textbf{read-head}: \texttt{ZN} has three read-heads, each of which reads one vector in the hierarchical representation at a specific level at current time step. \item \textbf{location vector}: The location vector, $v_l\in Z^3$ declares the location of the \textsl{read-heads}. For example, $v_l = [1, 1, 1]$ means the \textsl{read-heads} are pointing at the first word, the first sentence, and the first paragraph. \item \textbf{actions}: Instead of directly choosing one simple label at each time step, \texttt{Zooming-Controller} chooses and executes, which has a specific level and a specific type an action to generate labels. \item \textbf{action level}: Action level indicates the object of corresponding action is at which level, with three available options: word-level, sentence-level, and paragraph-level. \item \textbf{action type}: BIO is a classic label standard in a name-entity-recognition task. Since an action is can be at a sentence-level or paragraph level, we propose some corresponding action type to the BIO standard. 1)'O' indicates current fragment is outside of any mention of a named entity. 2)'B' indicates current fragment is the beginning of a mentioned named entity. 3)'I' indicates current fragment is inside of a mention of a named entity. By current fragment we mean the object language unit of current action. \item \textbf{previous action vector}: $v_p$ is an one-hot vector of length nine, indicating the action executed at last time step. \item \textbf{action execution}: The execution progress of an action is generating a label sub sequence based on the type and level of an action. For example, suppose the sentence-level read-head is pointing a sentence with length 5 when \texttt{Zooming-Controller} takes an sentence-level 'O' action, the corresponding label sequence generated at current time step should be $['O', 'O', 'O', 'O', 'O']$ \item \textbf{skipping rule}: After the execution of an action, the three read-heads should skip to the next location according to following rules: 1) If it is an word-level action, the word-level read-head first turn to the next word, and the other two read-heads then change/keep their position based on the belonging situation of the very word. 2) If it is an sentence-level action, the sentence-level first skip to the next sentence, then the word-level read-head turns to the first word of such sentence. And the paragraph-level read-head changes/keeps its location based on the belonging situation of the very sentence. 3) If it is a paragraph-level action, the paragraph-level read-head first turn to the next paragraph, and then the other two read-heads turn to the next word and the next sentence. \item \textbf{processing path}: We take the location history of the word-level read-head as the processing path. \item \textbf{action history}: We take the action execution history as action history. \end{itemize} \textsl{How does the Zooming Controller generate the label sequence by executing a series of actions?} We use the example in Figure X agin to give a rough description of this special decoding progress. After the encoding procedure, the model start to process the whole text from the very beginning. The representation of $w_1$, $s_1$, and $p_1$ and the previous action vector, $v_p$, which initialized as an all-zero vector are concatenated as the input vector. The RNN layer of Zooming Controller then takes the input vector and update its hidden state, which is used to predict an action. Suppose an ‘B’-sentence-level action is chosen, the corresponding label, $[B, I, I, I, I, I, I, I]$ is generated as the label of current sentence. Following the skipping rule, After the execution of the action, the location vector updates to $[9, 2, 1]$, and the previous action vector updates to $[0, 0, 0, 1, 0, 0, 0, 0, 0]$. After this, predictions, executions, and updates are looped until the entire text is processed. In this case, another four 'O'-word-level actions and one 'B'-paragraph-level action are executed, and the corresponding predicted labels are concatenated together as the result. We abstract the whole process into the following parts \begin{figure}[h] \centering \includegraphics[width=0.6\textwidth]{controller_example} \caption{The processing of the example} \label{fig:contollrt_example} \end{figure} \begin{itemize} \item \textbf{Initialization}: After the hierarchical representation established, we first initialize the location vector $v_{l_0}$ as $[1, 1, 1]$, the previous action vector $v_{p_0}$ as $[0, 0, 0, 0, 0, 0, 0, 0, 0]$, and the predicted label as an empty list. $$v_{l_0} = [1, 1, 1] \eqno{7}$$ $$v_{p_0} = [0, 0, 0, 0, 0, 0, 0, 0, 0] \eqno{8}$$ $$l_0 = [] \eqno{9}$$ \item \textbf{Prediction}: Guided by the location vector, each read-head reads a specific part of the hierarchical representation (a vector) in corresponding position. All three level vectors and the previous action vector are concatenated as current input vector $v_{i_t}$, which is then used to update the hidden state of RNN layer and choose the action at current time step through a fully connected layer and a softmax operation. $$v_{input}=[R_w[v_{l_t}[1]], R_s[v_{l_t}[2]], R_p[v_{l_t}[3]], v_{p_t}] \eqno{10}$$ $$h_t = f_{RNN}(v_i, h_{t-1}) \eqno{11}$$ $$a_t = argmax(softmax(f_c(h_t))) \eqno{12}$$ \item \textbf{Execution}: After chosen an action, a corresponding label sequence is generated following the \textbf{action execution} rule, then appended to the end of the predicted label. $$l_t = f_{execute}(a_t) \eqno{13}$$ $$l_{p_t} = [l_{p_{t-1}}, l_t] \eqno{14}$$ \item \textbf{Update}: Following the skip rule, the three read-heads move to the next positions. Meanwhile, the location vector $v_l$ and the previous action vector $v_p$ are updated correspondingly. $$v_{l_{t+1}} = f_{skipping}(v_{l_{t}}, a_t) \eqno{15}$$ $$v_{p_{t+1}} = one-hot(a_t) \eqno{16}$$ \item \textbf{Loop}: The \textbf{Prediction, Execution and Update} section are looped until the whole text is processed. \end{itemize} \begin{figure}[h] \centering \includegraphics[width=0.8\textwidth]{controller.png} \caption{Zooming Controller} \label{fig:zooming_controller} \end{figure} The whole controller processing procedure is illustrated in Figure \ref{fig:zooming_controller}. As we can see from above description, \texttt{Zooming-Controller} reads multi-level information simultaneously, which gives the model three advantages: 1) a flexible resource allocation (e.g., The units that build higher-level representation focuses on modeling long-term dependencies, while lower-level representation related units focus on modeling local features). 2) efficiency delivering long-term dependencies with fewer updates of controller hidden state when executing a sentence/paragraph level action, which mitigates the vanishing gradient problem. 3) operation bias of a whole language unit, which avoids false gaps inside a large-scale important information fragment. \section{Learning} Zooming Network is designed to 'zoom out' when the current segment is not highly correlated with the target information and 'zoom in' when find current information is significantly related to the target information. In other words, we hope that \texttt{ZN} has an efficient processing path while maintain a good accuracy. We utilize supervised learning to make sure the model with a high accuracy and reinforcement learning to drive the model to use more high-level actions. \subsection{Supervised Learning} As a sequence-to-sequence model, the optimization goal of \texttt{ZN} is minimizing the distance between the ground truth distribution of label sequences $P^*(Y|X)$ and predicted distribution $P(Y|X)$ condition on the input sequence $X$. With the special design of \texttt{Zooming-Controller} , instead of directly outputs a label sequence, \texttt{ZN} generates a sequence of actions, which makes it impossible to forthright leverage the ground truth label. In order to apply supervised learning, we convert the label into action supervision via the verification of whether the predicted label is correct after the execution of an action at each time step. As we can see, there can be more than one correct action at a specific time step. Take the text in Figure \ref{fig:example} as an example, at the very beginning, the 'B'-word-level action and 'B'-sentence-level action both can produce correct labels. We make all the correct actions into a set $A_t^*$. Since there is no way for us to know which action in $A_t^*$ is the best one (it involves the update path of the \texttt{Zooming-Controller} ), we turn to maximize the sum possibility of $A_t^*$. Here we employ a modified cross entropy as the loss function as shown in equation (17). $$L_\theta = -\frac{1}{T}\sum_{t=1}^T(\sum_{a_i\notin A_t^*}log(1-y_{a_i}) + log(\sum_{a_j \in A_t^*}y_{a_j})) \eqno{17}$$ \subsection{Path Reward} As mentioned above, the processing procedure can be very versatile with multiple correct actions available at each time step. Experientially, a better path means skipping the irrelevant sections quickly, zooming into the region of interest and zooming out when there comes an non-important section again, which is what it is like for a human reader. However, it is not only the efficiency the processing path influences but also the state updating strategy. In another word, it is impossible to explicitly tell which region of the text can indicate its context is the important information, even for a human. Hence, we adopt a relatively conservative training strategy. We use an reinforcement learning method(policy gradient) to help tuning the whole network. The processing of a single text is regarded as an episode, at the end of which the model receives a reward indicating how well is the current processing path as shown in equation(18). $$r=L_\theta * (- \frac{N_{a_w}}{N_{a_w} + N_{a_s} + N_{a_p}}) \eqno{18}$$ where the $L_\theta$ is current loss and $N_{a_w}, N_{a_s}, N_{a_p}$ separately indicates the action number of each level actions. As we can see, the model is encouraged to use more high level actions to get a larger reward, or less $L_\theta$. Moreover, such configuration can guarantee that once the model achieves small enough cost, the processing path turn to be converged together with the predicted label sequences. \subsection{Jointly Learning and Sampling Strategy} \texttt{ZN} is trained both using supervised learning and reinforcement learning, both involving gradient descent method. Intuitively, we leave the accuracy problem to supervised learning part, and use reinforcement learning to find a better processing path among hundreds of correct paths. Here, we introduce an hyper-parameter $\lambda$ to balance the supervised learning and reinforcement learning by giving a weighted sum gradient changes in equation (19). $$J_\theta=-\sum_{t=1}^Tr_t * log(\pi_\theta(a_t, s_t))$$ $$L_\theta = -\frac{1}{T}\sum_{t=1}^T(\sum_{a_i\notin A_t^*}log(1-y_{a_i}) + log(\sum_{a_j \in A_t^*}y_{a_j}))$$ $$min(L_\theta - \lambda * J_\theta)$$ Since \texttt{Zooming-Controller} is essentially a sequence model with feedback inputs(we input the previous action vector into the controller module), we execute one of the correct actions at each time step during the training procedure following an on-policy method. In specific, we first calculate the probability of each correct action in the set $A_t^*$, and execute a proportional random selection from the very set. In this way, we guarantee that the model always follow a correct processing path during training and given the right feedback information(the previous action vector $v_p$). \section{Experiments} \subsection{TaskI:Event Extraction in Court Documents} In this Task, we deal with some legal documents about some fact description, which is the detail information of a stealing case. Such samples shares following characters: 1) The text can be divided into several semantic sections. More specific, criminal case judgment contains the basic information of the criminal, the investigation procedure, the ascertained facts, the legal basis, the judgment conclusion and the specific judgments. 2) The information of interest only appears in a specific section. The detail information of stealing events are always placed in the asertained facts section. An example of the data is shown in Figure []. Since the extraction of region of interest is a sequantial labeling task, we take one of the state of the art named entity recognition model, bidirectional Long short-term momery and conditional random field (biLSTM-crf) as the baseline model. We use the word-level accuracy and fragment-level f1 as the evaluation standard. The results are shown in Figure[]. To illustrate the processing efficiencies, we introduce a contant named wlar(word level action ratio). A model with lower wlar means it has better processing efficiency. We build this dataset including 3944 judgment documents about theft cases in Chinese. In such documents, the description of the court can be broadly divided into five parts: \textsl{basic information}, \textsl{the proposals of procuratorate}, \textsl{ascertain of facts}, \textsl{court's conclusion} and \textsl{judgment}. The identification task is to recognize theft incidents in both \textsl{the proposals of procuratorate} and \textsl{ascertain of facts} one by one, which is labeled at word-level. An instance is shown in Figure \ref{fig:TcJD} \begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{tcjd.png} \caption{Part of an instance in TcJD: red part and blue part respectively indicts one incident} \label{fig:TcJD} \end{figure} On average, a sample of \textsl{TcJD} has 1089.94 words, and 207.26 words of incident description. \subsection{TaskII:Focus Extraction in Court Documents} To give a step further test of \texttt{ZN} , we design the second extraction task, the extraction of argument focuses in an intellectual property dispute cases. This dataset is built with 2180 judgment documents about patten infringement written in Chinese. Similar to \textsl{TcJD}, the documents can be roughly divided into several sections as well. The task is to identify focuses of dispute between the plaintiff and defendant.The focuses of the dispute is more varied than the description of the incident in \textsl{JcJD}, and its position is more uncertain. Two fragments of examples are shown below in Figure \ref{fig:PiJD} \begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{pijd.png} \caption{Two fragments of instances in PiJD: red part and blue part respectively indicts one focus of dispute} \label{fig:PiJD} \end{figure} On average, a sample of \textsl{PiJD} has 6133.61 words, and 82.11 words of description of focus. \subsection{Evaluation Methods} We use entity(or fragment)-level precision, recall and F1 measure to evaluate the performance of the proposed model. Meanwhile, we use \textsl{word-level actions ratio(wlar)} to evaluate the processing efficiency of our model, which is calculated as follows: $$wlar = \frac{n_{a_w}}{n_w + n_s + n_p}$$ Lower wlar value infers that the model takes fewer actions in processing, which means more efficient. \subsection{Implement Details} We use \texttt{biLSTM-crf}, which is one of the state-of-the-art sequence labeling models, proposed in \cite{huang2015bidirectional}, as a baseline model. We set both \texttt{biLSTM-crf} and \texttt{ZN} with similar number of parameters to balance the different structure complexities of them as show in Table \ref{t:parameters}. \begin{table}[h] \begin{center} \begin{tabular}{|l|l|l|l|l|} \hline \multicolumn{4}{|c|}{sfIN} & biLSTM-crf\\ \hline Component & \textbf{TE} & {SC} & Total & Total\\ \hline parameters & 49876 & 167936 & 217812 & 196608\\ \hline \end{tabular} \end{center} \caption{Parameters Numbers} \label{t:parameters} \end{table} In both incident identification task on \textsl{TcJD} and focuses of dispute identification task on \textsl{PiJD}, we randomly sample 500 documents as the test set and the other documents are used in training procedure. \section{Results and Discussion} In this section, we are going to show results of experiments and explain some interesting phenomena during the test procedure. \begin{table*}[h] \footnotesize \begin{center} \begin{tabular}{|l|l|l|l|l|l|} \toprule model & WA(\%) & precision(\%) & recall(\%) & F1(\%) & $wlar$ \\ \hline \multicolumn{6}{|c|}{TaskI} \\ \toprule biLSTM-crf & $97.29$ & $78.62$ & $85.26$ & $81.81$ & 1 \\ ZN & $99.93$ & $95.34$ & $95.64$ & $95.49$ & 0.16 \\ \hline \multicolumn{6}{|c|}{TaskII} \\ \toprule biLSTM-crf & $99.61$ & $78.31$ & $86.83$ & $82.36$ & 1\\ ZN & $99.92$ & $94.74$ & $95.06$ & $94.91$ & 0.15\\ \hline \end{tabular} \end{center} \caption{Evaluation Results, WA: wrod-level accuracy} \label{t:result} \end{table*} Table \ref{t:result} presents our comparisons of \texttt{biLSTM-crf} and \texttt{ZN} for \textbf{TaskI}(incident identification) and \textbf{TaskII}(focuses identification). \texttt{ZN} outperforms \texttt{biLSTM-crf} by more than 10 F1-measure on both tasks. Though \texttt{biLSTM-crf} and other similar sequence labeling models achieve great successes on several tasks, they fail to perform well on long text for several reasons: (1) Although an LSTM has a self-loop for the gradients that helps to capture the long-term dependencies by mitigating the vanishing gradient problem, in practice, it is still limited to a few hundred time steps due to the leaky integration by which the contents to memorize for a long-term is gradually diluted at every time step.\cite{chung2016hierarchical} (2) Dependencies in such long texts simultaneously involve multi-level information, which is very hard for models not capable of explicitly leveraging text structures. In contrast, \texttt{ZN} has following advantages: (1) With text structure hierarchies, representation directly corresponds to language structures. This allows \texttt{ZN} to precisely integrate multi-level information in modeling complex long-term dependencies. (2) Taking high-level actions significantly reduces the time steps between decision and the information it needs, thus it provides short-cuts for gradient back-propagation. (3) \texttt{ZN} is more efficiency in processing. As shown in Table \ref{t:result}, only 15\% of actions \texttt{ZN} used are at word-level. \begin{figure}[h] \centering \includegraphics[width=0.4\textwidth]{curve.png} \caption{average $wlar$ and $F1$ of validation set during training} \label{fig:curve} \end{figure} Figure \ref{fig:curve} shows average $wlar$ and $F1$ of validation set during a simple \texttt{ZN} training procedure. By jointly using supervised learning and reinforcement learning, the model learns to simultaneously improve accuracy and efficiency. \begin{figure}[h] \centering \includegraphics[width=0.45\textwidth]{case} \caption{processing procedure on a fragment of a simple case: red part indicates using word-level actions and blue part indicates using sentence-level or paragraph-level actions} \label{fig:case} \end{figure} To gain a more intuitive understanding how \texttt{ZN} works, we randomly choose a sample from \textsl{TcJD} dataset, as shown in Figure \ref{fig:case}. The processing path \texttt{ZN} takes is very intuitive: (1) Irrelevant sections such as \textsl{personal information} and the \textsl{judgment} are processed using high-level actions. (2) Fragments that obviously indicating clue for target information and target information itself are processed by word-level actions. This strategy is exactly what humans use to choose between coarse reading or intensive reading. \section{Conclusion} The proposed model \texttt{ZN} is capable of building an effective multi-resolution representation and developing its own analyzing rhythm by choosing different actions combinations to extract critical information. Trained with a hybrid paradigm of supervised learning (distinguishing right and wrong decision) and reinforcement learning (determining the goodness among multiple right paths), our model has both high accuracy and efficiency. The experiments show that the model achieves higher performance than the state-of-the-art sequence labeling model in long text labeling tasks. \newpage \bibliographystyle{elsarticle-num}
{'timestamp': '2018-10-05T02:09:12', 'yymm': '1810', 'arxiv_id': '1810.02114', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02114'}
arxiv
\section{Introduction} \label{gen_inst} Possessing the ability to elicit customers' preferences and restrictions (PR) is crucial to the success for an organization in designing and providing services or products. Nevertheless, as in most scenarios, one can only observe their decisions or behaviors corresponding to external signals, while cannot directly access their decision making schemes. Indeed, decision makers probably do not have exact information regarding their own decision making process \cite{keshavarz2011imputing}. To bridge that discrepancy, inverse optimization has been proposed and received significant research attention, which is to infer or learn the missing information of the underlying decision models from observed data, assuming that human decision makers are rationally making decisions \cite{ahuja2001inverse,iyengar2005inverse,Schaefer2009,wang2009cutting,keshavarz2011imputing,barmann2017emulating,aswani2016inverse,chan2014generalized,bertsimas2012inverse,esfahani2017data,dong2018inferring}. Nowadays, extending from its initial form that only considers a single observation \cite{ahuja2001inverse,iyengar2005inverse,Schaefer2009,wang2009cutting} with clean data, inverse optimization has been further developed and applied to handle more realistic cases that have many observations with noisy data \cite{keshavarz2011imputing,barmann2017emulating,aswani2016inverse,bertsimas2012inverse,esfahani2017data,dong2018inferring}. Despite of these remarkable achievements, traditional inverse optimization (typically in batch setting) has not proven fully applicable for supporting recent attempts in AI to automate the elicitation of human decision maker's PR in real time. Consider, for example, recommender systems (RSs) used by online retailers to increase product sales. The RSs first elicit one customer's PR from the historical sequence of her purchasing behaviors, and then make predictions about her future shopping actions. Indeed, building RSs for online retailers is challenging because of the sparsity issue. Given the large amount of products available, customer's shopping vector, each element of which represents the quantity of one product purchased, is highly sparse. Moreover, the shift of the customer's shopping behavior along with the external signal (e.g. price, season) aggravates the sparsity issue. Therefore, it is particularly important for RSs to have access to large data sets to perform accurate elicitation \cite{aggarwal2016recommender}. Considering the complexity of the inverse optimization problem (IOP), it will be extremely difficult and time consuming to extract user's PR from large, noisy data sets using conventional techniques. Thus, incorporating traditional inverse optimization into RSs is impractical for real time elicitation of user's PR. \begin{figure*} \centering \includegraphics[width=0.9\linewidth]{figure/iop_vs_online} \caption{An overview of inverse optimization through batch learning versus through online learning. \textbf{Left:} Framework of inverse optimization in batch setting. \textbf{Right:} Framework of the generalized inverse optimization in online setting proposed in our paper.} \label{fig:iop_vs_online} \vspace{-15pt} \end{figure*} To automate the elicitation of human decision maker's PR, we aim to unlock the potential of inverse optimization through online learning in this paper. Specifically, we formulate such learning problem as an IOP considering noisy data, and develop an online learning algorithm to derive unknown parameters occurring in either the objective function or constraints. At the heart of our algorithm is taking inverse optimization with a single observation as a subroutine to define an implicit update rule. Through such an implicit rule, our algorithm can rapidly incorporate sequentially arrived observations into this model, without keeping them in memory. Indeed, we provide a general mechanism for the incremental elicitation, revision and reuse of the inference about decision maker's PR. \textbf{Related work} Our work is most related to the subject of inverse optimization with multiple observations. The goal is to find an objective function or constraints that explains the observations well. This subject actually carries the data-driven concept and becomes more applicable as large amounts of data are generated and become readily available, especially those from digital devices and online transactions. Solution methods in batch setting for such type of IOP include convex optimization approach \cite{keshavarz2011imputing,bertsimas2015data,esfahani2017data} and non-convex optimization approach \cite{aswani2016inverse}. The former approach often yields incorrect inferences of the parameters \cite{aswani2016inverse} while the later approach is known to lead to intractable programs to solve \cite{esfahani2017data}. In contrast, we do inverse optimization in online setting, and the proposed online learning algorithm significantly accelerate the learning process with performance guarantees, allowing us to deal with more realistic and complex PR elicitation problems. Also related to our work is \cite{barmann2017emulating}, which develops an online learning method to infer the utility function from sequentially arrived observations. They prove a different regret bound for that method under certain conditions, and demonstrate its applicability to handle both continuous and discrete decisions. However, their approach is only possible when the utility function is linear and the data is assumed to be noiseless. Differently, our approach does not make any such assumption and only requires the convexity of the underlying decision making problem. Besides the regret bound, we also show the statistical consistency of our algorithm by applying both the consistency result proven in \cite{aswani2016inverse} and the regret bound provided in this paper, which guarantees that our algorithm will asymptotically achieves the best prediction error permitted by the inverse model we consider. \textbf{Our contributions} To the best of authors' knowledge, we propose the first general framework for eliciting decision maker's PR using inverse optimization through online learning. This framework can learn general convex utility functions and constraints with observed (signal, noisy decision) pairs. In Figure \ref{fig:iop_vs_online}, we provide the comparison of inverse optimization through batch learning versus through online learning. Moreover, we prove that the online learning algorithm, which adopts an implicit update rule, has a $\mathcal{O}(\sqrt{T})$ regret under certain regularity conditions. In addition, this algorithm is statistically consistent when the data satisfies some rather common conditions, which guarantees that our algorithm will asymptotically achieves the best prediction error permitted by the inverse model we consider. Finally, we illustrate the performance of our learning method on both a consumer behavior problem and a transshipment problem. Results show that our algorithm can learn the parameters with great accuracy and is very robust to noises, and achieves drastic improvement in computational efficacy over the batch learning approach. \section{Problem setting} \subsection{Decision making problem} We consider a family of parameterized decision making problems, in which $\mfx \in \bR^{n}$ is the decision variable, $u \in \mathcal{U} \subseteq \bR^{m}$ is the external signal, and $ \theta \in \Theta \subseteq \bR^{p} $ is the parameter. \begin{align*} \label{fop} \tag*{DMP} \begin{array}{rlll} \min\limits_{\mfx \in \bR^{n}} & f(\mfx,u,\theta) \\ \;s.t. & \mfg(\mfx,u,\theta) \leq \zero, \end{array} \end{align*} where $f : \bR^{n}\times\bR^{m} \times \bR^{p} \mapsto \bR$ is a real-valued function, and $\mfg : \bR^{n}\times\bR^{m} \times \bR^{p} \mapsto \bR^{q}$ is a vector-valued function. We denote $ X(u,\theta) = \{x \in \bR^{n}: \mfg(\mfx,u,\theta) \leq \zero \} $ the feasible region of \ref{fop}. We let $ S(u,\theta) = \arg\min\{f(\mfx,u,\theta):x \in X(u,\theta) \} $ be the optimal solution set of \ref{fop}. \subsection{Inverse optimization and online setting} Consider a learner who monitors the signal $ u \in \mathcal{U} $ and the decision maker' decision $ \mfx \in X(u,\theta) $ in response to $ u $. We assume that the learner does not know the decision maker's utility function or constraints in \ref{fop}. Since the observed decision might carry measurement error or is generated with a bounded rationality of the decision maker, i.e., being suboptimal, we denote $ \mfy $ the observed noisy decision for $ u \in \mathcal{U} $. Note that $\mfy$ does not necessarily belong to $X(u,\theta)$, i.e., it might be infeasible with respect to $X(u,\theta)$. Throughout the paper, we assume that the (signal,noisy decision) pair $ (u,\mfy) $ is distributed according to some unknown distribution $ \bP $ supported on $ \{(u,\mfy) : u \in \mathcal{U}, \mfy \in \mathcal{Y}\} $. In our inverse optimization model, the learner aims to learn the decision maker's objective function or constraints from (signal, noisy decision) pairs. More precisely, the goal of the learner is to estimate the parameter $ \theta $ of the \ref{fop}. In our online setting, the (signal, noisy decision) pair become available to the learner one by one. Hence, the learning algorithm produces a sequence of hypotheses $(\theta_{1},\ldots,\theta_{T+1})$. Here, $T$ is the total number of rounds, and $\theta_{1}$ is an arbitrary initial hypothesis and $\theta_{t}$ for $t \geq 2$ is the hypothesis chosen after observing the $(t-1)$th (signal,noisy decision) pair. Let $l(\mfy_{t},u_{t},\theta_{t})$ denote the loss the learning algorithm suffers when it tries to predict the $ t $th decision given $ u_{t} $ based on $\{(u_{1},\mfy_{1}),\cdots,(u_{t-1},\mfy_{t-1})\}$. The goal of the learner is to minimize the regret, which is the cumulative loss $\sum_{t \in [T]}l(\mfy_{t},u_{t},\theta_{t})$ against the possible loss when the whole batch of (signal,noisy decision) pairs are available. Formally, the regret is defined as \begin{align*} R_{T} = \sum_{t\in[T]}l(\mfy_{t},u_{t},\theta_{t}) - \min_{\theta \in \Theta}\sum_{t \in [T]}l(\mfy_{t},u_{t},\theta). \end{align*} In the following, we make a few assumptions to simplify our understanding, which are actually mild and frequently appear in the inverse optimization literature \cite{keshavarz2011imputing,bertsimas2015data,esfahani2017data,aswani2016inverse}. \begin{assumption} \label{assumption:convex_setting} Set $\Theta$ is a convex compact set. There exists $D>0$ such that $\norm{\theta} \leq D$ for all $\theta \in \Theta$. In addition, for each $u \in \mathcal{U}, \theta \in \Theta$, both $\mathbf{f}(\mfx,u,\theta)$ and $\mathbf{g}(\mfx,u,\theta)$ are convex in $\mfx$. \end{assumption} \section{Learning the parameters} \subsection{The loss function}\label{sec:loss function} Different loss functions that capture the mismatch between predictions and observations have been used in the inverse optimization literature. In particular, the (squared) distance between the observed decision and the predicted decision enjoys a direct physical meaning, and thus is most widely used \cite{yang1992estimation,dempe2006inverse,timothy2015inverse,aswani2016inverse}. Hence, we take the (squared) distance as our loss function in this paper. In batch setting, statistical properties of inverse optimization with such a loss function have been analyzed extensively in \cite{aswani2016inverse}. In this paper, we focus on exploring the performance of the online setting. Given a (signal,noisy decision) pair $(u,\mfy)$ and a hypothesis $\theta$, we set the loss function as the minimum (squared) distance between $\mfy$ and the optimal solution set $S(u,\theta)$ in the following. \begin{align*} \label{loss_function} \tag*{Loss Function} l(\mfy,u,\theta) = \min_{\mfx \in S(u,\theta)} \norm{\mfy - \mfx}^{2}. \end{align*} \subsection{Online implicit updates} Once receiving the $t$th (signal,noisy decision) pair $ (u_{t},\mfy_{t}) $, $\theta_{t+1}$ can be obtained by solving the following optimization problem: \begin{align} \label{update} \begin{array}{llll} \theta_{t+1} = \arg\min\limits_{\theta \in \Theta} & \frac{1}{2}\norm{\theta- \theta_{t}}^{2} + \eta_{t}l(\mfy_{t},u_{t},\theta), \end{array} \end{align} where $\eta_{t}$ is the learning rate in round $ t $, and $l(\mfy_{t},u_{t},\theta)$ is defined in \eqref{loss_function}. The updating rule \eqref{update} seeks to balance the tradeoff between "conservativeness" and correctiveness", where the first term characterizes how conservative we are to maintain the current estimation, and the second term indicates how corrective we would like to modify with the new estimation. As there is no closed form for $\theta_{t+1}$ in general, we call \eqref{update} an implicit update rule \cite{cheng2007,kulis2010implicit}. To solve \eqref{update}, we can replace $\mfx \in S(u,\theta)$ by KKT conditions of the \ref{fop}, and get a mixed integer nonlinear program. Consider, for example, a decision making problem that is a quadratic optimization problem. Namely, the \ref{fop} has the following form: \begin{align*} \label{qp} \tag*{QP} \begin{array}{llll} \min\limits_{\mfx \in \bR^{n}} & \frac{1}{2}\mfx^{T} Q\mfx + \mfc^{T}\mfx \vspace{2mm}\\ \;s.t. & A\mfx \geq \mfb. \end{array} \end{align*} Suppose that $ \mfb $ changes over time $ t $. That is, $ \mfb $ is the external signal for \ref{qp} and equals to $ \mfb_{t} $ at time $ t $. If we seek to learn $ \mfc $, the optimal solution set for \ref{qp} can be characterized by KKT conditions as $ S(\mfb_{t}) = \{\mfx: \mfA\mfx \geq \mfb_{t},\; \mfu \in \bR^{m}_{+},\; \mfu^{T}(\mfA\mfx - \mfb_{t}) = 0,\; Q\mfx + \mfc - \mfA^{T}\mfu = 0\} $. Here, $ \mfu $ is the dual variable for the constraints. Then, the single level reformulation of the update rule by solving \eqref{update} is \begin{align} \label{iqp} \tag*{IQP} \begin{array}{llll} \min\limits_{\mfc \in \Theta} & \frac{1}{2}\norm{\mfc- \mfc_{t}}^{2} + \eta_{t}\lVert \mfy_{t} - \mfx\rVert_{2}^{2} \vspace{1mm} \\ \text{s.t.} & \mfA\mfx \geq \mfb_{t}, \vspace{1mm}\\ & \mfu \leq M\mfz, \vspace{1mm} \\ & \mfA\mfx - \mfb_{t} \leq M(1 - \mfz), \vspace{1mm} \\ & Q\mfx + \mfc - \mfA^{T}\mfu = 0, \vspace{1mm} \\ & \mfc \in \bR^{m},\;\; \mfx \in \bR^{n},\;\; \mfu \in \bR^{m}_{+}, \;\; \mfz \in \{0,1\}^{m}, \end{array} \end{align} where $ \mfz $ is the binary variable used to linearize KKT conditions, and $ M $ is an appropriate number used to bound the dual variable $ \mfu $ and $ \mfA\mfx - \mfb_{t} $. Clearly, \ref{iqp} is a mixed integer second order conic program (MISOCP). More examples are given in supplementary material. Our application of the implicit updates to learn the parameter of \ref{fop} proceeds in Algorithm \ref{alg:online-iop}. \begin{algorithm}[ht] \caption{Implicit Online Learning for Generalized Inverse Optimization} \label{alg:online-iop} \begin{algorithmic}[1] \STATE {\bfseries Input:} (signal,noisy decision) pairs $\{(u_{t},\mfy_{t})\}_{t \in [T]}$ \STATE {\bfseries Initialization:} $\theta_{1}$ could be an arbitrary hypothesis of the parameter. \FOR{$ t = 1 $ to $ T $} \STATE receive $ (u_{t},\mfy_{t}) $ \STATE suffer loss $ l(\mfy_{t},u_{t},\theta_{t}) $ \IF{$l(\mfy_{t},u_{t},\theta_{t})= 0 $} \STATE $ \theta_{t+1} \leftarrow \theta_{t} $ \ELSE \STATE set learning rate $ \eta_{t} \propto 1/\sqrt{t} $ \STATE update $ \theta_{t+1} = \arg\min\limits_{\theta \in \Theta} \frac{1}{2}\norm{\theta- \theta_{t}}^{2} + \eta_{t}l(\mfy_{t},u_{t},\theta) $ (solve \eqref{update}) \ENDIF \ENDFOR \end{algorithmic} \vspace{-5pt} \end{algorithm} \begin{remark} $(i)$ In Algorithm \ref{alg:online-iop}, we let $\theta_{t+1} = \theta_{t}$ if the prediction error $l(\mfy_{t},u_{t},\theta_{t})$ is zero. But in practice, we can set a threshold $\epsilon >0$ and let $\theta_{t+1} = \theta_{t}$ once $l(\mfy_{t},u_{t},\theta_{t}) < \epsilon$. $(ii)$ Normalization of $\theta_{t+1}$ is needed in some situations, which eliminates the impact of trivial solutions. \end{remark} \begin{remark} To obtain a strong initialization of $\theta $ in Algorithm \ref{alg:online-iop}, we can incorporate an idea in \cite{keshavarz2011imputing}, which imputes a convex objective function by minimizing the residuals of KKT conditions incurred by the noisy data. Assume we have a historical data set $\widetilde{T}$, which may be of bad qualities for the current learning. This leads to the following initialization problem: \begin{align} \label{dis-qp} \begin{array}{llll} \min\limits_{\theta\in\Theta} & \frac{1}{|\widetilde{T}|}\sum\limits_{t \in [\widetilde{T}]}\big(r_{c}^{t} + r_{s}^{t}\big) \\ \text{s.t.} & \lvert\mfu_{t}^{T}\mathbf{g}(\mfy_{t},u_{t},\theta) \rvert \leq r_{c}^{t}, & \forall t \in \widetilde{T}, \\ & \norm[2]{\nabla f(\mfy_{t},u_{t},\theta) + \nabla\mfu_{t}^{T}\mathbf{g}(\mfy_{t},u_{t},\theta)} \leq r_{s}^{t}, & \forall t \in \widetilde{T}, \\ & \mfu_{t} \in \bR^{m}_{+}, \;\; r_{c}^{t} \in \bR_{+}, \;\; r_{s}^{t} \in \bR_{+}, & \forall t \in \widetilde{T}, \end{array} \end{align} where $ r_{c}^{t} $ and $ r_{s}^{t} $ are residuals corresponding to the complementary slackness and stationarity in KKT conditions for the $ t $-th noisy decision $ \mfy_{t} $, and $ \mfu_{t} $ is the dual variable corresponding to the constraints in \ref{fop}. Note that \eqref{dis-qp} is a convex program. It can be solved quite efficiently compared to solving the inverse optimization problem in batch setting \cite{aswani2016inverse}. Other initialization approaches using similar ideas e.g., computing a variational inequality based approximation of inverse model \cite{bertsimas2015data}, can also be incorporated into our algorithm. \end{remark} \subsection{Theoretical analysis}\label{sec:theoretical Analysis} Note that the implicit online learning algorithm is generally applicable to learn the parameter of any convex \ref{fop}. In this section, we prove that the average regret $R_{T}/T$ converges at a rate of $\mathcal{O}(1/\sqrt{T})$ under certain regularity conditions. Furthermore, we will show that the proposed algorithm is statistically consistent when the data satisfies some common regularity conditions. We begin by introducing a few assumptions that are rather common in literature \cite{keshavarz2011imputing,bertsimas2015data,esfahani2017data,aswani2016inverse}. \begin{assumption} \label{assumption:set-assumption} \begin{description} \item[(a)] For each $ u \in \cU $ and $ \theta \in \Theta $, $X(u,\theta)$ is closed, and has a nonempty relative interior. $X(u,\theta)$ is also uniformly bounded. That is, there exists $B >0$ such that $\norm{\mfx} \leq B$ for all $\mfx \in X(u,\theta)$. \item[(b)] $ f(\mfx,u,\theta) $ is $ \lambda $-strongly convex in $ \mfx $ on $ \mathcal{Y} $ for fixed $ u \in \cU $ and $ \theta \in \Theta $. That is, $ \forall \mfx, \mfy \in \mathcal{Y} $, \begin{align*} \bigg(\nabla f(\mfy,u,\theta) - \nabla f(\mfx,u,\theta)\bigg)^{T}(\mfy - \mfx) \geq \lambda\norm{\mfx - \mfy}^{2}. \end{align*} \end{description} \end{assumption} \begin{remark} For strongly convex program, there exists only one optimal solution. Therefore, Assumption \ref{assumption:set-assumption}.(b) ensures that $ S(u,\theta) $ is a single-valued set for each $u \in \cU$. However, $ S(u,\theta) $ might be multivalued for general convex \ref{fop} for fixed $ u $. Consider, for example, $ \min_{x_{1},x_{2}} \{x_{1} + x_{2}: x_{1} + x_{2} \geq 1\} $. Note that all points on line $ x_{1} + x_{2} = 1 $ are optimal. Indeed, we find such case is quite common when there are many variables and constraints. Actually, it is one of the major challenges when learning parameters of a function that's not strongly convex using inverse optimization. \end{remark} For convenience of analysis, we assume below that we seek to learn the objective function while constraints are known. Then, the performance of Algorithm \ref{alg:online-iop} also depends on how the change of $ \theta $ affects the objective values. For $\forall \mfx \in \mathcal{Y}, \forall u \in \cU, \forall \theta_{1}, \theta_{2} \in \Theta $, we consider the difference function \begin{align}\label{difference function} h(\mfx,u,\theta_{1},\theta_{2}) = f(\mfx,u,\theta_{1}) - f(\mfx,u,\theta_{2}). \end{align} \begin{assumption}\label{assumption:lipschitz} $ \exists \kappa >0 $, $ \forall u \in \cU, \forall \theta_{1},\theta_{2} \in \Theta $, $ h(\cdot,u,\theta_{1},\theta_{2}) $ is Lipschitz continuous on $ \mathcal{Y} $: \begin{align*} |h(\mfx,u,\theta_{1},\theta_{2}) - h(\mfy,u,\theta_{1},\theta_{2})| \leq \kappa\norm{\theta_{1} - \theta_{2}}\norm{\mfx - \mfy}, \forall \mfx,\mfy \in \mathcal{Y}. \end{align*} \end{assumption} Basically, this assumption says that the objectives functions will not change very much when either the parameter $ \theta $ or the variable $ \mfx $ is perturbed. It actually holds in many common situations, including the linear program and quadratic program. \begin{lemma}\label{lemma:lipschitz} Under Assumptions \ref{assumption:convex_setting} - \ref{assumption:lipschitz}, the loss function $ l(\mfy,u,\theta) $ is uniformly $ \frac{4(B+R)\kappa}{\lambda} $-Lipschitz continuous in $ \theta $. That is, $ \forall \mfy \in \cY, \forall u \in \cU, \forall \theta_{1},\theta_{2} \in \Theta $, we have \begin{align*} |l(\mfy,u,\theta_{1}) - l(\mfy,u,\theta_{2})| \leq \frac{4(B+R)\kappa}{\lambda}\norm{\theta_{1} - \theta_{2}}. \end{align*} \end{lemma} The establishment of Lemma \ref{lemma:lipschitz} is based on the key observation that the perturbation of $ S(u,\theta) $ due to $ \theta $ is bounded by the perturbation of $ \theta $ through applying Proposition 6.1 in \cite{bonnans1998optimization}. Details of the proof are given in supplementary material. \begin{remark} When we seek to learn the constraints or jointly learn the constraints and objective function, similar result can be established by applying Proposition 4.47 in \cite{bonnans2013perturbation} while restricting not only the Lipschitz continuity of the difference function in \eqref{difference function}, but also the Lipschitz continuity of the distance between the feasible sets $ X(u,\theta_{1}) $ and $ X(u,\theta_{2}) $ (see Remark 4.40 in \cite{bonnans2013perturbation}). \end{remark} \begin{assumption}\label{assumption:convex-assumption} For the \ref{fop}, $\forall \mfy \in \cY, \forall u \in \cU, \forall \theta_{1}, \theta_{2} \in \Theta $, $\forall \alpha, \beta \geq 0$ s.t. $\alpha + \beta = 1$, we have \begin{align*} & \norm{\alpha S(u,\theta_{1}) + \beta S(u,\theta_{2}) - S(u,\alpha\theta_{1} + \beta\theta_{2})} \leq \alpha\beta\norm{S(u,\theta_{1}) - S(u,\theta_{2})}/(2(B + R)). \end{align*} \end{assumption} Essentially, this assumption requires that the distance between $S(u,\alpha\theta_{1} + \beta\theta_{2})$ and the convex combination of $S(u,\theta_{1})$ and $S(u,\theta_{2})$ shall be small when $S(u,\theta_{1})$ and $S(u,\theta_{2})$ are close. Actually, this assumption holds in many situations. We provide an example in supplementary material. Let $\theta^{*}$ be an optimal inference to $\min_{\theta \in \Theta}\frac{1}{T}\sum_{t \in [T]}l(\mfy_{t},\theta)$, i.e., an inference derived with the whole batch of observations available. Then, the following theorem asserts that $ R_{T} = \sum_{t \in [T]}(l(\mfy_{t},\theta_{t})- l(\mfy_{t},\theta^{*})) $ of the implicit online learning algorithm is of $ \mathcal{O}(\sqrt{T}) $. \begin{theorem}[Regret bound]\label{theorem : regret bound} Suppose Assumptions \ref{assumption:convex_setting} - \ref{assumption:convex-assumption} hold. Then, choosing $\eta_{t} = \frac{D\lambda}{2\sqrt{2}(B+R)\kappa}\frac{1}{\sqrt{t}}$, we have \begin{align*} R_{T} \leq \frac{4\sqrt{2}(B+R) D \kappa}{\lambda}\sqrt{T}. \end{align*} \end{theorem} \begin{remark} We establish of the above regret bound by extending Theorem 3.2. in \cite{kulis2010implicit}. Our extension involves several critical and complicated analyses for the structure of the optimal solution set $ S(u,\theta) $ as well as the loss function, which is essential to our theoretical understanding. Moreover, we relax the requirement of smoothness of loss function in that theorem to Lipschitz continuity through a similar argument in Lemma 1 of \cite{wang2017memory} and \cite{duchi2011}. \end{remark} By applying both the risk consistency result in Theorem 3 of \cite{aswani2016inverse} and the regret bound proved in Theorem \ref{theorem : regret bound}, we show the risk consistency of the online learning algorithm in the sense that the average cumulative loss converges in probability to the true risk in the batch setting. \begin{theorem}[Risk consistency]\label{theorem:risk consistency} Let $ \theta^{0} = \arg\min_{\theta \in \Theta}\{\bE \left[l(\mfy,u,\theta)\right]\} $ be the optimal solution that minimizes the true risk in batch setting. Suppose the conditions in Theorem \ref{theorem : regret bound} hold. If $ \bE [\mfy^{2}] < \infty $, then choosing $\eta_{t} = \frac{D\lambda}{2\sqrt{2}(B+R)\kappa}\frac{1}{\sqrt{t}}$, we have \begin{align*} \frac{1}{T}\sum_{t\in[T]}l(\mfy_{t},u_{t},\theta_{t}) \overset{p}{\longrightarrow} \bE \left[l(\mfy,u,\theta^{0})\right]. \end{align*} \end{theorem} \begin{corollary}\label{corollary:risk consistency} Suppose that the true parameter $ \theta_{true} \in \Theta $, and $ \mfy = \mfx + \epsilon $, where $ \mfx \in S(u,\theta_{true}) $ for some $ u \in \mathcal{U} $, $ \bE [\epsilon] = 0, \bE[\epsilon^{T}\epsilon] < \infty $, and $ u,\mfx $ are independent of $ \epsilon $. Let the conditions in Theorem \ref{theorem : regret bound} hold. Then choosing $\eta_{t} = \frac{D\lambda}{2\sqrt{2}(B+R)\kappa}\frac{1}{\sqrt{t}}$, we have \begin{align*} \frac{1}{T}\sum_{t\in[T]}l(\mfy_{t},u_{t},\theta_{t}) \overset{p}{\longrightarrow} \bE[\epsilon^{T}\epsilon]. \end{align*} \end{corollary} \begin{remark}\label{remark:consistency} $ (i) $ Theorem \ref{theorem:risk consistency} guarantees that the online learning algorithm proposed in this paper will asymptotically achieves the best prediction error permitted by the inverse model we consider. $ (ii) $ Corollary \ref{corollary:risk consistency} suggests that the prediction error is inevitable as long as the data carries noise. This prediction error, however, will be caused merely by the noisiness of the data in the long run. \end{remark} \section{Applications to learning problems in IOP} In this section, we will provide sketches of representative applications for inferring objective functions and constraints using the proposed online learning algorithm. Our preliminary experiments have been run on Bridges system at the Pittsburgh Supercomputing Center (PSC) \cite{Nystrom}. The mixed integer second order conic programs, which are derived from using KKT conditions in \eqref{update}, are solved by Gurobi. All the algorithms are programmed with Julia \cite{bezanson2017julia}. \subsection{Learning consumer behavior} \begin{figure*} \centering \begin{subfigure}[t]{0.33\textwidth} \includegraphics[width=\textwidth]{figure/qp_c_coldVswarm} \caption{} \label{fig:qp_c_coldVswarm} \end{subfigure} \begin{subfigure}[t]{0.28\textwidth} \includegraphics[width=\textwidth]{figure/qp_c_time} \caption{} \label{fig:qp_c_time} \end{subfigure} \begin{subfigure}[t]{0.33\textwidth} \includegraphics[width=\textwidth]{figure/qp_c_online_loss} \caption{} \label{fig:qp_c_online_loss} \end{subfigure} \caption{Learning the utility function over $T = 1000$ rounds. (a) We run $100$ repetitions of the experiments using Algorithm \ref{alg:online-iop} with two settings. \textbf{Cold-start} means that we initialize $ \mathbf{r} $ as a vector of zeros. \textbf{Warm-start} means that we initialize $ \mathbf{r} $ by solving the initialization problem \eqref{dis-qp} with the $ 1000 $ (price,noisy decision) pairs. We plot the estimation errors over round $ t $ in pink and brown for all the $100$ repetitions, respectively. We also plot the average estimation errors of the $100$ repetitions in red line and dashed brown line, respectively. (b) The dotted brown line is the error bar plot of the average running time over 10 repetitions in batch setting. The blue line is the error bar plot of the average running time over 100 repetitions in online setting. (c) We randomly pick one repetition. The loss over round is indicated by the dot. The average cumulative loss is indicated by the line. The dotted line is the reference line indicating the variance of the noise. Here, $ \mathbf{E}[\epsilon^{T}\epsilon] = 0.2083 $. } \label{fig:qp_c_online} \vspace{-10pt} \end{figure*} We now study the consumer's behavior problem in a market with $ n $ products. The prices for the products are denoted by $ \mfp_{t} \in \bR^{n}_{+} $ which varies over time $ t \in [T] $. We assume throughout that the consumer has a rational preference relation, and we take $ u $ to be the utility function representing these preferences. The consumer's decision making problem of choosing her most preferred consumption bundle $ \mfx $ given the price vector $ \mfp_{t} $ and budget $ b $ can be stated as the following utility maximization problem (UMP) \cite{mas1995microeconomic}. \begin{align*} \label{ump} \tag*{UMP} \begin{array}{rlll} \max\limits_{\mfx \in \bR_{+}^{n}} & u(\mfx) \vspace{1mm} \\ \;s.t. & \mfp^{T}_{t}\mfx \leq b, \end{array} \end{align*} where $ \mfp^{T}_{t}\mfx \leq b $ is the budget constraint at time $ t $. For this application, we will consider a concave quadratic representation for $ u(\mfx) $. That is, $ u(\mfx) = \frac{1}{2}\mfx^{T}Q\mfx + \mathbf{r}^{T}\mfx $, where $ Q \in \mathbf{S}^{n}_{-} $ (the set of symmetric negative semidefinite matrices), $ \mathbf{r} \in \bR^{n}$. We consider a problem with $ n = 10 $ products, and the budget $ b = 40 $. $ Q $ and $ \mathbf{r} $ are randomly generated and are given in supplementary material. Suppose the prices are changing in $T$ rounds. In each round, the learner would receive one (price,noisy decision) pair $ (\mfp_{t},\mfy_{t}) $. Her goal is to learn the utility function or budget of the consumer. The (price,noisy decision) pair in each round is generated as follows. In round $t$, we generate the prices from a uniform distribution, i.e. $ p_{i}^{t} \sim U[p_{min},p_{max}] $, with $ p_{min} = 5 $ and $ p_{max} = 25 $. Then, we solve \ref{ump} and get the optimal decision $ \mfx_{t} $. Next, the noisy decision $\mfy_{t}$ is obtained by corrupting $ \mfx_{t} $ with noise that has a jointly uniform distribution with support $[-0.25,0.25]^{2}$. Namely, $\mfy_{t} = \mfx_{t} + \epsilon_{t}$, where each element of $\epsilon_{t} \sim U(-0.25,0.25)$. \textbf{Learning the utility function}\;\; In the first set of experiments, the learner seeks to learn $ \mathbf{r} $ given $ \{(\mfp_{t},\mfy_{t})\}_{t\in[T]} $ that arrives sequentially in $ T = 1000 $ rounds. We assume that $\mathbf{r}$ is within $[0,5]^{10}$. The learning rate is set to $\eta_{t} = 5/\sqrt{t}$. Then, we implement Algorithm \ref{alg:online-iop} with two settings. We report our results in Figure \ref{fig:qp_c_online}. As can be seen in Figure \ref{fig:qp_c_coldVswarm}, solving the initialization problem provides quite good initialized estimations of $ \mathbf{r} $, and Algorithm \ref{alg:online-iop} with Warm-start converges faster than that with Cold-start. Note that \eqref{dis-qp} is a convex program and the time to solve it is negligible in Algorithm \ref{alg:online-iop}. Thus, the running times with and without Warm-start are roughly the same. This suggests that one might prefer to use Algorithm \ref{alg:online-iop} with Warm-start if she wants to get a relatively good estimation of the parameters in few iterations. However, as shown in the figure, both settings would return very similar estimations on $ \mathbf{r} $ in the long run. To keep consistency, we would use Algorithm \ref{alg:online-iop} with Cold-start in the remaining experiments. We can also see that estimation errors over rounds for different repetitions concentrate around the average, indicating that our algorithm is pretty robust to noises. Moreover, Figure \ref{fig:qp_c_time} shows that inverse optimization in online setting is drastically faster than in batch setting. This also suggests that windowing approach for inverse optimization might be practically infeasible since it fails even with a small subset of data, such as window size equals to $ 10 $. We then randomly pick one repetition and plot the loss over round and the average cumulative loss in Figure \ref{fig:qp_c_online_loss}. We see clearly that the average cumulative loss asymptotically converges to the variance of the noise. This makes sense because the loss merely reflects the noise in the data when the estimation converges to the true value as stated in Remark \ref{remark:consistency}. \begin{figure*} \centering \begin{subfigure}[t]{0.33\textwidth} \includegraphics[width=\textwidth]{figure/qp_b_online_error} \caption{} \label{fig:qp_b_online_error} \end{subfigure} \begin{subfigure}[t]{0.27\textwidth} \includegraphics[width=\textwidth]{figure/qp_b_time} \caption{} \label{fig:qp_b_time} \end{subfigure} \begin{subfigure}[t]{0.33\textwidth} \includegraphics[width=\textwidth]{figure/qp_b_online_loss} \caption{} \label{fig:qp_b_online_loss} \end{subfigure} \caption{Learning the budget over $T = 1000$ rounds. (a) We run $100$ repetitions of the experiments. We plot the estimation error over round $ t $ for all the $100$ repetitions in pink. We also plot the average estimation error of the $100$ repetitions in red. (b) The dotted brown line is the error bar plot of the average running time over 10 repetitions in batch setting. The blue line is the error bar plot of the average running time over 100 repetitions in online setting. (c) We randomly pick one repetition. The loss over round is indicated by the dot. The average cumulative loss is indicated by the line. The dotted line is the reference line indicating the variance of the noise. Here, $ \mathbf{E}[\epsilon^{T}\epsilon] = 0.2083 $. } \label{fig:qp_b_online} \vspace{-10pt} \end{figure*} \textbf{Learning the budget}\;\; In the second set of experiments, the learner seeks to learn the budget $ b $ in $ T = 1000 $ rounds. We assume that $b$ is within $[0,100]$. The learning rate is set to $\eta_{t} = 100/\sqrt{t}$. Then, we apply Algorithm \ref{alg:online-iop} with Cold-start. We show the results in Figure \ref{fig:qp_b_online}. All the analysis for the results in learning the utility function apply here. One thing to emphasize is that learning the budget is much faster than learning the utility function, as shown in Figure \ref{fig:qp_c_time} and \ref{fig:qp_b_time}. The main reason is that the budget $ \mfb $ is a one dimensional vector, while the utility vector $ \mathbf{r} $ is a ten dimensional vector, making it drastically more complex to solve \eqref{update}. \subsection{Learning the transportation cost} We now consider the transshipment network $ G = (V_{s}\cup V_{d},E) $, where nodes $ V_{s} $ are producers and the remaining nodes $ V_{d} $ are consumers. The production level is $ y_{v} $ for node $ v \in V_{s} $, and has a maximum capacity of $ w_{v} $. The demand level is $ d_{v}^{t} $ for node $ v \in V_{s} $ and varies over time $ t \in [T] $. We assume that producing $ y_{v} $ incurs a cost of $ C^{v}(y_{v}) $ for node $ v \in V_{s} $; furthermore, we also assume that there is a transportation cost $ c_{e}x_{e} $ associated with edge $ e\in E $, and the flow $ x_{e} $ has a maximum capacity of $ u_{e} $. The transshipment problem can be formulated in the following: \begin{align*} \label{mcf} \tag*{TP} \begin{array}{rlll} \min & \sum\limits_{v \in V_{s}} C^{v}(y_{v}) + \sum\limits_{e \in E}c_{e}x_{e} \vspace{1mm} \\ \;s.t. & \sum\limits_{e \in \delta^{+}(v)} x_{e} - \sum\limits_{e \in \delta^{-}(v)} x_{e} = y_{v}, & \forall v \in V_{s},\vspace{1mm} \\ & \sum\limits_{e \in \delta^{+}(v)} x_{e} - \sum\limits_{e \in \delta^{-}(v)} x_{e} = d_{v}^{t}, & \forall v \in V_{d},\vspace{1mm} \\ & 0 \leq x_{e} \leq u_{e},\;\; 0 \leq y_{v} \leq w_{v}, & \forall e \in E, \forall v \in V_{s}, \end{array} \end{align*} where we want to learn the transportation cost $ c_{e} $ for $ e \in E $. For this application, we will consider a convex quadratic cost for $ C^{v}(y_{v}) $. That is, $ C^{v}(y_{v}) = \frac{1}{2}\lambda_{v}y_{v}^2$, where $ \lambda_{v} \geq 0 $. We create instances of the problem based on the network in Figure \ref{fig:network}. $ \lambda_{1}, \lambda_{2} $, $ \{u_{e}\}_{e \in E} $, $ \{w_{v}\}_{v \in V_{s}} $ and the randomly generated $ \{c_{e}\}_{e \in E} $ are given in supplementary material. In each round, the learner would receive the demands $ \{d_{v}^{t}\}_{v \in V_{d}} $, the production levels $ \{y_{v}\}_{v \in V_{s}} $ and the flows $ \{x_{e}\}_{e \in E} $, where the later two are corrupted by noises. In round $t$, we generate the $ d_{v}^{t} $ for $ v \in V_{d} $ from a uniform distribution, i.e. $ d_{v}^{t} \sim U[-1.25,0] $. Then, we solve \ref{mcf} and get the optimal production levels and flows. Next, the noisy production levels and flows are obtained by corrupting the optimal ones with noise that has a jointly uniform distribution with support $[-0.25,0.25]^{8}$. Suppose the transportation cost on edge $ (2,3) $ and $ (2,5) $ are unknown, and the learner seeks to learn them given the (demand,noisy decision) pairs that arrive sequentially in $ T = 1000 $ rounds. We assume that $c_{e}$ for $ e \in E $ is within $[1,10]$. The learning rate is set to $\eta_{t} = 2/\sqrt{t}$. Then, we implement Algorithm \ref{alg:online-iop} with Cold-start. Figure \ref{fig:trans_c_online_error} shows the estimation error of $c$ in each round over the $100$ repetitions. We also plot the average estimation error of the $100$ repetitions. As shown in this figure, $ c_{t} $ asymptotically converges to the true transportation cost $ c_{ture} $ pretty fast. Also. estimation errors over rounds for different repetitions concentrate around the average, indicating that our algorithm is pretty robust to noises. We then randomly pick one repetition and plot the loss over round and the average cumulative loss in Figure \ref{fig:trans_c_online_loss}. Note that the variance of the noise $ \mathbf{E}[\epsilon^{T}\epsilon] = 0.1667 $. We can see that the average cumulative loss asymptotically converges to the variance of the noise. \begin{figure*} \centering \begin{subfigure}[t]{0.25\textwidth} \includegraphics[width=\textwidth]{figure/network} \caption{} \label{fig:network} \end{subfigure} \begin{subfigure}[t]{0.33\textwidth} \includegraphics[width=\textwidth]{figure/trans_c_online_error} \caption{} \label{fig:trans_c_online_error} \end{subfigure} \begin{subfigure}[t]{0.34\textwidth} \includegraphics[width=\textwidth]{figure/trans_c_online_loss} \caption{} \label{fig:trans_c_online_loss} \end{subfigure}\hspace{10mm} \caption{Learning the transportation cost over $T = 1000$ rounds. (a) We plot the five-node network in our experiment. (b) Denote $ c \in \bR^{|E|} $ the vector of transportation costs. We run $100$ repetitions of the experiments. We plot the estimation error at each round $ t $ for all the $100$ experiments. We also plot the average estimation error of the $100$ repetitions. (c) We randomly pick one repetition. The loss over round is indicated by the dot. The average cumulative loss is indicated by the line. The dotted line is the reference line indicating the variance of the noise. Here, $ \mathbf{E}[\epsilon^{T}\epsilon] = 0.1667 $. } \label{fig:trans_online} \vspace{-15pt} \end{figure*} \section{Conclustions and final remarks} In this paper, an online learning method to infer preferences or restrictions from noisy observations is developed and implemented. We prove a regret bound for the implicit online learning algorithm under certain regularity conditions, and show the algorithm is statistically consistent, which guarantees that our algorithm will asymptotically achieves the best prediction error permitted by the inverse model. Finally, we illustrate the performance of our learning method on both a consumer behavior problem and a transshipment problem. Results show that our algorithm can learn the parameters with great accuracy and is very robust to noises, and achieves drastic improvement in computational efficacy over the batch learning approach. \subsubsection*{Acknowledgments} This work was partially supported by CMMI-1642514 from the National Science Foundation. This work used the Bridges system, which is supported by NSF award number ACI-1445606, at the Pittsburgh Supercomputing Center (PSC). \bibliographystyle{unsrt}
{'timestamp': '2018-11-05T02:17:55', 'yymm': '1810', 'arxiv_id': '1810.01920', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01920'}
arxiv
\section{Introduction} Efforts to explain the effectiveness of gradient descent in deep learning have uncovered an exciting possibility: it not only finds solutions with low error, but also biases the search for low complexity solutions which generalize well \citep{rethinking,spectrally_normalized,nati_iclr,nati_nips}. This paper analyzes the implicit regularization of gradient descent and gradient flow on deep linear networks and linearly separable data. For strictly decreasing losses, the optimum is at infinity, and we establish various \emph{alignment phenomena}: \begin{itemize} \item For each weight matrix $W_i$, the corresponding normalized weight matrix $\nicefrac{W_i}{\|W_i\|_F}$ asymptotically equals its rank-$1$ approximation $u_iv_i^\top$, where the Frobenius norm $\|W_i\|_F$ satisfies $\|W_i\|_F\to\infty$. In other words, $\nicefrac{\|W_i\|_2 }{ \|W_i\|_F } \to 1$, and asymptotically only the rank-$1$ approximation of $W_i$ contributes to the final predictor, a form of implicit regularization. \item Adjacent rank-$1$ weight matrix approximations are aligned: $|v_{i+1}^\top{}u_i| \to 1$. \item For the logistic loss, the first right singular vector $v_1$ of $W_1$ is aligned with the data, meaning $v_1$ converges to the unique maximum margin predictor $\bar u$ defined by the data. Moreover, the linear predictor induced by the network, $w_{\mathrm{prod}} := W_L\cdots W_1$, is also aligned with the data, meaning $\nicefrac{w_{\mathrm{prod}} }{ \|w_{\mathrm{prod}}\| }\to \bar u$. \end{itemize} Simultaneously, this work proves that the risk is globally optimized: it asymptotes to 0. Alignment and risk convergence are proved simultaneously; the phenomena are coupled within the proofs. Since the layers align, they can be viewed as a \emph{minimum norm solution}: they do not ``waste norm'' on components which are killed off when the layers are multiplied together. Said another way, given data $((x_i,y_i))_{i=1}^n$, the normalized matrices $(\nicefrac {W_1}{\|W_1\|_F}, \ldots, \nicefrac{W_L}{\|W_L\|_F})$ asymptotically solve a maximum margin problem which demands \emph{all} weight matrices be small, not merely their product: \[ \max_{\substack{W_L \in \R^{1\times d_{L-1}}\\ \|W_L\|_F = 1}} \cdots \max_{\substack{W_1 \in \R^{d_1\times d_0}\\ \|W_1\|_F = 1}} \quad \min_i y_i(W_L \cdots W_1)x_i. \] \begin{figure}[h!] \centering \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{mn6__d} \caption{Margin maximization.\label{fig:maxmarg}} \end{subfigure} \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{mn6__d__mod1__sr} \caption{Alignment and risk minimization.\label{fig:align}} \end{subfigure} \caption{Visualization of margin maximization and self-regularization of layers on synthetic data with a $4$-layer linear network compared to a $1$-layer network (a linear predictor). \Cref{fig:maxmarg} shows the convergence of $1$-layer and $4$-layer networks to the same margin-maximizing linear predictor on positive (blue) and negative (red) separable data. \Cref{fig:align} shows the convergence of $\|W_i\|_2/\|W_i\|_F$ to 1 on each layer, plotted against the risk. } \label{fig:intro:margin_dists} \end{figure} The paper is organized as follows. This introduction continues with related work, notation, and assumptions in \Cref{sec:related,sec:notation}. The analysis of gradient flow is in \Cref{sec:gf}, and gradient descent is analyzed in \Cref{sec:gd}. The paper closes with future directions in \Cref{sec:future}; a particular highlight is a preliminary experiment on CIFAR-10 which establishes empirically that a form of the alignment phenomenon occurs on the standard nonlinear network AlexNet. \begin{figure}[h!] \centering \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{j3__1vs4layers__d0_d1} \caption{Overall margin maximization.\label{fig:il}} \end{subfigure} \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{j3__W4__layer0} \caption{Margin maximization at layer 1.\label{fig:il:0}} \end{subfigure} \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{j3__W4__layer1} \caption{Margin maximization at layer 2.\label{fig:il:1}} \end{subfigure} \begin{subfigure}[b]{0.495\textwidth} \includegraphics[width = 1.0\textwidth]{j3__W4__layer2} \caption{Margin maximization at layer 3.\label{fig:il:2}} \end{subfigure} \caption{A visualization of inter-layer alignment on data consisting of two well-separated circles with a 3-layer linear network. \Cref{fig:il} depicts, as in \Cref{fig:maxmarg}, that optimizing 1- and 3-layer linear networks finds the same maximum margin solution. The other three plots show the data as it is mapped through progressively more and more layers. Due to alignment, the product $W_i\cdots{}W_1$ becomes $u_i\bar{u}^\top$, where $u_i$ is the top left singular vector of $W_i$, which means that asymptotically the mapped data will be well separated and lie along the span of $u_i$, as depicted by the flattening in \Cref{fig:il:0,fig:il:1,fig:il:2}. Additionally, these three subfigures show that the top right singular vector $v_{i+1}$ of the subsequent layer is aligned with this $u_i$, which in these plots (with principal component axes) corresponds to following a horizontal line. } \label{fig:interlayer_align} \end{figure} \subsection{Related work} \label{sec:related} On the implicit regularization of gradient descent, \citet{nati_iclr} show that for linear predictors and linearly separable data, the gradient descent iterates converge to the same direction as the maximum margin solution. \citet{ours} further characterize such an implicit bias for general nonseparable data. \citet{nati_nips} consider gradient descent on fully connected linear networks and linear convolutional networks. In particular, for the exponential loss, assuming the risk is minimized to $0$ and the gradients converge in direction, they show that the whole network converges in direction to the maximum margin solution. These two assumptions are on the gradient descent process itself, and specifically the second one might be hard to interpret and justify. Compared with \citet{nati_nips}, this paper \emph{proves} that the risk converges to $0$ and the weight matrices align; moreover the proof here proves the properties simultaneously, rather than assuming one and deriving the other. Lastly, \citet{arora_icml} show for deep linear networks (and later \citet{jason_nips} for ReLU networks) that gradient flow does not change the difference between squared Frobenius norms of any two layers. We use a few of these tools in our proofs; please see \Cref{sec:gf,sec:gd} for details. For a smooth (nonconvex) function, \citet{jason_gd} show that any strict saddle can be avoided almost surely with small step sizes. If there are only countably many saddle points and they are all strict, and if gradient descent iterates converge, then this implies (almost surely) they converge to a local minimum. In the present work, since there is no finite local minimum, gradient descent will go to infinity and never converge, and thus these results of \citet{jason_gd} do not show that the risk converges to $0$. There has been a rich literature on linear networks. \citet{saxe} analyze the learning dynamics of deep linear networks, showing that they exhibit some learning patterns similar to nonlinear networks, such as a long plateau followed by a rapid risk drop. \citet{arora_icml} show that depth can help accelerate optimization. On the landscape properties of deep linear networks, \citet{kawaguchi,laurent_icml} show that under various structural assumptions, all local optima are global. \citet{zhou_iclr} give a necessary and sufficient characterization of critical points for deep linear networks. \subsection{Notation, setting, and assumptions} \label{sec:notation} Consider a data set $\{(x_i,y_i)\}_{i=1}^n$, where $x_i\in \mathbb{R}^d$, $\|x_i\|\le1$, and $y_i\in\{-1,+1\}$. The data set is assumed to be linearly separable, i.e., there exists a unit vector $u$ which correctly classifies every data point: for any $1\le i\le n$, $y_i\langle u,x_i\rangle>0$. Furthermore, let $\gamma:=\max_{\|u\|=1}\min_{1\le i\le n}y_i\langle u,x_i\rangle>0$ denote the maximum margin, and $\bar{u} := \argmax_{\|u\|=1}\min_{1\le i\le n}y_i\langle u,x_i\rangle$ denote the maximum margin solution (the solution to the hard-margin SVM). A linear network of depth $L$ is parameterized by weight matrices $W_L,\ldots,W_1$, where $W_k\in \mathbb{R}^{d_k\times d_{k-1}}$, $d_0=d$, and $d_L=1$. Let $W=(W_L,\ldots,W_1)$ denote all parameters of the network. The (empirical) risk induced by the network is given by \begin{equation*} \mathcal{R}(W)=\mathcal{R}\del{W_L,\ldots,W_1}=\frac{1}{n}\sum_{i=1}^{n}\ell\del{y_iW_L\cdots W_1x_i}=\frac{1}{n}\sum_{i=1}^{n}\ell\del{\langlew_{\mathrm{prod}},z_i\rangle}, \end{equation*} where $w_{\mathrm{prod}} := (W_L\cdots W_1)^{\top}$, and $z_i:=y_ix_i$. The loss $\ell$ is assumed to be continuously differentiable, unbounded, and strictly decreasing to $0$. Examples include the exponential loss $\ell_{\exp}(x)=e^{-x}$ and the logistic loss $\ell_{\log}(x)=\ln\del{1+e^{-x}}$. \begin{assumption}\label{ass:loss} $\ell'<0$ is continuous, $\lim_{x\to-\infty}\ell(x)=\infty$ and $\lim_{x\to\infty}\ell(x)=0$. \end{assumption} This paper considers gradient flow and gradient descent, where gradient flow $\cbr{W(t)\middle|t\ge0,t\in \mathbb{R}}$ can be interpreted as gradient descent with infinitesimal step sizes. It starts from some $W(0)$ at $t=0$, and proceeds as \begin{equation*} \frac{\dif W(t)}{\dif t}=-\nabla\cR\del{W(t)}. \end{equation*} By contrast, gradient descent $\cbr{W(t)\middle|t\ge0,t\in \mathbb{Z}}$ is a discrete-time process given by \begin{equation*} W(t+1)=W(t)-\eta_t\nabla\cR\del{W(t)}, \end{equation*} where $\eta_t$ is the step size at time $t$. We assume that the initialization of the network is not a critical point and induces a risk no larger than the risk of the trivial linear predictor $0$. \begin{assumption}\label{ass:init} The initialization $W(0)$ satisfies $\nabla\cR\del{W(0)}\ne0$ and $\mathcal{R}\del{W(0)}\le\mathcal{R}(0)=\ell(0)$. \end{assumption} It is natural to require that the initialization is not a critical point, since otherwise gradient flow/descent will never make a progress. The requirement $\mathcal{R}\del{W(0)}\le\mathcal{R}(0)$ can be easily satisfied, for example, by making $W_1(0)=0$ and $W_L(0)\cdots W_2(0)\ne0$. On the other hand, if $\mathcal{R}\del{W(0)}>\mathcal{R}(0)$, gradient flow/descent may never minimize the risk to $0$. Proofs of those claims are given in \Cref{sec:notation_app}. \section{Results for gradient flow}\label{sec:gf} In this section, we consider gradient flow. Although impractical when compared with gradient descent, gradient flow can simplify the analysis and highlight proof ideas. For convenience, we usually use $W$, $W_k$, and $w_{\mathrm{prod}}$, but they all change with (the continuous time) $t$. Only proof sketches are given here; detailed proofs are deferred to \Cref{sec:gf_app}. \subsection{Risk convergence} One key property of gradient flow is that it never increases the risk: \begin{equation}\label{eq:gf_risk_no_inc} \frac{\dif\mathcal{R}(W)}{\dif t}=\left\langle\nabla\cR(W),\frac{\dif W}{\dif t}\right\rangle=-\|\nabla\cR(W)\|^2=-\sum_{k=1}^{L}\enVert{\frac{\partial\mathcal{R}}{\partial W_k}}_F^2\le0. \end{equation} We now state the main result: under \Cref{ass:loss,ass:init}, gradient flow minimizes the risk, $W_k$ and $w_{\mathrm{prod}}$ all go to infinity, and the alignment phenomenon occurs. \begin{theorem}\label{thm:gf_risk} Under \Cref{ass:loss,ass:init}, gradient flow iterates satisfy the following properties: \begin{itemize} \item $\lim_{t\to\infty}\mathcal{R}(W)=0$. \item For any $1\le k\le L$, $\lim_{t\to\infty}\|W_k\|_F=\infty$. \item For any $1\le k\le L$, letting $(u_k,v_k)$ denote the first left and right singular vectors of $W_k$, \begin{equation*} \lim_{t\to\infty}\enVert{\frac{W_k}{\|W_k\|_F}-u_kv_k^{\top}}_F=0. \end{equation*} Moreover, for any $1\le k<L$, $\lim_{t\to\infty}\envert{\langle v_{k+1},u_k\rangle}=1$. As a result, \begin{equation*} \lim_{t\to\infty}\envert{\left\langle \frac{w_{\mathrm{prod}}}{\prod_{k=1}^L\|W_k\|_F},v_1\right\rangle}=1, \end{equation*} and thus $\lim_{t\to\infty}\|w_{\mathrm{prod}}\|=\infty$. \end{itemize} \end{theorem} \Cref{thm:gf_risk} is proved using two lemmas, which may be of independent interest. To show the ideas, let us first introduce a little more notation. Recall that $\mathcal{R}(W)$ denotes the empirical risk induced by the deep linear network $W$. Abusing the notation a little, for any linear predictor $w\in \mathbb{R}^d$, we also use $\mathcal{R}(w)$ to denote the risk induced by $w$. With this notation, $\mathcal{R}(W)=\mathcal{R}(w_{\mathrm{prod}})$, while \begin{equation*} \nabla\cR(w_{\mathrm{prod}})=\frac{1}{n}\sum_{i=1}^{n}\ell'\del{\langlew_{\mathrm{prod}},z_i\rangle}z_i=\frac{1}{n}\sum_{i=1}^{n}\ell'\del{W_L\cdots W_1z_i}z_i \end{equation*} is in $\mathbb{R}^{d}$ and different from $\nabla\cR(W)$, which has $\sum_{k=1}^{L}d_{k}d_{k-1}$ entries, as given below: \begin{equation*} \frac{\partial\mathcal{R}}{\partial W_k}=W_{k+1}^{\top}\cdots W_L^{\top}\nabla\cR(w_{\mathrm{prod}})^{\top}W_1^{\top}\cdots W_{k-1}^{\top}. \end{equation*} Furthermore, for any $R>0$, let \begin{equation*} B(R)=\cbr{W\middle|\max_{1\le k\le L}\|W_k\|_F\le R}. \end{equation*} The first lemma shows that for any $R>0$, the time spent by gradient flow in $B(R)$ is finite. \begin{lemma}\label{lem:gf_unbounded} Under \Cref{ass:loss} and \ref{ass:init}, for any $R>0$, there exists a constant $\epsilon(R)>0$, such that for any $t\ge1$ and any $W\in B(R)$, $\|\partial\mathcal{R}/\partial W_1\|_F\ge\epsilon(R)$. As a result, gradient flow spends a finite amount of time in $B(R)$ for any $R>0$, and $\max_{1\le k\le L}\|W_k\|_F$ is unbounded. \end{lemma} Here is the proof sketch. If $\|W_k\|_F$ are bounded, then $\|\nabla\cR(w_{\mathrm{prod}})\|$ will be lower bounded by a positive constant, therefore if $\|\partial\mathcal{R}/\partial W_1\|_F=\|W_L\cdots W_2\|\|\nabla\cR(w_{\mathrm{prod}})\|$ can be arbitrarily small, then $\|W_L\cdots W_2\|$ and $\|w_{\mathrm{prod}}\|$ can also be arbitrarily small, and thus $\mathcal{R}(W)$ can be arbitrarily close to $\mathcal{R}(0)$. This cannot happen after $t=1$, otherwise it will contradict \Cref{ass:init} and \cref{eq:gf_risk_no_inc}. To proceed, we need the following properties of linear networks from prior work \citep{arora_icml,jason_nips}. For any time $t\ge0$ and any $1\le k<L$, \begin{equation}\label{eq:gf_lnn_spec} W_{k+1}^{\top}(t)W_{k+1}(t)-W_{k+1}^{\top}(0)W_{k+1}(0)=W_k(t)W_k^{\top}(t)-W_k(0)W_k^{\top}(0). \end{equation} To see this, just notice that \begin{equation*} W_{k+1}^{\top}\frac{\partial\mathcal{R}}{\partial W_{k+1}}=W_{k+1}^{\top}\cdots W_L^{\top}\nabla\cR(w_{\mathrm{prod}})^{\top}W_1^{\top}\cdots W_k^{\top}=\frac{\partial\mathcal{R}}{\partial W_k}W_k^{\top}. \end{equation*} Taking the trace on both sides of \cref{eq:gf_lnn_spec}, we have \begin{equation}\label{eq:gf_lnn_norm} \enVert{W_{k+1}(t)}_F^2-\enVert{W_{k+1}(0)}_F^2=\enVert{W_k(t)}_F^2-\enVert{W_k(0)}_F^2. \end{equation} In other words, the difference between the squares of Frobenius norms of any two layers remains a constant. Together with \Cref{lem:gf_unbounded}, it implies that all $\|W_k\|_F$ are unbounded. However, even if $\|W_k\|_F$ are large, it does not follow necessarily that $\|w_{\mathrm{prod}}\|$ is also large. \Cref{lem:gf_align} shows that this is indeed true: for gradient flow, as $\|W_k\|_F$ get larger, adjacent layers also get more aligned to each other, which ensures that their product also has a large norm. For $1\le k\le L$, let $\sigma_k$, $u_k$, and $v_k$ denote the first singular value (the $2$-norm), the first left singular vector, and the first right singular vector of $W_k$, respectively. Furthermore, define \begin{align*} D &:=\del{\max_{1\le k\le L}\|W_k(0)\|_F^2}-\|W_L(0)\|_F^2+\sum_{k=1}^{L-1}\enVert{W_k(0)W_k^{\top}(0)-W_{k+1}^{\top}(0)W_{k+1}(0)}_2, \end{align*} which depends only on the initialization. If for any $1\le k<L$, $W_k(0)W_k^{\top}(0)=W_{k+1}^{\top}(0)W_{k+1}(0)$, then $D=0$. \begin{lemma}\label{lem:gf_align} The gradient flow iterates satisfy the following properties: \begin{itemize} \item For any $1\le k\le L$, $\|W_k\|_F^2-\|W_k\|_2^2\le D$. \item For any $1\le k<L$, $\langle v_{k+1},u_k\rangle^2\ge1-\nicefrac{\del[1]{D+\|W_{k+1}(0)\|_2^2+\|W_k(0)\|_2^2}}{\|W_{k+1}\|_2^2}$. \item Suppose $\max_{1\le k\le L}\|W_k\|_F\to\infty$, then $\envert{\left\langle \nicefrac{w_{\mathrm{prod}}}{\prod_{k=1}^{L}\|W_k\|_F}, v_1\right\rangle}\to1$. \end{itemize} \end{lemma} The proof is based on \cref{eq:gf_lnn_spec} and \cref{eq:gf_lnn_norm}. If $W_k(0)W_k^{\top}(0)=W_{k+1}^{\top}(0)W_{k+1}(0)$, then \cref{eq:gf_lnn_spec} gives that $W_{k+1}$ and $W_k$ have the same singular values, and $W_{k+1}$'s right singular vectors and $W_k$'s left singular vectors are the same. If it is true for any two adjacent layers, since $W_L$ is a row vector, all layers have rank $1$. With general initialization, we have similar results when $\|W_k\|_F$ is large enough so that the initialization is negligible. Careful calculations give the exact results in \Cref{lem:gf_align}. An interesting point is that the implicit regularization result in \Cref{lem:gf_align} helps establish risk convergence in \Cref{thm:gf_risk}. Specifically, by \Cref{lem:gf_align}, if all layers have large norms, $\|W_L\cdots W_2\|$ will be large. If the risk is not minimized to $0$, $\|\nabla\cR(w_{\mathrm{prod}})\|$ will be lower bounded by a positive constant, and thus $\|\partial\mathcal{R}/\partial W_1\|_F=\|W_L\cdots W_2\|\|\nabla\cR(w_{\mathrm{prod}})\|$ will be large. Invoking \cref{eq:gf_risk_no_inc}, \Cref{lem:gf_unbounded} and \cref{eq:gf_lnn_norm} gives a contradiction. Since the risk has no finite optimum, $\|W_k\|_F\to\infty$. \subsection{Convergence to the maximum margin solution} Here we focus on the exponential loss $\ell_{\exp}(x)=e^{-x}$ and the logistic loss $\ell_{\log}(x)=\ln(1+e^{-x})$. In addition to risk convergence, these two losses also enable gradient descent to find the maximum margin solution. To get such a strong convergence, we need one more assumption on the data set. Recall that $\gamma=\max_{\|u\|=1}\min_{1\le i\le n}\langle u,z_i\rangle>0$ denotes the maximum margin, and $\bar{u}$ denotes the unique maximum margin predictor which attains this margin $\gamma$. Those data points $z_i$ for which $\langle\bar{u},z_i\rangle=\gamma$ are called support vectors. \begin{assumption}\label{ass:data} The support vectors span the whole space $\mathbb{R}^d$. \end{assumption} \Cref{ass:data} appears in prior work \citet{nati_iclr}, and can be satisfied in many cases: for example, it is almost surely true if the number of support vectors is larger than or equal to $d$ and the data set is sampled from some density w.r.t. the Lebesgue measure. It can also be relaxed to the situation that the support vectors and the whole data set span the same space; in this case $\nabla\cR(w_{\mathrm{prod}})$ will never leave this space, and we can always restrict our attention to this space. With \Cref{ass:data}, we can state the main theorem. \begin{theorem}\label{thm:gf_min_norm} Under \Cref{ass:init,ass:data}, for almost all data and for losses $\ell_{\exp}$ and $\ell_{\log}$, then $\lim_{t\to\infty}\envert{\langle v_1,\bar{u}\rangle}=1$, where $v_1$ is the first right singular vector of $W_1$. As a result, $\lim_{t\to\infty}\nicefrac{w_{\mathrm{prod}}}{\prod_{k=1}^L\|W_k\|_F}=\bar{u}$. \end{theorem} Before summarizing the proof, we can simplify both theorems into the following \emph{minimum norm} property mentioned in the introduction. \begin{corollary} \label{fact:gf_min_norm_2} Under \Cref{ass:init,ass:data}, for almost all data and for losses $\ell_{\exp}$ and $\ell_{\log}$, \[ \min_i y_i \del{ \frac {W_L}{\|W_L\|_F} \cdots \frac {W_1}{\|W_1\|_F} } x_i \quad\xrightarrow[t\to\infty]{}\quad \max_{\substack{A_L \in \R^{1 \times d_{L-1}}\\\|A_L\|_F = 1}} \cdots \max_{\substack{A_1 \in \R^{d_1 \times d_0}\\\|A_1\|_F = 1}} \min_i y_i \del{ A_L \cdots A_1 } x_i. \] \end{corollary} \Cref{thm:gf_min_norm} relies on two structural lemmas. The first one is based on a similar almost-all argument due to \citet[Lemma 12]{nati_iclr}. Let $S\subset\{1,\ldots,n\}$ denote the set of indices of support vectors. \begin{lemma}\label{lem:strong_conv} Under \Cref{ass:data}, if the data set is sampled from some density w.r.t. the Lebesgue measure, then with probability $1$, \begin{equation*} \alpha:=\min_{|\xi|=1,\xi\perp\bar{u}}\max_{i\in S}\langle\xi,z_i\rangle>0. \end{equation*} \end{lemma} Let $\bar{u}^{\perp}$ denote the orthogonal complement of $\mathrm{span}(\bar{u})$, and let $\Pi_{\perp}$ denote the projection onto $\bar{u}^{\perp}$. We prove that if $\|\Pi_{\perp}w\|$ is large enough, gradient flow starting from $w$ will tend to decrease $\|\Pi_{\perp}w\|$. \begin{lemma}\label{lem:perp_bound} Under \Cref{ass:data}, for almost all data, $\ell_{\exp}$ and $\ell_{\log}$, and any $w\in \mathbb{R}^d$, if $\langle w,\bar{u}\rangle\ge0$ and $\|\Pi_{\perp}w\|$ is larger than $\nicefrac{1+\ln(n)}{\alpha}$ for $\ell_{\exp}$ or $\nicefrac{2n}{e\alpha}$ for $\ell_{\log}$, then $\langle \Pi_{\perp}w,\nabla\cR(w)\rangle\ge0$. \end{lemma} With \Cref{lem:strong_conv} and \Cref{lem:perp_bound} in hand, we can prove \Cref{thm:gf_min_norm}. Let $\Pi_{\perp}W_1$ denote the projection of rows of $W_1$ onto $\bar{u}^{\perp}$. Notice that \begin{equation*} \Pi_{\perp}w_{\mathrm{prod}}=\del{W_L\ldots W_2(\Pi_{\perp}W_1)}^{\top}\quad\textrm{and}\quad \frac{\dif\|\Pi_{\perp}W_1\|_F^2}{\dif t}=-2\langle\Pi_{\perp}w_{\mathrm{prod}},\nabla\cR(w_{\mathrm{prod}})\rangle. \end{equation*} If $\|\Pi_{\perp}W_1\|_F$ is large compared with $\|W_1\|_F$, since layers become aligned, $\|\Pi_{\perp}w_{\mathrm{prod}}\|$ will also be large, and then \Cref{lem:perp_bound} implies that $\|\Pi_{\perp}W_1\|_F$ will not increase. At the same time, $\|W_1\|_F\to\infty$, and thus for large enough $t$, $\|\Pi_{\perp}W_1\|_F$ must be very small compared with $\|W_1\|_F$. Many details need to be handled to make this intuition exact; the proof is given in \Cref{sec:gf_app}. \section{Results for gradient descent}\label{sec:gd} One key property of gradient flow which is used in the previous proofs is that it never increases the risk, which is not necessarily true for gradient descent. However, for smooth losses (i.e, with Lipschitz continuous derivatives), we can design some decaying step sizes, with which gradient descent never increases the risk, and basically the same results hold as in the gradient flow case. Deferred proofs are given in \Cref{sec:gd_app}. We make the following additional assumption on the loss, which is satisfied by the logistic loss $\ell_{\log}$. \begin{assumption}\label{ass:smooth} $\ell'$ is $\beta$-Lipschitz (i.e, $\ell$ is $\beta$-smooth), and $|\ell'|\le G$ (i.e., $\ell$ is $G$-Lipschitz). \end{assumption} Under \Cref{ass:smooth}, the risk is also a smooth function of $W$, if all layers are bounded. \begin{lemma}\label{lem:nn_smooth} Suppose $\ell$ is $\beta$-smooth. If $R\ge1$, then $\beta(R)=2L^2R^{2L-2}(\beta+G)$, and $\mathcal{R}(W)$ is a $\beta(R)$-smooth function on the set $B(R)=\cbr{W\middle|\|W_k\|_F\le R,1\le k\le L}$. \end{lemma} Smoothness ensures that for any $W,V\in B(R)$, $\mathcal{R}(W)-\mathcal{R}(V)\le \langle\nabla\cR(V),W-V\rangle+\nicefrac{\beta(R)\|W-V\|^2}{2}$ (see \citet{bubeck_conv} Lemma 3.4). In particular, if we choose some $R$ and set a constant step size $\eta_t=1/\beta(R)$, then as long as $W(t+1)$ and $W(t)$ are both in $B(R)$, \begin{align} \mathcal{R}\del{W(t+1)}-\mathcal{R}\del{W(t)} & \le \left\langle\nabla\cR\del{W(t)},-\eta_t\nabla\cR\del{W(t)}\right\rangle+\frac{\beta(R)\eta_t^2}{2}\enVert{\nabla\cR\del{W(t)}}^2 \nonumber \\ & =-\frac{1}{2\beta(R)}\enVert{\nabla\cR\del{W(t)}}^2=-\frac{\eta_t}{2}\enVert{\nabla\cR\del{W(t)}}^2. \label{eq:gd_dec} \end{align} In other words, the risk does not increase at this step. However, similar to gradient flow, the gradient descent iterate will eventually escape $B(R)$, which may increase the risk. \begin{lemma}\label{lem:gd_escape} Under \Cref{ass:loss}, \ref{ass:init} and \ref{ass:smooth}, suppose gradient descent is run with a constant step size $1/\beta(R)$. Then there exists a time $t$ when $W(t)\not\in B(R)$, in other words, $\max_{1\le k\le L}\|W_k(t)\|_F>R$. \end{lemma} Fortunately, this issue can be handled by adaptively increasing $R$ and correspondingly decreasing the step sizes, formalized in the following assumption. \begin{assumption}\label{ass:step_size} The step size $\eta_t=\min\{1/\beta(R_t),1\}$, where $R_t$ satisfies $W(t)\in B(R_t-1)$, and if $W(t+1)\in B(R_t-1)$, $R_{t+1}=R_t$. \end{assumption} \Cref{ass:step_size} can be satisfied by a line search, which ensures that the gradient descent update is not too aggressive and the boundary $R$ is increased properly. With the additional \Cref{ass:smooth,ass:step_size}, exactly the same theorems can be proved for gradient descent. We restate them briefly here. \begin{theorem}\label{thm:gd_risk} Under \Cref{ass:loss}, \ref{ass:init}, \ref{ass:smooth}, and \ref{ass:step_size}, gradient descent satisfies \begin{itemize} \item $\lim_{t\to\infty}\mathcal{R}\del{W(t)}=0$. \item For any $1\le k\le L$, $\lim_{t\to\infty}\|W_k(t)\|_F=\infty$. \item $\lim_{t\to\infty}\envert{\left\langle \nicefrac{w_{\mathrm{prod}}(t)}{\prod_{k=1}^L\|W_k(t)\|_F},v_1(t)\right\rangle}=1$, where $v_1(t)$ is the first right singular vector of $W_1(t)$. \end{itemize} \end{theorem} \begin{theorem}\label{thm:gd_min_norm} Under \Cref{ass:init,ass:data,ass:step_size}, for the logistic loss $\ell_{\log}$ and almost all data, $\lim_{t\to\infty}\envert{\langle v_1(t),\bar{u}\rangle}=1$, and $\lim_{t\to\infty}\nicefrac{w_{\mathrm{prod}}(t)}{\prod_{k=1}^L\|W_k(t)\|_F}=\bar{u}$. \end{theorem} \begin{corollary} \label{fact:gd_min_norm_2} Under \Cref{ass:init,ass:data,ass:step_size}, for the logistic loss $\ell_{\log}$ and almost all data, \[ \min_i\ y_i \del{ \frac {W_L}{\|W_L\|_F} \cdots \frac {W_1}{\|W_1\|_F} } x_i \quad\xrightarrow[t\to\infty]{}\quad \max_{\substack{A_L \in \R^{1 \times d_{L-1}}\\\|A_L\|_F = 1}} \cdots \max_{\substack{A_1 \in \R^{d_1 \times d_0}\\\|A_1\|_F = 1}} \min_i\ y_i \del{ A_L \cdots A_1 } x_i. \] \end{corollary} Proofs of \Cref{thm:gd_risk} and \ref{thm:gd_min_norm} are given in \Cref{sec:gd_app}, and are basically the same as the gradient flow proofs. The key difference is that an error of $\sum_{t=0}^{\infty}\eta_t^2\|\nabla\cR(W(t))\|^2$ will be introduced in many parts of the proof. However, it is bounded in light of \cref{eq:gd_dec}: \begin{equation*} \sum_{t=0}^{\infty}\eta_t^2\enVert{\nabla\cR\del{W(t)}}^2\le \sum_{t=0}^{\infty}\eta_t\enVert{\nabla\cR\del{W(t)}}^2\le2\mathcal{R}\del{W(0)}. \end{equation*} Since all weight matrices go to infinity, such a bounded error does not matter asymptotically, and thus proofs still go through. \section{Summary and future directions}\label{sec:future} \begin{figure}[t] \centering \begin{subfigure}{0.495\textwidth} \centering \includegraphics[width=\textwidth]{cifar_vanilla_init.pdf} \caption{Default initialization.} \label{fig:cifar:vanilla} \end{subfigure} \begin{subfigure}{0.495\textwidth} \centering \includegraphics[width=\textwidth]{cifar_fancy_init.pdf} \caption{Initialization with the same Frobenius norm.} \label{fig:cifar:fancy} \end{subfigure} \caption{Risk and alignment of dense layers (the ratio $\|W_i\|_2/\|W_i\|_F$) of (nonlinear!) AlexNet on CIFAR-10. \Cref{fig:cifar:vanilla} uses default PyTorch initialization, while \Cref{fig:cifar:fancy} forces initial Frobenius norms to be equal amongst dense layers.} \label{fig:cifar} \end{figure} This paper rigorously proves that, for deep linear networks on linearly separable data, gradient flow and gradient descent minimize the risk to $0$, align adjacent weight matrices, and align the first right singular vector of the first layer to the maximum margin solution determined by the data. There are many potential future directions; a few are as follows. \paragraph{Convergence rates and practical step sizes.} This paper only proves asymptotic convergence, moreover for adaptive step sizes depending on the current weight matrix norms. A refined analysis with rates for practical step sizes (e.g., constant step sizes) would allow the algorithm to be compared to other methods which also globally optimize this objective, would suggest ways to improve step sizes and initialization, and ideally even exhibit a sensitivity to the network architecture and suggest how it could be improved. \paragraph{Nonseparable data and nonlinear networks.} Real-world data is generally not linearly separable, but nonlinear deep networks can reliably decrease the risk to 0, even with random labels \citep{rethinking}. This seems to suggest that a nonlinear notion of separability is at play; is there some way to adapt the present analysis? The present analysis is crucially tied to the alignment of weight matrices: alignment and risk are analyzed simultaneously. Motivated by this, consider a preliminary experiment, presented in \Cref{fig:cifar}, where stochastic gradient descent was used to minimize the risk of a standard AlexNet on CIFAR-10 \citep{alexnet,cifar}. Even though there are ReLUs, max-pooling layers, and convolutional layers, the alignment phenomenon is occurring in a reduced form on the dense layers (the last three layers of the network). Specifically, despite these weight matrices having shape $(1024,4096)$, $(4096,4096)$, and $(4096,10)$ the key alignment ratios $\|W_i\|_2/\|W_i\|_F$ are much larger than their respective lower bounds $(1024^{-1/2}, 4096^{-1/2}, 10^{-1/2})$. Two initializations were tried: default PyTorch initialization, and a Gaussian initialization forcing all initial Frobenius norms to be just $4$, which is suggested by the norm preservation property in the analysis and removes noise in the weights. \subsection*{Acknowledgements} The authors are grateful for support from the NSF under grant IIS-1750051. This grant allowed them to focus on research, and when combined with an NVIDIA GPU grant, led to the creation of their beloved GPU machine $\textsc{DutchCrunch}$.
{'timestamp': '2019-02-26T02:17:09', 'yymm': '1810', 'arxiv_id': '1810.02032', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02032'}
arxiv
\section{Introduction} In the setting of Huber's $\epsilon$-contamination model \citep{huber1964robust,huber1965robust}, one has i.i.d observations \begin{equation} X_1,...,X_n\sim (1-\epsilon)P_{\theta}+\epsilon Q, \label{eq:Huber} \end{equation} and the goal is to estimate the model parameter $\theta$. Under the data generating process (\ref{eq:Huber}), each observation has a $1-\epsilon$ probability to be drawn from $P_{\theta}$ and the other $\epsilon$ probability to be drawn from the contamination distribution $Q$. The presence of an unknown contamination distribution poses both statistical and computational challenges. For example, consider a normal mean estimation problem with $P_{\theta}=N(\theta,I_p)$. Due to the contamination of data, the sample average, which is optimal when $\epsilon=0$, can be arbitrarily far away from the true mean if $Q$ charges a positive probability at infinity. Moreover, even robust estimators such as coordinatewise median and geometric median are proved to be suboptimal under the setting of (\ref{eq:Huber}) \citep{chen2018robust,diakonikolas2016robust,lai2016agnostic}. The search for both statistically optimal and computationally feasible procedures has become a fundamental problem in areas including robust statistics and theoretical computer science. It has been shown in \cite{chen2016general} that the minimax rate $\mathcal{R}(\epsilon)$ of estimating $\theta$ under Huber's $\epsilon$-contamination model takes the form of $\mathcal{R}(\epsilon)\asymp\mathcal{R}(0)\vee\omega(\epsilon,\Theta)$, where $\mathcal{R}(0)$ is the minimax rate of the problem when $\epsilon=0$, and $\omega(\epsilon,\Theta)$ is the modulus of continuity \citep{donoho1991geometrizing} between the loss function and the total variation distance with respect to the parameter space $\Theta$. The two terms in the minimax rate characterize the difficulty of the problem with both the statistical complexity and the influence of contamination. For the normal mean estimation problem, the minimax rate with respect to the squared $\ell_2$ loss is $\frac{p}{n}\vee\epsilon^2$ \citep{chen2018robust}, and is achieved by Tukey's median \citep{tukey1975mathematics}, defined as \begin{equation} \widehat{\theta} = \mathop{\rm argsup}_{\eta\in\mathbb{R}^p}\inf_{\|u\|=1}\frac{1}{n}\sum_{i=1}^n\mathbb{I}\{u^T(X_i-\eta)\geq 0\},\label{eq:Tukey} \end{equation} the maximizer of Tukey's halfspace depth. Despite the statistical optimality of Tukey's median, computation of (\ref{eq:Tukey}) is not tractable. In fact, even an approximate algorithm takes $O(e^{Cp})$ in time \citep{amenta2000regression,chan2004optimal,rousseeuw1998computing}. Recent developments in theoretical computer science are focused on the search of computationally tractable algorithms for estimating $\theta$ under Huber's $\epsilon$-contamination model (\ref{eq:Huber}). The success of the efforts started from two fundamental papers \cite{diakonikolas2016robust,lai2016agnostic}, where two different but related computational strategies ``iterative filtering" and ``dimension halving" were proposed to robustly estimate the normal mean. These algorithms can provably achieve the minimax rate $\frac{p}{n}\vee\epsilon^2$ up to a poly-logarithmic factor in polynomial time. The main idea behind the two methods is the fact that a good robust moment estimator can be certified efficiently by higher moments. This idea was later further extended \citep{diakonikolas2017being,du2017computationally,diakonikolas2016bayesian,diakonikolas2018sever,diakonikolas2018efficient,diakonikolas2018list,kothari2018robust} to develop robust and computable procedures for various other problems. Compared with these computationally feasible procedures proposed in the recent literature for robust estimation, Tukey's median (\ref{eq:Tukey}) and other depth-based estimators \citep{rousseeuw1999regression,mizera2002depth,zhang2002some,mizera2004location,paindaveine2017halfspace} have some indispensable advantages in terms of their statistical properties. First, the depth-based estimators have clear objective functions that can be interpreted from the perspective of projection pursuit \citep{mizera2002depth}. Second, the depth-based procedures are adaptive to nuisance parameters in the models such as covariance structures, contamination proportion, and error distributions \citep{chen2018robust,gao2017robust}. In comparison, many of the computationally feasible procedures for robust mean estimation in the literature rely on the knowledge of covariance matrix, and sometimes the order of the contamination proportion as well. Even though these assumptions can be relaxed, nontrivial modifications of the algorithms are required for such extensions and sometimes statistical error rates will be affected. Last but not least, Tukey's depth and other depth functions are mostly designed for robust quantile estimation, while the recent advancements in the theoretical computer science literature are all focused on robust moments estimation. Although this is not an issue when it comes to the problem of normal mean estimation, the difference becomes fundamental for robust location estimation under general settings such as elliptical distributions where moments do not necessarily exist. For a thorough overview of statistical properties of depth-based estimators, we refer the readers to \cite{liu1999multivariate,zuo2000general,zuo2018general}. Given the desirable statistical properties discussed above, this paper is focused on the development of computational strategies of depth-like procedures. Our key observation is that robust estimators that are maximizers of depth functions, including halfspace depth, regression depth and covariance matrix depth, can all be derived under the framework of $f$-GAN \citep{nowozin2016f}. As a result, these depth-based estimators can be viewed as minimizers of variational lower bounds of the total variation distance between the empirical measure and the model distribution. This observation allows us to leverage the recent developments in the deep learning literature to compute these variational lower bounds through neural network approximations. Our theoretical results give insights on how to choose appropriate neural network classes that lead to minimax optimal robust estimation under Huber's $\epsilon$-contamination model. The main contributions of the paper are listed below. \begin{enumerate} \item We identify an important subclass of $f$-GAN, called $f$-Learning (Section \ref{sec:f-learn}), which helps us to unify the understandings of various depth-based estimators, GANs, and MLE in a single framework. The connection between depth functions and $f$-GAN allows us to develop depth-like estimators that not only share good statistical properties of (\ref{eq:Tukey}), but can also be trained by stochastic gradient ascent/descent algorithms. \item In order to choose an appropriate discriminator class for robust estimation, we establish a relation between (JS)-GAN optimization and feature matching (Proposition \ref{prop:local-JS}). This implies the necessity of hidden layers of neural network structures used in the GAN training. A neural network class without hidden layer is equivalent to matching linear features, and is thus not suitable for robust estimation. \item We prove that rate-optimal robust location estimation for both Gaussian distribution (Theorem \ref{thm:TV-NN1} for TV-GAN and Theorem \ref{thm:JS-NN2} for JS-GAN with bounded activations, and Theorem \ref{thm:JS-DNN} for deep ReLU networks) and the general family of elliptical distributions (Theorem \ref{thm:elliptical}) can be achieved by GANs that use neural network discriminator classes with appropriate structures and regularizations. Extensive numerical experiments are conducted to verify our theoretical findings and show that these procedures can be computed in practice. \end{enumerate} Our work is also related to the recent literature on the investigation of statistical properties of GAN. For example, nonparametric density estimation using GAN is studied by \cite{liang2017well}. Provable guarantees of learning Gaussian distributions with quadratic discriminators are established by \cite{feizi2017understanding}. Theoretical guarantees of learning Gaussian mixtures, exponential families and injective neural network generators are obtained by \cite{bai2018approximability}. The result we obtain in this paper is the first theoretical guarantee of GAN in robust estimation under Huber's $\epsilon$-contamination model. The rest of the paper is organized as follows. In Section \ref{sec:framework}, we introduce an $f$-Learning framework and discuss the connection between robust estimation and $f$-GAN. The theoretical results of robust Gaussian mean estimation using $f$-GAN are given in Section \ref{sec:main}. Results for deep ReLU networks are given in Section \ref{sec:deep}. An extension to robust location estimation for the family of Elliptical distributions is presented in Section \ref{sec:ellip} that includes both Gaussian distribution and Cauchy distribution whose moments do not exist. In Section \ref{sec:num}, we present extensive numerical studies of the proposed procedures. Section \ref{sec:disc} collects some discussions on the results of the paper and several possible extensions of the work. Finally, all the technical proofs are given in Section \ref{sec:pf}. We close this section by introducing the notations used in the paper. For $a,b\in\mathbb{R}$, let $a\vee b=\max(a,b)$ and $a\wedge b=\min(a,b)$. For an integer $m$, $[m]$ denotes the set $\{1,2,...,m\}$. Given a set $S$, $|S|$ denotes its cardinality, and $\mathbb{I}_S$ is the associated indicator function. For two positive sequences $\{a_n\}$ and $\{b_n\}$, the relation $a_n\lesssim b_n$ means that $a_n\leq Cb_n$ for some constant $C>0$, and $a_n\asymp b_n$ if both $a_n\lesssim b_n$ and $b_n\lesssim a_n$ hold. For a vector $v\in\mathbb{R}^p$, $\norm{v}$ denotes the $\ell_2$ norm, $\|v\|_{\infty}$ the $\ell_{\infty}$ norm, annd $\|v\|_1$ the $\ell_1$ norm. For a matrix $A\in\mathbb{R}^{d_1\times d_2}$, we use $\opnorm{A}$ to denote its operator norm, which is its largest singular value. We use $\mathbb{P}$ and $\mathbb{E}$ to denote generic probability and expectation whose distribution is determined from the context. The symbol $E_P$ is used for the expectation operator under the distribution $P$. The sigmoid function and the rectified linear unit function (ReLU) are denoted by ${\sf sigmoid}(x)=\frac{1}{1+e^{-x}}$ and ${\sf ReLU}(x)=\max(x,0)$. \section{Robust Estimation and $f$-GAN}\label{sec:framework} We start with the definition of $f$-divergence \citep{csiszar1964informationstheoretische,ali1966general}. Given a strictly convex function $f$ that satisfies $f(1)=0$, the $f$-divergence between two probability distributions $P$ and $Q$ is defined by \begin{equation} D_f(P\|Q)=\int f\left(\frac{p}{q}\right)dQ.\label{eq:f-div} \end{equation} Here, we use $p(\cdot)$ and $q(\cdot)$ to stand for the density functions of $P$ and $Q$ with respect to some common dominating measure. For a fully rigorous definition, see \cite{polyanskiy2014lecture}. Let $f^*$ be the convex conjugate of $f$. That is, $f^*(t)=\sup_{u\in\text{dom}_f}(ut-f(u))$. A variational lower bound of (\ref{eq:f-div}) is \begin{equation} D_f(P\|Q) \geq \sup_{T\in\mathcal{T}}\left[E_PT(X)-E_Qf^*(T(X))\right]. \label{eq:f-div-variational} \end{equation} Note that the inequality (\ref{eq:f-div-variational}) becomes an equality whenever the class $\mathcal{T}$ contains the function $f'\left(p/q\right)$ \citep{nguyen2010estimating}. For notational simplicity, we also use $f'$ for an arbitrary element of the subdifferential when the derivative does not exist. With i.i.d. observations $X_1,...,X_n\sim P$, the variational lower bound (\ref{eq:f-div-variational}) naturally leads to the following learning method \begin{equation} \widehat{P}=\mathop{\rm arginf}_{Q\in\mathcal{Q}}\sup_{T\in\mathcal{T}}\left[\frac{1}{n}\sum_{i=1}^nT(X_i)-E_Qf^*(T(X))\right]. \label{eq:f-GAN} \end{equation} The formula (\ref{eq:f-GAN}) is a powerful and general way to learn the distribution $P$ from its i.i.d. observations. It is known as $f$-GAN \citep{nowozin2016f}, an extension of GAN \citep{goodfellow2014generative}, which stands for \emph{generative adversarial nets}. The idea is to find a $\widehat{P}$ so that the best discriminator $T$ in the class $\mathcal{T}$ cannot tell the difference between $\widehat{P}$ and the empirical distribution $\frac{1}{n}\sum_{i=1}^n\delta_{X_i}$. \subsection{$f$-Learning: A Unified Framework} \label{sec:f-learn} Our $f$-Learning framework is based on a special case of the variational lower bound (\ref{eq:f-div-variational}). That is, \begin{equation} D_f(P\|Q)\geq \sup_{\widetilde{Q}\in\widetilde{\mathcal{Q}}_{Q}}\left[E_Pf'\left(\frac{\widetilde{q}(X)}{q(X)}\right)-E_Qf^*\left(f'\left(\frac{\widetilde{q}(X)}{q(X)}\right)\right)\right],\label{eq:f-Learning-pop} \end{equation} where $\widetilde{q}(\cdot)$ stands for the density function of $\widetilde{Q}$. Note that here we allow the class $\widetilde{\mathcal{Q}}_{Q}$ to depend on the distribution $Q$ in the second argument of $D_f(P\|Q)$. Compare (\ref{eq:f-Learning-pop}) with (\ref{eq:f-div-variational}), and it is easy to realize that (\ref{eq:f-Learning-pop}) is a special case of (\ref{eq:f-div-variational}) with \begin{equation} \mathcal{T} = \mathcal{T}_Q = \left\{f'\left(\frac{\widetilde{q}}{q}\right): \widetilde{q}\in\widetilde{\mathcal{Q}}_Q\right\}.\label{eq:class-T-LR} \end{equation} Moreover, the inequality (\ref{eq:f-Learning-pop}) becomes an equality as long as $P\in\widetilde{\mathcal{Q}}_Q$. The sample version of (\ref{eq:f-Learning-pop}) leads to the following learning method \begin{equation} \widehat{P} = \mathop{\rm arginf}_{Q\in\mathcal{Q}}\sup_{\widetilde{Q}\in\widetilde{\mathcal{Q}}_Q}\left[\frac{1}{n}\sum_{i=1}^nf'\left(\frac{\widetilde{q}(X_i)}{q(X_i)}\right)-E_Qf^*\left(f'\left(\frac{\widetilde{q}(X)}{q(X)}\right)\right)\right]. \label{eq:f-Learning} \end{equation} The learning method (\ref{eq:f-Learning}) will be referred to as \emph{$f$-Learning} in the sequel. It is a very general framework that covers many important learning procedures as special cases. For example, consider the special case where $\widetilde{\mathcal{Q}}_Q=\widetilde{\mathcal{Q}}$ independent of $Q$, $\mathcal{Q}=\widetilde{\mathcal{Q}}$, and $f(x)=x\log x$. Direct calculations give $f'(x)=\log x+1$ and $f^*(t)=e^{t-1}$. Therefore, (\ref{eq:f-Learning}) becomes $$\widehat{P}=\mathop{\rm arginf}_{Q\in\mathcal{Q}}\sup_{\widetilde{Q}\in\mathcal{Q}}\frac{1}{n}\sum_{i=1}^n\log\frac{\widetilde{q}(X_i)}{q(X_i)}=\mathop{\rm argsup}_{Q\in\mathcal{Q}}\frac{1}{n}\sum_{i=1}^n\log q(X_i),$$ which is the \emph{maximum likelihood estimator (MLE)}. The $f$-Learning (\ref{eq:f-Learning}) is related to but is different from the rho-estimation framework \citep{baraud2016rho,baraud2017new}. The unpenalized version of the rho-estimator is defined by $$\widehat{P}=\mathop{\rm arginf}_{Q\in\mathcal{Q}}\sup_{\widetilde{Q}\in\mathcal{Q}}\frac{1}{n}\sum_{i=1}^n\psi\left(\sqrt{\frac{\widetilde{q}(X_i)}{q(X_i)}}\right),$$ where $\psi:[0,+\infty]\rightarrow [-1,1]$ is a non-decreasing function that satisfies $\psi(x)=-\psi(1/x)$. The rho-estimation framework has a different motivation. The function $\psi$ is designed to generalize the logarithmic function (which leads to the MLE) so that the induced procedure is robust to a Hellinger model misspecification. On the other hand, the $f$-Learning (\ref{eq:f-Learning}) is directly derived from a variational lower bound of the $f$-divergence. \subsection{TV-Learning and Depth-Based Estimators} \label{sec:f-learndepth} An important generator $f$ that we will discuss here is $f(x)=(x-1)_+$. This leads to the total variation distance $D_f(P\|Q)=\frac{1}{2}\int|p-q|$. With $f'(x)=\mathbb{I}\{x\geq 1\}$ and $f^*(t)=t\mathbb{I}\{0\leq t\leq 1\}$, the \emph{TV-Learning} is given by \begin{equation} \widehat{P}=\mathop{\rm arginf}_{Q\in\mathcal{Q}}\sup_{\widetilde{Q}\in\mathcal{Q}_Q}\left[\frac{1}{n}\sum_{i=1}^n\mathbb{I}\left\{\frac{\widetilde{q}(X_i)}{q(X_i)}\geq 1\right\}-Q\left(\frac{\widetilde{q}}{q}\geq 1\right)\right]. \label{eq:TV-Learning} \end{equation} The TV-Learning (\ref{eq:TV-Learning}) is a very useful tool in robust estimation. A closely related idea was previously explored by \cite{yatracos1985rates,devroye2012combinatorial}. We illustrate its applications by several examples of depth-based estimators. In the first example, consider $$\mathcal{Q}=\left\{N(\eta,I_p):\eta\in\mathbb{R}^p\right\},\quad \widetilde{\mathcal{Q}}_{\eta}=\left\{N(\widetilde{\eta},I_p):\|\widetilde{\eta}-\eta\|\leq r\right\}.$$ In other words, $\mathcal{Q}$ is the class of Gaussian location family, and $\widetilde{\mathcal{Q}}_{\eta}$ is taken to be a subset in a local neighborhood of $N(\eta,I_p)$. Then, with $Q=N(\eta,I_p)$ and $\widetilde{Q}=N(\widetilde{\eta},I_p)$, the event $\widetilde{q}(X)/q(X)\geq 1$ is equivalent to $\|X-\widetilde{\eta}\|^2\leq\|X-\eta\|^2$. Since $\|\widetilde{\eta}-\eta\|\leq r$, we can write $\widetilde{\eta}=\eta+\widetilde{r}u$ for some $\widetilde{r}\in\mathbb{R}$ and $u\in\mathbb{R}^p$ that satisfy $0\leq \widetilde{r}\leq r$ and $\|u\|=1$. Then, (\ref{eq:TV-Learning}) becomes \begin{equation} \widehat{\theta}=\mathop{\rm arginf}_{\eta\in\mathbb{R}^p}\sup_{\substack{\|u\|=1\\0\leq \widetilde{r}\leq r}}\left[\frac{1}{n}\sum_{i=1}^n\mathbb{I}\left\{u^T(X_i-\eta)\geq\frac{\widetilde{r}}{2}\right\}-\mathbb{P}\left(N(0,1)\geq\frac{\widetilde{r}}{2}\right)\right].\label{eq:TV-Learning-finite-r} \end{equation} Letting $r\rightarrow 0$, we obtain (\ref{eq:Tukey}), the exact formula of \emph{Tukey's median}. A traditional understanding of Tukey's median is that (\ref{eq:Tukey}) maximizes the halfspace depth \citep{donoho1992breakdown} so that $\widehat{\theta}$ is close to the center of all one-dimensional projections of the data. In the $f$-Learning framework, $N(\widehat{\theta},I_p)$ is understood to be the minimizer of a variational lower bound of the total variation distance. The next example is a linear model $y|X\sim N(X^T\theta,1)$. Consider the following classes \begin{eqnarray*} \mathcal{Q} &=& \left\{P_{y,X}=P_{y|X}P_X: P_{y|X}=N(X^T\eta,1), \eta\in\mathbb{R}^p\right\}, \\ \widetilde{\mathcal{Q}}_{\eta} &=& \left\{P_{y,X}=P_{y|X}P_X: P_{y|X}=N(X^T\widetilde{\eta},1), \|\widetilde{\eta}-\eta\|\leq r\right\}. \end{eqnarray*} Here, $P_{y,X}$ stands for the joint distribution of $y$ and $X$. The two classes $\mathcal{Q}$ and $\widetilde{\mathcal{Q}}_{\eta}$ share the same marginal distribution $P_X$ and the conditional distributions are specified by $N(X^T\eta,1)$ and $N(X^T\widetilde{\eta},1)$, respectively. Follow the same derivation of Tukey's median, let $r\rightarrow 0$, and we obtain \begin{equation} \widehat{\theta} = \mathop{\rm argsup}_{\eta\in\mathbb{R}^p}\inf_{\|u\|=1}\frac{1}{n}\sum_{i=1}^n\mathbb{I}\{u^TX_i(y_i-X_i^T\eta)\geq 0\}, \label{eq:regression-depth} \end{equation} which is the estimator that maximizes the \emph{regression depth} proposed by \cite{rousseeuw1999regression}. It is worth noting that the derivation of (\ref{eq:regression-depth}) does not depend on the marginal distribution $P_X$. The last example is on covariance matrix estimation. For this task, we set $\mathcal{Q}=\{N(0,\Gamma):\Gamma\in\mathcal{E}_p\}$, where $\mathcal{E}_p$ is the class of all $p\times p$ covariance matrices. Inspired by the derivations of Tukey depth and regression depth, it is tempting to choose $\widetilde{\mathcal{Q}}_{\Gamma}$ in the neighborhood of $N(0,\Gamma)$. However, a naive choice would lead to a definition that is not even Fisher consistent. We propose a rank-one neighborhood, given by \begin{equation} \widetilde{\mathcal{Q}}_{\Gamma}=\left\{N(0,\widetilde{\Gamma}): \widetilde{\Gamma}^{-1}=\Gamma^{-1}+\widetilde{r}uu^T\in\mathcal{E}_p, |\widetilde{r}|\leq r, \|u\|=1\right\}.\label{eq:inv-nb} \end{equation} Then, a direct calculation gives \begin{equation} \mathbb{I}\left\{\frac{dN(0,\widetilde{\Gamma})}{dN(0,\Gamma)}(X)\geq 1\right\}=\mathbb{I}\left\{ \widetilde{r}|u^TX|^2\leq\log(1+\widetilde{r}u^T\Gamma u)\right\}.\label{eq:event-cov} \end{equation} Since $\lim_{\widetilde{r}\rightarrow 0} \frac{\log(1+\widetilde{r}u^T\Gamma u)}{\widetilde{r}u^T\Gamma u}=1$, the limiting event of (\ref{eq:event-cov}) is either $\mathbb{I}\{|u^TX|^2\leq u^T\Gamma u\}$ or $\mathbb{I}\{|u^TX|^2\geq u^T\Gamma u\}$, depending on whether $\widetilde{r}$ tends to zero from left or from right. Therefore, with the above $\mathcal{Q}$ and $\widetilde{\mathcal{Q}}_{\Gamma}$, (\ref{eq:TV-Learning}) becomes \begin{eqnarray} \label{eq:matrix-depth2} \widehat{\Sigma} &=& \mathop{\rm arginf}_{\Gamma\in\mathcal{E}_p}\sup_{\|u\|=1}\Bigg[\left(\frac{1}{n}\sum_{i=1}^n\mathbb{I}\{|u^TX_i|^2\leq u^T\Gamma u\}-\mathbb{P}(\chi_1^2\leq 1)\right) \\ \nonumber && \qquad\qquad\qquad \vee\left(\frac{1}{n}\sum_{i=1}^n\mathbb{I}\{|u^TX_i|^2> u^T\Gamma u\}-\mathbb{P}(\chi_1^2> 1)\right)\Bigg], \end{eqnarray} under the limit $r\rightarrow 0$. Even though the definition of (\ref{eq:inv-nb}) is given by a rank-one neighborhood of the inverse covariance matrix, the formula (\ref{eq:matrix-depth2}) can also be derived with $\widetilde{\Gamma}^{-1}=\Gamma^{-1}+\widetilde{r}uu^T$ in (\ref{eq:inv-nb}) replaced by $\widetilde{\Gamma}=\Gamma+\widetilde{r}uu^T$ by applying the Sherman-Morrison formula. A similar formula to (\ref{eq:matrix-depth2}) in the literature is given by \begin{equation} \widehat{\Sigma} = \mathop{\rm argsup}_{\Gamma\in\mathcal{E}_p}\inf_{\|u\|=1}\left[\frac{1}{n}\sum_{i=1}^n\mathbb{I}\{|u^TX_i|^2\leq \beta u^T\Gamma u\}\wedge \frac{1}{n}\sum_{i=1}^n\mathbb{I}\{|u^TX_i|^2\geq \beta u^T\Gamma u\}\right], \label{eq:matrix-depth} \end{equation} which is recognized as the maximizer of what is known as the \emph{covariance matrix depth} function \citep{zhang2002some,chen2018robust,paindaveine2017halfspace}. The $\beta$ in (\ref{eq:matrix-depth}) is a scalar defined through the equation $\mathbb{P}(N(0,1)\leq \sqrt{\beta})=3/4$. It is proved in \cite{chen2018robust} that $\widehat{\Sigma}$ achieves the minimax rate under Huber's $\epsilon$-contamination model. While the formula (\ref{eq:matrix-depth2}) can be derived from TV-Learning with discriminators in the form of $\mathbb{I}\left\{\frac{dN(0,\widetilde{\Gamma})}{dN(0,\Gamma)}(X)\geq 1\right\}$, a special case of (\ref{eq:class-T-LR}), the formula (\ref{eq:matrix-depth}) can be derived directly from TV-GAN with discriminators in the form of $\mathbb{I}\left\{\frac{dN(0,\beta\widetilde{\Gamma})}{dN(0,\beta\Gamma)}(X)\geq 1\right\}$ by following a similar rank-one neighborhood argument. \subsection{From $f$-Learning to $f$-GAN} The depth-based estimators (\ref{eq:Tukey}), (\ref{eq:regression-depth}) and (\ref{eq:matrix-depth}) are all proved to be statistically optimal under Huber's contamination model \citep{chen2018robust,gao2017robust}. This shows the importance of TV-Learning in robust estimation. However, it is well-known that depth-based estimators are very hard to compute \citep{amenta2000regression,van1999efficient,rousseeuw1998computing}, which limits their applications only for very low-dimensional problems. On the other hand, the general $f$-GAN framework (\ref{eq:f-GAN}) has been successfully applied to learn complex distributions and images in practice \citep{goodfellow2014generative,radford2015unsupervised,salimans2016improved}. The major difference that gives the computational advantage to $f$-GAN is its flexibility in terms of designing the discriminator class $\mathcal{T}$ using neural networks compared with the pre-specified choice (\ref{eq:class-T-LR}) in $f$-Learning. While $f$-Learning provides a unified perspective in understanding various depth-based procedures in robust estimation, we can step back into the more general $f$-GAN for its computational advantages, and to design efficient computational strategies. However, there are at least two questions that are unclear: \begin{enumerate} \item How to choose the function $f$ that leads to robust learning procedures which are easy to optimize? \item How to specify the discriminator class to learn the parameter of interest with minimax rate under Huber's $\epsilon$-contamination model? \end{enumerate} In the rest of the paper, we will study a robust mean estimation problem in detail to answer these questions and illustrate the power of $f$-GAN in robust estimation. \section{Robust Mean Estimation via GAN}\label{sec:main} In this section, we focus on the problem of robust mean estimation under Huber's $\epsilon$-contamination model. Our goal is to reveal how the choice of the class of discriminators affects robustness and statistical optimality under the simplest possible setting. That is, we have i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,I_p)+\epsilon Q$, and we need to estimate the unknown location $\theta\in\mathbb{R}^p$ with the contaminated data. Our goal is to achieve the minimax rate $\frac{p}{n}\vee\epsilon^2$ with respect to the squared $\ell_2$ loss uniformly over all $\theta\in\mathbb{R}^p$ and all $Q$. \iffalse In this section, we focus on the problem of robust mean estimation under Huber's $\epsilon$-contamination model. Our goal is to reveal how the choice of the class of discriminators affects robustness and statistical optimality under the simplest possible setting. That is, we have i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,I_p)+\epsilon Q$, and we need to estimate the unknown location $\theta\in\mathbb{R}^p$ with the contaminated data. It is shown in \cite{chen2018robust} that the minimax rate with respect to the squared $\ell_2$ loss is $\frac{p}{n}\vee\epsilon^2$, which can be achieved by Tukey's median (\ref{eq:Tukey}). Provably polynomial-time procedures have been developed by \cite{lai2016agnostic,diakonikolas2016robust}, and can achieve the minimax rate up to a logarithmic factor. Compared with these algorithms that are specifically designed for the problem of robust mean estimation, our task in this paper is to tackle the problem from the general perspective of $f$-GAN/$f$-Learning framework. We hope that the results discovered here can serve as an example of using the $f$-GAN framework to build computationally feasible procedures with statistical guarantees to general robust estimation problems. We will reveal some important principles in terms of designing the discriminator class by both theoretical investigation and extensive numerical experiments. \fi \subsection{Results for TV-GAN}\label{sec:TV-GAN} We start with the total variation GAN (TV-GAN) with $f(x)=(x-1)_+$ in (\ref{eq:f-GAN}). For the Gaussian location family, (\ref{eq:f-GAN}) can be written as \begin{equation} \widehat{\theta}=\mathop{\rm arginf}_{\eta\in\mathbb{R}^p}\sup_{D\in\mathcal{D}}\left[\frac{1}{n}\sum_{i=1}^nD(X_i)-E_{N(\eta,I_p)}D(X)\right],\label{eq:TV-GAN-NN1} \end{equation} with $T(x)=D(x)$ in (\ref{eq:f-GAN}). Now we need to specify the class of discriminators $\mathcal{D}$ to solve the classification problem between $N(\eta,I_p)$ and the empirical distribution $\frac{1}{n}\sum_{i=1}^n\delta_{X_i}$. One of the simplest discriminator classes is the logistic regression, \begin{equation} \mathcal{D}=\left\{D(x)={\sf sigmoid}(w^Tx+b): w\in\mathbb{R}^p,b\in\mathbb{R}\right\}. \label{eq:TV-NN1} \end{equation} With $D(x)={\sf sigmoid}(w^Tx+b)$ in (\ref{eq:TV-NN1}), the procedure (\ref{eq:TV-GAN-NN1}) can be viewed as a smoothed version of TV-Learning (\ref{eq:TV-Learning}). To be specific, the sigmoid function ${\sf sigmoid}(w^Tx+b)$ tends to an indicator function as $\|w\|\rightarrow\infty$, which leads to a procedure very similar to (\ref{eq:TV-Learning-finite-r}). In fact, the class (\ref{eq:TV-NN1}) is richer than the one used in (\ref{eq:TV-Learning-finite-r}), and thus (\ref{eq:TV-GAN-NN1}) can be understood as the minimizer of a sharper variational lower bound than that of (\ref{eq:TV-Learning-finite-r}). \begin{thm}\label{thm:TV-NN1} Assume $\frac{p}{n}+\epsilon^2\leq c$ for some sufficiently small constant $c>0$. With i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,I_p)+\epsilon Q$, the estimator $\widehat{\theta}$ defined by (\ref{eq:TV-GAN-NN1}) satisfies $$\|\widehat{\theta}-\theta\|^2 \leq C\left(\frac{p}{n}\vee\epsilon^2\right),$$ with probability at least $1-e^{-C'(p+n\epsilon^2)}$ uniformly over all $\theta\in\mathbb{R}^p$ and all $Q$. The constants $C,C'>0$ are universal. \end{thm} Though TV-GAN can achieve the minimax rate, it may suffer from optimization difficulties especially when the distributions $Q$ and $N(\theta, I_p)$ are far away from each other. The main obstacle is, with optimization based on gradient, the discriminator may be stuck in a local maximum which will then pass wrong signals to the generator. We illustrate this point with a simple one-dimensional example in Figure \ref{fig:tv_landscape_10}, where samples are drawn from $(1-\epsilon)N(1, 1) + \epsilon N(10, 1)$ with $\epsilon=0.2$, and we optimize (\ref{eq:TV-GAN-NN1}) via alternative gradient ascent and descent shown in Algorithm \ref{alg:jsgan}. Even with a good initialization, TV-GAN in the form of (\ref{eq:TV-GAN-NN1}) will continuously increase the value of $\eta$ (from the light area to the dark area in the heatmap) if $w$ cannot achieve its global maximum, and thus fails to learn the saddle point. However, it is almost impossible for ${w}$ to correct its way from $w\to\infty$ to $w\to-\infty$ simply by the information of its local gradient. In comparison, the landscape becomes better when $Q$ and $N(\theta, I_p)$ are close, where the signal passed to the generator becomes weak before being stuck in the local maximum, as shown in Figure \ref{fig:tv_landscape_15}. \begin{figure} \includegraphics[width=.5\textwidth]{tv_3dsurface_cf10.png} \includegraphics[width=.5\textwidth]{tv_2dheatmap_cf10.png} \caption{Landscape of $F(\eta, w)= \sup_{b}[E_P{\sf sigmoid}(wX+b)-E_{N(\eta,1)}{\sf sigmoid}(wX+b)]$, where $b$ is maximized out for visualization. Samples are drawn from $P=(1-\epsilon)N(1, 1) + \epsilon N(10, 1)$ with $\epsilon=0.2$. Left: a surface plot of $F(\eta,w)$. The solid curves are marginal functions for fixed $\eta$'s: $F(1, w)$ (red) and $F(5, w)$ (blue), and the dash curves are marginal functions for fixed $w$'s: $F(\eta, -10)$ (orange) and $F(\eta, 10)$ (green). Right: a heatmap of $F(\eta, w)$. It is clear that $\tilde{F}(w) = F(\eta, w)$ has two local maxima for a given $\eta$, achieved at $w=+\infty$ and $w=-\infty$. In fact, the global maximum for $\tilde{F}(w)$ has a phase transition from $w=+\infty$ to $w=-\infty$ as $\eta$ grows. For example, the maximum is achieved at $w=+\infty$ when $\eta=1$ (blue solid) and is achieved at $w=-\infty$ when $\eta=5$ (red solid). Unfortunately, even if we initialize with ${\eta}_0=1$ and ${w}_0> 0$, gradient ascents on $\eta$ will only increase the value of $\eta$ (green dash), and thus as long as the discriminator cannot reach the global maximizer, $w$ will be stuck in the positive half space $\{w: w>0\}$ and further increase the value of $\eta$.}\label{fig:tv_landscape_10} \end{figure} \begin{figure} \includegraphics[width=.5\textwidth]{tv_3dsurface_cf15.png} \includegraphics[width=.5\textwidth]{tv_2dheatmap_cf15.png} \caption{Landscape of $F(\eta, w)= \sup_{b}[E_P{\sf sigmoid}(wX+b)-E_{N(\eta,1)}{\sf sigmoid}(wX+b)]$, where $b$ is maximized out for visualization. Samples are drawn from $P=(1-\epsilon)N(1, 1) + \epsilon N(1.5, 1)$ with $\epsilon=0.2$. Left: a surface plot of $F(\eta,w)$. Right: a heatmap of $F(\eta, w)$. Compared with the heatmap in Figure \ref{fig:tv_landscape_10}, the landscape becomes better in the sense that no matter whether we start from the left-top area or the right-bottom area of the heatmap, gradient ascent on $\eta$ does not consistently increase or decrease the value of $\eta$. This is because the signal becomes weak when it is close to the saddle point around $\eta=1$.}\label{fig:tv_landscape_15} \end{figure} \subsection{Results for JS-GAN} Given the intractable optimization property of TV-GAN, we next turn to Jensen-Shannon GAN (JS-GAN) with $$f(x)=x\log x-(x+1)\log\frac{x+1}{2}.$$ The estimator is defined by \begin{equation} \widehat{\theta}=\mathop{\rm arginf}_{\eta\in\mathbb{R}^p}\sup_{D\in\mathcal{D}}\left[\frac{1}{n}\sum_{i=1}^n\log D(X_i) + E_{N(\eta,I_p)}\log(1-D(X))\right]+\log 4, \label{eq:JS-GAN-gen} \end{equation} with $T(x)=\log D(x)$ in (\ref{eq:f-GAN}). This is exactly the original GAN \citep{goodfellow2014generative} specialized to the normal mean estimation problem. The advantages of JS-GAN over other forms of GAN have been studied extensively in the literature \citep{lucic2017gans,kurach2018gan}. Before presenting theoretical properties of (\ref{eq:JS-GAN-gen}), we first show a simple numerical result that implies important consequences on the choice of the discriminator class $\mathcal{D}$. Consider i.i.d. observations drawn from the one-dimensional contamination model $(1-\epsilon)N(\theta,1)+ \epsilon N(t,1)$ with $\theta=1$ and $\epsilon=0.2$. We consider two estimators in the form of (\ref{eq:JS-GAN-gen}) that use different discriminator classes. The first one is the same logistic regression class defined in (\ref{eq:TV-NN1}), and the second one is the class of neural networks with one hidden layer. Then, the values of the two estimators are plotted against $t$ in Figure \ref{fig:js_landscape}. It is clear that the two estimators have completely different behaviors. For the estimator trained by JS-GAN using a logistic regression discriminator class, it is always close to $0.2+0.8t$, which is the grand mean of the entire distribution $(1-\epsilon)N(\theta,1)+ \epsilon N(t,1)$. Thus, the estimator is not robust, and its deviation from $\theta$ will become arbitrarily large when the value of $t$ is increased. On the other hand, with an extra hidden layer built into the neural nets, the second estimator is always close to the mean $\theta$ that we want to learn, regardless of the value of $t$. The green curve in Figure \ref{fig:js_landscape} first increases as $t$ increases, but it eventually converges to $\theta=1$ as $t$ further increases. The hardest contamination distribution $N(t,1)$ is the one with a $t$ that is not far away from $\theta$, which is well predicted by the minimax theory of robust estimation \citep{chen2018robust}. \begin{figure}[H] \centering \includegraphics[width=.50\textwidth]{js_1dim.png} \caption{The solid blue line is the mean of $(1-\epsilon)N(\theta,1)+ \epsilon N(t,1)$ with $\theta=1$ and $\epsilon=0.2$. At each level of $t$, we consider the estimators in the form of (\ref{eq:JS-GAN-gen}) that use different discriminator classes. The JS-GAN using discriminators without hidden layers always gives an estimator close to $0.2+0.8t$ (green dash line), while the JS-GAN using discriminators with one hidden layer leads to robust estimation (red dash line).}\label{fig:js_landscape} \end{figure} To understand why and how the class of the discriminators affects the robustness property of JS-GAN, we introduce a new concept called restricted Jensen-Shannon divergence. Let $g:\mathbb{R}^p\rightarrow\mathbb{R}^d$ be a function that maps a $p$-dimensional observation to a $d$-dimensional feature space. The restricted Jensen-Shannon divergence between two probability distributions $P$ and $Q$ with respect to the feature $g$ is defined as $${\sf JS}_g(P,Q)=\sup_{w\in\mathcal{W}}\left[E_P\log{\sf sigmoid}(w^Tg(X))+E_Q\log(1-{\sf sigmoid}(w^Tg(X)))\right]+\log 4.$$ In other words, $P$ and $Q$ are distinguished by a logistic regression classifier that uses the feature $g(X)$. It is easy to see that ${\sf JS}_g(P,Q)$ is a variational lower bound of the original Jensen-Shannon divergence. The key property of ${\sf JS}_g(P,Q)$ is given by the following proposition. \begin{proposition}\label{prop:local-JS} Assume $\mathcal{W}$ is a convex set that contains an open neighborhood of $0$. Then, ${\sf JS}_g(P,Q)=0$ if and only if $E_Pg(X)=E_Qg(X)$. \end{proposition} \begin{proof} Define $F(w)=E_P\log{\sf sigmoid}(w^Tg(X))+E_Q\log(1-{\sf sigmoid}(w^Tg(X)))+\log 4$, so that ${\sf JS}_g(P,Q)=\sup_{w\in\mathcal{W}}F(w)$. The gradient and Hessian of $F(w)$ are given by \begin{eqnarray*} \nabla F(w) &=& E_P\frac{e^{-w^Tg(X)}}{1+e^{-w^Tg(X)}}g(X) - E_Q\frac{e^{w^Tg(X)}}{1+e^{w^Tg(X)}}g(X), \\ \nabla^2 F(w) &=& -E_P \frac{e^{w^Tg(X)}}{(1+e^{w^Tg(X)})^2}g(X)g(X)^T - E_Q \frac{e^{-w^Tg(X)}}{(1+e^{-w^Tg(X)})^2}g(X)g(X)^T. \end{eqnarray*} Therefore, $F(w)$ is concave in $w$, and $\sup_{w\in\mathcal{W}}F(w)$ is a convex optimization with a convex $\mathcal{W}$. Suppose ${\sf JS}_g(P,Q)=0$. Then $\sup_{w\in\mathcal{W}}F(w)=0=F(0)$, which implies $\nabla F(0)=0$, and thus we have $E_Pg(X)=E_Qg(X)$. Now suppose $E_Pg(X)=E_Qg(X)$, which is equivalent to $\nabla F(0)=0$. Therefore, $w=0$ is a stationary point of a concave function, and we have ${\sf JS}_g(P,Q)=\sup_{w\in\mathcal{W}}F(w)=F(0)=0$. \end{proof} The proposition asserts that ${\sf JS}_g(\cdot,\cdot)$ cannot distinguish $P$ and $Q$ if the feature $g(X)$ has the same expected value under the two distributions. This \textit{generalized moment matching effect} has also been studied by \cite{liu2017approximation} for general $f$-GANs. However, the linear discriminator class considered in \cite{liu2017approximation} is parameterized in a different way compared with the discriminator class here. When we apply Proposition \ref{prop:local-JS} to robust mean estimation, the JS-GAN is trying to match the values of $\frac{1}{n}\sum_{i=1}^ng(X_i)$ and $E_{N(\eta,I_\eta)}g(X)$ for the feature $g(X)$ used in the logistic regression classifier. This explains what we observed in our numerical experiments. A neural net without any hidden layer is equivalent to a logistic regression with a linear feature $g(X)=(X^T,1)^T\in\mathbb{R}^{p+1}$. Therefore, whenever $\eta=\frac{1}{n}\sum_{i=1}^nX_i$, we have ${\sf JS}_g\left(\frac{1}{n}\sum_{i=1}^n\delta_{X_i},N(\eta,I_p)\right)=0$, which implies that the sample mean is a global maximizer of (\ref{eq:JS-GAN-gen}). On the other hand, a neural net with at least one hidden layers involves a nonlinear feature function $g(X)$, which is the key that leads to the robustness of (\ref{eq:JS-GAN-gen}). We will show rigorously that a neural net with one hidden layer is sufficient to make (\ref{eq:JS-GAN-gen}) robust and optimal. Consider the following class of discriminators, \begin{equation} \mathcal{D}=\left\{D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j\sigma(u_j^Tx+b_j)\right): \sum_{j\geq 1}|w_j|\leq \kappa, u_j\in\mathbb{R}^p, b_j\in\mathbb{R}\right\}.\label{eq:JS-NN2} \end{equation} The class (\ref{eq:JS-NN2}) consists of two-layer neural network functions. While the dimension of the input layer is $p$, the dimension of the hidden layer can be arbitrary, as long as the weights have a bounded $\ell_1$ norm. The nonlinear activation function $\sigma(\cdot)$ is allowed to take 1) indicator: $\sigma(x)=\mathbb{I}\{x\geq 1\}$, 2) sigmoid: $\sigma(x)=\frac{1}{1+e^{-x}}$, 3) ramp: $\sigma(x)=\max(\min(x+1/2,1),0)$. Other bounded activation functions are also possible, but we do not exclusively list them. The rectified linear unit (ReLU) will be studied in Section \ref{sec:deep}. \begin{thm}\label{thm:JS-NN2} Consider the estimator $\widehat{\theta}$ defined by (\ref{eq:JS-GAN-gen}) with $\mathcal{D}$ specified by (\ref{eq:JS-NN2}). Assume $\frac{p}{n}+\epsilon^2\leq c$ for some sufficiently small constant $c>0$, and set $\kappa=O\left(\sqrt{\frac{p}{n}}+\epsilon\right)$. With i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,I_p)+\epsilon Q$, we have $$\|\widehat{\theta}-\theta\|^2 \leq C\left(\frac{p}{n}\vee\epsilon^2\right),$$ with probability at least $1-e^{-C'(p+n\epsilon^2)}$ uniformly over all $\theta\in\mathbb{R}^p$ and all $Q$. The constants $C,C'>0$ are universal. \end{thm} Theorem \ref{thm:JS-NN2} verifies our numerical experiments, and shows that the JS-GAN using a neural net discriminator with hidden layers is not only robust, but it also achieves the minimax rate of the problem. The condition $\kappa=O\left(\sqrt{\frac{p}{n}}+\epsilon\right)$ is needed for technical reasons, and the numerical performance does not seem to be affected without it. Figure \ref{fig:rate-1} shows numerical experiments with i.i.d. observations drawn from $(1-\epsilon)N(0_p,I_p)+ \epsilon N(t*1_p,I_p)$ with $\epsilon=0.2$. The magnitude of $t$ characterizes the distance between $N(0_p,I_p)$ and the contamination distribution $N(t*1_p,I_p)$. When $t$ is very small, the contamination barely affects the overall distribution, and we expect a good performance of the estimator. On other hand, when $t$ is very large, it is easy to tell the difference between the contaminated observations and the good ones. Therefore, the hardest case is when $t$ is close to $0$, but not too close, which is verified by the left plot of Figure \ref{fig:rate-1}. The right plot of Figure \ref{fig:rate-1} demonstrates the relation between $\|w\|_1$ and the value of $t$. Note that a larger value of $\|w\|_1$ indicates that it is easier to tell the difference between the data generating process $(1-\epsilon)N(\theta,I_p)+\epsilon Q$ and the distribution we learned, which is $N(\widehat{\theta},I_p)$. Therefore, we observe an increasing pattern of $\|w\|_1$ with respect to $t$ in Figure \ref{fig:rate-1}. If we imposed a constraint on $\|w\|_1$ in the optimization, the JS-GAN would have a less distinguishing ability between the data generating process and the estimated model, which would further affect the performance of the estimator when $t$ is very large (the error would not eventually decrease as in the left plot in Figure \ref{fig:rate-1}). In summary, the $\ell_1$ constraint is only needed in the proof to establish the minimax (worst-case) convergence rate, but it is not needed in practice so that the estimator can perform even better than the minimax rate when the contamination distribution is far away from $N(\theta,I_p)$. \begin{figure}[H] \includegraphics[width=.48\textwidth]{js_error_.png} \includegraphics[width=.48\textwidth]{js_weight_.png} \caption{Numerical experiments for JS-GAN with $p=100$ and $n=50,000$. Left: $\ell_2$ error with respect to $t$. Right: the $\ell_1$ norm $\|w\|_1$ of the weight matrix in the last layer with respect to $t$. Network structure: 100-20-1.}\label{fig:rate-1} \end{figure} \section{Deep ReLU Networks}\label{sec:deep} In this section, we investigate the performance of discriminator classes of deep neural nets with the ReLU activation function. Since our goal is to learn a $p$-dimensional mean vector, a deep neural network discriminator without any regularization will certainly lead to overfitting. Therefore, it is crucial to design a network class with some appropriate regularizations. Inspired by the work of \cite{bartlett1997valid,bartlett2002rademacher}, we consider a network class with $\ell_1$ regularizations on all layers except for the second last layer with an $\ell_2$ regularization. With $\mathcal{G}_1^H(B)=\left\{g(x)={\sf ReLU}(v^Tx): \|v\|_1\leq B\right\}$, a neural network class with $l+1$ layers is defined as $$\mathcal{G}_{l+1}^H(B)=\left\{g(x)={\sf ReLU}\left(\sum_{h=1}^Hv_hg_h(x)\right): \sum_{h=1}^H|v_h|\leq B, g_h\in\mathcal{G}_l^H(B)\right\}.$$ Combining with the last sigmoid layer, we obtain the following discriminator class, \begin{eqnarray*} {\mathcal{F}}_L^H(\kappa,\tau,B) &=& \Bigg\{D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j{\sf sigmoid}\left(\sum_{h=1}^{2p}u_{jh}g_{jh}(x)+b_j\right)\right): \\ &&\quad\quad \sum_{j\geq 1}|w_j|\leq\kappa, \sum_{h=1}^{2p}u_{jh}^2\leq 2,|b_j|\leq\tau, g_{jh}\in\mathcal{G}_{L-1}^H(B)\Bigg\}. \end{eqnarray*} Note that all the activation functions are ${\sf ReLU}(\cdot)$ except that we use ${\sf sigmoid}(\cdot)$ in the last layer of feature map $g(\cdot)$. A theoretical guarantees of the class defined above is given by the following theorem. \begin{thm}\label{thm:JS-DNN} Assume $\frac{p\log p}{n}\vee\epsilon^2\leq c$ for some sufficiently small constant $c>0$. Consider i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,I_p)+\epsilon Q$ and the estimator $\widehat{\theta}$ defined by (\ref{eq:JS-GAN-gen}) with $\mathcal{D}=\mathcal{F}_L^H(\kappa,\tau,B)$ with $H\geq 2p$, $2\leq L=O(1)$, $2\leq B=O(1)$, and $\tau=\sqrt{p\log p}$. We set $\kappa= O\left(\sqrt{\frac{p\log p}{n}}+\epsilon\right)$. Then, for the estimator $\widehat{\theta}$ defined by (\ref{eq:JS-GAN-gen}) with $\mathcal{D}={\mathcal{F}}_L^H(\kappa,\tau,B)$, we have $$ \|\widehat{\theta}-\theta\|^2\leq C\left(\frac{p\log p}{n}\vee\epsilon^2\right), $$ with probability at least $1-e^{-C'(p\log p+n\epsilon^2)}$ uniformly over all $\theta\in\mathbb{R}^p$ such that $\|\theta\|_{\infty}\leq \sqrt{\log p}$ and all $Q$. \end{thm} The theorem shows that JS-GAN with a deep ReLU network can achieve the error rate $\frac{p\log p}{n}\vee\epsilon^2$ with respect to the squared $\ell_2$ loss. The condition $\|\theta\|_{\infty}\leq\sqrt{\log p}$ for the ReLU network can be easily satisfied with a simple preprocessing step. We split the data into two halves, whose sizes are $\log n$ and $n-\log n$, respectively. Then, we calculate the coordinatewise median $\widetilde{\theta}$ using the small half. It is easy to show that $\|\widetilde{\theta}-\theta\|_{\infty}\leq \sqrt{\frac{\log p}{\log n}}\vee\epsilon$ with high probability. Then, for each $X_i$ from the second half, the conditional distribution of $X_i-\widetilde{\theta}$ given the first half is $(1-\epsilon)N(\theta-\widetilde{\theta},I_p)+\epsilon \widetilde{Q}$. Since $\sqrt{\frac{\log p}{\log n}}\vee\epsilon\leq \sqrt{\log p}$, the condition $\|\theta-\widetilde{\theta}\|_{\infty}\leq\sqrt{\log p}$ is satisfied, and thus we can apply the estimator (\ref{eq:JS-GAN-gen}) using the shifted data $X_i-\widetilde{\theta}$ from the second half. The theoretical guarantee of Theorem \ref{thm:JS-DNN} will be $$\|\widehat{\theta}-(\theta-\widetilde{\theta})\|^2\leq C\left(\frac{p\log p}{n}\vee\epsilon^2\right),$$ with high probability. Hence, we can use $\widehat{\theta}+\widetilde{\theta}$ as the final estimator to achieve the same rate in Theorem \ref{thm:JS-DNN}. On the other hand, our experiments show that this preprocessing step is not needed. We believe that the assumption $\|\theta\|_{\infty}\leq\sqrt{\log p}$ is a technical artifact in the analysis of the Rademacher complexity. It can probably be dropped by a more careful analysis. \section{Elliptical Distributions} \label{sec:ellip} An advantage of Tukey's median (\ref{eq:Tukey}) is that it leads to optimal robust location estimation under general elliptical distributions including Cauchy distribution whose mean does not exist. In this section, we show that JS-GAN shares the same property. A random vector $X\in\mathbb{R}^p$ follows an elliptical distribution if it admits a representation $$X=\theta+\xi AU,$$ where $U$ is uniformly distributed on the unit sphere $\{u\in\mathbb{R}^p:\|u\|=1\}$ and $\xi\geq 0$ is a random variable independent of $U$ that determines the shape of the elliptical distribution \citep{fang2017symmetric}. The center and the scatter matrix are $\theta$ and $\Sigma=AA^T$. For a unit vector $v$, let the density function of $\xi v^TU$ be $h$. Note that $h$ is independent of $v$ because of the symmetry of $U$. Then, there is a one-to-one relation between the distribution of $\xi$ and $h$, and thus the triplet $(\theta,\Sigma,h)$ fully parametrizes an elliptical distribution. Note that $h$ and $\Sigma=AA^T$ are not identifiable, because $\xi A=(c\xi)(c^{-1}A)$ for any $c>0$. Therefore, without loss of generality, we can restrict $h$ to be a member of the following class $$\mathcal{H}=\left\{h:h(t)=h(-t),h\geq 0, \int h=1, \int \sigma(t)(1-\sigma(t))h(t)dt=1\right\}.$$ This makes the parametrization $(\theta,\Sigma,h)$ of an elliptical distribution fully identifiable, and we use $EC(\theta,\Sigma,h)$ to denote an elliptical distribution parametrized in this way. The JS-GAN estimator is defined as \begin{equation} (\widehat{\theta},\widehat{\Sigma},\widehat{h})=\mathop{\rm arginf}_{\eta\in\mathbb{R}^p,\Gamma\in\mathcal{E}_p(M),g\in\mathcal{H}}\sup_{D\in\mathcal{D}}\left[\frac{1}{n}\sum_{i=1}^n\log D(X_i)+E_{EC(\eta,\Gamma,g)}\log(1-D(X))\right]+\log 4,\label{eq:JS-GAN-EC} \end{equation} where $\mathcal{E}_p(M)$ is the set of all positive semi-definite matrix with spectral norm bounded by $M$. \begin{thm}\label{thm:elliptical} Consider the estimator $\widehat{\theta}$ defined above with $\mathcal{D}$ specified by (\ref{eq:JS-NN2}). Assume $M=O(1)$, $\frac{p}{n}+\epsilon^2\leq c$ for some sufficiently small constant $c>0$, and set $\kappa=O\left(\sqrt{\frac{p}{n}}+\epsilon\right)$. With i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)EC(\theta,\Sigma,h)+\epsilon Q$, we have $$\|\widehat{\theta}-\theta\|^2\leq C\left(\frac{p}{n}\vee\epsilon^2\right),$$ with probability at least $1-e^{-C'(p+n\epsilon^2)}$ uniformly over all $\theta\in\mathbb{R}^p$, $\Sigma\in\mathcal{E}_p(M)$ and all $Q$. The constants $C,C'>0$ are universal. \end{thm} Note that Theorem \ref{thm:elliptical} guarantees the same convergence rate as in the Gaussian case for all elliptical distributions. This even includes multivariate Cauchy where mean does not exist. Therefore, the location estimator (\ref{eq:JS-GAN-EC}) is fundamentally different from \cite{diakonikolas2016robust,lai2016agnostic}, which is only designed for robust mean estimation. To achieve rate-optimality for robust location estimation under general elliptical distributions, the estimator (\ref{eq:JS-GAN-EC}) is different from (\ref{eq:JS-GAN-gen}) only in the generator class. They share the same discriminator class (\ref{eq:JS-NN2}). This underlines an important principle for designing GAN estimators: the overall statistical complexity of the estimator is only determined by the discriminator class. The estimator (\ref{eq:JS-GAN-EC}) also outputs $(\widehat{\Sigma},\widehat{h})$, but we do not claim any theoretical property for $(\widehat{\Sigma},\widehat{h})$ in this paper. \section{Numerical Experiments} \label{sec:num} In this section, we give extensive numerical studies of robust mean estimation via GAN. After introducing the implementation details in Section \ref{sec:imp}, we verify our theoretical results on minimax estimation with both TV-GAN and JS-GAN in Section \ref{sec:rate}. Comparison with other methods on robust mean estimation in the literature is given in Section \ref{sect:comp}. The effects of various network structures are studied in Section \ref{sec:n-structure}. Finally, adaptation to unknown covariance structure and elliptical distributions are investigated in Section \ref{sec:cov} and Section \ref{sec:last}. \subsection{Implementations}\label{sec:imp} The implementation for JS-GAN is given in Algorithm \ref{alg:jsgan}, and a simple modification of the objective function leads to that of TV-GAN. A PyTorch implementation is available at \url{https://github.com/zhuwzh/Robust-GAN-Center} or \url{https://github.com/yao-lab/Robust-GAN-Center}. Several important implementation details are listed below. \begin{algorithm} \caption{JS-GAN: $\mathop{\rm arginf}_{\eta}\sup_{w}[\frac{1}{n}\sum_{i=1}^n \log D_{w}(X_i) + \mathbb{E} \log(1-D_{w}(G_{\eta}(Z)))]$}\label{alg:jsgan} \textbf{Input}: Observation set $S=\{X_{1},\ldots,X_{n}\}\in\mathbb{R}^{p}$, discriminator network $D_{w}(x)$, generator network $G_{\eta}(z)=z+\eta$, learning rates $\gamma_{d}$ and $\gamma_{g}$ for the discriminator and the generator, batch size $m$, discriminator steps in each iteration $K$, total epochs $T$, average epochs $T_0$.\\ \textbf{Initialization}: Initialize $\eta$ with coordinatewise median of $S$. Initialize $w$ with $N(0, .05)$ independently on each element or Xavier \citep{glorot2010understanding}. \begin{algorithmic}[1] \For{\texttt{$t=1,\ldots,T$}} \For{\texttt{$k=1,\ldots,K$}} \State Sample mini-batch $\{X_{1},\ldots,X_{m}\}$ from $S$. Sample $\{Z_{1},\ldots,Z_{m}\}$ from $N(0,I_{p})$ \State $g_{w}\gets\nabla_{w}[\frac{1}{m}\Sigma_{i=1}^{m} \log D_{w}(X_{i}) + \frac{1}{m}\Sigma_{i=1}^{m} \log (1 - D_{w}(G_{\eta}(Z_{i})))]$ \State $w \gets w + \gamma_{d}g_{w}$ \EndFor \State Sample $\{Z_{1},\ldots,Z_{m}\}$ from $N(0,I_{p})$ \State $g_{\eta}\gets\nabla_{\eta}[\frac{1}{m}\Sigma_{i=1}^{m} \log(1-D_{w}(G_{\eta}(Z_{i})))]$ \State $\eta \gets \eta - \gamma_{g}g_{\eta}$ \EndFor \end{algorithmic} \textbf{Return}: The average estimate $\eta$ over the last $T_0$ epochs. \end{algorithm} \begin{itemize} \item \textit{How to tune parameters?} The choice of learning rates is crucial to the convergence rate, but the minimax game is hard to evaluate. We propose a simple strategy to tune hyper-parameters including the learning rates. Suppose we have estimators $\widehat{\theta}_{1},\ldots, \widehat{\theta}_{M}$ with corresponding discriminator networks $D_{\widehat{w}_{1}}$,\ldots, $D_{\widehat{w}_{M}}$. Fixing $\eta=\widehat{\theta}$, we further apply gradient descent to $D_{w}$ with a few more epochs (but not many in order to prevent overfitting, for example 10 epochs) and select the $\widehat{\theta}$ with the smallest value of the objective function (\ref{eq:JS-GAN-gen}) (JS-GAN) or (\ref{eq:TV-GAN-NN1}) (TV-GAN). We note that training discriminator and generator alternatively usually will not suffer from overfitting since the objective function for either the discriminator or the generator is always changing. However, we must be careful about the overfitting issue when training the discriminator alone with a fixed $\eta$, and that is why we apply an early stopping strategy here. Fortunately, the experiments show that if the structures of networks are same (then of course, the dimensions of the inputs are same), the choices of hyper-parameters are robust to different models. \iffalse \begin{table}[h] \centering \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline Structure & Net & $\gamma_g$ & $\gamma_d$ & $K$ & $T$ & $T_0$ & $\lambda$\\ \hline \hline \multirow{2}{*}{100-20-1} & JS & 0.02 & 0.2 & 5 & 150 & 25 & 0 \\ & TV & 0.0001 & 0.3 & 2 & 150 & 1 & 0.1 \\ \hline \multirow{2}{*}{100-2-1} & JS & 0.01 & 0.2 & 5 & 150 & 25 & 0 \\ & TV & 0.01 & 0.1 & 5 & 150 & 1 & 1 \\ \hline \multirow{2}{*}{200-20-1} & JS & 0.02 & 0.2 & 5 & 200 & 25 & 0 \\ & TV & 0.0001 & 0.1 & 2 & 200 & 1 & 0.5 \\ \hline 200-200-100-1 & JS & 0.005 & 0.1 & 2 & 200 & 25 & 0 \\ \hline 400-200-20-1 & JS & 0.02 & 0.05 & 2 & 250 & 25 & 0.5 \\ \hline \end{tabular} \caption{Choices of hyper-parameters. The parameter $\lambda$ is the penalty factor for the regularization term (\ref{eq:alg-reg}) and other parameters are listed in Algorithm \ref{alg:jsgan}. We apply Xavier initialization \citep{glorot2010understanding} for both JS-GAN and TV-GAN trainings.}\label{tab:param} \end{table} \fi \item \textit{When to stop training?} Judging convergence is a difficult task in GAN trainings, since sometimes oscillation may occur. In computer vision, people often use a task related measure and stop training once the requirement based on the measure is achieved. In our experiments below, we simply use a sufficiently large $T$ (see below), which works well in practice. It is interesting to explore an efficient early stopping rule in the future work. \item \textit{How to design the network structure?} Although Theorem \ref{thm:TV-NN1} and Theorem \ref{thm:JS-NN2} guarantee the minimax rates of TV-GAN without hidden layer and JS-GAN with one hidden layer, one may wonder whether deeper network structures will perform better. From our experiments, TV-GAN with one hidden layer is better than TV-GAN without any hidden layer. Moreover, JS-GAN with deep network structures can significantly improve over shallow networks especially when the dimension is large (e.g. $p\geq 200$). For a network with one hidden layer, the choice of width may depend on the sample size. If we only have 5,000 samples of 100 dimensions, two hidden units performs better than five hidden units, which performs better than twenty hidden units. If we have 50,000 samples, networks with twenty hidden units perform the best. \item \textit{How to stabilize and accelerate TV-GAN?} As we have discussed in Section \ref{sec:TV-GAN}, TV-GAN has a bad landscape when $N(\theta,I_p)$ and the contamination distribution $Q$ are linearly separable (see Figure \ref{fig:tv_landscape_10}). An outlier removal step before training TV-GAN may be helpful. Besides, spectral normalization \citep{miyato2018spectral} is also worth trying since it can prevent the weight from going to infinity and thus can increase the chance to escape from bad saddle points. To accelerate the optimization of TV-GAN, in all the numerical experiments below, we adopt a regularized version of TV-GAN inspired by Proposition \ref{prop:local-JS}. Since a good feature extractor should match nonlinear moments of $P=(1-\epsilon)N(\theta,I_p) + \epsilon Q$ and $N(\eta, I_{p})$, we use an additional regularization term that can accelerate training and sometimes even leads to better performances. Specifically, let $D(x)={\sf sigmoid}(w^T\Phi(x))$ be the discriminator network with $w$ being the weights of the output layer and $\Phi_D(x)$ be the corresponding network after removing the output layer from $D(x)$. The quantity $\Phi_D(x)$ is usually viewed as a feature extractor, which naturally leads to the following regularization term \citep{salimans2016improved,mroueh2017mcgan}, defined as \begin{equation}\label{eq:alg-reg} r(D,\eta) = \left\|T(\Phi_D, \mathbb{P}_n) - T(\Phi_D, N(\eta, I_{p}))\right\|^{2}, \end{equation} where $\mathbb{P}_n=(1/n)\sum_{i=1}^n\delta_{X_i}$ is the empirical distribution, and $T(\Phi, P)$ can be either moment matching $T(\Phi, P)=\mathbb{E}_{P}\Phi(X)$, or median matching $T(\Phi, P)=\textnormal{Median}_{X\sim P}\Phi_D(X)$. \end{itemize} \subsection{Numerical Supports for the Minimax Rates}\label{sec:rate} In this section, we verify the minimax rates achieved by TV-GAN (Theorem \ref{thm:TV-NN1}) and JS-GAN (Theorem \ref{thm:JS-NN2}) via numerical experiments. The TV-GAN has no hidden layer, while the JS-GAN has one hidden layer with five hidden units in our experiments. All activation functions are sigmoid. Two main scenarios we consider here are $\sqrt{p/n} < \epsilon$ and $\sqrt{p/n}>\epsilon$, where in both cases, various types of contamination distributions $Q$, are considered. We introduce the contamination distributions $Q$ used in the experiments. We first consider $Q=N(\mu,I_p)$ with $\mu$ ranges in $\{0.2,0.5,1,5\}$. Note that the total variation distance between $N(0_p,I_p)$ and $N(\mu,I_p)$ is of order $\|0_p-\mu\|=\|\mu\|$. We hope to use different levels of $\|\mu\|$ to test the algorithm and verify the error rate in the worst case. Second, we consider $Q=N(1.5*1_p, \Sigma)$ to be a Gaussian distribution with a non-trivial covariance matrix $\Sigma$. The covariance matrix is generated according to the following steps. First generate a sparse precision matrix $\Gamma=(\gamma_{ij})$ with each entry $\gamma_{ij} = z_{ij}*\tau_{ij}, i\leq j$, where $z_{ij}$ and $\tau_{ij}$ are independently generated from Uniform$(0.4, 0.8)$ and Bernoulli$(0.1)$. We then define $\gamma_{ij}=\gamma_{ji}$ for all $i>j$ and $\bar{\Gamma}=\Gamma + (|\min \textnormal{eig}(\Gamma)| + 0.05)I_p$ to make the precision matrix symmetric and positive definite, where $\min\textnormal{eig}(\Gamma)$ is the smallest eigenvalue of $\Gamma$. The covariance matrix is $\Sigma=\bar{\Gamma}^{-1}$. Finally, we consider $Q$ to be a Cauchy distribution with independent component, and the $j$th component takes a standard Cauchy distribution with location parameter $\tau_j=0.5$. Tables \ref{tab:rate-eps}-\ref{tab:rate-n} show experiment results with i.i.d. samples drawn from $(1-\epsilon)N(0_p,I_p)+\epsilon Q$. The first scenario we consider is when $\epsilon$ dominates $\sqrt{p/n}$, and we expect the worse-case $\ell_2$ loss $\|\widehat{\theta}-\theta\|$ is approximately linear with respect to $\epsilon$. Table \ref{tab:rate-eps} shows the performance of both JS-GAN and TV-GAN. To visualize the verification of the minimax rate, we take the maximum error among all choices of $Q$ in Table \ref{tab:rate-eps}, and plot the worst-case errors in Figure \ref{fig:rate}. Similar experiments are conducted for the second scenario when $\sqrt{p/n}$ dominates $\epsilon$. Table \ref{tab:rate-p} and Table \ref{tab:rate-n} show experiment results with a fixed $n$ and a fixed $p$, respectively. Again, the worst-case errors among all $Q$'s considered are plotted in Figure \ref{fig:rate}. \begin{table}[H] \centering \resizebox{\linewidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|} \hline $Q$ & Net & $\epsilon=0.05$ & $\epsilon=0.10$ & $\epsilon=0.15$ & $\epsilon=0.20$\\ \hline \hline \multirow{2}{*}{$N(0.2*1_p,I_p)$} & JS & 0.1025 (0.0080) & 0.1813 (0.0122) & \textbf{0.2632 (0.0080)} & \textbf{0.3280 (0.0069)} \\ & TV & 0.1110 (0.0204) & 0.2047 (0.0112) & 0.2769 (0.0315) & 0.3283 (0.0745) \\ \hline \multirow{2}{*}{$N(0.5*1_p, I_p)$} & JS & 0.1407 (0.0061) & 0.1895 (0.0070) & 0.1714 (0.0502) & 0.1227 (0.0249)\\ & TV & 0.2003 (0.0480) & 0.2065 (0.1495) & 0.2088 (0.0100) & 0.3985 (0.0112)\\ \hline \multirow{2}{*}{$N(1_p, I_p)$} & JS & 0.0855 (0.0054) & 0.1055 (0.0322) & 0.0602 (0.0133) & 0.0577 (0.0029) \\ & TV & 0.1084 (0.0063) & 0.0842 (0.0036) & 0.3228 (0.0123) & 0.1329 (0.0125)\\ \hline \multirow{2}{*}{$N(5*1_p, I_p)$} & JS & 0.0587 (0.0033) & 0.0636 (0.0025) & 0.0625 (0.0045) & 0.0591 (0.0040) \\ & TV & \textsl{1.2886 (0.5292)} & \textsl{4.4511 (0.8754)} & \textsl{7.3868 (0.8081)} & \textsl{10.5724 (1.2605)}\\ \hline \multirow{2}{*}{Cauchy$(0.5*1_p)$} & JS & 0.0625 (0.0045) & 0.0652 (0.0044) & 0.0648 (0.0035) & 0.0687 (0.0042)\\ & TV & 0.2280 (0.0067) & 0.3842 (0.0083) & 0.5740 (0.0071) & \textbf{0.7768 (0.0074)}\\ \hline \multirow{2}{*}{$N(0.5*1_p,\Sigma)$} & JS & \textbf{0.1490 (0.0061)} & \textbf{0.1958 (0.0074)} & 0.2379 (0.0076) & 0.1973 (0.0679) \\ & TV & \textbf{0.2597 (0.0090)} & \textbf{0.4621 (0.0649)} & \textbf{0.6344 (0.0905)} & 0.7444 (0.3115) \\ \hline \end{tabular}} \caption{Scenario I: $\sqrt{p/n}<\epsilon$. Setting: $p=100, n=50,000$, and $\epsilon$ from $0.05$ to $0.20.$ Network structure of JS-GAN: one hidden layer with 5 hidden units. Network structure of TV-GAN: zero-hidden layer. The number in each cell is the average of $\ell_2$ loss $\|\widehat{\theta}-\theta\|$ with standard deviation in parenthesis from 10 repeated experiments. The bold character marks the worst case among our choices of $Q$ at each $\epsilon$ level. The results of TV-GAN for $Q=N(5*1_p,I_{p})$ are highlighted in slanted font. The failure of training in this case is due to the bad landscape when $N(0_p,I_p)$ and $Q$ are linearly separable, as discussed in Section \ref{sec:TV-GAN} (see Figure \ref{fig:tv_landscape_10}).}\label{tab:rate-eps} \end{table} \begin{table}[H] \centering \resizebox{\linewidth}{!} \begin{tabular}{|c|c|c|c|c|c|c|} \hline $Q$ & Net & $p=10$ & $p=25$ & $p=50$ & $p=75$ & $p=100$\\ \hline\hline \multirow{2}{*}{$N(0.2*1_p,I_p)$} & JS & 0.1078 (0.0338) & 0.1819 (0.0215) & 0.3355 (0.0470) & 0.4806 (0.0497) & 0.5310 (0.0414)\\ &TV & 0.2828 (0.0580) & 0.4740 (0.1181) & 0.5627 (0.0894) & 0.8217 (0.0382) & 0.8090 (0.0457) \\ \hline \multirow{2}{*}{$N(0.5*1_p, I_p)$} & JS & 0.1587 (0.0438) & 0.2684 (0.0386) & \textbf{0.4213 (0.0356)} & \textbf{0.5355 (0.0634)} & 0.6825 (0.0981)\\ & TV & 0.2864 (0.0521) & 0.5024 (0.1038) & 0.6878 (0.1146) & 0.9204 (0.0589) & 0.9418 (0.0551) \\ \hline \multirow{2}{*}{$N(1_p, I_p)$} & JS & 0.1644 (0.0255) & 0.2177 (0.0480) & 0.3505 (0.0552) & 0.4740 (0.0742) & 0.6662 (0.0611) \\ & TV & \textbf{0.3733 (0.0878)} & \textbf{0.5407 (0.0634)} & \textbf{0.9061 (0.1029)} & \textbf{1.0672 (0.0629)} & \textbf{1.1150 (0.0942)} \\ \hline \multirow{2}{*}{$N(5*1_p, I_p)$} & JS & 0.0938 (0.0195) & 0.2058 (0.0218) & 0.3316 (0.0462) & 0.4054 (0.0690) & 0.5553 (0.0518) \\ & TV & 0.3707 (0.2102) & 0.7434 (0.3313) & 1.1532 (0.3488) & 1.1850 (0.3739) & 1.3257 (0.1721) \\ \hline \multirow{2}{*}{Cauchy$(0.5*1_p)$} & JS & 0.1188 (0.0263) & 0.1855 (0.0282) & 0.2967 (0.0284) & 0.4094 (0.0385) & 0.4826 (0.0479) \\ & TV & 0.3198 (0.1543) & 0.5205 (0.1049) & 0.6240 (0.0652) & 0.7536 (0.0673) & 0.7612 (0.0613) \\ \hline \multirow{2}{*}{$N(0.5*1_p,\Sigma)$} & JS & \textbf{0.1805 (0.0220)} & \textbf{0.2692 (0.0318)} & 0.3885 (0.0339) & 0.5144 (0.0547) & \textbf{0.6833 (0.1094)} \\ & TV & 0.3036 (0.0736) & 0.5152 (0.0707) & 0.7305 (0.0966) & 0.9460 (0.0900) & 1.0888 (0.0863) \\ \hline \end{tabular}} \caption{Scenario II-a: $\sqrt{p/n}>\epsilon$. Setting: $n=1,000, \epsilon=0.1$, and $p$ from $10$ to $100$. Other details are the same as above. The bold character marks the worst case among our choices of $Q$ at each level of $p$.}\label{tab:rate-p} \end{table} \begin{table}[H] \centering \resizebox{\linewidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|c|} \hline $Q$ & Net & $n=50$ & $n=100$ & $n=200$ & $n=500$ & $n=1000$\\ \hline \hline \multirow{2}{*}{$N(0.2*1_p,I_p)$} & JS & 1.3934 (0.5692) & 1.0055 (0.1040) & 0.8373 (0.1335) & 0.4781 (0.0677) & 0.3213 (0.0401) \\ &TV & 1.9714 (0.1552) & 1.2629 (0.0882) & 0.7579 (0.0486) & 0.6640 (0.0689) & 0.6348 (0.0547)\\ \hline \multirow{2}{*}{$N(0.5*1_p, I_p)$} & JS & 1.6422 (0.6822) & 1.2101 (0.2826) & 0.8374 (0.1021) & \textbf{0.5832 (0.0595)} & 0.3930 (0.0485)\\ & TV & 1.9780 (0.2157) & 1.2485 (0.0668) & 0.8198 (0.0778) & 0.7597 (0.0456) & 0.7346 (0.0750) \\ \hline \multirow{2}{*}{$N(1_p, I_p)$} & JS & 1.8427 (0.9633) & 1.2179 (0.2782) & \textbf{1.0147 (0.2170)} & 0.5586 (0.1013) & 0.3639 (0.0464) \\ & TV & 1.9907 (0.1498) & \textbf{1.4575 (0.1270)} & \textbf{0.9724 (0.0802)} & \textbf{0.9050 (0.1479)} & \textbf{0.8747 (0.0757)} \\ \hline \multirow{2}{*}{$N(5*1_p, I_p)$} & JS & \textbf{2.6392 (1.3877)} & \textbf{1.3966 (0.5370)} & 0.9633 (0.1383) & 0.5360 (0.0808) & 0.3265 (0.0336) \\ & TV & 2.1050 (0.3763) & 1.5205 (0.2221) & 1.1909 (0.2273) & 1.0957 (0.1390) & 1.0695 (0.2639) \\ \hline \multirow{2}{*}{Cauchy$(0.5*1_p)$} & JS & 1.6563 (0.5246) & 1.0857 (0.3613) & 0.8944 (0.1759) & 0.5363 (0.0593) & 0.3832 (0.0408) \\ & TV & \textbf{2.1031 (0.2300)} & 1.1712 (0.1493) & 0.6904 (0.0763) & 0.6300 (0.0642) & 0.5085 (0.0662) \\ \hline \multirow{2}{*}{$N(0.5*1_p,\Sigma)$} & JS & 1.2296 (0.3157) & 0.7696 (0.0786) & 0.5892 (0.0931) & 0.5015 (0.0831) & \textbf{0.4085 (0.0209)} \\ & TV & 1.9243 (0.2079) & 1.2217 (0.0681) & 0.7939 (0.0688) & 0.7033 (0.0414) & 0.7125 (0.0490) \\ \hline \end{tabular}} \caption{Scenario II-b: $\sqrt{p/n}>\epsilon$. Setting: $p=50, \epsilon=0.1$, and $n$ from $50$ to $1,000$. Other details are the same as above. The bold character marks the worst case among our choices of $Q$ at each level of $n$.}\label{tab:rate-n} \end{table} \begin{figure}[H] \includegraphics[width=.32\textwidth]{rate_eps.png} \includegraphics[width=.32\textwidth]{rate_p.png} \includegraphics[width=.32\textwidth]{rate_n.png} \caption{$\ell_2$ error $\|\widehat{\theta} - \theta\|$ against $\epsilon$ (left), $\sqrt{p}$ (middle) and $1/\sqrt{n}$ (right), respectively. The vertical bars indicate $\pm$ standard deviations. In all cases, the errors are approximately linear with respect to the corresponding numbers, which empirically verifies the conclusions of Theorem \ref{thm:TV-NN1} and Theorem \ref{thm:JS-NN2}.}\label{fig:rate} \end{figure} \subsection{Comparisons with Other Methods}\label{sect:comp} We perform additional experiments to compare with other methods including \textit{dimension halving} \citep{lai2016agnostic} and \textit{iterative filtering} \citep{diakonikolas2017being} under various settings. \begin{itemize} \item \textit{Dimension Halving.} Experiments conducted are based on the code from \url{https://github.com/kal2000/AgnosticMeanAndCovarianceCode}. The only hyper-parameter is the threshold in the outlier removal step, and we take $C=2$ as suggested in the file \textsf{outRemSperical.m}. \item \textit{Iterative Filtering.} Experiments conducted are based on the code from \url{https://github.com/hoonose/robust-filter}. We assume $\epsilon$ is known and take other hyper-parameters as suggested in the file \textsf{filterGaussianMean.m}. \end{itemize} We emphasize that our method does not require any prior knowledge the nuisance parameters such as the contamination proportion $\epsilon$. Tuning GAN is only a matter of optimization and one can tune parameters based on the objective function only. Table \ref{tab:comparison} shows the performances of JS-GAN, TV-GAN, dimension halving, and iterative filtering with i.i.d. observations sampled from $(1-\epsilon)N(0_p,I_p)+\epsilon Q$. The network structure, for both JS-GAN and TV-GAN, has one hidden layer with 20 hidden units when the sample size is 50,000 and 2 hidden units when sample size is 5,000. With fixed network structure, the hyper parameters are robust to various sampling distributions. For the network with 20 hidden units, the critical parameters to reproduce the results in the table are $\gamma_g=0.02$, $\gamma_d=0.2$, $K=5$, $T=150$ ($p=100$), $T=250$ ($p=200$), $T_0 = 25$ for JS-GAN and $\gamma_{g}=0.0001$, $\gamma_{d}=0.3$, $K=2$, $T=150$ ($p=100$), $T=250$ ($p=200$), $T_0=1$, $\lambda=0.1$ for TV-GAN, where $\lambda$ is the penalty factor of the additional regularization term (\ref{eq:alg-reg}). For the network with 2 hidden units, the critical parameters to reproduce the results below are $\gamma_g=0.01$, $\gamma_d=0.2$, $K=5$, $T=150$ ($p=100$), $T_0 = 25$ for JS-GAN and $\gamma_{g}=0.01$, $\gamma_{d}=0.1$, $K=5$, $T=150$ ($p=100$), $T_0=1$ for TV-GAN. We use Xavier initialization \citep{glorot2010understanding} for both JS-GAN and TV-GAN trainings. To summarize, our method outperforms other algorithms in most cases. TV-GAN is good at cases when $Q$ and $N(0_p, I_p)$ are non-separable but fails when $Q$ is far away from $N(0_p, I_p)$ due to optimization issues discussed in Section \ref{sec:TV-GAN} (Figure \ref{fig:tv_landscape_10}). On the other hand, JS-GAN stably achieves the lowest error in separable cases and also shows competitive performances for non-separable ones. \begin{table}[H] \begin{center} \resizebox{\linewidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline $Q$ & $n$ & $p$ & $\epsilon$ & TV-GAN & JS-GAN & Dimension Halving & Iterative Filtering \\%& Median \\ \hline\hline $N(0.5*1_p, I_p)$ & 50,000 & 100 & .2 & \textbf{0.0953 (0.0064)} & 0.1144 (0.0154) & 0.3247 (0.0058) & 0.1472 (0.0071) \\ \hline $N(0.5*1_p, I_p)$ & 5,000 & 100 & .2 & \textbf{0.1941 (0.0173)} & 0.2182 (0.0527) & 0.3568 (0.0197) & 0.2285 (0.0103) \\ \hline $N(0.5*1_p, I_p)$ & 50,000 & 200 & .2 & \textbf{0.1108 (0.0093)} & 0.1573 (0.0815) & 0.3251 (0.0078) & 0.1525 (0.0045) \\%& 1.3908(0.0059)\\ \hline $N(0.5*1_p ,I_p)$ & 50,000 & 100 &.05 & 0.0913 (0.0527) & 0.1390 (0.0050) & 0.0814 (0.0056) &\textbf{0.0530 (0.0052)}\\ \hline $N(5*1_p, I_p)$ & 50,000 & 100 & .2 & 2.7721 (0.1285) & \textbf{0.0534 (0.0041)} & 0.3229 (0.0087) & 0.1471 (0.0059)\\ \hline $N(0.5*1_p, \Sigma)$ & 50,000 & 100 & .2 & 0.1189 (0.0195) & \textbf{0.1148 (0.0234)} & 0.3241 (0.0088) & 0.1426 (0.0113)\\% & 0.9903 (0.0037)\\ \hline Cauchy$(0.5*1_p)$ & 50,000 & 100 & .2& 0.0738 (0.0053) & \textbf{0.0525 (0.0029)} & 0.1045 (0.0071) & 0.0633 (0.0042)\\ \hline \end{tabular}} \caption{Comparison of various robust mean estimation methods. The smallest error of each case is highlighted in bold.}\label{tab:comparison} \end{center} \end{table} \subsection{Network Structures}\label{sec:n-structure} In this section, we study the performances of TV-GAN and JS-GAN with various structures of neural networks. The experiments are conducted with i.i.d. observations drawn from $(1-\epsilon)N(0_p, I_p)+\epsilon N(0.5*1_p, I_p)$ with $\epsilon=0.2$. Table \ref{tab:shallownet} summarizes results for $p=100$, $n\in\{5000,50000\}$ and various network structures. We observe that TV-GAN that uses neural nets with one hidden layer improves over the performance of that without any hidden layer. This indicates that the landscape of TV-GAN is improved by a more complicated network structure. However, adding one more layer does not improve the results. For JS-GAN, we omit the results without hidden layer because of its lack of robustness (Proposition \ref{prop:local-JS}). Deeper networks sometimes improve over shallow networks, but this is not always true. Table \ref{tab:deepnet} illustrates the improvements of network with more than one hidden layers over that with only one hidden layer for JS-GAN when $p\in\{200,400\}$. We also observe that the optimal choice of the width of the hidden layer depends on the sample size. \begin{table}[H] \centering \begin{tabular}{|c|c|c|c|c|} \hline Structure & $n$ & JS-GAN & TV-GAN \\ \hline\hline 100-1 & 50,000 & - & 0.1173 (0.0056) \\ \hline 100-20-1 & 50,000 & 0.0953 (0.0064) & 0.1144 (0.0154) \\ \hline 100-50-1 & 50,000 & 0.2409 (0.0500) & 0.1597 (0.0219) \\ \hline 100-20-20-1 & 50,000 & 0.1131 (0.0855) & 0.1724 (0.0295)\\ \hline 100-1 & 5,000 & - & 0.9818 (0.0417)\\ \hline 100-2-1 & 5,000 & 0.1941 (0.0173) & 0.1941 (0.0173) \\ \hline 100-5-1 & 5,000 & 0.2148 (0.0241) & 0.2244 (0.0238) \\ \hline 100-20-1 & 5,000 & 0.3379 (0.0273) & 0.3336 (0.0186) \\ \hline \end{tabular} \caption{Experiment results for JS-GAN and TV-GAN with various network structures.}\label{tab:shallownet} \end{table} \begin{table}[H] \centering \begin{tabular}{|c|c|c|c|c|} \hline $p$ & 200-100-20-1 & 200-20-10-1 & 200-100-1 & 200-20-1 \\ \hline 200 & \textbf{0.0910 (0.0056)} & 0.2251 (0.1311) & 0.3064 (0.0077) & 0.1573 (0.0815) \\ \hline \hline $p$ & 400-200-100-50-20-1 & 400-200-100-20-1 & 400-200-20-1 & 400-200-1 \\ \hline 400 & 0.1477 (0.0053) & 0.1732 (0.0397) & \textbf{0.1393 (0.0090)} & 0.3604 (0.0990) \\ \hline \end{tabular} \caption{Experiment results for JS-GAN using networks with different structures. The samples are drawn independently from $(1-\epsilon)N(0_p, I_p)+\epsilon N(0.5*1_p, I_p)$ with $\epsilon=0.2$, $p\in\{200,400\}$ and $n=50,000$.}\label{tab:deepnet} \end{table} \subsection{Adaptation to Unknown Covariance} \label{sec:cov} The robust mean estimator constructed through JS-GAN can be easily made adaptive to unknown covariance structure, which is a special case of (\ref{eq:JS-GAN-EC}). We define $$ (\widehat{\theta},\widehat{\Sigma}) = \mathop{\rm arginf}_{\eta\in\mathbb{R}^p,\Gamma\in\mathcal{E}_p}\sup_{D\in\mathcal{D}}\left[\frac{1}{n}\sum_{i=1}^n\log D(X_i) + E_{N(\eta,\Gamma)}\log(1-D(X_i))\right]+\log 4, $$ The estimator $\widehat{\theta}$, as a result, is rate-optimal even when the true covariance matrix is not necessarily identity and is unknown (see Theorem \ref{thm:elliptical}). Below, we demonstrate some numerical evidence of the optimality of $\widehat{\theta}$ as well as the error of $\widehat{\Sigma}$ in Table \ref{tab:unknowcov}. \begin{table}[ht] \centering \resizebox{0.9\linewidth}{!}{% \begin{tabular}{|c||c|c|c|c|} \hline Data generating process & Network structure & $\|\widehat{\theta}-0_p\|$ & $\opnorm{\widehat{\Sigma}-\Sigma_1}$ \\ \hline\hline $0.8N(0_p, \Sigma_1)+0.2N(0.5*1_p, \Sigma_2)$ & 100-20-1 & 0.1680 (0.1540) & 1.9716 (0.7405) \\ \hline $0.8N(0_p, \Sigma_1)+0.2N(0.5*1_p, \Sigma_2)$ & 100-20-20-1 & 0.1824 (0.3034) & 1.4495 (0.6028) \\ \hline $0.8N(0_p, \Sigma_1)+0.2N(1_p, \Sigma_2)$ & 100-20-1 & 0.0817 (0.0213) & 1.2753 (0.4523) \\ \hline $0.8N(0_p, \Sigma_1)+0.2N(6*1_p, \Sigma_2)$ & 100-20-1 & 0.1069 (0.0357) & 1.1668 (0.1839) \\ \hline $0.8N(0_p, \Sigma_1)+0.2\textnormal{Cauchy}(0.5*1_p)$ & 100-20-1 & 0.0797 (0.0257) & 4.0653 (0.1569) \\ \hline \end{tabular}} \caption{Numerical experiments for robust mean estimation with unknown covariance trained with $50,000$ samples. The covariance matrices $\Sigma_1$ and $\Sigma_2$ are generated by the same way described in Section \ref{sec:rate}.}\label{tab:unknowcov} \end{table} \subsection{Adaptation to Elliptical Distributions}\label{sec:last} To illustrate the performance of (\ref{eq:JS-GAN-EC}), we conduct a numerical experiment for the estimation of the location parameter $\theta$ with i.i.d. observations $X_1,...,X_n\sim(1-\epsilon)\textnormal{Cauchy}(\theta, I_p) + \epsilon Q$. The density function of $\textnormal{Cauchy}(\theta, I_p)$ is given by $p_{\theta}(x) \propto \left(1+\|x-\theta\|\right)^{-(1+p)/2}$. Compared with Algorithm \ref{alg:jsgan}, the difference lies in the choice of the generator. We consider the generator $G_1(\xi, U)=g_\omega(\xi)U + \theta$, where $g_\omega(\xi)$ is a non-negative neural network parametrized by $\omega$ and some random variable $\xi$. The random vector $U$ is sampled from the uniform distribution on $\{u\in\mathbb{R}^p: \|u\|=1\}$. If the scatter matrix is unknown, we will use the generator $G_2(\xi, U)=g_\omega(\xi)AU + \theta$, with $AA^T$ modeling the scatter matrix. Table \ref{tab:EC} shows the comparison with other methods. Our method still works well under Cauchy distribution, while the performance of other methods that rely on moment conditions deteriorates in this setting. \vspace{-2mm} \begin{table}[H] \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{|c|c|c|c|c|} \hline Contamination $Q$ & JS-GAN ($G_1$) & JS-GAN ($G_2$) & Dimension Halving & Iterative Filtering \\%& Median \\ \hline\hline $\textnormal{Cauchy}(1.5*1_p, I_p)$ & \bf{0.0664 (0.0065)} & 0.0743 (0.0103) & 0.3529 (0.0543) & 0.1244 (0.0114) \\ \hline $\textnormal{Cauchy}(5.0*1_p, I_p)$ & \bf{0.0480 (0.0058)} & 0.0540 (0.0064) & 0.4855 (0.0616)& 0.1687 (0.0310) \\ \hline $\textnormal{Cauchy}(1.5*1_p, 5*I_p)$ & 0.0754 (0.0135) & \bf{0.0742 (0.0111)} & 0.3726 (0.0530) & 0.1220 (0.0112) \\ \hline $\textnormal{Normal}(1.5*1_p, 5*I_p)$ & \bf{0.0702 (0.0064)} & 0.0713 (0.0088) & 0.3915 (0.0232) & 0.1048 (0.0288)) \\ \hline \end{tabular}} \caption{{Comparison of various methods of robust location estimation under Cauchy distributions. Samples are drawn from $(1-\epsilon)\textnormal{Cauchy}(0_p, I_p) + \epsilon Q$ with $\epsilon=0.2, p=50$ and various choices of $Q$. Sample size: 50,000. Discriminator net structure: 50-50-25-1. Generator $g_\omega(\xi)$ structure: 48-48-32-24-12-1 with absolute value activation function in the output layer. }}\label{tab:EC} \end{center} \end{table} \vspace{-2mm} \section{Discussions} \label{sec:disc} \paragraph{Variational Lower Bounds for Robust Estimation.} In this paper, we study robust estimation via the technique of generative adversarial nets. We show that the presence of hidden layers are crucial for the estimators trained by JS-GAN to be robust. To better understand the intuition of the results in the paper, we give some further discussion from the perspective of variational lower bounds. In view of (\ref{eq:f-div-variational}), we have \begin{equation} {\sf JS}(N(\theta,I_p),N(\eta,I_p))\geq \sup_{D\in\mathcal{D}}\left[E_{N(\theta,I_p)}\log D(X)+E_{N(\eta,I_p)}\log(1-D(X))\right]+\log 4, \label{eq:vlb-JS} \end{equation} for any discriminator class $\mathcal{D}$. Moreover, according to \citep{nguyen2010estimating,goodfellow2014generative}, the optimal discriminator is achieved at \begin{equation} D(X)=\frac{dN(\theta,I_p)}{dN(\theta,I_p)+dN(\eta,I_p)}(X)={\sf sigmoid}\left((\theta-\eta)^TX+\frac{\|\eta\|^2-\|\theta\|^2}{2}\right). \label{eq:optimal-discri} \end{equation} Interestingly, (\ref{eq:optimal-discri}) is in the form of logistic regression, and this immediately implies that the variational lower bound (\ref{eq:vlb-JS}) is sharp when we take $\mathcal{D}$ to be the class of logistic regression defined in (\ref{eq:TV-NN1}). Indeed, when there is no contamination or $\epsilon=0$, the sample version of JS-GAN (\ref{eq:JS-GAN-gen}) with the logistic regression discriminator class (\ref{eq:TV-NN1}) leads to the estimator $\widehat{\theta}=\frac{1}{n}\sum_{i=1}^nX_i$ according to Proposition \ref{prop:local-JS}, and this is obviously a minimax optimal estimator \citep{lehmann2006theory}. In contrast, when there is contamination or $\epsilon>0$, the logistic regression discriminator class (\ref{eq:TV-NN1}) does not even lead to a consistent estimator. This is because the population objective function to be minimized is $${\sf JS}\left((1-\epsilon)N(\theta,I_p)+\epsilon Q,N(\eta,I_p)\right)$$ instead of ${\sf JS}(N(\theta,I_p),N(\eta,I_p))$. The variational lower bound with the logistic regression discriminator class (\ref{eq:TV-NN1}) is not sharp anymore because of the presence of the contamination distribution $Q$. In fact, a discriminator class $\mathcal{D}$ that leads to a sharp variational lower bound has to include the function \begin{equation} D(X)=\frac{(1-\epsilon)dN(\theta,I_p)+\epsilon dQ}{(1-\epsilon)dN(\theta,I_p)+\epsilon dQ+dN(\eta,I_p)}(X).\label{eq:D-with-Q} \end{equation} However, since there is no assumption on the contamination distribution $Q$, the discriminator function (\ref{eq:D-with-Q}) can take an infinite many of forms. As a consequence, a discriminator class $\mathcal{D}$ that includes all possible functions in the form of (\ref{eq:D-with-Q}) will certainly overfit the data, and thus is not practical at all. On the other hand, we show that for the purpose of robust mean estimation, we only need to add an extra hidden layer to the logistic regression discriminator class (\ref{eq:TV-NN1}). The class (\ref{eq:JS-NN2}) of neural nets with one hidden layer does not lead to a sharp variational lower bound, but it is rich enough for the estimator trained by JS-GAN to be robust against any contamination distribution. Moreover, the complexity of the class (\ref{eq:JS-NN2}) is well controlled so that overfitting does not happen and thus the estimator achieves the minimax rate of the problem. \iffalse \paragraph{Adaptation to Unknown Covariance.} The robust mean estimator constructed through JS-GAN can be easily made adaptive to unknown covariance structure. We define \begin{equation} (\widehat{\theta},\widehat{\Sigma}) = \mathop{\rm arginf}_{\eta\in\mathbb{R}^p,\Gamma\in\mathcal{E}_p(M)}\sup_{D\in\mathcal{D}}\left[\frac{1}{n}\sum_{i=1}^n\log D(X_i) + E_{N(\eta,\Gamma)}\log(1-D(X))\right]+\log 4, \label{eq:JS-GAN-cov} \end{equation} where $\mathcal{E}_p(M)=\left\{\Gamma\in\mathcal{E}_p:\opnorm{\Gamma}\leq M\right\}$. Compared with (\ref{eq:JS-GAN-gen}), (\ref{eq:JS-GAN-cov}) optimizes over both the mean and the covariance matrix. The estimator $\widehat{\theta}$, as a result, is rate-optimal even when the true covariance matrix is not necessarily identity and is unknown. \begin{thm} \label{thm:unknown-cov} Consider the estimator $\widehat{\theta}$ defined by (\ref{eq:JS-GAN-cov}) with $\mathcal{D}$ specified by (\ref{eq:JS-NN2}). Assume $M=O(1)$, $\frac{p}{n}+\epsilon^2\leq c$ for some sufficiently small constant $c>0$, and set $\kappa=O\left(\sqrt{\frac{p}{n}}+\epsilon\right)$. With i.i.d. observations $X_1,...,X_n\sim (1-\epsilon)N(\theta,\Sigma)+\epsilon Q$, we have $$\|\widehat{\theta}-\theta\|^2 \leq C\left(\frac{p}{n}\vee\epsilon^2\right),$$ with probability at least $1-e^{-C'(p+n\epsilon^2)}$ uniformly over all $\theta\in\mathbb{R}^p$, $\Sigma\in\mathcal{E}_p(M)$ and all $Q$. The constants $C,C'>0$ are universal. \end{thm} Theorem \ref{thm:unknown-cov} enjoys the same error rate as in Theorem \ref{thm:JS-NN2}, even if the covariance matrix is not known. This is because the complexity of (\ref{eq:JS-GAN-cov}) is determined by the discriminator class through $$\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|,$$ regardless of the generator class. Similar results of adaptation also hold for $\mathcal{D}$ being deep neural network classes, and will be omitted in this paper. Table \ref{tab:unknowcov} summarizes numerical results of (\ref{eq:JS-GAN-cov}) when the covariance matrix is not known. The results show that the estimator (\ref{eq:JS-GAN-cov}) is able to adapt to the unknown covariance structure, even if the estimation of the covariance matrix itself is not fully satisfactory. \begin{table}[H] \centering \resizebox{\linewidth}{!}{% \begin{tabular}{|c|c|c|c|c|} \hline Data generating process & Network structure & Case & $\|\widehat{\theta}-0_p\|$ & $\opnorm{\widehat{\Sigma}-\Sigma_1}$ \\ \hline\hline \multirow{3}{*}{$0.8N(0_p, \Sigma_1)+0.2N(0.5*1_p, \Sigma_2)$} & \multirow{3}{*}{100-20-1} & cov. unknown & 0.1680 (0.1540) & 1.9716 (0.7405) \\ & & cov. known & 0.0554 (0.0135) & - \\ & & cov. ignored & $>1.0000$ & - \\ \hline \multirow{3}{*}{$0.8N(0_p, \Sigma_1)+0.2N(0.5*1_p, \Sigma_2)$} & \multirow{3}{*}{100-20-20-1} & cov. unknown & 0.1824 (0.3034) & 1.4495 (0.6028) \\ & & cov. known & 0.0465 (0.0077) & - \\ & & cov. ignored & $>1.0000$ & - \\ \hline \multirow{3}{*}{$0.8N(0_p, \Sigma_1)+0.2N(1_p, \Sigma_2)$} & \multirow{3}{*}{100-20-1} & cov. unknown & 0.0817 (0.0213) & 1.2753 (0.4523) \\ & & cov. known & 0.0463 (0.0066) & - \\ & & cov. ignored & 0.5399 (0.0892) & - \\ \hline \multirow{3}{*}{$0.8N(0_p, \Sigma_1)+0.2N(6*1_p, \Sigma_2)$} & \multirow{3}{*}{100-20-1} & cov. unknown & 0.1069 (0.0357) & 1.1668 (0.1839) \\ & & cov. known & 0.0422 (0.0040) & - \\ & & cov. ignored & 0.2451 (0.0855) & - \\ \hline \multirow{3}{*}{$0.8N(0_p, \Sigma_1)+0.2\textnormal{Cauchy}(0.5*1_p)$} & \multirow{3}{*}{100-20-1} & cov. unknown & 0.0797 (0.0257) & 4.0653 (0.1569) \\ & & cov. known & 0.0446 (0.0102) & - \\ & & cov. ignored & 0.2053 (0.0599) & - \\ \hline \end{tabular}} \caption{Numerical experiments for robust mean estimation with unknown covariance trained with $50,000$ samples. The network structure is shown in the table (one hidden layer with twenty hidden units and two hidden layers with twenty hidden units for each). The covariance matrices $\Sigma_1$ and $\Sigma_2$ are generated by the same way described in Section \ref{sec:rate}. The most interesting case is to estimate the mean without knowing the covariance by learning the generator $G(Z)=\Gamma^{1/2}Z + \eta$, with $Z\sim N(0,I_p)$. For comparison, we consider two baseline cases: $G(Z)=\Sigma_1^{1/2}Z+\eta$ with known covariance $\Sigma_1$, and $G(Z)=Z+\eta$ the covariance structure completely ignored.}\label{tab:unknowcov} \end{table} \fi \paragraph{Future Projects.} Besides the topic of robust mean estimation, other important problems include robust covariance matrix estimation, robust high-dimensional regression, robust learning of Gaussian mixture models, and robust classification. It will be interesting to investigate what class of discriminators are suitable for these tasks. Another line of research is motivated from the goal to understand the class of divergence functions that are suitable for robust estimation. In addition to JS-GAN and TV-GAN studied in this paper, we would like to know whether it is possible to train robust estimators using GAN derived from other $f$-divergence functions. A further question is whether it is possible to use GAN derived from integral probability metrics including Wasserstein distance \citep{arjovsky2017wasserstein} and maximum mean discrepancy \citep{dziugaite2015training,li2015generative,binkowski2018demystifying}. Finally, the landscapes and optimization properties of various GANs under robust estimation settings are topics to be explored. \section{Proofs}\label{sec:pf} In this section, we present proofs of all technical results in the paper. We first establish some useful lemmas in Section \ref{sec:aux-lem}, and the the proofs of main theorems will be given in Section \ref{sec:pf-main}. \subsection{Some Auxiliary Lemmas}\label{sec:aux-lem} \begin{lemma}\label{lem:EP-NN1} Given i.i.d. observations $X_1,...,X_n\sim\mathbb{P}$ and the function class $\mathcal{D}$ defined in (\ref{eq:TV-NN1}), we have for any $\delta>0$, $$\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^nD(X_i)-\mathbb{E}D(X)\right|\leq C\left(\sqrt{\frac{p}{n}}+ \sqrt{\frac{\log(1/\delta)}{n}}\right),$$ with probability at least $1-\delta$ for some universal constant $C>0$. \end{lemma} \begin{proof} Let $f(X_1,...,X_n)=\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^nD(X_i)-\mathbb{E}D(X)\right|$. It is clear that $f(X_1,...,X_n)$ satisfies the bounded difference condition. By McDiarmid's inequality \citep{mcdiarmid1989method}, we have $$f(X_1,...,X_n)\leq \mathbb{E}f(X_1,...,X_n) + \sqrt{\frac{\log(1/\delta)}{2n}},$$ with probability at least $1-\delta$. Using a standard symmetrization technique \citep{pollard2012convergence}, we obtain the following bound that involves Rademacher complexity, \begin{equation} \mathbb{E}f(X_1,...,X_n)\leq 2\mathbb{E}\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i D(X_i)\right|,\label{eq:RC-NN1} \end{equation} where $\epsilon_1,...,\epsilon_n$ are independent Rademacher random variables. The Rademacher complexity can be bounded by Dudley's integral entropy bound, which gives $$\mathbb{E}\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i D(X_i)\right|\lesssim \mathbb{E}\frac{1}{\sqrt{n}}\int_0^2\sqrt{\log\mathcal{N}(\delta,\mathcal{D},\|\cdot\|_n)}d\delta,$$ where $\mathcal{N}(\delta,\mathcal{D},\|\cdot\|_n)$ is the $\delta$-covering number of $\mathcal{D}$ with respect to the empirical $\ell_2$ distance $\|f-g\|_n=\sqrt{\frac{1}{n}\sum_{i=1}^n(f(X_i)-g(X_i))^2}$. Since the VC-dimension of $\mathcal{D}$ is $O(p)$, we have $\mathcal{N}(\delta,\mathcal{D},\|\cdot\|_n)\lesssim p\left(16e/\delta\right)^{O(p)}$ (see Theorem 2.6.7 of \cite{van1996weak}). This leads to the bound $\frac{1}{\sqrt{n}}\int_0^2\sqrt{\log\mathcal{N}(\delta,\mathcal{D},\|\cdot\|_n)}d\delta\lesssim \sqrt{\frac{p}{n}}$, which gives the desired result. \end{proof} \begin{lemma}\label{lem:JS-NN2} Given i.i.d. observations $X_1,...,X_n\sim\mathbb{P}$, and the function class $\mathcal{D}$ defined in (\ref{eq:JS-NN2}), we have for any $\delta>0$, $$\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|\leq C\kappa\left(\sqrt{\frac{p}{n}}+ \sqrt{\frac{\log(1/\delta)}{n}}\right),$$ with probability at least $1-\delta$ for some universal constant $C>0$. \end{lemma} \begin{proof} Let $f(X_1,...,X_n)=\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|$. Since $$\sup_{D\in\mathcal{D}}\sup_{x}|\log(2D(x))|\leq\kappa,$$ we have $$\sup_{x_1,...,x_n,x_i'}\left|f(x_1,...,x_n)-f(x_1,...,x_{i-1},x_i',x_{i+1},...,x_n)\right|\leq \frac{2\kappa}{n}.$$ Therefore, by McDiarmid's inequality \citep{mcdiarmid1989method}, we have \begin{equation} f(X_1,...,X_n)\leq \mathbb{E}f(X_1,...,X_n) + \kappa\sqrt{\frac{2\log(1/\delta)}{n}},\label{eq:bd-diff-JS-NN2} \end{equation} with probability at least $1-\delta$. By the same argument of (\ref{eq:RC-NN1}), it is sufficient to bound the Rademacher complexity $\mathbb{E}\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\log(2D(X_i))\right|$. Since the function $\psi(x)=\log(2{\sf sigmoid}(x))$ has Lipschitz constant $1$ and satisfies $\psi(0)=0$, we have $$\mathbb{E}\sup_{D\in\mathcal{D}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\log(2D(X_i))\right|\leq 2\mathbb{E}\sup_{\sum_{j\geq 1}|w_j|\leq\kappa,u_j\in\mathbb{R}^p,b_j\in\mathbb{R}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sum_{j\geq 1}w_j\sigma(u_j^TX_i+b_j)\right|,$$ which uses Theorem 12 of \cite{bartlett2002rademacher}. By H\"{o}lder's inequality, we further have \begin{eqnarray*} && \mathbb{E}\sup_{\sum_{j\geq 1}|w_j|\leq\kappa,u_j\in\mathbb{R}^p,b_j\in\mathbb{R}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sum_{j\geq 1}w_j\sigma(u_j^TX_i+b_j)\right| \\ &\leq& \kappa \mathbb{E}\sup_{j\geq 1}\sup_{u_j\in\mathbb{R}^p,b_j\in\mathbb{R}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sigma(u_j^TX_i+b_j)\right| \\ &=& \kappa\mathbb{E}\sup_{u\in\mathbb{R}^p,b\in\mathbb{R}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sigma(u^TX_i+b)\right|. \end{eqnarray*} Note that for a monotone function $\sigma:\mathbb{R}\rightarrow [0,1]$, the VC-dimension of the class $\{\sigma(u^Tx+b):u\in\mathbb{R},b\in\mathbb{R}\}$ is $O(p)$. Therefore, by using the same argument of Dudley's integral entropy bound in the proof Lemma \ref{lem:EP-NN1}, we have $$\mathbb{E}\sup_{u\in\mathbb{R}^p,b\in\mathbb{R}}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sigma(u^TX_i+b)\right|\lesssim \sqrt{\frac{p}{n}},$$ which leads to the desired result. \end{proof} \iffalse \begin{lemma}\label{lem:JS-DNN} Given i.i.d. observations $X_1,..,X_n\sim N(\theta,I_p)$ and the function class $\mathcal{F}_L^H(\kappa,\tau,B)$. Assume $\|\theta\|_{\infty}\leq \sqrt{\log p}$ and set $\tau=\sqrt{p\log p}$. We have for any $\delta>0$, $$\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|\leq C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n}},$$ with probability at least $1-p^{-C'}$ for some universal constants $C,C'>0$. \end{lemma} \begin{proof} We use the notation $Z_i=X_i-\theta\sim N(0,I_p)$ for $i=1,...,n$. Define $$f(Z_1,...,Z_n)=\sup_{D\in\mathcal{F}_L^H(\kappa,\beta)}\left|\frac{1}{n}\sum_{i=1}^n\log D(Z_i+\theta)-\mathbb{E}\log D(X)\right|.$$ We first show that $f(Z_1,...,Z_n)$ is a Lipschitz function. For any $D\in\mathcal{F}_L^H(\kappa,\tau,B)$, we can write $D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j{\sf ReLU}\left(\ell_j(x)\right)\right)$ with $\ell_j(x)=\sum_{h=1}^pu_{jh}g_{jh}(x)+b_j$. Then, \begin{eqnarray*} && |f(Z_1,...,Z_n)-f(Y_1,...,Y_n)| \\ &\leq& \frac{1}{n}\sum_{i=1}^n\sup_{\|w\|_1\leq \kappa, \ell_j}\left|\log{\sf sigmoid}\left(\sum_{j\geq 1}w_j{\sf ReLU}\left(\ell_j(Z_i+\theta)\right)\right)-\log{\sf sigmoid}\left(\sum_{j\geq 1}w_j{\sf ReLU}\left(\ell_j(Y_i+\theta)\right)\right)\right| \\ &\leq& \frac{1}{n}\sum_{i=1}^n\sup_{\|w\|_1\leq \kappa, \ell_j}\left|\sum_{j\geq 1}w_j{\sf ReLU}\left(\ell_j(Z_i+\theta)\right)-\sum_{j\geq 1}w_j{\sf ReLU}\left(\ell_j(Y_i+\theta)\right)\right| \\ &\leq& \kappa\frac{1}{n}\sum_{i=1}^n\sup_{j\geq 1}\sup_{\ell_j}\left|{\sf ReLU}(\ell_j(Z_i+\theta))-{\sf ReLU}(\ell_j(Y_i+\theta))\right| \\ &=& \kappa\frac{1}{n}\sum_{i=1}^n\sup_{\ell}\left|{\sf ReLU}(\ell(Z_i+\theta))-{\sf ReLU}(\ell(Y_i+\theta))\right| \\ &\leq& \kappa\frac{1}{n}\sum_{i=1}^n\sup_{\|u\|^2\leq 2, g_h\in\mathcal{G}_{L-1}^H(B)}\left|\sum_{h=1}^{2p}u_hg_h(Z_i+\theta)-\sum_{h=1}^{2p}u_hg_h(Y_i+\theta)\right| \\ &\leq& \sqrt{4p}\kappa\frac{1}{n}\sum_{i=1}^n\sup_{g\in\mathcal{G}_{L-1}^H(B)}\left|g(Z_i+\theta)-g(Y_i+\theta)\right|. \end{eqnarray*} We use induction to bound $\sup_{g\in\mathcal{G}_{L-1}^H(B)}\left|g(Z_i+\theta)-g(Y_i+\theta)\right|$. Since \begin{eqnarray*} && \sup_{g\in\mathcal{G}_{1}^H(B)}\left|g(Z_i+\theta)-g(Y_i+\theta)\right| \\ &\leq& \sup_{\|v\|_1\leq B}\left|v^T(Z_i+\theta)-v^T(Y_i+\theta)\right| \\ &\leq& B\|Z_i-Y_i\|_{\infty}, \end{eqnarray*} and \begin{eqnarray*} && \sup_{g\in\mathcal{G}_{l+1}^H(B)}\left|g(Z_i+\theta)-g(Y_i+\theta)\right| \\ &\leq& \sup_{\|v\|_1\leq B, g_h\in\mathcal{G}_l^H(B)}\left|\sum_{h=1}^Hv_hg_h(Z_i+\theta)-\sum_{h=1}^Hv_hg_h(Y_i+\theta)\right| \\ &\leq& B\sup_{g\in\mathcal{G}_l^H(B)}|g(Z_i+\theta)-g(Y_i+\theta)|, \end{eqnarray*} we have $$\sup_{g\in\mathcal{G}_{L-1}^H(B)}\left|g(Z_i+\theta)-g(Y_i+\theta)\right|\leq B^{L-1}\|Z_i-Y_i\|_{\infty},$$ which leads to the bound \begin{eqnarray*} && |f(Z_1,...,Z_n)-f(Y_1,...,Y_n)| \\ &\leq& \kappa B^{L-1}\sqrt{p}\frac{1}{n}\sum_{i=1}^n\|Z_i-Y_i\|_{\infty} \\ &\leq& \kappa B^{L-1}\sqrt{\frac{p}{n}}\sqrt{\sum_{i=1}^n\|Z_i-Y_i\|_{\infty}^2} \\ &\leq& \kappa B^{L-1}\sqrt{\frac{p}{n}}\sqrt{\sum_{i=1}^n\|Z_i-Y_i\|^2}. \end{eqnarray*} Therefore, $f(Z_1,...,Z_n)$ is a Lipschitz function with Lipschitz constant $\kappa B^{L-1}\sqrt{\frac{p}{n}}$. By Talagrand's inequality \citep{talagrand1995concentration}, we have $$f(Z_1,...,Z_n)\leq \mathbb{E}f(Z_1,...,Z_n) + C\kappa B^{L-1}\sqrt{\frac{p}{n}\log\left(\frac{2}{\delta}\right)},$$ with probability at least $1-\delta$. By the same argument of (\ref{eq:RC-NN1}), it is sufficient to bound the Rademacher complexity. We have \begin{eqnarray*} && \mathbb{E}\left(\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i\log D(Z_i+\theta)\right) \\ &=& \mathbb{E}\left(\sup_{\|w\|_1\leq \kappa,\ell_j}\frac{1}{n}\sum_{i=1}^n\epsilon_i\log{\sf sigmoid}\left(\sum_{j\geq 1}w_j{\sf ReLU}(\ell_j(Z_i+\theta))\right)\right) \\ &\leq& \mathbb{E}\left(\sup_{\|w\|_1\leq \kappa,\ell_j}\frac{1}{n}\sum_{i=1}^n\epsilon_i\left(\sum_{j\geq 1}w_j{\sf ReLU}(\ell_j(Z_i+\theta))\right)\right) \\ &\leq& \kappa\mathbb{E}\left(\sup_{j\geq 1}\sup_{\ell_j}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i{\sf ReLU}(\ell_j(Z_i+\theta))\right|\right) \\ &\leq& 2\kappa\mathbb{E}\left(\sup_{\ell}\frac{1}{n}\sum_{i=1}^n\epsilon_i{\sf ReLU}(\ell(Z_i+\theta))\right), \end{eqnarray*} where we have used Theorem 7 of \cite{meir2003generalization}. We continue the bound, and we have \begin{eqnarray} \label{eq:later-used} && \mathbb{E}\left(\sup_{\ell}\frac{1}{n}\sum_{i=1}^n\epsilon_i{\sf ReLU}(\ell(Z_i+\theta))\right) \\ \nonumber &=& \mathbb{E}\left(\sup_{\|u\|^2\leq 2, |b|\leq \tau, g_h\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i{\sf ReLU}\left(\sum_{h=1}^{2p}u_hg_h(Z_i+\theta)+b\right)\right) \\ \nonumber &\leq& \mathbb{E}\left(\sup_{\|u\|^2\leq 2, |b|\leq \tau, g_h\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i\left(\sum_{h=1}^{2p}u_hg_h(Z_i+\theta)+b\right)\right) \\ \nonumber &\leq& 4\sqrt{p}\mathbb{E}\left(\sup_{g\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right)+\tau\mathbb{E} \left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\right|. \end{eqnarray} We bound $\mathbb{E}\left(\sup_{g\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right)$ by induction. Since \begin{eqnarray*} && \mathbb{E}\left(\sup_{g\in\mathcal{G}_{1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right) \\ &\leq& \mathbb{E}\left(\sup_{\|v\|_1\leq B}\frac{1}{n}\sum_{i=1}^n\epsilon_iv^T(Z_i+\theta)\right) \\ &\leq& B\left(\mathbb{E}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_iZ_i\right|_{\infty} + \|\theta\|_{\infty}\mathbb{E}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\right|\right) \\ &\leq& CB\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}, \end{eqnarray*} and \begin{eqnarray*} && \mathbb{E}\left(\sup_{g\in\mathcal{G}_{l+1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right) \\ &\leq& \mathbb{E}\left(\sup_{\|v\|_1\leq B,g_h\in\mathcal{G}_l^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i \sum_{h=1}^Hv_hg_h(Z_i+\theta)\right) \\ &\leq& B\mathbb{E}\left(\sup_{g\in\mathcal{G}_l^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right|\right) \\ &\leq& 2B\mathbb{E}\left(\sup_{g\in\mathcal{G}_{l}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right), \end{eqnarray*} we have $$\mathbb{E}\left(\sup_{g\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right)\leq C(2B)^{L-1}\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}.$$ Combining the above inequalities, we get $$\mathbb{E}\left(\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i\log D(Z_i+\theta)\right)\leq C\kappa\left(\sqrt{p}(2B)^{L-1}\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}+\frac{\tau}{\sqrt{n}}\right).$$ This leads to the desired result under the conditions on $\tau$ and $\|\theta\|_{\infty}$ with $\delta$ set to satisfy $\log(2/\delta)\asymp\log p$. \end{proof} \fi \begin{lemma}\label{lem:JS-DNN-sig} Given i.i.d. observations $X_1,..,X_n\sim N(\theta,I_p)$ and the function class ${\mathcal{F}}_L^H(\kappa,\tau,B)$. Assume $\|\theta\|_{\infty}\leq \sqrt{\log p}$ and set $\tau=\sqrt{p\log p}$. We have for any $\delta>0$, $$\sup_{D\in{\mathcal{F}}_L^H(\kappa,\tau,B)}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|\leq C\kappa\left((2B)^{L-1}\sqrt{\frac{p\log p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ with probability at least $1-\delta$ for some universal constants $C>0$. \end{lemma} \begin{proof} Write $f(X_1,...,X_n)=\sup_{D\in{\mathcal{F}}_L^H(\kappa,\tau,B)}\left|\frac{1}{n}\sum_{i=1}^n\log D(X_i)-\mathbb{E}\log D(X)\right|$. Then, the inequality (\ref{eq:bd-diff-JS-NN2}) holds with probability at least $1-\delta$. It is sufficient to analyze the Rademacher complexity. Using the fact that the function $\log(2{\sf sigmoid}(x))$ is Lipschitz and H\"{o}lder's inequality, we have \begin{eqnarray*} && \mathbb{E}\sup_{D \in{\mathcal{F}}_L^H(\kappa,\tau,B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\log(2D(X_i))\right| \\ &\leq& 2\mathbb{E}\sup_{\|w\|_1\leq\kappa, \|u_{j*}\|^2\leq 2,|b_j|\leq\tau, g_{jh}\in\mathcal{G}_{L-1}^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\sum_{j\geq 1}w_j{\sf sigmoid}\left(\sum_{h=1}^{2p}u_{jh}g_{jh}(X_i)+b_j\right)\right| \\ &\leq& 2\kappa\mathbb{E}\sup_{\|u\|^2\leq 2,|b|\leq\tau,g_h\in\mathcal{G}_{L-1}^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i{\sf sigmoid}\left(\sum_{h=1}^{2p}u_hg_h(X_i)+b\right)\right| \\ &\leq& 4\kappa\mathbb{E}\sup_{\|u\|^2\leq 2,|b|\leq\tau,g_h\in\mathcal{G}_{L-1}^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\left(\sum_{h=1}^{2p}u_hg_h(X_i)+b\right)\right| \\ &\leq& 8\sqrt{p}\kappa\mathbb{E}\sup_{g\in\mathcal{G}_{L-1}^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_ig(X_i)\right| + 4\kappa\tau\mathbb{E}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\right|. \end{eqnarray*} Now we use the notation $Z_i=X_i-\theta\sim N(0,I_p)$ for $i=1,...,n$. We bound $\mathbb{E}\sup_{g\in\mathcal{G}_{L-1}^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right|$ by induction. Since \begin{eqnarray*} && \mathbb{E}\left(\sup_{g\in\mathcal{G}_{1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right) \\ &\leq& \mathbb{E}\left(\sup_{\|v\|_1\leq B}\frac{1}{n}\sum_{i=1}^n\epsilon_iv^T(Z_i+\theta)\right) \\ &\leq& B\left(\mathbb{E}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_iZ_i\right|_{\infty} + \|\theta\|_{\infty}\mathbb{E}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_i\right|\right) \\ &\leq& CB\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}, \end{eqnarray*} and \begin{eqnarray*} && \mathbb{E}\left(\sup_{g\in\mathcal{G}_{l+1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right) \\ &\leq& \mathbb{E}\left(\sup_{\|v\|_1\leq B,g_h\in\mathcal{G}_l^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i \sum_{h=1}^Hv_hg_h(Z_i+\theta)\right) \\ &\leq& B\mathbb{E}\left(\sup_{g\in\mathcal{G}_l^H(B)}\left|\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right|\right) \\ &\leq& 2B\mathbb{E}\left(\sup_{g\in\mathcal{G}_{l}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right), \end{eqnarray*} we have $$\mathbb{E}\left(\sup_{g\in\mathcal{G}_{L-1}^H(B)}\frac{1}{n}\sum_{i=1}^n\epsilon_ig(Z_i+\theta)\right)\leq C(2B)^{L-1}\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}.$$ Combining the above inequalities, we get $$\mathbb{E}\left(\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}\frac{1}{n}\sum_{i=1}^n\epsilon_i\log D(Z_i+\theta)\right)\leq C\kappa\left(\sqrt{p}(2B)^{L-1}\frac{\sqrt{\log p}+\|\theta\|_{\infty}}{\sqrt{n}}+\frac{\tau}{\sqrt{n}}\right).$$ This leads to the desired result under the conditions on $\tau$ and $\|\theta\|_{\infty}$. \end{proof} \subsection{Proofs of Main Theorems} \label{sec:pf-main} \begin{proof}[Proof of Theorem \ref{thm:TV-NN1}] We first introduce some notations. Define $F(P,\eta)=\sup_{w,b}F_{w,b}(P,\eta)$, where $$F_{w,b}(P,\eta)=E_P{\sf sigmoid}(w^TX+b)-E_{N(\eta,I_p)}{\sf sigmoid}(w^TX+b).$$ With this definition, we have $\widehat{\theta}=\mathop{\rm arginf}_{\eta}F(\mathbb{P}_n,\eta)$, where we use $\mathbb{P}_n$ for the empirical distribution $\frac{1}{n}\sum_{i=1}^n\delta_{X_i}$. We shorthand $N(\eta,I_p)$ by $P_{\eta}$, and then \begin{eqnarray} \label{eq:T1-1} F(P_{\theta},\widehat{\theta}) &\leq& F((1-\epsilon)P_{\theta}+\epsilon Q,\widehat{\theta}) + \epsilon \\ \label{eq:T1-2} &\leq& F(\mathbb{P}_n,\widehat{\theta}) + \epsilon + C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T1-3} &\leq& F(\mathbb{P}_n,\theta) + \epsilon + C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T1-4} &\leq& F((1-\epsilon)P_{\theta}+\epsilon Q,\theta) + \epsilon + 2C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T1-5} &\leq& F(P_{\theta},\theta) + 2\epsilon + 2C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T1-6} &=& 2\epsilon + 2C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right). \end{eqnarray} With probability at least $1-\delta$, the above inequalities hold. We will explain each inequality. Since $$F((1-\epsilon)P_{\theta}+\epsilon Q,\eta)=\sup_{w,b}\left[(1-\epsilon)F_{w,b}(P_{\theta},\eta)+\epsilon F_{w,b}(Q,\eta)\right],$$ we have $$\sup_{\eta}\left|F((1-\epsilon)P_{\theta}+\epsilon Q,\eta)-F(P_{\theta},\eta)\right|\leq\epsilon,$$ which implies (\ref{eq:T1-1}) and (\ref{eq:T1-5}). The inequalities (\ref{eq:T1-2}) and (\ref{eq:T1-4}) are implied by Lemma \ref{lem:EP-NN1} and the fact that $$\sup_{\eta}\left|F(\mathbb{P}_n,\eta)-F((1-\epsilon)P_{\theta}+\epsilon Q,\eta)\right|\leq \sup_{w,b}\left|\frac{1}{n}\sum_{i=1}^n{\sf sigmoid}(w^TX_i+b)-\mathbb{E}{\sf sigmoid}(w^TX+b)\right|.$$ The inequality (\ref{eq:T1-3}) is a direct consequence of the definition of $\widehat{\theta}$. Finally, it is easy to see that $F(P_{\theta},\theta)=0$, which gives (\ref{eq:T1-6}). In summary, we have derived that with probability at least $1-\delta$, $$F_{w,b}(P_{\theta},\widehat{\theta})\leq 2\epsilon + 2C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ for all $w\in\mathbb{R}^p$ and $b\in\mathbb{R}$. For any $u\in\mathbb{R}^p$ such that $\|u\|=1$, we take $w=u$ and $b=-u^T\theta$, and we have $$f(0)-f(u^T(\theta-\widehat{\theta}))\leq 2\epsilon + 2C\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ where $f(t)=\int \frac{1}{1+e^{z+t}}\phi(z)dz$, with $\phi(\cdot)$ being the probability density function of $N(0,1)$. It is not hard to see that as long as $|f(t)-f(0)|\leq c$ for some sufficiently small constant $c>0$, then $|f(t)-f(0)|\geq c'|t|$ for some constant $c'>0$. This implies \begin{eqnarray*} \|\widehat{\theta}-\theta\| &=& \sup_{\|u\|=1}|u^T(\widehat{\theta}-\theta)| \\ &\leq& \frac{1}{c'}\sup_{\|u\|=1}\left|f(0)-f(u^T(\theta-\widehat{\theta}))\right| \\ &\lesssim& \epsilon + \sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}, \end{eqnarray*} with probability at least $1-\delta$. The proof is complete. \end{proof} \begin{proof}[Proof of Theorem \ref{thm:JS-NN2}] We continue to use $P_{\eta}$ to denote $N(\eta,I_p)$. Define $$F(P,\eta)=\sup_{\|w\|_1\leq\kappa,u,b}F_{w,u,b}(P,\eta),$$ where $$F_{w,u,b}(P,\eta)=E_P\log D(X)+E_{N(\eta,I_p)}\log\left(1-D(X)\right)+\log 4,$$ with $D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j\sigma(u_j^Tx+b_j)\right)$. Then, \begin{eqnarray} \label{eq:T2-1} F(P_{\theta},\widehat{\theta}) &\leq& F((1-\epsilon)P_{\theta}+\epsilon Q,\widehat{\theta}) + 2\kappa\epsilon \\ \label{eq:T2-2} &\leq& F(\mathbb{P}_n,\widehat{\theta}) + 2\kappa\epsilon + C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T2-3} &\leq& F(\mathbb{P}_n,\theta) + 2\kappa\epsilon + C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T2-4} &\leq& F((1-\epsilon)P_{\theta}+\epsilon Q,\theta) + 2\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \label{eq:T2-5} &\leq& F(P_{\theta},\theta) + 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ \nonumber &=& 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right). \end{eqnarray} The inequalities (\ref{eq:T2-1})-(\ref{eq:T2-5}) follow similar arguments for (\ref{eq:T1-1})-(\ref{eq:T1-5}). To be specific, (\ref{eq:T2-2}) and (\ref{eq:T2-4}) are implied by Lemma \ref{lem:JS-NN2}, and (\ref{eq:T2-3}) is a direct consequence of the definition of $\widehat{\theta}$. To see (\ref{eq:T2-1}) and (\ref{eq:T2-5}), note that for any $w$ such that $\|w\|_1\leq \kappa$, we have $$|\log (2D(X))|\leq \left|\sum_{j\geq 1}w_j\sigma(u_j^TX+b_j)\right|\leq \kappa.$$ A similar argument gives the same bound for $|\log(2(1-D(X)))|$. This leads to $$\sup_{\eta}\left|F((1-\epsilon)P_{\theta}+\epsilon Q,\eta)-F(P_{\theta},\eta)\right|\leq 2\kappa\epsilon,$$ which further implies (\ref{eq:T2-1}) and (\ref{eq:T2-5}). To summarize, we have derived that with probability at least $1-\delta$, $$F_{w,u,b}(P_{\theta},\widehat{\theta})\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ for all $\|w\|_1\leq \kappa$, $\|u_j\|\leq 1$ and $b_j$. Take $w_1=\kappa$, $w_j=0$ for all $j>1$, $u_1=u$ for some unit vector $u$ and $b_1=-u^T\theta$, and we get \begin{equation} f_{u^T(\widehat{\theta}-\theta)}(\kappa)\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right), \label{eq:not-c} \end{equation} where \begin{equation} f_{\delta}(t)=\mathbb{E}\log\frac{2}{1+e^{-t\sigma(Z)}}+\mathbb{E}\log\frac{2}{1+e^{t\sigma(Z+\delta)}},\label{eq:def-f-delta-t} \end{equation} with $Z\sim N(0,1)$. Direct calculations give \begin{eqnarray} \nonumber f_{\delta}'(t) &=& \mathbb{E}\frac{e^{-t\sigma(Z)}}{1+e^{-t\sigma(Z)}}\sigma(Z) - \mathbb{E}\frac{e^{t\sigma(Z+\delta)}}{1+e^{t\sigma(Z+\delta)}}\sigma(Z+\delta), \\ \label{eq:f''} f_{\delta}''(t) &=& -\mathbb{E}\sigma(Z)^2\frac{e^{-t\sigma(Z)}}{(1+e^{-t\sigma(Z)})^2} - \mathbb{E}\sigma(Z+\delta)^2\frac{e^{t\sigma(Z+\delta)}}{(1+e^{t\sigma(Z+\delta)})^2}. \end{eqnarray} Therefore, $f_{\delta}(0)=0$, $f_{\delta}'(0)=\frac{1}{2}\left(\mathbb{E}\sigma(Z)-\mathbb{E}\sigma(Z+\delta)\right)$, and $f''_{\delta}(t)\geq-\frac{1}{2}$. By the inequality $$f_{\delta}(\kappa)\geq f_{\delta}(0) + \kappa f_{\delta}'(0) - \frac{1}{4}\kappa^2,$$ we have $\kappa f_{\delta}'(0)\leq f_{\delta}(\kappa)+\kappa^2/4$. In view of (\ref{eq:not-c}), we have \begin{eqnarray*} && \frac{\kappa}{2}\left(\int\sigma(z)\phi(z)dz-\int\sigma(z+u^T(\widehat{\theta}-\theta))\phi(z)dz\right) \\ &\leq& 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) + \frac{\kappa^2}{4}. \end{eqnarray*} It is easy to see that for the choices of $\sigma(\cdot)$, $\int\sigma(z)\phi(z)dz-\int\sigma(z+t)\phi(z)dz$ is locally linear with respect to $t$. This implies that $$\kappa\|\widehat{\theta}-\theta\|=\kappa\sup_{\|u\|=1}u^T(\widehat{\theta}-\theta)\lesssim \kappa\left(\epsilon+\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right)+\kappa^2.$$ Therefore, with a $\kappa\lesssim \sqrt{\frac{p}{n}}+\epsilon$, the proof is complete. \end{proof} \iffalse \begin{proof}[Proof of (\ref{eq:JS-DNN-bound1}) in Theorem \ref{thm:JS-DNN}] We continue to use $P_{\eta}$ to denote $N(\eta,I_p)$. For i.i.d. observations from $(1-\epsilon)P_{\theta}+\epsilon Q$, they can be written as $\{X_i\}_{i=1}^n=\{Y_i\}_{i=1}^{n_1}\cup\{Z_i\}_{i=1}^{n_2}$. Marginally, we have $n_2\sim\text{Binomial}(n,\epsilon)$ and $n_1=n-n_2$. Conditioning on $n_1$ and $n_2$, $\{Y_i\}_{i=1}^{n_1}$ are i.i.d. from $P_{\theta}$ and $\{Z_i\}_{i=1}^{n_2}$ are i.i.d. from $Q$. According to Lemma 7.1 of \cite{chen2018robust}, we have \begin{equation} \frac{n_2}{n_1}\leq \frac{\epsilon}{1-\epsilon} + \frac{25}{12}\sqrt{\frac{1}{2n}\log(1/\delta)}, \label{eq:eps-n2n1} \end{equation} with probability at least $1-\delta$ as long as $\epsilon + \sqrt{\frac{\log(1/\delta)}{n}}$ is sufficiently small. Below, the analysis will condition on $n_1,n_2$ that satisfy the event (\ref{eq:eps-n2n1}). Define $F(P,\eta)=\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}F_{D}(P,\eta)$, with \begin{equation} F_{D}(P,\eta)=E_P\log D(X)+E_{N(\eta,I_p)}\log(1-D(X))+\log 4.\label{eq:def-F-D-eta} \end{equation} We also use the notations $F(\{X_i\}_{i=1}^n,\eta)$ and $F(\{Y_i\}_{i=1}^{n_1},\eta)$ for $P=\frac{1}{n}\sum_{i=1}^n\delta_{X_i}$ and $P=\frac{1}{n_1}\sum_{i=1}^{n_1}\delta_{Y_i}$, respectively. It is not hard to see that \begin{equation} \sup_{\eta}\left|\frac{n}{n_1}F(\{X_i\}_{i=1}^n,\eta)-F(\{Y_i\}_{i=1}^{n_1},\eta)\right| \leq (\log 4)\frac{n_2}{n_1}. \label{eq:JS-con-bound} \end{equation} Then, \begin{eqnarray} \label{eq:T3-1} F(P_{\theta},\widehat{\theta}) &\leq& F(\{Y_i\}_{i=1}^{n_1},\widehat{\theta}) + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}} \\ \label{eq:T3-2} &\leq& \frac{n}{n_1}F(\{X_i\}_{i=1}^n,\widehat{\theta}) + (\log 4)\frac{n_2}{n_1} + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}} \\ \label{eq:T3-3} &\leq& \frac{n}{n_1}F(\{X_i\}_{i=1}^n,\theta) + (\log 4)\frac{n_2}{n_1} + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}} \\ \label{eq:T3-4} &\leq& F(\{Y_i\}_{i=1}^{n_1},\theta) + 2(\log 4)\frac{n_2}{n_1} + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}} \\ \label{eq:T3-5} &\leq& F(P_{\theta},\theta) + 2(\log 4)\frac{n_2}{n_1} + 2C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}} \\ \nonumber &=& 2(\log 4)\frac{n_2}{n_1} + 2C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n_1}}. \end{eqnarray} The inequalities (\ref{eq:T3-1}) and (\ref{eq:T3-5}) are due to Lemma \ref{lem:JS-DNN}. The inequalities (\ref{eq:T3-2}) and (\ref{eq:T3-4}) are implied by (\ref{eq:JS-con-bound}), and (\ref{eq:T3-3}) uses the definition of $\widehat{\theta}$. Together with (\ref{eq:eps-n2n1}), we have derived that with probability at least $1-\delta-p^{-C'}$, \begin{equation} F_D(P_{\theta},\widehat{\theta})\leq C\left(\epsilon+\sqrt{\frac{\log(1/\delta)}{n}}\right) + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n}}, \label{eq:jay-chou} \end{equation} for any $D\in\mathcal{F}_L^H(\kappa,\tau,B)$. Choose $w_1=\kappa$ and $w_j=0$ for all $w_j>1$. For any unit vector $\widetilde{u}\in\mathbb{R}^p$, take $u_{1h}=-u_{1(h+p)}=\widetilde{u}_h$ for $h=1,...,p$ and $b_1=-\widetilde{u}^T\theta$. For $h=1,...,p$, set $g_{1h}(x)=\max(x_h,0)$. For $h=p+1,...,2p$, set $g_{1h}(x)=\max(-x_{h-p},0)$. It is obvious that such $u$ and $b$ satisfy $\sum_hu_{1h}^2\leq 2$ and $|b_1|\leq \|\theta\|\leq \sqrt{p}\|\theta\|_{\infty}\leq\sqrt{p\log p}$. We need to show both the functions $\max(x,0)$ and $\max(-x,0)$ are elements of $\mathcal{G}_{L-1}^H(B)$. This can be proved by induction. It is obvious that $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_1^H(B)$ for any $h=1,...,p$. Suppose we have $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_l^H(B)$ for any $h=1,...,p$. Then, \begin{eqnarray*} \max\left(\max(x_h,0)-\max(-x_h,0),0\right) &=& \max(x_h,0), \\ \max\left(\max(-x_h,0)-\max(x_h,0),0\right) &=& \max(-x_h,0). \end{eqnarray*} Therefore, $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_{l+1}^H(B)$ as long as $B\geq 2$. Hence, the above construction satisfies $D(x)={\sf sigmoid}(\kappa{\sf ReLU}(\widetilde{u}^T(x-\theta)))\in\mathcal{F}_L^H(\kappa,\tau,B)$, and we have \begin{equation} f_{u^T(\widehat{\theta}-\theta)}(\kappa)\leq C\left(\epsilon+\sqrt{\frac{\log(1/\delta)}{n}}\right) + C\kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n}}, \label{eq:not-c-again} \end{equation} where the definition of $f_{\delta}(t)$ is given by (\ref{eq:def-f-delta-t}) with $Z\sim N(0,1)$ and $\sigma(\cdot)$ replaced by ${\sf ReLU}(\cdot)$. Suppose $f_{\delta}(\kappa)\leq \kappa c$ for a sufficiently constant $c>0$, we get $|\delta|<C_1$ for some constant $C_1>0$. Together with the formula (\ref{eq:f''}), we have $f''_{\delta}(t)\geq -C_2$ for some constant $C_2>0$ whenever $|\delta|<C_1$. Apply the a similar in the proof of Theorem \ref{thm:JS-NN2}, we obtain $$\kappa\|\widehat{\theta}-\theta\|\lesssim \epsilon+\sqrt{\frac{\log(1/\delta)}{n}} + \kappa\left(1+(2B)^{L-1}\right)\sqrt{\frac{p\log p}{n}} + \kappa^2.$$ The choice $\kappa\asymp\epsilon^{1/2}+n^{-1/4}$ gives the desired result. \end{proof} \fi \begin{proof}[Proof of Theorem \ref{thm:JS-DNN}] We continue to use $P_{\eta}$ to denote $N(\eta,I_p)$. Define $$F(P,\eta)=\sup_{D\in\mathcal{F}_L^H(\kappa,\tau,B)}F_{D}(P,\eta),$$ with $$ F_{D}(P,\eta)=E_P\log D(X)+E_{N(\eta,I_p)}\log(1-D(X))+\log 4.\label{eq:def-F-D-eta} $$ Follow the same argument in the proof of Theorem \ref{thm:JS-NN2}, use Lemma \ref{lem:JS-DNN-sig}, and we have $$F_D(P_{\theta},\widehat{\theta})\leq C\kappa\left(\epsilon+(2B)^{L-1}\sqrt{\frac{p\log p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ uniformly over $D\in{\mathcal{F}}_L^H(\kappa,\tau,B)$ with probability at least $1-\delta$. Choose $w_1=\kappa$ and $w_j=0$ for all $w_j>1$. For any unit vector $\widetilde{u}\in\mathbb{R}^p$, take $u_{1h}=-u_{1(h+p)}=\widetilde{u}_h$ for $h=1,...,p$ and $b_1=-\widetilde{u}^T\theta$. For $h=1,...,p$, set $g_{1h}(x)=\max(x_h,0)$. For $h=p+1,...,2p$, set $g_{1h}(x)=\max(-x_{h-p},0)$. It is obvious that such $u$ and $b$ satisfy $\sum_hu_{1h}^2\leq 2$ and $|b_1|\leq \|\theta\|\leq \sqrt{p}\|\theta\|_{\infty}\leq\sqrt{p\log p}$. We need to show both the functions $\max(x,0)$ and $\max(-x,0)$ are elements of $\mathcal{G}_{L-1}^H(B)$. This can be proved by induction. It is obvious that $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_1^H(B)$ for any $h=1,...,p$. Suppose we have $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_l^H(B)$ for any $h=1,...,p$. Then, \begin{eqnarray*} \max\left(\max(x_h,0)-\max(-x_h,0),0\right) &=& \max(x_h,0), \\ \max\left(\max(-x_h,0)-\max(x_h,0),0\right) &=& \max(-x_h,0). \end{eqnarray*} Therefore, $\max(x_h,0), \max(-x_h,0)\in\mathcal{G}_{l+1}^H(B)$ as long as $B\geq 2$. Hence, the above construction satisfies $D(x)={\sf sigmoid}(\kappa{\sf sigmoid}(\widetilde{u}^T(x-\theta)))\in\mathcal{F}_L^H(\kappa,\tau,B)$, and we have \begin{equation} f_{u^T(\widehat{\theta}-\theta)}(\kappa)\leq C\kappa\left(\epsilon+(2B)^{L-1}\sqrt{\frac{p\log p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right), \label{eq:not-c-again} \end{equation} where the definition of $f_{\delta}(t)$ is given by (\ref{eq:def-f-delta-t}) with $Z\sim N(0,1)$ and $\sigma(\cdot)$ is taken as ${\sf sigmoid}(\cdot)$. Apply the a similar in the proof of Theorem \ref{thm:JS-NN2}, we obtain the desired result. \end{proof} \begin{proof}[Proof of Theorem \ref{thm:elliptical}] We use $P_{\theta,\Sigma,h}$ to denote the elliptical distribution $EC(\theta,\Sigma,h)$. Define $$F(P,(\eta,\Gamma,g))=\sup_{\|w\|_1\leq\kappa,u,b}F_{w,u,b}(P,(\eta,\Gamma,g)),$$ where $$F_{w,u,b}(P,(\eta,\Gamma,g))=E_P\log D(X)+E_{EC(\eta,\Gamma,g)}\log\left(1-D(X)\right)+\log 4,$$ with $D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j\sigma(u_j^Tx+b_j)\right)$. The same argument in Theorem \ref{thm:JS-NN2} leads to the fact that with probability at least $1-\delta$, $$F_{w,u,b}(P_{\theta,\Sigma,h},(\widehat{\theta},\widehat{\Sigma},\widehat{h}))\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ for all $\|w\|_1\leq \kappa$, $\|u_j\|\leq 1$ and $b_j$. Take $w_1=\kappa$, $w_j=0$ for all $j>1$, $u_1=u/\sqrt{u^T\widehat{\Sigma}u}$ for some unit vector $u$ and $b_1=-u^T\theta/\sqrt{u^T\widehat{\Sigma}u}$, and we get $$f_{\frac{u^T(\widehat{\theta}-\theta)}{\sqrt{u^T\widehat{\Sigma}u}}}(\kappa)\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ where $$f_{\delta}(t)=\int \log\left(\frac{2}{1+e^{-t\sigma(\Delta s)}}\right)h(s)ds+\int\log\left(\frac{2}{1+e^{t\sigma(\delta+s)}}\right)\widehat{h}(s)ds,$$ where $\delta=\frac{u^T(\widehat{\theta}-\theta)}{\sqrt{u^T\widehat{\Sigma}u}}$ and $\Delta=\frac{\sqrt{u^T\Sigma u}}{\sqrt{u^T\widehat{\Sigma}u}}$. A similar argument to the proof of Theorem \ref{thm:JS-NN2} gives \begin{eqnarray*} && \frac{\kappa}{2}\left(\int\sigma(\Delta s)h(s)ds-\int \sigma(\delta+s)\widehat{h}(s)ds\right) \\ &\leq& 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) + \frac{\kappa^2}{4}. \end{eqnarray*} Since $$\int\sigma(\Delta s)h(s)ds=\frac{1}{2}=\int\sigma(s)\widehat{h}(s)ds,$$ the above bound is equivalent to $$\frac{\kappa}{2}\left(H(0)-H(\delta)\right)\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) + \frac{\kappa^2}{4},$$ where $H(\delta)=\int \sigma(\delta+s)\widehat{h}(s)ds$. The above bound also holds for $\frac{\kappa}{2}(H(\delta)-H(0))$ by a symmetric argument, and therefore the same bound holds for $\frac{\kappa}{2}|H(\delta)-H(0)|$. Since $H'(0)=\int\sigma(s)(1-\sigma(s))\widehat{h}(s)ds=1$, $H(\delta)$ is locally linear at $\delta=0$, which leads to a desired bound for $\delta=\frac{u^T(\widehat{\theta}-\theta)}{\sqrt{u^T\widehat{\Sigma}u}}$. Finally, since $u^T\widehat{\Sigma}u\leq M$, we get the bound for $u^T(\widehat{\theta}-\theta)$. The proof is complete by taking supreme of $u$ over the class of all unit vectors. \end{proof} \iffalse \begin{proof}[Proof of Theorem \ref{thm:unknown-cov}] We use $P_{\eta,\Gamma}$ to denote the distribution $N(\eta,\Gamma)$. Define $F(P,(\eta,\Gamma))=\sup_{\|w\|_1\leq\kappa,u,b}F_{w,u,b}(P,(\eta,\Gamma))$, where $$F_{w,u,b}(P,(\eta,\Gamma))=E_P\log D(X)+E_{N(\eta,\Gamma)}\log\left(1-D(X)\right)+\log 4,$$ with $D(x)={\sf sigmoid}\left(\sum_{j\geq 1}w_j\sigma(u_j^Tx+b_j)\right)$. Then, following the same arguments that derive (\ref{eq:T2-1})-(\ref{eq:T2-5}), we get \begin{eqnarray*} F(P_{\theta,\Sigma},(\widehat{\theta},\widehat{\Sigma})) &\leq& F(P_{\theta,\Sigma},(\widehat{\theta},\widehat{\Sigma})) + 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) \\ &=& 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right). \end{eqnarray*} In other words, we have with probability at least $1-\delta$, $$F_{w,u,b}(P_{\theta,\Sigma},(\widehat{\theta},\widehat{\Sigma}))\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ for all $\|w\|_1\leq \kappa$, $\|u_j\|\leq 1$ and $b_j$. Take $w_1=\kappa$, $w_j=0$ for all $j>1$, $u_1=u$ for some unit vector $u$ and $b_1=-u^T\theta$, and we get $$ f_{u^T(\widehat{\theta}-\theta),\sqrt{u^T\widehat{\Sigma}u},\sqrt{u^T\Sigma u}}(\kappa)\leq 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right),$$ where $$ f_{\delta,a,b}(t)=\mathbb{E}\log\frac{2}{1+e^{-t\sigma(aZ)}}+\mathbb{E}\log\frac{2}{1+e^{t\sigma(bZ+\delta)}},$$ with $Z\sim N(0,1)$. Then, by similar calculations in the proof of Theorem \ref{thm:JS-NN2}, we have \begin{eqnarray*} && \frac{\kappa}{2}\left(\int\sigma(\sqrt{u^T\Sigma u}z)\phi(z)dz-\int\sigma(\sqrt{u^T\widehat{\Sigma}u}z+u^T(\widehat{\theta}-\theta))\phi(z)dz\right) \\ &\leq& 4\kappa\epsilon + 2C\kappa\left(\sqrt{\frac{p}{n}}+\sqrt{\frac{\log(1/\delta)}{n}}\right) + \frac{\kappa^2}{4}. \end{eqnarray*} If we can show \begin{equation} \sup_{\|u\|=1}\left(\int\sigma(\sqrt{u^T\Sigma u}z)\phi(z)dz-\int\sigma(\sqrt{u^T\widehat{\Sigma}u}z+u^T(\widehat{\theta}-\theta))\phi(z)dz\right) \gtrsim \sup_{\|u\|=1}u^T(\widehat{\theta}-\theta), \label{eq:critical-cov} \end{equation} the proof will be complete. Since $\sigma(\cdot)-\frac{1}{2}$ is an odd function, we have $$\int\sigma(\sqrt{u^T\Sigma u}z)\phi(z)dz=\frac{1}{2}+\int\left(\sigma(\sqrt{u^T\Sigma u}z)-\frac{1}{2}\right)\phi(z)dz=\frac{1}{2}.$$ Now consider the function $h(\delta)=\int \sigma(bz+\delta)\phi(z)dz$, where $b=\sqrt{u^T\widehat{\Sigma}u}\leq \sqrt{M}=O(1)$. The fact that $|h(\delta)-1/2|$ is sufficiently small implies that $|\delta|=O(1)$. Then, by the local linearity of $h(\delta)$, we have $|h(\delta)-1/2|=|h(\delta)-h(0)|\gtrsim |\delta|$, which implies (\ref{eq:critical-cov}). Thus, the proof is complete. \end{proof} \fi \section*{Acknowledgement} The research of Chao Gao was supported in part by NSF grant DMS-1712957 and NSF Career Award DMS-1847590. The research of Yuan Yao was supported in part by Hong Kong Research Grant Council (HKRGC) grant 16303817, National Basic Research Program of China (No. 2015CB85600), National Natural Science Foundation of China (No. 61370004, 11421110001), as well as awards from Tencent AI Lab, Si Family Foundation, Baidu Big Data Institute, and Microsoft Research-Asia. \bibliographystyle{plainnat}
{'timestamp': '2019-02-27T02:02:18', 'yymm': '1810', 'arxiv_id': '1810.02030', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02030'}
arxiv
\section{Introduction}\label{sec:INTRO} Lattice codes are appealing for high data rate communications, because they can achieve both high coding gain and high shaping gain. Construction D$^\prime$ lattices \cite{Barnes-cjm83} are based on nested binary linear codes and can be regarded as multilevel codes \cite{Wachsmann-1999}. If lattices are to be widely used in future communications systems, Construction D$^\prime$ lattices using binary low-density parity-check (LDPC) codes are an extremely likely candidate, because many communication standards have recently adopted binary LDPC codes for error correction in the physical layer. A particularly important class of LDPC codes are quasi-cyclic (QC) LDPC codes \cite{Fossorier-2004} that have been included in various IEEE 802-related standards such as: 802.11n, 11ad, 15.3c, 16e and 22, because of their excellent error-rate performance in noisy channels and efficient hardware implementation. Recently, Branco da Silva and Silva solved an important problem, giving efficient encoding and decoding algorithms for Construction D$^\prime$ lattices using LDPC codes \cite{Silva-isit18}. For lattice design, they used the \emph{equal-error-probability rule} to design binary LDPC codes by an extended progressive edge growth (PEG) algorithm that includes check-node splitting. Their multistage decoding algorithm has linear complexity and uses belief-propagation (BP) binary decoders. Single-level Construction A lattices using QC-LDPC codes are proposed in \cite{Khodaiemehr-2017}, but since all the higher levels are uncoded, the error-rate performance quickly degrades as the block length increases. In this paper, we use the \emph{balanced-distances rule} to design underlying codes to form Construction D$^\prime$ lattices. The lattice coding gain can be maximized by designing the underlying codes with appropriate minimum Hamming distances. Rather than randomly constructing binary LDPC codes by check-node splitting \cite{Silva-isit18}, we use binary QC-LDPC codes at the first encoding level and single parity-check (SPC) product codes at the second level. One of our designs uses the QC-LDPC codes from the IEEE 802.16e standard \cite{802.16e-2006}. The minimum Hamming distance of these codes can be efficiently computed using their QC structure \cite{Rosnes-2009,Rosnes-2012}. Compared to generalized Construction D$^\prime$ lattices \cite{Silva-isit18}, the proposed lattices are based on QC-LDPC codes without using the PEG algorithm. Our lattice design uses the minimum Hamming distance of binary codes and does not require the simulation-based design of the equal-error-probability rule. QC-LDPC codes can be encoded with simple shift registers in linear time and efficiently decoded using partial parallelization. SPC product codes are simple and easy to implement. Simulation results show that the proposed lattice based on IEEE 802.16e QC-LDPC codes performs competitively to the generalized Construction D$^\prime$ lattice based on LDPC codes in \cite{Silva-isit18} and the Construction D lattice based on polar codes in \cite{Yan-isit13} over the power-unconstrained additive white Gaussian noise (AWGN) channel with respect to the block-error rate. \section{Background} \label{sec:BG} \subsection{QC-LDPC Codes} An LDPC code is a linear block code given by the null space of a sparse $m \times n$ parity-check matrix $\H$. If $\H$ consists of $z \times z$ square submatrices that are either circulant permutation matrices (CPMs) or the zero matrix, the code can be characterized as a QC-LDPC code with circulant size $z$. The $m \times n$ parity-check matrix of a QC-LDPC code with code length $n=zn_{\mathrm{b}}$ and redundancy $m=zm_\mathrm{b}$ can be represented by \begin{align} \setlength{\arraycolsep}{2.05pt} \H_{\mathrm{qc}} = \left[ \begin{array}{cccc} \mathbf{P}_{b(0,0)} & \mathbf{P}_{b(0,1)} & \cdots & \mathbf{P}_{b(0,n_{\mathrm{b}}-1)} \\ \mathbf{P}_{b(1,0)} & \mathbf{P}_{b(1,1)} & \cdots & \mathbf{P}_{b(1,n_{\mathrm{b}}-1)} \\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{P}_{b(m_\mathrm{b}-1,0)} & \mathbf{P}_{b(m_\mathrm{b}-1,1)} & \cdots & \mathbf{P}_{b(m_\mathrm{b}-1,n_{\mathrm{b}}-1)}\\ \end{array} \label{eq:H_qc} \right], \setlength{\arraycolsep}{5pt} \end{align} where $\mathbf{P}_{b(i,j)}$, $0 \leq i \leq m_\mathrm{b}-1$, $0 \leq j \leq n_{\mathrm{b}}-1 $, represents a $z \times z$ CPM, which is a cyclic shift of the columns of the identity matrix to the right $b(i,j) \in \{-1,0,\ldots,z-1\}$ times; $\mathbf{P}_{-1}$ denotes the zero matrix. In the following, $g_{\mathrm{qc}} = \left\{ \mathbf{c}_{\mathrm{qc}} \in \{0,1\}^n : \H_{\mathrm{qc}} \mathbf{c}_{\mathrm{qc}}^T = \bm{0} \right\}$, where $(\cdot)^T$ denotes the transpose of its argument, will denote a binary QC-LDPC code with minimum Hamming distance $d_{\mathrm{qc}}$. The code rate $r_{\mathrm{qc}}$ is lower-bounded by $1 - m/n$, with equality when $\H_{\mathrm{qc}}$ is full rank. \subsection{SPC Product Codes} A two-dimensional product code \cite[Sec.~3.5]{Ryan-Lin-book-2009} with code length $n = p q$ can be constructed from a $p \times q$ rectangular array in which every row and column are codewords of two binary linear block codes of length $q$ and $p$, respectively. Consider both component codes to be binary SPC codes, of which each codeword consists of $q-1$ or $p-1$ information bits and one parity-check bit. Then the product code formed from the SPC component codes is an SPC product code. A codeword of the SPC product code consists of four parts: $(p-1)(q-1)$ information bits, $p-1$ parity-check bits for the rows, $q-1$ parity-check bits for the columns and one parity-check bit for the row (or column) parity-check bits. A $(p+q) \times pq$ parity-check matrix of an SPC product code is given by \begin{align} \renewcommand{\arraystretch}{1.25} \H_{\mathrm{spc}} = \left[ \begin{array}{c} \bm{\mathcal{I}} \\ \hline \bm{\mathcal{S}} \end{array} \right] = \left[ \begin{array}{ccccc} \mathbf I_0 & \mathbf I_1 & \mathbf I_2 & \cdots & \mathbf I_{p-1} \\ \hline \mathbf{S}_0 & \mathbf{S}_1 & \mathbf{S}_2 & \cdots & \mathbf{S}_{p-1} \end{array} \right], \label{eq:H_spc} \end{align} where $\H_{\mathrm{spc}}$ is divided into two parts: $\bm{\mathcal{I}}$ and $\bm{\mathcal{S}}$ that each contains a single one in each column. The top part $\bm{\mathcal{I}}$, which consists of identity matrices of size $q$, denoted by $\mathbf I_j$ ($0 \leq j \leq p-1$), represents parity checks on the columns of the product code. The bottom part $\bm{\mathcal{S}}$, which consists of $p \times q$ submatrices denoted by $\mathbf{S}_j$ ($0 \leq j \leq p-1$), represents parity checks on the rows of the product code. The submatrix $\mathbf{S}_j$ has $q$ contiguous ones in its $j$-th row and zeros elsewhere. This results in a ``staircase'' block row $\bm{\mathcal{S}}$ as follows: \begin{align} \setlength{\arraycolsep}{2.25pt} \bm{\mathcal{S}} \!=\! \left[ \begin{array}{cccccccccccccccc} 1 & 1 & \cdots & 1 & 0 & 0 & \cdots & 0 & 0 & 0 & \cdots & 0 & 0 & 0 & \cdots & 0 \\ 0 & 0 & \cdots & 0 & 1 & 1 & \cdots & 1 & 0 & 0 & \cdots & 0 & 0 & 0 &\cdots & 0 \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \ddots & \ddots & \ddots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & 0 & 0 & 0 & \cdots & 0 & 0 & 0 & \cdots & 0 & 1 & 1 & \cdots & 1 \\ \end{array} \label{eq:S} \right]\!. \setlength{\arraycolsep}{5pt} \end{align} In addition, the check on the checks of the SPC product code is contained in both $\bm{\mathcal{I}}$ and $\bm{\mathcal{S}}$, which leaves one redundant row in $\H_{\mathrm{spc}}$. This results in $\H_{\mathrm{spc}}$ having rank $p+q-1$. In the following, $g_{\mathrm{spc}} = \left\{ \mathbf{c}_{\mathrm{spc}} \in \{0,1\}^n : \H_{\mathrm{spc}} \mathbf{c}_{\mathrm{spc}}^T = \bm{0} \right\}$ will denote a binary SPC product code with code rate $r_{\mathrm{spc}} = (p-1)(q-1) / pq$ and minimum Hamming distance $d_{\mathrm{spc}} = 4$. \subsection{Construction D$^\prime$ Lattices} Construction D$^\prime$ converts a set of parity checks defining a family of nested binary linear codes into congruences for a lattice. Let $g_0 \subseteq g_1 \subseteq \cdots \subseteq g_{L} = \{0,1\}^n$ be a family of nested binary codes, where $g_l$ is an $(n, k_l, d_l)$ code of length $n$, dimension $k_l$ and minimum Hamming distance $d_l \geq 4^{L-l}$ for $l = 0, \ldots, L-1$. Let $\mathbf{h}_0, \ldots, \mathbf{h}_{n-1}$ be linearly independent vectors in $\{0,1\}^n$ such that for $l = 0, \ldots, L-1$, $g_l$ with rate $r_l = k_l / n = (n-m_l) / n$ is defined by the parity-check matrix \begin{align} \renewcommand{\arraystretch}{1} \H_l = \left[ \begin{array}{c} \mathbf{h}_0 \\ \vdots \\ \mathbf{h}_{m_l-1} \\ \end{array} \right]. \label{eq:H_l} \end{align} Note that because $g_L = \{0,1\}^n$, $r_L = 1$, $k_L = n$, $m_L = 0$ and $d_L = 1$. Then the Construction D$^\prime$ lattice $\Lambda$ is defined by \begin{align} \begin{split} \Lambda =& \left\{ \mathbf{x} \in \mathbb Z^n : \mathbf{h}_j \cdot \mathbf{x}^T \equiv 0 \: (\mathrm{mod} \: 2^{l+1}),\right. \\ &\left.\;\; 0 \leq l \leq L-1,\, m_{l+1} \leq j \leq m_l-1 \right\}, \label{eq:congruence} \end{split} \end{align} where $\mathbb Z$ denotes the set of integers. The volume of the Voronoi region for an $n$-dimensional Construction D$^\prime$ lattice $\Lambda$ is given by \begin{align} V(\Lambda) &= 4^{\left(L- \sum^{L-1}_{l=0} r_l\right) n/2}. \label{eq:volume} \end{align} The squared minimum Euclidean distance between any two points in the lattice $\Lambda$ is the squared minimum distance $d^2_{\min}(\Lambda)$. Then the lattice coding gain is given by \begin{align} \gamma_{\mathrm{c}}(\Lambda) = \frac{d^2_{\mathrm{min}}(\Lambda)} {V(\Lambda)^{2/n}}. \label{eq:coding_gain} \end{align} \subsection{Design for Construction D$^\prime$ Lattices} There are three approaches that have been used to design multilevel Construction D or D$^\prime$ lattices recently \cite{Wachsmann-1999}: 1) The \emph{capacity rule} was used for designing the polar lattices \cite{Yan-isit13}: the component code rate $r_l$ is chosen equal to the capacity of the channel at each coding level $l$, $l=0,\ldots,L-1$. 2) The \emph{equal-error-probability rule} was used for designing the LDPC lattice \cite{Silva-isit18}: the underlying binary codes should have an analytic expression for their error probability, and the codes are chosen in such a way that the error probabilities of the channels or their bounds are equal. 3) The \emph{balanced-distances rule} is based on the squared minimum Euclidean distance in signal space. This rule is satisfied by well-known lattices such as the Barnes-Wall lattice. The balanced-distances rule used in this paper provides that for Construction D$^\prime$ lattices at each encoding level $l$, the minimum Hamming distance $d_l$ of the component code $g_l$ should satisfy \begin{align} 4^l d_l = \mathrm{constant}, \qquad l = 0, \ldots, L-1. \label{eq:BDR} \end{align} From the bound on the squared minimum distance of Construction D$^\prime$ lattices given in \cite[Th.~3.1]{Sadeghi-2006}, for a commonly used two-level construction, $d^2_{\min}(\Lambda)$ of the lattice $\Lambda$ given by Construction D$^\prime$ is bounded by \begin{align} 4^L \geq d_{\min}^2(\Lambda) \geq \min \left\{ d_0, 4d_1 \right\}, \label{eq:d_min_l=2} \end{align} from which $d^2_{\min}(\Lambda)$ is no greater than $16$ for $L=2$. To achieve the upper bound of $d_{\min}^2(\Lambda) = 16$, we set $\mathrm{constant}=16$ in \eqref{eq:BDR}, which results in $d_0 = 16$ for $g_0$ and $d_1 = d_0 / 4 = 4$ for $g_1$. This will be our code design objective. \subsection{Encoding and Decoding for Construction D$^\prime$ Lattices} We use the encoding and decoding algorithms with complexity $O(Ln)$ for Construction D$^\prime$ lattices described in \cite{Silva-isit18}. Sequential encoding modifies the congruence of Construction D$^\prime$ lattices from a zero vector to the syndrome vector of the previous encoding level. Since the underlying component codes are binary LDPC codes, one can easily modify the efficient encoding algorithm of \cite{Richardson-enco-2001} by appending the syndrome vector to the approximately triangular parity-check matrix of each component code at the left or right side. Then a dummy bit `$1$' is correspondingly added to each component codeword at the head or the tail, depending on the appended position of the syndrome vector. On the other hand, the decoding is a multistage decoding based on applying the sum-product algorithm (SPA) in each level. Appending the syndrome vector to the parity-check matrix in each encoding level makes no requirement of an efficient reencoding process for multistage decoding. The log-likelihood ratio of the dummy bit `$1$' is set to infinity, which indicates that the first or last bit of the component codeword is always equal to one. \section{Proposed Construction D$^\prime$ Lattices}\label{sec:PP} In this section, using the balanced-distances rule, we propose two-level Construction D$^\prime$ lattices. The lattices are based on modified QC-LDPC codes $g_{\mathrm{qc}}$ with $d_{\mathrm{qc}}=16$ for the first-level component code $g_0$ and SPC product codes $g_{\mathrm{spc}}$ with $d_{\mathrm{spc}}=4$ for the second-level component code $g_1$. These binary linear codes and their parity-check matrices are nested, which means that $g_0$ is contained in $g_1$ as a subcode and $\H_1$ is a submatrix of $\H_0$. In contrast, a key property of \cite{Silva-isit18} is that $\H_1$ does not need to be a submatrix of $\H_0$. \subsection{Construction} First consider a QC-LDPC code $g_{\mathrm{qc}}$ defined by the parity-check matrix $\H_{\mathrm{qc}}$ with circulant size $z$ as shown in \eqref{eq:H_qc}. $g_{\mathrm{qc}}$ can be efficiently encoded by $\H_{\mathrm{qc}}$. Then to construct a lattice, we want $g_{\mathrm{qc}}$ to be nested with another binary linear code. Our inspiration is from the fact that a code $g_{\mathrm{spc}}$ can be naturally nested into $g_{\mathrm{qc}}$ by merging their parity-check matrices. For the proposed construction, $\H_{\mathrm{qc}}$ should contain at least one block row $i$ consisting of nonzero matrices, i.e., ${b(i,j)} \geq 0$ for all $0 \leq j \leq n_\mathrm{b}-1$. The first-level code $g_0$ is defined by a $(m + n / z) \times n$ parity-check matrix $\H_0$ of the following form: \begin{align} \H_0 &= \left[ \renewcommand{\arraystretch}{1.25} \begin{array}{c} \H_{\mathrm{qc}} \\ \hline \bm{\mathcal{S}} \\ \end{array} \right] \nonumber \\ &= \left[ \setlength{\arraycolsep}{1.9pt} \renewcommand{\arraystretch}{1} \begin{array}{cccc} \mathbf{P}_{b(0,0)} & \mathbf{P}_{b(0,1)} & \cdots & \mathbf{P}_{b(0,n_{\mathrm{b}}-1)} \\ \mathbf{P}_{b(1,0)} & \mathbf{P}_{b(1,1)} & \cdots & \mathbf{P}_{b(1,n_{\mathrm{b}}-1)} \\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{P}_{b(m_\mathrm{b}-1,0)} & \mathbf{P}_{b(m_\mathrm{b}-1,1)} & \cdots & \mathbf{P}_{b(m_\mathrm{b}-1,n_{\mathrm{b}}-1)} \\ \hline \mathbf{S}_{0} & \mathbf{S}_{1} & \cdots & \mathbf{S}_{n_{\mathrm{b}}-1} \\ \end{array} \right], \label{eq:H_0} \setlength{\arraycolsep}{5pt} \end{align} where the block row $\bm{\mathcal{S}}$ is as shown in \eqref{eq:S} with $p=n/z$ and $q=z$. The resulting $g_0$ is a binary linear code, specifically it is a modified QC-LDPC code $g_{\mathrm{qc}}$ with code length $n$ and $m+n/z$ parity checks. Hence, the code rate of $g_0$ is bounded as $r_{\mathrm{qc}} \geq r_0 > 1 - (m+n/z) / n$, where the left inequality is due to the appended $n/z$ rows in $\H_0$ and the right inequality indicates that $\H_0$ is \emph{rank deficient}. Note that $g_0$ still has a QC structure, since the parity check described by each $\mathbf S_j$ defines a cyclic code, for all $0 \leq j \leq n_\mathrm{b}-1$. Furthermore, $d_0 \geq d_{\mathrm{qc}}$, since the appended $\bm{\mathcal S}$ cannot decrease the minimum Hamming distance. The second-level code $g_1$, which contains $g_0$, is defined by the $(z+n/z) \times n$ parity-check matrix \begin{align} \setlength{\arraycolsep}{1.8pt} \renewcommand{\arraystretch}{1.25} \H_1 = \left[ \begin{array}{c} \bm{\mathcal{P}} \\ \hline \bm{\mathcal{S}} \end{array} \right] {=} \left[ \begin{array}{cccc} \mathbf{P}_{b(i,0)} & \mathbf{P}_{b(i,1)} & \cdots & \mathbf{P}_{b(i,n_{\mathrm{b}}-1)} \\ \hline \mathbf{S}_{0} & \mathbf{S}_{1} & \cdots & \mathbf{S}_{n_{\mathrm{b}}-1} \\ \end{array} \right], \label{eq:H_1} \setlength{\arraycolsep}{5pt} \end{align} which is a submatrix of $\H_0$. Compared to \eqref{eq:H_spc}, although $\H_1$ does not necessarily include identity matrices, $g_1$ defined by $\H_1$ is still an SPC product code with code rate $r_1 = 1 - (z + n/z - 1) / n$. \subsection{Design Example} In this subsection, we give a design example of the proposed Construction D$^\prime$ lattices. \begin{example} Consider a $(3,5)$-regular QC-LDPC code with circulant size $z = 34$, code length $n = 5 \times 34 = 170$ and $m = 3 \times 34 = 102$ parity checks. We start with a base-prototype matrix $\H_{\mathrm{b}}$ consisting of fifteen $34 \times 34$ identity matrices, i.e., $b(i,j) = 0$ for $0 \leq i \leq 2 $ and $0 \leq j \leq 4 $. We then replace the values of all $b(i,j)$ by random numbers from $\{0,\ldots,33\}$ and compute the corresponding minimum Hamming distance using the algorithm in \cite{Rosnes-2009,Rosnes-2012}, until $d_{\mathrm{qc}} = 16$ is obtained. The $3 \times 5$ base-prototype matrix \begin{align} \H_{\mathrm{b}} = \left[ \begin{array}{ccccc} 7& 13& 19& 22& 31 \\ 1& 11& 3& 2& 19 \\ 31& 25& 18& 3& 26 \end{array} \right], \label{eq:H_b} \end{align} which defines a code $g_{\mathrm{qc}}$ with $d_{\mathrm{qc}} = 16$ for $z=34$, was obtained. Then we can obtain $\H_{\mathrm{qc}}$ by expanding $\H_{\mathrm{b}}$ and append $\bm{\mathcal{S}}$ to generate $\H_0$. As a result, we form a Construction D$^\prime$ lattice by two nested binary linear codes $g_0$ and $g_1$, where $g_0$ is a modified $g_{\mathrm{qc}}$ with parameters $(170\!+\!1,68,d_0=16)$, $r_0 = 0.398$ and $g_1$ is an SPC product code $g_{\mathrm{spc}}$ with parameters $(170\!+\!1,132,d_1=4)$, $r_1 = 0.772$. Thus from the balanced-distances rule, the constructed lattice $\Lambda$ has $d_{\min}^2(\Lambda) = 16$ and coding gain $\gamma_{\mathrm{c}}(\Lambda) = 7.04 \textrm{ dB}$. \label{exp:1} \end{example} Simulation results of each component code and the constructed lattice in Example~\ref{exp:1} are shown in Section~\ref{sec:SR}. \section{Lattices from IEEE 802.16e QC-LDPC Codes} \label{sec:802.16e} \subsection{IEEE 802.16e QC-LDPC Codes} The IEEE 802.16e standard \cite{802.16e-2006} provides a class of well-designed QC-LDPC codes. In the standard, several $m_{\mathrm{b}} \times n_{\mathrm{b}}$ base-prototype matrices $\H_{\mathrm{b}}$ are used to generate QC-LDPC codes of various lengths and rates. An $\H_{\mathrm{b}}$ is defined for the codes with length $n=2304$ and circulant size $z=96$. To generate codes of length $n$, we can use the modulo operation \begin{align} b_n(i,j) = b_{2304}(i,j) \: \mathrm{mod} \: \left(96 \times \frac{n}{2304}\right) \label{eq:b_ij} \end{align} to modify the right circulant permutations given by $b_n(i,j)$ that are specified as entries in $\H_{\mathrm{b}}$, for all $0 \leq i \leq m_\mathrm{b}-1$, $0 \leq j \leq n_{\mathrm{b}}-1$, and circulant size $z = 96 \times n / 2304$. From \cite{Rosnes-2012}, the rate-$1/2$ code of $n=1152$ and $z=48$ is a good candidate for our lattice construction, since $d_{\mathrm{qc}}=16$. \subsection{Modification to IEEE 802.16e QC-LDPC Codes} We proposed to construct $g_0$ by appending the block row $\bm{\mathcal{S}}$ to the parity-check matrix $\H_{\mathrm{qc}}$ in Section~\ref{sec:PP}. However, using the IEEE 802.16e base-prototype matrix, it is not possible to form a single SPC product code for $g_1$ using the appended $\bm{\mathcal{S}}$, because the base-prototype matrix does not contain one block row of nonzero matrices. Nevertheless, by modifying the base-prototype matrix it is possible to form two SPC-like product codes. Then a concatenation of the two SPC-like product codes can be used for $g_1$. We intend to find block rows in the unmodified base-prototype matrix such that their sum can cover as many block columns as possible. The selected block rows should have a minimal overlap of CPMs. The modification to the $12 \times 24$ base-prototype matrix of rate-$1/2$ codes is shown in Table~\ref{tb:H_b}, \begin{table*}[!htbp] \centering \renewcommand{\arraystretch}{1.1} \addtolength{\tabcolsep}{-2pt} \caption{Base-Prototype Matrix $\H_{\mathrm{b}}$ of the First-Level Component Code $g_0$ from IEEE 802.16e Rate-$1/2$ QC-LDPC Codes} \label{tb:H_b} \begin{tabular}{c|cccccccccccccccccccccccc} $i \backslash j$ &0&1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23 \\ \hline 0&-1&94&73&-1&-1&-1&-1&-1&55&83&-1&-1&7&0&-1&-1&-1&-1&-1&-1&-1&-1&-1&-1 \\ \bf{1}&-1&27&-1&-1&-1&22&$\mathbf{Q}_{-1}$&9&-1&-1&-1&12&$\mathbf{Q}_{33}$&0&0&-1&-1&-1&-1&-1&-1&-1&-1&-1 \\ 2&-1&-1&-1&24&22&81&-1&33&-1&-1&-1&0&-1&-1&0&0&-1&-1&-1&-1&-1&-1&-1&-1 \\ 3&61&-1&47&-1&-1&-1&-1&-1&65&25&-1&-1&-1&-1&-1&0&0&-1&-1&-1&-1&-1&-1&-1 \\ \bf{4}&-1&-1&39&-1&-1&-1&84&-1&-1&41&72&-1&-1&-1&-1&$\mathbf{Q}_{6}$&0&0&-1&-1&-1&-1&-1&-1 \\ 5&-1&-1&-1&-1&46&40&-1&82&-1&-1&-1&79&0&-1&-1&-1&-1&0&0&-1&-1&-1&-1&-1 \\ 6&-1&-1&95&53&-1&-1&-1&-1&-1&14&18&-1&-1&-1&-1&-1&-1&-1&0&0&-1&-1&-1&-1 \\ 7&-1&11&73&-1&-1&-1&2&-1&-1&47&-1&-1&-1&-1&-1&-1&-1&-1&-1&0&0&-1&-1&-1 \\ \bf{8}&12&-1&-1&-1&83&24&-1&43&-1&-1&-1&51&-1&-1&-1&-1&-1&-1&$\mathbf{Q}_{10}$&-1&0&0&-1&-1 \\ 9&-1&-1&-1&-1&-1&94&-1&59&-1&-1&70&72&-1&-1&-1&-1&-1&-1&-1&-1&-1&0&0&-1 \\ \bf{10}&-1&-1&7&65&-1&-1&-1&-1&39&49&-1&-1&-1&-1&-1&-1&-1&-1&-1&$\mathbf{Q}_{46}$&-1&-1&0&0 \\ 11&43&-1&-1&-1&-1&66&-1&41&-1&-1&-1&26&7&-1&-1&-1&-1&-1&-1&-1&-1&-1&-1&0 \\ $\bm{\mathcal{S}}$&$\mathbf{S}_{0}$&$\mathbf{S}_{1}$&$\mathbf{S}_{2}$&$\mathbf{S}_{3}$&$\mathbf{S}_{4}$&$\mathbf{S}_{5}$&$\mathbf{S}_{6}$&$\mathbf{S}_{7}$&$\mathbf{S}_{8}$&$\mathbf{S}_{9}$&$\mathbf{S}_{10}$&$\mathbf{S}_{11}$&$\mathbf{S}_{12}$&$\mathbf{S}_{13}$&$\mathbf{S}_{14}$&$\mathbf{S}_{15}$&$\mathbf{S}_{16}$&$\mathbf{S}_{17}$&$\mathbf{S}_{18}$&$\mathbf{S}_{19}$&$\mathbf{S}_{20}$&$\mathbf{S}_{21}$&$\mathbf{S}_{22}$&$\mathbf{S}_{23}$\\ \end{tabular} \addtolength{\tabcolsep}{2pt} \vspace{-0.2cm} \end{table*} where the appended block row $\bm{\mathcal{S}}$ consisting of $\mathbf{S}_j$, $0 \leq j \leq 23$, can be expanded to a $24 \times 1152$ submatrix of the form in \eqref{eq:S}. We selected the block rows $1$, $4$, $8$ and $10$ to be modified by replacing four specific zero matrices (for which $b(i,j) = -1$) with the four CPMs: $\mathbf{Q}_{b(1,12)}$, $\mathbf{Q}_{b(4,15)}$, $\mathbf{Q}_{b(8,18)}$ and $\mathbf{Q}_{b(10,19)}$. To remove overlap of CPMs in one block column among the selected block rows, a CPM $\mathbf{P}_{b(1,6)}$ is replaced with a zero matrix denoted by $\mathbf{Q}_{-1}$. To ensure that $\H_{\mathrm{qc}}$ is free of cycles of length $4$, we \emph{do not} reuse any existing or repeated value for these right circulant permutations. For rate-$1/2$ codes with $n = 1152$, by random search, the selection $b_{n}(1,12)=33$, $b_{n}(4,15)=6$, $b_{n}(8,18) = 10$ and $b_{n}(10,19)=46$ for the four specific right circulant permutations mentioned above gave the lowest error rate for the modified $g_{\rm qc}$. Furthermore, by using the algorithm from \cite{Rosnes-2009,Rosnes-2012}, we found that the minimum Hamming distance of the modified $g_{\mathrm{qc}}$ was increased to $d_{\mathrm{qc}}=23$. \subsection{Lattice from Modified IEEE 802.16e QC-LDPC Codes} For $g_0$, we use the modified $\H_{\mathrm{b}}$ given in Table~\ref{tb:H_b} with $z=48$ resulting in a modified $g_{\mathrm{qc}}$ with $n=1152$. For $g_1$, we add block rows $1$ and $8$ and block rows $4$ and $10$ of the modified $\H_{\mathrm{b}}$ and then append the block row $\bm{\mathcal S}$. The summations of block rows shown in Table~\ref{tb:H_c1} do not result in an SPC product code because of the double CPMs of weight $2$. \begin{table*}[htbp] \centering \renewcommand{\arraystretch}{1.1} \addtolength{\tabcolsep}{-3.2pt} \caption{Base-Prototype Matrix of the Second-Level Component Code $g_1$} \label{tb:H_c1} \begin{threeparttable} \begin{tabular}{c|cccccccccccccccccccccccc} &0&1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23 \\ \hline $1+8$&12&27&-1&-1&83&$22/24$\tnote{a}&$\mathbf{Q}_{-1}$&$9/43$\tnote{a}&-1&-1&-1&$12/51$\tnote{a}&$\mathbf{Q}_{33}$&0&0&-1&-1&-1&$\mathbf{Q}_{10}$&-1&0&0&-1&-1\\ $4+10$&-1&-1&$39/7$\tnote{a}&65&-1&-1&84&-1&39&$41/49$\tnote{a}&72&-1&-1&-1&-1&$\mathbf{Q}_{6}$&0&0&-1&$\mathbf{Q}_{46}$&-1&-1&0&0 \\ $\bm{\mathcal{S}}$&$\mathbf{S}_{0}$&$\mathbf{S}_{1}$&$\mathbf{S}_{2}$&$\mathbf{S}_{3}$&$\mathbf{S}_{4}$&$\mathbf{S}_{5}$&$\mathbf{S}_{6}$&$\mathbf{S}_{7}$&$\mathbf{S}_{8}$&$\mathbf{S}_{9}$&$\mathbf{S}_{10}$&$\mathbf{S}_{11}$&$\mathbf{S}_{12}$&$\mathbf{S}_{13}$&$\mathbf{S}_{14}$&$\mathbf{S}_{15}$&$\mathbf{S}_{16}$&$\mathbf{S}_{17}$&$\mathbf{S}_{18}$&$\mathbf{S}_{19}$&$\mathbf{S}_{20}$&$\mathbf{S}_{21}$&$\mathbf{S}_{22}$&$\mathbf{S}_{23}$\\ \end{tabular} \begin{tablenotes} \item [a] denotes a double CPM of weight $2$. \end{tablenotes} \end{threeparttable} \addtolength{\tabcolsep}{3.2pt} \vspace{-0.25cm} \end{table*} However, the resulting $g_1$ is the concatenation of two SPC-like product codes, has $d_1 = 4$ and can be decoded using BP decoding. As a result, the underlying code $g_0$ is encoded with parameters $(1152\!+\!1, 564, d_0 \geq 25)$, $r_0 = 0.489$; $g_1$ is encoded with parameters $(1152\!+\!1, 1034, d_1=4)$, $r_1 = 0.897$. For the constructed lattice $\Lambda$, we have $d_{\min}^2(\Lambda) = 16$ and $\gamma_{\mathrm{c}}(\Lambda) = 8.34 \textrm{ dB}$. \section{Simulation Results} \label{sec:SR} To verify the contribution to the lattices of each component code described in Example~\ref{exp:1} and Section~\ref{sec:802.16e} without the effects of error propagation, we evaluated the component codes separately from the lattice. These component codes were used over an additive mod-$2$ Gaussian noise (AMGN) channel with noise variance $\sigma^2$. Then we evaluated the error-rate performance of the lattices constructed by these nested component codes over the power-unconstrained AWGN channel. In the simulation, SPA decoding was performed in each stage for a maximum of $100$ iterations. The block-error rate for each component code is a function of the signal-to-noise ratio defined as $\mathrm{SNR} = 1 / \sigma^2$. The block-error rate for the lattice $\Lambda$ is a function of the volume-to-noise ratio defined as \begin{align} \mathrm{VNR} = \frac{V(\Lambda)^{2/n}}{2\pi {\mathrm e} \sigma^2}. \label{eq:vnr} \end{align} Fig.~\ref{fig:lattice-subcode-fer} shows the block-error rates of two sets of component codes and the Construction D$^\prime$ lattices based on these binary codes. \begin{figure}[tp] \centering \includegraphics[width=\columnwidth]{fer_comp_prop_lattice.pdf} \caption{Block-error rates of two sets of component codes and the Construction D$^\prime$ lattices based on these codes. The $n=171$ set of codes are from Example~\ref{exp:1}. The $n=1153$ set of codes are from a modified IEEE 802.16e QC-LDPC code. The component codes were individually used over the AMGN channel for different SNRs and the lattices were used over the power-unconstrained AWGN channel for different VNRs.} \label{fig:lattice-subcode-fer} \vspace{-0.05cm} \end{figure} For the $n=171$ set, the error-rate performance of the constructed lattice is dominated by the first-level component code $g_0$. This is so because the error-rate performance gap between the curves for $g_0$ and $g_1$ is always less than $6 \textrm{ dB}$, which is the difference in noise variance between the channels at the first and second encoding level. For the $n=1153$ set, the performance gap between the curves for $g_0$ and $g_1$ is $6 \textrm{ dB}$ at an error rate of $4 \times 10^{-5}$. Above this error rate, the performance of the constructed lattice is dominated by $g_0$; below this error rate, performance is dominated by $g_1$. Then we compared the error-rate performance between the proposed lattice based on a modified IEEE 802.16e QC-LDPC code and a concatenation of two SPC-like product codes ($n=1153$), a generalized Construction D$^\prime$ lattice based on LDPC codes ($n=1025$; the simulation curve is extracted from \cite{Silva-isit18}) and a Construction D lattice based on polar codes ($n=1024$; the simulation curve is extracted from \cite{Yan-isit13}). These two-level lattices were used over the power-unconstrained AWGN channel using multistage decoding. Fig.~\ref{fig:diff_lattice-fer} \begin{figure}[tbp] \centering \includegraphics[width=\columnwidth]{fer_comp_diff_lattice.pdf} \caption{Block-error rates of two-level lattices used over the power-unconstrained AWGN channel with multistage decoding: the proposed lattice based on a modified IEEE 802.16e QC-LDPC code and a concatenation of two SPC-like product codes ($n = 1153$), a generalized Construction D$^\prime$ lattice based on LDPC codes ($n = 1025$, curve extracted from \cite{Silva-isit18}), and a polar lattice ($n=1024$, curve extracted from \cite{Yan-isit13}). The Poltyrev limit which is at $0$ \textrm{dB} is also shown.} \label{fig:diff_lattice-fer} \vspace{-0.25cm} \end{figure} shows that the proposed lattice performs comparably to the generalized Construction D$^\prime$ lattice based on LDPC codes and looses about $0.1$ \textrm{dB} to the polar lattice. The loss in performance might be due to the increase in $d_0$ that does not strictly satisfy the balanced-distances rule, which affected the coding gain $\gamma_{\mathrm c}(\Lambda)$ of the constructed lattice $\Lambda$. However, decoding the proposed lattice has a low complexity $O(Ln)$ with sparse parity-check matrices; decoding the polar lattice has complexity $O(Ln \log n)$. The proposed lattice also benefits substantially from the QC structure of the underlying component codes. \section{Conclusion} \label{sec:CC} We have proposed a two-level Construction D$^\prime$ lattice using binary QC-LDPC codes and simple SPC product codes. Lattices constructed by these component codes can benefit substantially from their QC structure. The design criteria of the underlying component codes follow the balanced-distances rule. Under this rule, the component codes contribute in a balanced manner to the squared minimum distance of the constructed lattices. This results in a high coding gain for the lattices given by Construction D$^\prime$. We modified a rate-$1/2$ QC-LDPC code from the IEEE 802.16e standard. Simulation results show that the proposed two-level Construction D$^\prime$ lattice from the modified QC-LDPC code performs competitively to a generalized Construction D$^\prime$ lattice based on LDPC codes and a Construction D lattice based on polar codes in terms of block-error rate for the Poltyrev scenario. \bibliographystyle{IEEEtran}
{'timestamp': '2018-10-05T02:10:34', 'yymm': '1810', 'arxiv_id': '1810.02163', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02163'}
arxiv
\section{Introduction} \input{intro} \section{Related Work} \label{related-sec} \input{related} \section{Background} \label{background-sec} \input{background} \section{Data Collection Experiments} \label{method-sec} \input{methodology} \section{Results} \label{results-sec} \input{results} \section{Discussion} \label{discussion-sec} \input{discussion} \section{Conclusions and Future Work} \label{conclusion-sec} \input{conclusions} \section*{Acknowledgments} This research was sponsored by the U.S. Army Research Laboratory. The authors would like to thank Brendan Byrne, Taylor Cassidy, A. William Evans, Anya Hee, Reginald Hobbs, Su Lei, and Douglas Summers-Stay for their past contributions to this project, and the anonymous reviewers for their helpful comments. \section*{Appendix} \subsection{Collaborative Exploration Domain} \begin{figure}[t] \includegraphics[width=3in]{media/expt-layout-rescue.pdf} \caption{\label{wozsetup} The Commander issues verbal commands to the robot, whose capabilities are performed by two wizards standing in for respective abilities of dialogue and navigation. } \label{expt-layout} \end{figure} The domain testbed for our work is collaborative exploration in a low-bandwidth environment. This testbed mimics what can be found in reconnaissance and search-and-rescue operations---scenarios wherein a human may verbally instruct a robot from a remote location. The human ``Commander'' who instructs the robot has specific goals for the exploration, such as locating doors or types of objects in the physical space, but is unable to directly act in or observe this environment. The Commander cannot directly teleoperate the robot, but instead provides unconstrained spoken instructions (e.g., ``turn left 90 degrees,'' ``go through the doorway'') to accomplish assigned tasks with the robot. The Commander's knowledge of the environment is based solely upon information streams provided by the robot (see Figure~\ref{wozsetup}, upper right): a LIDAR map of the area built up in real time as the robot moves, still images taken upon request, and text message replies from the ``robot''. \subsection{Multi-Wizard Setup} \label{multi-wizard} While the main focus of this paper is on using a wizard for bootstrapping natural communication, in the initial phases of this work we use a second wizard for robot navigation. Each wizard takes the role of what we assume will ultimately be separate modules in a fully autonomous robot. In our setup, a Dialogue Manager Wizard (DM-Wizard) listens to the Commander's speech and communicates directly with him/her using a chat window to send text status updates and requests for clarification. If the instructions are executable in the current context, then in another chat window, the DM-Wizard passes a simplified text instruction set to the Robot Navigator Wizard (RN), who teleoperates the robot. When hearing robot status updates directly from the RN, the DM-Wizard communicates this information back to the Commander. Figure~\ref{wozsetup} presents our setup. \subsection{Multi-Phased Approach} The multi-phased approach to developing robot dialogue capabilities consists of a series of Experiments: In Experiment (Exp)-1, our goal was to elicit the full range of communications that may arise in our domain. To allow for this, the DM-Wizard spontaneously typed responses ({\it Free Response Mode}, see Figure~\ref{tab:examples}) to the Commander based on simple response/execution policy guidelines. The guidelines identified the minimal requirements for an executable instruction: instructions must contain both a clear action and respective endpoint. In Exp-1, the role of the DM-Wizard was relatively burdensome, as the wizard not only had to choose responses and compose messages to both the RN and to the Commander, but also had to physically type the messages as quickly and with as few typographical errors as possible. \begin{figure}[t] \centering \begin{small} \begin{tabular}{ |p{2.9in}| } \hline {\bf Free Response Mode (Experiment 1)} \\ \hline {\it P}: move forward \\ {\it Robot (DM)}: You can tell me to move to something that you see. \\ \hline {\it P}: continue to move down the hallway \\ {\it Robot (DM)}: How far should I continue down the hallway? Would you like me to reach something that you see or go a certain distance? \\ \hline \hline {\bf Structured Response Mode (Experiment 2)} \\ \hline {\it P}: robot go forward \\ {\it Robot (DM)}: I'm not sure where or when to stop moving forward. You can tell me to move a certain distance or to move to an object. \\ \hline {\it P}: can you move forward \\ {\it Robot (DM)}: I'm not sure where or when to stop moving forward. You can tell me to move a certain distance or to move to an object. \\ \hline \end{tabular} \end{small} \caption{Dialogues in Free Response Mode and Structured Response Mode between Commander Participants (P) and Robot (DM-Wizard).} \label{tab:examples} \vspace{-0.2in} \end{figure} The Exp-1 data were analyzed to extract a set of DM-Wizard messages and message templates to strike a balance between tractability for an autonomous robot and full coverage of what humans were likely to say in the context of the task domain, including how to elicit clarifications and recover from problematic instructions. This set of communications was incorporated in a GUI (Figure~\ref{dm-gui}) for the DM-Wizard in Exp-2. This {\it Structured Response Mode} reduced the typing burden and much of the composition burden for the DM-Wizard. Figure~\ref{tab:examples} shows the greater uniformity in response policy for Structured Response Mode. In the creation of the wizard interface, we considered the possibility that there would be the need for responses to the Commander that had not arisen in the data from Exp-1, thus not mapped to a button in the interface. The GUI therefore includes buttons that represent a general, non-understanding policy, which is used in cases where no more specific response could have been given. This might happen because the request was off-topic and there was no proper response (e.g., ``are you male or female?''), nonsensical in the current environment (e.g., ``turn 200 feet left''), or outside capabilities in some way that had not been encountered before. \subsection{Qualitative Lessons Learned} Based on both experiments, we found that speed and responsiveness at processing dialogue data are important for approaching a more realistic and natural pace of dialogue. Structured Response Mode allows the participant to complete more instructions when interacting with the DM-Wizard. We also found that the fast-paced nature of the dialogue requires simple messages to be sent to the participant (e.g., ``processing\dots'') to hold the conversational floor while the DM-Wizard decides what to do next. Feedback of this nature has the benefit of preventing situations where the participant issues a command, receives no response over a certain period of time, assumes something went wrong, and issues another command. We found that near-complete coverage of the language in this domain was made possible by including the following types of button categories in the GUI: (1)~fixed buttons for common instructions and clarifications, (2)~slightly generalized buttons (e.g., referring to ``which one?'' instead of ``which cone?'') for less common referents, (3)~flexible templates with slots for less common metric references and descriptions (e.g.,~``I see\dots''), and (4)~very general non-understanding responses for things that cannot be handled with other buttons sensibly (e.g.,~``I'm not sure what you're asking me to do\dots''). A mix of templating and fixed buttons helped with GUI efficiency as well: templatic when needed, but these take longer, while fixed buttons can generate quick replies. However, fixed buttons alone cannot provide full coverage. \subsection{Design and Research Implications} The results we presented provide strong support for a systematic, data-driven approach that feeds free response data from one series of human-robot dialogue collection runs forward into a structured GUI that allowed participants to provide more executable instructions than with the traditional free response approach. At the same time, high coverage of a navigation domain can be achieved with a fairly limited number of participant sessions. While the WoZ method is often used to simulate NLU in order to understand a phenomena, in this work it is used to provide a bootstrapped dataset that can be used to train a dialogue system. The interface design and eventual autonomous behaviors are driven directly by Wizard-of-Oz data collection, as opposed to researchers predicting what users want, or creating synthetic training data, as is common in traditional dialogue systems research. This approach works to address the ``cold start'' problem---what data do you use to start training a system?---with a dataset that approximates interaction with an idealized automated system (i.e., wizards). \subsection{Experiment Design and Method} Each participant first answered a questionnaire to collect demographic information. The participant was then seated at a computer monitor, fitted with a headset microphone, and given a push-to-talk button. The participant was also given a list of the robot's capabilities (see Appendix), shown a photo of the robot, and was provided with a worksheet listing the tasks and a pen for taking notes. Participants viewed the interface shown in Figure~\ref{expt-layout} (upper right), but were unaware that the robot was controlled by wizards. \begin{figure*}[t] \centering \includegraphics[width=5.6in]{media/dialogue_flow.pdf} \caption{Two wizards manage the labor of robot intelligence. Dialogues divide into \textit{transactions} where a participant gives an instruction, a \textit{Dialogue Manager} (DM-Wizard) decides how to handle it, and the DM-Wizard passes well-formed instructions to a \textit{Robot Navigator} (RN) that moves the robot.} \label{open-ended} \end{figure*} Next, the participant completed a training period in which he/she was asked to perform navigation and search tasks with the robot in a remotely-located alley-like environment. Once comfortable, the participant moved on to the two main trials, in which the robot was placed in a new, house-like environment. All environments were unfamiliar to participants. Each trial had a different start location within the house-like environment and a different set of tasks, such as counting doorways, shovels, or determining whether the space was recently occupied. The order of the main trials was counterbalanced across participants. The main trials lasted until the participant reported completion or 20 minutes, whichever occurred first. We found that participants took the full 20 minutes. No feedback was given as to their performance of the tasks. Ten people participated in each experiment. People who participated in Exp-1 did not participate again in Exp-2. In Exp-1, there were 8 male and 2 female participants, and the mean age was 44 (min = 28, max = 58). In Exp-2, there were 5 male and 5 female participants, and the mean age was 42 (min = 18, max = 58). \subsection{Corpus \& Annotations} In addition to questionnaire data, we collected data from the experiments, including speech of the participant and RN, text messages from DM-Wizard, and logs of all robot images, maps, and navigation commands. The entire corpus (training and main trials) consists of recordings from 20 participants (approximately 20 hours of audio; 3,573 utterances; 18,336 words). In addition to this raw data, all speech was transcribed, and several kinds of annotation were performed \cite{traum2018dialogue}, which we describe below. \subsubsection{Dialogue Utterances} We segment participant speech by separating it into individual \textit{utterances}, which may range from single words to phrases (e.g.,~``Turn left 90 degrees and take a picture'' would segment as ``Turn left 90 degrees'' and ``and take a picture''). \subsubsection{Dialogue Structure Annotation} To follow information exchange and assess the effectiveness of the communication, we annotated the dialogue using a dialogue structure annotation schema in which sequential sets of utterances involved with executing an instruction are encoded as a \textit{Transaction Unit} (TU)~\cite{marge2017exploring}, and each utterance is annotated for its structural role in the exchange during that TU. Figure~\ref{open-ended} shows the structure of a single TU; there are four streams of communication: (1) the participant speaking to the DM-Wizard, (2) the DM-Wizard communicating with the participant in text via a chat window, (3) the DM-Wizard communicating with the the RN also in text via a chat window, and (4) the RN speaking to the DM-Wizard. Note that there is no direct verbal communication path between the participant and the RN---utterances must be ``translated'' by the DM-Wizard. The dialogue exchange in Figure~\ref{open-ended} depicts a TU containing a \textit{Successful Instruction} (SI), that is, a well-formed instruction for which the RN reported successful execution. \subsection{Measures} We aim to assess differences in dialogue efficiency, dialogue coverage, and training data utility between Free and Structured Response Modes. We address four main questions (previously mentioned in the Introduction and summarized here): First, we ask whether more data is gathered per participant when using the Structured Mode GUI (Q1; i.e., whether participants engage in more dialogue). Second, we ask whether the human-robot communication is more productive when using the Structured Mode (Q2; i.e., more tasks completed). Third, we ask whether the Structured Mode GUI successfully achieves good coverage of the dialogue used in the task (Q3). Fourth, we ask if data collected will result in better automated NLU performance (Q4; i.e., more useful training data). For \textit{dialogue efficiency}, we measure both greater quantity of data (Q1), as well as higher task productivity (Q2) in terms of the ability of the participant to effectively communicate to the DM-Wizard, who can then pass executable instructions to the RN to navigate the space. For \textit{dialogue coverage}, we tabulate occurrences of wizard non-understanding under Structured Response Mode (Q3). For measuring \textit{utility as training data}, we compute accuracy at selecting gold standard dialogue responses with an NLU classifier (Q4). The measures are described below. \textbf{Dialogue Utterances and Words (Q1).} A greater number of participant utterances and words indicates that a greater sample of human and wizard language was collected, and might suggest a productive data-gathering session. We combine the number of utterances from the participant and from the DM-Wizard to take into account the full sum of interactions between the two speakers. \textbf{Dialogue Structure (Q2). } Utterance count alone may or may not suggest a more productive human-robot interaction in terms of successful communication or task completion. For example, if an initial instruction did not contain sufficient information or was misunderstood, more utterances would be required to clarify and repair the instruction, leading to a more verbose, but not more productive, interaction. To account for the potential correlation between more verbose instructions and more unsuccessful interactions in terms of task completion, we compute several metrics related to dialogue structure annotations to assess dialogue efficiency. A higher number of TUs corresponds with more instructions issued. In addition, the number of TUs that include a successful instruction (SI-TU) is a measure of communication effectiveness, namely the participants' ability to work with the ``robot'' (DM-Wizard) to issue a well-formed and executable instruction. The metrics by themselves may be biased towards specific instruction preferences or patterns. A participant may wait for the first instruction to be completed before issuing another (e.g., ``Turn right 90 degrees'' and then after the first instruction is executed, ``Take a picture,'' resulting in two TUs with one SI in each), or may issue instructions in a group (e.g. ``Turn right 90 degrees and take a picture,'' resulting in a single TU with two SIs). To counter this potential bias in the SI-TU metric where there may be multiple SIs within a TU, we consider the total number of SIs independent of TUs. Further, we compute an SI ratio per participant as the number of TUs that contain an SI divided by the total number of TUs (SI/TU ratio). This metric ensures that no matter how many TUs were issued, the percent of them that were well-formed and executed will be normalized across participants despite differences in instruction-giving preferences. We note that the SI-TU and SI/TU metrics count the entire TU as successful even if only part had been completed before being abandoned. The DM-Wizard will always engage in a clarification dialogue with the Commander in the event that their instructions that cannot be executed. However, the Commander may abandon a TU in which the RN has only completed a subset of the issued instructions. Since there is no way for the DM-Wizard or RN to know \textit{a priori} if the Commander will abandon the TU, we consider these TUs successful---the RN accomplished the requested tasks until the Commander decided to abandon their original request. \textbf{GUI-Button Coverage (Q3).} To measure coverage of the Structured Response Mode GUI, we examine the use of the general, non-understanding buttons and compute the percent of utterances from the DM-Wizard to the participant that are of this type (e.g., ``I'm not sure what you are asking me to do''). These indicate that (1) there is no corresponding button to pass the instruction to the RN and/or (2) there is no way to clarify the instruction in a manner that pinpoints the specific problem. \textbf{NLU Component Training Data (Q4).} Data from the experiments can be used to train machine learning algorithms for natural language understanding (NLU) and response selection. The NLU component should map an incoming user utterance to a representation that an automated dialogue manager can act upon; while there are many possible structured representations that can fit the task, we have not yet settled on a specific representation for our future automated system. Therefore, as a proxy for a structured representation, we use buttons from the DM-Wizard GUI. That is, we test the ability of using data from the experiments to identify the DM-Wizard's first reaction to participant instructions in a held-out test set (for example, relaying the utterance to the RN or asking the participant for clarification). Using Exp-2 data for training and testing the NLU is straightforward, because the DM-Wizard's reaction to each user utterance is a GUI button press. In Exp-1, however, the DM-Wizard's reaction is free text; in order to use Exp-1 data for training and testing the NLU, we manually mapped each DM-Wizard text to the corresponding GUI button. We held out one whole dialogue from each experiment as test data, and used the remainder for training. Overall we had 33~test utterances and 595~training utterances from Exp-1, and 52~test utterances and 977~training utterances from \mbox{Exp-2}. We trained and tested different versions of the NLU component using NPCEditor~\cite{LeuskiTraum2011}, a system that has been used to create classifiers for both structured and free text natural language understanding. We trained three versions of the NLU component, using Exp-1 data, Exp-2 data, and the combined data; we then tested each one on the Exp-1 test set, the Exp-2 test set, and the combined test set. Our measure of performance is accuracy: a classifier response is considered correct if it is identical to the DM-Wizard's action in the test set. However, there are some cases of distinct but equivalent DM-Wizard actions. For example, one of the test utterances is \emph{a hundred and eighty degrees to the right}, and one of the classifiers mapped it to the action \emph{w-turn\_right\_180}; however, the DM-Wizard's action in the test set was the equivalent action \emph{w-turn\_180} (no direction specified). To reflect the classifier's correct performance in cases such as this, we manually checked the output of each classifier, and marked as correct cases where it chose an action equivalent to the action in the test set. \textbf{Questionnaire Measures.} Spatial ability has been found to impact results on spoken language use in spatial contexts~\cite{schober2009spatial}. All participants completed a Spatial Orientation Survey to assess spatial orientation ability~\cite{guilford1948guilford}. \subsection{Dialogue for HRI} While natural language interaction has been explored extensively in HRI \cite{mavridis2015review}, the primary focus, as described below, has been on analyzing and determining strategies for one direction of communication (human-to-robot or vice versa), but not both directions at the same time. For human-to-robot communications, many approaches follow the methodology of \textit{corpus-based robotics} \cite{Bugmann04}, where natural language in the form of route instructions are collected from people (e.g., datasets such as \textsc{Marco} \cite{Macmahon06walkthe} and the TeamTalk corpus \cite{margeteamtalkcorpus}). Computational approaches center around natural language understanding (e.g.,~\cite{kruijff2010situated,williams2015going}) and symbol grounding methods that map language to symobolic representations used for motion planning (e.g., Tellex et al. \shortcite{tellex2011understanding}; Hemachandra et al. \shortcite{hemachandra2015learning}). Very limited effort has gone into developing robot-to-human communications beyond researchers writing the capabilities themselves. Some have made focused efforts to understand how robots can explain tasks \cite{foster2009evaluating} or paths \cite{bohus2014directions,perera2016dynamic} to people in natural language. Others have developed computational methods to ask for clarification about symbols \cite{deits2013clarifying} and to ask for help with tasks \cite{knepper2015recovering}. Differences between a human and robot's internal representation of an environment represent an instance of the grounding problem \cite{clark_1996} and must be resolved for grounding to occur. Some have studied the nature of breakdowns in human-robot communication (e.g., Marge and Rudnicky \shortcite{Marge2015}), while others have implemented real-time grounding frameworks \cite{chai2016collaborative}. Several dialogue interfaces have been developed for robots (e.g., DIARC \cite{scheutz2018cognitive} and TeamTalk \cite{usarsimteamtalk}), but most rely on handcrafted grammars or synthetic training data. Our work builds upon previous research by investigating empirical methods to human-robot \textit{dialogue} collection (not unidirectional) that strike a balance between eliciting the naturally-occurring diversity of communication strategies from participants and ensuring the data can be patterned and tractable enough for training a dialogue system. \subsection{Wizard-of-Oz (WoZ) Methodology} WoZ design is a useful tool that has been widely adopted by dialogue and HRI researchers because it allows for low development costs and extremely malleable robot functionality. WoZ has been used for handling natural language since the early days of HRI \cite{riek2012wizard} and dialogue \cite{fraser1991simulating}, and has been extended to incorporate multi-wizard setups for multimodal interfaces \cite{salber1993applying} due to task complexities such as supporting HRI (e.g., Green, Huttenrauch, and Eklundh \shortcite{green2004applying}). Wizards have also played a role in collecting dialogue clarification strategies \cite{passonneau2011embedded}. Our work expands on these methods by addressing multimodal communication when the robot and human are not co-present, where information such as robot position, visual media, and dialogue would need to be exchanged. The WoZ methodology has also been used successfully in fairly open-domain tasks, for example a conversational assistant for general-purpose information access which works by crowdsourcing multiple wizards in real time \cite{Lasecki:2013:CCC:2501988.2502057}, or an agent for social conversation which uses crowd-sourced wizards to expand its dialogue abilities \cite{Kennedy-EtAl:2017:IVA}. These open-domain applications benefit from access to many wizards with general human knowledge and limited training. In contrast, a robot navigating a specific physical environment requires fairly little knowledge (mostly about objects in the environment), but we found that standing in for such a robot requires substantial training \cite{marge-EtAl:2016:IVA}. Our work therefore concentrates on the robot's navigation and communication actions, rather than general knowledge. Some criticisms of the WoZ approach have highlighted concerns about the validity of using human-human interaction disguised as a human-robot or human-agent interaction \cite{weiss2009userexp}, and successfully migrating a WoZ setup onto an autonomous robot \cite{breazeal2005effects}. These concerns partially motivate the multi-phased approach we have adopted from virtual human research \cite{devault2014simsensei}, but with extensions for situated dialogue where the robot must be aware of, navigate, and refer to its surroundings while handling misunderstandings. \subsection{Dialogue Efficiency} We analyzed dialogue efficiency by measures associated with dialogue utterances, participant words, TUs, and SIs (Table~\ref{tab:dialogue-efficiency}). Addressing (Q1), we tabulated the number of dialogue utterances between the participant and DM-Wizard across response mode. Only response mode had a significant main effect on total dialogue utterances (F[1, 16] = 28.9, p $<$ 0.0001). We observed no significant main effects for response mode on participant number of words. Addressing (Q2), participants issued significantly more TUs when the DM-Wizard used Structured Response Mode compared to Free Response Mode. Only response mode had a significant main effect on total TUs (F[1, 16] = 11.8, p = 0.003). Participants also completed significantly more SI-TUs when the DM-Wizard used Structured Response Mode compared to Free Response Mode. Only response mode had a significant main effect on total SI-TUs (F[1, 16] = 10.9, p = 0.005). The DM-Wizard also sent more task completion messages to the participant (i.e., SIs) with Structured over Free Response Mode. Again, only response mode had a significant main effect on total SIs (F[1, 16] = 9.3, p = 0.008). We observed no significant main effects for response mode on SI-TU ratio. \subsection{Dialogue Coverage} Addressing (Q3), we measured coverage of the DM-Wizard's ability in Structured Response Mode to respond to participant instructions by tabulating the number of TUs that did not contain a non-understanding on the part of the DM-Wizard. We observed 99\% coverage of responses via the GUI in Structured Response Mode. Only 1\% of TUs completed during Structured Response Mode trials contained a non-understanding (11 out of the total 926). We found that 8 trials (out of 20 total) contained a non-understanding; these trials had a TU rate of non-understanding that ranged from 2-6\%. \subsection{Utility as Training Data} Addressing (Q4), performance of the three classifiers on the three test sets is reported in Table~\ref{tab:classifier-accuracy}. \begin{table} \small \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}rcccccc} \toprule & \multicolumn{6}{c}{Test data} \\ \cmidrule{2-7} & \multicolumn{2}{c}{Exp-1} & \multicolumn{2}{c}{Exp-2} & \multicolumn{2}{c}{Total} \\ & \multicolumn{2}{c}{\textit{(N=33)}} & \multicolumn{2}{c}{\textit{(N=52)}} & \multicolumn{2}{c}{\textit{(N=85)}} \\ \cmidrule{2-3}\cmidrule{4-5}\cmidrule{6-7} Training data & Count & \% & Count & \% & Count & \% \\ \midrule Exp-1 & 30 & 91 & 46 & 88 & 76 & 89 \\ Exp-2 & 32 & 97 & 49 & 94 & 81 & 95 \\ Total & 30 & 91 & 47 & 90 & 77 & 91 \\ \bottomrule \end{tabular*} \caption{\label{tab:classifier-accuracy}NLU classifier accuracy for different training data sizes on the dialogue response generation task. There were 595 training utterances from Exp-1 and 977 training utterances from Exp-2.} \end{table} We note that the accuracies are all fairly high, ranging from 88\% to~97\%, demonstrating that data from the experiments is useful for training an automated NLU component. The test data from Exp-1 consistently results in higher accuracies, suggesting that it's probably an easier test set. As for the training sets, we note that the best results for all test sets come from training on Exp-2 data alone---better even than training on the combined data.
{'timestamp': '2018-10-09T02:13:54', 'yymm': '1810', 'arxiv_id': '1810.02017', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02017'}
arxiv
\section*{Background} High-throughput techniques provide a high revolutionary technology to replace hybridization-based microarrays for gene expression analysis \cite{Mardis2008, Wang2009, Morozova2009}. The next-generation sequencing has evoked a wide range of applications, e.g., splicing variants \cite{wan:san:08, sul:sch:ric:08} and single nucleotide polymorphisms \cite{wan:sun:08}. In particular, RNA-seq has become an attractive alternative to detect genes with differential expression (DE) between different species, which is used to explore the evolution of gene expression levels in mammalian organs \cite{brawand:11} and the effect of gene expression levels in medicine. As one example, gene expression analyses performed in model species such as mouse is commonly used to study human diseases \cite{Ala2009}, including cancer \cite{Segal2005, Sweet2005} and hypertension \cite{Marques2010}. For different species, several studies have emerged in the recent literature to compare the gene expression levels in different organisms using microarrays or RNA-seq data. Liu et al.\cite{Liu2011} reported a systematic comparison of RNA-seq for detecting differential gene expression between closely related species. Lu et al.\cite{Lu2010} developed some probabilistic graphical models and use them to analyze the gene expression between different species. Kristiansson et al.\cite{Kristiansson2013} proposed a new statistical method for meta-analysis of gene expression profiles from different species with RNA-seq data. For different species, the RNA-seq experiments will result in not only different gene numbers and gene lengths, but also different read counts, i.e., sequencing depths. To make the expression levels of orthologous genes comparable between different species, normalization is a crucial step in the data processing procedure. The main purposes of normalization are to remove the systematic variation and to reduce the noise in the data. In the case of one species (see the first panel of Fig~\ref{fig:samesp}), various normalization methods have been developed in the last decade, e.g., modifying the gene expression with a global factor \cite{Bol:Iri:03, Mar:Mas:08, Rob:Smy:06, Bul:Pur:09}. Mortazavi et al.\cite{Mor:Wil:08} transformed RNA-seq data to reads per kilobase per million mapped (RPKM). Robinson et al.\cite{rob:osh:10, robinson2010edger} proposed a weighted trimmed mean of log-ratios method (TMM). Zhou et al.\cite{Zhou2017a} developed a hypothesis testing based normalization (HTN) method by utilizing the available knowledge of housekeeping genes, and showed that the HTN method is more robust than TMM for analyzing RNA-seq data. \begin{figure*}[!hpt] [width=4.8in, height=2in]{ppt2samespecies.pdf} [width=4.8in, height=2in]{ppt2diffspecies.pdf} \caption[Illustration]{The first panel shows the same genes of different human samples, and the second panel shows the orthologous genes in human and mouse. }\label{fig:samesp} \end{figure*} We note, however, that normalization of RNA-seq data with different species is more difficult than that with same species. For different species, we need to consider not only the total read counts but also the different gene numbers and gene lengths (see the second panel of Fig~\ref{fig:samesp}). To the best of our knowledge, few studies are available in the literature for normalizing RNA-seq data with different species. As a routine method for normalization, one often standardizes the data with different species by scaling their total number of reads to a common value. For instance, Brawand et al.\cite{brawand:11} used RPKM in \cite{Mor:Wil:08} to normalize RNA-seq data with different species. Specifically, they first identified the most conserved 1000 genes between species and then assessed their median expression levels in each species among the genes with expression values in the interquartile range for different species. Lastly, they derived the scaling factors that adjust those median values to a common value. In this paper, we extend the HTN method to the setting of different species. As described in \cite{Zhou2017a}, HTN is a normalization method under different sequence depths for the same species, and its performance outperforms other normalization methods. Based on hypothesis testing framework, it transforms the problem to find the scaling factor in normalization. By utilizing the available knowledge of housekeeping genes, it get the optimal scaling factor by minimizing the deviation between the empirical and the nominal type I error. However, the HTN method cannot be directly applied to normalize the different species dataset, because of the assumption of the same number and length. By extending the HTN method to the setting of different species, we develop a scale based normalization (SCBN) method by utilizing the available knowledge of conserved orthologous genes and the hypothesis testing framework. Here, we define conserved orthologous genes for different species instead of housekeeping genes. It is noted that the normalization scaling factor is stable for different confidence levels in the hypothesis test in both simulation studies and real data analysis. The rest of the paper is organized as follows. we first introduce the new SCBN method in detail in Section ``Materials and Methods". In Section ``Simulation Studies", we conduct simulation studies to assess the performance of the SCBN method and also compare it with the existing method. In Section ``Real Data Analysis", we apply the SCBN method to a real dataset with human and mouse to demonstrate its superiority over the existing method. The paper is concluded in Section ``Discussion" with some discussions and future work. \section*{Materials and Methods} In the following section, we propose a novel normalization method for RNA-seq data with different species by utilizing the available knowledge of conserved orthologous genes and the hypothesis testing framework. \subsection*{\bf Notations and model} Let $G=\{g_1,g_2,\ldots,g_n\}$ be the complete set of genes from two different species, and $G_0$ be the set of one-to-one orthologous genes that are to be tested for differential expression. For species $t=1$ or $2$, let $X_{g_{k}t}$ be the random variable that represents the count of reads mapped to the orthologous gene $g_{k} \in G_0$, and $x_{g_{k}t}$ be the observed value of $X_{g_k t}$. Accordingly, the total number of orthologous reads for species $t$ is $N_t=\sum_{g_{k} \in G_0}x_{g_{k}t}$. For ease of presentation, our normalization method is presented for the setting of one sample in each species only. Our proposed method, however, can be readily extended to more general settings including multiple samples for each species. For gene $g_k$ in species $t$, we consider the mean model: \begin{equation} E(X_{g_{k}t}) = \frac{\mu_{g_{k}t}L_{g_{k}t}}{S_t}N_t,\label{eq:1} \end{equation} where $\mu_{g_{k}t}$ are the true expression levels, $L_{g_{k}t}$ are the true gene lengths, and $S_t=\sum_{g_{k} \in G_0}\mu_{g_{k}t}L_{g_{k}t}$ is the total expression output of all orthologous genes in species $t$. Note that, since $L_{g_{k}t}$ are often different between species, we have included them in model (\ref{eq:1}) to alleviate the bias in gene lengths. \subsection*{\bf Novel normalization method} We propose a novel normalization method by employing the available knowledge of conserved orthologous genes and the hypothesis testing framework. Specifically, we choose a scale to minimize the deviation between the empirical and nominal type I errors in RNA-seq data based on the hypothesis test. To detect differential expressions of orthologous genes between two species, for each $g_k\in G_0$, we consider the hypothesis \begin{eqnarray*} H_{0}^{g_k}: \mu_{g_{k}1}=\mu_{g_{k}2}\quad {\rm versus} \quad H_{1}^{g_k}: \mu_{g_{k}1}\neq \mu_{g_{k}2}. \end{eqnarray*} We further assume that the reads mapped to the orthologous genes are Poisson random variables with $\lambda_{g_{k}1}=E(X_{g_{k}1})$ and $\lambda_{g_{k}2}=E(X_{g_{k}2})$. Then under model (\ref{eq:1}), the hypothesis is equivalent to \begin{align} H_{0}^{g_k}:\lambda_{g_{k}1}=\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}c\lambda_{g_{k}2}\quad {\rm versus}\ \ H_{1}^{g_k}:\lambda_{g_{k}1}\neq\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}c\lambda_{g_{k}2}, \label{eq:2} \end{align} where $c=S_2/S_1$ is the scaling factor for normalization. Given that $X_{g_{k}1}+X_{g_{k}2}=n_{g_{k}}$ with $n_{g_{k}}$ a fixed integer, the random variable $X_{g_{k}1}$ follows a binomial distribution with the conditional probability density function as \begin{eqnarray*} && P(X_{g_{k}1}= x_{g_k 1}\big|{X_{g_{k}1}+X_{g_{k}2}}=n_{g_{k}}) =\frac{n_{g_{k}}!}{x_{g_{k}1}!(n_{g_{k}}-x_{g_{k}1})!} (p_0^{g_{k}})^{x_{g_{k}1}} (1-p_0^{g_{k}})^{n_{g_{k}}-x_{g_{k}1}}, \end{eqnarray*} where $$p_0^{g_{k}}=\frac{\lambda_{g_{k}1}}{\lambda_{g_{k}1}+\lambda_{g_{k}2}}= \frac{cL_{g_{k}1}N_1}{L_{g_{k}2}N_2+cL_{g_{k}1}N_1}$$ is the probability of success under the null hypothesis of (\ref{eq:2}). For the above model, the $p$-value of the test is \begin{align} p_{g_{k}}(c)&=P( | X_{g_{k}1}-n_{g_{k}} p_0^{g_{k}}|\geq | x_{g_{k}1}-n_{g_{k}} p_0^{g_{k}}|\big|n_{g_{k}})\notag \nonumber\\ &=P(|(1+\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}c)X_{g_{k}1}-\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}cn_{g_{k}}| \geq \nonumber\\ &~~~~~|(1+\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}c)x_{g_{k}1}-\frac{L_{g_{k}1}}{L_{g_{k}2}}\frac{N_1}{N_2}cn_{g_{k}}|\big|n_{g_{k}}). \label{eq:3} \end{align} Note that the $p$-value in (\ref{eq:3}) is a function of the scaling factor $c$ under the condition $X_{g_{k}1}+X_{g_{k}2}=n_{g_{k}}$. To search for the optimal $c$ for normalization, we apply the following two questions as criteria. (i) Does the normalization method improve the accuracy of DE detection, i.e., whether or not it will decrease the false discovery rate (FDR) of the tests? (ii) Does the normalization method result in a lower technical variability or specificity? For multiple testing, Storey\cite{Stor:JD:03} pointed out that different hypothesis tests will result in different significant regions. To transform these tests into a common space, the $p$-value is a natural way to do so with respect to the positive false discovery rate (pFDR). By taking the number of set $G_0$ identical hypothesis tests, the pFDR is defined as follows: \begin{align} \mbox{pFDR}_{g_{k}}&=\!\frac{P(H_0;c)P( R_{g_k}\mid H_0; c)}{P( R_{g_k};c)} \nonumber\\ &\!=\!\frac{P(H_0;c)P( R_{g_k}\mid H_0;c)}{\!P(H_0;c)P( R_{g_k}\mid H_0;c)+P(H_1;c)P( R_{g_k}\mid H_1;c)\!}, \label{eq:31} \end{align} where $\alpha$ is the significance level and $R_{g_k}=\{p_{g_k}(c) < \alpha \}$ is the rejection region. By (\ref{eq:31}), the pFDR of gene $g_k$ is a function of both $\alpha$ and $c$. Given the values of $\alpha$ and $c$, we can apply the empirical distributions to estimate $P(R_{g_k}|H_0;c)$ and $P(R_{g_k}|H_1;c)$. Let $V_0$ and $V_1$ be the sets of non-DE genes and DE genes in $G_0$, respectively. Then, $\mbox{pFDR}_{g_{k}}(\alpha;c)$ can be estimated as \begin{eqnarray*} \widehat{\mbox{pFDR}}_{g_{k}}=\!\frac{P(H_0;c){\widehat P}( R_{g_k}\mid H_0;c)}{P(H_0;c){\widehat P}( R_{g_k}\mid H_0;c)+P(H_1;c){\widehat P}( R_{g_k}\mid H_1;c)\!}, \end{eqnarray*} where $${\widehat P}(R_{g_k} \mid H_0;c)=\frac{1}{n_0}\sum_{g_k\in V_0}I(p_{g_{k}}(c)<\alpha|H_0;c)$$ for any ${g_k\in V_0}$, and $${\widehat P}(R_{g_k}\mid H_1;c)=\frac{1}{n_1}\sum_{g_k\in V_1}I(p_{g_{k}}(c) <\alpha|H_1;c)$$ for any ${g_k\in V_1}$, where $I(\cdot)$ is the indicator function, and $n_0$ and $n_1$ represent the cardinalities of $V_0$ and $V_1$, respectively. When all non-DE genes in $V_0$ are given, we can perform our new normalization by determining the optimal scaling factor that minimizes the value of pFDR. For real data, however, it is not uncommon that only a small proportion of non-DE genes are known a priori by background knowledge. In this paper, we assume that a set of conserved orthologous genes between species are given in advance, which may either be reported in other studies or be selected by a certain biological measure \cite{brawand:11, chen:pai:14}. For the given set $H$ of conserved orthologous genes that are considered as non-DE genes for its stability between species, we search for the optimal scaling factor by minimizing the deviation between the empirical and nominal type I errors. Let $m$ be the number of genes in the set $H$. Given the true value of $c$, the $p$-values of the tests for the conserved orthologous genes follow a uniform distribution on interval $(0,1)$. That is, for the specified $\alpha$ and $c$, the value of $\sum_{g_k \in H}(1/m)I(p_{g_{k}}(c)<\alpha|H_0;c)$ should be around the nominal level at $\alpha$. In our method, we define the optimal scaling factor as $c_{\rm opt}$ that minimizes the objective function $\mid\sum_{g_k \in H}(1/m)I(p_{g_{k}}(c)<\alpha|H_0;c)-\alpha\mid $; that is, \begin{align} c_{\rm opt}=\underset{c>0}{\mbox{argmin}} \big|\sum_{g_k \in H}\frac{1}{m}I(p_{g_{k}}(c)<\alpha|H_0;c)-\alpha \big|. \label{eq:33} \end{align} Finally, to estimate the optimal scaling factor defined in (\ref{eq:33}), we apply a grid search method and denote the best estimate as $\hat c_{\rm opt}$. For convenience, we refer to the proposed scale based normalization method as the SCBN method. \section*{Simulation Studies} For a fair comparison, we generate the simulation datasets following the settings in \cite{rob:osh:10}, but with the structure of different species rather than same species. For different species, we consider different sequencing depths and lengths of orthologous genes to generate the datasets, including the DE genes, non-DE genes and unmapped genes for two species to mimic the real scenario. The unmapped genes represent those genes that exist only in one species. They are different from the unique genes, representing those orthologous genes that exist in both species but are expressed in only one of them. After setting the numbers of unique genes and unmapped genes, proportion, magnitude and direction of DE genes between two species, we randomly generate the rate of a gene expression level to the output of all the orthologous genes from a given empirical distribution of real counts. We set the expected values of the Poisson distributions from model (\ref{eq:1}), and then randomly generate simulation datasets from the respective distributions. \begin{figure}[h!] \centerline{[width=4.8in,height=3.2in]{compound.pdf}} \caption[Illustration]{The left panel is the false discovery numbers of the median and SCBN methods with different numbers of conserved genes. The right panel is the false discovery numbers of the two methods with different rates of noise in conserved genes.}\label{fig:1} \end{figure} We first evaluate the stability of the proposed SCBN method for the fixed parameters. In Study 1, we compare the false discovery numbers of the SCBN method and the median method with different numbers of conserved genes. We set 10\% of the orthologous genes as DE genes at the 1.2-fold level; of those DE genes, 90\% are up-regulated in the second species, and we set the number of unique genes as 1000 and 2000 for two species, respectively. Besides, we set 2000 and 4000 unmapped genes for two species. With the fixed parameters, we consider the cases where the number of conserved orthologous genes varies from 50 to 1000. In Study 2, the parameters are the same as those in Study 1 except that the fold level of DE genes is increased to 1.5, and we select 1000 conserved genes in each experiment. Then, we investigate the stability of the proposed method when the rates of noise in conserved genes increase from 0 to 0.6 with step size 0.1. In Study 3, we consider the adjusted M versus A plots in \cite{rob:osh:10} to compare the scaling factors of two normalization methods when the rates of noise in conserved genes equal to 0 and 0.4. In this paper, the rate of noise means the proportion of DE genes in all the conserved genes. To make it more obvious, we adjust the parameters with 20\% DE genes at the 8-fold level, and 70\% are up-regulated in the second species. The unique genes and unmapped genes are the same as before. In Study 4, we test the stability of the SCBN method by choosing different $p$-values as cutoff. In this study, we consider the cutoff values varying from 0.0001 to 0.6. The parameters are the same as those in Study 1 except that 40\% of genes are differentially expressed. Next, we investigate the performance of the SCBN method with several criteria, including the false discovery number, precision, sensitivity and $F$-score, which were also adopted in \cite{Lin2014}. In Studies 5 and 6, the parameters are kept the same as those in Study 2. In Study 5, the false discovery numbers of the two normalization methods are shown with different rates of noise in conserved genes, ranging from 0 to 0.5. In Study 6, we compare the precision, sensitivity and $F$-score for the two methods. The precision denotes the rate of true positives in all the predicted positives, the sensitivity represents the rate of true positives in all real positives, and the $F$-score is a metric to overview both the precision and sensitivity. Here, we take 0.01 as the $p$-value cutoff. In Study 7, we compare the performance of the two methods for different rates of DE genes in all orthologous genes. We set the fold change of DE genes as 1.5, the rate of noise in conserved genes as 0.2, and the rate of DE genes varying from 0.1 to 0.6. Other parameters are kept the same as those in Study 4. For each simulated dataset, we compare the false discovery numbers, which are computed by repeating the simulation 100 times, while there are time consuming in each repeat, and averaging over all the repetitions. We report the stability of the SCBN method with various parameters in Fig~\ref{fig:1}. Fig~\ref{fig:5} compares the SCBN method to the median method with false discovery number, precision, sensitivity and $F$-score criteria. The Additional file 1 compares the false discovery numbers with different rates of noise in the selected conserved genes. \begin{figure}[!h] \centerline{[width=4.8in,height=3.2in]{test4.pdf}} \caption[Illustration]{Precision (left), sensitivity (middle) and $F$-score (right) values of two normalization methods with various rates of noise.}\label{fig:5} \end{figure} The left panel of Fig~\ref{fig:1} (Study 1) shows that the false discovery numbers are reduced as the number of conserved genes increases. Whereas the false discovery numbers of the median method increase drastically when conserved genes become less, the SCBN method is much more robust to the number of conserved genes. Furthermore, the SCBN method performs much better than the median method for each number of conserved genes. As shown in the right panel of Fig~\ref{fig:1} (Study 2), the false discovery numbers of the SCBN method keep stable, but that of the median method increases gradually as the rate of noise increases. From these two studies, we can see that the SCBN method is more robust than the median method, especially when the number of conserved gene is small, or the rate of noise is large. In Study 3, the two scaling factors are presented in Additional file 2. From the left panel, the lines of the two normalization methods are close when conserved genes do not include noise. However, as the rate of noise equals to 0.4, the right panel shows the scaling factors for the SCBN method are much closer to the center of non-DE genes. Additional file 3 presents the result of Study 4, which demonstrates the choice of $p$-value cutoffs has no impact on the results of the SCBN method. In Study 5, we investigate the overall situations of false discoveries changed with different rates of noise. The results are shown in Additional file 1, which shows that the two normalization methods have a similar performance when all selected conserved genes are non-DE genes. However, the SCBN method outperforms the median method when the rate of noise becomes larger than 0.1. Hence, we conclude that the SCBN method performs significantly better than the median method when moderate-to-large rates of noise are present. \begin{figure}[h!] \centerline{[width=4.8in,height=4in]{test5.pdf}} \caption[Illustration]{The false discovery number of two normalization methods with DE genes at the rates of 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6, respectively. }\label{fig:6} \end{figure} Fig~\ref{fig:5} shows the experimental results of precision, sensitivity and $F$-scores. Since $F$-score is the harmonic mean of precision and sensitivity, it is clear that the SCBN method has overall better performance as it achieves higher $F$-scores in most cases. As we can see from the plots, when rate of noise is less than 0.1, the values of sensitivity and $F$-score for two normalization methods are very close. The median method performs slightly better than the SCBN method in precision when conserved genes have no noise or small noise, but its precision decreases enormously with noise increased. For instance, the precisions of the median method are 0.93, 0.68 and 0.32 with conserved genes have 0, 30\% and 60\% of DE genes. The SCBN method has precision values 0.91, 0.93 and 0.91, respectively. It is evident that the median method depends greatly on the selected conserved genes, including numbers and purity of conserved genes. On contrary, conserved genes have much less impact on the performance of the SCBN method. In Study 7, we focus on the impact of the rate of DE genes on two normalization methods. Fig~\ref{fig:6} shows that the SCBN method outperforms the median method for various rates of DE genes, especially when the rate of DE genes is not too large. The result implies that the SCBN method is more sensitive to identify less fold of DE genes than that of the median method. \section*{Real Data Analysis} We illustrate the usefulness of our proposed SCBN method in real dataset by the study of \cite{brawand:11}. The dataset consists of two groups of orthologous transcripts in human and mouse, with respective transcripts lengths and counts of reads (see Additional file 4 for details). We refer to the human transcripts (GRCh38.p10) and the mouse transcripts (GRCm38.p5) in Ensembl Genes 91 available at http://asia.ensembl.org/biomart/martview/eb8237d1bbc63bbeff285/c0d5a2c3742. There are a total of 63967 transcripts in human and 53946 transcripts in mouse, 27779 of which are orthologous transcripts (see the right panel of Fig~\ref{fig:samesp}). By excluding the unmatched, duplicated and unexpressed transcripts, there are 19330 available orthologous transcripts. Fig~\ref{tab1} shows the expressions of several orthologous transcripts in human and mouse. As shown in Fig~\ref{fig:samesp}, unlike the case of same species where the numbers and lengths of genes are equal to each other, different species have different gene numbers and thus different gene lengths. Regarding the different lengths of the orthologous transcripts, only 105 transcripts or only 0.54\% of all transcripts, have the same length between human and mouse in Additional file 5. The average difference of the transcripts lengths between two species is 1039, and the maximum is 21666 in Additional file 6. The evolutionary process of the eukaryotic genome includes events such as duplication and recombination, which creates complicated relationships among genes. As a consequence, the normalization methods for same species may not provide a satisfactory performance or may not even be applicable for different species. The challenges of normalization between different species are mainly due to the different lengths of orthologous genes and the different sequencing depths due to different platforms. \begin{figure*}[h!] \centerline{[width=5in,height=3in]{table_new.pdf}} \caption{The RNA-seq data of orthologous transcripts in human and mouse.}\label{tab1} \end{figure*} We get the conserved orthologous genes with a three-step procedure. First, we confirm the orthologous transcripts between human and mouse, by using the BioMart function in the Ensemble to search all human transcripts and filtering out the genes that do not exist in mouse. Second, according to the orthology quality-controls criterion, we sort the data from the most conserve to the least. Third, we select 143 most conserved orthologous transcripts between human and mouse and list them in Additional file 7. The most conserved 500 or 1000 orthologous transcripts are likely non-DE transcripts between two species, and we compare the two methods with the first group data. First, we select the most 500 or 1000 conserved transcripts with the above steps, and then use the two methods to normalize the sequence data with the 143 conserved transcripts. Next, we calculate $p$-values (see Additional file 8) with adjusted sage.test function. Last, we get DE transcripts between human and mouse with $p$-value cutoff $10^{-6}$, which are shown in Table~\ref{table2}. Among the most conserved 500 or 1000 orthologous transcripts, 332 and 647 of them are detected as DE transcripts by using the SCBN method, in which 48\% and 46\% significantly higher in human, whereas the median method detects 351 and 697 DE transcripts, in which 32\% and 29\% significantly higher in human. For all orthologous transcripts, the SCBN method detects 9662 DE transcripts, and the median method detects 9910 DE transcripts. Assuming that the most conserved 500 orthologous transcripts are non-DE transcripts, there are 351 false detected DE transcripts with the median method and 332 false detected DE transcripts with the SCBN method. Then the FDR of the median method is 0.035, which is larger than 0.034 of the SCBN method. For the 1000 conserved transcripts, we get a similar result that the FDR of the median method (0.070) is also larger than that of the SCBN method (0.067). Therefore, the FDRs of the SCBN method are generally smaller than those of the median method. \begin{table}[!ht] \caption{The number of DE genes between human and mouse at a cutoff $p$-value $<10^{-6}$ for the median and SCBN methods.} \begin{center} \begin{tabular}{ccccccccc} \hline \hline & Median &SCBN & Overlap\\ \hline Higher in human &4370 &5824 & 2610 \\ Higher in mouse &5540 &3838 &2184 \\ Total &9910 &9662 & 4794 \\ \hline Top conserved genes (500)\\ Higher in human &112 &159 &56 \\ Higher in mouse &239 &173 &119 \\ Total &351 &332 &175 \\ \hline Top conserved genes (1000) \\ Higher in human &201 &300 &87 \\ Higher in mouse &496 &347 &240 \\ Total &697 &647 &327 \\ \hline \end{tabular} \label{table2} \end{center} \end{table} Next, we compare the accuracy of the two normalization methods by looking deeper into the biological function. We apply the SCBN method to detect the most significant 1000 DE transcripts for each pair comparison between human and mouse, that is the smallest 1000 $p$-values for each comparison, among which 567 are common. Also, the median method detects 584 common DE transcripts for two species. Fig~\ref{fig:7} shows the common DE transcripts and the unique DE transcripts of the two normalization methods. For the unique transcripts, we refer to NCBI \cite{NCBI:web} to find out which genes are associated with evolution or illness. There are 48 of 123 (39.02\%) DE transcripts, which are related to evolution or illness with the SCBN method, and 43 of 140 (30.71\%) DE transcripts are related to evolution or illness with the median method. Specifically, among the unique DE transcripts detected by the SCBN method, we find that `ENSG00000102316' is involved in breast cancer and melanoma, `ENSG00000152137' is involved in the regulation of cell proliferation, apoptosis, and carcinogenesis, and `ENSG00000135744' is associated with the susceptibility to essential hypertension, and can cause renal tubular dysgenesis, a severe disorder of renal tubular development. Mutations in gene `ENSG00000152137' have been associated with different neuromuscular diseases, including the Charcot-Marie-Tooth disease. We note, however, that above genes are not included in the 584 most significant DE transcripts detected by the median method. More details are presented in Additional file 9. The results show that our proposed SCBN method provide a more accurate normalization than the median method in real data analysis. \begin{figure}[h!] \centerline{[width=3.6in,height=2in]{venn_new1.pdf}} \caption[Illustration]{The common genes and the unique DE genes detected by two normalization methods. }\label{fig:7} \end{figure} \section*{Discussion} Detecting DE genes between different species is an effective way to identify evolutionarily conserved transcriptional responses. For different species, the RNA-seq experiments will result in not only different read counts, but also different numbers and lengths of genes. To make the expression levels of orthologous genes comparable between different species, normalization is a crucial step in the process of detecting DE genes. This is in sharp contrast to the case of same species, where the numbers and lengths of genes are equal to each other. Therefore, the existing normalization methods for same species may not provide a satisfactory performance or may not even be applicable for RNA-seq data with different species. Therefore, developing new normalization methods for RNA-seq data with different species is extremely urgent. In this paper, we propose a scale based normalization (SCBN) method between different species for RNA-seq data. Two main contributions of our work are: (i) dealing with RNA-seq data with two different species, which have different lengths of genes and sequencing depths, and (ii) employing the hypothesis testing approaches to search for the optimal scaling factor, which minimizes the deviation between the empirical and nominal type I errors. From the simulation results, we find that the proposed SCBN method outperforms the existing median method, especially when the number of selected conserved genes is small or the selected conserved genes involves a lot of noise. In real data analysis, we analyze an RNA-seq data of two species, human and mouse, and the results indicate that the SCBN method delivers a more satisfactory performance than the median method. Compared to the RNA-seq data with same species, normalization between different species is much more complicated. Although our proposed method has largely improved the effectiveness to detect DE genes in some cases, we note that it may still not be able to provide a satisfactory performance when the rate of DE genes is very high in the whole samples. In addition, the unmatched genes and the relation of orthologous genes are not considered in the process of normalization between different species. This may call for a future work that develops new methods to further improve our current method. \begin{backmatter} \section*{Funding} Yan Zhou's research was supported by the National Natural Science Foundation of China (Grant No. 11701385), the National Statistical Research Project (Grant No. 2017LY56) and the Doctor Start Fund of Guangdong Province (Grant No. 2016A030310062). Tiejun Tong's research was supported by the Hong Kong Baptist University grants FRG1/16-17/018 and FRG2/16-17/074, the Health and Medical Research Fund (Grant No. 04150476) and the National Natural Science Foundation of China (Grant No. 11671338). Bingqing Lin's research was supported by the National Natural Science Foundation of China (Grant No. 11701386) and the Tianyuan Fund for Mathematics (Grant No. 11626159). \section*{Availability of data and materials} The data sets supporting the results of this article are included within the article and the references. The ``SCBN" package is made in the form of R code and the complete documentation is available on request from the corresponding author ([email protected]). \section*{Author's contributions} YZ, JDZ and JZ developed the SCBN method for normalization, conducted the simulation studies and real data analysis, and wrote the draft of the manuscript. JZ, TJT and BQL revised the manuscript. JHW provided the guidance on methodology and finalized the manuscript. All authors read and approved the final manuscript. \section*{Competing interests} The authors declare that they have no competing interests. \section*{Consent for publication} Not applicable. \section*{Ethics approval and consent to participate} Not applicable. \bibliographystyle{bmc-mathphys}
{'timestamp': '2018-10-05T02:06:25', 'yymm': '1810', 'arxiv_id': '1810.02037', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.02037'}
arxiv
\section{Introduction} \label{sec:Introduction} Autonomy in robotics relies on sensory data processing to capture information about the world and adapt to it. Although the influence of machine learning has been growing more important in the last decades, traditional approaches to this problem of data processing involve significant manual design from engineers that build the robot. Consequently the resulting techniques for artificial perception appear rigid and constrained for tractability. Each of these specialized algorithms is applicable to only a small set of tasks, with potentially limiting inbuilt biases from the designer. While acceptable for well-defined processes, such as industrial manufacturing, the potential need for a large degree of human involvement makes such methods inadequate as a source of long-term autonomy in a robot. Instead, an autonomous robot must be able to cope with the complexity of its world, build its own way to perceive it and adapt to its variations. To address this issue, the field of developmental robotics takes inspiration from biological and cognitive development in children \cite{cangelosi2015developmental}. It proposes that an agent learns to interact with its environment, autonomously and on an ontogenic timescale. Without prior knowledge, a naive robot must learn the structure of its own body, of its environment, and how the two interact. In this context, \emph{perception} is a prerequisite to developing more advanced cognitive abilities that allow a rich interaction with the environment. Yet, the emergence of this fundamental capacity, traditionally hand-coded in the system, poses a challenge: What is \textit{perception} for a naive agent in which manually pre-defined features and labels are replaced by a flow of uninterpreted sensorimotor data? Sensorimotor contingencies theory (SMCT) attempts to answer this question \cite{o2001sensorimotor} by fundamentally re-defining perception: \emph{perception is the mastery of regularities in the way actions transform sensory inputs}. It suggests that a naive agent can actively explore its environment, extract regularities that the world imposes on its sensorimotor flow, and later identify those regularities when interacting with the environment in order to perceive it. Those regularities, or \emph{contingencies}, are the ground on which the agent can build perceptive abilities. Moreover this active account of perception naturally links actions to perception, meaning that the agent intrinsically knows what it could \emph{do} with any perceived feature \cite{seth2014predictive}. Despite its philosophical aspect, the SMCT is based on experimental results. Among other things, it elegantly accounts for instance for sensory substitution. Those are experiences in which a subject is provided with information from one modality (e.g. vision) through another modality's pathway (e.g. skin or ears) \cite{bach1969vision,auvray2007learning}. The theory naturally encompasses such a phenomenon as it defines perception as based on structure in the sensorimotor flow instead of properties of the pathway it takes. Such a possibility leads us to consider artificial ``plug-and-play" agents that could be equipped with new sensors, and would discover how to perceive with them by learning to master the associated sensorimotor flows. The SMCT has been relatively slow to spread in the robotics community, partly because of the complete overhaul it induces in the field of artificial perception. To date, the approach has been applied to model the acquisition of perceptive concepts such as space \cite{laflaquiere2015learning, terekhov2013space}, colors \cite{philipona2006color,witzel2015}, environments \cite{laflaquiere2015grounding}, and objects \cite{laflaquiere2015objects}. Primarily, these works characterize properties of the external world explored by the agent. However, a naive agent's body is also part of the unknown world it has to discover. It contributes, like the structure of the environment, to shaping the regularities the agent experiences in its sensorimotor flow. As such, properties of the agent's body should also be captured through sensorimotor contingencies. In this paper, we address the problem of capturing properties of sensors plugged on a naive agent, and in particular properties of the \emph{visual field} generated by visual sensors. The experience of visual field encapsulates the set of regularities describing how visual features are encoded differently by various parts of the sensor, as well as how they shift on it due to motion. This fact is particularly striking when considering heterogeneous visual sensors, like the human retina, for which visual features are encoded by significantly different cell patterns depending on where they land on the retina. This discrepancy between our stable subjective experience of visual features and their actual variable sensory encoding has already been brought forward in the paper introducing the SMCT \cite{o2001sensorimotor}. Yet, only recently has it led to further inquiries with the development of psycho-motor experiments \cite{herwig2014predicting}. Their results suggest that the brain learns the correspondence between the different sensory patterns that encode the same visual feature on different parts of the retina, and the motor commands (ocular saccades) that transform one into the other. By exploring artificial visual setups where two distinct visual features are consistently associated before and after a saccade, it is possible to alter previously learned correspondences. This artificial interaction with the world leads to a modification of the subjective perceptive experience of visual features, even in adult subjects. The work presented in this paper proposes a computational model inspired by this perceptive phenomenon. Nonetheless it also fits into a more general endeavor to develop a computational model for the autonomous learning of sensorimotor regularities \cite{laflaquiere2015grounding, maye2013, seth2014predictive}, the lack of which has been the second reason of the slow spread of SMCT. The formalism converges towards the hierarchical building of a predictive model of sensorimotor experiences \cite{laflaquiere2015grounding}. This approach is in line with recent developments in neuroscience, which describe the brain as a predictive machine \cite{friston10,clark2013whatever,hohwy2014self}. By learning to predict future sensory outcomes of its actions, the agent estimates latent causes of its experience and progressively extends the control from its motor component to its sensory component. The work presented in this paper will focus on letting a naive agent discover the sensorimotor regularities that define the \emph{visual field} associated with a visual sensor. The next section presents a formalization of the problem and describes a computational model to address it. A simulation is then introduced in Sec.\ref{sec:Simulation} to illustrate the approach. The results are analyzed in Sec.~\ref{sec:Results} in light of previous works in the sensorimotor approach of perception. Finally, limitations and potential future extensions of the model are discussed~in the last section. \section{Problem Formulation} \label{sec:Formulation} In this section we present the problem a naive agent is facing when discovering the sensorimotor structure induced by its visual sensor. We describe the regularities that underlie the experience of a \emph{visual field}. Then we propose a computational formalism to process the agent's sensorimotor flow and detail how it can capture those regularities. \subsection{Experiencing a visual field} \label{sec:Experiencing a visual field} This work focuses on agents equipped with a visual-like sensor: an array of sensels collecting information from a part of the environment, where a sensel is the basic element of a sensor array (e.g. pixels in a camera, or rods and cones in our retina). In this work, we use the term \textit{visual feature} to refer to the visual information received from a small part of the environment. Contrarily to computer vision literature where visual features are the internal outcome of some sensory processing, the term here describes the (partial) state of the external environment. Conversely, we use the term \textit{sensory inputs} to refer to the information generated when visual features are projected on the sensor and transformed into an encoded signal accessible to the agent (see Fig.~\ref{fig:Retina_principle}). Depending on where it is present in the visual field, a visual feature can be projected onto different parts of the sensor array. It can thus be encoded by different sensory inputs. Such a claim does not appear obvious when considering a camera because it is usually assumed that the sensory encoding is translation-invariant: physical properties of the sensor are such that a visual feature generates the same sensory input regardless of where it is encoded in the array. This is for instance an implicit hypothesis in Convolutional Neural Networks, a class of algorithms that prove to be very efficient in visual scene analysis \cite{krizhevsky2012imagenet}. It also indirectly assumes that the later unit that processes sensory inputs does know the spatial organization of sensels and can switch on the fly between different groups of neighboring sensels. Yet, such a property is far from evident for a biological system like our visual cortex. This fact appears even less realistic when taking into account the heterogeneity of the human retina \cite{records1979physiology}. As underlined in \cite{o2001sensorimotor}, the way visual features are encoded changes significantly across the retina, due to its physiological properties. Yet, our subjective experience of visual features is that they are stable across the whole field of view. The sensorimotor point of view on such a phenomenon claims that the brain learns to associate the different sensory inputs corresponding to the same visual feature by actively exploring visual scenes. This hypothesis has been recently strengthened by psycho-motor experiments in which those associations were artificially altered \cite{herwig2014predicting}. \begin{figure}[t] \includegraphics[width=0.8\linewidth]{Retina_principle.pdf} \centering \caption{The heterogeneous structure of the retina implies that visual features are encoded by different sensory inputs depending on where they are in the visual field. These different sensory inputs can be experienced by saccading with the eye.} \label{fig:Retina_principle} \end{figure} According to SMCT, the very mastery of those sensorimotor associations participates in the experience of seeing. More precisely, by focusing on regularities induced by the physical structure of the sensor, one can describe those that give rise the experience of having a \emph{visual field}: \begin{itemize} \item Sets of different sensory inputs encode the same visual features on different parts of the sensor. \item Motor commands can transform sensory inputs into another one encoding the same visual feature. \end{itemize} Those two statements describe that visual features shift on the retina and that their encoding changes when the agent moves its sensor (see Fig.~\ref{fig:Retina_principle}). It is important to notice that the only way for a naive agent to discover such properties is to actively explore visual scenes. They could not be extracted through a passive sensory processing, like the ones usually proposed in unsupervised contexts \cite{bengio2013representation}. For instance, the different sensory inputs related to a single visual feature would not necessarily share the same statistical properties or lie close to one another in the sensory space, especially if the sensor is significantly heterogeneous. Additionally, passively extracted knowledge wouldn't be directly useful to a naive agent as it wouldn't know how to actively transform its sensory state to eventually reach a goal state (for instance, move the sensor to bring a visual feature in a given part of the visual field). Yet, the association of sensory inputs seems intimately linked to the ability to perform visual tasks such as search and recognition, as demonstrated in \cite{herwig2014predicting}. We claim that a naive agent has to explore its environment and learn the sensorimotor regularities induced by its visual sensor. In line with the Predicting Processing approach \cite{clark2013whatever}, which describes the brain as a predictive machine, we propose to capture those regularities in a predictive model described hereunder. \subsection{Formalization and learning of the predictive model} \label{sec:Formalization and learning of the predictive model} The phenomenon described in Sec.~\ref{sec:Experiencing a visual field} suggests that the sensory experience generated by the visual sensor can be studied locally. Taking inspiration from biology, and in particular the structure of the human retina, we treat the array as a cluster of \emph{receptive fields} \cite{hubel1968receptive}. Each receptive field is made of numerous neighboring sensels that cover a limited part of the whole array, all with the same physical extent. No additional constraint is assumed and the different receptive fields may have different properties: e.g. the number of sensels, their spatial arrangement, or their excitation function. Receptive fields encode independently the visual feature they receive from the environment. For the naive agent, each receptive field initially appears to be an independent sensor generating its own sensory input. Formally, we define the \emph{sensory input} generated by a receptive field as a multivariate random variable $\mathbf{S}^a$ that can take values: \begin{equation} \mathbf{s}^a_i = [s_{i,1},\dots,s_{i,d^a}], \end{equation} where $i$ denotes the index of the sensory input, $a$ denotes the receptive field, $s_{i,k}$ is the individual sensation provided by the $k^{th}$ sensel in receptive field $a$, and $d^a$ is the number of sensels in this receptive field. The agent is able to move its visual sensor using saccades, analogous to human eye movements. Formally, we denote the saccadic motor commands as a multivariate random variable $\mathbf{M}$ that can take values: \begin{equation} \mathbf{m_q} = [m_{q,1},\dots, m_{q,d^m}], \end{equation} where $q$ denotes the index of the motor command, $m_{q,k}$ is the individual command sent to the $k^{th}$ motor moving the sensor, and $d^m$ is the number of those motors. No specific superscript is needed for the motor command as all receptive fields move together in a rigid manner when the sensor is moved. Like with the human eye, we assume that saccades are fast enough that the state of the environment can be considered constant during the execution of most of the motor commands. Moreover, sensory inputs are supposed to be generated instantaneously by each receptive field, before and after a saccade. According to our sensorimotor approach, the naive agent needs to explore actively the world to capture regularities underlying its sensorimotor experiences. In line with a Bayesian description of the brain \cite{knill2004bayesian}, we propose to capture those regularities by letting the agent build a predictive model of its sensorimotor experiences. Note that we're interested in how the agent can actively transform its experience, which means that it has to model sensorimotor transitions. A similar modeling of sensorimotor transitions has already been proposed in the literature, although often intimely linked to a reinforcement learning framework \cite{sutton2011horde,mugan2012autonomous,ghadirzadeh2016self}. More precisely here, the agent should estimate the probability: \begin{equation} P\big(\mathbf{S}^b(t+1)\:|\:\mathbf{S}^a(t)=\mathbf{s}^a_i,\mathbf{M}(t)=\mathbf{m}_q \big), \end{equation} corresponding to the conditional post-saccadic distribution of sensory input $\mathbf{S}^b$ in receptive field $b$, given that a sensory input $\mathbf{s}^a_i$ was experienced in receptive field $a$ before the execution of the saccadic motor command $\mathbf{m}_q$. For the sake of simplicity, this probability is later denoted: \begin{equation} P(\mathbf{S}^b\:|\:\mathbf{s}^a_i,\mathbf{m}_q). \end{equation} The agent can estimate this distribution by collecting multiple instances of sensorimotor transitions, \begin{equation} (\mathbf{s}^a_i,\mathbf{m}_q \rightarrow \mathbf{s}^b_j), \end{equation} and statistically estimate the distribution over $j$. This model is relatively simple but notice that multiple ones have to be estimated in parallel as the sensor is made of numerous receptive fields. The physical embedding of the sensor in the world does not allow all possible sensorimotor transitions. Those implicit constraints should appear as regularities in the predictive model: transitions imposed by the sensor and the world should have high probabilities while ``forbidden" ones should be improbable. In particular, the definition of a visual field proposed in Sec.~\ref{sec:Experiencing a visual field} can now be further formalized by introducing the following set: \begin{equation} \mathcal{G}_{\mathbf{s}^a_i} = \{\mathbf{s}^b_j \:|\: \exists \mathbf{m}_q : P(\mathbf{s}^b_j\:|\:\mathbf{s}^a_i,\mathbf{m}_q) \geq \epsilon\} \label{eq:similarity_set} \end{equation} where $\epsilon$ is a threshold defined to distinguish significant probabilities from unsignificant ones. The set $\mathcal{G}_{\mathbf{s}^a_i}$ gathers all sensory inputs $\mathbf{s}^b_j$ that the agent can transition to with a probability greater than $\epsilon$ from input $\mathbf{s}^a_i$ by performing a motor command $\mathbf{m}_q$. In our approach, the probability of active sensorimotor transitions can be seen as a similarity measure between the two involved sensory inputs $\mathbf{s}^a_i$ and $\mathbf{s}^b_j$ \cite{laflaquiere2015grounding}. For a fixed significance threshold $\epsilon$, $\mathcal{G}_{\mathbf{s}^a_i}$ can thus be seen as the set of all sensory inputs $\mathbf{s}^b_j$ considered similar to $\mathbf{s}^a_i$ by the agent. In the next section, we introduce a simulated system to evaluate our approach on two different kinds of environments. The predictive models estimated by the agent after exploring those environments will later be analyzed in detail in Sec.~\ref{sec:Results}. \section{Simulation} \label{sec:Simulation} \begin{figure}[t] \includegraphics[width=1\linewidth]{Simulated_retina.pdf} \caption{The simulated visual sensor is coarsely inspired by the retina structure. \textit{On the left}, the sensor has a field of view limited to a $30\times 30$ pixels patch which captures information from the environment. \textit{In the center}, this initial patch is divided into smaller $10\times 10$ ones corresponding to the $9$ receptive fields. Simultaneously, the resolution of all $8$ peripheral receptive fields is halved both in height and width to form the final inputs accessible to the agent. \textit{On the right}, independent K-Means are run for the different receptive fields to generate sensory prototypes and cluster later sensory inputs.} \label{fig:Simulated_retina} \end{figure} \begin{figure}[t] \includegraphics[width=1\linewidth]{Simulation.pdf} \caption{The agent interacts with its environment through its visual sensor. \textit{On the top left}, two kinds of environments, random and natural images, are considered and explored during two independent runs of the simulation. \textit{On the center left}, the narrow patch of information captured by the sensor is encoded by $9$ independent sensory states. \textit{On the bottom left}, the agent actively explores the visual environment by randomly performing $8$ saccades that shift the locations of receptive fields. \textit{On the right}, the agent builds a predictive model of the sensorimotor transitions it experiences. It is made up of multiple distributions over post-saccadic states $\mathbf{s}^b_j$ estimated for each pre-saccadic receptive field $a$ and state $i$, each post-saccadic receptive field $b$ and each motor command $q$. Individual distributions related to the same values of $a$ and $b$ are grouped to form 'blocks', which are themselves grouped according to the value of $q$ to form the $3$D matrix $T$.} \label{fig:Simulation} \end{figure} A simple system is simulated in order to illustrate the approach. In this section, we describe the agent's sensory and motor systems, the different kinds of visual scenes considered during exploration, as well as the algorithmic details of the predictive model estimation. \subsection{Simulated agent} \label{sec:agent} As illustrated in Fig.~\ref{fig:Simulated_retina} and \ref{fig:Simulation}, the simulated system intends to coarsely capture the kind of interaction a moving eye has with its environment. The agent is a translatable camera exploring a two-dimensional visual environment. Its field of view is limited to a narrow $30\times 30$ pixels square. As such, it captures only a small portion of what a human retina would capture in a visual scene. The sensor must thus be seen as a simple model of what happens in a small part of an actual retina. The field of view is divided into $9$ receptive fields of size $10\times 10$ pixels. However, the resolution of each peripheral receptive field is artificially lowered to imitate the coarser sensory encoding in the peripheral retina compared to the central fovea. The reduced resolution is obtained by downsampling the original $10\times 10$ inputs: only one column in every two and one row in every two are considered to form a $5\times 5$ pixels input (see Fig.~\ref{fig:Simulated_retina}). Pixels discarded this way are considered nonexistent in the sensor and do not interfere in any way in the remaining pixels excitation (for instance by applying a local average or a max-pooling criterion). A fourth of the original information is thus accessible to the agent in the peripheral layer of the retina. Finally, the sensory inputs $\mathbf{s}^a_i$ generated by the different receptive fields are respectively of size $d^a=100$ for the central receptive field ($a=5$), and $d^a=25$ for peripheral ones ($a\neq5$). In order to limit the simulation complexity, we consider that each receptive field $a$ can take only a restricted set of $N^a$ prototypical sensory inputs $\mathbf{s}^a_i, i\in [1,N^a]$, called sensory states. The constant $N^a$ is arbitrarily set in relation to the associated sensory space dimensionality: $N^a=50$ for the central (foveal) receptive field ($a=5$), and $N^{a}=20$ for the peripheral ones ($a\neq5$). The prototypical sensory states $\mathbf{s}^a_i$ are determined in a data-driven way by collecting a large number of sensory inputs and applying a clustering algorithm. Pragmatically, we let the agent randomly explore multiple environments and collect $10^6$ sensory inputs per receptive field. Independent K-Means \cite{lloyd1982least} are then run on the data collected in each receptive field to generate the prototypical sensory states. These latter are thus potentially different between receptive fields, even with the same resolution. Such data clustering can be seen as the analogous encoding that visual data undergoes just after the retina \cite{marcelja1980mathematical}. In later exploration, sensory inputs received in a receptive field are simply encoded by the closest prototypical sensory state $\mathbf{s}^a_i$ (winner-takes-all strategy). The agent can translate in the visual scene to sample different parts of its environment. Similarly to sensory inputs, movements are discretized into a limited set of $Q=8$ saccades $\mathbf{m}_q$. They correspond to all translations of the retina such that the central receptive field shifts to the pre-saccadic location of one of the 8 peripheral receptive fields (see Fig.~\ref{fig:Simulation}). Those saccades have been purposely chosen so that visual features entirely shift between receptive fields during movements of the sensor, which will facilitate the results analysis. \subsection{The environment} \label{sec:environments} The environment corresponds to visual scenes, simple images that the agent can explore one at a time. Two different types of images are considered in the simulation (see Fig.~\ref{fig:Simulation}): \begin{itemize} \item \textit{Random}: gray-scale images of size $1024\times 1024$ pixels generated by randomly drawing the integer value of each pixel independently from a uniform distribution $\text{U}(0,255)$. \item \textit{Natural}: images taken from a standard RGB database \cite{mit-saliency-benchmark} and converted to gray-scale pixel values. \end{itemize} The simulation can be run independently on each type of visual environment. The random images are intended to test the system in the absence of any environmental structure. It corresponds to an optimal setting in which only the sensor structure constrains the agent's sensorimotor experience. On the contrary, natural images are used to evaluate the approach in a more realistic setting. Note that we do not want the system to over-fit its model to a specific visual scene. For each type of environment, $100$ different scenes are thus generated/drawn for the agent to successively explore during the simulation. As explained in Sec.~\ref{sec:Formalization and learning of the predictive model}, we assume that saccades are fast enough so that the environment can be considered static while most sensorimotor transitions are experienced. More precisely, we hypothesize that the probability of having the environment change (draw a new image) during a saccade is significantly lower than the probability of executing a saccade (the ratio is arbitrarily set to $1$ to $10^4$). Such a dynamic appears reasonable when considering the speed of a human saccade. This constraint may nonetheless be loosened by assuming a greater ratio. Implicitly this assumption means that if this temporal stability hypothesis were to be broken and the environment would always change during saccades, the agent could not discover enough regularities to structure an experience of visual field. This kind of assumption has also been recently described as a requirement for robotic systems \cite{jonschkowski2015learning}. \subsection{Building the predictive model} \label{sec:Building the predictive model} We want the agent to model its interaction with the world by building a predictive model of the sensorimotor transitions it can experience. As claimed by the sensorimotor approach described previously, the agent needs to actively explore its environment in order to build this model. To this end, the agent is arbitrarily placed at the center of its environment (center position in the first image it explores) and let to explore by randomly executing $10^6$ successive motor commands. The visual scene is changed after every $10^4$ saccades, so that the agent successively interacts with all the $100$ scenes. This random exploration policy is natural for a naive agent that has no a priori knowledge about itself nor the environment. It can be seen as analogous to body babbling observed in babies. Each saccade generates an elementary sensorimotor transition experience $(\mathbf{s}^a_i,\mathbf{m}_q\rightarrow \mathbf{s}^b_j)$ for each $a$ and $b$. Given that the sensor is divided into $9$ receptive fields, this sums up to $81$ sensorimotor transitions for each saccade. The agent estimates each discrete distribution $P(\mathbf{S}^b\:|\:\mathbf{s}^a_i,\mathbf{m}_q)$ based on the collected data by simply building a normalized histogram of outputs $\mathbf{s}^b_j$ for each triplet $(a,i,q)$. Intuitively, the robot estimates in which state receptive field $b$ will statistically be if receptive $a$ is in state $i$ and it performs the motor command $q$. For visualization, all atomic predictive models are stored in a 3D matrix $T$ (see Fig.~\ref{fig:Simulation}). Each distribution $P(\mathbf{S}^b\:|\:\mathbf{s}^a_i,\mathbf{m}_q)$ is stored as a row vector obtained by concatenating the individual probabilities $P(\mathbf{s}^b_j\:|\:\mathbf{s}^a_i,\mathbf{m}_q), \forall j \in [1,N^b]$. All the possible distributions generated by the different values of $a$, $i$, $b$, and $q$ are then concatenated to form $T$ such that: its rows correspond to the pre-saccadic states $i$ for the different values of $a$, its columns correspond to the post-saccadic states $j$ for the different values of $b$, and its pages correspond to the executed saccadic motor command $q$. This way, the matrix $T$ can be interpreted by ``blocks", which are 2D matrices corresponding to the predictive structure between pairs of receptive fields $(a,b)$ for a given saccade $q$. For this reason, we will later refer to these blocks using the triplet $(a,b,q)$ (see Fig.~\ref{fig:Simulation}). In the next section, we analyze the predictive model built by the agent while exploring the two kinds of environments. In particular, we will focus on describing the sensorimotor structure captured by the naive agent and that defines properties of the visual field generated by its sensor. \section{Results} \label{sec:Results} As claimed by the sensorimotor approach described in Sec.~\ref{sec:Formulation}, physical properties of the agent's visual sensor and its related visual field constrain the sensorimotor interaction it has with the world. Those constraints should appear as a highly predictable structure in the predictive model built by the agent. Hereunder, we identify and analyze this structure for the two kinds of environments considered in the simulation. \begin{figure}[!t] \includegraphics[width=1\linewidth]{Matrices_noise.pdf} \caption{The $3$D matrix $T$ estimated by exploring random visual scenes and displayed one page at a time for each motor command $q$. Distributions in the whole matrix are generally uniform. However, for each saccade, a few blocks $(a,b)$ display sparser distributions. This is for instance the case of block $(a=8,b=7)$ for the saccade $q=1$. Looking at the sensor's structure, this higher predictability can be explained by the shift of visual features between corresponding receptive fields when the saccade is performed. (best seen in color)} \label{fig:Matrices_noise} \end{figure} \subsection{Random images} \label{sec:Random images} The matrix $T$ built by the agent after exploring random images is presented in Fig.~\ref{fig:Matrices_noise}. Although unrealistic, this environmental setup is optimal to study how the agent does capture the structure induced by its visual sensor. Indeed no environmental structure is expected to influence the learning process. Transitions probabilities in the whole matrix $T$ are generally very low. Such a result is not surprising in a random environment as it indicates that the agent cannot accurately predict future sensory states $\mathbf{s}^b_j$ based on current sensory states $\mathbf{s}^a_i$ and the saccade $\mathbf{m}_q$. Globally, each block $(a,b,q)$ displays close to uniform distributions over $j$ for the different pre-saccadic states $i$. Those blocks thus appear as almost uniform blue patches in Fig.~\ref{fig:Matrices_noise}. The central column of blocks that corresponds to predicting the sensory state of the foveal receptive field ($b=5$) also appears darker. This is simply because those distributions $P(\mathbf{S}^5\:|\:\mathbf{s}^a_i,\mathbf{m}_q)$ are spread across a larger number ($N^b=50$) of sensory states than for peripheral receptive fields ($N^b=20$). Yet a few blocks $(a,b,q)$ appear to exhibit a different structure due to sparser distributions (see highlighted blocks in Fig.~\ref{fig:Matrices_noise}). In other terms, for each saccade $q$, there exist pairs of receptive fields $(a,b)$ for which knowing $\mathbf{s}^a_i$ helps predicting $\mathbf{s}^b_j$. When checking the values $(a,b,q)$ associated with those blocks and which receptive fields/saccades they correspond to, one can notice that they actually capture the shift of visual features on the sensor during saccades. As an example, the first ``structured" block encountered in the matrix $T$ is $(a=2,b=1,q=1)$. When looking at the actual sensor structure in Figures~\ref{fig:Simulated_retina}\ and~\ref{fig:Simulation}, one can verify that any visual feature projected in the receptive field $a=2$ gets transferred to receptive field $b=1$ when the saccade $q=1$ moves the sensor to the right. Without specifying in advance the structure of the sensor, we can see that its properties have been implicitly captured in the predictive sensorimotor model built by the agent. Based on this model, the agent can determine relations between its receptive fields (which initially appear as unknown independent sensors) and its motor commands. It can know - or more precisely did estimate - that some sets of sensory states exist, where members of the set can be transformed into one another by sending motor commands (see Eq.~\ref{eq:similarity_set}). From an external point of view, those sets correspond to the different sensory encodings of visual features projected on different parts of the sensor. The model of sensorimotor transitions built by the agent has thus intrinsically captured properties of the visual field generated by the sensor. Importantly enough, those properties are not internally represented as ungrounded symbolic information but directly in a sensorimotor model that can be used by the agent to interact with the world and perform visual tasks \cite{herwig2014predicting}. An example of such a visual task would be to look into the estimated predictive model for the saccade that would transform, with the highest probability, a current sensory input into another desired one. Such an algorithm has been recently proposed in \cite{laflaquiere2016ICDL}. \textit{Influence of the model:} The maximal values of $P(\mathbf{s}^b_j\:|\:\mathbf{s}^a_i,\mathbf{m}_q)$ are relatively low, even in structured blocks where predictability should theoretically be very high. This phenomenon is due to the simplicity of the predictive model we proposed. As a reminder, sensory inputs of each receptive field have been clustered using the K-Means algorithm. This method minimizes distances between samples and their closest prototype, and form convex clusters. However, those clusters are not necessarily ``aligned" between the receptive fields. This means that all the data falling into a cluster $i$ of one receptive field can fall at the intersection of multiple clusters $j$ when projected into the sensory space of another receptive field. The effect is particularly marked when exploring random images: sensory samples can be scattered in the whole sensory space, which consequently generates a high variance in the positions of K-Means prototypes between the receptive fields. The consequence of this misalignment for the predictive model is that each sensory state can be transformed into a few other states in the associated receptive field when the sensor saccades (see highlighted block in Fig.~\ref{fig:Matrices_noise}). Maximal predictability is thus relatively low, even in couple blocks. \textit{Information transfer:} Despite those limitations, we were able to visually distinguish a predictive structure in coupled blocks $(a,b,q)$. However, in order to evaluate this structure more formally, we propose to introduce a measure derived from information theory. For each block $(a,b,q)$ we compute the normalized conditional entropy $H(a\,|\,b,q)$ as follows: \begin{equation} H(a\,|\,b,q) = -\sum_{i,j}\frac{P(\mathbf{s}^b_j,\mathbf{s}^a_i\:|\:\mathbf{m}_q)}{\log N^b} \log \bigg( \frac{P(\mathbf{s}^b_j,\mathbf{s}^a_i\:|\:\mathbf{m}_q)}{P(\mathbf{s}^a_i\:|\:\mathbf{m}_q)} \bigg) \end{equation} Entropy is a measure of uncertainty in the statistical model. Intuitively $H(a\,|\,b,q)$ measures the unpredictability of sensory input $\mathbf{S}^b$ in receptive field $b$ given the input $\mathbf{S}^a$ in receptive field $a$ and the saccade $\mathbf{m}_q$. Consequently, $H(a\,|\,b,q)$ should be significantly lower in blocks coupled by the structure of the sensor than in others. As shown in Fig.~\ref{fig:Entropies}, this is indeed the case as coupled blocks appear darker than their counterparts. This measure validates the fact that, even if the sensory clusters are misaligned in the different sensory spaces, a transfer of information does occur between coupled receptive fields when saccades are performed. This transfer is directly caused by the physical structure of the sensor. One can also notice that coupled blocks involving the foveal receptive fields display a slightly higher entropy than when they only involve peripheral ones (for instance, blocks $(a=5,b=4,q=1)$ and $(a=6,b=5,q=1)$ for the first motor command). This is the result of multiple causes that reduce the quality of the predictive mapping between a peripheral sensory space and the foveal one: the dimension of the foveal sensory space is higher than in periphery, the number of foveal prototypes is also higher than in periphery, and the loss of resolution (see Sec.~\ref{sec:agent}) induces a lower predictability between peripheral and foveal sensory states. \subsection{Natural images} \label{sec:Natural images} The matrix $T$ built by the agent after exploring natural images is presented in Fig.~\ref{fig:Matrices_natural}. This setup is proposed to evaluate the approach in a more realistic environment containing structure. \begin{figure}[!t] \includegraphics[width=1\linewidth]{Matrices_natural.pdf} \caption{The $3$D matrix $T$ estimated by exploring natural visual scenes and displayed one page at a time for each motor command $q$. Distributions in the whole matrix are sparser than when exploring random images because environmental structure is captured in the predictive model. However, same blocks $(a,b,q)$ as in the previous simulation display higher predictability. They correspond to receptive fields coupled by the physical structure of the sensor and between which visual features shift when a saccade is performed. (best seen in color)} \label{fig:Matrices_natural} \end{figure} \begin{figure}[!t] \includegraphics[width=1\linewidth]{Entropies.pdf} \caption{Normalized conditional entropies $H(a\,|\,b,q)$ computed on blocks $(a,b,q)$ and displayed so as to keep the shape as matrix $T$. For both kinds of visual scenes, $H(a\,|\,b,q)$ has a significantly lower value in the coupled blocks already identified in matrices $T$. This measure formally demonstrated that information is transferred between some receptive fields when a saccade is performed. From an external point of view, this transfer is due to the physical structure of the sensor.} \label{fig:Entropies} \end{figure} Overall the estimated model appears to contain more predictive structure than when the agent was exploring random environments. The different blocks in the matrix $T$ generally display sparser distributions. This visual analysis is confirmed by the measure of conditional entropies $H(a\,|\,b,q)$ that are significantly lower than in the previous scenario (see Fig.~\ref{fig:Entropies}). Such a result is to be expected when the agent explores natural images. Those visual scenes indeed have some intrinsic structure which implies that, locally, visual features can help predict other features with significant accuracy. For instance, surfaces in the world tend to keep the same appearance and receiving a uniform black visual feature in a receptive field allows to predict that neighboring receptive fields also probably observe the same visual feature. The same way, one can predict that all those receptive fields will most probably receive a black uniform feature regardless of the saccade the agent performs. This environmental structure constrains the sensorimotor experience of the agent and naturally gets captured in the sensorimotor predictive model it estimates. Nonetheless, apart from this environmental structure that appears scattered everywhere in the matrix $T$, one can also notice that some blocks $(a,b,q)$ display even sparser distributions. They correspond to the same blocks that were already identified in the previous scenario (for instance, blocks $(a=2,b=4,q=2)$ or $(a=8,b=4,q=8)$). As shown in Fig.~\ref{fig:Entropies}, their conditional entropy measures $H(a\,|\,b,q)$ are significantly lower than their counterparts, which confirms the fact that information gets largely transferred between those paired receptive fields when the corresponding saccade is performed. Once again, the constraints imposed by the sensor's structure have been captured by the agent and define its visual field experience. Notice however that the structure in those blocks is much sparser than in the previous simulation (see Fig.~\ref{fig:Matrices_natural} compared to Fig.~\ref{fig:Matrices_noise}). In other words, in coupled blocks $(a,b,q)$, knowing the pre-saccadic sensory state $\mathbf{s}^a_i$ allows to predict with a very high probability the post-saccadic sensory state $\mathbf{s}^b_j$, given $\mathbf{m}_q$. The reason of such a good predictive mapping is that visual data provided by natural images is not scattered in the whole sensory space of each receptive field like it was the case for the randomly generated data. They instead tend to naturally cluster in subparts of the sensory space. The independent K-Means performed in the different receptive fields' sensory spaces thus tend to converge towards similar clusters. Those clusters are thus relatively well aligned, which means that data falling into one cluster in a receptive field almost entirely falls into a single cluster when projected into another receptive field. This alignment allows the predictive model to reach very high probabilities for those transitions. Nonetheless, two exceptions can be identified. They both correspond to transitions involving the fovea (see Fig.~\ref{fig:Matrices_natural}). The first one is when the foveal sensory state predicts the post-saccadic sensory state of a coupled peripheral receptive field (for instance block $(a=5,b=4,q=1)$, or more generally any coupled block with $a=5$). In those blocks, some distributions $P(\mathbf{S}^b\:|\:\mathbf{s}^a_i,\mathbf{m}_q)$ are very sparse, with a single peak (appearing red in the color code), while some display multiple peaks of lower probability. This phenomenon is due to the different quantizations of the foveal sensory space, with $N^a=50$ prototypes, and the peripheral ones, with $N^a=20$ prototypes. Intuitively, the $50$ clusters, once projected into a peripheral sensory space, cover a space that is otherwise covered by $20$ bigger clusters. Some former clusters thus get entirely included into a bigger one while others end up partially overlapping multiple adjacent bigger clusters. The first case leads to perfect predictability while the second case leads to sparser distributions. This explains the particular predictive structure observed in those blocks. The second exception is when a peripheral sensory state predicts the post-saccadic sensory state of the fovea (for instance block $(a=6,b=5,q=1)$, or more generally any coupled block with $b=5$). In those blocks, distributions are not as sparse as in blocks involving only peripheral receptive fields. Consequently, they also display intermediary values in the conditional entropy matrix (see Fig.~\ref{fig:Entropies}). This result can be explained by two factors. First, the difference of number of prototypes between the two sensory spaces has the inverse effect of the previous case. The $20$ big peripheral clusters overlap many smaller clusters when projected in the foveal sensory space. An optimal configuration where a big cluster would be included entirely in a smaller one thus never happens. This leads to lower predictability of the post-saccadic foveal state. The second factor is not related to the computational model used in the simulation but to the sensor properties. The difference of resolution between the peripheral and foveal receptive fields is such that the peripheral encoding of a visual field does not contain enough information to determine precisely its foveal encoding. This ambiguity does set an upper limit on the transition probabilities in those blocks. Despite those limitations, those blocks remain the ones with the lowest conditional entropy $H(a\,|\,b,q)$ compared to blocks in the same column $b=5$ for each saccade $q$. This impossibility to optimally predict the foveal sensory state would thus not prevent the agent to associate those pairs of receptive fields when trying to predict next foveal experiences. \begin{figure}[!t] \centering \includegraphics[width=0.85\linewidth]{Sensory_groups.pdf} \caption{Sets of sensory states $\mathbf{s}^b_j$ estimated as similar to foveal sensory states $\mathbf{s}^a_i$ for a threshold value $\epsilon=0.5$. Globally, the agent has been able to identify sensory states that encode the same visual features in the different receptive fields. Some sets appear incomplete due to the different clustering of sensory inputs in the receptive fields. } \label{fig:Sensory_groups} \end{figure} \textit{Visualizing similar sensory states:} Due to the low probabilities observed in matrix $T$ when exploring random environments (see Sec.~\ref{sec:Random images}), trying to identify \emph{similar} sensory states was not a very meaningful endeavor. The situation is however different with natural images as K-Means clusters are better aligned and lead to more predictability in the model. According to Eq.~\ref{eq:similarity_set}, we estimate sets $\mathcal{G}_{\mathbf{s}^a_i}$ of sensory states $\mathbf{s}^b_j$ considered similar to a given sensory state $\mathbf{s}^a_i$. The similarity threshold is arbitrarily set to $\epsilon=0.5$. We also limit the analysis to the foveal sensory states ($a=5$) as the central receptive field has been the only one to be shifted to all other receptive fields during the simulation. Ten of the $N^5=50$ sets $\mathcal{G}_{\mathbf{s}^5_i}$ are displayed in Fig.~\ref{fig:Sensory_groups}. One can see that, although the agent had no a priori knowledge about the correspondence between the sensory states of its different receptive fields, it has been able to group together sensory states that encode the same visual features. For $6$ of the sets $\mathcal{G}_{\mathbf{s}^5_i}$ ($i=1,2,6,31,32,44$), a similar sensory state has correctly been identified in all the other receptive fields $b$. For $3$ other sets ($i=36,47,50$), between $3$ and $6$ similar states have been identified, and no similar state was found for $i=27$. These incomplete results are due to two factors. First, the number of foveal sensory states $N^{a}=50$ is greater than the number of peripheral ones $N^a=20$. This finer covering of the foveal sensory space means that foveal sensory states do not necessarily have an equivalent in all peripheral receptive fields. Second, because K-Means has been run independently for all receptive fields, similar sensory states do not necessarily exist in all of them. This is for instance well illustrated by the presence of $\mathbf{s}^8_{22}$ in the set $\mathcal{G}_{\mathbf{s}^5_{47}}$. Visually, its pattern does not look like its counterparts but it still appears in the set because the receptive field $b=8$ does not have a better corresponding prototype. All sensory inputs looking like $\mathbf{s}^5_{47}$ are thus encoded by $\mathbf{s}^8_{22}$, the closest prototype, when encoded in receptive field $b=8$. This leads to a predictable sensorimotor transition between the two prototypes and to the naive agent evaluating them as similar. \section{Conclusion} \label{sec:Discussion} We propose a sensorimotor approach of perception, inspired by the sensorimotor contingencies theory, which claims that a naive agent should learn to master the way it can transform its sensorimotor experience. In this work, we applied such a view to explain how a robot without any a priori knowledge about the structure of its body or the structure of the world can discover the existence of the visual field generated by its unknown visual sensor. Discovering this visual field means for the agent to capture the sensorimotor regularities that it induces: different sensory states encode the same visual feature, depending on where it is encoded on the sensor array, and the agent can actively transform one into the other by sending motor commands. Those sensorimotor experiences seen from the agent's internal point of view correspond externally to the fact that visual features from the environment shift on the retina when the sensor moves and consequently get encoded by different sensels. This encoding variability is particularly marked in a heterogeneous sensor array like the human retina. We proposed a simple visual system inspired by the retina, as well as a computational model to explain how an agent can explore and capture those sensorimotor regularities. The model is based on the definition of receptive fields, small neighborhoods of sensels that each encode only a small part of the visual scene the agent can observe. Apart from its biological motivation, the introduction of those receptive fields can be seen as an attempt to create a compositional structure in the sensor that mirrors the compositional structure of the world \cite{minsky1975framework}. For the naive agent, all receptive fields act as independent sensors which generate their own sensory inputs in parallel. However, by actively exploring visual scenes, it can discover that its sensory experiences change in regular ways. In particular, the sensory state of some receptive fields is useful to predict what the next sensory state will be in another receptive field when it performs a certain motor command. Also, different pairs of receptive fields are coupled this way when different motor commands are sent. One could ask why it is so important for the agent to learn and model such a thing. The answer is that this agent, that initially did not have any knowledge, can now make use of what we would call its visual field. He does know that different sensory states it experiences, and that belong to a set $\mathcal{G}_{\mathbf{s}^a_i}$, can be interpreted as similar, up to a motor command. This knowledge can be seen as the internal emergence of the concept of \emph{visual feature}, an external reality that was not previously accessible to the agent. Moreover, it also knows how to actively transform one of those sensory states into the other. This active aspect of the model is fundamental in our approach. It means that the sensory regularities extracted by the agent only make sense through action. The knowledge acquired through sensory information is thus directly able to guide action, which is the fundamental role of \emph{perception}. The agent could for instance use its estimated model to perform a visual search task. Let us assume that, for some reason, receiving the sensory state $\mathbf{s}^5_{18}$ ($18^\text{th}$ state of the foveal receptive field $5$) is rewarding for the agent. Given its internal model, it can counterfactually \cite{seth2014predictive} determine if a sensory state from another receptive field does correspond to the same visual feature and which saccade to execute to reach the rewarding sensory state. This is the kind of visual tasks that were proposed to subjects with altered sensory states associations in \cite{herwig2014predicting} and for which a basic model has recently been proposed in \cite{laflaquiere2016ICDL}. This use of the predictive model has not been illustrated in this paper. It is part of the multiple future directions in which we intend to extend this work. First, the system proposed in the simulation was very simple compared to its biological counterpart. It will be replaced by a larger retina split into more receptive fields organized in multiple concentric rings with decreasing visual resolutions. A parallel version of the algorithm used in this simulation will however be necessary to benefit from the computational power of a GPU and process efficiently the huge amount of parallel data that such a richer sensor will generate. This technical improvement can be seen as a computational requirement but also as a direct inspiration from our visual nervous system. Another direction of future research is the analysis of the environmental structure captured in the predictive model. As mentioned in Sec.~\ref{sec:Natural images}, this structure appears in particular in unpaired blocks and reveals properties of the environment. According to the SMCT, it is thus possible to cluster sensory states that encode the same visual features, but it is also possible to assess properties of those features based on the way they get transformed by actions. A simple example proposed in \cite{o2001sensorimotor} is the one of an horizontal line. Regardless of the way such a visual feature is encoded by the sensor, it is true that this sensory input will be invariant to a leftward or rightward movement of the sensor. Characterizing visual features will also provide a better picture of the experience of \emph{seeing} in the sensorimotor approach of perception by describing the intermingled influence of the sensor and environmental structures. The predictive model used in the simulation should also be modified to improve the predictability between sensory states that encode the same visual features. The current model is far from satisfying: it discards a lot of information by discretizing the sensory spaces and relies on the alignment of clusters in sensory spaces that do not necessarily share the same properties. A more powerful approach, but also more complex to train, would be to directly estimate a non-linear mapping between the different sensory spaces associated with the receptive fields. Each sensory data could be processed through those mappings without relying on clusters and the associated loss of information. This would lead to a more satisfying notion of equivalence between sensory states by increasing the threshold value $\epsilon$ (see Sec.~\ref{sec:Formalization and learning of the predictive model}). Finally, the most challenging improvement will be to take into account continuous motor commands instead of the very limited discrete set of saccades considered in the current simulation. Continuous saccades might require a less constrained definition of receptive field for which any sensel and its neighbors could be considered a receptive field, leading to an almost continuous coverage of the retina by overlapping receptive fields. Despite its current limitations, the model introduced in this paper proposes an innovative perspective to address the problem of visual perception in artificial systems. It relies on the division of the sensor into smaller sensory units and on extracting regularities in the way actions transform their states. This is very different from traditional approaches which generally process static images as a whole to extract interesting features. Of course, many algorithms, such as convolutional neural networks, do focus on small patches in the image that could be compared to the receptive fields used in this work. However, they do so based on the strong hypothesis that all patches share the same properties and encode visual information the same way. This assumption is not realistic for a heterogeneous sensor such as the human eye. Our approach is more general and is able to deal with heterogeneous sensors. It also emphasizes the fact that action is a necessary component for a naive agent to extract useful information from an uninterpreted sensory flow. In fact, the algorithm used in this work is general enough that it could process information coming from different kinds of sensor arrays. For instance, the simulated sensor described in this paper could just as much be a tactile sensor and the visual scenes could be tactile textures that the agent would touch. The agent would discover properties of the ``field of touch" the sensor generates and how tactile features move in the array when motor commands are sent. Moreover, the sensorimotor approach also seems promising to address problems related to multimodality. Without a priori knowledge, one does not need to assume the existence of separate modalities. The agent would thus naturally extract sensorimotor regularities that combine multiple modalities. Yet, an even more interesting and challenging question will be the one related to the co-discovery of contingencies by a naive agent. So far the sensorimotor approach of perception has been applied to capture regularities associated with targeted properties of the world thanks to specific settings: space, colors, environments, objects, and now visual field \cite{laflaquiere2015learning, terekhov2013space, philipona2006color, witzel2015, laflaquiere2015grounding, laflaquiere2015objects}. The next difficult problem is to develop a system that is able to extract those different contingencies, and others, in parallel. This should reveal the intrinsic intermingling of the notion of visual field with the one of space, especially when extending the set of actions to $3$D displacements in the environment. \bibliographystyle{elsarticle-harv}
{'timestamp': '2018-10-05T02:00:17', 'yymm': '1810', 'arxiv_id': '1810.01871', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01871'}
arxiv
\section{INTRODUCTION} Stable dynamic locomotion for bipedal robots is an important problem that has received considerable research attention from the robotics community. It is particularly challenging due to the complexity of high dimensional models, underactuation, unilateral ground contacts, nonlinear and hybrid dynamics, among others. Most existing bipedal walking control methods rely on accurate physical models of the system. These model-based approaches can be further divided into two categories: methods that are based on simplified models and methods that are based on the full order model of the robot. The linear inverted pendulum (LIP) \cite{Kajita1992} is a popular reduced order model. Since its inception, LIP has been widely used jointly with the zero moment point (ZMP) criteria \cite{Vukobratovic2004} to compute feasible motion trajectories using pattern generators \cite{Yoshida2008}, \cite{Stephens2010}. LIP has also been used along with the Capture Point (CP) approach to analyze the push recovery problem in bipedal walking robots \cite{Pratt2006}, \cite{Pratt2012}. Although the simplicity of reduced models presents many advantages particularly in the practical implementation of the online algorithms, they do not consider the physical joint and actuator limits while designing the gaits, and they often require the robot to be fully actuated. Another branch of methods uses the full order model of the robot, which can capture the underlying dynamics more accurately, and often leads to more natural dynamic walking behaviors. Although these methods are computationally more expensive, recent progress in optimization techniques and computer hardware have made them feasible for realistic robotic systems. Some representative methods along this direction include Linear Quadratic Regulator (LQR) \cite{Posa2016}, Model Predictive Control (MPC) \cite{Erez2013}, \cite{Koenemann2015}, and Hybrid Zero Dynamics (HZD) \cite{Westervelt2007}, \cite{Hereid2018}. In particular, HZD is a formal framework for the control of bipedal robots with or without underactuation through the design of nonlinear feedback controllers and a set of virtual constraints. It has been successfully implemented in several physical robots, including many underactuated robots \cite{Chevallereau2003,Chevallereau2009,Sreenath2011,Hereid2014,Hereid2018}. Most of the aforementioned results are based on analytic models of the robot, which can be hard to derive for complex robotic systems. In addition, biped walking dynamics include contact and collision between the robot and the ground, which makes precise modeling of the dynamics difficult. Recently, there is an increasing interest in using Reinforcement Learning (RL) to obtain effective control policies using the dynamic simulation of the robot. Some early approaches use RL with Central Pattern Generator (CPG)-based controllers using the cerebellar model arithmetic computer (CMAC) neural networks \cite{Benbrahim1997}. More recent work use state-of-the-art policy gradient methods to find policies that map from the observation space to the action space in order to achieve a continuous walking motion \cite{Lillicrap2015}, \cite{Schulman2015}. However, general RL methods combined with deep neural networks can be sampling inefficient (millions of data samples) and are usually over-parameterized (thousands of tunable parameters) as they do not consider the underlying physics of bipedal walking. This may lead to unnatural motions that are not applicable to real robots. In addition, to our best knowledge existing model-free RL methods in the literature consider neither regulating the walking speed of the robot nor the local stability of the walking gaits. Some efforts to address the velocity regulating problem rely on the use of Supervised Learning (SL) as a tool for obtaining a policy that renders stable dynamic walking gaits for different speeds \cite{Da2016, Da2017}. The authors proposed an offline approach to design an explicit model-based feedback control policy based on HZD and SL. However, these methods still require the knowledge of an analytic model of the robot. This paper focuses on developing a novel model-free RL approach for bipedal walking control that employs a non-traditional RL structure with an embedded HZD framework. The proposed method does not need an analytic form of the robot's model. Instead, it uses a realistic physics simulator that can capture the interactions between the robot and the environment. The proposed structure of the neural network used for the training of the control policy does not use the full state space of the robot, but a reduced state space. By means of the HZD, the outputs of the neural network are mapped into a set of polynomials that define the desired outputs for the actuated joints of the robot. This allows reducing the number of parameters of the neural network. Then, the desired outputs are tracked by an adaptive PD controller, which ensure the compliance of the HZD virtual constraints. The main contribution of the paper is on improving the existing RL methods for training bipedal walking control by incorporating some key insights from the HZD into the learning process. We believe that incorporating physical insights of bipedal walking can significantly improve the training results of the RL and make them more realistic and applicable to real robots. To the best of our knowledge, this is the first time HZD is combined with RL to realize feedback controllers for bipedal walking. The result of combining RL and HZD allows the learned control policy to track different desired speeds within a continuous interval. Moreover, the learned controller outperforms the traditional HZD-based controller regarding robustness while still maintaining the stability of the walking limit cycle, which is one of the key features of the HZD approach. Finally, we demonstrate the feasibility and effectiveness of the proposed method by evaluating the performance of the learned policy for speed tracking and robustness to external disturbances on the simulation of a five link-planar underactuated robot on MuJoCo -a novel physics engine \cite{Todorov2012}. In this paper, the model of RABBIT robot is used; however, the method can be extended to other robot models. \section{PROBLEM FORMULATION} In this section, we present the description of the robot used for the implementation and evaluation of the proposed method. Moreover, we provide some backgrounds for HZD and RL, which are the main components of the proposed control strategy. \subsection{Robot Description} As a starting point for the proposed method, we consider the model of the robot RABBIT, which is a well known test-bed robot model for the HZD framework \cite{Chevallereau2003}. Despite its simple mechanical structure, RABBIT is still a good representation of biped locomotion. RABBIT is a five-link, planar underactuated bipedal robot with a total weight of 32 kg. The five links of the robot correspond to the torso, right thigh, right shin, left thigh and left shin. The robot has point feet and four actuated joints, two in the hip joints and two in the knee joints. This configuration results in a five degree-of-freedom mechanism during the single support phase (considering the stance leg end does not slip) and four degrees of actuation. In the upright position, with both legs together and straight, the hip is 80 cm above the ground, and the tip of the torso is at 1.43 m \cite{Westervelt2007}. See Table \ref{table_1} for a description of the length, mass, and inertia of each link of the robot. All these parameters have been included in the simulation model used for both the training process and the evaluation of the learned control policy. Fig. \ref{fig:Rabbit_model} shows the schematic of RABBIT and the notation used in this paper for the description of the state variables of the robot. \begin{table}[h!] \centering \begin{tabular}{|l|l|l|l|l} \cline{1-4} & Torso & Femur & Tibia & \\ \cline{1-4} Length $[m]$ & 0.63 & 0.4 & 0.4 & \\ \cline{1-4} Mass $[kg]$ & 12 & 6.8 & 3.2 & \\ \cline{1-4} Inertia $[kg \cdot m^{2}]$ & 1.33 & 0.47 & 0.2 & \\ \cline{1-4} \end{tabular} \caption{Model parameters of RABBIT robot} \label{table_1} \end{table} \vspace*{-5mm} \begin{figure}[h] \centering \includegraphics[width=3.5cm]{images/Rabbit_model.png} \caption{Coordinate system schematic of RABBIT robot} \label{fig:Rabbit_model} \end{figure} \vspace*{-4mm} \subsection{Hybrid Zero Dynamics} We now briefly review some key concepts and ideas about HZD that are useful for developing our new reinforcement learning framework. In the HZD based controllers, virtual constraints are introduced as a means to synthesize feedback controllers that realize stable and dynamic locomotion. By designing virtual constraints that are invariant through impact, an invariant sub-manifold is created---termed the \emph{hybrid zero dynamics surface}---wherein the evolution of the system is dictated by the dynamics of the reduced-dimensional underactuated degrees of freedom of the system \cite{Westervelt2007, Ames2013Human}. Let $q = (q_t, q_{sh}, q_{sk}, q_{nsh}, q_{nsk})$ be the joint coordinates of RABBIT (see Fig.~\ref{fig:Rabbit_model}) and $\tau(q) \in [0,1] $ be a state-based time representation (see \eqref{eq:tau} for explicit definition), then virtual constraints are defined as the difference between the actual and desired outputs of the robot \cite{Ames2013Human}: \begin{align} y_{2} &:= y^a_{2}(q) - y^d_{2}(\tau(q),\alpha), \label{eq_vc} \end{align} where $y_{2}$ is (vector) relative degree 2 due to the second order dynamical system of the robot mechanical model, and $y^d_{2}$ is a vector of desired outputs defined in terms of $5^{\text{th}}$ order B\'ezier polynomials parameterized by the coefficients $\alpha$, given as: \begin{align} y^d_2(\tau(q),\alpha) := \sum_{k=0}^{5} \alpha[k] \frac{M!}{k!(M-k)!} \tau(q)^k (1-\tau(q))^{M-k}. \end{align} Moreover, the B\'ezier polynomial has a very nice feature: $y^d_2(0,\alpha) = \alpha[0]$ and $y^d_2(1,\alpha) = \alpha[5]$. This will be used later to reduce the search space of the neural network parameters in the proposed RL approach. In this paper, we choose $\tau(q)$ to be the scaled relative forward hip position with respect to the stance foot, i.e., \begin{align} \label{eq:tau} \tau(q) = \frac{p_{hip}(q) - p_{hip}^-}{p_{hip}^+ - p_{hip}^-} \end{align} where $p_{hip}^+$ and $p_{hip}^-$ are the values of $p_{hip}(q)$ at the beginning and end of a step. It can be noted that by driving virtual constraints to zeros through feedback controllers, the trajectories of all joints are synchronized to the evolution of the relative forward hip motion, i.e., the zero dynamics of the system. By properly choosing the coefficients of these B\'ezier polynomials, one can achieve different walking motions. More importantly, the local stability of the periodic walking gait can be formally validated by computing the Poincar\'e map of the reduced dimensional zero dynamics surface. \subsection{Reinforcement Learning} Generally speaking, RL aims to find an approximate solution to an optimal control problem of a certain class of dynamical systems, which can be formalized as follows: \begin{align} \label{eq:optimal-control-problem} & \underset{x}{\text{maximize}} & & J(\theta) = E_{p((s_t, a_t);\theta)} \left[ \sum_{t=1}^{T} \gamma^t r(s_t, a_t) \right], \gamma \in (0, 1], \nonumber\\ & \text{subject to} & & s_{t+1} = f(s_t, a_t). \end{align} That is, given state $s_t$ with dynamics transition $f$, one seeks to maximize the expected discounted accumulated reward $r(s_t, a_t)$ through the action sequence $a_t$. The trajectory distribution $p((s_t, a_t);\theta)$ is induced by the probabilistic policy $a_t \sim \pi(s_t | \theta)$. With policy being a neural network, $\theta$ represents the set of network parameters. The main approaches to solve RL problems are based on either value iteration \cite{Mnih2013} or policy gradient \cite{Lillicrap2015}, \cite{Schulman2017}. Value iteration, such as Q-learning \cite{Mnih2013}, takes advantage of the recursive form of the Bellman equation to establish an off-policy algorithm to learn the action-value function $Q^{\pi}(s_t, a_t)$. While such methods have shown promising performance on complex tasks with high-dimensional state space, it can only handle discrete, low-dimensional action space. For robotic applications with continuous high-dimensional action space, policy gradient methods are more commonly adopted \cite{Lillicrap2015}. In this paper, we adopted two state-of-the-art RL algorithms in our simulation, including Evolution Strategies (ES) \cite{Gomez2005} and Proximal Policy Gradient (PPO) \cite{Schulman2017}. Both methods estimate the policy gradient \begin{align} \label{eq:policy gradient} \triangledown_{\theta} J(\theta) = E_{p(x_t;\theta)}\left[ r(x_t) \triangledown_{\theta} \log p(x_t;\theta) \right], x_t = (s_t, a_t), \end{align} either implicitly (ES) or explicitly (PPO). The policy is iteratively improved through simulation rollouts followed by gradient accent with respect to the objective. ES is one of the random search methods where a population of $N$ policies ${\pi(s|\theta_i)}_{i=1}^{N}$ are sampled following $\theta_i \sim \mathcal{N}(\theta_{\mu}, \sigma)$. The normal distribution of policy parameterized on $\theta_{\mu}$ and $\sigma$ is then improved through estimated gradient using the evaluation results from the sampled policies. PPO proposes a novel objective function of \begin{align} \label{eq:clip loss} L^{CLIP}(\theta) = E_t \left[ \min(g_t(\theta)A_t, clip (g_t(\theta), 1-\epsilon, 1+\epsilon)A_t) \right], \end{align} where $A_t$ is the so-called advantage estimation \cite{schulman2015high}. The policy $\pi_{\theta}(a_t|s_t)$ is improved by a modified probability ratio of $g_t(\theta)=\frac{\pi_{\theta}(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}$ controlled by the clip ratio $\epsilon$. In our simulation, both training methods provide similar results in terms of training speed, sampling efficiency, and policy performance. They are also sharing the same neural network structure (see section III). We will not distinguish between these two methods in later sections. \section{HYBRID ZERO DYNAMICS BASED REINFORCEMENT LEARNING (HZD-RL)} This section will introduce the proposed control-learning framework that combines HZD-based control design with reinforcement learning. We will first lay out the overall control-learning structure and then provide technical details for some key components in the framework. \subsection{Control-Learning Structure} Traditional RL algorithms for bipedal walking search for control policies that directly map the current robot's states to the control action. We propose a non-traditional structure for the RL framework, whose resulting control policy maps from a reduced order of the robot's state to a set of coefficients of the B\'ezier polynomials that define the trajectory of the actuated joints. It is worth noticing that general RL algorithms adopt probabilistic policies to facilitate the training process. As a result, the system trajectories become stochastic despite we start with a deterministic robot model. In addition, as the desired policy needs to be able to perform speed tracking, we also consider the desired velocity and the velocity tracking error. Finally, we use an adaptive low level PD controller for tracking the desired output for each joint. This enforces the compliance of the HZD virtual constraints, which render stable and robust locomotion for the bipedal robot. It is worth mentioning that unlike some RL methods, reference trajectories for the robot's joints are not given as an input of the RL process in our approach \cite{Levine2013, Peng2017, Xie2018}. Instead, they are naturally obtained by the proposed HZD-RL structure. Fig. \ref{fig:CL_struct} presents a diagram of the overall control-learning structure. For each time step, the desired walking speed ($v_d$) and the actual speed of the robot's hip ($v_a$) are used to generate the inputs of the neural network. A Detailed explanation of the neural network structure will be provided in the subsection B. The trained control policy maps directly the inputs of the neural network to the set of coefficients $\alpha$ and the controller's derivative gain $K_d$. Then, $\alpha$ jointly with the phase variable $\tau$ are used to compute the desired joint's position and velocity for each actuated joint of the robot by means of the HZD framework. The adaptive PD controller uses the tracking error between the desired and actual value of the output to compute the torque of each actuated joint, which is the input of the dynamic system that represents the walking motion of the robot. Finally, the measured outputs of the system (states of the robot) are used as feedback for the inner and outer control loops. \begin{figure}[t] \vspace{2mm} \centering \includegraphics[width=8.5cm]{images/CL_structure.png} \caption{Learning-Control Structure} \label{fig:CL_struct} \vspace{-4mm} \end{figure} As part of the RL framework, we need to establish the reward function that will be used during the training process. This reward function is defined in the quadratic form \begin{align} r(s_t, a_t) = |\overline{v_a}-v_d|^2 \end{align} with constraints conditions \begin{align} |q_t|<0.5, \quad 0.6<z<0.8, \end{align} and steps of rollouts with discount factor $\gamma=0.99$. \subsection{Neural Network Structure} The structure of the neural network used during the training process is presented in Fig. \ref{fig:NN_struct}. Because of the complex dynamics of the walking motion, it is impossible to guarantee a good tracking performance for the instantaneous speed of the robot along the $x$ axis, which corresponds to the walking direction of the robot. Therefore, it is necessary to consider the average speed of the walking motion. Here, we consider this average speed to be the speed during about one walking step of the robot, which takes about 200 simulation steps. Therefore, the inputs of the neural network are the value of the desired velocity ($v_d$), the average hip's velocity ($\overline{v_a}$) of the robot for the last 200 simulation steps, and the average error between the desired velocity and the instantaneous velocity of the robot's hip during the last 200 simulation steps. The value of the desired velocity is uniformly sampled from a continuous space interval from 0.7 to 1.5 $m/s$. The output of the neural network corresponds to the values for the coefficients of the B\'ezier polynomials. Since the robot has four actuated joints and each B\'ezier polynomial is of degree 5, the total size of the set of parameters $\alpha$ is 24. However, to encourage the invariance through impact of the virtual constraints, we enforce the position of the hip joints ($q_{sh}$, $q_{nsh}$) and knee joints ($q_{sk}$, $q_{nsk}$) to be equal at the beginning and end of the step ($\tau(q)=0$ and $\tau(q)=1$ respectively). This leads to the following set of equalities. \begin{align} \alpha[1] = \alpha[23]; \alpha[2] = \alpha[24]; \alpha[3] = \alpha[21]; \alpha[4] = \alpha[22] \nonumber \end{align} Therefore, the number of outputs of the neural network is reduced to 20. Additionally, we consider as an output of the neural network the derivative constant of the PD controller used for the tracking of the desired outputs. The number of hidden layers is 3, each one with 12 neurons, and the final layer employs a sigmoid function to limit the range of the outputs. A very important feature of the proposed HZD-RL structure is the physical insight that the set of coefficients of the B\'ezier polynomials have. Due to the family of polynomials chosen to construct the desired outputs, this set of parameters defines the waypoints for the trajectories of the desired outputs. Therefore, the output range of the set of parameters can be limited by the physical constraint of each actuated joints. This important feature allows reducing the continuous interval of the output, which greatly decreases the complexity of the RL problem and improves the efficiency and effectiveness of the learning process. \begin{figure}[t] \vspace{2mm} \centering \includegraphics[width=8.5cm]{images/NN_structure.png} \caption{Structure of the Neural Network} \label{fig:NN_struct} \vspace*{-4mm} \end{figure} \subsection{Adaptive PD controller} Adaptive control can improve the performance of a control law to handle the uncertainty of unknown parameters in a system and the complexity of highly non-linear models. Early approaches in adaptive control discuss the advantages of using the tracking error as an update law for adaptive controllers based on adaptive inverse dynamics control \cite{Ortega1988}, \cite{Slotine1989}. More recent work combines the idea of adaptive control with machine learning to obtain controllers whose parameters evolve with the dynamics of the process \cite{Wang2007}, \cite{Manoonpong2007}. In this paper, we use an adaptive PD controller with fixed proportional gain and variable derivative gain to compute the torque applied to each actuated joint. For this, each controller takes the position tracking error and the velocity tracking error of each joint according to the following structure. \begin{align} u &= K_p\textbf{e} + K_d\dot{\textbf{e}} \end{align} with $\textbf{e} = q_d - q_a$ and $\dot{\textbf{e}} = \dot{q}_d - \dot{q}_a$, where $q_d$ and $q_a$ are the desired and actual joint positions, $\dot{q}_d$ and $\dot{q}_a$ are the desired and actual joint velocities, respectively. It is important to clearly state the strong connection between the adaptive PD controller, the HZD framework, and the RL structure. From section II, we know that HZD virtual constraints are defined by equation \ref{eq_vc}, where the desired output is defined in terms of $5^{th}$ order B\'ezier polynomials. Therefore, the desired position and velocity for each joint are defined by \begin{align} q_d &= y_d(\tau(q), \alpha) \\ \dot{q}_d &= \dot{y}_d(\tau(q), \alpha) \end{align} Since the set of coefficients $\alpha$, and the controller's derivative constant are outputs of the neural network, we can compute them by using the learned control policy resulting from the training process. This is, $[\alpha,K_d]={\pi(s|\theta)}$. Finally, at each simulation step, the output of each PD adaptive controller (torque of each actuated joint) results in an output of the dynamic system (states of the robot), which is used as feedback for both the adaptive PD controller and the neural network. This closes the loop of the feedback control process. The described controller can adapt its behavior to the changes in the dynamics of the walking cycle and the disturbances inherent from the hybrid dynamics and external forces. Particularly, such adaptability feature turns out to be highly useful for speed tracking when a change of the desired speed is detected and for disturbance rejection. \section{SIMULATION RESULTS} The implementation of the customized environment for RABBIT was build in OpenAI Gym \cite{Brockman2016}, and the environment was simulated using the MuJoCo physics engine \cite{Todorov2012}. The number of trainable parameter for the neural network is 620, and the training time is about 30 minutes using a 12-core CPU machine. Visualized results of the learning process and evaluation of the policy in simulation can be seen in the accompanying video submission (can also be found in \cite{video_link}). In order to encourage a good speed tracking performance on the learned policy, for each episode of rollout the desired velocity is updated once in the same way it is chosen at the beginning of the episode (uniform sampling). The control policy obtained from the training is evaluated for several scenarios including speed tracking and convergence of the walking limit cycle. Finally, we evaluated the robustness of the learned policy using the HZD-RL method and compared it with the control policy obtained using the traditional model-based HZD framework. \subsection{Speed tracking} The learned policy was tested for tracking one specific desired speed in several scenarios, including tracking a fixed desired speed and a range of variable desired speeds. Fig. \ref{change_vel} shows the filtered instantaneous speed when the robot walks while tracking a set of different desired speeds. The policy's performance is good, and it allows the robot to track effectively the fixed speeds as well as speed changes. The plot only shows the speed tracking results for 20 seconds; however, since the policy renders a stable walking limit cycle, the robot is able to keep walking for much longer time. This aspect is discussed further in the next subsection. \subsection{Stability of the walking limit cycle} One of the main advantages of the HZD is that it provides a formal framework to prove the stability of the walking limit cycle \cite{Plestan2003}. Therefore, since HZD is the underlying layer of our proposed method, we analyze not only the effectiveness of the policy for tracking a desired fixed or variable speed, but also the convergence of the walking limit cycle. Fig. \ref{limit_cycle} presents the limit cycle over several steps with the parameters defined by the learned policy. The resulting trajectory converges to a limit cycle, supporting the stability analysis presented in the HZD theory \cite{Westervelt2007}, \cite{Chevallereau2009}, \cite{Plestan2003}. \begin{figure}[h] \vspace{2mm} \centering \includegraphics[width=1.0\columnwidth]{images/change_vel.png} \caption{Speed tracking performance of the learned policy} \label{change_vel} \end{figure} \begin{figure}[h] \centering \includegraphics[width=1\columnwidth]{images/limit_cycle.png} \caption{Walking limit cycle of the learned policy} \label{limit_cycle} \end{figure} \vspace*{-3mm} \subsection{Disturbance rejection and robustness comparison} To evaluate the robustness of the learned control policy, we applied an external force directly into the robot's torso in three different scenarios: 1) Small forces applied in the forward direction. 2) Small forces applied in the backward direction. 3) Large forces applied to the backward direction. The controller used for the comparison test is obtained from the Fast Robot Optimization and Simulation Toolkit (FROST), which is a software environment for developing model-based control for robotic systems using the HZD framework \cite{Hereid2017}. This model-based controller is implemented in the environment simulation of RABBIT under the same conditions used for the evaluation of the HZD-RL policy. \begin{figure}[!ht] \vspace*{2mm} \subfloat[Speed tracking during external disturbance]{% \includegraphics[clip,width=1\columnwidth]{images/adv_forward.png} \label{comp_small_fw_a}% } \subfloat[Motion produced by HZD policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzd_forward_motion.jpg} \label{comp_small_fw_b}% } \subfloat[Motion produced by HZD-RL policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzdrl_forward_motion.jpg} \label{comp_small_fw_c}% } \caption{Robustness comparison between HZD-RL and HZD when a small force is applied in the forward direction.} \label{comp_small_fw} \end{figure} \begin{figure}[!ht] \vspace{2mm} \subfloat[Speed tracking during external disturbance]{% \includegraphics[clip,width=1\columnwidth]{images/adv_backward.png} \label{comp_small_bw_a}% } \subfloat[Motion produced by HZD policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzd_backward_motion.jpg} \label{comp_small_bw_b}% } \subfloat[Motion produced by HZD-RL policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzdrl_backward_motion.jpg} \label{comp_small_bw_c}% } \caption{Robustness comparison between HZD-RL and HZD when a small force is applied in the backward direction.} \label{comp_small_bw} \end{figure} \begin{figure}[!h] \vspace{2mm} \subfloat[Speed tracking during external disturbance]{% \includegraphics[clip,width=1\columnwidth]{images/adv_backward_hard.png} \label{comp_large_bw_a}% } \subfloat[Motion produced by HZD policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzd_backward_hard_motion.jpg} \label{comp_large_bw_b}% } \subfloat[Motion produced by HZD-RL policy]{% \includegraphics[clip,width=1\columnwidth]{images/hzdrl_backward_hard_motion.jpg} \label{comp_large_bw_c}% } \caption{Robustness comparison between HZD-RL and HZD when a large force is applied in the backward direction.} \label{comp_large_bw} \end{figure} Fig. \ref{comp_small_fw} illustrates the comparison of the policies for case 1. A small external force is applied in the forward direction for both controllers at time $t=2s$, $t=4s$, and $t=6s$ using the same technique described in \cite{Pinto2017}. Fig. \ref{comp_small_fw_a} shows the response of both controllers. The traditional HZD controller cannot reject the disturbance and the robot falls while the HZD-RL control policy is able to recover from the disturbance and allows the robot to continue walking. Visual details of the performance of the HZD and HZD-RL policies are shown in Fig. \ref{comp_small_fw_b} and \ref{comp_small_fw_c} respectively. Fig. \ref{comp_small_bw} shows the result of the comparison in case 2. When the external force is applied, the HZD controller cannot finish the step, goes back to the start position of that step, and get stuck there. This effect can be appreciated in Fig. \ref{comp_small_bw_b}, where the speed decreases gradually to $0\:(m/s)$. On the other hand, the HZD-RL policy permits the robot to complete the step and recover from the external disturbance while maintaining tracking the desired walking speed. Fig. \ref{comp_small_bw_b} and \ref{comp_small_bw_c} provide visual details of the consequent walking motion. Finally, Fig. \ref{comp_large_bw} shows the comparison for case 3. Fig. \ref{comp_large_bw_a} shows the abrupt speed change in the robot speed caused by the robot falling to the ground when the HZD controller is used. The HZD-RL controller keeps the robot walking after the external force is applied. Visual details of the performance of both controllers is shown in Fig. \ref{comp_large_bw_b} and \ref{comp_large_bw_c}. \section{CONCLUSIONS} This paper presents a novel model-free RL approach for the design of feedback controllers based on the HZD framework. We showed that by considering the physics insight of the bipedal walking into the structure of the RL, we can obtain a control policy that is able to track different walking speeds within a continuous interval. The proposed structure is simple, leading to reduced the number of parameters of the neural network. The proposed method is validated through simulation of the RABBIT robot, where the stability and robustness of the learned policy is evaluated. The results show a good performance of the learned policy for tracking any desired speed within a continuous range while maintaining stability of the walking limit cycle. Finally, the robustness comparison showed that the learned control policy outperforms the traditional model-based HZD controller when recovering from external disturbances. \newpage
{'timestamp': '2018-10-05T02:03:35', 'yymm': '1810', 'arxiv_id': '1810.01977', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01977'}
arxiv
\section{Introduction} The goal of unsupervised modelling is to learn a characterization of the data generating distribution from a set of training instances. Generative modelling also aims at a constructive procedure to generate samples from the learned distribution. Evaluating the quality of these models is not trivial:~\citep{theis2015note} shows that most commonly used criteria such as average log-likelihood, Parzen window estimates, and visual quality of samples are largely independent of each other when the data is high-dimensional. More importantly, they conclude that extrapolation from one criterion to another is not warranted and generative models need to be evaluated directly with respect to the application(s) they were intended for~~\cite{theis2015note}. The difficulties in the evaluation of generative models become exacerbated when we consider the notion of \emph{spurious} samples~\cite{bengio2013generalized}. These kinds of examples (Figure~\ref{figOutOfDistributionExamples}) are ubiquitous in the mainstream generative model literature. Traditionally, researchers strive to eliminate these samples~\cite{bengio2013generalized,goodfellow2016nips,salimans2016improved} since they are considered failures. There is also a chance that in published work such samples are underreported. By contrast, recent work \cite{nguyen2015innovation, lake2015human, kazakcci2016digits, cherti2017out} has shown growing interest in exploiting or studying these kind of samples. \citet{kazakcci2016digits} found that it was quite easy to generate examples that had zero likelihood under any possible notion of likelihood; more precisely, they generated symbols by models trained on digits which were not digits under any notion of what a digit is (Figure~\ref{figNewTypes}). \citet{lake2015human} called these examples ``unconstrained''. Such studies highlight that spurious samples should not be discarded (e.g., as ``noise''): they share deep structural properties with examples of the training set, yet they are obviously not coming from the distribution that generated these training sets. \begin{figure}[!ht] \centering \begin{subfigure}[b]{\columnwidth} \includegraphics[width=\columnwidth]{innovation_engine} \caption{``Synthetic'' objects from imagenet categories from Figure~7 of \cite{nguyen2015innovation}\label{figInnovationEngine}} \end{subfigure} \begin{subfigure}[b]{\columnwidth} \includegraphics[width=0.24\columnwidth]{tenenbaum_1} \includegraphics[width=0.24\columnwidth]{tenenbaum_2} \includegraphics[width=0.24\columnwidth]{tenenbaum_3} \includegraphics[width=0.24\columnwidth]{tenenbaum_4} \caption{``Unconstrained'' symbols from Figure~7 of \cite{lake2015human}\label{figOneShot}} \end{subfigure} \begin{subfigure}[b]{\columnwidth} \includegraphics[width=\columnwidth]{clus_figure.png} \caption{New types of symbols from Figure~6 of \cite{kazakcci2016digits}\label{figNewTypes}} \end{subfigure} \begin{subfigure}[b]{0.5\columnwidth} \includegraphics[width=\columnwidth]{dag} \caption{ Non-recognizable animal generated by~\cite{goodfellow2016nips}. } \end{subfigure} \caption{Examples of spurious objects.} \label{figOutOfDistributionExamples} \end{figure} Given these shared structural properties between relevant and spurious samples, one trivial and fundamental question needs to be answered: is it possible to get rid of all spurious samples without sacrificing the coverage of a model? This question translates into understanding the relationship between the following kinds of failure modes: \begin{enumerate} \item \emph{Spurious modes}: whether the model generates objects that clearly do not belong to the domain (Figure~\ref{mnist_spurious}). \item \emph{Missing modes} or the lack of \emph{coverage}: whether the model can generate \emph{all} objects (e.g., all bedrooms or handwritten digits) of the domain (Figure~\ref{mnist_missing_modes}). \end{enumerate} \begin{figure}[!ht] \centering \begin{subfigure}{0.24\columnwidth} \includegraphics[width=\columnwidth]{mnist_spurious} \caption{}\label{mnist_spurious} \end{subfigure} \begin{subfigure}{0.24\columnwidth} \includegraphics[width=\columnwidth]{mnist_missing_modes} \caption{}\label{mnist_missing_modes} \end{subfigure} \begin{subfigure}{0.24\columnwidth} \includegraphics[width=\columnwidth]{mnist_tail} \caption{}\label{mnist_tail} \end{subfigure} \caption{Generated hand-written symbols illustrating (a) spurious modes and (b) missing modes. Detecting missing modes visually is hard; even in case of the simple domain of MNIST we need a reference sample (c) from the tail of the distribution to notice that the model that generated (b) is probably missing some of the modes.} \label{figGeneratedSymbols} \end{figure} In other words, in this paper we ask the question whether it is possible at all to learn a training set (e.g., MNIST digits) and \emph{only} the training set, or when we learn a representation of all the training set, we will inescapably learn a larger set of structurally similar objects, not present in the training set. This would mean that for achieving full coverage, we need to live with spurious objects. On the specific set of models we studied, the answer seems affirmative: we either discard a subset of digits, learning only the bulk of the distribution, losing the tail, or if we pick up the full set of digits, the models also naturally represent a much larger set of structurally similar objects. Contrary to latest research on generative modeling, we chose MNIST as the main data set of study, complemented by the HWRT dataset \cite{thoma2015line} of handwritten mathematical symbols for out-of-class objects, mainly since the experimental setup required to train a large number of generative models. Unlike positive results of learnability (a new algorithm which \emph{can} learn MNIST), our argument is not harmed by this limitation. Essentially, we provide evidence that \emph{even a simple distribution or training set} is difficult to learn properly. This is a negative result; eliminating spurious modes while covering the full distribution should be \emph{more difficult} on larger, more heterogeneous and higher dimensional data sets. The paper has the following contributions: \begin{itemize} \item We provide an experimental framework to study and to quantify both spurious and missing modes in a specific type of generative models. \item We define a new metric that can be used to tune the spurious/missing mode trade-off and for selecting models that achieve the best compromise. \item We show that, for the type of models we studied, it is impossible to, at the same time, eliminate spurious modes while learning all genuine modes. \end{itemize} \section{Spurious samples and the evaluation of generative models } \citet{theis2015note} argues against using simple Parzen-based~\citep{breuleux2009unlearning}) likelihood estimators, even going as far as saying that if the goal is visual appeal, then likelihood itself is not necessarily a good measure. Detecting spurious modes (Figure~\ref{mnist_spurious}; Figure~\ref{figOutOfDistributionExamples}) visually is relatively easy. So, when the goal is not to generate these spurious examples \cite{bengio2013generalized} or failures \cite{salimans2016improved}, non-likelihood-based metrics concentrate on eliminating them. Inception (or, more generally, \emph{objectness}) score \cite{salimans2016improved} and Frechet (inception) distance \cite{heusel2017gans} require a sub-class predictor to label sub-class modes (e.g., imagenet or MNIST classes), somewhat defeating the very goal of unsupervised learning. Moreover, by design, they are susceptible to missing modes that were not labeled, within the classes used in the prediction task. For example, Figure~\ref{mnist_missing_modes} displays a generated sample which is missing some labels (sub-classes, from a point of view of modeling digits) but it also shows less variety within the classes. Missing classes are detected by objectness but the lack of within-class variety is not. One may argue that objectness even \emph{penalizes} tail examples since the predictor is better at classifying typical examples than tail examples. Also note that detecting missing modes visually is hard, even in case of the simple domain of MNIST we need a reference sample (Figure~\ref{mnist_tail}) from the tail of the test sample to notice that the model that generated the sample in Figure~\ref{mnist_missing_modes} is probably missing some of the modes. None of these metrics seem suitable to analyze the relationship between spurious and missing modes. In the next section, we propose a new metric $\Delta$ that we derive from the in-class and out-of-class reconstruction rates. As we will see, this metric has the advantage that it does not require a sub-class classifier (like the inception imagenet classifier). On the other hand, it requires a control sample on which we can measure out-of-class reconstruction rates. In practical situations, say, in a data challenge, the control set can be kept hidden from the modelers, making it less likely that they overfit $\Delta$. It is even possible to use several proxy control sets and to combine the resulting $\Delta$ scores using various statistics (e.g., mean or min). Besides the control set, another requirement for applying l is that each trained model $M$ have to be able to answer to the binary question whether a given object $x$ can or cannot be reconstructed by $M$. Autoencoders~\citep{vincent2010stacked, bengio2013generalized} and autoregressive models \citep{oord2016pixel,van2016conditional} have this property but, for example, GANs\cite{goodfellow2014generative} do not. \section{The formal setup} Let $\cX$ be the set of all images of dimension $28 \times 28$ with gray-scale pixel values in $[0, 1]$. Each model $M$ is an autoencoder that represents a manifold $\cM_M = \{x \in \cX: M(x) \approx x\} = \{x \in \cX: \|M(x) - x\|_1 < \theta$\}. We shall also say that $M$ can \emph{reconstruct} elements of $\cM_M$ or $\cM_M$ itself. The threshold $\theta$ was set to $50$ experimentally in order to maximize the dynamic range of our scores (smaller or larger thresholds would have resulted in models that reconstructed few digits and symbols or most of them, respectively, see Figure~\ref{figTheta}). The manifold $\cM_M$ is loosely related to the distribution of the images \cite{alain2014regularized}, more precisely, it is the approximate \emph{support} of the distribution when the autoencoder is used in an iterative generative mode targeting its fixed points (Figure~\ref{figIterativeGeneration}). In our setup we are not interested in the actual likelihood assigned to the fixed point (related to the measure of the set of random seeds that generate the fixed point), rather to a yes/no answer to the question whether the model $M$ can represent/generate a given image $x$. Also note that the actual setup of turning the generative model into an oracle that can answer to the question ``can you reconstruct $x$?'' may vary, depending on the model. The particular setup is somewhat independent of the metrics we propose. \begin{figure}[!ht] \centering \includegraphics[width=1.0\columnwidth]{iterative} \caption{Iterative generation with autoencoders. We start from random images obtained by randomly picking pixel intensities uniformly from 0 to 1, and we repeatedly apply the autoencoder on the images for several iterations. Each row corresponds to an independent sample, while columns correspond to iterations. The images of the last iteration correspond to approximate fixed points of the autoencoder. In other words, those points $x$ can be reconstructed very well by the autoencoder, that is $M(x) \approx x$.} \label{figIterativeGeneration} \end{figure} The models are all trained on the 60000 training images of MNIST. We use the test set $\cD$ of MNIST for evaluation. For detecting spurious modes, we also use a control set of handwritten mathematical symbols from~\cite{thoma2015line}. This dataset is originally vectorized and consists in a sequence of coordinates $(x, y)$ for each example. We rasterized it by joining the coordinates by segments with a thickness similar to MNIST. We also padded the images with zeros as it was done in MNIST. The full dataset has 369 classes of mathematical symbols. We remove all the classes with less than 100 examples, obtaining a total of 343 classes and 151853 examples. We randomly split the full set into a training set of 60000 examples and a test set $\cS$ of 91853 examples. The training sets were used to train a digit vs. symbol classifier which was used in the analysis in Section~\ref{secTradeOff}. We denote the posterior probabilities output by this classifier by $p(D | x)$ and $p(S | x)$. Let $\cD_M = \cM_M \cap \cD$ and $\cS_M = \cM_M \cap \cS$ be the set of digits and symbols, respectively, which a trained model $M$ can reconstruct. The \emph{in-class reconstruction rate} (IRR) and \emph{out-of-class reconstruction rate} (ORR) of a model $M$ are defined as \begin{equation}\label{eqnIRR} \text{IRR}(M) = \frac{|\cM_M \cap \cD|}{|\cD|} = \frac{|\cD_M|}{|\cD|} \end{equation} and \begin{equation}\label{eqnORR} \text{ORR}(M) = \frac{|\cM_M \cap \cS|}{|\cS|} = \frac{|\cS_M|}{|\cS|}. \end{equation} For each model $M$, we will use $1 - IRR(M)$ and $ORR(M)$ to quantify the ``measure'' of the missing modes and spurious modes, respectively. Assuming that the $\cD$ and $\cS$ are generated i.i.d, $1 - IRR(M)$ and $ORR(M)$ are unbiased estimates of probabilities that a digit $x \not\in \cM_M$ and a symbol $x \in \cM_M$, respectively. Thus, $1 - IRR(M)$ is indeed a measure of the missing modes under the sampling distribution of $\cD$, but $ORR(M)$ is only a proxy of the measure of the spurious modes since it only covers those modes that are sampled by the symbol set $\cS$. In the experiments we will use the difference \begin{equation}\label{eqnDelta} \Delta(M) = \text{IRR}(M) - \text{ORR}(M) \end{equation} as a proxy metrics for identifying ``good'' models, that is, good compromises of low rates of both spurious and missing modes. \begin{figure}[!ht] \centering \begin{subfigure}[b]{0.9\columnwidth} \includegraphics[width=0.45\columnwidth]{theta_30_pos} \includegraphics[width=0.45\columnwidth]{theta_30_neg} \caption{$\theta=30$} \end{subfigure} \begin{subfigure}[b]{0.9\columnwidth} \includegraphics[width=0.45\columnwidth]{theta_50_pos} \includegraphics[width=0.45\columnwidth]{theta_50_neg} \caption{$\theta=50$} \end{subfigure} \begin{subfigure}[b]{0.9\columnwidth} \includegraphics[width=0.45\columnwidth]{theta_80_pos} \includegraphics[width=0.45\columnwidth]{theta_80_neg} \caption{$\theta=80$} \end{subfigure} \caption{The effect of the threshold $\theta$ on images that are considered as``recognized'' and the ones that are not. For each value of $\theta$, the left panels correspond to images considered as recognized by the model, while the right panels correspond to images considered that are not. Within each panel, the top row contains the original images and the bottom row contains their corresponding reconstructions. The reconstructions are obtained from a convolutional autoencoder trained on MNIST training set and the reconstructions are obtained from the test set of handwritten mathematical symbols. } \label{figTheta} \end{figure} \section{Experiments} In the experiments, we use a family of convolutional autoencoders. All the models consists in a set of $L$ convolutional layers on the encoder, followed by a set of $L$ convolutional layers with padding~\citep{dumoulin2016guide} (to increase the size of the feature maps) on the decoder, thus a total of $2L$ layers. Each convolutional layer has a filter of size $k$ and use the \emph{ReLU} activation function. We apply an activation function $\text{act}(\cdot)$ in the bottleneck ("code"). The output layer used a sigmoid activation function. To explore the space of the architectures, we vary several hyperparameters, while we fix others. We vary the number of layers $L$ from 1 to 6. We use 128 feature maps in all the layers, except in the bottleneck layer where the number of feature maps varies and can take values from $\{2, 4, 8, 16, 32, 64, 128\}$. We use a filter size of $k=5$ in all the layers and a stride of $1$. For the activation function of the bottleneck $\text{act}(\cdot)$, we use the spatial Winner-Take-All (WTA) activation used in ~\cite{makhzani2015winner}. In each feature map, $\text{spatialwta}$ zeroes out all the activations except the activation with the maximum value, thus backpropagating only through through the activation with the maximum value in each feature map. After applying $\text{spatialwta}$, we apply an additional sparsity activation, which we call $\text{channelwta}$. $\text{channelwta}$ is parametrized by a sparsity rate $\rho$, it keeps only the feature maps with the highest activation\footnote{Only a single activation is greater than zero per feature map after having applied $\text{spatialwta}$}, zeroing out $\rho\%$ of them to achieve a channel-wise sparsity rate of $\rho$. We use the values $\rho \in \{0, 0.1, 0.2, 0.4, 0.5, 0.7, 0.9\}$, where $\rho = 0$ means we do not use $\text{channelwta}$. We also use denoising~\citep{vincent2010stacked} with \emph{salt and pepper} noise by varying probabilities of corruption $p_{\text{corruption}}$ where $p_{\text{corruption}} \in \{0, 0.1, 0.2, 0.3, 0.4, 0.5\}$. All the models are trained on the MNIST training dataset with the reconstruction error objective, using mean squared error (MSE). A total of 187 models have been trained for the current experiments. \subsection{The spurious/missing mode trade-off} \label{secTradeOff} Figure~\ref{figORRVsIRRModes} shows the out-of-class recognition rate ORR (\ref{eqnORR}) versus the in-class recognition rate IRR (\ref{eqnIRR}) of each trained model $M$. For selected models, we show some digits $x \in \cD \backslash \cD_M$ that they cannot reconstruct, illustrating the missing modes, and some symbols $x \in \cS_M$ that they can, illustrating the spurious modes. The most important observation here is that none of the models are perfect: they either reconstruct all digits but also a large portion of the symbols, or they have a low rate of spurious modes but missing also a large portion of the digits. While the actual numbers are somewhat dependent on the reconstruction threshold $\theta$, with the threshold we selected $\theta = 50$, the first model that can reconstruct $99.5\%$ of the digits can also reconstruct about $30\%$ of the symbols, and the first model that discards $95\%$ of the symbols can only reconstruct about $60\%$ of the digits. The model with the best $\Delta = 0.85$ (\ref{eqnDelta}) makes a compromise of reconstructing $95\%$ of the digits and about $10\%$ of the symbols. The panels attached to selected models $M$ show both the original digits and symbols (first and third rows) $x$ and the reconstructed digits and symbols (second and fourth rows). As we move from $(0,0)$ towards $(1, 1)$, missing modes become more ant more ``esoteric'' until they disappear completely, while spurious modes become richer and richer as models pick up more and more symbols. One criticism of the methodology could be that the set of symbols and digits overlap, and the reconstructed symbols $\cS_M$ all look like digits (coming from $\cD \cap \cS$). It is clear from the examples that this is not the case: most reconstructed symbols do not look like digits to a human evaluator. To make this counterargument more formal, we trained a digit vs. symbol classifier $p(S|x)$. The low test error of $0.2\%$ showed that indeed most symbols can be recognized as symbols by an ``objective'' classifier. There still remained a doubt on whether the models ``pulled'' all the reconstructed symbols $M(x)$ into the digit set, so we also looked at the symbol classification rate in $\{M(x): x \in \cS_M\}$, that is, the rate of reconstructed symbols that looked like digits to the discriminator. While the rates were higher than $0.2\%$, they remained in the low 10s, confirming that indeed, most reconstructed symbols are spurious, even under this more stringent criterion. \begin{figure*}[!ht] \centering \includegraphics[width=0.8\textwidth]{ORR_vs_IRR_modes} \caption{The out-of-class recognition rate ORR (\ref{eqnORR}) versus the in-class recognition rate IRR (\ref{eqnIRR}). The panels show a random set of digits that cannot be reconstructed by the selected model in the first row, and their (attempted) reconstructions in the second row. These images represent missing modes. The third row of each panel is the symbols that the selected model can reconstruct, with the reconstruction in the fourth row. These images represent spurious modes. An interactive version of the plot, where the reader can click on any dot to see the corresponding panel is available at \url{https://goo.gl/ehbrb3}. } \label{figORRVsIRRModes} \end{figure*} Figure~\ref{figORRVsIRRSamples} shows the same ORR vs. IRR plot, but panels of selected models show images generated from random seeds using the procedure in Figure~\ref{figIterativeGeneration}. Models towards $(0,0)$ generate overwhelmingly digits, but the variability of these digits is visibly lower than in MNIST. Models towards $(1,1)$ generate overwhelmingly spurious symbols. These models are typical candidates for research in novelty generation \cite{nguyen2015innovation,lake2015human,kazakcci2016digits,cherti2017out}. Finally, models towards $(0,1)$ are those that could be considered a good compromise, generating mostly digit-looking symbols with a high variability. \begin{figure*}[!ht] \centering \includegraphics[width=0.8\textwidth]{ORR_vs_IRR_samples} \caption{The out-of-class recognition rate ORR (\ref{eqnORR}) versus the in-class recognition rate IRR (\ref{eqnIRR}). The panels show a random set of images generated from random seeds by the procedure described in Figure~\ref{figIterativeGeneration} for selected models. An interactive version of the plot, where the reader can click on any dot to see the corresponding panel is available at \url{https://goo.gl/Ltzp3V}. } \label{figORRVsIRRSamples} \end{figure*} Using $\Delta(M)$ can be considered as a metric for selecting these models, and the full IRR-ORR plane can be used to tune the trade-off between accepting either spurious or missing modes. Note also that in practical situations, say, in a data challenge, the control set $\cS$ can be kept hidden from the modelers, making it less likely that they overfit the particular ORR metrics and thus $\Delta$. It is even possible to use several proxy control sets and to combine the resulting $\Delta$ scores using various statistics (e.g., mean or min). \subsection{Comparing $\Delta$ to objectness} Objectness (or inception score) \cite{salimans2016improved} is one of the popular non-likelihood-based quality metrics. It requires a sub-class classifier so we trained for it a standard convnet for classifying MNIST digits. Figures~\ref{figObjectness} shows the the scatterplot of objectness vs. $\Delta$. The two metrics agree on what bad models are, but not on what good models are. Furthermore, it is hard to say if there is any correlation between these measures and human judgement. Objectness tends to be insensitive to spurious modes, possibly because of the ``blind spots'' of the classifier (it confidently classifies spurious symbols into one of the digit classes). \begin{figure*}[!ht] \centering \includegraphics[width=0.8\textwidth]{objectness} \caption{Objectness \cite{salimans2016improved} vs. $\Delta$, visualizing generated images of selected models. An interactive version of the plot, where the reader can click on any dot to see the corresponding panel is available at \url{https://goo.gl/KWuTvk}. } \label{figObjectness} \end{figure*} \section{Discussion} The paper presents an investigation of the spurious samples in deep generative models and their relationship with a model's ability to effectively learn the domain being modelled. Through a set of experiments and for a specific model family, we have shown that there is a trade-off between a model's potential to generate spurious samples and its effectiveness for covering all the available training instances. This implies that, at least for the models we considered, one cannot eliminate spurious samples without sacrificing the model's ability to generate some data we actually want to model. The metrics we used in this study, in-class and out-of-class reconstruction rates and their difference, can be used as an alternative non-likelihood-based metrics to tune the spurious/missing mode trade-off and for selecting models that achieve the best compromise. \bibliographystyle{icml2018}
{'timestamp': '2018-10-05T02:00:19', 'yymm': '1810', 'arxiv_id': '1810.01876', 'language': 'en', 'url': 'https://arxiv.org/abs/1810.01876'}
arxiv
\section{Abstract} We provide a method to determine whether a new recommendation system improves the revenue per visit ($RPV$) compared to the status quo. We achieve our goal by splitting $RPV$ into conversion rate and average order value ($AOV$). We use the two-part test suggested by Lachenbruch to determine if the data generating process in the new system is different. In cases that this test does not give us a definitive answer about the change in $RPV$, we proposed two alternative tests to determine if $RPV$ has changed. Both of these tests rely on the assumption that non-zero purchase values follow a log-normal distribution. We empirically validated this assumption using data collected at different points in time from Staples.com. On average, our method needs a smaller sample size than other methods. Furthermore, it does not require any subjective outlier removal. Finally, it characterises the uncertainty around $RPV$ by providing a confidence interval. \section{Introduction} Measurement is a never-ending journey. Every measurement method has its own drawbacks, so there is no one size fits all approach. Because for retail recommendations the vast majority of outcomes (usually > 95\%) are ``no-purchase'' events, the conversion rate is small (large clumping at no-purchases). Furthermore, there are always customers with large purchases, and thus, the distribution of non-zero order values is not normal. Using Normal theory tests in this case causes bias in estimates (\cite{lachenbruch1976analysis}). In addition, outlier removal is a difficult task and in many cases subjective removal might bias estimates. For example, when data is skewed and non-normal (like the distribution of prices) studies show that sample size needs to increase (\cite{muthen2002use}). Or in the case of non-normality, bootstrap estimates might be inconsistent (\cite{andrews2000inconsistency,sen2010inconsistency}). Finally, estimates that are efficient for clean data from simple distributions (e.g. normal distribution which is symmetric and unimodal with thin tail) may not be robust to contamination by outliers, and may be inefficient for more complicated distributions, raising the need for very large sample sizes for valid inference (\cite{Wikipedia2010}). One performance metric of a recommendation model is Revenue Per Visit ($RPV$). The relationship between $RPV$, Average Order Value ($AOV$), and conversion rate r is as follows: \begin{center} \begin{equation} RPV=r.AOV. \end{equation} \par\end{center} To determine whether a new recommendation model has changed either of $r$ or $AOV$, we can use a powerful test proposed by \cite{lachenbruch1976analysis}. This test combines statistics for detecting differences in conversion rate and $AOV$ to obtain a Chi-square valued measure that determines if there is a statistically significant difference between the two models. This test is powerful because it requires a small sample size. We will describe Lachenbruch's test in the next section. In a general sense, comparisons can be defined in 3 exclusive states: significantly positive (Pos. Sig.), non-significant (Non-Sig.), or significantly negative (Neg. Sig.). Since the objective of a recommendation system is to increase $RPV$, we can visualize the outcomes of a significance test of $r$ and $AOV$ on $RPV$ based on Table 1, where + is a guaranteed significantly positive difference in $RPV$, \textminus{} is a decrease, 0 is no difference, and X is indeterminate. For most of the cases, Lachenbruch's test tells us with a relatively small sample size whether the new recommendation system is more effective. For the two indeterminate cases we develop two parametric tests of significance. \begin{table} \caption{Expected Revenue Significance Test} \begin{centering} \begin{tabular}{|c|c|c|c|} \hline & $AOV$ Pos. Sig. & $AOV$ Non-Sig. & $AOV$ Neg. Sig.\tabularnewline \hline \hline $r$ Pos. Sig. & + & + & X\tabularnewline \hline $r$ Non-Sig. & + & 0 & -\tabularnewline \hline $r$ Neg. Sig. & X & - & -\tabularnewline \hline \end{tabular} \par\end{centering} \end{table} \section{Tests of Significance } In this section, we will describe in detail the process to determine whether $RPV$ of the new recommendation is different from the old recommendation system in a statistically significant sense. To summarize this process, its stages are as follows: 1. Run a pilot study and determine the sample size for Lachenbruch's Test. 2. Run Lachenbruch's Test and if it results in one of the determinate cases, then stop the test with a definite conclusion (See Table 1). 3. If Lachenbruch's Test is indeterminate, run a new pilot study to determine the sample size for either of our newly devised parametric tests (derived in the next section). 4. Run the new parametric test, and conclude if there is a statistically significant difference for $RPV$ between the two models. \section{Lachenbruch\textquoteright s Two-Part Test } Lachenbruch's Test applies to data with clumping at zero. Clumping at zero for recommendation systems can be interpreted as no purchase. This test compares the distribution of $RPV$ across control and treatment groups. In other words, the null hypothesis in this test asserts the equality of these two distributions. To run this test, \cite{lachenbruch1976analysis} uses two statistical measures: $z_{p}$ and $z_{U}$. The value $z_{p}$ denotes z-statistics for proportion of no purchases, and it has a normal distribution in the limit, so its square has an asymptotic Chi-square distribution with one degree of freedom. The value $z_{U}$ is a function of Mann-Whitney-Wilcox U statistic for order values and has an asymptotic normal distribution, so its square has Chi-square distribution with one degree of freedom. As a result, Lachenbruch's statistic $L=z_{p}^{2}+z_{U}^{2}$ has an asymptotic Chi-square distribution with two degrees of freedom. If $L$ is greater than 9.633 we can reject the null hypothesis with 95\% confidence. The statistic $z_{p}$ is defined as follows: \begin{equation} z_{p}=\frac{p_{1}-p_{2}}{\sqrt{p_{p}(1-p_{p})(\frac{1}{n_{1}}+\frac{1}{n_{2}})}} \end{equation} where $p_{1}$, $p_{2}$ denote the no-purchase probabilities for the treatment and control groups, respectively. The value $p_{p}$ denotes the no purchase probability for the pooled group (i.e. $p_{p}=\frac{k_{1}+k_{2}}{n_{1}+n_{2}}).$ The values $k_{1}$, $k_{2}$ denote the observed number of no purchases for the treatment and control groups, respectively. The values $n_{1}$, $n_{2}$ denote the sample sizes for the treatment and control groups, respectively. The value $z_{U}$ is defined as follows: \begin{equation} z_{U}=\frac{U-\frac{n_{1}n_{2}}{2}}{\sqrt{n_{1}n_{2}(n_{1}+n_{2}+1)/12}} \end{equation} where $U$ is the Mann-Whitney-Wilcoxon statistic for order values.\footnote{Computing rank-sum $U$ involves counting the number of times the first value wins over any observations in the other set (the other value loses if the first is larger) with 0.5 for any ties. The sum of wins and ties construct the $U$ measure. $U$ can be calculated using most statistical packages or python (scipy.stats mannwhitneyu).}. If the Chi-square test suggests significant difference in the distributions of $RPV$ between the treatment and control groups, \cite{lachenbruch1976analysis} suggests we can compare the values of $z_{p}$ and $z_{U}$ against the standard normal distribution (i.e. 1.96 and -1.96 as a threshold for 95\% confidence) to identify the sources of the difference. Knowing the sources of the difference between the two distributions, we can use Table 1 in order to identify whether the expected revenue between treatment and control groups are statistically different. In the cases where Table 1 is indeterminate, we need to use another statistical test. This test requires collecting a new data set (i.e. we can not use the old data set for the new test). \begin{figure} \caption{\label{fig:The-Two-Stage}The Two-Stage Model where the first stage is Customer Decision to Purchase (conversion) and the second stage is, if decision was to purchase, order value. Order value is often modeled as a log-normal distribution \cite{Feldman2013}.} \includegraphics[width=0.8\textwidth]{image01.png} \end{figure} \section{Tests for Detecting Change In Expected Revenue } In this section, we introduce two tests that assume a parametric form for $RPV$ and attempt to establish if there is any change in $RPV$ between treatment and control groups. Both tests assume that the data is generated in a two-stage process, which mixes non-purchases with log-normally distributed order values (See Figure \ref{fig:The-Two-Stage}). The first test uses the multivariate Delta method to estimate the variance of the estimated expected revenue. The second test uses the likelihood-ratio test to make inference. A log-normal distribution is a good candidate to deal with fat tails and is widely used in science and business (\cite{limpert2001log}). This distribution can arise due to wealth and income distribution (\cite{gabaix2009power}) or the cognitive lock-in of customers to the Staples website (\cite{johnson2003cognitive}). We checked Staples.com order values data for log-normal distribution using $Q-Q$ plots, and found that it fits (See Appendix). \subsection*{Method 1: Expected Revenue Confidence Interval Using the Delta Method} To compare expected revenues between treatment and control groups, we will derive a confidence interval for this difference. This confidence interval depends on our estimates for $r$ ($\hat{r}$) and $AOV$ ($\hat{AOV}$), and our uncertainty around them. The estimates $\hat{r}$ and $\hat{AOV}$ are independent. Therefore, their covariance is zero. As a result, we can use the multivariate Delta method\footnote{The Delta Method, Theorem 20 of http://www.stat.cmu.edu/\textasciitilde larry/=stat705/Lecture4.pdf, accessed on Feb 21st, 2017.} to estimate the variance of $RPV$ from our point and variance estimates of $\hat{r}$ and $\hat{AOV}$. Specifically: \begin{equation} \sigma_{RPV}^{2}=\hat{AOV}^{2}\hat{\sigma}_{r}^{2}+\hat{r}^{2}\hat{\sigma}_{AOV}^{2} \end{equation} where all these values are pooled estimates (i.e. the estimates are computed over a sample that consists of combined observations from treatment and control groups). To estimate $AOV$ and our uncertainty around it from purchase values, which we assumed to have a log-normal distribution, we transform the purchase values by the log function. These transformed values have a normal distribution, so we use its mean $\hat{\mu}$ as a measure for its location, and its standard deviation $\hat{\sigma}_{AOV}$ as a measure for uncertainty around it. Since $\hat{r}$ is a binomial proportion, its estimated variance is: \begin{equation} \hat{\sigma}_{r}^{2}=\hat{r}(1-\hat{r}) \end{equation} where $\hat{r}$ is the pooled proportions of non-purchases. As a result, we can write the estimated variance of $RPV$ as follows: \begin{equation} \hat{\sigma}_{RPV}^{2}=e^{\hat{\mu}+\hat{\sigma}_{AOV}^{2}/2}\hat{r}(1-\hat{r})+\hat{r}^{2}(e^{\hat{\sigma}_{AOV}^{2}}-1)e^{2\hat{\mu}+\hat{\sigma}_{AOV}^{2}} \end{equation} To make inference, the final step is computing the convergence rate for the asymptotic distribution, which is equal to the harmonic mean of sample sizes: \begin{equation} h(n_{1}+n_{2})=(\frac{1}{n_{1}}+\frac{1}{n_{2}})^{-1} \end{equation} As a result, the 95\% confidence interval for the expected revenue $RPV$ can be computed as follows: \begin{equation} (\hat{RPV}_{treatment}-\hat{RPV}_{control})\pm1.96\sqrt{\frac{\hat{\sigma}_{RPV}^{2}}{h(n_{1},n_{2})}} \end{equation} \subsection*{Method 2: Likelihood Ratio Test for Expected Revenue } Likelihood ratio test allows comparison between treatment and control groups parametrically. Based on Wilk\textquoteright s Theorem, the log likelihood ratio has an asymptotic Chi-square distribution with the degree-of-freedom (df) equal to the difference between degrees of freedom of the null and alternative hypotheses. The likelihood ratio test rejects the null hypothesis if the value of this statistic is too small. The Neyman-Pearson lemma states that likelihood ratio test is the most powerful test of significance. Many common test statistics such as Z-test, F-test, Pearson\textquoteright s chi-square test, and G-test can be phrased as log-likelihood ratio test or its approximation. In order to define the likelihood ratio test for expected revenue, we need to specify a likelihood function under the null and alternative hypotheses. Then we form the likelihood ratio value which is defined as follows: \begin{equation} LR=\frac{L(H_{0})}{L(H_{1})} \end{equation} where $L$ is the likelihood function. $LR$ is a number between zero and one. The low values of the likelihood ratio mean that the observed result was less likely to occur under the null hypothesis as compared to the alternative. For our expected revenue test, null hypothesis likelihood function is defined as follows: \begin{equation} L(H_{0})=LN(OV_{c}|\mu_{c},\sigma_{c}^{2})Bin(n_{c},k_{c}|p_{c})LN(OV_{t}|\mu_{t},\sigma_{t}^{2})Bin(n_{t},k_{t}|p_{t}) \end{equation} under \[ p_{c}\mu_{c}=p_{t}\mu_{t}, \] where $OV$ denotes the order value, $LN$ denotes log-normal distribution, and $Bin$ denotes the binomial distribution. The null hypothesis puts constraints over the parameter space of the likelihood function. This constraint requires that the expected revenues under control and treatment groups are equal. Similarly, but excluding the constraint, we can define the likelihood function under the alternative hypothesis as follows: \begin{equation} L(H_{1})=LN(OV_{c}|\mu_{c},\sigma_{c}^{2})Bin(n_{c},k_{c}|p_{c})LN(OV_{t}|\mu_{t},\sigma_{t}^{2})Bin(n_{t},k_{t}|p_{t}) \end{equation} In order to run the likelihood ratio test, we need to first find the maximum likelihood estimates of parameters (i.e. $\mu_{c},\sigma_{c}^{2},p_{c},\mu_{t},\sigma_{t}^{2},p_{t}$). To find these parameters for the alternative hypothesis, we can use the closed form solution we specified in the Delta method section because we don\textquoteright t have any constraints. As maximizing the likelihood function is equivalent to maximizing the log likelihood function, and derivatives of the log likelihood functions are analytically more tractable than that of the likelihood function, we use the log likelihood function rather than the likelihood function. We define the Lagrangian as follows: \begin{equation} \begin{array}{c} Log(H_{0})=\log LN(OV_{c}|\mu_{c},\sigma_{c}^{2})+\log Bin(n_{c},k_{c}|p_{c})+\log LN(OV_{t}|\mu_{t},\sigma_{t}^{2})\\ +\log Bin(n_{t},k_{t}|p_{t})-\lambda(p_{c}\mu_{c}-p_{t}\mu_{t}) \end{array} \end{equation} In order to optimize the Lagrangian, we compute its gradient with respect to the parameter vector (i.e. $(\mu_{c},\sigma_{c}^{2},p_{c},\mu_{t},\sigma_{t}^{2},p_{t},\lambda)$) and equate it to a vector of zeros. As a result, we will have the following system of equations to solve for the parameter vector: \begin{equation} \begin{cases} \begin{array}{c} k_{c}(1-p_{c})-p_{c}(n_{c}-k_{c})-\lambda\mu_{c}p_{c}(1-p_{c})=0\\ k_{t}(1-p_{t})-p_{c}(n_{t}-k_{t})-\lambda\mu_{t}p_{t}(1-p_{t})=0\\ \log AOV_{c}-\mu_{c}-\lambda\mu_{c}^{2}p_{c}=0\\ \log AOV_{t}-\mu_{t}-\lambda\mu_{t}^{2}p_{t}=0\\ \begin{array}{c} (\log AOV_{c}-\mu_{c})^{2}=\sigma_{c}^{2}\\ (\log AOV_{t}-\mu_{t})^{2}=\sigma_{t}^{2}\\ \mu_{t}p_{t}-\mu_{c}p_{c}=0 \end{array} \end{array}\end{cases} \end{equation} We did not find a closed form solution for this system of equations, so we use a nonlinear optimization algorithm to numerically find these parameters. Specifying search procedures that gives us this parameter vector completes our specification of this test. \section{Sample Size Estimation} In this section we determine the sample size required in order to obtain the desired statistical power for each of the tests that we discussed above. Note that although we carry two tests sequentially (i.e. Lanchenbruch\textquoteright s Test followed by either likelihood ratio or Delta method test), the overall sample size we will need for these two tests is going to be smaller than average. This is because, in many cases Lachenbruch\textquoteright s Two-part Test can establish whether the distribution of active and control groups are the same or not. The standard process in hypothesis testing consists of collecting data, followed by the execution of the test. In the testing stage, two possible errors can happen: rejecting the null hypothesis when it is true (Type I error), and not rejecting the null hypothesis when it is false (Type II error). In our case, null hypothesis states that the treatment and control groups have the same distribution. As a consequence, a Type I error will make us believe that we have an improvement over our existing system, while in reality we do not. On the other hand, a Type II error makes us believe that the new system is not better than the old system, while in reality it is, so it costs us the opportunity to replace the existing system with a better one. The probability of committing a Type I error is a function of the shape of the null model distribution. The magnitude of a Type II error is a function of the sample size and the model. Specifying the magnitude of these two types of error allows us to find the sample size required for the test. \subsection*{Sample size determination using Monte Carlo Method } The Monte Carlo simulation method is applicable for all tests that we discussed above. Steps of this process are as follows: \begin{enumerate} \item Run a pilot study to estimate the magnitude of the effect and uncertainty around it. \item Specify the desired statistical power level. \item Start with an initial guess about the required sample size. \item Repeat many times (e.g. 100 or 1000 times) the following: \begin{enumerate} \item Sample with replacement from the data collected in the pilot study as many times as the sample size specified in the previous step. \item Run the statistical test for each of the samples. \item Compute the proportion of times that this test identifies the effect as significant. \item Consider this proportion as the power of the statistical test. \end{enumerate} \item Adjust the sample size by comparing the power of the statistical test with the desired power. If you need a higher power, increase the sample size, and run step 2 again. \end{enumerate} \section{Conclusion, Limitations, and Future Work} In this paper, we addressed the problem of incremental revenue measurement and valid statistical inference. Our approach has three distinct advantages. First, it allows analysts to conclude whether a new system is effective using a smaller sample size. Second, our approach does not require subjective outlier removal. Third, our approach provides a method to determine a confidence interval for $RPV$. Although our approach improves the current measurement methods, it does not account for the dependence between multiple visits of a given visitor. We address this issue in a forthcoming paper. \section*{Acknowledgements} We thank Karthik Kumar, Stephanie Whang, Ryan Applegate, and Nitin Varma for their helpful discussions. \bibliographystyle{acm} \nocite{*}
{'timestamp': '2019-06-18T02:02:22', 'yymm': '1906', 'arxiv_id': '1906.06390', 'language': 'en', 'url': 'https://arxiv.org/abs/1906.06390'}
arxiv
\section{Introduction}\label{secI} Let $\mathbb{F}_q$ denote the finite field with $q$ elements, and $\mathbb{F}_q^*$ the multiplicative group for a prime power $q$. If a polynomial $f(x)$ over $\mathbb{F}_q$ induces a bijection map from $\mathbb{F}_q$ to itself, it is called a permutation polynomial (PP). If both $f(x)$ and $f(x)+x$ are permutation polynomials over $\mathbb{F}_q$, $f(x)$ is called a complete permutation polynomial. PPs and CPPs have attracted researchers' much attention for their wide applications in cryptography, coding theory, and combinational design \cite{A00015}. Permutation polynomials attract peoples' interest for their extraordinary properties and algebraic forms. Orthomorphisms map each maximal subgroup of the additive group of $\mathbb{F}_q$ half into itself and half into its complement, they have a single fixed point, and are the same as CPPs in even characteristic. Nonlinear orthomorphisms (or CPPs) are of cryptographic interest, and Mittenthal used them for the design of nonlinear dynamic substitution device \cite{A000M01,A000M02}. Mann introduced CPPs in the construction of orthogonal Latin squares \cite{A000M}. PPs have been applied in the Lay–Massey scheme, the block cipher SMS4, the stream cipher Loiss \cite{DL01,DL02,DL03,FF01}, the design of Hash functions, quasigroups, and also in the constructions of some cryptographically strong functions \cite{V01,V02,V03,V04,V05,V06}. A monomial $x^n$ permutes $\mathbb{F}_q$ if $\textup{gcd}(n,q-1)=1$, they are the simplest kind of permutation polynomials. For binomials and trinomials, the permutation properties are not so easy to determine. Carlitz studied permutation binomials in 1962 \cite{A0003c}. In \cite{A0003cw}, Carlitz and Wells found that for $q$ large enough than $d$, the polynomial $f(x)=x(x^{{q-1}\over d}+a)$ might be a permutation polynomial over $\mathbb{F}_q$. Hou and Lappano studied permutation binomials of the form $ax+x^{3q-2}, ax+x^{5q-4}$ \cite{A000152,A00012}. However, only a limited number of constructions are known for PPs. More recent constructions of PPs can be found in \cite{D01,A000152,A00012,LL01,L02,A00025,W01,W02,W03,W04,W05,W06,W07}. In this paper, we construct some new classes of permuation polynomials, to some extent they are modifications of some of the PPs proposed in \cite{X01}. And we continue the work of \cite{X01} to investigate the necessities of two classes of permutation polynomials presented therein, where the sufficient conditions are given. To deal with these classes of permutation polynomials, we mainly use the unit circle of the finite fields, and the algebraic structures of the polynomials. Before coming to our work in Sections \ref{Section II} and \ref{SecIII}, let us first present the following lemmas which might be useful for our study. \begin{lemma}\label{l01}\cite{Z01} Let $d,r>0$ with $d\mid q-1$, and let $h(x)\in \mathbb{F}_q[x]$. Then $f(x)=x^rh(x^{(q-1)/d})$ permutes $\mathbb{F}_q$ if and only if the following two conditions hold: \begin{enumerate} \renewcommand{\labelenumi}{$($\mbox{\roman{enumi}}$)$} \item $ \textup{gcd}(r,(q-1)/d)=1;$ \item $x^rh(x)^{(q-1)/d}$ permutes $\mu_{d}, $ where $\mu_{d}$ denotes the $d$-th root of unity in $\mathbb{F}_q$. \end{enumerate} \end{lemma} For each element $x$ in the finite field $\mathbb{F}_{2^{2m}}$, define $\bar{x}=x^{{2^m}}$. The unit circle of $\mathbb{F}_{2^{2m}}$ is the set \[ \mathcal{U}=\{\eta\in \mathbb{F}_{2^{2m}}:\eta^{2^m+1}=\eta \bar{\eta}=1\}. \] The following lemma can be verified without much difficulty. \begin{lemma}\label{l02} Each nonzero element $x$ in the finite fields $\mathbb{F}_{2^{2m}} $ has a unique expression of the following form \[ x=u\lambda, \] with $u\in \mathbb{F}_{2^{m}}^*$ and $\lambda\in \mathcal{U}.$ \end{lemma} \begin{lemma}\label{l03}\cite{A000242} Let $q=2^k$, where $k$ is a positive integer. The quadratic equation $x^2+ux+v$, where $u,v\in \mathbb{F}_q$ and $u\not=0$, has roots in $\mathbb{F}_q$ if and only if $\textup{Tr}_q(v/{u^2})=0$. \end{lemma} \section{Constructions of several classes of permutation polynomials over finite fields}\label{Section II} In this section, we construct four classes of permutation polynomials over finite fields. To some extent the first three are modifications of permutation polynomials constructed in \cite{X01}, and the fourth class of permutation polynomials comes from a kind of PPs in \cite{L03}. \subsection{PPs of type $(bx+\delta)^{2^m+1}+ x^{2^m}+cx$ over $\mathbb{F}_{2^{km}}$} In \cite[Proposition 1]{X01}, X. Xu {\sl et al.} proposed a class of permutation polynomials of the form $(x^{2^m}+x+\delta)^{s}+bx$ over $\mathbb{F}_{2^{km}}$, with $b\in \mathbb{F}_{2^{m }}^*$ and $\delta$ can be any value. In the following proposition, we consider PPs over $ \mathbb{F}_{2^{km}}$ by moving the $2^m\textup{th}$ power term out of the bracket, and adding one more constant $c$. \begin{proposition} For positive integers $m,n,k$ with $n=km,2\nmid k$. For any $\delta \in \mathbb{F}_{2^n}$, the polynomial \[ g(x)=(bx+\delta)^{2^m+1}+ x^{2^m}+cx \] is a permutation of $\mathbb{F}_{2^n}$ where $b,c \in \mathbb{F}_{2^n}\backslash \mathbb{F}_{2}$ satisfying $c={b\over b^{2^{2m}}}$. \end{proposition} \begin{IEEEproof} We prove that $g(x)=d$ has at most one solution for any $d\in \mathbb{F}_{2^n}$, which is equivalent to \begin{equation}\label{e301} x^{2^m}+cx+d=(bx+\delta)^{2^m+1} \end{equation} has a unique solution. It can be verified that $\textup{gcd}(2^m+1,2^n-1)=1$ for $n=km$ when $2\nmid k$. Let $y=bx+\delta$, then $x={y\over b}+{\delta \over b}$. Equation (\ref{e301}) can be rewritten as \begin{equation*}\label{e302} ({{y\over b}+{\delta \over b}})^{2^m}+c({{y\over b}+{\delta \over b}})+d=y^{2^m+1}, \end{equation*} which is equivalent to \begin{equation*}\label{e303} y^{2^m+1}+{1\over {b^{2^m}}}y^{2^m}+{c \over b}y+{{ \delta^{2^m}}\over {b^{2^m}}} +{{c \delta}\over b} +d=0. \end{equation*} That is \begin{equation*}\label{e304} (y^{2^m}+{c \over b})(y+{ 1\over {b^{2^m}}})+{{c }\over {b^{2^m+1}}} +{{\delta^{2^m}}\over {b^{2^m}}} +{{c \delta}\over b} +d=0. \end{equation*} So, \begin{equation}\label{e305} (y+{ 1\over {b^{2^m}}})^{2^m+1}={{c }\over {b^{2^m+1}}} +{{\delta^{2^m}}\over {b^{2^m}}} +{{c \delta}\over b} +d. \end{equation} by the assumption. Now, $\textup{gcd}(2^m+1,2^n-1)=1$ means that $y^{2^m+1}$ is a permutation of $\mathbb{F}_{2^n}$. Therefore there is a unique $y$ satisfying equation (\ref{e305}). \end{IEEEproof} \begin{example} Let $ m=2,k=3$, then $n=6$. Let $\delta \in \mathbb{F}_{2^6}$ be any element, $b, c \in \mathbb{F}_{2^6}\backslash{\mathbb{F}_{2}}$, satisfying $c=b^{48}$. Using Magma, it can be verified that \[ g(x)=(bx+ \delta)^{5}+x^{4}+cx \] is a permutation polynomial over $\mathbb{F}_{2^6}$. \end{example} \subsection{PPs of type $(x^{2^m}+x+\delta)^{-s}+bx$ over $\mathbb{F}_{2^{2m}}$} In \cite[Proposition 7]{X01}, X. Xu {\sl et al.} proposed a class of permutation polynomials of the form $(x^{2^m}+x+\delta)^{-s}+bx$ over $\mathbb{F}_{2^{km}}$, with $b\in \mathbb{F}_{2^{m\over 2}}^*$. In the following proposition, we consider PPs over $ \mathbb{F}_{2^{2m}}$ by changing $2^m+1$ therein to $2^m+2$, and different range of $\delta$. \begin{proposition} Let $s,m$ be positive integers satisfying $(2^m+2)(-s) \equiv 2^m-1 \ (\textup{mod} \ 2^{2m}-1$), where $m$ is an odd integer. Let $\delta \in \mathbb{F}_{2^m}$, then the polynomial \begin{equation*} g(x)=(x^{2^m}+x+\delta)^{-s}+bx \end{equation*} is a permutation of $\mathbb{F}_{2^{2m}}$, with $b\in \mathbb{F}_{2^{m}}\backslash \mathbb{F}_{2}$. \end{proposition} \begin{IEEEproof} Since $\textup{gcd}(2^m+2,2^m+1)=1$, and $\textup{gcd}(2^m+2,2^m-1)=\textup{gcd}(3,2^m-1)=1$ for $m$ odd, \begin{equation}\label{e201} \textup{gcd}(2^m+2,2^{2m}-1)=1. \end{equation} To prove that $g(x)$ is a permutation polynomial, it is enough to prove that for any $d\in \mathbb{F}_{2^{2m}}$, $g(x)=d$ has a unique solution. That is \begin{equation*}\label{e202} (x^{2^m}+x+\delta)^{-s}=bx+d \end{equation*} is satisfied by at most one $x$. By (\ref{e201}), taking the $(2^m+2)\textup{th}$ power on both sides of the above equation gives the equivalent equation \begin{equation}\label{e203} (x^{2^m}+x+\delta)^{2^m-1}=(bx+d)^{2^m+2}. \end{equation} First, if there exists a solution $x$ such that \begin{equation*}\label{e2032} x^{2^m}+x+\delta =0, \end{equation*} then $x={d\over b}$, for the right side of equation (\ref{e203}) is also zero. In this case, the above equation becomes \begin{equation}\label{e2033} {{d^{2^m}}\over {b^{2^m}}}+{d\over b}+\delta =0. \end{equation}. Second, let us assume that $x^{2^m}+x+\delta\not=0$. Since taking the $(2^m+1)\textup{th}$ power, the left side of equation (\ref{e203}) is $1$, the right side is in the unit circle $\mathcal{U}$, that is \begin{equation*}\label{e204} (bx+d)^{2^m+2}=\lambda_0 \end{equation*} for some $\lambda_0\in \mathcal{U}$. But since $\textup{gcd}(2^m+2,2^{ m}+1)=1$, \begin{equation*}\label{e205} bx+d =\lambda \end{equation*} for some $\lambda\in \mathcal{U}$. Thus \begin{equation*}\label{e206} (bx+d)^{2^m+2}=\lambda^{2^m+2}=\lambda =bx+d. \end{equation*} And equation (\ref{e203}) can be rewritten as \begin{equation*}\label{e207} (x^{2^m}+x+\delta)^{2^m-1}=bx+d. \end{equation*} Since $\delta^{2^m}=\delta$, the left side of the above equation becomes \begin{equation*}\label{e207} {{x^{2^m}+x+\delta^{2^m}\over {x^{2^m}+x+\delta }}}=1. \end{equation*} So, we have $x={{d+1}\over b}$. Now, the above two situations can be summarized. For every element $b\in \mathbb{F}_{2^{2m}}$, if $b$ satisfies equation (\ref{e2033}), there are two possibilities for the values of $x$ as considered above. But $x={{d+1}\over b}$ is not the solution. For substituting it into equation (\ref{e203}), the left side becomes \begin{equation}\label{e208} ({{d^{2^m}}\over {b^{2^m}}}+{d\over b}+\delta +{{ 1}\over {b^{2^m}}}+{1\over b})^{2^m-1} =({{ 1}\over {b^{2^m}}}+{1\over b})^{2^m-1}=0 . \end{equation} It is not equal to the right side which now becomes $1$. If $d$ doesn't satisfy equation (\ref{e2033}), and if $x$ is a solution of equation (\ref{e203}), then $x^{2^m}+x+\delta \not=0$. The second situation tells us that the only solution is $x={{d+1}\over b}$. \end{IEEEproof} \begin{example} Set $ m=3,s=6$. Let $\delta \in \mathbb{F}_{2^3}$ be any element, and $b\in \mathbb{F}_{2^3}\backslash{\mathbb{F}_{2 }}$. Using Magma, it can be verified that \[ g(x)=(x^8+ x+\delta)^{57}+bx \] is a permutation polynomial over $\mathbb{F}_{2^6}$. \end{example} \subsection{PPs of type $x^{2^{m+1}}+b^{\prime}x^2+bx$ over $\mathbb{F}_{2^{2m}}$} In \cite[Proposition 8]{X01}, X. Xu {\sl et al.} proposed a class of permutation polynomials over $\mathbb{F}_{2^{4m}}$, of the form $(x^{2^m}-x+\delta)^{2^{3m}+2^{m}}+bx$, with $b\in \mathbb{F}_{2^{m}}^*$. In the following proposition, we consider a type of PPs over $ \mathbb{F}_{2^{2m}}$, of different form and different range of $b$. \begin{proposition}For the finite field $\mathbb{F}_{2^{2m}}$, let $b^{\prime}\in \mathcal{U} $ be in the unit circle, and $b\notin \mathbb{F}_{2^{ m}}$ satisfying $b^{2(2^m-1)}{b^{\prime} }^3=1$. Then the linearized polynomial \[ g(x)=x^{2^{m+1}}+b^{\prime}x^2+bx \] is a permutation polynomial of $\mathbb{F}_{2^{2m}}$. \end{proposition} \begin{IEEEproof} By the assumption, it can be checked that \begin{equation}\label{e23} b^{\prime}\not=b^{1-2^m}. \end{equation} Otherwise from $b^{2(2^m-1)}{b^{\prime} }^3=1$, we have $b^{ 2^m-1} =1$, contradiction with the condition that $b\notin \mathbb{F}_{2^{ m}}$. Since $g(x)$ is a linearzed polynomial, to verify that it is a permutation polynomial, it is necessary to check that \begin{equation}\label{e01} g(x)=x^{2^{m+1}}+b^{\prime}x^2+bx=0 \end{equation} has only the zero solution. There are two situations to be considered. First assume that $x\in \mathbb{F}_{2^{m}}^*$ is a solution of (\ref{e01}), then \begin{equation*}\label{e02} g(x)=x^{2^{m+1}}+b^{\prime}x^2+bx=x^2+b^{\prime}x^2+bx=0. \end{equation*} That is \begin{equation*}\label{e03} (1+b^{\prime})x+b=0. \end{equation*} If $b^{\prime}=1$, the above equation becomes $b=0$, contradicton. So, let us assume that $b^{\prime}\not=1$, then \begin{equation*}\label{e04} x={{b}\over{1+b^{\prime}}}. \end{equation*} But we have $x\in \mathbb{F}_{2^{m}}^*$, that is $x^{2^m}=x$, thus \begin{equation*}\label{e05} {{b^{2^m}}\over{1+{b^{\prime}}^{2^m}}}={{b}\over{1+b^{\prime}}}. \end{equation*} So, \begin{equation*}\label{e06} {{b^{2^m}b^{\prime}}\over{1+{b^{\prime}} }}={{b}\over{1+b^{\prime}}}, \end{equation*} which implies that \begin{equation*}\label{e07} b^{\prime}=b^{1-2^{m}}, \end{equation*} contradiction with equation (\ref{e23}). Second let us assume that $x\in \mathbb{F}_{2^{2m}}\backslash \mathbb{F}_{2^{m}}$, by Lemma \ref{l02}, we can write \begin{equation*}\label{e08} x=u\lambda \end{equation*}\label{e08} with $u\in \mathbb{F}_{2^{m}}^*$ and $\lambda\in \mathcal{U}.$ Substituting the above $x$ into equation (\ref{e01}), \begin{equation*}\label{e09} g(x)=x^{2^{m+1}}+b^{\prime}x^2+bx=u^2{1\over {\lambda^2}}+b^{\prime}u^2{\lambda^2}+bu\lambda=0. \end{equation*} That is \begin{equation}\label{e10} u{1\over {\lambda^2}}+b^{\prime}u{\lambda^2}+b\lambda=u({1\over {\lambda^2}}+b^{\prime}{\lambda^2})+b\lambda=0. \end{equation} If $\lambda^4={1\over {b^{\prime}}}= {b^{\prime}}^{2^m}$. The above equation becomes $b\lambda=0$, contradiction. So, $\lambda^4\not={1\over {b^{\prime}}}$, that is \begin{equation}\label{e24} {1\over {\lambda^2}}+b^{\prime} {\lambda^2}\not=0. \end{equation} Then from equation (\ref{e10}), \begin{equation*}\label{e11} u={{b\lambda}\over b^{\prime}{\lambda^2}+{1\over {\lambda^2}}}. \end{equation*} Since $u\in \mathbb{F}_{2^{m}}^*$, we have that $u^{2^m}=u$. The above equation becomes \begin{equation*}\label{eq12} \begin{array}{lll} {{b\lambda}\over b^{\prime}{\lambda^2}+{1\over {\lambda^2}}}&=&{{b^{2^m}\lambda^{2^m}}\over {b^{\prime}}^{2^m}{\lambda^{2^{m+1}}}+{1\over {\lambda^{2^{m+1}}}}}\\ &=& {{b^{2^m}{1\over {\lambda}}}\over {b^{\prime}}^{2^m}{1\over {\lambda^2}}+{\lambda^2}}. \end{array} \end{equation*} That is \begin{equation*}\label{eq13} {{b\lambda^3}\over b^{\prime}{\lambda^4}+1}= {{b^{2^m}{ {\lambda}}}\over {b^{\prime}}^{2^m} +{\lambda^4}} \Longleftrightarrow {{b\lambda^2}\over b^{\prime}{\lambda^4}+1}= {{b^{2^m}{ }}\over {b^{\prime}}^{2^m} +{\lambda^4}}, \end{equation*} which can be rewritten as \begin{equation}\label{eq14} b\lambda^6+b{b^{\prime}}^{2^m}\lambda^2=b^{\prime}b^{2^m}{\lambda^4}+b^{2^m} \Longleftrightarrow \lambda^6+b^{\prime}b^{2^m-1}{\lambda^4}+ {b^{\prime}}^{2^m}\lambda^2+b^{2^m-1} =0. \end{equation} Let $\lambda_0=\lambda^2$, equation (\ref{eq14}) can be transformed into \begin{equation}\label{e15} \lambda_0^3+b^{\prime}b^{2^m-1}{\lambda_0^2}+ {b^{\prime}}^{2^m}\lambda_0+b^{2^m-1} =0. \end{equation} Take derivative of the above equation \begin{equation*}\label{eq16} \lambda_0^2+ {b^{\prime}}^{2^m } =0. \end{equation*} Substituting $\lambda_0^2= {b^{\prime}}^{2^m }$ into equation (\ref{e15}) \begin{equation*}\label{e17} {b^{\prime}}^{2^m}\lambda_0+ {b^{\prime}}^{2^m+1}b^{2^m-1} + {b^{\prime}}^{2^m}\lambda_0+b^{2^m-1} =b^{2^m-1}+b^{2^m-1}=0. \end{equation*} That is $\lambda_0= {b^{\prime}}^{2^{m-1} }$ is a double root of (\ref{e15}), which has three roots at most counting multiplicity. But, \begin{equation*}\label{eq18} \lambda^4=\lambda_0^2= {b^{\prime}}^{2^m } \end{equation*} contradiction with equation (\ref{e24}). The third root of (\ref{e15}) is \begin{equation*}\label{eq20} \lambda_1={b^{2^m-1}\over {b^{\prime}}^{2^m } }=b^{2^m-1}b^{\prime}. \end{equation*} So \begin{equation*}\label{eq21} \lambda^2= \lambda_1=b^{2^m-1}b^{\prime} \Longleftrightarrow \lambda^4=b^{2(2^m-1)}{b^{\prime} }^2. \end{equation*} And equation (\ref{e10}) becomes \begin{equation*}\label{e22} u({{1 +b^{\prime}{\lambda^4}}\over {\lambda^2}})+b\lambda=u({{1+b^{2(2^m-1)}{b^{\prime} }^3 }\over {\lambda^2}})+b\lambda=b\lambda=0 \end{equation*} by assumption, contradiction. \end{IEEEproof} \begin{example} Set $ m=4$. Let $b^{\prime} \in \mathcal{U}$ be any element of the unit circle in $\mathbb{F}_{2^8}\backslash\mathbb{F}_{2^4}$, $b\in \mathbb{F}_{2^8}\backslash{\mathbb{F}_{2^4}}$ satisfying $b^{30}{b^{\prime} }^3=1$. Using Magma, it can be verified that \[ g(x)=x^{32}+b^{\prime}x^2+bx \] is a permutation polynomial over $\mathbb{F}_{2^8}$. \end{example} \subsection{PPs of type $x^r(x^{q-1}+a)$ over $\mathbb{F}_{q^{e}}$} In \cite[Theorem 1]{L03}, K. Li {\sl et al.} studied a class of permutation polynomials of the form $x^r(x^{q-1}+a)$ over $\mathbb{F}_{q^{2}}$, necessary and sufficient conditions are given. In the following proposition, we consider the same kind of PPs, but over different field $ \mathbb{F}_{q^{e}}$, with two particular values of $r$. \begin{proposition} Let $\mathbb{F}_{q}$ be the finite field with $q$ elements, then \[ g(x)=x^r(x^{q-1}+a) \] is a permutation polynomial over $\mathbb{F}_{q^e}$ for $r=1, q^{e-1}+q^{e-2}+\cdots+q^2+1$. Here $a\in \mathbb{F}_{q^e}^*$ satisfying $a^{q^{e-1}+q^{e-2}+\cdots+q+1}\not=(-1)^e$, and \textup{gcd}(e-1,q-1)=1. \end{proposition} \begin{IEEEproof} First, we consider the case $r=1$. Then \begin{equation*}\label{e601} g(x)=x^q+ax, \end{equation*} which is a linearized polynomial. Since $a\in \mathbb{F}_{q^e}^*$, and $a^{q^{e-1}+q^{e-2}+\cdots+q+1}\not=(-1)^e$, it is a PP over $\mathbb{F}_{q^e}$. Second, let us consider the case $r=q^{e-1}+q^{e-2}+\cdots+q^2+1$. We found that $d=q^{e-1}+q^{e-2}+\cdots+q+1$ in Lemma \ref{l01}, and $h(x)=x+a$. Thus, $g(x)$ is a permutation polynomial if and only if \begin{equation*}\label{e602} \textup{gcd}(r,q-1)=\textup{gcd}(q^{e-1}+q^{e-2}+\cdots+q^2+1,q-1)=\textup{gcd}(e-1,q-1)=1, \end{equation*} and \begin{equation}\label{e603} x^r(x+a)^{q-1} \end{equation} permutes $\mu_d$, the $d\textup{th}$ roots of unity in $\mathbb{F}_{q^e}$. Then equation (\ref{e603}) becomes \begin{equation}\label{e604} x^{-q}(x+a)^{q-1} \end{equation} on $\mu_d$. Since $\textup{gcd}(-q,q-1)=1$, using Lemma \ref{l01} again, equation (\ref{e604}) permutes $\mu_d$ if and only if \begin{equation}\label{e605} x^{-q}(x^{q-1}+a) \end{equation} is a permutation polynomial of $\mathbb{F}_{q^e}$. Now, equation (\ref{e605}) can be rewritten as \begin{equation*}\label{e606} x^{-1}+ax^{-q}, \end{equation*} which is a permutation polynomial of $\mathbb{F}_{q^e}$, since it is linearized if writing $y=x^{-1}$, and $a^{q^{e-1}+q^{e-2}+\cdots+q+1}\not=(-1)^e$. \end{IEEEproof} \begin{example} Let $q=5,e=4,$, and $\omega$ be a primitive root of the finite field $\mathbb{F}_{5^4}$, then $r=1, q^3+q^2+1=151$. Using Magma, it can be verified that for $a=w^i$, with $1\leq i\leq 623, i\not=0 \ \textup{mod}\ 4$, \[ g(x)=x^{r}(x^{4}+a) \] is a permutation polynomial over $\mathbb{F}_{5^4}$. \end{example} \section{Necessities of two kinds of permutation polynomials}\label{SecIII} In this section, we investigate the necessities of two classes of permutation polynomials studied in \cite{X01}, where the sufficient conditions are given. \subsection{PPs of type $(x^{2^m}+x+\delta)^{2^{2m-1}+2^{m-1}}+bx$ over $\mathbb{F}_{2^{2m}}$} In \cite[Proposition 10]{X01}, X. Xu {\sl et al.} proposed a class of permutation polynomials of the form $(x^{2^m}+x+\delta)^{2^{2m-1}+2^{m-1}}+bx$ over $\mathbb{F}_{2^{2m}}$, and sufficient conditions are given. In the following proposition, we consider the same kind of PPs, but its necessary conditions. \begin{proposition} For a positive integer $m$ and a fixed $\delta \in \mathbb{F}_{2^{2m}}$ with $\textup{Tr}_m^{2m}(\delta)\not= 0$, let \[ g(x)=(x^{2^m}+x+\delta)^{2^{2m-1}+2^{m-1}}+bx \] where $b\in \mathbb{F}_{2^{2m}}$. When $b\notin \mathbb{F}_{2^{m}}$, $g(x)$ is permutation polynomial if and only if $b+b^m=b^{2^m+1}$. \end{proposition} \begin{IEEEproof} As pointed out at the beginning of this subsection, \cite[Proposition 10]{X01} gives the sufficiency verification. Now let us consider the necessity. Assume that $g(x)$ is a permuatation polynomial. Then for every $d\in \mathbb{F}_{2^{2m}}$, $g(x)=d$ has a unique solution. That is \begin{equation*}\label{e401} (x^{2^m}+x+\delta )^{2^{2m-1}+2^{m-1}}+ bx=d \end{equation*} has at most one possibile root in $ \mathbb{F}_{2^{2m}}$. Squaring both sides of the above equation, we get the following equivalent equation \begin{equation*}\label{e402} (x^{2m}+x+\delta )^{2^{2m }+2^{m }}+ b^2x^2=d^2. \end{equation*} That is \begin{equation*}\label{e403} (x^{2^m}+x+\delta )(x^{2^m}+x+\delta^{2^m} )= b^2x^2+d^2, \end{equation*} which can be transformed into \begin{equation*}\label{e404} (x^{2^m}+x )^2+( \delta+\delta^{2^m} )(x^{2^m}+x)+\delta^{2^m+1}= b^2x^2+d^2. \end{equation*} Which implies that \begin{equation}\label{e405} x^{2^{m+1}}+ ( \delta+\delta^{2^m} )x^{2^m} +(b^2+1)x^2+ ( \delta+\delta^{2^m} )x +\delta^{2^m+1}+d^2=0 \end{equation} has a unique solution in $ \mathbb{F}_{2^{2m}}$. Then for $x_1\not= x_2 \in \mathbb{F}_{2^{2m}}$ with $x_1$ a solution of equation (\ref{e405}), the following equation \begin{equation*}\label{e406} x_2^{2^{m+1}}+ ( \delta+\delta^{2^m} )x_2^{2^m} +(b^2+1)x_2^2+ ( \delta+\delta^{2^m} )x_2 +\delta^{2^m+1}+d^2=0 \end{equation*} can not hold. Adding the above two equations, \begin{equation}\label{e407} (x_1+x_2)^{2^{m+1}}+ ( \delta+\delta^{2^m} )(x_1+x_2)^{2^m} +(b^2+1)(x_1+x_2)^2+ ( \delta+\delta^{2^m} )(x_1+x_2) =0 \end{equation} does not hold for any $x_2$ different from $x_1$. Now let $y=x_1+x_2$. With $x_1$ fixed and $x_2$ varying, $y$ can be any nonzero element of the finite field $ \mathbb{F}_{2^{2m}}$. So, \begin{equation}\label{e408} y^{2^{m+1}}+ ( \delta+\delta^{2^m} )y^{2^m} +(b^2+1)y^2+ ( \delta+\delta^{2^m} )y =0 \end{equation} has only the solution zero in $ \mathbb{F}_{2^{2m}}$, this is from the assumption that $g(x)$ is a permutation polynomial. If a nonzero solution $y\in \mathbb{F}_{2^{2m}} $ of equation (\ref{e408}) exists. Taking the $2^{m}\textup{th}$ power, \begin{equation}\label{e409} y^{2 }+ ( \delta+\delta^{2^m} )y +(b^{2^{m+1}}+1)y^{2^{m+1}}+ ( \delta+\delta^{2^m} )y^{2^m} =0. \end{equation} Adding equations (\ref{e408}) and (\ref{e409}), \begin{equation*}\label{e410} b^{2^{m+1}}y^{2^{m+1}}+b^2y^2 =(b^2y^2 )^{2^m}+(b^2y^2 )=0. \end{equation*} Thus \begin{equation*}\label{e411} (by )^{2^m}+(by )=0, \end{equation*} that is $by$ lies in the field $ \mathbb{F}_{2^{m}}$. By Lemma \ref{l02}, we can write \begin{equation}\label{e412} b={c_0\over \lambda_0 } \end{equation} for some fixed $c_0\in \mathbb{F}_{2^{m}}\backslash{\{0\}}$, and $\lambda_0 \in \mathcal{U}$ the unit circle. If $y$ is written in the following form \[ y=c\lambda \] for $c\in \mathbb{F}_{2^m}$ and $\lambda \in \mathcal{U}$. Since $by\in \mathbb{F}_{2^{m}}$, we must have $\lambda=\lambda_0$. That is \begin{equation}\label{e413} y=c\lambda_0 \end{equation} for some $c\in \mathbb{F}_{2^m}\backslash{\{0\}}$. Substituting (\ref{e412}) and (\ref{e413}) into equation (\ref{e408}) \begin{equation*}\label{e414} {c^2\over \lambda_0^2}+( \delta+\delta^{2^m} ){c \over \lambda_0 } +( {c_0^2\over \lambda_0^2}+1)c^2\lambda_0^2+ ( \delta+\delta^{2^m} )c\lambda_0 =0. \end{equation*} Dividing $c$ on both sides of the above equation \begin{equation*}\label{e415} {c \over \lambda_0^2}+( \delta+\delta^{2^m} ){1\over \lambda_0 } +( {c_0^2\over \lambda_0^2}+1)c \lambda_0^2+ ( \delta+\delta^{2^m} ) \lambda_0 =0, \end{equation*} which can be transformed into \begin{equation*}\label{e416} ( {c_0^2 }+\lambda_0^2+{1\over \lambda_0^2})c =( \delta+\delta^{2^m} ){1\over \lambda_0 } + ( \delta+\delta^{2^m} ) \lambda_0. \end{equation*} By our assumption, equation (\ref{e408}) has no nonzero solution, then \begin{equation*}\label{e417} {c_0^2 }+\lambda_0^2+{1\over \lambda_0^2}=0, \end{equation*} which is equivalent to \begin{equation*}\label{e418} {c_0 }=\lambda_0 +{1\over \lambda_0 } \end{equation*} for some $\lambda_0\not=1$ in $\mathcal{U}$, because $b\notin \mathbb{F}_{2^{m}}$. By equation (\ref{e412}), \begin{equation*}\label{e419} b=1+{1\over \lambda_0^2 }. \end{equation*} That is, \begin{equation*}\label{e420} b=1+{1\over \lambda } \end{equation*} for some $\lambda\in \mathcal{U}\backslash{\{1\}}$. So, we have \begin{equation*}\label{e421} b^{2^m+1}=(1+{1\over \lambda })(1+{ \lambda })={1\over \lambda }+\lambda. \end{equation*} And \begin{equation*}\label{e422} b^{2^m }+b=(1+{ \lambda })+(1+{1\over \lambda })={1\over \lambda }+\lambda. \end{equation*} Which implies that \begin{equation*}\label{e422} b^{2^m }+b=b^{2^m+1}, \end{equation*} that is the necessity of our proposition. \end{IEEEproof} \begin{example} Let $ m=4$, $\delta \in \mathbb{F}_{2^8}$ with $\textup{Tr}_m^{2m}(\delta)\not=0$. Using Magma, it can be verified that for $b\in \mathbb{F}_{2^8}\backslash{\mathbb{F}_{2^4}}$, \[ g(x)=(x^{16}+x+\delta)^{136}+bx \] is not a permutation polynomial over $\mathbb{F}_{2^8}$ when $b^{16}+b\not=b^{17}$. \end{example} \subsection{PPs of type $(x^2+x+\delta)^{2^{2k-1}-2^{k-1}}+bx$ over $\mathbb{F}_{2^{2k}}$} In \cite[Proposition 6]{X01}, X. Xu {\sl et al.} proposed a class of permutation polynomials of the form $(x^{2 }+x+\delta)^{2^{2k-1}-2^{k-1}}+bx$ over $\mathbb{F}_{2^{2k}}$, and sufficient conditions are given. In the following proposition, we consider the same kind of PPs, but its necessary conditions. \begin{proposition} For nonnegative integers $n,k$ with $n=2k, k>1$, let $\delta \in \mathbb{F}_{2^n}$ with $\textup{Tr}_1^n(\delta)=1$. Then the polynomial \[ g(x)=(x^2+x+\delta)^{2^{2k-1}-2^{k-1}}+bx \] is a permutation of $\mathbb{F}_{2^n}$ if and only if $b\in \mathbb{F}_{2^k}\backslash{\{0\}}$. \end{proposition} \begin{IEEEproof} The sufficiency is given in \cite[Proposition 6]{X01}. In the following we only consider the necessity. Assume that $b\notin \mathbb{F}_{2^k}$, and $g(x)$ is a PP. Since $\textup{Tr}_1^n(\delta)=1$, $x^2+x+\delta$ is always nonzero by Lemma \ref{l03}. For any $d\in \mathbb{F}_{2^n}$, the following equation \begin{equation*}\label{e501} (x^2+x+\delta)^{2^{2k-1}-2^{k-1}}+bx=d \end{equation*} has only one solution, which can be transformed into \begin{equation}\label{e504} (x^2+x+\delta)^{2^{2k-1}-2^{k-1}}=bx+d. \end{equation} Taking the $(2^k+1)\textup{th}$ power on both sides of the above equation \begin{equation*}\label{e502} 1=(bx+d)^{2^k+1}. \end{equation*} So, $bx+d=\lambda$, that is \begin{equation}\label{e506} x={{\lambda+d}\over b} \end{equation} for some element $\lambda$ in the unit circle $\mathcal{U}$. Squaring both sides of equation (\ref{e504}) \begin{equation}\label{e503} (x^2+x+\delta)^{1-2^{k }}= (bx+d)^2. \end{equation} That is \begin{equation*}\label{e505} {{x^2+x+\delta}\over {x^{2^{k+1}}+x^{2^k}+\delta^{2^k}} } = \lambda^2, \end{equation*} which is equivalent to \begin{equation*}\label{e507} {{x^2+x+\delta} }= \lambda^2(x^{2^{k+1}}+x^{2^k}+\delta^{2^k} ). \end{equation*} Substituting (\ref{e506}) into the above equation, \begin{equation}\label{e508} ({1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k})\lambda^2 +({1\over b}+{1\over b^{2^k}})\lambda +{{d^2\over b^2}+{d\over b}+{1\over b^{2^{k+1}}}}+\delta=0. \end{equation} We can choose $d$ such that \begin{equation*}\label{e509} {1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}\not=0. \end{equation*} Since $g(x)$ is a permutation polynomial, there must exists $\lambda_1$ in the unit circle $\mathcal{U}$, satisfying equation (\ref{e508}). Then \begin{equation*}\label{e510} x_1={{\lambda_1+d}\over b} \end{equation*} satisfies equation (\ref{e503}), and in fact $g(x)=d$, since they are equivalent. Equation (\ref{e508}) can be transformed into \begin{equation*}\label{e511} \lambda^2 +{{{1\over b}+{1\over b^{2^k}}}\over {{1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}}}\lambda +{ ({{1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}})^{2^k}\over {{1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}}}=0. \end{equation*} Since ${ ({{1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}})^{2^k}\over {{1\over b^{2}}+{d^{2^{k+1}}\over b^{2^{k+1}}}+{d^{2^{k }}\over b^{2^{k }}}+\delta^{2^k}}} $ is in the unit circle, the other root of equation (\ref{e508}), which we denote $\lambda_2$, is also in the unit circle $\mathcal{U}$. And \[ \lambda_1\not=\lambda_2, \] since $\lambda_1+\lambda_2={1\over b}+{1\over b^{2^k}}\not=0$ for $b\notin \mathbb{F}_{2^k}$. Now, for equation (\ref{e506}), set \begin{equation*}\label{e512} x_2={{\lambda_2+d}\over b}. \end{equation*} Then $x_2$ satisfies equation (\ref{e503}) also, that is $g(x)=d$ has two solutions $x_1,x_2$ for such $d$, contradiction. \end{IEEEproof} \begin{example} Set $k=4$, then $n=8$. Let $\delta \in \mathbb{F}_{2^n}$ with $\textup{Tr}(\delta)=1$. Using Magma, it can be verified that for $b\in \mathbb{F}_{2^n}\backslash{\mathbb{F}_{2^k}}$, \[ g(x)=(x^2+x+\delta)^{120}+bx \] is not a permutation polynomial over $\mathbb{F}_{2^8}$. \end{example} \section{Conclusion} In this paper, we construct some classes of permutation polynomials over finite fields, which are modifications of known permutation polynomials recently studied. We also investigate the necessities of permutation properties of the polynomials studied in \cite{X01}, where the sufficient conditions are given. \section*{Acknowledgment} The author would like to thank the anonymous referees for helpful suggestions and comments.
{'timestamp': '2019-06-18T02:04:13', 'yymm': '1906', 'arxiv_id': '1906.06453', 'language': 'en', 'url': 'https://arxiv.org/abs/1906.06453'}
arxiv