Questions tagged [logical-constraints]

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

Filter by
Sorted by
Tagged with
31 votes
3 answers
18k views

In an integer program, how I can force a binary variable to equal 1 if some condition holds?

Suppose we have a binary or continuous variable $x$, a binary variable $y$, and a constant $b$, and we want to enforce a relationship like If $x \gtreqless b$, then $y = 1$. How can we write this ...
LarrySnyder610's user avatar
12 votes
2 answers
3k views

In an integer program, how can I “activate” a constraint only if a decision variable has a certain value?

Suppose we have the constraint $$a_1x_1 + \cdots + a_nx_n \gtreqless b,$$ where $a_i$ and $b$ are constants and $x_i$ are decision variables. Suppose also that we want the constraint to hold if $y=1$ (...
LarrySnyder610's user avatar
13 votes
4 answers
2k views

Single reference for Mixed Integer Programming formulations to linearize, handle logical constraints and disjunctive constraints, do Big M, etc?

Is there a single crisp and accessible reference which covers how to generate Mixed Integer Programming formulations to linearize products, handle logical constraints and disjunctive constraints, do ...
Mark L. Stone's user avatar
29 votes
3 answers
7k views

What is the difference between integer programming and constraint programming?

At first glance both approaches appear to be very similar. What are the major differences between integer programming and constraint programming?
YukiJ's user avatar
  • 2,013
6 votes
1 answer
8k views

How to linearize min function as a constraint?

I'm trying to solve an optimization problem including following constraint, and I need to linearize it in a maximization nonlinear programming model. Please help me to reformulate it with mixed ...
Vida's user avatar
  • 77
11 votes
1 answer
485 views

Expressing a chain of boolean ORs using ILP involving different variables

How can I express a chain of OR operations in an ILP, given that each operand is an inequality between two binary variables? I have asked a similar question here: Chain of Boolean ORs. In that ...
ephemeral's user avatar
  • 897
5 votes
2 answers
730 views

How to linearize specific range constraints?

I would like to know about the linearization of the $(If, Then)$ constraints as follows: $$\begin{array}{l} \text { If: } \\ 15 \leqslant x \leqslant 25 \\ \text { then: } \quad y=\color{blue}{a} x+\...
A.Omidi's user avatar
  • 8,450
4 votes
0 answers
115 views

Conditional constraint formulation [duplicate]

How can I create constraints to make sure $x=1$ if $k\geq 0$ and $x=0$ if $k<0$, where $x\in \{0,1\}$ and $k\in \mathbb{R}$? Here is my attempt: \begin{equation}\label{cons:1} \begin{aligned} ...
tcokyasar's user avatar
  • 1,249
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....
RobPratt's user avatar
  • 30.5k
2 votes
1 answer
119 views

Linearize product of $x\cdot y \text{ with } x,y \in \{-1,0,1\}$ for MILP

I have a problem where I have many products between variables drawn out of $\{-1,0,1\}$. Could you suggest a linearization in terms of variables in $\{-1,0,1\}$ or $B_1 - B_2$ where $B_i \in \{0,1\}$ ...
worldsmithhelper's user avatar
17 votes
1 answer
4k views

What is the "big-M" method? And are there two of them?

I’ve seen the "big-$M$ method" referred to in different ways. What is the "big-$M$ method" and why does it seem to mean two different things?
LarrySnyder610's user avatar
12 votes
3 answers
2k views

Does it make sense to use strict equality constraints in optimization?

Once I learned from some post that the strict equality constraint in an optimization problem does not make much sense. We should always use $\le$ constraint. How much truth is in this? If I must have ...
KGM's user avatar
  • 2,211
12 votes
1 answer
5k views

If-then constraints in MIP programming

For continuous variables $x$ and $y$, the constraints are: ...
Qbik's user avatar
  • 221
12 votes
2 answers
610 views

Expressing an implication as ILP where each implication term comprises a chain of boolean ORs

Consider an implication of the form $A \implies B$ where both $A, B$ comprises a chain of Boolean OR variables. For example, $(a_1 \lor a_2 \lor a_3) \implies (b_1 \lor b_2 \lor b_3)$. How can this ...
ephemeral's user avatar
  • 897
5 votes
2 answers
528 views

How to convert this if-then constraint to MIP constraint?

How to convert this if-then constraint to MIP constraint? $\text{if } a \geq 0 \text{ then } b=K_1 \text{ else(a <0 ) } \ b =K_2$
SAH's user avatar
  • 294
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, ...
Bohdana Nevierova's user avatar
4 votes
2 answers
307 views

Model "If, then" constraint

How to model the following "If, then" type constraint? If $\sum\limits_{i \in I}x_i = 0$ then $\sum\limits_{j \in J}x_{j} = n$ where $x$ are binary variables, $n$ is a known parameter and $...
Farouk Hammami's user avatar
4 votes
2 answers
525 views

Formulating the conditional constraint

I want to develop a model extension of capacitated location problem. The variables are a binary $x_i$ and a continuous $Q_i$. The following condition must be satisfied: if $x_i = 0$, $Q_i$ must be ...
Bobby Kurniawan's user avatar
3 votes
1 answer
542 views

If else condition to MILP

I have following problem: $c_i = 1$ if $X + \sum_j^N G_j = T$ else $c_i = 0$ Also there is another constraint which upper bounds equation $X + \sum_j^N G_j \le T$. $c_i$ is binary $X, T$ are ...
ooo's user avatar
  • 1,589
3 votes
1 answer
417 views

Constraint on groups of variables

Assume a LP/MILP with a large number of variables. It is easy to formulate constraints to group variables such that each variable in a group takes the same value, if we know which variables are in a ...
Jonn's user avatar
  • 333
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 ...
akkha's user avatar
  • 67
1 vote
3 answers
424 views

How can I linearize this IF-THEN constraint?

Let $P_{t,u}; t=1,2,\ldots,T, u=1,2,\ldots,U$ be known values $\alpha$ is also a known parameter $X_{t,u}$ an optimization variable I have the following constraint: IF $P_{t,u}\geq\alpha$, THEN $X_{...
KGM's user avatar
  • 2,211