dsdpsetdata.c
Go to the documentation of this file.
#include "dsdp.h"
#include "dsdp5.h"
#include "dsdpsys.h"
#undef __FUNCT__
#define __FUNCT__ "DSDPSetDualObjective"
int DSDPSetDualObjective(DSDP dsdp,int i, double bi){
int info;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (i>dsdp->m || i<=0){
DSDPSETERR2(1,"Invalid variable number: Is 1 <= %d <= %d?\n",i,dsdp->m);}
info=DSDPVecSetElement(dsdp->b,i,bi);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPCopyB"
int DSDPCopyB(DSDP dsdp,double bb[], int m){
int i,info;
double *b;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (dsdp->m < m) DSDPFunctionReturn(1);
info=DSDPVecGetArray(dsdp->b,&b);DSDPCHKERR(info);
for (i=0;i<m;i++) bb[i]=b[i+1];
info=DSDPVecRestoreArray(dsdp->b,&b);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetY0"
int DSDPSetY0(DSDP dsdp,int i, double yi0){
int info;double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (i>dsdp->m || i<=0){
DSDPSETERR2(1,"Invalid variable number: Is 1<= %d <= %d\n",i,dsdp->m);}
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
info=DSDPVecSetElement(dsdp->y,i,scale*yi0);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetY"
int DSDPGetY(DSDP dsdp,double y[], int m){
int i,info;
double scale,*yy;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (dsdp->m < m-1) DSDPFunctionReturn(1);
if (dsdp->m > m) DSDPFunctionReturn(1);
info=DSDPVecCopy(dsdp->xmaker[0].y,dsdp->ytemp); DSDPCHKERR(info);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
info=DSDPVecGetArray(dsdp->ytemp,&yy);DSDPCHKERR(info);
for (i=0;i<m;i++) y[i]=yy[i+1]/scale;
info=DSDPVecRestoreArray(dsdp->ytemp,&yy);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetScale"
int DSDPGetScale(DSDP dsdp,double *scale){
int info;double sscale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPVecGetC(dsdp->y,&sscale);DSDPCHKERR(info);
*scale=fabs(sscale);
if (sscale==0) *scale=1.0;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetScale"
int DSDPSetScale(DSDP dsdp,double scale){
int info;double sscale;
DSDPFunctionBegin;
DSDPValid(dsdp);
scale=fabs(scale);
if (scale==0) scale=1.0;
info=DSDPGetScale(dsdp,&sscale);DSDPCHKERR(info);
sscale=scale/sscale;
info=DSDPVecScale(sscale,dsdp->y);
dsdp->mutarget*=sscale;
dsdp->pobj*=sscale;
dsdp->dobj*=sscale;
dsdp->ppobj*=sscale;
dsdp->ddobj*=sscale;
dsdp->mu*=sscale;
DSDPLogInfo(0,2,"Set DSDP C Scaling: %4.4e\n",scale);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPAddObjectiveConstant"
int DSDPAddObjectiveConstant(DSDP dsdp,double c){
int info;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPVecSetC(dsdp->b,-c);DSDPCHKERR(info);
DSDPLogInfo(0,2,"Add Objective Constant: %4.4e\n",c);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetMaxIts"
int DSDPSetMaxIts(DSDP dsdp,int its){
DSDPFunctionBegin;
DSDPValid(dsdp);
if (its >= 0) dsdp->maxiter = its;
DSDPLogInfo(0,2,"Set Maximum Iterates: %4d\n",its);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetMaxIts"
int DSDPGetMaxIts(DSDP dsdp,int *its){
DSDPFunctionBegin;
DSDPValid(dsdp);
*its=dsdp->maxiter;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetMaxTrustRadius"
int DSDPSetMaxTrustRadius(DSDP dsdp,double rad){
DSDPFunctionBegin;
DSDPValid(dsdp);
if (rad > 0) dsdp->maxtrustradius = rad;
DSDPLogInfo(0,2,"Set Maximum Trust Radius: %4.4e\n",rad);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetMaxTrustRadius"
int DSDPGetMaxTrustRadius(DSDP dsdp,double *rad){
DSDPFunctionBegin;
DSDPValid(dsdp);
*rad=dsdp->maxtrustradius;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetZBar"
int DSDPSetZBar(DSDP dsdp,double ppobj){
int info;
double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
dsdp->ppobj=ppobj*scale;
DSDPLogInfo(0,2,"Set Primal Objective and Upper bound on solution: %4.4e. \n",ppobj);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetR0"
int DSDPSetR0(DSDP dsdp,double res){
int info;
double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
info=DSDPSetRR(dsdp,scale*res); DSDPCHKERR(info);
if (res>=0)dsdp->goty0=DSDP_TRUE;
DSDPLogInfo(0,2,"Set Dual Initial Infeasibility to %4.4e times Identity Matrix. \n",res);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetBarrierParameter"
int DSDPSetBarrierParameter(DSDP dsdp,double mu){
int info;double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
dsdp->mutarget = mu*scale;
DSDPLogInfo(0,2,"Set InitialBarrierParameter: %4.4e \n",mu);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetBarrierParameter"
int DSDPGetBarrierParameter(DSDP dsdp, double *mu){
int info;double scale;
DSDPFunctionBegin;
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*mu=dsdp->mutarget/scale;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPUsePenalty"
int DSDPUsePenalty(DSDP dsdp,int yesorno){
DSDPPenalty UsePenalty;
int info;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (yesorno>0){
UsePenalty=DSDPAlways;
} else if (yesorno<0){
UsePenalty=DSDPNever;
} else {
UsePenalty=DSDPInfeasible;
}
dsdp->UsePenalty=UsePenalty;
info=RConeSetType(dsdp->rcone,UsePenalty);DSDPCHKERR(info);
DSDPLogInfo(0,2,"Set UsePenalty: %d \n",yesorno);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetPenaltyParameter"
int DSDPSetPenaltyParameter(DSDP dsdp,double Gamma){
int info;
double scale,ppenalty;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
ppenalty=fabs(Gamma*scale);
info=DSDPVecSetR(dsdp->b,ppenalty);DSDPCHKERR(info);
DSDPLogInfo(0,2,"Set Penalty Parameter: %4.4e\n",Gamma);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPenaltyParameter"
int DSDPGetPenaltyParameter(DSDP dsdp,double *Gamma){
int info;
double ppenalty;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPVecGetR(dsdp->b,&ppenalty);DSDPCHKERR(info);
*Gamma=fabs(ppenalty);
DSDPFunctionReturn(0);
}
/* Not current; not documented
*/
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPenalty"
int DSDPGetPenalty(DSDP dsdp,double *penalty){
int info;double ppenalty;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPVecGetR(dsdp->b,&ppenalty);DSDPCHKERR(info);
*penalty=fabs(ppenalty);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPPObjective"
int DSDPGetPPObjective(DSDP dsdp,double *ppobj){
int info;
double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*ppobj=(dsdp->ppobj)/scale;
if (dsdp->cnorm==0) *ppobj=0;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetDObjective"
int DSDPGetDObjective(DSDP dsdp,double *dobj){
int info; double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*dobj = (dsdp->dobj)/scale;
if (dsdp->cnorm==0) *dobj=-fabs(*dobj);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetDDObjective"
int DSDPGetDDObjective(DSDP dsdp,double *ddobj){
int info; double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*ddobj = (dsdp->ddobj)/scale;
if (dsdp->cnorm==0) *ddobj=-fabs(*ddobj);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetDualityGap"
int DSDPGetDualityGap(DSDP dsdp,double *dgap){
int info; double scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*dgap = (dsdp->dualitygap)/scale;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetIts"
int DSDPGetIts(DSDP dsdp,int *its){
DSDPFunctionBegin;
DSDPValid(dsdp);
*its=dsdp->itnow;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPStopReason"
int DSDPStopReason(DSDP dsdp,DSDPTerminationReason *reason){
DSDPFunctionBegin;
DSDPValid(dsdp);
*reason=dsdp->reason;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetR"
int DSDPGetR(DSDP dsdp, double *res){
int info;double rr,scale;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPGetRR(dsdp,&rr);DSDPCHKERR(info);
info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info);
*res=rr/scale;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetDataNorms"
int DSDPGetDataNorms(DSDP dsdp, double dnorm[3]){
int info;
DSDPFunctionBegin;
DSDPValid(dsdp);
if (dsdp->setupcalled==DSDP_FALSE){
info=DSDPComputeDataNorms(dsdp);DSDPCHKERR(info);
}
dnorm[0]=dsdp->cnorm;
dnorm[1]=dsdp->anorm;
dnorm[2]=dsdp->bnorm;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetMaxYElement"
int DSDPGetMaxYElement(DSDP dsdp,double* ymax){
int info;
DSDPFunctionBegin;
info=DSDPGetYMaxNorm(dsdp,ymax);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetDimension"
int DSDPGetDimension(DSDP dsdp, double *n){
int info;
DSDPFunctionBegin;
info=DSDPGetConicDimension(dsdp,n);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetYMaxNorm"
int DSDPGetYMaxNorm(DSDP dsdp, double *ynorm){
int info;
double cc,rr,yy;
DSDPFunctionBegin;
DSDPValid(dsdp);
info=DSDPVecGetC(dsdp->y,&cc);DSDPCHKERR(info);
info=DSDPVecGetR(dsdp->y,&rr);DSDPCHKERR(info);
info=DSDPVecSetC(dsdp->y,0);DSDPCHKERR(info);
info=DSDPVecSetR(dsdp->y,0);DSDPCHKERR(info);
info=DSDPVecNormInfinity(dsdp->y,&yy);DSDPCHKERR(info);
info=DSDPVecSetC(dsdp->y,cc);DSDPCHKERR(info);
info=DSDPVecSetR(dsdp->y,rr);DSDPCHKERR(info);
if (cc) yy/=fabs(cc);
if (ynorm) *ynorm=yy;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetNumberOfVariables"
int DSDPGetNumberOfVariables(DSDP dsdp, int *m){
DSDPFunctionBegin;
DSDPValid(dsdp);
*m=dsdp->m;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPnorm"
int DSDPGetPnorm(DSDP dsdp, double *pnorm){
DSDPFunctionBegin;
DSDPValid(dsdp);
*pnorm=dsdp->pnorm;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetStepLengths"
int DSDPGetStepLengths(DSDP dsdp, double *pstep, double *dstep){
DSDPFunctionBegin;
DSDPValid(dsdp);
*dstep=dsdp->dstep;
*pstep=dsdp->pstep;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetPotentialParameter"
int DSDPSetPotentialParameter(DSDP dsdp, double rho){
DSDPFunctionBegin;
DSDPValid(dsdp);
if (rho>1) dsdp->rhon=rho;
DSDPLogInfo(0,2,"Set Potential Parameter %4.4f\n",rho);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPotentialParameter"
int DSDPGetPotentialParameter(DSDP dsdp, double *rho){
DSDPFunctionBegin;
DSDPValid(dsdp);
*rho=dsdp->rhon;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetPotential"
int DSDPGetPotential(DSDP dsdp, double *potential){
DSDPFunctionBegin;
DSDPValid(dsdp);
*potential=dsdp->potential;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPUseDynamicRho"
int DSDPUseDynamicRho(DSDP dsdp, int yesorno){
DSDPFunctionBegin;
DSDPValid(dsdp);
if (yesorno) dsdp->usefixedrho=DSDP_FALSE;
else dsdp->usefixedrho=DSDP_TRUE;
DSDPLogInfo(0,2,"Set UseDynamicRho: %d \n",yesorno);
DSDPFunctionReturn(0);
}
/* Not Current or documented
*/
#undef __FUNCT__
#define __FUNCT__ "DSDPBoundDualVariables"
/* !
\fn int DSDPBoundDualVariables(DSDP dsdp, double lbound, double ubound)
\brief Bounds on the variables y.
\param dsdp is the solver
\param lbound will be the lower bound of the variables y
\param ubound will be the upper bound of the variables y
\sa DSDPSetYBounds()
\ingroup DSDPSolver
*/
int DSDPBoundDualVariables(DSDP dsdp,double lbound, double ubound){
int info;
double bbound;
DSDPFunctionBegin;
bbound=DSDPMax(fabs(lbound),fabs(ubound));
DSDPLogInfo(0,2,"Bound Variables between %4.4e and %4.4e \n",-bbound,bbound);
info = BoundYConeSetBounds(dsdp->ybcone,-bbound,bbound);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetYBounds"
int DSDPGetYBounds(DSDP dsdp,double *lbound, double *ubound){
int info;
DSDPFunctionBegin;
info=BoundYConeGetBounds(dsdp->ybcone,lbound,ubound);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetYBounds"
int DSDPSetYBounds(DSDP dsdp,double lbound, double ubound){
int info;
DSDPFunctionBegin;
info=BoundYConeSetBounds(dsdp->ybcone,lbound,ubound);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPReuseMatrix"
int DSDPReuseMatrix(DSDP dsdp, int rm){
DSDPFunctionBegin;
DSDPValid(dsdp);
dsdp->reuseM=rm;
DSDPLogInfo(0,2,"Reuse the Schur Matrix: %d times\n",rm);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPGetReuseMatrix"
int DSDPGetReuseMatrix(DSDP dsdp, int *rm){
DSDPFunctionBegin;
DSDPValid(dsdp);
*rm=dsdp->reuseM;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetMonitor"
int DSDPSetMonitor(DSDP dsdp, int (*monitor)(DSDP,void*), void* monitorctx){
DSDPFunctionBegin;
DSDPValid(dsdp);
if (dsdp->nmonitors<MAX_DSDP_MONITORS){
DSDPLogInfo(0,2,"Set Monitor\n");
dsdp->dmonitor[dsdp->nmonitors].monitor=monitor;
dsdp->dmonitor[dsdp->nmonitors].monitorctx=monitorctx;
dsdp->nmonitors++;
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetConvergenceFlag"
int DSDPSetConvergenceFlag(DSDP dsdp, DSDPTerminationReason reason ){
DSDPFunctionBegin;
DSDPValid(dsdp);
dsdp->reason=reason;
if (reason==DSDP_INFEASIBLE_START){
DSDPLogInfo(0,2,"Initial Point Infeasible, Check variable bounds? \n",0);
}
DSDPFunctionReturn(0);
}
BoundYConeGetBounds
int BoundYConeGetBounds(LUBounds lucone, double *lb, double *ub)
Get bounds on the variables.
Definition allbounds.c:532
BoundYConeSetBounds
int BoundYConeSetBounds(LUBounds lucone, double lb, double ub)
Set bounds on the variables.
Definition allbounds.c:512
dsdp5.h
The API to DSDP for those applications using DSDP as a subroutine library.
dsdp.h
Internal data structure for the DSDP solver.
DSDPSetRR
int DSDPSetRR(DSDP, double)
Set variable r.
Definition dualimpl.c:345
DSDPComputeDataNorms
int DSDPComputeDataNorms(DSDP)
Compute norms of A,C, and b.
Definition dsdpsetup.c:283
DSDPGetConicDimension
int DSDPGetConicDimension(DSDP, double *)
Get the total dimension of the cones.
Definition dsdpcops.c:401
DSDPGetRR
int DSDPGetRR(DSDP, double *)
Get variable r.
Definition dualimpl.c:361
DSDPTerminationReason
DSDPTerminationReason
There are many reasons to terminate the solver.
Definition dsdpbasictypes.h:50
DSDP_INFEASIBLE_START
@ DSDP_INFEASIBLE_START
Definition dsdpbasictypes.h:52
DSDP_FALSE
@ DSDP_FALSE
Definition dsdpbasictypes.h:19
DSDP_TRUE
@ DSDP_TRUE
Definition dsdpbasictypes.h:19
dsdpsys.h
Error handling, printing, and profiling.
DSDP_C
Internal structures for the DSDP solver.
Definition dsdp.h:65