
Align 環境を使用して ILP モデルを記述すると、番号付けがうまくいきません。各番号が制約の後に続くのではなく、すべての制約の後にすべての番号が続きます。同じコードを別のドキュメントで使用すると、正常に動作します。何が問題なのでしょうか?
\begin{align}
\mbox{min.} \quad & \sum_{p \in P} \sum_{(t_{1},v_{1},t_{2},v_{2}) \in WT} c_{v_{1},v_{2}}x^p_{t_{1},v_{1},t_{2},v_{2}} \notag \\
\mbox{s.t.} \quad
& \sum_{(t_{2},v_{2},t_{1},v_{1}) \in BS(t_{1},v_{1})} x^p_{t_{2},v_{2},t_{1},v_{1}} - \sum_{(t_{1},v_{1},t_{2},v_{2}) \in FS(t_{1},v_{1})} x^p_{t_{1},v_{1},t_{2},v_{2}}\; = \; 0\qquad \forall p \in P,(v_{1},t_{1}) \in VT \\
& - \sum_{(p,o,t_{2},v_{2}) \in FS(p,o)} x^p_{p,o,t_{2},v_{2}}\; = \; - d_p \qquad \forall p \in P\\
& \sum_{(t_{1},v_{1},p,w) \in BS(p,w)} x^p_{t_{1},v_{1},p,w} \; = \; + d_p \qquad \forall p \in P\\
& \sum_{p \in P} \sum_{(t_{2},v_{2},t_{1},v_{1}) \in BS(t_{1},v_{1})} x^p_{t_{2},v_{2},t_{1},v_{1}} \; \leq \; Q \qquad\qquad\qquad\qquad\qquad\qquad\qquad\forall (v_{1},t_{1}) \in VT \\
& x^p_{t_{1},v_{1},t_{2},v_{2}} \in Z \qquad \qquad \qquad \qquad \qquad \quad \forall p \in P, \forall (t_{1},v_{1},t_{2},v_{2}) \in WT
\end{align}\\
\\
答え1
alignat{2}
環境の中に環境を埋め込むことをお勧めしますgather*
。両方の環境はパッケージによって提供されamsmath
、パッケージによって自動的にロードされますmathtools
。さらに、\smashoperator
マクロ (パッケージによって提供mathtools
) を使用して、いくつかのディレクティブの下の資料を\sum
よりコンパクトにタイプセットします。
\documentclass{article} % or some other suitable document class
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters as needed
\usepackage{mathtools} % for '\smashoperator' macro
\newcommand\vn[1]{\mathit{#1}}
\begin{document}
\begin{gather*}
\min \sum_{p \in P\mathstrut} \
\smashoperator[r]{\sum_{(t_{1},v_{1},t_{2},v_{2}) \in \vn{\vn{WT}}} }
c_{v_{1},v_{2}}x^p_{t_{1},v_{1},t_{2},v_{2}} \\
\shortintertext{such that}
\begin{alignat}{2}
\smashoperator{\sum_{(t_{2},v_{2},t_{1},v_{1}) \in \vn{BS}(t_{1},v_{1})}}
x^p_{t_{2},v_{2},t_{1},v_{1}}
\quad-\quad
\smashoperator{\sum_{(t_{1},v_{1},t_{2},v_{2}) \in \vn{FS}(t_{1},v_{1})}}
x^p_{t_{1},v_{1},t_{2},v_{2}}
&= 0
&\qquad&\forall p \in P,\ \forall(v_{1},t_{1}) \in \vn{VT} \\
-\smashoperator{\sum_{(p,o,t_{2},v_{2}) \in \vn{FS}(p,o)}}
x^p_{p,o,t_{2},v_{2}}
&= -d_p
&&\forall p \in P \\
\smashoperator{\sum_{(t_{1},v_{1},p,w) \in \vn{BS}(p,w)}}
x^p_{t_{1},v_{1},p,w}
&= + d_p
&&\forall p \in P\\
\sum_{p \in P\mathstrut} \
\smashoperator[r]{\sum_{(t_{2},v_{2},t_{1},v_{1}) \in \vn{BS}(t_{1},v_{1})}}
x^p_{t_{2},v_{2},t_{1},v_{1}}
&\leq Q
&&\forall (v_{1},t_{1}) \in \vn{VT} \\
x^p_{t_{1},v_{1},t_{2},v_{2}} &\in Z
&& \forall p \in P,\
\forall (t_{1},v_{1},t_{2},v_{2}) \in \vn{WT}
\end{alignat}
\end{gather*}
\end{document}
補遺これらの式を書き出すのが面倒なだけでなく、読者にとって理解しにくい大きな原因は、合計の下付き文字の位置に 4 つの組があることです。これらの組の省略形 (たとえば、\tau_1
thru \tau_4
) を作成し、二重合計表記法を使用することが許容される場合は、式を次のように書き直すことができます。
\documentclass{article}
\usepackage{mathtools} % for '\smashoperator' macro
\newcommand\vn[1]{\mathit{#1}}
\newcommand\doublesum{\mathop{\sum\sum}}
\begin{document}
\begin{gather*}
\min \smashoperator{\doublesum_{p \in P,\;\tau_1\in\vn{WT}}}
c^{}_{v_{1},v_{2}}x^p_{\tau_1} \\
\intertext{such that}
\begin{alignat}{2}
\smashoperator{\sum_{\tau_1\in\vn{FS}(\tau)}}
x^p_{\tau_1}
&=
\smashoperator[r]{\sum_{\tau_2\in\vn{BS}(\tau)}}
x^p_{\tau_2}
&\quad&
\forall p \in P,\ \forall\tau\in\vn{VT} \\
-\smashoperator{\sum_{\tau_3\in\vn{FS}(p,o)}}
x^p_{\tau_3}
&= -d_p
&&\forall p \in P \\
\smashoperator{\sum_{\tau_4\in\vn{BS}(p,w)}}
x^p_{\tau_4}
&= +d_p
&&\forall p \in P \\
\smashoperator{\doublesum_{p \in P,\;\tau_2\in\vn{BS}(\tau)}}
x^p_{\tau_2}
&\leq Q
&&\forall \tau\in\vn{VT} \\
x^p_{\tau_1} &\in Z
&& \forall p \in P,\ \forall \tau_1\in\vn{WT}
\end{alignat}
\end{gather*}
where $\tau\equiv(t_{1},v_{1})$,
$\tau_1\equiv(t_{1},v_{1},t_{2},v_{2})$,
$\tau_2\equiv(t_{2},v_{2},t_{1},v_{1})$,
$\tau_3\equiv(p,o,t_{2},v_{2})$, and
$\tau_4\equiv(t_{1},v_{1},p,w)$.
\end{document}