[Tex/LaTex] Algorithm as a figure (to include additional caption below the figure)

algorithmscaptionsfloats

I have an algorithm in latex, and I need to add an addition caption underneath the algorithm (just like in a figure at the bottom: "Figure 1: Whatever it is". I tried simply changing the \begin{algorithm} to \begin{figure}, this does put a caption below the algorithm, however, this also changes the layout of the algorithm, and I don't want that to happen. It is possible to remain the same layout, but somehow add an additional caption just like in figure?

This is my code:

\begin{algorithm}[t]
\caption{Ant Colony Algorithm}
\label{ACA}
\begin{algorithmic}
\STATE Set parameters, initialize pheromone trails
\WHILE{stopping condition not met}
\STATE construct ant paths
\STATE local search (optional)
\STATE update pheromone
\ENDWHILE
\STATE \textbf{output:} the ACO solution path
\end{algorithmic}
\end{algorithm}

Best Answer

The algorithm float uses the ruled style of the float package, and this style can be changed.

\documentclass{article}

\usepackage{algorithm,algorithmic}
\makeatletter
\renewcommand\fs@ruled{%
  \def\@fs@cfont{\rmfamily}%
  \let\@fs@capt\floatc@plain%
  \def\@fs@pre{\hrule height.8pt depth0pt \kern2pt}%% or use \def\@fs@pre{} to get rid of the top rule
  \def\@fs@post{\kern2pt\hrule\relax}%% or use \def\@fs@post{} to get rid of the last rule
  \def\@fs@mid{\kern2pt\hrule\kern2pt}%% or use \def\@fs@mid{} to get rid of the middle rule
  \let\@fs@iftopcapt\iffalse}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{algorithm}[t]
\caption{Ant Colony Algorithm}
\label{ACA}
\begin{algorithmic}
\STATE Set parameters, initialize pheromone trails
\WHILE{stopping condition not met}
\STATE construct ant paths
\STATE local search (optional)
\STATE update pheromone
\ENDWHILE
\STATE \textbf{output:} the ACO solution path
\end{algorithmic}
\end{algorithm}

For reference:
\begin{table}[hb]
  \caption{Table caption}
\end{table}
\end{document}

sample output

If you want to get rid of the last line below the caption (which looks better to me), use \def\@fs@post{} as indicated in the code. Likewise, you can get rid of any of the rules, if you wish so.