# How can I typeset this optimisation problem?

I need to reproduce the following equation:

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:

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

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}


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}


\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

• 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

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}