2

I need to avoid showing end in line 10. It seems I miss using some packages

\listfiles
%\documentclass[12pt]{IEEEtran}
%\documentclass[12pt,reqno]{thesis}
\documentclass[12pt,reqno]{siugrad51}
%\documentclass[14pt,reqno]{article}
\usepackage[margin=1in]{geometry}
%\geometry{top=0.75in,left=0.80in,bottom=0.75in,right=0.80in}
%\pagestyle{empty}
\linespread{2}
%\usepackage{blindtext}
%\setlength{\parskip}{0.1mm} 
\setlength{\parskip}{0mm}
\raggedbottom




\usepackage{multirow}


%\usepackage[utf8]{inputenc}
%\usepackage[intoc]{nomencl}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup{compatibility=false}

\iffalse
\textwidth=6in \oddsidemargin=0.5in \topmargin=-0.5in
\textheight=9in  % 9in must include page numbers
\textfloatsep = 0.4in \addtocontents{toc}{\vspace{0.4in} \hfill
Page\endgraf} \addtocontents{lof}{\vspace{0.2in} \hspace{0.13in} \
Figure\hfill Page\endgraf} \addtocontents{lot}{\vspace{0.2in}
\hspace{0.13in} \ Table\hfill Page\endgraf}
\fi
\usepackage{graphicx}
\graphicspath{{C:/Users/SIU850607993/Documents/Conferences/CLOUD-2017/fig/}}



\usepackage{graphicx}
\usepackage{caption}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{color}
\usepackage[left=1.5in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage[table]{xcolor}
 \usepackage{amsfonts}
 \usepackage{amsbsy,bm}
 \usepackage{amssymb}
 \usepackage{rotating}
 \usepackage{float}
 \usepackage{stmaryrd}
 \usepackage{soul}
\usepackage{eepic}
%\usepackage{colortbl}
\usepackage[numbers]{natbib}
\usepackage{indentfirst}
%\usepackage{figure}
\usepackage[mathscr]{euscript}
\usepackage[titletoc,title]{appendix}
%\usepackage[titletoc]{appendix}
%\usepackage[tocgraduated]{tocstyle}

\usepackage{textcomp}
\usepackage{array}
\usepackage{listings}
\usepackage{setspace}
\usepackage{mathptmx}
%\usepackage{colortbl}
\usepackage{amssymb, amsmath} 
%\usepackage{subfig}
%\usepackage{epsfig}
\usepackage{times}
\usepackage{makeidx}
\usepackage{url}

\usepackage{booktabs}
%\usepackage[subfigure, titles]{tocloft}
\usepackage{acronym}
\usepackage{datetime}
%\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{varwidth}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}


\usepackage{makecell}
\usepackage{titletoc}
\usepackage{appendix}
\usepackage[nottoc]{tocbibind}
\DontPrintSemicolon
%\renewcommand{\nomname}{LIST OF ABBREVIATIONS}
%\makenomenclature
\graphicspath{{images/}}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.PNG, .eps, .tiff}

\urlstyle{same}
\setcounter{secnumdepth}{7}
\setcounter{tocdepth}{7}
\usepackage[document]{ragged2e}
\usepackage[bookmarks=false]{hyperref}

 \begin{document}

\begin{algorithm}
    \caption{Pseudo-code}
    \Input{Machine Type}
    \Output{Host }
    $max = \text{max resource }$\;
    
    \ForEach {$host \in \mathcal Host$}{
        
        $VMn \gets \text{VMEvents}(failure, t)$\;   
    }
    %$TrainedANN(Input for Host)$\;
    $\lambda_{\textit{VMfail}}, ResUti \gets PredictANN(Input for Host)$\;
    \If{($ResUti \geq max$)}
    {
        $\delta \gets low value $\;
        \Else
        {   
            $\delta \gets high value $\;
        }
    }
    $R\textsubscript{resource} = e^{-\lambda_{\textit{VMfail}}.t} *\delta +   ResUti * (1-\delta) $\;
    
    
\end{algorithm}

\end{document}

Here is my output

enter image description here

3

Use \eIf{<condition>}{<true>}{<false>}, see the documentation of algorithm2e.

Full simplified example (more \text needed)

\documentclass{article}
\usepackage{amsmath} 

\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{algpseudocode}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}

\begin{document}

\begin{algorithm}
    \caption{Pseudo-code}
    \Input{Machine Type}
    \Output{Host }
    $max = \text{max resource }$\;
    
    \ForEach {$host \in \mathcal Host$}{
        
        $VMn \gets \text{VMEvents}(failure, t)$\;   
    }
    %$TrainedANN(Input for Host)$\;
    $\lambda_{\textit{VMfail}}, ResUti \gets PredictANN(Input for Host)$\;
    \eIf{($ResUti \geq max$)}
    {
        $\delta \gets low value $\;
    }{   
        $\delta \gets high value $\;
    }
    $R\textsubscript{resource} = e^{-\lambda_{\textit{VMfail}}.t} *\delta +   ResUti * (1-\delta) $\; 
\end{algorithm}

\end{document}

enter image description here

1
  • many thanks. your code works great
    – jou sed
    Dec 20 '20 at 0:27

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.