Skip to main content

Questions tagged [logical-constraints]

For questions about constraints that can be expressed in (usually propositional) logic.

Filter by
Sorted by
Tagged with
1 vote
1 answer
91 views

Conditional binary programming

I am currently trying to model the relationship that if the binary variables $b_{it}=0$ and $c_{it}=1$, and for the integer non-negative variable $b^{n}_{i(t-1)}=0$, then the new binary variable $a_{...
mingabua's user avatar
2 votes
2 answers
121 views

Deriving linear constraints from logical notation

I have the following two logical implications. $x_{it}$ and $y_{it}$ are binary, $N$ is an integer number. $i$ and $k$ are indexes. $$\sum_{k=1}^{t}x_{ik}\ge N~\implies y_{it}=1$$ $$\sum_{k=1}^{t}x_{...
manofthousandnames's user avatar
0 votes
2 answers
79 views

Help modeling specific constraint

I have the following variables and I am trying to formulate a suitable constraint. I have the binary variables $a_{ij}$ and $b_{ij}$ and now I want to encode $c_{ij}$ (also binary). $c_{ij}$ should ...
Uni ewr's user avatar
  • 61
4 votes
2 answers
297 views

Linear condition between two continuous variables

There are two real variables $x$ and $y$. The conditions are such that: if $y\le 0$, then $x=0$ if $y>0$, then $x=y$ How to write linear equations or inequalities to satisfy both the conditions?
Lorentz's user avatar
  • 41
1 vote
1 answer
62 views

Help with logical operator

I have a model with different days $t\in T$ and different shifts $k\in ${ $k_1, k_2, k_3$}. I now want to write the following sentence with logic operators. "For all $t\in ${$1,...,T-1$}, if ...
manofthousandnames's user avatar
0 votes
1 answer
36 views

Add second "constraint" to model a binary variable

in my model I have the binary variable $f_{ij}$ which pushes a time-dependent $j$ integer variable $D_{ij}$ to zero if $f_{ij}$ takes the value 1 and keeps the integer number if $f_{ij}$ equals 0. Yes,...
marvelfab12's user avatar
4 votes
3 answers
322 views

How to maximize the number of variables with value at least 0?

Given a matrix $A$ and a vector $b$, I would like to find a vector $x$ satisfying the set of linear constraints $A x \leq b$, and subject to that, contains as many variables as possible with ...
Erel Segal-Halevi's user avatar
1 vote
1 answer
103 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 ...
xavgo's user avatar
  • 11
1 vote
1 answer
115 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 ...
Clement's user avatar
  • 2,252
0 votes
1 answer
85 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 ...
Ying's user avatar
  • 105
2 votes
1 answer
250 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 ...
Basma Ben Mahmoud's user avatar
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 ...
Matheus Diógenes Andrade's user avatar
1 vote
1 answer
94 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 ...
Lemma's user avatar
  • 23
1 vote
1 answer
87 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} \...
lukdooxb1's user avatar
1 vote
1 answer
118 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$...
abcd's user avatar
  • 55
1 vote
2 answers
223 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}\...
abcd's user avatar
  • 55
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 ...
abcd's user avatar
  • 55
0 votes
0 answers
37 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 ...
Vamsi Krishna Kunapareddy's user avatar
2 votes
2 answers
173 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 ...
TTY's user avatar
  • 245
1 vote
1 answer
122 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}$ ...
CHE's user avatar
  • 113
2 votes
1 answer
131 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?
uni_lad's user avatar
  • 39
2 votes
1 answer
64 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 ...
Hemfri's user avatar
  • 33
1 vote
1 answer
434 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 \...
Rainbow's user avatar
  • 53
3 votes
1 answer
239 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 ...
Nicolas Kaiser's user avatar
1 vote
2 answers
222 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} =...
ephemeral's user avatar
  • 917
1 vote
1 answer
42 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 ...
A.Omidi's user avatar
  • 8,950
1 vote
0 answers
87 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 ...
B.Kim's user avatar
  • 11
0 votes
0 answers
34 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 $...
al b's user avatar
  • 1
7 votes
3 answers
742 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 ...
orpanter's user avatar
  • 517
0 votes
2 answers
73 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 ...
ephemeral's user avatar
  • 917
1 vote
1 answer
95 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 ...
ephemeral's user avatar
  • 917
7 votes
1 answer
640 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 $\...
nflgreaternba's user avatar
3 votes
2 answers
302 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 }...
user11940's user avatar
3 votes
2 answers
391 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 ...
mingabua's user avatar
5 votes
4 answers
882 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 ...
linkho's user avatar
  • 177
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 ...
Mike's user avatar
  • 717
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 =...
Optimization team's user avatar
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 ...
A.Omidi's user avatar
  • 8,950
4 votes
2 answers
379 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.
Clement's user avatar
  • 2,252
2 votes
2 answers
375 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 \...
Krypt's user avatar
  • 97
3 votes
1 answer
126 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....
RobPratt's user avatar
  • 32.3k
3 votes
3 answers
262 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 ...
tomashauser's user avatar
2 votes
0 answers
105 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 ...
A.Omidi's user avatar
  • 8,950
4 votes
2 answers
310 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) \...
Mr. Blue's user avatar
0 votes
1 answer
69 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$ ...
Libra's user avatar
  • 937
2 votes
2 answers
242 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$...
A.Omidi's user avatar
  • 8,950
3 votes
3 answers
661 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 ...
mufassir's user avatar
  • 211
3 votes
3 answers
310 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: ...
devOn's user avatar
  • 33
-1 votes
2 answers
92 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$ ...
Ghulam Mohy-ud-din's user avatar
2 votes
1 answer
172 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 ...
akkha's user avatar
  • 67