Questions tagged [logical-constraints]
For questions about constraints that can be expressed in (usually propositional) logic.
129
questions
3
votes
2
answers
139
views
Will adding this constraint help my model?
I am solving a maximization problem with continuous variables $x,z\in \mathbb{R}^+$ and binary variable $\delta \in \{0,1\}$.
I am maximizing $x$ subject to side constraints and would like to enforce ...
0
votes
0
answers
31
views
Could you model this if -else statement [duplicate]
I need to build a if-else constraint for this statement, where $c_j$ and $x_{ij}$ are decision variables, and $m_i$ is a constant:
if $c_j$ = $m_i$ then $x_{ij}$ = 1 else $x_{ij} = 0$.
Any help is ...
-3
votes
0
answers
30
views
2
votes
2
answers
171
views
Express cardinality of index set satisfying conditions
I have two sets of binary variables $x_{i,j}$ and $y_{i,k}$, where $i, j, k$ ranges over some index set $I,J,K$, which satisfies the constraint $\sum_j x_{i,j} = 1$, $\sum_{k} y_{i, k} = 1$. How do I ...
1
vote
1
answer
110
views
How to linearize the following constraints
Given the following two expressions:
$ x - \frac{1}{T}\sum_{i} y_{i}$
$ x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i}$
where $x \in \mathbb{Z}_{+}$, $y \in \mathbb{R}_{+}$, and $T$, $Q$ and $\beta_{i}$ ...
2
votes
1
answer
112
views
logic constraints for IP model
I have been struggling with the formulation of logic constraints. Is there any source you would recommend to understand the topic better or trick of formulation of the constraints?
2
votes
1
answer
60
views
how to linearize if-then when having an operand?
if $x_{i,j,p,s}$ and $y_{i,j,p,s}$ are binary and $z_i^s$ is integer; how to enforce:
$$
((x_{i,j,p,s}=1) \land (z_i^s \ge 5 )) \implies y_{i,j,p,s}=1
$$
The value of $z$ in my problem could be 1 to ...
1
vote
1
answer
424
views
Is it possible to do a linearization without introducing new variables?
I have three binary variables $x_{i,j}^{m,r}$ , $y_i^{m,r}$, and $z_i^{m,r}$. There is another integer variable $w_i^r$. And I want to linearize the following logic:
$$ \sum_{m} x_{i,j}^{m,r} \ge 1 \...
3
votes
1
answer
210
views
Formulation of binary constraint with the least binary variables for linear programming
I am currently working on a formulation for a linear program of a complex problem. At the moment I am facing to formulate the following logical condition:
There are two binary variables. Let's name ...
1
vote
2
answers
151
views
Linearizing if else conditions in ILP
We are given three binary indicator variables $X_{ij}, Y_{jk}$ and $Z_{jl}$. Write linear constraints such that,
a) if $X_{ij}$ is equal to 1, then for that $j$ when $X_{ij} = 1$, exactly one $Y_{jk} =...
1
vote
1
answer
40
views
Activating a sequence of the binary variables in a multi-dimensional array
Suppose we have an array of binary variables $\{x_{i,t,n}, \ \forall i \in I, t \in T, n \in N \}$. If we want to define a condition as, if any of $x_{i,t,n} = 1$ in an arbitrary index $i$, then the ...
1
vote
0
answers
68
views
Linearization of Conditional Constraints for MIP using Cplex
I'm currently working on a mixed-integer programming (MIP) problem and I'm trying to implement a set of conditional constraints in CPlex. These constraints involve decision variables that are indexed ...
0
votes
0
answers
29
views
Joint, two-sided chance constraint of MILP reformulation of a logical constrain
I reformulated the logical constraint $x = \min\{y,z\}$ as this MILP problem
$$
\begin{array}{ll}
x &\leq y \\
x &\leq z \\
x &\geq y-M(1-w) \\
x &\geq z-Mw
\end{array}
$$
in which $...
7
votes
3
answers
731
views
Binary logical constraint dependent on indices
I don't know if I can ask this here, but I've been pulling my hair out trying to think of how to represent this in constraints.
I have two sets of binary variables: $X_t$ and $Y_{it}$. So, I want to ...
0
votes
2
answers
54
views
ILP constraint conditional on a value of a variable
If $X_{ijklm}$ are Boolean Variables, where $i,j,k,l,m$ range from $1$ to $n$, then write an ILP constraint to ensure that for each value of $k$, either all the $jth$ variables are set to $0$ or all ...
1
vote
1
answer
74
views
Setting constant values in constraints depending on actual values of variables
We have a set of constraints in an ILP of the following form :
$ \gamma (X_{11} + X_{12} + X_{13}) \leq C_1$ where $X_{ij} \in \{0,1\}$ and the value of $\gamma$ is going to depend on the actual value ...
7
votes
1
answer
613
views
How can one model a binary variable?
I am looking for the formulation of a constraint that does the following. I want to introduce a new binary variable $\kappa_{it}$ that takes the value 1 if the sum of the other binary variable $\...
3
votes
2
answers
286
views
Modeling a continuous variable which can't take values between a and b
Consider two binary variables $p_1$ and $p_2$. Suppose, $x$ is a continuous variable that should not take values between $a$ and $b$.
Here is my try:
$$
p_1 =1 \mbox{ if } x \le a \\
p_1 =0 \mbox{ if }...
3
votes
2
answers
386
views
How to model a binary variable?
I am trying to find a constraint for the following relationship, but am failing a bit at it right now. I want to find a linear constraint that does the following. The binary variable $switch_{ot}$ is ...
5
votes
4
answers
875
views
Rewriting if-then constraints of binary summations
Suppose both $x_{i,j}^{ab}$ and $y_{i,j}^a$ are binaries. Then how can I rewrite the following if-then in linear form?
$\sum_b x_{i,j}^{ab} \ge 1 \implies \sum_{i,j} y_{i,j}^a = 0$
I was thinking of ...
1
vote
1
answer
54
views
Assistance in formulating implication constraints for inequalities
I would like to seek some advice on modeling the following logical implications, where $\delta$ is a binary variable, $D_{j}$ and $A_{j}$ are nonnegative discrete variables, and $p_{j}$ are ...
4
votes
3
answers
500
views
How can I formulate this 'if-then' constraint problem?
I have five integer variables, and I need to write some constraints on them:
$x_0$ , $[x_1, x_2, x_3, x_4 ]$. $1 \leq x_i \leq 3$
if $x_0 =1$ then no constraint on $[x_1, x_2, x_3, x_4 ]$
if $x_0 =...
2
votes
1
answer
47
views
A tighter relaxation of the mix logical constraints
Suppose the following logical form there exists.
$$Iff: (x_{j,m} \land x_{k,m}) \implies ((C_{j} \leq S_{k}) \lor (C_{k} \leq S_{j}))$$
This is well-known as a no_overlap_constraint in the parallel ...
4
votes
2
answers
376
views
How to model $C_1=C_2$ implies $b_1 = b_2$
Suppose $C_1 \ge 0$, $C_2 \ge 0$ are continuous variables and $b_1$, $b_2$ are binary variables.
How could I model the following?
$C_1 = C_2 \implies b_1 = b_2$, the opposite does not hold.
2
votes
2
answers
373
views
Representing "and"/"or" relationships into constraints
How do I represent the following constraints in terms of equations?
For each i, either (1) holds or (2) holds-
$$
x_{1}^i \geq x_{2}^i \quad and \quad x_{3}^i \geq x_{4}^i \quad {(1)}
$$
$$
x_{1}^i \...
3
votes
1
answer
87
views
How to enforce logical implication $\sum_j a_j x_j \le b \implies \sum_j c_j x_j \le d$
Some modeling languages and solvers support indicator constraints of the form $$y=\hat{y} \implies \sum_j a_j x_j \le b,$$ where $y$ is a binary decision variable and $\hat{y}\in\{0,1\}$ is a constant....
3
votes
3
answers
249
views
Equivalence between constraints in ILP
Let's have binary variables $x$ and $y$. I'd like to define a helping binary variable $z$ such that
$$ z = 1 \; \;\; \mathrm{iff} \; \; \; x + y = 2.$$
If I wanted to express the equivalence between ...
2
votes
0
answers
88
views
The linearization of the logical constraints
I know the logical constraints can be linearized by either the logical representation of whose relation, (for pure binary variables e.g. CNF/DNF) or for general form by using Big-M formulation. As I ...
4
votes
2
answers
297
views
The linearization of the (Iff-and-only-Iff) expression
I am trying to linearize the following expression without using the Big-M formulation, but I cannot convert it. I am willing to know if there exists an efficient way to do that?
$$ Iff \quad (w=1) \...
0
votes
1
answer
65
views
Maximization problem with preferences on variables
Consider the following trivial, theoretical model:
$$
\max x+2y+3z \qquad s.t.
$$
$$
x \leq b_x
$$
$$
y \leq b_y
$$
$$
z \leq b_z
$$
$$
x+y+z = 1
$$
$$
x,y,z \in \{0, 1\}
$$
and $b_x$, $b_y$ and $b_z$ ...
2
votes
2
answers
236
views
Linearizing a disjunctive expression into MILP
I want to linearize the following disjunctive form.
$$\left[\begin{gathered}w_{1}\\x \geq a\end{gathered}\right] \vee \left[\begin{gathered}w_{2}\\x \geq b\end{gathered}\right]$$
where $w_1$ and $w_2$...
3
votes
3
answers
606
views
Modelling if elif else conditions as MIP
I have 4 variables. Xl6, Xs6, Pl6, Ps6. I have a constant C as well.
Xl6 and Xs6 are binary whereas Pl6 and Ps6 are integers. Also, all variables can take only positive values.
I have to implement ...
3
votes
3
answers
298
views
Set null the next set of N values
I'm dealing with a problem I already modelled by using linear programming. The already existing constraints set at 1 groups of contiguous variables (for ex: ...
-1
votes
2
answers
89
views
How to apply smooth approximation to non-linear complementarity constraints?
$P =$
$ x, if U \geq U^{max} $
$ y, if U^{up} < U < U^{max} $
$ z, if U^{down} < U < U^{up} $
$ \alpha, if U^{min} < U < U^{down} $
$ \beta, if U \leq U^{min} $
Where $P$, and $U$ ...
2
votes
1
answer
159
views
Piecewise constraint using big-M notation
I have a piecewise constraint that I am having a hard time converting using big-M modelling. The context is a gym owner that is updating membership costs subject to churn restrictions. The owner can ...
4
votes
1
answer
358
views
How can I transform this logical if-then constraint? [duplicate]
I want to know how to transform this logical if-then constraint? If $B=1$,then $A \ge C$, else $A=0$, where $A$ and $B$ are decision variables and $C$ are constants. $B$ is binary variable and $A\ge 0$...
1
vote
1
answer
182
views
How to write this logical expression with Gurobi + Java, or express it as a big-m formulation
I am trying to write the following expression in Gurobi+Java or Gurobi+python, if it is more practical It could be expressed as a big-M formulation.
\begin{equation} \label{const4}
\text{D}_{uv} =
...
5
votes
3
answers
253
views
MIP constraint with sum of decision variables having certain value : $\sum_{i=1}^nx_i = 2 \implies \delta = 1$
I want to formulate a MIP constraint such that :
$$\sum_{i=1}^nx_i = 2 \implies \delta = 1$$
$x_i, \delta \in \{0, 1\}$.
My problem is that delta should be one when this sum is exactly 2 and not ...
2
votes
1
answer
446
views
If/then constraint formulation
Let's assume we have event $i=1,2,\cdots,k$, denoted as $\text{event}_i$. We know for a fact that $\text{event}_i$ is smaller then $\text{event}_{i+1}$ i.e., $\text{event}_i \leq \text{event}_{i+1}$. ...
2
votes
1
answer
128
views
Conditional constraint for binary
Could you please check where I might be wrong?
Task is:
If $z=1$, then either $x=1$ or $y=1$
My approach:
If $z=1$, then $x+y=1$
$\implies x+y\le1$
$\implies x+y\ge1$
If $z=0$, then $x+y\ge0 - M\cdot(...
3
votes
2
answers
297
views
Can we use continuous variables instead of binary variables in this NLP problem?
The following problem is defined with binary variables $a_{i1}, a_{i2}, a_{i3}, k_1$ and $k_2$.
Is it possible to avoid binary variables and to only work with continuous variables? How would we ought ...
4
votes
3
answers
434
views
How to transform a logical constraint with integer variables?
Consider the binary variables $x_1, x_2 \in \{0,1\}$ and the integer variable $y \in \mathbb{Z}$ with $0 \leq y \leq 3$.
I'd like to formulate the following logical constraint:
$$
x_1 = 1 \wedge y \...
2
votes
1
answer
179
views
Binary variable constraint for condition
I am trying to solve the following task:
If $x=1$ or $y=0$ then $z=0$
My approach:
If $z=0$ then $x+y \le 2 + Mz \implies x+y \le 2+2z \quad$
where $M = 2$
If $z=1$ then $x+y=1 \\
\implies
x+y \le 1, ...
0
votes
1
answer
75
views
Conditional constraint for binary variables
I would appreciate any help to solve the following task:
If $y=1$ then $x_i=1$ for at least $k$ of the possible indices $i\in\{1,\cdots,n\}$ where $k$ and $n$ are parameters, $x$ is a binary variable ...
2
votes
2
answers
73
views
How to model this?
$i$ is a set $1$ to $n$.
$j$ is a set $1$ to $m$.
$j$ and $k$ are from the same set such that $j\neq k$.
$c_{ij}$ is a parameter.
$x_{ij}$ and $y_{j}$ are binary variables.
How to model: If
$$c_{ij}\...
5
votes
2
answers
345
views
Binary variable constraint
The task is to ensure that if $x_i = 1$ for at least $k$ of the possible indices $i$ in $\{1,...,n\}$ then $y = 1$, where $k$ and $n$ are parameters, $x$ is a binary variable vector with $n$ elements, ...
3
votes
1
answer
286
views
Binary variables constraint
What constraints would you write to ensure that if $x = 1$ then $y = 0$ where $x, y$ are binary variables?
Until now I only learnt how to build the constraint with 3 binary variables, therefore the ...
4
votes
1
answer
75
views
Another difficult constraint for an ILP
How can I add to this ILP with all binary variables (again related to this question):
$$\min \sum_{1\leq i<j\leq n-1-h} t_{i,j}$$
$$\sum_{i=1}^{n-1-h} a_{k,i} \ge \lfloor (n-1)/2\rfloor \qquad \...
5
votes
3
answers
685
views
Constraint for two binary vectors to be different
If I have a matrix $A$ of binary variables $a_{i,j}$, $1 \le i \le n$, $1 \le j \le m$, how can I enforce in an Integer Linear Program with binary variables, the condition that every two columns must ...
3
votes
2
answers
100
views
How to model if-then?
$i$ is a set $1$ to $n$.
$j$ is a set $1$ to $m$.
$j$ and $k$ are from the same set such that $j\neq k$.
$c_{ij}$ is a parameter.
$x_{ij}$ is a binary variable.
How to model: If
$$c_{ij}\cdot x_{ij} \...