Originally posted by: ccasorra
Hi all,
I've tried implementing Benders on a MIP using the annotations and bender.strategy parameter that has been introduced recently in CPLEX 12.7.
My MIP has three sets of variables: Continuous c[j] for all j in J, binary q[k,j] for all k in K and j in J and continuous y[k,l,j] for all k in K, l in J and j in J.
So, I build up my model:
m1 = ERASERMIPpS.solveMIPpS(K, J, p, m, UDC, UDU, UAC, UAU)
And I annotate my variables as follows, leaving the c and the q variables in the master (I don't annotate these as their default value is 0), and sending the y[k,l,j] variables to K separations problems:
cpxBendersPartition=m1.long_annotations.add(name='cpxBendersPartition', defval=0)
variables=m1.long_annotations.object_type.variable
for k in range(K):
for i in range(J*K+J+(J*J)*k,J*K+J+J*J+(J*J)*k,1):
m1.long_annotations.set_values(cpxBendersPartition,variables,i,k+1)
Just to make sure that I'm annotating correctly, I print out the annotation:
print m1.long_annotations.get_values(cpxBendersPartition,variables)
For a small example where J=2, K=3, the first 2 variables are the c variables, the next 6 are the q's and the rest are the y variables. And, indeed, printing out the annotation I get:
[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]
which corresponds to the c and q variables being left in the master and the y variables being sent to K=3 different subproblems. Then, I set the benders.strategy parameter to 0 and solve:
m1.parameters.benders.strategy.set(0)
m1.solve()
I get the following CPLEX error:
CplexSolverError: CPLEX Error 2004: problem not compatible with Benders.
I know for a fact that the MIP I'm trying to solve allows not one but several Benders Decompositions depending on the variables I leave in the master and what I move down to the subproblems. I checked whether my annotation had had anything to do with the error by setting the benders.strategy to 3 where CPLEX disregards any annotation I may have written and the error persists.
So, I would like to know if the way I'm annotating my variables is correct, if my attempt to solve using Benders is correct and what could be causing the error I'm getting.
Many thanks!
Carlos Casorrán.
#CPLEXOptimizers#DecisionOptimization