DSDP
dsdpsetoptions.c
Go to the documentation of this file.
1#include "dsdp5.h"
6/*
7 static char[] ZGAPTOL="-gaptol";
8 static char[] ZPRINT="-print";
9 static char[] ZPENALTY="-penalty";
10 static char[] ZBIGM="-bigM";
11 static char[] ZMAXIT="-maxit";
12 static char[] ZR0="-r0";
13 static char[] ZZBAR="-zbar";
14 static char[] ZINFDTOL="-infdtol";
15 static char[] ZINFPTOL="-infptol";
16 static char[] ZRHO="-rho";
17 static char[] ZDRHO="-drho";
18 static char[] ZBOUNDY="-boundy";
19 static char[] ZSTEPTOL="-steptol";
20 static char[] ZREUSE="-reuse";
21 static char[] ADADD="-dadd";
22 static char[] ZDBOUND="-dbound";
23 static char[] ZMU0="-mu0";
24 static char[] DOBJMIN="-dobjmin";
25*/
26
44#undef __FUNCT__
45#define __FUNCT__ "DSDPSetOptions"
46int DSDPSetOptions(DSDP dsdp,char *runargs[],int nargs){
47
48 int kk, info,reuse;
49 int maxit,rpos,drho,iloginfo;
50 double penalty,rho,zbar,cc,r0,mu0,gaptol,dbound,dd;
51 double ylow,yhigh,maxtrust,steptol,inftol,infptol,pnormtol;
52
53 DSDPFunctionBegin;
54
55 for (kk=0; kk<nargs-1; kk++){
56 if (strncmp(runargs[kk],"-gaptol",5)==0){
57 gaptol=atof(runargs[kk+1]);
58 info=DSDPSetGapTolerance(dsdp,gaptol);DSDPCHKERR(info);
59 } else if (strncmp(runargs[kk],"-penalty",7)==0){
60 penalty=atof(runargs[kk+1]);
61 info=DSDPSetPenaltyParameter(dsdp,penalty); DSDPCHKERR(info);
62 } else if (strncmp(runargs[kk],"-bigM",5)==0){
63 rpos=atoi(runargs[kk+1]);
64 info=DSDPUsePenalty(dsdp,rpos); DSDPCHKERR(info);
65 } else if (strncmp(runargs[kk],"-maxit",6)==0){
66 maxit=atoi(runargs[kk+1]);
67 info=DSDPSetMaxIts(dsdp,maxit); DSDPCHKERR(info);
68 } else if (strncmp(runargs[kk],"-r0",3)==0){
69 r0=atof(runargs[kk+1]);
70 info=DSDPSetR0(dsdp,r0); DSDPCHKERR(info);
71 } else if (strncmp(runargs[kk],"-zbar",5)==0){
72 zbar=atof(runargs[kk+1]);
73 info=DSDPSetZBar(dsdp,zbar);DSDPCHKERR(info);
74 } else if (strncmp(runargs[kk],"-infdtol",7)==0){
75 inftol=atof(runargs[kk+1]);
76 info=DSDPSetRTolerance(dsdp,inftol);DSDPCHKERR(info);
77 } else if (strncmp(runargs[kk],"-infptol",7)==0){
78 infptol=atof(runargs[kk+1]);
79 info=DSDPSetPTolerance(dsdp,infptol);DSDPCHKERR(info);
80 } else if (strncmp(runargs[kk],"-rho",4)==0){
81 rho=atof(runargs[kk+1]);
82 info=DSDPSetPotentialParameter(dsdp,rho); DSDPCHKERR(info);
83 } else if (strncmp(runargs[kk],"-drho",5)==0){
84 drho=atoi(runargs[kk+1]);
85 info=DSDPUseDynamicRho(dsdp,drho);DSDPCHKERR(info);
86 } else if (strncmp(runargs[kk],"-mu0",4)==0){
87 mu0=atof(runargs[kk+1]);
88 info=DSDPSetBarrierParameter(dsdp,mu0);DSDPCHKERR(info);
89 } else if (strncmp(runargs[kk],"-maxtrustradius",7)==0){
90 maxtrust=atof(runargs[kk+1]);
91 info=DSDPSetMaxTrustRadius(dsdp,maxtrust); DSDPCHKERR(info);
92 } else if (strncmp(runargs[kk],"-boundy",6)==0){
93 yhigh=fabs(atof(runargs[kk+1]));ylow=-yhigh;
94 info=DSDPSetYBounds(dsdp,ylow,yhigh);DSDPCHKERR(info);
95 } else if (strncmp(runargs[kk],"-steptol",7)==0){
96 steptol=fabs(atof(runargs[kk+1]));
97 info=DSDPSetStepTolerance(dsdp,steptol); DSDPCHKERR(info);
98 } else if (strncmp(runargs[kk],"-pnormtol",7)==0){
99 pnormtol=fabs(atof(runargs[kk+1]));
100 info=DSDPSetPNormTolerance(dsdp,pnormtol); DSDPCHKERR(info);
101 } else if (strncmp(runargs[kk],"-reuse",6)==0){
102 reuse=atoi(runargs[kk+1]);
103 info=DSDPReuseMatrix(dsdp,reuse);DSDPCHKERR(info);
104 } else if (strncmp(runargs[kk],"-dadd",6)==0){
105 cc=atof(runargs[kk+1]);
106 info=DSDPAddObjectiveConstant(dsdp,cc);DSDPCHKERR(info);
107 } else if (strncmp(runargs[kk],"-dbound",6)==0){
108 dbound=atof(runargs[kk+1]);
109 info=DSDPSetDualBound(dsdp,dbound);DSDPCHKERR(info);
110 } else if (strncmp(runargs[kk],"-fix",4)==0){
111 info=DSDPSetFixedVariable(dsdp,1,atof(runargs[kk+1]));DSDPCHKERR(info);
112 } else if (strncmp(runargs[kk],"-dobjmin",7)==0){
113 dd=atof(runargs[kk+1]);
114 info = DSDPSetDualLowerBound(dsdp,dd);DSDPCHKERR(info);
115 } else if (strncmp(runargs[kk],"-dloginfo",8)==0){
116 iloginfo=atoi(runargs[kk+1]);
117 info=DSDPLogInfoAllow(iloginfo,0);
118 }
119 }
120
121 for (kk=0; kk<nargs; kk++){
122 if (0){
123 } else if (strncmp(runargs[kk],"-help",5)==0){
124 info=DSDPPrintOptions();
125 }
126 }
127 DSDPFunctionReturn(0);
128}
129
140#define MAXOPTIONS 40
141#define STRLENGTH 40
142#define BUFFERSIZ 100
143#undef __FUNCT__
144#define __FUNCT__ "DSDPReadOptions"
145int DSDPReadOptions(DSDP dsdp, char filename[]){
146
147 int i,info,line=0;
148 char thisline[BUFFERSIZ]="%",doption[STRLENGTH],dvalue[STRLENGTH];
149 char fargs[2*MAXOPTIONS][STRLENGTH];
150 char *fargs2[2*MAXOPTIONS];
151 FILE *fp;
152
153 DSDPFunctionBegin;
154
155 for (i=0;i<2*MAXOPTIONS;i++){fargs2[i]=fargs[i];}
156
157 fp=fopen(filename,"r");
158 if (fp){
159 while(!feof(fp) ){
160 if (line>=MAXOPTIONS) break;
161 fgets(thisline,BUFFERSIZ,fp);
162 if (sscanf(thisline,"%s %s",doption,dvalue)>=2){
163 if (doption[0]!='%'){
164 strncpy(fargs[2*line],doption,STRLENGTH-1);
165 strncpy(fargs[2*line+1],dvalue,STRLENGTH-1);
166 line++;
167 }
168 }
169 thisline[0]='%';
170 }
171
172 info=DSDPSetOptions(dsdp,fargs2,2*line);
173 fclose(fp);
174 }
175 DSDPFunctionReturn(0);
176}
177
188#undef __FUNCT__
189#define __FUNCT__ "DSDPView"
190int DSDPView(DSDP dsdp){
191
192 int info,reuse,m,maxit;
193 double penalty,rho,mu0,gaptol,dnorm[3],derror[6],potential,ymax;
194 double ylow,yhigh,maxtrust,steptol,inftol,infptol,pnormtol,dbound,tracex;
195 DSDPSolutionType pdfeasible;
196
197 DSDPFunctionBegin;
198 info=DSDPGetMaxIts(dsdp,&maxit); DSDPCHKERR(info);
199 printf("Terminate DSDP after %d iterations.\n",maxit);
200 info=DSDPGetDualBound(dsdp,&dbound); DSDPCHKERR(info);
201 printf("Terminate DSDP if dual objective is greater than %8.4e\n",dbound);
202 info=DSDPGetGapTolerance(dsdp,&gaptol);DSDPCHKERR(info);
203 printf("Terminate DSDP if the relative duality gap is less than %8.4e\n",gaptol);
204 info=DSDPGetStepTolerance(dsdp,&steptol); DSDPCHKERR(info);
205 printf("Terminate DSDP if step length in D less than %8.4e\n",steptol);
206 info=DSDPGetPNormTolerance(dsdp,&pnormtol); DSDPCHKERR(info);
207 printf("Terminate DSDP only if Pnorm less than %8.4e\n",pnormtol);
208 info=DSDPGetMaxTrustRadius(dsdp,&maxtrust); DSDPCHKERR(info);
209 printf("Max Trust Radius is %8.4e\n",maxtrust);
210 info=DSDPGetReuseMatrix(dsdp,&reuse);DSDPCHKERR(info);
211 printf("Reapply Hessian of Barrier up to %d times per iteration.\n",reuse);
212
213 info=DSDPGetDataNorms(dsdp,dnorm);DSDPCHKERR(info);
214 printf("The norms of C: %8.4e, A: %4.4e, and b: %8.4e\n",dnorm[0],dnorm[1],dnorm[2]);
215 info=DSDPGetNumberOfVariables(dsdp,&m);DSDPCHKERR(info);
216 printf("There are %d y variables: ",m);
217 info=DSDPGetYMaxNorm(dsdp,&ymax); DSDPCHKERR(info);
218 printf("largest is %8.4e, ",ymax);
219 info=DSDPGetYBounds(dsdp,&ylow,&yhigh);DSDPCHKERR(info);
220 printf("bounded below by %8.4e and above by %8.4e. \n",ylow,yhigh);
221 info=DSDPGetTraceX(dsdp,&tracex);DSDPCHKERR(info);
222 printf("The X variables have a trace of %8.4e ",tracex);
223 info=DSDPGetPenaltyParameter(dsdp,&penalty); DSDPCHKERR(info);
224 printf("bounded by penalty parameter: %8.4e\n",penalty);
225 info=DSDPGetBarrierParameter(dsdp,&mu0);DSDPCHKERR(info);
226 printf("Current Barrier Parameter: %8.4e\n",mu0);
227 info=DSDPGetPotentialParameter(dsdp,&rho); DSDPCHKERR(info);
228 printf("Potential Parameter: %8.4e ( times dimension) \n",rho);
229 info=DSDPGetPotential(dsdp,&potential);DSDPCHKERR(info);
230 printf("The value of the potential function is %8.4e\n",potential);
231 info=DSDPGetRTolerance(dsdp,&inftol); DSDPCHKERR(info);
232 printf("(D) Feasible only if R < %8.4e\n",inftol);
233 info=DSDPGetPTolerance(dsdp,&infptol); DSDPCHKERR(info);
234 printf("(P) Feasible only if Pinfeas < %8.4e\n",infptol);
235 info=DSDPGetSolutionType(dsdp,&pdfeasible);DSDPCHKERR(info);
236 if (pdfeasible==DSDP_PDFEASIBLE){
237 printf(" DSDP Solutions are both feasible and bounded\n");
238 } else if (pdfeasible==DSDP_UNBOUNDED){
239 printf(" (D) is unbounded and (P) is infeasible\n");
240 } else if (pdfeasible==DSDP_INFEASIBLE){
241 printf(" (D) is infeasible and (D) is unbounded\n");
242 } else if (pdfeasible==DSDP_PDUNKNOWN){
243 printf(" Hmm. Not clear whether either solution is feasible.\n");
244 }
245 info=DSDPGetFinalErrors(dsdp,derror);DSDPCHKERR(info);
246 printf("The errors: %8.4e, %4.4e, %8.4e, ",derror[0],derror[1],derror[2]);
247 printf("%8.4e, %4.4e, %8.4e\n",derror[3],derror[4],derror[5]);
248 DSDPFunctionReturn(0);
249}
250
251
252static char dsdpoptions[]="\
253 -gaptol <1e-6> stop when relative duality gap less than \n\
254 -r0 <-1> if nonnegative, initialize S by adding this multiple of the identity matrix \n\
255 -penalty <1e10>< penalize dual infeasibility \n\
256 -boundy <1e7> bound for variables y \n\
257 -maxit <200> set maximum iterates \n\
258 -zbar <1e10> Upper bound for dual solution \n\
259 -mu0 <-1> if positive, set initial barrier parameter \n\
260 -rho <3> Potential parameter as multiple of dimension \n\
261 -drho <1> Use dynamic rho strategy \n\
262 -pnormtol <1e30> stop only if pnorm less than \n\
263 -reuse <4> Reuse the Schur Matrix this many times\n\
264 -dobjmin <> apply a known lower bound for the objective at solution as a constraint. \n\
265 -bigM <0> if positive, modify algorithm to make dual \n\
266 infeasibility positive with a large associated cost \n\
267 -dloginfo <0> - print more information for higher numbers \n\
268 -params <filename> to read selected options from a file \n\
269 -help for this help message\n";
270
280 DSDPFunctionBegin;
281 printf("%s",dsdpoptions);
282 DSDPFunctionReturn(0);
283}
The API to DSDP for those applications using DSDP as a subroutine library.
DSDPSolutionType
Formulations (P) and (D) can be feasible and bounded, feasible and unbounded, or infeasible.
@ DSDP_UNBOUNDED
@ DSDP_PDFEASIBLE
@ DSDP_PDUNKNOWN
@ DSDP_INFEASIBLE
int DSDPGetSolutionType(DSDP dsdp, DSDPSolutionType *pdfeasible)
Solutions can be bounded, infeasible, or unbounded.
Definition: dsdpx.c:254
int DSDPSetOptions(DSDP dsdp, char *runargs[], int nargs)
Read command line arguments to set options in DSDP.
int DSDPView(DSDP dsdp)
Print many of the parameters currently set in DSDP.
int DSDPGetPNormTolerance(DSDP dsdp, double *ptol)
Get the termination tolerance.
Definition: dsdpconverge.c:180
int DSDPGetRTolerance(DSDP dsdp, double *inftol)
Copy the maximum infeasibility allowed (D).
Definition: dsdpx.c:434
int DSDPSetGapTolerance(DSDP dsdp, double gaptol)
Terminate the solver when the relative duality gap is less than this tolerance.
Definition: dsdpconverge.c:110
int DSDPSetPNormTolerance(DSDP dsdp, double ptol)
Terminate the solver when the relative duality gap is suffiently small and the PNorm is less than thi...
Definition: dsdpconverge.c:158
int DSDPGetGapTolerance(DSDP dsdp, double *gaptol)
Get the termination tolerance.
Definition: dsdpconverge.c:132
int DSDPSetStepTolerance(DSDP dsdp, double steptol)
Terminate the solver if the step length in (DD) is below this tolerance.
Definition: dsdpconverge.c:252
int DSDPGetPTolerance(DSDP dsdp, double *inftol)
Copy the feasibility tolerance.
Definition: dsdpx.c:386
int DSDPSetRTolerance(DSDP dsdp, double inftol)
Classify (D) as feasible only if the variable r is less than this tolerance.
Definition: dsdpx.c:409
int DSDPSetMaxIts(DSDP dsdp, int its)
Terminate the solver after this number of iterations.
Definition: dsdpsetdata.c:206
int DSDPSetDualBound(DSDP dsdp, double dbound)
Terminate the solver if the objective value in (DD) is greater than this tolerance.
Definition: dsdpconverge.c:205
int DSDPGetDualBound(DSDP dsdp, double *dbound)
Get the termination parameter.
Definition: dsdpconverge.c:227
int DSDPGetStepTolerance(DSDP dsdp, double *steptol)
Get the current tolerance.
Definition: dsdpconverge.c:273
int DSDPGetMaxIts(DSDP dsdp, int *its)
Copy the maximum number of iterations from the solver.
Definition: dsdpsetdata.c:225
int DSDPSetPTolerance(DSDP dsdp, double inftol)
Classify (P) as feasible only if the infeasibility is less than this tolerance.
Definition: dsdpx.c:365
int DSDPGetYMaxNorm(DSDP dsdp, double *ynorm)
Copy the the infinity norm of the variables y.
Definition: dsdpsetdata.c:678
int DSDPGetTraceX(DSDP dsdp, double *tracex)
Copy the trace of the variables X in (P).
Definition: dsdpx.c:278
int DSDPAddObjectiveConstant(DSDP dsdp, double c)
Add a constant to the objective.
Definition: dsdpsetdata.c:185
int DSDPGetFinalErrors(DSDP dsdp, double err[6])
Copy six different error measurements into an array.
Definition: dsdpx.c:297
int DSDPSetR0(DSDP dsdp, double res)
Set an initial value for the variable r in (DD)
Definition: dsdpsetdata.c:311
int DSDPGetDataNorms(DSDP dsdp, double dnorm[3])
Copy the norms of the data C, A, and b into an array.
Definition: dsdpsetdata.c:621
int DSDPGetNumberOfVariables(DSDP dsdp, int *m)
Copy the number of variables y.
Definition: dsdpsetdata.c:707
int DSDPGetPotential(DSDP dsdp, double *potential)
Copy the potential of the current solution.
Definition: dsdpsetdata.c:803
int DSDPGetBarrierParameter(DSDP dsdp, double *mu)
Copy the current barrier parameter.
Definition: dsdpsetdata.c:364
int DSDPGetPotentialParameter(DSDP dsdp, double *rho)
Copy the potential parameter.
Definition: dsdpsetdata.c:784
int DSDPUsePenalty(DSDP dsdp, int yesorno)
Use penalty parameter to enforce feasibility.
Definition: dsdpsetdata.c:383
int DSDPSetZBar(DSDP dsdp, double ppobj)
Set an upper bound on the objective value at the solution.
Definition: dsdpsetdata.c:283
int DSDPSetFixedVariable(DSDP dsdp, int vari, double val)
Fix variable y to exact value.
Definition: dsdpschurmat.c:675
int DSDPSetBarrierParameter(DSDP dsdp, double mu)
Set the current barrier parameter.
Definition: dsdpsetdata.c:340
int DSDPSetPotentialParameter(DSDP dsdp, double rho)
Set the potential parameter.
Definition: dsdpsetdata.c:765
int DSDPGetMaxTrustRadius(DSDP dsdp, double *rad)
Copy the current radius of the trust region.
Definition: dsdpsetdata.c:265
int DSDPReuseMatrix(DSDP dsdp, int rm)
Reuse the Hessian of the barrier function multiple times at each DSDP iteration.
Definition: dsdpsetdata.c:905
int DSDPSetPenaltyParameter(DSDP dsdp, double Gamma)
Set the penalty parameter Gamma.
Definition: dsdpsetdata.c:418
int DSDPReadOptions(DSDP dsdp, char filename[])
Read DSDP parameters from a file.
int DSDPPrintOptions()
Print runtime options;.
int DSDPSetMaxTrustRadius(DSDP dsdp, double rad)
Set a maximum trust radius on the step direction.
Definition: dsdpsetdata.c:246
int DSDPSetYBounds(DSDP dsdp, double lbound, double ubound)
Bound the variables y.
Definition: dsdpsetdata.c:885
int DSDPGetPenaltyParameter(DSDP dsdp, double *Gamma)
Copy the penalty parameter Gamma.
Definition: dsdpsetdata.c:443
int DSDPUseDynamicRho(DSDP dsdp, int yesorno)
Use a dynamic strategy to choose parameter rho.
Definition: dsdpsetdata.c:821
int DSDPGetYBounds(DSDP dsdp, double *lbound, double *ubound)
Copy the bounds on the variables y.
Definition: dsdpsetdata.c:866
int DSDPGetReuseMatrix(DSDP dsdp, int *rm)
Copy this parameter.
Definition: dsdpsetdata.c:925
Internal structures for the DSDP solver.
Definition: dsdp.h:65