Hello everyone,

I have the following Benders code for a maximization problem on GAMS. It happens that sometimes GAMS give an suboptimal solution even though it should find the exact solution, since no heuristics exist and Benders tolerance (BdTol= Upper Bound - Lower Bound) is 0. I ensure that both the subproblem and the master problem are solved to optimality and optcr and optca values are taken as 0, too. I realized it as follows: for a dataset I solved the problem without enforcing any variable to take any value, and it provided an objective value. Then, I enforced a variable to take a certain value, and it provided a higher objective value. Shouldn’t GAMS find the highest possible value automatically as it is a maximization problem? Do you think there is something wrong with the code?

```
Sets
i /1*100/
j /1*10/;
Parameters
p /4/
m /1/
BdTol /0/;
Table a(i,j) DATA;
Table b(i,j) DATA;
variables
q 'cut set variable';
binary variables
y(j)
x(i,j);
positive variables
w(j);
*---------------------------------------------------------------------
* Benders Decomposition Initialization
*---------------------------------------------------------------------
display "--------------------- BENDERS ALGORITHM ----------------------------";
scalar UB 'upperbound' /INF/;
scalar LB 'lowerbound' /-INF/;
*Initial values for the master problem variables are given to initiate the algorithm and solving the subproblem.
x.l(i,j)=1;
y.l(j)=1;
q.l=0;
*---------------------------------------------------------------------
* Benders Subproblem
*---------------------------------------------------------------------
variables
z;
equations
subobj 'objective'
subconstr 'dual constraint'
subconstr2;
subobj..z=e=-sum((i,j),b(i,j)*x.l(i,j)*w(j));
subconstr..sum(j,w(j))=e=m;
subconstr2(j)..w(j)=l=y.l(j);
w.up(j)=1;
model subproblem /subobj, subconstr, subconstr2/;
*---------------------------------------------------------------------
* Benders Relaxed Master Problem
*---------------------------------------------------------------------
set iter /iter1*iter1000000/;
set cutset(iter) 'dynamic set';
cutset(iter)=no;
variable z0 'relaxed master objective variable'
q 'cut set variable';
parameters
cutcoeff(iter,i,j);
Equations
master_obj
cut(iter) 'Benders cut for optimal subproblem'
master_constr1
master_constr2
master_constr3;
master_obj..z0=e=sum((i,j),a(i,j)*x(i,j))+q;
cut(cutset)..q=l=-sum((i,j),cutcoeff(cutset,i,j)*x(i,j));
master_constr1(i)..sum(j,x(i,j))=l=1;
master_constr2..sum(j,y(j))=e=p;
master_constr3(i,j)..x(i,j)=l=y(j);
model master /master_obj,cut,master_constr1,master_constr2,master_constr3/;
*---------------------------------------------------------------------
* Benders Algorithm
*---------------------------------------------------------------------
loop(iter$((abs(UB-LB)> BdTol)),
option lp=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve subproblem maximizing z using lp;
abort$(subproblem.modelstat>=2) "Subproblem not solved to optimality";
UB = min(UB, sum((i,j),a(i,j)*x.l(i,j))+q.l);
cutset(iter) = yes;
cutcoeff(iter,i,j) = b(i,j)*w.l(j);
option mip=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve master maximizing z0 using mip;
abort$(master.modelstat>=2) "Masterproblem not solved to optimality";
LB = max(LB, sum((i,j),a(i,j)*x.l(i,j))+z.l);
display x.l, y.l, z0.l, w.l, UB, LB;
);
```