\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{cleveref}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{groupplots}

\title{Figures for ``performance enhancements'' paper}
\author{Chris Coey, Lea Kapelevich, Juan Pablo Vielma}
\date{February 2022}

\begin{document}

\maketitle

% figure 1
\begin{figure}[!htb]
\centering
\begin{tikzpicture}
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=0.9cm},
    width = 5.1cm,
    height = 3.8cm,
    % width = 7cm,
    % height = 5cm,
    scale only axis,
    ymin=0, 
    ybar,
    table/col sep=comma,
    typeset ticklabels with strut,
    ]
% 
\nextgroupplot[
    xlabel = instance size ($n + p + q$), 
    xmin=0,
    xmax=5,
    xtick={0,1,2,3,4,5},
    xticklabels={$10^0$,$10^1$,$10^2$,$10^3$,$10^4$,$10^5$},
    hist={bins=20, data min=0, data max=5},
    ]
\addplot+ [] table [y index=0, y=log_npq] {csvs/inst_stats.csv};
% 
\nextgroupplot[
    xlabel = exotic cone count ($K$),
    xmin=0,
    xmax=3.5,
    xtick={0,1,2,3},
    xticklabels={$10^0$,$10^1$,$10^2$,$10^3$},
    hist={bins=20, data min=0, data max=4},
    ]
]
\addplot+ [] table [y index=0, y=log_numcones] {csvs/inst_stats.csv};
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Histograms summarizing the benchmark instances in the primal conic form \cref{eq:prim}.
Instance size (log scale) is the sum of the primal variable, equality, and conic constraint dimensions.
Exotic cone count (log scale) is the number of exotic cones comprising the Cartesian product cone.
}
\label{fig:npqKhist}
\end{figure}

% figure 2
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[]
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=0.8cm},
    width = 5.05cm,
    height = 4cm,
    % width = 7cm,
    % height = 5cm,
    scale only axis,
    ymin=0, 
    ybar,
    table/col sep=comma,
    typeset ticklabels with strut,
    ]
% 
\nextgroupplot[
    xlabel = iteration count, 
    xtick={0,1,2,3}, 
    xticklabels={$10^0$,$10^1$,$10^2$,$10^3$},
    xmax=3,
    xmin=0,
    hist={bins=20, data min=0, data max=3},
    ]
\addplot+ [
    red!60,
    fill opacity=0.2,
    ] table [y index=0, y=log_iters]  {csvs/basicconv.csv};
\addplot+ [
    blue!60,
    fill opacity=0.4,
    ] table [y index=0, y=log_iters]  {csvs/combconv.csv};
\legend{basic,comb}
% 
\nextgroupplot[
    xlabel = solve time (seconds),
    xtick={-4,-2,0,2,4}, 
    xticklabels={$10^{-4}$,$10^{-2}$,$10^0$,$10^2$,$10^4$},
    xmax=4,
    xmin=-4.5,
    hist={bins=20, data min=-4, data max=4},
    ]
\addplot+ [
    red!60,
    fill opacity=0.2,
    ] table [y index=0, y=log_solve_time] {csvs/basicconv.csv};
\addplot+ [
    blue!60,
    fill opacity=0.4,
    ] table [y index=0, y=log_solve_time] {csvs/combconv.csv};
\legend{basic,comb}
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Overlayed histograms of iteration count (left, log scale) and solve time (right, log scale, in seconds) for the \emph{basic} and \emph{comb} stepping procedures, excluding instances that fail to converge.
}
\label{fig:solvehist}
\end{figure}

% figure 3
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[]
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=1.1cm},
    width = 4.6cm,
    height = 4.4cm,
    % width = 6.4cm,
    % height = 5cm,
    scale only axis,
    table/col sep=comma,
    xmode = log,
    xlabel = barrier parameter ($\nu$),
    xticklabel style={/pgf/number format/fixed},
    ]
% 
\nextgroupplot[
    title = basic,
    ylabel = iteration count,
    ]
\addplot+ [only marks, mark size = 0.75pt] table [x=nu, y=iters] {csvs/basicconv.csv};
% 
\nextgroupplot[
    title = comb,
]
\addplot+ [only marks, mark size = 0.75pt] table [x=nu, y=iters] {csvs/combconv.csv};
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Iteration count against instance barrier parameter for the \emph{basic} (left) and \emph{comb} (right) stepping procedures, excluding instances that fail to converge.
}
\label{fig:nuiter}
\end{figure}

% figure 4
\begin{figure}[!htb]
\centering
\begin{tikzpicture}
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=0.9cm},
    width = 5.1cm,
    height = 3.8cm,
    % width = 7cm,
    % height = 5cm,
    scale only axis,
    xmin=0, 
    ymin=0, ymax=1,
    no markers,
    every axis plot/.append style={line width=1pt},
    legend pos = south east,
    x tick label style={/pgf/number format/.cd, fixed},
    table/col sep=comma,
    ]
% 
\nextgroupplot[
    title = iteration count, 
    xmax=5, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/basic_vs_comb_iters.csv};
\addplot [red] table [x=x, y=y] 
{csvs/comb_vs_basic_iters.csv};
\legend{basic,comb};
% 
\nextgroupplot[
    title = solve time,
    xmax=4, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/basic_vs_comb_solve_time.csv};
\addplot [red] table [x=x, y=y] 
{csvs/comb_vs_basic_solve_time.csv};
\legend{basic,comb};
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Performance profiles (see \cref{sec:testing:method}) of iteration count (left) and solve time (right) for the four stepping enhancements overall.
}
\label{fig:perftotal}
\end{figure}

% figure 5
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[]
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=1.1cm},
    width = 4.6cm,
    height = 4.4cm,
    % width = 6.4cm,
    % height = 5cm,
    scale only axis,
    table/col sep=comma,
    xticklabel style={/pgf/number format/fixed},
    ]
% 
\nextgroupplot[
    xmode = log,
    ymode = log,
    xlabel = instance size ($n + p + q$),
    ylabel = solve time (seconds),
    ]
\addplot+ [only marks, mark size = 0.75pt] table [x=npq, y=solve_time] {csvs/combconv.csv};
% 
\nextgroupplot[
    xmin = 0,
    ymode = log,
    xlabel = proportion of time in \emph{RHS},
    ]
\addplot+ [only marks, mark size = 0.75pt] table [x=prop_rhs, y=solve_time] {csvs/combconv.csv};
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Solve time (log scale, in seconds) for the \emph{comb} stepping procedure against (left) instance size (log scale) and (right) the proportion of solve time spent in \emph{RHS}, excluding instances that fail to converge.
}
\label{fig:comb}
\end{figure}

% figure 6
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[]
\begin{groupplot}[
    group style = {group size=2 by 1, horizontal sep=1cm},
    width = 4.8cm,
    height = 4.4cm,
    % width = 6.6cm,
    % height = 5cm,
    scale only axis,
    table/col sep=comma,
    xticklabel style={/pgf/number format/fixed},
    ]
% 
\nextgroupplot[
    ylabel = relative improvement,
    xmin = 0,
    ymax = 1, 
    xlabel = iteration count,
    ]
\addplot+ [only marks, mark size = 0.75pt] table [x=iters, y=iters_impr, col sep=comma] {csvs/basiccombconv.csv};
% 
\nextgroupplot[
    xmode = log,
    xlabel = solve time (seconds),
    ymax = 1, 
    ]
\addplot+ [only marks, mark size = 0.75pt] table [x=solve_time, y=time_impr, col sep=comma] {csvs/basiccombconv.csv};
% 
\end{groupplot}
\end{tikzpicture}
\caption{
Relative improvement, from \emph{basic} to \emph{comb}, in iteration count (left) or solve time (right) against iteration count or solve time (in seconds) respectively for \emph{comb}, over the 356 instances on which both \emph{basic} and \emph{comb} converge.
}
\label{fig:relimpr}
\end{figure}

% figure 7
\begin{figure}[!p]
\centering
\begin{tikzpicture}
\begin{groupplot}[
    group style = {group size=2 by 4, vertical sep=0.9cm, horizontal sep=0.9cm},
    width = 5.05cm,
    height = 3.5cm,
    % width = 7cm,
    % height = 3.8cm,
    scale only axis,
    xmin=0, 
    ymin=0, ymax=1,
    no markers,
    every axis plot/.append style={line width=1pt},
    legend pos = south east,
    x tick label style={/pgf/number format/.cd, fixed},
    title style={yshift=5pt},
    table/col sep=comma,
    ]
% 
\nextgroupplot[
    title = iteration count, 
    xmax=2.5, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/basic_vs_prox_iters.csv};
\addplot [red] table [x=x, y=y] 
{csvs/prox_vs_basic_iters.csv};
\legend{basic,prox};
% 
\nextgroupplot[
    title = solve time,
    xmax=2.5, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/basic_vs_prox_solve_time.csv};
\addplot [red] table [x=x, y=y] 
{csvs/prox_vs_basic_solve_time.csv};
\legend{basic,prox};
% 
\nextgroupplot[
    xmax=2, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/prox_vs_toa_iters.csv};
\addplot [red] table [x=x, y=y] 
{csvs/toa_vs_prox_iters.csv};
\legend{prox,TOA};
% 
\nextgroupplot[
    xmax=1.5, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/prox_vs_toa_solve_time.csv};
\addplot [red] table [x=x, y=y] 
{csvs/toa_vs_prox_solve_time.csv};
\legend{prox,TOA};
% 
\nextgroupplot[
    xmax=1, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/toa_vs_curve_iters.csv};
\addplot [red] table [x=x, y=y] 
{csvs/curve_vs_toa_iters.csv};
\legend{TOA,curve};
% 
\nextgroupplot[
    xmax=2, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/toa_vs_curve_solve_time.csv};
\addplot [red] table [x=x, y=y] 
{csvs/curve_vs_toa_solve_time.csv};
\legend{TOA,curve};
% 
\nextgroupplot[
    xmax=2, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/curve_vs_comb_iters.csv};
\addplot [red] table [x=x, y=y] 
{csvs/comb_vs_curve_iters.csv};
\legend{curve,comb};
% 
\nextgroupplot[
    xmax=2, % adjust
    ]
\addplot [black] table [x=x, y=y] 
{csvs/curve_vs_comb_solve_time.csv};
\addplot [red] table [x=x, y=y] 
{csvs/comb_vs_curve_solve_time.csv};
\legend{curve,comb};
% 
\end{groupplot}
\end{tikzpicture}
% \setlength{\abovecaptionskip}{0pt plus 0pt minus 0pt}
\caption{
Performance profiles (see \cref{sec:testing:method}) of iteration count (left column) and solve time (right column) for the four stepping enhancements (rows).
}
\label{fig:perf}
\end{figure}

\end{document}
