10

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 to location $z$, car $2$ needs to make an equal amount of deliveries as well.

In other words: if an integer variable $x_n$ is larger than $0$ it should be equal to all $x_n$ for all $x_n$ larger than $0$

How do I capture this in constraints in linear programming?

I think I need to create a new decision variable $b_i$ that is $1$ if a car makes $1$ or more deliveries, and $0$ if there are no deliveries. From there on I need to somehow set the $x_n$ values equal. But how?

Tim
  • 205
  • 1
  • 6
  • It sounds like you are just saying $x_n = x_m$ for all $n$, $m$ -- is that correct? If one of them equals 0 then they all must equal 0, and if one of them equals something positive then they all must equal the same positive number? – LarrySnyder610 Nov 12 '19 at 13:36
  • 1
    Thanks, but that's incorrect. If one of them equals zero, others must still be able to be positive. However, all positive $x_n$ have to be equal. – Tim Nov 12 '19 at 13:41
  • Ah. Sorry. I missed that. Thanks for the clarification, and welcome to OR.SE! – LarrySnyder610 Nov 12 '19 at 13:42

1 Answers1

11

Let $b_n$ be a binary indicator variable, and let integer variable $y$ be the common value of the positive $x_n$. Then you want to enforce $x_n=b_n y$, which you can linearize using the formulation given here.

RobPratt
  • 32,006
  • 1
  • 44
  • 84