COPT-Public / cuPDLP-C

Code for solving LP on GPU using first-order methods
MIT License
148 stars 34 forks source link

Incorrect dual solution after projection #16

Closed Yakun1125 closed 7 months ago

Yakun1125 commented 8 months ago

I've encountered an issue within a specific segment of _cupdlpsolver where the dual solution might not be calculated correctly under certain conditions, specifically when a primal solution is at its bound. This is observed in the code snippet involved in correcting the dual objective value.

  cupdlp_dot(work, lp->nCols, dSlackPos, resobj->dLowerFiltered, &temp);
  *dDualObj += temp;

  CUPDLP_COPY_VEC(dSlackNeg, dualResidual, cupdlp_float, lp->nCols);

  cupdlp_projNeg(dSlackNeg, lp->nCols);

  cupdlp_scaleVector(work, -1.0, dSlackNeg, lp->nCols);

  cupdlp_edot(dSlackNeg, problem->hasUpper, lp->nCols);

  // cupdlp_dot(work, lp->nCols, x, dSlackNeg, &temp);
  // *dComplementarity -= temp;
  // cupdlp_dot(work, lp->nCols, dSlackNeg, resobj->dUpperFiltered, &temp);
  // *dComplementarity += temp;
  cupdlp_dot(work, lp->nCols, dSlackNeg, resobj->dUpperFiltered, &temp);
  *dDualObj -= temp;

Issue the operations to update dDualObj with temp do not seem to correct the dual solution. When manually computing the dual objective using the dual solution returned after completing, the result matches the objective value prior to adding or subtracting temp,

Expected Behavior Maybe some modification needs to be done for dual solution in order the solution matches the objective function after updating?

SkyLiu0 commented 7 months ago

Thank you for your feedback! Could you please provide some scripts with the LP instance in .mps format for us to reproduce this issue? You can email us at chuwzhang@gmail.com.

bzhangcw commented 7 months ago

Hi, we've tested your provided mps. We cannot reproduce the problem you provided since they match the correct solution (by COPT). We suggest you use the main branch as it is now stable.