Skip to content

Commit

Permalink
Added printing of primal-dual iterates for small problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Feb 25, 2025
1 parent 8c9ec71 commit a0c74d7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/pdlp/cupdlp/cupdlp_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,23 @@ void PDHG_Compute_SolvingTime(CUPDLPwork *pdhg) {
timers->dSolvingTime = getTimeStamp() - timers->dSolvingBeg;
}

void iterReport(char* message, CUPDLPwork *pdhg) {
CUPDLPproblem *problem = pdhg->problem;
if (pdhg->settings->nLogLevel<=1 || problem->data->nCols + problem->data->nRows >10) return;
CUPDLPresobj *resobj = pdhg->resobj;
CUPDLPiterates *iterates = pdhg->iterates;
CUPDLPtimers *timers = pdhg->timers;
printf("grep-%s,%4d,x,", message, timers->nIter);
for (int iCol = 0; iCol < problem->data->nCols; iCol++)
printf("%11.5g,", iterates->x->data[iCol]);
printf("y,");
for (int iRow = 0; iRow < problem->data->nRows; iRow++)
printf("%11.5g,", iterates->y->data[iRow]);
printf("%11.5g,", resobj->dPrimalFeas);
printf("%11.5g,", resobj->dDualFeas);
printf("%11.5g\n", resobj->dRelObjGap);
}

cupdlp_retcode PDHG_Solve(CUPDLPwork *pdhg) {
cupdlp_retcode retcode = RETCODE_OK;

Expand Down Expand Up @@ -820,6 +837,8 @@ cupdlp_retcode PDHG_Solve(CUPDLPwork *pdhg) {
const int iter_log_between_header = 50;
int iter_log_since_header = iter_log_between_header;
for (timers->nIter = 0; timers->nIter < settings->nIterLim; ++timers->nIter) {
// Possibly report each iterate
iterReport("Full", pdhg);
PDHG_Compute_SolvingTime(pdhg);
#if CUPDLP_DUMP_ITERATES_STATS & CUPDLP_DEBUG
PDHG_Dump_Stats(pdhg);
Expand Down Expand Up @@ -850,6 +869,7 @@ cupdlp_retcode PDHG_Solve(CUPDLPwork *pdhg) {
PDHG_Compute_Average_Iterate(pdhg);
PDHG_Compute_Residuals(pdhg);
PDHG_Compute_Infeas_Residuals(pdhg);
iterReport("Chek", pdhg);

if (bool_print) {
// With reduced printing, the header is only needed for the
Expand Down

0 comments on commit a0c74d7

Please sign in to comment.