我该如何排版这个优化问题?

我该如何排版这个优化问题?

我需要重现以下等式:

在此处输入图片描述

我尝试了以下方法:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*} 
  \begin{aligned}
 & \text{minimize} & & \sum_{i=1}^{N}\sigma[i] (t_\text{indoor}[i] - t_\text{setpoint})^2 + \lambda \sum_{i=1}^{N}t_\text{flow}[i] && \\
 & \text{subject to} & & t_\text{indoor}[i] \geq t_\text{reduced}, && i = 1, \ldots, N \\
 & & & t_\text{indoor}[i] \leq t_\text{flow}[i] \leq t_\text{flowmax}, && i = 1, \ldots, N \\
  \end{aligned}
\end{equation*} 

\end{document}

不幸的是,这并不能完全满足我的要求:

在此处输入图片描述

我怎样才能使两个“i = 1,...,N”语句保持一致,但更接近这个优化问题的约束?

答案1

您可以使用align*cases环境

\documentclass{article}
\usepackage{amsmath}

\begin{document}


\begin{align*}
\text{minimize} & \sum_{i=1}^{N}\sigma[i] (t_\text{indoor}[i] - t_\text{setpoint})^2 + \lambda \sum_{i=1}^{N}t_\text{flow}[i] \\
\text{subject to} & \begin{cases}
                 t_\text{indoor}[i] \geq t_\text{reduced},& i = 1, \ldots, N \\
                 t_\text{indoor}[i] \leq t_\text{flow}[i] \leq t_\text{flowmax}, & i = 1, \ldots, N \\
                    \end{cases}
\end{align*}

\end{document} 

在此处输入图片描述

正如你所见,cases环境会产生左括号,如果你不想要括号,你可以写

\begin{array}{ll}
 t_\text{indoor}[i] \geq t_\text{reduced},& i = 1, \ldots, N \\
 t_\text{indoor}[i] \leq t_\text{flow}[i] \leq t_\text{flowmax}, & i = 1, \ldots, N 
\end{array}

反而

\begin{cases}
   t_\text{indoor}[i] \geq t_\text{reduced},& i = 1, \ldots, N \\
   t_\text{indoor}[i] \leq t_\text{flow}[i] \leq  t_\text{flowmax}, & i = 1, \ldots, N \\
\end{cases}

要得到

在此处输入图片描述

答案2

两种解决方案,分别是mathtoolsarray

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
                  & \text{minimize} & \quad & \sum_{i=1}^{N}\sigma[i] (t_\text{indoor}[i] - t_\text{setpoint})^2 + \lambda \sum_{i=1}^{N}t_\text{flow}[i] \\
                  & \text{subject to} & &
  \begin{aligned} & t_\text{indoor}[i] \geq t_\text{reduced}, & & i = 1, \ldots, N \\
                  & t_\text{indoor}[i] \leq t_\text{flow}[i] \leq t_\text{flowmax}, & & i = 1, \ldots, N \\
  \end{aligned}
\end{alignat*}

\begin{alignat*}{2}
    & \text{minimize} & \quad & \sum_{i=1}^{N}\sigma[i] (t_\text{indoor}[i] - t_\text{setpoint})^2 + \lambda \sum_{i=1}^{N}t_\text{flow}[i] \\
    & \text{subject to} & &
  \begin{array}{|@{\:}l} t_\text{indoor}[i] \geq t_\text{reduced}, \\[0.5ex]
  t_\text{indoor}[i] \leq t_\text{flow}[i] \leq t_\text{flowmax},
  \end{array}\quad i = 1, \ldots, N
\end{alignat*}

\end{document} 

在此处输入图片描述

相关内容