rocarvaj
2/18/2014 - 9:12 PM

Example of algorithm/algorithmic packages

Example of algorithm/algorithmic packages

\usepackage{algorithm}
\usepackage{algorithmic}

\renewcommand{\algorithmicensure}{\textbf{Output:}}

\begin{algorithm}[!ht]
    \caption{Solving the Lagrangian dual for (CF)}
\label{alg:lower_bound}
\begin{algorithmic}[1]
    \ENSURE Lower bound $\underbar z$ and upper bound $\bar z$.
    \STATE $S = \emptyset$, $\lambda = 0$, $\pi = 0$ 
    \WHILE{Termination condition is not met}
    \FOR{$l\in L$}
    \STATE Compute $z_l = \min\{F_l(x^l, y^l; \lambda, \pi)\colon 
    y^l\in Y\setminus S, x^l\in X_l(y^l)\}$\label{alg:solve_subproblem}
    \STATE Let $(\bar x^l, \bar y^l)$ be the optimal solution obtained.
    \ENDFOR
    \STATE \emph{//Lower bound}
    \STATE Compute $\underbar{z} = \sum_{l\in L} z_l$
    \STATE
    \STATE \emph{//Upper bound}
    \FOR{$l\in L$}
    \STATE Evaluate $\bar y^l$ and update $\bar z$\label{alg:evaluate}.
    \STATE $S \leftarrow S\cup\{\bar y^l\}$\label{alg:add_cut}
    \ENDFOR
    \STATE Update $\lambda$ and $\pi$.\label{alg:update_lambda}
    \ENDWHILE
\end{algorithmic}
\end{algorithm}