dsdpcone.c
Go to the documentation of this file.
#include "dsdpcone_impl.h"
#include "dsdpcone.h"
#include "dsdpsys.h"
#define DSDPNoOperationError(a); { DSDPSETERR1(10,"Cone type: %s, Operation not defined\n",(a).dsdpops->name); }
#define DSDPChkConeError(a,b); { if (b){DSDPSETERR1(b,"Cone type: %s,\n",(a).dsdpops->name); } }
#undef __FUNCT__
#define __FUNCT__ "DSDPConeSetUp"
int DSDPConeSetUp(DSDPCone K,DSDPVec y){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conesetup){
info=K.dsdpops->conesetup(K.conedata,y);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeSetUp2"
int DSDPConeSetUp2(DSDPCone K, DSDPVec yy0, DSDPSchurMat M){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conesetup2){
info=K.dsdpops->conesetup2(K.conedata,yy0,M);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeDestroy"
int DSDPConeDestroy(DSDPCone *K){
int info;
DSDPFunctionBegin;
if ((*K).dsdpops->conedestroy){
info=(*K).dsdpops->conedestroy((*K).conedata);DSDPChkConeError(*K,info);
info=DSDPConeInitialize(K); DSDPCHKERR(info);
} else {
DSDPNoOperationError(*K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeHessian"
int DSDPConeComputeHessian( DSDPCone K , double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conehessian){
info=K.dsdpops->conehessian(K.conedata,mu,M,vrhs1,vrhs2);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeMultiplyAdd"
int DSDPConeMultiplyAdd( DSDPCone K , double mu, DSDPVec vrow, DSDPVec v, DSDPVec vv){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conehmultiplyadd){
info=K.dsdpops->conehmultiplyadd(K.conedata,mu,vrow,v,vv);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeRHS"
int DSDPConeComputeRHS( DSDPCone K , double mu, DSDPVec vrow,DSDPVec rhs1,DSDPVec rhs2){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conerhs){
info=K.dsdpops->conerhs(K.conedata,mu,vrow,rhs1,rhs2);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeANorm2"
int DSDPConeANorm2( DSDPCone K , DSDPVec anorm2){
int info;
DSDPFunctionBegin;
if (K.dsdpops->coneanorm2){
info=K.dsdpops->coneanorm2(K.conedata,anorm2);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeSetXMaker"
int DSDPConeSetXMaker( DSDPCone K, double mu, DSDPVec y, DSDPVec dy){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conesetxmaker){
info=K.dsdpops->conesetxmaker(K.conedata,mu,y,dy);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeX"
int DSDPConeComputeX( DSDPCone K, double mu, DSDPVec y, DSDPVec dy, DSDPVec AX, double *tracexs){
int info;
double trxs;
DSDPFunctionBegin;
if (K.dsdpops->conecomputex){
trxs=0;
info=K.dsdpops->conecomputex(K.conedata,mu,y,dy,AX,&trxs);DSDPChkConeError(K,info);
*tracexs+=trxs;
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeS"
int DSDPConeComputeS(DSDPCone K, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conecomputes){
info=K.dsdpops->conecomputes(K.conedata,Y,flag,ispsdefinite);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeInvertS"
int DSDPConeInvertS(DSDPCone K){
int info;
DSDPFunctionBegin;
if (K.dsdpops->coneinverts){
info=K.dsdpops->coneinverts(K.conedata);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeMaxStepLength"
int DSDPConeComputeMaxStepLength(DSDPCone K, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){
int info;
double conesteplength=1.0e20;
DSDPFunctionBegin;
conesteplength=1.0e30;
if (K.dsdpops->conemaxsteplength){
info=K.dsdpops->conemaxsteplength(K.conedata,DY,flag,&conesteplength);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
*maxsteplength=conesteplength;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeGetDimension"
int DSDPConeGetDimension(DSDPCone K, double *n){
int info;
double nn=0;
DSDPFunctionBegin;
if (K.dsdpops->conesize){
info=K.dsdpops->conesize(K.conedata,&nn);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
*n=nn;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSparsityInSchurMat"
int DSDPConeSparsityInSchurMat(DSDPCone K, int row, int rnnz[], int m){
int info,tt;
DSDPFunctionBegin;
if (K.dsdpops->conesparsity){
info=K.dsdpops->conesparsity(K.conedata,row,&tt,rnnz,m);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeView"
int DSDPConeView(DSDPCone K){
int info;
DSDPFunctionBegin;
if (K.dsdpops->coneview){
info=K.dsdpops->coneview(K.conedata);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeMonitor"
int DSDPConeMonitor(DSDPCone K, int tag){
int info;
DSDPFunctionBegin;
if (K.dsdpops->conemonitor){
info=K.dsdpops->conemonitor(K.conedata,tag);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeComputeLogSDeterminant"
int DSDPConeComputeLogSDeterminant(DSDPCone K, double *logdetobj, double *logdet){
int info;
double conepotential1=0,conepotential2=0;
DSDPFunctionBegin;
if (K.dsdpops->conelogpotential){
info=K.dsdpops->conelogpotential(K.conedata,&conepotential1,&conepotential2);DSDPChkConeError(K,info);
} else {
DSDPNoOperationError(K);
}
*logdetobj=conepotential1;
*logdet=conepotential2;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetConeName"
int DSDPGetConeName(DSDPCone K, char *cname, int maxlength){
DSDPFunctionBegin;
strncpy(cname,K.dsdpops->name,maxlength);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeOpsInitialize"
int DSDPConeOpsInitialize(struct DSDPCone_Ops* dops){
DSDPFunctionBegin;
if (dops==NULL) return 0;
dops->conesetup=0;
dops->conesetup2=0;
dops->conedestroy=0;
dops->coneanorm2=0;
dops->conehessian=0;
dops->conehmultiplyadd=0;
dops->conerhs=0;
dops->conesetxmaker=0;
dops->conecomputex=0;
dops->conecomputes=0;
dops->coneinverts=0;
dops->conemaxsteplength=0;
dops->conesparsity=0;
dops->conelogpotential=0;
dops->conemonitor=0;
dops->coneview=0;
dops->id=0;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPConeSetData"
int DSDPConeSetData(DSDPCone *K, struct DSDPCone_Ops* ops, void* data){
DSDPFunctionBegin;
(*K).dsdpops=ops;
(*K).conedata=data;
DSDPFunctionReturn(0);
}
static struct DSDPCone_Ops dsdpcops;
#undef __FUNCT__
#define __FUNCT__ "DSDPConeOpsInitialize"
int DSDPConeInitialize(DSDPCone *K){
int info;
DSDPFunctionBegin;
info=DSDPConeOpsInitialize(&dsdpcops); DSDPCHKERR(info);
info=DSDPConeSetData(K,&dsdpcops,0); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
DSDPDualFactorMatrix
DSDPDualFactorMatrix
DSDP requires two instances of the data structures S.
Definition dsdpbasictypes.h:25
DSDPTruth
DSDPTruth
Boolean variables.
Definition dsdpbasictypes.h:19
DSDPConeView
int DSDPConeView(DSDPCone K)
View contents of the cone.
Definition dsdpcone.c:358
DSDPConeComputeX
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.
Definition dsdpcone.c:216
DSDPConeInitialize
int DSDPConeInitialize(DSDPCone *K)
Initialize the pointers to 0.
Definition dsdpcone.c:495
DSDPGetConeName
int DSDPGetConeName(DSDPCone K, char *cname, int maxlength)
Get name of the cone.
Definition dsdpcone.c:427
DSDPConeComputeMaxStepLength
int DSDPConeComputeMaxStepLength(DSDPCone K, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength)
Determine distance to the edge of the cone.
Definition dsdpcone.c:288
DSDPConeComputeS
int DSDPConeComputeS(DSDPCone K, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite)
Given y, compute S and determine whether its in the cone.
Definition dsdpcone.c:242
DSDPConeSetXMaker
int DSDPConeSetXMaker(DSDPCone K, double mu, DSDPVec y, DSDPVec dy)
Pass information needed to construct X.
Definition dsdpcone.c:191
DSDPConeMonitor
int DSDPConeMonitor(DSDPCone K, int tag)
Do anything at in the cone at each iteration.
Definition dsdpcone.c:380
DSDPConeComputeLogSDeterminant
int DSDPConeComputeLogSDeterminant(DSDPCone K, double *logdetobj, double *logdet)
Evaluate logrithmic barrier function.
Definition dsdpcone.c:403
DSDPConeInvertS
int DSDPConeInvertS(DSDPCone K)
Invert the dual matrix S.
Definition dsdpcone.c:265
DSDPConeGetDimension
int DSDPConeGetDimension(DSDPCone K, double *n)
Provide the dimension of the cone.
Definition dsdpcone.c:312
DSDPConeSetUp
int DSDPConeSetUp(DSDPCone K, DSDPVec y)
Factor the data and allocate data structures.
Definition dsdpcone.c:22
DSDPConeDestroy
int DSDPConeDestroy(DSDPCone *K)
Free the internal memory of the cone.
Definition dsdpcone.c:64
DSDPConeComputeRHS
int DSDPConeComputeRHS(DSDPCone K, double mu, DSDPVec vrow, DSDPVec rhs1, DSDPVec rhs2)
Compute gradient of barrier function.
Definition dsdpcone.c:147
DSDPConeSparsityInSchurMat
int DSDPConeSparsityInSchurMat(DSDPCone K, int row, int rnnz[], int m)
Identify sparsity pattern in a row of the Hessian term.
Definition dsdpcone.c:338
DSDPConeComputeHessian
int DSDPConeComputeHessian(DSDPCone K, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2)
Compute Hessian and gradient of barrier function.
Definition dsdpcone.c:92
DSDPConeSetData
int DSDPConeSetData(DSDPCone *K, struct DSDPCone_Ops *ops, void *data)
Initialize the pointers to 0.
Definition dsdpcone.c:477
DSDPConeMultiplyAdd
int DSDPConeMultiplyAdd(DSDPCone K, double mu, DSDPVec vrow, DSDPVec v, DSDPVec vv)
Multiply Hessian by a vector and add the result.
Definition dsdpcone.c:119
DSDPConeOpsInitialize
int DSDPConeOpsInitialize(struct DSDPCone_Ops *dops)
Initialize the function pointers to 0.
Definition dsdpcone.c:443
DSDPConeSetUp2
int DSDPConeSetUp2(DSDPCone K, DSDPVec yy0, DSDPSchurMat M)
Factor the data and allocate data structures.
Definition dsdpcone.c:43
DSDPConeANorm2
int DSDPConeANorm2(DSDPCone K, DSDPVec anorm2)
Add square of 2-norm of data correponding to each variable y.
Definition dsdpcone.c:168
dsdpcone.h
The public interface between the cones and the solver.
DSDPCone
struct DSDPCone_C DSDPCone
This object holds the data of a SDP, LP, or other cone. Its structure is opaque to the DSDP Solver,...
Definition dsdpcone.h:27
dsdpcone_impl.h
Implementations of a cone (SDP,LP,...) must provide a structure of function pointers.
dsdpsys.h
Error handling, printing, and profiling.
DSDPVec
struct DSDPVec_C DSDPVec
This object hold m+2 variables: a scaling of C, the y variables, and r.
Definition dsdpvec.h:25
DSDPSchurMat_C
Schur complement matrix whose solution is the Newton direction.
Definition dsdpschurmat.h:35