我想将两种算法并排放置,并留有合理的余地。有谁能帮我吗?谢谢
\documentclass{llncs}
%
\usepackage{makeidx} % allows for indexgeneration
\usepackage{algorithm}
\usepackage{threeparttable}
\usepackage{algorithmic}
\usepackage{amsfonts}
\usepackage{enumerate}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{verbatim}
\usepackage{tabularx}
\usepackage[pdftex]{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\usepackage{epstopdf}
\usepackage{multirow}
\usepackage{times}
\usepackage{caption}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage{appendix}
\usepackage{geometry}
\geometry{left = 2cm, right = 2cm, top = 2cm, bottom = 2cm}
%\newtheorem{definition}{Definition}
%\newtheorem{theorem}{Theorem}
%\newtheorem{myDef}{Definition}
%\newtheorem{myTheo}{Theorem}
\renewcommand{\labelitemi}{$\bullet$}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\algorithmicforall}{\textbf{for each}}
%
\begin{document}
\begin{minipage}[t]{6cm}
\vspace{2pt}
\begin{algorithm}[H]
\caption{Secure Comparison Across Domain(SCAD)}
\label{Secure Comparison Across Domain}
\begin{algorithmic}
\REQUIRE CSP has encrypted data $ [\![x]\!]_{{pk}_M} $ and $ [\![y]\!]_{{pk}_\Sigma} $, where $ x, y \leq N/4 $. Evaluator has the master key $ \mathbf{MK} $.
\ENSURE CSP gets the encrypted comparison result $ [\![t]\!]_{{pk}_M} $. If $ t =1 $, it means $ x \geq y $. Otherwise, it shows $ x < y $.
\STATE 1. CSP:
\STATE \quad (1) $ A \leftarrow ([\![x]\!]_{{pk}_M})^2 \cdot [\![1]\!]_{{pk}_M} $, $ B \leftarrow ([\![y]\!]_{{pk}_\Sigma})^2 $.
\STATE \quad (2) Randomly pick $ a \stackrel{\textit{R}} {\longleftarrow} \{0,1\}$, $C \leftarrow A^{a(N-1)}$, $D\leftarrow B^{(1-a)(N-1)}$.
\STATE \quad (3) Randomly choose $ r_a, r_b \stackrel{\textit{R}} {\longleftarrow} \mathbb{Z}_N$, and calculate $ C' \leftarrow C \cdot [\![r_a]\!]_{{pk}_M} $, $ D' \leftarrow D \cdot [\![r_b]\!]_{{pk}_\Sigma} $.
\STATE \quad (4) Send $C'$ and $ D' $ to Evaluator.
\STATE 2. Evaluator :
\STATE \quad (1) $ c' \leftarrow\mathbf{mDec_{({pk_{M},MK})}(C')} $, $ d' \leftarrow\mathbf{mDec_{({pk_{\Sigma},MK})}(D')} $.
\STATE \quad (2) Calculate $E \leftarrow [\![c'+ d']\!]_{pk_\Sigma}$, then send $E$ to CSP.
\STATE 3. CSP :
\STATE \quad (1) $F \leftarrow E\cdot ([\![r_a+r_b]\!]_{pk_\Sigma})^{N-1}$.
\STATE \quad (2) Randomly choose $ r_1, r_2$, where $r_1, r_2 \stackrel{\textit{R}} {\longleftarrow} \{1,\cdots, N/4\}$, $r_2 \ll r_1$, and calculate $ F'\leftarrow F^{r_1} \cdot [\![r_2]\!]_{{pk}_\Sigma} $.
\STATE \quad (3) Send $F'$ to Evaluator.
\STATE 4. Evaluator :
\STATE \quad (1) $ z \leftarrow \mathbf{mDec_{({pk_\Sigma,MK})}(F')} $.
\STATE \quad (2) If $ z <N/2 $, $ \delta \leftarrow 1 $ else $ \delta \leftarrow 0 $. Send $ [\![\delta]\!]_{{pk}_\Sigma} $.
\STATE 5. CSP:
\STATE \quad If $ a=0 $, $ [\![t]\!]_{{pk}_\Sigma} = [\![\delta]\!]_{{pk}_\Sigma}$. Else, $ [\![t]\!]_{{pk}_\Sigma} \leftarrow [\![1]\!]_{{pk}_\Sigma} \cdot ([\![\delta]\!]_{{pk}_\Sigma})^{N-1} $.
\end{algorithmic}
\end{algorithm}
\end{minipage}%
\begin{minipage}[t]{6cm}
\vspace{2pt}
\begin{algorithm}[H]
\caption{Secure Association Rule Mining (SARM)}
\label{Secure Association Rule Mining}
\begin{algorithmic}
\REQUIRE CSP has $ m $ encrypted transactions data $ C = \{ \vec{C_1}, \cdots, \vec{C_m}\} $, where $\vec{C_j} = ([\![c_{j,1}]\!]_{{pk}_{{DO}_i}}, \cdots , [\![c_{j,n}]\!]_{{pk}_{{DO}_i}} )$, $i\in(1,\cdots,\eta)$, $j \in (1, \cdots, m)$. The CSP also has the support of query $[\![u]\!]_{{pk}_\Sigma} $ from \textbf{SFIM}. Miner has the frequent itemset $ \vec{f} $ and the threshold of confidence $\alpha/\beta$, where $ \vec{f} = ([\![f_1]\!]_{{pk}_M},\cdots, [\![f_n]\!]_{{pk}_M}) $. Evaluator has the master key $ \mathbf{MK} $.
\ENSURE Miner gets the strong association rule.
\STATE 1. Miner:
\STATE \quad (1) Get the sets of $\vec{f }$'s nonvoid proper subset $H$, where $ H = \{ \vec{h_1},\cdots, \vec{h}_{2^z-2}\} $. Suppose that the number of 1s in $\vec{h_i} $ is $k_i$.
\STATE \quad (2) Encrypt every $\vec{h_i}$, $k_i$ , $\alpha$ and $\beta$, where $i \in (1,\cdots, 2^z-2)$. Send them to CSP.
\STATE 2.
\FORALL {$i=1$ to $2^z-2$ }
\STATE CSP and Evaluator:
\STATE \quad (1) The same procedure as in \textbf{SFIM} from Step 3 to Step 7. At the end, CSP gets $[\![u_i]\!]_{{pk}_\Sigma} $.
\STATE \quad (2) $[\![\tau_i]\!]_{{pk}_\Sigma} \leftarrow \mathbf{SMAD}([\![\beta]\!]_{{pk}_M}, [\![u]\!]_{{pk}_\Sigma})$, $[\![\varepsilon_i]\!]_{{pk}_\Sigma} \leftarrow \mathbf{SMAD}([\![\alpha]\!]_{{pk}_M}, [\![u_i]\!]_{{pk}_\Sigma})$
\STATE \quad (3) $[\![\gamma_i]\!]_{{pk}_M} \leftarrow \mathbf{SC} ([\![\tau_i]\!]_{{pk}_\Sigma}, [\![\varepsilon_i]\!]_{{pk}_\Sigma} ) $
\STATE \quad (4) Send $[\![\gamma_i]\!]_{{pk}_M} $ to the miner.
\STATE Miner:
\STATE $\gamma_i \leftarrow \mathbf{Dec_{sk_M)}}([\![\gamma_i]\!]_{{pk}_M})$.
\IF{$\gamma_i =1$}
\STATE Output $\vec{h_i} \Rightarrow( \vec{f }- \vec{h_i})$
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{document}
答案1
我删除了您调用的不需要演示问题的包。请注意,我更改了调用包的顺序(hyperref
在您的案例中应该是最后调用的包)。
就您而言,\hfil
两个小页面之间缺少一个内容:
\begin{minipage}[t]{7cm}%6cm <==========================================
%
\end{minipage}%
\hfil % <===============================================================
\begin{minipage}[t]{7cm}%6cm <==========================================
%
\end{minipage}%
使用以下完整的 MWE
\documentclass{llncs}
\usepackage{geometry}
\geometry{left = 2cm, right = 2cm, top = 2cm, bottom = 2cm}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{hyperref}
\renewcommand{\labelitemi}{$\bullet$}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\algorithmicforall}{\textbf{for each}}
%
\begin{document}
\begin{minipage}[t]{7cm}%6cm <==========================================
\vspace{2pt}
\begin{algorithm}[H]
\caption{Secure Comparison Across Domain (SCAD)}
\label{Secure Comparison Across Domain}
\begin{algorithmic}
\REQUIRE CSP has encrypted data $ [\![x]\!]_{{pk}_M} $ and $ [\![y]\!]_{{pk}_\Sigma} $, where $ x, y \leq N/4 $. Evaluator has the master key $ \mathbf{MK} $.
\ENSURE CSP gets the encrypted comparison result $ [\![t]\!]_{{pk}_M} $. If $ t =1 $, it means $ x \geq y $. Otherwise, it shows $ x < y $.
\STATE 1. CSP:
\STATE \quad (1) $ A \leftarrow ([\![x]\!]_{{pk}_M})^2 \cdot [\![1]\!]_{{pk}_M} $, $ B \leftarrow ([\![y]\!]_{{pk}_\Sigma})^2 $.
\STATE \quad (2) Randomly pick $ a \stackrel{\textit{R}} {\longleftarrow} \{0,1\}$, $C \leftarrow A^{a(N-1)}$, $D\leftarrow B^{(1-a)(N-1)}$.
\STATE \quad (3) Randomly choose $ r_a, r_b \stackrel{\textit{R}} {\longleftarrow} \mathbb{Z}_N$, and calculate $ C' \leftarrow C \cdot [\![r_a]\!]_{{pk}_M} $, $ D' \leftarrow D \cdot [\![r_b]\!]_{{pk}_\Sigma} $.
\STATE \quad (4) Send $C'$ and $ D' $ to Evaluator.
\STATE 2. Evaluator :
\STATE \quad (1) $ c' \leftarrow\mathbf{mDec_{({pk_{M},MK})}(C')} $, $ d' \leftarrow\mathbf{mDec_{({pk_{\Sigma},MK})}(D')} $.
\STATE \quad (2) Calculate $E \leftarrow [\![c'+ d']\!]_{pk_\Sigma}$, then send $E$ to CSP.
\STATE 3. CSP :
\STATE \quad (1) $F \leftarrow E\cdot ([\![r_a+r_b]\!]_{pk_\Sigma})^{N-1}$.
\STATE \quad (2) Randomly choose $ r_1, r_2$, where $r_1, r_2 \stackrel{\textit{R}} {\longleftarrow} \{1,\cdots, N/4\}$, $r_2 \ll r_1$, and calculate $ F'\leftarrow F^{r_1} \cdot [\![r_2]\!]_{{pk}_\Sigma} $.
\STATE \quad (3) Send $F'$ to Evaluator.
\STATE 4. Evaluator :
\STATE \quad (1) $ z \leftarrow \mathbf{mDec_{({pk_\Sigma,MK})}(F')} $.
\STATE \quad (2) If $ z <N/2 $, $ \delta \leftarrow 1 $ else $ \delta \leftarrow 0 $. Send $ [\![\delta]\!]_{{pk}_\Sigma} $.
\STATE 5. CSP:
\STATE \quad If $ a=0 $, $ [\![t]\!]_{{pk}_\Sigma} = [\![\delta]\!]_{{pk}_\Sigma}$. Else, $ [\![t]\!]_{{pk}_\Sigma} \leftarrow [\![1]\!]_{{pk}_\Sigma} \cdot ([\![\delta]\!]_{{pk}_\Sigma})^{N-1} $.
\end{algorithmic}
\end{algorithm}
\end{minipage}%
\hfil % <===============================================================
\begin{minipage}[t]{7cm}%6cm <==========================================
\vspace{2pt}
\begin{algorithm}[H]
\caption{Secure Association Rule Mining (SARM)}
\label{Secure Association Rule Mining}
\begin{algorithmic}
\REQUIRE CSP has $ m $ encrypted transactions data $ C = \{ \vec{C_1}, \cdots, \vec{C_m}\} $, where $\vec{C_j} = ([\![c_{j,1}]\!]_{{pk}_{{DO}_i}}, \cdots , [\![c_{j,n}]\!]_{{pk}_{{DO}_i}} )$, $i\in(1,\cdots,\eta)$, $j \in (1, \cdots, m)$. The CSP also has the support of query $[\![u]\!]_{{pk}_\Sigma} $ from \textbf{SFIM}. Miner has the frequent itemset $ \vec{f} $ and the threshold of confidence $\alpha/\beta$, where $ \vec{f} = ([\![f_1]\!]_{{pk}_M},\cdots, [\![f_n]\!]_{{pk}_M}) $. Evaluator has the master key $ \mathbf{MK} $.
\ENSURE Miner gets the strong association rule.
\STATE 1. Miner:
\STATE \quad (1) Get the sets of $\vec{f }$'s nonvoid proper subset $H$, where $ H = \{ \vec{h_1},\cdots, \vec{h}_{2^z-2}\} $. Suppose that the number of 1s in $\vec{h_i} $ is $k_i$.
\STATE \quad (2) Encrypt every $\vec{h_i}$, $k_i$ , $\alpha$ and $\beta$, where $i \in (1,\cdots, 2^z-2)$. Send them to CSP.
\STATE 2.
\FORALL {$i=1$ to $2^z-2$ }
\STATE CSP and Evaluator:
\STATE \quad (1) The same procedure as in \textbf{SFIM} from Step 3 to Step 7. At the end, CSP gets $[\![u_i]\!]_{{pk}_\Sigma} $.
\STATE \quad (2) $[\![\tau_i]\!]_{{pk}_\Sigma} \leftarrow \mathbf{SMAD}([\![\beta]\!]_{{pk}_M}, [\![u]\!]_{{pk}_\Sigma})$, $[\![\varepsilon_i]\!]_{{pk}_\Sigma} \leftarrow \mathbf{SMAD}([\![\alpha]\!]_{{pk}_M}, [\![u_i]\!]_{{pk}_\Sigma})$
\STATE \quad (3) $[\![\gamma_i]\!]_{{pk}_M} \leftarrow \mathbf{SC} ([\![\tau_i]\!]_{{pk}_\Sigma}, [\![\varepsilon_i]\!]_{{pk}_\Sigma} ) $
\STATE \quad (4) Send $[\![\gamma_i]\!]_{{pk}_M} $ to the miner.
\STATE Miner:
\STATE $\gamma_i \leftarrow \mathbf{Dec_{sk_M)}}([\![\gamma_i]\!]_{{pk}_M})$.
\IF{$\gamma_i =1$}
\STATE Output $\vec{h_i} \Rightarrow( \vec{f }- \vec{h_i})$
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{document}
您将获得以下结果: