# Defining logical constraints

 0 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 28 Aug '15, 13:05 UbaAbd 15●1●1●6 accept rate: 0% The wording of your constraints is a bit unclear. Do you mean exactly one of the $$m_p$$ takes the value 2 and exactly one takes the value 1, or do you mean at least one of each? (28 Aug '15, 16:15) Paul Rubin ♦♦ @paul you're right. I have updated my question. It is "at least one". (29 Aug '15, 04:24) UbaAbd

 2 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 31 Aug '15, 10:10 Rob Pratt 1.2k●2●6 accept rate: 28%
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: