help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] expressing a constraint depending on a boolean variable


From: Andrew Makhorin
Subject: Re: [Help-glpk] expressing a constraint depending on a boolean variable
Date: Wed, 04 Nov 2015 13:35:00 +0300

> Please could you help me to express the following constraint if
> possible.
> 
> 
> for i in {1..2} if V[i] =1 then 2<= sum {x in MySet} V2[x] <=3
>                     else (V[i] =0) then sum {x in MySet} V2[x]  may
> have any value (i do not care about the value in this case)
> 
> 
> 
> 
> with V and V2 are boolean variables
> 

The disjunctive condition

   if z = 1 then   a <= x <= b
   if z = 0 then -M1 <= x <= +M2

where M1 and M2 are sufficiently big numbers, is equivalent to:

   a * z - M1 * (1 - z) <= x <= b * z + M2 * (1 - z)

from which it follows that:

   x >= (a + M1) * z - M1
   x <= (b - M2) * z + M2

Note that M1 = - inf x, and M2 = + sup x should be chosen as small as
possible.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]