Linear programming consists of a target function and several constraints, and there is no direct command to write linear programming in Latex. The simple approach is to use \begin{eqnarray} ... \end{eqnarray} command, but the Eqnarray command is to align several equations vertically with an intermediate two-tuple (such as an equals sign), while the constraints on a linear plan have a two-element relationship, but the constraints are often followed by quantifier symbols, which also require vertical alignment. In other words, there is more than one position in a linear plan that requires vertical alignment. or simply use \begin{array} ... \end{array} command, so that you can do multiple vertical alignment, but also encountered the formula cannot be automatically numbered, some mathematical symbols in the table (such as \sigma) can not be displayed in the mathematical format, but only to display the text format, and so on a number of issues. In short, although some methods can be used to "make up" the planning of the line, but many places can not be satisfactory.
Until one day accidentally saw the Amsmath bag of \begin{alignat} ... \end{alignat} command, only to find that the linear programming can be better solved by using this command. The code is given directly below:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\title{linearprogram}
\maketitle
\BEGIN{ALIGNAT}{2}
\min\quad & \sum_{\ell\in L}x_{\ell} &{}& \TAG{LP1} \label{eqn-lp}\\
\mbox{s.t.}\quad
&\sum_{e \in P} x_{f (E)} \geq 1, &\quad& \forall P \in \mathcal{p}_{st}\\
&x_{\ell} \geq 0, &{}& \forall \ell \in L \nonumber
\end{alignat}
Inthe linear program (\REF{EQN-LP}), ...
\end{document}
The resulting linear programming is as follows:
There are several points to explain.
(1) The entire linear plan appears to consist of 4 columns. That is, the leftmost "min" and "s.t.", the constraint of the 2nd column, the constraint quantifier for the 3rd column, and the number of the 4th column. The 2nd and 3rd columns are left-aligned, which makes them look more beautiful.
Of course, there is a common way of linear programming is the constraints in accordance with the binary relationship vertical alignment, I believe that after reading this article, we will construct such a linear plan. For a large number of linear programming, both formats have advantages and disadvantages.
(2) The objective function and constraints of linear programming can be referenced according to the standard \ref{} command. For those constraints that do not need to be referenced, simply write the \nonumber on the corresponding line and the right end is numbered.
It is worth mentioning that the number of the objective function, in the example above is "(LP1)", rather than the uniform number of constraints. This (LP1) is the same as Latex produces a standard number on the right-hand side of the page, and it also uses the \ref{} command reference as the standard number. As shown in the example, this is done using the \tag command. (Know that the \tag command can achieve such a function, but also a lot of reading after the accidental discovery, it took quite a long time ...) )
(3) The following is a brief explanation of the implementation of the above example. The entire linear plan is actually divided into 4 columns as shown, so you need to use 3 "&" symbols in the Alignat command to separate the columns. The purpose of column C is to separate a certain distance between the quantifier and the constraint condition.
According to the use of the Alignat command, these 4 columns actually form the two-column equations under the Alingat command point of view. Where AB is the 1th-column equations, and the CD is the 2nd-column equation Group. That is, the Eqnarray command is used to align a set of equations, while the Alignat command is used to set the equations of the Zito column. This also explains why the Alignat command in the previous example code has a parameter {2} behind it. About the Alignat command here do not do further, we are interested in reference to Amsmath package information.
Of course, the above methods of writing linear programming can also be generalized to the general mathematical programming. I wish to share mutual encouragement.
(Please replace all full-width "\" in the text with a half-width backslash.) )
From:http://blog.sciencenet.cn/blog-482332-749340.html
Write linear programming with Latex