1

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}

New contributor
Danish Shaikh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Welcome to tex.sx. What is the question exactly? To format the code in your question, highlight it with your mouse, then click on the {} icon above the question box. Jun 23 at 21:48
  • (La)TeX output isn't automatically shown in this group; in order to answer quetions accurately, we need to look at the input. This question gives a method to include the output: How do I get latex output to show up on tex.SE? (read the comments) Jun 23 at 21:53

2 Answers 2

1

Something like this?

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}

\begin{document}
\begin{alignat}{3}
\max    \quad  & \sum_{k\in K} \sum_{j\in S^k} \pi_{j}x{_{j}^k} 
                    &                       \label{slnl-1}  \\
\text{such that:}   % s.t. <?
        \quad  & \pi_{j}   \geq 0,
                    & \forall {j \in J}     \label{slnl-2}  \\
                &   \begin{multlined}       \label{slnl-3}
                \bigl(w s_j^k + (1- w)(r_j^k - \pi_j)\bigr) x_j^k  \geq    \\
                \bigl(w s_i^k + (1- w) r_i^k \bigr) x_j^k - (1-w)\pi_i - Mw_i^k 
                \end{multlined}
                    & \qquad    \forall k \in K;\ \forall  i,j \in S^k : i \neq j
 \end{alignat}
\end{document}

I'm not sure if I correctly figured out your equations. Anyway a skeleton, how can you organize your optimization problem is given.

2

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”.

2
  • Thank you for such a detailed response , can we use \begin{alignat} for single equations ? Jun 24 at 13:33
  • @DanishShaikh For a single equation use equation.
    – egreg
    Jun 24 at 14:18

Your Answer

Danish Shaikh is a new contributor. Be nice, and check out our Code of Conduct.

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.