Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a package for specifying optimization problems, such as in linear programming, quadratic programming, convex programming, etc.?

Or do I have to write my own code with align, constraints and so on? I thought that there might be a very elegant way to specify a min/max problem with some constraints below it.

I am talking about something like Example 2.2 in http://people.ucsc.edu/~rgil/Optimization.pdf.

EDIT: Following a request below, I add an illustrating example of a problem I had with align.

\begin{alignat}{3}
\min && n \\
\mathrm{s.t.} && xxxxxxx \\
&& yyyyyyyyyyyyyyyyyyy \\
&& zzzzzzzzzzzzzzzzzzz
\end{alignat}

What happens is that n is aligned to the far left. I want all of the left columns to be centered below each other. This is my way of formulating a constrained optimization problem, if someone has a better idea I will be glad to hear about it.

If I use only two columns, there is almost no space between $\min$ and $n$. I am almost tempted to use eqnarray :-)

share|improve this question
    
I am not familiar with the desired formatting. Could you please add an image of (or provide a link to) some example of what you want to achieve? –  Gonzalo Medina May 30 '11 at 17:57
    
Example 2.2 in people.ucsc.edu/~rgil/Optimization.pdf –  kloop May 30 '11 at 18:12
    
Maybe I am expecting for too much from latex, and it can be just as easily done as using begin{align} end{align}. I thought there might be a more elegant way to do it. Thanks. –  kloop May 30 '11 at 18:13
    
perhaps you could edit your question to provide the link there and not just in a comment? –  Gonzalo Medina May 30 '11 at 19:00

2 Answers 2

The align of alignat environments (from amsmath) seem the way to go here; in some cases you could use \intertext (or \shotintertex from the mathtools package) for interrupting some multiline displays while still maintaining the alignment points.

EDIT: As a side note, the set of equations in Example 2.2 (in the document you linked in a comment) that goes after "Then," was probably typeset using eqnarray; you should avoid using this environment since the spacing surrounding the equal sign is bigger than for the other aligning environments, rendering the document somehow inconsistent. This nice article from Lars Madsen explains (and illustrates with examples) why eqnarray shouln't be used anymore: Avoid eqnarray!

EDIT2: using an align environment you can write:

\documentclass{report} 
\usepackage{amsmath}

\begin{document}

\begin{align}
  \min  &\hspace{0.5em} n \\
  \mathrm{s.t.}   &\hspace{0.5em} xxxxxxx \\
  & \hspace{0.5em} yyyyyyyyyyyyyyyyyyy \\
  & \hspace{0.5em} zzzzzzzzzzzzzzzzzzz
\end{align}

\end{document}
share|improve this answer
    
when I use align, everything is aligned to the right. Is there a way to make everything centered? I couldn't find anything on google. –  kloop May 30 '11 at 19:22
    
@kloop: can you please add an example illustrating this behaviour? –  Gonzalo Medina May 30 '11 at 20:15
    
just did. thanks! –  kloop May 30 '11 at 20:33
    
@klooṕ: I've updated my answer adding an example given the desired alignment; I wasn't sure that this was what you desired; if it is not, please let me know, and explain in some more detail the kind of alignment that you want to achieve. –  Gonzalo Medina May 30 '11 at 22:22

This is another possibility, where I like the spacing:

\begin{equation}
\begin{aligned}
    &\min          &&c^\top x + p^\top(b-Ax)\\
    &\textrm{s.t.} &&x \geq 0
\label{eq:LagrangeRelax}
\end{aligned}
\end{equation}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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