4

I was trying to write a optimization formula which has two part as objective and 2 constraints. But, the objective function is a little bigger and i want to see it in multiline not in single line. But it's not working the way i want it to work. Can someone provide me some good suggestion about how to make it in multiline while the objective function is one equation and constraints are assigned as separate equation. The LaTeX code is like this:

\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}
egreg
  • 1,121,712
  • 1
    Welcome to TeX.SE. It would be better if you turned your code snippet into a a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem.

    While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.

    – Peter Grill Oct 02 '14 at 14:06
  • Note that there should be no blank line in an align environment. I presume that the ones in the example code were due to copy paste. – egreg Oct 02 '14 at 15:18

3 Answers3

5

You can use split inside 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}

enter image description here

egreg
  • 1,121,712
4

I suggest using the \MoveEqLeft command from mathtools and having only one number for the constraints. If your want independent numbring of constraints, I have a solution with 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} 

enter image description here

Bernard
  • 271,350
1

Do you want something like this?

% 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}

enter image description here

LaRiFaRi
  • 43,807