I am trying to write the following algorithm in LaTex using algorithm2e package.
\IncMargin{1em}
\begin{algorithm}
\caption{An example}
\SetNoFillComment
\DontPrintSemicolon
\BlankLine
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{set ($x$), $y$, $Q$, $x_t$, epsilon (\varepsilon)}
\Output{$G_r$}
\BlankLine
$x$ = \{$x_1$, $x_2$,\dots\}; $x_t$ \in $x$\;
\\$y$ = \{$y_1$, $y_2$,\dots\}\;
\SetKwFunction{Fmain}{main}
\SetKwProg{Fn}{Function}{:}{end}
\Fn{\Fmain{}}{
\eIf {condition 1}
{do this\;
do this\;
\eIf {condition 11}
{$x_t$ \leftarrow $\max\limits_y Q(x_t,.)$\;}
{x_t \leftarrow $rand$\quad$num$\;}
$G_u$ =$x_t$\;
}
{$G_u$ = 0\;}
return $G_u$\;}
\end{algorithm}
But the above code gave the following output. Would anyone please help to correct my code? Thank you.
Best Answer
You get many (really many) errors with that input, due to inconsistent usage of
$
to delimit math formulas.