# Questions tagged [logical-constraints]

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

52 questions
Filter by
Sorted by
Tagged with
5k 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 ...
3k 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?
921 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?
208 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 ...
800 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 ...
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 ...
351 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 ...
2k views

### If-then constraints in MIP programming

For continuous variables $x$ and $y$, the constraints are: ...
961 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$ (...
305 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 ...
131 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 ...
237 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 ...
100 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$...
294 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 ...
68 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,...
240 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 ...
744 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 ...
640 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 ...
156 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 ...
3k 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 ...
202 views

197 views

166 views

### Logical operation on an array in DOCplex

Here is a simple example of logical operation in docplex taken from here. Code below works fine. ...
198 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 ...
40 views

### How to write the following constraint? [duplicate]

I would like to write the following constraint, where $varBuyWater$ and $varSellWater$ are decision variables on how much water to buy and to sell. However, I do not want the solver to buy and sell ...
107 views

### Same values constraint and grouping of variables

In a linear program, I would like some variables to: 1. Take the same values 2. Group some variables i.e. some variables should take same values or lie within certain percentage. 3. All different ...
I have some points with determined coordinates $(a_i,b_i)$. A vehicle can move between these points based on rectangular distance. In more detail, we consider that the path between points is an ...