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);
The API to DSDP for those applications using DSDP as a subroutine library.
struct DSDP_C * DSDP
An implementation of the dual-scaling algorithm for semidefinite programming.
DSDPTerminationReason
There are many reasons to terminate the solver.
int DSDPGetConvergenceMonitor(DSDP, ConvergenceMonitor **)
Get the structure containing convergence parameters.
Detect convergence of the solver from the duality gap and step sizes.
int DSDPGetRHistory(DSDP dsdp, double hist[], int length)
Copy a history of the infeasibility in (D) into an array.
int DSDPDefaultConvergence(DSDP dsdp, void *ctx)
Check for Convergence.
int DSDPSetConvergenceFlag(DSDP dsdp, DSDPTerminationReason reason)
Monitor each iteration of the solver.
int DSDPGetPNormTolerance(DSDP dsdp, double *ptol)
Get the termination tolerance.
int DSDPGetRTolerance(DSDP dsdp, double *inftol)
Copy the maximum infeasibility allowed (D).
int DSDPSetGapTolerance(DSDP dsdp, double gaptol)
Terminate the solver when the relative duality gap is less than this tolerance.
int DSDPSetPNormTolerance(DSDP dsdp, double ptol)
Terminate the solver when the relative duality gap is suffiently small and the PNorm is less than thi...
int DSDPStopReason(DSDP dsdp, DSDPTerminationReason *reason)
Copy the reason why the solver terminated.
int DSDPGetGapHistory(DSDP dsdp, double hist[], int length)
Copy a history of the duality gap into an array.
int DSDPGetGapTolerance(DSDP dsdp, double *gaptol)
Get the termination tolerance.
int DSDPSetStepTolerance(DSDP dsdp, double steptol)
Terminate the solver if the step length in (DD) is below this tolerance.
int DSDPSetDualBound(DSDP dsdp, double dbound)
Terminate the solver if the objective value in (DD) is greater than this tolerance.
int DSDPGetDualBound(DSDP dsdp, double *dbound)
Get the termination parameter.
int DSDPGetIts(DSDP dsdp, int *its)
Copy the current iteration number.
int DSDPGetStepTolerance(DSDP dsdp, double *steptol)
Get the current tolerance.
int DSDPGetDimension(DSDP dsdp, double *n)
Copy the dimension of the cones, or the number of constraints in (D).
int DSDPGetPnorm(DSDP dsdp, double *pnorm)
Copy the proximity of the solution to the central path.
int DSDPGetR(DSDP dsdp, double *res)
Copy the infeasibility in (D), or the variable r in (DD).
int DSDPGetPPObjective(DSDP dsdp, double *ppobj)
Copy the objective value (PP).
int DSDPGetDDObjective(DSDP dsdp, double *ddobj)
Copy the objective value (DD).
int DSDPGetStepLengths(DSDP dsdp, double *pstep, double *dstep)
Copy the step sizes in the current iteration.
int DSDPGetDualityGap(DSDP dsdp, double *dgap)
Copy the difference between the objective values.
int DSDPGetBarrierParameter(DSDP dsdp, double *mu)
Copy the current barrier parameter.
int DSDPSetBarrierParameter(DSDP dsdp, double mu)
Set the current barrier parameter.