LaTeX算法排版

算法排版

  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.效果

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值