LaTeX伪代码编辑

代码以及伪代码在LaTeX中的实现,尽量选择自带宏包,以方便有效为目的。

宏包:\usepackage[ruled]{algorithm2e}

其中参数部分[ruled] 作用是实现代码的页面居顶。

\begin{algorithm}%[H]
    \caption{The Cascading Bandits on Mobility Management}
    \label{alg:CascadeBandits}
    %\KwIn{this text}
    %\KwOut{how to write algorithm with \LaTeX2e }

    Initialization: Observe $\omega_0$, and $\forall e \in E : T_0 (e) = 1, \quad \hat \omega _1 (e)\gets \omega_0(e)$\;

    \While{$t \leq T$}{

        Compute UCBs $U_t(e)$ for every BSs according to equation \ref{equ:UCB};

        //Recommend a list of $L$ BSs from the NCL

        Let $a_1^t,a_2^t,\dots,a_L^t$ be $L$ BSs with largest UCBs

        $F_t \gets (a_1^t,a_2^t,\dots,a_L^t)$

        UE check all BSs on the list and get the feedback $C_t$

        //Update statistics

        $\forall e \in F $:$T_t(e)\gets T_{t-1}(e)$

        \ForAll {$k=1,2,\dots,\min \{C_t,L\}$}{

            $e\gets a_k^t$

            $T_t(e) \gets T_t(e)+1$

            $\hat \omega _{T_{t}(e)}(e)\gets \frac{T_{t-1}(e) \hat \omega_{T_{t-1}(e)}(e)+ \mathds 1{C_t =k}}{T_t(e)}$

        $t\gets t+1$
}
}
\end{algorithm}

其中命令 \KwIn \KwOut 表示输入输出,

效果如下:

伪代码

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值