我需要避免 end
在第 10 行显示。似乎我错过了使用一些包
\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}
这是我的输出
答案1
使用\eIf{<condition>}{<true>}{<false>}
,请参阅记录algorithm2e
。
完整简化示例(\text
需要更多)
\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}