DSDP
dsdpprintout.c
Go to the documentation of this file.
1 #include "dsdp5.h"
7 static int dsdpprintlevel=0;
8 static int dsdpprintlevel2=0;
9 
10 #undef __FUNCT__
11 #define __FUNCT__ "DSDPPrintStats"
12 int DSDPPrintStatsFile(DSDP dsdp, void *dummy){
13 
14  double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
15  int iter,info;
16  int printlevel=dsdpprintlevel2;
17  DSDPTerminationReason reason;
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"
53 int 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"
71 int DSDPPrintStats(DSDP dsdp, void *dummy){
72 
73  double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm;
74  int iter,info;
75  int printlevel=dsdpprintlevel;
76  DSDPTerminationReason reason;
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"
153 int DSDPSetStandardMonitor(DSDP dsdp, int k){
154  int info;
155  info=DSDPSetMonitor(dsdp,DSDPPrintStats,0); DSDPCHKERR(info);
156  dsdpprintlevel=k;
157  return (0);
158 }
159 
int DSDPGetStepLengths(DSDP dsdp, double *pstep, double *dstep)
Copy the step sizes in the current iteration.
Definition: dsdpsetdata.c:742
int DSDPGetBarrierParameter(DSDP dsdp, double *mu)
Copy the current barrier parameter.
Definition: dsdpsetdata.c:364
int DSDPGetPPObjective(DSDP dsdp, double *ppobj)
Copy the objective value (PP).
Definition: dsdpsetdata.c:479
int DSDPGetPnorm(DSDP dsdp, double *pnorm)
Copy the proximity of the solution to the central path.
Definition: dsdpsetdata.c:724
Internal structures for the DSDP solver.
Definition: dsdp.h:65
int DSDPPrintStats(DSDP dsdp, void *dummy)
Print statistics about the current solution to standard output.
Definition: dsdpprintout.c:71
DSDPTerminationReason
There are many reasons to terminate the solver.
The API to DSDP for those applications using DSDP as a subroutine library.
int DSDPGetPInfeasibility(DSDP dsdp, double *pperror)
Copy the infeasibility in (P).
Definition: dsdpx.c:343
int DSDPStopReason(DSDP dsdp, DSDPTerminationReason *reason)
Copy the reason why the solver terminated.
Definition: dsdpsetdata.c:582
int DSDPGetIts(DSDP dsdp, int *its)
Copy the current iteration number.
Definition: dsdpsetdata.c:564
int DSDPGetDDObjective(DSDP dsdp, double *ddobj)
Copy the objective value (DD).
Definition: dsdpsetdata.c:523
int DSDPGetR(DSDP dsdp, double *res)
Copy the infeasibility in (D), or the variable r in (DD).
Definition: dsdpsetdata.c:601
int DSDPSetStandardMonitor(DSDP dsdp, int k)
Print at every kth iteration.
Definition: dsdpprintout.c:153