1

As mentioned in the title, how to use a linear constrain to ensure an integer n is staying out of (n1, n2), in which n,n1,n2 are all integers, and the interval is not [n1, n2].

I formulate the problem in GAMS as

n2 - n1 =l= abs(2*n - n2 - n1)

but the abs() is not allowed in a MIP model.

THX

Patrick
  • 181
  • 1
  • 1
  • 11

1 Answers1

0

You need to define a binary variable (nlow) for n beening eighter below or above the interval. Then use two constraints to inforce this. The number M should be large egnouf that it does not limit your variable n.

Scalar M /1000/;    
Integer Variable n;    
Binary Variable nlow;    
Equation below, above;

below ..  n =L= n1 + M*(1-nlow);    
above ..  n =G= n2 - M*nlow;
Catyes
  • 1
  • 1