%\VignetteIndexEntry{lmi}
% JSS Article Template
\documentclass{article}


%%% Additional Packages %%%

% Algorithms
% http://tex.stackexchange.com/questions/229355/algorithm-algorithmic-algorithmicx-algorithm2e-algpseudocode-confused
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx


% Font stuff
\usepackage[T1]{fontenc}% for correct hyphenation and T1 encoding
%\usepackage{lmodern}% latin modern font
\usepackage[american]{babel}% for American English

% Math fonts/symbols
\usepackage{amsmath}% sophisticated mathematical formulas with amstex (includes \text{})
\usepackage{mathtools}% fix amsmath deficiencies
\usepackage{amssymb}% sophisticated mathematical symbols with amstex
\usepackage{amstext}% ams mathematical fonts
\usepackage{amsfonts}% ams mathematical fonts

% Figures
\usepackage{graphicx}% for including figures

%%% Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% vetors
\newcommand{\ve}[1]{\mathbf{#1}}           % for vetors
\newcommand{\sv}[1]{\boldsymbol{#1}}   % for greek letters
\newcommand{\m}[1]{\mathbf{#1}}               % for matrices
\newcommand{\sm}[1]{\boldsymbol{#1}}   % for greek letters
\newcommand{\tr}[1]{{#1}^{\mkern-1.5mu\mathsf{T}}}              % for transpose
\newcommand{\norm}[1]{||{#1}||}              % for transpose
\newcommand*{\mve}{\operatorname{ve}}
\newcommand*{\trace}{\operatorname{trace}}
\newcommand*{\rank}{\operatorname{rank}}
\newcommand*{\diag}{\operatorname{diag}}
\newcommand*{\vspan}{\operatorname{span}}
\newcommand*{\rowsp}{\operatorname{rowsp}}
\newcommand*{\colsp}{\operatorname{colsp}}
\newcommand*{\svd}{\operatorname{svd}}
\newcommand*{\edm}{\operatorname{edm}}  % euclidean distance matrix (D * D)


% statistical
\newcommand{\widebar}[1]{\overline{#1}}  

% 
% operators
\newcommand{\Had}{\circ}
\DeclareMathOperator*{\lmin}{Minimize}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\arginf}{arg\,inf}
\DeclareMathOperator*{\argsup}{arg\,sup}
%\newcommand*{\arginf}{\operatorname*{arginf}}
%\newcommand*{\argsup}{\operatorname*{argsup}}

% Sets
\newcommand*{\intersect}{\cap}
\newcommand*{\union}{\cup}
\let\oldemptyset\emptyset
\let\emptyset\varnothing

% Fields, Reals, etc. etc
\newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\Reals}{\field{R}}
\newcommand{\Integers}{\field{Z}}
\newcommand{\Naturals}{\field{N}}
\newcommand{\Complex}{\field{C}}
\newcommand{\Rationals}{\field{Q}}

% Hyphenation
\hyphenation{Ar-chi-me-dean}

% Editorial
\newcommand*{\TODO}[1]{\textcolor{red}{TODO: #1}}
\newcommand*{\NOTE}[1]{\textcolor{blue}{Note: #1}}
\newtheorem{theorem}{Theorem}
\newtheorem{Proof}{Proof}

\usepackage[total={6.5in,8.75in}, top=0.9in, left=0.7in, right=0.7in, includefoot]{geometry}


% Misc
%\makeatletter
%\newcommand\myisodate{\number\year-\ifcase\month\or 01\or 02\or 03\or 04\or 05\or 06\or 07\or 08\or 09\or 10\or 11\or 12\fi-\ifcase\day\or 01\or 02\or 03\or 04\or 05\or 06\or 07\or 08\or 09\or 10\or 11\or 12\or 13\or 14\or 15\or 16\or 17\or 18\or 19\or 20\or 21\or 22\or 23\or 24\or 25\or 26\or 27\or 28\or 29\or 30\or 31\fi}% create iso date
\makeatother
%\newcommand*{\abstractnoindent}{}% define abstract such that it has no indent
%\let\abstractnoindent\abstract
%\renewcommand*{\abstract}{\let\quotation\quote\let\endquotation\endquote
%  \abstractnoindent}
%\deffootnote[1em]{1em}{1em}{\textsuperscript{\thefootnotemark}}% setting for footnote

\author{Adam Rahman}
\title{Linear Matrix Inequality Problems}


%% need no \usepackage{Sweave.sty}

\begin{document}
\SweaveOpts{concordance=FALSE}

\maketitle

We consider three distinct linear matrix inequality problems, all written in the form of a dual optimization problem. The first linear matrix inequality problem we will consider is defined by the following optimization equation for some $n\times p$ matrix $\m{B}$ known in advance

\[
\begin{array}{ll}
\underset{\eta,~\m{Y}}{\text{maximize}} & -\eta \\
\text{subject to} & \\
 & \begin{array}{rl}
\m{B}\m{Y} + \m{Y}\tr{\m{B}} &\preceq~~ 0 \\
-\m{Y} &\preceq~~ -\m{I} \\
\m{Y} - \eta \m{I} &\preceq~~ 0 \\
Y_{11} &=~~ 1, \quad \m{Y} \in \mathcal{S}^{n}
\end{array}
\end{array}
\]

The function \verb!lmi1! takes as input a matrix \verb!B!, and returns the optimal solution using \verb!sqlp!.

\begin{verbatim}
R> out <- lmi1(B)
\end{verbatim}

As a numerical example, consider the following matrix:

\begin{verbatim}
R> B <- matrix(c(-1,5,1,0,-2,1,0,0,-1), nrow=3)
R> B

     [,1] [,2] [,3]
[1,]   -1    0    0
[2,]    5   -2    0
[3,]    1    1   -1

R> out <- lmi1(B)
\end{verbatim}

Here, the output of interest, $\m{P}$, is stored in the vector \verb!y!.

\begin{verbatim}
R> P <- smat(blk,1, out$y)

             [,1]         [,2]         [,3]
[1,] 1.000000e+00 9.453573e-07 7.251638e-07
[2,] 9.453573e-07 3.244985e+00 1.722086e+00
[3,] 7.251638e-07 1.722086e+00 2.321009e+00
\end{verbatim}

The second linear matrix inequality problem is

\[
\begin{array}{ll}
\underset{\m{P},~\ve{d}}{\text{maximize}} & -tr(\m{P}) \\
\text{subject to} & \\
& \begin{array}{rl}
\m{A}_{1}\m{P} + \m{P}\tr{\m{A}_{1}} + \m{B}*diag(\ve{d})*\tr{\m{B}} &\preceq~~ 0 \\
\m{A}_{2}\m{P} + \m{P}\tr{\m{A}_{2}} + \m{B}*diag(\ve{d})*\tr{\m{B}} &\preceq~~ 0 \\
-\ve{d} &\preceq~~ 0 \\
\sum_{i}^{p} d_{i}  &=~~ 1
\end{array}
\end{array}
\]

Here, the matrices $\m{B}$, $\m{A}_{1}$, and $\m{A}_{2}$ are known in advance. 

The function \verb!lmi2! takes the matrices \verb!A1!, \verb!A2!, and \verb!B! as input, and returns the optimal solution using \verb!sqlp!.

\begin{verbatim}
R> out <- lmi2(A1,A2,B)
\end{verbatim}

As a numerical example, consider the following matrices

\begin{verbatim}
R> A1 <- matrix(c(-1,0,1,0,-2,1,0,0,-1),3,3)

     [,1] [,2] [,3]
[1,]   -1    0    0
[2,]    0   -2    0
[3,]    1    1   -1

R> A2 <- A1 + 0.1*t(A1)

     [,1] [,2] [,3]
[1,] -1.1  0.0  0.1
[2,]  0.0 -2.2  0.1
[3,]  1.0  1.0 -1.1

R> B <- matrix(c(1,3,5,2,4,6),3,2)

     [,1] [,2]
[1,]    1    2
[2,]    3    4
[3,]    5    6

R> out <- lmi2(A1,A2,B)
R> blk <- out$blk
R> At <- out$At
R> C <- out$C
R> b <- out$b

R> out <- sqlp(blk,At,C,b)
\end{verbatim}

Like \verb!lmi1!, the outputs of interest $\m{P}$ and $\ve{d}$ are stored in the \verb!y! output variable

\begin{verbatim}
R> n <- ncol(A1)
R> dlen <- ncol(B)
R> N <- n*(n+1)/2

R> P <- smat(blk,1,out$y[1:N])

         [,1]     [,2]      [,3]
[1,] 1.074734 1.243470  3.575851
[2,] 1.243470 2.366032  6.167900
[3,] 3.575851 6.167900 22.255810

R> d <- out$y[N + c(1:dlen)]

             [,1]
[1,] 1.000000e+00
[2,] 3.355616e-11
\end{verbatim}

The final linear matrix inequality problem originates from a problem in control theory (\cite{boyd1994linear}) and requires three matrices be known in advance, $\m{A}$, $\m{B}$, and $\m{G}$

\[
\begin{array}{ll}
\underset{\eta,~\m{P}}{\text{maximize}} & \eta \\
\text{subject to} & \\
 & \left[\begin{array}{cc}
\m{A}\m{P} + \m{P}\tr{\m{A}} & \m{0} \\
\m{B}\m{P} & \m{0}
\end{array} \right]
+ \eta
\left[\begin{array}{cc}
\m{0} & \m{0} \\
\m{0} & \m{I}
\end{array} \right]
\preceq
\left[\begin{array}{cc}
-\m{G} & \m{0} \\
\m{0} & \m{0}
\end{array} \right]
\end{array}
\]

The function \verb!lmi3! takes as input the matrices \verb!A!, \verb!B!, and \verb!G!, and returns the optimal solution using \verb!sqlp!.

\begin{verbatim}
R> out <- lmi3(A,B,G)
\end{verbatim}

As a numerical example, consider the following matrices

\begin{verbatim}
R> A <- matrix(c(-1,0,1,0,-2,1,0,0,-1),3,3)

     [,1] [,2] [,3]
[1,]   -1    0    0
[2,]    0   -2    0
[3,]    1    1   -1

R> B <- matrix(c(1,2,3,4,5,6), 2, 3)

     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6

R> G <- matrix(1,3,3)

     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
[3,]    1    1    1

R> out <- lmi3(A,B,G)
\end{verbatim}

Like the other two linear matrix inequality problems, the matrix of interest is stored in the output vector \verb!y!

\begin{verbatim}
R> n <- ncol(A)
R> N <- n*(n+1)/2
R> blktmp <- matrix(list(),1,2)
R> blktmp[[1,1]] <- "s"
R> blktmp[[1,2]] <- n

R> P <- smat(blktmp,1,out$y[1:N])

           [,1]      [,2]       [,3]
[1,]  15.568926 -13.20284  -6.006543
[2,] -13.202839  57.77663 -28.927474
[3,]  -6.006543 -28.92747  39.165821
\end{verbatim}

\bibliographystyle{plain}
\bibliography{sdpt3r}
\end{document}