How to see the Steps number in an algorithm
Some changes and the numbers appear:
\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}
%\DontPrintSemicolon % Some LaTeX compilers require you to use \dontprintsemicolon instead
\KwIn{a,b,c,d}
\KwOut{e,r}
Calculate $x$, and $y$\\
Check, \linebreak
%\renewcommand{\labelenumi}{(\Roman{enumi})}
%\begin{enumerate}[noitemsep,nolistsep]
%\item
(I) If $k \geq n$, then the $m_{2}$.
\linebreak
%\item
(II) If $h \geq j$, then $m_{1}$.\\
%\end{enumerate}
Otherwise,\\
Initialisation: \textit{$g(0)=nj$}\\
$i=0$\\
Compute $n_{2}$,
\[
n(i)=\frac {a}{b(i)\sqrt{3v}}
\]\\
Update $b$,
\[
b(i+1)=( -\frac{1}{2(g(i)/D}+1)
\]\\
$i=i+1$,\\
Repeat \textit{Steps 3 to 6}, till $|a(i+1)-a(i) |<\epsilon$
\caption{algo of g}
\label{algo:b}
\end{algorithm}
\end{document}
I am not sure, which lines should be numbered, but the general idea is clear now, I hope.
Here's an approach that uses the functionality provided by algorithm2e
to form conditional and repetition structures. Of course, since you're calling the package with vlined
, the output also includes this.
\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\DontPrintSemicolon
\begin{document}
\begin{algorithm}
\KwIn{$a$, $b$, $c$, $d$}
\KwOut{$e$, $r$}
Calculate~$x$ and~$y$\;
\lIf{$k \geq n$}{$m_2$}\;
\lIf{$h \geq j$}{$m_1$}\;
\Else{%
\Repeat{$|a(i+1)-a(i)| < \epsilon$}{%
Initialisation: $g(0) = nj$\;\label{stepA}
$i=0$\;
Compute~$n_2$
\[
n(i) = \frac{a}{b(i)\sqrt{3v}}
\]
\nl Update~$b$
\[
b(i+1) = (-\frac{1}{2(g(i)/D} + 1)
\]
\nl $i = i + 1$\;
}
}
\caption{My algorithm}
\label{algo:b}
\end{algorithm}
\end{document}
Note that, instead of manually referencing steps, you can use a regular \label
and \ref
it later.