1

I need to reproduce the following equation:

enter image description here

I've tried the following:

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

Unfortunately, this doesn't quite give what I want:

enter image description here

How can I make the two "i = 1, ..., N," statements remain aligned, but be closer to the constraints of this optimisation problem?

3

You could use align* and cases environments

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

enter image description here

As you can see cases environment produces left braces, if you dont want braces you could write

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

instead

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

to get

enter image description here

  • Good answer. If you simply use an array, (\begin{array}{ll}) instead of the cases environment, you can lose the brace as well :) – Au101 May 27 '15 at 15:42
  • Yeah, I write cases because is more clear the conditions ... – juanuni May 27 '15 at 15:46
1

Two solutions, with mathtools and array:

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

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.