0

Let's suppose to have three integer variables for integer programming, thus:

a \in {1,2,3}
b \in {1,2,3}
c \in {1,2,3}

Now I want to model that all variables are different. Obviously I can do the following for every combination (three in this case). I show it with a and b.

a <= b - 1 + bin1 * bigM
a >= b + 1 - (1 - bin1) * bigM
bin1 \in {0, 1}

Is there an easier way without producing lots of new constraints, bigMs, and binary variables?

1
  • I'm not aware of any better formulation with linear programming. I guess you can't since it's actually a combinatorial optimization problem. Constraint Programming solvers/languages implement global constraints, see z3 Distinct and Minizinc all_different for instance. Commented May 24, 2016 at 12:52

2 Answers 2

1

Sorry, not really. This construct is often called the all-different constraint. Here is a reference:

H.P.Williams, Hong Yan, "Representations of the all-different Predicate of Constraint Satisfaction in Integer Programming," INFORMS Journal on Computing, Vol. 13 (2001) 96-103

See also the discussion here.

Sign up to request clarification or add additional context in comments.

Comments

0

I found out, that one could do the following as well:

x_j   \in {1,2,3} for j \in {1,2,3}
b_i_j \in {0,1} for i,j \in {1,2,3}
\sum_{i=1}^{3} i * b_i_j = x_j for j \in {1,2,3}
\sum_{i=1}^{3} b_i_j = 1 for j \in {1,2,3}

Well, obviously there is j^2 new binary variables now. But you have your x_j variables as well as your b_i_j variables thus you are much more flexible for all kind of constraints.

all-different constraint:
\sum_{j=1}^{3} b_i_j = 1 for i \in {1,2,3}

Seems okay, doesn't it?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.