# Questions tagged [logical-constraints]

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

50 questions
Filter by
Sorted by
Tagged with
73 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 ...
36 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 ...
187 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 ...
424 views

221 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 - ...
146 views

### Switching of decision variables to be equal to a certain decision variable according to a binary (indicator) variable

I would like to seek some advice on modeling the following: I have two integer decisions variables, $x, x'$, that are either equal or greater than zero and either of them is to be equated to a third ...
96 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 ...
104 views

### how to apply Big M to model the logic constraint （if-then-else）

I was hoping to get some help in modelling the following logic as an MIP Constraint c_{m,l}^{RC} is binary decision variable. Simplify it：
171 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 ...
123 views

57 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 ...
186 views

I have the following optimization problem: \mbox{maximize } j^{*} \mbox{ subject to:} \sum_{j^{*}\leq j\leq J} \min({\bf A}_j,{\bf B}_j) \geq \lambda, \lambda \in \mathbb{R} \mbox{ and } {\bf A}_j,{... 2answers 381 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 2answers 182 views ### Conditional Constraint in MIP I need to formulate a conditional constraint for a binary variable z defined as: z_{i,j,k}, \ \ i=1:10 \ , \ j=1:5 \ , \ k=1:3 If any z_{i,j,3} = 1 then z_{i,j,1} + z_{i,j,2} = 0 \ \ \... 1answer 184 views ### How to fomulate the following conditional constraint in MILP? How can I formulate the following conditional constraint to a linear constraint using indicator variables? Please note that all variables are continuous and c \ge 0 \text{1: if} \ c=0 \ \& \ ... 1answer 91 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 ... 1answer 123 views ### Buying shares in increments I constructed an optimisation model which objective is to find highest return on available stocks. Now want to add a constraint that allows to buy stocks only in 2000 increments, how can I do it? i.e ... 1answer 85 views ### Inputting logical constraints into a binary programming model in Gurobi I am very new to Gurobi and OR in general (I'm in my first class for it now), so apologies if this is a very obvious answer. For a project in that class, I am generating a flight schedule for a ... 1answer 128 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. ... 1answer 66 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,... 3answers 1k views ### Does it make sense to use strict equality constraint in optimization? Once I learned from some post that the strict equality constraint in optimization problem does not make much sense. We should always use \le constraint. How far this is true. If I must have a ... 1answer 111 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 ... 6answers 205 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 ... 1answer 2k views ### If-then constraints in MIP programming For continuous variables x and y, the constraints are: ... 1answer 237 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 ... 1answer 96 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... 2answers 219 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 ... 2answers 335 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 ... 1answer 285 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 ... 1answer 2k 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 ... 2answers 289 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 ... 0answers 93 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: \label{cons:1} \begin{aligned} ... 3answers 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? 1answer 752 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? 2answers 867 views ### In an integer program, how can I “activate” a constraint only if a decision variable has a certain value? Suppose we have the constrainta_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$ (...
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 ...