Let \( m_p \in \{0,1,2,\ldots,s_{max} \} \text{ for } p \in M = \{1,2,\ldots,n_{max} \} \). Let \( F \subset M \). I want to define the following constraints: \[ \begin{align} m_p &= 2, \text{ for at least one } p \in F, \\ m_p &= 1, \text{ for at least one } p \in F, \\ m_p &\ge 0, \text{ for all other } p \in M. \\ \end{align} \] Most of the literature I have searched through define logical operations for binary \( m_p \). My limited attempt was as follows: \[ \sum_{p=1}^{n_{max}} m_p \ge 3. \] But now I get stuck at the configuration where three \( m_p \) equals one. Please guide how to proceed with this.
asked
UbaAbd |

For \(p \in F\) and \(k \in \{1,2\}\), introduce binary variables \(x_{p,k}\) to indicate \(m_p=k\). Then the following constraints enforce that \(x_{p,k} = 1 \Rightarrow m_p=k\): \[k x_{p,k} \le m_p \le s_{\max} - (s_{\max} - k) x_{p,k}.\] Now \(\sum_{p \in F} x_{p,k} \ge 1\) for \(k \in \{1,2\}\) finishes the job.
answered
Rob Pratt |

The wording of your constraints is a bit unclear. Do you mean

exactly oneof the \(m_p\) takes the value 2 andexactly onetakes the value 1, or do you meanat leastone of each?@paul you're right. I have updated my question. It is "at least one".