Skip to content

Instantly share code, notes, and snippets.

@rocarvaj
Created February 18, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocarvaj/9080219 to your computer and use it in GitHub Desktop.
Save rocarvaj/9080219 to your computer and use it in GitHub Desktop.
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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment