Initializing help system before first use

XPRBgetdual

XPRBgetdual


Purpose
Get dual value.
Synopsis
double XPRBgetdual(XPRBctr ctr);
Argument
ctr 
Reference to a constraint.
Return value
Dual value for the constraint, 0 in case of an error.
Example
XPRBprob expl2;
XPRBctr ctr2;
XPRBarrvar ty1;
double dval;
   ...
expl2 = XPRBnewprob("example2");
ty1 = XPRBnewarrvar(expl2, 5, XPRB_PL, "arry1", 0, 500);
ctr2 = XPRBnewsum(expl2, "r2", ty1, XPRB_E, 9);
XPRBlpoptimize(expl2, "");
dval = XPRBgetdual(ctr2);
This obtains the dual value for the constraint ctr2.
Further information
This function returns the dual value for a constraint. The user may wish to test first whether this constraint is part of the problem, for instance by checking that the row number is non-negative.
Dual information is available only after LP solving. To obtain dual values for a MIP solution (that is, if function XPRBgetmipstat returns values XPRB_MIP_SOLUTION or XPRB_MIP_OPTIMAL), you need to fix the discrete variables to their solution values with a call to XPRSfixglobals, followed by a call to XPRBlpoptimize before calling XPRBgetdual. Otherwise, if this function is called when a MIP solution is available it returns 0.
If no solution information is available this function outputs a warning and returns 0.
If this function is used during the execution of an optimization process (for instance in Optimizer library callback functions) it needs to be preceded by a call to XPRBsync with the flag XPRB_XPRS_SOL. In this case it returns the dual value in the last LP that has been solved.
Related topics