Answers to: Defining logical constraintshttp://www.or-exchange.com/questions/12766/defining-logical-constraints<p>Let \( m_p \in \{0,1,2,\ldots,s_{max} \} \text{ for } p \in M = \{1,2,\ldots,n_{max} \} \). Let \( F \subset M \).</p>
<p>I want to define the following constraints:</p>
<p>\[
\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}
\]</p>
<p>Most of the literature I have searched through define logical operations for binary \( m_p \). My limited attempt was as follows: </p>
<p>\[
\sum_{p=1}^{n_{max}} m_p \ge 3.
\]</p>
<p>But now I get stuck at the configuration where three \( m_p \) equals one. Please guide how to proceed with this.</p>enMon, 31 Aug 2015 10:10:49 -0400Answer by Rob Pratthttp://www.or-exchange.com/questions/12766/defining-logical-constraints/12775<p>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.</p>Rob PrattMon, 31 Aug 2015 10:10:49 -0400http://www.or-exchange.com/questions/12766/defining-logical-constraints/12775