Dear all,

I am implemented a kind of branch-and-cut algorithm in GAMS. I need to add dynamically constraints to my model: how can I do it? I think I have to use dynamic set, but I don’t know how.

Thanks in advance,

Luca

Dear all,

I am implemented a kind of branch-and-cut algorithm in GAMS. I need to add dynamically constraints to my model: how can I do it? I think I have to use dynamic set, but I don’t know how.

Thanks in advance,

Luca

Hi,

I do not know whether you want to add one more constraint per iteration or not. But here is my example. This is a Benders Decomposition example, and it works for adding one more Benders cut constraint to the master problem in each iteration. I use semi-pseudocode to enhance readability.

```
Set
k iteration counter /1*100/
i /1*10/;
Set cutset(k) dynamic set;
cutset(k) = no;
**** Build your Model ****
Parameter alpha(k), beta(k,i), ...;
Scalar ...;
Free Variable objective, eta...;
Positive Variable x(i), ...;
Negative Variable ...;
Equations
obj, con1, con2, BDcut(k);
obj.. objective =e= eta + ...;
con1.. ...;
con2.. ...;
BDcut(cutset).. alpha(cutset) + sum(i, beta(cutset,i) * x(i)) =l= eta;
Model BDmaster /all/;
Loop(k,
...;
cutset(k) = yes;
solve BDmaster use LP min objective;
);
display ..;
```

I have tried to write the codes explicitly. For more reference, you can reach the dynamic set documentation as follows.

https://www.gams.com/latest/docs/UG_DynamicSets.html

Cheers!

Gabriel

Thanks very much Gabriel for your answer.