带约束对齐和参考 MILP 模型的 Optidef 问题

带约束对齐和参考 MILP 模型的 Optidef 问题

嗨,我读过 optidef 指南,但我无法在 overleaf 中正确编写我的混合整数线性问题,约束未对齐,并且它没有显示所有约束的括号之间的数字。此外,我不知道我是否可以像使用 \ref{} 方法一样在文本中引用每个约束

\documentclass[11pt,a4paper]{article}
\usepackage[short]{optidef}
\begin{document}
\begin{mini} {}{C_{\text{max}}}{}{} 
\addConstraint{\sum_{k \in M_j} X_{ijk}}{= 1,}{\quad \forall i \in J, \forall j \in O_i\label{eq:1}}
\addConstraint{S_{ijk} + C_{ijk}}{\leq X_{ijk}\cdot L,}{\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j \label{eq:2}} 
\addConstraint{C_{ijk}}{\geq S_{ijk} + t_{ijk} - (1 - X_{ijk}) \cdot L,}{\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j \label{eq:3}} 
\addConstraint{S_{ijk}}{\geq C_{i’j’k} - (Y_{iji’j’k}) \cdot L,}{\quad \forall i < i’, \forall j \in O_i, \forall j’ \in O_{i’}, \forall k \in M_j \cap M_{j’} \label{eq:4}} 
\addConstraint{S_{i’j’k}}{\geq C_{ijk} - (1 - Y_{iji’j’k}) \cdot L,}{\quad \forall i < i’, \forall j \in O_i, \forall j’ \in O_{i’}, \forall k \in M_j \cap M_{j’} \label{eq:5}} 
\addConstraint{\sum_{k \in M_j} S_{ijk}}{\geq \sum_{k \in M_j} C_{i,j-1,k},}{\quad \forall i \in J, \forall j \in O_i \setminus {O_{if(i)}} \label{eq:6}} 
\addConstraint{C_i}{\geq \sum_{k \in M_j} C_{i,O_{il_{(i)}},k},}{\quad \forall i \in J \label{eq:7}} 
\addConstraint{C_{\text{max}}}{\geq C_i,}{\quad \forall i \in J \label{eq:8}} \addConstraint{X_{ijk}}{\in {0, 1},}{\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j} 
\addConstraint{S_{ijk}, C_{ijk}, C_i}{\geq 0,}{\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j} 
\addConstraint{Y_{iji’j’k}}{\in {0, 1},}{\quad \forall i < i’, \forall j \in O_i, \forall j’ \in O_{i’}, \forall k \in M_j \cap M_{j’}} 
\end{mini}
\end{document}

输出如下:

在此处输入图片描述

答案1

你好像想要mini!

\documentclass[a4paper]{article}
\usepackage[margin=1cm,heightrounded]{geometry}
\usepackage[short]{optidef}
\begin{document}

\begin{mini!} {}{C_{\mathrm{max}}}{}{\notag}
\addConstraint{\sum_{k \in M_j} X_{ijk}}{= 1,}
  {\quad \forall i \in J, \forall j \in O_i\label{eq:1}}
\addConstraint{S_{ijk} + C_{ijk}}{\leq X_{ijk}\cdot L,}
  {\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j \label{eq:2}} 
\addConstraint{C_{ijk}}{\geq S_{ijk} + t_{ijk} - (1 - X_{ijk}) \cdot L,}
  {\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j \label{eq:3}} 
\addConstraint{S_{ijk}}{\geq C_{i'j'k} - (Y_{iji'j'k}) \cdot L,}
  {\quad \forall i < i', \forall j \in O_i, \forall j' \in O_{i'},
   \forall k \in M_j \cap M_{j'} \label{eq:4}} 
\addConstraint{S_{i'j'k}}{\geq C_{ijk} - (1 - Y_{iji'j'k}) \cdot L,}
  {\quad \forall i < i', \forall j \in O_i, \forall j' \in O_{i'},
   \forall k \in M_j \cap M_{j'} \label{eq:5}} 
\addConstraint{\sum_{k \in M_j} S_{ijk}}{\geq \sum_{k \in M_j} C_{i,j-1,k},}
  {\quad \forall i \in J, \forall j \in O_i \setminus {O_{if(i)}} \label{eq:6}} 
\addConstraint{C_i}{\geq \sum_{k \in M_j} C_{i,O_{il_{(i)}},k},}
  {\quad \forall i \in J \label{eq:7}} 
\addConstraint{C_{\mathrm{max}}}{\geq C_i,}
  {\quad \forall i \in J \label{eq:8}}
\addConstraint{X_{ijk}}{\in {0, 1},}
  {\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j} 
\addConstraint{S_{ijk}, C_{ijk}, C_i}{\geq 0,}
  {\quad \forall i \in J, \forall j \in O_i, \forall k \in M_j} 
\addConstraint{Y_{iji'j'k}}{\in {0, 1},}
  {\quad \forall i < i', \forall j \in O_i, \forall j' \in O_{i'},
   \forall k \in M_j \cap M_{j'}} 
\end{mini!}
\end{document}

在此处输入图片描述

应该是\mathrm{max}(或\max),而不是\text{max}

相关内容