Define optimization problems by LaTeX

First of all, this issue has bothered me A LOT for such a long time. But every time I just leave it away because the final version of my manuscript looks acceptable in its formatting of optimization problems, well, at least fits ok with the journal template. After these years, I do have a few alternative solutions but, to the best of my knowledge, it doesn’t exist a simple way to be the best solution which dominates the others in all aspects. Please kindly let me know If I am wrong.

So, this is a note for a few different ways to define optimization problems in your tex file.

1. Optidef

A co-author recommended Optidef to me. This is a library provides a standard set of environments for writing optimization problems. Before we start, you should import it first.


If this library isn’t included in your environment, visit its website ( and directly download. Unzip and put the whole folder into where your environment place $\LaTeX$ library, for example, for those MiKTeX users, it would be C:\Program Files\MiKTeX 2.9\tex\latex

The follows is an example of applying Optidef.

\begin{mini}{x_1,x_2}{3x_1+8x_2} {\label{eq1}}{}

\addConstraint{x_1+x_2}{\leq 25}

\addConstraint{x_1}{\geq 3}

\addConstraint{x_2}{\geq 0}




See its documentation for more detail.

2. eqnarray

\begin{eqnarray} \min &\sum_{i}\sum_{s}\sum_{f}\sum_{r} (C_{isfr}^+ + C_{isfr}^-)+\textbf{M}\sum_s D_s^-\nonumber \\
\begin{eqnarray} \textrm{s.t.}&\sum_i\sum_s(PQ_{isfr}+ C_{isfr}^+ - C_{isfr}^-)\times PT_{isfr}\nonumber\\
&\quad =C_{fr} \quad \forall f,r
\begin{eqnarray} & \sum_{i}\sum_{s}\sum_{f}\sum_{r} (\frac{C_{isfr}^+ + C_{isfr}^-}{PT_{isfr}}) \leq CF
\begin{eqnarray} & \sum_{i}\sum_{s}\sum_{f}(C_{isfr}^- - C_{isfr}^+)\leq 0 \quad \forall r
\begin{eqnarray} & \sum_{f}PQ_{isfr}+D_s^- = WSPM_i \quad \forall i,r,s
\begin{eqnarray} & C_{isfr}^+ \geq 0 \quad \forall i,s,f,r
\begin{eqnarray} & C_{isfr}^- \geq 0 \quad \forall i,s,f,r
\begin{eqnarray} & D_s^- \geq 0 \quad \forall s


I was writing a manuscript for an IEEE transactions, and the paper format is always two-column. Obviously, a breaking equation may be necessary for your optimization problem, and this is one of my compromise solutions for this situation.

3. Array

For most of one-column paper, this might be my priority one. But please note that you would better  add “\displaystyle” every time you use a summation symbol, and a comparison is made for your reference. Please note the \displaybreak[d], see row 2, is an option setting about controlling the break between pages. About the parameter d is described as follows:

 d=0 means breaking between pages is strictly forbidden, and d=4 means breaking the model is enforced. If you would like to let the break occurs conveniently in between equations, try d=1~3

\displaystyle\min_{y} & \multicolumn{3}{l}{z=y^2_1+y^2_2+\ldots+y^2_n} \\
\textrm{s.t.} & y_1y_2\ldots y_n & = & c \\
&\displaystyle \sum_{i=1}^5 y_i & \leq & 5 \\
&\sum_{i=1}^5 y_i & \leq & 5 \\
& y_i & \geq & 0 & & i=1,2,\ldots,5 \\


4. Align

Basically, this will make a align-right style

\min_{y} \quad z=y^2_1+y^2_2+\ldots+y^2_n \\
\textrm{s.t.}\quad y_1y_2\ldots y_n & = c \\
\sum_{i=1}^5 y_i & \leq 5\\
y_i &\geq 0 \quad i=1,2,\ldots,5


5. Aligned

This one is interesting because it generates align-left style. So, no matter what, your optimization problem will not look too bad at all.

& \min_{y} && z=y^2_1+y^2_2+\ldots+y^2_n \\
& \textrm{s.t.} && y_1y_2\ldots y_n=c \\
&&& \sum_{i=1}^5 y_i \leq 5\\
&&& y_i \geq 0 \quad i=1,2,\ldots,5 \\



6. Matrix

I only used this method for typing a statistics handout for students. My understanding is, this is appropriate for the length of each equation is similar.

\min_{y} & \displaystyle z=\sum_{i=1}^5 y_i^2 \\
\textrm{s.t.} & y_1y_2\ldots y_n & = & c \\
& \displaystyle \sum_{i=1}^5 y_i & \leq & 5\\
& y_i & \geq & 0 && \quad i=1,2,\ldots,5 \\




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s