Can you elaborate a bit on what you mean when you say you are getting "Strange values"? One possible explanation is that if you call getDuals()
on a model that includes some variables bounds other than $[0, +\infty)$, then your dual unbounded ray requires that you look at the reduced costs as well as the the dual variables returned by getDuals()
. However, based on your comment that you didn't encounter this behavior with Gurobi, this seems somewhat less likely to explain this (unless you formulated the subproblem in Gurobi in a way that has such nondefault bounds, but your CPLEX subproblem uses just the default ones).
Regarding the other questions, when the primal simplex method has determined your problem is infeasible, getDuals()
will return the dual variable values associated with the phase I objective from which infeasibility was determined. In the case where all variables have bounds of $[0,+\infty)$, this comprises the unbounded ray for the dual. That is also true if some of the primal variables are free variables. But if they have finite bounds, you also need to look at the reduced costs to properly construct the direction of unboundedness.
Regarding the order in which dualFarkas()
the object oriented APIs returns dual variables, that depends completely on the order on which you pass the constraints in the first argument to this method. So look at the order in which the constraints were added when you built the model. If you built the model using a single IloRangeArray, then that gives you the order you seek. But, if you used multiple IloRangeArrays, or build it with individual statements where you didn't record a handle to point to some of the ranges being added (e.g. call model.add(x + y <= 2)
), then you probably should maintain an IloRangeArray of handles to the individual linear constraints you created for the model, in the order you added them to the model.
And finally, regarding the experiment you are doing, note that CPLEX's automatic Benders also allows you to customize the boundary between the master and subproblems through variable annotations instead of letting CPLEX just decide the boundary. So if your Benders decomposition approach can be implemented by adjusting the boundary in this way, you might be able to just compare default and nondefault annotations.