调整优化方程

调整优化方程

我试图编写一个优化公式,它有两部分,即目标函数和 2 个约束。但是,目标函数有点大,我想在多行中看到它,而不是在单行中。但它没有按照我想要的方式工作。有人能给我一些好的建议,关于如何在目标函数是一个方程而约束被分配为单独的方程的情况下将其制作成多行。LaTeX 代码如下:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
\label{green}
\text{minimize } & \quad {\sum\nolimits_{\tau=t}^{t+T-1}}s(\tau)[V(\t)-x(\tau)-y(\tau)-Y(\tau)] +{\sum\nolimits_{\tau=t}^{t+T-1}}[(X(\tau)+Y(\tau))(b(\tau)-v(\tau))] \\
\text{subject to } & \quad \quad {something1}\\
& \quad \quad {something 2} 
\end{align}

\end{document}

答案1

我建议使用\MoveEqLeft命令,mathtools并且只为约束设置一个数字。如果您想要独立编号约束,我有一个解决方案alignat

    \documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier, heuristica}
\usepackage[showframe, nomarginpar]{geometry}

\usepackage{mathtools, cases}

\begin{document}

\begin{align}
\label{green}
\MoveEqLeft\text{Minimize: }\notag\\
& \quad {∑_{\tau=t}^{t+T-1}}s(τ)\bigl[Vβ(τ)-Q(τ)-X(τ)-Y(τ)\bigr] +{∑_{\tau=t}^{t+T-1}}\bigl[(X(τ)+Y(τ))(γ b(τ)-γ v(τ))\bigr] \\
 \MoveEqLeft\text{subject to}
\qquad \!\begin{cases}
\hspace*{0.5em} 0 \leq s(τ)\leq s_{\max}, \quad ∀ τ \\
\hspace*{0.5em}\displaystyle∑_{\mathclap{\tau=t}}^{\mathclap{t+T-1}} γ β(τ)\leq N_{\max}
\end{cases}
\end{align}


\begin{alignat}{2}
\label{green}
\MoveEqLeft[2]\text{Minimize: }\notag\\
& ∑_{\tau=t}^{t+T-1}s(τ) & &\bigl[Vβ(τ)-Q(τ)-X(τ)-Y(τ)\bigr] +{∑_{\tau=t}^{t+T-1}}\bigl[(X(τ)+Y(τ))(γ b(τ)-γ v(τ))\bigr] \\[1ex]
 \MoveEqLeft \text{subject to}
 & & 0 \leq s(τ)\leq s_{\max}, \quad ∀ τ \\
& & & \displaystyle∑_{\mathclap{\tau=t}}^{\mathclap{t+T-1}} γ β(τ)\leq N_{\max}
\end{alignat}

\end{document} 

在此处输入图片描述

答案2

您可以split在内部使用align

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}
\begin{split}
\text{minimize}\qquad &
  \sum_{\tau=t}^{t+T-1} s(\tau)[V\beta(\tau)-Q(\tau)-X(\tau)-Y(\tau)] \\
  &\qquad  +\sum_{\tau=t}^{t+T-1} [(X(\tau)+Y(\tau))(\gamma b(\tau)-\gamma v(\tau))]
  \end{split}
\label{green} 
\\[2ex]
\text{subject to}\qquad & 0\leq s(\tau)\leq s_{\textup{max}}, \quad \forall \tau   
\label{green-constraint-1} 
\\
& \sum_{\tau=t}^{t+T-1} \gamma \beta(\tau)\leq N_{\textup{max}}
\label{green-constraint-2}
\end{align}

Check: \eqref{green} with \eqref{green-constraint-1} and \eqref{green-constraint-2}.

\end{document}

在此处输入图片描述

答案3

你想要这样的东西吗?

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{blindtext}

\begin{document}
\blindtext
\begin{align}
    \shortintertext{Minimize}   
    \MoveEqLeft[3]\sum\nolimits_{\tau=t}^{t+T-1}s(\tau)[V\beta(\tau)-Q(\tau)-X(\tau)-Y(\tau)] \nonumber \\
    +{}&\sum\nolimits_{\tau=t}^{t+T-1}[(X(\tau)+Y(\tau))(\gamma b(\tau)-\gamma v(\tau))]\label{green}\\
    \shortintertext{subject to} 
    &0\leq s(\tau)\leq s_\text{max}, \quad \forall \tau \\  
    &\sum\nolimits_{\tau=t}^{t+T-1} \gamma \beta(\tau)\leq N_\text{max}
\end{align} 
\blindtext
\end{document}

在此处输入图片描述

相关内容