8 #define DSDPCHKCONEERR(a,b); { if (b){ DSDPSETERR1(b,"Cone Number: %d,\n",a);} } 10 static int ConeSetup=0,ConeComputeS=0,ConeComputeSS=0,ConeComputeH=0,ConeHMultiplyAdd=0,ConeMaxPStep=0,ConeMaxDStep=0,ConePotential=0,ConeComputeX=0,ConeView=0,ConeDestroy=0,ConeXEigs=0,ConeRHS=0,ConeInvertS=0;
11 static int DSDPRegisterConeEvents(
void);
19 #define __FUNCT__ "DSDPZeroConeEvents" 20 static int DSDPZeroConeEvents(){
22 ConeSetup=0;ConeComputeS=0;ConeComputeSS=0;ConeComputeH=0;ConeHMultiplyAdd=0;ConeMaxPStep=0;ConeMaxDStep=0;ConePotential=0;ConeComputeX=0;ConeView=0;ConeDestroy=0;ConeXEigs=0;ConeRHS=0;ConeInvertS=0;
23 DSDPFunctionReturn(0);
27 #define __FUNCT__ "DSDPRegisterConeEvents" 28 static int DSDPRegisterConeEvents(){
31 DSDPEventLogRegister(
"Cone Setup 1&2",&ConeSetup);
32 DSDPEventLogRegister(
"Cone Invert S",&ConeInvertS);
33 DSDPEventLogRegister(
"Cone RHS",&ConeRHS);
34 DSDPEventLogRegister(
"Cone Compute Newton Eq.",&ConeComputeH);
35 DSDPEventLogRegister(
"Cone Newton Multiply-Add",&ConeHMultiplyAdd);
36 DSDPEventLogRegister(
"Cone Max P Step Length",&ConeMaxPStep);
37 DSDPEventLogRegister(
"Cone Compute and Factor SP",&ConeComputeSS);
38 DSDPEventLogRegister(
"Cone Max D Step Length",&ConeMaxDStep);
39 DSDPEventLogRegister(
"Cone Compute and Factor S",&ConeComputeS);
40 DSDPEventLogRegister(
"Cone Potential",&ConePotential);
41 DSDPEventLogRegister(
"Cone View",&ConeView);
42 DSDPEventLogRegister(
"Cone Compute X",&ConeComputeX);
43 DSDPEventLogRegister(
"Cone X Residuals",&ConeXEigs);
44 DSDPEventLogRegister(
"Cone Destroy",&ConeDestroy);
46 DSDPFunctionReturn(0);
57 #define __FUNCT__ "DSDPSetUpCones" 62 info=DSDPRegisterConeEvents();
63 DSDPEventLogBegin(ConeSetup);
64 for (kk=0;kk<dsdp->ncones;kk++){
65 DSDPEventLogBegin(dsdp->K[kk].coneid);
66 info=
DSDPConeSetUp(dsdp->K[kk].cone,yy0);DSDPCHKCONEERR(kk,info);
67 DSDPEventLogEnd(dsdp->K[kk].coneid);
69 DSDPEventLogEnd(ConeSetup);
70 DSDPFunctionReturn(0);
83 #define __FUNCT__ "DSDPSetUpCones2" 87 DSDPEventLogBegin(ConeSetup);
88 for (kk=0;kk<dsdp->ncones;kk++){
89 DSDPEventLogBegin(dsdp->K[kk].coneid);
90 info=
DSDPConeSetUp2(dsdp->K[kk].cone,yy0,M);DSDPCHKCONEERR(kk,info);
91 DSDPEventLogEnd(dsdp->K[kk].coneid);
93 DSDPEventLogEnd(ConeSetup);
94 DSDPFunctionReturn(0);
106 #define __FUNCT__ "DSDPDestroyCones" 108 int info,kk,ncones=dsdp->ncones;
110 DSDPEventLogBegin(ConeDestroy);
111 for (kk=ncones-1;kk>=0; kk--){
112 DSDPEventLogBegin(dsdp->K[kk].coneid);
114 DSDPEventLogEnd(dsdp->K[kk].coneid);
118 if (dsdp->maxcones>0){
119 DSDPFREE(&dsdp->K,&info);DSDPCHKERR(info);
123 DSDPEventLogEnd(ConeDestroy);
124 info=DSDPZeroConeEvents();DSDPCHKERR(info);
125 DSDPFunctionReturn(0);
141 #define __FUNCT__ "DSDPComputeHessian" 143 int info,kk;
double r;
145 DSDPEventLogBegin(ConeComputeH);
146 dsdp->schurmu=dsdp->mutarget;
147 info=DSDPVecGetR(dsdp->y,&r);DSDPCHKERR(info);
150 info=DSDPVecZero(vrhs1);DSDPCHKERR(info);
151 info=DSDPVecZero(vrhs2);DSDPCHKERR(info);
152 info=DSDPVecZero(M.schur->rhs3);DSDPCHKERR(info);
154 for (kk=dsdp->ncones-1;kk>=0;kk--){
155 DSDPEventLogBegin(dsdp->K[kk].coneid);
157 DSDPEventLogEnd(dsdp->K[kk].coneid);
164 if (0 && dsdp->UsePenalty==DSDPNever){
165 info=DSDPVecAXPY(1.0,M.schur->rhs3,vrhs2);DSDPCHKERR(info);
166 info=DSDPVecZero(M.schur->rhs3);DSDPCHKERR(info);
167 info=DSDPVecZero(M.schur->dy3);DSDPCHKERR(info);
168 info=DSDPVecSetR(vrhs1,0);DSDPCHKERR(info);
169 info=DSDPVecSetR(vrhs2,r);DSDPCHKERR(info);
171 DSDPEventLogEnd(ConeComputeH);
172 DSDPFunctionReturn(0);
177 #define __FUNCT__ "DSDPHessianMultiplyAdd" 192 DSDPEventLogBegin(ConeHMultiplyAdd);
195 for (kk=0;kk<dsdp->ncones;kk++){
196 DSDPEventLogBegin(dsdp->K[kk].coneid);
197 info=
DSDPConeMultiplyAdd(dsdp->K[kk].cone,dsdp->schurmu,vrow,v,vv);DSDPCHKCONEERR(kk,info);
198 DSDPEventLogEnd(dsdp->K[kk].coneid);
201 DSDPEventLogEnd(ConeHMultiplyAdd);
202 DSDPFunctionReturn(0);
206 #define __FUNCT__ "DSDPComputeG" 216 int info,kk;
double r;
218 DSDPEventLogBegin(ConeRHS);
219 info=DSDPVecZero(vrhs1);DSDPCHKERR(info);
220 info=DSDPVecZero(vrhs2);DSDPCHKERR(info);
221 info=DSDPVecGetR(dsdp->y,&r);DSDPCHKERR(info);
225 if (0 && r==0){info=DSDPVecSetR(vrhs1,0);info=DSDPVecSetR(vrhs2,0);}
227 for (kk=0;kk<dsdp->ncones;kk++){
228 DSDPEventLogBegin(dsdp->K[kk].coneid);
229 info=
DSDPConeComputeRHS(dsdp->K[kk].cone,dsdp->schurmu,vt,vrhs1,vrhs2);DSDPCHKCONEERR(kk,info);
230 DSDPEventLogEnd(dsdp->K[kk].coneid);
232 DSDPEventLogEnd(ConeRHS);
235 DSDPFunctionReturn(0);
239 #define __FUNCT__ "DSDPComputeANorm2" 249 for (kk=0;kk<dsdp->ncones;kk++){
250 DSDPEventLogBegin(dsdp->K[kk].coneid);
251 info=
DSDPConeANorm2(dsdp->K[kk].cone,Anorm2);DSDPCHKCONEERR(kk,info);
252 DSDPEventLogEnd(dsdp->K[kk].coneid);
254 DSDPFunctionReturn(0);
271 #define __FUNCT__ "DSDPComputeSS" 277 DSDPEventLogBegin(ConeComputeS);
279 DSDPEventLogBegin(ConeComputeSS);
281 for (kk=dsdp->ncones-1; kk>=0 && psd==
DSDP_TRUE;kk--){
282 DSDPEventLogBegin(dsdp->K[kk].coneid);
283 info=
DSDPConeComputeS(dsdp->K[kk].cone,Y,flag,&psd); DSDPCHKCONEERR(kk,info);
284 DSDPEventLogEnd(dsdp->K[kk].coneid);
288 DSDPEventLogEnd(ConeComputeS);
290 DSDPEventLogEnd(ConeComputeSS);
292 DSDPFunctionReturn(0);
306 #define __FUNCT__ "DSDPInvertS" 310 DSDPEventLogBegin(ConeInvertS);
311 for (kk=0;kk<dsdp->ncones;kk++){
312 DSDPEventLogBegin(dsdp->K[kk].coneid);
314 DSDPEventLogEnd(dsdp->K[kk].coneid);
316 DSDPEventLogEnd(ConeInvertS);
317 DSDPFunctionReturn(0);
335 #define __FUNCT__ "DSDPComputeMaxStepLength" 338 double msteplength=1.0e30,conesteplength;
341 DSDPEventLogBegin(ConeMaxDStep);
343 DSDPEventLogBegin(ConeMaxPStep);
345 for (kk=0;kk<dsdp->ncones;kk++){
346 DSDPEventLogBegin(dsdp->K[kk].coneid);
347 conesteplength=1.0e20;
349 msteplength=DSDPMin(msteplength,conesteplength);
350 DSDPEventLogEnd(dsdp->K[kk].coneid);
352 *maxsteplength=msteplength;
354 DSDPEventLogEnd(ConeMaxDStep);
356 DSDPEventLogEnd(ConeMaxPStep);
358 DSDPFunctionReturn(0);
377 #define __FUNCT__ "DSDPPassXVectors" 381 for (kk=0;kk<dsdp->ncones;kk++){
382 DSDPEventLogBegin(dsdp->K[kk].coneid);
384 DSDPEventLogEnd(dsdp->K[kk].coneid);
386 DSDPFunctionReturn(0);
400 #define __FUNCT__ "DSDPGetConicDimension" 405 for (kk=0;kk<dsdp->ncones;kk++){
411 DSDPFunctionReturn(0);
423 #define __FUNCT__ "DSDPViewCones" 427 DSDPEventLogBegin(ConeView);
428 for (kk=0;kk<dsdp->ncones;kk++){
429 DSDPEventLogBegin(dsdp->K[kk].coneid);
430 info=
DSDPConeView(dsdp->K[kk].cone);DSDPCHKCONEERR(kk,info);
431 DSDPEventLogEnd(dsdp->K[kk].coneid);
433 DSDPEventLogEnd(ConeView);
434 DSDPFunctionReturn(0);
449 #define __FUNCT__ "DSDPMonitorCones" 453 DSDPEventLogBegin(ConeView);
454 for (kk=0;kk<dsdp->ncones;kk++){
455 DSDPEventLogBegin(dsdp->K[kk].coneid);
457 DSDPEventLogEnd(dsdp->K[kk].coneid);
459 DSDPEventLogEnd(ConeView);
460 DSDPFunctionReturn(0);
473 #define __FUNCT__ "DSDPSparsityInSchurMat" 477 for (kk=0;kk<dsdp->ncones;kk++){
482 DSDPFunctionReturn(0);
494 #define __FUNCT__ "DSDPComputeLogSDeterminant" 497 double coneobjective,conepotential,llogdet=0;
499 DSDPEventLogBegin(ConePotential);
500 for (kk=0;kk<dsdp->ncones;kk++){
501 DSDPEventLogBegin(dsdp->K[kk].coneid);
502 coneobjective=0;conepotential=0;
504 llogdet+=conepotential;
505 DSDPEventLogEnd(dsdp->K[kk].coneid);
508 DSDPEventLogEnd(ConePotential);
509 DSDPFunctionReturn(0);
521 #define __FUNCT__ "DSDPSetCone" 527 if (dsdp->ncones>=dsdp->maxcones){
528 tc=2*dsdp->maxcones+4;
530 DSDPCALLOC2(&ccones,DCone,tc,&info);DSDPCHKERR(info);
531 for (i=0;i<dsdp->ncones;i++){ccones[i].cone=dsdp->K[i].cone;}
532 for (i=0;i<dsdp->ncones;i++){ccones[i].coneid=dsdp->K[i].coneid;}
533 DSDPFREE(&dsdp->K,&info);DSDPCHKERR(info);
538 DSDPEventLogRegister(conename,&tc);
539 dsdp->K[dsdp->ncones].cone=tcone;
540 dsdp->K[dsdp->ncones].coneid=tc;
542 DSDPFunctionReturn(0);
568 #define __FUNCT__ "DSDPAddCone" 576 DSDPFunctionReturn(0);
601 #define __FUNCT__ "DSDPSetSchurMatOps" 606 DSDPFunctionReturn(0);
621 #define __FUNCT__ "DSDPSetSchurRow" 626 DSDPFunctionReturn(0);
653 #define __FUNCT__ "DSDPComputeXVariables" 656 double ttracexs=0,tttracexs=0,tracex;
659 DSDPEventLogBegin(ConeComputeX);
660 info=DSDPVecZero(AX);DSDPCHKERR(info);
661 for (kk=0;kk<dsdp->ncones;kk++){
662 DSDPEventLogBegin(dsdp->K[kk].coneid);
664 info=
DSDPConeComputeX(dsdp->K[kk].cone,xmakermu,xmakery,xmakerdy,AX,&tttracexs);DSDPCHKCONEERR(kk,info);
666 DSDPEventLogEnd(dsdp->K[kk].coneid);
668 info=DSDPVecGetR(AX,&tracex); DSDPCHKERR(info);
669 DSDPLogInfo(0,2,
"Trace(X): %4.2e\n",dsdp->tracex);
670 info=DSDPVecAXPY(-1.0,dsdp->b,AX); DSDPCHKERR(info);
671 info=DSDPComputeFixedYX(dsdp->M,AX); DSDPCHKERR(info);
673 info=DSDPVecSetR(AX,tracex); DSDPCHKERR(info);
674 DSDPEventLogEnd(ConeComputeX);
675 DSDPFunctionReturn(0);
int DSDPDestroyCones(DSDP dsdp)
Each cone shoudl free its data structures.
DSDPTruth
Boolean variables.
int DSDPConeComputeS(DSDPCone K, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite)
Given y, compute S and determine whether its in the cone.
int DSDPConeInvertS(DSDPCone K)
Invert the dual matrix S.
struct DSDPVec_C DSDPVec
This object hold m+2 variables: a scaling of C, the y variables, and r.
Schur complement matrix whose solution is the Newton direction.
int DSDPSetUpCones2(DSDP dsdp, DSDPVec yy0, DSDPSchurMat M)
Each cone should allocate its data structures .
int DSDPComputeANorm2(DSDP dsdp, DSDPVec Anorm2)
Compute norm of A and C.
int DSDPConeANorm2(DSDPCone K, DSDPVec anorm2)
Add square of 2-norm of data correponding to each variable y.
Error handling, printing, and profiling.
int DSDPComputeXVariables(DSDP dsdp, double xmakermu, DSDPVec xmakery, DSDPVec xmakerdy, DSDPVec AX, double *tracexs)
Compute the X variables in each cone.
int DSDPObjectiveGH(DSDP, DSDPSchurMat, DSDPVec)
Compute gradient of dual objective.
int DSDPSetSchurMatOps(DSDP, struct DSDPSchurMat_Ops *, void *)
Set the Schur complement matrix.
int DSDPMonitorCones(DSDP dsdp, int tag)
This routine is called once per iteration.
int DSDPComputeMaxStepLength(DSDP dsdp, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength)
Compute the maximum step length for the given step direction.
int DSDPComputeHessian(DSDP dsdp, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2)
Compute the Schur complement, or Gram, matrix for each cone.
Internal structures for the DSDP solver.
int DSDPConeSetXMaker(DSDPCone K, double mu, DSDPVec y, DSDPVec dy)
Pass information needed to construct X.
int DSDPConeMonitor(DSDPCone K, int tag)
Do anything at in the cone at each iteration.
int DSDPInvertS(DSDP dsdp)
Invert the S variables in each cone.
int DSDPGetConicDimension(DSDP dsdp, double *n)
Get the total dimension of the cones.
int DSDPConeSetData(DSDPCone *K, struct DSDPCone_Ops *ops, void *data)
Initialize the pointers to 0.
int DSDPConeInitialize(DSDPCone *K)
Initialize the pointers to 0.
int DSDPConeView(DSDPCone K)
View contents of the cone.
int DSDPSetUpCones(DSDP dsdp)
Each cone should factor data or allocate internal data structures.
int DSDPSchurSparsity(DSDP dsdp, int row, int rnnz[], int m)
Each cone should print its state.
int DSDPComputeG(DSDP dsdp, DSDPVec vt, DSDPVec vrhs1, DSDPVec vrhs2)
Compute the gradient of the barrier for each cone.
int DSDPConeDestroy(DSDPCone *K)
Free the internal memory of the cone.
int DSDPSchurMatZeroEntries(DSDPSchurMat M)
Zero all element in the matrix.
int DSDPConeComputeRHS(DSDPCone K, double mu, DSDPVec vrow, DSDPVec rhs1, DSDPVec rhs2)
Compute gradient of barrier function.
int DSDPViewCones(DSDP dsdp)
Each cone should print its state.
Internal data structure for the DSDP solver.
int DSDPComputeLogSDeterminant(DSDP dsdp, double *logdet)
Compute the logarithmic barrier function for the dual varialbe S.
int DSDPConeComputeMaxStepLength(DSDPCone K, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength)
Determine distance to the edge of the cone.
int DSDPGetConeName(DSDPCone K, char *cname, int maxlength)
Get name of the cone.
int DSDPSchurMatRowScaling(DSDPSchurMat M, DSDPVec D)
Identify which rows on on this processor.
int DSDPConeSetUp2(DSDPCone K, DSDPVec yy0, DSDPSchurMat M)
Factor the data and allocate data structures.
int DSDPHessianMultiplyAdd(DSDP dsdp, DSDPVec v, DSDPVec vv)
Add the product of Schur matrix with v.
struct DSDPCone_C DSDPCone
This object holds the data of a SDP, LP, or other cone. Its structure is opaque to the DSDP Solver...
int DSDPPassXVectors(DSDP dsdp, double mu, DSDPVec Y, DSDPVec DY)
Pass the information needed to compute the variables X in each cone but do not compute X...
int DSDPSchurMatSetData(DSDPSchurMat *M, struct DSDPSchurMat_Ops *ops, void *data)
Set the Schur matrix with an opaque pointer and structure of function pointers.
int DSDPConeMultiplyAdd(DSDPCone K, double mu, DSDPVec vrow, DSDPVec v, DSDPVec vv)
Multiply Hessian by a vector and add the result.
int DSDPSchurMatAssemble(DSDPSchurMat M)
Final assembly of M.
int DSDPConeSetUp(DSDPCone K, DSDPVec y)
Factor the data and allocate data structures.
int DSDPSetCone(DSDP dsdp, DSDPCone tcone)
Pass a cone to the DSDP solver.
int DSDPConeGetDimension(DSDPCone K, double *n)
Provide the dimension of the cone.
int DSDPSchurMatAddRow(DSDPSchurMat, int, double, DSDPVec)
Add elements to a row of the Schur matrix.
int DSDPSchurMatSetR(DSDPSchurMat M, double rr)
Set up the data structure.
int DSDPAddSchurRow(DSDP, int, DSDPVec)
Add a row to the Schur matrix.
int DSDPConeSparsityInSchurMat(DSDPCone K, int row, int rnnz[], int m)
Identify sparsity pattern in a row of the Hessian term.
DSDPDualFactorMatrix
DSDP requires two instances of the data structures S.
int DSDPAddCone(DSDP dsdp, struct DSDPCone_Ops *dsdpops, void *dsdpcone)
Apply DSDP to a conic structure.
int DSDPSchurMatReducePVec(DSDPSchurMat M, DSDPVec x)
Collect elements of the vector.
int DSDPConeComputeX(DSDPCone K, double mu, DSDPVec y, DSDPVec dy, DSDPVec AX, double *tracexs)
Given y,dy, and mu, construct X and add its inner product with the data and S.
int DSDPConeComputeLogSDeterminant(DSDPCone K, double *logdetobj, double *logdet)
Evaluate logrithmic barrier function.
int DSDPComputeSS(DSDP dsdp, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite)
Compute the dual variables S in each cone.
int DSDPConeComputeHessian(DSDPCone K, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2)
Compute Hessian and gradient of barrier function.