Aligning a oversized multiple line equation

alignsplit

My Apologize, I am new here.
I am noticing my latex is not displaying in a processed format.
How do I do this?

\begin{document}
\begin{flalign}
\text{max} & \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x{{j}^k} &\label{slnl-1} \
\text{such that: } & \pi
{j} \geq 0,
& \qquad \forall {j \in J} \label{slnl-2} \
\begin{split} \label{slnl-3}
\left( w s{{j}^k} + \left(1- w \right) \left(r{{j}^k}- \pi_{j} \right) \right) x{{j}^k} \geq {}
&\left( w s{
{i}^k} + (1- w ) r{{i}^k} \right) x{{j}^k} \
& – \left( 1- w \right) \pi_{i} – M q{_{i}^k}, \qquad \forall {k \in K, i,j \in S^k : i \neq j}
\end{split} \
% \end{align}
\end{document}

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{gather}
a = b + c\
d = e + f \qquad g = h + i
\end{gather}
\end{document}

Best Answer

You can split the long constraint with aligned and also the conditions.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{3}
&\text{max}    && \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x_{j}^k \label{slnl-1} \\
&\text{s.t.:} && \pi_{j}   \geq 0, && \qquad  \forall j \in J  \label{slnl-2}  \\
\label{slnl-3}
&&& \begin{aligned}
      & (ws_{j}^k + (1-w )(r_{j}^k - \pi_{j})) x_{j}^k \\
      & \geq (ws_{i}^k + (1-w)r_{i}^k) x_{j}^k - (1-w)\pi_{i} - Mq_{i}^k,
    \end{aligned}
    &&  \quad 
    \left\{\begin{aligned}
    & \forall k \in K, \\
    & \forall i,j \in S^k : i \neq j
    \end{aligned}\right.
\end{alignat}

\end{document}

enter image description here

Note that \left( and \right) do no good in this context. Also

s{_{j}^k}

is wrong syntax and should be, more simply

s_{j}^k

(or for being consistent, s_{j}^{k}).

There is no need of braces after \forall, which is not a command with argument.

Finally, “s.t.” used in optimization reads “subject to”, not “such that”.