%\VignetteIndexEntry{maxkcut}
% 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{The Max-kCut Problem}


%% need no \usepackage{Sweave.sty}

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

\maketitle

Similar to the Max-Cut problem, the Max-kCut problem asks, given a graph $\m{G} = (\m{V},\m{E})$ and an integer $k$, does a cut exist of at least size $k$. For a given (weighted) adjacency matrix $\m{B}$ and integer $k$, the Max-kCut problem is formulated as the following primal problem

\[
\begin{array}{ll}
\underset{\m{X}}{\text{minimize}} & \langle \m{C},~\m{X} \rangle \\
\text{subject to} & \\
 & \begin{array}{rl}
diag(\m{X}) &=~~\ve{1} \\
X_{ij} &\geq~~ 1/(k-1) \quad \forall~i \neq j\\
\m{X} &\in ~~\mathcal{S}_{n}
\end{array}
\end{array}
\]

Here, $\m{C} = -(1-1/k)/2 * (diag(\m{B}\ve{1})-\m{B})$. The Max-kCut problem is slightly more complex than the Max-Cut problem due to the inequality constraint. In order to turn this into a standard SQLP, we must replace the inequality constraints with equality constraints, which we do by introducing a slack variable $\ve{x}^{l}$, allowing the problem to be restated as

\[
\begin{array}{ll}
\underset{\m{X}}{\text{minimize}}  & \langle \m{C},~\m{X} \rangle \\
\text{subject to} & \\
 & \begin{array}{rl}
diag(\m{X}) &=~~\ve{1} \\
X_{ij} - x^{l} &=~~ 1/(k-1) \quad \forall~i \neq j\\
\m{X} &\in ~~\mathcal{S}^{n} \\
\ve{x}^{l} &\in ~~ \mathcal{L}^{n(n+1)/2} 
\end{array}
\end{array}
\]

The function \verb!maxkcut! takes as input an adjacency matrix \verb!B! and an integer \verb!k!, and returns the optimal solution using \verb!sqlp!.

\begin{verbatim}
R> out <- maxkcut(B,k)
\end{verbatim}

\section*{Numerical Example}

To demonstrate the output provided by \verb!sqlp!, consider the adjacency matrix

\begin{verbatim}
R> data(Bmaxkcut)
R> Bmaxcut

      V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
 [1,]  0  0  0  1  0  0  1  1  0   0
 [2,]  0  0  0  1  0  0  1  0  1   1
 [3,]  0  0  0  0  0  0  0  1  0   0
 [4,]  1  1  0  0  0  0  0  1  0   1
 [5,]  0  0  0  0  0  0  1  1  1   1
 [6,]  0  0  0  0  0  0  0  0  1   0
 [7,]  1  1  0  0  1  0  0  1  1   1
 [8,]  1  0  1  1  1  0  1  0  0   0
 [9,]  0  1  0  0  1  1  1  0  0   1
[10,]  0  1  0  1  1  0  1  0  1   0
\end{verbatim}

Like the max-cut problem, here we are interested in the primal objective function. Like the max-cut problem, we take the negated value. We will use a value of $k=5$ in the example.

\begin{verbatim}
R> out <- maxkcut(Bmaxkcut,5)

R> -out$pobj
[1] 19
\end{verbatim}

Note also that the returned matrix \verb!X! is a correlation matrix

\begin{verbatim}
      [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
V1   1.000  0.381  0.503 -0.250  0.403  0.347 -0.250 -0.250  0.060  0.181
V2   0.381  1.000  0.231 -0.250  0.627  0.380 -0.250  0.160 -0.250 -0.250
V3   0.503  0.231  1.000  0.395  0.387  0.597  0.185 -0.250  0.074  0.089
V4  -0.250 -0.250  0.395  1.000  0.134  0.261  0.449 -0.250  0.163 -0.250
V5   0.403  0.627  0.387  0.134  1.000  0.348 -0.250 -0.250 -0.250 -0.250
V6   0.347  0.380  0.597  0.261  0.348  1.000  0.224  0.180 -0.250  0.239
V7  -0.250 -0.250  0.185  0.449 -0.250  0.224  1.000 -0.250 -0.250 -0.250
V8  -0.250  0.160 -0.250 -0.250 -0.250  0.180 -0.250  1.000  0.118  0.216
V9   0.060 -0.250  0.074  0.163 -0.250 -0.250 -0.250  0.118  1.000 -0.250
V10  0.181 -0.250  0.089 -0.250 -0.250  0.239 -0.250  0.216 -0.250  1.000
\end{verbatim}
\end{document}