如何删除算法前的空格(由布局引起)

如何删除算法前的空格(由布局引起)

我不是 Latex 专家,我无法解决以下问题。我有一个很长的算法,它占据了整整一列,问题是编译器在它前面添加了一个空格,我需要它与文本对齐。

我已尝试使用 \vspace 和 \floatsep 但未能解决问题。

这正是我的问题的一个例子:图像可以更好地解释: 例子

以及重现该问题的代码:

\documentclass[a4paper, twocolumn, 10pt]{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage[italian]{babel}

\begin{document}
\begin{algorithm}
\caption{Optimization with Tabu Search of the }\label{alg1}
\begin{algorithmic}[1]
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm
\State row of algorithm

\end{algorithmic}
\end{algorithm}

Tabu search, created by Fred W. Glover in 1986[1] and formalized in 1989,[2][3] is a metaheuristic search method employing local search methods used for mathematical optimization.

Local (neighborhood) searches take a potential solution to a problem and check its immediate neighbors (that is, solutions that are similar except for one or two minor details) in the hope of finding an improved solution\footnote{this is a footnote, it can be userful and i have it on this point and it have two rows}. Local search methods have a tendency to become stuck in suboptimal regions or on plateaus where many solutions are equally fit.

Tabu search enhances the performance of local search by relaxing its basic rule. First, at each step worsening moves can be accepted if no improving move is available (like when the search is stuck at a strict local mimimum). In addition, prohibitions (henceforth the term tabu) are introduced to discourage the search from coming back to previously-visited solutions.

The implementation of tabu search uses memory structures that describe the visited solutions or user-provided sets of rules.[2] If a potential solution has been previously visited within a certain short-term period or if it has violated a rule, it is marked as "tabu" (forbidden) so that the algorithm does not consider that possibility repeatedly.

Tabu search uses a local or neighborhood search procedure to iteratively move from one potential solution x to an improved solution x' in the neighborhood of x, until some stopping criterion has been satisfied (generally, an attempt limit or a score threshold). Local search procedures often become stuck in poor-scoring areas or areas where scores plateau. In order to avoid these pitfalls and explore regions of the search space that would be left unexplored by other local search procedures, tabu search carefully explores the neighborhood of each solution as the search progresses. The solutions admitted to the new neighborhood, N (x), are determined through the use of memory structures. Using these memory structures, the search progresses by iteratively moving from the current solution x to an improved solution x' in N (x).

These memory structures form what is known as the tabu list, a set of rules and banned solutions used to filter which solutions will be admitted to the neighborhood N (x) to be explored by the search. In its simplest form, a tabu list is a short-term set of the solutions that have been visited in the recent past (less than n iterations ago, where n is the number of previous solutions to be stored - is also called the tabu tenure). More commonly, a tabu list consists of solutions that have changed by the process of moving from one solution to another. It is convenient, for ease of description, to understand a solution to be coded and represented by such attributes.

The memory structures used in tabu search can roughly be divided into three categories:[6]
Short-term: The list of solutions recently considered. If a potential solution appears on the tabu list, it cannot be revisited until it reaches an expiration point.
Intermediate-term: Intensification rules intended to bias the search towards promising areas of the search space.
 Long-term: Diversification rules that drive the search into new regions (i.e. regarding resets when the search becomes stuck in a plateau or a suboptimal dead-end).
\end{document}

附言:尽管我已设置意大利语,但算法的标题仍为“算法 1”(英文)。有没有办法覆盖此文本并设置“Algoritmo 1”?

答案1

在双列模式下,每列都被视为一页。在这种情况下,算法被放置在浮动页面上,我们必须遵循如何将浮动元素放置在仅浮动元素的页面的顶部?

要重命名算法的名称,我们可以在加载包时使用可选参数,感谢 egreg。

这是完整的例子。

\documentclass[a4paper, twocolumn, 10pt]{article}
\usepackage[Algorithmo]{algorithm}
\usepackage{algpseudocode}
\usepackage[italian]{babel}

\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{document}
\begin{algorithm}[tbph]
    \caption{Optimization with Tabu Search of the }\label{alg1}
    \begin{algorithmic}[1]
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm
        \State row of algorithm

    \end{algorithmic}
\end{algorithm}

Tabu search, created by Fred W. Glover in 1986[1] and formalized in 1989,[2][3] is a metaheuristic search method employing local search methods used for mathematical optimization.

Local (neighborhood) searches take a potential solution to a problem and check its immediate neighbors (that is, solutions that are similar except for one or two minor details) in the hope of finding an improved solution\footnote{this is a footnote, it can be userful and i have it on this point and it have two rows}. Local search methods have a tendency to become stuck in suboptimal regions or on plateaus where many solutions are equally fit.

Tabu search enhances the performance of local search by relaxing its basic rule. First, at each step worsening moves can be accepted if no improving move is available (like when the search is stuck at a strict local mimimum). In addition, prohibitions (henceforth the term tabu) are introduced to discourage the search from coming back to previously-visited solutions.

The implementation of tabu search uses memory structures that describe the visited solutions or user-provided sets of rules.[2] If a potential solution has been previously visited within a certain short-term period or if it has violated a rule, it is marked as "tabu" (forbidden) so that the algorithm does not consider that possibility repeatedly.

Tabu search uses a local or neighborhood search procedure to iteratively move from one potential solution x to an improved solution x' in the neighborhood of x, until some stopping criterion has been satisfied (generally, an attempt limit or a score threshold). Local search procedures often become stuck in poor-scoring areas or areas where scores plateau. In order to avoid these pitfalls and explore regions of the search space that would be left unexplored by other local search procedures, tabu search carefully explores the neighborhood of each solution as the search progresses. The solutions admitted to the new neighborhood, N (x), are determined through the use of memory structures. Using these memory structures, the search progresses by iteratively moving from the current solution x to an improved solution x' in N (x).

These memory structures form what is known as the tabu list, a set of rules and banned solutions used to filter which solutions will be admitted to the neighborhood N (x) to be explored by the search. In its simplest form, a tabu list is a short-term set of the solutions that have been visited in the recent past (less than n iterations ago, where n is the number of previous solutions to be stored - is also called the tabu tenure). More commonly, a tabu list consists of solutions that have changed by the process of moving from one solution to another. It is convenient, for ease of description, to understand a solution to be coded and represented by such attributes.

The memory structures used in tabu search can roughly be divided into three categories:[6]
Short-term: The list of solutions recently considered. If a potential solution appears on the tabu list, it cannot be revisited until it reaches an expiration point.
Intermediate-term: Intensification rules intended to bias the search towards promising areas of the search space.
 Long-term: Diversification rules that drive the search into new regions (i.e. regarding resets when the search becomes stuck in a plateau or a suboptimal dead-end).
 \end{document}

相关内容