Questions tagged [logical-constraints]

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

62 questions
Filter by
Sorted by
Tagged with
7k 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 ...
4k 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?
1k 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?
892 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 ...
215 views

How to formulate: each pair of elements in $A$ has one common unit in $B$

We have two sets, $A$ and $B$. Some elements of $A$ must be connected to some elements of $B$, but no element of a given set is connected to another element of the same set. (Think of a bipartite ...
1k 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$ (...
1k 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 ...
390 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 ...
3k views

If-then constraints in MIP programming

For continuous variables $x$ and $y$, the constraints are: ...
345 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 ...
180 views

MIP: If integer variable $>0$ it should be equal to other integer variables $>0$

I have an MIP problem where $n$ different types of cars are delivering packages. Sometimes multiple types of cars are required to go to a single location. For example if car $1$ makes two deliveries ...
272 views

Common structures in Gurobi - Python

I'm new to Gurobi in Python and I was wondering if someone knows how to code some common structures of linear constraints. I'm trying to understand how you'll code something like the following ...
105 views

Binary variable to count appearances

Let $x \in \mathbb{R}^n$ be an optimization variable. Now, at a constraint, I would like to count how many times a value, say $2$, appears in $x$ decision. I think we can have a binary variable $y_i$...
318 views

Difference between Chance constraints and logical constraints

A logical constraint combines linear constraints using logical operators, such as logical-and, logical-or, negation (that is, not), conditional statements (that is, if ... then ...) to express complex ...
76 views

Expressing a chain of boolean if-then with logical ANDs using MIP

How to express a chain of boolean If-then as MIP such as: If $(x_{10} \ge b_1$ and $x_{11} \le b_1)$ AND $(x_{20} \ge b_2$ and $x_{21} \le b_2)$... AND... then $y_1 = 1$ else $y_1 = 0$. So basically,...
269 views

Logical Constraints Modelling using Big-M formulation

I am trying to model some logical constraints in ILOG. Logical constraints could be given such as: Constraint 1 or Constraint 2, Constraint 3 or Constraint 4, Constraint 5 or Constraint 6. The ...
760 views

Can this be formulated as one inequality

I have two binary variables $x_1$ and $x_2$ and a non-negative continuous variable $y$. In addition, I have the following two parameters $u>q>0$. I would like to formulate the following ...
714 views

How to transform this logical if-then constraint?

Consider the binary variables $x, y, z \in \{0,1\}$. I'd like to formulate the two if-then constraints: $$x + y \geq 2 \implies z = 0, \tag{1}$$ $$x + y \leq 1 \implies z = 1. \tag{2}$$ Constraint ...
190 views

ILP Constraint to ensure exactly one constraint from a set of constraints is satisfied

Consider several Integer (0/1) ILP variables, i.e., Boolean variables, $x_i$'s. Consider an ILP constraint $x_1 + x_2 + x_3 \geq 1$ and another constraint $x_4 + x_5 + x_6 \geq 1$. I would like to ...
4k 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 ...
256 views

188 views

In a MIP, how to force a decision variable to be zero unless the sum of specific other decision variables is equal to a certain number?

In an MIP, how can I formulate a constraint such that a decision variable is only greater (or equal to) zero if (and only if) the sum of different decision variables is equal to something. I'm working ...
307 views

Model "if and only if" indicator constraints in Linear programming

Apologies if this question has been asked, but I haven't been able to find it. I'm modelling something with Gurobi and want to do the following: \begin{align}\text{cond} < \dfrac{1}{3} &\iff x =...
437 views

409 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$
238 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 ...
109 views

Formulating these logical constraint in an ILP

I have these two constraints : $z \leq My$ $t \leq M'y$ where $z$ and $t$ are two integer variables $z, t\geq 0$, $y$ is a binary variable, and $M$, $M'$ are two big numbers. So basically these ...
123 views

Constrain Mixed-Integer problem such that a graph is fully connected

I have a problem (see my questions about Architectural layouts which poses an interesting abstract question) where there exists an implicit (symmetric) graph whose values in the adjacency matrix are ...
64 views

Maximizing 1-norm: using binary variables to relax non-convexity

It is well-known that when we maximize a 1-norm, e.g., $\|Ax\|_1$, we can use binary variables and obtain a mixed-integer convex problem (otherwise maximizing 1-norm is non-convex). I am mentioning ...
132 views

215 views

Linearize x different of y in ILP

I am surprised I couldn't find an already written answer for my question in the internet. I want to linearize $x$ different of $y$ for two nonegative integer decision variables. I am not considering ...
261 views

How to linearize the Min function while letting the binary variable to be fixed for x1==x2 as well?

As discussed here, the min function, i.e $X = \min\{x_1,x_2\}$, can be linearized as follows: \begin{align} X & \le x_1 \\ X & \le x_2 \\ X & \ge x_1 - ...
152 views

Complicated constraint with logical operators in PuLP

I have an optimization problem that I am trying to solve with PuLP. All the variables are Booleans. The variables that are "selected" will be true, all others false. Objective function is ...
87 views

MILP modelling on minimal disturbance of right-hand-side to make a linear system infeasible

I try to model the following problem: given $z\in\{0,1\}^m$ and a linear system $Ax\le b(z), x\in\Bbb R^n, A\in\Bbb R^{d\times n}, b(z)\in\Bbb R^{d}$, where $b(z)$ means that some entries of $b$ are ...
319 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 ...
207 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 ...
74 views

Write in ILP: If $x$ within range then $s=1$, else $0$

How can write the following function in LP: $$s= \begin{cases} 1 & 1 \leq x \leq C \\ 0 & \text{otherwise} \end{cases}$$ where $x$ takes only non-negative integers and $C$ is some large ...
209 views

How to express this logical constraint for an ILP?

I am trying to write an ILP for a problem but I have this logical constraint and I'm stuck. In my model I have: two binary variables: $x$ and $y$ One Integer variable: $z$ The logical constraint I am ...