Stating a linear program

I would consider the code below as the common way to do that.

\documentclass[11pt,a4paper]{article}
\usepackage{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\begin{document}
  \begin{alignat*}{2}
    \text{minimize }   & \sum_{i=1}^m c_i x_i + \sum_{j=1}^n d_j t_j\  \\
    \text{subject to } & \sum_{i=1}^m a_{ij} + e_j t_j \geq g_j &,\ & 1\leq j\leq n\\
                       & f_i x_i + \sum_{j=1}^n b_{ij}t_j \geq h_i\ &,\ & 1\leq i\leq m\\
                       & x\geq 0,\ t_j\geq 0\ &,\ & 1\leq j\leq n,\ 1\leq i\leq m
  \end{alignat*}
\end{document}

This is a short definition I sometimes use in my articles. More like a boilerplate, and you need to change some stuff if you happen to have more constraints. The \eqnlimit macro is a shorthand for index ranges.

\documentclass{article}
\usepackage[sumlimits]{amsmath}
\usepackage{xargs}

\newcommandx*\eqnlimit[3][1=1, 3=n]{\ensuremath{#1 \leq #2 \leq #3}}

\newcommand{\linprog}[6]{
    \begin{alignat}{5}
          \label{#6-1}
          \min        & \quad #1 & \\
          \label{#6-2}
          \text{s.t.} & \quad #2 &, & \quad #3\\
          \label{#6-3}
                      & \quad #4 &, & \quad #5
    \end{alignat}}

\begin{document}
    \linprog{f(x)}{g_i(x) \leq 0}{\eqnlimit[1]{i}[n]}{h_j(x) = 0}{\eqnlimit[1]{j}[m]}{eq:linprog1}
    \linprog{f(x)}{g_i(x) \leq 0}{\eqnlimit[1]{i}[n]}{h_j(x) = 0}{\eqnlimit[1]{j}[m]}{eq:linprog2}
    \\
    First linear program\\
    This is the objective: (\ref{eq:linprog1-1}), the inequality constraint set: (\ref{eq:linprog1-2}), and the equality constraint set(\ref{eq:linprog1-3}).
    \\ \\
    Second linear program\\
    This is the objective: (\ref{eq:linprog2-1}), the inequality constraint set: (\ref{eq:linprog2-2}), and the equality constraint set(\ref{eq:linprog2-3}).
\end{document}

Thanks to Caramdir for the help with the labelling.

Tags:

Math Mode