DSDP
dsdpprintout.c
Go to the documentation of this file.
1#include "dsdp5.h"
7static int dsdpprintlevel=0;
8static int dsdpprintlevel2=0;
9
10#undef __FUNCT__
11#define __FUNCT__ "DSDPPrintStats"
12int DSDPPrintStatsFile(DSDP dsdp, void *dummy){
13
14 double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
15 int iter,info;
16 int printlevel=dsdpprintlevel2;
18
19 if(printlevel<=0) return(0);
20 if(!dsdpoutputfile) return(0);
21
22 info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info);
23 info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info);
24
25 if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){
26 info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info);
27 info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info);
28 info = DSDPGetR(dsdp,&res); DSDPCHKERR(info);
29 info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info);
30 info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info);
31 info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info);
32 info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info);
33 if (reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0;
34
35 if (iter==0){
36 fprintf(dsdpoutputfile,"Iter PP Objective DD Objective PInfeas DInfeas Mu StepLength Pnrm\n");
37 fprintf(dsdpoutputfile,"--------------------------------------------------------------------------------------\n");
38 }
39 fprintf(dsdpoutputfile,"%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu);
40 fprintf(dsdpoutputfile," %4.2f %4.2f",pstp,dstp);
41 if (pnorm>1.0e3){
42 fprintf(dsdpoutputfile," %1.0e \n",pnorm);
43 } else {
44 fprintf(dsdpoutputfile," %5.2f \n",pnorm);
45 }
46
47 }
48 return 0;
49}
50
51#undef __FUNCT__
52#define __FUNCT__ "DSDPSetStandardMonitor"
53int DSDPSetFileMonitor(DSDP dsdp, int printlevel){
54 int info;
55 dsdpprintlevel2=printlevel;
56 info=DSDPSetMonitor(dsdp,DSDPPrintStatsFile,0); DSDPCHKERR(info);
57 return (0);
58}
59
69#undef __FUNCT__
70#define __FUNCT__ "DSDPPrintStats"
71int DSDPPrintStats(DSDP dsdp, void *dummy){
72
73 double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
74 int iter,info;
75 int printlevel=dsdpprintlevel;
77
78 if(printlevel<=0) return(0);
79
80 info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info);
81 info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info);
82
83 if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){
84 info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info);
85 info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info);
86 info = DSDPGetR(dsdp,&res); DSDPCHKERR(info);
87 info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info);
88 info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info);
89 info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info);
90 info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info);
91 if (0 && reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0;
92
93 if (iter==0){
94 printf("Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm\n")
95 ;
96 printf("---------------------------------------------------------------------------------------\n")
97 ;
98 }
99 printf("%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu);
100 printf(" %4.2f %4.2f",pstp,dstp);
101 if (pnorm>1.0e3){
102 printf(" %1.0e \n",pnorm);
103 } else {
104 printf(" %5.2f \n",pnorm);
105 }
106 fflush(NULL);
107 }
108 return 0;
109}
110
151#undef __FUNCT__
152#define __FUNCT__ "DSDPSetStandardMonitor"
153int DSDPSetStandardMonitor(DSDP dsdp, int k){
154 int info;
155 info=DSDPSetMonitor(dsdp,DSDPPrintStats,0); DSDPCHKERR(info);
156 dsdpprintlevel=k;
157 return (0);
158}
159
The API to DSDP for those applications using DSDP as a subroutine library.
DSDPTerminationReason
There are many reasons to terminate the solver.
@ CONTINUE_ITERATING
Internal structures for the DSDP solver.
Definition dsdp.h:65