Originally posted by: JorisK
To implement the constraints of the following LP in cplex:
minimize ...
ax <= c
ax >= b
x >= 0
One can use the addRange command:
IloRange ir=cplex.addRange(b,ax,c)
Associate dual variables y and z with resp. the first (ax <= c) and second (ax >= b) constraint.
If I now want to obtain the dual variables associated with the first and second constraint, I can invoke:
double d = cplex.getDual(ir)
This however is only a single value whereas there are actually 2 dual variables. What would be the best way to obtain the dual variables y and z? I could do something like this:
If |c-b| > 0 holds, then one of the constraints must slack so its dual variable must be zero. Hence:
if(d < 0){
y=d;
z=0
}else{
y=0;
z=d;
}
But what if |c-b|=0, that is, if b and c are equal? Then both constraints will hold with equality and both dual variables can be non-zero? I'm probably missing something very obvious here.
Edit: when |c-b|=0 then both primal constraints can be replaced by a single constraint: ax=b, resulting in a single dual variable for that constraint.
#CPLEXOptimizers#DecisionOptimization