Questions tagged [indicator-constraints]
For questions on constraints controlled by binary variables.
57
questions
1
vote
1
answer
76
views
Mixed Integer programming, the big M
In the constraints below, why have they used the big M? What do we look for in order to identify the big M in other questions?
1
vote
2
answers
154
views
Matrix lookup modelling variants
As part of a bigger model I have a matrix of variables $x_{ij} \geq 0$ and a "selector" set of variables $y_j \in \{0,1\}, \sum_j y_j = 1$.
From $x_{ij}$ I'd like to get the variables of ...
1
vote
1
answer
39
views
if else condition with multiple criteria in MIP
I have problem like below
Decision variable x1 >= 0
But it depends on selection variable s1 as binary variable
If s1 = 0 then x1= 0 and
if s1 = 1 then x1>0
how I can write this as constraint for ...
2
votes
1
answer
97
views
Formulation for choosing how many items to manufacture
I am working on a scheduler for a manufacturing plant. I have currently set it up so the decision variables are set up as binary variables:
$x_{m,p,s}$ = 1 if machine m is running part p on shift s
...
1
vote
0
answers
68
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 ...
1
vote
0
answers
37
views
The rule of the slack variable in an indicator constraint
In some cases I have seen, the indicator constraint can be written as indcons(expression, binary_var). Then it is interpreted as follows:
$$LHS - slack (\leq = \geq)...
0
votes
2
answers
105
views
Modelling a binary variable in LPs
I need your help.
I'm setting up an LP and I'm trying to find constraints to introduce the binary varibale $b_{ij}$. So it should take the value 0 if the sum of all $a_{ij}$ values to the period t are ...
5
votes
4
answers
875
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 ...
1
vote
1
answer
54
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 ...
-1
votes
1
answer
209
views
[OR-Tools][CP-SAT] Implement an indicator function in a constraint
Good morning ! I would like to implement this constraint using CP-SAT (see image below).
x_i,j is a boolean variable, a and b are given. The problem is that I don't know how to implement the ...
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....
2
votes
2
answers
420
views
Using indicator constraint with two variables
I want to use the sum of two binary decision variables (when their sum equals to one) as the condition of Model.AddGenConstrIndicator https://www.gurobi.com/documentation/current/refman/...
3
votes
1
answer
102
views
Modelling Question
Let $W^C_t$, $W_t$ be binary variables and $p$ an integer variable with $1 \leq p \leq 3$
The variables are related through the following equation:
$$W^C_t = \sum_{\theta=1}^{p} W_{t-\theta}$$
I can ...
6
votes
2
answers
488
views
Is this constraint with an indicator function nonlinear?
We have two variables $x\geq0$ and $y\in\mathbb{Z}^{0+}$.
We have this constraint in our model
$$x = \sum_{i = 0}c_i \mathbb{1}_{\{y=i\}}$$
where $c_i$ is a parameter and $\mathbb{1}_{A} = 1$ if $A$ ...
1
vote
1
answer
182
views
How to write this logical expression with Gurobi + Java, or express it as a big-m formulation
I am trying to write the following expression in Gurobi+Java or Gurobi+python, if it is more practical It could be expressed as a big-M formulation.
\begin{equation} \label{const4}
\text{D}_{uv} =
...
1
vote
2
answers
176
views
How to express this constraint efficiently?
Let, $\mathcal{C}=\{1,2,\cdots,C\}$,
$\mathcal{U}=\{1,2,\cdots,U\}$
$\mathcal{S}_u$ is a subset of $\mathcal{C}$ with $u\in \mathcal{U}$
$d_{u,c}$ is a binary variable with $u=1,2,\cdots,U$ and $c=1,2,...
-2
votes
2
answers
66
views
How to model the following "if, then" constraint
There are two matrices:
Matrix $S^{v\times v} \in \{0,1\}$ this is a know parameter.
Matrix $X^{v\times p} \in \mathbb{N}$. Elements of $X$ are the variables.
I want to model:
$$\textrm{if }s_{v v'} =...
3
votes
2
answers
315
views
How to model logic constraint: $y=1$ if $a\le x\le b$ and $y=0$ otherwise?
I am trying to formulate indicator-type of constraints. $y$ is binary $0$ or $1$ and $x$ is a continuous variable.
$$ y =
\begin{cases}
1, & \text{ if } a \leq x \leq b \\
0, & \...
3
votes
1
answer
291
views
Piecewise function with two variables
I have a square like region centered at the origin, which is divided into 4 sub-regions. Region 1 can formed from by the diagonal of a square, $x + y \leq 0$. Region 2 is formed by joining the center ...
3
votes
1
answer
304
views
gurobi bigM constraint vs. epsilon
I am new to mathematical programming and I am trying to implement case specific constrains in Gurobi with Python.
I am wondering about how I can implement my constraints in the fastest or most common ...
3
votes
3
answers
1k
views
Converting if conditions to linear constraints
I have an optimization problem and I want to convert the following if conditions to linear constraints:
If $(y_1 > U_1)$ and $(m_1)$ and $(E_1)$ then $x_1=1$
If $(y_2 > U_2)$ and $(m_2)$ and $(...
5
votes
1
answer
152
views
Binary variable to indicate zero probabilities
I have a finite probability distribution $p_1, p_2, \ldots, p_n$ (but these are variables of an optimization problem). Moreover, we have monotonicity, $p_1 \geq p_2 \geq \cdots \geq p_n$.
Assume we ...
2
votes
1
answer
136
views
Robust way to implement $(x=0) \Rightarrow (y=0)$, with $x$ nonnegative and $y$ binary
I am formulating a MILP in which there is a continuous variable x and a binary variable $y$.
In the program formulation there are the following constraints:
$Ay\leq x \leq By$ (with $0\leq A\leq B$). ...
7
votes
2
answers
368
views
how can I modify my LP to activate the most constraints possible?
Suppose I have a linear program (LP) that has many optimal solutions. Of those optima, I want to find the optimum that activates (aka, "pegs" or "bumps") the largest number of ...
3
votes
1
answer
178
views
If-then condition formulation to avoid variable multiplication
I'm trying to formulate the following logic:
If $y_i =1$, then $c_i \leq x_i$
If $y_i =0$, then $c_i \leq 0$
Where $y_i$, $c_i$, and $x_i$ are decision variables.
The easy way would be to write:
$$c_i ...
4
votes
1
answer
295
views
Can you calculate the mean of some MIP variables using linear constraints?
got a lingering question from a graduate course in integer programming that's been bugging me ever since.
Is it possible to find the mean of some variables in a MIP without resorting to quadratic ...
3
votes
1
answer
208
views
Conditional constraint with a strict inequality
It's almost this question: Formulating the conditional constraint
But there they have non-strict inequality. I have $x_i$ a boolean decision var and $Q_i$ as a nonnegative integer decision variable ...
1
vote
0
answers
129
views
Multiple conditions in indicator constraint of Gurobi
I'm working on a vehicle routing problem, in which a vehicle need to pick up amounts of things in some nodes. I'm trying to solve it by Gurobi optimizer. Except for meeting the time windows of each ...
5
votes
1
answer
591
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 =...
2
votes
1
answer
181
views
CPLEX Indicator Constraints in Java API
I'm using the Java API of CPLEX (12.6.1 version) to solve a MILP problem.
This is how I create 'normal' constraints:
...
4
votes
3
answers
904
views
How to couple a binary variable to a continuous variable to indicate values greater 0
I have a continuous variable $x_t$. A binary variable $b_t$ should be coupled to $x_t$ such that $b_t$ has the value $1$ if $x_t$ has a value greater than $0$ and $b_t$ has the value $0$ if $x_t$ has ...
2
votes
1
answer
230
views
MILP constrained by the minimum number of satisfied constraints
I have an MILP where we have
$$
t_k = \sum_i P_i\cdot C_{ik} : P_i\ \in \{0,1\}, C_{ik} \in I^+
$$
and our model is constrained by the number of times $t_k$ is bigger than a certain value $T_k$.
$$
\...
0
votes
1
answer
475
views
if-else query depending on optimization variable in Gurobi (Java)
I am looking for the most elegant solution to the following problem:
I have an if-else query that depends on my optimization variable $x_i$.
If $a \leq b_i + x_i$, the parameter $c$ should take the ...
3
votes
2
answers
611
views
If-then constraint with continuous variables
I was usually using if-then constraints with integer variables but ended up using continuous variables and got confused. I have variables $x_{ij}\in\mathbb{R}_{\geq 0}$, and would like to force the ...
3
votes
1
answer
73
views
Logical equivalencies to modeling an indicator decision variable in transportation problem
I am formulating a model that seeks to minimize the cost of shipping goods from factories to warehouses, where the cost of shipping is independent of the type or amount of goods being shipped (except ...
1
vote
2
answers
244
views
Modeling the product of two variables
Suppose we have two continuous nonnegative variables $X_{1}$ and $X_{2}$ both bounded by the number $M$ from above.
I would like to model the following:
If $X_{1} > 0$ then $X_{2} = 0$
If $X_{2} &...
1
vote
1
answer
119
views
How to model this chain of logical implication II
I would like to seek some advice on modeling the following (chain of) logical implication:
For instance $\omega_{xz}$ might indicate precedence, i.e., $x$, $z$ being the nodes $x$ and $z$, ...
1
vote
1
answer
135
views
How to model this chain of logical implication
I would like to seek some advice on modeling the following (chain of) logical implication:
For instance $\omega_{xy}$ might indicate precedence, i.e., $x$, $y$ being the nodes $x$ and $y$, ...
2
votes
0
answers
122
views
Indicator function for integer variable with inequality constraint
I have $n$ integer variables $\vec{x}$ with the following integer programming problem.
$$
COST = \sum^{n-1}_{i = 0} a_i x_i + \sum^{n-1}_{j=0} b_j I(x_j > 0)
$$
Here, $a_i, b_j \in \mathbb{R}_+$ ...
3
votes
1
answer
470
views
Portfolio optimization with indicator function constraint in CVXPY
I have the following portfolio optimization problem that I want to solve using CVXPY: \begin{align}\min_w&\quad w^\top\Pi\\\text{s.t.}&\quad\sum_{i=1}^nw_i=1\\&\quad w^\top\Sigma w\le\...
1
vote
2
answers
420
views
Switching of decision variables to be larger than or equal to a decision variable according to an indicator variable value
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 greater than or equal to a ...
4
votes
1
answer
260
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 ...
2
votes
1
answer
104
views
Formulating indicator constraint set
I am having difficulty formulating the indicator constraints for the following:
Consider a set of $A_{n}$ decision variables such that $A_{1},A_{2},⋯,A_{n}<A$. While all of them are integers that ...
2
votes
1
answer
66
views
Reformulating to locate the second largest decision variable of a set of decision variables
Consider a set of $A_{vn}$ decision variables such that $A_{v1},A_{v2},\cdots,A_{vn}<A$. While this is the standard formulation finding the maximum value of $A_{vn}$, I would also like to find the ...
2
votes
1
answer
245
views
Linearize sum of continuous and boolean variable
For maximizing the objective function $\sum_i{d_i y_i}+ A x - B \cdot \mathbb{I}_{x>0}$, how can I linearize $ A x - B \cdot \mathbb{I}_{x>0}$ term where $d_i, A$ and $B$ are positive constants ...
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 ...
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 $...
4
votes
3
answers
745
views
Faster implementation of "or" constraints in ILP
I have implemented a set of "or" constraints in my ILP using binary decision variables (as in this method). It works fine for smaller problems, but when I try to increase the number of ...
4
votes
1
answer
584
views
Indicator function in math programming
Let $x$ be an integer variable that takes the values $1$, $2$ or $3$.
Let $y_1$ and $y_2$ be binary variables.
I want to express the two following logical constraints:
if $x=2$ then $y_1=1$
if $x=3$ ...
3
votes
1
answer
159
views
How to optimize with "if" constraints
The minimizing problem is the following :
$$ \underset{w}{\operatorname{argmin}} \sum_{i=1}^{n}\left[w_{i}\times (\frac{Vw}{\sigma})_{i} - b_{i}\right]^{2}$$
with $V$ a $n\times n$ matrix (covariance ...