Questions tagged [logical-constraints]
For questions about constraints that can be expressed in (usually propositional) logic.
137
questions
1
vote
1
answer
61
views
In Pyomo, how do I modify the Variable if the value is less than 0?
Pyomo does not allow to use if statements that involves variables. I want to create a new dictionary, model.Excess1, which uses the values from model.Excess to ...
1
vote
1
answer
113
views
How to model the following Constraint
I would like to model the following:
$B \le \alpha \implies \sum_i W(i) \ge \beta$, where $B$ a continuous variable, $W(i)$ binary variables, $\alpha$ a real constant number, $\beta$ an integer ...
0
votes
1
answer
84
views
How to represent "if $y_{it} = 1$ and $z_{jt'}=1$ then $x_{ij,t+t'}=1$"
There is a fulfillment problem in the e-commerce logistics field, where the fulfillment of each order is composed of a main transport (from City A to City B, referred to as a route) and an end ...
2
votes
1
answer
249
views
Replace the constraint using ==> by a linear formulation
I would like to know how to express the continuity constraint without using a decision variable in the conditional form. My challenge is to stay with a linear formulation.
I will start to explain my ...
0
votes
1
answer
46
views
Circular queue modeling
Let
$P$ be a set of discretely interruptible processes/tasks;
$T_i \in \mathbb{N}$ be the running time of process $i \in P$; And
$\tau \in \mathbb{N}$ be the maximum amount of time a process can use ...
1
vote
1
answer
93
views
Logical conditions
This is similar to question I asked here: Priotization rules for variable allocation in linear programming. In an optimization problem, the goal is to manage the purchase and sale of items under ...
1
vote
1
answer
85
views
Problems with Big-M Constraint
I have the following constraints for my roster optimisation problem:
\begin{align}
&(1-r_{i,t})\le \sum_{j=t-\chi}^{t-1}sc_{i,j}\quad &\forall i\in I, t\in \{1+\chi,\ldots,T\}
\end{align}
\...
1
vote
1
answer
117
views
Which of these formulations has the tightest linear relaxation ? (Part 2)
This is a follow up question of this question, in which it was asked to compare the "tightness" of two models:
I have a sequence of binary variables $x_i$ and want to enforce
consecutive $1$...
1
vote
2
answers
221
views
Which of these formulations has the tightest linear relaxation?
I have a sequence of binary variables $x_i$ and want to enforce consecutive $1$'s of length at least $3$. I have $2$ formulations:
Model $1$ (from here):
\begin{align}
x_i \le x_{i-1}+x_{i+1} \tag{1}\...
3
votes
2
answers
150
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
36
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 ...
2
votes
2
answers
172
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
119
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
127
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
62
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
431
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
230
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
182
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
41
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
83
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
32
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
738
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
66
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
92
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
624
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
300
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
390
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
877
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
55
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
502
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
48
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
377
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
121
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
259
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
97
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
304
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
68
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
241
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
631
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
309
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
90
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
169
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
363
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
187
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
285
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
471
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
131
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
333
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
444
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 \...