I have written the following algorithm but unfortunately LaTeX puts it in the center of a new page and leaves the rest of this page completely blank even though there is still quite a lot of space left on the page.
Code: Select all
\begin{algorithm}
\caption{Solve Query}
\begin{algorithmic}[1]
\Require \hspace*{1mm}
\newline \(q_{init}\): robot's current configuration
\newline \(q_{goal}\): destination configuration
\newline \textit{k}: number of closest neighbours being examined for each configuration
\newline \textit{G} = (\textit{V},\textit{E}) is the previously computed roadmap
\Ensure \hspace*{1mm}
\newline P is a path from \(q_{init}\) to \(q_{goal}\) or NIL if such a path does not exist
\newline
\State \textit{\(N_{q_{init}}\)} \(\leftarrow\) the \textit{k} closest neighbours of \textit{\(q_{init}\)} from \textit{V} according to \textit{dist}
\State \textit{\(N_{q_{goal}}\)} \(\leftarrow\) the \textit{k} closest neighbours of \textit{\(q_{goal}\)} from \textit{V} according to \textit{dist}
\ForAll{\(q' \in N_{q_{init}}\)}
\If{\textit{\(\Delta\)}(\textit{\(q_{init}\)}, \textit{q'}) \(\neq\) NIL}
\State \textit{E} \(\leftarrow\) (\textit{\(q_{init}\)}, \textit{q'}) \(\cup\) \textit{E}
\State break
\EndIf
\EndFor
\ForAll{\(q' \in N_{q_{goal}}\)}
\If{\textit{\(\Delta\)}(\textit{\(q_{goal}\)}, \textit{q'}) \(\neq\) NIL}
\State \textit{E} \(\leftarrow\) (\textit{\(q_{goal}\)}, \textit{q'}) \(\cup\) \textit{E}
\State break
\EndIf
\EndFor
\State \textit{P} \(\leftarrow\) shortest path(\textit{\(q_{init}\)}, \textit{\(q_{goal}\)}, \textit{G})
\State \Return P
\end{algorithmic}
\end{algorithm}
Thanks a lot,
Sebastian