为什么算法会出现这样的情况?

为什么算法会出现这样的情况?

我正在尝试编写算法,但它不起作用。

\usepackage[options ]{algorithm2e}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

    \begin{algorithm}
\SetAlgoLined
 \caption{Log Linear Learning algorithm}\label{euclid}
 \begin{algorithmic}[1]{
 & initialization: $t=0,T$ and $action(0)=random \in A $ \;
 \While{t\leq T}{
    pick a random $player_i \in P$\;
    fix other players $action_{-i}(t+1)=action_{-i}(t)$\;
    calculate reward vector $R\in R^n$\;
    calculate distribution vector $\alpha_j=1/z e^{r_j/temp}$\;
    choose action_i randomly using distribution vector \alpha\;
    $t=t+1$\;
    }
 }
 \end{algorithmic}
\end{algorithm}

但事实就是这样的。 无法正常工作

答案1

您必须正确使用algpseudocode说明,不要忽视代码中出现的大量错误。

\documentclass{article}

\usepackage{amsmath,amssymb}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{document}

\begin{algorithm}
%\SetAlgoLined
\caption{Log Linear Learning algorithm}\label{loglinear}
\begin{algorithmic}[1]
\State initialization: $t=0,T$ and $\mathit{action}(0)=\mathit{random} \in A$\;
\While{$t\leq T$}
   \State pick a random $\mathit{player}_i \in P$\;
   \State fix other players $\mathit{action}_{-i}(t+1)=\mathit{action}_{-i}(t)$\;
   \State calculate reward vector $R\in \mathbb{R}^n$\;
   \State calculate distribution vector $\alpha_j=1/z e^{r_j/\mathit{temp}}$\;
   \State choose $\mathit{action}_i$ randomly using distribution vector $\alpha$\;
   \State $t=t+1$\;
\EndWhile
\end{algorithmic}
\end{algorithm}

\end{document}

在此处输入图片描述

相关内容