10 double primalr,dualr,x,logr;
11 DSDPPenalty UsePenalty;
15 typedef struct RDCone RCone;
18 #define __FUNCT__ "DSDPRHessian" 20 RCone *K=(RCone*)dspcone;
25 info=DSDPVecGetSize(vrhs2,&m);DSDPCHKERR(info);
29 rssr=mu*rr/(K->dualr*K->dualr);
30 info=DSDPVecAddR(vrhs2,sr);DSDPCHKERR(info);
34 DSDPFunctionReturn(0);
39 #define __FUNCT__ "DSDPRHS" 41 RCone *K=(RCone*)dspcone;
47 info=DSDPVecGetR(vrow,&rr);DSDPCHKERR(info);
48 info=DSDPVecAddR(vrhs2,rr*sr);DSDPCHKERR(info);
50 DSDPFunctionReturn(0);
55 #define __FUNCT__ "DSDPSetupRCone" 56 static int DSDPSetupRCone(
void* dspcone,
DSDPVec y){
58 DSDPFunctionReturn(0);
62 #define __FUNCT__ "DSDPSetupRCone2" 65 DSDPFunctionReturn(0);
70 #define __FUNCT__ "DSDPDestroyRCone" 71 static int DSDPDestroyRCone(
void* dspcone){
74 DSDPFREE(&dspcone,&info);DSDPCHKERR(info);
75 DSDPFunctionReturn(0);
80 #define __FUNCT__ "DSDPRSize" 81 static int DSDPRSize(
void*dspcone,
double *n){
82 RCone *K=(RCone*)dspcone;
86 DSDPFunctionReturn(0);
90 #define __FUNCT__ "DSDPRSparsity" 91 static int DSDPRSparsity(
void*dspcone,
int row,
int *tnnz,
int rnnz[],
int m){
94 DSDPFunctionReturn(0);
99 #define __FUNCT__ "DSDPComputeRS" 101 RCone *K=(RCone*)dspcone;
105 info=DSDPVecGetR(Y,&rbeta); DSDPCHKERR(info);
106 if (K->UsePenalty==DSDPAlways){
109 if (rbeta>0) rbeta=0;
112 if (flag==
DUAL_FACTOR){ K->dualr=rbeta; }
else { K->primalr=rbeta;}
113 DSDPFunctionReturn(0);
116 #define __FUNCT__ "DSDPInvertRS" 117 static int DSDPInvertRS(
void *dspcone){
119 DSDPFunctionReturn(0);
125 #define __FUNCT__ "DSDPComputeRStepLength" 127 RCone *K=(RCone*)dspcone;
128 double r,rbeta,msteplength=1.0e100,rt=1.0e30;
132 info=DSDPVecGetR(DY,&rbeta); DSDPCHKERR(info);
133 if (flag==
DUAL_FACTOR){ r=K->dualr; }
else { r=K->primalr;}
134 if (r * rbeta<0) rt=-r/rbeta;
136 if (K->UsePenalty==DSDPAlways){msteplength=rt;}
140 *maxsteplength=msteplength;
141 DSDPFunctionReturn(0);
145 #define __FUNCT__ "DSDPRX" 147 RCone *K=(RCone*)dspcone;
149 double rr,dr,trxs,r=K->dualr;
152 info=DSDPVecGetR(y,&rr); DSDPCHKERR(info);
153 info=DSDPVecGetR(dy,&dr); DSDPCHKERR(info);
158 DSDPLogInfo(0,2,
"RESIDUAL X (Minimum Penalty Parameter): %4.4e, Trace(XS): %4.4e\n",K->x,trxs);
163 DSDPFunctionReturn(0);
167 #define __FUNCT__ "DSDPSetX" 168 static int DSDPSetX(
void *dspcone,
double mu,
DSDPVec y,
DSDPVec dy){
169 RCone *K=(RCone*)dspcone;
174 info=DSDPVecGetR(y,&rr); DSDPCHKERR(info);
175 info=DSDPVecGetR(dy,&dr); DSDPCHKERR(info);
180 DSDPLogInfo(0,2,
"RESIDUAL X (Minimum Penalty Parameter): %4.4e, Trace(XS): %4.4e\n",K->x,trxs);
185 DSDPFunctionReturn(0);
189 #define __FUNCT__ "DSDPComputeRLog" 190 static int DSDPComputeRLog(
void *dspcone,
double *logobj,
double *logdet){
191 RCone *K=(RCone*)dspcone;
196 *logdet=log(-K->dualr);
197 K->logr=log(-K->dualr);
199 DSDPFunctionReturn(0);
203 #define __FUNCT__ "DSDPRANorm2" 204 static int DSDPRANorm2(
void *dspcone,
DSDPVec Anorm2){
206 DSDPFunctionReturn(0);
210 #define __FUNCT__ "DSDPRMultiplyAdd" 212 RCone *K=(RCone*)dspcone;
217 info=DSDPVecGetR(vrow,&v1);DSDPCHKERR(info);
218 info=DSDPVecGetR(vin,&v2);DSDPCHKERR(info);
219 rssr=v1*v2*mu/(K->dualr*K->dualr);
220 info=DSDPVecAddR(vout,rssr);DSDPCHKERR(info);
222 DSDPFunctionReturn(0);
226 #define __FUNCT__ "DSDPRMonitor" 227 static int DSDPRMonitor(
void *dspcone,
int tag){
229 DSDPFunctionReturn(0);
232 static struct DSDPCone_Ops kops;
233 static const char* matname=
"R Cone";
236 #define __FUNCT__ "RConeOperationsInitialize" 237 static int RConeOperationsInitialize(
struct DSDPCone_Ops* coneops){
239 if (coneops==NULL)
return 0;
241 coneops->conehessian=DSDPRHessian;
242 coneops->conesetup=DSDPSetupRCone;
243 coneops->conesetup2=DSDPSetupRCone2;
244 coneops->conedestroy=DSDPDestroyRCone;
245 coneops->conecomputes=DSDPComputeRS;
246 coneops->coneinverts=DSDPInvertRS;
247 coneops->conesetxmaker=DSDPSetX;
248 coneops->conecomputex=DSDPRX;
249 coneops->conerhs=DSDPRHS;
250 coneops->conemaxsteplength=DSDPComputeRStepLength;
251 coneops->conelogpotential=DSDPComputeRLog;
252 coneops->conesize=DSDPRSize;
253 coneops->conesparsity=DSDPRSparsity;
254 coneops->coneanorm2=DSDPRANorm2;
255 coneops->conemonitor=DSDPRMonitor;
256 coneops->conehmultiplyadd=DSDPRMultiplyAdd;
258 coneops->name=matname;
270 #define __FUNCT__ "RConeSetType" 271 int RConeSetType(RCone *rcone, DSDPPenalty UsePenalty){
273 rcone->UsePenalty=UsePenalty;
274 DSDPFunctionReturn(0);
286 #define __FUNCT__ "RConeGetRX" 287 int RConeGetRX(RCone *rcone,
double *xtrace){
290 DSDPFunctionReturn(0);
301 #define __FUNCT__ "DSDPAddRCone" 304 DSDPPenalty UsePenalty=DSDPInfeasible;
307 info=RConeOperationsInitialize(&kops); DSDPCHKERR(info);
308 DSDPCALLOC1(&rcone,RCone,&info); DSDPCHKERR(info);
309 info=RConeSetType(rcone,UsePenalty); DSDPCHKERR(info);
313 info=
DSDPAddCone(dsdp,&kops,(
void*)rcone); DSDPCHKERR(info);
314 DSDPFunctionReturn(0);
DSDPTruth
Boolean variables.
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.
Error handling, printing, and profiling.
Internal structures for the DSDP solver.
Solver, solution types, termination codes,.
int DSDPAddRCone(DSDP dsdp, RCone **rrcone)
A separate cone specifies that r must be nonnegative.
int DSDPSchurMatAddDiagonalElement(DSDPSchurMat, int, double)
Determine with the cone should compute this diagonal element of M and RHS.
Implementations of a cone (SDP,LP,...) must provide a structure of function pointers.
DSDPDualFactorMatrix
DSDP requires two instances of the data structures S.
int DSDPSchurMatVariableCompute(DSDPSchurMat, int, double *)
Determine with the cone should compute this diagonal element of M and RHS.
int DSDPAddCone(DSDP, struct DSDPCone_Ops *, void *)
Apply DSDP to a conic structure.
int DSDPConeOpsInitialize(struct DSDPCone_Ops *dops)
Initialize the function pointers to 0.