As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [constraint]

For questions related to constraints, i.e. any restriction or relation a set of decision variables has to satisfy.

Filter by
Sorted by
Tagged with
30 votes
3 answers
16k 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 ...
LarrySnyder610's user avatar
12 votes
2 answers
2k 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$ (...
LarrySnyder610's user avatar
15 votes
1 answer
7k views

How to formulate (linearize) a maximum function in a constraint?

How to formulate (linearize) a maximum function in a constraint? Suppose $C = \max \{c_1, c_2\}$, where both $c_1$ and $c_2$ are variables. If the objective function is minimizing $C$, then it can be ...
Mostafa's user avatar
  • 2,074
27 votes
3 answers
7k 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?
YukiJ's user avatar
  • 1,983
22 votes
4 answers
3k views

Linearize or approximate a square root constraint

I encounter a nonlinear constraint that contains the square root of a sum of integer variables. Of course one could use nonlinear solvers and techniques; but I like linear programming. Are there any ...
Albert Schrotenboer's user avatar
17 votes
1 answer
2k views

Working with absolute values in constraint in a LP or MILP

Having all the approaches explained in the blog called "OR in an OB World" (this address) in my mind, I would like to ask the following question: What is the best practice to make a constraint linear ...
Oguz Toragay's user avatar
  • 8,483
5 votes
1 answer
216 views

How to set a limit for a switch to 0 of a variable

I would like to know how to define a constraint to set a limit for switching to 0 for a decision variable? So I have a linear variable $x(t)$ which quantifies the modulation degree of a heating device....
PeterBe's user avatar
  • 1,668
3 votes
2 answers
555 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 ...
tcokyasar's user avatar
  • 1,239
14 votes
3 answers
12k views

Soft constraints and hard constraints

The terms "soft constraints" and "hard constraints" are used in the context of optimization modeling. Is there any standard way to figure out which is which in some of the complicated models?
A.Omidi's user avatar
  • 7,644
12 votes
1 answer
4k views

If-then constraints in MIP programming

For continuous variables $x$ and $y$, the constraints are: ...
Qbik's user avatar
  • 221
12 votes
3 answers
2k 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 ...
KGM's user avatar
  • 2,191
12 votes
1 answer
330 views

2 stage stochastic programming to approximate many stage problems

There are many naturally multi-stage (i.e., more than two) stochastic programming problems that are approximated by a two-stage stochastic programming model due to the complete intractability of the '...
Albert Schrotenboer's user avatar
11 votes
3 answers
338 views

Is my approach to my internship project good? Optimal allocation of product across stores, constrained optimization

Context: I am a CS student currently in a non-CS internship (logistics, supply chain). My manager wants to leverage my knowledge of programming to build a program to solve the following problem: As ...
Marco's user avatar
  • 211
10 votes
2 answers
519 views

What is the standard practice in Constraint Programming modeling?

I know some general concepts regarding Constraint Programming (e.g., the ones explained in this answer). I am interested in learning how to formulate a combinatorial optimisation problem as a ...
rasul's user avatar
  • 2,140
9 votes
1 answer
585 views

Adding a constraint in constraint programming

Is it true that the more we add constraint to a constraint programming solver the more efficient it will be? How does this compare to adding constraints in integer programming solvers.
Best_fit's user avatar
  • 567
7 votes
1 answer
851 views

How to find the idle intervals in integer programming?

I have a scheduling problem with one machine and one job. I defined a binary variable $z_t$ that is 1 iff the job is scheduled at time $t$ (the job can be served in multiple times that are not ...
zdm's user avatar
  • 381
4 votes
3 answers
636 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 ...
PeterBe's user avatar
  • 1,668
4 votes
1 answer
682 views

Gurobi: how to add a constraint to make there be only one non-integer value

line1 line2 line3 line4 A 2.3 0 3.1 0 B 0 4 2.2 0 C 1.1 0 0 4.6 Let's say after optimization with certain constraints, my model will generate an optimal production allocation table similar to ...
Tracy's user avatar
  • 41
4 votes
1 answer
236 views

How to transform a (thermal) range constraint into the objective function

I have an mixed-integer linear optimization problem that includes a energetic difference equation for the temperature of a building for the time $t$: $$T(t) = T(t-1) + \frac{E^{\rm Heating}(t)-E^{\rm ...
PeterBe's user avatar
  • 1,668
3 votes
1 answer
153 views

Space constraint in scheduling problem

I'm studying an MIP model with a scheduling problem and I'm wondering if the space constraint is correct. If there is space in the factory at that time, the block can be processed, where $i$ is the ...
boroboro's user avatar
3 votes
1 answer
3k views

How to find out which constraint causes problems in Pyomo

I have a Pyomo model with many constraints and variables. When solving it with Gurobi, I get the message "Model is infeasible or unbounded". Now I would like to find out which constraints ...
PeterBe's user avatar
  • 1,668
3 votes
2 answers
302 views

How to make following constraint a convex one?

I would like to write a constraint as follows, where $x,y>0$ are optimization variables, and $a,b,c,d,A$ are positive constants. How to make it a convex constraint? \begin{equation} \frac{{ax}}{{\...
qinqinxiaoguai's user avatar
3 votes
2 answers
296 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 $...
Farouk Hammami's user avatar
2 votes
1 answer
120 views

Piecewise constraint using big-M notation

I have a piecewise constraint that I am having a hard time converting using big-M modelling. The context is a gym owner that is updating membership costs subject to churn restrictions. The owner can ...
akkha's user avatar
  • 43
2 votes
1 answer
122 views

Fixing a complex linear constraint in pyomo

My directed graph f with any node u has a set of outgoing and incoming links as uv ∈ O(u) and vu ∈ I(u) respectively. I am trying to write this constraint here ϕ refers to a binary decision variable ...
Waqas Swati's user avatar