LaTeX算法排版

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wcs_152/article/details/82025054

算法排版

  1. 宏包
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}

2.代码

\begin{frame}[plain,t]
\frametitle{The uncapacitated facility location problem}
\vspace{3ex}
\xiaowuhao
\begin{algorithm}[H]
    \scriptsize
    \label{alg10}
    \caption{Algorithm for the uncapacitated facility location problem}
%   \KwIn{input parameters A, B, C}%输入参数
%   \KwOut{output result}%输出    
    $v \leftarrow 0 $,$ w\leftarrow 0 $\;
    $ S\leftarrow D $\;
    $T \leftarrow \varnothing $\;
    \While{$ S\neq \varnothing $}{
        //While not all clients neighbor a facility in $ T $\;
        Increase ${v}_{j}$ for all $ j\in S $ and $ {w}_{ij} $ for all $ i\in N(j) $,$ j\in S $ uniformly until some $i \in T$ or some $ i\notin T $ has a tight dual inequality\;

        \If{some $ j\in S $ neighbors some $ i\in T $}{
            $ S\leftarrow S-\{j\} $\;
        }
        \If{$ i\notin T $ has a tight dual inequality}{
            $ T\leftarrow T\cup \{i\} \qquad $// facility $ i $ is added to $ T $\;
            $ S\leftarrow S-N(i) $\; 
        }
    }
    $ {T}^{\prime}\leftarrow \varnothing $ \;
    \While{$ T\neq \varnothing $}{
        Pick $ i\in T;{T}^{\prime}\leftarrow {T}^{\prime}\cup \{i\} $\;
        //Remove all facilities $ h $ if some client $ j $ contributes to $ h $ and $ i $\;
        $ T\leftarrow T-\{ h\in T:\exists j\in D,{w}_{ij}>0 $ and $ {w}_{hj}>0 \} $\;
    }
\end{algorithm}
\end{frame}

3.效果

这里写图片描述

猜你喜欢

转载自blog.csdn.net/wcs_152/article/details/82025054
今日推荐