4

Is it possible to label an optimization problem with a master label, as well as to label each line with a sublabel?

For example, I want to label the optimization problem as (AP), but I also want to label the objective and each of the constraints, in a single equation environment.

This is what I am able to do.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

The assignment problem is the problem of assigning
agents $i = 1, 2, \ldots, N$
to tasks $j = 1, 2, \ldots N$
in order to minimize the total cost of the assignments.
Any agent could be assigned to any task,
incurring a cost that depends on the agent-task assignment.
The objective is to minimize the total cost of assignment.

\paragraph{Input data:}
\begin{itemize}
\item $N = $ number of agents $ = $ number of tasks
\item $c_{ij} = $ cost of assigning task $j$ to agent $i$
\end{itemize}

\paragraph{Decision variables:}
\begin{itemize}
\item $x_{ij} = 1$ if agent $i$ is assigned to task $j$,
$x_{ij} = 0$ otherwise
\end{itemize}

\paragraph{Optimization problem formulation:}
\begin{alignat}{3}
   & \min\
  && \sum_{i=1}^N \sum_{j=1}^N c_{ij}x_{ij}
  & \quad &
  \label{objective}  
\\
   & \text{s.t.}
  && \sum_{i=1}^N x_{ij} = 1
  && \forall j \in \{1,2,\ldots,N\}
  \label{each task must be assigned to an agent}
\\
   & 
  && \sum_{j=1}^N x_{ij} = 1
  && \forall i = \{1,2,\ldots,N\}
  \label{each agent must be assigned to a task}
\\
   &
  && 0 \leq x_{ij} \geq 1
  && \forall i \in \{1,2,\ldots,N\}, j \in \{1,2,\ldots,N\}
  \label{binary variable constraint}
\end{alignat}

The objective \eqref{objective} is to minimize the total cost of assignment.
The constraint \eqref{each task must be assigned to an agent}
states that each task must be assigned to an agent.
The constraint \eqref{each agent must be assigned to a task}
states that each agent must be assigned to a task.
The constraint \eqref{binary variable constraint}
imposes binary lower and upper bounds on the assignment variables $x_{ij}$.


The assignment problem can be formulated as the following optimization problem
\begin{equation}
\tag{AP}
\label{assignment problem}
\begin{alignedat}{3}
   & \min\
  && \sum_{i=1}^N \sum_{j=1}^N c_{ij}x_{ij}
  & \quad &
\\
   & \text{s.t.}
  && \sum_{i=1}^N x_{ij} = 1
  && \forall j \in \{1,2,\ldots,N\}
\\
   & 
  && \sum_{j=1}^N x_{ij} = 1
  && \forall i = \{1,2,\ldots,N\}
\\
   &
  && 0 \leq x_{ij} \leq 1
  && \forall i \in \{1,2,\ldots,N\}, j \in \{1,2,\ldots,N\}
\end{alignedat}
\end{equation}

Are you looking for the formulation of the assignment problem?
It is in equation \eqref{assignment problem} above.

\end{document}

enter image description here

I would like the output to be something like the following:

        min  sum sum c_ij x_ij               (1)
(AP)    s.t. sum_i x_ij = 1                  (2)
             sum_j x_ij = 1                  (3)
             0 <= x_ij <= 1                  (4)

where (AP) is vertically aligned in the center, basically a combination of the two equations in the output image.

If there is a better way to achieve this master labels and sublabels, I would like to know about this as well.

1
  • \label, \ref and \eqref are used with counters, not tags. Why is "assignment problem" easier to remember than "(AP)"> Aug 14, 2014 at 3:27

2 Answers 2

4

I assume you want to replace (AP) with a (I) (II) etc. One can just as easily use (AP.1) or (A), etc. The \rule is there just to check alignment.

The disadvantage of this approach is that the equations are not quite centered. The advantage is that you can include text or very long equations without overlap. You might even consider moving the assignment number into the left margin using \llap.

\documentclass{article}
\usepackage{amsmath}

\newcounter{AScount}
\renewcommand{\theAScount}{\Roman{AScount}}
\newlength{\ASlen}

\newenvironment{assignment}[1]% #1=label
{\refstepcounter{AScount}\label{#1}%
\ifvmode\noindent\else\newline\fi%
\makebox[\labelwidth][l]{(\theAScount)}%
\setlength{\ASlen}{\linewidth}%
\addtolength{\ASlen}{-\labelwidth}%
\minipage[c]{\ASlen}}%
{\endminipage}

\begin{document}
\noindent\rule{\textwidth}{1pt}

\begin{assignment}{assignment problem}
\begin{equation}
x=a
\end{equation}
\begin{equation}
y=b
\end{equation}
\end{assignment}

Assignment problem \eqref{assignment problem}.
\end{document}

assignment

2

This may have been asked before. I hope you're flexible with the alignat environment. I switched to align. Sorry, force of habit. If that doesn't work for you, leave a comment.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{mysubeqns}[1]
 {%
  \addtocounter{equation}{-1}%
  \begin{subequations}
  \renewcommand{\theparentequation}{#1}%
  \def\@currentlabel{#1}%
 }
 {%
  \end{subequations}
 }
\makeatother

\begin{document}

The assignment problem is the problem of assigning
agents $i = 1, 2, \ldots, N$
to tasks $j = 1, 2, \ldots N$
in order to minimize the total cost of the assignments.
Any agent could be assigned to any task,
incurring a cost that depends on the agent-task assignment.
The objective is to minimize the total cost of assignment.

\paragraph{Input data:}
\begin{itemize}
\item $N = $ number of agents $ = $ number of tasks
\item $c_{ij} = $ cost of assigning task $j$ to agent $i$
\end{itemize}

\paragraph{Decision variables:}
\begin{itemize}
\item $x_{ij} = 1$ if agent $i$ is assigned to task $j$,
$x_{ij} = 0$ otherwise
\end{itemize}

\paragraph{Optimization problem formulation:}
\begin{alignat}{3}
   & \min\
  && \sum_{i=1}^N \sum_{j=1}^N c_{ij}x_{ij}
  & \quad &
  \label{objective}  
\\
   & \text{s.t.}
  && \sum_{i=1}^N x_{ij} = 1
  && \forall j \in \{1,2,\ldots,N\}
  \label{each task must be assigned to an agent}
\\
   & 
  && \sum_{j=1}^N x_{ij} = 1
  && \forall i = \{1,2,\ldots,N\}
  \label{each agent must be assigned to a task}
\\
   &
  && 0 \leq x_{ij} \geq 1
  && \forall i \in \{1,2,\ldots,N\}, j \in \{1,2,\ldots,N\}
  \label{binary variable constraint}
\end{alignat}

The objective \eqref{objective} is to minimize the total cost of assignment.
The constraint \eqref{each task must be assigned to an agent}
states that each task must be assigned to an agent.
The constraint \eqref{each agent must be assigned to a task}
states that each agent must be assigned to a task.
The constraint \eqref{binary variable constraint}
imposes binary lower and upper bounds on the assignment variables $x_{ij}$.


The assignment problem can be formulated as the following optimization problem

\begin{mysubeqns}{AP}
\label{eq:assignment problem}
  \begin{align}
  \min\     &\sum_{i=1}^N \sum_{j=1}^N c_{ij}x_{ij}     &&                  & \label{eq:assignment problem1} \\
  \text{s.t.}   &\sum_{i=1}^N x_{ij} = 1            && \forall j \in \{1,2,\ldots,N\}   & \label{eq:assignment problem2} \\
        &\sum_{j=1}^N x_{ij} = 1            && \forall i = \{1,2,\ldots,N\} &\label{eq:assignment problem3} \\
        &0 \leq x_{ij} \leq 1                   && \forall i \in \{1,2,\ldots,N\}, j \in \{1,2,\ldots,N\}   &\label{eq:assignment problem4}
  \end{align}
\end{mysubeqns}
Another equation
\begin{equation}
2=2
\end{equation}

Are you looking for the formulation of the assignment problem?
It is in equation \eqref{eq:assignment problem} above.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .