2

I am having trouble typesetting an optimization problem, and would like to know how to ignore the alignment for a certain line in an alignat environment.

I've currently typeset the optimization problem as:

\begin{alignat}{4}
\centering
\min_{\lambda} \quad & \frac{1}{N} \sum_{i = 1}^N{\alpha_i} & + & C_0 \sum_{i = 1}^N{\beta_i} & + & C_1 \sum_{i = 1} ^N{\gamma_i} \\
s.t. \quad & -M\alpha + \epsilon & \leq & \lambda^T X y & \leq & M(1-\alpha) + \epsilon \\ 
     & -\beta \bar{\lambda}  & \leq &  \lambda & \leq & \beta \bar{\lambda} \\ 
     &-\gamma & \leq & \lambda & \leq & \gamma \\ 
     & \lambda \in \mathbb{Z}^P & \quad & \alpha \in \{0,1\}^N  &\quad & \beta, \gamma \in \{0,1\}^P 
\end{alignat}

However this runs into issues since the bottom line causes weird spacing.

I would appreciate any formulations that can make this mess legible in some way... That said, I think that I can get around this problem if I can just tell the alignat environment to ignore the last line, and also center the contents between each of the & signs.

2 Answers 2

3

I wouldn't try aligning the inequalities: the formulas are too different from each other. Here's a possibility:

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{gather}
\min_{\lambda}
  \,\frac{1}{N} \sum_{i=1}^N{\alpha_i} +
   C_0 \sum_{i=1}^N{\beta_i} +
   C_1 \sum_{i=1} ^N{\gamma_i}
\\
\begin{align}
\makebox[0pt][r]{s.t.\quad}
  &{-}M\alpha + \epsilon \leq \lambda^T X y \leq M(1-\alpha) + \epsilon \\[1ex]
  &{-}\beta \bar{\lambda} \leq \lambda \leq \beta \bar{\lambda} \\[1ex]
  &{-}\gamma \leq \lambda \leq \gamma \\[1ex]
  &\lambda \in \mathbb{Z}^P,\qquad
   \alpha \in \{0,1\}^N, \qquad  \beta, \gamma \in \{0,1\}^P
\end{align}
\end{gather}
\end{document}

It's necessary to use {-} because otherwise the minus sign would be detached from the symbol it refers to.

enter image description here

2

Just a suggestion but there doesn't really seem to be any meaning that is conveyed by aligning parts of the main expression to be minimised with the definitions of the variables, you could consider losing the alignment altogether.

enter image description here

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


\begin{equation}
\min_{\lambda} \frac{1}{N} \sum_{i = 1}^N{\alpha_i}  +  C_0 \sum_{i = 1}^N{\beta_i} +  C_1 \sum_{i = 1} ^N{\gamma_i}
\end{equation}
s.t.
\begin{gather}
   -M\alpha + \epsilon  \leq  \lambda^T X y  \leq  M(1-\alpha) + \epsilon \\ 
   -\beta \bar{\lambda}   \leq   \lambda  \leq  \beta \bar{\lambda} \\ 
    -\gamma  \leq  \lambda  \leq  \gamma \\[\jot]
    \lambda \in \mathbb{Z}^P  \quad  \alpha \in \{0,1\}^N  \quad  \beta, \gamma \in \{0,1\}^P 
\end{gather}
\end{document}
2
  • or one could even use \intertext for the "such that" if all the equation lines really do have equation numbers. Mar 28, 2013 at 19:41
  • I agree, and will use this as a backup. Ideally I'd like to also omit the main expression from the alignat environment, but align the $\leq$ and $\geq$ signs in the constraints.
    – Berk U.
    Mar 28, 2013 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .