dsdpprintout.c
Go to the documentation of this file.
#include "dsdp5.h"
static int dsdpprintlevel=0;
static int dsdpprintlevel2=0;
#undef __FUNCT__
#define __FUNCT__ "DSDPPrintStats"
int DSDPPrintStatsFile(DSDP dsdp, void *dummy){
double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
int iter,info;
int printlevel=dsdpprintlevel2;
DSDPTerminationReason reason;
if(printlevel<=0) return(0);
if(!dsdpoutputfile) return(0);
info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info);
info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info);
if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){
info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info);
info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info);
info = DSDPGetR(dsdp,&res); DSDPCHKERR(info);
info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info);
info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info);
info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info);
info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info);
if (reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0;
if (iter==0){
fprintf(dsdpoutputfile,"Iter PP Objective DD Objective PInfeas DInfeas Mu StepLength Pnrm\n");
fprintf(dsdpoutputfile,"--------------------------------------------------------------------------------------\n");
}
fprintf(dsdpoutputfile,"%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu);
fprintf(dsdpoutputfile," %4.2f %4.2f",pstp,dstp);
if (pnorm>1.0e3){
fprintf(dsdpoutputfile," %1.0e \n",pnorm);
} else {
fprintf(dsdpoutputfile," %5.2f \n",pnorm);
}
}
return 0;
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetStandardMonitor"
int DSDPSetFileMonitor(DSDP dsdp, int printlevel){
int info;
dsdpprintlevel2=printlevel;
info=DSDPSetMonitor(dsdp,DSDPPrintStatsFile,0); DSDPCHKERR(info);
return (0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPPrintStats"
int DSDPPrintStats(DSDP dsdp, void *dummy){
double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
int iter,info;
int printlevel=dsdpprintlevel;
DSDPTerminationReason reason;
if(printlevel<=0) return(0);
info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info);
info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info);
if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){
info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info);
info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info);
info = DSDPGetR(dsdp,&res); DSDPCHKERR(info);
info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info);
info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info);
info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info);
info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info);
if (0 && reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0;
if (iter==0){
printf("Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm\n")
;
printf("---------------------------------------------------------------------------------------\n")
;
}
printf("%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu);
printf(" %4.2f %4.2f",pstp,dstp);
if (pnorm>1.0e3){
printf(" %1.0e \n",pnorm);
} else {
printf(" %5.2f \n",pnorm);
}
fflush(NULL);
}
return 0;
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetStandardMonitor"
int DSDPSetStandardMonitor(DSDP dsdp, int k){
int info;
info=DSDPSetMonitor(dsdp,DSDPPrintStats,0); DSDPCHKERR(info);
dsdpprintlevel=k;
return (0);
}
dsdp5.h
The API to DSDP for those applications using DSDP as a subroutine library.
DSDPTerminationReason
DSDPTerminationReason
There are many reasons to terminate the solver.
Definition dsdpbasictypes.h:50
CONTINUE_ITERATING
@ CONTINUE_ITERATING
Definition dsdpbasictypes.h:59
DSDP_C
Internal structures for the DSDP solver.
Definition dsdp.h:65