25 #define __FUNCT__ "DSDPCheckConvergence"
28 ConvergenceMonitor *conv=(ConvergenceMonitor*)ctx;
31 double rgap,rgap2,rgaptol=conv->rgaptol;
33 double pnorm,dstep,pstep,steptol=conv->steptol,pnormtol=conv->pnormtol;
34 double ppobj,ddobj, gap, dualbound=conv->dualbound;
41 info =
DSDPGetIts(dsdp,&iter); DSDPCHKERR(info);
44 info =
DSDPGetR(dsdp,&res); DSDPCHKERR(info);
50 rgap=(gap)/(1.0+fabs(ddobj)/2+fabs(ppobj)/2);
51 rgap2=(mu*np)/(1.0+fabs(ddobj)/2+fabs(ppobj)/2);
53 conv->history = DSDPHistory;
54 for (i=0; i<DSDPHistory; i++){
56 conv->gaphist[i] = 0.0;
57 conv->infhist[i] = 0.0;
60 if (iter<conv->history && iter>0){
61 conv->gaphist[iter-1]=(ppobj-ddobj);
62 conv->infhist[iter-1]=res;
67 }
else if ( ddobj!=ddobj || pnorm < 0){
69 DSDPLogInfo(0,2,
"Stop due to Numerical Error\n");
70 }
else if ( rgap <=rgaptol/1.01 && res<=infeastol ){
76 DSDPLogInfo(0,2,
"DSDP Converged: Relative Duality Gap %4.2e < %4.2e, Primal Feasible, Dual Infeasiblity %4.2e < %4.2e \n",rgap,rgaptol,res,infeastol);
78 }
else if ( rgap2 <=rgaptol/100 && rgap<0.01){
80 DSDPLogInfo(0,2,
"DSDP Converged: Relative Duality Gap %4.2e < %4.2e. Check Feasiblity \n",rgap,rgaptol);
81 }
else if ( ddobj > dualbound && res<=infeastol){
83 DSDPLogInfo(0,2,
"DSDP Converged: Dual Objective: %4.2e > upper bound %4.2e\n",pnorm,dualbound);
84 }
else if ( iter > 5 && dstep<steptol && dstep*pnorm< steptol && rgap <= 1.0e-3 ) {
86 DSDPLogInfo(0,2,
"DSDP Terminated: Small relative gap and small steps detected (3)\n");
91 DSDPFunctionReturn(0);
109 #define __FUNCT__ "DSDPSetGapTolerance"
112 ConvergenceMonitor *conv;
115 if (gaptol > 0) conv->rgaptol = gaptol;
116 DSDPLogInfo(0,2,
"Set Relative Gap Tolerance: %4.4e\n",gaptol);
117 DSDPFunctionReturn(0);
131 #define __FUNCT__ "DSDPGetGapTolerance"
134 ConvergenceMonitor *conv;
138 *gaptol=conv->rgaptol;
139 DSDPFunctionReturn(0);
157 #define __FUNCT__ "DSDPSetPNormTolerance"
160 ConvergenceMonitor *conv;
163 if (ptol > 0) conv->pnormtol = ptol;
164 DSDPLogInfo(0,2,
"Set Relative PNorm Tolerance: %4.4e\n",ptol);
165 DSDPFunctionReturn(0);
179 #define __FUNCT__ "DSDPGetPNormTolerance"
182 ConvergenceMonitor *conv;
186 *ptol=conv->pnormtol;
187 DSDPFunctionReturn(0);
204 #define __FUNCT__ "DSDPSetDualBound"
207 ConvergenceMonitor *conv;
210 conv->dualbound=dbound;
211 DSDPLogInfo(0,2,
"Set DualBound of %4.4e \n",dbound);
212 DSDPFunctionReturn(0);
226 #define __FUNCT__ "DSDPGetDualBound"
229 ConvergenceMonitor *conv;
232 *dbound=conv->dualbound;
233 DSDPFunctionReturn(0);
251 #define __FUNCT__ "DSDPSetStepTolerance"
254 ConvergenceMonitor *conv;
257 if (steptol > 0) conv->steptol = steptol;
258 DSDPFunctionReturn(0);
272 #define __FUNCT__ "DSDPGetStepTolerance"
275 ConvergenceMonitor *conv;
278 *steptol=conv->steptol;
279 DSDPFunctionReturn(0);
297 #define __FUNCT__ "DSDPGetRHistory"
300 ConvergenceMonitor *conv;
303 for (i=0;i<length;i++) hist[i]=0.0;
304 for (i=0;i<DSDPMin(length,DSDPHistory);i++) hist[i]=conv->infhist[i];
305 DSDPFunctionReturn(0);
320 #define __FUNCT__ "DSDPGetGapHistory"
323 ConvergenceMonitor *conv;
326 for (i=0;i<length;i++) hist[i]=0.0;
327 for (i=0;i<DSDPMin(length,DSDPHistory);i++) hist[i]=conv->gaphist[i];
328 DSDPFunctionReturn(0);