0
\documentclass[two column,conference]{IEEEtran}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
    \caption{HD}
    \label{array-sum}
    1: Initialization of parameters \\
    2: Randomly generate population using Eq. 28\\
    3: \textbf{for} u=1:k \\
    4: \textbf{for} s=1:i$_{c}$\\
    5:  Randomly generated X$_{s}^{u}$ in da\\
    6: \textbf{end for} \\
    7: \textbf{end for}\\
    8: End of initialization step\\
    9: \textbf{While} Maximum number of iteration reached \textbf{do}\\
    10:  Construction and assessment of new candidate\\
    11: \textbf{if} ($rand (0,1)\leq$ cpu)\\
    12: Choose random no \\
    13: \textbf {if} ($rand (0,1 ) \leq$ cpu) \\
    14:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    15: \textbf{end if} \\
    16: \textbf{else} \\
    17: Evaluate fitness function a: F(a) using Eq. 17\\
    27: End of the construction and assessment step\\
    28: Construction and assessment of new candidate: a   \\
    29: if (F(y) has best value than the worst member \\
    30: Replace DA member with new candidate: a\\
    31: else\\
    32: Discard x\\
    33: \textbf{endif}\\
    34: End of update\\
    35: Until a preset termination criterion is met\\
    36: end \textbf{while}\\
\end{algorithm}
\end{document}

I want to draw vertical lines for loops and if statement. Kindly help me out and also I didn't use any specific package

  • Welcome to TeX SX! Yet the algorithmis defined by a package… – Bernard Jul 14 '17 at 13:05
  • yeah!! Only algorithm package, However, it didn't worked for me can you please help me out. – Smith Jul 14 '17 at 13:10
  • I can try. Would you be kind enough to post a full compilable code? – Bernard Jul 14 '17 at 13:20
  • It is full code except for package {\usepackage{algorithm} However, I will also edit the code. – Smith Jul 14 '17 at 13:30
0

You have to load algorithm2e to do that easily:

\documentclass[two column,conference]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[ruled, lined, longend, linesnumbered]{algorithm2e}

\begin{document}

\begin{algorithm}
    \caption{HD}
    \label{array-sum}
     Initialization of parameters\;
     Randomly generate population using Eq. 28\;
   \For{u=1:k}{%
     \For{s=1:i$_{c}$}{%
     Randomly generated X$_{s}^{u}$ in da \;
            }
            }
     End of initialization step\;
     \While{Maximum number of iteration reached}{
    Construction and assessment of new candidate\;
    \eIf{($rand (0,1)\leq$ cpu)}{%
     Choose random no \;
     \textbf {if} ($rand (0,1 ) \leq$ cpu) \\
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     \textbf{end if}
     }{%
     Evaluate fitness function a: F(a) using Eq. 17 \;
     End of the construction and assessment step\;
     Construction and assessment of new candidate: a \;
     \eIf {(F(y) has best value than the worst member}{
     Replace DA member with new candidate: a
     }{%
     Discard x}%
        }%
     End of update\;
     Until a preset termination criterion is met}
\end{algorithm}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.