Anonymous
Anonymous

Reputation: 23

How can I augment this MILP by using equations with IFF conditions as cuts in GAMS?

So I am trying to implement an algorithm in GAMS by augmenting a master problem with cuts after every iteration. The master problem is,

minimize w =-x - 10z
s.t. 
   -25x + 20z ≤ 30
   x + 2z ≤ 10
   2x - z ≤ 15
   -2x - 10z ≤ -15
   w >= -26
   w <= -22
where x and z are nonnegative integer variables. 

After the 1st iteration i want to add the constraints,

1 ≤ x ≤ 6 IFF z ≤ 2 

After the 2nd iteration I want to add the constraint,

2.5 ≤ x ≤ 8 IFF z ≤ 1

These two constraints augmenting the problem restricts the solution space yielding (w=-22, x=2, z=2) as the optimal solution.

I tried to implement it in GAMS (with help from GAMSworld) by using dynamic sets with the following script. The final solution given out by GAMS however is (x=6, z=2). The optimal answer should be (x=2, z=2) as due to the constraint after the 2nd iteration, x cannot be greater than 2.5 unless z <= 1.

Integer Variable
x, z;

Free Variable w;

Set      k       /1*5/;

Set cut1set(k);
cut1set(k) = no;

Set cut2set(k);
cut2set(k) = no;

Equations
     obj, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11;

obj..    w =e= - x - 10 *z;
c1..     -25 * x + 20 * z =l= 30;
c2..     x + 2 * z =l= 10;
c3..     2 * x - z =l= 15;
c4..     - 2 * x - 10 * z =l= - 15;
c5..     w =g= -26;
c6..     w =l= -22;
* z is nonnegative integer
* z is nonnegative integer
c7..     z =g= 0;
c8(cut1set)..    x =l= 6;
c9(cut1set)..    x =g= 1;
c10(cut2set)..   x =l= 8;
c11(cut2set)..   x =g= 2.5;

Model mymodel /all/;

loop(k,
         solve mymodel use mip min w;

         if(ord(k) = 1 and z.l <= 2,
                 cut1set(k) = yes;
         );
         if(ord(k) = 2 and z.l <= 1,
                 cut2set(k) = yes;
         );
);

Can anyone tell me how I can use the cuts from the augmented constraints with IFF conditions after the iterations ? The way I have it right now is not constraining the solution space properly. I will really appreciate some help. Thank You!

Upvotes: 1

Views: 89

Answers (2)

Erwin Kalvelagen
Erwin Kalvelagen

Reputation: 16724

May be this is easier:

solve mymodel using mip minimizing w;
if (z.l <= 2,
    x.lo = 1;
    x.up = 6;
    solve mymodel using mip minimizing w;
    if (z.l <= 1,
       x.lo = 2.5;
       x.up = 8;
       solve mymodel using mip minimizing w;
    );
);

Upvotes: 1

Richard
Richard

Reputation: 177

Try this

You just want two cut,One only in the first iteration and one in the second iteration.So the cuts should be added exactly in the same two steps,A conditional statement like cut1set(k)$(k.val=1) = yes; does this.

 Integer Variable x, z;

 Free Variable w;
 Set      k       /1*5/;
 Set cut1set(k);
 cut1set(k) = no;
Set cut2set(k);
 Cut2set(k) = no;

 Equations
 obj, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11;
 Obj..    w =e= - x - 10 *z;
  C1..     -25 * x + 20 * z =l= 30;
 c2..     x + 2 * z =l= 10;
 c3..     2 * x - z =l= 15;
 c4..     - 2 * x - 10 * z =l= - 15;
 c5..     w =g= -26;
c6..     w =l= -22;
 c7..     z =g= 0;
 c8(cut1set)..    x =l= 6;
 c9(cut1set)..    x =g= 1;
 c10(cut2set)..   x =l= 8;
 c11(cut2set)..   x =g= 2.5;

  Model mymodel /all/   ;

 loop(k,
     solve mymodel use mip min w;

     if(k.val = 1 and z.l <= 2,
             cut1set(k)$(k.val=1) = yes;
         );
     if(k.val= 2 and z.l <= 1,
             cut2set(k) $(k.val=2)= yes;
         );
 );

Upvotes: 0

Related Questions