Skip to main content

Questions tagged [binary-variable]

For questions that involve variables than can only take on one of two values, usually 0 or 1.

Filter by
Sorted by
Tagged with
0 votes
1 answer
66 views

Inconsistencies in modeling a binary variable that indicates a switch

this is a follow-up question to this post here and to @RobPratt's answer. I have implemented the whole thing, and now it happened that on day 1 the machine did not run and was only used for the first ...
marvelfab12's user avatar
2 votes
1 answer
219 views

Set a limit on value change of a binary variable

I am working on an Energy Management problem. The objective is to minimize the electricity bill for the customer. I have a time-series data with 15 min. intervals spanning the course of 1 year. The ...
Kushagr Goyal's user avatar
1 vote
1 answer
94 views

Conditional binary programming

I am currently trying to model the relationship that if the binary variables $b_{it}=0$ and $c_{it}=1$, and for the integer non-negative variable $b^{n}_{i(t-1)}=0$, then the new binary variable $a_{...
mingabua's user avatar
0 votes
2 answers
79 views

Help modeling specific constraint

I have the following variables and I am trying to formulate a suitable constraint. I have the binary variables $a_{ij}$ and $b_{ij}$ and now I want to encode $c_{ij}$ (also binary). $c_{ij}$ should ...
Uni ewr's user avatar
  • 71
-1 votes
1 answer
79 views

How to use gurobi to describe the process of finding the rank of matrix without objective function?

I have a general square matrix [[1,1,0],[1,1,0],[0,0,0]] (the element is on a binary field--Galois Fields) I want to find the rank of this matrix (like the function:...
wenny's user avatar
  • 1
2 votes
1 answer
119 views

Modelling L-0 norm of a vector

I have a binary variable $\bf x$ of length 4000. Let ${\bf x}=[x_1,x_2,\cdots, x_{4000}]$. Let's say we have ${\bf y}=[y_1,y_2,y_3,y_4]$, where \begin{align} y_1&=x_1+x_5+x_{9}+\cdots+x_{3997} \\ ...
KGM's user avatar
  • 2,377
2 votes
1 answer
213 views

How to transform a binary QP into an MILP?

I have a binary quadratic problem with objective ${\bf{x}}^T{\bf{Qx}}+{\bf{c}}^T{\bf{x}}$ subject to ${\bf{A}}{\bf{x}}\le{\bf{b}}$ ${\bf{A}}_{eq}{\bf{x}}={\bf{b}}_{eq}$. here ${\bf{x}}$ is binary. ...
KGM's user avatar
  • 2,377
0 votes
0 answers
61 views

How to model constraints without introducing additional variables?

I have a binary variable $\bf x$ of size $12\times 1$, such as ${\bf x} =[x_1\hspace{1mm} x_2\hspace{1mm} x_3\hspace{1mm} x_4\hspace{1mm} x_5\hspace{1mm} x_6\hspace{1mm} x_7\hspace{1mm} x_8\hspace{1mm}...
KGM's user avatar
  • 2,377
1 vote
1 answer
126 views

In Pyomo, how do I modify the Variable if the value is less than 0?

Pyomo does not allow to use if statements that involves variables. I want to create a new dictionary, model.Excess1, which uses the values from model.Excess to ...
xavgo's user avatar
  • 11
1 vote
2 answers
115 views

Priotization rules for variable allocation in linear programming

I’m working on an optimization problem and need help with correctly prioritizing the allocation of certain variables in a constraint. The rules are: Only one of the variables $y_{t}$, $zn_{t}$ and $...
Lemma's user avatar
  • 23
0 votes
2 answers
153 views

Generalize working days constraints

I have the following constraints. The first ensures that in my shift plan there are always exactly two days off between blocks of working days and only then does the next block begin. It reads as ...
lukdooxb1's user avatar
1 vote
0 answers
62 views

Strong relaxations for binary variables

Having the following optimization problem that models $\sum_i\min(c_i, C)$: $$ \min_{\mathbf{Y},\,\,\{x_i\}_i} \sum_i^{n} c_ix_i + C(1-x_i) $$ and where $C$ is a positive constant, each $x_i$ is a ...
abc's user avatar
  • 11
2 votes
1 answer
113 views

Solving a weighted XOR-SAT problem

I want to solve a variant of the weighted XOR-SAT problem. Concretely, Given $n$ boolean variables $x_1,\ldots,x_n$ each of which is assigned a non-negative cost $c_1,\ldots,c_n\in\mathbb{R}_{\ge 0}$ ...
nalzok's user avatar
  • 123
0 votes
2 answers
162 views

Need help with integer programming exercise

This is an exercise from Wolsey that I can't solve. Show how to go from Equivalence (1) to (2) and from Equivalence (2) to (3): $$ \begin{align} X &= \{ x \in \{0, 1\}^4~\mid~97x_1 + 32x_2 + ...
Tio Pikachu Lizardon's user avatar
1 vote
0 answers
58 views

How to linearize a product and ratio of $x$ and $y$ where $x$ is binary and $y$ is a continuous variable?

I am an electrical engineer who is currently learning about optimization. From this post, they have shown how to linearize the product of two binary variables. But in my case, I have a product $x \...
Tuong Nguyen Minh's user avatar
0 votes
2 answers
76 views

What is the best way to constrain a binary matrix so that at most one row has positive values?

I have a binary variable $x_{i,j}$ for $i\in\{1,\ldots,m\}$ and $j\in\{1,\ldots,n\}$ and the constraint is to have at most one row that has ones. I wrote this as: $$x_{i,j}+x_{i',j'}\leqslant1,\forall ...
Jika's user avatar
  • 101
2 votes
2 answers
93 views

How to linearize the product of a binary and a negative continuous variable?

Suppose we have a binary variable $x$ and a negative continuous variable $y$. How can we linearize the product $u=xy$?
m.amin's user avatar
  • 31
0 votes
1 answer
173 views

Production scheduling

I'm formulating a scheduling problem with the following decision variables: $$X_t \space \text{is power sold to market in time period t} \\ Y_t \space \text{is power used for production in time period ...
fikacoder's user avatar
3 votes
1 answer
246 views

Formulation of binary constraint with the least binary variables for linear programming

I am currently working on a formulation for a linear program of a complex problem. At the moment I am facing to formulate the following logical condition: There are two binary variables. Let's name ...
Nicolas Kaiser's user avatar
0 votes
2 answers
260 views

Gurobi founds optimal solution but it is not feasible

I'm currently solving a MIP model with pyomo using gurobi and I am facing strange results. I have one constraint that looks like this: ...
Franco's user avatar
  • 13
3 votes
2 answers
265 views

Binary Integer Programming Problem - Enforce Zeros on Certain Groups

I'm working on a binary integer programming problem using pulp. I have a vector X = [x_1, x_2, x_3, . . . , x_n]. I have enforced a number of simple constraints. I ...
user16668649's user avatar
0 votes
1 answer
166 views

Using binary variable or integer variable in Constraint Programming (CP)?

I am trying to solve an assignment problem by Constraint Programming (CP). Let us consider a task assignment problem that have $|M|$ tasks and $|N|$ machines, each task has different processing time ...
Penghui Guo's user avatar
2 votes
1 answer
291 views

How to do one octomino?

Here are all the 369 octominoes: https://en.wikipedia.org/wiki/Octomino If I have an 8x8 area, how to create one octomino, any of those 369 and any rotation and mirroring is allowed? I have tried ...
user9050's user avatar
  • 119
7 votes
3 answers
744 views

Binary logical constraint dependent on indices

I don't know if I can ask this here, but I've been pulling my hair out trying to think of how to represent this in constraints. I have two sets of binary variables: $X_t$ and $Y_{it}$. So, I want to ...
orpanter's user avatar
  • 517
3 votes
1 answer
195 views

Assignment Problem - Students and teachers

I ran across this problem at work and I'm sure that we can optimize it with OR. I have $n(T) = 4$ teachers and $n(S) = 7$ students that should have a weekly individual class. If a student $s$ has a ...
nickh's user avatar
  • 133
1 vote
2 answers
225 views

Efficient ways to do pairwise/multiplicative variables in integer linear programming on PuLP / Python

I'm trying to formulate an LP that is in essence a variant of the sudoku problem, and I've repurposed the code from https://coin-or.github.io/pulp/CaseStudies/a_sudoku_problem.html. The differences ...
Riezz's user avatar
  • 41
7 votes
1 answer
641 views

How can one model a binary variable?

I am looking for the formulation of a constraint that does the following. I want to introduce a new binary variable $\kappa_{it}$ that takes the value 1 if the sum of the other binary variable $\...
nflgreaternba's user avatar
2 votes
1 answer
149 views

Conditional constraints in MILPs

I want to understand how to represent iff constraints in MILPs. For example, I want to represent the following as the constraints of a MILP $$ c = \begin{cases} 1 &\text{if } d \geq e \\ 0 & \...
Anonymous Bunny's user avatar
0 votes
2 answers
115 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 ...
Karl Seidl's user avatar
0 votes
1 answer
299 views

LP - How to model binary variable that indicates a switch

I have the following question / concern. I have a modeling problem with the decision variable $d_{ptm}$ which indicates whether product $p$ was serviced by machine $m$ in period $t$. It takes the ...
marvelfab12's user avatar
-1 votes
1 answer
210 views

creating individual Variables in pyomo with different length

I am new to pyomo and I do have some smaller (or bigger) problems and hope someone can help me. How can you create this variable in pyomo? I wanted to create it with pyo.Varlist() in which I pass ...
Tamara Koch's user avatar
-1 votes
3 answers
220 views

Multi objective optimization is giving wrong results

I am trying to solve a multi objective optimization problem. I have a set of nodes belonging to different counties and each node is associated with some cost and some priority. I want to select the ...
MSS's user avatar
  • 111
0 votes
0 answers
46 views

How to linearize such a constraint?

My original content was like this: Assuming that server $k$ can only allocate corresponding computing functions to MU $i$ after receiving their tasks. Let $$ y_{i,k,t} = \begin{cases} 1 & \text{if ...
Yunqi Li's user avatar
3 votes
2 answers
396 views

How to model a binary variable?

I am trying to find a constraint for the following relationship, but am failing a bit at it right now. I want to find a linear constraint that does the following. The binary variable $switch_{ot}$ is ...
mingabua's user avatar
1 vote
2 answers
85 views

Grouping variables to take same value

Assume we have 50 variables that we want to split into 3 groups and each group should have at least 5 variables. How to formulate that all variables in the same group take the same values? I used the ...
milad's user avatar
  • 21
1 vote
1 answer
55 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 ...
Mike's user avatar
  • 717
3 votes
2 answers
391 views

How to model this binary constraint?

I have an optimization problem that has a variable in the matrix form. The variable is a binary matrix. It has size $M \times N = 10 \times 50$ where $M$ is the number of machines and $N$ is the ...
TheExerminate's user avatar
2 votes
3 answers
225 views

Linearization the product of three variables (two binary & one continuous)

Consider the following binary variable $x \in \{0,1\}$ and two continuous real variables $y,p \in \mathbb{R}$. I am trying to model the following conditional equations as constraints: \begin{cases} ...
Ahmed's user avatar
  • 113
3 votes
2 answers
299 views

Reformulate bilinear binary constraint

I'm a solving a model that has the following constraint: $$ c_{p,n} = \sum_{s\in S}\sum_{i \in \{1,2,3\} } x_{p,s,i-1} x_{n,s,i}, \forall (p,n) \in C $$ where both the $c$ and $x$ variables are binary,...
cholo14's user avatar
  • 233
2 votes
2 answers
73 views

How to restrict the amount of consecutive assignments

I'm working on a scheduling/rostering problem. In this scenario the shifts are predefined with a starting and ending date and time. The problem basically assigns people to shifts with a binary ...
Daniel Baquero's user avatar
2 votes
1 answer
182 views

Reduced cost fixing for binary programs

Consider the binary program $$ \min_{ x \in \{0,1\}^N } \left\{ c^T x \mid Ax \leq b \right\}$$ where $A$ and $b$ are real matrices with appropriate dimensions. I am interested in solving large binary ...
rolfvdhulst's user avatar
2 votes
0 answers
58 views

Is it useful to consider metaheuristics for power flow optimization involving binary variables?

I want to optimize the power flow in a low voltage grid, with respect to customer requests for electric vehicle (EV) charging, but also avoid grid overload (basically, the formulation can be seen in ...
Andre's user avatar
  • 303
1 vote
2 answers
751 views

Pyomo: Value assignment for binary variables through constraints

I am currently working on a cost minimisation model for multi-product, multi-period supplier selection with Pyomo. It is a linear model described below. **Problem statement** I have no idea how to ...
NullNeuner's user avatar
4 votes
2 answers
229 views

how to ensure minimum output of a generator (else zero output) in linear programming?

I want to ensure, that a generator (in my case a heat generator, for example a boiler) first starts to output thermal energy, when a certain minimum output can be realized. Otherwise the output should ...
Andre's user avatar
  • 303
3 votes
1 answer
103 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 ...
Clement's user avatar
  • 2,252
3 votes
3 answers
311 views

Set null the next set of N values

I'm dealing with a problem I already modelled by using linear programming. The already existing constraints set at 1 groups of contiguous variables (for ex: ...
devOn's user avatar
  • 33
2 votes
0 answers
89 views

Branching the product of binary and continuous variable in Gurobi

I have a binary variable (X) multiplying a continuous variable (Y). I know I can linearize by adding an auxiliary variable (I have that model working), but I now want to do my own branching in the ...
orpanter's user avatar
  • 517
4 votes
1 answer
1k views

Can sensitivity analysis and limits report be done on an BILP problem?

I am not that experienced with Operations Research yet. I have become familiar with what Sensitivity Analysis and Limits Reports are in general and through the use of Excel. I know that they can only ...
Tita's user avatar
  • 205
3 votes
1 answer
131 views

Expressing $\{0,1\}$ assignment across a matrix in MILP?

I have a MILP (Xpress) constraint, which is doing what I want it to, but I'm struggling to translate it into a LaTeX friendly mathematical expression. The below code enforces that in the matrix $V$, ...
jbuddy_13's user avatar
  • 551
2 votes
1 answer
140 views

Conditional constraint for binary

Could you please check where I might be wrong? Task is: If $z=1$, then either $x=1$ or $y=1$ My approach: If $z=1$, then $x+y=1$ $\implies x+y\le1$ $\implies x+y\ge1$ If $z=0$, then $x+y\ge0 - M\cdot(...
Bohdana Nevierova's user avatar