\documentclass{segabs}
\usepackage{mathrsfs,amsmath,url,xspace}

% An example of defining macros
\newcommand{\rs}[1]{\mathstrut\mbox{\scriptsize\rm #1}}
\newcommand{\rr}[1]{\mbox{\rm #1}}
% My equations
%-----------------------------------------------------------
\renewcommand{\div}{\nabla\cdot}
\newcommand{\grad}{\vec \nabla}
\newcommand{\curl}{{\vec \nabla}\times}
\renewcommand{\H}{{\vec H}}
\newcommand {\J}{{\vec J}}
\newcommand {\E}{{\vec E}}
\newcommand{\siginf}{\sigma_\infty}
\newcommand{\dsig}{\triangle\sigma}
\newcommand{\dcurl}{{\mathbf C}}
\newcommand{\dgrad}{{\mathbf G}}
\newcommand{\Acf}{{\mathbf A_c^f}}
\newcommand{\Ace}{{\mathbf A_c^e}}
\renewcommand{\S}{{\mathbf \Sigma}}
\newcommand{\St}{{\mathbf \Sigma_\tau}}
\newcommand{\T}{{\mathbf T}}
\newcommand{\Tt}{{\mathbf T_\tau}}
\newcommand{\diag}{\mathbf{diag}}
\newcommand{\M}{{\mathbf M}}
\newcommand{\MfMui}{{\M^f_{\mu^{-1}}}}
\newcommand{\MfMuoi}{{\M^f_{\mu_0^{-1}}}}
\newcommand{\dMfMuI}{{d_m (\M^f_{\mu^{-1}})^{-1}}}
\newcommand{\dMfMuoI}{{d_m (\M^f_{\mu_0^{-1}})^{-1}}}
\newcommand{\MeSig}{{\M^e_\sigma}}
\newcommand{\MeSigInf}{{\M^e_{\sigma_\infty}}}
\newcommand{\MeSigInfEtab}{{\M^e_{\sigma_\infty \bar{\eta}}}}
\newcommand{\MeSigInfEtat}{{\M^e_{\sigma_\infty \peta}}}
\newcommand{\MedSig}{{\M^e_{\triangle\sigma}}}
\newcommand{\MeSigO}{{\M^e_{\sigma_0}}}
\newcommand{\Me}{{\M^e}}
\newcommand{\Js}{\mathbf{J}^s}
\newcommand{\Mes}[1]{{\M^e_{#1}}}
\newcommand{\Mee}{{\M^e_e}}
\newcommand{\Mej}{{\M^e_j}}
\newcommand{\BigO}[1]{\mathcal{O}\bigl(#1\bigr)}
\newcommand{\bE}{\mathbf{E}}
\newcommand{\bEp}{\mathbf{E}^p}
\newcommand{\bB}{\mathbf{B}}
\newcommand{\bBp}{\mathbf{B}^p}
\newcommand{\bEs}{\mathbf{E}^s}
\newcommand{\bBs}{\mathbf{B}^s}
\newcommand{\bH}{\mathbf{H}}
\newcommand{\B}{\vec{B}}
\newcommand{\D}{\vec{D}}
\renewcommand{\H}{\vec{H}}
\newcommand{\s}{\vec{s}}
\newcommand{\bfJ}{\bf{J}}
\newcommand{\vecm}{\vec m}
\renewcommand{\Re}{\mathsf{Re}}
\renewcommand{\Im}{\mathsf{Im}}
\renewcommand {\j}  { {\vec j} }
\newcommand {\h}  { {\vec h} }
\renewcommand {\b}  { {\vec b} }
\newcommand {\e}  { {\vec e} }
\renewcommand {\d}  { {\vec d} }
\renewcommand {\u}  { {\vec u} }

\renewcommand {\dj}  { {\mathbf{j} } }
\renewcommand {\dh}  { {\mathbf{h} } }
\newcommand {\db}  { {\mathbf{b} } }
\newcommand {\de}  { {\mathbf{e} } }

\newcommand{\vol}{\mathbf{v}}
\newcommand{\I}{\vec{I}}
\newcommand{\A}{\mathbf{A}}
\newcommand{\bI}{\mathbf{I}}
\newcommand{\bus}{\mathbf{u}^s}
\newcommand{\brhss}{\mathbf{rhs}_s}
\newcommand{\bup}{\mathbf{u}^p}
\newcommand{\brhs}{\mathbf{rhs}}
%%-------------------------------
\newcommand{\bon}{b^{on}(t)}
\newcommand{\bp}{b^{p}}
\newcommand{\dbondt}{\frac{db^{on}(t)}{dt}}
\newcommand{\dfdt}{\frac{df(t)}{dt}}
\newcommand{\dbdt}{\frac{\partial \b}{\partial t}}
\newcommand{\dfdtdsiginf}{\frac{\partial\frac{df(t)}{dt}}{\partial\siginf}}
\newcommand{\dfdsiginf}{\frac{\partial f(t)}{\partial\siginf}}
\newcommand{\dbgdsiginf}{\frac{\partial b^{Impulse}(t)}{\partial\siginf}}
\newcommand{\digint}{\frac{2}{\pi}\int_0^{\infty}}
\newcommand{\Gbiot}{\mathbf{G}_{Biot}}
%%-------------------------------
\newcommand{\peta}{\tilde{\eta}}
\newcommand{\petadt}{\frac{\partial \tilde{\eta}}{\partial t}}
\newcommand{\eFmax}{\e^{F}_{max}}
\newcommand{\dip}{d^{IP}}
\newcommand{\sigpert}{\delta\sigma}

\newcommand{\SimPEG}{\textsc{SimPEG}\xspace}
\newcommand{\simpegEM}{\textsc{simpegEM}\xspace}

\begin{document}

\title{Moving between dimensions in electromagnetic inversions}

\renewcommand{\thefootnote}{\fnsymbol{footnote}}

\author{Seogi Kang\footnotemark[1], Rowan Cockett, Lindsey J. Heagy, \& Douglas W. Oldenburg, Geophysical Inversion Facility, University of British Columbia}

\footer{Example}
\lefthead{Kang et al.}
\righthead{Moving between dimensions in EM inversions}

\maketitle
\begin{abstract}
Electromagnetic (EM) methods are used to characterize the electrical conductivity distribution of the earth. Recently, due in part to computational advances, EM geophysical surveys are increasingly being simulated and inverted in 3D. However, the availability of computational resources does not invalidate the use of lower dimensional formulations and methods, which can be useful depending on the geological complexity as well as the survey geometry. For example, a progressive procedure can be used to invert EM data, starting with 1D inversion, then moving to multi-dimensional inversions. As such, we require a set of tools that allow a geophysicists to easily move between dimensions of the EM problem. In this study, we suggest a mapping function, which transforms the inversion model to physical property model for forward modeling. Using this general framework, we apply EM inversion with a suite of models from 1D to 3D and suggests the importance of choosing a proper model based on the task you have in the EM inversion.
\end{abstract}
\renewcommand{\figdir}{Fig} % figure directory
% In this presentation, we will share examples as well as our experience from creating a range of simulation and inversion tools for EM methods that span dimensions (1D, 2D and 3D). The flexibility and consistency in our EM package allows us to be methodical so that we have the capacity to tackle a spectrum of problems in EM geophysics.
% This is the motivation behind the open source software package \simpegEM which is part of a software ecosystem for Simulation and Parameter Estimation in Geophysics (\SimPEG).
\section{Introduction}
Using electromagnetic (EM) waves, we excite the earth and measure signals from the earth.
This signal includes conductivity distribution of the earth. By solving Maxwell's
equations, we can compute forward response of the system with known conductivity
distribution.
Using the EM inversion technique, we recover a conductivity model, which explains the
measured EM response.
This model can be discretized voxel of the 3D conductivity.
To proceed this 3D inversion, we need to compute forward response from the 3D earth.
Therefore a natural choice of the inversion model can be 3D distribution of the conductivity.
Recently, 3D EM inversion technique using gradient based optimiztion has actively been
developed and interrogated on various applications (\cite{Doug2013,Gribenko2007,Chung2014}).

The gradient based geophysical inversion technique includes several pieces in general:
uncertainty, data misfit, sensitivity, model and regularization.
Our focus in this paper is the inversion model.
In most cases, the inversion model has been considered as 3D distribution of the conductivity.
However, our model can be more general. For example, let us assume we have 3D conductivity
model for sewatuer intrusion as shown in Figure ~\ref{fig:mapping123D}.
Although physical property model can be in 3D, inversion model can be either 1D or 2D
as shown in Figure ~\ref{fig:mapping123D}.
Realization of this is possible using model mapping function, which can be defined as
\begin{equation}
  \sigma  = \mathcal{M}[m],
\end{equation}
where $\sigma$ is the electrical conductivity (S/m). This mapping function
($\mathcal{M}[\cdot]$) transforms the space from the inversion model to physical property
model. Moving our spatial dimensions from 1D to 3D or 2D to 3D can be possible using this
mapping function. On top of that, we can use a geometric function like sphere or
ellipsoid to parameterize 3D structure with few parameters (\cite{MikeParam2014}).
Implementation of this is done through \simpegEM which is part of a software ecosystem
for Simulation and Parameter Estimation in Geophysics (\cite{SimPEG}).
\simpegEM provides forward and inverse problem of EM methods in both frequency and time domain (\cite{SimPEGEM}).

In this study, we exploit seawater intrusion problem with ground loop EM survey to visit
suite of model spaces that we can use in the EM inversion. We use time domain EM (TEM)
methods. To setup a survey design, we use 1D seawater intrusion model and perform feasibility test. Based on this, we compute forward response from 3D seawater intrusion
model. 1D stitched and 2D inversion to a line profile data are going to be applied to
restore the 2D conductivity model. Using multiple line profile data, we perform 3D EM
inversion to restore 3D conductivity model. Based on the knowledge from 1D 2D and 3D inversion, parameterization of seawater intrusion model with arbitrary geometric function
is possible, and this may allow us to answer specialized question like ``where is the
interface between seawater and freshwater''.

\plot{mapping123D}{width=0.8\columnwidth}
{Conceptual diagram of 1D, 2D and 3D models for the seawater intrusion problem.}

\section*{Methodology}
EM inversion is gearing towards recovering a model, which explains measured response. EM response is governed by Maxwell's equations.  In time domain we have
\begin{equation}
  \curl \e = -\dbdt,
\end{equation}
\begin{equation}
  \curl \mu^{-1}\b -\sigma \e = \j_s,
\end{equation}
where $\e$ is electrical field, $\b$ is magnetic flux density, $\j_s$ is the source term, $\sigma$ is conductivity and $\mu$ is magnetic susceptibility.
% \begin{equation}
%   \curl \E = -\imath \omega \B,
% \end{equation}
% \begin{equation}
%   \curl \mu^{-1}\B -\sigma \E = \J_s.
% \end{equation}
We consider electrical conductivity ($\sigma$) as a physical model that we want to recover from the EM inversion, and this can be 3D distribution: $\sigma(x, y, z)$. We excite the earth by putting time varying current through source term: $\j_s$, and measure EM response form the earth on receiver locations. By discretizing above Maxwell's equations for both TD and FD, we can compute forward response, which can be simply written as
\begin{equation}
  d^{pre} = F[\sigma],
\end{equation}
where $F[\cdot]$ is Maxwell's operator and $d^{pre}$ is computed EM response on receiver locations for corresponding source.
A major goal of EM survey is to recover distribution of the conductivity. To achieve this goal, we use geophysical inversion technique based on gradient based optimization. Objective function of the inversion can be written as
\begin{equation}
  \phi(m) = \phi_d(m) + \beta\phi_m(m),
\end{equation}
where $\phi$ is the objective function, $\phi_d=\frac{1}{2}\|d^{pred}-d^{obs}\|^2_2$ is data misfit, $\phi_m$ is regularization term, $\beta$ is trade-off term between $\phi_d$ and $\phi_m$, and $m$ is the inversion model. Recalling we defined model mapping function: $\sigma = \mathcal{M}[m]$, we can transform the inversion model to conductivity in 3D. The core of the gradient based optimization is the sensitivity function:
\begin{equation}
  J = \frac{\partial F[\sigma]}{\partial m} = \frac{\partial d^{pred}}{\partial \sigma}\frac{\partial \sigma}{\partial m}.
\end{equation}
Assuming that we know how to compute $\frac{\partial F[\sigma]}{\partial \sigma}$, we can proceed EM inversion with the knowledge of derivative of the mapping function($\frac{\partial \sigma}{\partial m} = \frac{\partial \mathcal{M}(m)}{\partial m}$).
This mapping does not necessarily has to be a single function, but can be a combination of multiple functions, and computation of derivative can be defined using chain-rule. For example, conventionally in EM inversion, we use logarithmic conductivity ($m = log(\sigma)$) as our model, and we do not include air cells in our forward modeling domain. Therefore, in this case, our mapping can be expressed as a combination of two different maps:
\begin{equation}
  \sigma = \mathcal{M}_{exp}[\mathcal{M}_{active}[m]],
  \label{eq:combomap1}
\end{equation}
where $\mathcal{M}_{exp}[m]=exp(m)$ is exponential map and $\mathcal{M}_{active}[m]$ is active map. Here, the active maps transforms our model parameter, which is only defined inside of the earth:
\begin{equation}
  \sigma = \mathcal{M}_{active}[m] = Q_{active}m + m_{inactive},
\end{equation}
where $Q_{active}$ is a mapping matrix composed of 0 and 1, which maps active cells to entire cells in the domain. $m_{inactive}$ is a model for inactive cells, and this has same dimension with entire cells. Computating the derivative of mapping $w.r.t$ $m$ for these maps are straightforward. Similarly, we can have 1D or 2D maps ($\mathcal{M}_{1D}[m]$ and $\mathcal{M}_{2D}[m]$), which take 1D or 2D model and transform to 3D model. Therfore combined model with equation (\ref{eq:combomap1}), can be written as
\begin{equation}
  \sigma = \mathcal{M}_{exp}[\mathcal{M}_{1D \ or \ 2D}[\mathcal{M}_{active}[m]]].
  \label{eq:combomap2}
\end{equation}
For this case, with 1D map in vertical direction, our model can be logarithmic conductivity of subsurface layers, but the output of the combined map is 3D conductivity of the earth including air cells. Implementation of a geometircal model such as ellipsoid and arbitrary plane to the inversion is straightforward, once we have knowledge to evaluate mapping function and its derivative.

\section*{Seawater intrusion example}
In coastal area, seawater intrusion is a serious problem due to the contamination of groundwater (Figure \ref{fig:concept}). One of the key to treat this problem is to recognizing the distribution of highly saturated zone by seawater. Ground loop EM survey has been used to detect intruded seawater, because of highly conductive nature of the seawater (\cite{Mills1988}). Figure \ref{fig:concept} shows typical ground loop TEM survey geometry and hydorological model on coastal area. By putting time-varying current through the transmitter loop, we excite the earth. We use EM induction phenomenon to excite the earth in this case, which is highly sensitive to conductive structure. 3D conductivity model shown in Figure \ref{fig:sigtrue} clearly shows intruded seawater distribution in 3D. As a geophyscist, we may want to suggest possible region where we have serious seawater intrusion. Therefore, recovering conductivity distribution, which has high correlation with seawater saturation is a principal task. More specifically, interface between freshwater and seawater is an important information.
\plot{concept}{width=0.8\columnwidth}
{Conceptual diagram of sea water intrusion and geometry of ground loop EM survey.}

\plot{sigtrue}{width=1.0\columnwidth}
{Plan and section views of 3D conductivity model for seawater intrusion.}

\subsection*{Feasibility test: anomalous response}
To measure EM response from the intruded seawater, we need to design a proper survey parameter. Figure \ref{fig:geometry} shows survey geometry of ground loop EM survey. We have two circular loops, which has 250 m radius. We use simple layered earth model (1D) to make this analyses simple. Because ground loop source is circular thus, survey parameters are distance from the center of the loop ($r$) and time. We compute two forward responses due to the layered model with seawater layer and without seawater layer, and compute amplitude ratio between them. This 1D model is shown in the right panel of Figure \ref{fig:ampratio_time}. Because we measure vertical component of magnetic flux density ($b_z$), amplitude ratio that we compute can be written as $\Big|\frac{b_z[\sigma_{seawater}]|}{b_z[\sigma_{background}]}\Big|$. In the right panel of Figure \ref{fig:ampratio_time}, we provide amplitude ratio in 2D plane of which axes are time and $r$. Contours on high amplitude ratios clearly shows measured response at time range 1-10 ms are sensitive to the seawater. At the center of the loop ($r$=0), we have maximum ratio, and it decreases $r$ increases. Based on this feasibility test, we designed ground loop EM survey geometry as shown in Figure \ref{fig:geometry}, and the time range we measure EM response is 0.1-10 ms.

\plot{geometry}{width=0.8\columnwidth}
{Ground loop EM survey geometry. Blue and red color indicate corresponding Tx and Rx pairs. Black dots show a line profile data used for 1D and 2D inversion. }

\plot{ampratio_time}{width=1.0\columnwidth}
{Layered-earth model for seawater intrusion (left panel). Amplitude ratio of vertical magnetic flux density with seawater and without seawater (right panel).}

\subsection*{1D and 2D inversion}
Conventionally for ground loop EM survey, we only measure one or two profile lines of the data in the loop (CITE). And for the interpretation of this data, we use 1D inversion, which assume layered-earth structure; here 1D inversion for each datum is separate. After 1D inversion for each datum, we stitch recovered 1D conductivity model together to make a 2D-like section images. We generated synthetic ground TEM data set using conductivity model shown in Figure \ref{fig:sigtrue} with survey geometry shown in Figure \ref{fig:geometry}. Using mappting function for 1D and 2D inversion (equation (\ref{eq:combomap2})), we can proceed EM inversion. For 2D case, the forward modeling is performed in 3D, although our inversion model is in 2D. Applying same procedure to 1D stitched case is possible, but this will be expensive. We use 2D cylinderical mesh by exploiting azimuthal symmetry of the system. For this case, thus conductivity is defined on 2D mesh, although the inversion model is 1D layered-earth.
Considering typical field configuration, we only used a profile line in two loops for 1D and 2D inversions, which are expressed as black dots in Figure \ref{fig:geometry}.
Recovered 1D stitched inversion model shown on the left panel of Figure \ref{fig:1DinvTD} shows reasonable layering on the east-side. However, on the west-side we can recognize artifacts in 1D stitched inversion due to 3D effect. On the right panel of Figure \ref{fig:1DinvTD}, we have also shown recovered conductivity model from 2D inversion. This shows better horizontal resolution then 1D inversion results, whereas layering show more spreaded distribution compared to 1D case. Comparison of observed and predicted data for these 1D and 2D inversions are shown in Figure \ref{fig:1D2Dobspred}. Although both predicted data from 1D and 2D inversion results show reasonable match with the observed data, we can recognize some discrepancy between observed and predicted data, which may be caused by 3D effect that we cannot explain with 1D or 2D model.

\plot{1DinvTD}{width=1.0\columnwidth}
{Vertical sections of recovered conductivity. Left and right panel show 1D stitched and 2D inversion.}

\plot{1D2Dobspred}{width=1.0\columnwidth}
{Comparisons of observed and predicted data for 1D and 2D inversions. }

\subsection*{3D inversion}
In reality, the distribution of intruded seawater is in 3D, thus restoration of 3D conductivity model is one of the important tasks to characterize seawater intruded region in the subsurface. For 1D and 2D inversions, we used a profile line data, which were located in the loops. However, for 3D inversion, having more measurement points aside from the center line is be crucial to have reasonable sensitivity for the 3D volume. We used all receivers shown in Figure \ref{fig:geometry}. Using mapping function shown in equation \ref{eq:combomap1}, we perform 3D EM inversion. Figure \ref{fig:3DinvTD} shows plan and section views of the recovered conductivity model from the 3D inversion. Interface between fresh and seawater is nicely imaged in both horizontal and vertical directions. We fit the observed data well as shown in Figure \ref{fig:3Dobspred}. We also provide cut-off 3D volume of conductivity distribution in Figure \ref{fig:final}.

\plot{3DinvTD}{width=1.0\columnwidth}
{Plan and section views of recovered 3D conductivity.}

\plot{3Dobspred}{width=1.0\columnwidth}
{A comparison of observed and predicted response for transmitter one.}

\section*{Conclusions}
Using mapping function in our geophysical inversion, we decoupled inversion model space from physical model space. This enables us to set an arbitrary inversion model, although our forward modeling space can be in 3D. We set three different inversion models, which were 1D, 2D and 3D using mapping function, and performed TEM inversions for seawater intrusion problem. Each inversion showed reasonable recovered model based on the used mapping for each case. Although we treated limited subsets of inversion models such as 1D, 2D and 3D, general definition of mapping function that we suggested can be extended to a parametric inversion model such as geometry of interfaces. For instance, we can ask a specific question: ``where is the boundary of freshwater and seawater?'' in the EM inversion using this mapping function. We believe this separation of inversion model from physical property model will be a powerful concept in the geophysical inversion because the capability to resolve a certain geological feature of the earth system  will accelerate communications with other disciplines in geoscience.

\plot{final}{width=1.0\columnwidth}
{Cut-off 3D volume of true and recovered conductivity distribution of seawater intrusion.}

% \plot{model}{width=0.75\columnwidth, height=0.22\textheight}
% {Planal and sectional views of 3D complex conductivity model based on Cole-Cole representation. Dashed line in contours the boundary of the conductive IP body.}

% \multiplot{2}{resp_ch1,resp_ch2}{width=0.5\textwidth, height=0.18\textheight}
% {Responses of $EMIP$ (black line), $EM$ (blue line) at $t=6$ (a) and $t=24$ $ms$ (b). Top-left panels of (a) and (b) show time decay curves at center sounding location and dashed circles here show that corresponding time for other figures. Bottom pannels of (a) and (b) show that responses from all the sounding in the survey geometry at specific time channel and solid circles here indicate sounding locations. Red dashed line indicates the profile lines, which are shown at top-right panels of (a) and (b).}

\section{Acknowledgement}
Thank you for Klara Steklova for helpful discussion about hydrological problem and  \SimPEG developers. Generating 3D distribution of seawater intrusion model was performed using GIFtools.

\twocolumn
\onecolumn
% \append{The source of the bibliography}
% \verbatiminput{example.bib}
\bibliographystyle{seg}  % style file is seg.bst
\bibliography{example}

\end{document}


\documentclass{beamer}

\title{Raven Comparison Statistics}
\author{Josh Cogliati\\ (and this would not have happened without\\ Ivan Rinaldi and Cristian Rabiti.  \\Thanks also to Andrea Alfonsi and Diego Mandelli)}

\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\begin{frame}
  \frametitle{Outline}
  \tableofcontents
\end{frame}

\section{Motivation}

\begin{frame}
  \frametitle{Why are we doing this?}
  We have codes that we need to compare to each other and to experiments.
\end{frame}

\begin{frame}
  \frametitle{Example}
  \includegraphics[height=6cm]{example}
\end{frame}

\section{Comparisons}

%cdf area difference
\begin{frame}
  \frametitle{CDF difference area}
  This calculates the difference in area between the two CDFs
  \begin{equation}
    cdf\_area\_difference = \int_{-\infty}^{\infty}{\|CDF_a(x)-CDF_b(x)\|dx}
  \end{equation}
  \begin{columns}
    \column{.5\textwidth}
    \includegraphics[height=3cm]{example_cdf_area}
    \column{.5\textwidth}
    Note that this area will have the same units as x.
  \end{columns}
\end{frame}

%common pdf area
\begin{frame}
  \frametitle{Common PDF area}
  This calculates the common area between the two PDFs.
  \begin{equation}
    pdf\_common\_area = \int_{-\infty}^{\infty}{\min(PDF_a(x),PDF_b(x))}dx
  \end{equation}
  \begin{columns}
    \column{.5\textwidth}
    \includegraphics[height=3cm]{example_pdf_common}
    \column{.5\textwidth}
    This will range from 0\% to 100\%, with 100\% being a complete match.
  \end{columns}
\end{frame}

%difference between pdfs
\begin{frame}
  \frametitle{Difference between PDFs}
  This calculates a difference between the PDFs.
  \begin{equation}
    f_Z(z) = \int_{-\infty}^{\infty}f_X(x)f_Y(x-z)dx
  \end{equation}
  \begin{columns}
    \column{0.5\textwidth}
    \includegraphics[height=3cm]{f_z}
    \column{0.5\textwidth}
    This generates a new pdf, with mean related
    to the average difference, and variance depending on a variety of
    factors.
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{Use of Differences between PDFs}
  This calculates the average:
  \begin{equation}
    \bar{z} = \int_{-\infty}^{\infty}{z f_Z(z)dz}
  \end{equation}
  This calculates the variance:
  \begin{equation}
    var = \int_{-\infty}^{\infty}{(z-\bar{z})^2 f_Z(z)dz}
  \end{equation}
\end{frame}

\section{Implementation}

%getting bins
\begin{frame}
  \frametitle{Getting the Numeric CDF and PDF}
  \begin{enumerate}
  \item Get the data and sort it
  \item Choose bins boundaries, and count the number of points in each bin
  \item Normalize the number of bins, and then calculate the running total to get the CDF
  \item Take the derivative of the CDF to get the PDF.
  \end{enumerate}
\end{frame}

%creating interpolation functions
\begin{frame}
  \frametitle{Interpolation functions}
  \begin{itemize}
  \item Using scipy's intererpolate.interp1d with the numeric data
  \item For the pdf, force the numbers outside the data to be zero
  \item For the cdf, force the numbers lower that the data to zero and higher to one
  \end{itemize}
\end{frame}

%integrating
\begin{frame}
  \frametitle{Integrating functions}
  \begin{itemize}
  \item Use Simpson method for calculating numbers
  \item For the pdfs and cdfs, use $-3\sigma+\mu$ to $3\sigma+\mu$ as
    the bounds (and the min and max of these if there are multiple
    ones)
  \item For the $f_Z$, the midpoint is $\mu_X-\mu_Y$ and the lower and
    upper bounds are $3\sigma_{max}$ away (where the largest $\sigma$
    is used).
  \end{itemize}
\end{frame}

\section{Future Directions}

\begin{frame}
  \frametitle{Future things to do}
  \begin{itemize}
  \item Multidimensional data
  \item Correlated data (input and output correlated)
  \item Flexibility for statistics (plugins or interfaces)
  \end{itemize}
\end{frame}

\section{Comments}

\begin{frame}
  \frametitle{Comments, complaints, concerns, contraindications, contributions \ldots ?}
\end{frame}

\end{document}


\chapter{Formalism}
\label{chap:cpv:theory}

The measurement of \ARaw, as defined in \cref{eqn:cpv:introduction:araw}, can
be contaminated by production and detection asymmetries.
By reconstructing \LcTopKK\ and \LcToppipi\ decays from
\decay{\PLambdab}{\PLambdac\Pmuon X}\ decays, \ARaw\ can include the effects of
the \PLambdab/\APLambdab\ production asymmetry, the \Pmuon/\APmuon detection
asymmetry, and the detection asymmetry of the \PLambdac\ final state
$f$/$\bar{f}$.

The \PLambdab\ production asymmetry is predicted to be non-zero due to the \pp\
collision environment~\cite{PhysRevD.90.014023}, and indeed \lhcb\ has found
evidence of such an asymmetry as a function of \PLambdab\
rapidity~\cite{Aaij:2015fea}.
The two detection asymmetries are also expected to be non-zero, due to the
known differences between the hadron/anti-hadron and muon/anti-muon
cross-sections with matter~\cite{PDG2014}.
The final state detection asymmetry can be broken down into two terms: one due
to the detection asymmetry of the proton; and another due to the detection
asymmetry of the \KmKp pair and the \pimpip\ pair.
If the meson kinematics are equal within a given mode, for example if the
\PKminus kinematics are identical to those of the \PKplus\ in the \pKK\ data,
then the final state asymmetry reduces to the proton detection asymmetry.

Both the \PLambdab\ production and the muon detection asymmetries should be
independent of the \PLambdac\ final state, given the same \PLambdac\
kinematics.
Different acceptance efficiencies between \pKK\ and \ppipi\ can create unequal
\PLambdac\ kinematics, but the kinematics can be weighted to equalise them
between the modes.

It will now be shown how the background asymmetries entering \ARaw\ can be
removed in the difference \dACP\@.
The number of reconstructed \LcTof\ decays can be expressed as the product of
several effective probabilities
\begin{equation}
  N(f) = \prob(\PLambdab)\cdot
         \Gamma(\LbToLcmuX)\cdot
         \Gamma(\LcTof)\cdot
         \eff(\Pmuon)\cdot
         \eff(f),
  \label{eqn:cpv:theory:yield}
\end{equation}
where $\prob(\PLambdab)$ is the probability of producing a $\PLambdab$ baryon
given a \pp\ collision, and $\eff(\Pmuon)$ and $\eff(f)$ are the muon and
$\PLambdac$ final-state detection efficiencies.
A similar expression exists for $N(\bar{f})$, where are particles are replaced
by their charge conjugates.
It is assumed that the \LbToLcmuX\ decay is \CP-symmetric, but that all other
factors may not be, for example $\eff(\Pmuon) \neq \eff(\APmuon)$.

To express \ARaw\ in terms of its component asymmetries, the notation of a
general asymmetry parameter $X$ is defined, which describes the asymmetry
between two quantities $x$ and $\bar{x}$
\begin{equation}
  X = \frac{x - \bar{x}}{x + \bar{x}}.
  \label{eqn:cpv:theory:generic_asym}
\end{equation}
This can be rearranged as
\begin{align}
  x &= \frac{1}{2}(x + \bar{x})(1 + X),\ \text{and}\label{eqn:cpv:theory:asym_form_one}\\
  \bar{x} &= \frac{1}{2}(x + \bar{x})(1 - X).\label{eqn:cpv:theory:asym_form_two}
\end{align}
An asymmetry parameter like that in \cref{eqn:cpv:theory:generic_asym} can be defined for each of the relevant terms in
\cref{eqn:cpv:theory:yield}
\begin{align*}
  \APLb(f) &= \frac{%
    \prob(\PLambdab) - \prob(\APLambdab)
  }{%
    \prob(\PLambdab) + \prob(\APLambdab)
  },\\
  \ADmu(f) &= \frac{%
    \eff(\Pmuon) - \eff(\APmuon)
  }{%
    \eff(\Pmuon) + \eff(\APmuon)
  },\ \text{and}\\
  \ADf(f)  &= \frac{%
    \eff(f) - \eff(\bar{f})
  }{%
    \eff(f) + \eff(\bar{f})
  },
\end{align*}
and the asymmetry in $\Gamma(\LcTof)$ is \ACP\ as in
\cref{eqn:cpv:introduction:acp}.
Each parameter is, at least implicitly, dependent on the detected \PLambdac\
final state, as each parameter can vary in quantities that may also vary
between \PLambdac\ decay modes.
Substituting Equation~\ref{eqn:cpv:theory:yield} into
Equation~\ref{eqn:cpv:introduction:araw}
\begin{equation*}
  \ARaw(f) = \frac{%
    \prob(\PLambdab)\Gamma(f)\eff(\Pmuon)\eff(f) -
    \prob(\APLambdab)\Gamma(\bar{f})\eff(\APmuon)\eff(\bar{f})
  }{%
    \prob(\PLambdab)\Gamma(f)\eff(\Pmuon)\eff(f) +
    \prob(\APLambdab)\Gamma(\bar{f})\eff(\APmuon)\eff(\bar{f})
  },
\end{equation*}
and then substituting each quantity for its equivalent form as in
\cref{eqn:cpv:theory:asym_form_one,eqn:cpv:theory:asym_form_two}, all factors
of $\sfrac{1}{2}$ and all factors of the form $(x - \bar{x})$ cancel, leaving
\begin{equation}
  \ARaw(f) = \frac{Y}{Z}.
\end{equation}
where (dropping the final state parameter temporarily for compactness)
\begin{align}
  Y = \APLb\ADmu\ADf &+ \APLb\ADmu\ACP + \APLb\ADf\ACP + \ADmu\ADf\ACP \nonumber\\
                     &+ \APLb +  \ADmu + \ADf + \ACP,
\end{align}
and
\begin{align}
  Z = 1 &+ \APLb\ADmu + \APLb\ADf + \APLb\ACP + \ADmu\ADf + \ADmu\ACP \nonumber\\
        &+ \ADf\ACP + \APLb\ADmu\ADf\ACP.
\end{align}
Assuming that the individual asymmetries are small, of the order of
\SI{1}{\percent}, the product of two or more asymmetries is negligible with
respect to the leading order, and so
\begin{equation}
  \ARaw(f) \approx \ACP(f) + \APLb(f) + \ADmu(f) + \ADf(f).
  \label{eqn:cpv:theory:araw_approx}
\end{equation}
By assuming that these background asymmetries are mode-independent, that is to
say $\AD(f) = \AD(g)$ and $\AP(f) = \AP(g)$, the difference between \ARaw\ for
the \pKK\ and \ppipi\ will only have contributions from \ACP
\begin{align}
  \dACP &= \ARaw(\pKK) - \ARaw(\ppipi),\label{eqn:cpv:theory:dacp}\\
        &\approx \ACP(\pKK) - \ACP(\ppipi)\nonumber.
\end{align}

The assumption that the production and detection asymmetries in
\cref{eqn:cpv:theory:araw_approx} are mode independent is not true in general.
This can been seen by first making a weaker assumption that the background
asymmetries are dependent only on the kinematics of the representative
particles.
Different final states will in general have different acceptance,
reconstruction and selection efficiencies as a function of \PLambdac\
kinematics.
The kinematics of the \PLambdac\ are correlated to those of the muon and the
\PLambdab, and so two samples with different \PLambdac\ kinematics will likely
also have different \PLambdab\ and muon kinematics.
Hence, there can still be net production and detection asymmetries in \dACP\@.

The assumption that the background asymmetries depend only on particle
kinematics is not unreasonable.
The production asymmetry, for example, is a difference in cross-sections, which
are usually parameterised by the kinematics of the produced particle (\pT\ and
either \Eta\ or rapidity).
Similarly, a detection asymmetry describes the differences of material
interactions between matter and antimatter, and these are dependent on the
momentum of the particle in question and, assuming a non-uniform material
distribution, its flight path.

As it is not given that the \PLambdac\ kinematics are the same between
\LcTopKK\ and \LcToppipi\ decays in the data, the data can be weighted to
equalise the \PLambdac\ kinematics.
The background asymmetries \AP\ and \ADmu\ will then cancel in the difference
\dACP\@.
The proton kinematics will not necessarily agree after such a weighting, as the
energy release in the \pKK\ and \ppipi\ decays is different.
These considerations govern the analysis strategy: measure the number of
\PLambdac\ candidates in the \pKK\ and \ppipi\ samples after weighting them
such that the \PLambdac\ kinematics look alike, such that the \PLambdab\ and
\Pmuon kinematics also agree.
Additional weighting may be required to equalise the proton kinematics.

\section{Decay phase space}
\label{chap:cpv:theory:phsp}

The phase space of a decay is the set of variables which fully parameterises
all possible dynamics.
Although a three-body decay requires 12 parameters to describe the kinematics,
under the assumptions of four-momentum conservation and that the masses of the
three decay products are known, the number of free parameters is only five.
When all particles involved have zero spin, the distribution of the momenta of
the decay products is isotropic, such that there are only 2 degrees of freedom.
These are usually taken to be two child-pair squared masses, which can be
visualised as a Dalitz plot.
In the case of \LcTophh, the spin \sfrac{1}{2} of the proton means that the
three-body system is no longer rotationally symmetric, and the full five
degrees of freedom are required to describe the phase space.

For a meaningful comparison of the measurement of \dACP\ with theoretical
predictions, which are not presently available, the efficiency of the
\PLambdac\ selection across the five-dimensional phase space must be known.
The definition of ``selection'' includes the effects of the \lhcb\ acceptance
and the trigger, stripping, and offline requirements.
The efficiency model can either be provided to theorists so that they can apply
the same efficiencies to their phase space models, or it can be used to correct
the data before the \dACP\ measurement is made.

The five dimensions of the phase space are defined here in a similar way to the
\LcTopKpi\ amplitude analysis performed by the \esno\
collaboration~\cite{Aitala:1999uq}.
This defines two child-pair squared masses, of the proton and
oppositely-charged child \msqphm\ and of the two opposite-sign pseudo-scalars
\msqhh, and three decay angles.
The child-pair squared masses are invariant under Lorentz transformations, but
the decay angles are not and so a definition of the frame in which they are
computed is required.

The \esno\ analysis defines a coordinate system in the \PLambdac\ rest frame.
The $z$-axis, also called the quantisation axis or polarisation axis \polzlcp,
is perpendicular to the plane of production
\begin{equation}
  z = \polzlcp = \phatbeam \times \phatlcp,
\end{equation}
where \phatbeam\ is the direction of the beam\footnotemark\ and \phatlcp\ is
the direction of the \PLambdac\ measured in the laboratory frame.
\footnotetext{%
  E791 was a fixed-target experiment, colliding a \SI{500}{\GeVc} pion beam
  with metal foils.
}
The $x$-axis of the \PLambdac\ rest frame is \phatlcp.
As the \PLambdac\ candidates in this analysis are not produced directly from
the \pp\ collision but in the decays of \PLambdab\ baryons, here the `beam
direction' is defined as the direction of the \PLambdab\ momentum vector, which
is equal to the direction vector pointing from the \pp\ primary vertex
$v_{\pp}$ to the $\PLambdac\Pmuon$ vertex $v_{\PLambdac\Pmuon}$
\begin{equation}
  \phatbeam = \phatlbz = v_{\PLambdac\Pmuon} - v_{\pp}.
\end{equation}
With this coordinate system and inertial frame, the three decay angles are
defined as:
\begin{enumerate}
  \item The angle \thetap\ between the proton momentum vector and the $z$-axis;
  \item The angle \phip\ between the proton momentum vector and the $x$-axis;
    and
  \item The angle \phihh\ between the plane containing the proton momentum
    vector and the $z$-axis and the plane containing the two pseudo-scalar
    meson momentum vectors.
\end{enumerate}
These definitions are illustrated in \cref{fig:cpv:theory:phsp:angles}

The distributions of the five phase space variables will be presented in
\cref{chap:cpv:phsp}, along with the evaluation of the efficiency as a function
of the position in phase space.

\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \resizebox{\textwidth}{!}{%
      \input{figures/cpv/theory/phase_space_angles}
    }
  \end{subfigure}
  \begin{subfigure}{0.5\textwidth}
    \resizebox{\textwidth}{!}{%
      \input{figures/cpv/theory/phase_space_planes}
    }
  \end{subfigure}
  \caption{%
    Definition of inertial reference frame axes and \LcTophh\ phase space decay
    angles.
    Adapted from Figure~1 in the \esno\ \LcTopKpi\ amplitude analysis
    paper~\cite{Aitala:1999uq}.
  }
  \label{fig:cpv:theory:phsp:angles}
\end{figure}


\subsection{Analysis of Rapid Environmental Fluctuations}
In this article, to analyze the interaction of the mixed growth of multiple fungi, we establish Multi-groups Logistic Model. However, we do not make a detailed analysis of the environmental changes. Hence, we are going to examine the sensitivity of our model to rapid fluctuations in the environment.
\par
In the real natural environment, disasters that are not conducive to the survival and reproduction of living things happen from time to time. When a disaster occurs, the natural environment fluctuates rapidly, and the survival of organisms in the area is threatened and restricted. Combining our model and the characteristics of fungi, we find that when the environment fluctuates rapidly, the inherent growth rate of fungi will change rapidly in a short time. Meanwhile, the natural maximum capacity of fungi will be reduced accordingly.


\chapter{Introduction}
\label{chap:introduction}

\section{Motivation and the research needs}
Boolean satisfiability (SAT)~\cite{SATHandbook} has been successfully applied to numerous research fields
including artificial intelligence~\cite{Nilsson2014,Russell2020},
electronic design automation~\cite{Marques2000,Wang2009},
software verification~\cite{Jhala2009, Berard2013}, etc.
The tremendous benefits have encouraged the development of more advanced decision procedures
for satisfiability with respect to more complex logics beyond pure propositional.
For example,
solvers for majority SAT (MAJSAT) decide whether the majority of the assignments satisfy a propositional formula,
and its functional problem is known as model counting~\cite{SATHandbook-ModelCounting};
quantified Boolean formula (QBF)~\cite{Narizzano2006,SATHandbook-QBF} allows both existential and universal quantifiers;
stochastic Boolean satisfiability (SSAT)~\cite{Littman2001,SATHandbook-SSAT} models uncertainty with randomized quantification;
dependency QBF (DQBF)~\cite{Balabanov2014,Scholl2018} equips Henkin quantifiers to describe multi-player games with partial information;
and solvers of the satisfiability modulo theories (SMT)~\cite{Moura2011,HBMC-SMT} accommodate first order logic fragments.
Due to their simplicity and generality,
various satisfiability formulations are under active investigation.

Among various generalizations of Boolean satisfiability,
\textit{stochastic Boolean satisfiability} (SSAT)~\cite{SATHandbook-SSAT} is a logical formalism
for problems endowed with randomness.
First formulated by Papadimitriou,
SSAT is interpreted as \textit{games against nature}~\cite{Papadimitriou1985}.
Nondeterministic factors are introduced into the world of propositional logic
through the creation of the \textit{randomized quantifier}.
A Boolean variable $x$ can be randomly quantified with a probability $p\in[0,1]$ in an SSAT formula
by a randomized quantifier $\random{p}$ that requires $x$ to take the Boolean value
\true with probability $p$ and
\false with probability $1-p$.
Via randomized quantifiers,
a variety of computational problems inherent with uncertainty can be encoded into SSAT formulas,
such as propositional probabilistic planning~\cite{Littman1998},
Bayesian-network inference~\cite{Cooper1990,Jensen1996,Bacchus2003},
and the analysis of partially observable Markov decision process (POMDP)~\cite{Majercik2003}.

While SSAT has been employed to solve various AI problems,
to the best of our knowledge,
it has not yet been applied to analyze VLSI systems,
and how VLSI systems would benefit from the probabilistic reasoning of SSAT remains unclear.
Conventionally, uncertain system behavior is undesirable and
would be mitigated by employing techniques such as
error detection~\cite{Constantinescu2003} and error correction~\cite{Mitra2006}.
Nevertheless, in the post-Moore's era,
the variability and uncertainty of manufacturing at the atomic level
make devices under miniaturization sensitive to process variation and environmental fluctuation.
As a result, the manufactured ICs may exhibit uncertain probabilistic behavior,
which imposes serious challenges to the design of reliable systems.

Recent research efforts have been made to accept the inevitable imperfection of devices
based on the notions of \textit{approximate design} and \textit{probabilistic design}.
In both notions, a system's behavior may deviate from its expected specification;
however, this deviation is deterministic in the former case but probabilistic in the latter case.
Despite the advancements made by prior endeavors,
the analysis and synthesis of probabilistic design have gained relatively less attention.
Hence,
\textbf{there is a research need of a framework to evaluate probabilistic design},
and SSAT stands up as a suitable logical formalism to address the need.
(In the following,
the term ``design'' is used as a general term to refer to a single design instance,
a set of design instances,
or design process;
the term ``synthesis" is referred to as the design automation process
transforming a system under design from high-level system specification to low-level circuit implementation.)

SSAT is closely related to two generalizations of Boolean satisfiability:
\textit{model counting} of propositional formulas and \textit{quantified Boolean formulas} (QBFs).
Given a propositional formula, model counting asks to compute the number of its satisfying assignments.
In the weighted version, weights are assigned to the Boolean variables in the formula,
and the goal is to compute the summation of weights of the satisfying assignments.
Algorithms for model counting are under active development in recent years.
In addition to \textit{exact} model counting~\cite{Sang2004,Sang2005ModelCounting},
\textit{approximate} model counting~\cite{Gomes2006,Gomes2007,Chakraborty2016}
has been investigated to improve scalability by relaxing exactness.
On the other hand, from the perspective of the computational complexity,
solving an SSAT formula lies in the PSPACE-complete~\cite{Stockmeyer1973} complexity class,
the same as solving a QBF.
Many endeavors have been invested in the algorithmic improvement~\cite{SATHandbook-QBF}
and solver evaluation~\cite{Narizzano2006} for QBF.

Nevertheless, in spite of its broad applications and profound theoretical values,
SSAT has drawn relatively little attention compared to SAT, model counting, or QBF.
Most prior efforts for SSAT solving are based on the conventional
Davis-Putnam-Logemann-Loveland (DPLL) search~\cite{Davis1962},
which suffers from the scalability issue when problem sizes grow.
Therefore, \textbf{there is a research need to develop novel algorithms to enhance the scalability of SSAT solving},
and the recent advancements of SAT/QBF solving and model counting can be leveraged to help the algorithm design.

In spite of its rich expressiveness to encode problems ranging from AI to VLSI,
SSAT is limited by its descriptive power within the PSPACE complexity class.
More complex problems with nondeterminism might not be succinctly modeled as SSAT formulas.
As a result, \textbf{there is a research need of a logical formalism for problems beyond PSPACE and with uncertainty.}

Finally, most research work regarding SSAT solving was done
before the year 2010~\cite{Majercik1998,Majercik2003,Majercik2004,Majercik2005,Teige2010,SATHandbook-SSAT}.
Open-source implementations and SSAT instances for testing are barely available,
which hinder the understanding of the algorithmic details and empirical solver comparison.
Consequently, \textbf{there is a need to provide open-source implementations and databases of SSAT instances to facilitate convenient evaluation of different algorithms and drive further advancements.}

\section{Our contributions}
\begin{figure}[t]
      \centering
      \includegraphics{fig/build/nutshell.pdf}
      \caption{The contributions of this dissertation in a nutshell}
      \label{fig:intro-nutshell}
\end{figure}

This dissertation aims at contributing to the aforementioned research needs.
Our achievements positioned in the hierarchy of various complexity classes beyond NP are visualized in~\cref{fig:intro-nutshell}.
In a nutshell, we investigate the application of SSAT to VLSI analysis,
leverage the advancements of SAT, MAJSAT, and QBF to design new decision procedures for SSAT,
and combine SSAT and DQBF to propose a new formulation, called DSSAT, for NEXPTIME problems with uncertainty.
In the following, we will explain each contribution in more detail.

First, we approach the analysis of probabilistic design by
formalizing the problem of \textit{probabilistic property evaluation}.
Different computational solutions are provided for the problem.
Particularly, random-exist and exist-random quantified SSAT formulas are exploited
to solve the average-case and worst-case analyses, respectively.
To the best of our knowledge,
this is the first attempt that analyzes VLSI systems with SSAT.
(In the following,
the terms ``analysis'' and ``evaluation'' are used interchangeably as general terms
referring to the process of determining qualitative or quantitative properties of a design.
We will formulate the problem of \textit{probabilistic property evaluation},
and refer to the term ``evaluation" as computing the satisfying probability of
certain properties of a probabilistic design.)

Second, in contrast to the previous DPLL-based algorithms,
we utilize modern techniques of SAT/QBF solving and model counting to improve SSAT solving.
Motivated by the new VLSI applications,
we focus on random-exist and exist-random quantified fragments of SSAT formulas.

The random-exist quantified SSAT formula is of the form $\Qf=\random{}X,\exists Y.\pf$,
which is the counterpart of the forall-exist QBF.
It has applications in Bayesian-network inference~\cite{Cooper1990,Bacchus2003}.
We propose an algorithm that uses modern SAT solvers~\cite{Een2003Solver,Een2003Incremental} as plug-in engines.
In addition to SAT solving,
we also incorporate weighted model counting,
which has been widely used in probabilistic inference~\cite{Sang2005BayesianInference,Chavira2008},
to tackle randomized quantifiers.
The randomized quantification in an SSAT formula can be approached with weighted model counting
by assigning the weight of a variable quantified by $\random{p}$ to be $p$.
The proposed algorithm uses an SAT solver and a model counter in a \textit{stand-alone} manner,
leaving the internal structures of these solvers intact.
Due to the stand-alone usage of these solvers,
the proposed algorithm may directly benefit from the advancement of the solvers without any modification.

The exist-random quantified SSAT formulas has the form $\Qf=\exists X,\random{}Y.\pf$,
which is also known as \textit{E-MAJSAT}~\cite{Littman1998}.
Computational problems, such as computing a maximum-a-posteriori (MAP) hypothesis or
a maximum-expected-utility (MEU) solution~\cite{Dechter1998} in Bayesian networks,
and searching an optimal plan for probabilistic conformant planning domains~\cite{Littman1998},
can be formulated with E-MAJSAT.
Inspired by the \textit{clause-selection}~\cite{Janota2015,Rabe2015} technique,
which is recently devised for QBF solving and becomes the state-of-the-art,
we propose a learning method based on the \textit{clause-containment principle} to solve E-MAJSAT.
To the best of our knowledge,
this is the first attempt to adopt QBF approaches for SSAT solving.

Moreover, the proposed algorithms solve an SSAT formula in a gradual manner
that converges from approximate bounds of the satisfying probability to the exact answer.
Therefore, they are able to provide useful information even if the exact answer is unavailable (e.g., due to limited computational resources).

Third, to provide a logical formalism for more complex problems with uncertainty,
we extend \textit{dependency QBF} (DQBF)~\cite{Balabanov2014,Scholl2018} to the stochastic domain
in view of the close relation between QBF and SSAT.
DQBF is a representative problem in the NEXPTIME-complete~\cite{Peterson2001} complexity class.
It equips QBF with Henkin quantifiers to describe multi-player games with partial information.
We formalize the problem of \textit{dependency SSAT} (DSSAT) as a generalization for SSAT.
We prove that DSSAT has the same NEXPTIME-complete complexity as DQBF,
and therefore it can succinctly encode decision problems with uncertainty in the NEXPTIME complexity class.
We demonstrate the potential applications of DSSAT to the synthesis of probabilistic and approximate design and the encoding of decentralized POMDP (Dec-POMDP)~\cite{Oliehoek2016} problems.
Our theoretical results would encourage the solver development.

Fourth, our implementation of the proposed SSAT algorithms
and formula instances used in the experiments are open-source,
which will help other researchers to understand the details of the approaches and
facilitate convenient empirical evaluation of different algorithms.

\section{An overview of the dissertation}
The structure of this dissertation is outlined as follows.
\begin{itemize}
      \item
            In~\cref{chap:related-work}, a brief survey of the literature is provided to highlight the advancements made in this dissertation.
      \item
            In~\cref{chap:background}, background knowledge required throughout the dissertation is discussed.
            Specific material for an individual chapter will be introduced when it is needed.
      \item
            In~\cref{chap:prob-design-eval}, a formal framework to evaluate properties of probabilistic design is proposed.
            Especially, random-exist and exist-random quantified SSAT formulas are exploited to solve the formulation.
            This chapter is based on our conference paper~\cite{LeeICCAD14ProbDesign} published at ICCAD\,'14 and journal paper~\cite{LeeTC18ProbDesign} published in IEEE Transactions on Computers.
      \item
            In~\cref{chap:random-exist-ssat}, modern SAT-solving and model-counting techniques are combined to solve random-exist quantified SSAT formulas.
            This chapter is based on our conference paper~\cite{LeeIJCAI17RESSAT} published at IJCAI\,'17.
      \item
            In~\cref{chap:exist-random-ssat}, a clause-learning technique inspired by \textit{clause selection}, a prevailing method recently invented for QBF, is devised to solve exist-random quantified SSAT formulas.
            This chapter is based on our conference paper~\cite{LeeIJCAI18ERSSAT} published at IJCAI\,'18.
      \item
            In~\cref{chap:dependency-ssat}, SSAT is lifted from the PSPACE-complete complexity class to the NEXPTIME-completeness.
            We show the applicability of the lifted formalism to the analysis of probabilistic design and decentralized POMDP.
            This chapter is based on our conference paper~\cite{LeeAAAI21DSSAT} published at AAAI\,'21.
      \item
            In~\cref{chap:conclusion-future-work}, we give concluding remarks and point out some potential directions for future investigation.
\end{itemize}

\section{Data availability statement}
To improve the reproducibility of the results presented in this dissertation,
we provide a reproduction package on Zenodo~\cite{dissertation-artifact},
including the source code of the proposed solvers,
the pre-compiled binaries of the evaluated tools,
the used benchmark sets,
the scripts to perform experiments,
and the raw data generated from our experiments.
Current versions of the proposed SSAT solvers are available at~\url{\ssatabcurl}.
The collection of SSAT instances is hosted at~\url{\ssatbenchmarkurl}.
The \LaTeX~code for this dissertation as well as the slides used in the oral defense is also made public at~\url{\thesisurl}.


\chapter{Fitting the Spectra}

Fitting of the spectra involves selecting a spectral line of interest (e.g. \ion{Fe}{12} 195.12\,\AA) from the spectral windows of the data and determining a guess on the fit parameters. The next ingredient for a fit is the selection of an optimization method\sidenote{Here we use a Python implementation of the well-known IDL method mpfit which solves the non-linear least squares problem using the Levenberg-Marquardt algorithm. The Python implementation mpfit.py is found on GitHub (https://github.com/segasai/astrolibpy/) and included in our analysis software.}.

For this we've created a set of fit templates for different spectral lines. An \verb+h5dump+ on the file shows that it contains a \verb+/template+ group for the initial guess on the fit parameters and a \verb+/parinfo+ group containing constraints on the parameters for \verb+mpfit.py+.

\begin{lstlisting}
h5dump -n fe_12_195_119.2c.template.h5
HDF5 "fe_12_195_119.2c.template.h5" {
FILE_CONTENTS {
 group      /
 group      /parinfo
 dataset    /parinfo/fixed
 dataset    /parinfo/limited
 dataset    /parinfo/limits
 dataset    /parinfo/tied
 dataset    /parinfo/value
 group      /template
 dataset    /template/component
 dataset    /template/data_e
 dataset    /template/data_x
 dataset    /template/data_y
 dataset    /template/fit
 dataset    /template/fit_back
 dataset    /template/fit_gauss
 dataset    /template/line_ids
 dataset    /template/n_gauss
 dataset    /template/n_poly
 dataset    /template/order
 dataset    /template/wmax
 dataset    /template/wmin
 }
\end{lstlisting}

 The object \verb+eis_read_template.py+ can be used to read a template file and examine the contents.

\begin{lstlisting}
from eis_read_template import eis_read_template
filename = 'fe_12_195_119.2c.template.h5'
template = eis_read_template(filename)
\end{lstlisting}

This produces the output below, showing the \verb+/parinfo+ group that contains  parameters (peak, centroid, width, background) for a double Gaussian fit along with the parameter constraints. Note that this is specific to using the \verb+mpfit+ method (see the GitHub page for more info).
\begin{lstlisting}
+ template file = fe_12_195_119.2c.template.h5
*PARAMETER CONSTRAINTS*
*              Value      Fixed            Limited                 Limits               Tied
 p[0]     57514.6647          0          1          0       0.0000       0.0000
 p[1]       195.1179          0          1          1     195.0778     195.1581
 p[2]         0.0289          0          1          1       0.0191       0.0510
 p[3]      8013.4013          0          1          0       0.0000       0.0000
 p[4]       195.1779          0          1          1     195.1378     195.2181          p[1]+0.06
 p[5]         0.0289          0          1          1       0.0191       0.0510          p[2]
 p[6]       664.3349          0          0          0       0.0000       0.0000
 \end{lstlisting}

 Next you'll want to prep the data for fitting. Once you've read in a template file, you can use the central wavelength to find the desired spectral window in the data using \verb+eis_read_raster+ as shown in the previous chapter.

\begin{lstlisting}
from eis_read_raster import eis_read_raster
from eis_read_template import eis_read_template

# input data and template files
file_data     = 'eis_20190404_131513.data.h5'
file_template = 'fe_12_195_119.2c.template.h5'

# read fit template
template = eis_read_template(file_template)

# get central wavelength
wmin = template.template['wmin']
wmax = template.template['wmax']
wave = wmin + (wmax-wmin)*0.5

# read raster
raster = eis_read_raster(file_data, wave)
ints   = raster.data['data']
wave   = raster.data['wave']
corr   = raster.data['wave_corr']
\end{lstlisting}

Prepping of the data can be handled at various levels of sophistication at the user's discretion, however, at a minimum it should include handling bad values\sidenote{Negative values are a result of the background subtraction.} in the raster, correcting for the wavelength offsets\sidenote{From thermal drift over the  orbit.}, and computing the errors on the intensities\sidenote{The square root of the counts is a good first-order approximation.}.

\begin{lstlisting}
# get dimensions
ndata = ints.shape
nx    = ndata[0]
ny    = ndata[1]
nz    = ndata[2]

# bad data correction
bad = np.where(ints<0)
ints[bad] = 0.0

# compute error on counts
errs = np.sqrt(ints)

# wavelength correction
newwave = np.zeros(ndata)
for i in range(nx):
    for j in range(ny):
        newwave[i,j,::] = wave-corr[i,j]
wave = newwave
\end{lstlisting}

Now on to the fitting! Now that you have a fit template and the data elements, you can perform a fit of the entire raster by calling \verb+eis_fit_raster.py+\sidenote{Here's what's happening under the hood. The object eis-fit-raster calls eis-scale-guess to scale the initial parameter guess to the data, then calls eis-mpfit to implement the Levenberg-Marquardt fitting. The module eis-fit-deviates contains the callable function that returns the fit deviates computed from a model function for eis-mpfit.}. The fit results can be saved and read back using \verb+eis_save_fit.py+ and \verb+eis_read_fit.py+.

\begin{lstlisting}
from eis_fit_raster import eis_fit_raster
from eis_save_fit import save_fit
from eis_read_fit import read_fit

# fit profile
parinfo  = template.parinfo
template = template.template
fit = eis_fit_raster(wave, ints, errs, template, parinfo)

# save fit output
fit = fit.fit
file_fit = save_fit(fit, file_data)

# read fit output back from file
fit = read_fit(file_fit[0])
\end{lstlisting}

The output fit parameters are stored to a dictionary.

\begin{lstlisting}
background   float64      (512, 87, 1)
centroid     float64      (512, 87, 2)
chi2         float64      (512, 87)
component    int64        1
e_background float64      (512, 87, 1)
e_centroid   float64      (512, 87, 2)
e_int        float64      (512, 87, 2)
e_peak       float64      (512, 87, 2)
e_width      float64      (512, 87, 2)
int          float64      (512, 87, 2)
line_ids     object       (2,)
n_gauss      int16        1
n_poly       int16        1
params       float64      (512, 87, 7)
peak         float64      (512, 87, 2)
perror       float64      (512, 87, 7)
status       float64      (512, 87)
wavelength   float64      (512, 87, 24)
width        float64      (512, 87, 2)
\end{lstlisting}

The above steps are illustrated in the example routine \verb+eis_fit_example.py+, which produces a plot like the one shown below.

\begin{figure}[t]
  \centerline{\includegraphics[clip,width=0.8\linewidth,bb=0 0 750 737]{figures/fit_example.pdf}}
  \centerline{\includegraphics[clip,width=0.8\linewidth,bb=750 0 1500 737]{figures/fit_example.pdf}}
  \caption{Example line profile fits. The top two panels show the raster formed by summing over the
    profile (left) and fitting each profile (right). The bottom panels show fits to four
    \ion{Fe}{12} 195.119\,\AA\ line profiles.}
  \label{fig:fit_example}
\end{figure}

As a final note about the fitting routines, there's also a parallelized version for fitting the raster that uses the Python Multiprocessing module \sidenote{This uses a pool of processes and parallelizes over the rasters so that each sub-process gets a raster position.}. When using the parallel version, an extra argument can be passed to the function to specify the number of processes to use (default=4) as in the below example. You can also check out the example in \verb+eis_fit_example_parallel.py+.

\begin{lstlisting}
fit = eis_fit_raster_parallel(wave, ints, errs, template, parinfo, ncpu=8)
\end{lstlisting}


\subsection{Overview of Examples}
We establish some fundamental properties of solutions to the SIP under different QoI maps in terms of the skewness of the $Q$'s being compared.
We seek an estimated probability measure $\hat{\PP}_\pspace$ on the parameter space to converge (with respect to the metric $d_\text{TV}$) to some reference measure $\PP_\pspace$ as more samples (i.e., model evaluations), $\nsamps$ are used.
Such a reference measure could be either some known distribution taken as truth, or another approximation deemed to be sufficiently resolved for the given application or computational budget (i.e. higher-fidelity model, mesh, or Monte Carlo sample-size).\footnote{However, we could also choose to interrogate the push-forward measures given by propagating the $\hat{\PP}_\pspace$ and $\PP_\pspace$ forward to a data space by a QoI map and taking the distance on the resulting output space.
This would measure the ability of the maps to reconstruct the output probability measure.}

In Figure~\ref{fig:voronoi_sols}, we illustrate the solution to the problem of comparing measures defined on two different (implicitly-defined) $\sa$s shown in Figure~\ref{fig:voronoi_issues}.
By introducing a third set against which both sample sets of size $\nsamps=50$ are compared, we can leverage theoretical results from Lemma~\ref{lem:measuresets} to compare solutions to the SIP under different QoI maps.

\begin{figure}[ht]
\centering
	\begin{minipage}{.275\textwidth}
		\includegraphics[width=\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N25_r0_no_label}
	\end{minipage}
	\begin{minipage}{.4\textwidth}
		\includegraphics[width=\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N500_r50}
	\end{minipage}
		\begin{minipage}{.275\textwidth}
		\includegraphics[width=\linewidth]{./images/voronoi_diagrams/voronoi_diagram_N25_r10_no_label}
	\end{minipage}
\caption{
(Left/Right): The two partitions from Figure~\ref{fig:voronoi_issues} will be projected onto a third reference partition (center), in order to compare them on a common $\sa$.
Center: A possibly over-resolved reference sample set, generated using $\nsamps = 500$ uniform i.i.d.~random samples.
}
\label{fig:voronoi_sols}
\end{figure}

To isolate the effect of skewness on the ability to approximate sets with finite sampling, we choose the maps so that they preserve the sizes of sets between $\pspace$ and $\dspace$ under the push-forward measure given in Eq.~\eqref{eq:dataspace_pushforward_measure}.
The sizes of these inverse sets correspond to the average precision of maps $Q$, so we fix the maps to all be equally informative from this perspective; for linear maps, this means they all have the same determinant.

All of our experiments follow the same structure, where $\qspace$ denotes a set of QoI maps under consideration in each example:
\begin{itemize}
\item[[0-a]] Select $\qoi\in\qspace$ and define $\PP_{\dspace_\qoi}$ as a uniform distribution centered on a reference QoI value $Q(\paramref)$ for $\paramref$ taken as the midpoint of $\pspace$.
Note that $\PP_{\dspace_\qoi}$ is exactly discretized with $M=1$ sample, so that
\[
P_{\pspace, 1} = P_\pspace.
\]
\item[[0-b]] Create a regular grid of samples in $\pspace=[0,1]^n$ using $N_{\text{ref},i}$ equispaced points in each dimension.
Set $\bar{N} := \prod N_{\text{ref},i}$.
Since $n$ is small in the numerical examples shown here, we select $N_{\text{ref},i} = 200 \; \forall \; i$ in each example.
\item[[0-c]] Use Algorithm~\ref{alg:inv_density} to construct a reference solution $\PP_{\pspace,\bar{N}}\approx \PP_\pspace$.
\item[[1]] Generate $\set{S_k^{(n)}}_{n=1}^{50}$ sets of uniform i.i.d.~random samples where $N_k = 25, 50, 100, 200, \hdots, 6400$, and $n$ represents the number of repeated trials of a sample size $N_k$.
%, constructing $\set{\set{\VVV_k^{(j)}}_{k=1}^{50}}_{j=1}^{N}$ so that when we compute Total Variation distances on the approximate measures defined on each $\set{\VVV_k^{(j)}}{j=1}{N}$, we can reduce the variance in our expected Total Variation distance values for each instance of $N$. Note that we experimented with using more trials and found the variance in expected Total Variation distances was sufficiently low with as few as twenty trials for the maps under consideration herein.
%\item[[3]] For every trial $T$ and $N$ value (including $\bar{N}$), the reference parameter $\lambda = (\lambda_1, \lambda_2) = (0.5, 0.5)$ is mapped by $Q$ to $\dspace_\qoi = Q(\pspace)$.
%\item[3] A uniform distribution with support $[Q(\lambda_1) - 0.05, Q(\lambda_1) + 0.05] \times [Q(\lambda_2) - 0.05, Q(\lambda_2) + 0.05]$ is defined on $\dspace_\qoi$, representing equal uncertainty in each component of our measured functional values.
\item[[2]] Solve the SIPs using Algorithm~\ref{alg:inv_density} to construct $\set{\PP_{\pspace,M,N}^{(n)}}_{n=1}^{50}$.
\item[[3]] Use $1E5$ i.i.d.~random samples to estimate $\set{d_H^2( \PP_{\pspace,M,N}^{(n)}, \PP_{\pspace,\bar{N}})}_{n=1}^{50}$.
\item[[4]] Average over all trials $n$ for each $N$ to estimate the {\em expected} Total Variation distance for $N$ samples and analyze convergence to $\PP_{\pspace,\bar{N}}$.
\item[[5]] Repeat steps [0-a]--[4] for each $\qoi\in\qspace$ under consideration.
\end{itemize}

\FloatBarrier


\documentclass{article}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
% necessary packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{oldstyle}
\usepackage{color}
\usepackage{soul}
% disabled b/c we're using tcolorbox
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

% math stuff
\providecommand{\inv}[1]{{#1}^{\ensuremath{\mathsf{-1}}}} % inverse ...
\providecommand{\tr}[1]{{#1}^{\ensuremath{\mathsf{T}}}} % transpose ...
\providecommand{\itr}[1]{{#1}^{\ensuremath{\mathsf{-T}}}} % transpose ...
\providecommand{\strans}[1]{{#1}^{\ensuremath{\mathsf{S}}}} % transpose ...
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\left\lVert#1\right\rVert}
\providecommand{\svect}[1]{\hat{\bm{#1}}}
\providecommand{\vect}[1]{\bm#1}
\providecommand{\mat}[1]{\mathbf#1}
\providecommand{\smat}[1]{\hat{\mathbf{#1}}}
\providecommand{\bigTheta}{\mathit{\Theta}}
\providecommand{\bigO}{\mathit{O}}
\providecommand{\sgn}[1]{\textrm{sgn}(#1)}
\providecommand{\xform}[3]{\hspace{0mm}_#1\mat{#2}_#3}
\newcommand{\ud}{\,\mathrm{d}}

% lists
\newcommand{\ia}{(\textos{a})\!}
\newcommand{\ib}{(\textos{b})\!}
\newcommand{\ic}{(\textos{c})\!}
\newcommand{\id}{(\textos{d})\!}
\newcommand{\ie}{(\textos{e})\!}
\newcommand{\1}{(\textos{1})\!}
\newcommand{\2}{(\textos{2})\!}
\newcommand{\3}{(\textos{3})\!}
\newcommand{\4}{(\textos{4})\!}
\newcommand{\5}{(\textos{5})\!}
\newcommand{\6}{(\textos{6})\!}
\newcommand{\7}{(\textos{7})\!}
\newcommand{\8}{(\textos{8})\!}

\DeclareMathOperator*{\minimize}{minimize}

% indicate necessary changes
\providecommand{\captiontxt}[1]{\caption{\emph{#1}}}
\providecommand{\note}[1]{\textcolor{orange}{#1}}
\providecommand{\changeme}[1]{\textcolor{red}{#1}}
\providecommand{\TODO}[1]{
\sethlcolor{yellow}
\noindent
$\cdot$\ \hl{#1}
\\
}

\title{Computing the principal pivoting transform for solving Linear Complementarity Problems with Lemke's Algorithm}
\date{}
\author{Hongkai Dai and Evan Drumwright\\Toyota Research Institute}

\begin{document}
\maketitle
\section{Problem statement} Given tuples $w = \{ w_1, \hdots, w_n \}$ and $z = \{z_1, \hdots, z_n, z_{n+1}\}$, which can be arranged into vectors as follows:
\begin{align*}
	\vect{w} =& \tr{\begin{bmatrix}w_1 & \hdots & w_n \end{bmatrix}}\in\mathbb{R}^n \\
		\vect{z} =& \tr{\begin{bmatrix}z_1 & \hdots & z_n & z_{n+1} \end{bmatrix}}\in\mathbb{R}^{n+1},
\end{align*}
we seek to permute the relationship:
\begin{align*}
	\vect{w} = \vect{q} + \mat{M}\vect{z}
\end{align*}
where $\vect{q}\in\mathbb{R}^n, \mat{M}\in\mathbb{R}^{n\times (n+1)}$ are a given vector/matrix (note that boldface is used to help distinguish vectors and matrices from sets). $z_{n+1}$ will hereforth be referred to as the ``artificial variable'' by swapping some entries in the ``dependent variable tuple'' $w$ with some entries in the ``independent variable'' tuple $z$, yielding two new sets $z'$ and $w'$. Similarly to the matrix/vector relationship above, vectors $\vect{z}' \in \mathbb{R}^{n+1}$ and $\vect{w}' \in \mathbb{R}^n$ can be defined that correspond to variable indices of $z$ and $w$. \emph{The problem that this document seeks to solve is the vector} $\vect{q}'$ \emph{and the matrix} $\mat{M}'$ (actually, just a single column of it) \emph{such that the relationship}:
\begin{align*}
\vect{w}' = \vect{q}' + \mat{M}'\vect{z}'
\end{align*}
follows from the ordering in the vectors corresponding to the positions of the
individual $w$ and $z$ variables in the tuples $w'$ and $z'$. Recall that
pivoting takes the value $\vect{z'} = \vect{0}$, which allows $\vect{w'}$ to be
determined simply be setting it equal to $\vect{q}'$, via the equation above.
This rearrangement is known as a \emph{principal pivoting transform}.

One of the variables in the independent variable tuple $z'$ will be identified as the \textit{driving variable}. We will denote this variable as $z'_{\textrm{driving}}$. Our goal is to find the vector $\vect{q}'$, together with the column in $\mat{M}'$ that will be multiplied (i.e., via the inner product operation) with $z'_{\textrm{driving}}$. We will denote this column as $\mat{M}'_{\textrm{driving}}$.

\subsubsection{Running example}
We consider the LCP from Example 4.4.7 in \cite{Cottle:1992}:
\begin{align*}
	\begin{bmatrix} w_1 \\ w_2 \\ w_3\end{bmatrix} = \underbrace{\begin{bmatrix}-3 \\ 6 \\ -1\end{bmatrix}}_{q} + \underbrace{\begin{bmatrix}  0 & -1 & 2 & 1\\ 2 & 0 & -2 & 1 \\ -1 & 1 & 0 & 1\end{bmatrix}}_{M}\begin{bmatrix}z_1 \\ z_2 \\ z_3 \\ z_4\end{bmatrix}
\end{align*}
After some number of pivoting operations, assume that the ``dependent'' tuple $w'$ and ``independent'' tuple $z'$ consist of:
\begin{align}
	w' = \{ z_4, w_2, z_3 \} ,
	z' = \{ w_1, w_3, z_2, z_1 \}
    \tag{1} % NOTE: Do not change equation number without changing
            % unrevised_lemke_solver_test.cc
\end{align}

\subsection{Terminology} \label{subsec:terminology}
We now introduce some terminology:
\begin{itemize}
	\item \textsc{independent w}: the tuple of variables from $w$ that (partially) comprise $z'$ in the order in which they are found in $w$  (i.e., the elements of \textsc{independent w} appear in ascending order, e.g., $\{ w_1, w_2 \}$). In the running example, \textsc{independent w} is $\{ w_1, w_3 \}$.
		\begin{itemize}
			\item  $\alpha$: the positions in $w$ of the elements from \textsc{independent w}. In the running example, $\alpha = \{ 1, 3 \}$. From the definition of \textsc{independent w}, these $w$ elements of $\alpha$ appear in ascending order.
			\item $\alpha'$: the respective indices in $z'$ of the variables from \textsc{independent w}. In the running example, $\alpha' = \{ 1, 2\}$. These $w$ elements of $\alpha'$ \emph{elements will not necessarily be present in ascending order.}
		\end{itemize}
		Note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \textbf{observe} the invariant $w_{\alpha_i} = z'_{\alpha'_i}$.
	\item \textsc{dependent z}: the tuple of variables from $z$ that (partially) comprise $w'$ in the order in which they are found in $z$ (i.e., the elements of \textsc{dependent z} appear in ascending order, e.g., $\{ z_3, z_4 \}$). In the running example, \textsc{dependent z} is $\{ z_3, z_4 \}$.
		\begin{itemize}
			\item $\beta$: the positions in $z$ of the elements from \textsc{dependent z}. In the running example, $\beta = \{3, 4\}$ (corresponding to $z_3$ and $z_4$). From the definition of \textsc{dependent z}, these $z$ elements of $\beta$ appear in ascending order.
			\item $\beta'$: the respective indices in $w'$ of the variables from \textsc{dependent z}. In the running example, $\beta' = \{3, 1\}$. These $z$ elements of $\alpha'$ \emph{elements will not necessarily be present in ascending order.}
		\end{itemize}
		Again, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \textbf{observe} the invariant $z_{\beta_i} = w'_{\beta'_i}$.
	\item \textsc{dependent w}: the tuple of variables from $w$ that (partially) comprise $w'$ in the order in which they are found in $w$ (i.e., the elements of \textsc{dependent w} appear in ascending order, e.g., $\{ w_1, w_2 \}$). In the running example, \textsc{dependent w} is $\{ w_2 \}$.
		\begin{itemize}
			\item $\bar{\alpha}$: the positions in $w$ of the elements from \textsc{dependent w}. In the running example, $\bar{\alpha} = \{ 2 \}$. From the definition of \textsc{dependent w}, these $w$ elements of $\bar{\alpha}$ appear in ascending order.
			\item $\bar{\alpha}'$: the respective indices in $w'$ of the variables from \textsc{dependent w}. In the running example, $\bar{\alpha}' = \{ 2 \}$. These $w$ elements of $\bar{\alpha}$'s \emph{elements are not necessarily present in ascending order}.
		\end{itemize}
		Again, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \textbf{observe} the invariant $w_{\bar{\alpha}_i} = w'_{\bar{\alpha}'_i}$.
	\item \textsc{independent z}: the tuple of variables from $z$ that (partially) comprise $z'$ in the order in which they are found in $z$ (i.e., the elements of \textsc{independent z} appear in ascending order, e.g., $\{ z_1, z_2 \}$). In the running example, \textsc{independent z} is $\{ z_1, z_2 \}$. The elements in \textsc{independent z} are present in ascending order (e.g., $\{ z_1, z_2 \}$).
		\begin{itemize}
			\item $\bar{\beta}$: one greater, respectively, than the positions in $z$ of the elements from \textsc{independent z}. In the running examples, $\bar{\beta} = \{1, 2 \}$. From the definition of \textsc{independent z}, the elements of $\bar{\beta}$'s elements appear in ascending order.
			\item $\bar{\beta}'$: the respective indices in $z'$ of the variables from \textsc{independent z}. In the running example, $\bar{\beta}' = \{4, 3 \}$. These $z$ elements of $\bar{\beta}'$ \emph{elements are not necessarily present in ascending order}.
		\end{itemize}
		Once more, note that the elements in the ``vanilla'' tuple correspond to variable indices, while elements in the primed tuple correspond to tuple indices. Also, \textbf{observe} the invariant $z_{\bar{\beta}_i} = z'_{\bar{\beta}'_i}$.
\end{itemize}

\section{Approach}
\begin{lemma}
	The length of \textsc{independent w} is the same as that of \textsc{dependent z}.
\end{lemma}
We will denote the length of \textsc{independent w} as $m$. In the running example, $m = 2$.
\subsection{Computing $q'$}
We first define a \textit{square} matrix $\mat{M}^{\alpha\beta} \in\mathbb{R}^{m \times m}$ as being comprised of entries $i \in 1,\ldots,m$ and $j \in 1, \ldots, m$:
\begin{align*}
	\mat{M}^{\alpha\beta}_{ij} = \mat{M}_{\alpha_i\beta_j}
\end{align*}
and a rectangular matrix $\mat{M}^{\bar{\alpha}\beta} \in\mathbb{R}^{(n-m)\times m}$ as being comprised of entries $i \in 1,\ldots,n-m$ and $j \in 1, \ldots, m$:
\begin{align*}
	\mat{M}^{\bar{\alpha}\beta}_{ij} = \mat{M}_{\bar{\alpha}_i\beta_j}
\end{align*}

Likewise, we define vectors $\vect{q}^{\alpha} \in \mathbb{R}^m$ and $\vect{q}^{\bar{\alpha}} \in \mathbb{R}^{(n-m)}$ as being comprised of entries $i \in 1,\ldots,m$ and $j \in 1, \ldots, n-m$:
\begin{align*}
	q^{\alpha}_i & = q_{\alpha_i} \\
	q^{\bar{\alpha}}_j & = q_{\bar{\alpha}_j}
\end{align*}
In the running example---recall that $\alpha = \{1, 3\}, \beta = \{3, 4\},
\bar{\alpha} = \{2 \}$---we highlight the parts of $\vect{q}$ and $\mat{M}$ that correspond to $\textcolor{red}{q^{\alpha}}$, $\textcolor{red}{M^{\alpha\beta}}$ in red, and $\textcolor{blue}{q^{\bar{\alpha}}}$, $\textcolor{blue}{M^{\bar{\alpha}\beta}}$ in blue. Now putting the example into ``tableaux form'':
\begin{center}
	\begin{tabular}{|c|c|c c c c|}
		\hline
		      &  & $z_1$ & $z_2$ & $\textcolor{red}{z_3}$ & $\textcolor{red}{z_4}$\\
		\hline
		$\textcolor{red}{w_1}$ &\textcolor{red}{-3} & 0 & -1 & \textcolor{red}{2} & \textcolor{red}{1}\\
		$\textcolor{blue}{w_2}$ & \textcolor{blue}{6} & 2 & 0 & \textcolor{blue}{-2} & \textcolor{blue}{1}\\
		$\textcolor{red}{w_3}$ & \textcolor{red}{-1} & -1 & -1 & \textcolor{red}{0} & \textcolor{red}{1}\\
		\hline
	\end{tabular}
\end{center}
thereby yielding the following vectors and matrices:
\begin{align*}
		\textcolor{red}{q^{\alpha} = \begin{bmatrix} -3 \\ -1\end{bmatrix}},
		\textcolor{blue}{q^{\bar{\alpha}} = \begin{bmatrix} 6\end{bmatrix}},
		\textcolor{red}{M^{\alpha\beta} = \begin{bmatrix} 2 & 1 \\ 0 & 1\end{bmatrix}},
		\textcolor{blue}{M^{\bar{\alpha}\beta} = \begin{bmatrix} -2 & 1 \end{bmatrix}}
\end{align*}
With the index sets $\alpha', \bar{\alpha}'$ defined in Subsection
\ref{subsec:terminology}, and Equation 10 from Page 71 of~\cite{Cottle:1992}, we
can write $\vect{q}'$ as:
\begin{align}
	\vect{q}'^{\beta'} = -(\mat{M}^{\alpha\beta})^{-1}\vect{q}^{\alpha}
 \tag{2} \\
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
	\vect{q}'^{\bar{\alpha}'} = \vect{q}^{\bar{\alpha}} +
    \mat{M}^{\bar{\alpha}\beta}\vect{q}'^{\beta'}
 \tag{3}
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
\end{align}
where $\vect{q}'^{\alpha'}, \vect{q}'^{\bar{\alpha}'}$ are ``views'' of the
vector $q'$, as $\vect{q}'^{\alpha'}_i = \vect{q}'_{\alpha'_i},
\vect{q}'^{\bar{\alpha}'}_i = \vect{q}'_{\bar{\alpha}'_i}$. In the running
example $\vect{q}'^{\alpha'} = \tr{\begin{bmatrix}1 & 1\end{bmatrix}},
\vect{q}'^{\bar{\alpha}'} = [5]$. \textbf{$\vect{q}'$ is not composed by
stacking $\vect{q}'^{\alpha'}, \vect{q}'^{\bar{\alpha}'}$ as is done in similar procedures in~\cite{Cottle:1992}.}

\subsection{Computing $\mat{M}'_{\textrm{driving}}$}
This computation requires considering two cases for the driving variable, which is an entry in the new independent variable $z'$. The driving variable can be either:
\begin{enumerate}
		\item a dependent variable from $w$.
		\item an independent variable $z$.
\end{enumerate}
in the running example, if the driving variable is $w_1$ or $w_3$, then it belongs to the first case; if the driving variable is $z_2$ or $z_1$, then it belongs to the second case. Let's discuss the two cases separately.

\subsubsection{Driving variable is a dependent variable from $w$}
If the driving variable $z'_{\textrm{driving}}$ is a dependent variable from $w$, then it also belongs to the vector \textsc{independent w}. We denote the index of $z'_{\textrm{driving}}$ in \textsc{independent w} as $\gamma$, namely:
\begin{align}
	w^{\alpha}_\gamma = w_{\alpha_\gamma} = z'_{\textrm{driving}} \tag{4}
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
\end{align}
where $w^{\alpha}$ is the vector \textsc{independent w}. In the running example,
\textsc{independent w} is $\{ w_1, w_3 \}$, thus $\alpha = \{ 1, 3 \}$. If
$z'_{\textrm{driving}} \equiv w_1$, then the index $\gamma \equiv 1$. If
$z'_{\textrm{driving}} \equiv w_3$, then the index $\gamma \equiv 2$. To compute
the column vector $\mat{M}'_{\textrm{driving}}$, we need to first compute the
$\gamma^{\textrm{th}}$ column of the matrix $(\mat{M}^{\alpha\beta})^{-1}$. To
this end, we define a unit vector $\vect{e} \in\mathbb{R}^m$ as:
\begin{align*}
	&e_{\gamma} = 1\\
	&e_i = 0 \quad \text{if } i \neq \gamma
\end{align*}
and we can compute $M'_{\textrm{driving}}$ as:
\begin{align}
	&\mat{M}'^{\beta'}_{\textrm{driving}} =
    (\mat{M}^{\alpha\beta})^{-1}\vect{e}\label{eq:b_prime_alpha_prime}
    \tag{5}\\
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
	&\mat{M}'^{\bar{\alpha}'}_{\textrm{driving}} =
    \mat{M}^{\bar{\alpha}\beta}\mat{M}'_{\textrm{driving}_{\beta'}} \tag{6}
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
\end{align}
Notice that $\mat{M}'_{\textrm{driving}_{\alpha'}}$ is the
$\gamma^{\textrm{th}}$ column of $\mat{M}_{\alpha\beta}^{-1}$ according to Equation~\eqref{eq:b_prime_alpha_prime}.

\subsubsection{Driving variable is an independent variable from $z$}
If the driving variable $z'_{\textrm{driving}}$ is an independent variable from $z$, we denote the position in $z$ of $z'_{\textrm{driving}}$ as $\zeta$. In the running example, if the driving variable is $z_2$, then $\zeta \equiv 2$; if the driving variable is $z_1$, then $\zeta \equiv 1$.

To compute the column vector $\mat{M}'_{\textrm{driving}}$ in $\mat{M}'$, we
need the $\zeta^{\textrm{th}}$ column of $\mat{M}$, denoted $\vect{g}$, which
will be decomposed into two sub-vectors. One sub-vector  $\vect{g}^{\alpha}$
contains the entries with row indices in $\alpha$ while the other,  $\vect{g}^{\bar{\alpha}}$, contains the entries with row indices from $\bar{\alpha}$. Namely:
\begin{align*}
	&g^{\alpha}_i = M_{\alpha_i\zeta}\\
	&g^{\bar{\alpha}}_i = M_{\bar{\alpha}_i\zeta}
\end{align*}

In the running example, $\textcolor{red}{w_1, w_3}$ will be pivoted to $z'$, and
$\textcolor{blue}{w_2}$ will remain in $w'$. If the driving variable is $z_2$,
we highlight the vector $\textcolor{red}{g^{\alpha}},
\textcolor{blue}{g^{\bar{\alpha}}}$ in $\mat{M}$ as:
\begin{center}
\begin{tabular}{|c|cccc|}
	\hline
		& $z_1$ & $z_2$ & $z_3$ & $z_0$\\
		\hline
		$\textcolor{red}{w_1}$ & 0 & \textcolor{red}{-1} & 2 & 1\\
		$\textcolor{blue}{w_2}$ & 2 & \textcolor{blue}{0} & -2 & 1\\
		$\textcolor{red}{w_3}$ & -1 & \textcolor{red}{1} & 0 & 1\\
		\hline
\end{tabular}
\end{center}
so $\textcolor{red}{g^{\alpha}} \equiv \tr{\begin{bmatrix}-1 & 1\end{bmatrix}}, \textcolor{blue}{g^{\bar{\alpha}}} = [0]$.

with the vector $\vect{g}^{\alpha}, \vect{g}^{\bar{\alpha}}$, we can then
compute $\mat{M}'_{\textrm{driving}}$ as
\begin{align}
	&\mat{M}'^{\beta'}_{\textrm{driving}} =
    -(\mat{M}^{\alpha\beta})^{-1}\vect{g}^{\alpha} \tag{7} \\
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
	&\mat{M}'^{\bar{\alpha}'}_{\textrm{driving}} = \vect{g}^{\bar{\alpha}} +
    \mat{M}^{\bar{\alpha}\beta}\mat{M}'^{\beta'}_{\textrm{driving}} \tag{8}
  % NOTE: Do not change equation number without changing
  % unrevised_lemke_solver.cc
\end{align}

\bibliographystyle{abbrv}
\begin{thebibliography}{56}
\bibitem{Cottle:1992}
Richard W. Cottle, Jong-Shi Pang, and R.E. Stone. \emph{The Linear
Complementarity Problem}, Academic Press, 1992.
\end{thebibliography}

\end{document}