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 表示输入输出,

效果如下:

LaTeX伪代码编辑_第1张图片

你可能感兴趣的:(Bandit-Pro)