DSDP5.8/0000755000175000017500000000000010326240756012006 5ustar twernertwernerDSDP5.8/src/0000755000175000017500000000000010326241002012556 5ustar twernertwernerDSDP5.8/src/solver/0000755000175000017500000000000010326241002014070 5ustar twernertwernerDSDP5.8/src/solver/dsdpsetup.c0000644000175000017500000003571610326241002016263 0ustar twernertwerner#include "dsdp.h" #include "dsdpsys.h" #include "dsdp5.h" /*! \file dsdpsetup.c \brief Create DSDP solver and its data strucutures. */ /*! \fn int DSDPCreate(int m, DSDP *dsdpnew) \brief Create a DSDP solver. FIRST DSDP routine! \param m the number of variables y \param *dsdpnew will be set to a new solver object \sa DSDPSetDualObjective() \sa DSDPSetup() \sa DSDPSolve() \sa DSDPDestroy() \ingroup DSDPBasic For example, to create a DSDP solver for a problem with 10 y variables, \code int m=10; DSDP dsdp; DSDPCreate(m,&dsdp); \endcode */ #undef __FUNCT__ #define __FUNCT__ "DSDPCreate" int DSDPCreate(int m,DSDP* dsdpnew){ DSDP dsdp; int info; DSDPFunctionBegin; DSDPCALLOC1(&dsdp,PD_DSDP,&info);DSDPCHKERR(info); *dsdpnew=dsdp; dsdp->keyid=DSDPKEY; /* Initialize some parameters */ DSDPEventLogInitialize(); dsdp->m=m; dsdp->maxcones=0; dsdp->ncones=0; dsdp->K=0; dsdp->setupcalled=DSDP_FALSE; dsdp->ybcone=0; dsdp->ndroutines=0; /* info = DSDPSetStandardMonitor(dsdp);DSDPCHKERR(info); */ info = DSDPVecCreateSeq(m+2,&dsdp->b);DSDPCHKERR(info); info = DSDPVecZero(dsdp->b);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->b,&dsdp->y);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->b,&dsdp->ytemp);DSDPCHKERR(info); info = DSDPVecZero(dsdp->y);DSDPCHKERR(info); info = DSDPVecSetC(dsdp->y,-1.0);DSDPCHKERR(info); info = DSDPAddRCone(dsdp,&dsdp->rcone);DSDPCHKERR(info); info = DSDPCreateLUBoundsCone(dsdp,&dsdp->ybcone);DSDPCHKERR(info); info=DSDPSetDefaultStatistics(dsdp);DSDPCHKERR(info); info=DSDPSetDefaultParameters(dsdp);DSDPCHKERR(info); info=DSDPSetDefaultMonitors(dsdp);DSDPCHKERR(info); /* info = DSDPMatInitialize(m,m,&dsdp->Q);DSDPCHKERR(info); */ info = DSDPSchurMatInitialize(&dsdp->M);DSDPCHKERR(info); info = DSDPSetDefaultSchurMatrixStructure(dsdp); DSDPCHKERR(info); info = DSDPCGInitialize(&dsdp->sles); DSDPCHKERR(info); /* Set the one global variable sdat=dsdp; */ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetDefaultStatistics" /*! \fn int DSDPSetDefaultStatistics(DSDP dsdp); \brief Set default statistics. \param dsdp the solver */ int DSDPSetDefaultStatistics(DSDP dsdp){ int i; DSDPFunctionBegin; DSDPValid(dsdp); dsdp->reason=CONTINUE_ITERATING; dsdp->pdfeasible=DSDP_PDUNKNOWN; dsdp->itnow=0; dsdp->pobj= 1.0e10; dsdp->ppobj= 1.0e10; dsdp->dobj= -1.0e+9; dsdp->ddobj= -1.0e+9; dsdp->dualitygap=dsdp->ppobj-dsdp->ddobj; dsdp->pstep=1.0; dsdp->dstep=0.0; for (i=0;ixmaker[i].mu=1.0e200; dsdp->xmaker[i].pstep=0.0; } dsdp->pnorm=0.001; dsdp->mu=1000.0; dsdp->np=0; dsdp->anorm=0; dsdp->bnorm=0; dsdp->cnorm=0; dsdp->tracex=0; dsdp->tracexs=0; dsdp->Mshift=0; dsdp->goty0=DSDP_FALSE; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetDefaultParameters" /*! \fn int DSDPSetDefaultParameters(DSDP dsdp); \brief Set default parameters. \param dsdp the solver */ int DSDPSetDefaultParameters(DSDP dsdp){ int info; DSDPFunctionBegin; DSDPValid(dsdp); /* Stopping parameters */ info=DSDPSetMaxIts(dsdp,500);DSDPCHKERR(info); info=DSDPSetGapTolerance(dsdp,1.0e-6);DSDPCHKERR(info); info=DSDPSetPNormTolerance(dsdp,1.0e30);DSDPCHKERR(info); if (dsdp->m<100){info=DSDPSetGapTolerance(dsdp,1.0e-7);DSDPCHKERR(info);} if (dsdp->m>3000){info=DSDPSetGapTolerance(dsdp,5.0e-6);DSDPCHKERR(info);} info=RConeSetType(dsdp->rcone,DSDPInfeasible);DSDPCHKERR(info); info=DSDPSetDualBound(dsdp,1.0e20);DSDPCHKERR(info); info=DSDPSetStepTolerance(dsdp,5.0e-2);DSDPCHKERR(info); info=DSDPSetRTolerance(dsdp,1.0e-6);DSDPCHKERR(info); info=DSDPSetPTolerance(dsdp,1.0e-4);DSDPCHKERR(info); /* Solver options */ info=DSDPSetMaxTrustRadius(dsdp,1.0e10);DSDPCHKERR(info); info=DSDPUsePenalty(dsdp,0);DSDPCHKERR(info); info=DSDPSetInitialBarrierParameter(dsdp,-1.0);DSDPCHKERR(info); info=DSDPSetPotentialParameter(dsdp,3.0);DSDPCHKERR(info); info=DSDPUseDynamicRho(dsdp,1);DSDPCHKERR(info); info=DSDPSetR0(dsdp,-1.0);DSDPCHKERR(info); info=DSDPSetPenaltyParameter(dsdp,1.0e8);DSDPCHKERR(info); info=DSDPReuseMatrix(dsdp,4);DSDPCHKERR(info); if (dsdp->m>100){info=DSDPReuseMatrix(dsdp,7);DSDPCHKERR(info);} if (dsdp->m>1000){info=DSDPReuseMatrix(dsdp,10);DSDPCHKERR(info);} if (dsdp->m<=100){info=DSDPSetPotentialParameter(dsdp,5.0);DSDPCHKERR(info);DSDPCHKERR(info);} dsdp->maxschurshift=1.0e-11; dsdp->mu0=-1.0; dsdp->slestype=2; info = DSDPSetYBounds(dsdp,-1e7,1e7);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetDefaultMonitors" /*! \fn int DSDPSetDefaultMonitors(DSDP dsdp); \brief Set convergence monitor. \param dsdp the solver */ int DSDPSetDefaultMonitors(DSDP dsdp){ int info; DSDPFunctionBegin; DSDPValid(dsdp); dsdp->nmonitors=0; info=DSDPSetMonitor(dsdp,DSDPDefaultConvergence,(void*)&dsdp->conv); DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPSetup(DSDP dsdp) \brief Set up data structures in the solver and the cones associated with it. \param dsdp the solver \sa DSDPCreate() \sa DSDPSolve() \sa DSDPDestroy() \ingroup DSDPBasic This routine must be called before DSDPSolve(). Do not create SDP, LP or other cones after calling this routines, and do not set data into the cones after calling this routine. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetUp" int DSDPSetup(DSDP dsdp){ int i,info; DSDPFunctionBegin; DSDPValid(dsdp); /* Create the Work Vectors */ info = DSDPVecDuplicate(dsdp->y,&dsdp->rhs1);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->rhs2);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->rhs);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->rhstemp);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->dy1);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->dy2);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->dy);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->y0);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->xmakerrhs);DSDPCHKERR(info); for (i=0;iy,&dsdp->xmaker[i].y);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->xmaker[i].dy);DSDPCHKERR(info); info = DSDPVecDuplicate(dsdp->y,&dsdp->xmaker[i].rhs);DSDPCHKERR(info); } /* Create M */ info = DSDPSetUpCones(dsdp);DSDPCHKERR(info); info = DSDPSchurMatSetup(dsdp->M,dsdp->ytemp);DSDPCHKERR(info); info = DSDPCGSetup(dsdp->sles,dsdp->ytemp); DSDPCHKERR(info); info = DSDPSetUpCones2(dsdp,dsdp->y,dsdp->M);DSDPCHKERR(info); info = DSDPGetConicDimension(dsdp,&dsdp->np);DSDPCHKERR(info); info=DSDPComputeDataNorms(dsdp);DSDPCHKERR(info); dsdp->pinfeas=dsdp->bnorm+1; dsdp->perror=dsdp->bnorm+1; info=DSDPScaleData(dsdp);DSDPCHKERR(info); info=DSDPGetConicDimension(dsdp,&dsdp->np);DSDPCHKERR(info); dsdp->solvetime=0; dsdp->cgtime=0; dsdp->ptime=0; dsdp->dtime=0; dsdp->ctime=0; info=DSDPEventLogRegister("Primal Step",&dsdp->ptime); info=DSDPEventLogRegister("Dual Step",&dsdp->dtime); info=DSDPEventLogRegister("Corrector Step",&dsdp->ctime); info=DSDPEventLogRegister("CG Solve",&dsdp->cgtime); info=DSDPEventLogRegister("DSDP Solve",&dsdp->solvetime); dsdp->setupcalled=DSDP_TRUE; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetSchurMatrix" int DSDPGetSchurMatrix(DSDP dsdp, DSDPSchurMat *M){ DSDPFunctionBegin; DSDPValid(dsdp); *M=dsdp->M; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetConvergenceMonitor" /*! \fn int DSDPGetConvergenceMonitor(DSDP dsdp, ConvergenceMonitor**ctx); \brief Get the structure containing convergence parameters. \param dsdp the solver \param *ctx will point to the structure. \ingroup DSDPRoutines \note This structure part of the DSDP structure. */ int DSDPGetConvergenceMonitor(DSDP dsdp, ConvergenceMonitor**ctx){ DSDPFunctionBegin; DSDPValid(dsdp); *ctx=&dsdp->conv; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeDataNorms" /*! \fn int DSDPComputeDataNorms(DSDP dsdp); \brief Compute norms of A,C, and b. \param dsdp the solver */ int DSDPComputeDataNorms(DSDP dsdp){ int info; DSDPVec ytemp=dsdp->ytemp; DSDPFunctionBegin; DSDPValid(dsdp); info = DSDPComputeANorm2(dsdp,ytemp);DSDPCHKERR(info); info = DSDPFixedVariablesNorm(dsdp->M,ytemp);DSDPCHKERR(info); info = DSDPVecGetC(ytemp,&dsdp->cnorm);DSDPCHKERR(info); dsdp->cnorm=sqrt(dsdp->cnorm); info = DSDPVecSetR(ytemp,0);DSDPCHKERR(info); info = DSDPVecSetC(ytemp,0);DSDPCHKERR(info); info = DSDPVecNorm1(ytemp,&dsdp->anorm);DSDPCHKERR(info); dsdp->anorm=sqrt(dsdp->anorm); DSDPLogInfo(0,2,"Norm of data: %4.2e\n",dsdp->anorm); info=DSDPVecCopy(dsdp->b,ytemp);DSDPCHKERR(info); info = DSDPVecSetR(ytemp,0);DSDPCHKERR(info); info = DSDPVecSetC(ytemp,0);DSDPCHKERR(info); info = DSDPVecNorm2(ytemp,&dsdp->bnorm);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPScaleData" /*! \fn int DSDPScaleData(DSDP dsdp); \brief Scale the matrix C. \param dsdp the solver */ int DSDPScaleData(DSDP dsdp){ int info; double scale; DSDPFunctionBegin; DSDPValid(dsdp); scale=1.0*dsdp->anorm; if (dsdp->bnorm){ scale/=dsdp->bnorm;} if (dsdp->cnorm){ scale/=dsdp->cnorm;} scale=DSDPMin(scale,1.0); scale=DSDPMax(scale,1.0e-6); if (dsdp->cnorm==0){ scale=1;} info=DSDPSetScale(dsdp,scale);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPSolve(DSDP dsdp) \brief Apply DSDP to the problem. Call this routine after DSDPCreate() and DSDPSetup(), and after setting the data. \param dsdp is the solver \sa DSDPCreate() \sa DSDPGetSolutionType() \sa DSDPGetDObjective() \sa DSDPGetY() \sa DSDPStopReason() \ingroup DSDPBasic */ #undef __FUNCT__ #define __FUNCT__ "DSDPSolve" int DSDPSolve(DSDP dsdp){ int info; DSDPFunctionBegin; info=DSDPEventLogBegin(dsdp->solvetime); dsdp->pdfeasible=DSDP_PDUNKNOWN; info=DSDPSetConvergenceFlag(dsdp,CONTINUE_ITERATING);DSDPCHKERR(info); info=DSDPInitializeVariables(dsdp);DSDPCHKERR(info); info=DSDPSolveDynamicRho(dsdp);DSDPCHKERR(info); if (dsdp->pstep==1){info=DSDPRefineStepDirection(dsdp,dsdp->xmakerrhs,dsdp->xmaker[0].dy);DSDPCHKERR(info);} if (dsdp->pdfeasible==DSDP_PDUNKNOWN) dsdp->pdfeasible=DSDP_PDFEASIBLE; info=DSDPEventLogEnd(dsdp->solvetime); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCallMonitors" /*! \fn int DSDPCallMonitors(DSDP dsdp,DMonitor dmonitor[], int ndmonitors); \param dsdp solver \param dmonitor array of monitors \param ndmonitors number of monitors. \brief Call the monitor routines. */ int DSDPCallMonitors(DSDP dsdp,DMonitor dmonitor[], int ndmonitors){ int i,info; DSDPFunctionBegin; for (i=0; inp);DSDPCHKERR(info); dsdp->rgap=(dsdp->ppobj-dsdp->ddobj)/(1.0+fabs(dsdp->ppobj)+fabs(dsdp->ddobj)); dsdp->pstepold=dsdp->pstep; if (dsdp->reason==CONTINUE_ITERATING){ if (dsdp->itnow>0){ info=DSDPCheckForUnboundedObjective(dsdp,&unbounded);DSDPCHKERR(info); if (unbounded==DSDP_TRUE){ dsdp->pdfeasible=DSDP_UNBOUNDED; info=DSDPSetConvergenceFlag(dsdp,DSDP_CONVERGED); DSDPCHKERR(info); } } if (dsdp->reason==CONTINUE_ITERATING){ if (dsdp->muoldmutarget && dsdp->pstep==1 && dsdp->dstep==1 && dsdp->rgap<1e-5){ info=DSDPSetConvergenceFlag(dsdp,DSDP_NUMERICAL_ERROR); DSDPCHKERR(info); DSDPLogInfo(0,2,"DSDP Finished: Numerical issues: Increase in Barrier function. \n");} if (dsdp->itnow >= dsdp->maxiter){ info=DSDPSetConvergenceFlag(dsdp,DSDP_MAX_IT); DSDPCHKERR(info);} if (dsdp->Mshift>dsdp->maxschurshift){ info = DSDPSetConvergenceFlag(dsdp,DSDP_INDEFINITE_SCHUR_MATRIX); DSDPCHKERR(info); } } info=DSDPCallMonitors(dsdp,dsdp->dmonitor,dsdp->nmonitors);DSDPCHKERR(info); info=DSDPMonitorCones(dsdp,0); DSDPCHKERR(info); } dsdp->muold=dsdp->mutarget; info = DSDPStopReason(dsdp,reason); DSDPCHKERR(info); DSDPFunctionReturn(0); } /* ---------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "DSDPTakeDown" /*! \fn int DSDPTakeDown(DSDP dsdp); \param dsdp solver \brief Destroy internal data structures. */ int DSDPTakeDown(DSDP dsdp){ int i,info; DSDPFunctionBegin; DSDPValid(dsdp); info = DSDPVecDestroy(&dsdp->rhs);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->rhs1);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->rhs2);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->rhstemp);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->y);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->ytemp);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->dy1);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->dy2);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->dy);DSDPCHKERR(info); for (i=0;ixmaker[i].y);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->xmaker[i].dy);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->xmaker[i].rhs);DSDPCHKERR(info); } info = DSDPVecDestroy(&dsdp->xmakerrhs);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->y0);DSDPCHKERR(info); info = DSDPVecDestroy(&dsdp->b);DSDPCHKERR(info); info = DSDPCGDestroy(&dsdp->sles);DSDPCHKERR(info); info = DSDPDestroyCones(dsdp);DSDPCHKERR(info); info = DSDPSchurMatDestroy(&dsdp->M);DSDPCHKERR(info); info = DSDPGetConicDimension(dsdp,&dsdp->np);DSDPCHKERR(info); dsdp->setupcalled=DSDP_FALSE; DSDPFunctionReturn(0); } /*! \fn int DSDPSetDestroyRoutine(DSDP dsdp, int (*fd)(void*), void* ctx); \brief Set a routine that will be called during DSDPDestroy(). \param dsdp the solver \param fd function pointer \param ctx pointer to structure. \sa DSDPDestroy() */ int DSDPSetDestroyRoutine(DSDP dsdp, int (*fd)(void*), void* ctx){ int nd=dsdp->ndroutines; if (nd<10){ dsdp->droutine[nd].f=fd; dsdp->droutine[nd].ptr=ctx; dsdp->ndroutines++; } else { printf("TOO MANY Destroy routines\n"); return 1; } return 0; } /*! \fn int DSDPDestroy(DSDP dsdp) \brief Free the internal data structures of the solver and the cones associated with it. \param dsdp the solver \sa DSDPCreate() \sa DSDPSolve() \sa DSDPSetup() \ingroup DSDPBasic */ #undef __FUNCT__ #define __FUNCT__ "DSDPDestroy" int DSDPDestroy(DSDP dsdp){ int i,info; DSDPFunctionBegin; DSDPValid(dsdp); for (i=0;indroutines;i++){ info=(*dsdp->droutine[i].f)(dsdp->droutine[i].ptr);DSDPCHKERR(info); } info=DSDPTakeDown(dsdp);DSDPCHKERR(info); DSDPFREE(&dsdp,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpcg.c0000644000175000017500000002426110326241002015505 0ustar twernertwerner#include "dsdpcg.h" #include "dsdpschurmat.h" #include "dsdpvec.h" #include "dsdpsys.h" #include "dsdp.h" /*! \file dsdpcg.c \brief Apply Conjugate Gradient method to solve the Schur matrix. */ typedef enum { DSDPNoMatrix=1, DSDPUnfactoredMatrix=2, DSDPFactoredMatrix=3} DSDPCGType; typedef struct{ DSDPCGType type; DSDPSchurMat M; DSDPVec Diag; DSDP dsdp; } DSDPCGMat; #undef __FUNCT__ #define __FUNCT__ "DSDPCGMatMult" int DSDPCGMatMult(DSDPCGMat M, DSDPVec X, DSDPVec Y){ int info; DSDPFunctionBegin; info=DSDPVecZero(Y); DSDPCHKERR(info); if (M.type==DSDPUnfactoredMatrix){ info=DSDPSchurMatMultiply(M.M,X,Y); DSDPCHKERR(info); } else if (M.type==DSDPFactoredMatrix){ info=DSDPSchurMatMultR(M.M,X,Y); DSDPCHKERR(info); info=DSDPVecAXPY(-0*M.dsdp->Mshift,X,Y); DSDPCHKERR(info); } else if (M.type==DSDPNoMatrix){ info=DSDPHessianMultiplyAdd(M.dsdp,X,Y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGMatPre" int DSDPCGMatPre(DSDPCGMat M, DSDPVec X, DSDPVec Y){ int info; DSDPFunctionBegin; info=DSDPVecZero(Y); DSDPCHKERR(info); if (M.type==DSDPUnfactoredMatrix){ info=DSDPVecPointwiseMult(X,M.Diag,Y);DSDPCHKERR(info); info=DSDPVecPointwiseMult(Y,M.Diag,Y);DSDPCHKERR(info); } else if (M.type==DSDPFactoredMatrix){ info=DSDPSchurMatSolve(M.M,X,Y);DSDPCHKERR(info); } else if (M.type==DSDPNoMatrix){ info=DSDPVecCopy(X,Y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGMatPreLeft" int DSDPCGMatPreLeft(DSDPCGMat M, DSDPVec X, DSDPVec Y){ int info; DSDPFunctionBegin; info=DSDPVecZero(Y); DSDPCHKERR(info); if (M.type==DSDPUnfactoredMatrix){ info=DSDPVecPointwiseMult(X,M.Diag,Y);DSDPCHKERR(info); } else if (M.type==DSDPFactoredMatrix){ info=DSDPSchurMatSolve(M.M,X,Y);DSDPCHKERR(info); } else if (M.type==DSDPNoMatrix){ info=DSDPVecCopy(X,Y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGMatPreRight" int DSDPCGMatPreRight(DSDPCGMat M, DSDPVec X, DSDPVec Y){ int info; DSDPFunctionBegin; info=DSDPVecZero(Y); DSDPCHKERR(info); if (M.type==DSDPNoMatrix){ info=DSDPVecPointwiseMult(X,M.Diag,Y);DSDPCHKERR(info); } else if (M.type==DSDPFactoredMatrix){ info=DSDPVecCopy(X,Y);DSDPCHKERR(info); } else if (M.type==DSDPUnfactoredMatrix){ info=DSDPVecCopy(X,Y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPConjugateResidual" int DSDPConjugateResidual(DSDPCGMat B, DSDPVec X, DSDPVec D, DSDPVec R, DSDPVec BR, DSDPVec P, DSDPVec BP, DSDPVec TT3, int maxits, int *iter){ int i,n,info; double zero=0.0,minus_one=-1.0; double alpha,beta,bpbp,rBr,rBrOld; double r0,rerr=1.0e20; DSDPFunctionBegin; info=DSDPVecNorm2(X,&rBr); DSDPCHKERR(info); if (rBr>0){ info=DSDPVecCopy(X,P); DSDPCHKERR(info); info=DSDPCGMatPreRight(B,P,X);DSDPCHKERR(info); info=DSDPCGMatMult(B,X,R); DSDPCHKERR(info); } else { info=DSDPVecSet(zero,R); DSDPCHKERR(info); } info=DSDPVecAYPX(minus_one,D,R); DSDPCHKERR(info); info=DSDPCGMatPreLeft(B,D,R);DSDPCHKERR(info); info=DSDPVecCopy(R,P); DSDPCHKERR(info); info=DSDPCGMatPreRight(B,R,BR);DSDPCHKERR(info); info=DSDPCGMatMult(B,BR,TT3); DSDPCHKERR(info); info=DSDPCGMatPreRight(B,TT3,BR);DSDPCHKERR(info); info=DSDPVecCopy(BR,BP); DSDPCHKERR(info); info=DSDPVecDot(BR,R,&rBr); DSDPCHKERR(info); info=DSDPVecGetSize(X,&n); DSDPCHKERR(info); r0=rBr; for (i=0;i0){ info=DSDPCGMatMult(B,X,R);DSDPCHKERR(info); } alpha=-1.0; info=DSDPVecAYPX(alpha,D,R); DSDPCHKERR(info); info=DSDPVecNorm2(R,&rerr); DSDPCHKERR(info); if (rerr*sqrt(1.0*n)<1e-11 +0*cgtol*cgtol){ *iter=1; DSDPFunctionReturn(0); } if (rerr>0){ info=DSDPVecCopy(R,P); DSDPCHKERR(info); info=DSDPVecSetR(P,0);DSDPCHKERR(info); info=DSDPVecNorm2(P,&rerr); DSDPCHKERR(info); info=DSDPCGMatPre(B,R,Z);DSDPCHKERR(info); } info=DSDPVecCopy(Z,P); DSDPCHKERR(info); info=DSDPVecDot(R,Z,&rz); DSDPCHKERR(info); r0=rerr;rz0=rz; for (i=0;i1){ if (rerr*sqrt(1.0*n) < cgtol){ break;} if (rz*n < cgtol*cgtol){ break;} if (rerr/r0 < cgtol){ break;} } if (rerr<=0){ break;} info=DSDPCGMatPre(B,R,Z);DSDPCHKERR(info); rzold=rz; info=DSDPVecDot(R,Z,&rz); DSDPCHKERR(info); beta=rz/rzold; info= DSDPVecAYPX(beta,Z,P); DSDPCHKERR(info); } DSDPLogInfo(0,2,"Conjugate Gradient, Initial ||r||: %4.2e, Final ||r||: %4.2e, Initial ||rz||: %4.4e, ||rz||: %4.4e, Iterates: %d\n",r0,rerr,rz0,rz,i+1); *iter=i+1; DSDPFunctionReturn(0); } /*! \fn int DSDPCGSolve(DSDP dsdp, DSDPSchurMat MM, DSDPVec RHS, DSDPVec X,double cgtol, DSDPTruth *success); \brief Apply CG to solve for the step directions. \param dsdp the solver \param MM matrix \param RHS right-hand side \param X solution \param cgtol accuracy \param success output whether a solution of suitable accuracy was found */ #undef __FUNCT__ #define __FUNCT__ "DSDPCGSolve" int DSDPCGSolve(DSDP dsdp, DSDPSchurMat MM, DSDPVec RHS, DSDPVec X,double cgtol, DSDPTruth *success){ int iter=0,n,info,maxit=10; double dd,ymax; DSDPCG *sles=dsdp->sles; DSDPCGMat CGM; DSDPFunctionBegin; info=DSDPEventLogBegin(dsdp->cgtime); info=DSDPVecZero(X);DSDPCHKERR(info); info=DSDPVecGetSize(X,&n); DSDPCHKERR(info); *success=DSDP_TRUE; if (0){ maxit=0; } else if (dsdp->slestype==1){ CGM.type=DSDPNoMatrix; CGM.M=MM; CGM.dsdp=dsdp; cgtol*=1000; maxit=5; } else if (dsdp->slestype==2){ CGM.type=DSDPUnfactoredMatrix; CGM.M=MM; CGM.Diag=sles->Diag; CGM.dsdp=dsdp; cgtol*=100; maxit=(int)sqrt(1.0*n)+10; if (maxit>20) maxit=20; info=DSDPVecSet(1.0,sles->Diag);DSDPCHKERR(info); /* info=DSDPSchurMatGetDiagonal(MM,sles->Diag);DSDPCHKERR(info); info=DSDPVecReciprocalSqrt(sles->Diag); DSDPCHKERR(info); */ } else if (dsdp->slestype==3){ CGM.type=DSDPFactoredMatrix; CGM.M=MM; CGM.dsdp=dsdp; maxit=0; info=DSDPGetMaxYElement(dsdp,&ymax);DSDPCHKERR(info); if (ymax > 1e5 && dsdp->rgap<1e-1) maxit=3; if (0 && ymax > 1e5 && dsdp->rgap<1e-2){ maxit=6; } else if (dsdp->rgap<1e-5){ maxit=3; } info=DSDPSchurMatSolve(MM,RHS,X);DSDPCHKERR(info); } else if (dsdp->slestype==4){ CGM.type=DSDPFactoredMatrix; CGM.M=MM; CGM.dsdp=dsdp; maxit=3; info=DSDPSchurMatSolve(MM,RHS,X);DSDPCHKERR(info); } if (nR,sles->BR,sles->P,sles->BP, sles->TTT,cgtol,maxit,&iter);DSDPCHKERR(info); if (iter>=maxit) *success=DSDP_FALSE; info=DSDPVecDot(RHS,X,&dd);DSDPCHKERR(info); if (dd<0) *success=DSDP_FALSE; info=DSDPEventLogEnd(dsdp->cgtime); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGInitialize" int DSDPCGInitialize(DSDPCG **sles){ DSDPCG *ssles; int info; DSDPFunctionBegin; DSDPCALLOC1(&ssles,DSDPCG,&info);DSDPCHKERR(info); ssles->setup2=0; *sles=ssles; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGSetup" int DSDPCGSetup(DSDPCG *sles,DSDPVec X){ int info; DSDPFunctionBegin; info=DSDPVecGetSize(X,&sles->m);DSDPCHKERR(info); if (sles->setup2==0){ info = DSDPVecDuplicate(X,&sles->R); DSDPCHKERR(info); info = DSDPVecDuplicate(X,&sles->P); DSDPCHKERR(info); info = DSDPVecDuplicate(X,&sles->BP); DSDPCHKERR(info); info = DSDPVecDuplicate(X,&sles->BR); DSDPCHKERR(info); info = DSDPVecDuplicate(X,&sles->Diag); DSDPCHKERR(info); info = DSDPVecDuplicate(X,&sles->TTT); DSDPCHKERR(info); } sles->setup2=1; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCGDestroy" int DSDPCGDestroy(DSDPCG **ssles){ int info; DSDPCG *sles=*ssles; DSDPFunctionBegin; if (ssles==0 || sles==0){DSDPFunctionReturn(0);} if (sles->setup2==1){ info = DSDPVecDestroy(&sles->R); DSDPCHKERR(info); info = DSDPVecDestroy(&sles->P); DSDPCHKERR(info); info = DSDPVecDestroy(&sles->BP); DSDPCHKERR(info); info = DSDPVecDestroy(&sles->BR); DSDPCHKERR(info); info = DSDPVecDestroy(&sles->Diag); DSDPCHKERR(info); info = DSDPVecDestroy(&sles->TTT); DSDPCHKERR(info); } DSDPFREE(ssles,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpcg.h0000644000175000017500000000075710326241002015516 0ustar twernertwerner#include "dsdpvec.h" #if !defined(__DSDP_CG_H) #define __DSDP_CG_H /*! \file dsdpcg.h \brief Internal data structure for CG method. */ typedef struct{ int setup2; int m; DSDPVec Diag; DSDPVec RHS2; DSDPVec R; DSDPVec BR; DSDPVec P; DSDPVec BP; DSDPVec TTT; } DSDPCG; #ifdef __cplusplus extern "C" { #endif int DSDPCGSetup(DSDPCG*, DSDPVec); int DSDPCGDestroy(DSDPCG**); int DSDPCGInitialize(DSDPCG **); #ifdef __cplusplus } #endif #endif DSDP5.8/src/solver/dsdpcone.c0000644000175000017500000003152110326241002016035 0ustar twernertwerner#include "dsdpcone_impl.h" #include "dsdpcone.h" #include "dsdpsys.h" /*! \file dsdpcone.c \brief Methods of a cone. */ #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); } } /*! \fn int DSDPConeSetUp(DSDPCone K, DSDPVec y); \brief Factor the data and allocate data structures. \param K the cone \param y initial solution vector */ #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); } /*! \fn int DSDPConeSetUp2(DSDPCone K, DSDPVec yy0, DSDPSchurMat M); \brief Factor the data and allocate data structures. \param K the cone \param yy0 initial solution vector \param M Schur matrix */ #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); } /*! \fn int DSDPConeDestroy(DSDPCone *K); \brief Free the internal memory of the cone. \param K the cone */ #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); } /*! \fn int DSDPConeComputeHessian(DSDPCone K, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2); \brief Compute Hessian and gradient of barrier function. \param K the cone \param mu barrier parameter \param M Schur matrix \param vrhs1 objective gradient \param vrhs2 barrier gradient This routine assumes that the dual matrix has already been factored and inverted. \sa SDPConeComputeHessian() */ #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); } /*! \fn int DSDPConeMultiplyAdd(DSDPCone K, double mu, DSDPVec vrow, DSDPVec v, DSDPVec vv); \brief Multiply Hessian by a vector and add the result. \param K the cone \param mu barrier parameter \param vrow scaling for each element in the product. \param v input vector gradient \param vv output vector This routine assumes that the dual matrix has already been factored and inverted. If M is the hessian, then vv += vrow .* Mv */ #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); } /*! \fn int DSDPConeComputeRHS(DSDPCone K, double mu, DSDPVec vrow, DSDPVec rhs1, DSDPVec rhs2); \brief Compute gradient of barrier function. \param K the cone \param mu barrier parameter \param vrow scaling for each element in the gradient. \param rhs1 objective gradient \param rhs2 barrier gradient This routine assumes that the dual matrix has already been factored and inverted. Define rhs2 += mu * vrow .* A(S^{-1}) \sa SDPConeComputeRHS() */ #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); } /*! \fn int DSDPConeANorm2(DSDPCone K, DSDPVec anorm2); \brief Add square of 2-norm of data correponding to each variable y. \param K the cone \param anorm2 norm of constraint data for each varibles \sa DSDPBlockANorm2 */ #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); } /*! \fn int DSDPConeSetXMaker(DSDPCone K, double mu, DSDPVec y, DSDPVec dy); \brief Pass information needed to construct X. \param K the cone \param mu barrier parameter \param y solution \param dy step direction */ #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); } /*! \fn int DSDPConeComputeX(DSDPCone K, double mu, DSDPVec y, DSDPVec dy, DSDPVec AX, double *tracexs); \brief Given y,dy, and mu, construct X and add its inner product with the data and S \param K the cone \param mu barrier parameter \param y solution \param dy step direction \param AX add the inner product of the data with X \param tracexs inner product of X and S. \sa SDPConeComputeXX() */ #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); } /*! \fn int DSDPConeComputeS(DSDPCone K, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite); \brief Given y, compute S and determine whether its in the cone. \param K the cone \param Y solution \param flag identifies which of two S matrix structures should be used. \param ispsdefinite true if S is positive definite or an element of the cone. */ #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); } /*! \fn int DSDPConeInvertS(DSDPCone K); \brief Invert the dual matrix S. \param K the cone Assumes that the matrix has already been factored. */ #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); } /*! \fn int DSDPConeComputeMaxStepLength(DSDPCone K, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength); \brief Determine distance to the edge of the cone. \param K the cone \param DY step direction \param flag identifies which of two S matrix structures should be used. \param maxsteplength distance to the edge of the cone. */ #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); } /*! \fn int DSDPConeGetDimension(DSDPCone K, double *n); \brief Provide the dimension of the cone. \param K the cone \param n conic dimension (an integer value) */ #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); } /*! \fn int DSDPConeSparsityInSchurMat(DSDPCone K, int row, int rnnz[], int m); \brief Identify sparsity pattern in a row of the Hessian term \param K the cone \param row between 1 and m \param rnnz mark elements nonzero for nonzeros in Hessian of barrier. \param m number of y variables, length of array, and size of M matrix \sa DSDPSparsityInSchurMat() \sa DSDPSchurSparsity() */ #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); } /*! \fn int DSDPConeView(DSDPCone K); \brief View contents of the cone. \param K the cone */ #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); } /*! \fn int DSDPConeMonitor(DSDPCone K, int tag); \brief Do anything at in the cone at each iteration. \param K the cone \param tag allows for multiple types of monitors. This routine has be used to visualize data, print some statistics, ... */ #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); } /*! \fn int DSDPConeComputeLogSDeterminant(DSDPCone K, double *logdetobj, double *logdet); \brief Evaluate logrithmic barrier function. \param K the cone \param logdetobj used term. \param logdet logarithmic barrier of cone Assumes S is in cone. */ #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); } /*! \fn int DSDPGetConeName(DSDPCone K, char *cname, int maxlength); \brief Get name of the cone. \param K the cone \param cname string to copy the string \param maxlength maximum length of the string. */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetConeName" int DSDPGetConeName(DSDPCone K, char *cname, int maxlength){ DSDPFunctionBegin; strncpy(cname,K.dsdpops->name,maxlength); DSDPFunctionReturn(0); } /*! \fn int DSDPConeOpsInitialize(struct DSDPCone_Ops* dops); \brief Initialize the function pointers to 0. \param dops address of a structure of function pointers. */ #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); } /*! \fn int DSDPConeSetData(DSDPCone *K, struct DSDPCone_Ops* ops, void* data); \brief Initialize the pointers to 0. \param K the cone \param ops address of a structure of function pointers. \param data address of a structure representing a cone */ #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; /*! \fn int DSDPConeInitialize(DSDPCone *K); \brief Initialize the pointers to 0. \param K the cone */ #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); } DSDP5.8/src/solver/dsdpcone.h0000644000175000017500000000346110326241002016044 0ustar twernertwerner#ifndef __DSDPCONEOPERATIONS_H #define __DSDPCONEOPERATIONS_H /*! \file dsdpcone.h \brief The public interface between the cones and the solver. */ #include "dsdpbasictypes.h" #include "dsdpvec.h" #include "dsdpschurmat.h" /*! \typedef struct DSDPCone DSDPCone; \brief This object holds the data of a SDP, LP, or other cone. Its structure is opaque to the DSDP Solver, but it must implement the interface below and provide a structure of function pointers. */ struct DSDPCone_C{ void* conedata; struct DSDPCone_Ops* dsdpops; }; typedef struct DSDPCone_C DSDPCone; #ifdef __cplusplus extern "C" { #endif extern int DSDPConeSetUp(DSDPCone,DSDPVec); extern int DSDPConeSetUp2(DSDPCone, DSDPVec, DSDPSchurMat); extern int DSDPConeGetDimension(DSDPCone,double*); extern int DSDPConeSparsityInSchurMat(DSDPCone, int,int[],int); extern int DSDPConeComputeS(DSDPCone,DSDPVec,DSDPDualFactorMatrix,DSDPTruth *); extern int DSDPConeInvertS(DSDPCone); extern int DSDPConeComputeHessian(DSDPCone,double,DSDPSchurMat,DSDPVec,DSDPVec); extern int DSDPConeMultiplyAdd(DSDPCone,double,DSDPVec,DSDPVec,DSDPVec); extern int DSDPConeComputeRHS(DSDPCone,double,DSDPVec,DSDPVec,DSDPVec); extern int DSDPConeComputeMaxStepLength(DSDPCone,DSDPVec,DSDPDualFactorMatrix,double*); extern int DSDPConeComputeLogSDeterminant(DSDPCone,double*,double*); extern int DSDPConeComputeX(DSDPCone,double,DSDPVec,DSDPVec,DSDPVec,double*); extern int DSDPConeSetXMaker(DSDPCone,double,DSDPVec,DSDPVec); extern int DSDPConeView(DSDPCone); extern int DSDPConeMonitor(DSDPCone,int); extern int DSDPConeDestroy(DSDPCone*); extern int DSDPConeANorm2(DSDPCone,DSDPVec); extern int DSDPGetConeName(DSDPCone,char*,int); extern int DSDPConeSetData(DSDPCone*,struct DSDPCone_Ops*,void*); extern int DSDPConeInitialize(DSDPCone*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/solver/dsdpcone_impl.h0000644000175000017500000000233310326241002017062 0ustar twernertwerner#ifndef __DSDPCONE_H #define __DSDPCONE_H /*! \file dsdpcone_impl.h \brief Implementations of a cone (SDP,LP,...) must provide a structure of function pointers. */ #include "dsdpbasictypes.h" #include "dsdpvec.h" #include "dsdpschurmat.h" struct DSDPCone_Ops{ int id; int (*conesize)(void*,double*); int (*conesetup)(void*,DSDPVec); int (*conesetup2)(void*,DSDPVec,DSDPSchurMat); int (*conecomputes)(void*,DSDPVec,DSDPDualFactorMatrix,DSDPTruth*); int (*coneinverts)(void*); int (*conelogpotential)(void*,double*,double*); int (*conesetxmaker)(void*,double,DSDPVec,DSDPVec); int (*conecomputex)(void*,double,DSDPVec,DSDPVec,DSDPVec,double*); int (*conehessian)(void*,double,DSDPSchurMat,DSDPVec,DSDPVec); int (*conehmultiplyadd)(void*,double,DSDPVec,DSDPVec,DSDPVec); int (*conerhs)(void*,double,DSDPVec,DSDPVec,DSDPVec); int (*conemaxsteplength)(void*,DSDPVec,DSDPDualFactorMatrix,double*); int (*coneanorm2)(void*,DSDPVec); int (*conesparsity)(void*,int,int*,int[],int); int (*conemonitor)(void*,int); int (*conedestroy)(void*); int (*coneview)(void*); const char *name; }; extern int DSDPAddCone(DSDP,struct DSDPCone_Ops*, void*); extern int DSDPConeOpsInitialize(struct DSDPCone_Ops*); #endif DSDP5.8/src/solver/dsdpconverge.c0000644000175000017500000002324710326241002016727 0ustar twernertwerner#include "dsdp5.h" #include "dsdpconverge.h" /*! \file dsdpconverge.c \brief Monitor convergence. */ extern int DSDPGetConvergenceMonitor(DSDP, ConvergenceMonitor**); /*! \fn int DSDPDefaultConvergence(DSDP dsdp, void *ctx) \brief Check for Convergence. \param dsdp is the solver \param ctx is a pointer to a structure containing convergence parameters \sa DSDPSetGapTolerance() \sa DSDPSetStepTolerance() \ingroup DSDPConverge \note DSDP calls this routine before each iteration. */ #undef __FUNCT__ #define __FUNCT__ "DSDPCheckConvergence" int DSDPDefaultConvergence(DSDP dsdp,void *ctx){ ConvergenceMonitor *conv=(ConvergenceMonitor*)ctx; int info,i,iter; double mu,mu2; double rgap,rgap2,rgaptol=conv->rgaptol; double infeastol=0; double pnorm,dstep,pstep,steptol=conv->steptol,pnormtol=conv->pnormtol; double ppobj,ddobj, gap, dualbound=conv->dualbound; double res,np; DSDPTerminationReason reason; DSDPFunctionBegin; info = DSDPGetStepLengths(dsdp,&pstep,&dstep); DSDPCHKERR(info); info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info); info = DSDPGetIts(dsdp,&iter); DSDPCHKERR(info); info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info); info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info); info = DSDPGetR(dsdp,&res); DSDPCHKERR(info); info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info); info = DSDPGetDimension(dsdp,&np); DSDPCHKERR(info); info = DSDPStopReason(dsdp,&reason); DSDPCHKERR(info); info = DSDPGetRTolerance(dsdp,&infeastol); DSDPCHKERR(info); info = DSDPGetDualityGap(dsdp,&gap); DSDPCHKERR(info); rgap=(gap)/(1.0+fabs(ddobj)/2+fabs(ppobj)/2); rgap2=(mu*np)/(1.0+fabs(ddobj)/2+fabs(ppobj)/2); if (iter==0){ conv->history = DSDPHistory; for (i=0; ialpha[i] = 0.0; conv->gaphist[i] = 0.0; conv->infhist[i] = 0.0; } } if (iterhistory && iter>0){ conv->gaphist[iter-1]=(ppobj-ddobj); conv->infhist[iter-1]=res; } if ( 0==1 ){ } else if ( ddobj!=ddobj || pnorm < 0){ reason = DSDP_NUMERICAL_ERROR; DSDPLogInfo(0,2,"Stop due to Numerical Error\n"); } else if ( rgap <=rgaptol/1.01 && res<=infeastol ){ if (pnorm>pnormtol){ mu2=gap/np; info = DSDPSetBarrierParameter(dsdp,mu2); DSDPCHKERR(info); } else { reason = DSDP_CONVERGED; DSDPLogInfo(0,2,"DSDP Converged: Relative Duality Gap %4.2e < %4.2e, Primal Feasible, Dual Infeasiblity %4.2e < %4.2e \n",rgap,rgaptol,res,infeastol); } } else if ( rgap2 <=rgaptol/100 && rgap<0.01){ reason = DSDP_CONVERGED; DSDPLogInfo(0,2,"DSDP Converged: Relative Duality Gap %4.2e < %4.2e. Check Feasiblity \n",rgap,rgaptol); } else if ( ddobj > dualbound && res<=infeastol){ reason = DSDP_UPPERBOUND; DSDPLogInfo(0,2,"DSDP Converged: Dual Objective: %4.2e > upper bound %4.2e\n",pnorm,dualbound); } else if ( iter > 5 && dstep 0) conv->rgaptol = gaptol; DSDPLogInfo(0,2,"Set Relative Gap Tolerance: %4.4e\n",gaptol); DSDPFunctionReturn(0); } /*! \fn int DSDPGetGapTolerance(DSDP dsdp, double *gaptol) \brief Get the termination tolerance. \param dsdp is the solver \param *gaptol will be set to the termination tolerance \sa DSDPGetDualityGap() \sa DSDPSetGapTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetGapTolerance" int DSDPGetGapTolerance(DSDP dsdp,double *gaptol){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); DSDPFunctionBegin; *gaptol=conv->rgaptol; DSDPFunctionReturn(0); } /*! \fn int DSDPSetPNormTolerance(DSDP dsdp, double ptol) \brief Terminate the solver when the relative duality gap is suffiently small and the PNorm is less than this quantity. Smaller values imply the final solution will be nearer to the central path. \param dsdp is the solver \param ptol is the tolerance, (>0, default is very big) \sa DSDPGetPnorm() \sa DSDPGetPNormTolerance() \sa DSDPSetGapTolerance() \sa DSDP_CONVERGED \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetPNormTolerance" int DSDPSetPNormTolerance(DSDP dsdp,double ptol){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); if (ptol > 0) conv->pnormtol = ptol; DSDPLogInfo(0,2,"Set Relative PNorm Tolerance: %4.4e\n",ptol); DSDPFunctionReturn(0); } /*! \fn int DSDPGetPNormTolerance(DSDP dsdp, double *ptol) \brief Get the termination tolerance. \param dsdp is the solver \param *ptol will be set to the termination tolerance \sa DSDPGetPnorm() \sa DSDPSetPNormTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPNormTolerance" int DSDPGetPNormTolerance(DSDP dsdp,double *ptol){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); DSDPFunctionBegin; *ptol=conv->pnormtol; DSDPFunctionReturn(0); } /*! \fn int DSDPSetDualBound(DSDP dsdp, double dbound) \brief Terminate the solver if the objective value in (DD) is greater than this tolerance. This parameter is helpful in branch and bound applictions. \param dsdp is the solver \param dbound is the bound \sa DSDPGetDualBound() \sa DSDPGetDDObjective() \sa DSDP_UPPERBOUND \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetDualBound" int DSDPSetDualBound(DSDP dsdp,double dbound){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); conv->dualbound=dbound; DSDPLogInfo(0,2,"Set DualBound of %4.4e \n",dbound); DSDPFunctionReturn(0); } /*! \fn int DSDPGetDualBound(DSDP dsdp, double *dbound) \brief Get the termination parameter. \param dsdp is the solver \param *dbound is a bound on (DD) \sa DSDPSetDualBound() \sa DSDPGetDDObjective() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetDualBound" int DSDPGetDualBound(DSDP dsdp,double *dbound){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); *dbound=conv->dualbound; DSDPFunctionReturn(0); } /*! \fn int DSDPSetStepTolerance(DSDP dsdp, double steptol) \brief Terminate the solver if the step length in (DD) is below this tolerance This heuristic will only be applied when the objective values in (PP) and (DD) match to three significant digits. \param dsdp is the solver \param steptol is the tolerance \sa DSDPGetStepTolerance() \sa DSDPGetStepLengths() \sa DSDP_SMALL_STEPS \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetStepTolerance" int DSDPSetStepTolerance(DSDP dsdp,double steptol){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); if (steptol > 0) conv->steptol = steptol; DSDPFunctionReturn(0); } /*! \fn int DSDPGetStepTolerance(DSDP dsdp, double *steptol) \brief Get the current tolerance. \param dsdp is the solver \param *steptol will be set to the current tolerance \sa DSDPSetStepTolerance() \sa DSDPGetStepLengths() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetStepTolerance" int DSDPGetStepTolerance(DSDP dsdp,double *steptol){ int info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); *steptol=conv->steptol; DSDPFunctionReturn(0); } /*! \fn int DSDPGetRHistory(DSDP dsdp, double hist[], int length) \brief Copy a history of the infeasibility in (D) into an array Elememt i of the array will be set the the infeasibility in (D) at iteration i (unless i exceeds the length of the array) \param dsdp is the solver \param hist is an array \param length is the length of the array \sa DSDPGetR() \sa DSDPGetGapHistory() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetRHistory" int DSDPGetRHistory(DSDP dsdp, double hist[], int length){ int i,info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); for (i=0;iinfhist[i]; DSDPFunctionReturn(0); } /*! \fn int DSDPGetGapHistory(DSDP dsdp, double hist[], int length) \brief Copy a history of the duality gap into an array \param dsdp is the solver \param hist is an array \param length is the length of the array \sa DSDPGetDualityGap() \sa DSDPGetRHistory() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetGapHistory" int DSDPGetGapHistory(DSDP dsdp, double hist[], int length){ int i,info; ConvergenceMonitor *conv; DSDPFunctionBegin; info=DSDPGetConvergenceMonitor(dsdp,&conv); DSDPCHKERR(info); for (i=0;igaphist[i]; DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpcops.c0000644000175000017500000004773310326241002016071 0ustar twernertwerner#include "dsdp.h" #include "dsdpsys.h" /*! \file dsdpcops.c \brief Applies conic operations to each cone in the solver. */ #define DSDPCHKCONEERR(a,b); { if (b){ DSDPSETERR1(b,"Cone Number: %d,\n",a);} } 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; static int DSDPRegisterConeEvents(void); int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*, void*); int DSDPAddSchurRow(DSDP,int, DSDPVec); /* int DSDPIdentifySchurColumns(DSDP,int, int*, int*, int); */ #undef __FUNCT__ #define __FUNCT__ "DSDPZeroConeEvents" static int DSDPZeroConeEvents(){ DSDPFunctionBegin; 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; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRegisterConeEvents" static int DSDPRegisterConeEvents(){ DSDPFunctionBegin; DSDPEventLogRegister("Cone Setup 1&2",&ConeSetup); DSDPEventLogRegister("Cone Invert S",&ConeInvertS); DSDPEventLogRegister("Cone RHS",&ConeRHS); DSDPEventLogRegister("Cone Compute Newton Eq.",&ConeComputeH); DSDPEventLogRegister("Cone Newton Multiply-Add",&ConeHMultiplyAdd); DSDPEventLogRegister("Cone Max P Step Length",&ConeMaxPStep); DSDPEventLogRegister("Cone Compute and Factor SP",&ConeComputeSS); DSDPEventLogRegister("Cone Max D Step Length",&ConeMaxDStep); DSDPEventLogRegister("Cone Compute and Factor S",&ConeComputeS); DSDPEventLogRegister("Cone Potential",&ConePotential); DSDPEventLogRegister("Cone View",&ConeView); DSDPEventLogRegister("Cone Compute X",&ConeComputeX); DSDPEventLogRegister("Cone X Residuals",&ConeXEigs); DSDPEventLogRegister("Cone Destroy",&ConeDestroy); DSDPFunctionReturn(0); } /*! \fn int DSDPSetUpCones( DSDP dsdp); \brief Each cone should factor data or allocate internal data structures. \param dsdp the solver */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetUpCones" int DSDPSetUpCones(DSDP dsdp){ int info,kk; DSDPVec yy0=dsdp->y; DSDPFunctionBegin; info=DSDPRegisterConeEvents(); DSDPEventLogBegin(ConeSetup); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeSetUp(dsdp->K[kk].cone,yy0);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeSetup); DSDPFunctionReturn(0); } /*! \fn int DSDPSetUpCones2( DSDP dsdp, DSDPVec yy0, DSDPSchurMat M); \brief Each cone should allocate its data structures . \param dsdp the solver \param yy0 variable vector \param M Shur Matrix */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetUpCones2" int DSDPSetUpCones2(DSDP dsdp, DSDPVec yy0, DSDPSchurMat M){ int info,kk; DSDPFunctionBegin; DSDPEventLogBegin(ConeSetup); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeSetUp2(dsdp->K[kk].cone,yy0,M);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeSetup); DSDPFunctionReturn(0); } /*! \fn int DSDPDestroyCones( DSDP dsdp); \brief Each cone shoudl free its data structures. \param dsdp the solver */ #undef __FUNCT__ #define __FUNCT__ "DSDPDestroyCones" int DSDPDestroyCones(DSDP dsdp){ int info,kk,ncones=dsdp->ncones; DSDPFunctionBegin; DSDPEventLogBegin(ConeDestroy); for (kk=ncones-1;kk>=0; kk--){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeDestroy(&dsdp->K[kk].cone);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); info=DSDPConeInitialize(&dsdp->K[kk].cone);DSDPCHKCONEERR(kk,info); dsdp->ncones--; } if (dsdp->maxcones>0){ DSDPFREE(&dsdp->K,&info);DSDPCHKERR(info); dsdp->K=0; dsdp->maxcones=0; } DSDPEventLogEnd(ConeDestroy); info=DSDPZeroConeEvents();DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeHessian( DSDP dsdp , DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2); \brief Compute the Schur complement, or Gram, matrix for each cone. \param dsdp the solver \param M matrix \param vrhs1 gradient of objective (b) \param vrhs2 gradient of barrier */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeHessian" int DSDPComputeHessian( DSDP dsdp , DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ int info,kk; double r; DSDPFunctionBegin; DSDPEventLogBegin(ConeComputeH); dsdp->schurmu=dsdp->mutarget; info=DSDPVecGetR(dsdp->y,&r);DSDPCHKERR(info); info=DSDPSchurMatSetR(dsdp->M,r);DSDPCHKERR(info); info=DSDPSchurMatZeroEntries(M);DSDPCHKERR(info); info=DSDPVecZero(vrhs1);DSDPCHKERR(info); info=DSDPVecZero(vrhs2);DSDPCHKERR(info); info=DSDPVecZero(M.schur->rhs3);DSDPCHKERR(info); info=DSDPObjectiveGH(dsdp,M,vrhs1); DSDPCHKERR(info); for (kk=dsdp->ncones-1;kk>=0;kk--){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeComputeHessian(dsdp->K[kk].cone,dsdp->schurmu,M,vrhs1,vrhs2);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } info=DSDPSchurMatAssemble(M);DSDPCHKERR(info); /* DSDPSchurMatView(M); */ info=DSDPSchurMatReducePVec(M,vrhs1);DSDPCHKERR(info); info=DSDPSchurMatReducePVec(M,vrhs2);DSDPCHKERR(info); info=DSDPSchurMatReducePVec(M,M.schur->rhs3);DSDPCHKERR(info); if (0 && dsdp->UsePenalty==DSDPNever){ info=DSDPVecAXPY(1.0,M.schur->rhs3,vrhs2);DSDPCHKERR(info); info=DSDPVecZero(M.schur->rhs3);DSDPCHKERR(info); info=DSDPVecZero(M.schur->dy3);DSDPCHKERR(info); info=DSDPVecSetR(vrhs1,0);DSDPCHKERR(info); info=DSDPVecSetR(vrhs2,r);DSDPCHKERR(info); } DSDPEventLogEnd(ConeComputeH); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPHessianMultiplyAdd" /*! \fn int DSDPHessianMultiplyAdd( DSDP dsdp , DSDPVec v, DSDPVec vv); \brief Add the product of Schur matrix with v. \param dsdp the solver \param v input vector. \param vv product gradient of barrier */ int DSDPHessianMultiplyAdd( DSDP dsdp , DSDPVec v, DSDPVec vv){ int info,kk; DSDPVec vrow=dsdp->sles->BR; DSDPFunctionBegin; DSDPEventLogBegin(ConeHMultiplyAdd); info=DSDPSchurMatRowScaling(dsdp->M,vrow);DSDPCHKERR(info); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeMultiplyAdd(dsdp->K[kk].cone,dsdp->schurmu,vrow,v,vv);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } info=DSDPSchurMatReducePVec(dsdp->M,vv);DSDPCHKERR(info); DSDPEventLogEnd(ConeHMultiplyAdd); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeG" /*! \fn int DSDPComputeG( DSDP dsdp , DSDPVec vt, DSDPVec vrhs1, DSDPVec vrhs2); \param dsdp the solver \param vt scaling for each element in the next two vectors \param vrhs1 scaled gradient of the objective function \param vrhs2 scaled gradient of the barrier function \brief Compute the gradient of the barrier for each cone. */ int DSDPComputeG( DSDP dsdp , DSDPVec vt, DSDPVec vrhs1, DSDPVec vrhs2){ int info,kk; double r; DSDPFunctionBegin; DSDPEventLogBegin(ConeRHS); info=DSDPVecZero(vrhs1);DSDPCHKERR(info); info=DSDPVecZero(vrhs2);DSDPCHKERR(info); info=DSDPVecGetR(dsdp->y,&r);DSDPCHKERR(info); info=DSDPSchurMatSetR(dsdp->M,r);DSDPCHKERR(info); info=DSDPSchurMatRowScaling(dsdp->M,vt);DSDPCHKERR(info); info=DSDPObjectiveGH(dsdp,dsdp->M,vrhs1); DSDPCHKERR(info); if (0 && r==0){info=DSDPVecSetR(vrhs1,0);info=DSDPVecSetR(vrhs2,0);} /* info=DSDPVecScale(1.0/dsdp->schurmu,vrhs1); DSDPCHKERR(info); */ for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeComputeRHS(dsdp->K[kk].cone,dsdp->schurmu,vt,vrhs1,vrhs2);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeRHS); info=DSDPSchurMatReducePVec(dsdp->M,vrhs1);DSDPCHKERR(info); info=DSDPSchurMatReducePVec(dsdp->M,vrhs2);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeANorm2" /*! \fn int DSDPComputeANorm2( DSDP dsdp , DSDPVec Anorm2); \param dsdp the solver \param Anorm2 norm of data corresponding to each variable y. \brief Compute norm of A and C. */ int DSDPComputeANorm2( DSDP dsdp , DSDPVec Anorm2){ int info,kk; DSDPFunctionBegin; for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeANorm2(dsdp->K[kk].cone,Anorm2);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPFunctionReturn(0); } /*! \fn int DSDPComputeSS(DSDP dsdp, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite); \brief Compute the dual variables S in each cone. \param dsdp the solver \param Y variables \param flag primal or dual structure \param ispsdefinite DSDP_TRUE if a member of the cone, DSDP_FALSE otherwise. */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeSS" int DSDPComputeSS(DSDP dsdp, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite){ int info,kk; DSDPTruth psd=DSDP_TRUE; DSDPFunctionBegin; if (flag==DUAL_FACTOR){ DSDPEventLogBegin(ConeComputeS); } else if (flag==PRIMAL_FACTOR){ DSDPEventLogBegin(ConeComputeSS); } for (kk=dsdp->ncones-1; kk>=0 && psd==DSDP_TRUE;kk--){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeComputeS(dsdp->K[kk].cone,Y,flag,&psd); DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } *ispsdefinite=psd; if (flag==DUAL_FACTOR){ DSDPEventLogEnd(ConeComputeS); } else if (flag==PRIMAL_FACTOR){ DSDPEventLogEnd(ConeComputeSS); } DSDPFunctionReturn(0); } /*! \fn int DSDPInvertS(DSDP dsdp); \brief Invert the S variables in each cone. \param dsdp the solver \sa DSDPComputeSS() */ #undef __FUNCT__ #define __FUNCT__ "DSDPInvertS" int DSDPInvertS(DSDP dsdp){ int info,kk; DSDPFunctionBegin; DSDPEventLogBegin(ConeInvertS); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeInvertS(dsdp->K[kk].cone); DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeInvertS); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeMaxStepLength(DSDP dsdp, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength); \brief Compute the maximum step length for the given step direction. \param dsdp the solver \param DY step direction \param flag primal or dual structure \param maxsteplength the minumum of maximums on each cone. \sa DSDPComputeSS() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeMaxStepLength" int DSDPComputeMaxStepLength(DSDP dsdp, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){ int info,kk; double msteplength=1.0e30,conesteplength; DSDPFunctionBegin; if (flag==DUAL_FACTOR){ DSDPEventLogBegin(ConeMaxDStep); } else if (flag==PRIMAL_FACTOR){ DSDPEventLogBegin(ConeMaxPStep); } for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); conesteplength=1.0e20; info=DSDPConeComputeMaxStepLength(dsdp->K[kk].cone,DY,flag,&conesteplength);DSDPCHKCONEERR(kk,info); msteplength=DSDPMin(msteplength,conesteplength); DSDPEventLogEnd(dsdp->K[kk].coneid); } *maxsteplength=msteplength; if (flag==DUAL_FACTOR){ DSDPEventLogEnd(ConeMaxDStep); } else if (flag==PRIMAL_FACTOR){ DSDPEventLogEnd(ConeMaxPStep); } DSDPFunctionReturn(0); } /*! \fn int DSDPPassXVectors(DSDP dsdp, double mu, DSDPVec Y, DSDPVec DY); \brief Pass the information needed to compute the variables X in each cone but do not compute X. \param dsdp the solver \param mu barrier parameter \param Y input y variables \param DY input step direction \sa DSDPComputeXVariables() */ #undef __FUNCT__ #define __FUNCT__ "DSDPPassXVectors" int DSDPPassXVectors(DSDP dsdp, double mu, DSDPVec Y, DSDPVec DY){ int info,kk; DSDPFunctionBegin; for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeSetXMaker(dsdp->K[kk].cone,mu,Y,DY);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPFunctionReturn(0); } /*! \fn int DSDPGetConicDimension(DSDP dsdp, double *n); \brief Get the total dimension of the cones. \param dsdp the solver \param n dimension */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetConicDimension" int DSDPGetConicDimension(DSDP dsdp, double *n){ int info,kk; double nn,nnn=0; DSDPFunctionBegin; for (kk=0;kkncones;kk++){ nn=0; info=DSDPConeGetDimension(dsdp->K[kk].cone,&nn);DSDPCHKCONEERR(kk,info); nnn+=nn; } *n=nnn; DSDPFunctionReturn(0); } /*! \fn int DSDPViewCones( DSDP dsdp); \brief Each cone should print its state. \param dsdp the solver */ #undef __FUNCT__ #define __FUNCT__ "DSDPViewCones" int DSDPViewCones(DSDP dsdp){ int info,kk; DSDPFunctionBegin; DSDPEventLogBegin(ConeView); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeView(dsdp->K[kk].cone);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeView); DSDPFunctionReturn(0); } /*! \fn int DSDPMonitorCones( DSDP dsdp, int tag); \brief This routine is called once per iteration. \param dsdp the solver \param tag allow for multiple monitors The cone can print statistics, visualize data, terminate solver, or whatever it wants. */ #undef __FUNCT__ #define __FUNCT__ "DSDPMonitorCones" int DSDPMonitorCones(DSDP dsdp,int tag){ int info,kk; DSDPFunctionBegin; DSDPEventLogBegin(ConeView); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); info=DSDPConeMonitor(dsdp->K[kk].cone,tag);DSDPCHKCONEERR(kk,info); DSDPEventLogEnd(dsdp->K[kk].coneid); } DSDPEventLogEnd(ConeView); DSDPFunctionReturn(0); } /*! \fn int DSDPSchurSparsity( DSDP dsdp, int row, int rnnz[], int m); \brief Each cone should print its state. \param dsdp the solver \param row corresponding to the variable y. \param rnnz nonzeros indicate a nonzero in the Shur matrix at that column. \param m size of Schur matrix and the arrow. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSparsityInSchurMat" int DSDPSchurSparsity(DSDP dsdp, int row, int rnnz[], int m){ int info,kk; DSDPFunctionBegin; for (kk=0;kkncones;kk++){ /* DSDPEventLogBegin(dsdp->K[kk].coneid); */ info=DSDPConeSparsityInSchurMat(dsdp->K[kk].cone,row,rnnz,m+2);DSDPCHKCONEERR(kk,info); /* DSDPEventLogEnd(dsdp->K[kk].coneid); */ } DSDPFunctionReturn(0); } /*! \fn int DSDPComputeLogSDeterminant(DSDP dsdp, double *logdet); \brief Compute the logarithmic barrier function for the dual varialbe S. \param dsdp the solver \param logdet evaluated barrier function \sa DSDPComputeSS() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeLogSDeterminant" int DSDPComputeLogSDeterminant(DSDP dsdp, double *logdet){ int info,kk; double coneobjective,conepotential,llogdet=0; DSDPFunctionBegin; DSDPEventLogBegin(ConePotential); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); coneobjective=0;conepotential=0; info=DSDPConeComputeLogSDeterminant(dsdp->K[kk].cone,&coneobjective,&conepotential);DSDPCHKCONEERR(kk,info); llogdet+=conepotential; DSDPEventLogEnd(dsdp->K[kk].coneid); } *logdet=llogdet; DSDPEventLogEnd(ConePotential); DSDPFunctionReturn(0); } /*! \fn int DSDPSetCone( DSDP dsdp, DSDPCone tcone); \brief Pass a cone to the DSDP solver. \param dsdp the solver \param tcone a cone object. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetCone" int DSDPSetCone(DSDP dsdp,DSDPCone tcone){ int info,i,tc; char conename[100]; DCone *ccones; DSDPFunctionBegin; if (dsdp->ncones>=dsdp->maxcones){ tc=2*dsdp->maxcones+4; DSDPCALLOC2(&ccones,DCone,tc,&info);DSDPCHKERR(info); for (i=0;incones;i++){ccones[i].cone=dsdp->K[i].cone;} for (i=0;incones;i++){ccones[i].coneid=dsdp->K[i].coneid;} DSDPFREE(&dsdp->K,&info);DSDPCHKERR(info); dsdp->K=ccones; dsdp->maxcones=tc; } info=DSDPGetConeName(tcone,conename,100);DSDPCHKERR(info); DSDPEventLogRegister(conename,&tc); dsdp->K[dsdp->ncones].cone=tcone; dsdp->K[dsdp->ncones].coneid=tc; dsdp->ncones++; DSDPFunctionReturn(0); } /*! \fn int DSDPAddCone(DSDP dsdp,struct DSDPCone_Ops* dsdpops, void* dsdpcone); \param dsdp the solver \param dsdpops address of a structure with function pointers \param dsdpcone address of a cone structure \brief Apply DSDP to a conic structure. DSDP operates on cones such as the semidefinite cone and nonnegative orthant. Given variables y from the solver, each cone implements operations such as computing S, maximum step length, computing the Newton matrix, and computing the Hessian. Each operation is well defined by the dual-scaling algorithm. A cone that implements these operations can be added to the DSDP solver. \sa DSDPCreateSDPCone() \sa DSDPCreateLPCone() \sa DSDPCreateBCone() \todo Add SOCP cone and application-specific cones. */ #undef __FUNCT__ #define __FUNCT__ "DSDPAddCone" int DSDPAddCone(DSDP dsdp,struct DSDPCone_Ops* dsdpops, void* dsdpcone){ int info; DSDPCone K; DSDPFunctionBegin; info=DSDPConeInitialize(&K); DSDPCHKERR(info); info=DSDPConeSetData(&K,dsdpops,dsdpcone); DSDPCHKERR(info); info=DSDPSetCone(dsdp,K); DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPSetSchurMatOps(DSDP dsdp,struct DSDPSchurMat_Ops* sops, void* mdata); \param dsdp the solver \param sops address of a structure with function pointers \param mdata address of a matrix object \brief Set the Schur complement matrix The step direction in DSDP is the solution to a set of linear equations. The cones used by DSDP compute the elements of the matrix and the right-hand side vectors. Any matrix that implements the Schur complement matrix interface can be used by DSDP. In addition to factoring a matrix and solving it, this interface also provides matrix assembly routines for the cones. \sa DSDPAddCone() \todo Use SCALAPACK to assemble, factor, and solve the matrix in parallel. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetSchurMatOps" int DSDPSetSchurMatOps(DSDP dsdp,struct DSDPSchurMat_Ops* sops, void* mdata){ int info; DSDPFunctionBegin; info=DSDPSchurMatSetData(&dsdp->M,sops,mdata);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPAddSchurRow( DSDP dsdp, int row, DSDPVec R); \brief Add a row to the Schur matrix. \param dsdp the solver \param row corresponding to which variable y. \param R the elements of the row. This routine is called by the conic routines that compute the Hessian matrix. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetSchurRow" int DSDPAddSchurRow(DSDP dsdp,int row, DSDPVec R){ int info; DSDPFunctionBegin; info=DSDPSchurMatAddRow(dsdp->M,row,1.0,R);DSDPCHKERR(info); DSDPFunctionReturn(0); } /* #undef __FUNCT__ #define __FUNCT__ "DSDPIdentifySchurColumns" int DSDPIdentifySchurColumns(DSDP dsdp,int row, int *mcol, int *ncols, int m){ DSDPFunctionBegin; int info; DSDPVec V; info=DSDPSchurMatRowColumnScaling(dsdp->M,row,V,ncols); DSDPCHKERR(info); DSDPFunctionReturn(1); } */ /*! \fn int DSDPComputeXVariables(DSDP dsdp, double xmakermu, DSDPVec xmakery, DSDPVec xmakerdy, DSDPVec AX, double *tracexs); \brief Compute the X variables in each cone. \param dsdp the solver \param xmakermu barrier parameter \param xmakery input y variables \param xmakerdy input step direction \param AX output product of X and the data \param tracexs ouput inner product of X and S. */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeXVariables" int DSDPComputeXVariables(DSDP dsdp, double xmakermu, DSDPVec xmakery, DSDPVec xmakerdy, DSDPVec AX, double *tracexs){ int kk,info; double ttracexs=0,tttracexs=0,tracex; DSDPFunctionBegin; DSDPEventLogBegin(ConeComputeX); info=DSDPVecZero(AX);DSDPCHKERR(info); for (kk=0;kkncones;kk++){ DSDPEventLogBegin(dsdp->K[kk].coneid); tttracexs=0; info=DSDPConeComputeX(dsdp->K[kk].cone,xmakermu,xmakery,xmakerdy,AX,&tttracexs);DSDPCHKCONEERR(kk,info); ttracexs+=tttracexs; DSDPEventLogEnd(dsdp->K[kk].coneid); } info=DSDPVecGetR(AX,&tracex); DSDPCHKERR(info); DSDPLogInfo(0,2,"Trace(X): %4.2e\n",dsdp->tracex); info=DSDPVecAXPY(-1.0,dsdp->b,AX); DSDPCHKERR(info); info=DSDPComputeFixedYX(dsdp->M,AX); DSDPCHKERR(info); *tracexs=ttracexs; info=DSDPVecSetR(AX,tracex); DSDPCHKERR(info); DSDPEventLogEnd(ConeComputeX); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdp.h0000644000175000017500000001706410326241002015203 0ustar twernertwerner#ifndef __DSDP_H #define __DSDP_H #include "dsdpbasictypes.h" #include "dsdpvec.h" #include "dsdpschurmat.h" #include "dsdpcone.h" #include "dsdpconverge.h" /*! \file dsdp.h \brief Internal data structure for the DSDP solver */ /*! \typedef struct LUBounds_C* YBoundCone; \brief Cone with bounds on variables y. */ typedef struct LUBounds_C* YBoundCone; /*! \typedef typedef struct RDCone* RRCone; \brief Cone with nonnegativity on variable r. */ typedef struct RDCone* RRCone; #define MAX_DSDP_MONITORS 5 #define MAX_XMAKERS 4 typedef struct { DSDPVec y; DSDPVec dy; double mu; double pstep; DSDPVec rhs; } XMaker; typedef struct { /* This information is needed to compute the step Direction */ DSDPVec y; double zbar; double mutarget; double logdet; } DSDPState; typedef struct { int (*f)(void*); void * ptr; }DRoutine; typedef struct { int (*monitor)(struct DSDP_C *, void*); void *monitorctx; } DMonitor; typedef struct { DSDPCone cone; int coneid; } DCone; /*! \struct DSDP_C dsdp.h "src/solver/dsdp.h" \brief Internal structures for the DSDP solver. \sa DSDP */ struct DSDP_C{ DSDPCG *sles; int slestype; double schurmu; DSDPSchurMat M; double Mshift; double maxschurshift; int ncones,maxcones; DCone* K; int keyid; int solvetime,cgtime,ptime,dtime,ctime; int reuseM; DSDPTruth goty0; DSDPTruth setupcalled; int m; /* number of constraints */ double np; /* Dimension of full variable matrix */ int itnow; /* current iterate */ int maxiter; /* Maximum number of iterates */ double pobj; /* current primal objective value - use duality gap */ double ppobj; /* current primal objetive value - evaluate P */ double dobj,ddobj; /* the current dual objective value */ double pstep,dstep; /* current primal and dual step lengths */ double dualitygap; double mutarget; double mu,muold,mu0; /* The current mu */ double rho,potential,logdet,rhon; double pnorm; /* the current value of ||P|| */ double maxtrustradius; double cnorm,anorm,bnorm; double tracex,tracexs; double rgap; double pstepold; DSDPVec y; /* dual variables */ DSDPVec y0; /* initial dual variables */ DSDPVec ytemp; /* temporary dual variables */ DSDPVec dy1; /* search direction 1 affine direction */ DSDPVec dy2; /* search direction 2 centering direction */ DSDPVec dy; /* total search direction = constant*dy1-dy2 */ DSDPVec rhs1; /* objective vector b to determine step direction */ DSDPVec rhs2; /* barrier vector A(S^{-1}) to determine step direction */ DSDPVec rhs; /* right-hand side of linear system */ DSDPVec rhstemp;/* temporary rhs vector */ DSDPVec b; /* dual objective vector */ /* Multiple of identity matrix added to dual */ double r; int rflag; DSDPPenalty UsePenalty; RRCone rcone; DSDPTruth usefixedrho; /* True if fixed rho used. */ XMaker xmaker[MAX_XMAKERS]; /* step direction used to create X */ DSDPVec xmakerrhs; YBoundCone ybcone; double pinfeas; /* Infeasible in P indirectly -- neglect numerical errors */ double perror; /* Infeasible in P computed directly */ DSDPSolutionType pdfeasible; double dinfeastol; /* Parameter: Classify (D) as feasible */ double pinfeastol; /* Parameter: Classify (P) as feasible */ ConvergenceMonitor conv; DSDPTerminationReason reason; DMonitor dmonitor[MAX_DSDP_MONITORS]; int nmonitors; DRoutine droutine[10]; int ndroutines; }; typedef struct DSDP_C PD_DSDP; #define DSDPKEY 5432 #define DSDPValid(a) {if (!(a)||((a)->keyid!=DSDPKEY)){ DSDPSETERR(101,"DSDPERROR: Invalid DSDP object\n");}} #include "dsdpbasictypes.h" extern int DSDPCreateLUBoundsCone(DSDP, YBoundCone*); extern int BoundYConeSetBounds(YBoundCone, double, double); extern int BoundYConeGetBounds(YBoundCone, double*, double*); extern int BoundYConeAddX(YBoundCone,double,DSDPVec,DSDPVec,DSDPVec,double*); extern int BoundYConeAddS(YBoundCone,DSDPVec,DSDPVec); #ifdef __cplusplus extern "C" { #endif extern int DSDPComputeObjective(DSDP, DSDPVec, double *); extern int DSDPComputeDY(DSDP, double, DSDPVec, double*); extern int DSDPComputeNewY(DSDP, double, DSDPVec); extern int DSDPComputeRHS(DSDP, double, DSDPVec); extern int DSDPComputePDY1(DSDP,double,DSDPVec); extern int DSDPComputePDY(DSDP, double, DSDPVec, double*); extern int DSDPComputePY(DSDP,double,DSDPVec); extern int DSDPComputeG(DSDP, DSDPVec,DSDPVec,DSDPVec); extern int DSDPComputePNorm(DSDP, double,DSDPVec,double*); extern int DSDPComputeDualityGap(DSDP, double, double*); extern int DSDPSaveYForX(DSDP, double, double); extern int DSDPSetY(DSDP,double,double,DSDPVec); extern int DSDPComputePotential(DSDP, DSDPVec, double,double*); extern int DSDPComputePotential2(DSDP, DSDPVec, double, double, double*); extern int DSDPSetRR(DSDP,double); extern int DSDPGetRR(DSDP,double*); extern int DSDPGetMaxYElement(DSDP,double*); extern int DSDPSolveDynamicRho(DSDP); extern int DSDPRefineStepDirection(DSDP,DSDPVec, DSDPVec); /* Cone operations */ extern int DSDPSetUpCones(DSDP); extern int DSDPSetUpCones2(DSDP, DSDPVec, DSDPSchurMat); extern int DSDPSchurSparsity(DSDP, int, int[], int); extern int DSDPComputeSS(DSDP, DSDPVec, DSDPDualFactorMatrix, DSDPTruth*); extern int DSDPInvertS(DSDP); extern int DSDPComputeHessian( DSDP, DSDPSchurMat, DSDPVec, DSDPVec); extern int DSDPHessianMultiplyAdd( DSDP, DSDPVec, DSDPVec); extern int DSDPComputeMaxStepLength(DSDP, DSDPVec, DSDPDualFactorMatrix, double*); extern int DSDPComputeLogSDeterminant(DSDP, double*); extern int DSDPComputeANorm2(DSDP,DSDPVec); extern int DSDPViewCones(DSDP); extern int DSDPMonitorCones(DSDP,int); extern int DSDPDestroyCones(DSDP); extern int DSDPPassXVectors(DSDP,double,DSDPVec,DSDPVec); extern int DSDPComputeXVariables(DSDP,double,DSDPVec,DSDPVec,DSDPVec,double*); extern int DSDPGetConicDimension(DSDP,double*); extern int DSDPSchurSparsity(DSDP, int, int[], int); extern int DSDPCGSolve(DSDP,DSDPSchurMat,DSDPVec,DSDPVec,double,DSDPTruth*); extern int DSDPComputeDualStepDirection(DSDP, double, DSDPVec); extern int DSDPComputeDualStepDirections(DSDP); extern int DSDPSetCone(DSDP,DSDPCone); extern int DSDPScaleData(DSDP); extern int DSDPComputeDataNorms(DSDP); extern int DSDPTakeDown(DSDP); extern int DSDPSetDefaultStatistics(DSDP); extern int DSDPSetDefaultParameters(DSDP); extern int DSDPSetDefaultMonitors(DSDP); /* DSDP subroutines */ extern int DSDPInitializeVariables(DSDP); extern int DSDPObjectiveGH( DSDP, DSDPSchurMat, DSDPVec); extern int DSDPCheckForUnboundedObjective(DSDP, DSDPTruth*); extern int DSDPCheckConvergence(DSDP,DSDPTerminationReason *); extern int DSDPMonitor(DSDP); extern int DSDPPrintStats(DSDP, void*); extern int DSDPPrintStatsFile(DSDP, void*); extern int DSDPGetSchurMatrix(DSDP,DSDPSchurMat*); #ifdef __cplusplus } #endif extern int DSDPAddRCone(DSDP,RRCone*); extern int RConeSetType(RRCone, DSDPPenalty); extern int RConeGetRX(RRCone, double*); extern int DSDPGetConvergenceMonitor(DSDP, ConvergenceMonitor**); extern int DSDPDefaultConvergence(DSDP,void *); extern int DSDPSetDefaultSchurMatrixStructure(DSDP); extern int DSDPFixedVariablesNorm(DSDPSchurMat,DSDPVec); extern int DSDPComputeFixedYX(DSDPSchurMat,DSDPVec); extern int DSDPAddBCone(DSDP,DSDPVec,double); #endif DSDP5.8/src/solver/dsdpobjcone.c0000644000175000017500000002054210326241002016531 0ustar twernertwerner#include "dsdpcone_impl.h" #include "dsdpsys.h" /*! \file dsdpobjcone.c \brief Apply a constraint that the objective solution (D) is greater than some lower bound. */ typedef struct { DSDPVec b,bb,T; double dmin; double pss,dss; DSDP dsdp; DSDPTruth useit; } BDCone; static int BComputeS(BDCone *K, DSDPVec v, double *ss){ int info; DSDPFunctionBegin; info=DSDPVecDot(K->bb,v,ss);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRHessian" static int DSDPRHessian( void *dspcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ BDCone *K=(BDCone*)dspcone; double bb,dd,ss=K->dss; int info,i,m,ncols; DSDPVec T=K->T,b=K->bb; DSDPFunctionBegin; if (K->useit){ info=DSDPVecGetSize(b,&m);DSDPCHKERR(info); for (i=0;idss; int info,i,m; DSDPVec b=K->bb; DSDPFunctionBegin; if (K->useit){ info=DSDPVecGetSize(b,&m);DSDPCHKERR(info); for (i=0;ib,K->bb);DSDPCHKERR(info); info=DSDPVecSetC(K->bb,K->dmin);DSDPCHKERR(info); info=DSDPVecSetR(K->bb,-1.0);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetupBCone2" static int DSDPSetupBCone2(void* dspcone, DSDPVec y, DSDPSchurMat M){ BDCone *K=(BDCone*)dspcone; int info; DSDPFunctionBegin; info=DSDPVecDuplicate(K->b,&K->T);DSDPCHKERR(info); info=DSDPVecDuplicate(K->b,&K->bb);DSDPCHKERR(info); info=DSDPSetDRData(K);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDestroyBCone" static int DSDPDestroyBCone(void* dspcone){ BDCone *K=(BDCone*)dspcone; int info; DSDPFunctionBegin; info=DSDPVecDestroy(&K->T);DSDPCHKERR(info); info=DSDPVecDestroy(&K->bb);DSDPCHKERR(info); DSDPFREE(&dspcone,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRSize" static int DSDPRSize(void*dspcone,double*n){ DSDPFunctionBegin; *n=1.0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRSparsity" static int DSDPRSparsity(void*dspcone,int row, int *tnnz, int rnnz[], int m){ BDCone *K=(BDCone*)dspcone; int i,info;double dd; DSDPFunctionBegin; *tnnz=0; info=DSDPVecGetElement(K->b,row,&dd);DSDPCHKERR(info); if (dd){ for (i=0;ib,i,&dd);DSDPCHKERR(info); if (dd!=0){rnnz[i]++; (*tnnz)++;} } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRS" static int DSDPComputeRS(void *dspcone, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite){ BDCone *K=(BDCone*)dspcone; int info; double ss; DSDPFunctionBegin; info=BComputeS(K,Y,&ss);DSDPCHKERR(info); if (ss>0){ *ispsdefinite=DSDP_TRUE; } else { *ispsdefinite=DSDP_FALSE;} if (flag==DUAL_FACTOR){ K->dss=ss; } else { K->pss=ss;} DSDPLogInfo(0,2,"DOBJCone SS: %4.4e \n",ss); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPInvertRS" static int DSDPInvertRS(void *dspcone){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRStepLength" static int DSDPComputeRStepLength(void *dspcone, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){ BDCone *K=(BDCone*)dspcone; double ds,ss,rt=1.0e30; int info; DSDPFunctionBegin; info=BComputeS(K,DY,&ds);DSDPCHKERR(info); if (flag==DUAL_FACTOR){ ss=K->dss; } else { ss=K->pss;} if (ds<0) rt=-ss/ds; if (K->useit){ *maxsteplength=rt; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetX" static int DSDPSetX( void *dspcone, double mu, DSDPVec y, DSDPVec dy){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRX" static int DSDPRX( void *dspcone, double mu, DSDPVec y, DSDPVec dy, DSDPVec AX,double*tracxs){ BDCone *K=(BDCone*)dspcone; double x,dss,ss=K->dss; int info; DSDPFunctionBegin; info=BComputeS(K,y,&ss);DSDPCHKERR(info); ss=1.0/ss; info=BComputeS(K,dy,&dss);DSDPCHKERR(info); x=mu*(ss+ss*dss*ss); DSDPLogInfo(0,2,"DOBJCone SS: %4.4e, RESIDUAL X: %4.4e\n",1.0/ss,x); if (fabs(x*ss)>1.0 && mu < 1) printf("Check Dual Min Bound\n"); info=DSDPVecAXPY(-x,K->bb,AX);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRLog" static int DSDPComputeRLog(void *dspcone, double *logobj, double *logdet){ BDCone *K=(BDCone*)dspcone; DSDPFunctionBegin; *logobj=0; *logdet=log(K->dss); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRANorm2" static int DSDPRANorm2(void *dspcone, DSDPVec Anorm2){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRMultiplyAdd" static int DSDPRMultiplyAdd(void *dspcone,double mu,DSDPVec vrow,DSDPVec vin,DSDPVec vout){ BDCone *K=(BDCone*)dspcone; DSDPVec T=K->T; int info; double dd,ss=K->dss; DSDPFunctionBegin; info=DSDPVecDot(vin,K->bb,&dd);DSDPCHKERR(info); dd=-mu*dd/(ss*ss); info=DSDPVecPointwiseMult(K->bb,vrow,T);DSDPCHKERR(info); info=DSDPVecAXPY(dd,T,vout);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRMonitor" static int DSDPRMonitor( void *dspcone, int tag){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static struct DSDPCone_Ops kops; static const char* matname="Dual Obj Cone"; #undef __FUNCT__ #define __FUNCT__ "BConeOperationsInitialize" static int BConeOperationsInitialize(struct DSDPCone_Ops* coneops){ int info; if (coneops==NULL) return 0; info=DSDPConeOpsInitialize(coneops); DSDPCHKERR(info); coneops->conehessian=DSDPRHessian; coneops->conesetup=DSDPSetupBCone; coneops->conesetup2=DSDPSetupBCone2; coneops->conedestroy=DSDPDestroyBCone; coneops->conecomputes=DSDPComputeRS; coneops->coneinverts=DSDPInvertRS; coneops->conecomputex=DSDPRX; coneops->conesetxmaker=DSDPSetX; coneops->conemaxsteplength=DSDPComputeRStepLength; coneops->conelogpotential=DSDPComputeRLog; coneops->conesize=DSDPRSize; coneops->conesparsity=DSDPRSparsity; coneops->coneanorm2=DSDPRANorm2; coneops->conemonitor=DSDPRMonitor; coneops->conehmultiplyadd=DSDPRMultiplyAdd; coneops->conerhs=DSDPRRHS; coneops->id=119; coneops->name=matname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPAddBCone" int DSDPAddBCone(DSDP dsdp, DSDPVec bb, double dmin){ BDCone *rcone; int info; DSDPFunctionBegin; info=BConeOperationsInitialize(&kops); DSDPCHKERR(info); DSDPCALLOC1(&rcone,BDCone,&info); DSDPCHKERR(info); rcone->b=bb; rcone->dmin=dmin; rcone->dsdp=dsdp; rcone->useit=DSDP_TRUE; info=DSDPAddCone(dsdp,&kops,(void*)rcone); DSDPCHKERR(info); DSDPFunctionReturn(0); } #include "dsdp.h" #include "dsdp5.h" #undef __FUNCT__ #define __FUNCT__ "DSDPSetDualLowerBound" int DSDPSetDualLowerBound(DSDP dsdp, double dobjmin){ int info; DSDPFunctionBegin; info = DSDPAddBCone(dsdp,dsdp->b,dobjmin);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdprescone.c0000644000175000017500000001764610326241002016563 0ustar twernertwerner#include "dsdpcone_impl.h" #include "dsdpsys.h" #include "dsdpbasictypes.h" /*! \file dsdprescone.c \brief Variable r must be nonnegative. */ struct RDCone{ double primalr,dualr,x,logr; DSDPPenalty UsePenalty; DSDP dsdp; /* Really only need the Penalty flag, which is here. */ }; typedef struct RDCone RCone; #undef __FUNCT__ #define __FUNCT__ "DSDPRHessian" static int DSDPRHessian( void *dspcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ RCone *K=(RCone*)dspcone; int info,m; double rr,sr,rssr; DSDPFunctionBegin; if (K->dualr ){ info=DSDPVecGetSize(vrhs2,&m);DSDPCHKERR(info); info=DSDPSchurMatVariableCompute(M,m-1,&rr);DSDPCHKERR(info); if (rr){ sr=-mu*rr/(K->dualr); rssr=mu*rr/(K->dualr*K->dualr); info=DSDPVecAddR(vrhs2,sr);DSDPCHKERR(info); info=DSDPSchurMatAddDiagonalElement(M,m-1,rssr);DSDPCHKERR(info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRHS" static int DSDPRHS( void *dspcone, double mu, DSDPVec vrow,DSDPVec vrhs1,DSDPVec vrhs2){ RCone *K=(RCone*)dspcone; int info; double rr,sr; DSDPFunctionBegin; if (K->dualr ){ sr=-mu/(K->dualr); info=DSDPVecGetR(vrow,&rr);DSDPCHKERR(info); info=DSDPVecAddR(vrhs2,rr*sr);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetupRCone" static int DSDPSetupRCone(void* dspcone,DSDPVec y){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetupRCone2" static int DSDPSetupRCone2(void* dspcone, DSDPVec y, DSDPSchurMat M){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDestroyRCone" static int DSDPDestroyRCone(void* dspcone){ int info; DSDPFunctionBegin; DSDPFREE(&dspcone,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRSize" static int DSDPRSize(void*dspcone,double *n){ RCone *K=(RCone*)dspcone; DSDPFunctionBegin; if (K->dualr){*n=1;} else {*n=0;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRSparsity" static int DSDPRSparsity(void*dspcone,int row, int *tnnz, int rnnz[], int m){ DSDPFunctionBegin; *tnnz=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRS" static int DSDPComputeRS(void *dspcone, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *ispsdefinite){ RCone *K=(RCone*)dspcone; int info; double rbeta; DSDPFunctionBegin; info=DSDPVecGetR(Y,&rbeta); DSDPCHKERR(info); if (K->UsePenalty==DSDPAlways){ if (rbeta<0){ *ispsdefinite=DSDP_TRUE; } else { *ispsdefinite=DSDP_FALSE;} } else { if (rbeta>0) rbeta=0; *ispsdefinite=DSDP_TRUE; } if (flag==DUAL_FACTOR){ K->dualr=rbeta; } else { K->primalr=rbeta;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPInvertRS" static int DSDPInvertRS(void *dspcone){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRStepLength" static int DSDPComputeRStepLength(void *dspcone, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){ RCone *K=(RCone*)dspcone; double r,rbeta,msteplength=1.0e100,rt=1.0e30; int info; DSDPFunctionBegin; info=DSDPVecGetR(DY,&rbeta); DSDPCHKERR(info); if (flag==DUAL_FACTOR){ r=K->dualr; } else { r=K->primalr;} if (r * rbeta<0) rt=-r/rbeta; if (K->UsePenalty==DSDPAlways){msteplength=rt;} else if (flag==PRIMAL_FACTOR){ msteplength=rt;} else if (flag==DUAL_FACTOR){msteplength=rt/0.94;} *maxsteplength=msteplength; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRX" static int DSDPRX( void *dspcone, double mu, DSDPVec y, DSDPVec dy, DSDPVec AX,double *tracexs){ RCone *K=(RCone*)dspcone; int info; double rr,dr,trxs,r=K->dualr; DSDPFunctionBegin; info=DSDPVecGetR(y,&rr); DSDPCHKERR(info); info=DSDPVecGetR(dy,&dr); DSDPCHKERR(info); if (K->dualr){ r=-1.0/rr; K->x=mu*(r-r*dr*r); trxs=K->x/r; DSDPLogInfo(0,2,"RESIDUAL X (Minimum Penalty Parameter): %4.4e, Trace(XS): %4.4e\n",K->x,trxs); /* *tracexs=trxs */ } else { K->x=0.0; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetX" static int DSDPSetX( void *dspcone, double mu, DSDPVec y, DSDPVec dy){ RCone *K=(RCone*)dspcone; int info; double rr,dr,trxs,r; DSDPFunctionBegin; info=DSDPVecGetR(y,&rr); DSDPCHKERR(info); info=DSDPVecGetR(dy,&dr); DSDPCHKERR(info); if (rr){ r=-1.0/rr; K->x=mu*(r-r*dr*r); trxs=K->x/r; DSDPLogInfo(0,2,"RESIDUAL X (Minimum Penalty Parameter): %4.4e, Trace(XS): %4.4e\n",K->x,trxs); /* *tracexs=trxs */ } else { K->x=0.0; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRLog" static int DSDPComputeRLog(void *dspcone, double *logobj, double *logdet){ RCone *K=(RCone*)dspcone; DSDPFunctionBegin; *logdet=K->logr; *logobj=0; if (K->dualr<0){ *logdet=log(-K->dualr); K->logr=log(-K->dualr); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRANorm2" static int DSDPRANorm2(void *dspcone,DSDPVec Anorm2){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRMultiplyAdd" static int DSDPRMultiplyAdd(void *dspcone,double mu,DSDPVec vrow,DSDPVec vin,DSDPVec vout){ RCone *K=(RCone*)dspcone; int info; double v1,v2,rssr; DSDPFunctionBegin; if (K->dualr){ info=DSDPVecGetR(vrow,&v1);DSDPCHKERR(info); info=DSDPVecGetR(vin,&v2);DSDPCHKERR(info); rssr=v1*v2*mu/(K->dualr*K->dualr); info=DSDPVecAddR(vout,rssr);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRMonitor" static int DSDPRMonitor( void *dspcone, int tag){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static struct DSDPCone_Ops kops; static const char* matname="R Cone"; #undef __FUNCT__ #define __FUNCT__ "RConeOperationsInitialize" static int RConeOperationsInitialize(struct DSDPCone_Ops* coneops){ int info; if (coneops==NULL) return 0; info=DSDPConeOpsInitialize(coneops); DSDPCHKERR(info); coneops->conehessian=DSDPRHessian; coneops->conesetup=DSDPSetupRCone; coneops->conesetup2=DSDPSetupRCone2; coneops->conedestroy=DSDPDestroyRCone; coneops->conecomputes=DSDPComputeRS; coneops->coneinverts=DSDPInvertRS; coneops->conesetxmaker=DSDPSetX; coneops->conecomputex=DSDPRX; coneops->conerhs=DSDPRHS; coneops->conemaxsteplength=DSDPComputeRStepLength; coneops->conelogpotential=DSDPComputeRLog; coneops->conesize=DSDPRSize; coneops->conesparsity=DSDPRSparsity; coneops->coneanorm2=DSDPRANorm2; coneops->conemonitor=DSDPRMonitor; coneops->conehmultiplyadd=DSDPRMultiplyAdd; coneops->id=19; coneops->name=matname; return 0; } /* \fn int RConeSetType(RCone *rcone, DSDPPenalty UsePenalty); \brief Set penalty type. \param dsdp the solver \param UsePenalty true or false */ #undef __FUNCT__ #define __FUNCT__ "RConeSetType" int RConeSetType(RCone *rcone, DSDPPenalty UsePenalty){ DSDPFunctionBegin; rcone->UsePenalty=UsePenalty; DSDPFunctionReturn(0); } /* \fn int RConeGetRX(RCone *rcone, double *rx); \brief Get slack of trace of matrix \param rcone cone \param rx dual of r. Accurate only when r > 0. */ #undef __FUNCT__ #define __FUNCT__ "RConeGetRX" int RConeGetRX(RCone *rcone, double *xtrace){ DSDPFunctionBegin; *xtrace=rcone->x; DSDPFunctionReturn(0); } /*! \fn int DSDPAddRCone(DSDP dsdp, RCone **rrcone); \brief A separate cone specifies that r must be nonnegative. \param dsdp the solver \param rrcone new r cone */ #undef __FUNCT__ #define __FUNCT__ "DSDPAddRCone" int DSDPAddRCone(DSDP dsdp, RCone **rrcone){ RCone *rcone; DSDPPenalty UsePenalty=DSDPInfeasible; int info; DSDPFunctionBegin; info=RConeOperationsInitialize(&kops); DSDPCHKERR(info); DSDPCALLOC1(&rcone,RCone,&info); DSDPCHKERR(info); info=RConeSetType(rcone,UsePenalty); DSDPCHKERR(info); rcone->dsdp=dsdp; rcone->logr=0; *rrcone=rcone; info=DSDPAddCone(dsdp,&kops,(void*)rcone); DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpschurmat.c0000644000175000017500000004706110326241002016745 0ustar twernertwerner#include "dsdpschurmat_impl.h" #include "dsdpschurmat.h" #include "dsdpbasictypes.h" #include "dsdpsys.h" /*! \file dsdpschurmat.c \brief Solve the Schur matrix for a step direction. */ static int hfactorevent=0,hsolveevent=0; #define DSDPNoOperationError(a); { DSDPSETERR1(10,"Schur matrix type: %s, Operation not defined\n",(a).dsdpops->matname); } #define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Schur matrix type: %s,\n",(a).dsdpops->matname);} } static int DSDPApplySMW(DSDPSchurMat, DSDPVec, DSDPVec); static int DSDPSchurMatSolveM(DSDPSchurMat, DSDPVec, DSDPVec); #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatSetData" /*! \fn int DSDPSchurMatSetData(DSDPSchurMat *M, struct DSDPSchurMat_Ops* ops, void*data); \brief Set the Schur matrix with an opaque pointer and structure of function pointers. \param M Schur matrix object \param ops address of a structure of function pointers. \param data opaque pointer to its internal data structure. */ int DSDPSchurMatSetData(DSDPSchurMat *M, struct DSDPSchurMat_Ops* ops, void*data){ DSDPFunctionBegin; (*M).dsdpops=ops; (*M).data=data; DSDPFunctionReturn(0); } static const char* schurmatname="NOT NAMED YET"; #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatOpsInitialize" /*! \fn int DSDPSchurMatOpsInitialize(struct DSDPSchurMat_Ops* dops); \brief Initialize function pointers to 0. \param dops address of a structure of function pointers. */ int DSDPSchurMatOpsInitialize(struct DSDPSchurMat_Ops* dops){ DSDPFunctionBegin; if (dops==NULL) return 0; dops->matzero=0; dops->matrownonzeros=0; dops->mataddrow=0; dops->mataddelement=0; dops->matadddiagonal=0; dops->matshiftdiagonal=0; dops->matassemble=0; dops->matscaledmultiply=0; dops->matmultr=0; dops->matfactor=0; dops->matsolve=0; dops->pmatonprocessor=0; dops->pmatwhichdiag=0; dops->pmatdistributed=0; dops->matdestroy=0; dops->matview=0; dops->matsetup=0; dops->id=0; dops->matname=schurmatname; DSDPFunctionReturn(0); } static struct DSDPSchurMat_Ops dsdpmops; #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatOpsInitialize" /*! \fn int DSDPSchurMatInitialize(DSDPSchurMat *M); \brief Initialize pointers to null. \param M Schur matrix object */ int DSDPSchurMatInitialize(DSDPSchurMat *M){ int info; DSDPFunctionBegin; info=DSDPSchurMatOpsInitialize(&dsdpmops); DSDPCHKERR(info); info=DSDPSchurMatSetData(M,&dsdpmops,0); DSDPCHKERR(info); DSDPCALLOC1(&M->schur,DSDPSchurInfo,&info);DSDPCHKERR(info); M->schur->m=0; M->schur->r=0; M->schur->dd=0; info=DSDPInitializeFixedVariable(&M->schur->fv);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatZeroEntries" /*! \fn int DSDPSchurMatZeroEntries(DSDPSchurMat M); \brief Zero all element in the matrix. \param M matrix */ int DSDPSchurMatZeroEntries(DSDPSchurMat M){ int info; DSDPFunctionBegin; if (M.dsdpops->matzero){ info=(M.dsdpops->matzero)(M.data); DSDPChkMatError(M,info); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatShiftDiagonal" /*! \fn int DSDPSchurMatShiftDiagonal(DSDPSchurMat M, double dd); \brief Add a scalar to each diagonal element of the matrix. \param M matrix \param dd diagonal shift */ int DSDPSchurMatShiftDiagonal(DSDPSchurMat M, double dd){ int info; DSDPFunctionBegin; if (dd==0){DSDPFunctionReturn(0);} M.schur->dd=dd; if (M.dsdpops->matshiftdiagonal){ /* if(M.schur->r){info=DSDPVecAddR(M.schur->rhs3,dd);DSDPCHKERR(info);} */ info=(M.dsdpops->matshiftdiagonal)(M.data,dd); DSDPChkMatError(M,info); DSDPLogInfo(0,2,"Add %4.4e to the Diagonal of Schur Matrix\n",dd); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatInParallel" /*! \fn int DSDPSchurMatInParallel(DSDPSchurMat M, DSDPTruth *flag); \brief Determine whether M is computed in parallel. \param M matrix \param flag true or false Important in parallel implementation. */ int DSDPSchurMatInParallel(DSDPSchurMat M, DSDPTruth *flag){ int info,flg; DSDPFunctionBegin; if (M.dsdpops->pmatdistributed){ info=(M.dsdpops->pmatdistributed)(M.data,&flg); DSDPChkMatError(M,info); if (flg) *flag=DSDP_TRUE; else *flag=DSDP_FALSE; } else { *flag=DSDP_FALSE; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAssemble" /*! \fn int DSDPSchurMatAssemble(DSDPSchurMat M); \brief Final assembly of M. \param M matrix Important in parallel implementation. */ int DSDPSchurMatAssemble(DSDPSchurMat M){ int info; DSDPFunctionBegin; if (M.dsdpops->matassemble){ info=(M.dsdpops->matassemble)(M.data); DSDPChkMatError(M,info); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatFactor" /*! \fn int DSDPSchurMatFactor(DSDPSchurMat M, DSDPTruth *successful); \brief Factor M \param M matrix \param successful false if factorization failed. */ int DSDPSchurMatFactor(DSDPSchurMat M, DSDPTruth *successful){ int info,flag=0; DSDPVec rhs3=M.schur->rhs3,dy3=M.schur->dy3; DSDPFunctionBegin; *successful=DSDP_TRUE; DSDPEventLogBegin(hfactorevent); if (M.dsdpops->matfactor){ info=(M.dsdpops->matfactor)(M.data,&flag); DSDPChkMatError(M,info); if (flag){ *successful=DSDP_FALSE; DSDPLogInfo(0,2,"Indefinite Schur Matrix -- Bad Factorization\n"); } } else { DSDPNoOperationError(M); } DSDPEventLogEnd(hfactorevent); if (M.schur->r){ info=DSDPSchurMatSolveM(M,rhs3,dy3);DSDPCHKERR(info);} else {info=DSDPVecZero(dy3);DSDPCHKERR(info);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatMultiply" /*! \fn int DSDPSchurMatMultiply(DSDPSchurMat M, DSDPVec x, DSDPVec y); \brief Multiply M by a vector. y = M x \param M matrix \param x in vector. \param y product. */ int DSDPSchurMatMultiply(DSDPSchurMat M, DSDPVec x, DSDPVec y){ int info,n; double *xx,*yy,r=M.schur->r; double r1,r2,dd; DSDPVec rhs3; DSDPFunctionBegin; if (M.dsdpops->matscaledmultiply){ info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); info=DSDPVecGetArray(y,&yy); DSDPCHKERR(info); info=(M.dsdpops->matscaledmultiply)(M.data,xx+1,yy+1,n-2); DSDPChkMatError(M,info); yy[0]=0; yy[n-1]=0; info=DSDPVecRestoreArray(y,&yy); DSDPCHKERR(info); info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); } else { DSDPNoOperationError(M); } if (r){ rhs3=M.schur->rhs3; info=DSDPVecGetR(rhs3,&r2);DSDPCHKERR(info); info=DSDPVecGetR(x,&r1);DSDPCHKERR(info); info=DSDPVecAXPY(r1,rhs3,y);DSDPCHKERR(info); info=DSDPVecDot(rhs3,x,&dd);DSDPCHKERR(info); info=DSDPVecAddR(y,dd-r1*r2);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatMultR" int DSDPSchurMatMultR(DSDPSchurMat M, DSDPVec x, DSDPVec y){ int info,n; double *xx,*yy,r=M.schur->r; double r1,r2,dd; DSDPVec rhs3; DSDPFunctionBegin; if (M.dsdpops->matmultr){ info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); info=DSDPVecGetArray(y,&yy); DSDPCHKERR(info); info=(M.dsdpops->matmultr)(M.data,xx+1,yy+1,n-2); DSDPChkMatError(M,info); yy[0]=0; yy[n-1]=0; info=DSDPVecRestoreArray(y,&yy); DSDPCHKERR(info); info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); if (r){ rhs3=M.schur->rhs3; info=DSDPVecGetR(rhs3,&r2);DSDPCHKERR(info); info=DSDPVecGetR(x,&r1);DSDPCHKERR(info); info=DSDPVecAXPY(r1,rhs3,y);DSDPCHKERR(info); info=DSDPVecDot(rhs3,x,&dd);DSDPCHKERR(info); info=DSDPVecAddR(y,dd-r1*r2);DSDPCHKERR(info); } } else { info=DSDPVecZero(y);DSDPCHKERR(info); /* DSDPNoOperationError(M); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatReducePVec" /*! \fn int DSDPSchurMatReducePVec(DSDPSchurMat M, DSDPVec x); \brief Collect elements of the vector \param M matrix \param x vector. Important in parallel implementation. Otherwise does nothing. */ int DSDPSchurMatReducePVec(DSDPSchurMat M, DSDPVec x){ int info,n; double *xx; DSDPTruth flag; DSDPFunctionBegin; if (M.dsdpops->pmatreduction){ info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); info=(M.dsdpops->pmatreduction)(M.data,xx+1,n-2); DSDPChkMatError(M,info); info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); } else { info=DSDPSchurMatInParallel(M,&flag);DSDPChkMatError(M,info); if (flag==DSDP_TRUE){ DSDPNoOperationError(M); } } info=DSDPZeroFixedVariables(M,x);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatSetR" /*! \fn int DSDPSchurMatSetR(DSDPSchurMat M, double rr); \brief Set up the data structure \param M matrix \param rr residual */ int DSDPSchurMatSetR(DSDPSchurMat M, double rr){ DSDPFunctionBegin; M.schur->r=rr; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatSetup" /*! \fn int DSDPSchurMatSetup(DSDPSchurMat M, DSDPVec Y); \brief Set up the data structure \param M matrix \param Y variable vector. */ int DSDPSchurMatSetup(DSDPSchurMat M, DSDPVec Y){ int info,m; DSDPFunctionBegin; info=DSDPVecDuplicate(Y,&M.schur->rhs3); info=DSDPVecDuplicate(Y,&M.schur->dy3); info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); if (M.dsdpops->matsetup){ info=(M.dsdpops->matsetup)(M.data,m-2); DSDPChkMatError(M,info); } else { DSDPNoOperationError(M); } DSDPEventLogRegister("Factor Newton Eq.",&hfactorevent); DSDPEventLogRegister("Solve Newton Eq.",&hsolveevent); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatView" /*! \fn int DSDPSchurMatView(DSDPSchurMat M); \brief Print the matrix \param M matrix */ int DSDPSchurMatView(DSDPSchurMat M){ int info; DSDPFunctionBegin; if (M.dsdpops->matview){ info=(M.dsdpops->matview)(M.data); DSDPChkMatError(M,info); } else { DSDPNoOperationError(M); } info=DSDPVecView(M.schur->rhs3);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatRowScaling" /*! \fn int DSDPSchurMatRowScaling(DSDPSchurMat M, DSDPVec D); \brief Identify which rows on on this processor. \param M matrix \param D Variables marked with 0 or 1. */ int DSDPSchurMatRowScaling(DSDPSchurMat M, DSDPVec D){ int info; DSDPFunctionBegin; info=DSDPSchurMatDiagonalScaling(M,D);DSDPCHKERR(info); info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatDestroy" /*! \fn int DSDPSchurMatDestroy(DSDPSchurMat *M); \brief Free the memory in the data structure \param M matrix */ int DSDPSchurMatDestroy(DSDPSchurMat *M){ int info; DSDPFunctionBegin; if ((*M).dsdpops->matdestroy){ info=((*M).dsdpops->matdestroy)((*M).data); DSDPChkMatError(*M,info); } else { /* DSDPNoOperationError(*M); */ } info=DSDPVecDestroy(&M->schur->rhs3);DSDPCHKERR(info); info=DSDPVecDestroy(&M->schur->dy3);DSDPCHKERR(info); /* info=DSDPSchurMatSetData(M,0,0); DSDPCHKERR(info); */ info=DSDPSchurMatOpsInitialize(&dsdpmops); DSDPCHKERR(info); info=DSDPSchurMatSetData(M,&dsdpmops,0); DSDPCHKERR(info); DSDPFREE(&M->schur,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatSolveM" static int DSDPSchurMatSolveM(DSDPSchurMat M, DSDPVec b, DSDPVec x){ int info,n; double *xx,*bb; DSDPFunctionBegin; info=DSDPEventLogBegin(hsolveevent); if (M.dsdpops->matsolve){ info=DSDPVecGetArray(b,&bb); DSDPCHKERR(info); info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); info=DSDPVecZero(x);DSDPCHKERR(info); info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); info=(M.dsdpops->matsolve)(M.data,bb+1,xx+1,n-2); DSDPChkMatError(M,info); info=DSDPVecRestoreArray(b,&bb); DSDPCHKERR(info); info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); } else { DSDPNoOperationError(M); } info=DSDPVecSetR(x,0.0);DSDPCHKERR(info); info=DSDPVecSetC(x,0.0);DSDPCHKERR(info); info=DSDPEventLogEnd(hsolveevent); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatSolve" /*! \fn int DSDPSchurMatSolve(DSDPSchurMat M, DSDPVec b, DSDPVec x); \brief Solve the linear system \param M matrix \param b the right-hand side \param x solution */ int DSDPSchurMatSolve(DSDPSchurMat M, DSDPVec b, DSDPVec x){ int info; DSDPFunctionBegin; info=DSDPSchurMatSolveM(M,b,x);DSDPCHKERR(info); info=DSDPApplySMW(M,b,x);DSDPCHKERR(info); info=DSDPZeroFixedVariables(M,x);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPApplySMW" static int DSDPApplySMW(DSDPSchurMat M, DSDPVec rhs, DSDPVec dy){ int info; double r=M.schur->r,rr,dr,rhsr,rssr; double rhsnorm,rhsnorm3,rhs1mrhs3=0,rhs3mrhs3=0; DSDPVec rhs3=M.schur->rhs3,dy3=M.schur->dy3; DSDPFunctionBegin; info=DSDPVecNormInfinity(rhs,&rhsnorm);DSDPCHKERR(info); info=DSDPVecNormInfinity(rhs3,&rhsnorm3);DSDPCHKERR(info); if (r==0 || rhsnorm==0){ info=DSDPVecSetR(dy,0); DSDPCHKERR(info); info=DSDPVecSetR(rhs,0); DSDPCHKERR(info); } else if (0 && rhsnorm3==0){ /* dsdp->UsePenalty==DSDPNever */ info=DSDPVecGetR(rhs,&rr); DSDPCHKERR(info); info=DSDPVecSetR(dy,rr); DSDPCHKERR(info); } else { /* Use bigM penalty method and Sherman-Morrison-Woodbury */ info=DSDPVecGetR(rhs,&rhsr); DSDPCHKERR(info); info=DSDPVecGetR(rhs3,&rssr); DSDPCHKERR(info); info=DSDPVecDot(rhs3,dy,&rhs1mrhs3); DSDPCHKERR(info); info=DSDPVecDot(rhs3,dy3,&rhs3mrhs3); DSDPCHKERR(info); if (rssr-rhs3mrhs3==0) rssr*=(1.00001); dr=-(rhs1mrhs3-rhsr )/(rssr-rhs3mrhs3); info=DSDPVecAXPY(-dr,dy3,dy);DSDPCHKERR(info); info=DSDPVecSetR(dy,dr); DSDPCHKERR(info); info=DSDPVecSetR(rhs,rhsr); DSDPCHKERR(info); info=DSDPVecDot(rhs,dy,&rhs3mrhs3); DSDPCHKERR(info); if (rhs3mrhs3 <=0){ DSDPLogInfo(0,3,"DSDP Step Direction Not Descent, Adjusting. \n"); info=DSDPVecAddR(rhs3,rssr*0.1);DSDPCHKERR(info); info=DSDPVecAXPY(dr,dy3,dy);DSDPCHKERR(info); info=DSDPVecSetR(dy,0); DSDPCHKERR(info); info=DSDPApplySMW(M,rhs,dy);DSDPCHKERR(info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPZeroFixedVariables" int DSDPZeroFixedVariables( DSDPSchurMat M, DSDPVec dy){ int i,info; FixedVariables *fv=&M.schur->fv; DSDPFunctionBegin; for (i=0;invars;i++){ info=DSDPVecSetElement(dy,fv->var[i],0.0);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPApplyFixedVariables" int DSDPApplyFixedVariables( DSDPSchurMat M, DSDPVec y){ int i,jj,info; double vv,scl; FixedVariables *fv=&M.schur->fv; info=DSDPVecGetC(y,&scl);DSDPCHKERR(info); DSDPFunctionBegin; for (i=0;invars;i++){ vv=fv->fval[i]*fabs(scl); jj=fv->var[i]; info=DSDPVecSetElement(y,jj,vv);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPFixedVariableNorm" int DSDPFixedVariablesNorm( DSDPSchurMat M, DSDPVec y){ int i,jj,info; double vv; FixedVariables *fv=&M.schur->fv; DSDPFunctionBegin; for (i=0;invars;i++){ jj=fv->var[i]; vv=fv->fval[i]; info=DSDPVecAddC(y,1.0);DSDPCHKERR(info); info=DSDPVecAddElement(y,jj,vv*vv);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeFixedYX" int DSDPComputeFixedYX( DSDPSchurMat M, DSDPVec berr){ int i,jj,info; double vv; FixedVariables *fv=&M.schur->fv; DSDPFunctionBegin; for (i=0;invars;i++){ jj=fv->var[i]; info=DSDPVecGetElement(berr,jj,&vv);DSDPCHKERR(info); info=DSDPVecSetElement(berr,jj,0);DSDPCHKERR(info); info=DSDPVecAddC(berr,-vv*fv->fval[i]);DSDPCHKERR(info); info=DSDPVecAddR(berr,fabs(vv));DSDPCHKERR(info); fv->fdual[i]=-vv; if (fv->xout) fv->xout[i]=-vv; DSDPLogInfo(0,2,"FIXED VAR DUAL: %d %4.4f, ADD %4.4f to objective.\n",jj,vv,-vv*fv->fval[i]); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPIsFixed" int DSDPIsFixed( DSDPSchurMat M, int vari, DSDPTruth *flag){ int i; FixedVariables *fv=&M.schur->fv; DSDPFunctionBegin; *flag=DSDP_FALSE; for (i=0;invars;i++){ if (fv->var[i]==vari){ *flag=DSDP_TRUE; break; } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPInitializeFixedVariables" int DSDPInitializeFixedVariable( FixedVariables *fv){ DSDPFunctionBegin; fv->nmaxvars=0; fv->nvars=0; fv->fval=0; fv->var=0; fv->fdual=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPAddFixedVariables" int DSDPAddFixedVariable( DSDPSchurMat M, int vari, double val){ int i,t,*iinew,info,nvars; double *ddnew,*vvnew; FixedVariables *fv=&M.schur->fv; DSDPFunctionBegin; nvars=fv->nvars; if (nvars>=fv->nmaxvars){ t=2*nvars + 2; DSDPCALLOC2(&iinew,int,t,&info); DSDPCALLOC2(&ddnew,double,t,&info); DSDPCALLOC2(&vvnew,double,t,&info); for (i=0;ivar[i]; ddnew[i]=fv->fval[i]; vvnew[i]=fv->fdual[i]; } DSDPFREE(&fv->var,&info);DSDPCHKERR(info); DSDPFREE(&fv->fval,&info);DSDPCHKERR(info); DSDPFREE(&fv->fdual,&info);DSDPCHKERR(info); fv->var=iinew; fv->fval=ddnew; fv->fdual=vvnew; fv->nmaxvars=t; } fv->var[fv->nvars]=vari; fv->fval[fv->nvars]=val; fv->nvars++; DSDPFunctionReturn(0); } #include "dsdp.h" #undef __FUNCT__ #define __FUNCT__ "DSDPSparsityInSchurMat" /*! \fn int DSDPSparsityInSchurMat(DSDP dsdp, int row, int rnnz[], int mm); \brief Identify nonzero elements in a row of the Schur complement. \param dsdp solver \param row corresponding to variable y. \param rnnz array to be marked nonzero if nonzero. \param mm dimension of M matrix */ int DSDPSparsityInSchurMat(DSDP dsdp, int row, int rnnz[], int mm){ int info,*iptr,m=mm+2; double *dd; DSDPVec R=dsdp->M.schur->rhs3; DSDPFunctionBegin; info=DSDPVecZero(R);DSDPCHKERR(info); info=DSDPVecGetArray(R,&dd);DSDPCHKERR(info); iptr=(int*)dd; info=DSDPSchurSparsity(dsdp,row+1,iptr,m);DSDPCHKERR(info); memcpy((void*)rnnz,(void*)(iptr+1),(mm)*sizeof(int)); info=DSDPVecRestoreArray(R,&dd);DSDPCHKERR(info); DSDPFunctionReturn(0); } #include "dsdp5.h" #undef __FUNCT__ #define __FUNCT__ "DSDPSetFixedVariable" /*! \fn int DSDPSetFixedVariable(DSDP dsdp, int vari, double val); \brief Fix variable y to exact value. \param dsdp solver \param vari variables y \param val fixed value \ingroup DSDPSolver \sa DSDPSetFixedVariables() */ int DSDPSetFixedVariable(DSDP dsdp, int vari, double val){ int info; DSDPFunctionBegin; DSDPLogInfo(0,2,"Set Fixed Variable: %d, %12.8f\n",vari,val); info= DSDPAddFixedVariable(dsdp->M,vari,val);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetFixedVariables" /*! \fn int DSDPSetFixedVariables(DSDP dsdp, double vars[], double vals[], double xout[], int nvars); \brief Fix variable y to exact values. \param dsdp solver \param vars variables y ( integer valued from 1 through m) \param vals fixed values \param xout array for the dual variables \param nvars length of the previous arrays. \ingroup DSDPSolver */ int DSDPSetFixedVariables(DSDP dsdp, double vars[], double vals[], double xout[], int nvars){ int i,info; DSDPFunctionBegin; for (i=0;iM.schur->fv.xout=xout; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetFixedYX" int DSDPGetFixedYX( DSDP dsdp, int vari, double *dd){ int i; FixedVariables *fv=&dsdp->M.schur->fv; DSDPFunctionBegin; for (i=0;invars;i++){ if (vari==fv->var[i]){ *dd=fv->fdual[i]; break; } } DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpschurmat.h0000644000175000017500000000546010326241002016747 0ustar twernertwerner#if !defined(__DSDP_SCHURMATRIXOPERATIONS_H) #define __DSDP_SCHURMATRIXOPERATIONS_H /*! \file dsdpschurmat.h \brief Methods of a Schur Matrix. */ #include "dsdpvec.h" #include "dsdpbasictypes.h" #include "dsdpcg.h" typedef struct { int *var; int nvars; int nmaxvars; double *fval; double *fdual; double *xout; } FixedVariables; typedef struct { FixedVariables fv; DSDPVec rhs3,dy3; double dd,r; int m; } DSDPSchurInfo; /*! struct DSDPSchurMat_C \brief Schur complement matrix whose solution is the Newton direction. \sa DSDPSchurMat */ struct DSDPSchurMat_C{ void* data; struct DSDPSchurMat_Ops *dsdpops; DSDPSchurInfo* schur; }; /*! \typedef struct DSDPSchurMat_C DSDPSchurMat; \brief This object represents the Schur Matrix. Its structure is opaque to the DSDP solver, but it must implement the interface below and provide a structure of function pointers. */ typedef struct DSDPSchurMat_C DSDPSchurMat; #ifdef __cplusplus extern "C" { #endif extern int DSDPSchurMatSetData(DSDPSchurMat*,struct DSDPSchurMat_Ops*, void*); extern int DSDPSchurMatInitialize(DSDPSchurMat*); extern int DSDPSchurMatSetup(DSDPSchurMat, DSDPVec); extern int DSDPSchurMatZeroEntries(DSDPSchurMat); extern int DSDPSchurMatInParallel(DSDPSchurMat, DSDPTruth*); extern int DSDPSchurMatShiftDiagonal(DSDPSchurMat, double); extern int DSDPSchurMatAssemble(DSDPSchurMat); extern int DSDPSchurMatMultiply(DSDPSchurMat, DSDPVec, DSDPVec); extern int DSDPSchurMatMultR(DSDPSchurMat, DSDPVec, DSDPVec); extern int DSDPSchurMatReducePVec(DSDPSchurMat, DSDPVec); extern int DSDPSchurMatFactor(DSDPSchurMat,DSDPTruth*); extern int DSDPSchurMatSolve(DSDPSchurMat, DSDPVec, DSDPVec); extern int DSDPSchurMatDestroy(DSDPSchurMat*); extern int DSDPSchurMatView(DSDPSchurMat); extern int DSDPSchurMatSetR(DSDPSchurMat, double); extern int DSDPSchurMatRowColumnScaling(DSDPSchurMat,int, DSDPVec,int*); extern int DSDPSchurMatAddRow(DSDPSchurMat, int, double, DSDPVec); extern int DSDPSchurMatVariableCompute(DSDPSchurMat, int, double*); extern int DSDPSchurMatVariableComputeC(DSDPSchurMat, double*); extern int DSDPSchurMatVariableComputeR(DSDPSchurMat, double*); extern int DSDPSchurMatAddDiagonalElement(DSDPSchurMat, int, double); extern int DSDPSchurMatAddC(DSDPSchurMat,int,double); extern int DSDPSchurMatAddR(DSDPSchurMat,int,double); extern int DSDPSchurMatDiagonalScaling(DSDPSchurMat, DSDPVec); extern int DSDPSchurMatAddDiagonal(DSDPSchurMat, DSDPVec); extern int DSDPSchurMatRowScaling(DSDPSchurMat, DSDPVec); extern int DSDPZeroFixedVariables( DSDPSchurMat, DSDPVec); extern int DSDPApplyFixedVariables( DSDPSchurMat, DSDPVec); extern int DSDPIsFixed( DSDPSchurMat, int, DSDPTruth*); extern int DSDPInitializeFixedVariable( FixedVariables *); extern int DSDPAddFixedVariable( DSDPSchurMat, int, double); #ifdef __cplusplus } #endif #endif DSDP5.8/src/solver/dsdpschurmat_impl.h0000644000175000017500000000236010326241002017764 0ustar twernertwerner#include "dsdpbasictypes.h" #if !defined(__DSDP_SCHURMATRICES_H) #define __DSDP_SCHURMATRICES_H /*! \file dsdpschurmat_impl.h \brief Function pointers that a Schur complement matrix (dense, sparse, parallel dense) must provide. */ struct DSDPSchurMat_Ops{ int id; int (*matzero)(void*); int (*matrownonzeros)(void*,int,double*,int*,int); int (*mataddrow)(void*,int,double,double[],int); int (*mataddelement)(void*,int,double); int (*matadddiagonal)(void*,double[],int); int (*matshiftdiagonal)(void*,double); int (*matassemble)(void*); int (*matscaledmultiply)(void*,double[],double[],int); int (*matmultr)(void*,double[],double[],int); int (*matfactor)(void*,int*); int (*matsolve)(void*,double[],double[],int); int (*matsetup)(void*,int); int (*pmatwhichdiag)(void*,double[],int); int (*pmatonprocessor)(void*,int,int*); int (*pmatlocalvariables)(void*,double[],int); int (*pmatreduction)(void*,double[],int); int (*pmatdistributed)(void*,int*); int (*matdestroy)(void*); int (*matview)(void*); const char *matname; }; extern int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*,void*); extern int DSDPSchurMatOpsInitialize(struct DSDPSchurMat_Ops*); extern int DSDPSparsityInSchurMat(DSDP,int,int[],int); #endif DSDP5.8/src/solver/dsdpsetdata.c0000644000175000017500000006355010326241002016545 0ustar twernertwerner/*! \file dsdpsetdata.c \brief Set parameters for the solver and retrieve statistics about the current solution. */ #include "dsdp.h" #include "dsdp5.h" #include "dsdpsys.h" /*! \fn int DSDPSetDualObjective(DSDP dsdp, int i, double bi) \brief Set the objective vector b in (D). \param dsdp is the solver \param i is the variable number from 1 through m \param bi is the objective value associated with variable i \sa DSDPSetY0() \sa DSDPGetDObjective() \ingroup DSDPBasic The dual objective function is \f$ \mbox{maximize} \ \ {\displaystyle \sum_{i=1}^m b_i \ y_i } \f$. */ #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); } /*! \fn int DSDPCopyB(DSDP dsdp, double bb[], int m) \brief Copies the variables b from solver into an array. \param dsdp is the solver \param bb is an array \param m is the length of the array and the dimension of y \sa DSDPSetDualObjective() \ingroup DSDPSolution */ #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;ib,&b);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPSetY0(DSDP dsdp,int i, double yi0) \brief Set the initial values of variables y in (D). To improve performance consider setting the initial values of the variables y in (D). \param dsdp is the solver \param i is the variable number from 1 through m \param yi0 is the initial value af that variable \sa DSDPGetY() \sa DSDPSetR0() \sa DSDPSetPotentialParameter() \sa DSDPReuseMatrix() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetY(DSDP dsdp, double y[], int m) \brief Copies the variables y into an array. \param dsdp is the solver \param y is an array \param m is the length of the array and the dimension of y \sa DSDPSetY0() \sa DSDPComputeX() \ingroup DSDPBasic */ #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;iytemp,&yy);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPGetScale(DSDP dsdp, double *scale) \brief Copy the internal scaling factor from the solver \param dsdp is the solver \param *scale will be set to the scaling factor used in the solver \sa DSDPSetScale() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPSetScale(DSDP dsdp, double scale) \brief Set the internal scaling factor. DSDP scales the data C and solves the scaled problem. DSDP determines a default scaling from a combination of the norms on the data. \param dsdp is the solver \param scale is the scaling factor used in the solver (>0) \sa DSDPGetScale() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPAddObjectiveConstant(DSDP dsdp, double c) \brief Add a constant to the objective. \param dsdp is the solver \param c is the constant. \sa DSDPGetDObjective() \note This parameter does not affect the performance of the solver. It can, however, make the standout output more consistent with the underlying application. \ingroup DSDPSolution */ #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); } /*! \fn int DSDPSetMaxIts(DSDP dsdp, int maxits) \brief Terminate the solver after this number of iterations. \param dsdp is the solver \param maxits is the maximum number of DSDP iterations (>0) \sa DSDPGetMaxIts() \sa DSDPGetIts() \sa DSDPSetGapTolerance() \ingroup DSDPConverge */ #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); } /*! \fn int DSDPGetMaxIts(DSDP dsdp, int *maxits) \brief Copy the maximum number of iterations from the solver \param dsdp is the solver \param *maxits will be the maximum number of iterations in DSDP \sa DSDPSetMaxIts() \sa DSDPGetIts() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetMaxIts" int DSDPGetMaxIts(DSDP dsdp,int *its){ DSDPFunctionBegin; DSDPValid(dsdp); *its=dsdp->maxiter; DSDPFunctionReturn(0); } /*! \fn int DSDPSetMaxTrustRadius(DSDP dsdp, double rad) \brief Set a maximum trust radius on the step direction. \param dsdp is the solver \param rad is radius of the trust region.(default: 1e30) \sa DSDPGetMaxTrustRadius() \ingroup DSDPSolver \note By default this tolerance is very large and does not */ #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); } /*! \fn int DSDPGetMaxTrustRadius(DSDP dsdp, double *rad) \brief Copy the current radius of the trust region. \param dsdp is the solver \param *rad will be set to radius of the trust region \sa DSDPSetMaxTrustRadius() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetMaxTrustRadius" int DSDPGetMaxTrustRadius(DSDP dsdp,double *rad){ DSDPFunctionBegin; DSDPValid(dsdp); *rad=dsdp->maxtrustradius; DSDPFunctionReturn(0); } /*! \fn int DSDPSetZBar(DSDP dsdp, double ppobj) \brief Set an upper bound on the objective value at the solution \param dsdp is the solver \param ppobj is the initial objective v (default: 1e30) \sa DSDPGetPPObjective() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPSetR0(DSDP dsdp, double r0) \brief Set an initial value for the variable r in (DD) A negative value asks DSDP to choose this parameter. The default heuristic generally uses very large values. Smaller values may significantly improve performance. \param dsdp is the solver \param r0 is the initial objective v (default: -1) \sa DSDPSetPenaltyParameter() \sa DSDPGetR() \sa DSDPSetY0() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPSetBarrierParameter(DSDP dsdp, double mu) \brief Set the current barrier parameter. The barrier parameter is defined as the difference between the objective functions (PP) and (DD) divided by the potential parameter rho. \param dsdp is the solver \param mu is the initial objective v \sa DSDPGetBarrierParameter() \sa DSDPSetZBar() \sa DSDPSetPotentialParameter() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetBarrierParameter(DSDP dsdp, double *mu) \brief Copy the current barrier parameter. \param dsdp is the solver \param *mu barrier parameter \sa DSDPSetBarrierParameter() \sa DSDPGetPPObjective() \sa DSDPGetDDObjective() \sa DSDPGetPotentialParameter() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPUsePenalty(DSDP dsdp, int yesorno) \brief Use penalty parameter to enforce feasibility. \param dsdp is the solver \param yesorno is the decision \sa DSDPSetPenaltyParameter() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPSetPenaltyParameter(DSDP dsdp, double Gamma) \brief Set the penalty parameter Gamma. DSDP uses a penalty parameter to enforce feasibility in (D). The default value is 1e8, but other values may improve performance. This value must exceed the trace of the solution X. \param dsdp is the solver \param Gamma is the penalty parameter \sa DSDPGetPenaltyParameter() \sa DSDPGetR() \sa DSDPGetTraceX() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetPenaltyParameter(DSDP dsdp, double *Gamma) \brief Copy the penalty parameter Gamma. \param dsdp is the solver \param *Gamma wil be set to the penalty parameter \sa DSDPSetPenaltyParameter() \sa DSDPGetR() \sa DSDPGetDDObjective() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetPPObjective(DSDP dsdp, double *ppobj) \brief Copy the objective value (PP). \param dsdp is the solver \param *ppobj will be the objective value in (PP) \sa DSDPGetDDObjective() \sa DSDPGetPObjective() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetDObjective(DSDP dsdp, double *dobj) \brief Copy the objective value (D). \param dsdp is the solver \param *dobj will be the objective value in (D) \sa DSDPGetPObjective() \sa DSDPGetDDObjective() \sa DSDPGetY() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetDDObjective(DSDP dsdp, double *ddobj) \brief Copy the objective value (DD). \param dsdp is the solver \param *ddobj will be the objective value in (DD) \sa DSDPGetPPObjective() \sa DSDPGetDObjective() \sa DSDPGetY() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetDualityGap(DSDP dsdp, double *dgap) \brief Copy the difference between the objective values. \param dsdp is the solver \param *dgap will be set to the difference between the objective values in (PP) and (DD) \sa DSDPGetDDObjective() \sa DSDPGetPPObjective() \sa DSDPGetDimension() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetIts(DSDP dsdp, int *its) \brief Copy the current iteration number. \param dsdp is the solver \param *its will be set to the current iteration number. \sa DSDPSetMaxIts() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetIts" int DSDPGetIts(DSDP dsdp,int *its){ DSDPFunctionBegin; DSDPValid(dsdp); *its=dsdp->itnow; DSDPFunctionReturn(0); } /*! \fn int DSDPStopReason(DSDP dsdp, DSDPTerminationReason *reason) \brief Copy the reason why the solver terminated. \param dsdp is the solver \param *reason will be set to the proper enumerated type. \sa DSDPSetMaxIts() \sa DSDPSetGapTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPStopReason" int DSDPStopReason(DSDP dsdp,DSDPTerminationReason *reason){ DSDPFunctionBegin; DSDPValid(dsdp); *reason=dsdp->reason; DSDPFunctionReturn(0); } /*! \fn int DSDPGetR(DSDP dsdp, double *res) \brief Copy the infeasibility in (D), or the variable r in (DD). \param dsdp is the solver \param *res will be set to the value of r. \sa DSDPSetMaxIts() \sa DSDPSetGapTolerance() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetDataNorms(DSDP dsdp, double dnorm[3]) \brief Copy the norms of the data C, A, and b into an array. \param dsdp is the solver \param dnorm will be set the norms the data C, A, and b. \sa DSDPSetDualObjective() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetMaxYElement(DSDP dsdp, double *ymax) \brief Copy the the infinity norm of the variables y. \param dsdp is the solver \param *ymax will be set to the magnitude of the largest variable y. \sa DSDPSetYBounds() \ingroup DSDPSolution */ #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" /*! \fn int DSDPGetDimension(DSDP dsdp, double *n); \brief Copy the dimension of the cones, or the number of constraints in (D). \param dsdp the solver \param *n will be set to the dimension (a whole number) \ingroup DSDPSolution \sa DSDPGetNumberOfVariables() */ int DSDPGetDimension(DSDP dsdp, double *n){ int info; DSDPFunctionBegin; info=DSDPGetConicDimension(dsdp,n);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPGetYMaxNorm(DSDP dsdp, double *ynorm) \brief Copy the the infinity norm of the variables y. \param dsdp is the solver \param *ynorm will be set to the magnitude of the largest variable y. \sa DSDPSetYBounds() \ingroup DSDPSolution */ #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); } /*! \fn int DSDPGetNumberOfVariables(DSDP dsdp, int *m) \brief Copy the number of variables y. \param dsdp the solver \param *m will be set the number of variables y \sa DSDPCreate() \sa DSDPGetDimension() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetNumberOfVariables" int DSDPGetNumberOfVariables(DSDP dsdp, int *m){ DSDPFunctionBegin; DSDPValid(dsdp); *m=dsdp->m; DSDPFunctionReturn(0); } /*! \fn int DSDPGetPnorm(DSDP dsdp, double *pnorm) \brief Copy the proximity of the solution to the central path. \param dsdp is the solver \param *pnorm will be set a norm of the gradient of the barrier function \sa DSDPSetGapTolerance() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPnorm" int DSDPGetPnorm(DSDP dsdp, double *pnorm){ DSDPFunctionBegin; DSDPValid(dsdp); *pnorm=dsdp->pnorm; DSDPFunctionReturn(0); } /*! \fn int DSDPGetStepLengths(DSDP dsdp, double *pstep, double *dstep) \brief Copy the step sizes in the current iteration. \param dsdp is the solver \param *pstep will be set to the step size in (PP) \param *dstep will be set to the step size in (DD) \sa DSDPSetStepTolerance() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetStepLengths" int DSDPGetStepLengths(DSDP dsdp, double *pstep, double *dstep){ DSDPFunctionBegin; DSDPValid(dsdp); *dstep=dsdp->dstep; *pstep=dsdp->pstep; DSDPFunctionReturn(0); } /*! \fn int DSDPSetPotentialParameter(DSDP dsdp, double rho) \brief Set the potential parameter. The parameter rho in the solver will be set to this multiple of the total dimension of the cones. The default value is 3, but values of 4 or more may significantly improve performance. \param dsdp is the solver \param rho the potential parameter. \sa DSDPGetPotentialParameter() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetPotentialParameter(DSDP dsdp, double *rho) \brief Copy the potential parameter. \param dsdp is the solver \param *rho will be set to the potential parameter \sa DSDPSetPotentialParameter() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPotentialParameter" int DSDPGetPotentialParameter(DSDP dsdp, double *rho){ DSDPFunctionBegin; DSDPValid(dsdp); *rho=dsdp->rhon; DSDPFunctionReturn(0); } /*! \fn int DSDPGetPotential(DSDP dsdp, double *potential) \brief Copy the potential of the current solution. \param dsdp is the solver \param *potential will be set to the value of the potential function \sa DSDPSetPotentialParameter() \sa DSDPGetDDObjective() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPotential" int DSDPGetPotential(DSDP dsdp, double *potential){ DSDPFunctionBegin; DSDPValid(dsdp); *potential=dsdp->potential; DSDPFunctionReturn(0); } /*! \fn int DSDPUseDynamicRho(DSDP dsdp, int yesorno) \brief Use a dynamic strategy to choose parameter rho. \param dsdp is the solver \param yesorno is nonzero to use the dynamic strategy (default 1) \sa DSDPSetPotentialParameter() \sa DSDPGetPotential() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetYBounds(DSDP dsdp, double *lbound, double *ubound) \brief Copy the bounds on the variables y. \param dsdp is the solver \param *lbound will be set to the lower bound of the variables y \param *ubound will be set to the upper bound of the variables y \sa DSDPSetYBounds() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPSetYBounds(DSDP dsdp, double lbound, double ubound) \brief Bound the variables y. \param dsdp is the solver \param lbound is the lower bound for each variable y. \param ubound is the upper bound for each variable y. \sa DSDPSetYBounds() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPReuseMatrix(DSDP dsdp, int rm) \brief Reuse the Hessian of the barrier function multiple times at each DSDP iteration. \param dsdp is the solver \param rm is the maximum number of times the matrix will be used in each DSDP iteration \sa DSDPGetReuseMatrix() \ingroup DSDPSolver */ #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); } /*! \fn int DSDPGetReuseMatrix(DSDP dsdp, int *rm) \brief Copy this parameter. \param dsdp is the solver \param *rm will be set to the maximum number of times the matrix will be reused \sa DSDPReuseMatrix() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetReuseMatrix" int DSDPGetReuseMatrix(DSDP dsdp, int *rm){ DSDPFunctionBegin; DSDPValid(dsdp); *rm=dsdp->reuseM; DSDPFunctionReturn(0); } /*! \fn int DSDPSetMonitor(DSDP dsdp, int (*monitor)(DSDP,void*), void* monitorctx ) \brief Monitor each iteration of the solver. \param dsdp is the solver \param monitor is a function that will be called at each iteration \param monitorctx is a pointer that will be passed to the function \sa DSDPSetStandardMonitor() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetMonitor" int DSDPSetMonitor(DSDP dsdp, int (*monitor)(DSDP,void*), void* monitorctx){ DSDPFunctionBegin; DSDPValid(dsdp); if (dsdp->nmonitorsdmonitor[dsdp->nmonitors].monitor=monitor; dsdp->dmonitor[dsdp->nmonitors].monitorctx=monitorctx; dsdp->nmonitors++; } DSDPFunctionReturn(0); } /*! \fn int DSDPSetConvergenceFlag(DSDP dsdp, DSDPTerminationReason reason ){ \brief Monitor each iteration of the solver. \param dsdp is the solver \param reason is the termination reason \sa DSDPStopReason() \ingroup DSDPConverge */ #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); } DSDP5.8/src/solver/dsdpvec.h0000644000175000017500000000626310326241002015700 0ustar twernertwerner#if !defined(__DSDP_VECTORS_H) #define __DSDP_VECTORS_H #include /*! \file dsdpvec.h \brief Vector operations used by the solver */ /* Define DSDP Vector Structure */ /*! \typedef struct DSDPVec_C DSDPVec; \brief This object hold m+2 variables: a scaling of C, the y variables, and r. Unscaled, this vector is \f$ [ -1 \ y_1 \ \ldots \ y_m \ r ] \f$. */ struct DSDPVec_C{ int dim; double *val; }; typedef struct DSDPVec_C DSDPVec; #define DSDPVecGetArray(a,b) 0;{ *(b)=((a).val); } #define DSDPVecRestoreArray(a,b) 0;{ *(b)=0; } #define DSDPVecGetSize(a,b) 0;{ *(b)=((a).dim); } #define DSDPVecAddElement(a,b,c) 0;{ if (c){((a).val[b])+=(c);} } #define DSDPVecSetElement(a,b,c) 0;{ {((a).val[b])=(c); } } #define DSDPVecGetElement(a,b,c) 0;{ *(c)=((a).val[b]); } #define DSDPVecSetR(a,b) 0;{ {((a).val[(a).dim-1])=(b); } } #define DSDPVecAddR(a,b) 0;{ if(b){((a).val[(a).dim-1])+=(b); } } #define DSDPVecGetR(a,b) 0;{ *(b)=((a).val[(a).dim-1]); } #define DSDPVecSetC(a,b) 0;{ {((a).val[0])=(b); } } #define DSDPVecAddC(a,b) 0;{ if(b){((a).val[0])+=(b); } } #define DSDPVecGetC(a,b) 0;{ *(b)=((a).val[0]); } #define DSDPVecCreateWArray(a,b,c) 0;{ (*(a)).val=(b); (*(a)).dim=(c);} /* extern int DSDPVecGetArray(DSDPVec, double **); extern int DSDPVecRestoreArray(DSDPVec, double **); extern int DSDPVecGetSize(DSDPVec, int *); extern int DSDPVecAddElement(DSDPVec, int, double); extern int DSDPVecSetElement(DSDPVec, int, double); extern int DSDPVecGetElement(DSDPVec, int, double*); extern int DSDPVecCreateWArray(DSDPVec*, double*, int); */ #ifdef __cplusplus extern "C" { #endif extern int DSDPVecCreateSeq(int,DSDPVec *); extern int DSDPVecDuplicate(DSDPVec,DSDPVec *); extern int DSDPVecSet(double, DSDPVec ); extern int DSDPVecISet(int*,DSDPVec); extern int DSDPVecZero(DSDPVec ); extern int DSDPVecNormalize(DSDPVec ); extern int DSDPVecSetValue(DSDPVec,int,double); extern int DSDPVecSetBasis(DSDPVec,int); extern int DSDPVecCopy( DSDPVec, DSDPVec); extern int DSDPVecScale(double, DSDPVec); extern int DSDPVecScaleCopy(DSDPVec, double, DSDPVec); extern int DSDPVecAXPY(double, DSDPVec, DSDPVec); extern int DSDPVecAYPX(double, DSDPVec, DSDPVec); extern int DSDPVecWAXPY(DSDPVec,double,DSDPVec,DSDPVec); extern int DSDPVecWAXPBY(DSDPVec,double,DSDPVec,double,DSDPVec); extern int DSDPVecPointwiseMin( DSDPVec, DSDPVec, DSDPVec); extern int DSDPVecPointwiseMax( DSDPVec, DSDPVec, DSDPVec); extern int DSDPVecPointwiseMult( DSDPVec, DSDPVec, DSDPVec); extern int DSDPVecPointwiseDivide( DSDPVec, DSDPVec, DSDPVec); extern int DSDPVecReciprocalSqrt(DSDPVec); extern int DSDPVecDot(DSDPVec, DSDPVec, double *); extern int DSDPVecSum( DSDPVec, double *); extern int DSDPVecNorm1( DSDPVec, double *); extern int DSDPVecNorm2( DSDPVec, double *); extern int DSDPVecNorm22( DSDPVec, double *); extern int DSDPVecNormInfinity( DSDPVec, double *); extern int DSDPVecAbsoluteValue( DSDPVec); extern int DSDPVecShift(double, DSDPVec); extern int DSDPVecView( DSDPVec); extern int DSDPVecDestroy(DSDPVec*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/solver/dualalg.c0000644000175000017500000005063110326241002015652 0ustar twernertwerner#include "dsdp.h" #include "dsdpsys.h" /*! \file dualalg.c \brief Implements the dual-scaling algorithm. */ int DSDPChooseBarrierParameter(DSDP,double,double*,double*); int DSDPYStepLineSearch(DSDP,double,double,DSDPVec); int DSDPYStepLineSearch2(DSDP,double,double,DSDPVec); int DSDPResetY0(DSDP); #undef __FUNCT__ #define __FUNCT__ "DSDPYStepLineSearch" /*! \fn int DSDPYStepLineSearch(DSDP dsdp, double mutarget, double dstep0, DSDPVec dy); \param dsdp the solver \param mutarget barrier parameter \param dstep0 initial step length \param dy step direction \brief Used for Newton step, the merit function of this line search is the dual potential function. */ int DSDPYStepLineSearch(DSDP dsdp, double mutarget, double dstep0, DSDPVec dy){ /* The merit function is the dual potential function */ int info,attempt,maxattempts=30; double dstep,newpotential,logdet; double better=0.05, steptol=1e-8,maxmaxstep=0; DSDPTruth psdefinite; DSDPFunctionBegin; info=DSDPComputeMaxStepLength(dsdp,dy,DUAL_FACTOR,&maxmaxstep);DSDPCHKERR(info); info=DSDPComputePotential(dsdp,dsdp->y,dsdp->logdet,&dsdp->potential);DSDPCHKERR(info); if (dsdp->pnorm<0.5) better=0.0; dstep=DSDPMin(dstep0,0.95*maxmaxstep); if (dstep * dsdp->pnorm > dsdp->maxtrustradius) dstep=dsdp->maxtrustradius/dsdp->pnorm; DSDPLogInfo(0,8,"Full Dual StepLength %4.4e, %4.4e\n",maxmaxstep,dstep); psdefinite=DSDP_FALSE; for (psdefinite=DSDP_FALSE,attempt=0; attemptytemp);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->ytemp,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite==DSDP_TRUE){ info=DSDPComputeLogSDeterminant(dsdp,&logdet);DSDPCHKERR(info); info=DSDPComputePotential(dsdp,dsdp->ytemp,logdet,&newpotential);DSDPCHKERR(info); if (newpotential>dsdp->potential-better && dstep > 0.001/dsdp->pnorm ){ DSDPLogInfo(0,2,"Not sufficient reduction. Reduce stepsize. Trust Radius: %4.4e\n",dstep*dsdp->pnorm); psdefinite=DSDP_FALSE; dstep=0.3*dstep; } } else { dstep=dstep/3.0; DSDPLogInfo(0,2,"Dual Matrix not Positive Definite: Reduce step %4.4e",dstep); } if (dstep*dsdp->pnorm < steptol && dstep < steptol) break; } /* Hopefully, the initial step size works and only go through loop once */ if (psdefinite==DSDP_TRUE){ info=DSDPSetY(dsdp,dstep,logdet,dsdp->ytemp);DSDPCHKERR(info); } else { info=DSDPSetY(dsdp,0,dsdp->logdet,dsdp->y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPYStepLineSearch2" /*! \fn int DSDPYStepLineSearch2(DSDP dsdp, double mutarget, double dstep0, DSDPVec dy); \param dsdp the solver \param mutarget barrier parameter \param dstep0 initial step length \param dy step direction \brief Used for centering steps, the merit function of this line search is the objective function plus the barrier term. */ int DSDPYStepLineSearch2(DSDP dsdp, double mutarget, double dstep0, DSDPVec dy){ /* The merit function is the objective (DD) plus the barrier function */ /* This line search is used in the corrector steps */ int info, attempt, maxattempts=10; double dstep,newpotential,bdotdy,oldpotential,logdet; double maxmaxstep=0,steptol=1e-6; double a,b; DSDPTruth psdefinite; DSDPFunctionBegin; info=DSDPComputeMaxStepLength(dsdp,dy,DUAL_FACTOR,&maxmaxstep);DSDPCHKERR(info); info=DSDPComputePotential2(dsdp,dsdp->y,mutarget, dsdp->logdet,&oldpotential);DSDPCHKERR(info); info=DSDPVecDot(dsdp->rhs,dy,&bdotdy);DSDPCHKERR(info); dstep=DSDPMin(dstep0,0.95*maxmaxstep); if (dstep * dsdp->pnorm > dsdp->maxtrustradius) dstep=dsdp->maxtrustradius/dsdp->pnorm; DSDPLogInfo(0,8,"Full Dual StepLength %4.4e, %4.4e\n",maxmaxstep,dstep); for (psdefinite=DSDP_FALSE,attempt=0; attemptytemp);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->ytemp,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite==DSDP_TRUE){ info=DSDPComputeLogSDeterminant(dsdp,&logdet);DSDPCHKERR(info); info=DSDPComputePotential2(dsdp,dsdp->ytemp,mutarget,logdet,&newpotential);DSDPCHKERR(info); b=bdotdy; a=2*(newpotential-oldpotential+bdotdy*dstep)/(dstep*dstep); if (newpotential>oldpotential-0.1*dstep*bdotdy ){ DSDPLogInfo(0,2,"Not sufficient reduction. Reduce stepsize. Step:: %4.4e\n",dstep); psdefinite=DSDP_FALSE; if (b/a0){ dstep=b/a;} else { dstep=dstep/2; } } } else { dstep=dstep/2.0; DSDPLogInfo(0,2,"Dual Matrix not Positive Definite: Reduce step %4.4e",dstep); } } /* Hopefully, the initial step size works and only go through loop once */ if (psdefinite==DSDP_TRUE && dstep>=steptol){ info=DSDPSetY(dsdp,dstep,logdet,dsdp->ytemp);DSDPCHKERR(info); } else { info=DSDPSetY(dsdp,0,dsdp->logdet,dsdp->y);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSolveDynmaicRho" /*! \fn int DSDPSolveDynamicRho(DSDP dsdp); \brief Apply dual-scaling algorithm. \param dsdp the solver */ int DSDPSolveDynamicRho(DSDP dsdp){ int info,attempt,maxattempts; double dd1,dd2,mutarget,ppnorm; DSDPTerminationReason reason; DSDPTruth cg1; DSDPTruth psdefinite; DSDPFunctionBegin; info=DSDPVecCopy(dsdp->y,dsdp->y0);DSDPCHKERR(info); for (dsdp->itnow=0; dsdp->itnow <= dsdp->maxiter+1 ; dsdp->itnow++){ /* Check Convergence, and print information if desired */ info=DSDPCheckConvergence(dsdp,&reason);DSDPCHKERR(info); if (reason != CONTINUE_ITERATING){break;} if (dsdp->mu0>0){dsdp->mutarget=DSDPMin(dsdp->mutarget,dsdp->mu0);} /* Compute the Gram matrix M and rhs */ info=DSDPComputeDualStepDirections(dsdp); DSDPCHKERR(info); if (dsdp->reason==DSDP_INDEFINITE_SCHUR_MATRIX){continue;} info=DSDPComputePDY(dsdp,dsdp->mutarget,dsdp->dy,&dsdp->pnorm); DSDPCHKERR(info); DSDPEventLogBegin(dsdp->ptime); info=DSDPComputePY(dsdp,1.0,dsdp->ytemp);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->ytemp,PRIMAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite==DSDP_TRUE){ dsdp->pstep=1.0; info=DSDPSaveYForX(dsdp,dsdp->mutarget,dsdp->pstep);DSDPCHKERR(info); } else { dsdp->pstep=0.0; } if (dsdp->usefixedrho==DSDP_TRUE){ dsdp->rho=dsdp->rhon*dsdp->np; mutarget=(dsdp->ppobj-dsdp->ddobj)/(dsdp->rho); dsdp->pstep=0.5; } else { info = DSDPChooseBarrierParameter(dsdp,dsdp->mutarget,&dsdp->pstep,&mutarget);DSDPCHKERR(info); dsdp->rho=(dsdp->ppobj-dsdp->ddobj)/(mutarget); } DSDPEventLogEnd(dsdp->ptime); DSDPLogInfo(0,6,"Current mu=%4.8e, Target X with mu=%4.8e, Rho: %8.4e, Primal Step Length: %4.8f, pnorm: %4.8e\n",dsdp->mu,mutarget,dsdp->rho/dsdp->np,dsdp->pstep, dsdp->pnorm); /* Take Dual Step */ /* Compute distance from chosen point on central path Pnorm */ DSDPEventLogBegin(dsdp->dtime); info=DSDPComputeDY(dsdp,mutarget,dsdp->dy,&dsdp->pnorm); DSDPCHKERR(info); if (dsdp->pnorm<0.1){ mutarget/=10; info=DSDPComputeDY(dsdp,mutarget,dsdp->dy,&dsdp->pnorm); DSDPCHKERR(info);} info=DSDPYStepLineSearch(dsdp, mutarget, 1.0, dsdp->dy);DSDPCHKERR(info); DSDPEventLogEnd(dsdp->dtime); maxattempts=dsdp->reuseM; if (dsdp->dstep<1 && dsdp->rgap<1e-5) maxattempts=0; if (dsdp->dstep<1e-13) maxattempts=0; if (dsdp->rgap<1e-6) maxattempts=0; if (maxattempts>dsdp->reuseM) maxattempts=dsdp->reuseM; for (attempt=0;attempt0 && dsdp->pnorm < 0.1) break; if (attempt > 0 && dsdp->dstep<1e-4) break; if (dsdp->rflag) break; DSDPEventLogBegin(dsdp->ctime); DSDPLogInfo(0,2,"Reuse Matrix %d: Ddobj: %12.8e, Pnorm: %4.2f, Step: %4.2f\n",attempt,dsdp->ddobj,dsdp->pnorm,dsdp->dstep); info=DSDPInvertS(dsdp);DSDPCHKERR(info); info=DSDPComputeG(dsdp,dsdp->rhstemp,dsdp->rhs1,dsdp->rhs2);DSDPCHKERR(info); if (dsdp->slestype==2 || dsdp->slestype==3){ if (dsdp->rflag){info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs1,dsdp->dy1,cgtol,&cg1);DSDPCHKERR(info);} info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs2,dsdp->dy2,cgtol,&cg1);DSDPCHKERR(info); } info=DSDPVecDot(dsdp->b,dsdp->dy1,&dd1);DSDPCHKERR(info); info=DSDPVecDot(dsdp->b,dsdp->dy2,&dd2);DSDPCHKERR(info); if (dd1>0 && dd2>0){ mutarget=DSDPMin(mutarget,dd1/dd2*dsdp->schurmu); } mutarget=mutarget*(dsdp->np/(dsdp->np+sqrt(dsdp->np))); info=DSDPComputeDY(dsdp,mutarget,dsdp->dy, &ppnorm);DSDPCHKERR(info); if (ppnorm<=0){ DSDPEventLogEnd(dsdp->ctime); break; } dsdp->pnorm=ppnorm; info=DSDPYStepLineSearch2(dsdp, mutarget, dsdp->dstep, dsdp->dy);DSDPCHKERR(info); DSDPEventLogEnd(dsdp->ctime); } if (attempt>0)dsdp->dstep=1.0; dsdp->mutarget=DSDPMin(dsdp->mu,mutarget); info=DSDPGetRR(dsdp,&dd1);DSDPCHKERR(info); if (dsdp->itnow==0 && dsdp->xmaker[0].pstep<1.0 && dd1> 0 && dsdp->pstep<1.0 && dsdp->goty0==DSDP_FALSE){ info=DSDPResetY0(dsdp);DSDPCHKERR(info); continue; dsdp->goty0=DSDP_FALSE; } } /* End of Dual Scaling Algorithm */ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPChooseBarrierParameter" /*! \fn int DSDPChooseBarrierParameter(DSDP dsdp, double mutarget, double *ppstep, double *nextmutarget); \param dsdp solver \param mutarget current barrier parameter \param ppstep set to primal step length \param nextmutarget set to new target barrier parameter \brief DSDP barrier heuristic choses the smalles value of mu such that X>0 This routine implements a dynamic strategy for reducing the barrier parameter. Basically, it looks for the smallest barrier parameter for which the primal matrix X is psd. Lower and upper bounds to this parameter also apply. */ int DSDPChooseBarrierParameter(DSDP dsdp, double mutarget, double *ppstep, double *nextmutarget){ int attempt,info,count=0; double pnorm,pstep=*ppstep,pmumin,mur, dmury1, mutarget2; DSDPTruth psdefinite=DSDP_FALSE; DSDPFunctionBegin; *nextmutarget=mutarget; /* Compute a feasible primal matrix with the smallest possible value of \mu */ /* Start by finding a psd feasible matrix */ if (*ppstep >=1){ pstep=1.0; /* PS should alread be formed and factored */ } else { mur=-1.0/mutarget; info=DSDPComputePDY(dsdp,mutarget,dsdp->dy,&pnorm); DSDPCHKERR(info); info=DSDPComputeMaxStepLength(dsdp,dsdp->dy,DUAL_FACTOR,&pstep);DSDPCHKERR(info); /* pstep=DSDPMin(0.97*pstep,1.0); */ if (pstep<1.0) {pstep=DSDPMin(0.97*pstep,1.0);} else {pstep=DSDPMin(1.0*pstep,1.0);} while (psdefinite==DSDP_FALSE){ if (count > 2 && pstep <1e-8){pstep=0;break;} info=DSDPComputePY(dsdp,pstep,dsdp->ytemp);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->ytemp,PRIMAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite==DSDP_FALSE){ if (count>1) pstep=0.5*pstep; else pstep=0.97*pstep; DSDPLogInfo(0,2,"Reducing pstep: %8.8e\n",pstep); count++; } } *ppstep=pstep; if (pstep > dsdp->xmaker[0].pstep || mutarget < dsdp->xmaker[0].mu * 1.0e-8){ info=DSDPSaveYForX(dsdp,mutarget,pstep);DSDPCHKERR(info); } if (pstep==0){ DSDPFunctionReturn(0); } } /* Now determine how much smaller of mu can be used */ mur=pstep/mutarget; info=DSDPComputePDY1(dsdp,mur,dsdp->rhstemp); DSDPCHKERR(info); /* Smallest value of mu that gives a positive definite matrix */ info=DSDPComputeMaxStepLength(dsdp,dsdp->rhstemp,PRIMAL_FACTOR,&dmury1);DSDPCHKERR(info); dmury1 = DSDPMin(1000,0.97*dmury1); /* We could test the point, My tests say its not necessary -- its good! */ attempt=0;psdefinite=DSDP_FALSE; pmumin=mutarget / (1.0 + 1.0 * dmury1); /* This should be positive definite */ while ( 0 && psdefinite==DSDP_FALSE){ pmumin=mutarget / (1.0 + 1.0 * dmury1); /* This should be positive definite */ if (attempt>2){pmumin=mutarget;}/* We have actually factored this one. It is PSD. */ info=DSDPComputePDY(dsdp,pmumin,dsdp->dy,&pnorm); DSDPCHKERR(info); info=DSDPComputePY(dsdp,pstep,dsdp->ytemp); DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->ytemp,PRIMAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite==DSDP_FALSE){ dmury1*=0.9; /* printf("NO GOOD \n"); */ } else { /* printf("ITS GOOD \n"); */} attempt++; DSDPLogInfo(0,2,"GOT X: Smallest Mu for feasible X: %4.4e.\n",pmumin); } DSDPLogInfo(0,6,"GOT X: Smallest Mu for feasible X: %4.4e \n",pmumin); mutarget2=mutarget; if (dsdp->pstep==1){ mutarget2 = pmumin; } else { /* printf("PMUMIN: %4.4e MUTARGET: %4.4e \n",pmumin,dsdp->mutarget); */ mutarget2 = mutarget; mutarget2 = (pstep)*mutarget + (1.0-pstep)*dsdp->mu; mutarget2 = (pstep)*pmumin + (1.0-pstep)*dsdp->mu; } mutarget2=DSDPMax(dsdp->mu/dsdp->rhon,mutarget2); if (dsdp->mu0>0){mutarget2=DSDPMin(mutarget2,dsdp->mu0);} *nextmutarget=mutarget2; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPResetY0" /*! \fn int DSDPResetY0(DSDP dsdp); \param dsdp solver \brief After 1 iteration, consider increasing the variable r */ int DSDPResetY0(DSDP dsdp){ int info; double r,rr,dd; DSDPTruth psdefinite; DSDPFunctionBegin; info=DSDPComputeDY(dsdp,dsdp->mutarget,dsdp->dy,&dsdp->pnorm); DSDPCHKERR(info); info=DSDPVecCopy(dsdp->y0,dsdp->y);DSDPCHKERR(info); info=DSDPGetRR(dsdp,&r);DSDPCHKERR(info); rr=DSDPMax(r*10000,1e12); info=DSDPSetRR(dsdp,rr);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->y,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); info=DSDPComputeLogSDeterminant(dsdp,&dsdp->logdet);DSDPCHKERR(info); info=DSDPSetY(dsdp,1.0,dsdp->logdet,dsdp->y);DSDPCHKERR(info); info=DSDPVecGetR(dsdp->b,&dd);DSDPCHKERR(info); dsdp->mutarget=fabs(rr*dd); dsdp->mu=fabs(rr*dd); /* dsdp->par.mu0=mutarget; */ dsdp->goty0=DSDP_TRUE; DSDPLogInfo(0,2,"Restart algorithm\n"); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeDualStepDirections(DSDP dsdp); \param dsdp the solver \brief Compute the step direction by computing a linear system and solving it. DSDP first attempts unpreconditioned CG to the matrix. Once the number of iterations becomes too large, it swithes a CG preconditioned by the Cholesky factorization. Usually only one iteration of the preconditioned CG is necessary, but solutions with large norms and very precise solutions may require additional iterations. */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeDualStepDirections" int DSDPComputeDualStepDirections(DSDP dsdp){ int info,computem=1; double madd,ymax,cgtol=1e-7; DSDPTruth cg1,cg2,psdefinite; DSDPFunctionBegin; if (dsdp->itnow>30) dsdp->slestype=3; if (dsdp->rgap<1e-3) dsdp->slestype=3; if (dsdp->m<40) dsdp->slestype=3; if (0 && dsdp->itnow>20 && dsdp->m<500) dsdp->slestype=3; info=DSDPGetMaxYElement(dsdp,&ymax);DSDPCHKERR(info); if (dsdp->slestype==1){ cg1=DSDP_TRUE; cg2=DSDP_TRUE; info=DSDPInvertS(dsdp);DSDPCHKERR(info); info=DSDPComputeG(dsdp,dsdp->rhstemp,dsdp->rhs1,dsdp->rhs2);DSDPCHKERR(info); info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs1,dsdp->dy1,cgtol,&cg1);DSDPCHKERR(info); if (cg1==DSDP_TRUE){info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs2,dsdp->dy2,cgtol,&cg2);DSDPCHKERR(info);} if (cg1==DSDP_FALSE || cg2==DSDP_FALSE) dsdp->slestype=2; } if (dsdp->slestype==2){ cg1=DSDP_TRUE; cg2=DSDP_TRUE; DSDPLogInfo(0,9,"Compute Hessian\n"); info=DSDPInvertS(dsdp);DSDPCHKERR(info); info=DSDPComputeHessian(dsdp,dsdp->M,dsdp->rhs1,dsdp->rhs2);DSDPCHKERR(info); computem=0; DSDPLogInfo(0,9,"Apply CG\n"); info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs1,dsdp->dy1,cgtol,&cg1);DSDPCHKERR(info); if (cg1==DSDP_TRUE){info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs2,dsdp->dy2,cgtol,&cg2);DSDPCHKERR(info);} if (cg1==DSDP_FALSE || cg2==DSDP_FALSE) dsdp->slestype=3; } if (dsdp->slestype==3){ DSDPLogInfo(0,9,"Factor Hessian\n"); psdefinite=DSDP_FALSE; if (dsdp->Mshift < 1e-12 || dsdp->rgap<0.1 || dsdp->Mshift > 1e-6){ madd=dsdp->Mshift; } else { madd=1e-13; } if (computem){ info=DSDPInvertS(dsdp);DSDPCHKERR(info); } while (psdefinite==DSDP_FALSE){ if (0==1 && dsdp->Mshift>dsdp->maxschurshift){ info = DSDPSetConvergenceFlag(dsdp,DSDP_INDEFINITE_SCHUR_MATRIX); DSDPCHKERR(info); break; } if (0 && dsdp->Mshift*ymax>dsdp->pinfeastol/10){ info = DSDPSetConvergenceFlag(dsdp,DSDP_INDEFINITE_SCHUR_MATRIX); DSDPCHKERR(info); break; } if (madd*ymax>dsdp->pinfeastol*1000){ info = DSDPSetConvergenceFlag(dsdp,DSDP_INDEFINITE_SCHUR_MATRIX); DSDPCHKERR(info); break; } if (computem){ info=DSDPComputeHessian(dsdp,dsdp->M,dsdp->rhs1,dsdp->rhs2);DSDPCHKERR(info);} if (0==1){info=DSDPSchurMatView(dsdp->M);DSDPCHKERR(info);} info = DSDPSchurMatShiftDiagonal(dsdp->M,madd);DSDPCHKERR(info); info = DSDPSchurMatFactor(dsdp->M,&psdefinite); DSDPCHKERR(info); computem=1; if (psdefinite==DSDP_FALSE){ madd=madd*4 + 1.0e-13; } } dsdp->Mshift=madd; if (psdefinite==DSDP_TRUE){ info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs1,dsdp->dy1,cgtol,&cg1);DSDPCHKERR(info); info=DSDPCGSolve(dsdp,dsdp->M,dsdp->rhs2,dsdp->dy2,cgtol,&cg2);DSDPCHKERR(info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputeDualStepDirections" int DSDPRefineStepDirection(DSDP dsdp,DSDPVec rhs, DSDPVec dy){ int info; double cgtol=1e-20; DSDPTruth cg1; DSDPFunctionBegin; if (dsdp->reason==DSDP_INDEFINITE_SCHUR_MATRIX){ } else if (dsdp->reason==DSDP_SMALL_STEPS){ } else if (dsdp->pstep<1){ } else { dsdp->slestype=4; info=DSDPCGSolve(dsdp,dsdp->M,rhs,dy,cgtol,&cg1);DSDPCHKERR(info); dsdp->slestype=3; } DSDPFunctionReturn(0); } #include "dsdp5.h" #undef __FUNCT__ #define __FUNCT__ "DSDPInitializeVariables" /*! \fn int DSDPInitializeVariables( DSDP dsdp ); \param dsdp the solver \brief Initialize variables and factor S */ int DSDPInitializeVariables( DSDP dsdp ){ int info; double r0,mutarget=dsdp->mutarget,penalty; DSDPTruth psdefinite=DSDP_FALSE; DSDPFunctionBegin; info=DSDPGetRR(dsdp,&r0);DSDPCHKERR(info); dsdp->rho=dsdp->np*dsdp->rhon; if (r0>=0) { /* Use the specified starting point */ info=DSDPComputeObjective(dsdp,dsdp->y,&dsdp->ddobj);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->y,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (mutarget<0) mutarget=(dsdp->ppobj-dsdp->ddobj)/(dsdp->rho); } else { info=DSDPGetPenalty(dsdp,&penalty);DSDPCHKERR(info); r0=0.1/(1.0+dsdp->cnorm); while (psdefinite==DSDP_FALSE ){ r0=r0*100; DSDPLogInfo(0,9,"Set Initial R0 %4.2e\n",r0); info=DSDPSetRR(dsdp,r0);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->y,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); } r0=r0*dsdp->np; if (dsdp->cnorm>0 && dsdp->anorm>0 && dsdp->cnorm/dsdp->anorm<1){ r0=r0/(dsdp->cnorm/dsdp->anorm);} dsdp->mu=r0*penalty; if (mutarget<0){ mutarget=(dsdp->ppobj-dsdp->ddobj)/(dsdp->rho); mutarget=(dsdp->ppobj-dsdp->ddobj)/(dsdp->np); mutarget=r0*penalty; } DSDPLogInfo(0,9,"Set Initial R0 %4.2e\n",r0); info=DSDPSetRR(dsdp,r0);DSDPCHKERR(info); info=DSDPComputeObjective(dsdp,dsdp->y,&dsdp->ddobj);DSDPCHKERR(info); info=DSDPComputeSS(dsdp,dsdp->y,DUAL_FACTOR,&psdefinite);DSDPCHKERR(info); } info=DSDPComputeObjective(dsdp,dsdp->y,&dsdp->ddobj);DSDPCHKERR(info); if (psdefinite==DSDP_FALSE){ info=DSDPSetConvergenceFlag(dsdp,DSDP_INFEASIBLE_START);DSDPCHKERR(info); } else { info=DSDPComputeLogSDeterminant(dsdp,&dsdp->logdet);DSDPCHKERR(info); info=DSDPComputePotential(dsdp,dsdp->y,dsdp->logdet,&dsdp->potential);DSDPCHKERR(info); } /* Tough guess, as all these rules suggest */ info=DSDPSetY(dsdp,0,dsdp->logdet,dsdp->y);DSDPCHKERR(info); info=DSDPSaveYForX(dsdp,dsdp->xmaker[0].mu,0);DSDPCHKERR(info); dsdp->mutarget=mutarget; dsdp->pstep=0.0; dsdp->pnorm=0; /* dsdp->par.mu0=mutarget; */ DSDPFunctionReturn(0); } /*! \fn int DSDPComputeAndFactorS(DSDP dsdp, DSDPTruth *psdefinite) \brief Compute and factor the dual matrix variables. This routine may be necessary after computing the X variables. \param dsdp is the solver \param psdefinite is DSDP_TRUE if the S variables are positive definite. \sa DSDPGetY() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeAndFactorS" int DSDPComputeAndFactorS(DSDP dsdp,DSDPTruth *psdefinite){ int info; DSDPFunctionBegin; info=DSDPComputeSS(dsdp,dsdp->y,DUAL_FACTOR,psdefinite);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dualimpl.c0000644000175000017500000003077210326241002016054 0ustar twernertwerner#include "dsdp.h" #include "dsdpsys.h" /*! \file dualimpl.c \brief Dual-scaling operations needed in the solver. */ /*! \fn int DSDPComputeObjective(DSDP dsdp, DSDPVec Y, double *ddobj); \brief Compute the objective function (DD). \param dsdp is the solver \param Y Current variables \param ddobj objective value \sa DSDPComputeNewY() \sa DSDPGetDDObjective() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeObjective" int DSDPComputeObjective(DSDP dsdp, DSDPVec Y, double *ddobj){ int info; DSDPFunctionBegin; info = DSDPVecDot(Y,dsdp->b,ddobj);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeDY(DSDP dsdp, double mu, DSDPVec DY, double *pnorm); \brief Compute the step direction. \param dsdp the solver \param mu barrier parameter \param DY Step direction \param pnorm distance to the target Assuming the affine direction and centering direction have alread been computed, combine them with the appropriate barrier parameter. \sa DSDPComputeRHS() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeDY" int DSDPComputeDY(DSDP dsdp, double mu, DSDPVec DY, double *pnorm){ int info; double ppnorm,ddy1=fabs(1.0/mu*dsdp->schurmu),ddy2=-1.0; DSDPFunctionBegin; info=DSDPComputeRHS(dsdp,mu,dsdp->rhs); DSDPCHKERR(info); info=DSDPVecWAXPBY(DY,ddy1,dsdp->dy1,ddy2,dsdp->dy2);DSDPCHKERR(info); info=DSDPComputePNorm(dsdp,mu,DY,&ppnorm);DSDPCHKERR(info); if (ppnorm<0){ /* If pnorm < 0 there are SMW numerical issues */ DSDPLogInfo(0,2,"Problem with PNORM: %4.4e < 0 \n",ppnorm); /* ppnorm=1.0; */ } *pnorm=ppnorm; DSDPFunctionReturn(0); } /*! \fn int DSDPComputePDY(DSDP dsdp, double mu, DSDPVec DY, double *pnorm); \brief Compute the step direction. \param dsdp the solver \param mu barrier parameter \param DY Step direction \param pnorm distance to the target Assuming the affine direction and centering direction have alread been computed, combine them with the appropriate barrier parameter. \sa DSDPComputeRHS() \sa DSDPComputeDY() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputePDY" int DSDPComputePDY(DSDP dsdp, double mu, DSDPVec DY, double *pnorm){ int info; double ppnorm,ddy1=-fabs(1.0/mu*dsdp->schurmu),ddy2=1.0; DSDPFunctionBegin; info=DSDPComputeRHS(dsdp,mu,dsdp->rhs); DSDPCHKERR(info); info=DSDPVecWAXPBY(DY,ddy1,dsdp->dy1,ddy2,dsdp->dy2);DSDPCHKERR(info); info=DSDPComputePNorm(dsdp,mu,DY,&ppnorm);DSDPCHKERR(info); if (ppnorm<0){ /* If pnorm < 0 there are SMW numerical issues */ DSDPLogInfo(0,2,"Problem with PNORM: %4.4e < 0 \n",ppnorm); /* ppnorm=1.0; */ } *pnorm=ppnorm; DSDPFunctionReturn(0); } /*! \fn int DSDPComputePDY1(DSDP dsdp, double mur, DSDPVec DY1); \brief Compute an affine step direction dy1. \param dsdp the solver \param mur reciprocal of barrier parameter \param DY1 Step direction Assuming the affine direction has alread been computed, scale it. \sa DSDPComputeDY() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputePDY1" int DSDPComputePDY1(DSDP dsdp, double mur, DSDPVec DY1){ int info; double ddy1=-fabs(mur*dsdp->schurmu); DSDPFunctionBegin; info=DSDPVecScaleCopy(dsdp->dy1,ddy1,DY1); DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeNewY(DSDP dsdp, double beta, DSDPVec Y); \brief Update the Y variables. \param dsdp the solver \param beta step length \param Y the new solution Add a multiple of the step direction to the current solution. */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeNewY" int DSDPComputeNewY(DSDP dsdp, double beta, DSDPVec Y){ int info; double rtemp; DSDPFunctionBegin; info=DSDPVecWAXPY(Y,beta,dsdp->dy,dsdp->y);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rtemp);DSDPCHKERR(info); rtemp=DSDPMin(0,rtemp); info=DSDPSchurMatSetR(dsdp->M,rtemp);DSDPCHKERR(info); info=DSDPVecSetR(Y,rtemp);DSDPCHKERR(info); info=DSDPApplyFixedVariables(dsdp->M,Y);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputePY(DSDP dsdp, double beta, DSDPVec PY); \brief Compute PY = Y - beta DY for use in computing X. \param dsdp the solver \param beta step length \param PY the new value \sa DSDPComputeNewY() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputePY" int DSDPComputePY(DSDP dsdp, double beta, DSDPVec PY){ int info; DSDPFunctionBegin; info=DSDPVecWAXPY(PY,beta,dsdp->dy,dsdp->y);DSDPCHKERR(info); info=DSDPApplyFixedVariables(dsdp->M,PY);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeRHS(DSDP dsdp, double mu, DSDPVec RHS); \brief Compute the right-hand side of the linear system that determines the step direction. \param dsdp the solver \param mu barrier parameter \param RHS right-hand side direction Assuming that the gradient of the objective and the gradient of the barrier have already been computed, combine them with the appropriate barrier parameter. This vector is basically \f$ b - mu * A(S^{-1}) \f$ \sa DSDPComputeDY() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeRHS" int DSDPComputeRHS(DSDP dsdp, double mu, DSDPVec RHS){ int info; double ddrhs1=1.0/mu*dsdp->schurmu,ddrhs2=-( mu/fabs(mu) ); DSDPFunctionBegin; info=DSDPVecWAXPBY(RHS,ddrhs1,dsdp->rhs1,ddrhs2,dsdp->rhs2);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPComputePNorm" /*! \fn int DSDPComputePNorm(DSDP dsdp, double mu, DSDPVec DY, double *pnorm); \brief Compute proximity to a point on the central path. \param dsdp the solver \param mu barrier parameter \param DY Newton step direction \param pnorm the norm \sa DSDPComputeDY() */ int DSDPComputePNorm(DSDP dsdp, double mu, DSDPVec DY, double *pnorm){ int info; double ppnorm=0; DSDPFunctionBegin; info=DSDPComputeRHS(dsdp,mu,dsdp->rhs); DSDPCHKERR(info); info = DSDPVecDot(dsdp->rhs,DY,&ppnorm);DSDPCHKERR(info); ppnorm/=dsdp->schurmu; if (ppnorm >= 0){ /* Theoretically True */ *pnorm=sqrt(ppnorm); } else { DSDPLogInfo(0,2,"Problem with PNORM: %4.4e is not positive.\n",ppnorm); *pnorm=ppnorm; } if (*pnorm!=*pnorm){DSDPSETERR1(1,"Problem with PNORM: %4.4e is not positive.\n",ppnorm);} DSDPFunctionReturn(0); } /*! \fn int DSDPComputeDualityGap(DSDP dsdp, double mu, double *gap); \brief Compute the current duality gap. \param dsdp the solver \param mu barrier parameter \param gap the duality gap \sa DSDPGetDualityGap() \sa DSDPGetPPObjective() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeDualityGap" int DSDPComputeDualityGap(DSDP dsdp, double mu, double *gap){ int info; double newgap=0,pnorm; double smu=1.0/dsdp->schurmu; DSDPFunctionBegin; info=DSDPComputeDY(dsdp,mu,dsdp->dy,&pnorm); DSDPCHKERR(info); info=DSDPVecDot(dsdp->dy,dsdp->rhs2,&newgap);DSDPCHKERR(info); newgap = (newgap*smu+dsdp->np)*mu; if (newgap<=0){ DSDPLogInfo(0,2,"GAP :%4.4e<0: Problem\n",newgap); } else { DSDPLogInfo(0,2,"Duality Gap: %12.8e, Update primal objective: %12.8e\n",newgap,dsdp->ddobj+newgap); } newgap=DSDPMax(0,newgap); *gap=newgap; DSDPFunctionReturn(0); } /*! \fn int DSDPComputePotential(DSDP dsdp, DSDPVec y, double logdet, double *potential); \brief Compute the potential of the given point. \param dsdp the solver \param y variables \param logdet logarithmic barrier function of the given point \param potential return the potential of the given point. \sa DSDPSetPotentialParameter() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputePotential" int DSDPComputePotential(DSDP dsdp, DSDPVec y, double logdet, double *potential){ int info; double dpotential,gap,ddobj; DSDPFunctionBegin; info=DSDPComputeObjective(dsdp,y,&ddobj);DSDPCHKERR(info); gap=dsdp->ppobj-ddobj; if (gap>0) dpotential=dsdp->rho*log(gap)-logdet; else {dpotential=dsdp->potential+1;} *potential=dpotential; DSDPLogInfo(0,9,"Gap: %4.4e, Log Determinant: %4.4e, Log Gap: %4.4e\n",gap,logdet,log(gap)); DSDPFunctionReturn(0); } /*! \fn int DSDPComputePotential2(DSDP dsdp, DSDPVec y, double mu, double logdet, double *potential); \brief Compute the objective function plus the barrier function. \param dsdp the solver \param y variables \param mu barrier function \param logdet logarithmic barrier function of the given point \param potential return the potential of the given point.\ \sa DSDPGetBarrierParameter() */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputePotential2" int DSDPComputePotential2(DSDP dsdp, DSDPVec y, double mu, double logdet, double *potential){ int info; double ddobj; DSDPFunctionBegin; info=DSDPComputeObjective(dsdp,y,&ddobj);DSDPCHKERR(info); *potential=-(ddobj + mu*logdet)*dsdp->schurmu; *potential=-(ddobj/mu + logdet)*dsdp->schurmu; DSDPFunctionReturn(0); } /*! \fn int DSDPSetY(DSDP dsdp, double beta, double logdet, DSDPVec ynew); \brief Update the solver with these y variables \param dsdp the solver \param beta most recent step length \param logdet logarithmic barrier function of the given point \param ynew current solution. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetY" int DSDPSetY(DSDP dsdp, double beta, double logdet, DSDPVec ynew){ int info; double r1,r2,rr,pp; DSDPFunctionBegin; info=DSDPVecGetR(dsdp->y,&r1);DSDPCHKERR(info); info=DSDPVecGetR(ynew,&r2);DSDPCHKERR(info); if (r2==0&&r1!=0){dsdp->rflag=1;} else {dsdp->rflag=0;}; info=DSDPVecCopy(ynew,dsdp->y);DSDPCHKERR(info); info = DSDPComputeObjective(dsdp,dsdp->y,&dsdp->ddobj);DSDPCHKERR(info); /* Correct ppobj if ppobj < ddobj , which can happen when dual infeasibility is present */ if (dsdp->ppobj<=dsdp->ddobj){ dsdp->ppobj=dsdp->ddobj+2*dsdp->mu * dsdp->np; DSDPLogInfo(0,2,"Primal Objective Not Right. Assigned: %8.8e\n",dsdp->ppobj); } info=DSDPVecGetR(ynew,&rr);DSDPCHKERR(info); info=DSDPVecGetR(dsdp->b,&pp);DSDPCHKERR(info); dsdp->dobj=dsdp->ddobj-rr*pp; DSDPLogInfo(0,2,"Duality Gap: %4.4e, Potential: %4.4e \n",dsdp->dualitygap,dsdp->potential); dsdp->dualitygap=dsdp->ppobj-dsdp->ddobj; dsdp->mu=(dsdp->dualitygap)/(dsdp->np); dsdp->dstep=beta; dsdp->logdet=logdet; info=DSDPComputePotential(dsdp,dsdp->y,dsdp->logdet,&dsdp->potential);DSDPCHKERR(info); DSDPLogInfo(0,2,"Duality Gap: %4.4e, Potential: %4.4e \n",dsdp->dualitygap,dsdp->potential); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetRR" /*! \fn int DSDPSetRR(DSDP dsdp,double res); \param dsdp solver \param res variable r \brief Set variable r. */ int DSDPSetRR(DSDP dsdp,double res){ int info; DSDPFunctionBegin; DSDPValid(dsdp); info=DSDPVecSetR(dsdp->y,-res);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetRR" /*! \fn int DSDPGetRR(DSDP dsdp,double *res); \param dsdp solver \param *res set variable r \brief Get variable r. */ int DSDPGetRR(DSDP dsdp,double *res){ int info; DSDPFunctionBegin; DSDPValid(dsdp); info=DSDPVecGetR(dsdp->y,res);DSDPCHKERR(info); *res=-*res; if (*res==0) *res=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPObjectiveGH" /*! \fn int DSDPObjectiveGH( DSDP dsdp , DSDPSchurMat M, DSDPVec vrhs1); \param dsdp solver \param M Schur matrix. \param vrhs1 gradient vector \brief Compute gradient of dual objective. */ int DSDPObjectiveGH( DSDP dsdp , DSDPSchurMat M, DSDPVec vrhs1){ int i,info,m; double rtemp,dd; DSDPFunctionBegin; info=DSDPVecGetSize(vrhs1,&m); DSDPCHKERR(info); for (i=0;ib,i,&rtemp);DSDPCHKERR(info); info=DSDPVecAddElement(vrhs1,i,rtemp);DSDPCHKERR(info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCheckForUnboundedObjective" int DSDPCheckForUnboundedObjective(DSDP dsdp, DSDPTruth *unbounded){ int info; double dtemp; DSDPTruth psdefinite; DSDPFunctionBegin; *unbounded=DSDP_FALSE; info = DSDPVecDot(dsdp->b,dsdp->dy2,&dtemp);DSDPCHKERR(info); if ( dtemp < 0 /* && dsdp->r==0 && dsdp->ddobj > 0 */) { info = DSDPVecScaleCopy(dsdp->dy2,-1.0,dsdp->ytemp); DSDPCHKERR(info); info = DSDPComputeSS(dsdp,dsdp->ytemp,PRIMAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite == DSDP_TRUE){ psdefinite=DSDP_FALSE; while(psdefinite==DSDP_FALSE){ /* Dual point should be a certificate of dual unboundedness, and be dual feasible */ info=DSDPComputeSS(dsdp,dsdp->ytemp,PRIMAL_FACTOR,&psdefinite);DSDPCHKERR(info); if (psdefinite == DSDP_TRUE) break; info=DSDPVecScale(2.0,dsdp->ytemp); DSDPCHKERR(info); } info = DSDPVecCopy(dsdp->ytemp,dsdp->y); DSDPCHKERR(info); info = DSDPSaveYForX(dsdp,1.0e-12,1.0);DSDPCHKERR(info); info = DSDPComputeObjective(dsdp,dsdp->y,&dsdp->ddobj);DSDPCHKERR(info); info = DSDPVecNormalize(dsdp->y); DSDPCHKERR(info); *unbounded=DSDP_TRUE; } } DSDPFunctionReturn(0); } DSDP5.8/src/solver/Makefile0000644000175000017500000000046110326241003015532 0ustar twernertwerner DSDPOBJ = dualalg.o dualimpl.o dsdpcops.o dsdpschurmat.o dsdpcg.o \ dsdpconverge.o dsdpsetup.o dsdpcone.o dsdpsetoptions.o \ dsdpsetdata.o dsdprescone.o dsdpobjcone.o dsdpprintout.o \ dsdpschurmatadd.o dsdpx.o include ../../make.include default: make dsdplib; clean: ${RM} ${DSDPOBJ} DSDP5.8/src/solver/dsdpconverge.h0000644000175000017500000000113210326241002016721 0ustar twernertwerner#ifndef __DSDP_CONVERGE_H #define __DSDP_CONVERGE_H /*! \file dsdpconverge.h \brief Detect convergence of the solver from the duality gap and step sizes. */ #define DSDPHistory 200 typedef struct { int history; /* length of records for iter, alpha, relgap */ double alpha[DSDPHistory]; /* History of stepsize */ double gaphist[DSDPHistory]; /* History of duality gap */ double infhist[DSDPHistory]; /* History of dual infeasiblity */ double steptol; double rgaptol; double pnormtol; double dualbound; } ConvergenceMonitor; #endif DSDP5.8/src/solver/dsdpprintout.c0000644000175000017500000001331610326241002016777 0ustar twernertwerner#include "dsdp5.h" /*! \file dsdpprintout.c \brief Print iteration statistics. */ static int dsdpprintlevel=0; static int dsdpprintlevel2=0; #undef __FUNCT__ #define __FUNCT__ "DSDPPrintStats" int DSDPPrintStatsFile(DSDP dsdp, void *dummy){ double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm; int iter,info; int printlevel=dsdpprintlevel2; DSDPTerminationReason reason; if(printlevel<=0) return(0); if(!dsdpoutputfile) return(0); info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info); info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info); if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){ info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info); info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info); info = DSDPGetR(dsdp,&res); DSDPCHKERR(info); info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info); info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info); info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info); info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info); if (reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0; if (iter==0){ fprintf(dsdpoutputfile,"Iter PP Objective DD Objective PInfeas DInfeas Mu StepLength Pnrm\n"); fprintf(dsdpoutputfile,"--------------------------------------------------------------------------------------\n"); } fprintf(dsdpoutputfile,"%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu); fprintf(dsdpoutputfile," %4.2f %4.2f",pstp,dstp); if (pnorm>1.0e3){ fprintf(dsdpoutputfile," %1.0e \n",pnorm); } else { fprintf(dsdpoutputfile," %5.2f \n",pnorm); } } return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPSetStandardMonitor" int DSDPSetFileMonitor(DSDP dsdp, int printlevel){ int info; dsdpprintlevel2=printlevel; info=DSDPSetMonitor(dsdp,DSDPPrintStatsFile,0); DSDPCHKERR(info); return (0); } /*! \fn int DSDPPrintStats(DSDP dsdp, void *ctx) \brief Print statistics about the current solution to standard output. \param dsdp is the solver \param ctx is a pointer to a structure (NULL in this case) \sa DSDPSetStandardMonitor() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPPrintStats" int DSDPPrintStats(DSDP dsdp, void *dummy){ double ppobj,ddobj,pstp,dstp,mu,res,pinfeas,pnorm; int iter,info; int printlevel=dsdpprintlevel; DSDPTerminationReason reason; if(printlevel<=0) return(0); info = DSDPStopReason(dsdp,&reason);DSDPCHKERR(info); info = DSDPGetIts(dsdp,&iter);DSDPCHKERR(info); if( (reason!=CONTINUE_ITERATING) || ((iter % printlevel)==0)){ info = DSDPGetDDObjective(dsdp,&ddobj); DSDPCHKERR(info); info = DSDPGetPPObjective(dsdp,&ppobj); DSDPCHKERR(info); info = DSDPGetR(dsdp,&res); DSDPCHKERR(info); info = DSDPGetPInfeasibility(dsdp,&pinfeas); DSDPCHKERR(info); info = DSDPGetStepLengths(dsdp,&pstp,&dstp); DSDPCHKERR(info); info = DSDPGetBarrierParameter(dsdp,&mu); DSDPCHKERR(info); info = DSDPGetPnorm(dsdp,&pnorm); DSDPCHKERR(info); if (0 && reason==CONTINUE_ITERATING && iter>100 && iter%10!=0) return 0; if (iter==0){ printf("Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm\n") ; printf("---------------------------------------------------------------------------------------\n") ; } printf("%-3d %16.8e %16.8e %9.1e %9.1e %9.1e",iter,ppobj,ddobj,pinfeas,res,mu); printf(" %4.2f %4.2f",pstp,dstp); if (pnorm>1.0e3){ printf(" %1.0e \n",pnorm); } else { printf(" %5.2f \n",pnorm); } fflush(NULL); } return 0; } /*! \fn int DSDPSetStandardMonitor(DSDP dsdp, int k) \brief Print at every kth iteration. \param dsdp is the solver \param k is the frequency to print information. \ingroup DSDPBasic \verbatim Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm --------------------------------------------------------------------------------------- 0 1.00000000e+02 -1.13743137e+05 2.2e+00 3.8e+02 1.1e+05 0.00 0.00 0.00 1 1.36503342e+06 -6.65779055e+04 5.1e+00 2.2e+02 1.1e+04 1.00 0.33 4.06 2 1.36631922e+05 -6.21604409e+03 5.4e+00 1.9e+01 4.5e+02 1.00 1.00 7.85 3 5.45799174e+03 -3.18292092e+03 1.5e-03 9.1e+00 7.5e+01 1.00 1.00 17.63 4 1.02930559e+03 -5.39166166e+02 1.1e-05 5.3e-01 2.7e+01 1.00 1.00 7.58 5 4.30074471e+02 -3.02460061e+01 3.3e-09 0.0e+00 5.6e+00 1.00 1.00 11.36 ... 11 8.99999824e+00 8.99999617e+00 1.1e-16 0.0e+00 1.7e-08 1.00 1.00 7.03 12 8.99999668e+00 8.99999629e+00 2.9e-19 0.0e+00 3.4e-09 1.00 1.00 14.19 \endverbatim - \c Iter - the current iteration number, - \c PP \c Objective - the current objective value in (PP), - \c DD \c Objective - the current objective value in (DD), - \c PInfeas - is the largest number \f$(x^u - x^l)_i\f$ in (PP), - \c DInfeas - the variable r in (DD) that corresponds to the infeasibility of y and S in (D). - \c Nu - the current barrier parameter \f$\frac{\bar{z} - b^Ty}{\rho}\f$. This parameter decreases to zero as the points get closer to the solution, - \c StepLength - the multiple of the step-directions in (PP) and (DD), - \c Pnrm - the proximity to a point on the central path: \f$\sqrt{-\nabla \psi^T(y^k,\bar{z}^k ) \Delta y}\f$. \sa DSDPGetIts() \sa DSDPGetDDObjective() \sa DSDPGetPPObjective() \sa DSDPGetR() \sa DSDPGetPInfeasibility() \sa DSDPGetBarrierParameter() \sa DSDPGetStepLengths() \sa DSDPGetPnorm() */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetStandardMonitor" int DSDPSetStandardMonitor(DSDP dsdp, int k){ int info; info=DSDPSetMonitor(dsdp,DSDPPrintStats,0); DSDPCHKERR(info); dsdpprintlevel=k; return (0); } DSDP5.8/src/solver/dsdpsetoptions.c0000644000175000017500000002514510326241002017325 0ustar twernertwerner#include "dsdp5.h" /*! \file dsdpsetoptions.c \brief Set DSDP options from file or command line arguments */ /* static char[] ZGAPTOL="-gaptol"; static char[] ZPRINT="-print"; static char[] ZPENALTY="-penalty"; static char[] ZBIGM="-bigM"; static char[] ZMAXIT="-maxit"; static char[] ZR0="-r0"; static char[] ZZBAR="-zbar"; static char[] ZINFDTOL="-infdtol"; static char[] ZINFPTOL="-infptol"; static char[] ZRHO="-rho"; static char[] ZDRHO="-drho"; static char[] ZBOUNDY="-boundy"; static char[] ZSTEPTOL="-steptol"; static char[] ZREUSE="-reuse"; static char[] ADADD="-dadd"; static char[] ZDBOUND="-dbound"; static char[] ZMU0="-mu0"; static char[] DOBJMIN="-dobjmin"; */ /*! \fn int DSDPSetOptions(DSDP dsdp,char *runargs[], int nargs); \brief Read command line arguments to set options in DSDP. \param dsdp is the solver \param runargs is the array of strings representing the options \param nargs is the number of arguments \sa DSDPReadOptions() \sa DSDPPrintOptions() \sa DSDPSetGapTolerance() \sa DSDPSetStandardMonitor() \sa DSDPSetPenaltyParameter() \sa DSDPSetMaxIts() \sa DSDPSetR0() \sa DSDPSetYBounds() \sa DSDPSetPotentialParameter() \ingroup DSDPBasic */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetOptions" int DSDPSetOptions(DSDP dsdp,char *runargs[],int nargs){ int kk, info,reuse; int maxit,rpos,drho,iloginfo; double penalty,rho,zbar,cc,r0,mu0,gaptol,dbound,dd; double ylow,yhigh,maxtrust,steptol,inftol,infptol,pnormtol; DSDPFunctionBegin; for (kk=0; kk=MAXOPTIONS) break; fgets(thisline,BUFFERSIZ,fp); if (sscanf(thisline,"%s %s",doption,dvalue)>=2){ if (doption[0]!='%'){ strncpy(fargs[2*line],doption,STRLENGTH-1); strncpy(fargs[2*line+1],dvalue,STRLENGTH-1); line++; } } thisline[0]='%'; } info=DSDPSetOptions(dsdp,fargs2,2*line); fclose(fp); } DSDPFunctionReturn(0); } /*! \fn int DSDPView(DSDP dsdp); \brief Print many of the parameters currently set in DSDP. \param dsdp is the solver \sa DSDPSetOptions() \sa DSDPGetPenaltyParameter() \sa DSDPGetSolutionType() \sa DSDPGetGapTolerance() \ingroup DSDPBasic */ #undef __FUNCT__ #define __FUNCT__ "DSDPView" int DSDPView(DSDP dsdp){ int info,reuse,m,maxit; double penalty,rho,mu0,gaptol,dnorm[3],derror[6],potential,ymax; double ylow,yhigh,maxtrust,steptol,inftol,infptol,pnormtol,dbound,tracex; DSDPSolutionType pdfeasible; DSDPFunctionBegin; info=DSDPGetMaxIts(dsdp,&maxit); DSDPCHKERR(info); printf("Terminate DSDP after %d iterations.\n",maxit); info=DSDPGetDualBound(dsdp,&dbound); DSDPCHKERR(info); printf("Terminate DSDP if dual objective is greater than %8.4e\n",dbound); info=DSDPGetGapTolerance(dsdp,&gaptol);DSDPCHKERR(info); printf("Terminate DSDP if the relative duality gap is less than %8.4e\n",gaptol); info=DSDPGetStepTolerance(dsdp,&steptol); DSDPCHKERR(info); printf("Terminate DSDP if step length in D less than %8.4e\n",steptol); info=DSDPGetPNormTolerance(dsdp,&pnormtol); DSDPCHKERR(info); printf("Terminate DSDP only if Pnorm less than %8.4e\n",pnormtol); info=DSDPGetMaxTrustRadius(dsdp,&maxtrust); DSDPCHKERR(info); printf("Max Trust Radius is %8.4e\n",maxtrust); info=DSDPGetReuseMatrix(dsdp,&reuse);DSDPCHKERR(info); printf("Reapply Hessian of Barrier up to %d times per iteration.\n",reuse); info=DSDPGetDataNorms(dsdp,dnorm);DSDPCHKERR(info); printf("The norms of C: %8.4e, A: %4.4e, and b: %8.4e\n",dnorm[0],dnorm[1],dnorm[2]); info=DSDPGetNumberOfVariables(dsdp,&m);DSDPCHKERR(info); printf("There are %d y variables: ",m); info=DSDPGetYMaxNorm(dsdp,&ymax); DSDPCHKERR(info); printf("largest is %8.4e, ",ymax); info=DSDPGetYBounds(dsdp,&ylow,&yhigh);DSDPCHKERR(info); printf("bounded below by %8.4e and above by %8.4e. \n",ylow,yhigh); info=DSDPGetTraceX(dsdp,&tracex);DSDPCHKERR(info); printf("The X variables have a trace of %8.4e ",tracex); info=DSDPGetPenaltyParameter(dsdp,&penalty); DSDPCHKERR(info); printf("bounded by penalty parameter: %8.4e\n",penalty); info=DSDPGetBarrierParameter(dsdp,&mu0);DSDPCHKERR(info); printf("Current Barrier Parameter: %8.4e\n",mu0); info=DSDPGetPotentialParameter(dsdp,&rho); DSDPCHKERR(info); printf("Potential Parameter: %8.4e ( times dimension) \n",rho); info=DSDPGetPotential(dsdp,&potential);DSDPCHKERR(info); printf("The value of the potential function is %8.4e\n",potential); info=DSDPGetRTolerance(dsdp,&inftol); DSDPCHKERR(info); printf("(D) Feasible only if R < %8.4e\n",inftol); info=DSDPGetPTolerance(dsdp,&infptol); DSDPCHKERR(info); printf("(P) Feasible only if Pinfeas < %8.4e\n",infptol); info=DSDPGetSolutionType(dsdp,&pdfeasible);DSDPCHKERR(info); if (pdfeasible==DSDP_PDFEASIBLE){ printf(" DSDP Solutions are both feasible and bounded\n"); } else if (pdfeasible==DSDP_UNBOUNDED){ printf(" (D) is unbounded and (P) is infeasible\n"); } else if (pdfeasible==DSDP_INFEASIBLE){ printf(" (D) is infeasible and (D) is unbounded\n"); } else if (pdfeasible==DSDP_PDUNKNOWN){ printf(" Hmm. Not clear whether either solution is feasible.\n"); } info=DSDPGetFinalErrors(dsdp,derror);DSDPCHKERR(info); printf("The errors: %8.4e, %4.4e, %8.4e, ",derror[0],derror[1],derror[2]); printf("%8.4e, %4.4e, %8.4e\n",derror[3],derror[4],derror[5]); DSDPFunctionReturn(0); } static char dsdpoptions[]="\ -gaptol <1e-6> stop when relative duality gap less than \n\ -r0 <-1> if nonnegative, initialize S by adding this multiple of the identity matrix \n\ -penalty <1e10>< penalize dual infeasibility \n\ -boundy <1e7> bound for variables y \n\ -maxit <200> set maximum iterates \n\ -zbar <1e10> Upper bound for dual solution \n\ -mu0 <-1> if positive, set initial barrier parameter \n\ -rho <3> Potential parameter as multiple of dimension \n\ -drho <1> Use dynamic rho strategy \n\ -pnormtol <1e30> stop only if pnorm less than \n\ -reuse <4> Reuse the Schur Matrix this many times\n\ -dobjmin <> apply a known lower bound for the objective at solution as a constraint. \n\ -bigM <0> if positive, modify algorithm to make dual \n\ infeasibility positive with a large associated cost \n\ -dloginfo <0> - print more information for higher numbers \n\ -params to read selected options from a file \n\ -help for this help message\n"; /*! \fn DSDPPrintOptions(); \brief Print runtime options; \sa DSDPSetOptions() \sa DSDPReadOptions() \sa DSDPView() \ingroup DSDPSolver */ int DSDPPrintOptions(){ DSDPFunctionBegin; printf("%s",dsdpoptions); DSDPFunctionReturn(0); } DSDP5.8/src/solver/dsdpx.c0000644000175000017500000003770010326241002015365 0ustar twernertwerner#include "dsdp.h" #include "dsdpsys.h" #include "dsdp5.h" /*! \file dsdpx.c \brief X variables, tolerances, errors, and feasibility. */ #undef __FUNCT__ #define __FUNCT__ "DSDPInspectXY" int DSDPInspectXY(DSDP dsdp, double xmakermu, DSDPVec xmakery, DSDPVec xmakerdy, DSDPVec AX, double *tracexs2, double *pobj2, double *rpinfeas2){ int info; DSDPFunctionBegin; info=BoundYConeAddX(dsdp->ybcone,xmakermu,xmakery,xmakerdy,AX,tracexs2); DSDPCHKERR(info); info=DSDPVecGetC(AX,pobj2);DSDPCHKERR(info); info=DSDPVecSetC(AX,0);DSDPCHKERR(info); info=DSDPVecSetR(AX,0);DSDPCHKERR(info); info=DSDPVecNorm1(AX,rpinfeas2); DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPComputeX(DSDP dsdp) \brief Compute the X variables. This routine explicitly computes X and determines the feasibility and unboundedness of the solution. This routine should be called after DSDPSolve(). The cost of the dual-scaling direction is less than the cost of other interior-point directions because the X matrix does not have to be computed explicitly at each iteration. \param dsdp the solver \sa DSDPSolve() \sa DSDPGetSolutionType() \sa DSDPGetPObjective() \ingroup DSDPBasic These four routines can usually be called together. \code DSDP dsdp; DSDPSolutionType type; DSDPSetup(dsdp); DSDPSolve(dsdp); DSDPComputeX(dsdp); DSDPGetSolutionType(dsdp,&type); \endcode */ #undef __FUNCT__ #define __FUNCT__ "DSDPComputeX" int DSDPComputeX(DSDP dsdp){ int i,info; double pobj=0,ppobj2=0,ddobj,tracexs=0,tracexs2=0,rpinfeas=0,rpinfeas2=0,rpobjerr=0; double err1,cc,rrr,bigM,ymax,pfeastol=dsdp->pinfeastol; DSDPTerminationReason reason; DSDPVec AX=dsdp->ytemp; DSDPFunctionBegin; info=DSDPStopReason(dsdp,&reason);DSDPCHKERR(info); info=DSDPGetDDObjective(dsdp,&ddobj);DSDPCHKERR(info); info=DSDPGetMaxYElement(dsdp,&ymax);DSDPCHKERR(info); info=DSDPGetR(dsdp,&rrr); DSDPCHKERR(info); info=DSDPGetPenalty(dsdp,&bigM);DSDPCHKERR(info); info=DSDPGetScale(dsdp,&cc);DSDPCHKERR(info); dsdp->pdfeasible=DSDP_PDFEASIBLE; for (i=0;i0 && dsdp->xmaker[i].pstep<1) continue; info=DSDPComputeXVariables(dsdp,dsdp->xmaker[i].mu,dsdp->xmaker[i].y,dsdp->xmaker[i].dy,AX,&tracexs);DSDPCHKERR(info); info=DSDPVecGetC(AX,&pobj); DSDPCHKERR(info); info=DSDPVecGetR(AX,&dsdp->tracex); DSDPCHKERR(info); info=DSDPVecSetC(AX,0);DSDPCHKERR(info); info=DSDPVecSetR(AX,0);DSDPCHKERR(info); info=DSDPVecNormInfinity(AX,&rpinfeas);DSDPCHKERR(info); rpinfeas=rpinfeas/(dsdp->tracex+1); DSDPLogInfo(0,2,"POBJ: %4.4e, DOBJ: %4.4e\n",pobj,ddobj/cc); info=DSDPVecNorm2(AX,&err1);DSDPCHKERR(info); dsdp->tracexs=tracexs; dsdp->perror=err1; dsdp->pobj=cc*pobj; info=DSDPInspectXY(dsdp,dsdp->xmaker[i].mu,dsdp->xmaker[i].y,dsdp->xmaker[i].dy,AX,&tracexs2,&ppobj2,&rpinfeas2);DSDPCHKERR(info); rpinfeas2=rpinfeas2/(dsdp->tracex+1); /* rpinfeas is infeasibility of (P) while rpinfeas2 is infeasibility of (PP) */ DSDPLogInfo(0,2,"X P Infeas: %4.2e , PObj: %4.8e\n",rpinfeas,pobj*(cc)); DSDPLogInfo(0,2,"TOTAL P Infeas: %4.2e PObj: %4.8e\n",rpinfeas2,ppobj2*(cc)); rpobjerr= fabs(pobj-dsdp->ppobj)/(1+fabs(dsdp->ppobj)); if (rpinfeas2 < pfeastol){ /* (PP) must be close to feasible */ if (dsdp->rgap<0.1){ if (rpinfeas>pfeastol/100 && fabs(rrr)>dsdp->dinfeastol){ dsdp->pdfeasible=DSDP_PDUNKNOWN; DSDPLogInfo(0,2,"Warning: Try Increasing penalty parameter\n"); } else if (rpinfeas>pfeastol && ddobj>0 && ppobj2<0 && fabs(rrr)dinfeastol){ dsdp->pdfeasible=DSDP_UNBOUNDED; DSDPLogInfo(0,2,"Warning: D probably unbounded\n"); } else if (/* fabs(bigM)-dsdp->tracex < fabs(rrr) && rpinfeasdsdp->dinfeastol){ dsdp->pdfeasible=DSDP_INFEASIBLE; DSDPLogInfo(0,2,"Warning: D probably infeasible \n"); } } i=i+10; break; } else { /* Step direction was not accurate enough to compute X from Schur complement */ DSDPLogInfo(0,2,"Try backup X\n"); info=DSDPSetConvergenceFlag(dsdp,DSDP_NUMERICAL_ERROR); DSDPCHKERR(info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSaveBackupYForX" int DSDPSaveBackupYForX(DSDP dsdp, int count,double mu, double pstep){ int info; double pnorm; DSDPFunctionBegin; info=DSDPVecCopy(dsdp->y,dsdp->xmaker[count].y);DSDPCHKERR(info); info=DSDPComputeDY(dsdp,mu,dsdp->xmaker[count].dy,&pnorm); DSDPCHKERR(info); dsdp->xmaker[count].pstep=pstep; dsdp->xmaker[count].mu = mu; DSDPFunctionReturn(0); } /*! \fn int DSDPSaveYForX(DSDP dsdp, double mu, double pstep); \brief Save the current solution for later computation of X \param dsdp the solver \param mu barrier function \param pstep primal step length, hopefully equals 1 */ #undef __FUNCT__ #define __FUNCT__ "DSDPSaveYForX" int DSDPSaveYForX(DSDP dsdp, double mu, double pstep){ int info,isgood=0; double pnorm,newgap,ymax,dd=0; DSDPFunctionBegin; dsdp->pstepold=dsdp->pstep; info=DSDPGetMaxYElement(dsdp,&ymax);DSDPCHKERR(info); if (pstep==0){ info=DSDPVecCopy(dsdp->y,dsdp->xmaker[0].y);DSDPCHKERR(info); dsdp->xmaker[0].pstep=pstep; } else if (dsdp->Mshift*ymax>dsdp->pinfeastol*10){ info=DSDPComputeDualityGap(dsdp,mu,&newgap);DSDPCHKERR(info); if (pstep==1 && newgap>0){ dsdp->ppobj = dsdp->ddobj + newgap; dsdp->mu=(newgap)/(dsdp->np); dsdp->dualitygap=newgap; } info=DSDPVecZero(dsdp->rhstemp); DSDPCHKERR(info); info=BoundYConeAddX(dsdp->ybcone,dsdp->xmaker[0].mu,dsdp->xmaker[0].y,dsdp->xmaker[0].dy,dsdp->rhstemp,&dd); DSDPCHKERR(info); info=DSDPVecSetC(dsdp->rhstemp,0); info=DSDPVecSetR(dsdp->rhstemp,0); info=DSDPVecNormInfinity(dsdp->rhstemp,&dsdp->pinfeas); DSDPCHKERR(info); dsdp->pinfeas+=dsdp->Mshift*ymax; if (0==1){info=DSDPVecView(dsdp->rhstemp);} /* Not good enough to save */ } else { info=DSDPVecCopy(dsdp->y,dsdp->xmaker[0].y);DSDPCHKERR(info); dsdp->xmaker[0].pstep=pstep; info=DSDPComputeRHS(dsdp,mu,dsdp->xmakerrhs); DSDPCHKERR(info); info=DSDPComputeDY(dsdp,mu,dsdp->xmaker[0].dy,&pnorm); DSDPCHKERR(info); dsdp->xmaker[0].mu = mu; info=DSDPComputeDualityGap(dsdp,mu,&newgap);DSDPCHKERR(info); if (pstep==1 && newgap>0){ dsdp->ppobj = dsdp->ddobj + newgap; dsdp->mu=(newgap)/(dsdp->np); dsdp->dualitygap=newgap; info=DSDPVecZero(dsdp->rhstemp); DSDPCHKERR(info); info=BoundYConeAddX(dsdp->ybcone,dsdp->xmaker[0].mu,dsdp->xmaker[0].y,dsdp->xmaker[0].dy,dsdp->rhstemp,&dd); DSDPCHKERR(info); info=DSDPVecSetC(dsdp->rhstemp,0); info=DSDPVecSetR(dsdp->rhstemp,0); info=DSDPVecNormInfinity(dsdp->rhstemp,&dsdp->pinfeas); DSDPCHKERR(info); dsdp->pinfeas+=dsdp->Mshift*ymax; if (0==1){info=DSDPVecView(dsdp->rhstemp);} } isgood=1; } if (isgood==1){ double penalty,r,rx; info=DSDPPassXVectors(dsdp,dsdp->xmaker[0].mu,dsdp->xmaker[0].y,dsdp->xmaker[0].dy); DSDPCHKERR(info); info=DSDPGetRR(dsdp,&r);DSDPCHKERR(info); if (r&& dsdp->rgap<0.1){ /* Estimate error in X */ info=RConeGetRX(dsdp->rcone,&rx);DSDPCHKERR(info); info=DSDPGetPenalty(dsdp,&penalty);DSDPCHKERR(info); dsdp->pinfeas = dsdp->pinfeas *(1+fabs(penalty-rx)); } } if (pstep==1.0 && dsdp->rgap>5.0e-1) { info=DSDPSaveBackupYForX(dsdp,MAX_XMAKERS-1,mu,pstep);DSDPCHKERR(info); } if (pstep==1.0 && dsdp->rgap>1.0e-3) { info=DSDPSaveBackupYForX(dsdp,2,mu,pstep);DSDPCHKERR(info); } if (pstep==1.0 && dsdp->rgap>1.0e-5) { info=DSDPSaveBackupYForX(dsdp,1,mu,pstep);DSDPCHKERR(info); } DSDPFunctionReturn(0); } /*! \fn int DSDPGetPObjective(DSDP dsdp, double *pobj) \brief Copy the objective value (P). \param dsdp is the solver \param *pobj will be the objective value in (P) \sa DSDPGetDObjective() \sa DSDPGetPPObjective() \sa DSDPComputeX() \note This value is correct only after calling DSDPComputeX() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPObjective" int DSDPGetPObjective(DSDP dsdp,double *pobj){ int info; double scale; DSDPFunctionBegin; DSDPValid(dsdp); info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info); *pobj=(dsdp->pobj)/scale; DSDPFunctionReturn(0); } /*! \fn int DSDPGetSolutionType(DSDP dsdp, DSDPSolutionType *pdfeasible) \brief Solutions can be bounded, infeasible, or unbounded. \param dsdp is the solver \param *pdfeasible will be set to the proper enumerated type. \sa DSDPSetPenaltyParameter() \sa DSDPSetYBounds() \sa DSDPStopReason() \ingroup DSDPBasic */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetSolutionType" int DSDPGetSolutionType(DSDP dsdp,DSDPSolutionType *pdfeasible){ DSDPFunctionBegin; DSDPValid(dsdp); *pdfeasible=dsdp->pdfeasible; DSDPFunctionReturn(0); } /*! \fn int DSDPGetTraceX(DSDP dsdp, double *tracex) \brief Copy the trace of the variables X in (P). For SDP blocks, this number corresponds to the trace of the blocks, and for LP, it corresponds the the sum of the variables x. If this number is near the penalty paramter, the problem (P) may be unbounded or the penalty parameter may have to be increased. \param dsdp is the solver \param *tracex will be set the trace of the variables in (P) \sa DSDPSetPenaltyParameter() \sa DSDPComputeX() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetTraceX" int DSDPGetTraceX(DSDP dsdp, double *tracex){ DSDPFunctionBegin; DSDPValid(dsdp); *tracex=dsdp->tracex; DSDPFunctionReturn(0); } /*! \fn int DSDPGetFinalErrors(DSDP dsdp, double err[6]) \brief Copy six different error measurements into an array. \param dsdp is the solver \param err will be set to the six error measurements \sa DSDPGetDualityGap() \sa DSDPGetR() \sa DSDPGetPInfeasibility() \ingroup DSDPSolution */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetFinalErrors" int DSDPGetFinalErrors(DSDP dsdp, double err[6]){ int info; double scale,rr,bnorm,dobj=0,pobj=0; DSDPFunctionBegin; DSDPValid(dsdp); info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info); info=DSDPVecGetR(dsdp->y,&rr); DSDPCHKERR(info); info=DSDPGetPObjective(dsdp,&pobj);DSDPCHKERR(info); info=DSDPGetDObjective(dsdp,&dobj);DSDPCHKERR(info); err[0]=dsdp->perror; err[1]=0; err[2]=fabs(rr)/scale; err[3]=0; err[4]=pobj - dobj; err[5]=dsdp->tracexs/scale; err[2] /= (1.0+dsdp->cnorm); info=DSDPVecCopy(dsdp->b,dsdp->ytemp);DSDPCHKERR(info); info=DSDPVecSetC(dsdp->ytemp,0);DSDPCHKERR(info); info=DSDPVecSetR(dsdp->ytemp,0);DSDPCHKERR(info); info=DSDPVecNormInfinity(dsdp->ytemp,&bnorm); err[0]=dsdp->perror/(1.0+bnorm); err[4]=(err[4])/(1.0+fabs(pobj)+fabs(dobj)); err[5]=(err[5])/(1.0+fabs(pobj)+fabs(dobj)); DSDPFunctionReturn(0); } /*! \fn int DSDPGetPInfeasibility(DSDP dsdp, double *pperror) \brief Copy the infeasibility in (P). This infeasibility is the maximum difference between the values xl and xu correponding to the bounds on the variables y. Due to roundoff error, this number is usually much less than the true infeasiblity in (P). The true infeasibility is not available at each iteration due to its high computational cost. \param dsdp is the solver \param *pperror will be set to the infeasibility in (P) \sa DSDPSetYBounds() \sa DSDPSetPTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPInfeasibility" int DSDPGetPInfeasibility(DSDP dsdp, double *pperror){ DSDPFunctionBegin; DSDPValid(dsdp); if (pperror) *pperror=dsdp->pinfeas; DSDPFunctionReturn(0); } /*! \fn int DSDPSetPTolerance(DSDP dsdp, double inftol) \brief Classify (P) as feasible only if the infeasibility is less than this tolerance \param dsdp is the solver \param inftol will be set to the infeasibility in (P) (>0) \sa DSDPSetYBounds() \sa DSDPGetPInfeasibility() \sa DSDPGetPTolerance() \sa DSDPGetRTolerance() \sa DSDPSolutionType \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetPTolerance" int DSDPSetPTolerance(DSDP dsdp,double inftol){ DSDPFunctionBegin; DSDPValid(dsdp); if (inftol > 0) dsdp->pinfeastol = inftol; DSDPLogInfo(0,2,"Set P Infeasibility Tolerance: %4.4e\n",inftol); DSDPFunctionReturn(0); } /*! \fn int DSDPGetPTolerance(DSDP dsdp, double *inftol) \brief Copy the feasibility tolerance. \param dsdp is the solver \param *inftol will be set to the infeasibility in (P) \sa DSDPSetYBounds() \sa DSDPGetPInfeasibility() \sa DSDPSetPTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetPTolerance" int DSDPGetPTolerance(DSDP dsdp,double *inftol){ DSDPFunctionBegin; DSDPValid(dsdp); if (inftol) *inftol=dsdp->pinfeastol; DSDPFunctionReturn(0); } /*! \fn int DSDPSetRTolerance(DSDP dsdp, double inftol) \brief Classify (D) as feasible only if the variable r is less than this tolerance. \param dsdp is the solver \param inftol is the tolerance (>0) \sa DSDPSetPenaltyParameter() \sa DSDPGetR() \sa DSDPGetRTolerance() \sa DSDPSolutionType \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetRTolerance" int DSDPSetRTolerance(DSDP dsdp,double inftol){ DSDPFunctionBegin; DSDPValid(dsdp); if (inftol > 0) dsdp->dinfeastol = inftol; DSDPLogInfo(0,2,"Set D Infeasibility Tolerance: %4.4e\n",inftol); DSDPFunctionReturn(0); } /*! \fn int DSDPGetRTolerance(DSDP dsdp, double *inftol) \brief Copy the maximum infeasibility allowed (D). DSDP will classify the solution to (D) as feasible only if the variable r in (DD) is less than this tolerance. Small values for r are enforced through a penalty parameter. \param dsdp is the solver \param *inftol will be set to the tolerance for r in (DD) \sa DSDPSetPenaltyParameter() \sa DSDPGetR() \sa DSDPSetRTolerance() \ingroup DSDPConverge */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetRTolerance" int DSDPGetRTolerance(DSDP dsdp,double *inftol){ DSDPFunctionBegin; DSDPValid(dsdp); *inftol=dsdp->dinfeastol; DSDPFunctionReturn(0); } /*! \fn int DSDPGetYMakeX(DSDP dsdp, double y[], int m) \brief Copies the variables y used to construct X into an array. \param dsdp is the solver \param y is an array \param m is the length of the array and the dimension of y \sa DSDPGetY() \sa DSDPComputeX() \sa DSDPGetDYMakeX() \sa DSDPGetMuMakeX() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetYMakeX" int DSDPGetYMakeX(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;iytemp,&yy);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPGetDYMakeX(DSDP dsdp, double dy[], int m) \brief Copies the variables dy used to construct X into an array. \param dsdp is the solver \param dy is an array \param m is the length of the array and the dimension of dy \sa DSDPComputeX() \sa DSDPGetYMakeX() \sa DSDPGetMuMakeX() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetDYMakeX" int DSDPGetDYMakeX(DSDP dsdp,double dy[], 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].dy,dsdp->ytemp); DSDPCHKERR(info); info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info); info=DSDPVecGetArray(dsdp->ytemp,&yy);DSDPCHKERR(info); for (i=0;iytemp,&yy);DSDPCHKERR(info); DSDPFunctionReturn(0); } /*! \fn int DSDPGetMuMakeX(DSDP dsdp, double *mu) \brief Copies the value of mu used to construct X. \param dsdp is the solver \param mu is the barrier parameter \sa DSDPComputeX() \sa DSDPGetYMakeX() \sa DSDPGetDYMakeX() \sa DSDPGetBarrierParameter() \ingroup DSDPSolver */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetMuMakeX" int DSDPGetMuMakeX(DSDP dsdp,double *mu){ int info; double scale; DSDPFunctionBegin; DSDPValid(dsdp); info=DSDPGetScale(dsdp,&scale);DSDPCHKERR(info); *mu=dsdp->xmaker[0].mu/scale; DSDPFunctionReturn(0); } DSDP5.8/src/solver/cscope.out0000644000175000017500000066717110326241002016117 0ustar twernertwernercscope 15 /nfs/mcs-homes64/benson/dsdp/DSDP5.8/src/solver 0000224294 @dsdp.h 1 #ide __DSDP_H 2  #__DSDP_H ) 4  ~"dsdpbasiys.h " 5  ~"dsdpvec.h " 6  ~"dsdpschurm.h " 7  ~"dsdpce.h " 8  ~"dsdpcvge.h " 14  _P_LUBounds * tYBoundCe ; 15  RDCe * tRRCe ; 18  #MAX_DSDP_MONITORS 5 ) 19  #MAX_XMAKERS 4 ) 22 DSDPVec my ; 23 DSDPVec mdy ; 24  mmu ; 25  mp ; 26 DSDPVec mrhs ; 27 } tXMak ; 30 DSDPVec my ; 31  mzb ; 32  mmurg ; 33  mlogd ; 34 } tDSDPS ; 43  s_PD_DSDP { 45 DSDPCG * mes ; 46  mey ; 48  mschurmu ; 49 DSDPSchurM mM ; 50  mMshi ; 51  mmaxschurshi ; 53  mnces , mmaxces ; 54 DSDPCe * mce ; 55 * mceid ; 56  mkeyid ; 58  msvime , mcgtime , mime , mdtime , mime ; 59  muM ; 60 DSDPTruth mgy0 ; 61 DSDPTruth mtuped ; 63  mm ; 64  m ; 66  mnow ; 67  mmax ; 68  mpobj ; 69  mobj ; 70  mdobj , mddobj ; 71  mp , md ; 72  mduyg ; 73  mmurg ; 74  mmu , mmud , mmu0 ; 75  mrho , mpْtl , mlogd , mrh ; 76  mm ; 77  mmaxudius ; 78  mm , mm , mbnm ; 79  max , maxs ; 80  mrg ; 81  mpd ; 83 DSDPVec my ; 84 DSDPVec my0 ; 85 DSDPVec mymp ; 86 DSDPVec mdy1 ; 87 DSDPVec mdy2 ; 88 DSDPVec mdy ; 89 DSDPVec mrhs1 ; 90 DSDPVec mrhs2 ; 91 DSDPVec mrhs ; 92 DSDPVec mrhemp ; 93 DSDPVec mb ; 96  mr ; 97  mrag ; 98 DSDPPty mUPty ; 99 RRCe mrce ; 101 DSDPTruth mufixedrho ; 103 XMak mxmak [ MAX_XMAKERS ]; 104 DSDPVec mxmakrhs ; 106 YBoundCe mybce ; 107  mpas ; 108  m ; 110 DSDPSutiTy mpdasib ; 111  mda ; 112  mpa ; 114 CvgMڙ mcv ; 115 DSDPTmiRs mas ; 117 (* mmڙ [ MAX_DSDP_MONITORS ])( m_PD_DSDP *, *); 118 * mmڙx [ MAX_DSDP_MONITORS ]; 119  mnmڙs ; 122  _PD_DSDP tPD_DSDP ; 124  #DSDPKEY 5432 ) 126  #DSDPVid ( a {i(!)||()-> keyid != DSDPKEY )){ `DSDPSETERR (101,"DSDPERROR: Invid DSDP obje\n");}} ) 128  ~"dsdpbasiys.h " 130  DSDPCeLUBoundsCe ( DSDP , YBoundCe *); 131  BoundYCeSBounds ( YBoundCe , , ); 132  BoundYCeGBounds ( YBoundCe , *, *); 133  BoundYCeAddX ( YBoundCe ,, DSDPVec ,DSDPVec,DSDPVec,*); 134  BoundYCeAddS ( YBoundCe , DSDPVec ,DSDPVec); 136  DSDPCompuObjeive ( DSDP , DSDPVec , *); 137  DSDPCompuDY ( DSDP , , DSDPVec , *); 138  DSDPCompuNewY ( DSDP , , DSDPVec ); 139  DSDPCompuRHS ( DSDP , , DSDPVec ); 140  DSDPCompuPDY1 ( DSDP ,, DSDPVec ); 141  DSDPCompuPDY ( DSDP , , DSDPVec , *); 142  DSDPCompuPY ( DSDP ,, DSDPVec ); 143  DSDPCompuG ( DSDP , DSDPVec ,DSDPVec,DSDPVec); 144  DSDPCompuPNm ( DSDP , , DSDPVec ,*); 145  DSDPCompuDuyG ( DSDP , , *); 146  DSDPSaveYFX ( DSDP , , ); 147  DSDPSY ( DSDP ,,, DSDPVec ); 148  DSDPCompuPْtl ( DSDP , DSDPVec , ,*); 149  DSDPCompuPْtl2 ( DSDP , DSDPVec , , , *); 150  DSDPSRR ( DSDP ,); 151  DSDPGRR ( DSDP ,*); 152  DSDPGMaxYEmt ( DSDP ,*); 153  DSDPSveDymicRho ( DSDP ); 154  DSDPRefeSpDei ( DSDP , DSDPVec , DSDPVec); 157  DSDPSUpCes ( DSDP ); 158  DSDPSUpCes2 ( DSDP , DSDPVec , DSDPSchurM ); 159  DSDPSchurSrsiy ( DSDP , , [], ); 160  DSDPCompuSS ( DSDP , DSDPVec , DSDPDuFaMrix , DSDPTruth *); 161  DSDPInvtS ( DSDP ); 162  DSDPCompuHessn DSDP , DSDPSchurM , DSDPVec , DSDPVec); 163  DSDPHessnMuɝlyAdd DSDP , DSDPVec , DSDPVec); 164  DSDPCompuMaxSpLgth ( DSDP , DSDPVec , DSDPDuFaMrix , *); 165  DSDPCompuLogSDmt ( DSDP , *); 166  DSDPCompuANm2 ( DSDP , DSDPVec ); 167  DSDPVwCes ( DSDP ); 168  DSDPMڙCes ( DSDP ,); 169  DSDPDeroyCes ( DSDP ); 170  DSDPPassXVes ( DSDP ,, DSDPVec ,DSDPVec); 171  DSDPCompuXVbs ( DSDP ,, DSDPVec ,DSDPVec,DSDPVec,*); 172  DSDPGCicDimsi ( DSDP ,*); 173  DSDPSchurSrsy ( DSDP , , [], ); 175  DSDPCGSve ( DSDP , DSDPSchurM , DSDPVec ,DSDPVec,, DSDPTruth *); 176  DSDPCompuDuSpDei ( DSDP , , DSDPVec ); 177  DSDPCompuDuSpDeis ( DSDP ); 179  DSDPAddBCe ( DSDP , DSDPVec ,); 180  DSDPAddICe ( DSDP ,, ); 181  DSDPAddRCe ( DSDP , RRCe *); 182  DSDPSCe ( DSDP , DSDPCe ); 183  RCeSTy ( RRCe , DSDPPty ); 185  DSDPSDa ( DSDP ); 186  DSDPCompuDaNms ( DSDP ); 188  DSDPTakeDown ( DSDP ); 189  DSDPSDeuStiics ( DSDP ); 190  DSDPSDeuPams ( DSDP ); 191  DSDPSDeuMڙs ( DSDP ); 194  DSDPInlizeVbs ( DSDP ); 195  DSDPObjeiveGH DSDP , DSDPSchurM , DSDPVec ); 196  DSDPCheckFUnboundedObjeive ( DSDP , DSDPTruth *); 198  DSDPCheckCvg ( DSDP , DSDPTmiRs *); 199  DSDPMڙ ( DSDP ); 200  DSDPDeuCvg ( DSDP ,*); 201  DSDPPrtSts ( DSDP , *); 202  DSDPPrtStsFe ( DSDP , *); 204  DSDPGSchurMrix ( DSDP , DSDPSchurM *); 205  DSDPFixedVbsNm ( DSDPSchurM , DSDPVec ); 206  DSDPCompuFixedYX ( DSDPSchurM , DSDPVec ); 210  DSDPLAPACKSchurCe (, DSDPSchurM *); 211  DSDPSSchurMrixSuu ( DSDP ,(*)( DSDPSchurM *, , *), *); 212  `DSDPSDeuSchurMrixSuu ( DSDP ); 213  `DSDPSchurSve ( DSDP , DSDPVec ,DSDPVec); 214  `DSDPGCvgMڙ ( DSDP , CvgMڙ **); 215  `DSDPSDeuCvgMڙ ( DSDP ); @dsdpcg.c 1  ~"dsdpcg.h " 2  ~"dsdpschurm.h " 3  ~"dsdpvec.h " 4  ~"dsdpsys.h " 5  ~"dsdp.h " 12 um { mDSDPNoMrix =1, mDSDPUnedMrix =2, mDSDPFaedMrix =3} tDSDPCGTy ; 15 DSDPCGTy mty ; 16 DSDPSchurM mM ; 17 DSDPVec mDg ; 18 DSDP mdsdp ; 19 } tDSDPCGM ; 21 #unde __FUNCT__ 22  #__FUNCT__ "DSDPCGMMu" ) 23  $DSDPCGMMu ( DSDPCGM M , DSDPVec X , DSDPVe Y ){ 24  fo ; 25 DSDPFuniBeg ; 26 fo = `DSDPVecZo ( Y ); `DSDPCHKERR (info); 27 i( M . ty == DSDPUnedMrix ){ 28 fo = `DSDPSchurMMuɝly ( M .M, X , Y ); `DSDPCHKERR (info); 29 } i( M . ty == DSDPFaedMrix ){ 30 fo = `DSDPSchurMMuR ( M .M, X , Y ); `DSDPCHKERR (info); 31 fo = `DSDPVecAXPY (-0* M . dsdp -> Mshi , X , Y ); `DSDPCHKERR (info); 32 } i( M . ty == DSDPNoMrix ){ 33 fo = `DSDPHessnMuɝlyAdd ( M . dsdp , X , Y ); `DSDPCHKERR (info); 35 `DSDPFuniRu (0); 36 } } 38 #unde __FUNCT__ 39  #__FUNCT__ "DSDPCGMP" ) 40  $DSDPCGMP ( DSDPCGM M , DSDPVec X , DSDPVe Y ){ 41  fo ; 42 DSDPFuniBeg ; 43 fo = `DSDPVecZo ( Y ); `DSDPCHKERR (info); 44 i( M . ty == DSDPUnedMrix ){ 45 fo = `DSDPVecPotwiMu ( X , M . Dg , Y ); `DSDPCHKERR (info); 46 fo = `DSDPVecPotwiMu ( Y , M . Dg ,Y); `DSDPCHKERR (info); 47 } i( M . ty == DSDPFaedMrix ){ 48 fo = `DSDPSchurMSve ( M .M, X , Y ); `DSDPCHKERR (info); 49 } i( M . ty == DSDPNoMrix ){ 50 fo = `DSDPVecCy ( X , Y ); `DSDPCHKERR (info); 52 `DSDPFuniRu (0); 53 } } 55 #unde __FUNCT__ 56  #__FUNCT__ "DSDPCGMPLe" ) 57  $DSDPCGMPLe ( DSDPCGM M , DSDPVec X , DSDPVe Y ){ 58  fo ; 59 DSDPFuniBeg ; 60 fo = `DSDPVecZo ( Y ); `DSDPCHKERR (info); 61 i( M . ty == DSDPUnedMrix ){ 62 fo = `DSDPVecPotwiMu ( X , M . Dg , Y ); `DSDPCHKERR (info); 63 } i( M . ty == DSDPFaedMrix ){ 64 fo = `DSDPSchurMSve ( M .M, X , Y ); `DSDPCHKERR (info); 65 } i( M . ty == DSDPNoMrix ){ 66 fo = `DSDPVecCy ( X , Y ); `DSDPCHKERR (info); 68 `DSDPFuniRu (0); 69 } } 71 #unde __FUNCT__ 72  #__FUNCT__ "DSDPCGMPRight" ) 73  $DSDPCGMPRight ( DSDPCGM M , DSDPVec X , DSDPVe Y ){ 74  fo ; 75 DSDPFuniBeg ; 76 fo = `DSDPVecZo ( Y ); `DSDPCHKERR (info); 77 i( M . ty == DSDPNoMrix ){ 78 fo = `DSDPVecPotwiMu ( X , M . Dg , Y ); `DSDPCHKERR (info); 79 } i( M . ty == DSDPFaedMrix ){ 80 fo = `DSDPVecCy ( X , Y ); `DSDPCHKERR (info); 81 } i( M . ty == DSDPUnedMrix ){ 82 fo = `DSDPVecCy ( X , Y ); `DSDPCHKERR (info); 84 `DSDPFuniRu (0); 85 } } 88 #unde __FUNCT__ 89  #__FUNCT__ "DSDPCjugeResidu" ) 90  $DSDPCjugeResidu ( DSDPCGM B , DSDPVec X , DSDPVe D , DSDPVe R , DSDPVe BR , DSDPVe P , DSDPVe BP , DSDPVe TT3 ,  maxs , * ){ 92  i , n , fo ; 93  zo =0.0, mus_e =-1.0; 94  pha , ba , bpbp , rBr , rBrOld ; 95  r0 , =1.0e20; 97 DSDPFuniBeg ; 98 fo = `DSDPVecNm2 ( X ,& rBr ); `DSDPCHKERR (info); 99 i( rBr >0){ 100 fo = `DSDPVecCy ( X , P ); `DSDPCHKERR (info); 101 fo = `DSDPCGMPRight ( B , P , X ); `DSDPCHKERR (info); 102 fo = `DSDPCGMMu ( B , X , R ); `DSDPCHKERR (info); 104 fo = `DSDPVecS ( zo , R ); `DSDPCHKERR (info); 106 fo = `DSDPVecAYPX ( mus_e , D , R ); `DSDPCHKERR (info); 108 fo = `DSDPCGMPLe ( B , D , R ); `DSDPCHKERR (info); 109 fo = `DSDPVecCy ( R , P ); `DSDPCHKERR (info); 111 fo = `DSDPCGMPRight ( B , R , BR ); `DSDPCHKERR (info); 112 fo = `DSDPCGMMu ( B , BR , TT3 ); `DSDPCHKERR (info); 113 fo = `DSDPCGMPRight ( B , TT3 , BR ); `DSDPCHKERR (info); 115 fo = `DSDPVecCy ( BR , BP ); `DSDPCHKERR (info); 116 fo = `DSDPVecD ( BR , R ,& rBr ); `DSDPCHKERR (info); 117 fo = `DSDPVecGSize ( X ,& n ); `DSDPCHKERR (info); 118 r0 = rBr ; 120  i =0;i< maxs ;i++){ 122 i( / n < 1.0e-30 || rBr /<1.0e-30 ||Br< 1.0e-12 * r0 ) ; 124 fo = `DSDPVecD ( BP ,BP,& bpbp ); `DSDPCHKERR (info); 125 pha = rBr / bpbp ; 126 fo `DSDPVecAXPY ( pha , P , X ); `DSDPCHKERR (info); 127 pha = -alpha; 128 fo = `DSDPVecAXPY ( pha , BP , R ); `DSDPCHKERR (info); 130 fo = `DSDPCGMPRight ( B , R , BR ); `DSDPCHKERR (info); 131 fo = `DSDPCGMMu ( B , BR , TT3 ); `DSDPCHKERR (info); 132 fo = `DSDPCGMPLe ( B , TT3 , BR ); `DSDPCHKERR (info); 134 rBrOld = rBr ; 135 fo = `DSDPVecNm2 ( R ,& ); `DSDPCHKERR (info); 136 fo = `DSDPVecD ( BR , R ,& rBr ); `DSDPCHKERR (info); 138 `DSDPLogInfo (0,11,"CG:r: %4.4e,Br: %4.4\n", , rBr ); 140 ba = rBr / rBrOld ; 141 fo = `DSDPVecAYPX ( ba , R , P ); `DSDPCHKERR (info); 142 fo = `DSDPVecAYPX ( ba , BR , BP ); `DSDPCHKERR (info); 145 fo = `DSDPVecCy ( X , BR ); `DSDPCHKERR (info); 146 fo = `DSDPCGMPRight ( B , BR , X ); `DSDPCHKERR (info); 148 `DSDPLogInfo (0,2,"CjugResidu, InrMr, %4.2e, FMr: %4.2e, Is: %d\n", r0 , rBr , i ); 150 * = i ; 152 `DSDPFuniRu (0); 153 } } 155 #unde __FUNCT__ 156  #__FUNCT__ "DSDPCjugeGd" ) 157  $DSDPCjugeGd ( DSDPCGM B , DSDPVec X , DSDPVe D , DSDPVe R , DSDPVe BR , DSDPVe P , DSDPVe BP , DSDPVe Z ,  cgt ,  maxs , * ){ 159  i , n , fo ; 160  pha , ba =0, bpbp ; 161  r0 , =1.0e20; 162  rz , rzd , rz0 ; 164 DSDPFuniBeg ; 165 i( maxs <=0){ 166 * =0; 167 `DSDPFuniRu (0); 169 fo = `DSDPVecGSize ( X ,& n ); `DSDPCHKERR (info); 170 fo = `DSDPVecNm2 ( X ,& ); `DSDPCHKERR (info); 171 fo = `DSDPVecZo ( R ); `DSDPCHKERR (info); 172 i( >0){ 173 fo = `DSDPCGMMu ( B , X , R ); `DSDPCHKERR (info); 175 pha =-1.0; 176 fo = `DSDPVecAYPX ( pha , D , R ); `DSDPCHKERR (info); 177 fo = `DSDPVecNm2 ( R ,& ); `DSDPCHKERR (info); 178 i( * `sq (1.0* n )<1e-11 +0* cgt *cgtol){ 179 * =1; 180 `DSDPFuniRu (0); 183 i( >0){ 184 fo = `DSDPVecCy ( R , P ); `DSDPCHKERR (info); 185 fo = `DSDPVecSR ( P ,0); `DSDPCHKERR (info); 186 fo = `DSDPVecNm2 ( P ,& ); `DSDPCHKERR (info); 187 fo = `DSDPCGMP ( B , R , Z ); `DSDPCHKERR (info); 190 fo = `DSDPVecCy ( Z , P ); `DSDPCHKERR (info); 191 fo = `DSDPVecD ( R , Z ,& rz ); `DSDPCHKERR (info); 192 r0 = ; rz0 = rz ; 194  i =0;i< maxs ;i++){ 196 fo = `DSDPCGMMu ( B , P , BP ); `DSDPCHKERR (info); 197 fo = `DSDPVecD ( BP , P ,& bpbp ); `DSDPCHKERR (info); 198 i( bpbp ==0) ; 199 pha = rz / bpbp ; 200 fo = `DSDPVecAXPY ( pha , P , X ); `DSDPCHKERR (info); 201 fo = `DSDPVecAXPY (- pha , BP , R ); `DSDPCHKERR (info); 202 fo = `DSDPVecNm2 ( R ,& ); `DSDPCHKERR (info); 204 `DSDPLogInfo (0,15,"CG: ir: %d,r: %4.4e,ha: %4.4e, ba=%4.4e,z: %4.4\n", i , , pha , ba , rz ); 205 i( i >1){ 206 i( * `sq (1.0* n < cgt ){ ;} 207 i( rz * n < cgt *cgtol){ ;} 208 i( / r0 < cgt ){ ;} 210 i( <=0){ ;} 211 fo = `DSDPCGMP ( B , R , Z ); `DSDPCHKERR (info); 212 rzd = rz ; 213 fo = `DSDPVecD ( R , Z ,& rz ); `DSDPCHKERR (info); 214 ba = rz / rzd ; 215 fo `DSDPVecAYPX ( ba , Z , P ); `DSDPCHKERR (info); 217 `DSDPLogInfo (0,2,"CjugGd, In||r||: %4.2e, F ||r||: %4.2e, In||rz||: %4.4e, ||rz||: %4.4e, Is: %d\n", r0 , , rz0 , rz , i +1); 219 * = i +1; 221 `DSDPFuniRu (0); 222 } } 238 #unde __FUNCT__ 239  #__FUNCT__ "DSDPCGSve" ) 240  $DSDPCGSve ( DSDP dsdp , DSDPSchurM MM , DSDPVec RHS , DSDPVe X , cgt , DSDPTruth * sucss ){ 241  =0, n , fo , max =10; 242  dd , ymax ; 243 DSDPCG * es = dsdp ->sles; 244 DSDPCGM CGM ; 245 DSDPFuniBeg ; 247 fo = `DSDPEvtLogBeg ( dsdp -> cgtime ); 248 fo = `DSDPVecZo ( X ); `DSDPCHKERR (info); 249 fo = `DSDPVecGSize ( X ,& n ); `DSDPCHKERR (info); 250 * sucss = DSDP_TRUE ; 252 max =0; 253 } i( dsdp -> ey ==1){ 255 CGM . ty = DSDPNoMrix ; 256 CGM . M = MM ; 257 CGM . dsdp =dsdp; 258 cgt *=1000; 259 max =5; 261 } i( dsdp -> ey ==2){ 262 CGM . ty = DSDPUnedMrix ; 263 CGM . M = MM ; 264 CGM . Dg = es ->Diag; 265 CGM . dsdp =dsdp; 266 cgt *=100; 267 max =() `sq (1.0* n )+10; 268 i( max >20) maxit=20; 269 fo = `DSDPVecS (1.0, es -> Dg ); `DSDPCHKERR (info); 275 } i( dsdp -> ey ==3){ 276 CGM . ty = DSDPFaedMrix ; 277 CGM . M = MM ; 278 CGM . dsdp =dsdp; 279 max =0; 280 fo = `DSDPGMaxYEmt ( dsdp ,& ymax ); `DSDPCHKERR (info); 281 i( ymax > 1e5 && dsdp -> rg <1e-1 max =3; 282 i(0 && ymax > 1e5 && dsdp -> rg <1e-2){ 283 max =6; 284 } i( dsdp -> rg <1e-5){ 285 max =3; 288 fo = `DSDPSchurMSve ( MM , RHS , X ); `DSDPCHKERR (info); 290 } i( dsdp -> ey ==4){ 291 CGM . ty = DSDPFaedMrix ; 292 CGM . M = MM ; 293 CGM . dsdp =dsdp; 294 max =3; 295 fo = `DSDPSchurMSve ( MM , RHS , X ); `DSDPCHKERR (info); 297 i( n < max ) maxit=n; 299 fo = `DSDPCjugeGd ( CGM , X , RHS , 300 es -> R ,es-> BR ,es-> P ,es-> BP , 301 es -> TTT , cgt , max ,& ); `DSDPCHKERR ( fo ); 303 i( >= max * sucss = DSDP_FALSE ; 304 fo = `DSDPVecD ( RHS , X ,& dd ); `DSDPCHKERR (info); 305 i( dd <0* sucss = DSDP_FALSE ; 306 fo = `DSDPEvtLogEnd ( dsdp -> cgtime ); 307 `DSDPFuniRu (0); 308 } } 311 #unde __FUNCT__ 312  #__FUNCT__ "DSDPCGInlize" ) 313  $DSDPCGInlize ( DSDPCG ** es ){ 314 DSDPCG * ses ; 315  fo ; 316 DSDPFuniBeg ; 317 `DSDPCALLOC1 (& ses , DSDPCG ,& fo ); `DSDPCHKERR (info); 318 ses -> tup2 =0; 319 * es = ses ; 320 `DSDPFuniRu (0); 321 } } 323 #unde __FUNCT__ 324  #__FUNCT__ "DSDPCGSup" ) 325  $DSDPCGSup ( DSDPCG * es , DSDPVec X ){ 326  fo ; 327 DSDPFuniBeg ; 328 fo = `DSDPVecGSize ( X ,& es -> m ); `DSDPCHKERR (info); 329 i( es -> tup2 ==0){ 330 fo = `DSDPVecDui ( X ,& es -> R ); `DSDPCHKERR (info); 331 fo = `DSDPVecDui ( X ,& es -> P ); `DSDPCHKERR (info); 332 fo = `DSDPVecDui ( X ,& es -> BP ); `DSDPCHKERR (info); 333 fo = `DSDPVecDui ( X ,& es -> BR ); `DSDPCHKERR (info); 334 fo = `DSDPVecDui ( X ,& es -> Dg ); `DSDPCHKERR (info); 335 fo = `DSDPVecDui ( X ,& es -> TTT ); `DSDPCHKERR (info); 337 es -> tup2 =1; 338 `DSDPFuniRu (0); 339 } } 341 #unde __FUNCT__ 342  #__FUNCT__ "DSDPCGDeroy" ) 343  $DSDPCGDeroy ( DSDPCG ** ses ){ 344  fo ; 345 DSDPCG * es =* ses ; 346 DSDPFuniBeg ; 347 i( ses ==0 || es ==0){ `DSDPFuniRu (0);} 348 i( es -> tup2 ==1){ 349 fo = `DSDPVecDeroy (& es -> R ); `DSDPCHKERR (info); 350 fo = `DSDPVecDeroy (& es -> P ); `DSDPCHKERR (info); 351 fo = `DSDPVecDeroy (& es -> BP ); `DSDPCHKERR (info); 352 fo = `DSDPVecDeroy (& es -> BR ); `DSDPCHKERR (info); 353 fo = `DSDPVecDeroy (& es -> Dg ); `DSDPCHKERR (info); 354 fo = `DSDPVecDeroy (& es -> TTT ); `DSDPCHKERR (info); 356 `DSDPFREE ( ses ,& fo ); `DSDPCHKERR (info); 357 `DSDPFuniRu (0); 358 } } @dsdpcg.h 1  ~"dsdpvec.h " 2 #i! defed ( __DSDP_CG_H ) 3  #__DSDP_CG_H ) 10  mtup2 ; 11  mm ; 13 DSDPVec mDg ; 14 DSDPVec mRHS2 ; 15 DSDPVec mR ; 16 DSDPVec mBR ; 17 DSDPVec mP ; 19 DSDPVec mBP ; 20 DSDPVec mTTT ; 22 } tDSDPCG ; 25  DSDPCGSup ( DSDPCG *, DSDPVec ); 26  DSDPCGDeroy ( DSDPCG **); 27  DSDPCGInlize ( DSDPCG **); @dsdpcone.c 1  ~"dsdpce_im.h " 2  ~"dsdpce.h " 3  ~"dsdpsys.h " 10  #DSDPNoOtiE ( a ); { `DSDPSETERR1 (10,"Cڐty: %s, Otiڂ defed\n",). dsdps -> me ); } ) 11  #DSDPChkCeE ( a , b ); { i(b){ `DSDPSETERR1 (b,"Cڐty: %s,\n",). dsdps -> me ); } } ) 13 #unde __FUNCT__ 14  #__FUNCT__ "DSDPCeSUp" ) 15  $DSDPCeSUp ( DSDPCe K , DSDPVec y ){ 16  fo ; 17 DSDPFuniBeg ; 18 i( K . dsdps -> cetup ){ 19 fo = K . dsdps -> `cetup (K. ceda , y ); `DSDPChkCeE (K,info); 21 `DSDPNoOtiE ( K ); 23 `DSDPFuniRu (0); 24 } } 26 #unde __FUNCT__ 27  #__FUNCT__ "DSDPCeSUp2" ) 28  $DSDPCeSUp2 ( DSDPCe K , DSDPVec yy0 , DSDPSchurM M ){ 29  fo ; 30 DSDPFuniBeg ; 31 i( K . dsdps -> cetup2 ){ 32 fo = K . dsdps -> `cetup2 (K. ceda , yy0 , M ); `DSDPChkCeE (K,info); 34 `DSDPNoOtiE ( K ); 36 `DSDPFuniRu (0); 37 } } 40 #unde __FUNCT__ 41  #__FUNCT__ "DSDPCeDeroy" ) 42  $DSDPCeDeroy ( DSDPCe * K ){ 43  fo ; 44 DSDPFuniBeg ; 45 i((* K ). dsdps -> cederoy ){ 46 fo =(* K ). dsdps -> `cederoy ((*K). ceda ); `DSDPChkCeE (*K,info); 47 fo = `DSDPCeInlize ( K ); `DSDPCHKERR (info); 49 `DSDPNoOtiE (* K ); 51 `DSDPFuniRu (0); 52 } } 55 #unde __FUNCT__ 56  #__FUNCT__ "DSDPCeCompuHessn" ) 57  $DSDPCeCompuHessn DSDPCe K ,  mu , DSDPSchurM M , DSDPVec vrhs1 , DSDPVe vrhs2 ){ 58  fo ; 59 DSDPFuniBeg ; 60 i( K . dsdps -> cehessn ){ 61 fo = K . dsdps -> `cehessn (K. ceda , mu , M , vrhs1 , vrhs2 ); `DSDPChkCeE (K,info); 63 `DSDPNoOtiE ( K ); 65 `DSDPFuniRu (0); 66 } } 69 #unde __FUNCT__ 70  #__FUNCT__ "DSDPCeMuɝlyAdd" ) 71  $DSDPCeMuɝlyAdd DSDPCe K ,  mu , DSDPVec vrow , DSDPVe v , DSDPVe vv ){ 72  fo ; 73 DSDPFuniBeg ; 74 i( K . dsdps -> cehmuɝlyadd ){ 75 fo = K . dsdps -> `cehmuɝlyadd (K. ceda , mu , vrow , v , vv ); `DSDPChkCeE (K,info); 77 `DSDPNoOtiE ( K ); 79 `DSDPFuniRu (0); 80 } } 83 #unde __FUNCT__ 84  #__FUNCT__ "DSDPCeCompuRHS" ) 85  $DSDPCeCompuRHS DSDPCe K ,  mu , DSDPVec vrow ,DSDPVe rhs1 ,DSDPVe rhs2 ){ 86  fo ; 87 DSDPFuniBeg ; 88 i( K . dsdps -> cڔhs ){ 89 fo = K . dsdps -> `cڔhs (K. ceda , mu , vrow , rhs1 , rhs2 ); `DSDPChkCeE (K,info); 91 `DSDPNoOtiE ( K ); 93 `DSDPFuniRu (0); 94 } } 96 #unde __FUNCT__ 97  #__FUNCT__ "DSDPCeANm2" ) 98  $DSDPCeANm2 DSDPCe K , DSDPVec m2 ){ 99  fo ; 100 DSDPFuniBeg ; 101 i( K . dsdps -> cڗnm2 ){ 102 fo = K . dsdps -> `cڗnm2 (K. ceda , m2 ); `DSDPChkCeE (K,info); 104 `DSDPNoOtiE ( K ); 106 `DSDPFuniRu (0); 107 } } 109 #unde __FUNCT__ 110  #__FUNCT__ "DSDPCeSXMak" ) 111  $DSDPCeSXMak DSDPCe K ,  mu , DSDPVec y , DSDPVe dy ){ 112  fo ; 113 DSDPFuniBeg ; 114 i( K . dsdps -> cetxmak ){ 115 fo = K . dsdps -> `cetxmak (K. ceda , mu , y , dy ); `DSDPChkCeE (K,info); 117 `DSDPNoOtiE ( K ); 119 `DSDPFuniRu (0); 120 } } 122 #unde __FUNCT__ 123  #__FUNCT__ "DSDPCeCompuX" ) 124  $DSDPCeCompuX DSDPCe K ,  mu , DSDPVec y , DSDPVe dy , DSDPVe AX , * axs ){ 125  fo ; 126  xs ; 127 DSDPFuniBeg ; 128 i( K . dsdps -> cecompux ){ 129 xs =0; 130 fo = K . dsdps -> `cecompux (K. ceda , mu , y , dy , AX ,& xs ); `DSDPChkCeE (K,info); 131 * axs += xs ; 133 `DSDPNoOtiE ( K ); 135 `DSDPFuniRu (0); 136 } } 138 #unde __FUNCT__ 139  #__FUNCT__ "DSDPCeCompuS" ) 140  $DSDPCeCompuS ( DSDPCe K , DSDPVec Y , DSDPDuFaMrix ag , DSDPTruth * isdefe ){ 141  fo ; 142 DSDPFuniBeg ; 143 i( K . dsdps -> cecompus ){ 144 fo = K . dsdps -> `cecompus (K. ceda , Y , ag , isdefe ); `DSDPChkCeE (K,info); 146 `DSDPNoOtiE ( K ); 148 `DSDPFuniRu (0); 149 } } 151 #unde __FUNCT__ 152  #__FUNCT__ "DSDPCeInvtS" ) 153  $DSDPCeInvtS ( DSDPCe K ){ 154  fo ; 155 DSDPFuniBeg ; 156 i( K . dsdps -> cevts ){ 157 fo = K . dsdps -> `cevts (K. ceda ); `DSDPChkCeE (K,info); 159 `DSDPNoOtiE ( K ); 161 `DSDPFuniRu (0); 162 } } 164 #unde __FUNCT__ 165  #__FUNCT__ "DSDPCeCompuMaxSpLgth" ) 166  $DSDPCeCompuMaxSpLgth ( DSDPCe K , DSDPVec DY , DSDPDuFaMrix ag , * maxngth ){ 167  fo ; 168  cength =1.0e20; 169 DSDPFuniBeg ; 170 cength =1.0e30; 171 i( K . dsdps -> cemaxngth ){ 172 fo = K . dsdps -> `cemaxngth (K. ceda , DY , ag ,& cength ); `DSDPChkCeE (K,info); 174 `DSDPNoOtiE ( K ); 176 * maxngth = cength ; 177 `DSDPFuniRu (0); 178 } } 180 #unde __FUNCT__ 181  #__FUNCT__ "DSDPCeGDimsi" ) 182  $DSDPCeGDimsi ( DSDPCe K , * n ){ 183  fo ; 184  =0; 185 DSDPFuniBeg ; 186 i( K . dsdps -> cesize ){ 187 fo = K . dsdps -> `cesize (K. ceda ,& ); `DSDPChkCeE (K,info); 189 `DSDPNoOtiE ( K ); 191 * n = ; 192 `DSDPFuniRu (0); 193 } } 195 #unde __FUNCT__ 196  #__FUNCT__ "DSDPSrsyInSchurM" ) 197  $DSDPCeSrsyInSchurM ( DSDPCe K ,  row ,  nz [],  m ){ 198  fo , ; 199 DSDPFuniBeg ; 200 i( K . dsdps -> cesy ){ 201 fo = K . dsdps -> `cesy (K. ceda , row ,& , nz , m ); `DSDPChkCeE (K,info); 203 `DSDPNoOtiE ( K ); 205 `DSDPFuniRu (0); 206 } } 208 #unde __FUNCT__ 209  #__FUNCT__ "DSDPCeVw" ) 210  $DSDPCeVw ( DSDPCe K ){ 211  fo ; 212 DSDPFuniBeg ; 213 i( K . dsdps -> cevw ){ 214 fo = K . dsdps -> `cevw (K. ceda ); `DSDPChkCeE (K,info); 216 `DSDPNoOtiE ( K ); 218 `DSDPFuniRu (0); 219 } } 221 #unde __FUNCT__ 222  #__FUNCT__ "DSDPCeMڙ" ) 223  $DSDPCeMڙ ( DSDPCe K ,  g ){ 224  fo ; 225 DSDPFuniBeg ; 226 i( K . dsdps -> cemڙ ){ 227 fo = K . dsdps -> `cemڙ (K. ceda , g ); `DSDPChkCeE (K,info); 229 `DSDPNoOtiE ( K ); 231 `DSDPFuniRu (0); 232 } } 235 #unde __FUNCT__ 236  #__FUNCT__ "DSDPCeCompuLogSDmt" ) 237  $DSDPCeCompuLogSDmt ( DSDPCe K , * logdobj , * logd ){ 238  fo ; 239  cڕْtl1 =0, cڕْtl2 =0; 240 DSDPFuniBeg ; 241 i( K . dsdps -> cږogpْtl ){ 242 fo = K . dsdps -> `cږogpْtl (K. ceda ,& cڕْtl1 ,& cڕْtl2 ); `DSDPChkCeE (K,info); 244 `DSDPNoOtiE ( K ); 246 * logdobj = cڕْtl1 ; 247 * logd = cڕْtl2 ; 248 `DSDPFuniRu (0); 249 } } 251 #unde __FUNCT__ 252  #__FUNCT__ "DSDPGCeName" ) 253  $DSDPGCeName ( DSDPCe K , * ame ,  maxngth ){ 254 DSDPFuniBeg ; 255 `y ( ame , K . dsdps -> me , maxngth ); 256 `DSDPFuniRu (0); 257 } } 261 #unde __FUNCT__ 262  #__FUNCT__ "DSDPCeOpsInlize" ) 263  $DSDPCeOpsInlize ( _P_DSDPCe_Ops * ds ){ 264 DSDPFuniBeg ; 265 i( ds == NULL )  0; 267 ds -> cetup =0; 268 ds -> cetup2 =0; 269 ds -> cederoy =0; 270 ds -> cڗnm2 =0; 271 ds -> cehessn =0; 272 ds -> cehmuɝlyadd =0; 273 ds -> cڔhs =0; 274 ds -> cetxmak =0; 275 ds -> cecompux =0; 276 ds -> cecompus =0; 277 ds -> cevts =0; 278 ds -> cemaxngth =0; 279 ds -> cesy =0; 280 ds -> cږogpْtl =0; 281 ds -> cemڙ =0; 282 ds -> cevw =0; 283 ds -> id =0; 284 `DSDPFuniRu (0); 285 } } 287 #unde __FUNCT__ 288  #__FUNCT__ "DSDPCeSDa" ) 289  $DSDPCeSDa ( DSDPCe * K ,  _P_DSDPCe_Ops * s , * da ){ 290 DSDPFuniBeg ; 291 (* K ). dsdps = s ; 292 (* K ). ceda = da ; 293 `DSDPFuniRu (0); 294 } } 297  _P_DSDPCe_Ops gdsdpcs ; 298 #unde __FUNCT__ 299  #__FUNCT__ "DSDPCeOpsInlize" ) 300  $DSDPCeInlize ( DSDPCe * K ){ 301  fo ; 302 DSDPFuniBeg ; 303 fo = `DSDPCeOpsInlize (& dsdpcs ); `DSDPCHKERR (info); 304 fo = `DSDPCeSDa ( K ,& dsdpcs ,0); `DSDPCHKERR (info); 305 `DSDPFuniRu (0); 306 } } @dsdpcone.h 1 #ide __DSDPCONEOPERATIONS_H 2  #__DSDPCONEOPERATIONS_H ) 9  ~"dsdpbasiys.h " 10  ~"dsdpvec.h " 11  ~"dsdpschurm.h " 14  s_P_DSDPCe { 15 * mceda ; 16  _P_DSDPCe_Ops * mdsdps ; 19  _P_DSDPCe tDSDPCe ; 21  DSDPCeSUp ( DSDPCe , DSDPVec ); 22  DSDPCeSUp2 ( DSDPCe , DSDPVec , DSDPSchurM ); 23  DSDPCeGDimsi ( DSDPCe ,*); 24  DSDPCeSrsyInSchurM ( DSDPCe , ,[],); 25  DSDPCeCompuS ( DSDPCe , DSDPVec , DSDPDuFaMrix , DSDPTruth *); 26  DSDPCeInvtS ( DSDPCe ); 27  DSDPCeCompuHessn ( DSDPCe ,, DSDPSchurM , DSDPVec ,DSDPVec); 28  DSDPCeMuɝlyAdd ( DSDPCe ,, DSDPVec ,DSDPVec,DSDPVec); 29  DSDPCeCompuRHS ( DSDPCe ,, DSDPVec ,DSDPVec,DSDPVec); 30  DSDPCeCompuMaxSpLgth ( DSDPCe , DSDPVec , DSDPDuFaMrix ,*); 31  DSDPCeCompuLogSDmt ( DSDPCe ,*,*); 32  DSDPCeCompuX ( DSDPCe ,, DSDPVec ,DSDPVec,DSDPVec,*); 33  DSDPCeSXMak ( DSDPCe ,, DSDPVec ,DSDPVec); 34  DSDPCeVw ( DSDPCe ); 35  DSDPCeMڙ ( DSDPCe ,); 36  DSDPCeDeroy ( DSDPCe *); 37  DSDPCeANm2 ( DSDPCe , DSDPVec ); 38  DSDPGCeName ( DSDPCe ,*,); 40  DSDPCeSDa ( DSDPCe *, _P_DSDPCe_Ops *,*); 41  DSDPCeInlize ( DSDPCe *); 42  DSDPSCe ( DSDP , DSDPCe ); @dsdpcone_impl.h 1 #ide __DSDPCONE_H 2  #__DSDPCONE_H ) 9  ~"dsdpbasiys.h " 10  ~"dsdpvec.h " 11  ~"dsdpschurm.h " 13  s_P_DSDPCe_Ops { 14  mid ; 15 (* mcesize )(*,*); 16 (* mcetup )(*, mDSDPVec ); 17 (* mcetup2 )(*, mDSDPVec , mDSDPSchurM ); 18 (* mcecompus )(*, mDSDPVec , mDSDPDuFaMrix , mDSDPTruth *); 19 (* mcevts )(*); 20 (* mcږogpْtl )(*,*,*); 21 (* mcetxmak )(*,, mDSDPVec ,DSDPVec); 22 (* mcecompux )(*,, mDSDPVec ,DSDPVec,DSDPVec,*); 23 (* mcehessn )(*,, mDSDPSchurM , mDSDPVec ,DSDPVec); 24 (* mcehmuɝlyadd )(*,, mDSDPVec ,DSDPVec,DSDPVec); 25 (* mcڔhs )(*,, mDSDPVec ,DSDPVec,DSDPVec); 26 (* mcemaxngth )(*, mDSDPVec , mDSDPDuFaMrix ,*); 27 (* mcڗnm2 )(*, mDSDPVec ); 28 (* mcesy )(*,,*,[],); 29 (* mcemڙ )(*,); 30 (* mcederoy )(*); 31 (* mcevw )(*); 32 cڡ * mme ; 35  DSDPAddCe ( DSDP , _P_DSDPCe_Ops *, *); 36  DSDPCeOpsInlize ( _P_DSDPCe_Ops *); @dsdpconverge.c 1  ~"dsdp5.h " 2  ~"dsdpcvge.h " 9  DSDPGCvgMڙ ( DSDP , CvgMڙ **); 24 #unde __FUNCT__ 25  #__FUNCT__ "DSDPCheckCvg" ) 26  $DSDPDeuCvg ( DSDP dsdp ,* x ){ 28 CvgMڙ * cv =(CvgMڙ*) x ; 29  fo , i , ; 30  mu , mu2 ; 31  rg , rg2 , rgt = cv ->rgaptol; 32  a =0; 33  m , d , p , t = cv ->t, mt =conv->pnormtol; 34  obj , ddobj , g , dubound = cv ->dualbound; 35  s , ; 36 DSDPTmiRs as ; 38 DSDPFuniBeg ; 39 fo = `DSDPGSpLgths ( dsdp ,& p ,& d ); `DSDPCHKERR (info); 40 fo = `DSDPGPnm ( dsdp ,& m ); `DSDPCHKERR (info); 41 fo = `DSDPGIts ( dsdp ,& ); `DSDPCHKERR (info); 42 fo = `DSDPGDDObjeive ( dsdp ,& ddobj ); `DSDPCHKERR (info); 43 fo = `DSDPGPPObjeive ( dsdp ,& obj ); `DSDPCHKERR (info); 44 fo = `DSDPGR ( dsdp ,& s ); `DSDPCHKERR (info); 45 fo = `DSDPGBrrPam ( dsdp ,& mu ); `DSDPCHKERR (info); 46 fo = `DSDPGDimsi ( dsdp ,& ); `DSDPCHKERR (info); 47 fo = `DSDPStRs ( dsdp ,& as ); `DSDPCHKERR (info); 48 fo = `DSDPGRTޔ ( dsdp ,& a ); `DSDPCHKERR (info); 49 fo = `DSDPGDuyG ( dsdp ,& g ); `DSDPCHKERR (info); 50 rg =( g )/(1.0+ `bs ( ddobj )/2+bs( obj )/2); 51 rg2 =( mu * )/(1.0+ `bs ( ddobj )/2+bs( obj )/2); 52 i( ==0){ 53 cv -> hiy = DSDPHiy ; 54  i =0; i< DSDPHiy ; i++){ 55 cv -> pha [ i ] = 0.0; 56 cv -> ghi [ i ] = 0.0; 57 cv -> fhi [ i ] = 0.0; 60 i( < cv -> hiy && iter>0){ 61 cv -> ghi [ -1]=( obj - ddobj ); 62 cv -> fhi [ -1]= s ; 67 } i ddobj !=ddobj || m < 0){ 68 as = DSDP_NUMERICAL_ERROR ; 69 `DSDPLogInfo (0,2,"Stop dueo Numerical Error\n"); 70 } i rg <= rgt /1.01 && s <= a ){ 71 i( m > mt ){ 72 mu2 = g / ; 73 fo = `DSDPSBrrPam ( dsdp , mu2 ); `DSDPCHKERR (info); 75 as = DSDP_CONVERGED ; 76 `DSDPLogInfo (0,2,"DSDP Cvged: RivDuy G %4.2< %4.2e, Prim Fsib, Du Inasibly %4.2< %4.2\n", rg , rgt , s , a ); 78 } i rg2 <= rgt /100 && rg <0.01){ 79 as = DSDP_CONVERGED ; 80 `DSDPLogInfo (0,2,"DSDP Cvged: RivDuy G %4.2< %4.2e. Check Fsibly \n", rg , rgt ); 81 } i ddobj > dubound && s <= a ){ 82 as = DSDP_UPPERBOUND ; 83 `DSDPLogInfo (0,2,"DSDP Cvged: Du Objeive: %4.2> u bound %4.2e\n", m , dubound ); 84 } i > 5 && d < t && d* m < s && rg <= 1.0e-3 ) { 85 as = DSDP_SMALL_STEPS ; 86 `DSDPLogInfo (0,2,"DSDP Terminated: Smallelative gapnd small steps detected (3)\n"); 89 fo = `DSDPSCvgFg ( dsdp , as ); `DSDPCHKERR (info); 91 `DSDPFuniRu (0); 92 } } 108 #unde __FUNCT__ 109  #__FUNCT__ "DSDPSGTޔ" ) 110  $DSDPSGTޔ ( DSDP dsdp , gt ){ 111  fo ; 112 CvgMڙ * cv ; 113 DSDPFuniBeg ; 114 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 115 i( gt > 0 cv -> rgt = gaptol; 116 `DSDPLogInfo (0,2,"S RivG Tޔ: %4.4e\n", gt ); 117 `DSDPFuniRu (0); 118 } } 130 #unde __FUNCT__ 131  #__FUNCT__ "DSDPGGTޔ" ) 132  $DSDPGGTޔ ( DSDP dsdp ,* gt ){ 133  fo ; 134 CvgMڙ * cv ; 135 DSDPFuniBeg ; 136 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 137 DSDPFuniBeg ; 138 * gt = cv -> rgt ; 139 `DSDPFuniRu (0); 140 } } 156 #unde __FUNCT__ 157  #__FUNCT__ "DSDPSPNmTޔ" ) 158  $DSDPSPNmTޔ ( DSDP dsdp , ){ 159  fo ; 160 CvgMڙ * cv ; 161 DSDPFuniBeg ; 162 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 163 i( > 0 cv -> mt =tol; 164 `DSDPLogInfo (0,2,"S RivPNm Tޔ: %4.4e\n", ); 165 `DSDPFuniRu (0); 166 } } 178 #unde __FUNCT__ 179  #__FUNCT__ "DSDPGPNmTޔ" ) 180  $DSDPGPNmTޔ ( DSDP dsdp ,* ){ 181  fo ; 182 CvgMڙ * cv ; 183 DSDPFuniBeg ; 184 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 185 DSDPFuniBeg ; 186 * = cv -> mt ; 187 `DSDPFuniRu (0); 188 } } 203 #unde __FUNCT__ 204  #__FUNCT__ "DSDPSDuBound" ) 205  $DSDPSDuBound ( DSDP dsdp , dbound ){ 206  fo ; 207 CvgMڙ * cv ; 208 DSDPFuniBeg ; 209 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 210 cv -> dubound = dbound ; 211 `DSDPLogInfo (0,2,"S DuBound o%4.4\n", dbound ); 212 `DSDPFuniRu (0); 213 } } 225 #unde __FUNCT__ 226  #__FUNCT__ "DSDPGDuBound" ) 227  $DSDPGDuBound ( DSDP dsdp ,* dbound ){ 228  fo ; 229 CvgMڙ * cv ; 230 DSDPFuniBeg ; 231 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 232 * dbound = cv -> dubound ; 233 `DSDPFuniRu (0); 234 } } 250 #unde __FUNCT__ 251  #__FUNCT__ "DSDPSSpTޔ" ) 252  $DSDPSSpTޔ ( DSDP dsdp , t ){ 253  fo ; 254 CvgMڙ * cv ; 255 DSDPFuniBeg ; 256 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 257 i( t > 0 cv ->steptol = steptol; 258 `DSDPFuniRu (0); 259 } } 271 #unde __FUNCT__ 272  #__FUNCT__ "DSDPGSpTޔ" ) 273  $DSDPGSpTޔ ( DSDP dsdp ,* t ){ 274  fo ; 275 CvgMڙ * cv ; 276 DSDPFuniBeg ; 277 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 278 * t = cv ->steptol; 279 `DSDPFuniRu (0); 280 } } 296 #unde __FUNCT__ 297  #__FUNCT__ "DSDPGRHiy" ) 298  $DSDPGRHiy ( DSDP dsdp ,  hi [],  ngth ){ 299  i , fo ; 300 CvgMڙ * cv ; 301 DSDPFuniBeg ; 302 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 303  i =0;i< ngth ;i++ hi [i]=0.0; 304  i =0;i< `DSDPM ( ngth , DSDPHiy );i++ hi [i]= cv -> fhi [i]; 305 `DSDPFuniRu (0); 306 } } 319 #unde __FUNCT__ 320  #__FUNCT__ "DSDPGGHiy" ) 321  $DSDPGGHiy ( DSDP dsdp ,  hi [],  ngth ){ 322  i , fo ; 323 CvgMڙ * cv ; 324 DSDPFuniBeg ; 325 fo = `DSDPGCvgMڙ ( dsdp ,& cv ); `DSDPCHKERR (info); 326  i =0;i< ngth ;i++ hi [i]=0.0; 327  i =0;i< `DSDPM ( ngth , DSDPHiy );i++ hi [i]= cv -> ghi [i]; 328 `DSDPFuniRu (0); 329 } } @dsdpconverge.h 1 #ide __DSDP_CONVERGE_H 2  #__DSDP_CONVERGE_H ) 7  #DSDPHiy 200 ) 9  mhiy ; 10  mpha [ DSDPHiy ]; 11  mghi [ DSDPHiy ]; 12  mfhi [ DSDPHiy ]; 14  mt ; 15  mrgt ; 16  mmt ; 17  mdubound ; 18 } tCvgMڙ ; @dsdpcops.c 1  ~"dsdp.h " 2  ~"dsdpsys.h " 8  #DSDPCHKCONEERR ( a , b ); { i(b){ `DSDPSETERR1 (b,"CڐNumb: %d,\n",a);} } ) 10  gCeSup =0, gCeCompuS =0, gCeCompuSS =0, gCeCompuH =0, gCeHMuɝlyAdd =0, gCeMaxPSp =0, gCeMaxDSp =0, gCePْtl =0, gCeCompuX =0, gCeVw =0, gCeDeroy =0, gCeXEigs =0, gCeRHS =0, gCeInvtS =0; 11  DSDPRegiCeEvts (); 12  DSDPSSchurMOps ( DSDP , _P_DSDPSchurM_Ops *, *); 13  DSDPAddSchurRow ( DSDP ,, DSDPVec ); 18 #unde __FUNCT__ 19  #__FUNCT__ "DSDPZoCeEvts" ) 20  $DSDPZoCeEvts (){ 21 DSDPFuniBeg ; 22 CeSup =0; CeCompuS =0; CeCompuSS =0; CeCompuH =0; CeHMuɝlyAdd =0; CeMaxPSp =0; CeMaxDSp =0; CePْtl =0; CeCompuX =0; CeVw =0; CeDeroy =0; CeXEigs =0; CeRHS =0; CeInvtS =0; 23 `DSDPFuniRu (0); 24 } } 26 #unde __FUNCT__ 27  #__FUNCT__ "DSDPRegiCeEvts" ) 28  $DSDPRegiCeEvts (){ 30 DSDPFuniBeg ; 31 `DSDPEvtLogRegi ("CڐSu1&2",& CeSup ); 32 `DSDPEvtLogRegi ("CڐInvS",& CeInvtS ); 33 `DSDPEvtLogRegi ("CڐRHS",& CeRHS ); 34 `DSDPEvtLogRegi ("CڐCompu Newt Eq.",& CeCompuH ); 35 `DSDPEvtLogRegi ("CڐNewt Muɝly-Add",& CeHMuɝlyAdd ); 36 `DSDPEvtLogRegi ("CڐMax P SLgth",& CeMaxPSp ); 37 `DSDPEvtLogRegi ("CڐCompund Fa SP",& CeCompuSS ); 38 `DSDPEvtLogRegi ("CڐMax D SLgth",& CeMaxDSp ); 39 `DSDPEvtLogRegi ("CڐCompund Fa S",& CeCompuS ); 40 `DSDPEvtLogRegi ("CڐPْtl",& CePْtl ); 41 `DSDPEvtLogRegi ("CڐVw",& CeVw ); 42 `DSDPEvtLogRegi ("CڐCompu X",& CeCompuX ); 43 `DSDPEvtLogRegi ("CڐX Residus",& CeXEigs ); 44 `DSDPEvtLogRegi ("CڐDeroy",& CeDeroy ); 46 `DSDPFuniRu (0); 47 } } 49 #unde __FUNCT__ 50  #__FUNCT__ "DSDPSUpCes" ) 51  $DSDPSUpCes ( DSDP dsdp ){ 52  fo , kk ; 53 DSDPVec yy0 = dsdp -> y ; 54 DSDPFuniBeg ; 55 fo = `DSDPRegiCeEvts (); 56 `DSDPEvtLogBeg ( CeSup ); 57  kk =0;kk< dsdp -> nces ;kk++){ 58 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 59 fo = `DSDPCeSUp ( dsdp -> ce [ kk ], yy0 ); `DSDPCHKCONEERR (kk,info); 60 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 62 `DSDPEvtLogEnd ( CeSup ); 63 `DSDPFuniRu (0); 64 } } 66 #unde __FUNCT__ 67  #__FUNCT__ "DSDPSUpCes2" ) 68  $DSDPSUpCes2 ( DSDP dsdp , DSDPVec yy0 , DSDPSchurM M ){ 69  fo , kk ; 70 DSDPFuniBeg ; 71 `DSDPEvtLogBeg ( CeSup ); 72  kk =0;kk< dsdp -> nces ;kk++){ 73 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 74 fo = `DSDPCeSUp2 ( dsdp -> ce [ kk ], yy0 , M ); `DSDPCHKCONEERR (kk,info); 75 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 77 `DSDPEvtLogEnd ( CeSup ); 78 `DSDPFuniRu (0); 79 } } 82 #unde __FUNCT__ 83  #__FUNCT__ "DSDPDeroyCes" ) 84  $DSDPDeroyCes ( DSDP dsdp ){ 85  fo , kk , nces = dsdp ->ncones; 86 DSDPFuniBeg ; 87 `DSDPEvtLogBeg ( CeDeroy ); 88  kk = nces -1;kk>=0; kk--){ 89 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 90 fo = `DSDPCeDeroy (& dsdp -> ce [ kk ]); `DSDPCHKCONEERR (kk,info); 91 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 92 fo = `DSDPCeInlize (& dsdp -> ce [ kk ]); `DSDPCHKCONEERR (kk,info); 93 dsdp -> nces --; 95 i( dsdp -> maxces >0){ 96 `DSDPFREE (& dsdp -> ce ,& fo ); `DSDPCHKERR (info); 97 `DSDPFREE (& dsdp -> ceid ,& fo ); `DSDPCHKERR (info); 98 dsdp -> ce =0; 99 dsdp -> maxces =0; 101 `DSDPEvtLogEnd ( CeDeroy ); 102 fo = `DSDPZoCeEvts (); `DSDPCHKERR (info); 103 `DSDPFuniRu (0); 104 } } 118 #unde __FUNCT__ 119  #__FUNCT__ "DSDPCompuHessn" ) 120  $DSDPCompuHessn DSDP dsdp , DSDPSchurM M , DSDPVec vrhs1 , DSDPVe vrhs2 ){ 121  fo , kk ;  r ; 122 DSDPFuniBeg ; 123 `DSDPEvtLogBeg ( CeCompuH ); 124 dsdp -> schurmu =dsdp-> murg ; 125 fo = `DSDPVecGR ( dsdp -> y ,& r ); `DSDPCHKERR (info); 126 fo = `DSDPSchurMSR ( dsdp -> M , r ); `DSDPCHKERR (info); 127 fo = `DSDPSchurMZoErs ( M ); `DSDPCHKERR (info); 128 fo = `DSDPVecZo ( vrhs1 ); `DSDPCHKERR (info); 129 fo = `DSDPVecZo ( vrhs2 ); `DSDPCHKERR (info); 130 fo = `DSDPVecZo ( M . schur -> rhs3 ); `DSDPCHKERR (info); 131 fo = `DSDPObjeiveGH ( dsdp , M , vrhs1 ); `DSDPCHKERR (info); 132  kk = dsdp -> nces -1;kk>=0;kk--){ 133 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 134 fo = `DSDPCeCompuHessn ( dsdp -> ce [ kk ],dsdp-> schurmu , M , vrhs1 , vrhs2 ); `DSDPCHKCONEERR (kk,info); 135 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 137 fo = `DSDPSchurMAsmb ( M ); `DSDPCHKERR (info); 139 fo = `DSDPSchurMReduPVec ( M , vrhs1 ); `DSDPCHKERR (info); 140 fo = `DSDPSchurMReduPVec ( M , vrhs2 ); `DSDPCHKERR (info); 141 fo = `DSDPSchurMReduPVec ( M ,M. schur -> rhs3 ); `DSDPCHKERR (info); 142 i(0 && dsdp -> UPty == DSDPNev ){ 143 fo = `DSDPVecAXPY (1.0, M . schur -> rhs3 , vrhs2 ); `DSDPCHKERR (info); 144 fo = `DSDPVecZo ( M . schur -> rhs3 ); `DSDPCHKERR (info); 145 fo = `DSDPVecZo ( M . schur -> dy3 ); `DSDPCHKERR (info); 146 fo = `DSDPVecSR ( vrhs1 ,0); `DSDPCHKERR (info); 147 fo = `DSDPVecSR ( vrhs2 , r ); `DSDPCHKERR (info); 149 `DSDPEvtLogEnd ( CeCompuH ); 150 `DSDPFuniRu (0); 151 } } 154 #unde __FUNCT__ 155  #__FUNCT__ "DSDPHessnMuɝlyAdd" ) 156  $DSDPHessnMuɝlyAdd DSDP dsdp , DSDPVec v , DSDPVe vv ){ 157  fo , kk ; 158 DSDPVec vrow = dsdp -> es -> BR ; 159 DSDPFuniBeg ; 160 `DSDPEvtLogBeg ( CeHMuɝlyAdd ); 162 fo = `DSDPSchurMRowSlg ( dsdp -> M , vrow ); `DSDPCHKERR (info); 163  kk =0;kk< dsdp -> nces ;kk++){ 164 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 165 fo = `DSDPCeMuɝlyAdd ( dsdp -> ce [ kk ],dsdp-> schurmu , vrow , v , vv ); `DSDPCHKCONEERR (kk,info); 166 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 168 fo = `DSDPSchurMReduPVec ( dsdp -> M , vv ); `DSDPCHKERR (info); 169 `DSDPEvtLogEnd ( CeHMuɝlyAdd ); 170 `DSDPFuniRu (0); 171 } } 173 #unde __FUNCT__ 174  #__FUNCT__ "DSDPCompuG" ) 183  $DSDPCompuG DSDP dsdp , DSDPVec vt , DSDPVe vrhs1 , DSDPVe vrhs2 ){ 184  fo , kk ;  r ; 185 DSDPFuniBeg ; 186 `DSDPEvtLogBeg ( CeRHS ); 187 fo = `DSDPVecZo ( vrhs1 ); `DSDPCHKERR (info); 188 fo = `DSDPVecZo ( vrhs2 ); `DSDPCHKERR (info); 189 fo = `DSDPVecGR ( dsdp -> y ,& r ); `DSDPCHKERR (info); 190 fo = `DSDPSchurMSR ( dsdp -> M , r ); `DSDPCHKERR (info); 191 fo = `DSDPSchurMRowSlg ( dsdp -> M , vt ); `DSDPCHKERR (info); 192 fo = `DSDPObjeiveGH ( dsdp ,dsdp-> M , vrhs1 ); `DSDPCHKERR (info); 193 i(0 && r ==0){ fo = `DSDPVecSR ( vrhs1 ,0);fo=DSDPVecSR( vrhs2 ,0);} 195  kk =0;kk< dsdp -> nces ;kk++){ 196 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 197 fo = `DSDPCeCompuRHS ( dsdp -> ce [ kk ],dsdp-> schurmu , vt , vrhs1 , vrhs2 ); `DSDPCHKCONEERR (kk,info); 198 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 200 `DSDPEvtLogEnd ( CeRHS ); 201 fo = `DSDPSchurMReduPVec ( dsdp -> M , vrhs1 ); `DSDPCHKERR (info); 202 fo = `DSDPSchurMReduPVec ( dsdp -> M , vrhs2 ); `DSDPCHKERR (info); 203 `DSDPFuniRu (0); 204 } } 206 #unde __FUNCT__ 207  #__FUNCT__ "DSDPCompuANm2" ) 208  $DSDPCompuANm2 DSDP dsdp , DSDPVec Anm2 ){ 209  fo , kk ; 210 DSDPFuniBeg ; 211  kk =0;kk< dsdp -> nces ;kk++){ 212 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 213 fo = `DSDPCeANm2 ( dsdp -> ce [ kk ], Anm2 ); `DSDPCHKCONEERR (kk,info); 214 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 216 `DSDPFuniRu (0); 217 } } 232 #unde __FUNCT__ 233  #__FUNCT__ "DSDPCompuSS" ) 234  $DSDPCompuSS ( DSDP dsdp , DSDPVec Y , DSDPDuFaMrix ag , DSDPTruth * isdefe ){ 235  fo , kk ; 236 DSDPTruth psd = DSDP_TRUE ; 237 DSDPFuniBeg ; 238 i( ag == DUAL_FACTOR ){ 239 `DSDPEvtLogBeg ( CeCompuS ); 240 } i( ag == PRIMAL_FACTOR ){ 241 `DSDPEvtLogBeg ( CeCompuSS ); 243  kk = dsdp -> nces -1; kk>=0 && psd == DSDP_TRUE ;kk--){ 244 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 245 fo = `DSDPCeCompuS ( dsdp -> ce [ kk ], Y , ag ,& psd ); `DSDPCHKCONEERR (kk,info); 246 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 248 * isdefe = psd ; 249 i( ag == DUAL_FACTOR ){ 250 `DSDPEvtLogEnd ( CeCompuS ); 251 } i( ag == PRIMAL_FACTOR ){ 252 `DSDPEvtLogEnd ( CeCompuSS ); 254 `DSDPFuniRu (0); 255 } } 267 #unde __FUNCT__ 268  #__FUNCT__ "DSDPInvtS" ) 269  $DSDPInvtS ( DSDP dsdp ){ 270  fo , kk ; 271 DSDPFuniBeg ; 272 `DSDPEvtLogBeg ( CeInvtS ); 273  kk =0;kk< dsdp -> nces ;kk++){ 274 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 275 fo = `DSDPCeInvtS ( dsdp -> ce [ kk ]); `DSDPCHKCONEERR (kk,info); 276 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 278 `DSDPEvtLogEnd ( CeInvtS ); 279 `DSDPFuniRu (0); 280 } } 296 #unde __FUNCT__ 297  #__FUNCT__ "DSDPCompuMaxSpLgth" ) 298  $DSDPCompuMaxSpLgth ( DSDP dsdp , DSDPVec DY , DSDPDuFaMrix ag , * maxngth ){ 299  fo , kk ; 300  mngth =1.0e30, cength ; 301 DSDPFuniBeg ; 302 i( ag == DUAL_FACTOR ){ 303 `DSDPEvtLogBeg ( CeMaxDSp ); 304 } i( ag == PRIMAL_FACTOR ){ 305 `DSDPEvtLogBeg ( CeMaxPSp ); 307  kk =0;kk< dsdp -> nces ;kk++){ 308 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 309 cength =1.0e20; 310 fo = `DSDPCeCompuMaxSpLgth ( dsdp -> ce [ kk ], DY , ag ,& cength ); `DSDPCHKCONEERR (kk,info); 311 mngth = `DSDPM (mngth, cength ); 312 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 314 * maxngth = mngth ; 315 i( ag == DUAL_FACTOR ){ 316 `DSDPEvtLogEnd ( CeMaxDSp ); 317 } i( ag == PRIMAL_FACTOR ){ 318 `DSDPEvtLogEnd ( CeMaxPSp ); 320 `DSDPFuniRu (0); 321 } } 338 #unde __FUNCT__ 339  #__FUNCT__ "DSDPPassXVes" ) 340  $DSDPPassXVes ( DSDP dsdp ,  mu , DSDPVec Y , DSDPVe DY ){ 341  fo , kk ; 342 DSDPFuniBeg ; 343  kk =0;kk< dsdp -> nces ;kk++){ 344 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 345 fo = `DSDPCeSXMak ( dsdp -> ce [ kk ], mu , Y , DY ); `DSDPCHKCONEERR (kk,info); 346 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 348 `DSDPFuniRu (0); 349 } } 361 #unde __FUNCT__ 362  #__FUNCT__ "DSDPGCicDimsi" ) 363  $DSDPGCicDimsi ( DSDP dsdp , * n ){ 364  fo , kk ; 365  , n =0; 366 DSDPFuniBeg ; 367  kk =0;kk< dsdp -> nces ;kk++){ 368 =0; 369 fo = `DSDPCeGDimsi ( dsdp -> ce [ kk ],& ); `DSDPCHKCONEERR (kk,info); 370 n += ; 372 * n = n ; 373 `DSDPFuniRu (0); 374 } } 377 #unde __FUNCT__ 378  #__FUNCT__ "DSDPVwCes" ) 379  $DSDPVwCes ( DSDP dsdp ){ 380  fo , kk ; 381 DSDPFuniBeg ; 382 `DSDPEvtLogBeg ( CeVw ); 383  kk =0;kk< dsdp -> nces ;kk++){ 384 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 385 fo = `DSDPCeVw ( dsdp -> ce [ kk ]); `DSDPCHKCONEERR (kk,info); 386 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 388 `DSDPEvtLogEnd ( CeVw ); 389 `DSDPFuniRu (0); 390 } } 393 #unde __FUNCT__ 394  #__FUNCT__ "DSDPMڙCes" ) 395  $DSDPMڙCes ( DSDP dsdp , g ){ 396  fo , kk ; 397 DSDPFuniBeg ; 398 `DSDPEvtLogBeg ( CeVw ); 399  kk =0;kk< dsdp -> nces ;kk++){ 400 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 401 fo = `DSDPCeMڙ ( dsdp -> ce [ kk ], g ); `DSDPCHKCONEERR (kk,info); 402 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 404 `DSDPEvtLogEnd ( CeVw ); 405 `DSDPFuniRu (0); 406 } } 409 #unde __FUNCT__ 410  #__FUNCT__ "DSDPSrsyInSchurM" ) 411  $DSDPSchurSrsy ( DSDP dsdp ,  row ,  nz [],  m ){ 412  fo , kk ; 413 DSDPFuniBeg ; 414  kk =0;kk< dsdp -> nces ;kk++){ 416 fo = `DSDPCeSrsyInSchurM ( dsdp -> ce [ kk ], row , nz , m +2); `DSDPCHKCONEERR (kk,info); 419 `DSDPFuniRu (0); 420 } } 434 #unde __FUNCT__ 435  #__FUNCT__ "DSDPCompuLogSDmt" ) 436  $DSDPCompuLogSDmt ( DSDP dsdp , * logd ){ 437  fo , kk ; 438  ceobjeive , cڕْtl , ogd =0; 439 DSDPFuniBeg ; 440 `DSDPEvtLogBeg ( CePْtl ); 441  kk =0;kk< dsdp -> nces ;kk++){ 442 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 443 ceobjeive =0; cڕْtl =0; 444 fo = `DSDPCeCompuLogSDmt ( dsdp -> ce [ kk ],& ceobjeive ,& cڕْtl ); `DSDPCHKCONEERR (kk,info); 445 ogd += cڕْtl ; 446 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 448 * logd = ogd ; 449 `DSDPEvtLogEnd ( CePْtl ); 450 `DSDPFuniRu (0); 451 } } 454 #unde __FUNCT__ 455  #__FUNCT__ "DSDPSCe" ) 456  $DSDPSCe ( DSDP dsdp , DSDPCe tce ){ 457  fo , i , tc ; 458 * ceid ; 459  cڒame [100]; 460 DSDPCe * cces ; 461 DSDPFuniBeg ; 462 i( dsdp -> nces >=dsdp-> maxces ){ 463 tc =2* dsdp -> maxces +4; 465 `DSDPCALLOC2 (& cces , _P_DSDPCe , tc ,& fo ); `DSDPCHKERR (info); 466  i =0;i< dsdp -> nces ;i++){ cces [i]=dsdp-> ce [i];} 467 `DSDPFREE (& dsdp -> ce ,& fo ); `DSDPCHKERR (info); 468 dsdp -> ce = cces ; 470 `DSDPCALLOC2 (& ceid ,, tc ,& fo ); `DSDPCHKERR (info); 471  i =0;i< dsdp -> nces ;i++){ ceid [i]=dsdp->coneid[i];} 472 `DSDPFREE (& dsdp -> ceid ,& fo ); `DSDPCHKERR (info); 473 dsdp -> ceid =coneid; 475 dsdp -> maxces = tc ; 477 fo = `DSDPGCeName ( tce , cڒame ,100); `DSDPCHKERR (info); 478 `DSDPEvtLogRegi ( cڒame ,& tc ); 479 dsdp -> ce [dsdp-> nces ]= tce ; 480 dsdp -> ceid [dsdp-> nces ]= tc ; 481 dsdp -> nces ++; 482 `DSDPFuniRu (0); 483 } } 510 #unde __FUNCT__ 511  #__FUNCT__ "DSDPAddCe" ) 512  $DSDPAddCe ( DSDP dsdp , _P_DSDPCe_Ops * dsdps , * dsdpce ){ 513  fo ; 514 DSDPCe K ; 515 DSDPFuniBeg ; 516 fo = `DSDPCeInlize (& K ); `DSDPCHKERR (info); 517 fo = `DSDPCeSDa (& K , dsdps , dsdpce ); `DSDPCHKERR (info); 518 fo = `DSDPSCe ( dsdp , K ); `DSDPCHKERR (info); 519 `DSDPFuniRu (0); 520 } } 546 #unde __FUNCT__ 547  #__FUNCT__ "DSDPSSchurMOps" ) 548  $DSDPSSchurMOps ( DSDP dsdp , _P_DSDPSchurM_Ops * ss , * mda ){ 549  fo ; 550 DSDPFuniBeg ; 551 fo = `DSDPSchurMSDa (& dsdp -> M , ss , mda ); `DSDPCHKERR (info); 552 `DSDPFuniRu (0); 553 } } 556 #unde __FUNCT__ 557  #__FUNCT__ "DSDPSSchurRow" ) 558  $DSDPAddSchurRow ( DSDP dsdp , row , DSDPVec R ){ 559  fo ; 560 DSDPFuniBeg ; 561 fo = `DSDPSchurMAddRow ( dsdp -> M , row ,1.0, R ); `DSDPCHKERR (info); 562 `DSDPFuniRu (0); 563 } } 590 #unde __FUNCT__ 591  #__FUNCT__ "DSDPCompuXVbs" ) 592  $DSDPCompuXVbs ( DSDP dsdp ,  xmakmu , DSDPVec xmaky , DSDPVe xmakdy , DSDPVe AX , * axs ){ 593  kk , fo ; 594  xs =0, axs =0, ax ; 596 DSDPFuniBeg ; 597 `DSDPEvtLogBeg ( CeCompuX ); 598 fo = `DSDPVecZo ( AX ); `DSDPCHKERR (info); 599  kk =0;kk< dsdp -> nces ;kk++){ 600 `DSDPEvtLogBeg ( dsdp -> ceid [ kk ]); 601 axs =0; 602 fo = `DSDPCeCompuX ( dsdp -> ce [ kk ], xmakmu , xmaky , xmakdy , AX ,& axs ); `DSDPCHKCONEERR (kk,info); 603 xs += axs ; 604 `DSDPEvtLogEnd ( dsdp -> ceid [ kk ]); 606 fo = `DSDPVecGR ( AX ,& ax ); `DSDPCHKERR (info); 607 `DSDPLogInfo (0,2,"T(X): %4.2e\n", dsdp -> ax ); 608 fo = `DSDPVecAXPY (-1.0, dsdp -> b , AX ); `DSDPCHKERR (info); 609 fo = `DSDPCompuFixedYX ( dsdp -> M , AX ); `DSDPCHKERR (info); 610 * axs = xs ; 611 fo = `DSDPVecSR ( AX , ax ); `DSDPCHKERR (info); 612 `DSDPEvtLogEnd ( CeCompuX ); 613 `DSDPFuniRu (0); 614 } } @dsdpobjcone.c 1  ~"dsdpce_im.h " 2  ~"dsdpsys.h " 9 DSDPVec mb , mbb , mT ; 10  mdm ; 11  mpss , mdss ; 12 DSDP mdsdp ; 13 DSDPTruth mu ; 14 } tBCe ; 17  $BCompuS ( BCe * K , DSDPVec v , * ss ){ 18  fo ; 19 DSDPFuniBeg ; 20 fo = `DSDPVecD ( K -> bb , v , ss ); `DSDPCHKERR (info); 21 `DSDPFuniRu (0); 22 } } 24 #unde __FUNCT__ 25  #__FUNCT__ "DSDPRHessn" ) 26  $DSDPRHessn * dce ,  mu , DSDPSchurM M , DSDPVec vrhs1 , DSDPVe vrhs2 ){ 27 BCe * K =(BCe*) dce ; 28  bb , dd , ss = K -> dss ; 29  fo , i , m , ncs ; 30 DSDPVec T = K ->T, b =K-> bb ; 31 DSDPFuniBeg ; 32 i( K -> u ){ 33 fo = `DSDPVecGSize ( b ,& m ); `DSDPCHKERR (info); 34  i =0;i< m ;i++){ 35 fo = `DSDPVecGEmt ( b , i ,& bb ); `DSDPCHKERR (info); 36 i( bb ==0) ; 38 fo = `DSDPSchurMRowCumnSlg ( M , i , T ,& ncs ); `DSDPCHKERR (info); 39 i( ncs ==0) ; 41 fo = `DSDPVecGEmt ( T , i ,& dd ); `DSDPCHKERR (info); 42 fo = `DSDPVecAddEmt ( vrhs2 , i ,- bb * dd * mu / ss ); `DSDPCHKERR (info); 44 fo = `DSDPVecPotwiMu ( T , b ,T); `DSDPCHKERR (info); 46 fo = `DSDPVecS ( mu * bb /( ss *ss), T ); `DSDPCHKERR (info); 47 fo = `DSDPSchurMAddRow ( M , i ,1.0, T ); `DSDPCHKERR (info); 51 i( i ==- m -1){ fo = `DSDPVecVw ( T );} 54 `DSDPFuniRu (0); 55 } } 57  $DSDPRRHS * dce ,  mu , DSDPVec vrow , DSDPVe vrhs1 , DSDPVe vrhs2 ){ 58 BCe * K =(BCe*) dce ; 59  bb , dd , ss = K -> dss ; 60  fo , i , m ; 61 DSDPVec b = K -> bb ; 62 DSDPFuniBeg ; 63 i( K -> u ){ 64 fo = `DSDPVecGSize ( b ,& m ); `DSDPCHKERR (info); 65  i =0;i< m ;i++){ 66 fo = `DSDPVecGEmt ( b , i ,& bb ); `DSDPCHKERR (info); 67 fo = `DSDPVecGEmt ( vrow , i ,& dd ); `DSDPCHKERR (info); 68 fo = `DSDPVecAddEmt ( vrhs2 , i ,- bb * dd * mu / ss ); `DSDPCHKERR (info); 78 `DSDPFuniRu (0); 79 } } 81 #unde __FUNCT__ 82  #__FUNCT__ "DSDPSupBCe" ) 83  $DSDPSupBCe (* dce , DSDPVec y ){ 84 DSDPFuniBeg ; 85 `DSDPFuniRu (0); 86 } } 89 #unde __FUNCT__ 90  #__FUNCT__ "DSDPSDRDa" ) 91  $DSDPSDRDa ( BCe * K ){ 92  fo ; 93 DSDPFuniBeg ; 94 fo = `DSDPVecCy ( K -> b ,K-> bb ); `DSDPCHKERR (info); 95 fo = `DSDPVecSC ( K -> bb ,K-> dm ); `DSDPCHKERR (info); 96 fo = `DSDPVecSR ( K -> bb ,-1.0); `DSDPCHKERR (info); 97 `DSDPFuniRu (0); 98 } } 100 #unde __FUNCT__ 101  #__FUNCT__ "DSDPSupBCe2" ) 102  $DSDPSupBCe2 (* dce , DSDPVec y , DSDPSchurM M ){ 103 BCe * K =(BCe*) dce ; 104  fo ; 105 DSDPFuniBeg ; 106 fo = `DSDPVecDui ( K -> b ,&K-> T ); `DSDPCHKERR (info); 107 fo = `DSDPVecDui ( K -> b ,&K-> bb ); `DSDPCHKERR (info); 108 fo = `DSDPSDRDa ( K ); `DSDPCHKERR (info); 109 `DSDPFuniRu (0); 110 } } 113 #unde __FUNCT__ 114  #__FUNCT__ "DSDPDeroyBCe" ) 115  $DSDPDeroyBCe (* dce ){ 116 BCe * K =(BCe*) dce ; 117  fo ; 118 DSDPFuniBeg ; 119 fo = `DSDPVecDeroy (& K -> T ); `DSDPCHKERR (info); 120 fo = `DSDPVecDeroy (& K -> bb ); `DSDPCHKERR (info); 121 `DSDPFREE (& dce ,& fo ); `DSDPCHKERR (info); 122 `DSDPFuniRu (0); 123 } } 126 #unde __FUNCT__ 127  #__FUNCT__ "DSDPRSize" ) 128  $DSDPRSize (* dce ,* n ){ 129 DSDPFuniBeg ; 130 * n =1.0; 131 `DSDPFuniRu (0); 132 } } 134 #unde __FUNCT__ 135  #__FUNCT__ "DSDPRSrsy" ) 136  $DSDPRSrsy (* dce , row , * nz ,  nz [],  m ){ 137 BCe * K =(BCe*) dce ; 138  i , fo ; dd ; 139 DSDPFuniBeg ; 140 * nz =0; 142 fo = `DSDPVecGEmt ( K -> b , row ,& dd ); `DSDPCHKERR (info); 143 i( dd ){ 144  i =0;i< m ;i++){ 145 fo = `DSDPVecGEmt ( K -> b , i ,& dd ); `DSDPCHKERR (info); 146 i( dd !=0){ nz [ i ]++; (* nz )++;} 149 `DSDPFuniRu (0); 150 } } 152 #unde __FUNCT__ 153  #__FUNCT__ "DSDPCompuRS" ) 154  $DSDPCompuRS (* dce , DSDPVec Y , DSDPDuFaMrix ag , DSDPTruth * isdefe ){ 155 BCe * K =(BCe*) dce ; 156  fo ; 157  ss ; 158 DSDPFuniBeg ; 159 fo = `BCompuS ( K , Y ,& ss ); `DSDPCHKERR (info); 160 i( ss >0){ * isdefe = DSDP_TRUE ; } { *isdefe= DSDP_FALSE ;} 161 i( ag == DUAL_FACTOR ){ K -> dss = ss ; } { K-> pss =ss;} 162 `DSDPLogInfo (0,2,"DOBJCڐSS: %4.4\n", ss ); 163 `DSDPFuniRu (0); 164 } } 166 #unde __FUNCT__ 167  #__FUNCT__ "DSDPInvtRS" ) 168  $DSDPInvtRS (* dce ){ 169 DSDPFuniBeg ; 170 `DSDPFuniRu (0); 171 } } 174 #unde __FUNCT__ 175  #__FUNCT__ "DSDPCompuRSpLgth" ) 176  $DSDPCompuRSpLgth (* dce , DSDPVec DY , DSDPDuFaMrix ag , * maxngth ){ 177 BCe * K =(BCe*) dce ; 178  ds , ss , =1.0e30; 179  fo ; 181 DSDPFuniBeg ; 182 fo = `BCompuS ( K , DY ,& ds ); `DSDPCHKERR (info); 183 i( ag == DUAL_FACTOR ){ ss = K -> dss ; } { ss=K-> pss ;} 184 i( ds <0 =- ss /ds; 185 i( K -> u ){ 186 * maxngth = ; 188 `DSDPFuniRu (0); 189 } } 191 #unde __FUNCT__ 192  #__FUNCT__ "DSDPSX" ) 193  $DSDPSX * dce ,  mu , DSDPVec y , DSDPVe dy ){ 194 DSDPFuniBeg ; 195 `DSDPFuniRu (0); 196 } } 197 #unde __FUNCT__ 198  #__FUNCT__ "DSDPRX" ) 199  $DSDPRX * dce ,  mu , DSDPVec y , DSDPVe dy , DSDPVe AX ,* acxs ){ 200 BCe * K =(BCe*) dce ; 201  x , dss , ss = K ->dss; 202  fo ; 203 DSDPFuniBeg ; 205 fo = `BCompuS ( K , y ,& ss ); `DSDPCHKERR (info); 206 ss =1.0/ss; 207 fo = `BCompuS ( K , dy ,& dss ); `DSDPCHKERR (info); 208 x = mu *( ss +ss* dss *ss); 209 `DSDPLogInfo (0,2,"DOBJCڐSS: %4.4e, RESIDUAL X: %4.4e\n",1.0/ ss , x ); 210 i( `bs ( x * ss )>1.0 && mu < 1 `tf ("Check Dual Min Bound\n"); 211 fo = `DSDPVecAXPY (- x , K -> bb , AX ); `DSDPCHKERR (info); 212 `DSDPFuniRu (0); 213 } } 215 #unde __FUNCT__ 216  #__FUNCT__ "DSDPCompuRLog" ) 217  $DSDPCompuRLog (* dce , * logobj , * logd ){ 218 BCe * K =(BCe*) dce ; 219 DSDPFuniBeg ; 220 * logobj =0; 221 * logd = `log ( K -> dss ); 222 `DSDPFuniRu (0); 223 } } 225 #unde __FUNCT__ 226  #__FUNCT__ "DSDPRANm2" ) 227  $DSDPRANm2 (* dce , DSDPVec Anm2 ){ 228 DSDPFuniBeg ; 229 `DSDPFuniRu (0); 230 } } 233 #unde __FUNCT__ 234  #__FUNCT__ "DSDPRMuɝlyAdd" ) 235  $DSDPRMuɝlyAdd (* dce , mu , DSDPVec vrow ,DSDPVe v ,DSDPVe vout ){ 236 BCe * K =(BCe*) dce ; 237 DSDPVec T = K ->T; 238  fo ; 239  dd , ss = K -> dss ; 240 DSDPFuniBeg ; 241 fo = `DSDPVecD ( v , K -> bb ,& dd ); `DSDPCHKERR (info); 242 dd =- mu *dd/( ss *ss); 243 fo = `DSDPVecPotwiMu ( K -> bb , vrow , T ); `DSDPCHKERR (info); 244 fo = `DSDPVecAXPY ( dd , T , vout ); `DSDPCHKERR (info); 245 `DSDPFuniRu (0); 246 } } 249 #unde __FUNCT__ 250  #__FUNCT__ "DSDPRMڙ" ) 251  $DSDPRMڙ * dce ,  g ){ 252 DSDPFuniBeg ; 253 `DSDPFuniRu (0); 254 } } 256  _P_DSDPCe_Ops gks ; 257 cڡ * gmme ="Dual Obj Cone"; 259 #unde __FUNCT__ 260  #__FUNCT__ "BCeOtisInlize" ) 261  $BCeOtisInlize ( _P_DSDPCe_Ops * ces ){ 262  fo ; 263 i( ces == NULL )  0; 264 fo = `DSDPCeOpsInlize ( ces ); `DSDPCHKERR (info); 265 ces -> cehessn = DSDPRHessn ; 266 ces -> cetup = DSDPSupBCe ; 267 ces -> cetup2 = DSDPSupBCe2 ; 268 ces -> cederoy = DSDPDeroyBCe ; 269 ces -> cecompus = DSDPCompuRS ; 270 ces -> cevts = DSDPInvtRS ; 271 ces -> cecompux = DSDPRX ; 272 ces -> cetxmak = DSDPSX ; 273 ces -> cemaxngth = DSDPCompuRSpLgth ; 274 ces -> cږogpْtl = DSDPCompuRLog ; 275 ces -> cesize = DSDPRSize ; 276 ces -> cesy = DSDPRSrsy ; 277 ces -> cڗnm2 = DSDPRANm2 ; 278 ces -> cemڙ = DSDPRMڙ ; 279 ces -> cehmuɝlyadd = DSDPRMuɝlyAdd ; 280 ces -> cڔhs = DSDPRRHS ; 281 ces -> id =119; 282 ces -> me = mme ; 284 } } 286 #unde __FUNCT__ 287  #__FUNCT__ "DSDPAddBCe" ) 288  $DSDPAddBCe ( DSDP dsdp , DSDPVec bb ,  dm ){ 289 BCe * rce ; 290  fo ; 291 DSDPFuniBeg ; 292 fo = `BCeOtisInlize (& ks ); `DSDPCHKERR (info); 293 `DSDPCALLOC1 (& rce , BCe ,& fo ); `DSDPCHKERR (info); 294 rce -> b = bb ; 295 rce -> dm =dmin; 296 rce -> dsdp =dsdp; 297 rce -> u = DSDP_TRUE ; 298 fo = `DSDPAddCe ( dsdp ,& ks ,(*) rce ); `DSDPCHKERR (info); 299 `DSDPFuniRu (0); 300 } } 302  ~"dsdp.h " 303 #unde __FUNCT__ 304  #__FUNCT__ "DSDPSDuLowBound" ) 305  $DSDPSDuLowBound ( DSDP dsdp ,  dobjm ){ 306  fo ; 307 DSDPFuniBeg ; 308 fo = `DSDPAddBCe ( dsdp ,dsdp-> b , dobjm ); `DSDPCHKERR (info); 309 `DSDPFuniRu (0); 310 } } @dsdpprintout.c 1  ~"dsdp5.h " 7  gdsdrev =0; 8  gdsdrev2 =0; 10 #unde __FUNCT__ 11  #__FUNCT__ "DSDPPrtSts" ) 12  $DSDPPrtStsFe ( DSDP dsdp , * dummy ){ 14  obj , ddobj , pp , dp , mu , s , pas , m ; 15  , fo ; 16  ev = dsdrev2 ; 17 DSDPTmiRs as ; 19 if( ev <=0) (0); 20 if(! dsdpouutfe ) (0); 22 fo = `DSDPStRs ( dsdp ,& as ); `DSDPCHKERR (info); 23 fo = `DSDPGIts ( dsdp ,& ); `DSDPCHKERR (info); 25 if( as != CONTINUE_ITERATING || (( % ev )==0)){ 26 fo = `DSDPGDDObjeive ( dsdp ,& ddobj ); `DSDPCHKERR (info); 27 fo = `DSDPGPPObjeive ( dsdp ,& obj ); `DSDPCHKERR (info); 28 fo = `DSDPGR ( dsdp ,& s ); `DSDPCHKERR (info); 29 fo = `DSDPGPInasiby ( dsdp ,& pas ); `DSDPCHKERR (info); 30 fo = `DSDPGSpLgths ( dsdp ,& pp ,& dp ); `DSDPCHKERR (info); 31 fo = `DSDPGBrrPam ( dsdp ,& mu ); `DSDPCHKERR (info); 32 fo = `DSDPGPnm ( dsdp ,& m ); `DSDPCHKERR (info); 33 i( as == CONTINUE_ITERATING && >100 && iter%10!=0)  0; 35 i( ==0){ 36 `rtf ( dsdpouutfe ,"Iter PP Objective DD Objective PInfeas DInfeas Mu StepLength Pnrm\n"); 37 `rtf ( dsdpouutfe ,"--------------------------------------------------------------------------------------\n"); 39 `rtf ( dsdpouutfe ,"%-3d %16.8 %16.8%9.1%9.1%9.1e", , obj , ddobj , pas , s , mu ); 40 `rtf ( dsdpouutfe ," %4.2 %4.2f", pp , dp ); 41 i( m >1.0e3){ 42 `rtf ( dsdpouutfe ," %1.0\n", m ); 44 `rtf ( dsdpouutfe ," %5.2\n", m ); 49 } } 51 #unde __FUNCT__ 52  #__FUNCT__ "DSDPSSnddMڙ" ) 53  $DSDPSFeMڙ ( DSDP dsdp ,  ev ){ 54  fo ; 55 dsdrev2 = ev ; 56 fo = `DSDPSMڙ ( dsdp , DSDPPrtStsFe ,0); `DSDPCHKERR (info); 58 } } 69 #unde __FUNCT__ 70  #__FUNCT__ "DSDPPrtSts" ) 71  $DSDPPrtSts ( DSDP dsdp , * dummy ){ 73  obj , ddobj , pp , dp , mu , s , pas , m ; 74  , fo ; 75  ev = dsdrev ; 76 DSDPTmiRs as ; 78 if( ev <=0) (0); 80 fo = `DSDPStRs ( dsdp ,& as ); `DSDPCHKERR (info); 81 fo = `DSDPGIts ( dsdp ,& ); `DSDPCHKERR (info); 83 if( as != CONTINUE_ITERATING || (( % ev )==0)){ 84 fo = `DSDPGDDObjeive ( dsdp ,& ddobj ); `DSDPCHKERR (info); 85 fo = `DSDPGPPObjeive ( dsdp ,& obj ); `DSDPCHKERR (info); 86 fo = `DSDPGR ( dsdp ,& s ); `DSDPCHKERR (info); 87 fo = `DSDPGPInasiby ( dsdp ,& pas ); `DSDPCHKERR (info); 88 fo = `DSDPGSpLgths ( dsdp ,& pp ,& dp ); `DSDPCHKERR (info); 89 fo = `DSDPGBrrPam ( dsdp ,& mu ); `DSDPCHKERR (info); 90 fo = `DSDPGPnm ( dsdp ,& m ); `DSDPCHKERR (info); 91 i(0 && as == CONTINUE_ITERATING && >100 && iter%10!=0)  0; 93 i( ==0){ 94 `tf ("Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm\n") 96 `tf ("---------------------------------------------------------------------------------------\n") 99 `tf ("%-3d %16.8 %16.8%9.1%9.1%9.1e", , obj , ddobj , pas , s , mu ); 100 `tf (" %4.2 %4.2f", pp , dp ); 101 i( m >1.0e3){ 102 `tf (" %1.0\n", m ); 104 `tf (" %5.2\n", m ); 106 `fush ( NULL ); 109 } } 151 #unde __FUNCT__ 152  #__FUNCT__ "DSDPSSnddMڙ" ) 153  $DSDPSSnddMڙ ( DSDP dsdp ,  k ){ 154  fo ; 155 fo = `DSDPSMڙ ( dsdp , DSDPPrtSts ,0); `DSDPCHKERR (info); 156 dsdrev = k ; 158 } } @dsdprescone.c 1  ~"dsdpce_im.h " 2  ~"dsdpsys.h " 3  ~"dsdpbasiys.h " 10  sRDCe { 11  mimr , mdur , mx , mlogr ; 12 DSDPPty mUPty ; 13 DSDP mdsdp ; 16  RDCe tRCe ; 18 #unde __FUNCT__ 19  #__FUNCT__ "DSDPRHessn" ) 20  $DSDPRHessn * dce ,  mu , DSDPSchurM M , DSDPVec vrhs1 , DSDPVe vrhs2 ){ 21 RCe * K =(RCe*) dce ; 22  fo , m ; 23  , , rs ; 24 DSDPFuniBeg ; 25 i( K -> dur ){ 26 fo = `DSDPVecGSize ( vrhs2 ,& m ); `DSDPCHKERR (info); 27 fo = `DSDPSchurMVbCompu ( M , m -1,& ); `DSDPCHKERR (info); 28 i( ){ 29 =- mu * /( K -> dur ); 30 rs = mu * /( K -> dur *K->dualr); 31 fo = `DSDPVecAddR ( vrhs2 , ); `DSDPCHKERR (info); 32 fo = `DSDPSchurMAddDgڮEmt ( M , m -1, rs ); `DSDPCHKERR (info); 35 `DSDPFuniRu (0); 36 } } 39 #unde __FUNCT__ 40  #__FUNCT__ "DSDPRHS" ) 41  $DSDPRHS * dce ,  mu , DSDPVec vrow ,DSDPVe vrhs1 ,DSDPVe vrhs2 ){ 42 RCe * K =(RCe*) dce ; 43  fo ; 44  , ; 45 DSDPFuniBeg ; 46 i( K -> dur ){ 47 =- mu /( K -> dur ); 48 fo = `DSDPVecGR ( vrow ,& ); `DSDPCHKERR (info); 49 fo = `DSDPVecAddR ( vrhs2 , * ); `DSDPCHKERR (info); 51 `DSDPFuniRu (0); 52 } } 55 #unde __FUNCT__ 56  #__FUNCT__ "DSDPSupRCe" ) 57  $DSDPSupRCe (* dce , DSDPVec y ){ 58 DSDPFuniBeg ; 59 `DSDPFuniRu (0); 60 } } 62 #unde __FUNCT__ 63  #__FUNCT__ "DSDPSupRCe2" ) 64  $DSDPSupRCe2 (* dce , DSDPVec y , DSDPSchurM M ){ 65 DSDPFuniBeg ; 66 `DSDPFuniRu (0); 67 } } 70 #unde __FUNCT__ 71  #__FUNCT__ "DSDPDeroyRCe" ) 72  $DSDPDeroyRCe (* dce ){ 73  fo ; 74 DSDPFuniBeg ; 75 `DSDPFREE (& dce ,& fo ); `DSDPCHKERR (info); 76 `DSDPFuniRu (0); 77 } } 80 #unde __FUNCT__ 81  #__FUNCT__ "DSDPRSize" ) 82  $DSDPRSize (* dce ,* n ){ 83 RCe * K =(RCe*) dce ; 84 DSDPFuniBeg ; 85 i( K -> dur ){* n =1;} 86 {* n =0;} 87 `DSDPFuniRu (0); 88 } } 90 #unde __FUNCT__ 91  #__FUNCT__ "DSDPRSrsy" ) 92  $DSDPRSrsy (* dce , row , * nz ,  nz [],  m ){ 93 DSDPFuniBeg ; 94 * nz =0; 95 `DSDPFuniRu (0); 96 } } 99 #unde __FUNCT__ 100  #__FUNCT__ "DSDPCompuRS" ) 101  $DSDPCompuRS (* dce , DSDPVec Y , DSDPDuFaMrix ag , DSDPTruth * isdefe ){ 102 RCe * K =(RCe*) dce ; 103  fo ; 104  rba ; 105 DSDPFuniBeg ; 106 fo = `DSDPVecGR ( Y ,& rba ); `DSDPCHKERR (info); 107 i( K -> UPty == DSDPAlways ){ 108 i( rba <0){ * isdefe = DSDP_TRUE ; } { *isdefe= DSDP_FALSE ;} 110 i( rba >0)beta=0; 111 * isdefe = DSDP_TRUE ; 113 i( ag == DUAL_FACTOR ){ K -> dur = rba ; } { K-> imr =rbeta;} 114 `DSDPFuniRu (0); 115 } } 116 #unde __FUNCT__ 117  #__FUNCT__ "DSDPInvtRS" ) 118  $DSDPInvtRS (* dce ){ 119 DSDPFuniBeg ; 120 `DSDPFuniRu (0); 121 } } 125 #unde __FUNCT__ 126  #__FUNCT__ "DSDPCompuRSpLgth" ) 127  $DSDPCompuRSpLgth (* dce , DSDPVec DY , DSDPDuFaMrix ag , * maxngth ){ 128 RCe * K =(RCe*) dce ; 129  r , rba , mngth =1.0e100, =1.0e30; 130  fo ; 131 DSDPFuniBeg ; 133 fo = `DSDPVecGR ( DY ,& rba ); `DSDPCHKERR (info); 134 i( ag == DUAL_FACTOR ){ r = K -> dur ; } {=K-> imr ;} 135 i( r * rba <0 =-r/rbeta; 137 i( K -> UPty == DSDPAlways ){ mngth = ;} 138 i( ag == PRIMAL_FACTOR ){ mngth = ;} 139 i( ag == DUAL_FACTOR ){ mngth = /0.94;} 141 * maxngth = mngth ; 142 `DSDPFuniRu (0); 143 } } 145 #unde __FUNCT__ 146  #__FUNCT__ "DSDPRX" ) 147  $DSDPRX * dce ,  mu , DSDPVec y , DSDPVe dy , DSDPVe AX ,* axs ){ 148 RCe * K =(RCe*) dce ; 149  fo ; 150  , dr , xs , r = K -> dur ; 151 DSDPFuniBeg ; 153 fo = `DSDPVecGR ( y ,& ); `DSDPCHKERR (info); 154 fo = `DSDPVecGR ( dy ,& dr ); `DSDPCHKERR (info); 155 i( K -> dur ){ 156 r =-1.0/ ; 157 K -> x = mu *( r -r* dr *r); 158 xs = K -> x / r ; 159 `DSDPLogInfo (0,2,"RESIDUAL X (Mimum Pty Pam): %4.4e, T(XS): %4.4e\n", K -> x , xs ); 162 K -> x =0.0; 164 `DSDPFuniRu (0); 165 } } 167 #unde __FUNCT__ 168  #__FUNCT__ "DSDPSX" ) 169  $DSDPSX * dce ,  mu , DSDPVec y , DSDPVe dy ){ 170 DSDPFuniBeg ; 178 `DSDPFuniRu (0); 179 } } 181 #unde __FUNCT__ 182  #__FUNCT__ "DSDPCompuRLog" ) 183  $DSDPCompuRLog (* dce , * logobj , * logd ){ 184 RCe * K =(RCe*) dce ; 185 DSDPFuniBeg ; 186 * logd = K -> logr ; 187 * logobj =0; 188 i( K -> dur <0){ 189 * logd = `log (- K -> dur ); 190 K -> logr = `log (-K-> dur ); 192 `DSDPFuniRu (0); 193 } } 195 #unde __FUNCT__ 196  #__FUNCT__ "DSDPRANm2" ) 197  $DSDPRANm2 (* dce , DSDPVec Anm2 ){ 198 DSDPFuniBeg ; 199 `DSDPFuniRu (0); 200 } } 202 #unde __FUNCT__ 203  #__FUNCT__ "DSDPRMuɝlyAdd" ) 204  $DSDPRMuɝlyAdd (* dce , mu , DSDPVec vrow ,DSDPVe v ,DSDPVe vout ){ 205 RCe * K =(RCe*) dce ; 206  fo ; 207  v1 , v2 , rs ; 208 DSDPFuniBeg ; 209 i( K -> dur ){ 210 fo = `DSDPVecGR ( vrow ,& v1 ); `DSDPCHKERR (info); 211 fo = `DSDPVecGR ( v ,& v2 ); `DSDPCHKERR (info); 212 rs = v1 * v2 * mu /( K -> dur *K->dualr); 213 fo = `DSDPVecAddR ( vout , rs ); `DSDPCHKERR (info); 215 `DSDPFuniRu (0); 216 } } 218 #unde __FUNCT__ 219  #__FUNCT__ "DSDPRMڙ" ) 220  $DSDPRMڙ * dce ,  g ){ 221 DSDPFuniBeg ; 222 `DSDPFuniRu (0); 223 } } 225  _P_DSDPCe_Ops gks ; 226 cڡ * gmme ="R Cone"; 228 #unde __FUNCT__ 229  #__FUNCT__ "RCeOtisInlize" ) 230  $RCeOtisInlize ( _P_DSDPCe_Ops * ces ){ 231  fo ; 232 i( ces == NULL )  0; 233 fo = `DSDPCeOpsInlize ( ces ); `DSDPCHKERR (info); 234 ces -> cehessn = DSDPRHessn ; 235 ces -> cetup = DSDPSupRCe ; 236 ces -> cetup2 = DSDPSupRCe2 ; 237 ces -> cederoy = DSDPDeroyRCe ; 238 ces -> cecompus = DSDPCompuRS ; 239 ces -> cevts = DSDPInvtRS ; 240 ces -> cetxmak = DSDPSX ; 241 ces -> cecompux = DSDPRX ; 242 ces -> cڔhs = DSDPRHS ; 243 ces -> cemaxngth = DSDPCompuRSpLgth ; 244 ces -> cږogpْtl = DSDPCompuRLog ; 245 ces -> cesize = DSDPRSize ; 246 ces -> cesy = DSDPRSrsy ; 247 ces -> cڗnm2 = DSDPRANm2 ; 248 ces -> cemڙ = DSDPRMڙ ; 249 ces -> cehmuɝlyadd = DSDPRMuɝlyAdd ; 250 ces -> id =19; 251 ces -> me = mme ; 253 } } 264 #unde __FUNCT__ 265  #__FUNCT__ "RCeSTy" ) 266  $RCeSTy ( RCe * rce , DSDPPty UPty ){ 267 DSDPFuniBeg ; 268 rce -> UPty =UsePenalty; 269 `DSDPFuniRu (0); 270 } } 281 #unde __FUNCT__ 282  #__FUNCT__ "DSDPAddRCe" ) 283  $DSDPAddRCe ( DSDP dsdp , RCe ** ce ){ 284 RCe * rce ; 285 DSDPPty UPty = DSDPInasib ; 286  fo ; 287 DSDPFuniBeg ; 288 fo = `RCeOtisInlize (& ks ); `DSDPCHKERR (info); 289 `DSDPCALLOC1 (& rce , RCe ,& fo ); `DSDPCHKERR (info); 290 fo = `RCeSTy ( rce , UPty ); `DSDPCHKERR (info); 291 rce -> dsdp =dsdp; 292 rce -> logr =0; 293 * ce = rce ; 294 fo = `DSDPAddCe ( dsdp ,& ks ,(*) rce ); `DSDPCHKERR (info); 295 `DSDPFuniRu (0); 296 } } @dsdpschurmat.c 1  ~"dsdpschurm_im.h " 2  ~"dsdpschurm.h " 3  ~"dsdpbasiys.h " 4  ~"dsdpsys.h " 12  ghevt =0, ghsvvt =0; 14  #DSDPNoOtiE ( a ); { `DSDPSETERR1 (10,"Schumrixy: %s, Otiڂ defed\n",). dsdps -> mme ); } ) 15  #DSDPChkME ( a , b ); { i(b){ `DSDPSETERR1 (b,"Schumrixy: %s,\n",). dsdps -> mme );} } ) 17  DSDPAlySMW ( DSDPSchurM , DSDPVec , DSDPVec); 18  DSDPSchurMSveM ( DSDPSchurM , DSDPVec , DSDPVec); 20 #unde __FUNCT__ 21  #__FUNCT__ "DSDPSchurMSDa" ) 22  $DSDPSchurMSDa ( DSDPSchurM * M ,  _P_DSDPSchurM_Ops * s , * da ){ 23 DSDPFuniBeg ; 24 (* M ). dsdps = s ; 25 (* M ). da =data; 26 `DSDPFuniRu (0); 27 } } 29 cڡ * gschurmme ="NOT NAMED YET"; 31 #unde __FUNCT__ 32  #__FUNCT__ "DSDPSchurMOpsInlize" ) 33  $DSDPSchurMOpsInlize ( _P_DSDPSchurM_Ops * ds ){ 34 DSDPFuniBeg ; 35 i( ds == NULL )  0; 36 ds -> mzo =0; 37 ds -> mrownzos =0; 38 ds -> maddrow =0; 39 ds -> maddemt =0; 40 ds -> madddgڮ =0; 41 ds -> mshidgڮ =0; 42 ds -> masmb =0; 43 ds -> msdmuɝly =0; 44 ds -> mmur =0; 45 ds -> m =0; 46 ds -> msve =0; 47 ds -> pmڴoss =0; 48 ds -> pmwhichdg =0; 49 ds -> pmdiribud =0; 50 ds -> mderoy =0; 51 ds -> mvw =0; 52 ds -> mtup =0; 53 ds -> id =0; 54 ds -> mme = schurmme ; 55 `DSDPFuniRu (0); 56 } } 58  _P_DSDPSchurM_Ops gdsdpms ; 61 #unde __FUNCT__ 62  #__FUNCT__ "DSDPSchurMOpsInlize" ) 63  $DSDPSchurMInlize ( DSDPSchurM * M ){ 64  fo ; 65 DSDPFuniBeg ; 66 fo = `DSDPSchurMOpsInlize (& dsdpms ); `DSDPCHKERR (info); 67 fo = `DSDPSchurMSDa ( M ,& dsdpms ,0); `DSDPCHKERR (info); 68 `DSDPCALLOC1 (& M -> schur , DSDPSchurInfo ,& fo ); `DSDPCHKERR (info); 69 M -> schur -> m =0; M->schur-> r =0; M->schur-> dd =0; 70 fo = `DSDPInlizeFixedVb (& M -> schur -> fv ); `DSDPCHKERR (info); 71 `DSDPFuniRu (0); 72 } } 74 #unde __FUNCT__ 75  #__FUNCT__ "DSDPSchurMZoErs" ) 76  $DSDPSchurMZoErs ( DSDPSchurM M ){ 77  fo ; 78 DSDPFuniBeg ; 79 i( M . dsdps -> mzo ){ 80 fo =( M . dsdps -> mzo )(M. da ); `DSDPChkME (M,info); 82 `DSDPNoOtiE ( M ); 84 `DSDPFuniRu (0); 85 } } 88 #unde __FUNCT__ 89  #__FUNCT__ "DSDPSchurMRowCumnSlg" ) 90  $DSDPSchurMRowCumnSlg ( DSDPSchurM M , row , DSDPVec V , * nzcs ){ 91  fo , m ; 92 * cs , r = M . schur ->r; 93 DSDPTruth ag ; 94 DSDPFuniBeg ; 95 fo = `DSDPVecS (0.0, V ); `DSDPCHKERR (info); 96 fo = `DSDPVecGSize ( V ,& m ); `DSDPCHKERR (info); 97 i( row ==0){ fo = `DSDPVecZo ( V ); `DSDPCHKERR (fo);* nzcs =0;} 98 i( row == m -1){ 99 fo = `DSDPVecZo ( V ); `DSDPCHKERR (fo);* nzcs =0; 100 i( r ){ fo = `DSDPVecSR ( V ,1.0); `DSDPCHKERR (fo);* nzcs =1;} 101 } i( M . dsdps -> mrownzos ){ 102 fo = `DSDPVecGSize ( V ,& m ); `DSDPCHKERR (info); 103 fo = `DSDPVecGAay ( V ,& cs ); `DSDPCHKERR (info); 104 fo =( M . dsdps -> mrownzos )(M. da , row -1, cs +1, nzcs , m -2); `DSDPChkME (M,info); 105 fo = `DSDPVecReeAay ( V ,& cs ); `DSDPCHKERR (info); 106 fo = `DSDPZoFixedVbs ( M , V ); `DSDPCHKERR (info); 107 fo = `DSDPVecSC ( V ,0.0); `DSDPCHKERR (info); 108 i( r ){ fo = `DSDPVecSR ( V ,1.0); `DSDPCHKERR (info);} 109 fo = `DSDPIsFixed ( M , row ,& ag ); `DSDPCHKERR (info); 110 i( ag == DSDP_TRUE &&* nzcs >0){ fo = `DSDPVecZo ( V );*nzcs=0; `DSDPFuniRu (0);} 112 `DSDPNoOtiE ( M ); 115 `DSDPFuniRu (0); 116 } } 118 #unde __FUNCT__ 119  #__FUNCT__ "DSDPSchurMAddRow" ) 120  $DSDPSchurMAddRow ( DSDPSchurM M ,  row ,  pha , DSDPVec R ){ 121  fo , j , m ; 122 * v , , dd =1e-1* M . schur ->dd; 123 DSDPVec rhs3 = M . schur ->rhs3; 124 DSDPTruth ag ; 125 DSDPFuniBeg ; 126 fo = `DSDPVecGSize ( R ,& m ); `DSDPCHKERR (info); 127 i( row ==0){ 128 } i( row == m -1){ 129 fo = `DSDPVecGR ( R ,& ); `DSDPCHKERR (info); 130 fo = `DSDPVecAddR ( rhs3 , pha * ); `DSDPCHKERR (info); 131 } i( M . dsdps -> maddrow ){ 132 fo = `DSDPVecGAay ( R ,& v ); `DSDPCHKERR (info); 134  j =0;j< m ;j++){ i( `bs ( v [j]< 1e-25 && row !=j){ v[j]=0.0;} } 135 v [ row ]*=(1.0+ dd ); 136 fo = `DSDPZoFixedVbs ( M , R ); `DSDPCHKERR (info); 137 fo = `DSDPIsFixed ( M , row ,& ag ); `DSDPCHKERR (info); 138 i( ag == DSDP_TRUE ){ fo = `DSDPVecSBasis ( R , row ); `DSDPCHKERR (info);} 139 fo =( M . dsdps -> maddrow )(M. da , row -1, pha , v +1, m -2); `DSDPChkME (M,info); 140 fo = `DSDPVecReeAay ( R ,& v ); `DSDPCHKERR (info); 141 fo = `DSDPVecGR ( R ,& ); `DSDPCHKERR (info); 142 fo = `DSDPVecAddEmt ( rhs3 , row , pha * ); `DSDPCHKERR (info); 144 `DSDPNoOtiE ( M ); 146 `DSDPFuniRu (0); 147 } } 149 #unde __FUNCT__ 150  #__FUNCT__ "DSDPSchurMAddDgڮEmt" ) 151  $DSDPSchurMAddDgڮEmt ( DSDPSchurM M ,  row ,  dd ){ 152  fo , m ; 153 DSDPVec rhs3 = M . schur ->rhs3; 154 DSDPFuniBeg ; 155 fo = `DSDPVecGSize ( rhs3 ,& m ); `DSDPCHKERR (info); 156 i( dd ==0){ 157 } i( row ==0){ 158 } i( row == m -1){ fo = `DSDPVecAddR ( rhs3 , dd ); 159 } i( M . dsdps -> maddemt ){ 160 fo =( M . dsdps -> maddemt )(M. da , row -1, dd ); `DSDPChkME (M,info); 162 `DSDPNoOtiE ( M ); 164 `DSDPFuniRu (0); 165 } } 167 #unde __FUNCT__ 168  #__FUNCT__ "DSDPSchurMAddR" ) 169  $DSDPSchurMAddR ( DSDPSchurM M ,  row ,  dd ){ 170  fo ; 171 DSDPFuniBeg ; 172 i( dd ==0){ `DSDPFuniRu (0);} 173 fo = `DSDPVecAddEmt ( M . schur -> rhs3 , row , dd ); `DSDPCHKERR (info); 174 `DSDPFuniRu (0); 175 } } 177 #unde __FUNCT__ 178  #__FUNCT__ "DSDPSchurMAddC" ) 179  $DSDPSchurMAddC ( DSDPSchurM M ,  row ,  dd ){ 180 DSDPFuniBeg ; 181 `DSDPFuniRu (0); 182 } } 184 #unde __FUNCT__ 185  #__FUNCT__ "DSDPSchurMShiDgڮ" ) 186  $DSDPSchurMShiDgڮ ( DSDPSchurM M ,  dd ){ 187  fo ; 188 DSDPFuniBeg ; 189 i( dd ==0){ `DSDPFuniRu (0);} 190 M . schur -> dd =dd; 191 i( M . dsdps -> mshidgڮ ){ 193 fo =( M . dsdps -> mshidgڮ )(M. da , dd ); `DSDPChkME (M,info); 194 `DSDPLogInfo (0,2,"Add %4.4tthDgڮ oSchuMrix\n", dd ); 196 `DSDPNoOtiE ( M ); 198 `DSDPFuniRu (0); 199 } } 201 #unde __FUNCT__ 202  #__FUNCT__ "DSDPSchurMAddDgڮ" ) 203  $DSDPSchurMAddDgڮ ( DSDPSchurM M , DSDPVec D ){ 204  m , fo ; 205 * dd ; 206 DSDPFuniBeg ; 207 i( M . dsdps -> madddgڮ ){ 208 fo = `DSDPZoFixedVbs ( M , D ); `DSDPCHKERR (info); 209 fo = `DSDPVecGSize ( D ,& m ); `DSDPCHKERR (info); 210 fo = `DSDPVecGAay ( D ,& dd ); `DSDPCHKERR (info); 211 fo =( M . dsdps -> madddgڮ )(M. da , dd +1, m -2); `DSDPChkME (M,info); 212 fo = `DSDPVecAddR ( M . schur -> rhs3 , dd [ m -1]); `DSDPCHKERR (info); 213 fo = `DSDPVecReeAay ( D ,& dd ); `DSDPCHKERR (info); 215 `DSDPNoOtiE ( M ); 217 `DSDPFuniRu (0); 218 } } 220 #unde __FUNCT__ 221  #__FUNCT__ "DSDPSchurMInPl" ) 222  $DSDPSchurMInPl ( DSDPSchurM M , DSDPTruth * ag ){ 223  fo , g ; 224 DSDPFuniBeg ; 225 i( M . dsdps -> pmdiribud ){ 226 fo =( M . dsdps -> pmdiribud )(M. da ,& g ); `DSDPChkME (M,info); 227 i( g * ag = DSDP_TRUE ; *ag= DSDP_FALSE ; 229 * ag = DSDP_FALSE ; 231 `DSDPFuniRu (0); 232 } } 234 #unde __FUNCT__ 235  #__FUNCT__ "DSDPSchurMVbCompu" ) 236  $DSDPSchurMVbCompu ( DSDPSchurM M ,  row , * rcv ){ 237  fo , m , dd =1; 238  r = M . schur ->r; 239 DSDPTruth ag ; 240 DSDPFuniBeg ; 241 fo = `DSDPVecGSize ( M . schur -> rhs3 ,& m ); 242 i( row ==0){ * rcv =0.0; 243 } i( row == m -1){ 244 i( r ){* rcv =1.0;} 245 {* rcv =0.0;} 246 } i( M . dsdps -> pmڴoss ){ 247 fo =( M . dsdps -> pmڴoss )(M. da , row -1,& dd ); `DSDPChkME (M,info); 248 i( dd ){* rcv =1.0;} {*rcv=0;} 250 fo = `DSDPSchurMInPl ( M ,& ag ); `DSDPChkME (M,info); 251 i( ag == DSDP_FALSE ){ * rcv =1.0; 253 `DSDPNoOtiE ( M ); 256 `DSDPFuniRu (0); 257 } } 259 #unde __FUNCT__ 260  #__FUNCT__ "DSDPSchurMVbCompuC" ) 261  $DSDPSchurMVbCompuC ( DSDPSchurM M , * rcv ){ 262 DSDPFuniBeg ; 263 * rcv =0.0; 264 `DSDPFuniRu (0); 265 } } 267 #unde __FUNCT__ 268  #__FUNCT__ "DSDPSchurMVbCompuR" ) 269  $DSDPSchurMVbCompuR ( DSDPSchurM M , * rcv ){ 270 DSDPFuniBeg ; 271 * rcv =0.0; 272 i( M . schur -> r * rcv =1.0; 273 `DSDPFuniRu (0); 274 } } 276 #unde __FUNCT__ 277  #__FUNCT__ "DSDPSchurMVbsOnPross" ) 278  $DSDPSchurMDgڮSlg ( DSDPSchurM M , DSDPVec D ){ 279  m , fo ; 280 * vs ; 281 DSDPTruth ag ; 282 DSDPFuniBeg ; 283 fo = `DSDPVecS (1.0, D ); `DSDPCHKERR (info); 284 fo = `DSDPVecGSize ( D ,& m ); `DSDPCHKERR (info); 285 i( M . dsdps -> pmlolvbs ){ 286 fo = `DSDPVecGAay ( D ,& vs ); `DSDPCHKERR (info); 287 fo =( M . dsdps -> pmlolvbs )(M. da , vs +1, m -2); `DSDPChkME (M,info); 288 fo = `DSDPVecReeAay ( D ,& vs ); `DSDPCHKERR (info); 290 fo = `DSDPSchurMInPl ( M ,& ag ); `DSDPChkME (M,info); 291 i( ag == DSDP_TRUE ){ 292 `DSDPNoOtiE ( M ); 295 fo = `DSDPVecSC ( D ,0.0); `DSDPCHKERR (info); 296 i( M . schur -> r ==0){ fo = `DSDPVecSR ( D ,0.0); `DSDPCHKERR (info);} 297 fo = `DSDPZoFixedVbs ( M , D ); `DSDPCHKERR (info); 298 `DSDPFuniRu (0); 299 } } 301 #unde __FUNCT__ 302  #__FUNCT__ "DSDPSchurMRowSlg" ) 303  $DSDPSchurMRowSlg ( DSDPSchurM M , DSDPVec D ){ 304  fo ; 305 DSDPFuniBeg ; 306 fo = `DSDPSchurMDgڮSlg ( M , D ); `DSDPCHKERR (info); 307 fo = `DSDPZoFixedVbs ( M , D ); `DSDPCHKERR (info); 308 `DSDPFuniRu (0); 309 } } 311 #unde __FUNCT__ 312  #__FUNCT__ "DSDPSchurMZoAsmb" ) 313  $DSDPSchurMAsmb ( DSDPSchurM M ){ 314  fo ; 315 DSDPFuniBeg ; 316 i( M . dsdps -> masmb ){ 317 fo =( M . dsdps -> masmb )(M. da ); `DSDPChkME (M,info); 319 `DSDPNoOtiE ( M ); 321 `DSDPFuniRu (0); 322 } } 324 #unde __FUNCT__ 325  #__FUNCT__ "DSDPSchurMFa" ) 326  $DSDPSchurMFa ( DSDPSchurM M , DSDPTruth * sucssful ){ 327  fo , ag =0; 328 DSDPVec rhs3 = M . schur ->rhs3, dy3 =M.schur->dy3; 329 DSDPFuniBeg ; 330 * sucssful = DSDP_TRUE ; 331 `DSDPEvtLogBeg ( hevt ); 332 i( M . dsdps -> m ){ 333 fo =( M . dsdps -> m )(M. da ,& ag ); `DSDPChkME (M,info); 334 i( ag ){ 335 * sucssful = DSDP_FALSE ; 336 `DSDPLogInfo (0,2,"Indefinite Schur Matrix -- Bad Factorization\n"); 339 `DSDPNoOtiE ( M ); 341 `DSDPEvtLogEnd ( hevt ); 342 i( M . schur -> r ){ 343 fo = `DSDPSchurMSveM ( M , rhs3 , dy3 ); `DSDPCHKERR (info);} 344 { fo = `DSDPVecZo ( dy3 ); `DSDPCHKERR (info);} 345 `DSDPFuniRu (0); 346 } } 349 #unde __FUNCT__ 350  #__FUNCT__ "DSDPSchurMMuɝly" ) 351  $DSDPSchurMMuɝly ( DSDPSchurM M , DSDPVec x , DSDPVe y ){ 352  fo , n ; 353 * xx ,* yy , r = M . schur ->r; 354  r1 , r2 , dd ; 355 DSDPVec rhs3 ; 356 DSDPFuniBeg ; 358 i( M . dsdps -> msdmuɝly ){ 359 fo = `DSDPVecGSize ( x ,& n ); `DSDPCHKERR (info); 360 fo = `DSDPVecGAay ( x ,& xx ); `DSDPCHKERR (info); 361 fo = `DSDPVecGAay ( y ,& yy ); `DSDPCHKERR (info); 362 fo =( M . dsdps -> msdmuɝly )(M. da , xx +1, yy +1, n -2); `DSDPChkME (M,info); 363 yy [0]=0; 364 yy [ n -1]=0; 365 fo = `DSDPVecReeAay ( y ,& yy ); `DSDPCHKERR (info); 366 fo = `DSDPVecReeAay ( x ,& xx ); `DSDPCHKERR (info); 368 `DSDPNoOtiE ( M ); 370 i( r ){ 371 rhs3 = M . schur ->rhs3; 372 fo = `DSDPVecGR ( rhs3 ,& r2 ); `DSDPCHKERR (info); 373 fo = `DSDPVecGR ( x ,& r1 ); `DSDPCHKERR (info); 374 fo = `DSDPVecAXPY ( r1 , rhs3 , y ); `DSDPCHKERR (info); 375 fo = `DSDPVecD ( rhs3 , x ,& dd ); `DSDPCHKERR (info); 376 fo = `DSDPVecAddR ( y , dd - r1 * r2 ); `DSDPCHKERR (info); 378 `DSDPFuniRu (0); 379 } } 381 #unde __FUNCT__ 382  #__FUNCT__ "DSDPSchurMMuR" ) 383  $DSDPSchurMMuR ( DSDPSchurM M , DSDPVec x , DSDPVe y ){ 384  fo , n ; 385 * xx ,* yy , r = M . schur ->r; 386  r1 , r2 , dd ; 387 DSDPVec rhs3 ; 388 DSDPFuniBeg ; 390 i( M . dsdps -> mmur ){ 391 fo = `DSDPVecGSize ( x ,& n ); `DSDPCHKERR (info); 392 fo = `DSDPVecGAay ( x ,& xx ); `DSDPCHKERR (info); 393 fo = `DSDPVecGAay ( y ,& yy ); `DSDPCHKERR (info); 394 fo =( M . dsdps -> mmur )(M. da , xx +1, yy +1, n -2); `DSDPChkME (M,info); 395 yy [0]=0; 396 yy [ n -1]=0; 397 fo = `DSDPVecReeAay ( y ,& yy ); `DSDPCHKERR (info); 398 fo = `DSDPVecReeAay ( x ,& xx ); `DSDPCHKERR (info); 399 i( r ){ 400 rhs3 = M . schur ->rhs3; 401 fo = `DSDPVecGR ( rhs3 ,& r2 ); `DSDPCHKERR (info); 402 fo = `DSDPVecGR ( x ,& r1 ); `DSDPCHKERR (info); 403 fo = `DSDPVecAXPY ( r1 , rhs3 , y ); `DSDPCHKERR (info); 404 fo = `DSDPVecD ( rhs3 , x ,& dd ); `DSDPCHKERR (info); 405 fo = `DSDPVecAddR ( y , dd - r1 * r2 ); `DSDPCHKERR (info); 408 fo = `DSDPVecZo ( y ); `DSDPCHKERR (info); 411 `DSDPFuniRu (0); 412 } } 414 #unde __FUNCT__ 415  #__FUNCT__ "DSDPSchurMReduPVec" ) 416  $DSDPSchurMReduPVec ( DSDPSchurM M , DSDPVec x ){ 417  fo , n ; 418 * xx ; 419 DSDPTruth ag ; 420 DSDPFuniBeg ; 422 i( M . dsdps -> pmdui ){ 423 fo = `DSDPVecGSize ( x ,& n ); `DSDPCHKERR (info); 424 fo = `DSDPVecGAay ( x ,& xx ); `DSDPCHKERR (info); 425 fo =( M . dsdps -> pmdui )(M. da , xx +1, n -2); `DSDPChkME (M,info); 426 fo = `DSDPVecReeAay ( x ,& xx ); `DSDPCHKERR (info); 428 fo = `DSDPSchurMInPl ( M ,& ag ); `DSDPChkME (M,info); 429 i( ag == DSDP_TRUE ){ 430 `DSDPNoOtiE ( M ); 433 fo = `DSDPZoFixedVbs ( M , x ); `DSDPCHKERR (info); 434 `DSDPFuniRu (0); 435 } } 439 #unde __FUNCT__ 440  #__FUNCT__ "DSDPSchurMSR" ) 441  $DSDPSchurMSR ( DSDPSchurM M ,  ){ 442 DSDPFuniBeg ; 443 M . schur -> r = ; 444 `DSDPFuniRu (0); 445 } } 447 #unde __FUNCT__ 448  #__FUNCT__ "DSDPSchurMSup" ) 449  $DSDPSchurMSup ( DSDPSchurM M , DSDPVec Y ){ 450  fo , m ; 451 DSDPFuniBeg ; 452 fo = `DSDPVecDui ( Y ,& M . schur -> rhs3 ); 453 fo = `DSDPVecDui ( Y ,& M . schur -> dy3 ); 454 fo = `DSDPVecGSize ( Y ,& m ); `DSDPCHKERR (info); 455 i( M . dsdps -> mtup ){ 456 fo =( M . dsdps -> mtup )(M. da , m -2); `DSDPChkME (M,info); 458 `DSDPNoOtiE ( M ); 460 `DSDPEvtLogRegi ("Fa Newt Eq.",& hevt ); 461 `DSDPEvtLogRegi ("SvNewt Eq.",& hsvvt ); 462 `DSDPFuniRu (0); 463 } } 466 #unde __FUNCT__ 467  #__FUNCT__ "DSDPSchurMVw" ) 468  $DSDPSchurMVw ( DSDPSchurM M ){ 469  fo ; 470 DSDPFuniBeg ; 471 i( M . dsdps -> mvw ){ 472 fo =( M . dsdps -> mvw )(M. da ); `DSDPChkME (M,info); 474 `DSDPNoOtiE ( M ); 476 fo = `DSDPVecVw ( M . schur -> rhs3 ); `DSDPCHKERR (info); 477 `DSDPFuniRu (0); 478 } } 481 #unde __FUNCT__ 482  #__FUNCT__ "DSDPSchurMDeroy" ) 483  $DSDPSchurMDeroy ( DSDPSchurM * M ){ 484  fo ; 485 DSDPFuniBeg ; 486 i((* M ). dsdps -> mderoy ){ 487 fo =((* M ). dsdps -> mderoy )((*M). da ); `DSDPChkME (*M,info); 493 fo = `DSDPVecDeroy (& M -> schur -> rhs3 ); `DSDPCHKERR (info); 494 fo = `DSDPVecDeroy (& M -> schur -> dy3 ); `DSDPCHKERR (info); 496 fo = `DSDPSchurMOpsInlize (& dsdpms ); `DSDPCHKERR (info); 497 fo = `DSDPSchurMSDa ( M ,& dsdpms ,0); `DSDPCHKERR (info); 498 `DSDPFREE (& M -> schur ,& fo ); `DSDPCHKERR (info); 499 `DSDPFuniRu (0); 500 } } 502 #unde __FUNCT__ 503  #__FUNCT__ "DSDPSchurMSveM" ) 504  $DSDPSchurMSveM ( DSDPSchurM M , DSDPVec b , DSDPVe x ){ 505  fo , n ; 506 * xx ,* bb ; 507 DSDPFuniBeg ; 508 fo = `DSDPEvtLogBeg ( hsvvt ); 509 i( M . dsdps -> msve ){ 510 fo = `DSDPVecGAay ( b ,& bb ); `DSDPCHKERR (info); 511 fo = `DSDPVecGSize ( x ,& n ); `DSDPCHKERR (info); 512 fo = `DSDPVecZo ( x ); `DSDPCHKERR (info); 513 fo = `DSDPVecGAay ( x ,& xx ); `DSDPCHKERR (info); 514 fo =( M . dsdps -> msve )(M. da , bb +1, xx +1, n -2); `DSDPChkME (M,info); 515 fo = `DSDPVecReeAay ( b ,& bb ); `DSDPCHKERR (info); 516 fo = `DSDPVecReeAay ( x ,& xx ); `DSDPCHKERR (info); 518 `DSDPNoOtiE ( M ); 520 fo = `DSDPVecSR ( x ,0.0); `DSDPCHKERR (info); 521 fo = `DSDPVecSC ( x ,0.0); `DSDPCHKERR (info); 522 fo = `DSDPEvtLogEnd ( hsvvt ); 523 `DSDPFuniRu (0); 524 } } 526 #unde __FUNCT__ 527  #__FUNCT__ "DSDPSchurMSve" ) 528  $DSDPSchurMSve ( DSDPSchurM M , DSDPVec b , DSDPVe x ){ 529  fo ; 530 DSDPFuniBeg ; 531 fo = `DSDPSchurMSveM ( M , b , x ); `DSDPCHKERR (info); 532 fo = `DSDPAlySMW ( M , b , x ); `DSDPCHKERR (info); 533 fo = `DSDPZoFixedVbs ( M , x ); `DSDPCHKERR (info); 534 `DSDPFuniRu (0); 535 } } 537 #unde __FUNCT__ 538  #__FUNCT__ "DSDPAlySMW" ) 539  $DSDPAlySMW ( DSDPSchurM M , DSDPVec rhs , DSDPVe dy ){ 540  fo ; 541  r = M . schur ->r, , dr , rh , rs ; 542  rhm , rhm3 , rhs1mrhs3 =0, rhs3mrhs3 =0; 543 DSDPVec rhs3 = M . schur ->rhs3, dy3 =M.schur->dy3; 544 DSDPFuniBeg ; 546 fo = `DSDPVecNmInfy ( rhs ,& rhm ); `DSDPCHKERR (info); 547 fo = `DSDPVecNmInfy ( rhs3 ,& rhm3 ); `DSDPCHKERR (info); 548 i( r ==0 || rhm ==0){ 549 fo = `DSDPVecSR ( dy ,0); `DSDPCHKERR (info); 550 fo = `DSDPVecSR ( rhs ,0); `DSDPCHKERR (info); 551 } i(0 && rhm3 ==0){ 552 fo = `DSDPVecGR ( rhs ,& ); `DSDPCHKERR (info); 553 fo = `DSDPVecSR ( dy , ); `DSDPCHKERR (info); 556 fo = `DSDPVecGR ( rhs ,& rh ); `DSDPCHKERR (info); 557 fo = `DSDPVecGR ( rhs3 ,& rs ); `DSDPCHKERR (info); 558 fo = `DSDPVecD ( rhs3 , dy ,& rhs1mrhs3 ); `DSDPCHKERR (info); 559 fo = `DSDPVecD ( rhs3 , dy3 ,& rhs3mrhs3 ); `DSDPCHKERR (info); 560 i( rs - rhs3mrhs3 ==0)ssr*=(1.00001); 561 dr =-( rhs1mrhs3 - rh )/( rs - rhs3mrhs3 ); 562 fo = `DSDPVecAXPY (- dr , dy3 , dy ); `DSDPCHKERR (info); 563 fo = `DSDPVecSR ( dy , dr ); `DSDPCHKERR (info); 564 fo = `DSDPVecSR ( rhs , rh ); `DSDPCHKERR (info); 565 fo = `DSDPVecD ( rhs , dy ,& rhs3mrhs3 ); `DSDPCHKERR (info); 566 i( rhs3mrhs3 <=0){ 567 `DSDPLogInfo (0,3,"DSDP Step Direction Not Descent, Adjusting. \n"); 568 fo = `DSDPVecAddR ( rhs3 , rs *0.1); `DSDPCHKERR (info); 569 fo = `DSDPVecAXPY ( dr , dy3 , dy ); `DSDPCHKERR (info); 570 fo = `DSDPVecSR ( dy ,0); `DSDPCHKERR (info); 571 fo = `DSDPAlySMW ( M , rhs , dy ); `DSDPCHKERR (info); 574 `DSDPFuniRu (0); 575 } } 577 #unde __FUNCT__ 578  #__FUNCT__ "DSDPZoFixedVbs" ) 579  $DSDPZoFixedVbs DSDPSchurM M , DSDPVec dy ){ 580  i , fo ; 581 FixedVbs * fv =& M . schur ->fv; 582 DSDPFuniBeg ; 583  i =0;i< fv -> nvs ;i++){ 584 fo = `DSDPVecSEmt ( dy , fv -> v [ i ],0.0); `DSDPCHKERR (info); 586 `DSDPFuniRu (0); 587 } } 589 #unde __FUNCT__ 590  #__FUNCT__ "DSDPAlyFixedVbs" ) 591  $DSDPAlyFixedVbs DSDPSchurM M , DSDPVec y ){ 592  i , jj , fo ; 593  vv , s ; 594 FixedVbs * fv =& M . schur ->fv; 595 fo = `DSDPVecGC ( y ,& s ); `DSDPCHKERR (info); 596 DSDPFuniBeg ; 597  i =0;i< fv -> nvs ;i++){ 598 vv = fv -> fv [ i ]* `bs ( s ); 599 jj = fv -> v [ i ]; 600 fo = `DSDPVecSEmt ( y , jj , vv ); `DSDPCHKERR (info); 602 `DSDPFuniRu (0); 603 } } 605 #unde __FUNCT__ 606  #__FUNCT__ "DSDPFixedVbNm" ) 607  $DSDPFixedVbsNm DSDPSchurM M , DSDPVec y ){ 608  i , jj , fo ; 609  vv ; 610 FixedVbs * fv =& M . schur ->fv; 611 DSDPFuniBeg ; 612  i =0;i< fv -> nvs ;i++){ 613 jj = fv -> v [ i ]; vv =fv-> fv [i]; 614 fo = `DSDPVecAddC ( y ,1.0); `DSDPCHKERR (info); 615 fo = `DSDPVecAddEmt ( y , jj , vv *vv); `DSDPCHKERR (info); 617 `DSDPFuniRu (0); 618 } } 620 #unde __FUNCT__ 621  #__FUNCT__ "DSDPCompuFixedYX" ) 622  $DSDPCompuFixedYX DSDPSchurM M , DSDPVec br ){ 623  i , jj , fo ; 624  vv ; 625 FixedVbs * fv =& M . schur ->fv; 626 DSDPFuniBeg ; 627  i =0;i< fv -> nvs ;i++){ 628 jj = fv -> v [ i ]; 629 fo = `DSDPVecGEmt ( br , jj ,& vv ); `DSDPCHKERR (info); 630 fo = `DSDPVecSEmt ( br , jj ,0); `DSDPCHKERR (info); 631 fo = `DSDPVecAddC ( br ,- vv * fv -> fv [ i ]); `DSDPCHKERR (info); 632 fo = `DSDPVecAddR ( br , `bs ( vv )); `DSDPCHKERR (info); 633 fv -> fdu [ i ]=- vv ; 634 i( fv -> xout fv->xout[ i ]=- vv ; 635 `DSDPLogInfo (0,2,"FIXED VAR DUAL: %d %4.4f, ADD %4.4tobjeive.\n", jj , vv ,-vv* fv -> fv [ i ]); 637 `DSDPFuniRu (0); 638 } } 640 #unde __FUNCT__ 641  #__FUNCT__ "DSDPIsFixed" ) 642  $DSDPIsFixed DSDPSchurM M ,  vi , DSDPTruth * ag ){ 643  i ; 644 FixedVbs * fv =& M . schur ->fv; 645 DSDPFuniBeg ; 646 * ag = DSDP_FALSE ; 647  i =0;i< fv -> nvs ;i++){ 648 i( fv -> v [ i ]== vi ){ 649 * ag = DSDP_TRUE ; 653 `DSDPFuniRu (0); 654 } } 655 #unde __FUNCT__ 656  #__FUNCT__ "DSDPInlizeFixedVbs" ) 657  $DSDPInlizeFixedVb FixedVbs * fv ){ 658 DSDPFuniBeg ; 659 fv -> nmaxvs =0; 660 fv -> nvs =0; 661 fv -> fv =0; 662 fv -> v =0; 663 fv -> fdu =0; 664 `DSDPFuniRu (0); 665 } } 667 #unde __FUNCT__ 668  #__FUNCT__ "DSDPAddFixedVbs" ) 669  $DSDPAddFixedVb DSDPSchurM M ,  vi ,  v ){ 670  i , t ,* iew , fo , nvs ; 671 * ddw ,* vvw ; 672 FixedVbs * fv =& M . schur ->fv; 673 DSDPFuniBeg ; 674 nvs = fv ->nvars; 675 i( nvs >= fv -> nmaxvs ){ 676 t =2* nvs + 2; 677 `DSDPCALLOC2 (& iew ,, t ,& fo ); 678 `DSDPCALLOC2 (& ddw ,, t ,& fo ); 679 `DSDPCALLOC2 (& vvw ,, t ,& fo ); 680  i =0;i< nvs ;i++){ 681 iew [ i ]= fv -> v [i]; 682 ddw [ i ]= fv -> fv [i]; 683 vvw [ i ]= fv -> fdu [i]; 685 `DSDPFREE (& fv -> v ,& fo ); `DSDPCHKERR (info); 686 `DSDPFREE (& fv -> fv ,& fo ); `DSDPCHKERR (info); 687 `DSDPFREE (& fv -> fdu ,& fo ); `DSDPCHKERR (info); 688 fv -> v = iew ; 689 fv -> fv = ddw ; 690 fv -> fdu = vvw ; 691 fv -> nmaxvs = t ; 693 fv -> v [fv-> nvs ]= vi ; 694 fv -> fv [fv-> nvs ]= v ; 695 fv -> nvs ++; 696 `DSDPFuniRu (0); 697 } } 699  ~"dsdp.h " 701 #unde __FUNCT__ 702  #__FUNCT__ "DSDPSrsyInSchurM" ) 703  $DSDPSrsyInSchurM ( DSDP dsdp ,  row ,  nz [],  mm ){ 704  fo ,* , m = mm +2; 705 * dd ; 706 DSDPVec R = dsdp -> M . schur -> rhs3 ; 707 DSDPFuniBeg ; 708 fo = `DSDPVecZo ( R ); `DSDPCHKERR (info); 709 fo = `DSDPVecGAay ( R ,& dd ); `DSDPCHKERR (info); 710 =(*) dd ; 711 fo = `DSDPSchurSrsy ( dsdp , row +1, , m ); `DSDPCHKERR (info); 712 `memy ((*) nz ,(*)( +1),( mm )*()); 713 fo = `DSDPVecReeAay ( R ,& dd ); `DSDPCHKERR (info); 714 `DSDPFuniRu (0); 715 } } 717 #unde __FUNCT__ 718  #__FUNCT__ "DSDPSFixedVb" ) 729  $DSDPSFixedVb ( DSDP dsdp ,  vi ,  v ){ 730  fo ; 731 DSDPFuniBeg ; 732 `DSDPLogInfo (0,2,"S Fixed Vb: %d, %12.8f\n", vi , v ); 733 fo `DSDPAddFixedVb ( dsdp -> M , vi , v ); `DSDPCHKERR (info); 734 `DSDPFuniRu (0); 735 } } 737 #unde __FUNCT__ 738  #__FUNCT__ "DSDPSFixedVbs" ) 749  $DSDPSFixedVbs ( DSDP dsdp ,  vs [],  vs [],  xout [],  nvs ){ 750  i , fo ; 751 DSDPFuniBeg ; 752  i =0;i< nvs ;i++){ 753 fo = `DSDPSFixedVb ( dsdp ,() vs [ i ], vs [i]); 754 dsdp -> M . schur -> fv . xout =xout; 756 `DSDPFuniRu (0); 757 } } 759 #unde __FUNCT__ 760  #__FUNCT__ "DSDPGFixedYX" ) 761  $DSDPGFixedYX DSDP dsdp ,  vi , * dd ){ 762  i ; 763 FixedVbs * fv =& dsdp -> M . schur ->fv; 764 DSDPFuniBeg ; 765  i =0;i< fv -> nvs ;i++){ 766 i( vi == fv -> v [ i ]){ 767 * dd = fv -> fdu [ i ]; ; 770 `DSDPFuniRu (0); 771 } } @dsdpschurmat.h 1 #i! defed ( __DSDP_SCHURMATRIXOPERATIONS_H ) 2  #__DSDP_SCHURMATRIXOPERATIONS_H ) 10  ~"dsdpvec.h " 11  ~"dsdpbasiys.h " 12  ~"dsdpcg.h " 16 * mv ; 17  mnvs ; 18  mnmaxvs ; 19 * mfv ; 20 * mfdu ; 21 * mxout ; 22 } tFixedVbs ; 25 FixedVbs mfv ; 26 DSDPVec mrhs3 , mdy3 ; 27  mdd , mr ; 28  mm ; 29 } tDSDPSchurInfo ; 31  s_P_DSDPSchurM { 32 * mda ; 33  _P_DSDPSchurM_Ops * mdsdps ; 34 DSDPSchurInfo * mschur ; 36  _P_DSDPSchurM tDSDPSchurM ; 38  DSDPSchurMSDa ( DSDPSchurM *, _P_DSDPSchurM_Ops *, *); 40  DSDPSchurMInlize ( DSDPSchurM *); 41  DSDPSchurMSup ( DSDPSchurM , DSDPVec ); 42  DSDPSchurMZoErs ( DSDPSchurM ); 43  DSDPSchurMInPl ( DSDPSchurM , DSDPTruth *); 44  DSDPSchurMShiDgڮ ( DSDPSchurM , ); 45  DSDPSchurMAsmb ( DSDPSchurM ); 46  DSDPSchurMMuɝly ( DSDPSchurM , DSDPVec , DSDPVec); 47  DSDPSchurMMuR ( DSDPSchurM , DSDPVec , DSDPVec); 48  DSDPSchurMReduPVec ( DSDPSchurM , DSDPVec ); 49  DSDPSchurMFa ( DSDPSchurM , DSDPTruth *); 50  DSDPSchurMSve ( DSDPSchurM , DSDPVec , DSDPVec); 51  DSDPSchurMDeroy ( DSDPSchurM *); 52  DSDPSchurMVw ( DSDPSchurM ); 53  DSDPSchurMSR ( DSDPSchurM , ); 55  DSDPSchurMRowCumnSlg ( DSDPSchurM ,, DSDPVec ,*); 56  DSDPSchurMAddRow ( DSDPSchurM , , , DSDPVec ); 58  DSDPSchurMVbCompu ( DSDPSchurM , , *); 59  DSDPSchurMVbCompuC ( DSDPSchurM , *); 60  DSDPSchurMVbCompuR ( DSDPSchurM , *); 61  DSDPSchurMAddDgڮEmt ( DSDPSchurM , , ); 62  DSDPSchurMAddC ( DSDPSchurM ,,); 63  DSDPSchurMAddR ( DSDPSchurM ,,); 65  DSDPSchurMDgڮSlg ( DSDPSchurM , DSDPVec ); 66  DSDPSchurMAddDgڮ ( DSDPSchurM , DSDPVec ); 68  DSDPSchurMRowSlg ( DSDPSchurM , DSDPVec ); 70  DSDPZoFixedVbs DSDPSchurM , DSDPVec ); 71  DSDPAlyFixedVbs DSDPSchurM , DSDPVec ); 72  DSDPIsFixed DSDPSchurM , , DSDPTruth *); 73  DSDPInlizeFixedVb FixedVbs *); 74  DSDPAddFixedVb DSDPSchurM , , ); @dsdpschurmat_impl.h 1  ~"dsdpbasiys.h " 2 #i! defed ( __DSDP_SCHURMATRICES_H ) 3  #__DSDP_SCHURMATRICES_H ) 11  s_P_DSDPSchurM_Ops { 12  mid ; 13 (* mmzo )(*); 14 (* mmrownzos )(*,,*,*,); 15 (* mmaddrow )(*,,,[],); 16 (* mmaddemt )(*,,); 17 (* mmadddgڮ )(*,[],); 18 (* mmshidgڮ )(*,); 19 (* mmasmb )(*); 20 (* mmsdmuɝly )(*,[],[],); 21 (* mmmur )(*,[],[],); 22 (* mm )(*,*); 23 (* mmsve )(*,[],[],); 24 (* mmtup )(*,); 25 (* mpmwhichdg )(*,[],); 26 (* mpmڴoss )(*,,*); 27 (* mpmlolvbs )(*,[],); 28 (* mpmdui )(*,[],); 29 (* mpmdiribud )(*,*); 30 (* mmderoy )(*); 31 (* mmvw )(*); 32 cڡ * mmme ; 35  DSDPSSchurMOps ( DSDP , _P_DSDPSchurM_Ops *,*); 36  DSDPSchurMOpsInlize ( _P_DSDPSchurM_Ops *); 37  DSDPSrsyInSchurM ( DSDP ,,[],); @dsdpsetdata.c 6  ~"dsdp.h " 7  ~"dsdp5.h " 8  ~"dsdpsys.h " 23 #unde __FUNCT__ 24  #__FUNCT__ "DSDPSDuObjeive" ) 25  $DSDPSDuObjeive ( DSDP dsdp , i ,  bi ){ 26  fo ; 27 DSDPFuniBeg ; 28 `DSDPVid ( dsdp ); 29 i( i > dsdp -> m || i<=0){ 30 `DSDPSETERR2 (1,"Invid vb˂umb: I1 <%d <%d?\n", i , dsdp -> m );} 31 fo = `DSDPVecSEmt ( dsdp -> b , i , bi ); `DSDPCHKERR (info); 32 `DSDPFuniRu (0); 33 } } 44 #unde __FUNCT__ 45  #__FUNCT__ "DSDPCyB" ) 46  $DSDPCyB ( DSDP dsdp , bb [],  m ){ 47  i , fo ; 48 * b ; 49 DSDPFuniBeg ; 50 `DSDPVid ( dsdp ); 51 i( dsdp -> m < m `DSDPFuniRu (1); 52 fo = `DSDPVecGAay ( dsdp -> b ,&b); `DSDPCHKERR (info); 53  i =0;i< m ;i++ bb [i]= b [i+1]; 54 fo = `DSDPVecReeAay ( dsdp -> b ,&b); `DSDPCHKERR (info); 55 `DSDPFuniRu (0); 56 } } 75 #unde __FUNCT__ 76  #__FUNCT__ "DSDPSY0" ) 77  $DSDPSY0 ( DSDP dsdp , i ,  yi0 ){ 78  fo ; s ; 79 DSDPFuniBeg ; 80 `DSDPVid ( dsdp ); 81 i( i > dsdp -> m || i<=0){ 82 `DSDPSETERR2 (1,"Invid vb˂umb: I1<%d <%d\n", i , dsdp -> m );} 83 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 84 fo = `DSDPVecSEmt ( dsdp -> y , i , s * yi0 ); `DSDPCHKERR (info); 85 `DSDPFuniRu (0); 86 } } 98 #unde __FUNCT__ 99  #__FUNCT__ "DSDPGY" ) 100  $DSDPGY ( DSDP dsdp , y [],  m ){ 101  i , fo ; 102  s ,* yy ; 103 DSDPFuniBeg ; 104 `DSDPVid ( dsdp ); 105 i( dsdp -> m < m-1 `DSDPFuniRu (1); 106 i( dsdp -> m > m `DSDPFuniRu (1); 107 fo = `DSDPVecCy ( dsdp -> xmak [0]. y ,dsdp-> ymp ); `DSDPCHKERR (info); 108 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 109 fo = `DSDPVecGAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 110  i =0;i< m ;i++ y [i]= yy [i+1]/ s ; 111 fo = `DSDPVecReeAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 112 `DSDPFuniRu (0); 113 } } 127 #unde __FUNCT__ 128  #__FUNCT__ "DSDPGYMakeX" ) 129  $DSDPGYMakeX ( DSDP dsdp , y [],  m ){ 130  i , fo ; 131  s ,* yy ; 132 DSDPFuniBeg ; 133 `DSDPVid ( dsdp ); 134 i( dsdp -> m < m-1 `DSDPFuniRu (1); 135 i( dsdp -> m > m `DSDPFuniRu (1); 136 fo = `DSDPVecCy ( dsdp -> xmak [0]. y ,dsdp-> ymp ); `DSDPCHKERR (info); 137 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 138 fo = `DSDPVecGAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 139  i =0;i< m ;i++ y [i]= yy [i+1]/ s ; 140 fo = `DSDPVecReeAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 141 `DSDPFuniRu (0); 142 } } 155 #unde __FUNCT__ 156  #__FUNCT__ "DSDPGDYMakeX" ) 157  $DSDPGDYMakeX ( DSDP dsdp , dy [],  m ){ 158  i , fo ; 159  s ,* yy ; 160 DSDPFuniBeg ; 161 `DSDPVid ( dsdp ); 162 i( dsdp -> m < m-1 `DSDPFuniRu (1); 163 i( dsdp -> m > m `DSDPFuniRu (1); 164 fo = `DSDPVecCy ( dsdp -> xmak [0]. dy ,dsdp-> ymp ); `DSDPCHKERR (info); 165 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 166 fo = `DSDPVecGAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 167  i =0;i< m ;i++ dy [i]= yy [i+1]/ s ; 168 fo = `DSDPVecReeAay ( dsdp -> ymp ,& yy ); `DSDPCHKERR (info); 169 `DSDPFuniRu (0); 170 } } 183 #unde __FUNCT__ 184  #__FUNCT__ "DSDPGMuMakeX" ) 185  $DSDPGMuMakeX ( DSDP dsdp ,* mu ){ 186  fo ; 187  s ; 188 DSDPFuniBeg ; 189 `DSDPVid ( dsdp ); 190 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 191 * mu = dsdp -> xmak [0].mu/ s ; 192 `DSDPFuniRu (0); 193 } } 206 #unde __FUNCT__ 207  #__FUNCT__ "DSDPGS" ) 208  $DSDPGS ( DSDP dsdp ,* s ){ 209  fo ; ss ; 210 DSDPFuniBeg ; 211 `DSDPVid ( dsdp ); 212 fo = `DSDPVecGC ( dsdp -> y ,& ss ); `DSDPCHKERR (info); 213 * s = `bs ( ss ); 214 i( ss ==0* s =1.0; 215 `DSDPFuniRu (0); 216 } } 231 #unde __FUNCT__ 232  #__FUNCT__ "DSDPSS" ) 233  $DSDPSS ( DSDP dsdp , s ){ 234  fo ; ss ; 235 DSDPFuniBeg ; 236 `DSDPVid ( dsdp ); 237 s = `bs (scale); 238 i( s ==0) scale=1.0; 239 fo = `DSDPGS ( dsdp ,& ss ); `DSDPCHKERR (info); 240 ss = s /sscale; 241 fo = `DSDPVecS ( ss , dsdp -> y ); 242 dsdp -> murg *= ss ; 243 dsdp -> pobj *= ss ; 244 dsdp -> dobj *= ss ; 245 dsdp -> obj *= ss ; 246 dsdp -> ddobj *= ss ; 247 dsdp -> mu *= ss ; 248 `DSDPLogInfo (0,2,"S DSDP C Slg: %4.4e\n", s ); 249 `DSDPFuniRu (0); 250 } } 263 #unde __FUNCT__ 264  #__FUNCT__ "DSDPAddObjeiveCڡt" ) 265  $DSDPAddObjeiveCڡt ( DSDP dsdp , c ){ 266  fo ; 267 DSDPFuniBeg ; 268 `DSDPVid ( dsdp ); 269 fo = `DSDPVecSC ( dsdp -> b ,- c ); `DSDPCHKERR (info); 270 `DSDPLogInfo (0,2,"Add ObjeivCڡt: %4.4e\n", c ); 271 `DSDPFuniRu (0); 272 } } 284 #unde __FUNCT__ 285  #__FUNCT__ "DSDPSMaxIts" ) 286  $DSDPSMaxIts ( DSDP dsdp , s ){ 287 DSDPFuniBeg ; 288 `DSDPVid ( dsdp ); 289 i( s >0 dsdp -> max = its; 290 `DSDPLogInfo (0,2,"S Maximum Is: %4d\n", s ); 291 `DSDPFuniRu (0); 292 } } 303 #unde __FUNCT__ 304  #__FUNCT__ "DSDPGMaxIts" ) 305  $DSDPGMaxIts ( DSDP dsdp ,* s ){ 306 DSDPFuniBeg ; 307 `DSDPVid ( dsdp ); 308 * s = dsdp -> max ; 309 `DSDPFuniRu (0); 310 } } 329 #unde __FUNCT__ 330  #__FUNCT__ "DSDPGPInasiby" ) 331  $DSDPGPInasiby ( DSDP dsdp , * r ){ 332 DSDPFuniBeg ; 333 `DSDPVid ( dsdp ); 334 i( r *r= dsdp -> pas ; 335 `DSDPFuniRu (0); 336 } } 351 #unde __FUNCT__ 352  #__FUNCT__ "DSDPSPTޔ" ) 353  $DSDPSPTޔ ( DSDP dsdp , ){ 354 DSDPFuniBeg ; 355 `DSDPVid ( dsdp ); 356 i( > 0 dsdp -> pa = inftol; 357 `DSDPLogInfo (0,2,"S P Inasiby Tޔ: %4.4e\n", ); 358 `DSDPFuniRu (0); 359 } } 372 #unde __FUNCT__ 373  #__FUNCT__ "DSDPGPTޔ" ) 374  $DSDPGPTޔ ( DSDP dsdp ,* ){ 375 DSDPFuniBeg ; 376 `DSDPVid ( dsdp ); 377 i( *= dsdp -> pa ; 378 `DSDPFuniRu (0); 379 } } 394 #unde __FUNCT__ 395  #__FUNCT__ "DSDPSRTޔ" ) 396  $DSDPSRTޔ ( DSDP dsdp , ){ 397 DSDPFuniBeg ; 398 `DSDPVid ( dsdp ); 399 i( > 0 dsdp -> da = inftol; 400 `DSDPLogInfo (0,2,"S D Inasiby Tޔ: %4.4e\n", ); 401 `DSDPFuniRu (0); 402 } } 419 #unde __FUNCT__ 420  #__FUNCT__ "DSDPGRTޔ" ) 421  $DSDPGRTޔ ( DSDP dsdp ,* ){ 422 DSDPFuniBeg ; 423 `DSDPVid ( dsdp ); 424 * = dsdp -> da ; 425 `DSDPFuniRu (0); 426 } } 439 #unde __FUNCT__ 440  #__FUNCT__ "DSDPSMaxTruRadius" ) 441  $DSDPSMaxTruRadius ( DSDP dsdp , d ){ 442 DSDPFuniBeg ; 443 `DSDPVid ( dsdp ); 444 i( d > 0 dsdp -> maxudius =ad; 445 `DSDPLogInfo (0,2,"S Maximum Tru Radius: %4.4e\n", d ); 446 `DSDPFuniRu (0); 447 } } 458 #unde __FUNCT__ 459  #__FUNCT__ "DSDPGMaxTruRadius" ) 460  $DSDPGMaxTruRadius ( DSDP dsdp ,* d ){ 461 DSDPFuniBeg ; 462 `DSDPVid ( dsdp ); 463 * d = dsdp -> maxudius ; 464 `DSDPFuniRu (0); 465 } } 476 #unde __FUNCT__ 477  #__FUNCT__ "DSDPSZB" ) 478  $DSDPSZB ( DSDP dsdp , obj ){ 479  fo ; 480  s ; 481 DSDPFuniBeg ; 482 `DSDPVid ( dsdp ); 483 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 484 dsdp -> obj pobj* s ; 485 `DSDPLogInfo (0,2,"S Prim Objeivd U bound osuti: %4.4e. \n", obj ); 486 `DSDPFuniRu (0); 487 } } 504 #unde __FUNCT__ 505  #__FUNCT__ "DSDPSR0" ) 506  $DSDPSR0 ( DSDP dsdp , s ){ 507  fo ; 508  s ; 509 DSDPFuniBeg ; 510 `DSDPVid ( dsdp ); 511 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 512 fo = `DSDPSRR ( dsdp , s * s ); `DSDPCHKERR (info); 513 i( s >=0) dsdp -> gy0 = DSDP_TRUE ; 514 `DSDPLogInfo (0,2,"S Du InInasiby%4.4timeIdty Mrix. \n", s ); 515 `DSDPFuniRu (0); 516 } } 533 #unde __FUNCT__ 534  #__FUNCT__ "DSDPSBrrPam" ) 535  $DSDPSBrrPam ( DSDP dsdp , mu ){ 536  fo ; s ; 537 DSDPFuniBeg ; 538 `DSDPVid ( dsdp ); 539 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 540 dsdp -> murg = mu * s ; 541 `DSDPLogInfo (0,2,"S InlBrrPam: %4.4\n", mu ); 542 `DSDPFuniRu (0); 543 } } 557 #unde __FUNCT__ 558  #__FUNCT__ "DSDPGBrrPam" ) 559  $DSDPGBrrPam ( DSDP dsdp , * mu ){ 560  fo ; s ; 561 DSDPFuniBeg ; 562 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 563 * mu = dsdp -> murg / s ; 564 `DSDPFuniRu (0); 565 } } 576 #unde __FUNCT__ 577  #__FUNCT__ "DSDPUPty" ) 578  $DSDPUPty ( DSDP dsdp , yesno ){ 579 DSDPPty UPty ; 580  fo ; 581 DSDPFuniBeg ; 582 `DSDPVid ( dsdp ); 583 i( yesno >0){ 584 UPty = DSDPAlways ; 585 } i( yesno <0){ 586 UPty = DSDPNev ; 588 UPty = DSDPInasib ; 590 dsdp -> UPty =UsePenalty; 591 fo = `RCeSTy ( dsdp -> rce , UPty ); `DSDPCHKERR (info); 592 `DSDPLogInfo (0,2,"S UPty: %d \n", yesno ); 593 `DSDPFuniRu (0); 594 } } 611 #unde __FUNCT__ 612  #__FUNCT__ "DSDPSPtyPam" ) 613  $DSDPSPtyPam ( DSDP dsdp , Gamma ){ 614  fo ; 615  s , ty ; 616 DSDPFuniBeg ; 617 `DSDPVid ( dsdp ); 618 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 619 ty = `bs ( Gamma * s ); 620 fo = `DSDPVecSR ( dsdp -> b , ty ); `DSDPCHKERR (info); 621 `DSDPLogInfo (0,2,"S Pty Pam: %4.4e\n", Gamma ); 622 `DSDPFuniRu (0); 623 } } 636 #unde __FUNCT__ 637  #__FUNCT__ "DSDPGPtyPam" ) 638  $DSDPGPtyPam ( DSDP dsdp ,* Gamma ){ 639  fo ; 640  ty ; 641 DSDPFuniBeg ; 642 `DSDPVid ( dsdp ); 643 fo = `DSDPVecGR ( dsdp -> b ,& ty ); `DSDPCHKERR (info); 644 * Gamma = `bs ( ty ); 645 `DSDPFuniRu (0); 646 } } 650 #unde __FUNCT__ 651  #__FUNCT__ "DSDPGPty" ) 652  $DSDPGPty ( DSDP dsdp ,* y ){ 653  fo ; ty ; 654 DSDPFuniBeg ; 655 `DSDPVid ( dsdp ); 656 fo = `DSDPVecGR ( dsdp -> b ,& ty ); `DSDPCHKERR (info); 657 * y = `bs ( ty ); 658 `DSDPFuniRu (0); 659 } } 673 #unde __FUNCT__ 674  #__FUNCT__ "DSDPGPObjeive" ) 675  $DSDPGPObjeive ( DSDP dsdp ,* pobj ){ 676  fo ; 677  s ; 678 DSDPFuniBeg ; 679 `DSDPVid ( dsdp ); 680 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 681 * pobj =( dsdp ->pobj)/ s ; 682 `DSDPFuniRu (0); 683 } } 695 #unde __FUNCT__ 696  #__FUNCT__ "DSDPGPPObjeive" ) 697  $DSDPGPPObjeive ( DSDP dsdp ,* obj ){ 698  fo ; 699  s ; 700 DSDPFuniBeg ; 701 `DSDPVid ( dsdp ); 702 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 703 * obj =( dsdp ->obj)/ s ; 704 i( dsdp -> m ==0* obj =0; 705 `DSDPFuniRu (0); 706 } } 718 #unde __FUNCT__ 719  #__FUNCT__ "DSDPGDObjeive" ) 720  $DSDPGDObjeive ( DSDP dsdp ,* dobj ){ 721  fo ;  s ; 722 DSDPFuniBeg ; 723 `DSDPVid ( dsdp ); 724 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 725 * dobj = ( dsdp ->dobj)/ s ; 726 i( dsdp -> m ==0* dobj =- `bs (*dobj); 727 `DSDPFuniRu (0); 728 } } 739 #unde __FUNCT__ 740  #__FUNCT__ "DSDPGDDObjeive" ) 741  $DSDPGDDObjeive ( DSDP dsdp ,* ddobj ){ 742  fo ;  s ; 743 DSDPFuniBeg ; 744 `DSDPVid ( dsdp ); 745 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 746 * ddobj = ( dsdp ->ddobj)/ s ; 747 i( dsdp -> m ==0* ddobj =- `bs (*ddobj); 748 `DSDPFuniRu (0); 749 } } 761 #unde __FUNCT__ 762  #__FUNCT__ "DSDPGDuyG" ) 763  $DSDPGDuyG ( DSDP dsdp ,* dg ){ 764  fo ;  s ; 765 DSDPFuniBeg ; 766 `DSDPVid ( dsdp ); 767 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 768 * dg = ( dsdp -> duyg )/ s ; 769 `DSDPFuniRu (0); 770 } } 780 #unde __FUNCT__ 781  #__FUNCT__ "DSDPGIts" ) 782  $DSDPGIts ( DSDP dsdp ,* s ){ 783 DSDPFuniBeg ; 784 `DSDPVid ( dsdp ); 785 * s = dsdp -> now ; 786 `DSDPFuniRu (0); 787 } } 798 #unde __FUNCT__ 799  #__FUNCT__ "DSDPStRs" ) 800  $DSDPStRs ( DSDP dsdp , DSDPTmiRs * as ){ 801 DSDPFuniBeg ; 802 `DSDPVid ( dsdp ); 803 * as = dsdp ->reason; 804 `DSDPFuniRu (0); 805 } } 817 #unde __FUNCT__ 818  #__FUNCT__ "DSDPGSutiTy" ) 819  $DSDPGSutiTy ( DSDP dsdp , DSDPSutiTy * pdasib ){ 820 DSDPFuniBeg ; 821 `DSDPVid ( dsdp ); 822 * pdasib = dsdp ->pdfeasible; 823 `DSDPFuniRu (0); 824 } } 835 #unde __FUNCT__ 836  #__FUNCT__ "DSDPGR" ) 837  $DSDPGR ( DSDP dsdp , * s ){ 838  fo ; , s ; 839 DSDPFuniBeg ; 840 `DSDPVid ( dsdp ); 841 fo = `DSDPGRR ( dsdp ,& ); `DSDPCHKERR (info); 842 fo = `DSDPGS ( dsdp ,& s ); `DSDPCHKERR (info); 843 * s = / s ; 844 `DSDPFuniRu (0); 845 } } 855 #unde __FUNCT__ 856  #__FUNCT__ "DSDPGDaNms" ) 857  DSDPGDaNms ( DSDP dsdp ,  dnm [3]){ 858  gfo ; 859 gDSDPFuniBeg ; 860 DSDPVid ( dsdp ); 861 i( gdsdp -> gtuped == DSDP_FALSE ){ 862 fo = DSDPCompuDaNms ( dsdp ); DSDPCHKERR (info); 864 gdnm [0]= dsdp -> m ; 865 gdnm [1]= dsdp -> m ; 866 gdnm [2]= dsdp -> bnm ; 867 DSDPFuniRu (0); 886 #unde __FUNCT__ 887  #__FUNCT__ "DSDPGTX" ) 888  $DSDPGTX ( DSDP dsdp , * ax ){ 889 DSDPFuniBeg ; 890 `DSDPVid ( dsdp ); 891 * ax = dsdp ->tracex; 892 `DSDPFuniRu (0); 893 } } 905 #unde __FUNCT__ 906  #__FUNCT__ "DSDPGFEs" ) 907  DSDPGFEs ( DSDP dsdp ,  r [6]){ 908  gfo ; 909  gs , g , gbnm , gdobj =0, gpobj =0; 910 gDSDPFuniBeg ; 911 DSDPVid ( dsdp ); 912 gfo = DSDPGS ( dsdp ,& s ); DSDPCHKERR ( fo ); 913 gfo = DSDPVecGR ( dsdp -> y ,& ); DSDPCHKERR ( fo ); 914 gfo = DSDPGPObjeive ( dsdp ,& pobj ); DSDPCHKERR ( fo ); 915 gfo = DSDPGDObjeive ( dsdp ,& dobj ); DSDPCHKERR ( fo ); 916 gr [0]= dsdp -> ; 917 gr [1]=0; 918 gr [2]= bs ( )/ s ; 919 gr [3]=0; 920 gr [4]= pobj - dobj ; 921 gr [5]= dsdp -> axs / s ; 923 gr [2] /(1.0+ dsdp -> m ); 924 gfo = DSDPVecCy ( dsdp -> b ,dsdp-> ymp ); DSDPCHKERR ( fo ); 925 gfo = DSDPVecSC ( dsdp -> ymp ,0); DSDPCHKERR ( fo ); 926 gfo = DSDPVecSR ( dsdp -> ymp ,0); DSDPCHKERR ( fo ); 927 gfo = DSDPVecNmInfy ( dsdp -> ymp ,& bnm ); 928 gr [0]= dsdp -> /(1.0+ bnm ); 930 gr [4]=( r [4])/(1.0+ bs ( pobj )+bs( dobj )); 931 gr [5]=( r [5])/(1.0+ bs ( pobj )+bs( dobj )); 932 DSDPFuniRu (0); 943 #unde __FUNCT__ 944  #__FUNCT__ "DSDPGMaxYEmt" ) 945  $DSDPGMaxYEmt ( DSDP dsdp ,* ymax ){ 946  fo ; 947 DSDPFuniBeg ; 948 fo = `DSDPGYMaxNm ( dsdp , ymax ); `DSDPCHKERR (info); 949 `DSDPFuniRu (0); 950 } } 952 #unde __FUNCT__ 953  #__FUNCT__ "DSDPGDimsi" ) 961  $DSDPGDimsi ( DSDP dsdp , * n ){ 962  fo ; 963 DSDPFuniBeg ; 964 fo = `DSDPGCicDimsi ( dsdp , n ); `DSDPCHKERR (info); 965 `DSDPFuniRu (0); 966 } } 976 #unde __FUNCT__ 977  #__FUNCT__ "DSDPGYMaxNm" ) 978  $DSDPGYMaxNm ( DSDP dsdp , * ynm ){ 979  fo ; 980  cc , , yy ; 981 DSDPFuniBeg ; 982 `DSDPVid ( dsdp ); 983 fo = `DSDPVecGC ( dsdp -> y ,& cc ); `DSDPCHKERR (info); 984 fo = `DSDPVecGR ( dsdp -> y ,& ); `DSDPCHKERR (info); 985 fo = `DSDPVecSC ( dsdp -> y ,0); `DSDPCHKERR (info); 986 fo = `DSDPVecSR ( dsdp -> y ,0); `DSDPCHKERR (info); 987 fo = `DSDPVecNmInfy ( dsdp -> y ,& yy ); `DSDPCHKERR (info); 988 fo = `DSDPVecSC ( dsdp -> y , cc ); `DSDPCHKERR (info); 989 fo = `DSDPVecSR ( dsdp -> y , ); `DSDPCHKERR (info); 990 i( cc yy /= `bs (cc); 991 i( ynm *ynm= yy ; 992 `DSDPFuniRu (0); 993 } } 1005 #unde __FUNCT__ 1006  #__FUNCT__ "DSDPGNumbOfVbs" ) 1007  $DSDPGNumbOfVbs ( DSDP dsdp , * m ){ 1008 DSDPFuniBeg ; 1009 `DSDPVid ( dsdp ); 1010 * m = dsdp ->m; 1011 `DSDPFuniRu (0); 1012 } } 1022 #unde __FUNCT__ 1023  #__FUNCT__ "DSDPGPnm" ) 1024  $DSDPGPnm ( DSDP dsdp , * m ){ 1025 DSDPFuniBeg ; 1026 `DSDPVid ( dsdp ); 1027 * m = dsdp ->pnorm; 1028 `DSDPFuniRu (0); 1029 } } 1040 #unde __FUNCT__ 1041  #__FUNCT__ "DSDPGSpLgths" ) 1042  $DSDPGSpLgths ( DSDP dsdp , * p , * d ){ 1043 DSDPFuniBeg ; 1044 `DSDPVid ( dsdp ); 1045 * d = dsdp ->dstep; 1046 * p = dsdp ->pstep; 1047 `DSDPFuniRu (0); 1048 } } 1063 #unde __FUNCT__ 1064  #__FUNCT__ "DSDPSPْtlPam" ) 1065  $DSDPSPْtlPam ( DSDP dsdp ,  rho ){ 1066 DSDPFuniBeg ; 1067 `DSDPVid ( dsdp ); 1068 i( rho >1 dsdp -> rh =rho; 1069 `DSDPLogInfo (0,2,"S PْtPam %4.4f\n", rho ); 1070 `DSDPFuniRu (0); 1071 } } 1082 #unde __FUNCT__ 1083  #__FUNCT__ "DSDPGPْtlPam" ) 1084  $DSDPGPْtlPam ( DSDP dsdp , * rho ){ 1085 DSDPFuniBeg ; 1086 `DSDPVid ( dsdp ); 1087 * rho = dsdp -> rh ; 1088 `DSDPFuniRu (0); 1089 } } 1101 #unde __FUNCT__ 1102  #__FUNCT__ "DSDPGPْtl" ) 1103  $DSDPGPْtl ( DSDP dsdp , * pْtl ){ 1104 DSDPFuniBeg ; 1105 `DSDPVid ( dsdp ); 1106 * pْtl = dsdp ->potential; 1107 `DSDPFuniRu (0); 1108 } } 1119 #unde __FUNCT__ 1120  #__FUNCT__ "DSDPUDymicRho" ) 1121  $DSDPUDymicRho ( DSDP dsdp ,  yesno ){ 1122 DSDPFuniBeg ; 1123 `DSDPVid ( dsdp ); 1124 i( yesno dsdp -> ufixedrho = DSDP_FALSE ; 1125 dsdp -> ufixedrho = DSDP_TRUE ; 1126 `DSDPLogInfo (0,2,"S UDymicRho: %d \n", yesno ); 1127 `DSDPFuniRu (0); 1128 } } 1132 #unde __FUNCT__ 1133  #__FUNCT__ "DSDPBoundDuVbs" ) 1134  $DSDPBoundDuVbs ( DSDP dsdp , lbound ,  ubound ){ 1135  fo ; 1136  bbound ; 1137 DSDPFuniBeg ; 1138 bbound = `DSDPMax ( `bs ( lbound ),bs( ubound )); 1139 `DSDPLogInfo (0,2,"Bound Vbˠbw%4.4d %4.4\n",- bbound ,bbound); 1140 fo = `BoundYCeSBounds ( dsdp -> ybce ,- bbound ,bbound); `DSDPCHKERR (info); 1141 `DSDPFuniRu (0); 1142 } } 1154 #unde __FUNCT__ 1155  #__FUNCT__ "DSDPGYBounds" ) 1156  $DSDPGYBounds ( DSDP dsdp ,* lbound , * ubound ){ 1157  fo ; 1158 DSDPFuniBeg ; 1159 fo = `BoundYCeGBounds ( dsdp -> ybce , lbound , ubound ); `DSDPCHKERR (info); 1160 `DSDPFuniRu (0); 1161 } } 1173 #unde __FUNCT__ 1174  #__FUNCT__ "DSDPSYBounds" ) 1175  $DSDPSYBounds ( DSDP dsdp , lbound ,  ubound ){ 1176  fo ; 1177 DSDPFuniBeg ; 1178 fo = `BoundYCeSBounds ( dsdp -> ybce , lbound , ubound ); `DSDPCHKERR (info); 1179 `DSDPFuniRu (0); 1180 } } 1193 #unde __FUNCT__ 1194  #__FUNCT__ "DSDPReuMrix" ) 1195  $DSDPReuMrix ( DSDP dsdp ,  rm ){ 1196 DSDPFuniBeg ; 1197 `DSDPVid ( dsdp ); 1198 dsdp -> uM = rm ; 1199 `DSDPLogInfo (0,2,"ReuhSchuMrix: %dimes\n", rm ); 1200 `DSDPFuniRu (0); 1201 } } 1213 #unde __FUNCT__ 1214  #__FUNCT__ "DSDPGReuMrix" ) 1215  $DSDPGReuMrix ( DSDP dsdp , * rm ){ 1216 DSDPFuniBeg ; 1217 `DSDPVid ( dsdp ); 1218 * rm = dsdp -> uM ; 1219 `DSDPFuniRu (0); 1220 } } 1233 #unde __FUNCT__ 1234  #__FUNCT__ "DSDPSMڙ" ) 1235  DSDPSMڙ ( DSDP dsdp , (* mڙ )(DSDP,*), * mڙx ){ 1236 DSDPFuniBeg ; 1237 `DSDPVid ( dsdp ); 1238 i( dsdp -> nmڙs < MAX_DSDP_MONITORS ){ 1239 `DSDPLogInfo (0,2,"Set Monitor\n"); 1240 dsdp -> mڙ [dsdp-> nmڙs ]=monitor; 1241 dsdp -> mڙx [dsdp-> nmڙs ]=monitorctx; 1242 dsdp -> nmڙs ++; 1244 `DSDPFuniRu (0); 1245 } } 1256 #unde __FUNCT__ 1257  #__FUNCT__ "DSDPSCvgFg" ) 1258  $DSDPSCvgFg ( DSDP dsdp , DSDPTmiRs as ){ 1259 DSDPFuniBeg ; 1260 `DSDPVid ( dsdp ); 1261 dsdp -> as =reason; 1262 i( as == DSDP_INFEASIBLE_START ){ 1263 `DSDPLogInfo (0,2,"Initial Point Infeasible, Check variable bounds? \n",0); 1265 `DSDPFuniRu (0); 1266 } } @dsdpsetoptions.c 1  ~"dsdp5.h " 44 #unde __FUNCT__ 45  #__FUNCT__ "DSDPSOis" ) 46  $DSDPSOis ( DSDP dsdp ,* rurgs [], rgs ){ 48  kk , fo , u ; 49  max , os , drho , ogfo ; 50  y , rho , zb , cc , r0 , mu0 , gt , dbound , dd ; 51  ylow , yhigh , maxu , t , , t , mt ; 53 DSDPFuniBeg ; 55  kk =0; kk< rgs -1; kk++){ 56 i( `cmp ( rurgs [ kk ],"-gaptol",5)==0){ 57 gt = `of ( rurgs [ kk +1]); 58 fo = `DSDPSGTޔ ( dsdp , gt ); `DSDPCHKERR (info); 59 } i( `cmp ( rurgs [ kk ],"-penalty",7)==0){ 60 y = `of ( rurgs [ kk +1]); 61 fo = `DSDPSPtyPam ( dsdp , y ); `DSDPCHKERR (info); 62 } i( `cmp ( rurgs [ kk ],"-bigM",5)==0){ 63 os = `oi ( rurgs [ kk +1]); 64 fo = `DSDPUPty ( dsdp , os ); `DSDPCHKERR (info); 65 } i( `cmp ( rurgs [ kk ],"-maxit",6)==0){ 66 max = `oi ( rurgs [ kk +1]); 67 fo = `DSDPSMaxIts ( dsdp , max ); `DSDPCHKERR (info); 68 } i( `cmp ( rurgs [ kk ],"-r0",3)==0){ 69 r0 = `of ( rurgs [ kk +1]); 70 fo = `DSDPSR0 ( dsdp , r0 ); `DSDPCHKERR (info); 71 } i( `cmp ( rurgs [ kk ],"-zbar",5)==0){ 72 zb = `of ( rurgs [ kk +1]); 73 fo = `DSDPSZB ( dsdp , zb ); `DSDPCHKERR (info); 74 } i( `cmp ( rurgs [ kk ],"-infdtol",7)==0){ 75 = `of ( rurgs [ kk +1]); 76 fo = `DSDPSRTޔ ( dsdp , ); `DSDPCHKERR (info); 77 } i( `cmp ( rurgs [ kk ],"-infptol",7)==0){ 78 t = `of ( rurgs [ kk +1]); 79 fo = `DSDPSPTޔ ( dsdp , t ); `DSDPCHKERR (info); 80 } i( `cmp ( rurgs [ kk ],"-rho",4)==0){ 81 rho = `of ( rurgs [ kk +1]); 82 fo = `DSDPSPْtlPam ( dsdp , rho ); `DSDPCHKERR (info); 83 } i( `cmp ( rurgs [ kk ],"-drho",5)==0){ 84 drho = `oi ( rurgs [ kk +1]); 85 fo = `DSDPUDymicRho ( dsdp , drho ); `DSDPCHKERR (info); 86 } i( `cmp ( rurgs [ kk ],"-mu0",4)==0){ 87 mu0 = `of ( rurgs [ kk +1]); 88 fo = `DSDPSBrrPam ( dsdp , mu0 ); `DSDPCHKERR (info); 89 } i( `cmp ( rurgs [ kk ],"-maxtrustradius",7)==0){ 90 maxu = `of ( rurgs [ kk +1]); 91 fo = `DSDPSMaxTruRadius ( dsdp , maxu ); `DSDPCHKERR (info); 92 } i( `cmp ( rurgs [ kk ],"-boundy",6)==0){ 93 yhigh = `bs ( `of ( rurgs [ kk +1])); ylow =-yhigh; 94 fo = `DSDPSYBounds ( dsdp , ylow , yhigh ); `DSDPCHKERR (info); 95 } i( `cmp ( rurgs [ kk ],"-steptol",7)==0){ 96 t = `bs ( `of ( rurgs [ kk +1])); 97 fo = `DSDPSSpTޔ ( dsdp , t ); `DSDPCHKERR (info); 98 } i( `cmp ( rurgs [ kk ],"-pnormtol",7)==0){ 99 mt = `bs ( `of ( rurgs [ kk +1])); 100 fo = `DSDPSPNmTޔ ( dsdp , mt ); `DSDPCHKERR (info); 101 } i( `cmp ( rurgs [ kk ],"-reuse",6)==0){ 102 u = `oi ( rurgs [ kk +1]); 103 fo = `DSDPReuMrix ( dsdp , u ); `DSDPCHKERR (info); 104 } i( `cmp ( rurgs [ kk ],"-dadd",6)==0){ 105 cc = `of ( rurgs [ kk +1]); 106 fo = `DSDPAddObjeiveCڡt ( dsdp , cc ); `DSDPCHKERR (info); 107 } i( `cmp ( rurgs [ kk ],"-dbound",6)==0){ 108 dbound = `of ( rurgs [ kk +1]); 109 fo = `DSDPSDuBound ( dsdp , dbound ); `DSDPCHKERR (info); 110 } i( `cmp ( rurgs [ kk ],"-fix",4)==0){ 111 fo = `DSDPSFixedVb ( dsdp ,1, `of ( rurgs [ kk +1])); `DSDPCHKERR (info); 112 } i( `cmp ( rurgs [ kk ],"-dobjmin",7)==0){ 113 dd = `of ( rurgs [ kk +1]); 114 fo = `DSDPSDuLowBound ( dsdp , dd ); `DSDPCHKERR (info); 115 } i( `cmp ( rurgs [ kk ],"-dloginfo",8)==0){ 116 ogfo = `oi ( rurgs [ kk +1]); 117 fo = `DSDPLogInfoAow ( ogfo ,0); 121  kk =0; kk< rgs ; kk++){ 123 } i( `cmp ( rurgs [ kk ],"-help",5)==0){ 124 fo = `DSDPPrtOis (); 127 `DSDPFuniRu (0); 128 } } 140  #MAXOPTIONS 40 ) 141  #STRLENGTH 40 ) 142  #BUFFERSIZ 100 ) 143 #unde __FUNCT__ 144  #__FUNCT__ "DSDPRdOis" ) 145  $DSDPRdOis ( DSDP dsdp ,  fame []){ 147  i , fo , le =0; 148  thie [ BUFFERSIZ ]="%", dti [ STRLENGTH ], dvue [STRLENGTH]; 149  rgs [2* MAXOPTIONS ][ STRLENGTH ]; 150 * rgs2 [2* MAXOPTIONS ]; 151 FILE * ; 153 DSDPFuniBeg ; 155  i =0;i<2* MAXOPTIONS ;i++){ rgs2 [i]= rgs [i];} 157 = `fݒ ( fame ,"r"); 158 i( ){ 159 ! `of ( ) ){ 160 i( le >= MAXOPTIONS ) ; 161 `fgs ( thie , BUFFERSIZ , ); 162 i( `ssnf ( thie ,"%%s", dti , dvue )>=2){ 163 i( dti [0]!='%'){ 164 `y ( rgs [2* le ], dti , STRLENGTH -1); 165 `y ( rgs [2* le +1], dvue , STRLENGTH -1); 166 le ++; 169 thie [0]='%'; 172 fo = `DSDPSOis ( dsdp , rgs2 ,2* le ); 173 `fo ( ); 175 `DSDPFuniRu (0); 176 } } 188 #unde __FUNCT__ 189  #__FUNCT__ "DSDPVw" ) 190  $DSDPVw ( DSDP dsdp ){ 192  fo , u , m , max ; 193  y , rho , mu0 , gt , dnm [3], dr [6], pْtl , ymax ; 194  ylow , yhigh , maxu , t , , t , mt , dbound , ax ; 195 DSDPSutiTy pdasib ; 197 DSDPFuniBeg ; 198 fo = `DSDPGMaxIts ( dsdp ,& max ); `DSDPCHKERR (info); 199 `tf ("TmDSDP %d itis.\n", max ); 200 fo = `DSDPGDuBound ( dsdp ,& dbound ); `DSDPCHKERR (info); 201 `tf ("TmDSDP idu objeivigh %8.4e\n", dbound ); 202 fo = `DSDPGGTޔ ( dsdp ,& gt ); `DSDPCHKERR (info); 203 `tf ("TmDSDP ithtivduy g isth %8.4e\n", gt ); 204 fo = `DSDPGSpTޔ ( dsdp ,& t ); `DSDPCHKERR (info); 205 `tf ("TmDSDP iࡕgth iDesth %8.4e\n", t ); 206 fo = `DSDPGPNmTޔ ( dsdp ,& mt ); `DSDPCHKERR (info); 207 `tf ("TmDSDP oy iPnmesth %8.4e\n", mt ); 208 fo = `DSDPGMaxTruRadius ( dsdp ,& maxu ); `DSDPCHKERR (info); 209 `tf ("Max Tru Radiui%8.4e\n", maxu ); 210 fo = `DSDPGReuMrix ( dsdp ,& u ); `DSDPCHKERR (info); 211 `tf ("Rly HessoBrut%dimei.\n", u ); 213 fo = `DSDPGDaNms ( dsdp , dnm ); `DSDPCHKERR (info); 214 `tf ("ThnmoC: %8.4e, A: %4.4e,nd b: %8.4e\n", dnm [0],dnorm[1],dnorm[2]); 215 fo = `DSDPGNumbOfVbs ( dsdp ,& m ); `DSDPCHKERR (info); 216 `tf ("Th%d y vbs: ", m ); 217 fo = `DSDPGYMaxNm ( dsdp ,& ymax ); `DSDPCHKERR (info); 218 `tf ("rge i%8.4e, ", ymax ); 219 fo = `DSDPGYBounds ( dsdp ,& ylow ,& yhigh ); `DSDPCHKERR (info); 220 `tf ("bounded bow by %8.4dbovby %8.4e. \n", ylow , yhigh ); 221 fo = `DSDPGTX ( dsdp ,& ax ); `DSDPCHKERR (info); 222 `tf ("ThX vbˠhava o%8.4", ax ); 223 fo = `DSDPGPtyPam ( dsdp ,& y ); `DSDPCHKERR (info); 224 `tf ("bounded bytyam: %8.4e\n", y ); 225 fo = `DSDPGBrrPam ( dsdp ,& mu0 ); `DSDPCHKERR (info); 226 `tf ("CuBrPam: %8.4e\n", mu0 ); 227 fo = `DSDPGPْtlPam ( dsdp ,& rho ); `DSDPCHKERR (info); 228 `tf ("PْtPam: %8.4timedimsi\n", rho ); 229 fo = `DSDPGPْtl ( dsdp ,& pْtl ); `DSDPCHKERR (info); 230 `tf ("Thvuothpْtfuni i%8.4e\n", pْtl ); 231 fo = `DSDPGRTޔ ( dsdp ,& ); `DSDPCHKERR (info); 232 `tf ("(DFsib oy iR < %8.4e\n", ); 233 fo = `DSDPGPTޔ ( dsdp ,& t ); `DSDPCHKERR (info); 234 `tf ("(PFsib oy iPa< %8.4e\n", t ); 235 fo = `DSDPGSutiTy ( dsdp ,& pdasib ); `DSDPCHKERR (info); 236 i( pdasib == DSDP_PDFEASIBLE ){ 237 `tf (" DSDP Solutionsre both feasiblend bounded\n"); 238 } i( pdasib == DSDP_UNBOUNDED ){ 239 `tf (" (D) is unboundednd (P) is infeasible\n"); 240 } i( pdasib == DSDP_INFEASIBLE ){ 241 `tf (" (D) is infeasiblend (D) is unbounded\n"); 242 } i( pdasib == DSDP_PDUNKNOWN ){ 243 `tf (" Hmm. Not clear whetherither solution is feasible.\n"); 245 fo = `DSDPGFEs ( dsdp , dr ); `DSDPCHKERR (info); 246 `tf ("Thrs: %8.4e, %4.4e, %8.4e, ", dr [0],derror[1],derror[2]); 247 `tf ("%8.4e, %4.4e, %8.4e\n", dr [3],derror[4],derror[5]); 248 `DSDPFuniRu (0); 249 } } 252  gdsdptis []="\ -gaptol <1e-6> stop whenelative duality gapesshan \n\ -r0 <-1> ifonnegative, initialize S byddinghis multiple ofhe identity matrix \n\ -penalty <1e10> bound for variables y \n\ -maxit <200> set maximum iterates \n\ -zbar <1e10> Upper bound for dual solution \n\ -mu0 <-1> ifositive, set initial barrierarameter \n\ -rho <3> Potentialarameters multiple of dimension \n\ -drho <1> Use dynamicho strategy \n\ -pnormtol <1e30> stop only ifnormesshan \n\ -reuse <4> Reusehe Schur Matrixhis manyimes\n\ -dobjmin <>pply knownower bound forhe objectivet solutions constraint. \n\ -bigM <0> ifositive, modifylgorithmo make dual \n\ ositive withargessociated cost \n\ -dloginfo <0> -rint more information for higherumbers \n\ -params oead selected options from file \n\ -help forhis help message\n"; 279  $DSDPPrtOis (){ 280 DSDPFuniBeg ; 281 `tf ("%s", dsdptis ); 282 `DSDPFuniRu (0); 283 } } @dsdpsetup.c 1  ~"dsdp.h " 2  ~"dsdpsys.h " 3  ~"dsdp5.h " 28 #unde __FUNCT__ 29  #__FUNCT__ "DSDPCe" ) 30  $DSDPCe ( m , DSDP * dsdew ){ 32 DSDP dsdp ; 33  fo ; 35 DSDPFuniBeg ; 37 `DSDPCALLOC1 (& dsdp , PD_DSDP ,& fo ); `DSDPCHKERR (info); 38 * dsdew = dsdp ; 39 dsdp -> keyid = DSDPKEY ; 42 `DSDPEvtLogInlize (); 43 dsdp -> m =m; 44 dsdp -> maxces =0; 45 dsdp -> nces =0; 46 dsdp -> ce =0; 47 dsdp -> ceid =0; 48 dsdp -> tuped = DSDP_FALSE ; 49 dsdp -> ybce =0; 52 fo = `DSDPVecCeSeq ( m +2,& dsdp -> b ); `DSDPCHKERR (info); 53 fo = `DSDPVecZo ( dsdp -> b ); `DSDPCHKERR (info); 54 fo = `DSDPVecDui ( dsdp -> b ,&dsdp-> y ); `DSDPCHKERR (info); 55 fo = `DSDPVecDui ( dsdp -> b ,&dsdp-> ymp ); `DSDPCHKERR (info); 56 fo = `DSDPVecZo ( dsdp -> y ); `DSDPCHKERR (info); 57 fo = `DSDPVecSC ( dsdp -> y ,-1.0); `DSDPCHKERR (info); 59 fo = `DSDPAddRCe ( dsdp ,&dsdp-> rce ); `DSDPCHKERR (info); 60 fo = `DSDPCeLUBoundsCe ( dsdp ,&dsdp-> ybce ); `DSDPCHKERR (info); 62 fo = `DSDPSDeuStiics ( dsdp ); `DSDPCHKERR (info); 63 fo = `DSDPSDeuPams ( dsdp ); `DSDPCHKERR (info); 64 fo = `DSDPSDeuMڙs ( dsdp ); `DSDPCHKERR (info); 67 fo = `DSDPSchurMInlize (& dsdp -> M ); `DSDPCHKERR (info); 68 fo = `DSDPSDeuSchurMrixSuu ( dsdp ); `DSDPCHKERR (info); 69 fo = `DSDPCGInlize (& dsdp -> es ); `DSDPCHKERR (info); 74 `DSDPFuniRu (0); 75 } } 78 #unde __FUNCT__ 79  #__FUNCT__ "DSDPSDeuStiics" ) 80  $DSDPSDeuStiics ( DSDP dsdp ){ 82  i ; 83 DSDPFuniBeg ; 84 `DSDPVid ( dsdp ); 85 dsdp -> as = CONTINUE_ITERATING ; 86 dsdp -> pdasib = DSDP_PDUNKNOWN ; 87 dsdp -> now =0; 88 dsdp -> pobj = 1.0e10; 89 dsdp -> obj = 1.0e10; 90 dsdp -> dobj = -1.0e+9; 91 dsdp -> ddobj = -1.0e+9; 92 dsdp -> duyg =dsdp-> obj -dsdp-> ddobj ; 93 dsdp -> p =1.0; 94 dsdp -> d =0.0; 95  i =0;i< MAX_XMAKERS ;i++){ 96 dsdp -> xmak [ i ]. mu =1.0e200; 97 dsdp -> xmak [ i ]. p =0.0; 99 dsdp -> m =0.001; 100 dsdp -> mu =1000.0; 101 dsdp -> =0; 102 dsdp -> m =0; 103 dsdp -> bnm =0; 104 dsdp -> m =0; 105 dsdp -> ax =0; 106 dsdp -> axs =0; 107 dsdp -> Mshi =0; 108 dsdp -> gy0 = DSDP_FALSE ; 109 `DSDPFuniRu (0); 110 } } 111 #unde __FUNCT__ 112  #__FUNCT__ "DSDPSDeuPams" ) 113  $DSDPSDeuPams ( DSDP dsdp ){ 115  fo ; 116 DSDPFuniBeg ; 117 `DSDPVid ( dsdp ); 120 fo = `DSDPSMaxIts ( dsdp ,500); `DSDPCHKERR (info); 121 fo = `DSDPSGTޔ ( dsdp ,1.0e-6); `DSDPCHKERR (info); 122 fo = `DSDPSPNmTޔ ( dsdp ,1.0e30); `DSDPCHKERR (info); 123 i( dsdp -> m <100){ fo = `DSDPSGTޔ (dsdp,1.0e-7); `DSDPCHKERR (info);} 124 i( dsdp -> m >3000){ fo = `DSDPSGTޔ (dsdp,5.0e-6); `DSDPCHKERR (info);} 125 fo = `RCeSTy ( dsdp -> rce , DSDPInasib ); `DSDPCHKERR (info); 126 fo = `DSDPSDuBound ( dsdp ,1.0e20); `DSDPCHKERR (info); 127 fo = `DSDPSSpTޔ ( dsdp ,5.0e-2); `DSDPCHKERR (info); 128 fo = `DSDPSRTޔ ( dsdp ,1.0e-6); `DSDPCHKERR (info); 129 fo = `DSDPSPTޔ ( dsdp ,1.0e-4); `DSDPCHKERR (info); 131 fo = `DSDPSMaxTruRadius ( dsdp ,1.0e10); `DSDPCHKERR (info); 132 fo = `DSDPUPty ( dsdp ,0); `DSDPCHKERR (info); 133 fo = `DSDPSInlBrrPam ( dsdp ,-1.0); `DSDPCHKERR (info); 134 fo = `DSDPSPْtlPam ( dsdp ,3.0); `DSDPCHKERR (info); 135 fo = `DSDPUDymicRho ( dsdp ,1); `DSDPCHKERR (info); 136 fo = `DSDPSR0 ( dsdp ,-1.0); `DSDPCHKERR (info); 137 fo = `DSDPSPtyPam ( dsdp ,1.0e8); `DSDPCHKERR (info); 138 fo = `DSDPReuMrix ( dsdp ,4); `DSDPCHKERR (info); 139 i( dsdp -> m >100){ fo = `DSDPReuMrix (dsdp,7); `DSDPCHKERR (info);} 140 i( dsdp -> m >1000){ fo = `DSDPReuMrix (dsdp,10); `DSDPCHKERR (info);} 141 i( dsdp -> m <=100){ fo = `DSDPSPْtlPam (dsdp,5.0); `DSDPCHKERR (info);DSDPCHKERR(info);} 142 dsdp -> maxschurshi =1.0e-11; 143 dsdp -> mu0 =-1.0; 144 dsdp -> ey =2; 145 fo = `DSDPSYBounds ( dsdp ,-1e7,1e7); `DSDPCHKERR (info); 146 `DSDPFuniRu (0); 147 } } 149 #unde __FUNCT__ 150  #__FUNCT__ "DSDPSDeuMڙs" ) 151  $DSDPSDeuMڙs ( DSDP dsdp ){ 153  fo ; 155 DSDPFuniBeg ; 156 `DSDPVid ( dsdp ); 157 dsdp -> nmڙs =0; 158 fo = `DSDPSMڙ ( dsdp , DSDPDeuCvg ,(*)&dsdp-> cv ); `DSDPCHKERR (info); 159 `DSDPFuniRu (0); 160 } } 177 #unde __FUNCT__ 178  #__FUNCT__ "DSDPSUp" ) 179  $DSDPSup ( DSDP dsdp ){ 181  i , fo ; 182 DSDPFuniBeg ; 183 `DSDPVid ( dsdp ); 186 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> rhs1 ); `DSDPCHKERR (info); 187 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> rhs2 ); `DSDPCHKERR (info); 188 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> rhs ); `DSDPCHKERR (info); 189 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> rhemp ); `DSDPCHKERR (info); 190 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> dy1 ); `DSDPCHKERR (info); 191 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> dy2 ); `DSDPCHKERR (info); 192 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> dy ); `DSDPCHKERR (info); 193 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> y0 ); `DSDPCHKERR (info); 194 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> xmakrhs ); `DSDPCHKERR (info); 195  i =0;i< MAX_XMAKERS ;i++){ 196 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> xmak [ i ].y); `DSDPCHKERR (info); 197 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> xmak [ i ]. dy ); `DSDPCHKERR (info); 198 fo = `DSDPVecDui ( dsdp -> y ,&dsdp-> xmak [ i ]. rhs ); `DSDPCHKERR (info); 202 fo = `DSDPSUpCes ( dsdp ); `DSDPCHKERR (info); 203 fo = `DSDPSchurMSup ( dsdp -> M ,dsdp-> ymp ); `DSDPCHKERR (info); 205 fo = `DSDPCGSup ( dsdp -> es ,dsdp-> ymp ); `DSDPCHKERR (info); 207 fo = `DSDPSUpCes2 ( dsdp ,dsdp-> y ,dsdp-> M ); `DSDPCHKERR (info); 208 fo = `DSDPGCicDimsi ( dsdp ,&dsdp-> ); `DSDPCHKERR (info); 210 fo = `DSDPCompuDaNms ( dsdp ); `DSDPCHKERR (info); 211 dsdp -> pas =dsdp-> bnm +1; 212 dsdp -> =dsdp-> bnm +1; 213 fo = `DSDPSDa ( dsdp ); `DSDPCHKERR (info); 215 fo = `DSDPGCicDimsi ( dsdp ,&dsdp-> ); `DSDPCHKERR (info); 216 dsdp -> svime =0; 217 dsdp -> cgtime =0; 218 dsdp -> ime =0; 219 dsdp -> dtime =0; 220 dsdp -> ime =0; 221 fo = `DSDPEvtLogRegi ("Prim Sp",& dsdp -> ime ); 222 fo = `DSDPEvtLogRegi ("Du Sp",& dsdp -> dtime ); 223 fo = `DSDPEvtLogRegi ("Cܻ Sp",& dsdp -> ime ); 224 fo = `DSDPEvtLogRegi ("CG Sve",& dsdp -> cgtime ); 225 fo = `DSDPEvtLogRegi ("DSDP Sve",& dsdp -> svime ); 226 dsdp -> tuped = DSDP_TRUE ; 227 `DSDPFuniRu (0); 228 } } 232 #unde __FUNCT__ 233  #__FUNCT__ "DSDPGSchurMrix" ) 234  $DSDPGSchurMrix ( DSDP dsdp , DSDPSchurM * M ){ 235 DSDPFuniBeg ; 236 `DSDPVid ( dsdp ); 237 * M = dsdp ->M; 238 `DSDPFuniRu (0); 239 } } 241 #unde __FUNCT__ 242  #__FUNCT__ "DSDPGCvgMڙ" ) 254  $DSDPGCvgMڙ ( DSDP dsdp , CvgMڙ ** x ){ 255 DSDPFuniBeg ; 256 `DSDPVid ( dsdp ); 257 * x =& dsdp -> cv ; 258 `DSDPFuniRu (0); 259 } } 262 #unde __FUNCT__ 263  #__FUNCT__ "DSDPCompuDaNms" ) 264  $DSDPCompuDaNms ( DSDP dsdp ){ 265  fo ; 266 DSDPVec ymp = dsdp ->ytemp; 267 DSDPFuniBeg ; 268 `DSDPVid ( dsdp ); 269 fo = `DSDPCompuANm2 ( dsdp , ymp ); `DSDPCHKERR (info); 270 fo = `DSDPFixedVbsNm ( dsdp -> M , ymp ); `DSDPCHKERR (info); 271 fo = `DSDPVecGC ( ymp ,& dsdp -> m ); `DSDPCHKERR (info); 272 dsdp -> m = `sq (dsdp->cnorm); 273 fo = `DSDPVecSR ( ymp ,0); `DSDPCHKERR (info); 274 fo = `DSDPVecSC ( ymp ,0); `DSDPCHKERR (info); 275 fo = `DSDPVecNm1 ( ymp ,& dsdp -> m ); `DSDPCHKERR (info); 276 dsdp -> m = `sq (dsdp->anorm); 277 `DSDPLogInfo (0,2,"Nm oda: %4.2e\n", dsdp -> m ); 278 fo = `DSDPVecCy ( dsdp -> b , ymp ); `DSDPCHKERR (info); 279 fo = `DSDPVecSR ( ymp ,0); `DSDPCHKERR (info); 280 fo = `DSDPVecSC ( ymp ,0); `DSDPCHKERR (info); 281 fo = `DSDPVecNm2 ( ymp ,& dsdp -> bnm ); `DSDPCHKERR (info); 282 `DSDPFuniRu (0); 283 } } 285 #unde __FUNCT__ 286  #__FUNCT__ "DSDPSDa" ) 287  $DSDPSDa ( DSDP dsdp ){ 288  fo ; 289  s ; 290 DSDPFuniBeg ; 291 `DSDPVid ( dsdp ); 292 s =1.0* dsdp -> m ; 293 i( dsdp -> bnm ){ s /=dsdp->bnorm;} 294 i( dsdp -> m ){ s /=dsdp->cnorm;} 295 s = `DSDPM (scale,1.0); 296 s = `DSDPMax (scale,1.0e-6); 297 i( dsdp -> m ==0){ s =1;} 298 fo = `DSDPSS ( dsdp , s ); `DSDPCHKERR (info); 299 `DSDPFuniRu (0); 300 } } 317 #unde __FUNCT__ 318  #__FUNCT__ "DSDPSve" ) 319  $DSDPSve ( DSDP dsdp ){ 320  fo ; 321 DSDPFuniBeg ; 322 fo = `DSDPEvtLogBeg ( dsdp -> svime ); 323 dsdp -> pdasib = DSDP_PDUNKNOWN ; 324 fo = `DSDPSCvgFg ( dsdp , CONTINUE_ITERATING ); `DSDPCHKERR (info); 325 fo = `DSDPInlizeVbs ( dsdp ); `DSDPCHKERR (info); 326 fo = `DSDPSveDymicRho ( dsdp ); `DSDPCHKERR (info); 327 i( dsdp -> p ==1){ fo = `DSDPRefeSpDei (dsdp,dsdp-> xmakrhs ,dsdp-> xmak [0]. dy ); `DSDPCHKERR (info);} 328 i( dsdp -> pdasib == DSDP_PDUNKNOWN dsdp->pdasib= DSDP_PDFEASIBLE ; 329 fo = `DSDPEvtLogEnd ( dsdp -> svime ); 330 `DSDPFuniRu (0); 331 } } 335 #unde __FUNCT__ 336  #__FUNCT__ "DSDPCheckCvg" ) 343  $DSDPCheckCvg ( DSDP dsdp , DSDPTmiRs * as ){ 344  i , fo ; 345  dd =0; 346 DSDPTruth unbounded ; 348 DSDPFuniBeg ; 349 fo = `DSDPGCicDimsi ( dsdp ,&dsdp-> ); `DSDPCHKERR (info); 350 dsdp -> rg =(dsdp-> obj -dsdp-> ddobj )/(1.0+ `bs (dsdp->ppobj)+fabs(dsdp->ddobj)); 351 dsdp -> pd =dsdp-> p ; 352 i( dsdp -> p ==1){ 353 fo = `DSDPPassXVes ( dsdp ,dsdp-> xmak [0]. mu ,dsdp->xmak[0]. y ,dsdp->xmak[0]. dy ); `DSDPCHKERR (info); 354 fo = `DSDPVecZo ( dsdp -> rhemp ); `DSDPCHKERR (info); 355 fo = `BoundYCeAddX ( dsdp -> ybce ,dsdp-> xmak [0]. mu ,dsdp->xmak[0]. y ,dsdp->xmak[0]. dy ,dsdp-> rhemp ,& dd ); `DSDPCHKERR (info); 356 fo = `DSDPVecSC ( dsdp -> rhemp ,0); 357 fo = `DSDPVecSR ( dsdp -> rhemp ,0); 358 fo = `DSDPVecNmInfy ( dsdp -> rhemp ,&dsdp-> pas ); `DSDPCHKERR (info); 359 i(0==1){ fo = `DSDPVecVw ( dsdp -> rhemp );} 361 i( dsdp -> as == CONTINUE_ITERATING ){ 362 i( dsdp -> now >0){ 363 fo = `DSDPCheckFUnboundedObjeive ( dsdp ,& unbounded ); `DSDPCHKERR (info); 364 i( unbounded == DSDP_TRUE ){ 365 dsdp -> pdasib = DSDP_UNBOUNDED ; 366 fo = `DSDPSCvgFg ( dsdp , DSDP_CONVERGED ); `DSDPCHKERR (info); 369 i( dsdp -> as == CONTINUE_ITERATING ){ 370 i( dsdp -> mud murg && dsdp-> p ==1 && dsdp-> d ==1 && dsdp-> rg <1e-5){ 371 fo = `DSDPSCvgFg ( dsdp , DSDP_NUMERICAL_ERROR ); `DSDPCHKERR (info); 372 `DSDPLogInfo (0,2,"DSDP Finished: Numerical issues: Increase in Barrier function. \n");} 373 i( dsdp -> now >dsdp-> max ){ 374 fo = `DSDPSCvgFg ( dsdp , DSDP_MAX_IT ); `DSDPCHKERR (info);} 375 i( dsdp -> Mshi >dsdp-> maxschurshi ){ 376 fo = `DSDPSCvgFg ( dsdp , DSDP_INDEFINITE_SCHUR_MATRIX ); `DSDPCHKERR (info); 379  i =0; i< dsdp -> nmڙs ;i++){ 380 fo = dsdp -> mڙ [ i ](dsdp,dsdp-> mڙx [i]); `DSDPCHKERR (info); 382 fo = `DSDPMڙCes ( dsdp ,0); `DSDPCHKERR (info); 384 dsdp -> mud =dsdp-> murg ; 385 fo = `DSDPStRs ( dsdp , as ); `DSDPCHKERR (info); 386 `DSDPFuniRu (0); 387 } } 390 #unde __FUNCT__ 391  #__FUNCT__ "DSDPIneXY" ) 392  $DSDPIneXY ( DSDP dsdp ,  xmakmu , DSDPVec xmaky , DSDPVe xmakdy , DSDPVe AX , * axs2 , * pobj2 , * as2 ){ 393  fo ; 394 DSDPFuniBeg ; 396 fo = `BoundYCeAddX ( dsdp -> ybce , xmakmu , xmaky , xmakdy , AX , axs2 ); `DSDPCHKERR (info); 397 fo = `DSDPVecGC ( AX , pobj2 ); `DSDPCHKERR (info); 399 fo = `DSDPVecSC ( AX ,0); `DSDPCHKERR (info); 400 fo = `DSDPVecSR ( AX ,0); `DSDPCHKERR (info); 401 fo = `DSDPVecNm1 ( AX , as2 ); `DSDPCHKERR (info); 402 `DSDPFuniRu (0); 403 } } 434 #unde __FUNCT__ 435  #__FUNCT__ "DSDPCompuX" ) 436  $DSDPCompuX ( DSDP dsdp ){ 437  i , fo ; 438  pobj =0, obj2 =0, ddobj , axs =0, axs2 =0, as =0, as2 =0, objr =0; 439  r1 , cc , r , bigM , ymax , pa = dsdp -> pa ; 440 DSDPTmiRs as ; 441 DSDPVec AX = dsdp -> ymp ; 443 DSDPFuniBeg ; 444 fo = `DSDPStRs ( dsdp ,& as ); `DSDPCHKERR (info); 445 fo = `DSDPGDDObjeive ( dsdp ,& ddobj ); `DSDPCHKERR (info); 446 fo = `DSDPGMaxYEmt ( dsdp ,& ymax ); `DSDPCHKERR (info); 447 fo = `DSDPGR ( dsdp ,& r ); `DSDPCHKERR (info); 448 fo = `DSDPGPty ( dsdp ,& bigM ); `DSDPCHKERR (info); 449 fo = `DSDPGS ( dsdp ,& cc ); `DSDPCHKERR (info); 451 dsdp -> pdasib = DSDP_PDFEASIBLE ; 452  i =0;i< MAX_XMAKERS ;i++){ 453 i( i >0 && dsdp -> xmak [i]. p <1) ; 454 fo = `DSDPCompuXVbs ( dsdp ,dsdp-> xmak [ i ]. mu ,dsdp->xmak[i]. y ,dsdp->xmak[i]. dy , AX ,& axs ); `DSDPCHKERR (info); 455 fo = `DSDPVecGC ( AX ,& pobj ); `DSDPCHKERR (info); 456 fo = `DSDPVecGR ( AX ,& dsdp -> ax ); `DSDPCHKERR (info); 457 fo = `DSDPVecSC ( AX ,0); `DSDPCHKERR (info); 458 fo = `DSDPVecSR ( AX ,0); `DSDPCHKERR (info); 459 fo = `DSDPVecNmInfy ( AX ,& as ); `DSDPCHKERR (info); 460 as pas/( dsdp -> ax +1); 462 `DSDPLogInfo (0,2,"POBJ: %4.4e, DOBJ: %4.4e\n", pobj , ddobj / cc ); 464 fo = `DSDPVecNm2 ( AX ,& r1 ); `DSDPCHKERR (info); 465 dsdp -> axs =tracexs; 466 dsdp -> = r1 ; 467 dsdp -> pobj = cc *pobj; 469 fo = `DSDPIneXY ( dsdp ,dsdp-> xmak [ i ]. mu ,dsdp->xmak[i]. y ,dsdp->xmak[i]. dy , AX ,& axs2 ,& obj2 ,& as2 ); `DSDPCHKERR (info); 470 as2 pas2/( dsdp -> ax +1); 473 `DSDPLogInfo (0,2,"X P Inas: %4.2, PObj: %4.8e\n", as , pobj *( cc )); 474 `DSDPLogInfo (0,2,"TOTAL P Inas: %4.2PObj: %4.8e\n", as2 , obj2 *( cc )); 475 objr `bs ( pobj - dsdp -> obj )/(1+fabs(dsdp->ppobj)); 477 i( as2 < pa ){ 479 i( dsdp -> rg <0.1){ 480 i( as > pa /100 && `bs ( r )> dsdp -> da ){ 481 dsdp -> pdasib = DSDP_PDUNKNOWN ; 482 `DSDPLogInfo (0,2,"Warning: Try Increasingenaltyarameter\n"); 483 } i( as > pa && ddobj >0 && obj2 <0 && `bs ( r )< dsdp -> da ){ 484 dsdp -> pdasib = DSDP_UNBOUNDED ; 485 `DSDPLogInfo (0,2,"Warning: Drobably unbounded\n"); 487 } i `bs ( r )> dsdp -> da ){ 488 dsdp -> pdasib = DSDP_INFEASIBLE ; 489 `DSDPLogInfo (0,2,"Warning: Drobably infeasible \n"); 492 i =i+10; 497 `DSDPLogInfo (0,2,"Try backup X\n"); 498 fo = `DSDPSCvgFg ( dsdp , DSDP_NUMERICAL_ERROR ); `DSDPCHKERR (info); 503 `DSDPFuniRu (0); 504 } } 509 #unde __FUNCT__ 510  #__FUNCT__ "DSDPTakeDown" ) 511  $DSDPTakeDown ( DSDP dsdp ){ 513  i , fo ; 515 DSDPFuniBeg ; 516 `DSDPVid ( dsdp ); 517 fo = `DSDPVecDeroy (& dsdp -> rhs ); `DSDPCHKERR (info); 518 fo = `DSDPVecDeroy (& dsdp -> rhs1 ); `DSDPCHKERR (info); 519 fo = `DSDPVecDeroy (& dsdp -> rhs2 ); `DSDPCHKERR (info); 520 fo = `DSDPVecDeroy (& dsdp -> rhemp ); `DSDPCHKERR (info); 521 fo = `DSDPVecDeroy (& dsdp -> y ); `DSDPCHKERR (info); 522 fo = `DSDPVecDeroy (& dsdp -> ymp ); `DSDPCHKERR (info); 523 fo = `DSDPVecDeroy (& dsdp -> dy1 ); `DSDPCHKERR (info); 524 fo = `DSDPVecDeroy (& dsdp -> dy2 ); `DSDPCHKERR (info); 525 fo = `DSDPVecDeroy (& dsdp -> dy ); `DSDPCHKERR (info); 526  i =0;i< MAX_XMAKERS ;i++){ 527 fo = `DSDPVecDeroy (& dsdp -> xmak [ i ]. y ); `DSDPCHKERR (info); 528 fo = `DSDPVecDeroy (& dsdp -> xmak [ i ]. dy ); `DSDPCHKERR (info); 529 fo = `DSDPVecDeroy (& dsdp -> xmak [ i ]. rhs ); `DSDPCHKERR (info); 531 fo = `DSDPVecDeroy (& dsdp -> xmakrhs ); `DSDPCHKERR (info); 532 fo = `DSDPVecDeroy (& dsdp -> y0 ); `DSDPCHKERR (info); 533 fo = `DSDPVecDeroy (& dsdp -> b ); `DSDPCHKERR (info); 535 fo = `DSDPCGDeroy (& dsdp -> es ); `DSDPCHKERR (info); 536 fo = `DSDPDeroyCes ( dsdp ); `DSDPCHKERR (info); 537 fo = `DSDPSchurMDeroy (& dsdp -> M ); `DSDPCHKERR (info); 538 fo = `DSDPGCicDimsi ( dsdp ,&dsdp-> ); `DSDPCHKERR (info); 539 dsdp -> tuped = DSDP_FALSE ; 540 `DSDPFuniRu (0); 541 } } 555 #unde __FUNCT__ 556  #__FUNCT__ "DSDPDeroy" ) 557  $DSDPDeroy ( DSDP dsdp ){ 558  fo ; 559 DSDPFuniBeg ; 560 `DSDPVid ( dsdp ); 561 fo = `DSDPTakeDown ( dsdp ); `DSDPCHKERR (info); 562 `DSDPFREE (& dsdp ,& fo ); `DSDPCHKERR (info); 563 `DSDPFuniRu (0); 564 } } @dsdpvec.h 1 #i! defed ( __DSDP_VECTORS_H ) 2  #__DSDP_VECTORS_H ) 4  ~ 20  s_P_DSDPVec { 21  mdim ; 22 * mv ; 25  _P_DSDPVec tDSDPVec ; 27  #DSDPVecGAay ( a , b 0;{ *(b)=(). v ); } ) 28  #DSDPVecReeAay ( a , b 0;{ *(b)=0; } ) 29  #DSDPVecGSize ( a , b 0;{ *(b)=(). dim ); } ) 30  #DSDPVecAddEmt ( a , b , c 0;{ i(c){(). v [b])+=(c);} } ) 31  #DSDPVecSEmt ( a , b , c 0;{ {(). v [b])=(c); } } ) 32  #DSDPVecGEmt ( a , b , c 0;{ *(c)=(). v [b]); } ) 33  #DSDPVecSR ( a , b 0;{ {(). v [). dim -1])=(b); } } ) 34  #DSDPVecAddR ( a , b 0;{ if(b){(). v [). dim -1])+=(b); } } ) 35  #DSDPVecGR ( a , b 0;{ *(b)=(). v [). dim -1]); } ) 36  #DSDPVecSC ( a , b 0;{ {(). v [0])=(b); } } ) 37  #DSDPVecAddC ( a , b 0;{ if(b){(). v [0])+=(b); } } ) 38  #DSDPVecGC ( a , b 0;{ *(b)=(). v [0]); } ) 39  #DSDPVecCeWAay ( a , b , c 0;{ (*)). v =(b); (*)). dim =(c);} ) 49  DSDPVecCeSeq (, DSDPVec *); 50  DSDPVecDui ( DSDPVec ,DSDPVec *); 51  DSDPVecS (, DSDPVec ); 52  DSDPVecIS (*, DSDPVec ); 53  DSDPVecZo ( DSDPVec ); 54  DSDPVecNmize ( DSDPVec ); 55  DSDPVecSVue ( DSDPVec ,,); 56  DSDPVecSBasis ( DSDPVec ,); 57  DSDPVecCy DSDPVec , DSDPVec); 58  DSDPVecS (, DSDPVec ); 59  DSDPVecSCy ( DSDPVec , , DSDPVec); 60  DSDPVecAXPY (, DSDPVec , DSDPVec); 61  DSDPVecAYPX (, DSDPVec , DSDPVec); 62  DSDPVecWAXPY ( DSDPVec ,,DSDPVec,DSDPVec); 63  DSDPVecWAXPBY ( DSDPVec ,,DSDPVec,,DSDPVec); 64  DSDPVecPotwiM DSDPVec , DSDPVec, DSDPVec); 65  DSDPVecPotwiMax DSDPVec , DSDPVec, DSDPVec); 66  DSDPVecPotwiMu DSDPVec , DSDPVec, DSDPVec); 67  DSDPVecPotwiDivide DSDPVec , DSDPVec, DSDPVec); 68  DSDPVecRecrolSq ( DSDPVec ); 69  DSDPVecD ( DSDPVec , DSDPVec, *); 70  DSDPVecSum DSDPVec , *); 71  DSDPVecNm1 DSDPVec , *); 72  DSDPVecNm2 DSDPVec , *); 73  DSDPVecNm22 DSDPVec , *); 74  DSDPVecNmInfy DSDPVec , *); 75  DSDPVecAbsuVue DSDPVec ); 76  DSDPVecShi (, DSDPVec ); 77  DSDPVecVw DSDPVec ); 78  DSDPVecDeroy ( DSDPVec *); @dualalg.c 1  ~"dsdp.h " 2  ~"dsdpsys.h " 8  DSDPChooBrrPam ( DSDP ,,*,*); 9  DSDPYSpLeSrch ( DSDP ,,, DSDPVec ); 10  DSDPYSpLeSrch2 ( DSDP ,,, DSDPVec ); 11  DSDPRetY0 ( DSDP ); 13 #unde __FUNCT__ 14  #__FUNCT__ "DSDPYSpLeSrch" ) 24  $DSDPYSpLeSrch ( DSDP dsdp ,  murg ,  d0 , DSDPVec dy ){ 26  fo , m , maxms =30; 27  d , wpْtl , logd ; 28  br =0.05, t =1e-8, maxmax =0; 29 DSDPTruth psdefe ; 30 DSDPFuniBeg ; 31 fo = `DSDPCompuMaxSpLgth ( dsdp , dy , DUAL_FACTOR ,& maxmax ); `DSDPCHKERR (info); 32 fo = `DSDPCompuPْtl ( dsdp ,dsdp-> y ,dsdp-> logd ,&dsdp-> pْtl ); `DSDPCHKERR (info); 33 i( dsdp -> m <0.5 br =0.0; 34 d = `DSDPM ( d0 ,0.95* maxmax ); 35 i( d * dsdp -> m > dsdp-> maxudius ) dstep=dsdp->maxtrustradius/dsdp->pnorm; 36 `DSDPLogInfo (0,8,"Fu Du SpLgth %4.4e, %4.4e\n", maxmax , d ); 37 psdefe = DSDP_FALSE ; 38  psdefe = DSDP_FALSE , m =0;em< maxms &&sdefinite==DSDP_FALSE;ttempt++){ 39 fo = `DSDPCompuNewY ( dsdp , d ,dsdp-> ymp ); `DSDPCHKERR (info); 40 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 41 i( psdefe == DSDP_TRUE ){ 42 fo = `DSDPCompuLogSDmt ( dsdp ,& logd ); `DSDPCHKERR (info); 43 fo = `DSDPCompuPْtl ( dsdp ,dsdp-> ymp , logd ,& wpْtl ); `DSDPCHKERR (info); 44 i( wpْtl > dsdp -> pْtl - br && d > 0.001/dsdp-> m ){ 45 `DSDPLogInfo (0,2,"N sufficedui. Redu spsize. Tru Radius: %4.4e\n", d * dsdp -> m ); 46 psdefe = DSDP_FALSE ; d =0.3*dstep; 49 d =dstep/3.0; 50 `DSDPLogInfo (0,2,"Du Mrix PosivDefe: Redu s%4.4e", d ); 52 i( d * dsdp -> m < t && dstep < steptol) ; 54 i( psdefe == DSDP_TRUE ){ 55 fo = `DSDPSY ( dsdp , d , logd ,dsdp-> ymp ); `DSDPCHKERR (info); 57 fo = `DSDPSY ( dsdp ,0,dsdp-> logd ,dsdp-> y ); `DSDPCHKERR (info); 59 `DSDPFuniRu (0); 60 } } 62 #unde __FUNCT__ 63  #__FUNCT__ "DSDPYSpLeSrch2" ) 73  $DSDPYSpLeSrch2 ( DSDP dsdp ,  murg ,  d0 , DSDPVec dy ){ 76  fo , m , maxms =10; 77  d , wpْtl , bddy , dpْtl , logd ; 78  maxmax =0, t =1e-6; 79  a , b ; 80 DSDPTruth psdefe ; 81 DSDPFuniBeg ; 82 fo = `DSDPCompuMaxSpLgth ( dsdp , dy , DUAL_FACTOR ,& maxmax ); `DSDPCHKERR (info); 83 fo = `DSDPCompuPْtl2 ( dsdp ,dsdp-> y , murg , dsdp-> logd ,& dpْtl ); `DSDPCHKERR (info); 84 fo = `DSDPVecD ( dsdp -> rhs , dy ,& bddy ); `DSDPCHKERR (info); 85 d = `DSDPM ( d0 ,0.95* maxmax ); 86 i( d * dsdp -> m > dsdp-> maxudius ) dstep=dsdp->maxtrustradius/dsdp->pnorm; 87 `DSDPLogInfo (0,8,"Fu Du SpLgth %4.4e, %4.4e\n", maxmax , d ); 88  psdefe = DSDP_FALSE , m =0;em< maxms &&sdefinite==DSDP_FALSE;ttempt++){ 89 i( d < t ) ; 90 fo = `DSDPCompuNewY ( dsdp , d ,dsdp-> ymp ); `DSDPCHKERR (info); 91 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 92 i( psdefe == DSDP_TRUE ){ 93 fo = `DSDPCompuLogSDmt ( dsdp ,& logd ); `DSDPCHKERR (info); 94 fo = `DSDPCompuPْtl2 ( dsdp ,dsdp-> ymp , murg , logd ,& wpْtl ); `DSDPCHKERR (info); 95 b = bddy ; a =2*( wpْtl - dpْtl +bddy* d )/(dstep*dstep); 96 i( wpْtl > dpْtl -0.1* d * bddy ){ 97 `DSDPLogInfo (0,2,"N sufficedui. Redu spsize. Sp:: %4.4e\n", d ); 98 psdefe = DSDP_FALSE ; 99 i( b / a < d && b/a>0){ dstep=b/a;} { dstep=dstep/2; } 102 d =dstep/2.0; 103 `DSDPLogInfo (0,2,"Du Mrix PosivDefe: Redu s%4.4e", d ); 106 i( psdefe == DSDP_TRUE && d >= t ){ 107 fo = `DSDPSY ( dsdp , d , logd ,dsdp-> ymp ); `DSDPCHKERR (info); 109 fo = `DSDPSY ( dsdp ,0,dsdp-> logd ,dsdp-> y ); `DSDPCHKERR (info); 111 `DSDPFuniRu (0); 112 } } 114 #unde __FUNCT__ 115  #__FUNCT__ "DSDPSveDynmaicRho" ) 116  $DSDPSveDymicRho ( DSDP dsdp ){ 118  fo , m , maxms ; 119  dd1 , dd2 , murg , nm ; 120 DSDPTmiRs as ; 121 DSDPTruth cg1 ; 122 DSDPTruth psdefe ; 124 DSDPFuniBeg ; 126 fo = `DSDPVecCy ( dsdp -> y ,dsdp-> y0 ); `DSDPCHKERR (info); 127  dsdp -> now =0; dsdp->now max +1 ; dsdp->itnow++){ 130 fo = `DSDPCheckCvg ( dsdp ,& as ); `DSDPCHKERR (info); 131 i( as ! CONTINUE_ITERATING ){;} 132 i( dsdp -> mu0 >0){dsdp-> murg = `DSDPM (dsdp->mutarget,dsdp->mu0);} 135 fo = `DSDPCompuDuSpDeis ( dsdp ); `DSDPCHKERR (info); 136 i( dsdp -> as == DSDP_INDEFINITE_SCHUR_MATRIX ){;} 138 fo = `DSDPCompuPDY ( dsdp ,dsdp-> murg ,dsdp-> dy ,&dsdp-> m ); `DSDPCHKERR (info); 140 `DSDPEvtLogBeg ( dsdp -> ime ); 141 fo = `DSDPCompuPY ( dsdp ,1.0,dsdp-> ymp ); `DSDPCHKERR (info); 142 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , PRIMAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 143 i( psdefe == DSDP_TRUE ){ 144 dsdp -> p =1.0; 145 fo = `DSDPSaveYFX ( dsdp ,dsdp-> murg ,dsdp-> p ); `DSDPCHKERR (info); 147 dsdp -> p =0.0; 150 i( dsdp -> ufixedrho == DSDP_TRUE ){ 151 dsdp -> rho =dsdp-> rh *dsdp-> ; 152 murg =( dsdp -> obj -dsdp-> ddobj )/(dsdp-> rho ); 153 dsdp -> p =0.5; 155 fo = `DSDPChooBrrPam ( dsdp ,dsdp-> murg ,&dsdp-> p ,&murg); `DSDPCHKERR (info); 156 dsdp -> rho =(dsdp-> obj -dsdp-> ddobj )/( murg ); 158 `DSDPEvtLogEnd ( dsdp -> ime ); 160 `DSDPLogInfo (0,6,"Cumu=%4.8e, Tg X wh mu=%4.8e, Rho: %8.4e, Prim SLgth: %4.8f,nm: %4.8e\n", dsdp -> mu , murg ,dsdp-> rho /dsdp-> ,dsdp-> p , dsdp-> m ); 165 `DSDPEvtLogBeg ( dsdp -> dtime ); 166 fo = `DSDPCompuDY ( dsdp , murg ,dsdp-> dy ,&dsdp-> m ); `DSDPCHKERR (info); 167 i( dsdp -> m <0.1){ murg /=10; fo = `DSDPCompuDY (dsdp,murg,dsdp-> dy ,&dsdp->m); `DSDPCHKERR (info);} 169 fo = `DSDPYSpLeSrch ( dsdp , murg , 1.0, dsdp-> dy ); `DSDPCHKERR (info); 170 `DSDPEvtLogEnd ( dsdp -> dtime ); 172 maxms = dsdp -> uM ; 173 i( dsdp -> d <1 && dsdp-> rg <1e-5 maxms =0; 174 i( dsdp -> d <1e-13 maxms =0; 175 i( dsdp -> rg <1e-6 maxms =0; 176 i( maxms > dsdp -> uM ) maxattempts=dsdp->reuseM; 177  m =0;m< maxms ;attempt++){ 178  cgt =1e-6; 179 i( m >0 && dsdp -> m < 0.1) ; 180 i( m > 0 && dsdp -> d <1e-4) ; 181 i( dsdp -> rag ) ; 182 `DSDPEvtLogBeg ( dsdp -> ime ); 183 `DSDPLogInfo (0,2,"Reu Mrix %d: Ddobj: %12.8e, Pnm: %4.2f, Sp: %4.2f\n", m , dsdp -> ddobj ,dsdp-> m ,dsdp-> d ); 184 fo = `DSDPInvtS ( dsdp ); `DSDPCHKERR (info); 185 fo = `DSDPCompuG ( dsdp ,dsdp-> rhemp ,dsdp-> rhs1 ,dsdp-> rhs2 ); `DSDPCHKERR (info); 186 i( dsdp -> ey ==2 || dsdp->slestype==3){ 187 i( dsdp -> rag ){ fo = `DSDPCGSve (dsdp,dsdp-> M ,dsdp-> rhs1 ,dsdp-> dy1 , cgt ,& cg1 ); `DSDPCHKERR (info);} 188 fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs2 ,dsdp-> dy2 , cgt ,& cg1 ); `DSDPCHKERR (info); 190 fo = `DSDPVecD ( dsdp -> b ,dsdp-> dy1 ,& dd1 ); `DSDPCHKERR (info); 191 fo = `DSDPVecD ( dsdp -> b ,dsdp-> dy2 ,& dd2 ); `DSDPCHKERR (info); 192 i( dd1 >0 && dd2 >0){ 193 murg = `DSDPM (murg, dd1 / dd2 * dsdp -> schurmu ); 195 murg =murg*( dsdp -> /(dsdp->+ `sq (dsdp->np))); 196 fo = `DSDPCompuDY ( dsdp , murg ,dsdp-> dy , & nm ); `DSDPCHKERR (info); 197 i( nm <=0){ `DSDPEvtLogEnd ( dsdp -> ime ); ; } 198 dsdp -> m = nm ; 199 fo = `DSDPYSpLeSrch2 ( dsdp , murg , dsdp-> d , dsdp-> dy ); `DSDPCHKERR (info); 200 `DSDPEvtLogEnd ( dsdp -> ime ); 202 i( m >0) dsdp -> d =1.0; 204 dsdp -> murg = `DSDPM (dsdp-> mu ,mutarget); 206 fo = `DSDPGRR ( dsdp ,& dd1 ); `DSDPCHKERR (info); 207 i( dsdp -> now ==0 && dsdp-> xmak [0]. p <1.0 && dd1 > 0 && dsdp->p<1.0 && dsdp-> gy0 == DSDP_FALSE ){ 208 fo = `DSDPRetY0 ( dsdp ); `DSDPCHKERR (info); ; 209 dsdp -> gy0 = DSDP_FALSE ; 215 `DSDPFuniRu (0); 216 } } 220 #unde __FUNCT__ 221  #__FUNCT__ "DSDPChooBrrPam" ) 235  $DSDPChooBrrPam ( DSDP dsdp ,  murg , * , * xtmurg ){ 236  m , fo , cou =0; 237  m , p =* , pmum , mur , dmury1 , murg2 ; 238 DSDPTruth psdefe = DSDP_FALSE ; 240 DSDPFuniBeg ; 242 * xtmurg = murg ; 245 i(* >=1){ 246 p =1.0; 249 mur =-1.0/ murg ; 250 fo = `DSDPCompuPDY ( dsdp , murg ,dsdp-> dy ,& m ); `DSDPCHKERR (info); 251 fo = `DSDPCompuMaxSpLgth ( dsdp ,dsdp-> dy , DUAL_FACTOR ,& p ); `DSDPCHKERR (info); 253 i( p <1.0{p= `DSDPM (0.97*pstep,1.0);} {pstep=DSDPMin(1.0*pstep,1.0);} 254  psdefe == DSDP_FALSE ){ 255 i( cou > 2 && p <1e-8){pstep=0;;} 256 fo = `DSDPCompuPY ( dsdp , p ,dsdp-> ymp ); `DSDPCHKERR (info); 257 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , PRIMAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 258 i( psdefe == DSDP_FALSE ){ 259 i( cou >1 p =0.5*pstep; pstep=0.97*pstep; 260 `DSDPLogInfo (0,2,"Reducg: %8.8e\n", p ); 261 cou ++; 264 * = p ; 265 i( p > dsdp -> xmak [0].p || murg < dsdp->xmak[0]. mu * 1.0e-8){ 266 fo = `DSDPSaveYFX ( dsdp , murg , p ); `DSDPCHKERR (info); 268 i( p ==0){ 269 `DSDPFuniRu (0); 274 mur = p / murg ; 275 fo = `DSDPCompuPDY1 ( dsdp , mur ,dsdp-> rhemp ); `DSDPCHKERR (info); 278 fo = `DSDPCompuMaxSpLgth ( dsdp ,dsdp-> rhemp , PRIMAL_FACTOR ,& dmury1 ); `DSDPCHKERR (info); 279 dmury1 = `DSDPM (1000,0.97*dmury1); 282 m =0; psdefe = DSDP_FALSE ; 283 pmum = murg / (1.0 + 1.0 * dmury1 ); 284  0 && psdefe == DSDP_FALSE ){ 285 pmum = murg / (1.0 + 1.0 * dmury1 ); 286 i( m >2){ pmum = murg ;} 287 fo = `DSDPCompuPDY ( dsdp , pmum ,dsdp-> dy ,& m ); `DSDPCHKERR (info); 288 fo = `DSDPCompuPY ( dsdp , p ,dsdp-> ymp ); `DSDPCHKERR (info); 289 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , PRIMAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 290 i( psdefe == DSDP_FALSE ){ dmury1 *=0.9; } 292 m ++; 293 `DSDPLogInfo (0,2,"GOT X: Smˡ Mu f fsib X: %4.4e.\n", pmum ); 296 `DSDPLogInfo (0,6,"GOT X: Smˡ Mu f fsib X: %4.4\n", pmum ); 298 murg2 = murg ; 299 i( dsdp -> p ==1){ 300 murg2 = pmum ; 303 murg2 = murg ; 304 murg2 = ( p )* murg + (1.0-p)* dsdp -> mu ; 305 murg2 = ( p )* pmum + (1.0-p)* dsdp -> mu ; 308 murg2 = `DSDPMax ( dsdp -> mu /dsdp-> rh ,mutarget2); 309 i( dsdp -> mu0 >0){ murg2 = `DSDPM (mutarget2,dsdp->mu0);} 311 * xtmurg = murg2 ; 312 `DSDPFuniRu (0); 313 } } 315 #unde __FUNCT__ 316  #__FUNCT__ "DSDPRetY0" ) 323  $DSDPRetY0 ( DSDP dsdp ){ 324  fo ; 325  r , , dd ; 326 DSDPTruth psdefe ; 327 DSDPFuniBeg ; 328 fo = `DSDPCompuDY ( dsdp ,dsdp-> murg ,dsdp-> dy ,&dsdp-> m ); `DSDPCHKERR (info); 329 fo = `DSDPVecCy ( dsdp -> y0 ,dsdp-> y ); `DSDPCHKERR (info); 330 fo = `DSDPGRR ( dsdp ,& r ); `DSDPCHKERR (info); 331 = `DSDPMax ( r *10000,1e12); 332 fo = `DSDPSRR ( dsdp , ); `DSDPCHKERR (info); 333 fo = `DSDPCompuSS ( dsdp ,dsdp-> y , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 334 fo = `DSDPCompuLogSDmt ( dsdp ,&dsdp-> logd ); `DSDPCHKERR (info); 335 fo = `DSDPSY ( dsdp ,1.0,dsdp-> logd ,dsdp-> y ); `DSDPCHKERR (info); 336 fo = `DSDPVecGR ( dsdp -> b ,& dd ); `DSDPCHKERR (info); 338 dsdp -> murg = `bs ( * dd ); 339 dsdp -> mu = `bs ( * dd ); 342 dsdp -> gy0 = DSDP_TRUE ; 343 `DSDPLogInfo (0,2,"Restartlgorithm\n"); 344 `DSDPFuniRu (0); 345 } } 364 #unde __FUNCT__ 365  #__FUNCT__ "DSDPCompuDuSpDeis" ) 366  $DSDPCompuDuSpDeis ( DSDP dsdp ){ 367  fo , compum =1; 368  madd , ymax , cgt =1e-7; 369 DSDPTruth cg1 , cg2 , psdefe ; 370 DSDPFuniBeg ; 372 i( dsdp -> now >30dsdp-> ey =3; 373 i( dsdp -> rg <1e-3dsdp-> ey =3; 374 i( dsdp -> m <40dsdp-> ey =3; 375 i(0 && dsdp -> now >20 && dsdp-> m <500dsdp-> ey =3; 376 fo = `DSDPGMaxYEmt ( dsdp ,& ymax ); `DSDPCHKERR (info); 377 i( dsdp -> ey ==1){ 378 cg1 = DSDP_TRUE ; cg2 =DSDP_TRUE; 379 fo = `DSDPInvtS ( dsdp ); `DSDPCHKERR (info); 380 fo = `DSDPCompuG ( dsdp ,dsdp-> rhemp ,dsdp-> rhs1 ,dsdp-> rhs2 ); `DSDPCHKERR (info); 381 fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs1 ,dsdp-> dy1 , cgt ,& cg1 ); `DSDPCHKERR (info); 382 i( cg1 == DSDP_TRUE ){ fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs2 ,dsdp-> dy2 , cgt ,& cg2 ); `DSDPCHKERR (info);} 383 i( cg1 == DSDP_FALSE || cg2 ==DSDP_FALSE dsdp -> ey =2; 385 i( dsdp -> ey ==2){ 386 cg1 = DSDP_TRUE ; cg2 =DSDP_TRUE; 387 `DSDPLogInfo (0,9,"Compute Hessian\n"); 388 fo = `DSDPInvtS ( dsdp ); `DSDPCHKERR (info); 389 fo = `DSDPCompuHessn ( dsdp ,dsdp-> M ,dsdp-> rhs1 ,dsdp-> rhs2 ); `DSDPCHKERR (info); 390 compum =0; 391 `DSDPLogInfo (0,9,"Apply CG\n"); 392 fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs1 ,dsdp-> dy1 , cgt ,& cg1 ); `DSDPCHKERR (info); 393 i( cg1 == DSDP_TRUE ){ fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs2 ,dsdp-> dy2 , cgt ,& cg2 ); `DSDPCHKERR (info);} 394 i( cg1 == DSDP_FALSE || cg2 ==DSDP_FALSE dsdp -> ey =3; 397 i( dsdp -> ey ==3){ 398 `DSDPLogInfo (0,9,"Factor Hessian\n"); 399 psdefe = DSDP_FALSE ; 400 i( dsdp -> Mshi < 1e-12 || dsdp-> rg <0.1 || dsdp->Mshift > 1e-6){ 401 madd = dsdp -> Mshi ; 403 madd =1e-13; 405 i( compum ){ 406 fo = `DSDPInvtS ( dsdp ); `DSDPCHKERR (info); 408  psdefe == DSDP_FALSE ){ 409 i(0==1 && dsdp -> Mshi >dsdp-> maxschurshi ){ 410 fo = `DSDPSCvgFg ( dsdp , DSDP_INDEFINITE_SCHUR_MATRIX ); `DSDPCHKERR (info); 413 i(0 && dsdp -> Mshi * ymax >dsdp-> pa /10){ 414 fo = `DSDPSCvgFg ( dsdp , DSDP_INDEFINITE_SCHUR_MATRIX ); `DSDPCHKERR (info); 417 i( madd * ymax > dsdp -> pa *1000){ 418 fo = `DSDPSCvgFg ( dsdp , DSDP_INDEFINITE_SCHUR_MATRIX ); `DSDPCHKERR (info); 421 i( compum ){ 422 fo = `DSDPCompuHessn ( dsdp ,dsdp-> M ,dsdp-> rhs1 ,dsdp-> rhs2 ); `DSDPCHKERR (info);} 423 i(0==1){ fo = `DSDPSchurMVw ( dsdp -> M ); `DSDPCHKERR (info);} 424 fo = `DSDPSchurMShiDgڮ ( dsdp -> M , madd ); `DSDPCHKERR (info); 425 fo = `DSDPSchurMFa ( dsdp -> M ,& psdefe ); `DSDPCHKERR (info); 426 compum =1; 427 i( psdefe == DSDP_FALSE ){ 428 madd =madd*4 + 1.0e-13; 431 dsdp -> Mshi = madd ; 432 i( psdefe == DSDP_TRUE ){ 433 fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs1 ,dsdp-> dy1 , cgt ,& cg1 ); `DSDPCHKERR (info); 434 fo = `DSDPCGSve ( dsdp ,dsdp-> M ,dsdp-> rhs2 ,dsdp-> dy2 , cgt ,& cg2 ); `DSDPCHKERR (info); 438 `DSDPFuniRu (0); 439 } } 440 #unde __FUNCT__ 441  #__FUNCT__ "DSDPCompuDuSpDeis" ) 442  $DSDPRefeSpDei ( DSDP dsdp , DSDPVec rhs , DSDPVe dy ){ 443  fo ; 444  cgt =1e-20; 445 DSDPTruth cg1 ; 446 DSDPFuniBeg ; 448 i( dsdp -> as == DSDP_INDEFINITE_SCHUR_MATRIX ){ 449 } i( dsdp -> as == DSDP_SMALL_STEPS ){ 450 } i( dsdp -> p <1){ 452 dsdp -> ey =4; 453 fo = `DSDPCGSve ( dsdp ,dsdp-> M , rhs , dy , cgt ,& cg1 ); `DSDPCHKERR (info); 454 dsdp -> ey =3; 457 `DSDPFuniRu (0); 458 } } 460  ~"dsdp5.h " 463 #unde __FUNCT__ 464  #__FUNCT__ "DSDPInlizeVbs" ) 471  $DSDPInlizeVbs DSDP dsdp ){ 473  fo ; 474  r0 , murg = dsdp ->murg, y ; 475 DSDPTruth psdefe = DSDP_FALSE ; 477 DSDPFuniBeg ; 478 fo = `DSDPGRR ( dsdp ,& r0 ); `DSDPCHKERR (info); 479 dsdp -> rho =dsdp-> *dsdp-> rh ; 480 i( r0 >=0) { 481 fo = `DSDPCompuObjeive ( dsdp ,dsdp-> y ,&dsdp-> ddobj ); `DSDPCHKERR (info); 482 fo = `DSDPCompuSS ( dsdp ,dsdp-> y , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 483 i( murg <0murg=( dsdp -> obj -dsdp-> ddobj )/(dsdp-> rho ); 485 fo = `DSDPGPty ( dsdp ,& y ); `DSDPCHKERR (info); 486 r0 =0.1/(1.0+ dsdp -> m ); 487  psdefe == DSDP_FALSE ){ 488 r0 =r0*100; 489 `DSDPLogInfo (0,9,"S InR0 %4.2e\n", r0 ); 490 fo = `DSDPSRR ( dsdp , r0 ); `DSDPCHKERR (info); 491 fo = `DSDPCompuSS ( dsdp ,dsdp-> y , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 493 r0 0* dsdp -> ; 494 i( dsdp -> m >0 && dsdp-> m >0 && dsdp->m/dsdp->m<1){ r0 =r0/(dsdp->cnorm/dsdp->anorm);} 495 dsdp -> mu = r0 * y ; 496 i( murg <0){ 497 murg =( dsdp -> obj -dsdp-> ddobj )/(dsdp-> rho ); 498 murg =( dsdp -> obj -dsdp-> ddobj )/(dsdp-> ); 499 murg = r0 * y ; 501 `DSDPLogInfo (0,9,"S InR0 %4.2e\n", r0 ); 502 fo = `DSDPSRR ( dsdp , r0 ); `DSDPCHKERR (info); 503 fo = `DSDPCompuObjeive ( dsdp ,dsdp-> y ,&dsdp-> ddobj ); `DSDPCHKERR (info); 504 fo = `DSDPCompuSS ( dsdp ,dsdp-> y , DUAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 506 fo = `DSDPCompuObjeive ( dsdp ,dsdp-> y ,&dsdp-> ddobj ); `DSDPCHKERR (info); 507 i( psdefe == DSDP_FALSE ){ 508 fo = `DSDPSCvgFg ( dsdp , DSDP_INFEASIBLE_START ); `DSDPCHKERR (info); 510 fo = `DSDPCompuLogSDmt ( dsdp ,&dsdp-> logd ); `DSDPCHKERR (info); 511 fo = `DSDPCompuPْtl ( dsdp ,dsdp-> y ,dsdp-> logd ,&dsdp-> pْtl ); `DSDPCHKERR (info); 514 fo = `DSDPSY ( dsdp ,0,dsdp-> logd ,dsdp-> y ); `DSDPCHKERR (info); 515 fo = `DSDPSaveYFX ( dsdp ,dsdp-> xmak [0]. mu ,0); `DSDPCHKERR (info); 516 dsdp -> murg =mutarget; 517 dsdp -> p =0.0; 518 dsdp -> m =0; 520 `DSDPFuniRu (0); 521 } } 534 #unde __FUNCT__ 535  #__FUNCT__ "DSDPCompuAndFaS" ) 536  $DSDPCompuAndFaS ( DSDP dsdp , DSDPTruth * psdefe ){ 537  fo ; 538 DSDPFuniBeg ; 539 fo = `DSDPCompuSS ( dsdp ,dsdp-> y , DUAL_FACTOR , psdefe ); `DSDPCHKERR (info); 540 `DSDPFuniRu (0); 541 } } @dualimpl.c 1  ~"dsdp.h " 2  ~"dsdpsys.h " 20 #unde __FUNCT__ 21  #__FUNCT__ "DSDPCompuObjeive" ) 22  $DSDPCompuObjeive ( DSDP dsdp , DSDPVec Y , * ddobj ){ 23  fo ; 24 DSDPFuniBeg ; 25 fo = `DSDPVecD ( Y , dsdp -> b , ddobj ); `DSDPCHKERR (info); 26 `DSDPFuniRu (0); 27 } } 45 #unde __FUNCT__ 46  #__FUNCT__ "DSDPCompuDY" ) 47  $DSDPCompuDY ( DSDP dsdp ,  mu , DSDPVec DY , * m ){ 48  fo ; 49  nm , ddy1 = `bs (1.0/ mu * dsdp -> schurmu ), ddy2 =-1.0; 50 DSDPFuniBeg ; 51 fo = `DSDPCompuRHS ( dsdp , mu ,dsdp-> rhs ); `DSDPCHKERR (info); 52 fo = `DSDPVecWAXPBY ( DY , ddy1 , dsdp -> dy1 , ddy2 ,dsdp-> dy2 ); `DSDPCHKERR (info); 53 fo = `DSDPCompuPNm ( dsdp , mu , DY ,& nm ); `DSDPCHKERR (info); 54 i( nm <0){ 55 `DSDPLogInfo (0,2,"Probm wh PNORM: %4.4< 0 \n", nm ); 58 * m = nm ; 59 `DSDPFuniRu (0); 60 } } 78 #unde __FUNCT__ 79  #__FUNCT__ "DSDPCompuPDY" ) 80  $DSDPCompuPDY ( DSDP dsdp ,  mu , DSDPVec DY , * m ){ 81  fo ; 82  nm , ddy1 =- `bs (1.0/ mu * dsdp -> schurmu ), ddy2 =1.0; 83 DSDPFuniBeg ; 84 fo = `DSDPCompuRHS ( dsdp , mu ,dsdp-> rhs ); `DSDPCHKERR (info); 85 fo = `DSDPVecWAXPBY ( DY , ddy1 , dsdp -> dy1 , ddy2 ,dsdp-> dy2 ); `DSDPCHKERR (info); 86 fo = `DSDPCompuPNm ( dsdp , mu , DY ,& nm ); `DSDPCHKERR (info); 87 i( nm <0){ 88 `DSDPLogInfo (0,2,"Probm wh PNORM: %4.4< 0 \n", nm ); 91 * m = nm ; 92 `DSDPFuniRu (0); 93 } } 108 #unde __FUNCT__ 109  #__FUNCT__ "DSDPCompuPDY1" ) 110  $DSDPCompuPDY1 ( DSDP dsdp ,  mur , DSDPVec DY1 ){ 111  fo ; 112  ddy1 =- `bs ( mur * dsdp -> schurmu ); 113 DSDPFuniBeg ; 114 fo = `DSDPVecSCy ( dsdp -> dy1 , ddy1 , DY1 ); `DSDPCHKERR (info); 115 `DSDPFuniRu (0); 116 } } 130 #unde __FUNCT__ 131  #__FUNCT__ "DSDPCompuNewY" ) 132  $DSDPCompuNewY ( DSDP dsdp ,  ba , DSDPVec Y ){ 133  fo ; 134  emp ; 135 DSDPFuniBeg ; 136 fo = `DSDPVecWAXPY ( Y , ba , dsdp -> dy ,dsdp-> y ); `DSDPCHKERR (info); 137 fo = `DSDPVecGR ( Y ,& emp ); `DSDPCHKERR (info); 138 emp = `DSDPM (0,rtemp); 139 fo = `DSDPSchurMSR ( dsdp -> M , emp ); `DSDPCHKERR (info); 140 fo = `DSDPVecSR ( Y , emp ); `DSDPCHKERR (info); 141 fo = `DSDPAlyFixedVbs ( dsdp -> M , Y ); `DSDPCHKERR (info); 142 `DSDPFuniRu (0); 143 } } 157 #unde __FUNCT__ 158  #__FUNCT__ "DSDPCompuPY" ) 159  $DSDPCompuPY ( DSDP dsdp ,  ba , DSDPVec PY ){ 160  fo ; 161 DSDPFuniBeg ; 162 fo = `DSDPVecWAXPY ( PY , ba , dsdp -> dy ,dsdp-> y ); `DSDPCHKERR (info); 163 fo = `DSDPAlyFixedVbs ( dsdp -> M , PY ); `DSDPCHKERR (info); 164 `DSDPFuniRu (0); 165 } } 186 #unde __FUNCT__ 187  #__FUNCT__ "DSDPCompuRHS" ) 188  $DSDPCompuRHS ( DSDP dsdp ,  mu , DSDPVec RHS ){ 189  fo ; 190  ddrhs1 =1.0/ mu * dsdp -> schurmu , ddrhs2 =-mu/ `bs (mu) ); 191 DSDPFuniBeg ; 192 fo = `DSDPVecWAXPBY ( RHS , ddrhs1 , dsdp -> rhs1 , ddrhs2 ,dsdp-> rhs2 ); `DSDPCHKERR (info); 193 `DSDPFuniRu (0); 194 } } 196 #unde __FUNCT__ 197  #__FUNCT__ "DSDPCompuPNm" ) 198  $DSDPCompuPNm ( DSDP dsdp ,  mu , DSDPVec DY , * m ){ 199  fo ; 200  nm =0; 201 DSDPFuniBeg ; 202 fo = `DSDPCompuRHS ( dsdp , mu ,dsdp-> rhs ); `DSDPCHKERR (info); 203 fo = `DSDPVecD ( dsdp -> rhs , DY ,& nm ); `DSDPCHKERR (info); 204 nm /= dsdp -> schurmu ; 205 i( nm >= 0){ 206 * m = `sq ( nm ); 208 `DSDPLogInfo (0,2,"Probm wh PNORM: %4.4inمosive.\n", nm ); 209 * m = nm ; 211 i(* m !=*m){ `DSDPSETERR1 (1,"Probm wh PNORM: %4.4inمosive.\n", nm );} 212 `DSDPFuniRu (0); 213 } } 227 #unde __FUNCT__ 228  #__FUNCT__ "DSDPCompuDuyG" ) 229  $DSDPCompuDuyG ( DSDP dsdp ,  mu , * g ){ 230  fo ; 231  wg =0, m ; 232  smu =1.0/ dsdp -> schurmu ; 233 DSDPFuniBeg ; 234 fo = `DSDPCompuDY ( dsdp , mu ,dsdp-> dy ,& m ); `DSDPCHKERR (info); 235 fo = `DSDPVecD ( dsdp -> dy ,dsdp-> rhs2 ,& wg ); `DSDPCHKERR (info); 236 wg = (wg* smu + dsdp -> )* mu ; 237 i( wg <=0){ 238 `DSDPLogInfo (0,2,"GAP :%4.4e<0: Probm\n", wg ); 240 `DSDPLogInfo (0,2,"Duy G: %12.8e, Updim objeive: %12.8e\n", wg , dsdp -> ddobj +newgap); 242 wg = `DSDPMax (0,newgap); 243 * g = wg ; 244 `DSDPFuniRu (0); 245 } } 259 #unde __FUNCT__ 260  #__FUNCT__ "DSDPCompuPْtl" ) 261  $DSDPCompuPْtl ( DSDP dsdp , DSDPVec y ,  logd , * pْtl ){ 262  fo ; 263  dpْtl , g , ddobj ; 264 DSDPFuniBeg ; 265 fo = `DSDPCompuObjeive ( dsdp , y ,& ddobj ); `DSDPCHKERR (info); 266 g = dsdp -> obj - ddobj ; 267 i( g >0 dpْtl = dsdp -> rho * `log (g)- logd ; 268 { dpْtl = dsdp -> pْtl +1;} 269 * pْtl = dpْtl ; 270 `DSDPLogInfo (0,9,"G: %4.4e, Log Dmt: %4.4e, Log G: %4.4e\n", g , logd , `log (gap)); 271 `DSDPFuniRu (0); 272 } } 287 #unde __FUNCT__ 288  #__FUNCT__ "DSDPCompuPْtl2" ) 289  $DSDPCompuPْtl2 ( DSDP dsdp , DSDPVec y ,  mu ,  logd , * pْtl ){ 290  fo ; 291  ddobj ; 292 DSDPFuniBeg ; 293 fo = `DSDPCompuObjeive ( dsdp , y ,& ddobj ); `DSDPCHKERR (info); 294 * pْtl =-( ddobj + mu * logd )* dsdp -> schurmu ; 295 * pْtl =-( ddobj / mu + logd )* dsdp -> schurmu ; 296 `DSDPFuniRu (0); 297 } } 311 #unde __FUNCT__ 312  #__FUNCT__ "DSDPSY" ) 313  $DSDPSY ( DSDP dsdp ,  ba ,  logd , DSDPVec yw ){ 314  fo ; 315  r1 , r2 , , ; 316 DSDPFuniBeg ; 317 fo = `DSDPVecGR ( dsdp -> y ,& r1 ); `DSDPCHKERR (info); 318 fo = `DSDPVecGR ( yw ,& r2 ); `DSDPCHKERR (info); 319 i( r2 ==0&& r1 !=0){ dsdp -> rag =1;} {dsdp->rflag=0;}; 320 fo = `DSDPVecCy ( yw , dsdp -> y ); `DSDPCHKERR (info); 321 fo = `DSDPCompuObjeive ( dsdp ,dsdp-> y ,&dsdp-> ddobj ); `DSDPCHKERR (info); 323 i( dsdp -> obj <=dsdp-> ddobj ){ 324 dsdp -> obj =dsdp-> ddobj +2*dsdp-> mu * dsdp-> ; 325 `DSDPLogInfo (0,2,"Prim ObjeivN Right. Assigd: %8.8e\n", dsdp -> obj ); 327 fo = `DSDPVecGR ( yw ,& ); `DSDPCHKERR (info); 328 fo = `DSDPVecGR ( dsdp -> b ,& ); `DSDPCHKERR (info); 329 dsdp -> dobj =dsdp-> ddobj - * ; 330 `DSDPLogInfo (0,2,"Duy G: %4.4e, Pْtl: %4.4\n", dsdp -> duyg ,dsdp-> pْtl ); 331 dsdp -> duyg =dsdp-> obj -dsdp-> ddobj ; 332 dsdp -> mu =(dsdp-> duyg )/(dsdp-> ); 333 dsdp -> d = ba ; 334 dsdp -> logd =logdet; 335 fo = `DSDPCompuPْtl ( dsdp ,dsdp-> y ,dsdp-> logd ,&dsdp-> pْtl ); `DSDPCHKERR (info); 336 `DSDPLogInfo (0,2,"Duy G: %4.4e, Pْtl: %4.4\n", dsdp -> duyg ,dsdp-> pْtl ); 337 `DSDPFuniRu (0); 338 } } 340 #unde __FUNCT__ 341  #__FUNCT__ "DSDPSaveBackupYFX" ) 342  $DSDPSaveBackupYFX ( DSDP dsdp ,  cou , mu ,  p ){ 343  fo ; 344  m ; 345 DSDPFuniBeg ; 346 fo = `DSDPVecCy ( dsdp -> y ,dsdp-> xmak [ cou ].y); `DSDPCHKERR (info); 347 fo = `DSDPCompuDY ( dsdp , mu ,dsdp-> xmak [ cou ]. dy ,& m ); `DSDPCHKERR (info); 348 dsdp -> xmak [ cou ]. p =pstep; 349 dsdp -> xmak [ cou ]. mu = mu; 350 `DSDPFuniRu (0); 351 } } 363 #unde __FUNCT__ 364  #__FUNCT__ "DSDPSaveYFX" ) 365  $DSDPSaveYFX ( DSDP dsdp ,  mu ,  p ){ 366  fo ; 367  m , wg , ymax ; 368 DSDPFuniBeg ; 369 fo = `DSDPGMaxYEmt ( dsdp ,& ymax ); `DSDPCHKERR (info); 370 i( p ==0){ 371 fo = `DSDPVecCy ( dsdp -> y ,dsdp-> xmak [0].y); `DSDPCHKERR (info); 372 dsdp -> xmak [0]. p =pstep; 373 } i( dsdp -> Mshi * ymax >dsdp-> pa *10){ 374 fo = `DSDPCompuDuyG ( dsdp , mu ,& wg ); `DSDPCHKERR (info); 375 i( p ==1 && wg >0){ 376 dsdp -> obj = dsdp-> ddobj + wg ; dsdp-> mu =ewg)/(dsdp-> ); 377 dsdp -> duyg = wg ; 381 fo = `DSDPVecCy ( dsdp -> y ,dsdp-> xmak [0].y); `DSDPCHKERR (info); 382 dsdp -> xmak [0]. p =pstep; 383 fo = `DSDPCompuRHS ( dsdp , mu ,dsdp-> xmakrhs ); `DSDPCHKERR (info); 384 fo = `DSDPCompuDY ( dsdp , mu ,dsdp-> xmak [0]. dy ,& m ); `DSDPCHKERR (info); 385 dsdp -> xmak [0]. mu = mu; 386 fo = `DSDPCompuDuyG ( dsdp , mu ,& wg ); `DSDPCHKERR (info); 387 i( p ==1 && wg >0){ 388 dsdp -> obj = dsdp-> ddobj + wg ; dsdp-> mu =ewg)/(dsdp-> ); 389 dsdp -> duyg = wg ; 393 i( p ==1.0 && dsdp -> rg >5.0e-1) { 394 fo = `DSDPSaveBackupYFX ( dsdp , MAX_XMAKERS -1, mu , p ); `DSDPCHKERR (info); 396 i( p ==1.0 && dsdp -> rg >1.0e-3) { 397 fo = `DSDPSaveBackupYFX ( dsdp ,2, mu , p ); `DSDPCHKERR (info); 399 i( p ==1.0 && dsdp -> rg >1.0e-5) { 400 fo = `DSDPSaveBackupYFX ( dsdp ,1, mu , p ); `DSDPCHKERR (info); 403 `DSDPFuniRu (0); 404 } } 406 #unde __FUNCT__ 407  #__FUNCT__ "DSDPSRR" ) 414  $DSDPSRR ( DSDP dsdp , s ){ 415  fo ; 416 DSDPFuniBeg ; 417 `DSDPVid ( dsdp ); 418 fo = `DSDPVecSR ( dsdp -> y ,- s ); `DSDPCHKERR (info); 419 `DSDPFuniRu (0); 420 } } 422 #unde __FUNCT__ 423  #__FUNCT__ "DSDPGRR" ) 430  $DSDPGRR ( DSDP dsdp ,* s ){ 431  fo ; 432 DSDPFuniBeg ; 433 `DSDPVid ( dsdp ); 434 fo = `DSDPVecGR ( dsdp -> y , s ); `DSDPCHKERR (info); 435 * s =-*res; 436 i(* s ==0) *res=0; 437 `DSDPFuniRu (0); 438 } } 441 #unde __FUNCT__ 442  #__FUNCT__ "DSDPObjeiveGH" ) 443  $DSDPObjeiveGH DSDP dsdp , DSDPSchurM M , DSDPVec vrhs1 ){ 444  i , fo , m ; 445  emp , dd ; 447 DSDPFuniBeg ; 448 fo = `DSDPVecGSize ( vrhs1 ,& m ); `DSDPCHKERR (info); 449  i =0;i< m ;i++){ 450 fo = `DSDPSchurMVbCompu ( M , i ,& dd ); `DSDPCHKERR (info); 451 i( dd ){ 452 fo = `DSDPVecGEmt ( dsdp -> b , i ,& emp ); `DSDPCHKERR (info); 453 fo = `DSDPVecAddEmt ( vrhs1 , i , emp ); `DSDPCHKERR (info); 456 `DSDPFuniRu (0); 457 } } 459 #unde __FUNCT__ 460  #__FUNCT__ "DSDPCheckFUnboundedObjeive" ) 461  $DSDPCheckFUnboundedObjeive ( DSDP dsdp , DSDPTruth * unbounded ){ 462  fo ; 463  dmp ; 464 DSDPTruth psdefe ; 465 DSDPFuniBeg ; 466 * unbounded = DSDP_FALSE ; 467 fo = `DSDPVecD ( dsdp -> b ,dsdp-> dy2 ,& dmp ); `DSDPCHKERR (info); 468 i dmp < 0 ) { 469 fo = `DSDPVecSCy ( dsdp -> dy2 ,-1.0,dsdp-> ymp ); `DSDPCHKERR (info); 470 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , PRIMAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 471 i( psdefe = DSDP_TRUE ){ 472 psdefe = DSDP_FALSE ; 473  psdefe == DSDP_FALSE ){ 474 fo = `DSDPCompuSS ( dsdp ,dsdp-> ymp , PRIMAL_FACTOR ,& psdefe ); `DSDPCHKERR (info); 475 i( psdefe = DSDP_TRUE ) ; 476 fo = `DSDPVecS (2.0, dsdp -> ymp ); `DSDPCHKERR (info); 478 fo = `DSDPVecCy ( dsdp -> ymp ,dsdp-> y ); `DSDPCHKERR (info); 479 fo = `DSDPSaveYFX ( dsdp ,1.0e-12,1.0); `DSDPCHKERR (info); 480 fo = `DSDPCompuObjeive ( dsdp ,dsdp-> y ,&dsdp-> ddobj ); `DSDPCHKERR (info); 481 fo = `DSDPVecNmize ( dsdp -> y ); `DSDPCHKERR (info); 482 * unbounded = DSDP_TRUE ; 485 `DSDPFuniRu (0); 486 } } @/usr/include/math.h 24 #idef _MATH_H 25  #_MATH_H 1 ) 27  ~ 29 g__BEGIN_DECLS 33  ~ 36 #ifdef __USE_ISOC99 37  ~ 40  ~ 48  #__MATHCALL ( funi , suffix , gs ) \ 49 `__MATHDECL ( _Mdoub_ , funi , suffix , gs ) ) 50  #__MATHDECL ( ty , funi , suffix , gs ) \ 51 `__MATHDECL_1 ( ty , funi , suffix , gs ); \ 52 `__MATHDECL_1 ( ty , `__CONCAT ( __ , funi ), suffix , gs ) ) 53  #__MATHCALLX ( funi , suffix , gs , ib ) \ 54 `__MATHDECLX ( _Mdoub_ , funi , suffix , gs , ib ) ) 55  #__MATHDECLX ( ty , funi , suffix , gs , ib ) \ 56 `__MATHDECL_1 ( ty , funi , suffix , gs `__ibu__ ( ib ); \ 57 `__MATHDECL_1 ( ty , `__CONCAT ( __ , funi ), suffix , gs `__ibu__ ( ib ) ) 58  #__MATHDECL_1 ( ty , funi , suffix , gs ) \ 59 ty `__MATH_PRECNAME ( funi , suffix gs __THROW ) 61  #_Mdoub_  ) 62  #__MATH_PRECNAME ( me , r `__CONCAT ame,r) ) 63  #_Mdoub_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD ) 64  #_Mdoub_END_NAMESPACE __END_NAMESPACE_STD ) 65  ~ 66 #unde _Mdoub_ 67 #unde _Mdoub_BEGIN_NAMESPACE 68 #unde _Mdoub_END_NAMESPACE 69 #unde __MATH_PRECNAME 71 #i defed __USE_MISC || defed __USE_ISOC99 77 #ide _Mt_ 78  #_Mt_  ) 80  #_Mdoub_ _Mt_ ) 81 #ifde __STDC__ 82  #__MATH_PRECNAME ( me , r me## f ## ) r 84  #__MATH_PRECNAME ( me , r m f ) r 86  #_Mdoub_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99 ) 87  #_Mdoub_END_NAMESPACE __END_NAMESPACE_C99 ) 88  ~ 89 #unde _Mdoub_ 90 #unde _Mdoub_BEGIN_NAMESPACE 91 #unde _Mdoub_END_NAMESPACE 92 #unde __MATH_PRECNAME 94 #i( __STDC__ - 0 || __GNUC__ - 0&& ! defed __NO_LONG_DOUBLE_MATH 98 #ide _Mlg_doub_ 99  #_Mlg_doub_  ) 101  #_Mdoub_ _Mlg_doub_ ) 102 #ifde __STDC__ 103  #__MATH_PRECNAME ( me , r me## l ## ) r 105  #__MATH_PRECNAME ( me , r m l ) r 107  #_Mdoub_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99 ) 108  #_Mdoub_END_NAMESPACE __END_NAMESPACE_C99 ) 109  ~ 110 #unde _Mdoub_ 111 #unde _Mdoub_BEGIN_NAMESPACE 112 #unde _Mdoub_END_NAMESPACE 113 #unde __MATH_PRECNAME 118 #unde __MATHDECL_1 119 #unde __MATHDECL 120 #unde __MATHCALL 123 #i defed __USE_MISC || defed __USE_XOPEN 125  signgam ; 130 #i __USE_ISOC99 168 mFP_NAN , 169  #FP_NAN FP_NAN ) 170 mFP_INFINITE , 171  #FP_INFINITE FP_INFINITE ) 172 mFP_ZERO , 173  #FP_ZERO FP_ZERO ) 174 mFP_SUBNORMAL , 175  #FP_SUBNORMAL FP_SUBNORMAL ) 176 mFP_NORMAL 177  #FP_NORMAL FP_NORMAL ) 181 #ifde __NO_LONG_DOUBLE_MATH 182  #assify ( x ) \ 183 ( ( x = (? `__assifyf (x: `__assify (x)) ) 185  #assify ( x ) \ 186 ( ( x ) ==  () \ 187 ? `__assifyf ( x ) \ 188 :  ( x ) ==  () \ 189 ? `__assify ( x : `__assifyl (x)) ) 193 #ifde __NO_LONG_DOUBLE_MATH 194  #signb ( x ) \ 195 ( ( x = (? `__signbf (x: `__signb (x)) ) 197  #signb ( x ) \ 198 ( ( x ) ==  () \ 199 ? `__signbf ( x ) \ 200 :  ( x ) ==  () \ 201 ? `__signb ( x : `__signbl (x)) ) 205 #ifde __NO_LONG_DOUBLE_MATH 206  #isfe ( x ) \ 207 ( ( x = (? `__fef (x: `__fe (x)) ) 209  #isfe ( x ) \ 210 ( ( x ) ==  () \ 211 ? `__fef ( x ) \ 212 :  ( x ) ==  () \ 213 ? `__fe ( x : `__f (x)) ) 217  #im ( x ( `assify (x= FP_NORMAL ) ) 221 #ifde __NO_LONG_DOUBLE_MATH 222  #i ( x ) \ 223 ( ( x = (? `__if (x: `__i (x)) ) 225  #i ( x ) \ 226 ( ( x ) ==  () \ 227 ? `__if ( x ) \ 228 :  ( x ) ==  () \ 229 ? `__i ( x : `__il (x)) ) 233 #ifde __NO_LONG_DOUBLE_MATH 234  #isf ( x ) \ 235 ( ( x = (? `__isff (x: `__isf (x)) ) 237  #isf ( x ) \ 238 ( ( x ) ==  () \ 239 ? `__isff ( x ) \ 240 :  ( x ) ==  () \ 241 ? `__isf ( x : `__is (x)) ) 245  #MATH_ERRNO 1 ) 246  #MATH_ERREXCEPT 2 ) 250 #ifdef __USE_MISC 254 m_IEEE_ = -1, 255 m_SVID_ , 256 m_XOPEN_ , 257 m_POSIX_ , 258 m_ISOC_ 259 } t_LIB_VERSION_TYPE ; 264 _LIB_VERSION_TYPE _LIB_VERSION ; 268 #ifde __USE_SVID 274 #ifde __lulus 275  g__exi 277  gexi 280  gty ; 281 * gme ; 282  gg1 ; 283  gg2 ; 284  gtv ; 287 #ifde __lulus 288  $mhr ( __exi * __exc `throw (); 290  `mhr ( exi * __exc ); 293  #X_TLOSS 1.41484755040568800000e+16 ) 296  #DOMAIN 1 ) 297  #SING 2 ) 298  #OVERFLOW 3 ) 299  #UNDERFLOW 4 ) 300  #TLOSS 5 ) 301  #PLOSS 6 ) 304  #HUGE 3.40282347e+38F ) 308 #ifde __USE_XOPEN 310  #MAXFLOAT 3.40282347e+38F ) 317 #i defed __USE_BSD || defed __USE_XOPEN 318  #M_E 2.7182818284590452354 ) 319  #M_LOG2E 1.4426950408889634074 ) 320  #M_LOG10E 0.43429448190325182765 ) 321  #M_LN2 0.69314718055994530942 ) 322  #M_LN10 2.30258509299404568402 ) 323  #M_PI 3.14159265358979323846 ) 324  #M_PI_2 1.57079632679489661923 ) 325  #M_PI_4 0.78539816339744830962 ) 326  #M_1_PI 0.31830988618379067154 ) 327  #M_2_PI 0.63661977236758134308 ) 328  #M_2_SQRTPI 1.12837916709551257390 ) 329  #M_SQRT2 1.41421356237309504880 ) 330  #M_SQRT1_2 0.70710678118654752440 ) 336 #ifde __USE_GNU 337  #M_El 2.7182818284590452353602874713526625L ) 338  #M_LOG2El 1.4426950408889634073599246810018921L ) 339  #M_LOG10El 0.4342944819032518276511289189166051L ) 340  #M_LN2l 0.6931471805599453094172321214581766L ) 341  #M_LN10l 2.3025850929940456840179914546843642L ) 342  #M_PIl 3.1415926535897932384626433832795029L ) 343  #M_PI_2l 1.5707963267948966192313216916397514L ) 344  #M_PI_4l 0.7853981633974483096156608458198757L ) 345  #M_1_PIl 0.3183098861837906715377675267450287L ) 346  #M_2_PIl 0.6366197723675813430755350534900574L ) 347  #M_2_SQRTPIl 1.1283791670955125738961589031215452L ) 348  #M_SQRT2l 1.4142135623730950488016887242096981L ) 349  #M_SQRT1_2l 0.7071067811865475244008443621048490L ) 356 #i defed __STRICT_ANSI__ && !defed __NO_MATH_INLINES 357  #__NO_MATH_INLINES 1 ) 361 #ifde __USE_EXTERN_INLINES 362  ~ 366 #i __USE_ISOC99 374 #ide isg 375  #isg ( x , y ) \ 376 ( __exnsi__ \ 377 ({ `__tyof__ ( x __x = (x); __tyof__( y __y = (y); \ 378 ! `isunded ( __x , __y && __x > __y; } })) ) 382 #ide isgequ 383  #isgequ ( x , y ) \ 384 ( __exnsi__ \ 385 ({ `__tyof__ ( x __x = (x); __tyof__( y __y = (y); \ 386 ! `isunded ( __x , __y && __x >__y; })) ) 390 #ide iess 391  #iess ( x , y ) \ 392 ( __exnsi__ \ 393 ({ `__tyof__ ( x __x = (x); __tyof__( y __y = (y); \ 394 ! `isunded ( __x , __y && __x < __y; })) ) 398 #ide iesqu 399  #iesqu ( x , y ) \ 400 ( __exnsi__ \ 401 ({ `__tyof__ ( x __x = (x); __tyof__( y __y = (y); \ 402 ! `isunded ( __x , __y && __x <__y; })) ) 406 #ide iessg 407  #iessg ( x , y ) \ 408 ( __exnsi__ \ 409 ({ `__tyof__ ( x __x = (x); __tyof__( y __y = (y); \ 410 ! `isunded ( __x , __y && (__x < __y || __y < __x); })) ) 414 #ide isunded 415  #isunded ( u , v ) \ 416 ( __exnsi__ \ 417 ({ `__tyof__ ( u __u = (u); __tyof__( v __v = (v); \ 418 `assify ( __u = FP_NAN || fpassify ( __v =FP_NAN; })) ) 423 g__END_DECLS @/usr/include/bits/huge_val.h 21 #ide _MATH_H 25  ~ 29 #i __GNUC_PREREQ (2,96) 30  #HUGE_VAL ( __exnsi__ 0x1.0 p2047 ) ) 32  #__HUGE_VAL_bys { 0, 0, 0, 0, 0, 0, 0xf0, 0x7} ) 34  #__huge_v_t uni {  __c [8];  __d ; } ) 35 #ifdef __GNUC__ 36  #HUGE_VAL ( __exnsi__ \ 37 (( __huge_v_t { __c : __HUGE_VAL_bys }). __d ) ) 39  __huge_v_t g__huge_v = { __HUGE_VAL_bys }; 40  #HUGE_VAL ( __huge_v . __d ) ) 47 #ifde __USE_ISOC99 49 #i __GNUC_PREREQ (2,96) 51  #HUGE_VALF ( __exnsi__ 0x1.0 p255f ) ) 52  #HUGE_VALL ( __exnsi__ 0x1.0 p32767L ) ) 56  #__HUGE_VALF_bys { 0, 0, 0x80, 0x7} ) 58  #__huge_vf_t uni {  __c [4];  __f ; } ) 59 #ifdef __GNUC__ 60  #HUGE_VALF ( __exnsi__ \ 61 (( __huge_vf_t { __c : __HUGE_VALF_bys }). __f ) ) 63  __huge_vf_t g__huge_vf = { __HUGE_VALF_bys }; 64  #HUGE_VALF ( __huge_vf . __f ) ) 68  #__HUGE_VALL_bys { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } ) 70  #__huge_vl_t uni {  __c [12];  __ld ; } ) 71 #ifde __GNUC__ 72  #HUGE_VALL ( __exnsi__ \ 73 (( __huge_vl_t { __c : __HUGE_VALL_bys }). __ld ) ) 75  __huge_vl_t g__huge_vl = { __HUGE_VALL_bys }; 76  #HUGE_VALL ( __huge_vl . __ld ) ) @/usr/include/bits/mathcalls.h 46 #ide _MATH_H 53 _Mdoub_BEGIN_NAMESPACE 55 __MATHCALL ( acos ,, ( _Mdoub_ __x )); 57 __MATHCALL ( as ,, ( _Mdoub_ __x )); 59 __MATHCALL ( ,, ( _Mdoub_ __x )); 61 __MATHCALL ( 2 ,, ( _Mdoub_ __y , _Mdoub_ __x )); 64 __MATHCALL ( cos ,, ( _Mdoub_ __x )); 66 __MATHCALL ( s ,, ( _Mdoub_ __x )); 68 __MATHCALL ( n ,, ( _Mdoub_ __x )); 73 __MATHCALL ( cosh ,, ( _Mdoub_ __x )); 75 __MATHCALL ( sh ,, ( _Mdoub_ __x )); 77 __MATHCALL ( nh ,, ( _Mdoub_ __x )); 78 g_Mdoub_END_NAMESPACE 80 #ifde __USE_GNU 82 __MATHDECL (, scos ,, 83 ( _Mdoub_ __x , _Mdoub_ * __sx , _Mdoub_ * __cosx )); 86 #i defed __USE_MISC || defed __USE_XOPEN_EXTENDED || defed __USE_ISOC99 87 __BEGIN_NAMESPACE_C99 89 __MATHCALL ( acosh ,, ( _Mdoub_ __x )); 91 __MATHCALL ( ash ,, ( _Mdoub_ __x )); 93 __MATHCALL ( h ,, ( _Mdoub_ __x )); 94 g__END_NAMESPACE_C99 99 _Mdoub_BEGIN_NAMESPACE 101 __MATHCALL ( exp ,, ( _Mdoub_ __x )); 104 __MATHCALL ( exp ,, ( _Mdoub_ __x , * __expڒt )); 107 __MATHCALL ( ldexp ,, ( _Mdoub_ __x ,  __expڒt )); 110 __MATHCALL ( log ,, ( _Mdoub_ __x )); 113 __MATHCALL ( log10 ,, ( _Mdoub_ __x )); 116 __MATHCALL ( modf ,, ( _Mdoub_ __x , _Mdoub_ * __ )); 117 g_Mdoub_END_NAMESPACE 119 #ifde __USE_GNU 121 __MATHCALL ( exp10 ,, ( _Mdoub_ __x )); 123 __MATHCALL ( pow10 ,, ( _Mdoub_ __x )); 126 #i defed __USE_MISC || defed __USE_XOPEN_EXTENDED || defed __USE_ISOC99 127 __BEGIN_NAMESPACE_C99 129 __MATHCALL ( expm1 ,, ( _Mdoub_ __x )); 132 __MATHCALL ( log1p ,, ( _Mdoub_ __x )); 135 __MATHCALL ( logb ,, ( _Mdoub_ __x )); 136 g__END_NAMESPACE_C99 139 #ifde __USE_ISOC99 140 __BEGIN_NAMESPACE_C99 142 __MATHCALL ( exp2 ,, ( _Mdoub_ __x )); 145 __MATHCALL ( log2 ,, ( _Mdoub_ __x )); 146 g__END_NAMESPACE_C99 152 _Mdoub_BEGIN_NAMESPACE 154 __MATHCALL ( pow ,, ( _Mdoub_ __x , _Mdoub_ __y )); 157 __MATHCALL ( sq ,, ( _Mdoub_ __x )); 158 g_Mdoub_END_NAMESPACE 160 #i defed __USE_MISC || defed __USE_XOPEN || defed __USE_ISOC99 161 __BEGIN_NAMESPACE_C99 163 __MATHCALL ( hyp ,, ( _Mdoub_ __x , _Mdoub_ __y )); 164 g__END_NAMESPACE_C99 167 #i defed __USE_MISC || defed __USE_XOPEN_EXTENDED || defed __USE_ISOC99 168 __BEGIN_NAMESPACE_C99 170 __MATHCALL ( cb ,, ( _Mdoub_ __x )); 171 g__END_NAMESPACE_C99 177 _Mdoub_BEGIN_NAMESPACE 179 __MATHCALLX ( ,, ( _Mdoub_ __x ), ( __cڡ__ )); 182 __MATHCALLX ( bs ,, ( _Mdoub_ __x ), ( __cڡ__ )); 185 __MATHCALLX ( o ,, ( _Mdoub_ __x ), ( __cڡ__ )); 188 __MATHCALL ( fmod ,, ( _Mdoub_ __x , _Mdoub_ __y )); 193 __MATHDECL_1 (, __isf ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 196 __MATHDECL_1 (, __fe ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 197 g_Mdoub_END_NAMESPACE 199 #ifde __USE_MISC 202 __MATHDECL_1 (, isf ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 205 __MATHDECL_1 (, fe ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 208 __MATHCALL ( dm ,, ( _Mdoub_ __x , _Mdoub_ __y )); 212 __MATHCALL ( signifind ,, ( _Mdoub_ __x )); 215 #i defed __USE_MISC || defed __USE_ISOC99 216 __BEGIN_NAMESPACE_C99 218 __MATHCALLX ( cysign ,, ( _Mdoub_ __x , _Mdoub_ __y ), ( __cڡ__ )); 219 g__END_NAMESPACE_C99 222 #ifde __USE_ISOC99 223 __BEGIN_NAMESPACE_C99 225 __MATHCALLX ( n ,, ( __cڡ * __gb ), ( __cڡ__ )); 226 g__END_NAMESPACE_C99 231 __MATHDECL_1 (, __i ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 233 #i defed __USE_MISC || defed __USE_XOPEN 235 __MATHDECL_1 (, i ,, ( _Mdoub_ __vue ) __ibu__ (( __cڡ__ )); 238 __MATHCALL ( j0 ,, ( _Mdoub_ )); 239 __MATHCALL ( j1 ,, ( _Mdoub_ )); 240 __MATHCALL ( jn ,, (, _Mdoub_ )); 241 __MATHCALL ( y0 ,, ( _Mdoub_ )); 242 __MATHCALL ( y1 ,, ( _Mdoub_ )); 243 __MATHCALL ( yn ,, (, _Mdoub_ )); 247 #i defed __USE_MISC || defed __USE_XOPEN || defed __USE_ISOC99 248 __BEGIN_NAMESPACE_C99 250 __MATHCALL ( f ,, ( _Mdoub_ )); 251 __MATHCALL ( fc ,, ( _Mdoub_ )); 252 __MATHCALL ( lgamma ,, ( _Mdoub_ )); 253 g__END_NAMESPACE_C99 256 #ifde __USE_ISOC99 257 __BEGIN_NAMESPACE_C99 259 __MATHCALL ( tgamma ,, ( _Mdoub_ )); 260 g__END_NAMESPACE_C99 263 #i defed __USE_MISC || defed __USE_XOPEN 265 __MATHCALL ( gamma ,, ( _Mdoub_ )); 268 #ifde __USE_MISC 272 __MATHCALL ( lgamma , _r , ( _Mdoub_ , * __signgamp )); 276 #i defed __USE_MISC || defed __USE_XOPEN_EXTENDED || defed __USE_ISOC99 277 __BEGIN_NAMESPACE_C99 280 __MATHCALL ( rt ,, ( _Mdoub_ __x )); 283 __MATHCALLX ( x ,, ( _Mdoub_ __x , _Mdoub_ __y ), ( __cڡ__ )); 284 #ifde __USE_ISOC99 285 __MATHCALLX ( xowd ,, ( _Mdoub_ __x ,  __y ), ( __cڡ__ )); 289 __MATHCALL ( mad ,, ( _Mdoub_ __x , _Mdoub_ __y )); 291 #i defed __USE_MISC || defed __USE_ISOC99 293 __MATHCALL ( slbn ,, ( _Mdoub_ __x ,  __n )); 297 __MATHDECL (, ogb ,, ( _Mdoub_ __x )); 300 #ifde __USE_ISOC99 302 __MATHCALL ( slb ,, ( _Mdoub_ __x ,  __n )); 306 __MATHCALL ( ìbyt ,, ( _Mdoub_ __x )); 310 __MATHCALLX ( round ,, ( _Mdoub_ __x ), ( __cڡ__ )); 314 __MATHCALLX ( unc ,, ( _Mdoub_ __x ), ( __cڡ__ )); 319 __MATHCALL ( mquo ,, ( _Mdoub_ __x , _Mdoub_ __y , * __quo )); 326 __MATHDECL (, ̚t ,, ( _Mdoub_ __x )); 327 __MATHDECL (, rt ,, ( _Mdoub_ __x )); 331 __MATHDECL (, ound ,, ( _Mdoub_ __x )); 332 __MATHDECL (, round ,, ( _Mdoub_ __x )); 336 __MATHCALL ( fdim ,, ( _Mdoub_ __x , _Mdoub_ __y )); 339 __MATHCALL ( fmax ,, ( _Mdoub_ __x , _Mdoub_ __y )); 342 __MATHCALL ( fm ,, ( _Mdoub_ __x , _Mdoub_ __y )); 346 __MATHDECL_1 (, __assify ,, ( _Mdoub_ __vue )) 347 __ibu__ (( __cڡ__ )); 350 __MATHDECL_1 (, __signb ,, ( _Mdoub_ __vue )) 351 __ibu__ (( __cڡ__ )); 355 __MATHCALL ( fma ,, ( _Mdoub_ __x , _Mdoub_ __y , _Mdoub_ __z )); 356 g__END_NAMESPACE_C99 358 #i defed __USE_MISC || defed __USE_XOPEN_EXTENDED 360 __MATHCALL ( slb ,, ( _Mdoub_ __x , _Mdoub_ __n )); @/usr/include/bits/mathdef.h 19 #i! defed _MATH_H && !defed _COMPLEX_H 23 #i defed __USE_ISOC99 && defed _MATH_H && !defed _MATH_H_MATHDEF 24  #_MATH_H_MATHDEF 1 ) 29  tt_t ; 31  tdoub_t ; 35  #INFINITY HUGE_VALF ) 38  #FP_ILOGB0 (-2147483647 - 1) ) 39  #FP_ILOGBNAN (-2147483647 - 1) ) @/usr/include/bits/mathinline.h 21 #ide _MATH_H 25 #ifde __lulus 26  #__MATH_INLINE __le ) 28  #__MATH_INLINE __le ) 32 #i defed __USE_ISOC99 && defed __GNUC__ && __GNUC__ >= 2 33 #i __GNUC_PREREQ (2,97) 35  #isg ( x , y `__but_isg (x, y) ) 36  #isgequ ( x , y `__but_isgequ (x, y) ) 37  #iess ( x , y `__but_iess (x, y) ) 38  #iesqu ( x , y `__but_iesqu (x, y) ) 39  #iessg ( x , y `__but_iessg (x, y) ) 40  #isunded ( x , y `__but_isunded (x, y) ) 46 #ifde __i686__ 49  #isg ( x , y ) \ 50 ({  __su ; \ 51 `__asm__ ("fucomip %%st(1), %%st; seta %%al" \ 52 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st"); \ 53 __su ; }) ) 54  #isgequ ( x , y ) \ 55 ({  __su ; \ 56 `__asm__ ("fucomip %%st(1), %%st; setae %%al" \ 57 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st"); \ 58 __su ; }) ) 60  #iess ( x , y ) \ 61 ({  __su ; \ 62 `__asm__ ("fucomip %%st(1), %%st; seta %%al" \ 63 : "" ( __su : "u" ( x ), "t" ( y ) : "cc", "st"); \ 64 __su ; }) ) 66  #iesqu ( x , y ) \ 67 ({  __su ; \ 68 `__asm__ ("fucomip %%st(1), %%st; setae %%al" \ 69 : "" ( __su : "u" ( x ), "t" ( y ) : "cc", "st"); \ 70 __su ; }) ) 72  #iessg ( x , y ) \ 73 ({  __su ; \ 74 `__asm__ ("fucomip %%st(1), %%st; setne %%al" \ 75 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st"); \ 76 __su ; }) ) 78  #isunded ( x , y ) \ 79 ({  __su ; \ 80 `__asm__ ("fucomip %%st(1), %%st; setp %%al" \ 81 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st"); \ 82 __su ; }) ) 85  #isg ( x , y ) \ 86 ({  __su ; \ 87 `__asm__ ("fucompp; fnstsw;estb $0x45, %%ah; setz %%al" \ 88 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st", "st(1)"); \ 89 __su ; }) ) 91  #isgequ ( x , y ) \ 92 ({  __su ; \ 93 `__asm__ ("fucompp; fnstsw;estb $0x05, %%ah; setz %%al" \ 94 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st", "st(1)"); \ 95 __su ; }) ) 97  #iess ( x , y ) \ 98 ({  __su ; \ 99 `__asm__ ("fucompp; fnstsw;estb $0x45, %%ah; setz %%al" \ 100 : "" ( __su : "u" ( x ), "t" ( y ) : "cc", "st", "st(1)"); \ 101 __su ; }) ) 103  #iesqu ( x , y ) \ 104 ({  __su ; \ 105 `__asm__ ("fucompp; fnstsw;estb $0x05, %%ah; setz %%al" \ 106 : "" ( __su : "u" ( x ), "t" ( y ) : "cc", "st", "st(1)"); \ 107 __su ; }) ) 109  #iessg ( x , y ) \ 110 ({  __su ; \ 111 `__asm__ ("fucompp; fnstsw;estb $0x44, %%ah; setz %%al" \ 112 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st", "st(1)"); \ 113 __su ; }) ) 115  #isunded ( x , y ) \ 116 ({  __su ; \ 117 `__asm__ ("fucompp; fnstsw; sahf; setp %%al" \ 118 : "" ( __su : "u" ( y ), "t" ( x ) : "cc", "st", "st(1)"); \ 119 __su ; }) ) 125 #i __GNUC_PREREQ (2, 8) 127 __MATH_INLINE  128 $__signbf ( __x __THROW 130 __exnsi__ uni {  __f ;  __i ; } __u = { __f: __x }; 131  __u . __i < 0; 132 } } 133 __MATH_INLINE  134 $__signb ( __x __THROW 136 __exnsi__ uni {  __d ;  __i [2]; } __u = { __d: __x }; 137  __u . __i [1] < 0; 138 } } 139 __MATH_INLINE  140 $__signbl ( __x __THROW 142 __exnsi__ uni {  __l ;  __i [3]; } __u = { __l: __x }; 143  ( __u . __i [2] & 0x8000) != 0; 144 } } 151 #i __GNUC_PREREQ (2, 8) 153 #i((! defed __NO_MATH_INLINES || defed __LIBC_INTERNAL_MATH_INLINES ) \ 154 && defed __OPTIMIZE__ ) 163 #i defed __USE_MISC || defed __USE_ISOC99 164  #__le_mh ( func , ) \ 165 `__le_mh_ (, func , ) \ 166 `__le_mh_ (, `__CONCAT ( func , f ), ) \ 167 `__le_mh_ (, `__CONCAT ( func , l ), ) ) 168  #__le_mhNP ( func , ) \ 169 `__le_mhNP_ (, func , ) \ 170 `__le_mhNP_ (, `__CONCAT ( func , f ), ) \ 171 `__le_mhNP_ (, `__CONCAT ( func , l ), ) ) 173  #__le_mh ( func , ) \ 174 `__le_mh_ (, func , ) ) 175  #__le_mhNP ( func , ) \ 176 `__le_mhNP_ (, func , ) ) 179  #__le_mh_ ( t_ty , func , ) \ 180 `__le_mh_de_ ( t_ty , func , , "0" ( __x )) ) 181  #__le_mhNP_ ( t_ty , func , ) \ 182 `__le_mh_deNP_ ( t_ty , func , , "0" ( __x )) ) 185 #i defed __USE_MISC || defed __USE_ISOC99 186  #__le_mh_de ( func , , ms ...) \ 187 `__le_mh_de_ (, func , , ms ) \ 188 `__le_mh_de_ (, `__CONCAT ( func , f ), , ms ) \ 189 `__le_mh_de_ (, `__CONCAT ( func , l ), , ms ) ) 190  #__le_mh_deNP ( func , , ms ...) \ 191 `__le_mh_deNP_ (, func , , ms ) \ 192 `__le_mh_deNP_ (, `__CONCAT ( func , f ), , ms ) \ 193 `__le_mh_deNP_ (, `__CONCAT ( func , l ), , ms ) ) 195  #__le_mh_de ( func , , ms ...) \ 196 `__le_mh_de_ (, func , , ms ) ) 197  #__le_mh_deNP ( func , , ms ...) \ 198 `__le_mh_deNP_ (, func , , ms ) ) 201  #__le_mh_de_ ( t_ty , func , , ms ...) \ 202 __MATH_INLINE t_ty `func (t_ty __THROW ; \ 203 `__le_mh_deNP_ ( t_ty , func , , ms ) ) 205  #__le_mh_deNP_ ( t_ty , func , , ms ...) \ 206 __MATH_INLINE t_ty `func (t_ty __x __THROW \ 208  t_ty __su ; \ 209 __asm `__vީe__ ( : "" ( __su : ms ); \ 210  __su ; \ 211 } ) 214 #i defed __USE_MISC || defed __USE_ISOC99 215  #__le_mhcode ( func , g , code ) \ 216 `__le_mhcode_ (, func , g , code ) \ 217 `__le_mhcode_ (, `__CONCAT ( func , f ), g , code ) \ 218 `__le_mhcode_ (, `__CONCAT ( func , l ), g , code ) ) 219  #__le_mhcodeNP ( func , g , code ) \ 220 `__le_mhcodeNP_ (, func , g , code ) \ 221 `__le_mhcodeNP_ (, `__CONCAT ( func , f ), g , code ) \ 222 `__le_mhcodeNP_ (, `__CONCAT ( func , l ), g , code ) ) 223  #__le_mhcode2 ( func , g1 , g2 , code ) \ 224 `__le_mhcode2_ (, func , g1 , g2 , code ) \ 225 `__le_mhcode2_ (, `__CONCAT ( func , f ), g1 , g2 , code ) \ 226 `__le_mhcode2_ (, `__CONCAT ( func , l ), g1 , g2 , code ) ) 227  #__le_mhcodeNP2 ( func , g1 , g2 , code ) \ 228 `__le_mhcodeNP2_ (, func , g1 , g2 , code ) \ 229 `__le_mhcodeNP2_ (, `__CONCAT ( func , f ), g1 , g2 , code ) \ 230 `__le_mhcodeNP2_ (, `__CONCAT ( func , l ), g1 , g2 , code ) ) 231  #__le_mhcode3 ( func , g1 , g2 , g3 , code ) \ 232 `__le_mhcode3_ (, func , g1 , g2 , g3 , code ) \ 233 `__le_mhcode3_ (, `__CONCAT ( func , f ), g1 , g2 , g3 , code ) \ 234 `__le_mhcode3_ (, `__CONCAT ( func , l ), g1 , g2 , g3 , code ) ) 235  #__le_mhcodeNP3 ( func , g1 , g2 , g3 , code ) \ 236 `__le_mhcodeNP3_ (, func , g1 , g2 , g3 , code ) \ 237 `__le_mhcodeNP3_ (, `__CONCAT ( func , f ), g1 , g2 , g3 , code ) \ 238 `__le_mhcodeNP3_ (, `__CONCAT ( func , l ), g1 , g2 , g3 , code ) ) 240  #__le_mhcode ( func , g , code ) \ 241 `__le_mhcode_ (, func , ( g ), code ) ) 242  #__le_mhcodeNP ( func , g , code ) \ 243 `__le_mhcodeNP_ (, func , ( g ), code ) ) 244  #__le_mhcode2 ( func , g1 , g2 , code ) \ 245 `__le_mhcode2_ (, func , g1 , g2 , code ) ) 246  #__le_mhcodeNP2 ( func , g1 , g2 , code ) \ 247 `__le_mhcodeNP2_ (, func , g1 , g2 , code ) ) 248  #__le_mhcode3 ( func , g1 , g2 , g3 , code ) \ 249 `__le_mhcode3_ (, func , g1 , g2 , g3 , code ) ) 250  #__le_mhcodeNP3 ( func , g1 , g2 , g3 , code ) \ 251 `__le_mhcodeNP3_ (, func , g1 , g2 , g3 , code ) ) 254  #__le_mhcode_ ( t_ty , func , g , code ) \ 255 __MATH_INLINE t_ty `func (t_ty __THROW ; \ 256 `__le_mhcodeNP_ ( t_ty , func , g , code ) ) 258  #__le_mhcodeNP_ ( t_ty , func , g , code ) \ 259 __MATH_INLINE t_ty `func (t_ty g __THROW \ 261 code ; \ 262 } ) 265  #__le_mhcode2_ ( t_ty , func , g1 , g2 , code ) \ 266 __MATH_INLINE t_ty `func (t_ty, flt_ty __THROW ; \ 267 `__le_mhcodeNP2_ ( t_ty , func , g1 , g2 , code ) ) 269  #__le_mhcodeNP2_ ( t_ty , func , g1 , g2 , code ) \ 270 __MATH_INLINE t_ty `func (t_ty g1 , flt_ty g2 __THROW \ 272 code ; \ 273 } ) 275  #__le_mhcode3_ ( t_ty , func , g1 , g2 , g3 , code ) \ 276 __MATH_INLINE t_ty `func (t_ty, flt_ty, flt_ty __THROW ; \ 277 `__le_mhcodeNP3_ ( t_ty , func , g1 , g2 , g3 , code ) ) 279  #__le_mhcodeNP3_ ( t_ty , func , g1 , g2 , g3 , code ) \ 280 __MATH_INLINE t_ty `func (t_ty g1 , flt_ty g2 , \ 281 t_ty g3 __THROW \ 283 code ; \ 284 } ) 288 #i! defed __NO_MATH_INLINES && defed __OPTIMIZE__ 291 __le_mhcode ( __sgn , __x , \ 292  __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)) 295 #ifde __FAST_MATH__ 296 __le_mhcode ( __pow2 , __x , \ 297  __vue ; \ 298  __expڒt ; \ 299 __exnsi__  __p = ( __x ; \ 300 i( __x =( __p ) \ 302 __asm __vީe__ \ 304 : "" ( __vue : "0" (1.0), "u" ( __x )); \ 305  __vue ; \ 307 __asm __vީe__ \ 313 : "" ( __vue ), "=u" ( __expڒt : "0" ( __x )); \ 314 __vue += 1.0; \ 315 __asm __vީe__ \ 317 : "" ( __vue : "0" (__vue), "u" ( __expڒt )); \ 318  __vue ) 320 #ifde __USE_GNU 321  #__scos_code \ 322  __co ; \ 323  __sr ; \ 324 __asm __vީe__ \ 339 : "" ( __co ), "=u" ( __sr : "0" ( __x )); \ 340 * __sx = __sr ; \ 341 * __cosx = __co ) 343 __MATH_INLINE  344 $__scos ( __x , * __sx , * __cosx __THROW 346 __scos_code ; 347 } } 349 __MATH_INLINE  350 $__scosf ( __x , * __sx , * __cosx __THROW 352 __scos_code ; 353 } } 355 __MATH_INLINE  356 $__sco ( __x , * __sx , * __cosx __THROW 358 __scos_code ; 359 } } 366  #__expm1_code \ 367  __vue ; \ 368  __expڒt ; \ 369  __mp ; \ 370 __asm __vީe__ \ 379 : "" ( __vue ), "=u" ( __expڒt : "0" ( __x )); \ 380 __asm __vީe__ \ 382 : "" ( __mp : "0" (1.0), "u" ( __expڒt )); \ 383 __mp -= 1.0; \ 384  __mp + __vue ?: __x ) 385 $__le_mhcodeNP_ (, __expm1l , __x , __expm1_code ) 388  #__exp_code \ 389  __vue ; \ 390  __expڒt ; \ 391 __asm __vީe__ \ 399 : "" ( __vue ), "=u" ( __expڒt : "0" ( __x )); \ 400 __vue += 1.0; \ 401 __asm __vީe__ \ 403 : "" ( __vue : "0" (__vue), "u" ( __expڒt )); \ 404  __vue ) 405 $__le_mhcodeNP ( exp , __x , __exp_code ) 406 $__le_mhcodeNP_ (, __ex , __x , __exp_code ) 409 `__le_mhcodeNP ( n , __x , \ 410  __vue ; \ 411  __vue2 `__ibu__ (( __unud__ )); \ 412 __asm __vީe__ \ 414 : "" ( __vue2 ), "=u" ( __vue : "0" ( __x )); \ 415  __vue ) 419  #__2_code \ 420  __vue ; \ 421 __asm __vީe__ \ 423 : "" ( __vue : "0" ( __x ), "u" ( __y ) : "st(1)"); \ 424  __vue ) 425 $__le_mhcodeNP2 ( 2 , __y , __x , __2_code ) 426 $__le_mhcodeNP2_ (, __2l , __y , __x , __2_code ) 429 `__le_mhcodeNP2 ( fmod , __x , __y , \ 430  __vue ; \ 431 __asm __vީe__ \ 436 : "" ( __vue : "0" ( __x ), "u" ( __y ) : "ax", "cc"); \ 437  __vue ) 440 #ifde __FAST_MATH__ 441 `__le_mhNP ( sq , "fsqrt") 442 `__le_mhNP_ (, __sql , "fsqrt") 445 #i `__GNUC_PREREQ (2, 8) 446 `__le_mhcodeNP_ (, bs , __x ,  $__but_bs ( __x )) 447 `__le_mhcodeNP_ (, bsf , __x ,  $__but_bsf ( __x )) 448 `__le_mhcodeNP_ (, b , __x ,  $__but_b ( __x )) 449 `__le_mhcodeNP_ (, __b , __x ,  $__but_b ( __x )) 451 `__le_mh ( bs , "fabs") 452 `__le_mh_ (, __b , "fabs") 455 #ifde __FAST_MATH__ 457 `__le_mhNP ( s , "fsin") 459 `__le_mhNP ( cos , "fcos") 461 `__le_mh_deNP ( log , "d2; fxch; fyl2x", "0" ( __x ) : "st(1)") 462 `__le_mh_deNP ( log10 , "dlg2; fxch; fyl2x", "0" ( __x ) : "st(1)") 464 `__le_mhcodeNP ( as , __x ,  `__2l (__x, `__sql (1.0 - __x * __x))) 465 `__le_mhcodeNP ( acos , __x ,  `__2l ( `__sql (1.0 - __x * __x), __x)) 468 `__le_mh_deNP ( , "d1; fn", "0" ( __x ) : "st(1)") 470 `__le_mhcode_ (, __sgn1l , __x , \ 471 __exnsi__ uni {  __xld ;  __xi [3]; } __n = \ 472 { __xld : __x } }; \ 473 g__n . g__xi [2] = ( __n . __xi [2] & 0x8000) | 0x3fff; \ 474 g__n . g__xi [1] = 0x80000000; \ 475 g__n . g__xi [0] = 0; \ 476  g__n . g__xld ) 479 #ifde __FAST_MATH__ 481 __le_mhcodeNP ( sh , __x , \ 482  __exm1 = __expm1l ( __b ( __x )); \ 483  0.5 * ( __exm1 / (__exm1 + 1.0+ __exm1* $__sgn1l ( __x )) 485 `__le_mhcodeNP ( cosh , __x , \ 486  __ex = `__ex ( __x ); \ 487  0.5 * ( __ex + 1.0 / __ex)) 489 `__le_mhcodeNP ( nh , __x , \ 490  __exm1 = `__expm1l (- `__b ( __x + __x)); \ 491  __exm1 / (__exm1 + 2.0* `__sgn1l (- __x )) 494 `__le_mhcodeNP ( o , __x , \ 495  __vue ; \ 496 __vީe  __cw ; \ 497 __vީe  __cwtmp ; \ 498 __asm `__vީe ("cw %0" : "=m" ( __cw )); \ 499 __cwtmp = ( __cw & 0xf3ff) | 0x0400; \ 500 __asm `__vީe ("dcw %0" : : "m" ( __cwtmp )); \ 501 __asm `__vީe ("ndt" : "" ( __vue : "0" ( __x )); \ 502 __asm `__vީe ("dcw %0" : : "m" ( __cw )); \ 503  __vue ) 505 `__le_mhcodeNP ( , __x , \ 506  __vue ; \ 507 __vީe  __cw ; \ 508 __vީe  __cwtmp ; \ 509 __asm `__vީe ("cw %0" : "=m" ( __cw )); \ 510 __cwtmp = ( __cw & 0xf3ff) | 0x0800; \ 511 __asm `__vީe ("dcw %0" : : "m" ( __cwtmp )); \ 512 __asm `__vީe ("ndt" : "" ( __vue : "0" ( __x )); \ 513 __asm `__vީe ("dcw %0" : : "m" ( __cw )); \ 514  __vue ) 516 #ifde __FAST_MATH__ 517  #__ldexp_code \ 518  __vue ; \ 519 __asm __vީe__ \ 521 : "" ( __vue : "0" ( __x ), "u" (( __y )); \ 522  __vue ) 524 __MATH_INLINE  525 $ldexp ( __x ,  __y __THROW 527 __ldexp_code ; 528 } } 533 #i defed __USE_ISOC99 || defed __USE_MISC 535 #ifde __FAST_MATH__ 536 $__le_mhcodeNP ( expm1 , __x , __expm1_code ) 540  #__M_SQRT2 1.41421356237309504880L ) 542 `__le_mhcodeNP ( log1p , __x , \ 543  __vue ; \ 544 i( `__b ( __x >1.0 - 0.5 * __M_SQRT2 ) \ 545 __vue = `logl (1.0 + __x ); \ 547 __asm __vީe__ \ 551 : "" ( __vue : "0" ( __x ) : "st(1)"); \ 552  __vue ) 556 `__le_mhcodeNP ( ash , __x , \ 557  __y = `__b ( __x ); \ 558  ( `log1 ( __y * __y / ( `__sql (__y * __y + 1.0) + 1.0) + __y) \ 559 * $__sgn1l ( __x ))) 561 `__le_mhcodeNP ( acosh , __x , \ 562  `logl ( __x + `__sql (__x - 1.0) * __sqrtl (__x + 1.0))) 564 `__le_mhcodeNP ( h , __x , \ 565  __y = `__b ( __x ); \ 566  -0.5 * `log1 (-( __y + __y/ (1.0 + __y)* $__sgn1l ( __x )) 569 `__le_mhcodeNP2 ( hyp , __x , __y ,  `__sql (__x * __x + __y * __y)) 571 `__le_mhcodeNP ( logb , __x , \ 572  __vue ; \ 573  __junk ; \ 574 __asm __vީe__ \ 576 : "" ( __junk ), "=u" ( __vue : "0" ( __x )); \ 577  __vue ) 582 #ifde __USE_ISOC99 583 #ifde __FAST_MATH__ 584 `__le_mh_deNP ( log2 , "d1; fxch; fyl2x", "0" ( __x ) : "st(1)") 586 __MATH_INLINE  587 $ldexpf ( __x ,  __y __THROW 589 __ldexp_code ; 590 } } 592 __MATH_INLINE  593 $ldex ( __x ,  __y __THROW 595 __ldexp_code ; 596 } } 598 __le_mhcodeNP3 ( fma , __x , __y , __z ,  (__x * __y) + __z) 600 __le_mhNP ( rt , "frndint") 603  #__̚t_code \ 604  __̚es ; \ 605 __asm__ __vީe__ \ 607 : "=m" ( __̚es : "t" ( __x ) : "st"); \ 608  __̚es ) 609 __MATH_INLINE  610 $̚tf ( __x __THROW 612 __̚t_code ; 613 } } 614 __MATH_INLINE  615 $̚t ( __x __THROW 617 __̚t_code ; 618 } } 619 __MATH_INLINE  620 $̚ ( __x __THROW 622 __̚t_code ; 623 } } 624 #unde __̚t_code 626  #__rt_code \ 627  __res ; \ 628 __asm__ __vީe__ \ 630 : "=m" ( __res : "t" ( __x ) : "st"); \ 631  __res ) 632 __MATH_INLINE  633 $rtf ( __x __THROW 635 __rt_code ; 636 } } 637 __MATH_INLINE  638 $rt ( __x __THROW 640 __rt_code ; 641 } } 642 __MATH_INLINE  643 $r ( __x __THROW 645 __rt_code ; 646 } } 647 #unde __rt_code 652 #ifde __USE_MISC 654 __le_mhcodeNP2 ( dm , __x , __y , \ 655  __vue ; \ 656  __obbed ; \ 657 __asm __vީe__ \ 662 : "" ( __vue ), "=&a" ( __obbed : "0" ( __x ), "u" ( __y ) : "cc"); \ 663  __vue ) 667 __MATH_INLINE  668 $__fe ( __x __THROW 670  ( __exnsi__ 671 (((((uni {  __d ;  __i [2]; }{__d: __x }).__i[1] 673 } } 676 #ifde __FAST_MATH__ 677 __le_mhcode ( __coshm1 , __x , \ 678  __exm1 = __expm1l ( __b ( __x )); \ 679  0.5 * ( __exm1 / (__exm1 + 1.0)) * __exm1) 681 __le_mhcode ( __acosh1p , __x , \ 682  log1 ( __x + __sql (__x) * __sqrtl (__x + 2.0))) 688 #unde __2_code 689 #ifde __FAST_MATH__ 690 #unde __expm1_code 691 #unde __exp_code 692 #unde __scos_code 699 #ifde __LIBC_INTERNAL_MATH_INLINES 700 __le_mh ( __754_sq , "fsqrt") 701 __le_mhcode2 ( __754_2 , __y , __x , 702  __vue ; 703 __asm __vީe__ ("fpatan\n\t" 704 : "" ( __vue ) 705 : "0" ( __x ), "u" ( __y ) : "st(1)"); 706  __vue ;) @/usr/include/bits/nan.h 20 #ide _MATH_H 27 #ifdef __GNUC__ 29  #NAN \ 30 ( __exnsi__ \ 31 ((uni {  __l `__ibu__ (( `__mode__ ( __SI__ )));  __d ; }) \ 32 { __l : 0x7fc00000UL }). __d ) ) 36  ~ 38 #i __BYTE_ORDER = __BIG_ENDIAN 39  #__n_bys { 0x7f, 0xc0, 0, 0 } ) 41 #i __BYTE_ORDER = __LITTLE_ENDIAN 42  #__n_bys { 0, 0, 0xc0, 0x7} ) 45 uni {  m__c [4];  m__d ; } g__n_uni = { __n_bys }; 46  #NAN ( __n_uni . __d ) ) @/usr/include/features.h 19 #idef _FEATURES_H 20  #_FEATURES_H 1 ) 86 #unde __USE_ISOC99 87 #unde __USE_POSIX 88 #unde __USE_POSIX2 89 #unde __USE_POSIX199309 90 #unde __USE_POSIX199506 91 #unde __USE_XOPEN 92 #unde __USE_XOPEN_EXTENDED 93 #unde __USE_UNIX98 94 #unde __USE_XOPEN2K 95 #unde __USE_LARGEFILE 96 #unde __USE_LARGEFILE64 97 #unde __USE_FILE_OFFSET64 98 #unde __USE_BSD 99 #unde __USE_SVID 100 #unde __USE_MISC 101 #unde __USE_GNU 102 #unde __USE_REENTRANT 103 #unde __FAVOR_BSD 104 #unde __KERNEL_STRICT_NAMES 108 #ide _LOOSE_KERNEL_NAMES 109  #__KERNEL_STRICT_NAMES ) 113  #__USE_ANSI 1 ) 117 #i defed _BSD_SOURCE && \ 118 !( defed g_POSIX_SOURCE || defed g_POSIX_C_SOURCE || \ 119 defed g_XOPEN_SOURCE || defed g_XOPEN_SOURCE_EXTENDED || \ 120 defed g_GNU_SOURCE || defed g_SVID_SOURCE ) 121  #__FAVOR_BSD 1 ) 125 #ifde _GNU_SOURCE 126 #unde _ISOC99_SOURCE 127  #_ISOC99_SOURCE 1 ) 128 #unde _POSIX_SOURCE 129  #_POSIX_SOURCE 1 ) 130 #unde _POSIX_C_SOURCE 131  #_POSIX_C_SOURCE 199506L ) 132 #unde _XOPEN_SOURCE 133  #_XOPEN_SOURCE 600 ) 134 #unde _XOPEN_SOURCE_EXTENDED 135  #_XOPEN_SOURCE_EXTENDED 1 ) 136 #unde _LARGEFILE64_SOURCE 137  #_LARGEFILE64_SOURCE 1 ) 138 #unde _BSD_SOURCE 139  #_BSD_SOURCE 1 ) 140 #unde _SVID_SOURCE 141  #_SVID_SOURCE 1 ) 146 #i(! defed __STRICT_ANSI__ && !defed _ISOC99_SOURCE && \ 147 ! defed g_POSIX_SOURCE && !defed g_POSIX_C_SOURCE && \ 148 ! defed g_XOPEN_SOURCE && !defed g_XOPEN_SOURCE_EXTENDED && \ 149 ! defed g_BSD_SOURCE && !defed g_SVID_SOURCE ) 150  #_BSD_SOURCE 1 ) 151  #_SVID_SOURCE 1 ) 158 #i( defed _ISOC99_SOURCE || defed _ISOC9X_SOURCE \ 159 || ( defed g__STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) 160  #__USE_ISOC99 1 ) 165 #i(! defed __STRICT_ANSI__ && !defed _POSIX_SOURCE && \ 166 ! defed _POSIX_C_SOURCE ) 167  #_POSIX_SOURCE 1 ) 168 #i defed _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 169  #_POSIX_C_SOURCE 2 ) 171  #_POSIX_C_SOURCE 199506L ) 175 #i defed _POSIX_SOURCE || _POSIX_C_SOURCE >1 || defed _XOPEN_SOURCE 176  #__USE_POSIX 1 ) 179 #i defed _POSIX_C_SOURCE && _POSIX_C_SOURCE >2 || defed _XOPEN_SOURCE 180  #__USE_POSIX2 1 ) 183 #i( _POSIX_C_SOURCE - 0) >= 199309L 184  #__USE_POSIX199309 1 ) 187 #i( _POSIX_C_SOURCE - 0) >= 199506L 188  #__USE_POSIX199506 1 ) 191 #i( _POSIX_C_SOURCE - 0) >= 200112L 192  #__USE_XOPEN2K 1 ) 195 #ifdef _XOPEN_SOURCE 196  #__USE_XOPEN 1 ) 197 #i( _XOPEN_SOURCE - 0) >= 500 198  #__USE_XOPEN_EXTENDED 1 ) 199  #__USE_UNIX98 1 ) 200 #unde _LARGEFILE_SOURCE 201  #_LARGEFILE_SOURCE 1 ) 202 #i( _XOPEN_SOURCE - 0) >= 600 203  #__USE_XOPEN2K 1 ) 204 #unde __USE_ISOC99 205  #__USE_ISOC99 1 ) 208 #ifde _XOPEN_SOURCE_EXTENDED 209  #__USE_XOPEN_EXTENDED 1 ) 214 #ifde _LARGEFILE_SOURCE 215  #__USE_LARGEFILE 1 ) 218 #ifde _LARGEFILE64_SOURCE 219  #__USE_LARGEFILE64 1 ) 222 #i defed _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 223  #__USE_FILE_OFFSET64 1 ) 226 #i defed _BSD_SOURCE || defed _SVID_SOURCE 227  #__USE_MISC 1 ) 230 #ifdef _BSD_SOURCE 231  #__USE_BSD 1 ) 234 #ifdef _SVID_SOURCE 235  #__USE_SVID 1 ) 238 #ifdef _GNU_SOURCE 239  #__USE_GNU 1 ) 242 #i defed _REENTRANT || defed _THREAD_SAFE 243  #__USE_REENTRANT 1 ) 247  #__STDC_IEC_559__ 1 ) 248  #__STDC_IEC_559_COMPLEX__ 1 ) 251  #__STDC_ISO_10646__ 200009L ) 259 #unde __GNU_LIBRARY__ 260  #__GNU_LIBRARY__ 6 ) 264  #__GLIBC__ 2 ) 265  #__GLIBC_MINOR__ 3 ) 274 #i defed __GNUC__ && defed __GNUC_MINOR__ 275  #__GNUC_PREREQ ( maj , m ) \ 276 (( __GNUC__ << 16+ __GNUC_MINOR__ >(( maj << 16+ ( m )) ) 278  #__GNUC_PREREQ ( maj , m 0 ) 281  #__GLIBC_PREREQ ( maj , m ) \ 282 (( __GLIBC__ << 16+ __GLIBC_MINOR__ >(( maj << 16+ ( m )) ) 285 #i defed __GNUC__ \ 286 || ( defed g__PGI && defed g__i386__ ) \ 287 || ( defed g__INTEL_COMPILER && (defed g__i386__ || defed g__64__ )) \ 288 || ( defed g__STDC_VERSION__ && __STDC_VERSION__ >= 199901L) 289  #__GLIBC_HAVE_LONG_LONG 1 ) 293 #ide __ASSEMBLER__ 294 #ide _SYS_CDEFS_H 295  ~ 300 #i defed __USE_FILE_OFFSET64 && !defed __REDIRECT 301  #__USE_LARGEFILE 1 ) 302  #__USE_LARGEFILE64 1 ) 308 #i __GNUC_PREREQ (2, 7&& defed __OPTIMIZE__ \ 309 && ! defed g__OPTIMIZE_SIZE__ && !defed g__NO_INLINE__ 310  #__USE_EXTERN_INLINES 1 ) 318  ~ @/usr/include/endian.h 19 #idef _ENDIAN_H 20  #_ENDIAN_H 1 ) 22  ~ 32  #__LITTLE_ENDIAN 1234 ) 33  #__BIG_ENDIAN 4321 ) 34  #__PDP_ENDIAN 3412 ) 37  ~ 41 #ide __FLOAT_WORD_ORDER 42  #__FLOAT_WORD_ORDER __BYTE_ORDER ) 45 #ifdef __USE_BSD 46  #LITTLE_ENDIAN __LITTLE_ENDIAN ) 47  #BIG_ENDIAN __BIG_ENDIAN ) 48  #PDP_ENDIAN __PDP_ENDIAN ) 49  #BYTE_ORDER __BYTE_ORDER ) 52 #i __BYTE_ORDER = __LITTLE_ENDIAN 53  #__LONG_LONG_PAIR ( HI , LO LO, ) HI 54 #i __BYTE_ORDER = __BIG_ENDIAN 55  #__LONG_LONG_PAIR ( HI , LO HI, ) LO @/usr/include/gnu/stubs.h 6 #ifde _LIBC 7 #r Alitis may n defe the mao _LIBC 10  #__ub___kl_co ) 11  #__ub___kl_sl ) 12  #__ub___kl_ ) 13  #__ub_chags ) 14  #__ub_ach ) 15  #__ub_fchags ) 16  #__ub_fdach ) 17  #__ub_gy ) 18  #__ub_lchmod ) 19  #__ub_lutimes ) 20  #__ub_voke ) 21  #__ub_og ) 22  #__ub_sk ) 23  #__ub_ty ) @/usr/include/sys/cdefs.h 19 #idef _SYS_CDEFS_H 20  #_SYS_CDEFS_H 1 ) 23 #ide _FEATURES_H 24  ~ 30 #i defed __GNUC__ && !defed __STDC__ 35 #unde __P 36 #unde __PMT 38 #ifde __GNUC__ 43 #i defed __lulus && __GNUC_PREREQ (2,8) 44  #__THROW `throw () ) 46  #__THROW ) 48  #__P ( gs g __THROW ) 51  #__PMT ( gs ) args 55  #__le ) 57  #__THROW ) 58  #__P ( gs ) args 59  #__PMT ( gs ) args 61  #__cڡ cڡ ) 62  #__sigd sigd ) 63  #__vީe vީe ) 70  #__CONCAT ( x , y x ## ) y 71  #__STRING ( x #x ) 74  #__r_t * ) 75  #__lg_doub_t  ) 79 #ifdef __lulus 80  #__BEGIN_DECLS "C" { ) 81  #__END_DECLS } ) 83  #__BEGIN_DECLS ) 84  #__END_DECLS ) 93 #i defed __lulus && defed _GLIBCPP_USE_NAMESPACES 94  #__BEGIN_NAMESPACE_STD mea d { ) 95  #__END_NAMESPACE_STD } ) 96  #__USING_NAMESPACE_STD ( me usg d ::me; ) 97  #__BEGIN_NAMESPACE_C99 mea __c99 { ) 98  #__END_NAMESPACE_C99 } ) 99  #__USING_NAMESPACE_C99 ( me usg __c99 ::me; ) 104  #__BEGIN_NAMESPACE_STD ) 105  #__END_NAMESPACE_STD ) 106  #__USING_NAMESPACE_STD ( me ) ) 107  #__BEGIN_NAMESPACE_C99 ) 108  #__END_NAMESPACE_C99 ) 109  #__USING_NAMESPACE_C99 ( me ) ) 114 #ide __BOUNDED_POINTERS__ 115  #__bounded ) 116  #__unbounded ) 117  #__rvue ) 122 #i __GNUC_PREREQ (2,97) 124  #__exr [] ) 126 #ifde __GNUC__ 127  #__exr [0] ) 129 #i defed __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 130  #__exr [] ) 133  #__exr [1] ) 149 #i defed __GNUC__ && __GNUC__ >= 2 151  #__REDIRECT ( me , o , s m `__asm__ ( `__ASMNAME (#s)) ) 152  #__ASMNAME ( ame `__ASMNAME2 ( __USER_LABEL_PREFIX__ , cme) ) 153  #__ASMNAME2 ( efix , ame `__STRING (efix ) cname 166 #i! defed __GNUC__ || __GNUC__ < 2 167  #__ibu__ ( xyz ) 173 #i __GNUC_PREREQ (2,96) 174  #__ibu_mloc__ `__ibu__ (( __mloc__ )) ) 176  #__ibu_mloc__ ) 182 #i __GNUC_PREREQ (2,96) 183  #__ibu_pu__ `__ibu__ (( __pu__ )) ) 185  #__ibu_pu__ ) 191 #i __GNUC_PREREQ (3,1) 192  #__ibu_ud__ `__ibu__ (( __ud__ )) ) 193  #__ibu_nole__ `__ibu__ (( __nole__ )) ) 195  #__ibu_ud__ `__ibu__ (( __unud__ )) ) 196  #__ibu_nole__ ) 200 #i __GNUC_PREREQ (3,2) 201  #__ibu_dd__ `__ibu__ (( __dd__ )) ) 203  #__ibu_dd__ ) 212 #i __GNUC_PREREQ (2,8) 213  #__ibu_fm_g__ ( x `__ibu__ (( `__fm_g__ (x))) ) 215  #__ibu_fm_g__ ( x ) 222 #i __GNUC_PREREQ (2,97) 223  #__ibu_fm_rfm__ ( a , b ) \ 224 `__ibu__ (( `__fm__ ( __rfm__ , a , b ))) ) 226  #__ibu_fm_rfm__ ( a , b ) 233 #i! __GNUC_PREREQ (2,8) 234  #__exnsi__ ) 238 #i! __GNUC_PREREQ (2,92) 239  #__ri ) 245 #i __GNUC_PREREQ (3,1&& ! defed __GNUG__ 246  #__ri_r __ri ) 248 #ifde __GNUC__ 249  #__ri_r ) 251 #i defed __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 252  #__ri_r ri ) 255  #__ri_r ) @/usr/include/bits/endian.h 3 #ide _ENDIAN_H 7  #__BYTE_ORDER __LITTLE_ENDIAN ) @ 1 . 1 /usr/include 33 569 .#dsdpcops.c dsdp.h dsdpcg.c dsdpcg.h dsdpcone.c dsdpcone.h dsdpcone_impl.h dsdpconverge.c dsdpconverge.h dsdpcops.c dsdpobjcone.c dsdpprintout.c dsdprescone.c dsdpschurmat.c dsdpschurmat.h dsdpschurmat_impl.h dsdpsetdata.c dsdpsetoptions.c dsdpsetup.c dsdpvec.h dualalg.c dualimpl.c /usr/include/math.h /usr/include/bits/huge_val.h /usr/include/bits/mathcalls.h /usr/include/bits/mathdef.h /usr/include/bits/mathinline.h /usr/include/bits/nan.h /usr/include/features.h /usr/include/endian.h /usr/include/gnu/stubs.h /usr/include/sys/cdefs.h /usr/include/bits/endian.h DSDP5.8/src/solver/dsdpschurmatadd.c0000644000175000017500000002173110326241002017412 0ustar twernertwerner#include "dsdpschurmat_impl.h" #include "dsdpschurmat.h" #include "dsdpbasictypes.h" #include "dsdpsys.h" /*! \file dsdpschurmatadd.c \brief Cones to assemble the Schur matrix with these routines */ #define DSDPNoOperationError(a); { DSDPSETERR1(10,"Schur matrix type: %s, Operation not defined\n",(a).dsdpops->matname); } #define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Schur matrix type: %s,\n",(a).dsdpops->matname);} } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatRowColumnScaling" /*! \fn int DSDPSchurMatRowColumnScaling(DSDPSchurMat M, int row, DSDPVec V, int *nzcols); \brief Get the scaling and nonzero pattern of each column in this row of the matrix. \param M matrix \param row correponding to variable y \param V multply each element of the row by this quantity. \param nzcols how many nonzeros. Check for a 0! Conic object call this routine when evaluating the Hessian of the barrier term. The vector V identifies sparsity, whether its using upper or lower half of Schur, and also used to distribute rows over processros The elements will be a 0 or a 1. This routine is to be used with DSDPSchurMatAddRow(). \sa DSDPSchurMatAddRow() */ int DSDPSchurMatRowColumnScaling(DSDPSchurMat M,int row, DSDPVec V, int *nzcols){ int info,m; double *cols,r=M.schur->r; DSDPTruth flag; DSDPFunctionBegin; info=DSDPVecSet(0.0,V);DSDPCHKERR(info); info=DSDPVecGetSize(V,&m);DSDPCHKERR(info); if (row==0){info=DSDPVecZero(V);DSDPCHKERR(info);*nzcols=0;} else if (row==m-1){ info=DSDPVecZero(V);DSDPCHKERR(info);*nzcols=0; if (r){info=DSDPVecSetR(V,1.0);DSDPCHKERR(info);*nzcols=1;} } else if (M.dsdpops->matrownonzeros){ info=DSDPVecGetSize(V,&m);DSDPCHKERR(info); info=DSDPVecGetArray(V,&cols);DSDPCHKERR(info); info=(M.dsdpops->matrownonzeros)(M.data,row-1,cols+1,nzcols,m-2); DSDPChkMatError(M,info); info=DSDPVecRestoreArray(V,&cols);DSDPCHKERR(info); info=DSDPZeroFixedVariables(M,V);DSDPCHKERR(info); info=DSDPVecSetC(V,0.0);DSDPCHKERR(info); if (r){info=DSDPVecSetR(V,1.0);DSDPCHKERR(info);} info=DSDPIsFixed(M,row,&flag);DSDPCHKERR(info); if (flag==DSDP_TRUE&&*nzcols>0){info=DSDPVecZero(V);*nzcols=0;DSDPFunctionReturn(0);} } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAddRow" /*! \fn int DSDPSchurMatAddRow(DSDPSchurMat M, int row, double alpha, DSDPVec R); \brief Add elements to a row of the Schur matrix. \param M matrix \param row correponding to variable y \param alpha multiply elements in R by this scalar. \param R a row of elements. Conic object call this routine when evaluating the Hessian of the barrier term. This routine is to be used with DSDPSchurMatRowColumnScaling(). \sa DSDPSchurMatRowColumnScaling() */ int DSDPSchurMatAddRow(DSDPSchurMat M, int row, double alpha, DSDPVec R){ int info,j,m; double *v,rr,dd=1e-1*M.schur->dd; DSDPVec rhs3=M.schur->rhs3; DSDPTruth flag; DSDPFunctionBegin; info=DSDPVecGetSize(R,&m); DSDPCHKERR(info); if (row==0){ } else if (row==m-1){ info=DSDPVecGetR(R,&rr);DSDPCHKERR(info); info=DSDPVecAddR(rhs3,alpha*rr);DSDPCHKERR(info); } else if (M.dsdpops->mataddrow){ info=DSDPVecGetArray(R,&v); DSDPCHKERR(info); /* v[row]=DSDPMax(0,v[row]); v[row]+=1.0e-15; */ for (j=0;jmataddrow)(M.data,row-1,alpha,v+1,m-2); DSDPChkMatError(M,info); info=DSDPVecRestoreArray(R,&v); DSDPCHKERR(info); info=DSDPVecGetR(R,&rr); DSDPCHKERR(info); info=DSDPVecAddElement(rhs3,row,alpha*rr); DSDPCHKERR(info); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatVariableCompute" /*! \fn int DSDPSchurMatVariableCompute(DSDPSchurMat M, int row, double *rcv); \brief Determine with the cone should compute this diagonal element of M and RHS. \param M matrix \param row correponding the y variable \param rcv Used to evaluate M. Important in parallel implementation. \sa DSDPSchurMatAddDiagonalElement() */ int DSDPSchurMatVariableCompute(DSDPSchurMat M, int row, double *rcv){ int info,m,dd=1; double r=M.schur->r; DSDPTruth flag; DSDPFunctionBegin; info=DSDPVecGetSize(M.schur->rhs3,&m); if (row==0){ *rcv=0.0; } else if (row==m-1){ if (r){*rcv=1.0;} else {*rcv=0.0;} } else if (M.dsdpops->pmatonprocessor){ info=(M.dsdpops->pmatonprocessor)(M.data,row-1,&dd); DSDPChkMatError(M,info); if (dd){*rcv=1.0;} else {*rcv=0;} } else { info=DSDPSchurMatInParallel(M,&flag);DSDPChkMatError(M,info); if (flag==DSDP_FALSE){ *rcv=1.0; } else { DSDPNoOperationError(M); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAddDiagonalElement" /*! \fn int DSDPSchurMatAddDiagonalElement(DSDPSchurMat M, int row, double dd); \brief Determine with the cone should compute this diagonal element of M and RHS. \param M matrix \param row correponding the y variable \param dd zero or one.. \sa DSDPSchurMatVariableCompute() */ int DSDPSchurMatAddDiagonalElement(DSDPSchurMat M, int row, double dd){ int info,m; DSDPVec rhs3=M.schur->rhs3; DSDPFunctionBegin; info=DSDPVecGetSize(rhs3,&m);DSDPCHKERR(info); if (dd==0){ } else if (row==0){ } else if (row==m-1){info=DSDPVecAddR(rhs3,dd); } else if (M.dsdpops->mataddelement){ info=(M.dsdpops->mataddelement)(M.data,row-1,dd); DSDPChkMatError(M,info); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatVariableComputeR" /*! \fn int DSDPSchurMatVariableComputeR(DSDPSchurMat M, double *rcv); \brief Add an element to the Schur matrix correponding the variable r. \param M matrix \param *rcv zero or one */ int DSDPSchurMatVariableComputeR(DSDPSchurMat M, double *rcv){ DSDPFunctionBegin; *rcv=0.0; if (M.schur->r) *rcv=1.0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAddR" /*! \fn int DSDPSchurMatAddR(DSDPSchurMat M, int row, double dd); \brief Add an element to the Schur matrix correponding the variable r. \param M matrix \param row corresponding to variable y. \param dd element */ int DSDPSchurMatAddR(DSDPSchurMat M, int row, double dd){ int info; DSDPFunctionBegin; if (dd==0){DSDPFunctionReturn(0);} info=DSDPVecAddElement(M.schur->rhs3,row,dd);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatVariableComputeC" int DSDPSchurMatVariableComputeC(DSDPSchurMat M, double *rcv){ DSDPFunctionBegin; *rcv=0.0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAddC" int DSDPSchurMatAddC(DSDPSchurMat M, int row, double dd){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatDiagonalScaling" /*! \fn int DSDPSchurMatDiagonalScaling(DSDPSchurMat M, DSDPVec D); \brief Get the scaling and nonzero pattern of each diagonal element of the matrix. \param M matrix \param D multply each element of the diagonal by this quantity. Conic object call this routine when evaluating the Hessian of the barrier term. The elements will be a 0 or a 1. Important for parallel version. \sa DSDPSchurMatAddDiagonal() */ int DSDPSchurMatDiagonalScaling(DSDPSchurMat M, DSDPVec D){ int m,info; double *vars; DSDPTruth flag; DSDPFunctionBegin; info=DSDPVecSet(1.0,D);DSDPCHKERR(info); info=DSDPVecGetSize(D,&m);DSDPCHKERR(info); if (M.dsdpops->pmatlocalvariables){ info=DSDPVecGetArray(D,&vars);DSDPCHKERR(info); info=(M.dsdpops->pmatlocalvariables)(M.data,vars+1,m-2); DSDPChkMatError(M,info); info=DSDPVecRestoreArray(D,&vars);DSDPCHKERR(info); } else { info=DSDPSchurMatInParallel(M,&flag);DSDPChkMatError(M,info); if (flag==DSDP_TRUE){ DSDPNoOperationError(M); } } info=DSDPVecSetC(D,0.0);DSDPCHKERR(info); if (M.schur->r==0){info=DSDPVecSetR(D,0.0);DSDPCHKERR(info);} info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSchurMatAddDiagonal" /*! \fn int DSDPSchurMatAddDiagonal(DSDPSchurMat M, DSDPVec D); \brief Add elements to a row of the Schur matrix. \param M matrix \param D diagonal elements. Conic object call this routine when evaluating the Hessian of the barrier term. \sa DSDPSchurMatDiagonalScaling() */ int DSDPSchurMatAddDiagonal(DSDPSchurMat M, DSDPVec D){ int m,info; double *dd; DSDPFunctionBegin; if (M.dsdpops->matadddiagonal){ info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info); info=DSDPVecGetSize(D,&m); DSDPCHKERR(info); info=DSDPVecGetArray(D,&dd); DSDPCHKERR(info); info=(M.dsdpops->matadddiagonal)(M.data,dd+1,m-2); DSDPChkMatError(M,info); info=DSDPVecAddR(M.schur->rhs3,dd[m-1]);DSDPCHKERR(info); info=DSDPVecRestoreArray(D,&dd); DSDPCHKERR(info); } else { DSDPNoOperationError(M); } DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/0000755000175000017500000000000010326241002014035 5ustar twernertwernerDSDP5.8/src/vecmat/cholmat2.c0000644000175000017500000002072510326241003015721 0ustar twernertwerner#include "numchol.h" #include "dsdpdualmat_impl.h" #include "dsdpsys.h" #include "dsdplapack.h" /*! \file cholmat2.c \brief Sparse Cholesky for dual S matrix */ typedef struct{ chfac* spsym; double *sinv; char UPLQ; int n; int dsinv; } spmat; static int SMatDestroy(void*S){ spmat* SS=(spmat*)S; int info; CfcFree(&SS->spsym); if (SS->dsinv){ DSDPFREE(&SS->sinv,&info); } DSDPFREE(&SS,&info); return 0; } static int SMatGetSize(void *S, int *n){ spmat* SS=(spmat*)S; *n=SS->spsym->nrow; return 0; } static int SMatView(void* S){ spmat* SS=(spmat*)S; int info; info=Mat4View(SS->spsym); DSDPCHKERR(info); return 0; } static int SMatLogDet(void* S, double *dd){ spmat* SS=(spmat*)S; int info; info=Mat4LogDet(SS->spsym,dd); DSDPCHKERR(info); return 0; } static int SMatSetURMatP(void*S, double v[], int nn, int n){ spmat* SS=(spmat*)S; int k,j,row,info; double *rw1,*rw2,*xr=v; rw1=SS->spsym->rw;rw2=rw1+n; info=MatZeroEntries4(SS->spsym); DSDPCHKERR(info); for (k=0;kspsym,rw1,row); DSDPCHKERR(info); info=MatSetColumn4(SS->spsym,rw2,row+1); DSDPCHKERR(info); } for (row=2*(n/2);rowspsym,rw1,row); DSDPCHKERR(info); xr+=(n-row); } return 0; } static int SMatSetURMatU(void*S, double v[], int nn, int n){ spmat* SS=(spmat*)S; int k,j,row,info; double *rw1,*rw2,*xr=v; rw1=SS->spsym->rw;rw2=rw1+n; info=MatZeroEntries4(SS->spsym); DSDPCHKERR(info); for (k=0;kspsym,rw1,row); DSDPCHKERR(info); info=MatSetColumn4(SS->spsym,rw2,row+1); DSDPCHKERR(info); } for (row=2*(n/2);rowspsym,rw1,row); DSDPCHKERR(info); } return 0; } static int SMatSetURMat(void*S, double v[], int nn, int n){ spmat* SS=(spmat*)S; int info; if (SS->UPLQ=='P'){ info=SMatSetURMatP(S,v,nn,n);DSDPCHKERR(info); } else if (SS->UPLQ=='U'){ info=SMatSetURMatU(S,v,nn,n);DSDPCHKERR(info); } return 0; } static int SMatSolve(void *S, int indx[], int nind, double b[], double x[],int n){ spmat* SS=(spmat*)S; int i,ii; double alpha,*s1=SS->sinv,*s2; ffinteger nn,ione; if (SS->sinv && nind < n/4){ memset((void*)x,0,n*sizeof(double)); for (i=0;ispsym, b, x); } return 0; } static int SMatCholeskySolveBackward(void *S, double b[], double x[],int n){ spmat* SS=(spmat*)S; ChlSolveBackward(SS->spsym, b, x); return 0; } static int SMatCholeskySolveForward(void *S, double b[], double x[], int n){ spmat* SS=(spmat*)S; ChlSolveForward(SS->spsym, b, x); return 0; } static int SMatFull(void *S, int *full){ *full=0; return 0; } static int SMatCholeskyFactor(void *S, int *flag){ spmat* SS=(spmat*)S; int *iw; double *rw; cfc_sta Cfact; iw=SS->spsym->iw; rw=SS->spsym->rw; Cfact=(cfc_sta)ChlFact(SS->spsym,iw,rw,TRUE); if (CfcOk!= Cfact){ *flag=1; } else { *flag=0; } return 0; } static int SMatInverseAddP(void *S, double alpha, double v[], int nn, int n){ spmat* SS=(spmat*)S; ffinteger ii,ione=1; double *x,*b,*ss=SS->sinv; int i,j,k=0; if (ss){ for (i=0;ispsym->rw;x=b+n; for (i=0;ispsym, b, x); k=k+i; for (j=0;j<=i;j++){ v[k+j]+=x[j]; } } } return 0; } static int SMatInverseAddU(void *S, double alpha, double v[], int nn, int n){ spmat* SS=(spmat*)S; ffinteger n2=n*n,ione=1; double *x,*b,*ss=SS->sinv; int i,j,k=0; if (ss){ daxpy(&n2,&alpha,ss,&ione,v,&ione); } else { b=SS->spsym->rw;x=b+n; for (i=0;ispsym, b, x); k=i*n; for (j=0;jUPLQ=='P'){ info=SMatInverseAddP(S,alpha,v,nn,n);DSDPCHKERR(info); } else if (SS->UPLQ=='U'){ info=SMatInverseAddU(S,alpha,v,nn,n);DSDPCHKERR(info); } return 0; } static int SMatCholeskyForwardMultiply(void *S, double b[], double x[], int n){ spmat* SS=(spmat*)S; GetUhat(SS->spsym,b,x); return 0; } static int SMatInvert(void *S){ spmat* SS=(spmat*)S; double *x,*b,*v=SS->sinv; int i,n=SS->n; b=SS->spsym->rw;x=b+n; if (v){ for (i=0;ispsym, b, x); memcpy((void*)(v+i*n),(void*)x,n*sizeof(double)); } } return 0; } static struct DSDPDualMat_Ops sdmatops; static const char* tmatname="SPARSE PSD"; static int SDualOpsInitialize(struct DSDPDualMat_Ops* sops){ int info; if (sops==NULL) return 0; info=DSDPDualMatOpsInitialize(sops); DSDPCHKERR(info); sops->matcholesky=SMatCholeskyFactor; sops->matsolveforward=SMatCholeskySolveForward; sops->matsolvebackward=SMatCholeskySolveBackward; sops->matinversemultiply=SMatSolve; sops->matinvert=SMatInvert; sops->matinverseadd=SMatInverseAdd; sops->matforwardmultiply=SMatCholeskyForwardMultiply; sops->matseturmat=SMatSetURMat; sops->matfull=SMatFull; sops->matdestroy=SMatDestroy; sops->matgetsize=SMatGetSize; sops->matview=SMatView; sops->matlogdet=SMatLogDet; sops->matname=tmatname; return 0; } static int dcholmatcreate(int n, char UPLQ, chfac *sp, struct DSDPDualMat_Ops **sops, void**smat){ spmat *S; int info; DSDPCALLOC1(&S,spmat,&info);DSDPCHKERR(info); S->UPLQ=UPLQ; S->n=n; S->sinv=0; S->dsinv=0; S->spsym=sp; info=SDualOpsInitialize(&sdmatops);DSDPCHKERR(info); *sops=&sdmatops; *smat=(void*)S; return 0; } static int dcholmatsinverse(int n, spmat *S1, spmat *S2){ int info; double *ssinv; DSDPCALLOC2(&ssinv,double,n*n,&info); S1->sinv=ssinv; S2->sinv=ssinv; S2->dsinv=1; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPDenseDualMatCreate" int DSDPDenseDualMatCreate(int n, char UPLQ, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ int info=0; chfac *sp; DSDPFunctionBegin; info=MchlSetup2(n,&sp); DSDPCHKERR(info); info=dcholmatcreate(n,UPLQ,sp,sops1,smat1);DSDPCHKERR(info); info=MchlSetup2(n,&sp); DSDPCHKERR(info); info=dcholmatcreate(n,UPLQ,sp,sops1,smat2);DSDPCHKERR(info); info=dcholmatsinverse(n,(spmat*)(*smat1),(spmat*)(*smat2));DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSparseDualMatCreate" int DSDPSparseDualMatCreate(int n, int *rnnz, int *snnz, int trank,char UPLQ,int*nnzz, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ int nnz,info=0; chfac *sp; DSDPFunctionBegin; SymbProc(rnnz,snnz,n,&sp); DSDPCHKERR(info); info=dcholmatcreate(n,UPLQ,sp,sops1,smat1);DSDPCHKERR(info); SymbProc(rnnz,snnz,n,&sp); DSDPCHKERR(info); info=dcholmatcreate(n,UPLQ,sp,sops2,smat2);DSDPCHKERR(info); nnz=sp->unnz;*nnzz=nnz; if (trank>2*n+2){ info=dcholmatsinverse(n,(spmat*)(*smat1),(spmat*)(*smat2));DSDPCHKERR(info); } DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/cholmat.c0000644000175000017500000002310610326241003015633 0ustar twernertwerner#include "numchol.h" #include "dsdpschurmat_impl.h" #include "dsdpsys.h" #include "dsdpvec.h" #include "dsdp5.h" /*! \file cholmat.c \brief Sparse Cholesky for Schur complement matrix */ int DSDPSparsityInSchurMat(DSDP, int, int *, int); int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*,void*); typedef struct { chfac *M; int m; int isdense; int *rnnz; int *colnnz; int nnz; DSDPVec D1; DSDP dsdp; } MCholSolverALL; static int dsdpuselapack=1; #undef __FUNCT__ #define __FUNCT__ "DSDPUseLAPACKForSchur" int DSDPUseLAPACKForSchur(DSDP dsdp,int flag){ DSDPFunctionBegin; dsdpuselapack = flag; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Taddline" static int Taddline(void* M, int row, double dd, double v[], int m){ int info; MCholSolverALL *AMA = (MCholSolverALL *)M; DSDPFunctionBegin; info=MatAddColumn4(AMA->M,dd,v,row); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tadddiagonal" static int Tadddiagonal(void* M, int row, double v){ int info; MCholSolverALL *AMA = (MCholSolverALL *)M; DSDPFunctionBegin; info=MatAddDiagonalElement(AMA->M,row,v); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tassemble" static int Tassemble(void*M){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCheckForSparsity" static int DSDPCheckForSparsity( DSDP dsdp, int m, int *rnnz, int tnnz[], int *totalnnz){ int info,i,j,tottalnnz=0; DSDPFunctionBegin; memset(rnnz,0,(m+1)*sizeof(int)); for (i=0;i0) rnnz[i+1]++;} } for (i=0;im,m=ABA->m; DSDP dsdp=ABA->dsdp; DSDPFunctionBegin; DSDPCALLOC2(&snnz,int,(totalnnz+1),&info); DSDPCHKERR(info); DSDPCALLOC2(&rnnz,int,(m+1),&info); DSDPCHKERR(info); for (i=0;i<=m;i++){ rnnz[i]=rrnnz[i];} tt=0; for (i=0;i0) {snnz[tt]=j; tt++;} } } printf("Trying Sparse M: Total nonzeros: %d of %d \n",totalnnz,m*(m-1)/2 ); /* Create sparse dual matrix structure */ SymbProc(rnnz+1,snnz,n,&sfptr); ABA->isdense=0; ABA->M=sfptr; ABA->nnz=totalnnz; ABA->rnnz=rnnz; ABA->colnnz=snnz; *M=sfptr; for (i=0;iinvp; for (i=m-1;i>=0;i--){ for (j=rnnz[i+1]-1;j>=rnnz[i];j--){ col=snnz[j]; tt=perm[col]; if (perm[i] > tt ){ for (k=j;kM; /* Cfact=(cfc_sta)ChlFact(sf,sf->iw,sf->rw,FALSE); */ Cfact=(cfc_sta)ChlFact(sf,sf->iw,sf->rw,TRUE); if (CfcOk!=Cfact ){ *flag=1; /* printf("Not Good factorization \n"); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLinearSolve" static int DSDPLinearSolve2(void* ctx, double dd[], double xx[], int n){ int i,info; double *bb; MCholSolverALL *AMA = (MCholSolverALL *)ctx; DSDPFunctionBegin; info=DSDPVecGetArray(AMA->D1, &bb);DSDPCHKERR(info); for (i=0;iM, bb, xx); info=DSDPVecRestoreArray(AMA->D1, &bb); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGramMatRowNonzeros" static int DSDPGramMatRowNonzeros(void*M, int row, double cols[], int *ncols, int nrows){ MCholSolverALL *AMA = (MCholSolverALL *)M; int i; DSDPFunctionBegin; if (AMA->isdense){ *ncols = nrows-row; for (i=row;irnnz[row+1] - AMA->rnnz[row]+1; cols[row]=1.0; for (i=AMA->rnnz[row]; irnnz[row+1]; i++){ cols[AMA->colnnz[i]]=1.0; } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tzero" static int Tzero(void*M){ int info; MCholSolverALL *AMA = (MCholSolverALL *)M; DSDPFunctionBegin; info=MatZeroEntries4(AMA->M); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tdestroy" static int Tdestroy(void*M){ MCholSolverALL *AMA = (MCholSolverALL *)M; int info; DSDPFunctionBegin; CfcFree(&AMA->M); info = DSDPVecDestroy(&AMA->D1); DSDPCHKERR(info); if (AMA->isdense==0 && AMA->rnnz ){ DSDPFREE(&AMA->rnnz,&info);DSDPCHKERR(info); DSDPFREE(&AMA->colnnz,&info);DSDPCHKERR(info); } DSDPFREE(&AMA,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } static int Tsetup(void*M, int m){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static int TTTMatMult(void*M,double x[],double y[],int n){ MCholSolverALL *AMA = (MCholSolverALL *)M; int info; DSDPFunctionBegin; info=MatMult4(AMA->M,x,y,n); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int TTTMatShiftDiagonal(void *M, double d){ MCholSolverALL *AMA = (MCholSolverALL *)M; int info; DSDPFunctionBegin; info=Mat4DiagonalShift(AMA->M,d); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int TTTMatAddDiagonal(void *M, double diag[], int m){ MCholSolverALL *AMA = (MCholSolverALL *)M; int info; DSDPFunctionBegin; info=Mat4AddDiagonal(AMA->M,diag,m); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int TTTMatView(void *M){ MCholSolverALL *AMA = (MCholSolverALL *)M; int info; DSDPFunctionBegin; info=Mat4View(AMA->M); DSDPCHKERR(info); DSDPFunctionReturn(0); } /* static int TTTMatGetDiagonal(void *M, double d[], int n){ chfac*A = (chfac*)M; int info; DSDPFunctionBegin; info=Mat4GetDiagonal(A,d,n); DSDPCHKERR(info); DSDPFunctionReturn(0); } */ static const char* tmatname="SPARSE PSD"; static int TMatOpsInit(struct DSDPSchurMat_Ops *mops){ int info; DSDPFunctionBegin; info=DSDPSchurMatOpsInitialize(mops); DSDPCHKERR(info); mops->matrownonzeros=DSDPGramMatRowNonzeros; mops->mataddrow=Taddline; mops->matadddiagonal=TTTMatAddDiagonal; mops->mataddelement=Tadddiagonal; mops->matshiftdiagonal=TTTMatShiftDiagonal; mops->matassemble=Tassemble; mops->matscaledmultiply=TTTMatMult; mops->matfactor=DSDPLinearSolverPrepare; mops->matsolve=DSDPLinearSolve2; mops->matdestroy=Tdestroy; mops->matzero=Tzero; mops->matsetup=Tsetup; mops->matview=TTTMatView; mops->id=5; mops->matname=tmatname; DSDPFunctionReturn(0); } static struct DSDPSchurMat_Ops dsdpmatops; int DSDPGetDiagSchurMat(int, struct DSDPSchurMat_Ops **,void **); int DSDPGetLAPACKSUSchurOps(int,struct DSDPSchurMat_Ops**,void**); int DSDPGetLAPACKPUSchurOps(int,struct DSDPSchurMat_Ops**,void**); static int DSDPCreateM(MCholSolverALL*,chfac**,int[],int[],int); static int DSDPCreateSchurMatrix(void*,int); #undef __FUNCT__ #define __FUNCT__ "DSDPCreateSchurMatrix" static int DSDPCreateSchurMatrix(void *ctx, int m){ int info; int *rnnz,*tnnz,totalnnz; int gotit=0; DSDP dsdp=(DSDP)ctx; chfac *sf; MCholSolverALL *AMA; void *tdata; struct DSDPSchurMat_Ops *tmatops; DSDPFunctionBegin; if (m<=1){ info=DSDPGetDiagSchurMat(m,&tmatops,&tdata); DSDPCHKERR(info); info=DSDPSetSchurMatOps(dsdp,tmatops,tdata); DSDPCHKERR(info); return 0; } DSDPCALLOC2(&rnnz,int,(m+1),&info); DSDPCHKERR(info); DSDPCALLOC2(&tnnz,int,(m+1),&info); DSDPCHKERR(info); info=DSDPCheckForSparsity(dsdp,m,rnnz,tnnz,&totalnnz); DSDPCHKERR(info); if (totalnnz*2+m > m*m*0.1 && dsdpuselapack) { gotit=1; info=DSDPGetLAPACKSUSchurOps(m,&tmatops,&tdata); /* DSDPCHKERR(info); */ if (info) {gotit=0;printf("Try packed format\n"); } DSDPLogInfo(0,8,"Creating Dense Full LAPACK Schur Matrix\n"); info=DSDPSetSchurMatOps(dsdp,tmatops,tdata); DSDPCHKERR(info); } if ( 0 && totalnnz*2+m > m*m*0.1 && dsdpuselapack) { info=DSDPGetLAPACKPUSchurOps(m,&tmatops,&tdata); DSDPCHKERR(info); DSDPLogInfo(0,8,"Creating Dense Packed LAPACK Schur Matrix\n"); info=DSDPSetSchurMatOps(dsdp,tmatops,tdata); DSDPCHKERR(info); gotit=1; } if (gotit==0){ DSDPCALLOC1(&AMA,MCholSolverALL,&info);DSDPCHKERR(info); AMA->dsdp=dsdp; AMA->m=m; info=DSDPVecCreateSeq(m,&AMA->D1); DSDPCHKERR(info); if (totalnnz*2+m > m*m * 0.11 ){ info=MchlSetup2(m,&sf); DSDPCHKERR(info); AMA->M=sf; AMA->isdense=1; AMA->rnnz=0; AMA->colnnz=0; DSDPLogInfo(0,8,"Creating Dense Full non LAPACK Schur Matrix\n"); } else { info=DSDPCreateM(AMA,&sf,rnnz,tnnz,totalnnz); DSDPCHKERR(info); DSDPLogInfo(0,8,"Creating Sparse Schur Matrix\n"); } AMA->M=sf; info=TMatOpsInit(&dsdpmatops); DSDPCHKERR(info); info=DSDPSetSchurMatOps(dsdp,&dsdpmatops,(void*)AMA); DSDPCHKERR(info); } DSDPFREE(&tnnz,&info);DSDPCHKERR(info); DSDPFREE(&rnnz,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } static struct DSDPSchurMat_Ops dsdpmatops000; #undef __FUNCT__ #define __FUNCT__ "DSDPSetDefaultSchurMatrixStructure" int DSDPSetDefaultSchurMatrixStructure(DSDP dsdp){ int info; DSDPFunctionBegin; info=DSDPSchurMatOpsInitialize(&dsdpmatops000); DSDPCHKERR(info); dsdpmatops000.matsetup=DSDPCreateSchurMatrix; info=DSDPSetSchurMatOps(dsdp,&dsdpmatops000,(void*)dsdp);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/diag.c0000644000175000017500000002553510326241003015120 0ustar twernertwerner #include "dsdpschurmat_impl.h" #include "dsdpdualmat_impl.h" #include "dsdpdsmat_impl.h" #include "dsdpsys.h" /*! \file diag.c \brief DSDPDualMat, DSDPDSMat, and the DSDPSchurMat implentations for diagonal matrices. */ typedef struct { int n; double *val; int owndata; } diagmat; static int DiagMatCreate(int,diagmat**); static int DiagMatMult(void*,double[],double[],int); static int DiagMatGetSize(void*, int *); static int DiagMatAddRow2(void*, int, double, double[], int); static int DiagMatDestroy(void*); static int DiagMatView(void*); static int DiagMatLogDeterminant(void*, double *); /* static int DiagMatScale(double *, diagmat *); */ static int DiagMatCreate(int n,diagmat**M){ int info; diagmat *M7; DSDPCALLOC1(&M7,diagmat,&info);DSDPCHKERR(info); DSDPCALLOC2(&M7->val,double,n,&info);DSDPCHKERR(info); if (n>0 && M7->val==NULL) return 1; M7->owndata=1; M7->n=n; *M=M7; return 0; } static int DiagMatDestroy(void* AA){ int info; diagmat* A=(diagmat*) AA; if (A->owndata && A->val){ DSDPFREE(&A->val,&info);DSDPCHKERR(info);} DSDPFREE(&A,&info);DSDPCHKERR(info); return 0; } static int DiagMatMult(void* AA, double x[], double y[], int n){ diagmat* A=(diagmat*) AA; double *vv=A->val; int i; if (A->n != n) return 1; if (x==0 && n>0) return 3; if (y==0 && n>0) return 3; for (i=0; in; return 0; } static int DiagMatView(void* AA){ diagmat* A=(diagmat*) AA; int i; for (i=0;in; i++){ printf(" Row: %d, Column: %d, Value: %8.4e \n",i,i,A->val[i]); } return 0; } static int DiagMatAddRow2(void* AA, int nrow, double dd, double row[], int n){ diagmat* A=(diagmat*) AA; A->val[nrow] += dd*row[nrow]; return 0; } static int DiagMatAddElement(void*A, int nrow, double dd){ diagmat* AA = (diagmat*)A; AA->val[nrow] += dd; return 0; } static int DiagMatZeros(void*A){ diagmat* AA = (diagmat*)A; int n=AA->n; memset(AA->val,0,n*sizeof(double)); return 0; } static int DiagMatSolve(void* A, double b[], double x[],int n){ diagmat* AA = (diagmat*)A; double *v=AA->val; int i; for (i=0;ival; int i,j; memset((void*)x,0,n*sizeof(double)); for (j=0;jval; int i,n=AA->n; *flag=0; for (i=0;ival; int i,n=AA->n; for (i=0;ival; for (i=0;ival; for (i=0;ival; for (i=0;ival; for (i=0;imatcholesky=DiagMatCholeskyFactor; sops->matsolveforward=DiagMatSolve; sops->matsolvebackward=DiagMatCholeskySolveBackward; sops->matinvert=DiagMatInvert; sops->matinverseadd=DiagMatInverseAddP; sops->matinversemultiply=DiagMatSolve2; sops->matseturmat=DiagMatTakeUREntriesP; sops->matfull=DiagMatFull; sops->matdestroy=DiagMatDestroy; sops->matgetsize=DiagMatGetSize; sops->matview=DiagMatView; sops->matlogdet=DiagMatLogDeterminant; sops->id=9; sops->matname=diagmatname; return 0; } static int DiagDualOpsInitializeU(struct DSDPDualMat_Ops* sops){ int info; if (sops==NULL) return 0; info=DSDPDualMatOpsInitialize(sops); DSDPCHKERR(info); sops->matcholesky=DiagMatCholeskyFactor; sops->matsolveforward=DiagMatSolve; sops->matsolvebackward=DiagMatCholeskySolveBackward; sops->matinvert=DiagMatInvert; sops->matinversemultiply=DiagMatSolve2; sops->matseturmat=DiagMatTakeUREntriesU; sops->matfull=DiagMatFull; sops->matinverseadd=DiagMatInverseAddU; sops->matdestroy=DiagMatDestroy; sops->matgetsize=DiagMatGetSize; sops->matview=DiagMatView; sops->matlogdet=DiagMatLogDeterminant; sops->id=9; sops->matname=diagmatname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPDiagDualMatCreateP" int DSDPDiagDualMatCreateP(int n, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ diagmat *AA; int info; DSDPFunctionBegin; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DiagDualOpsInitializeP(&sdmatopsp); DSDPCHKERR(info); *sops1=&sdmatopsp; *smat1=(void*)AA; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DiagDualOpsInitializeP(&sdmatopsp); DSDPCHKERR(info); *sops2=&sdmatopsp; *smat2=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDiagDualMatCreateU" int DSDPDiagDualMatCreateU(int n, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ diagmat *AA; int info; DSDPFunctionBegin; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DiagDualOpsInitializeU(&sdmatopsu); DSDPCHKERR(info); *sops1=&sdmatopsu; *smat1=(void*)AA; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DiagDualOpsInitializeU(&sdmatopsu); DSDPCHKERR(info); *sops2=&sdmatopsu; *smat2=(void*)AA; DSDPFunctionReturn(0); } static int DiagMatVecVec(void*A,double x[], int n, double *vv){ diagmat* AA = (diagmat*)A; double *v=AA->val,vAv=0; int i; for (i=0;imatseturmat=DiagMatTakeUREntriesP; ddiagops->matview=DiagMatView; ddiagops->matgetsize=DiagMatGetSize; ddiagops->matmult=DiagMatMult; ddiagops->matvecvec=DiagMatVecVec; ddiagops->matzeroentries=DiagMatZeros; ddiagops->matdestroy=DiagMatDestroy; ddiagops->id=9; ddiagops->matname=diagmatname; DSDPFunctionReturn(0); } static int DDiagDSMatOpsInitU(struct DSDPDSMat_Ops *ddiagops){ int info; if (ddiagops==NULL) return 0; info=DSDPDSMatOpsInitialize(ddiagops);DSDPCHKERR(info); ddiagops->matseturmat=DiagMatTakeUREntriesU; ddiagops->matview=DiagMatView; ddiagops->matgetsize=DiagMatGetSize; ddiagops->matmult=DiagMatMult; ddiagops->matvecvec=DiagMatVecVec; ddiagops->matzeroentries=DiagMatZeros; ddiagops->matdestroy=DiagMatDestroy; ddiagops->id=9; ddiagops->matname=diagmatname; DSDPFunctionReturn(0); } static struct DSDPDSMat_Ops dsdiagmatopsp; static struct DSDPDSMat_Ops dsdiagmatopsu; #undef __FUNCT__ #define __FUNCT__ "DSDPDiagDSMatP" int DSDPCreateDiagDSMatP(int n,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info=0; diagmat *AA; DSDPFunctionBegin; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DDiagDSMatOpsInitP(&dsdiagmatopsp); DSDPCHKERR(info); *dsmatops=&dsdiagmatopsp; *dsmat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDiagDSMatU" int DSDPCreateDiagDSMatU(int n,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info=0; diagmat *AA; DSDPFunctionBegin; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DDiagDSMatOpsInitU(&dsdiagmatopsu); DSDPCHKERR(info); *dsmatops=&dsdiagmatopsu; *dsmat=(void*)AA; DSDPFunctionReturn(0); } static int DiagRowNonzeros(void*M, int row, double cols[], int *ncols,int nrows){ DSDPFunctionBegin; *ncols = 1; cols[row]=1.0; DSDPFunctionReturn(0); } static int DiagAddDiag(void*M, double diag[], int m){ diagmat* AA = (diagmat*)M; double *v=AA->val; int i; DSDPFunctionBegin; for (i=0;ival; int i; DSDPFunctionBegin; for (i=0;ival; int i,m=AA->n; DSDPFunctionBegin; for (i=0;ival[ii]+=dd; DSDPFunctionReturn(0); } static int DiagMatOnProcessor(void*A,int row,int*flag){ *flag=1; return 0; } static int DiagAssemble(void*M){ return 0; } static struct DSDPSchurMat_Ops dsdpdiagschurops; #undef __FUNCT__ #define __FUNCT__ "DSDPDiagSchurOps" static int DiagSchurOps(struct DSDPSchurMat_Ops *sops){ int info; DSDPFunctionBegin; if (!sops) return 0; info=DSDPSchurMatOpsInitialize(sops); DSDPCHKERR(info); sops->matzero=DiagMatZeros; sops->mataddrow=DiagMatAddRow2; sops->mataddelement=DiagMatAddElement; sops->matdestroy=DiagMatDestroy; sops->matfactor=DiagMatCholeskyFactor; sops->matsolve=DiagMatSolve; sops->matadddiagonal=DiagAddDiag; sops->matshiftdiagonal=DiagShiftDiag; sops->mataddelement=DiagAddElement; sops->matscaledmultiply=DiagMultiply; sops->matassemble=DiagAssemble; sops->pmatonprocessor=DiagMatOnProcessor; sops->matrownonzeros=DiagRowNonzeros; sops->id=9; sops->matname=diagmatname; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetDiagSchurMat" int DSDPGetDiagSchurMat(int n, struct DSDPSchurMat_Ops **sops, void **data){ int info=0; diagmat *AA; DSDPFunctionBegin; info=DiagMatCreate(n,&AA); DSDPCHKERR(info); info=DiagSchurOps(&dsdpdiagschurops); DSDPCHKERR(info); if (sops){*sops=&dsdpdiagschurops;} if (data){*data=(void*)AA;} DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/dlpack.c0000644000175000017500000006053310326241003015447 0ustar twernertwerner#include "dsdpsys.h" #include "dsdpvec.h" #include "dsdplapack.h" /*! \file dlpack.c \brief DSDPDataMat, DSDPDualMat, DSDPDSMat, DSDPSchurMat, DSDPXMat, objects implemented in dense upper packed symmetric format. */ typedef struct{ char UPLO; double *val; double *v2; double *sscale; int scaleit; int n; int owndata; } dtpumat; static const char* lapackname="DENSE,SYMMETRIC,PACKED STORAGE"; int DTPUMatEigs(void*AA,double W[],double IIWORK[], int nn1, double *mineig){ dtpumat* AAA=(dtpumat*) AA; ffinteger info,INFO=0,M,N=AAA->n; ffinteger IL=1,IU=1,LDZ=1,IFAIL; ffinteger *IWORK=(ffinteger*)IIWORK; double *AP=AAA->val,ABSTOL=1e-13; double Z=0,VL=-1e10,VU=1; double *WORK; char UPLO=AAA->UPLO,JOBZ='N',RANGE='I'; DSDPCALLOC2(&WORK,double,7*N,&info);DSDPCHKERR(info); DSDPCALLOC2(&IWORK,ffinteger,5*N,&info);DSDPCHKERR(info); dspevx(&JOBZ,&RANGE,&UPLO,&N,AP,&VL,&VU,&IL,&IU,&ABSTOL,&M,W,&Z,&LDZ,WORK,IWORK,&IFAIL,&INFO); /* DSDPCALLOC2(&WORK,double,2*N,&info); LWORK=2*N; dspevd(&JOBZ,&UPLO,&N,AP,W,&Z,&LDZ,WORK,&LWORK,IWORK,&LIWORK,&INFO); */ *mineig=W[0]; DSDPFREE(&WORK,&info);DSDPCHKERR(info); DSDPFREE(&IWORK,&info);DSDPCHKERR(info); return INFO; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKROUTINE" static void dtpuscalevec(double alpha, double v1[], double v2[], double v3[], int n){ int i; for (i=0;isscale,double,n,&info);DSDPCHKERR(info); M23->owndata=0; M23->val=nz; M23->n=n; M23->UPLO='U'; for (i=0;isscale[i]=1.0; M23->scaleit=0; *M=M23; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACK ROUTINE" static int DTPUMatMult(void* AA, double x[], double y[], int n){ dtpumat* A=(dtpumat*) AA; ffinteger ione=1,N=n; double BETA=0.0,ALPHA=1.0; double *AP=A->val,*Y=y,*X=x; char UPLO=A->UPLO; if (A->n != n) return 1; if (x==0 && n>0) return 3; dspmv(&UPLO,&N,&ALPHA,AP,X,&ione,&BETA,Y,&ione); return 0; } static int DTPUMatSolve(void* AA, double b[], double x[], int n){ dtpumat* A=(dtpumat*) AA; ffinteger INFO,NRHS=1,LDB=A->n,N=A->n; double *AP=A->val,*ss=A->sscale; char UPLO=A->UPLO; if (N>0) LDB=N; dtpuscalevec(1.0,ss,b,x,n); dpptrs(&UPLO, &N, &NRHS, AP, x, &LDB, &INFO ); dtpuscalevec(1.0,ss,x,x,n); return INFO; } static int DTPUMatCholeskyFactor(void* AA, int *flag){ dtpumat* A=(dtpumat*) AA; int i; ffinteger INFO,LDA=1,N=A->n; double *AP=A->val,*ss=A->sscale,*v; char UPLO=A->UPLO; if (N<=0) LDA=1; else LDA=N; if (A->scaleit){ for (v=AP,i=0;in; double *v=A->val; for (i=0; ival[ii] +=dd; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DTPUMatDiag2" static int DTPUMatDiag2(void*M, double diag[], int m){ int row,ii; dtpumat* ABA=(dtpumat*)M; DSDPFunctionBegin; for (row=0;rowval[ii] +=diag[row]; } DSDPFunctionReturn(0); } static int DTPUMatAddRow(void* AA, int nrow, double dd, double row[], int n){ dtpumat* A=(dtpumat*) AA; ffinteger ione=1,nn,nnn; double *vv=A->val; nnn=nrow*(nrow+1)/2; nn=nrow+1; daxpy(&nn,&dd,row,&ione,vv+nnn,&ione); return 0; } static int DTPUMatZero(void* AA){ dtpumat* A=(dtpumat*) AA; int mn=A->n*(A->n+1)/2; double *vv=A->val; memset((void*)vv,0,mn*sizeof(double)); return 0; } static int DTPUMatGetSize(void *AA, int *n){ dtpumat* A=(dtpumat*) AA; *n=A->n; return 0; } static int DTPUMatDestroy(void* AA){ int info; dtpumat* A=(dtpumat*) AA; if (A && A->owndata){DSDPFREE(&A->val,&info);DSDPCHKERR(info);} if (A && A->sscale) {DSDPFREE(&A->sscale,&info);DSDPCHKERR(info);} if (A) {DSDPFREE(&A,&info);DSDPCHKERR(info);} return 0; } static int DTPUMatView(void* AA){ dtpumat* M=(dtpumat*) AA; int i,j,kk=0; double *val=M->val; for (i=0; in; i++){ for (j=0; j<=i; j++){ printf(" %9.2e",val[kk]); kk++; } printf("\n"); } return 0; } #include "dsdpschurmat_impl.h" #include "dsdpsys.h" static struct DSDPSchurMat_Ops dsdpmmatops; static int DSDPInitSchurOps(struct DSDPSchurMat_Ops* mops){ int info; DSDPFunctionBegin; info=DSDPSchurMatOpsInitialize(mops);DSDPCHKERR(info); mops->matrownonzeros=DTPUMatRowNonzeros; mops->matscaledmultiply=DTPUMatMult; mops->mataddrow=DTPUMatAddRow; mops->mataddelement=DTPUMatDiag; mops->matadddiagonal=DTPUMatDiag2; mops->matshiftdiagonal=DTPUMatShiftDiagonal; mops->matassemble=DTPUMatAssemble; mops->matfactor=DTPUMatCholeskyFactor; mops->matsolve=DTPUMatSolve; mops->matdestroy=DTPUMatDestroy; mops->matzero=DTPUMatZero; mops->matview=DTPUMatView; mops->id=1; mops->matname=lapackname; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetLAPACKPUSchurOps" int DSDPGetLAPACKPUSchurOps(int n,struct DSDPSchurMat_Ops** sops, void** mdata){ int info,nn=n*(n+1)/2; double *vv; dtpumat*AA; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTPUMatCreateWData(n,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1; AA->scaleit=1; info=DSDPInitSchurOps(&dsdpmmatops); DSDPCHKERR(info); *sops=&dsdpmmatops; *mdata=(void*)AA; DSDPFunctionReturn(0); } static void daddrow(double *v, double alpha, int i, double row[], int n){ double *s1; ffinteger j,nn=n,ione=1; nn=i+1; s1=v+i*(i+1)/2; daxpy(&nn,&alpha,s1,&ione,row,&ione); for (j=i+1;jv2,*Y=y,*X=x; int i,ii; char UPLO=A->UPLO; if (A->n != n) return 1; if (x==0 && n>0) return 3; if (nindn,INCX=1; double *AP=M->val,*ss=M->sscale; char UPLO=M->UPLO,TRANS='N',DIAG='N'; memcpy(x,b,N*sizeof(double)); dtpsv(&UPLO,&TRANS,&DIAG, &N, AP, x, &INCX ); dtpuscalevec(1.0,ss,x,x,n); return 0; } static int DTPUMatCholeskyForward(void* AA, double b[], double x[], int n){ dtpumat* M=(dtpumat*) AA; ffinteger N=M->n,INCX=1; double *AP=M->val,*ss=M->sscale; char UPLO=M->UPLO,TRANS='T',DIAG='N'; dtpuscalevec(1.0,ss,b,x,n); dtpsv(&UPLO,&TRANS,&DIAG, &N, AP, x, &INCX); return 0; } static int DenseSymPSDCholeskyForwardMultiply(void* AA, double x[], double y[], int n){ dtpumat* A=(dtpumat*) AA; int i,j,k=0; ffinteger N=A->n; double *AP=A->val,*ss=A->sscale; if (x==0 && N>0) return 3; for (i=0;in; double d=0,*v=A->val,*ss=A->sscale; for (i=0; in,nn=N*(N+1)/2; double *v=A->val,*AP=A->v2,*ss=A->sscale; char UPLO=A->UPLO; memcpy((void*)AP,(void*)v,nn*sizeof(double)); dpptri(&UPLO, &N, AP, &INFO ); if (INFO){ INFO=DTPUMatShiftDiagonal(AA,1e-11); memcpy((void*)AP,(void*)v,nn*sizeof(double)); dpptri(&UPLO, &N, AP, &INFO ); } if (A->scaleit){ dtpuscalemat(AP,ss,N); } return INFO; } static int DTPUMatInverseAdd(void* AA, double alpha, double y[], int nn, int n){ dtpumat* A=(dtpumat*) AA; ffinteger N=nn,ione=1; double *v2=A->v2; daxpy(&N,&alpha,v2,&ione,y,&ione); return 0; } static int DTPUMatScaleDiagonal(void* AA, double dd){ dtpumat* A=(dtpumat*) AA; int i,n=A->n; double *v=A->val; for (i=0; ival; char UPLO=A->UPLO; dspr(&UPLO,&N,&alpha,x,&ione,v); return 0; } static int DenseSymPSDNormF2(void* AA, int n, double *dddot){ dtpumat* A=(dtpumat*) AA; ffinteger ione=1,nn=A->n*(A->n+1)/2; double dd,tt=sqrt(0.5),*val=A->val; int info; info=DTPUMatScaleDiagonal(AA,tt); dd=dnrm2(&nn,val,&ione); info=DTPUMatScaleDiagonal(AA,1.0/tt); *dddot=dd*dd*2; return 0; } /* static int DTPUMatFNorm2(void* AA, double *mnorm){ dtpumat* A=(dtpumat*) AA; ffinteger ione=1,n; double vv=0,*AP=A->val; n=A->n*(A->n+1)/2; vv=dnrm2(&n,AP,&ione); *mnorm=2.0*vv; return 1; } */ #include "dsdpdualmat_impl.h" #include "dsdpdatamat_impl.h" #include "dsdpxmat_impl.h" #include "dsdpdsmat_impl.h" static int DTPUMatFull(void*A, int*full){ *full=1; return 0; } static int DTPUMatGetDenseArray(void* A, double *v[], int*n){ dtpumat* ABA=(dtpumat*)A; *v=ABA->val; *n=(ABA->n)*(ABA->n+1)/2; return 0; } static int DTPUMatRestoreDenseArray(void* A, double *v[], int *n){ *v=0;*n=0; return 0; } static int DDenseSetXMat(void*A, double v[], int nn, int n){ double *vv; dtpumat* ABA=(dtpumat*)A; vv=ABA->val; if (v!=vv){ memcpy((void*)vv,(void*)v,nn*sizeof(double)); } return 0; } static int DDenseVecVec(void* A, double x[], int n, double *v){ dtpumat* ABA=(dtpumat*)A; int i,j,k=0; double dd=0,*val=ABA->val; *v=0.0; for (i=0; imatseturmat=DDenseSetXMat; densematops->matview=DTPUMatView; densematops->matdestroy=DTPUMatDestroy; densematops->matgetsize=DTPUMatGetSize; densematops->matzeroentries=DTPUMatZero; densematops->matmult=DTPUMatMult; densematops->matvecvec=DDenseVecVec; densematops->id=1; densematops->matname=lapackname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDSMatWithArray" int DSDPCreateDSMatWithArray(int n,double vv[], int nnz, struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info; dtpumat*AA; DSDPFunctionBegin; info=DTPUMatCreateWData(n,vv,nnz,&AA); DSDPCHKERR(info); AA->owndata=0; info=DSDPDSDenseInitializeOps(&tdsdensematops); DSDPCHKERR(info); *dsmatops=&tdsdensematops; *dsmat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDSMat" int DSDPCreateDSMat(int n,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info,nn=n*(n+1)/2; double *vv; dtpumat*AA; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTPUMatCreateWData(n,vv,nn,&AA); DSDPCHKERR(info); info=DSDPDSDenseInitializeOps(&tdsdensematops); DSDPCHKERR(info); *dsmatops=&tdsdensematops; *dsmat=(void*)AA; AA->owndata=1; DSDPFunctionReturn(0); } static struct DSDPVMat_Ops turdensematops; static int DSDPDenseXInitializeOps(struct DSDPVMat_Ops* densematops){ int info; if (!densematops) return 0; info=DSDPVMatOpsInitialize(densematops); DSDPCHKERR(info); densematops->matview=DTPUMatView; densematops->matscalediagonal=DTPUMatScaleDiagonal; densematops->matshiftdiagonal=DTPUMatShiftDiagonal; densematops->mataddouterproduct=DTPUMatOuterProduct; densematops->matdestroy=DTPUMatDestroy; densematops->matfnorm2=DenseSymPSDNormF2; densematops->matgetsize=DTPUMatGetSize; densematops->matzeroentries=DTPUMatZero; densematops->matgeturarray=DTPUMatGetDenseArray; densematops->matrestoreurarray=DTPUMatRestoreDenseArray; densematops->matmineig=DTPUMatEigs; densematops->matmult=DTPUMatMult; densematops->id=1; densematops->matname=lapackname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPXMatCreate" int DSDPXMatPCreate(int n,struct DSDPVMat_Ops* *xops, void * *xmat){ int info,nn=n*(n+1)/2; double *vv; dtpumat*AA; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTPUMatCreateWData(n,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1; info=DSDPDenseXInitializeOps(&turdensematops); DSDPCHKERR(info); *xops=&turdensematops; *xmat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPXMatCreate" int DSDPXMatPCreateWithData(int n,double nz[],int nnz,struct DSDPVMat_Ops* *xops, void * *xmat){ int i,info; double dtmp; dtpumat*AA; DSDPFunctionBegin; for (i=0;imatseturmat=DDenseSetXMat; sops->matcholesky=DTPUMatCholeskyFactor; sops->matsolveforward=DTPUMatCholeskyForward; sops->matsolvebackward=DTPUMatCholeskyBackward; sops->matinvert=DTPUMatInvert; sops->matinverseadd=DTPUMatInverseAdd; sops->matinversemultiply=DTPUMatInverseMult; sops->matforwardmultiply=DenseSymPSDCholeskyForwardMultiply; sops->matfull=DTPUMatFull; sops->matdestroy=DTPUMatDestroy; sops->matgetsize=DTPUMatGetSize; sops->matview=DTPUMatView; sops->matlogdet=DTPUMatLogDet; sops->matname=lapackname; sops->id=1; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKDualMatCreate" int DSDPLAPACKPUDualMatCreate(int n,struct DSDPDualMat_Ops **sops, void**smat){ int info,nn=n*(n+1)/2; double *vv; dtpumat*AA; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTPUMatCreateWData(n,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1;; AA->scaleit=1; info=SDualOpsInitialize(&sdmatops);DSDPCHKERR(info); *sops=&sdmatops; *smat=(void*)AA; DSDPFunctionReturn(0); } static int switchptr(void* SD,void *SP){ dtpumat *s1,*s2; s1=(dtpumat*)(SD); s2=(dtpumat*)(SP); s1->v2=s2->val; s2->v2=s1->val; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKDualMatCreate2" int DSDPLAPACKPUDualMatCreate2(int n, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ int info; DSDPFunctionBegin; info=DSDPLAPACKPUDualMatCreate(n,sops1,smat1);DSDPCHKERR(info); info=DSDPLAPACKPUDualMatCreate(n,sops2,smat2);DSDPCHKERR(info); info=switchptr(*smat1,*smat2); DSDPFunctionReturn(0); } typedef struct { int neigs; double *eigval; double *an; } Eigen; typedef struct { dtpumat* AA; double alpha; Eigen Eig; } dvechmat; #undef __FUNCT__ #define __FUNCT__ "CreateDvechmatWData" static int CreateDvechmatWdata(int n, double alpha, double vv[], dvechmat **A){ int info,nn=(n*n+n)/2; dvechmat* V; DSDPCALLOC1(&V,dvechmat,&info);DSDPCHKERR(info); info=DTPUMatCreateWData(n,vv,nn,&V->AA); DSDPCHKERR(info); V->Eig.neigs=-1; V->Eig.eigval=0; V->Eig.an=0; V->alpha=alpha; *A=V; return 0; } static int DvechmatGetRowNnz(void* AA, int trow, int nz[], int *nnzz,int n){ int k; *nnzz=n; for (k=0;kval; nnn=nrow*(nrow+1)/2; for (i=0;iAA ,trow,scl*A->alpha,r,m); return 0; } static int DvechmatAddMultiple(void* AA, double alpha, double r[], int nnn, int n){ dvechmat* A=(dvechmat*)AA; ffinteger nn=nnn, ione=1; double *val=A->AA->val; alpha*=A->alpha; daxpy(&nn,&alpha,val,&ione,r,&ione); return 0; } static int DvechEigVecVec(void*, double[], int, double*); static int DvechmatVecVec(void* AA, double x[], int n, double *v){ dvechmat* A=(dvechmat*)AA; int i,j,k=0; double dd=0,*val=A->AA->val; *v=0.0; if (A->Eig.neigsalpha; } else { for (i=0; ialpha; } return 0; } static int DvechmatFNorm2(void* AA, int n, double *v){ dvechmat* A=(dvechmat*)AA; long int i,j,k=0; double dd=0,*x=A->AA->val; for (i=0; ialpha*A->alpha; return 0; } static int DvechmatCountNonzeros(void* AA, int *nnz, int n){ *nnz=n*(n+1)/2; return 0; } static int DvechmatDot(void* AA, double x[], int nn, int n, double *v){ dvechmat* A=(dvechmat*)AA; ffinteger ione=1,nnn=nn; double dd,*val=A->AA->val; dd=ddot(&nnn,val,&ione,x,&ione); *v=2*dd*A->alpha; return 0; } /* static int DvechmatNormF2(void* AA, int n, double *v){ dvechmat* A=(dvechmat*)AA; return(DTPUMatNormF2((void*)(A->AA), n,v)); } */ #undef __FUNCT__ #define __FUNCT__ "DvechmatDestroy" static int DvechmatDestroy(void* AA){ dvechmat* A=(dvechmat*)AA; int info; info=DTPUMatDestroy((void*)(A->AA)); if (A->Eig.an){DSDPFREE(&A->Eig.an,&info);DSDPCHKERR(info);} if (A->Eig.eigval){DSDPFREE(&A->Eig.eigval,&info);DSDPCHKERR(info);} A->Eig.neigs=-1; DSDPFREE(&A,&info);DSDPCHKERR(info); return 0; } static int DvechmatView(void* AA){ dvechmat* A=(dvechmat*)AA; dtpumat* M=A->AA; int i,j,kk=0; double *val=M->val; for (i=0; in; i++){ for (j=0; j<=i; j++){ printf(" %4.2e",A->alpha*val[kk]); kk++; } printf(" \n"); } return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDvechmatEigs" static int CreateEigenLocker(Eigen *E,int neigs, int n){ int info; DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,n*neigs,&info);DSDPCHKERR(info); E->neigs=neigs; return 0; } static int EigMatSetEig(Eigen* A,int row, double eigv, double v[], int n){ double *an=A->an; A->eigval[row]=eigv; memcpy((void*)(an+n*row),(void*)v,n*sizeof(double)); return 0; } static int EigMatGetEig(Eigen* A,int row, double *eigenvalue, double eigenvector[], int n){ double* an=A->an; *eigenvalue=A->eigval[row]; memcpy((void*)eigenvector,(void*)(an+n*row),n*sizeof(double)); return 0; } static int DvechmatComputeEigs(dvechmat*,double[],int,double[],int,double[],int,int[],int); static int DvechmatFactor(void*AA, double dmatp[], int nn0, double dwork[], int n, double ddwork[], int n1, int iptr[], int n2){ int info; dvechmat* A=(dvechmat*)AA; if (A->Eig.neigs>=0) return 0; info=DvechmatComputeEigs(A,dmatp,nn0,dwork,n,ddwork,n1,iptr,n2);DSDPCHKERR(info); return 0; } static int DvechmatGetRank(void *AA,int *rank, int n){ dvechmat* A=(dvechmat*)AA; if (A->Eig.neigs>=0){ *rank=A->Eig.neigs; } else { DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static int DvechmatGetEig(void* AA, int rank, double *eigenvalue, double vv[], int n, int indz[], int *nind){ dvechmat* A=(dvechmat*)AA; int i,info; double dd; if (A->Eig.neigs>0){ info=EigMatGetEig(&A->Eig,rank,&dd,vv,n);DSDPCHKERR(info); *nind=n; *eigenvalue=dd*A->alpha; for (i=0;iEig.neigs>=0){ an=A->Eig.an; neigs=A->Eig.neigs; eigval=A->Eig.eigval; for (rank=0;rankalpha; } else { DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static struct DSDPDataMat_Ops dvechmatops; static const char *datamatname="DENSE VECH MATRIX"; static int DvechmatOpsInitialize(struct DSDPDataMat_Ops *sops){ int info; if (sops==NULL) return 0; info=DSDPDataMatOpsInitialize(sops); DSDPCHKERR(info); sops->matvecvec=DvechmatVecVec; sops->matdot=DvechmatDot; sops->mataddrowmultiple=DvechmatGetRowAdd; sops->mataddallmultiple=DvechmatAddMultiple; sops->matview=DvechmatView; sops->matdestroy=DvechmatDestroy; sops->matfactor2=DvechmatFactor; sops->matgetrank=DvechmatGetRank; sops->matgeteig=DvechmatGetEig; sops->matrownz=DvechmatGetRowNnz; sops->matfnorm2=DvechmatFNorm2; sops->matnnz=DvechmatCountNonzeros; sops->id=1; sops->matname=datamatname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPGetDmat" int DSDPGetDMat(int n,double alpha, double *val, struct DSDPDataMat_Ops**sops, void**smat){ int info,k; double dtmp; dvechmat* A; DSDPFunctionBegin; for (k=0;kEig.neigs=-1; info=DvechmatOpsInitialize(&dvechmatops); DSDPCHKERR(info); if (sops){*sops=&dvechmatops;} if (smat){*smat=(void*)A;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DvechmatComputeEigs" static int DvechmatComputeEigs(dvechmat* AA,double DD[], int nn0, double W[], int n, double WORK[], int n1, int iiptr[], int n2){ int i,j,k,neigs,info; long int *i2darray=(long int*)DD; int ownarray1=0,ownarray2=0,ownarray3=0; double *val=AA->AA->val; double *dmatarray=0,*dworkarray=0,eps=1.0e-12; int nn1=0,nn2=0; /* create a dense array in which to put numbers */ if (n*n>nn1){ DSDPCALLOC2(&dmatarray,double,(n*n),&info); DSDPCHKERR(info); ownarray1=1; } memset((void*)dmatarray,0,n*n*sizeof(double)); if (n*n>nn2){ DSDPCALLOC2(&dworkarray,double,(n*n),&info); DSDPCHKERR(info); ownarray2=1; } if (n*n*sizeof(long int)>nn0*sizeof(double)){ DSDPCALLOC2(&i2darray,long int,(n*n),&info); DSDPCHKERR(info); ownarray3=1; } for (k=0,i=0; i eps ){ neigs++;} } info=CreateEigenLocker(&AA->Eig,neigs,n);DSDPCHKERR(info); /* Copy into structure */ for (neigs=0,i=0; i eps){ info=EigMatSetEig(&AA->Eig,neigs,W[i],dmatarray+n*i,n);DSDPCHKERR(info); neigs++; } } if (ownarray1){ DSDPFREE(&dmatarray,&info);DSDPCHKERR(info);} if (ownarray2){ DSDPFREE(&dworkarray,&info);DSDPCHKERR(info);} if (ownarray3){ DSDPFREE(&i2darray,&info);DSDPCHKERR(info);} return 0; } DSDP5.8/src/vecmat/identity.c0000644000175000017500000001546310326241003016044 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file identity.c \brief DSDPDataMat object representing a multiple of the identity matrix. */ typedef struct { int n; double dm; } identitymat; static int IdentityMatDestroy(void*); static int IdentityMatView(void*); static int IdentityMatVecVec(void*, double[], int, double *); static int IdentityMatDotP(void*, double[], int, int, double*); static int IdentityMatDotF(void*, double[], int, int, double*); static int IdentityMatGetRank(void*, int*,int); static int IdentityMatFactor(void*); static int IdentityMatGetEig(void*, int, double*, double[], int,int[],int*); static int IdentityMatAddRowMultiple(void*, int, double, double[], int); static int IdentityMatAddMultipleP(void*, double, double[], int, int); static int IdentityMatAddMultipleF(void*, double, double[], int, int); static int IdentityMatGetRowNnz(void*, int, int[], int*, int); static struct DSDPDataMat_Ops identitymatopsp; static struct DSDPDataMat_Ops identitymatopsf; static int IdentitymatOperationsInitializeP(struct DSDPDataMat_Ops*); static int IdentitymatOperationsInitializeF(struct DSDPDataMat_Ops*); /*! \fn int DSDPGetIdentityDataMatP(int n, double val, struct DSDPDataMat_Ops** dops, void** imat) \brief Create a sparse matrix usuable by DSDP in packed symmetric format. \param n number of rows and columns of the matrix \param val multiple of identity matrix. \param dops address of a pointer to a table of function pointers \param imat address of a pointer to an opaque data type. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetIdentityP" int DSDPGetIdentityDataMatP(int n, double val, struct DSDPDataMat_Ops** dops, void** imat){ int info; identitymat *AA; DSDPFunctionBegin; AA=(identitymat*) malloc(1*sizeof(identitymat)); AA->dm=val; AA->n=n; info=IdentitymatOperationsInitializeP(&identitymatopsp); DSDPCHKERR(info); if (dops){*dops=&identitymatopsp;} if (imat){*imat=(void*)AA;} DSDPFunctionReturn(0); } /*! \fn int DSDPGetIdentityDataMatF(int n, double val, struct DSDPDataMat_Ops** dops, void** imat) \brief Create a sparse matrix usuable by DSDP in full symmetric format. \param n number of rows and columns of the matrix \param val multiple of identity matrix. \param dops address of a pointer to a table of function pointers \param imat address of a pointer to an opaque data type. */ #undef __FUNCT__ #define __FUNCT__ "DSDPSetIdentityF" int DSDPGetIdentityDataMatF(int n, double val, struct DSDPDataMat_Ops** dops, void** imat){ int info; identitymat *AA; DSDPFunctionBegin; AA=(identitymat*) malloc(1*sizeof(identitymat)); AA->dm=val; AA->n=n; info=IdentitymatOperationsInitializeF(&identitymatopsf); DSDPCHKERR(info); if (dops){*dops=&identitymatopsf;} if (imat){*imat=(void*)AA;} DSDPFunctionReturn(0); } static int IdentityMatDestroy(void* AA){ free(AA); return 0; } static int IdentityMatVecVec(void* AA, double x[], int n, double *v){ identitymat* A=(identitymat*)AA; int i; *v=0; for (i=0;idm; return 0; } static int IdentityMatDotP(void* AA, double x[], int nn, int n, double *v){ identitymat* A=(identitymat*)AA; int i; double *xx=x; *v=0; for (i=0;idm; return 0; } static int IdentityMatDotF(void* AA, double x[], int nn, int n, double *v){ identitymat* A=(identitymat*)AA; int i; double *xx=x; *v=0; for (i=0;idm; return 0; } static int IdentityMatFNorm2(void* AA, int n, double *v){ identitymat* A=(identitymat*)AA; *v=A->n*A->dm*A->dm; return 0; } static int IdentityMatView(void* AA){ identitymat* A=(identitymat*)AA; printf("Multiple of Identity matrix: All Diagonal elements equal %8.8e \n",A->dm); return 0; } static int IdentityMatGetRank(void *AA, int*rank, int n){ identitymat* A=(identitymat*)AA; *rank=A->n;; return 0; } static int IdentityMatFactor(void*A){ return 0; } static int IdentityMatGetEig(void*AA, int neig, double *eig, double v[], int n, int* indx, int *nind){ identitymat* A = (identitymat*)AA; if (neig<0 || neig>= A->n){ *eig=0; return 0;} memset((void*)v,0,(A->n)*sizeof(double)); v[neig]=1.0; indx[0]=neig; *nind=1; *eig=A->dm; return 0; } static int IdentityMatGetRowNnz(void*A, int nrow, int nz[], int *nnzz, int n){ identitymat* AA = (identitymat*)A; if (nrow>=0 && nrow < AA->n){ *nnzz=1; nz[nrow]++; } else { *nnzz=0; } return 0; } static int IdentityMatCountNonzeros(void*A, int *nnz, int n){ identitymat* AA = (identitymat*)A; *nnz=AA->n; return 0; } static int IdentityMatAddRowMultiple(void*A, int nrow, double dd, double rrow[], int n){ identitymat* AA = (identitymat*)A; rrow[nrow] += dd*AA->dm; return 0; } static int IdentityMatAddMultipleP(void*A, double dd, double vv[], int nn, int n){ identitymat* AA = (identitymat*)A; double *v=vv,dm=dd*AA->dm; int i; for (i=0;idm; int i; for (i=0;imatfactor1=IdentityMatFactor; spdiagops->matgetrank=IdentityMatGetRank; spdiagops->matgeteig=IdentityMatGetEig; spdiagops->matvecvec=IdentityMatVecVec; spdiagops->matrownz=IdentityMatGetRowNnz; spdiagops->matdot=IdentityMatDotP; spdiagops->matfnorm2=IdentityMatFNorm2; spdiagops->matnnz=IdentityMatCountNonzeros; spdiagops->mataddrowmultiple=IdentityMatAddRowMultiple; spdiagops->mataddallmultiple=IdentityMatAddMultipleP; spdiagops->matdestroy=IdentityMatDestroy; spdiagops->matview=IdentityMatView; spdiagops->id=12; spdiagops->matname=datamatname; return 0; } static int IdentitymatOperationsInitializeF(struct DSDPDataMat_Ops* spdiagops){ int info; if (spdiagops==NULL) return 0; info=DSDPDataMatOpsInitialize(spdiagops); if (info){return info;} spdiagops->matfactor1=IdentityMatFactor; spdiagops->matgetrank=IdentityMatGetRank; spdiagops->matgeteig=IdentityMatGetEig; spdiagops->matvecvec=IdentityMatVecVec; spdiagops->matrownz=IdentityMatGetRowNnz; spdiagops->matdot=IdentityMatDotF; spdiagops->matfnorm2=IdentityMatFNorm2; spdiagops->matnnz=IdentityMatCountNonzeros; spdiagops->mataddrowmultiple=IdentityMatAddRowMultiple; spdiagops->mataddallmultiple=IdentityMatAddMultipleF; spdiagops->matdestroy=IdentityMatDestroy; spdiagops->matview=IdentityMatView; spdiagops->id=12; spdiagops->matname=datamatname; return 0; } DSDP5.8/src/vecmat/Makefile0000644000175000017500000000057010326241003015500 0ustar twernertwerner DSDPOBJ = vech.o vechu.o drowcol.o dlpack.o dufull.o \ sdpvec.o identity.o spds.o \ zeromat.o onemat.o diag.o rmmat.o \ cholmat.o cholmat2.o dtrsm2.o \ sdpmatx.o sdpnfac.o sdporder.o sdpalloc.o\ sdpsymb.o sdpxlist.o sdpdvct.o sdpexit.o DCFLAGS = -I${PP}solver -I${PP}sdp include ../../make.include default: make dsdplib; clean: ${RM} ${DSDPOBJ} DSDP5.8/src/vecmat/numchol.h0000644000175000017500000000576510326241003015671 0ustar twernertwerner#include #include #include #include typedef enum { CfcOk=0, CfcSpace, /* fail to allocate required space */ CfcIndef /* indefinity is detected */ } cfc_sta; typedef struct { int mrow; /* number of rows allocated */ int nrow; /* number of rows used */ int snnz; /* number of indices for nonzeros in S */ int *shead; /* position of first nonzero in row i of S */ int *ssize; /* number of non-zeros in row i of S below */ /* the diagonal */ int *ssub; /* column index buffer for non-zeros in S */ double *diag; /* diagonal matrix D in the factorization */ double *sqrtdiag;/* sqrt o diagonal matrix D in the factorization */ int unnz; /* number of nonzeros in the upper factor */ int ujnz; /* number of column indices in the compressed */ /* indices buffer ujsub */ int *ujbeg; /* beginning position of indices in row i of U */ int *uhead; /* position of first nonzero in row i of U */ int *ujsze; /* number of indices in row i of U */ int *usub; /* compressed column index buffer of U */ double *uval; /* nonzero values in factor U */ int *perm; /* permutation order */ int *invp; /* inverse order of perm */ int nsnds; /* number of supernodes */ int *subg; /* index of the first column in supernode i */ int ndens; /* numer of dense rows */ int nsndn; /* number supernodes in dense rows */ int *dhead; /* pointer first column in each dense row */ int *dsub; /* indices in dense rows */ int *dbeg; /* beginning of column index */ int sdens; /* separate dense row */ int alldense; double tolpiv; int cachesize; int cacheunit; /* New */ int n; int *iw; double *rw; int factor; } chfac; typedef struct { int idep; int last; int most; int cure; int loca; int lowp; int ntot; int *head; int *port; int *fwrd; int *bwrd; } xlist; typedef struct { int nnod; int nn0; int raft; int head; int last; int ntot; int *adjn; int *rbeg; int *rexs; int *rlen; int *rend; int *pres; int *succ; } order; typedef enum { OptFound=0, SysError=100, OutOfSpc,CholErr } xcode; #if !defined (min) #define min(a,b) ((a <= b)? (a) : (b)) #endif #if !defined (max) #define max(a,b) ((a >= b)? (a) : (b)) #endif #if !defined (sign) #define sign(a) ((a<0)? (-1) : (1)) #endif #if !defined (TRUE) #define TRUE 1 #endif #if !defined (FALSE) #define FALSE 0 #endif #include "sdpfun.h" DSDP5.8/src/vecmat/onemat.c0000644000175000017500000001035010326241003015464 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file onemat.c \brief DSDPDataMat object such that all elements are the same value. */ typedef struct { double cnst; char UPLQ; int n; } cmat; static int ConstMatDestroy(void*); static int ConstMatView(void*); static int ConstMatVecVec(void*, double[], int, double *); static int ConstMatDot(void*, double[],int,int,double *); static int ConstMatGetRank(void*, int*, int); static int ConstMatFactor(void*); static int ConstMatGetEig(void*, int, double*, double[], int,int[],int*); static int ConstMatRowNnz(void*, int, int[], int*, int); static int ConstMatAddRowMultiple(void*, int, double, double[], int); static int ConstMatAddMultiple(void*, double, double[], int,int); static int ConstMatTest(void*); static struct DSDPDataMat_Ops constantmatops; static int ConstMatOpsInitialize(struct DSDPDataMat_Ops*); #undef __FUNCT__ #define __FUNCT__ "DSDPGetConstantMat" int DSDPGetConstantMat(int n, double value, char UPLQ, struct DSDPDataMat_Ops**mops, void**mmat){ int info; cmat*AA; DSDPFunctionBegin; AA=(cmat*) malloc(1*sizeof(cmat)); if (AA==NULL) return 1; AA->cnst=value; AA->n=n; AA->UPLQ=UPLQ; info=ConstMatOpsInitialize(&constantmatops); if(info){return 1;} if (mops){*mops=&constantmatops;} if (mmat){*mmat=(void*)AA;} DSDPFunctionReturn(0); } static int ConstMatDot(void* A, double x[], int nn, int n, double *v){ cmat* AA = (cmat*)A; double dtmp=0.0; int i,j; for (i=0;iUPLQ=='U'){ x=x+n; } else { x=x+i+1; } } *v=2*dtmp*AA->cnst; return 0; } static int ConstMatVecVec(void* A, double x[], int n, double *v){ cmat* AA = (cmat*)A; double dtmp=0.0; int i; for (i=0; icnst; return 0; } static int ConstMatAddMultiple(void*A, double dd, double vv[], int nn, int n){ cmat* AA = (cmat*)A; int i,j; double ddd=dd*AA->cnst; for (i=0;iUPLQ=='U'){ vv=vv+n; } else { vv=vv+i+1; } } return 0; } static int ConstMatAddRowMultiple(void*A, int nrow, double dd, double row[], int n){ cmat* AA = (cmat*)A; int i; double ddd=dd*AA->cnst; for (i=0;icnst; *nind=n; } else { /* Or return an error */ for (i=0;icnst*A->cnst*n*n; return 0; } static int ConstMatCountNonzeros(void*A, int *nnz, int n){ *nnz=n*n; *nnz=1; *nnz=n; return 0; } static int ConstMatView(void* AA){ cmat* A = (cmat*)AA; printf("Every element of the matrix is the same: %10.8e\n",A->cnst); return 0; } static int ConstMatTest(void* AA){ return 0; } static int ConstMatDestroy(void* A){ if (A) free(A); return 0; } static const char *datamatname="ALL ELEMENTS THE SAME"; static int ConstMatOpsInitialize(struct DSDPDataMat_Ops* cmatops){ int info; if (cmatops==NULL) return 0; info=DSDPDataMatOpsInitialize(cmatops); DSDPCHKERR(info); cmatops->matfactor1=ConstMatFactor; cmatops->matgetrank=ConstMatGetRank; cmatops->matgeteig=ConstMatGetEig; cmatops->matvecvec=ConstMatVecVec; cmatops->matdot=ConstMatDot; cmatops->mataddrowmultiple=ConstMatAddRowMultiple; cmatops->mataddallmultiple=ConstMatAddMultiple; cmatops->matdestroy=ConstMatDestroy; cmatops->mattest=ConstMatTest; cmatops->matview=ConstMatView; cmatops->matrownz=ConstMatRowNnz; cmatops->matfnorm2=ConstMatFNorm2; cmatops->matnnz=ConstMatCountNonzeros; cmatops->id=14; cmatops->matname=datamatname; return 0; } DSDP5.8/src/vecmat/sdpalloc.c0000644000175000017500000000674010326241003016012 0ustar twernertwerner#include "numchol.h" int iSum(int,int*); void ShutDown(); int ExitProc(int,char *); int iAlloc(int len, char *info, int **r) { *r=NULL; if (len) { *r=(int*)calloc(len,sizeof(int)); if (!(*r)){ ExitProc(OutOfSpc,info); return 1;} } return 0; } /* iAlloc */ void iFree(int **x) { int *r=*x; if (r) { free(r); *x=NULL; } } /* iFree */ void cFree(char **x) { char *r = *x; /* printf("\n r %d &r %d",r,&r); getchar(); */ if(r) { free(r); *x = NULL; } } int dAlloc(int len, char *info, double **rr) { double *r=NULL; if (len) { r=(double*)calloc(len,sizeof(double)); if (!r){ ExitProc(OutOfSpc,info); return 1;} } *rr=r; return 0; } /* dAlloc */ void dFree(double **x) { double *r=*x; if (r) { free(r); *x=NULL; } } /* dFree */ int LvalAlloc(chfac *sf, char *info) { int ierr=0,nnz; nnz=iSum(sf->nrow,sf->ujsze); if ( nnz<=sf->unnz ) return 1; sf->unnz=0; if (sf->uval) dFree(&sf->uval); ierr=dAlloc(nnz,info,&sf->uval); sf->unnz=nnz; if (ierr) return 1; return 0; } /* LvalAlloc */ int CfcAlloc(int maxrow, char *info,chfac**rr) { chfac *r=NULL; int ierr=0; if (maxrow) { r=(chfac*)calloc(1,sizeof(chfac)); if (!r) ExitProc(OutOfSpc,info); r->mrow =maxrow; r->nrow =maxrow; r->snnz =0; ierr=iAlloc(maxrow,info,&r->shead); if(ierr) return 1; ierr=iAlloc(maxrow,info,&r->ssize); if(ierr) return 1; r->ssub =NULL; ierr=dAlloc(maxrow,info,&r->diag); if(ierr) return 1; ierr=dAlloc(maxrow,info,&r->sqrtdiag); if(ierr) return 1; r->unnz =0; r->ujnz =0; ierr=iAlloc(maxrow,info,&r->ujbeg); if(ierr) return 1; ierr=iAlloc(maxrow,info,&r->uhead); if(ierr) return 1; ierr=iAlloc(maxrow,info,&r->ujsze); if(ierr) return 1; r->usub =NULL; r->uval =NULL; ierr=iAlloc(maxrow,info,&r->perm); if(ierr) return 1; ierr=iAlloc(maxrow,info,&r->invp); if(ierr) return 1; r->nsnds=0; ierr=iAlloc(maxrow+1,info,&r->subg); if(ierr) return 1; r->n=maxrow; r->alldense=0; r->tolpiv=1.0e-13; /* Standard */ r->tolpiv=1.0e-35; r->cachesize =256; #ifdef DSDPCACHESIZE if (DSDPCACHESIZE>0){ r->cachesize = (int)DSDPCACHESIZE; } #endif r->cacheunit =1000; } *rr=r; return 0; } /* SchlAlloc */ void CfcFree(chfac **sf) { chfac *r=*sf; if (*sf) { iFree(&r->shead); iFree(&r->ssize); iFree(&r->ssub); dFree(&r->diag); dFree(&r->sqrtdiag); iFree(&r->uhead); iFree(&r->ujsze); dFree(&r->uval); iFree(&r->perm); iFree(&r->subg); iFree(&r->dhead); iFree(&r->dbeg); iFree(&r->dsub); iFree(&r->iw); dFree(&r->rw); if (r->alldense){ r->invp=0; r->ujbeg=0; r->usub=0; }else{ iFree(&r->invp); iFree(&r->ujbeg); iFree(&r->usub); } free(r); } *sf=NULL; } /* CfcFree */ int dPtAlloc(int n, char *info,double ***rr) { int ierr,i; double **r; r=NULL; *rr=NULL; if (!n) return 0; r=(double **)calloc(n,sizeof(double*)); if (!r){ ExitProc(OutOfSpc,info); return 1; } ierr=dAlloc(n*(n-1)/2,info,&r[0]); if(ierr) return 1; for (i=1; i int ExitProc(int,char *); void iZero(int n, int *x, int *s) { int i; if (s) { for(i=0; i void ShutDown(){ /* sdpdat* sdt = sdat; */ printf("\n Shutdown -- "); } /* ShutDown */ int ExitProc(int ccode, char *str) { xcode code=(xcode)ccode; printf("\n Exit -- %d : ",ccode); switch (code) { case OptFound: printf("optimal solution found"); return code; case OutOfSpc: printf("out of memory space"); break; default: break; } if (str) printf(", %s",str); ShutDown(); printf("\n Exiting -- "); return 1; } /* ExitProc */ DSDP5.8/src/vecmat/sdpfun.h0000644000175000017500000000564010326241003015513 0ustar twernertwerner /* * common functions */ #if !defined (min) #define min(a,b) ((a <= b)? (a) : (b)) #endif #if !defined (max) #define max(a,b) ((a >= b)? (a) : (b)) #endif #if !defined (sign) #define sign(a) ((a<0)? (-1) : (1)) #endif /* * functions in sdpallo.c */ int iAlloc(int,char*,int**); void iFree(int**); int dAlloc(int,char*,double**); void dFree(double**); void cFree(char**); int LvalAlloc(chfac*,char*); int CfcAlloc(int,char*,chfac**); void CfcFree(chfac**); int dPtAlloc(int,char*,double ***); void dPtFree(double***); /* * functions in sdpmain.c */ void GetUhat(chfac*,double*,double*); /* * functions in sdpshut.c */ void ShutDown(void); int ExitProc(int,char*); /* * functions in sdplib.a */ void DotProd(double*,chfac*); void ForwSubst(chfac*,double*,double*); int iSum(int,int*); void dCopy(int,double*,double*); int ChlFact(chfac*,int*,double*,int); void ChlSolve(chfac*,double*,double*); void ChlSolveForward(chfac*, double*, double*); void ChlSolveBackward(chfac*, double*, double*); int SymbProc(int*,int*,int,chfac**); void iCopy(int,int*,int*); int OdAlloc(int,int,char*,order**); void OdFree(order**); void OdInit(order*,int*); void OdIndex(order*,int,int); void OdProc(order*,xlist*,int*,int*,int*,int*,int*, int*,int*,int*,int*,int*,int*,int*,int*); int GetOrder(order*,int*); void DotProd(double*,chfac*); /* void CfcInit(chfac*,symat*,double*); */ int ChlFact(chfac*,int*,double*,int); void copyChl(chfac *, chfac *); /* void PermSmatx(smatx*,int*,int*); */ int XtAlloc(int,int,char*,xlist**); void XtFree(xlist**); int XtSucc(xlist*); void XtDel(xlist*,int); void XtPut(xlist*,int,int); int XtLeast(xlist*); int XtGet(xlist*,int*,int*); int IptAlloc(int,int,int**,char*); void IptFree(int,int**); int LocIntPos(int,int,int*); void PermTransSym(int,int*,int*,int*,int*,int,int*,int*,int*); void iZero(int,int*,int*); void iFill(int,int,int*,int*,int*); void iSwap(int,int,int*); void iCopy(int,int*,int*); int iSum(int,int*); void dZero(int,double*,int*,int*); void dCopy(int,double*,double*); void dCat(int,int*,double*,double*); double dSum(int,double*); void PlusByOne(int,int*,int*,int*); void iSet(int, int, int *, int *); void plusXs(int, int*, int*); int MatMult4(chfac *,double *,double*,int); int Mat4LogDet(chfac *,double *); int MatZeroEntries4(chfac *); int MatSolve4(chfac *,double *,double*,int); void CfcFree(chfac**); int MatSetColumn4(chfac *, double *, int); int MatAddColumn4(chfac *, double,double *, int); int MchlSetup2(int m, chfac** A); int MatSetValue4(chfac *, int,int,double, int); int Mat4GetDiagonal(chfac*, double *,int); int Mat4SetDiagonal(chfac*, double *,int); int Mat4AddDiagonal(chfac*, double *,int); int MatAddDiagonalElement(chfac*,int, double); int Mat4View(chfac *); int Mat4DiagonalShift(chfac*, double); DSDP5.8/src/vecmat/sdpmatx.c0000644000175000017500000004217010326241003015666 0ustar twernertwerner#include "numchol.h" void dCopy(int,double*,double*); static void SolFwdSnode(chfac *sf, int snde, int f, int l, double x[]) { int i,t,sze,*ls,*subg=sf->subg, *ujbeg=sf->ujbeg,*uhead=sf->uhead, *usub=sf->usub; double xi,*l1,*diag=sf->diag,*uval=sf->uval; f += subg[snde]; l += subg[snde]; for(i=f; i1; --i) { -- i; l1 = uval+fir[i-1]+1; l2 = uval+fir[i ]+0; sze = nrow-i-1; x1 = 0.0; x2 = 0.0; x0 = x+1+i; for(t=0; tsubg,*ujsze=sf->ujsze,*usub=sf->usub, *ujbeg=sf->ujbeg,*uhead=sf->uhead; double rtemp1,rtemp2,rtemp3,rtemp4, rtemp5,rtemp6,rtemp7,rtemp8, *l1,*l3,*l2,*l4,*l5,*l6,*l7,*l8, *uval=sf->uval; for(s=0; snsnds; ++s) { f = subg[s]; l = subg[s+1]; SolFwdSnode(sf,s,0,l-f,x); itemp = l-f-1; ls = usub+ujbeg[f]+itemp; sze = ujsze[f]-itemp; k = f; itemp = l-1; for(; k+7subg,*ujsze=sf->ujsze,*usub=sf->usub, *ujbeg=sf->ujbeg,*uhead=sf->uhead; double x1,x2,*l1,*l2,rtemp1, *diag=sf->diag,*uval=sf->uval; if (sf->nsnds) { s = sf->nsnds - 1; f = subg[s]; l = subg[s+1]; dCopy(l-f,x+f,b+f); SolBward(l-f,diag+f,uval,uhead+f,b+f); s = sf->nsnds-1; for(; s>=1; --s) { f = subg[s-1]; l = subg[s]; i = l; for(; i>1+f; --i) { -- i; ls = usub+ujbeg[i]; l1 = uval+uhead[i-1]+1; l2 = uval+uhead[i ]+0; sze = ujsze[i]; x1 = 0.0; x2 = 0.0; for(t=0; tf;) { -- i; l1 = uval+uhead[i]; ls = usub+ujbeg[i]; sze = ujsze[i]; x1 = 0.0; for(t=0; tnrow; double *sqrtdiag=sf->sqrtdiag; ChlSolveForwardPrivate(sf,b); for(i=0; idiag[i]); */ } } void ChlSolveBackward2(chfac *sf, double b[], double x[]){ int i,nrow=sf->nrow; double *sqrtdiag=sf->sqrtdiag; for(i=0; idiag[i]) ; */ } ChlSolveBackwardPrivate(sf,x,b); memcpy(x,b,nrow*sizeof(double)); } /* These routines together will solve an equation correctly */ void ChlSolveForward(chfac *sf, double b[], double x[]){ int i,nrow=sf->nrow,*perm=sf->perm; double *w=sf->rw,*sqrtdiag=sf->sqrtdiag; for(i=0; idiag[i]); */ } } void ChlSolveBackward(chfac *sf, double b[], double x[]){ int i,nrow=sf->nrow,*invp=sf->invp; double *w=sf->rw,*sqrtdiag=sf->sqrtdiag; for(i=0; inrow,*perm=sf->perm,*invp=sf->invp; double *rw=sf->rw; /* ChlSolveForward(sf,b,w,x); ChlSolveBackward(sf,w,x,b); */ for(i=0; isubg,*ujsze=sf->ujsze,*usub=sf->usub, *ujbeg=sf->ujbeg,*uhead=sf->uhead; double rtemp1,rtemp2,rtemp3,rtemp4, rtemp5,rtemp6,rtemp7,rtemp8, *l1,*l3,*l2,*l4,*l5,*l6,*l7,*l8, *diag=sf->diag,*uval=sf->uval; for(i=0; inrow; ++i) x[i] = b[sf->perm[i]]; for(s=0; snsnds; ++s) { f = subg[s]; l = subg[s+1]; SolFwdSnode(sf,s,0,l-f,x); itemp = l-f-1; ls = usub+ujbeg[f]+itemp; sze = ujsze[f]-itemp; k = f; itemp = l-1; for(; k+7nrow; i++){ x[i] = x[i] * sqrt( fabs(diag[i]) ); } } /* ForwSubst */ static void mulSnod(chfac *sf, int snde, int f, int l, double *b, double *x) { int i,t,sze,*ls,*subg,*ujbeg,*uhead,*usub; double xi,*l1,*diag,*uval; subg =sf->subg; ujbeg=sf->ujbeg; uhead=sf->uhead; usub =sf->usub; diag =sf->diag; uval =sf->uval; f += subg[snde]; l += subg[snde]; for(i=f; inrow; subg =sf->subg; ujsze=sf->ujsze; usub =sf->usub; ujbeg=sf->ujbeg; uhead=sf->uhead; diag =sf->diag; uval =sf->uval; for (i=0; i0) x[i]=b[i]/sqrt(diag[i]); else x[i]=b[i]/sqrt(-diag[i]); b[i]=0.0; } for (s=0; snsnds; s++) { f=subg[s]; l=subg[s+1]; mulSnod(sf,s,0,l-f,x,b); itemp=l-f-1; ls =usub+ujbeg[f]+itemp; sze =ujsze[f]-itemp; k =f; itemp=l-1; for(; k+7invp[i] ]=b[i]; } /* GetUhat */ int MatSolve4(chfac*sf, double *b, double *x,int n){ memcpy(x,b,n*sizeof(double)); ChlSolve(sf, b, x); return 0; } int Mat4GetDiagonal(chfac*sf, double *b,int n){ int i,*invp=sf->invp; double *diag=sf->diag; for (i=0; iinvp; double *diag=sf->diag; for (i=0; iinvp; double *diag=sf->diag; for (i=0; iinvp; double *diag=sf->diag; diag[invp[row]]+=dd; return 0; } int MatMult4(chfac *sf, double *x, double *y, int n){ int i,j,*invp=sf->invp,*perm=sf->perm; int *usub=sf->usub,*ujbeg=sf->ujbeg,*uhead=sf->uhead, *ujsze=sf->ujsze; int *iptr,k1,k2; double dd,*sval,*diag=sf->diag,*uval=sf->uval; for (i=0; i 1e-15){ k2=perm[iptr[j]]; y[k1] += dd * x[k2]; y[k2] += dd * x[k1]; } } } return 0; } static void setXYind2(int nnz, double* y, double* x, int* s, int* invp) { int i; for(i=0; iujsze[i],ai, cl->uval+cl->uhead[i], cl->usub+cl->ujbeg[i], cl->perm); } /* setColi */ static void setXYind2add(int nnz, double dd, double* y, double* x, int* s, int* invp) { int i; for(i=0; iujsze[i],dd,ai, cl->uval+cl->uhead[i], cl->usub+cl->ujbeg[i], cl->perm); } /* setColi */ static void getXYind2(int nnz, double* y, double* x, int* s, int* invp) { int i; for(i=0; inrow; double *v=sf->rw; for (i=0; iujsze[i],v, sf->uval+sf->uhead[i], sf->usub+sf->ujbeg[i], sf->perm); v[i]=sf->diag[sf->invp[i]]; printf("Row %d, ",i); for (j=0;jn; double *rw=sf->rw; memset((void*)(sf->diag),0,n*sizeof(double)); memset((void*)(rw),0,n*sizeof(double)); for (i=0; iinvp[col]; cl->diag[pcol]=val[col]; val[col]=0.0; setColi(cl,pcol,val); return 0; } /* SetColumn */ int MatAddColumn4(chfac *cl, double dd, double *val, int col){ int pcol=cl->invp[col]; cl->diag[pcol]+=dd*val[col]; val[col]=0.0; setColi2(cl,pcol,dd,val); return 0; } /* SetColumn */ int MatSetValue4(chfac *cl, int row,int col,double val, int setmode){ int i; double* x=cl->uval+cl->uhead[col]; int* s=cl->usub+cl->ujbeg[col]; int nnz=cl->ujsze[col]; int insertmode=1,addmode=2; if (row<0 || col<0 || row>=cl->n || col>=cl->n){ printf("CHol set Value error: Row: %d, COl: %d \n",row,col); return 1; } if (setmode==insertmode&&row==col){ cl->diag[cl->invp[col]]=val; } else if (setmode==addmode&&row==col) { cl->diag[cl->invp[col]]+=val; } else if (setmode==insertmode){ for(i=0; inrow; double *diag=sf->diag; for (i=0; inrow; double *diag=sf->diag,ddd=0; for (i=0; iujsze,*uhead=cf->uhead,*subg=cf->subg; double *diag=cf->diag,*uval=cf->uval; if (f==l || uf==ul) return; f += subg[snde]; l += subg[snde]; uf += subg[snde]; ul += subg[snde]; for(k=f; ksubg[snde]+f; if (!DiagUpdate(cf->diag+itemp, mode)) return (CfcIndef); if (fabs(cf->diag[itemp])<=cf->tolpiv) { printf("Singular d[%d]=%e\n", cf->subg[snde]+f,cf->diag[cf->subg[snde]+f]); return (CfcIndef); } for(k=f+1; ksubg[snde]+k; if (!DiagUpdate(&cf->diag[itemp], mode)) return (CfcIndef); if (fabs(cf->diag[itemp])<=cf->tolpiv) { printf(" singular d[%d]=%e\n", cf->subg[snde]+k,cf->diag[cf->subg[snde]+k]); return (CfcIndef); } } return CfcOk; } /* FacSnode */ static void UpdSnodes(int m, int n, int s, double diaga[], double *a, int fira[], double diagb[], double *b, int firb[], int subb[]) { int i,j,k,t,u,sze,delay, *ls; double rtemp1,rtemp2,rtemp3,rtemp4, rtemp5,rtemp6,rtemp7,rtemp8, rtemp9,rtemp10,rtemp11,rtemp12, rtemp13,rtemp14,rtemp15,rtemp16, *a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8, *a9,*a10,*a11,*a12,*a13,*a14,*a15,*a16, *b0; if (msubg, *ujsze=cf->ujsze,*usub=cf->usub,*ujbeg=cf->ujbeg,*uhead=cf->uhead; double *diag=cf->diag,*uval=cf->uval; f += subg[snde]; l += subg[snde]; if (usnde==cf->nsnds-1) { if (usub[ujbeg[f]+start]sdens) exit(0); ls = usub+ujbeg[f]+start; sze = ujsze[f]-start; for(k=f; ksubg, *ujsze=cf->ujsze,*uhead=cf->uhead,*ujbeg=cf->ujbeg,*usub=cf->usub; double rtemp1,*l0,*l1, *diag=cf->diag,*uval=cf->uval; if (f>subg[snde+1]-subg[snde]) { printf("\n PushFward"); exit(0); } if (f==l) return; f += subg[snde]; l += subg[snde]; offset = subg[snde+1]-f-1; sze = ujsze[f] - offset; ls1 = usub+ujbeg[f]+offset; if (f+1==l) { l1 = uval+uhead[f]+offset; stops = sze; for(t=0; t=subg[cf->nsnds-1]) break; rtemp1 = l1[0]/diag[f]; diag[j] -= rtemp1*l1[0]; ++ l1; l0 = uval+uhead[j]; ls0 = usub+ujbeg[j]; ++ ls1; -- stops; if (stops && ls1[stops-1]==ls0[stops-1]) { for(s=0; ssdens) ExtUpdSnode(cf,snde,cf->nsnds-1,f-subg[snde],l-subg[snde],t,iw); } else { stops = sze; for(t=0; t=subg[cf->nsnds-1]) { if (!cf->sdens) ExtUpdSnode(cf,snde,cf->nsnds-1,f-subg[snde], l-subg[snde],offset,iw); break; } ls0 = usub+ujbeg[j]; l0 = uval+uhead[j]; ++ ls1; -- stops; k = f; itemp = offset+f; if (stops && ls1[stops-1]==ls0[stops-1]) { for(k=f; ksubg,*ujsze=cf->ujsze, *ujbeg=cf->ujbeg,*uhead=cf->uhead, *usub=cf->usub,*dhead=cf->dhead, *dsub=cf->dsub,*dbeg=cf->dbeg,*ls; double *diag=cf->diag,*uval=cf->uval; int sresp; cacsze = cf->cachesize*cf->cacheunit; if (cf->sdens) { for(d=0; dndens; ++d) { c = 0; for(k=dhead[d]; knsnds-1]) { printf("\nindex error1"); exit(0); } for(j=subg[s]; jnsnds-1]) { printf("\nindex error"); exit(0); } } } if (c) { k = dhead[d]; s = dsub[k]; m = ujsze[subg[s]]-dbeg[k]; ls = usub+ujbeg[subg[s]]+dbeg[k]; if (m) { for(k=0; knsnds-1; sncl = cf->subg[s+1]-cf->subg[s]; for(k=0; k=k0+2 && sze>cacsze) --k; if (k>sncl) exit(0); sresp = FacSnode(cf,s,k0,k,iw,mode); if (sresp!=CfcOk) return (sresp); iUpdSnode(cf,s,k0,k,k,sncl,iw); } return (CfcOk); } /* FacDenNode */ int ChlFact(chfac *cf, int *iw, double *rw, int mode) { int s,sncl,k,k0,cacsze,sze, *subg=cf->subg,*ujsze=cf->ujsze; int cid; cacsze=cf->cachesize*cf->cacheunit; for(s=0; s+1nsnds; ++s) { sncl = cf->subg[s+1]-cf->subg[s]; for(k=0; k=k0+2 && sze>cacsze) --k; if (k>sncl) exit(0); cid=FacSnode(cf,s,k0,k,iw,mode); if (cid!=CfcOk) return (cid); iUpdSnode(cf,s,k0,k,k,sncl,iw); PushFward(cf,s,k0,k,iw); } } cid=FacDenNode(cf,iw,rw,mode); for (k=0;knrow;k++){ cf->sqrtdiag[k]=sqrt(fabs(cf->diag[k])); } return cid; } /* ChlFact */ DSDP5.8/src/vecmat/sdporder.c0000644000175000017500000003725610326241003016041 0ustar twernertwerner#include "numchol.h" int OdAlloc(int nnod, int nn0, char *info, order **rr) { order *r; int ierr=0; r=(order*)calloc(1,sizeof(order)); if (!r) ExitProc(OutOfSpc,info); r->nnod=nnod; r->nn0 =nn0; ierr=iAlloc(nn0,info,&r->adjn); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->rbeg); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->rexs); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->rlen); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->rend); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->pres); if(ierr) return 1; ierr=iAlloc(nnod,info,&r->succ); if(ierr) return 1; *rr=r; return (0); } /* OdAlloc */ void OdFree(order **od) { order *r; if (*od) { r=*od; iFree(&r->adjn); iFree(&r->rbeg); iFree(&r->rexs); iFree(&r->rlen); iFree(&r->rend); iFree(&r->pres); iFree(&r->succ); free(*od); *od=NULL; } } /* OdFree */ void OdInit(order *od, int *nnzi) { int i,n=od->nnod; if (n) { od->rexs[0]=nnzi[0]; od->rlen[0]=nnzi[0]; od->rbeg[0]=0; od->pres[0]=n; od->succ[0]=1; for(i=1; innod; ++i) { od->pres[i]=i-1; od->succ[i]=i+1; od->rexs[i]=nnzi[i]; od->rlen[i]=nnzi[i]; od->rbeg[i]=od->rbeg[i-1]+od->rlen[i-1]; } od->succ[n-1]=n; od->last =n-1; od->raft=od->rbeg[n-1]+nnzi[n-1]; if (od->raft>od->nn0) ExitProc(OutOfSpc,"InitMmd"); } } /* OdInit */ static void OdSet(order *od, int allow_eli, xlist *elist, int *node_status, int *marker, int *isize, int *ilink, int *oinfo, int *osize, int *e, int *p) { int i,n,deg,*rbeg,*rexs,*rend; n =od->nnod; rbeg=od->rbeg; rexs=od->rexs; rend=od->rend; *e =0; for (i=0; iadjn[od->rbeg[i]++]=j; od->adjn[od->rbeg[j]++]=i; } } /* OdIndex */ static void OdArriv(order *od, int *node_status, int *marker, int *isize, int x, int *xdeg, int *rsze, int *esze, int *rchset) { int *visited,i,n,y,z,l,s,t,f,stopt, stops,*adjn,*rbeg,*rexs,*rend; n =od->nnod; adjn =od->adjn; rbeg =od->rbeg; rexs =od->rexs; rend =od->rend; *rsze=0; *esze=0; if (rexs[x]) { l=n; visited=marker; visited[x]=TRUE; for(t=rbeg[x], stopt=rbeg[x]+rend[x]; tnnod; od->ntot+=xdeg--; p[*e] =x; (*e)++; for(c=x; ilink[c]!=n; c=ilink[c]) { od->ntot+=xdeg--; p[*e] =ilink[c]; (*e)++; } } /* OdRenew */ static void OdCheck(order *od, int *node_status) { int f,i,t,stopt,rnew,z,previous,n,*adjn, *rbeg,*rexs,*rlen,*rend,*pres,*succ; n =od->nnod; adjn=od->adjn; rbeg=od->rbeg; rexs=od->rexs; rlen=od->rlen; rend=od->rend; pres=od->pres; succ=od->succ; f=0; previous=n; for(i=od->head; i!=n; i=succ[i]) { if (node_status[i]!=0) { rnew=f; for(t=rbeg[i], stopt=rbeg[i]+rend[i]; thead=i; pres[i]=n; } else { succ[previous]=i; pres[i]=previous; } previous=i; } } if (previous!=n) { succ[previous]=n; od->raft=rbeg[previous]+rexs[previous]; } od->last=previous; } /* OdCheck */ static void OdAdd(order *od, int *node_status, int x, int newsze) { int n,*adjn,*rbeg,*rexs,*rlen,*pres,*succ; n =od->nnod; adjn=od->adjn; rbeg=od->rbeg; rexs=od->rexs; rlen=od->rlen; pres=od->pres; succ=od->succ; if (newsze<=rlen[x]) return; if (od->raft+newsze>od->nn0) OdCheck(od,node_status); if (od->raft+newsze>od->nn0) ExitProc(OutOfSpc,"OdAdd"); if (pres[x]!=n) rlen[pres[x]]+=rlen[x]; iCopy(rexs[x],adjn+rbeg[x],adjn+od->raft); rbeg[x]=od->raft; rlen[x]=newsze; od->raft+=newsze; if (pres[x]==n) { if (succ[x]==n) od->head=x; else od->head=succ[x]; } else { if (succ[x]==n) succ[pres[x]]=x; else succ[pres[x]]=succ[x]; } if (succ[x]!=n) pres[succ[x]]=pres[x]; if (od->last!=x) { succ[od->last]=x; pres[x]=od->last; } succ[x] =n; od->last=x; } /* OdAdd */ static int OdComb(order *od, int *node_status, int *marker, int *isize, int *ilink, int *osize, int xsize, int *xset) { int i,n,rnew,rlen,x,icur; n =od->nnod; rlen=0; if (xsize==0) rnew=n; else if (xsize==1) rnew=xset[0]; else { rnew=xset[0]; for(i=1; iadjn; rbeg =od->rbeg; rexs =od->rexs; rlen =od->rlen; rend =od->rend; n =od->nnod; slist=ibuf1; e0 = *e; OdArriv(od,node_status,marker,isize,x,&xdeg,rsze,&esze,rchset); XtDel(elist,x); OdRenew(od,ilink,x,xdeg,e,p); for(i=n-esze; i=rlen[y]) ExitProc(SysError,NULL); if (rexs[y]>rend[y]) adjn[rbeg[y]+rexs[y]]=adjn[rbeg[y]+rend[y]]; rexs[y]++; adjn[rbeg[y]+rend[y]]=x; rend[y]++; i++; } } iSet(ssze,FALSE,mask2,slist); if (*rsze==0) { node_status[x]=0; marker[x]=TRUE; } else { node_status[x]=3; rend[x]=0; rexs[x]=0; if (*rsze>rlen[x]) OdAdd(od,node_status,x,*rsze); rexs[x]=*rsze; iCopy(*rsze,rchset,adjn+rbeg[x]); tsze=0; tlist=ibuf2; for(i=0; innod; iSet(n,0,dependent,NULL); total_fillin=FALSE; for(; emindeg) break; if (node_status[x]!=1) XtDel(elist,x); else { XtSucc(elist); if (!dependent[x]) { total_fillin = OdSelect(od,elist,node_status,marker, isize,ilink,oinfo,osize,x, &rsze,rchset,ibuf8,ibuf9,mask2, &e,p); if (!total_fillin) { dependent[x]=2; slist[xsize++]=x; for(i=0; innod; ierr=XtAlloc(n,n+1,"xt, GetOrder",&xt); if(ierr) return FALSE; ierr=iAlloc(n,"ibuf21, GetOrder",&iwmd); if(ierr) return FALSE; IptAlloc(ibufs,n,ibuf,"ibuf, GetOrder"); IptAlloc(bbufs,n,bbuf,"bbuf, GetOrder"); OdProc(od,xt,ibuf[0],ibuf[1],ibuf[2],ibuf[3],ibuf[4],ibuf[5], ibuf[6],ibuf[7],ibuf[8],iwmd,bbuf[0],bbuf[1],p); /* XtFree(&xt); */ free(xt->head); free(xt->port); free(xt->fwrd); free(xt->bwrd); free(xt); iFree(&iwmd); IptFree(ibufs,ibuf); IptFree(bbufs,bbuf); return TRUE; } /* GetOrder */ DSDP5.8/src/vecmat/sdpsymb.c0000644000175000017500000003557710326241003015704 0ustar twernertwerner#include "numchol.h" int IptAlloc(int m, int n, int *ipt[], char *info) { int i; if (n) { for (i=0; ij) { subt[firt[i]+nnzt[i]]=j; nnzt[i]++; } else { subt[firt[j]+nnzt[j]]=i; nnzt[j]++; } } } } else { for(j=0; jj) { subt[firt[i]+nnzt[i]]=j; nnzt[i]++; } else { subt[firt[j]+nnzt[j]]=i; nnzt[j]++; } } } } } else { if (p) { for(s=0; s*i2) return (1); return (0); } /* CompIntElem */ static void iSort(int n, int *x) { qsort((void *)x,n,sizeof(int),CompIntElem); } /* iSort */ static void DetectDenseNodes(chfac *sf, int *i1nrow, int *i2nrow, int *i3nrow, int *i4nrow, int *i5nrow, int *i6nrow) { int ierr=0,j,k,l,t,ndens,nil=sf->nrow, *subg=sf->subg,*ujbeg=sf->ujbeg, *ujsze=sf->ujsze,*usub=sf->usub, *fir,*sze,*ilist,*ilink; if (!sf->nsnds|| !i1nrow || !i2nrow || !i3nrow || !i4nrow || !i5nrow || !i6nrow) { sf->sdens=FALSE; return; } sf->sdens =TRUE; fir =i1nrow; sze =i2nrow; ilist =i3nrow; ilink =i4nrow; sf->nsndn=0; l=subg[sf->nsnds-1]; for(k=0; k+1nsnds; ++k) { j=subg[k]; for(t=0; tnsnds-1,sf->nrow,fir,sze,usub, NULL, i6nrow,ilink,ilist,&ndens,i5nrow); ierr=iAlloc(ndens+1, "sf->dhead, DetectDenseNodes",&sf->dhead);if(ierr) return; ierr=iAlloc(sf->nsnds,"sf->dsub, DetectDenseNodes",&sf->dsub);if(ierr) return; ierr=iAlloc(sf->nsnds,"sf->dbeg, DetectDenseNodes",&sf->dbeg);if(ierr) return; nil =sf->nsnds-1; sf->ndens =0; sf->nsndn =0; sf->dhead[0]=0; for(k=0; kdhead[sf->ndens+1]=sf->dhead[sf->ndens]; sf->ndens++; for(; j!=nil; j=ilink[j]) { sf->nsndn += sf->subg[j+1]-sf->subg[j]; sf->dsub[sf->dhead[sf->ndens]]=j; sf->dbeg[sf->dhead[sf->ndens]]=fir[j]-ujbeg[subg[j]]; sf->dhead[sf->ndens]++; } iSort(sf->dhead[sf->ndens]-sf->dhead[sf->ndens-1], sf->dsub+sf->dhead[sf->ndens-1]); for(t=sf->dhead[sf->ndens-1]; tdhead[sf->ndens]; ++t) sf->dbeg[t]=fir[sf->dsub[t]]-ujbeg[subg[sf->dsub[t]]]; } } } /* DetectDenseNodes */ static int ChlSymb(chfac *sf, int ulnnz) { int ierr=0,chksn,i,j,t,stopt,sze,first,cur,k, ffree=0,ipos,nrow=sf->nrow,nil=nrow, *nnz,*fir,*pssub,*link,*buf,*mask, *usub,*tusub,*i1nrow,*i2nrow,*i3nrow, *i4nrow,*p=sf->perm,*invp=sf->invp, *ujbeg=sf->ujbeg,*ujsze=sf->ujsze, *subg=sf->subg; ierr=iAlloc(sf->snnz,"pssub, ChlSymb",&pssub);if(ierr) return FALSE; for(i=0; iuhead; fir=sf->subg; PermTransSym(nrow,sf->shead,sf->ssize,sf->ssub, invp,TRUE,fir,nnz,pssub); PermTransSym(nrow,fir,nnz,pssub,NULL,FALSE, sf->shead,sf->ssize,sf->ssub); iFree(&pssub); k =ulnnz+nrow; ierr =iAlloc(k,"usub, ChlSymb",&usub);if(ierr) return FALSE; buf =usub+ulnnz; mask=sf->uhead; link=invp; iZero(nrow,mask,NULL); iSet(nrow,nil,link,NULL); ffree =0; sf->nsnds=0; subg[0] =0; for(i=0; issize[i]; first=nil; cur =link[i]; chksn=FALSE; if (cur==nil) { subg[sf->nsnds+1] =1 + subg[sf->nsnds]; ujsze[i] =sze; ujbeg[i] =ffree; ffree += sze; iCopy(sze,sf->ssub+sf->shead[i],usub+ujbeg[i]); if (sze) { first=usub[ujbeg[i]]; for(cur=first; link[cur]!=nil; cur=link[cur]); link[cur] =sf->nsnds; link[sf->nsnds]=nil; } sf->nsnds++; } else { mask[i]=1; iCopy(sze,sf->ssub+sf->shead[i],buf); iSet(sze,1,mask,buf); for(; cur!=nil; cur=link[cur]) { chksn |= (1+cur==sf->nsnds); k =subg[cur]; for(t=ujbeg[k], stopt=t+ujsze[k]; ti && !mask[j] ) { buf[sze]=j; mask[j] =1; sze++; } } } if (chksn) { k =subg[sf->nsnds-1]; chksn=sze==( ujsze[k]-(subg[sf->nsnds]-subg[sf->nsnds-1]) ); } first =nrow; mask[i]=0; for(t=0; tnsnds]++; ujbeg[i] =ujbeg[i-1]+1; ujsze[i] =ujsze[i-1]-1; if (usub[ujbeg[i]-1]!=i) ExitProc(SysError,NULL); if ( first!=nil ) { for(cur=first; link[cur]!=nil; cur=link[cur]); link[cur] =sf->nsnds-1; link[sf->nsnds-1]=nil; } } else { subg[sf->nsnds+1] =1 + subg[sf->nsnds]; ujbeg[i] =ffree; ujsze[i] =sze; ffree += sze; if (ffree>ulnnz) ExitProc(SysError,NULL); iCopy(sze,buf,usub+ujbeg[i]); if ( first!=nil ) { for(cur=first; link[cur]!=nil; cur=link[cur]); link[cur] =sf->nsnds; link[sf->nsnds]=nil; } sf->nsnds++; } } if (ujsze[i]+1==nrow-i) break; } for(++i; insnds]++; } ierr=iAlloc(ffree,"tusub, ChlSymb",&tusub);if(ierr) return FALSE; fir=buf; nnz=sf->uhead; iZero(nrow,nnz,NULL); for(k=0; knsnds; ++k) { j=subg[k]; plusXs(ujsze[j],nnz,usub+ujbeg[j]); } fir[0]=0; for(k=1; knsnds; ++k) { j=subg[k]; for(t=ujbeg[j], stopt=t+ujsze[j]; tujnz) { iCopy(ffree,usub,sf->usub); iFree(&usub); } else { sf->ujnz=0; iFree(&sf->usub); ierr=iAlloc(ffree,"sf->usub, ChlSymb",&sf->usub);if(ierr) return FALSE; iCopy(ffree,usub,sf->usub); sf->ujnz=ffree; iFree(&usub); } ierr=iAlloc(4*nrow,"i1nrow, ChlSymb",&i1nrow);if(ierr) return FALSE; i2nrow=i1nrow+nrow; i3nrow=i2nrow+nrow; i4nrow=i3nrow+nrow; DetectDenseNodes(sf,sf->uhead,sf->invp, i1nrow,i2nrow,i3nrow,i4nrow); iFree(&i1nrow); sf->uhead[0]=0; for(i=1; iuhead[i]=sf->uhead[i-1]+sf->ujsze[i-1]; for(i=0; insnds; ++k) if ( subg[k]+1!=subg[k+1] ) break; ierr=iAlloc(3*sf->n,NULL,&sf->iw);if(ierr) return FALSE; ierr=dAlloc(2*sf->n,NULL,&sf->rw);if(ierr) return FALSE; sf->factor=0; return TRUE; } /* ChlSymb */ int SymbProc(int* isze, int* jsub, int n, chfac** sf) { int ierr,i,k,t,snnz,lnnz,*nnzi,nrow,resp; chfac* cf; order *od; /* * set data for symmetric matrix to be factorized */ ierr=CfcAlloc(n,"sdt->sf, SymbProc",&cf);if(ierr) return FALSE; nrow=cf->nrow; for (snnz=0,i=0; issub); if(ierr) return FALSE; cf->snnz=snnz; nnzi=cf->perm; iZero(nrow,nnzi,NULL); k=0; for (i=0; ishead[i]=k; cf->ssize[i]=snnz; k+=snnz; } iCopy(k,jsub,cf->ssub); nnzi=cf->perm; iZero(nrow,nnzi,NULL); for (i=0; issize[i]; plusXs(cf->ssize[i],nnzi,cf->ssub+cf->shead[i]); } ierr=OdAlloc(nrow,2*cf->snnz,"od, PspSymbo",&od); if(ierr) return FALSE; nnzi=cf->perm; OdInit(od,nnzi); for (i=0; issize[i]; ++t) OdIndex(od,i,cf->ssub[cf->shead[i]+t]); GetOrder(od,cf->perm); lnnz=od->ntot; OdFree(&od); resp=ChlSymb(cf,lnnz); LvalAlloc(cf,"cf, PspSymb"); /* sdt->sf=cf; */ *sf=cf; return resp; } /* SymbProc */ int MchlSetup2(int m, chfac** A) { int ierr,i,j,k,lnnz,mnnz; chfac *mf; ierr =CfcAlloc(m,NULL,&mf); if(ierr) return 1; *A=mf; mnnz=m*(m-1)/2; if (!mnnz && m>1) return TRUE; lnnz=mnnz; ierr=iAlloc(mnnz,NULL,&mf->ssub);if(ierr) return 1; mf->snnz=mnnz; k=0; for (i=0; ishead[i] =k; mf->ssize[i] =mnnz; for (j=0; jssub[k+j]=(j+1+i); k +=mnnz; mf->perm[i]=i; } k=ChlSymb(mf,lnnz); iFree(&mf->ssub); iFree(&mf->shead); iFree(&mf->ssize); /* This part is different */ mf->alldense=1; iFree(&mf->invp); mf->invp=mf->perm; iFree(&mf->ujbeg); mf->ujbeg=mf->perm; iFree(&mf->usub); mf->usub=mf->perm+1; ierr=LvalAlloc(mf,"cf, PspSymb");if(ierr) return 1; return 0; } /* MchlSetup2 */ DSDP5.8/src/vecmat/sdpvec.c0000644000175000017500000002555510326241003015502 0ustar twernertwerner#include "dsdpsys.h" #include "dsdpvec.h" #include "dsdplapack.h" /*! \file sdpvec.c \brief DSDPVec operations */ #if !defined (min) #define min(a,b) ((a <= b)? (a) : (b)) #endif #if !defined (max) #define max(a,b) ((a >= b)? (a) : (b)) #endif #define DSPPVecCheck(a,b) {if (a.dim != b.dim) return 1; if (a.dim>0 && (a.val==NULL || b.val==NULL) ) return 2;} static int nvecs=0; #undef __FUNCT__ #define __FUNCT__ "DSDPVecCreateSeq" int DSDPVecCreate(DSDPVec *V){ int info; info = DSDPVecCreateSeq(0,V);DSDPCHKERR(info); return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPVecCreateSeq" int DSDPVecCreateSeq(int n ,DSDPVec *V){ int info; V->dim=n; if (n>0){ nvecs++; DSDPCALLOC2(&(V->val),double,n,&info);DSDPCHKERR(info); if (V->val==NULL) return 1; } else { V->val=NULL; } return 0; } /* #undef __FUNCT__ #define __FUNCT__ "DSDPVecCreateWArray" int DSDPVecCreateWArray(DSDPVec *V, double* vv, int n){ V->dim=n; if (n>0){ V->val=vv; } else { V->val=NULL; } return 0; } */ #undef __FUNCT__ #define __FUNCT__ "DSDPVecDestroy" int DSDPVecDestroy(DSDPVec *V){ int info; if ((*V).val){ DSDPFREE(&(*V).val,&info);DSDPCHKERR(info); nvecs--; } (*V).dim=0; (*V).val=0; return 0; } /* int DSDPVecGetSize(DSDPVec V, int *n){ *n=V.dim; return 0; } int DSDPVecGetArray(DSDPVec V, double **dptr){ *dptr=V.val; return 0; } int DSDPVecRestoreArray(DSDPVec V, double **dptr){ *dptr=0; return 0; } */ #undef __FUNCT__ #define __FUNCT__ "DSDPVecView" int DSDPVecView(DSDPVec vec){ int i; for (i=0; iport[ind]==xt->idep); } /* ChkXlist */ static void XtClear(xlist *xt) { int i,sze; sze =xt->last; xt->idep=xt->most+1; xt->lowp=xt->idep; xt->cure=sze; xt->ntot=0; for (i=0; iidep; i++) xt->head[i]=xt->last; for (i=0; iport[i]=xt->idep; xt->fwrd[i]=xt->last; xt->bwrd[i]=xt->last; } } /* XtClear */ int XtAlloc(int last, int most, char *info, xlist**rr) { xlist *r; int ierr=0; r=(xlist*) calloc(1,sizeof(xlist)); if (!r) ExitProc(OutOfSpc,info); r->loca=TRUE; r->last=last; r->most=most; r->ntot=0; ierr=iAlloc(most+1,info,&r->head); if(ierr) return 1; ierr=iAlloc(last,info,&r->port); if(ierr) return 1; ierr=iAlloc(last,info,&r->fwrd); if(ierr) return 1; ierr=iAlloc(last,info,&r->bwrd); if(ierr) return 1; XtClear(r); *rr=r; return (0); } /* XtAlloc */ void XtFree(xlist **xt) { xlist *r=*xt; if (r) { if (r->loca) { iFree(&r->head); iFree(&r->port); iFree(&r->fwrd); iFree(&r->bwrd); } free(r); *xt=NULL; } } /* XtFree */ int XtSucc(xlist *xt) { int t,last=xt->last,most=xt->most, *head; if (xt->cure==last) return (FALSE); if (xt->fwrd[xt->cure]!=last) xt->cure=xt->fwrd[xt->cure]; else { head=xt->head; for(t=xt->port[xt->cure]+1; t<=most && head[t]==last; ++t); if (t>most) xt->cure=last; else xt->cure=xt->head[t]; } return (TRUE); } /* XtSucc */ void XtDel(xlist *xt, int e) { int p; if (!ChkXlist(xt,e)) { if (xt->ntot<=0) ExitProc(SysError,NULL); xt->ntot--; if (xt->cure==e) { if (xt->ntot) XtSucc(xt); else xt->cure=xt->last; } p =xt->port[e]; xt->port[e]=xt->idep; if (xt->bwrd[e]!=xt->last) xt->fwrd[xt->bwrd[e]]=xt->fwrd[e]; else xt->head[p]=xt->fwrd[e]; if (xt->fwrd[e]!=xt->last) xt->bwrd[xt->fwrd[e]]=xt->bwrd[e]; if (xt->head[p]==xt->last && xt->lowp==p) { xt->lowp=xt->idep; if (xt->ntot) { for(++p; p<=xt->most; ++p){ if (xt->head[p]!=xt->last){ xt->lowp=p; break; } } } } } } /* XtDel */ void XtPut(xlist *xt, int e, int p) { if (0<=e && elast && 0<=p && p<=xt->most) { XtDel(xt,e); xt->ntot++; xt->port[e] =p; xt->fwrd[e] =xt->head[p]; xt->bwrd[e]=xt->last; if (xt->head[p]!=xt->last) xt->bwrd[xt->head[p]]=e; xt->head[p]=e; xt->lowp =min(p,xt->lowp); } else ExitProc(SysError,NULL); } /* XtPut */ int XtLeast(xlist *xt) { if (xt->lowp==xt->idep) { if (xt->ntot!=0) ExitProc(SysError,NULL); xt->cure=xt->last; return FALSE; } else { if (xt->ntot<=0) ExitProc(SysError,NULL); xt->cure=xt->head[xt->lowp]; return TRUE; } } /* XtLeast */ int XtGet(xlist *xt, int *e, int *p) { if (xt->cure>xt->last) ExitProc(SysError,NULL); if (xt->cure==xt->last) return FALSE; *e=xt->cure; *p=xt->port[*e]; return TRUE; } /* XtGet */ DSDP5.8/src/vecmat/spds.c0000644000175000017500000001270410326241003015157 0ustar twernertwerner#include "dsdpsys.h" #include "dsdpdsmat_impl.h" /*! \file spds.c \brief DSDPDualMat object with sparse data structures. */ typedef struct { int n; double *an; int *col; int *nnz; } spdsmat; static int SpSymMatSetURValuesP(void*DS, double v[], int nn, int n){ spdsmat*ds=(spdsmat*)DS; int i,j,k1,k2,*nnz=ds->nnz,*col=ds->col; double *an=ds->an; for (i=0;innz,*col=ds->col; double *an=ds->an; for (i=0;in,*nnz=ds->nnz,*col=ds->col; double *an=ds->an; for (i=0;in,*nnz=ds->nnz; double *an=ds->an; for (i=0;innz,&info);if (info) return 1; DSDPFREE(&ds->col,&info);if (info) return 1; DSDPFREE(&ds->an,&info);if (info) return 1; DSDPFREE(&ds,&info);if (info) return 1; return 0; } static int SpSymMatGetSize(void *DS, int*n){ spdsmat*ds=(spdsmat*)DS; *n=ds->n; return 0; } static int SpSymMatZero(void*DS){ spdsmat*ds=(spdsmat*)DS; int nn=ds->nnz[ds->n]; double *an=ds->an; memset((void*)an,0,nn*sizeof(double)); return 0; } static int SpSymMatMult(void*DS, double x[], double y[], int n){ spdsmat*ds=(spdsmat*)DS; int i,j,k1,k2,*nnz=ds->nnz,*col=ds->col; double *an=ds->an; memset((void*)y,0,n*sizeof(double)); for (i=0;innz,*col=ds->col; double vv,*an=ds->an; *vAv=0; for (i=0;innz,*col=ds->col; double *an=ds->an; k1=nnz[row]; k2=nnz[row+1]; for (j=k1;jmatseturmat=SpSymMatSetURValuesP; dsops->matview=SpSymMatView; dsops->matdestroy=SpSymMatDestroy; dsops->matgetsize=SpSymMatGetSize; dsops->matzeroentries=SpSymMatZero; dsops->matmult=SpSymMatMult; dsops->matvecvec=SpSymMatVecVec; dsops->id=6; dsops->matname=dsmatname; return 0; } static int DSDPDSSparseInitializeOpsU(struct DSDPDSMat_Ops* dsops){ int info; if (!dsops) return 0; info=DSDPDSMatOpsInitialize(dsops); DSDPCHKERR(info); dsops->matseturmat=SpSymMatSetURValuesU; dsops->matview=SpSymMatView; dsops->matdestroy=SpSymMatDestroy; dsops->matgetsize=SpSymMatGetSize; dsops->matzeroentries=SpSymMatZero; dsops->matmult=SpSymMatMult; dsops->matvecvec=SpSymMatVecVec; dsops->id=6; dsops->matname=dsmatname; return 0; } static struct DSDPDSMat_Ops tdsdsopsp; static struct DSDPDSMat_Ops tdsdsopsu; #undef __FUNCT__ #define __FUNCT__ "DSDPCreateSparseDSMat" int DSDPSparseMatCreatePattern2P(int n, int rnnz[], int cols[], int tnnz,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int i,info; spdsmat*ds; DSDPFunctionBegin; DSDPCALLOC1(&ds,spdsmat,&info);DSDPCHKERR(info); DSDPCALLOC2(&ds->nnz,int,(n+1),&info);DSDPCHKERR(info); ds->nnz[0]=0; for (i=0;innz[i+1]=ds->nnz[i]+rnnz[i]; DSDPCALLOC2(&ds->col,int,tnnz,&info);DSDPCHKERR(info); DSDPCALLOC2(&ds->an,double,tnnz,&info);DSDPCHKERR(info); for (i=0;icol[i]=cols[i]; info=DSDPDSSparseInitializeOpsP(&tdsdsopsp); DSDPCHKERR(info); *dsmatops=&tdsdsopsp; *dsmat=(void*)ds; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateSparseDSMatU" int DSDPSparseMatCreatePattern2U(int n, int rnnz[], int cols[], int tnnz,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int i,info; spdsmat*ds; DSDPFunctionBegin; DSDPCALLOC1(&ds,spdsmat,&info);DSDPCHKERR(info); DSDPCALLOC2(&ds->nnz,int,(n+1),&info);DSDPCHKERR(info); ds->nnz[0]=0; for (i=0;innz[i+1]=ds->nnz[i]+rnnz[i]; DSDPCALLOC2(&ds->col,int,tnnz,&info);DSDPCHKERR(info); DSDPCALLOC2(&ds->an,double,tnnz,&info);DSDPCHKERR(info); for (i=0;icol[i]=cols[i]; info=DSDPDSSparseInitializeOpsU(&tdsdsopsu); DSDPCHKERR(info); *dsmatops=&tdsdsopsu; *dsmat=(void*)ds; DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/vech.c0000644000175000017500000003671710326241003015145 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file vech.c \brief DSDPDataMat for sparse matrices in upper packed symmetric format */ typedef struct { int neigs; double *eigval; double *an; int *cols,*nnz; } Eigen; /*! struct vechmat ; \brief A sparse symmetric data matrix is packed format. */ typedef struct { int nnzeros; const int *ind; const double *val; int ishift; double alpha; Eigen *Eig; int factored; int owndata; int n; } vechmat; #define GETI(a) (int)(sqrt(2*(a)+0.25)-0.5) #define GETJ(b,c) ((b)-((c)*((c)+1))/2) static void getij(int k, int *i,int *j){ *i=GETI(k); *j=GETJ(k,*i); return; } /* static void geti2(int k, int *i,int *j){ int r,c; double rr=sqrt(2*k+0.25)-0.5; r=(int)rr; c=k-(r*(r+1))/2; *i=r;*j=c; return; } */ #undef __FUNCT__ #define __FUNCT__ "CreateVechMatWData" static int CreateVechMatWdata(int n, int ishift, double alpha,const int *ind, const double *vals, int nnz, vechmat **A){ int info; vechmat* V; DSDPCALLOC1(&V,vechmat,&info);DSDPCHKERR(info); V->n=n; V->ishift=ishift, V->ind=ind; V->val=vals;V->nnzeros=nnz; V->alpha=alpha; V->owndata=0; V->Eig=0; *A=V; return 0; } static int VechMatAddMultiple(void* AA, double scl, double r[], int nn, int n){ vechmat* A=(vechmat*)AA; int k,nnz=A->nnzeros; const int* ind=A->ind; const double *val=A->val; double *rr=r-A->ishift; scl*=A->alpha; for (k=0; knnzeros; const int *ind=A->ind; double vv=0, *xx=x-A->ishift; const double *val=A->val; for (k=0;kalpha; return 0; } static int EigMatVecVec(Eigen*, double[], int, double*); static int VechMatGetRank(void*,int*,int); static int VechMatVecVec(void* AA, double x[], int n, double *v){ vechmat* A=(vechmat*)AA; int info,rank=n,i=0,j,k,kk; const int *ind=A->ind,ishift=A->ishift; double vv=0,dd; const double *val=A->val,nnz=A->nnzeros; if (A->factored==3){ info=VechMatGetRank(AA,&rank,n); if (nnz>3 && rankEig,x,n,&vv); *v=vv*A->alpha; return 0; } } for (k=0; kalpha; return 0; } static int VechMatGetRowNnz(void* AA, int trow, int nz[], int *nnzz,int nn){ vechmat* A=(vechmat*)AA; int i=0,j,k,ishift=A->ishift,nnz=A->nnzeros; const int *ind=A->ind; *nnzz=0; for (k=0; kishift,nnz=A->nnzeros; const int *ind=A->ind; double fn2=0; const double *val=A->val; for (k=0; kalpha*A->alpha; return 0; } static int VechMatAddRowMultiple(void* AA, int trow, double scl, double r[], int m){ vechmat* A=(vechmat*)AA; int i=0,j,k,ishift=A->ishift,nnz=A->nnzeros; const int *ind=A->ind; const double *val=A->val; scl*=A->alpha; for (k=0; knnzeros; return 0; } #undef __FUNCT__ #define __FUNCT__ "VechMatDestroy" static int VechMatDestroy(void* AA){ vechmat* A=(vechmat*)AA; int info; if (A->owndata){ /* Never happens if (A->ind){ DSDPFREE(&A->ind,&info);DSDPCHKERR(info);} if (A->val){ DSDPFREE(&A->val,&info);DSDPCHKERR(info);} */ return 1; } if (A->Eig){ DSDPFREE(&A->Eig->eigval,&info);DSDPCHKERR(info); DSDPFREE(&A->Eig->an,&info);DSDPCHKERR(info); if (A->Eig->cols){DSDPFREE(&A->Eig->cols,&info);DSDPCHKERR(info);} if (A->Eig->nnz){DSDPFREE(&A->Eig->nnz,&info);DSDPCHKERR(info);} DSDPFREE(&A->Eig,&info);DSDPCHKERR(info); } DSDPFREE(&A,&info);DSDPCHKERR(info); return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateVechMatEigs" static int CreateEigenLocker(Eigen **EE,int iptr[], int neigs, int n){ int i,k,info; Eigen *E; for (k=0,i=0;in*neigs/4){ DSDPCALLOC1(&E,Eigen,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,n*neigs,&info);DSDPCHKERR(info); E->neigs=neigs; E->cols=0; E->nnz=0; } else { DSDPCALLOC1(&E,Eigen,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->nnz,int,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,k,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->cols,int,k,&info);DSDPCHKERR(info); E->neigs=neigs; if (neigs>0) E->nnz[0]=iptr[0]; for (i=1;innz[i]=E->nnz[i-1]+iptr[i];} } *EE=E; return 0; } static int EigMatSetEig(Eigen* A,int row, double eigv, int idxn[], double v[], int nsub,int n){ int j,k,*cols=A->cols; double *an=A->an; A->eigval[row]=eigv; if (cols){ k=0; if (row>0){ k=A->nnz[row-1];} cols+=k; an+=k; for (k=0,j=0; jcols,bb,ee; double* an=A->an; *eigenvalue=A->eigval[row]; *nind=0; if (cols){ memset((void*)eigenvector,0,n*sizeof(double)); if (row==0){ bb=0;} else {bb=A->nnz[row-1];} ee=A->nnz[row]; for (i=bb;icols,neigs=A->neigs,*nnz=A->nnz,bb,ee; double* an=A->an,*eigval=A->eigval,dd,ddd=0; if (cols){ for (rank=0;rankishift,isdiag,nonzeros=A->nnzeros,info; int nn1=0,nn2=0; double *ss1=0,*ss2=0; const int *ind=A->ind; if (A->factored) return 0; memset((void*)iptr,0,3*n*sizeof(int)); /* Find number of nonzeros in each row */ for (isdiag=1,k=0; kfactored=1; return 0;} /* Find most nonzeros per row */ for (j=0,i=0; ij) j=iptr[i]; } if (j<2){ A->factored=2; return 0; } info=VechMatComputeEigs(A,dmatp,nn0,dwork,n,ddwork,n1,iptr,n2,ss1,nn1,ss2,nn2);DSDPCHKERR(info); A->factored=3; return 0; } static int VechMatGetRank(void *AA,int *rank,int n){ vechmat* A=(vechmat*)AA; switch (A->factored){ case 1: *rank=A->nnzeros; break; case 2: *rank=2*A->nnzeros; break; case 3: *rank=A->Eig->neigs; break; default: DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static int VechMatGetEig(void* AA, int rank, double *eigenvalue, double vv[], int n, int indx[], int *nind){ vechmat* A=(vechmat*)AA; const double *val=A->val,tt=sqrt(0.5); int info,i,j,k,ishift=A->ishift; const int *ind=A->ind; *nind=0; switch (A->factored){ case 1: memset(vv,0,n*sizeof(double)); getij(ind[rank]-ishift,&i,&j); vv[i]=1.0; *eigenvalue=val[rank]*A->alpha; *nind=1; indx[0]=i; break; case 2: memset(vv,0,n*sizeof(double)); k=rank/2; getij(ind[k]-ishift,&i,&j); if (i==j){ if (k*2==rank){ vv[i]=1.0; *eigenvalue=val[k]*A->alpha; *nind=1; indx[0]=i; } else { *eigenvalue=0; } } else { if (k*2==rank){ vv[i]=tt; vv[j]=tt; *eigenvalue=val[k]*A->alpha; *nind=2; indx[0]=i; indx[1]=j; } else { vv[i]=-tt; vv[j]=tt; *eigenvalue=-val[k]*A->alpha; *nind=2; indx[0]=i; indx[1]=j; } } break; case 3: info=EigMatGetEig(A->Eig,rank,eigenvalue,vv,n,indx,nind);DSDPCHKERR(info); *eigenvalue=*eigenvalue*A->alpha; break; default: DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static int VechMatView(void* AA){ vechmat* A=(vechmat*)AA; int info,i=0,j,k,rank=0,ishift=A->ishift,nnz=A->nnzeros; const int *ind=A->ind; const double *val=A->val; for (k=0; kalpha*val[k]); } if (A->factored>0){ info=VechMatGetRank(AA,&rank,A->n);DSDPCHKERR(info); printf("Detected Rank: %d\n",rank); } return 0; } static struct DSDPDataMat_Ops vechmatops; static const char *datamatname="STANDARD VECH MATRIX"; static int VechMatOpsInitialize(struct DSDPDataMat_Ops *sops){ int info; if (sops==NULL) return 0; info=DSDPDataMatOpsInitialize(sops); DSDPCHKERR(info); sops->matvecvec=VechMatVecVec; sops->matdot=VechMatDot; sops->matfnorm2=VechMatFNorm2; sops->mataddrowmultiple=VechMatAddRowMultiple; sops->mataddallmultiple=VechMatAddMultiple; sops->matview=VechMatView; sops->matdestroy=VechMatDestroy; sops->matfactor2=VechMatFactor; sops->matgetrank=VechMatGetRank; sops->matgeteig=VechMatGetEig; sops->matrownz=VechMatGetRowNnz; sops->matnnz=VechMatCountNonzeros; sops->id=3; sops->matname=datamatname; return 0; } /*! \fn int DSDPGetVechMat(int n,int ishift,double alpha, const int ind[], const double val[],int nnz, struct DSDPDataMat_Ops**sops, void**smat) \brief Given data in packed symmetric format, create a sparse matrix usuable by DSDP. \param n number of rows and columns of the matrix \param ishift the index of the first element in the matrix (usually 0) \param alpha the multiple of these matrix. \param ind array of indices for matrix. \param val array of matrix values. \param nnz size of arrays. \param sops address of a pointer to a table of function pointers \param smat address of a pointer to an opaque data type. */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetVechMat" int DSDPGetVechMat(int n,int ishift,double alpha, const int ind[], const double val[],int nnz, struct DSDPDataMat_Ops**sops, void**smat){ int info,i,j,k,itmp,nn=n*(n+1)/2; double dtmp; vechmat* AA; DSDPFunctionBegin; for (k=0;k=nn){ getij(itmp,&i,&j); /* DSDPSETERR(2,"Illegal index value: Element %d in array has row %d (>0) or column %d (>0) is greater than %d. \n",k+1,i+1,j+1,n); */ DSDPSETERR3(2,"Illegal index value: Element %d in array has index %d greater than or equal to %d. \n",k,itmp,nn); } else if (itmp<0){ DSDPSETERR1(2,"Illegal index value: %d. Must be >= 0\n",itmp); } } for (k=0;kfactored=0; AA->Eig=0; info=VechMatOpsInitialize(&vechmatops); DSDPCHKERR(info); if (sops){*sops=&vechmatops;} if (smat){*smat=(void*)AA;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VechMatComputeEigs" static int VechMatComputeEigs(vechmat* AA,double DD[], int nn0, double W[], int n, double WORK[], int n1, int iiptr[], int n2, double ss1[],int nn1, double ss2[], int nn2){ int i,j,k,nsub,neigs,info,*iptr,*perm,*invp; long int *i2darray=(long int*)DD; int ownarray1=0,ownarray2=0,ownarray3=0; int ishift=AA->ishift,nonzeros=AA->nnzeros; const int *ind=AA->ind; const double *val=AA->val; double *dmatarray=ss1,*dworkarray=ss2,maxeig,eps=1.0e-12,eps2=1.0e-12; iptr=iiptr; perm=iptr+n; invp=perm+n; /* These operations were done before calling this routine * / / * Integer arrays corresponding to rows with nonzeros and inverse map * / memset((void*)iiptr,0,3*n*sizeof(int)); / * Find number of nonzeros in each row * / for (i=0,k=0; k0){ invp[nsub]=i; perm[i]=nsub; nsub++;} } /* create a dense array in which to put numbers */ if (nsub*nsub>nn1){ DSDPCALLOC2(&dmatarray,double,(nsub*nsub),&info); DSDPCHKERR(info); ownarray1=1; } memset((void*)dmatarray,0,nsub*nsub*sizeof(double)); if (nsub*nsub>nn2){ DSDPCALLOC2(&dworkarray,double,(nsub*nsub),&info); DSDPCHKERR(info); ownarray2=1; } if (nsub*nsub*sizeof(long int)>nn0*sizeof(double)){ DSDPCALLOC2(&i2darray,long int,(nsub*nsub),&info); DSDPCHKERR(info); ownarray3=1; } for (i=0,k=0; kmaxeig){ maxeig=fabs(W[i]); } } memset((void*)iptr,0,nsub*sizeof(int)); /* Compute sparsity pattern for eigenvalue and eigenvector structures */ /* Count the nonzero eigenvalues */ for (neigs=0,k=0; k eps){ for (j=0;j= eps2){iptr[neigs]++; } else { dmatarray[nsub*k+j]=0.0;} } neigs++; /* } else if (fabs(W[k])>1.0e-100){ printf("SKIPPING EIGENVALUE: %4.4e, max is : %4.4e\n",W[k],maxeig); */ } } info=CreateEigenLocker(&AA->Eig,iptr,neigs,n);DSDPCHKERR(info); DSDPLogInfo(0,49," Data Mat has %d eigenvalues: \n",neigs); /* Copy into structure */ for (neigs=0,i=0; i eps){ info=EigMatSetEig(AA->Eig,neigs,W[i],invp,dmatarray+nsub*i,nsub,n);DSDPCHKERR(info); neigs++; } } if (ownarray1){ DSDPFREE(&dmatarray,&info);DSDPCHKERR(info);} if (ownarray2){ DSDPFREE(&dworkarray,&info);DSDPCHKERR(info);} if (ownarray3){ DSDPFREE(&i2darray,&info);DSDPCHKERR(info);} return 0; } DSDP5.8/src/vecmat/zeromat.c0000644000175000017500000000444410326241003015671 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file zeromat.c \brief DSDPDataMat object with all zero entries. */ static int ZDestroy(void*); static int ZView(void*); static int ZVecVec(void*, double[], int, double *); static int ZDot(void*, double[], int, int,double *); static int ZGetRank(void*, int*,int); static int ZFactor(void*); static int ZGetEig(void*, int, double*, double[], int,int[],int*); static int ZAddRowMultiple(void*, int, double, double[], int); static int ZAddMultiple(void*, double, double[], int,int); static int ZRowNnz(void*, int, int[], int*, int); static struct DSDPDataMat_Ops zeromatops; static int ZeroMatopsInitialize(struct DSDPDataMat_Ops*); int DSDPGetZeroDataMatOps(struct DSDPDataMat_Ops** zops){ int info; info=ZeroMatopsInitialize(&zeromatops); if (info){return info;} if (zops){*zops=&zeromatops;} return info; } static int ZFactor(void *A){ return 0; } static int ZGetRank(void*A,int*rank,int n){ *rank=0; return 0; } static int ZGetEig(void*A,int neig, double *eig, double v[], int n,int indx[],int*nind){ *eig=0.0; *nind=0; return 0; } static int ZDot(void*A, double x[], int nn, int n, double *sum){ *sum=0.0; return 0; } static int ZVecVec(void*A, double x[], int n, double *sum){ *sum=0.0; return 0; } static int ZAddMultiple(void*A, double dd, double row[], int nn, int n){ return 0; } static int ZAddRowMultiple(void*A, int nrow, double dd, double row[], int n){ return 0; } static int ZRowNnz(void*A, int row, int nz[], int *nnz, int n){ *nnz=0; return 0; } static int ZDestroy(void*A){ return 0; } static int ZNorm2(void*A,int n,double *v){ *v=0; return 0; } static int ZView(void*A){ printf("All zeros\n"); return 0; } static const char* datamatname="MATRIX OF ZEROS"; static int ZeroMatopsInitialize(struct DSDPDataMat_Ops* sops){ int info; if (sops==NULL) return 0; info=DSDPDataMatOpsInitialize(sops); if (info){ return info;} sops->matfactor1=ZFactor; sops->matgetrank=ZGetRank; sops->matgeteig=ZGetEig; sops->matvecvec=ZVecVec; sops->matdot=ZDot; sops->matfnorm2=ZNorm2; sops->matrownz=ZRowNnz; sops->mataddrowmultiple=ZAddRowMultiple; sops->mataddallmultiple=ZAddMultiple; sops->matdestroy=ZDestroy; sops->matview=ZView; sops->id=10; sops->matname=datamatname; return 0; } DSDP5.8/src/vecmat/dufull.c0000644000175000017500000010377610326241003015513 0ustar twernertwerner#include "dsdpsys.h" #include "dsdpvec.h" #include "dsdplapack.h" #include "dsdpdatamat_impl.h" /*! \file dufull.c \brief DSDPDataMat, DSDPDualMat, DSDPDSMat, DSDPSchurMat, DSDPXMat objects implemented in symmetric upper full symmetric format. */ typedef enum { Init=0, Assemble=1, Factored=2, /* fail to allocate required space */ Inverted=3, /* indefinity is detected */ ISymmetric=4 } MatStatus; typedef struct{ char UPLO; int LDA; double *val,*v2; double *sscale; double *workn; int scaleit; int n; int owndata; MatStatus status; } dtrumat; static int DTRUMatView(void*); #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKROUTINE" static void dtruscalevec(double alpha, double v1[], double v2[], double v3[], int n){ int i; for (i=0;iowndata=owndata; return; } static int SUMatGetLDA(int n){ int nlda=n; if (n>8 && nlda%2==1){ nlda++;} if (n>100){ while (nlda%8!=0){ nlda++;} } /* printf("LDA: %d %d %d \n",n,nlda,(int)sizeof(double)); */ return (nlda); } static int DTRUMatCreateWData(int n,int LDA,double nz[], int nnz, dtrumat**M){ int i,info; dtrumat*M23; if (nnzsscale,double,n,&info);DSDPCHKERR(info); DSDPCALLOC2(&M23->workn,double,n,&info);DSDPCHKERR(info); M23->owndata=0; M23->val=nz; M23->n=n; M23->UPLO='U';M23->LDA=n; M23->status=Init; for (i=0;isscale[i]=1.0; M23->scaleit=1; M23->LDA=LDA; if (n<=0){M23->LDA=1;} *M=M23; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPGetEigs" int DSDPGetEigs(double A[],int n, double AA[], int nn0, long int IA[], int nn1, double W[],int n2, double WORK[],int nd, int LLWORK[], int ni){ ffinteger N=n,LDA=n,LDZ=n,LWORK=nd,INFO=0; char UPLO='U',JOBZ='V',RANGE='A'; /* Faster, but returns more error codes. ie. INFO>0 sometimes*/ LDA=DSDPMax(1,n); LDZ=DSDPMax(1,n); if ( n2/2.5 > n || (ni<10*n+1) || (nd<26*n+1) || (nn0 < n*LDA) || (nn1LDA,INCX=1,INCY=1; double BETA=0.0,ALPHA=1.0; double *AP=A->val,*Y=y,*X=x; char UPLO=A->UPLO,TRANS='N'; if (A->n != n) return 1; if (x==0 && n>0) return 3; if (0==1){ dgemv(&TRANS,&N,&N,&ALPHA,AP,&LDA,X,&INCX,&BETA,Y,&INCY); } else { dsymv(&UPLO,&N,&ALPHA,AP,&LDA,X,&INCX,&BETA,Y,&INCY); } return 0; } static int DTRUMatMultR(void* AA, double x[], double y[], int n){ dtrumat* A=(dtrumat*) AA; ffinteger N=n,LDA=A->LDA,INCX=1,INCY=1; double ALPHA=1.0; double *AP=A->val,*Y=y,*X=x,*ss=A->sscale,*W=A->workn; char UPLO=A->UPLO,TRANS='N',DIAG='U'; UPLO='L'; if (A->n != n) return 1; if (x==0 && n>0) return 3; /* dsymv(&UPLO,&N,&ALPHA,AP,&LDA,X,&INCX,&BETA,Y,&INCY); */ memset(y,0,n*sizeof(double)); memcpy(W,X,n*sizeof(double)); TRANS='N'; UPLO='L'; dtrmv(&UPLO,&TRANS,&DIAG,&N,AP,&LDA,W,&INCY); daxpy(&N,&ALPHA,W,&INCX,Y,&INCY); memcpy(W,X,n*sizeof(double)); TRANS='T'; UPLO='L'; dtrmv(&UPLO,&TRANS,&DIAG,&N,AP,&LDA,W,&INCY); daxpy(&N,&ALPHA,W,&INCX,Y,&INCY); dsydadd(x,ss,y,n); return 0; } static void DTRUMatScale(void*AA){ dtrumat* A=(dtrumat*) AA; int i,N=A->n,LDA=A->LDA; double *ss=A->sscale,*v=A->val; for (i=0;ival,ss,N,LDA); } static int DTRUMatCholeskyFactor(void* AA, int *flag){ dtrumat* A=(dtrumat*) AA; ffinteger INFO,LDA=A->LDA,N=A->n; double *AP=A->val; char UPLO=A->UPLO; if (A->scaleit){ DTRUMatScale(AA);} dpotrf(&UPLO, &N, AP, &LDA, &INFO ); *flag=INFO; A->status=Factored; return 0; } int dtrsm2(char*,char*,char*,char*,ffinteger*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*); static int DTRUMatSolve(void* AA, double b[], double x[],int n){ dtrumat* A=(dtrumat*) AA; ffinteger ierr,INFO=0,NRHS=1,LDA=A->LDA,LDB=A->LDA,N=A->n; double *AP=A->val,*ss=A->sscale,ONE=1.0; char SIDE='L',UPLO=A->UPLO,TRANSA='N',DIAG='N'; dtruscalevec(1.0,ss,b,x,n); if (0==1){ dpotrs(&UPLO, &N, &NRHS, AP, &LDA, x, &LDB, &INFO ); } else { TRANSA='T'; ierr=dtrsm2(&SIDE,&UPLO,&TRANSA,&DIAG,&N, &NRHS, &ONE, AP, &LDA, x, &LDB ); TRANSA='N'; ierr=dtrsm2(&SIDE,&UPLO,&TRANSA,&DIAG,&N, &NRHS, &ONE, AP, &LDA, x, &LDB ); } dtruscalevec(1.0,ss,x,x,n); return INFO; } static int DTRUMatShiftDiagonal(void* AA, double shift){ dtrumat* A=(dtrumat*) AA; int i,n=A->n, LDA=A->LDA; double *v=A->val; for (i=0; iLDA,nn,INCX=1,INCY=A->LDA; double *vv=A->val; nn=nrow; daxpy(&nn,&dd,row,&INCX,vv+nrow,&INCY); nn=nrow+1; daxpy(&nn,&dd,row,&ione,vv+nrow*LDA,&ione); return 0; } static int DTRUMatZero(void* AA){ dtrumat* A=(dtrumat*) AA; int mn=A->n*(A->LDA); double *vv=A->val; memset((void*)vv,0,mn*sizeof(double)); A->status=Assemble; return 0; } static int DTRUMatGetSize(void *AA, int *n){ dtrumat* A=(dtrumat*) AA; *n=A->n; return 0; } static int DTRUMatDestroy(void* AA){ int info; dtrumat* A=(dtrumat*) AA; if (A && A->owndata){DSDPFREE(&A->val,&info);DSDPCHKERR(info);} if (A && A->sscale) {DSDPFREE(&A->sscale,&info);DSDPCHKERR(info);} if (A && A->workn) {DSDPFREE(&A->workn,&info);DSDPCHKERR(info);} if (A) {DSDPFREE(&A,&info);DSDPCHKERR(info);} return 0; } static int DTRUMatView(void* AA){ dtrumat* M=(dtrumat*) AA; int i,j; double *val=M->val; ffinteger LDA=M->LDA; for (i=0; in; i++){ for (j=0; j<=i; j++){ printf(" %9.2e",val[i*LDA+j]); } for (j=i+1; jLDA; j++){ printf(" %9.1e",val[i*LDA+j]); } printf("\n"); } return 0; } static int DTRUMatView2(void* AA){ dtrumat* M=(dtrumat*) AA; int i,j; double *val=M->v2; ffinteger LDA=M->LDA; for (i=0; in; i++){ for (j=0; j<=i; j++){ printf(" %9.2e",val[i*LDA+j]); } for (j=i+1; jLDA; j++){ printf(" %9.2e",val[i*LDA+j]); } printf("\n"); } return 0; } #include "dsdpschurmat_impl.h" #include "dsdpdualmat_impl.h" #include "dsdpdatamat_impl.h" #include "dsdpxmat_impl.h" #include "dsdpdsmat_impl.h" #include "dsdpsys.h" #undef __FUNCT__ #define __FUNCT__ "Tassemble" static int DTRUMatAssemble(void*M){ int info; double shift=1.0e-15; DSDPFunctionBegin; info= DTRUMatShiftDiagonal(M, shift); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int DTRUMatRowNonzeros(void*M, int row, double cols[], int *ncols,int nrows){ int i; DSDPFunctionBegin; *ncols = row+1; for (i=0;i<=row;i++){ cols[i]=1.0; } memset((void*)(cols+row+1),0,(nrows-row-1)*sizeof(int)); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "TAddDiag" static int DTRUMatAddDiag(void*M, int row, double dd){ int ii; dtrumat* ABA=(dtrumat*)M; ffinteger LDA=ABA->LDA; DSDPFunctionBegin; ii=row*LDA+row; ABA->val[ii] +=dd; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "TAddDiag2" static int DTRUMatAddDiag2(void*M, double diag[], int m){ int row,ii; dtrumat* ABA=(dtrumat*)M; ffinteger LDA=ABA->LDA; DSDPFunctionBegin; for (row=0;rowval[ii] +=diag[row]; } DSDPFunctionReturn(0); } static struct DSDPSchurMat_Ops dsdpmmatops; static const char* lapackname="DENSE,SYMMETRIC U STORAGE"; static int DSDPInitSchurOps(struct DSDPSchurMat_Ops* mops){ int info; DSDPFunctionBegin; info=DSDPSchurMatOpsInitialize(mops);DSDPCHKERR(info); mops->matrownonzeros=DTRUMatRowNonzeros; mops->matscaledmultiply=DTRUMatMult; mops->matmultr=DTRUMatMultR; mops->mataddrow=DTRUMatAddRow; mops->mataddelement=DTRUMatAddDiag; mops->matadddiagonal=DTRUMatAddDiag2; mops->matshiftdiagonal=DTRUMatShiftDiagonal; mops->matassemble=DTRUMatAssemble; mops->matfactor=DTRUMatCholeskyFactor; mops->matsolve=DTRUMatSolve; mops->matdestroy=DTRUMatDestroy; mops->matzero=DTRUMatZero; mops->matview=DTRUMatView; mops->id=1; mops->matname=lapackname; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetLAPACKSUSchurOps" int DSDPGetLAPACKSUSchurOps(int n,struct DSDPSchurMat_Ops** sops, void** mdata){ int info,nn,LDA; double *vv; dtrumat *AA; DSDPFunctionBegin; LDA=SUMatGetLDA(n); nn=n*LDA; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTRUMatCreateWData(n,LDA,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1; info=DSDPInitSchurOps(&dsdpmmatops); DSDPCHKERR(info); *sops=&dsdpmmatops; *mdata=(void*)AA; DSDPFunctionReturn(0); } static int DTRUMatCholeskyBackward(void* AA, double b[], double x[], int n){ dtrumat* M=(dtrumat*) AA; ffinteger N=M->n,INCX=1,LDA=M->LDA; double *AP=M->val,*ss=M->sscale; char UPLO=M->UPLO,TRANS='N',DIAG='N'; memcpy(x,b,N*sizeof(double)); dtrsv(&UPLO,&TRANS,&DIAG, &N, AP, &LDA, x, &INCX ); dtruscalevec(1.0,ss,x,x,n); return 0; } static int DTRUMatCholeskyForward(void* AA, double b[], double x[], int n){ dtrumat* M=(dtrumat*) AA; ffinteger N=M->n,INCX=1,LDA=M->LDA; double *AP=M->val,*ss=M->sscale; char UPLO=M->UPLO,TRANS='T',DIAG='N'; dtruscalevec(1.0,ss,b,x,n); dtrsv(&UPLO,&TRANS,&DIAG, &N, AP, &LDA, x, &INCX ); return 0; } static int DTRUMatLogDet(void* AA, double *dd){ dtrumat* A=(dtrumat*) AA; int i,n=A->n,LDA=A->LDA; double d=0,*v=A->val,*ss=A->sscale; for (i=0; in,LDA=A->LDA; double *AP=A->val,*ss=A->sscale; /* char UPLO=A->UPLO,TRANS='N',DIAG='N'; */ if (x==0 && N>0) return 3; /* memcpy(y,x,N*sizeof(double)); dtrmv(&UPLO,&TRANS,&DIAG,&N,AP,&LDA,Y,&INCY); */ for (i=0;in,LDA=A->LDA; double *AP=A->val,*ss=A->sscale; /* char UPLO=A->UPLO,TRANS='N',DIAG='N'; */ if (x==0 && N>0) return 3; /* memcpy(y,x,N*sizeof(double)); dtrmv(&UPLO,&TRANS,&DIAG,&N,AP,&LDA,Y,&INCY); */ for (i=0;iLDA,N=A->n,nn=LDA*N; double *v=A->val,*AP=A->v2,*ss=A->sscale; char UPLO=A->UPLO; memcpy((void*)AP,(void*)v,nn*sizeof(double)); dpotri(&UPLO, &N, AP, &LDA, &INFO ); if (INFO){ INFO=DTRUMatShiftDiagonal(AA,1e-11); INFO=0; memcpy((void*)AP,(void*)v,nn*sizeof(double)); dpotri(&UPLO, &N, AP, &LDA, &INFO ); } if (A->scaleit){ dtruscalemat(AP,ss,N,LDA); } A->status=Inverted; return INFO; } static void DTRUSymmetrize(dtrumat* A){ int i,j,n=A->n,row,LDA=A->LDA; double *v2=A->v2,*r1=A->v2,*r2=A->v2+LDA,*c1; for (i=0;istatus=ISymmetric; return; } static int DTRUMatInverseAdd(void* AA, double alpha, double y[], int nn, int n){ dtrumat* A=(dtrumat*) AA; ffinteger i,LDA=A->LDA,N,ione=1; double *v2=A->v2; for (i=0;iLDA,i,ione=1; double *v2=A->v2; for (i=0;iLDA,N=A->n,INCX=1,INCY=1; double *AP=A->v2,*s1=A->v2,*s2,*X=x,*Y=y,ALPHA=1.0,BETA=0.0; char UPLO=A->UPLO,TRANS='N'; int i,ii,usefull=1; if (usefull){ if (A->status==Inverted){ DTRUSymmetrize(A); } if (nind < n/4){ memset((void*)y,0,n*sizeof(double)); for (ii=0;iiLDA; double *vv=ABA->val; if (vv!=v){ for (i=0;istatus=Assemble; return 0; } static int DTRUMatSetXMatP(void*A, double v[], int nn, int n){ dtrumat* ABA=(dtrumat*)A; int i,LDA=ABA->LDA; double *vv=ABA->val; if (vv!=v){ for (i=0;istatus=Assemble; return 0; } static int DTRUMatFull(void*A, int*full){ *full=1; return 0; } static int DTRUMatGetArray(void*A,double **v,int *n){ dtrumat* ABA=(dtrumat*)A; *n=ABA->n*ABA->LDA; *v=ABA->val; return 0; } static struct DSDPDualMat_Ops sdmatops; static int SDualOpsInitialize(struct DSDPDualMat_Ops* sops){ int info; if (sops==NULL) return 0; info=DSDPDualMatOpsInitialize(sops);DSDPCHKERR(info); sops->matseturmat=DTRUMatSetXMat; sops->matgetarray=DTRUMatGetArray; sops->matcholesky=DTRUMatCholeskyFactor; sops->matsolveforward=DTRUMatCholeskyForward; sops->matsolvebackward=DTRUMatCholeskyBackward; sops->matinvert=DTRUMatInvert; sops->matinverseadd=DTRUMatInverseAdd; sops->matinversemultiply=DTRUMatInverseMultiply; sops->matforwardmultiply=DTRUMatCholeskyForwardMultiply; sops->matbackwardmultiply=DTRUMatCholeskyBackwardMultiply; sops->matfull=DTRUMatFull; sops->matdestroy=DTRUMatDestroy; sops->matgetsize=DTRUMatGetSize; sops->matview=DTRUMatView; sops->matlogdet=DTRUMatLogDet; sops->matname=lapackname; sops->id=1; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKSUDualMatCreate" static int DSDPLAPACKSUDualMatCreate(int n,struct DSDPDualMat_Ops **sops, void**smat){ dtrumat *AA; int info,nn,LDA=n; double *vv; DSDPFunctionBegin; LDA=SUMatGetLDA(n); nn=n*LDA; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTRUMatCreateWData(n,LDA,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1; info=SDualOpsInitialize(&sdmatops);DSDPCHKERR(info); *sops=&sdmatops; *smat=(void*)AA; DSDPFunctionReturn(0); } static int switchptr(void *SD,void *SP){ dtrumat *s1,*s2; s1=(dtrumat*)(SD); s2=(dtrumat*)(SP); s1->v2=s2->val; s2->v2=s1->val; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKSUDualMatCreate2" int DSDPLAPACKSUDualMatCreate2(int n, struct DSDPDualMat_Ops **sops1, void**smat1, struct DSDPDualMat_Ops **sops2, void**smat2){ int info; DSDPFunctionBegin; info=DSDPLAPACKSUDualMatCreate(n,sops1,smat1);DSDPCHKERR(info); info=DSDPLAPACKSUDualMatCreate(n,sops2,smat2);DSDPCHKERR(info); info=switchptr(*smat1,*smat2);DSDPCHKERR(info); DSDPFunctionReturn(0); } static struct DSDPDualMat_Ops sdmatopsp; static int SDualOpsInitializeP(struct DSDPDualMat_Ops* sops){ int info; if (sops==NULL) return 0; info=DSDPDualMatOpsInitialize(sops);DSDPCHKERR(info); sops->matseturmat=DTRUMatSetXMatP; sops->matgetarray=DTRUMatGetArray; sops->matcholesky=DTRUMatCholeskyFactor; sops->matsolveforward=DTRUMatCholeskyForward; sops->matsolvebackward=DTRUMatCholeskyBackward; sops->matinvert=DTRUMatInvert; sops->matinverseadd=DTRUMatInverseAddP; sops->matinversemultiply=DTRUMatInverseMultiply; sops->matforwardmultiply=DTRUMatCholeskyForwardMultiply; sops->matbackwardmultiply=DTRUMatCholeskyBackwardMultiply; sops->matfull=DTRUMatFull; sops->matdestroy=DTRUMatDestroy; sops->matgetsize=DTRUMatGetSize; sops->matview=DTRUMatView; sops->matlogdet=DTRUMatLogDet; sops->matname=lapackname; sops->id=1; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKSUDualMatCreate" static int DSDPLAPACKSUDualMatCreateP(int n, struct DSDPDualMat_Ops **sops, void**smat){ dtrumat *AA; int info,nn,LDA; double *vv; DSDPFunctionBegin; LDA=SUMatGetLDA(n); nn=LDA*n; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DTRUMatCreateWData(n,LDA,vv,nn,&AA); DSDPCHKERR(info); AA->owndata=1; info=SDualOpsInitializeP(&sdmatopsp);DSDPCHKERR(info); *sops=&sdmatopsp; *smat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLAPACKSUDualMatCreate2P" int DSDPLAPACKSUDualMatCreate2P(int n, struct DSDPDualMat_Ops* *sops1, void**smat1, struct DSDPDualMat_Ops* *sops2, void**smat2){ int info; DSDPFunctionBegin; info=DSDPLAPACKSUDualMatCreateP(n,sops1,smat1); info=DSDPLAPACKSUDualMatCreateP(n,sops2,smat2); info=switchptr(*smat1,*smat2); DSDPFunctionReturn(0); } static int DTRUMatScaleDiagonal(void* AA, double dd){ dtrumat* A=(dtrumat*) AA; ffinteger LDA=A->LDA; int i,n=A->n; double *v=A->val; for (i=0; iLDA; double *v=A->val; char UPLO=A->UPLO; dsyr(&UPLO,&N,&alpha,x,&ione,v,&LDA); return 0; } static int DenseSymPSDNormF2(void* AA, int n, double *dddot){ dtrumat* A=(dtrumat*) AA; ffinteger ione=1,nn=A->n*A->n; double dd,tt=sqrt(0.5),*val=A->val; int info; info=DTRUMatScaleDiagonal(AA,tt); dd=dnrm2(&nn,val,&ione); info=DTRUMatScaleDiagonal(AA,1.0/tt); *dddot=dd*dd*2; return 0; } static int DTRUMatGetDenseArray(void* A, double *v[], int*n){ dtrumat* ABA=(dtrumat*)A; *v=ABA->val; *n=ABA->n*ABA->LDA; return 0; } static int DTRUMatRestoreDenseArray(void* A, double *v[], int *n){ *v=0;*n=0; return 0; } static int DDenseSetXMat(void*A, double v[], int nn, int n){ dtrumat* ABA=(dtrumat*)A; int i,LDA=ABA->LDA; double *vv=ABA->val; if (v!=vv){ for (i=0;istatus=Assemble; return 0; } static int DDenseVecVec(void* A, double x[], int n, double *v){ dtrumat* ABA=(dtrumat*)A; int i,j,k=0,LDA=ABA->LDA; double dd=0,*val=ABA->val; *v=0.0; for (i=0; in; ffinteger IL=1,IU=1,LDA=AAA->LDA,LDZ=LDA,LWORK,IFAIL; ffinteger *IWORK=(ffinteger*)IIWORK; double *AP=AAA->val; double Z=0,VL=-1e10,VU=1e10,*WORK,ABSTOL=1e-13; char UPLO=AAA->UPLO,JOBZ='N',RANGE='I'; DSDPCALLOC2(&WORK,double,8*N,&info); DSDPCALLOC2(&IWORK,ffinteger,5*N,&info); LWORK=8*N; dsyevx(&JOBZ,&RANGE,&UPLO,&N,AP,&LDA,&VL,&VU,&IL,&IU,&ABSTOL,&M,W,&Z,&LDZ,WORK,&LWORK,IWORK,&IFAIL,&INFO); /* ffinteger LIWORK=nn1; dsyevd(&JOBZ,&UPLO,&N,AP,&LDA,W,WORK,&LWORK,IWORK,&LIWORK,&INFO); */ DSDPFREE(&WORK,&info); DSDPFREE(&IWORK,&info); *mineig=W[0]; return INFO; } static struct DSDPVMat_Ops turdensematops; static int DSDPDenseXInitializeOps(struct DSDPVMat_Ops* densematops){ int info; if (!densematops) return 0; info=DSDPVMatOpsInitialize(densematops); DSDPCHKERR(info); densematops->matview=DTRUMatView; densematops->matscalediagonal=DTRUMatScaleDiagonal; densematops->matshiftdiagonal=DTRUMatShiftDiagonal; densematops->mataddouterproduct=DTRUMatOuterProduct; densematops->matmult=DTRUMatMult; densematops->matdestroy=DTRUMatDestroy; densematops->matfnorm2=DenseSymPSDNormF2; densematops->matgetsize=DTRUMatGetSize; densematops->matzeroentries=DTRUMatZero; densematops->matgeturarray=DTRUMatGetDenseArray; densematops->matrestoreurarray=DTRUMatRestoreDenseArray; densematops->matmineig=DTRUMatEigs; densematops->id=1; densematops->matname=lapackname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPXMatUCreateWithData" int DSDPXMatUCreateWithData(int n,double nz[],int nnz,struct DSDPVMat_Ops* *xops, void * *xmat){ int i,info; double dtmp; dtrumat*AA; DSDPFunctionBegin; if (nnzowndata=0; info=DSDPDenseXInitializeOps(&turdensematops); DSDPCHKERR(info); *xops=&turdensematops; *xmat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPXMatUCreate" int DSDPXMatUCreate(int n,struct DSDPVMat_Ops* *xops, void * *xmat){ int info,nn=n*n; double *vv; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DSDPXMatUCreateWithData(n,vv,nn,xops,xmat);DSDPCHKERR(info); DTRUMatOwnData((dtrumat*)(*xmat),1); DSDPFunctionReturn(0); } static struct DSDPDSMat_Ops tdsdensematops; static int DSDPDSDenseInitializeOps(struct DSDPDSMat_Ops* densematops){ int info; if (!densematops) return 0; info=DSDPDSMatOpsInitialize(densematops); DSDPCHKERR(info); densematops->matseturmat=DDenseSetXMat; densematops->matview=DTRUMatView; densematops->matdestroy=DTRUMatDestroy; densematops->matgetsize=DTRUMatGetSize; densematops->matzeroentries=DTRUMatZero; densematops->matmult=DTRUMatMult; densematops->matvecvec=DDenseVecVec; densematops->id=1; densematops->matname=lapackname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDSMatWithArray2" int DSDPCreateDSMatWithArray2(int n,double vv[],int nnz,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info; dtrumat*AA; DSDPFunctionBegin; info=DTRUMatCreateWData(n,n,vv,nnz,&AA); DSDPCHKERR(info); AA->owndata=0; info=DSDPDSDenseInitializeOps(&tdsdensematops); DSDPCHKERR(info); *dsmatops=&tdsdensematops; *dsmat=(void*)AA; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateXDSMat2" int DSDPCreateXDSMat2(int n,struct DSDPDSMat_Ops* *dsmatops, void**dsmat){ int info,nn=n*n; double *vv; DSDPFunctionBegin; DSDPCALLOC2(&vv,double,nn,&info);DSDPCHKERR(info); info=DSDPCreateDSMatWithArray2(n,vv,nn,dsmatops,dsmat);DSDPCHKERR(info); DTRUMatOwnData((dtrumat*)(*dsmat),1); DSDPFunctionReturn(0); } typedef struct { int neigs; double *eigval; double *an; } Eigen; typedef struct { dtrumat* AA; Eigen *Eig; } dvecumat; #undef __FUNCT__ #define __FUNCT__ "CreateDvecumatWData" static int CreateDvecumatWdata(int n, double vv[], dvecumat **A){ int info,nnz=n*n; dvecumat* V; DSDPCALLOC1(&V,dvecumat,&info);DSDPCHKERR(info); info=DTRUMatCreateWData(n,n,vv,nnz,&V->AA); DSDPCHKERR(info); V->Eig=0; *A=V; return 0; } static int DvecumatGetRowNnz(void* AA, int trow, int nz[], int *nnzz,int n){ int k; *nnzz=n; for (k=0;kval; nnn=nrow*n; for (i=0;i<=nrow;i++){ row[i]+=ytmp*v[nnn+i]; } for (i=nrow+1;iAA ,trow,scl,r,m); return 0; } static int DvecumatAddMultiple(void* AA, double alpha, double r[], int nnn, int n){ dvecumat* A=(dvecumat*)AA; ffinteger nn=nnn, ione=1; double *val=A->AA->val; daxpy(&nn,&alpha,val,&ione,r,&ione); return 0; } static int DvecuEigVecVec(void*, double[], int, double*); static int DvecumatVecVec(void* AA, double x[], int n, double *v){ dvecumat* A=(dvecumat*)AA; int i,j,k=0,LDA=A->AA->LDA; double dd=0,*val=A->AA->val; *v=0.0; if (A->Eig && A->Eig->neigsAA->LDA; double dd=0,*x=A->AA->val; for (i=0; iAA->val; ffinteger i,n2,ione=1,LDA=A->AA->LDA; for (i=0;iAA), n,v)); } */ #undef __FUNCT__ #define __FUNCT__ "DvecumatDestroy" static int DvecumatDestroy(void* AA){ dvecumat* A=(dvecumat*)AA; int info; info=DTRUMatDestroy((void*)(A->AA)); if (A->Eig){ DSDPFREE(&A->Eig->an,&info);DSDPCHKERR(info); DSDPFREE(&A->Eig->eigval,&info);DSDPCHKERR(info); } DSDPFREE(&A->Eig,&info);DSDPCHKERR(info); DSDPFREE(&A,&info);DSDPCHKERR(info); return 0; } static int DvecumatView(void* AA){ dvecumat* A=(dvecumat*)AA; dtrumat* M=A->AA; int i,j,LDA=M->LDA; double *val=M->val; for (i=0; in; i++){ for (j=0; jn; j++){ printf(" %4.2e",val[j]); } val+=LDA; } return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDvecumatEigs" static int CreateEigenLocker(Eigen **EE,int neigs, int n){ int info; Eigen *E; DSDPCALLOC1(&E,Eigen,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,n*neigs,&info);DSDPCHKERR(info); E->neigs=neigs; *EE=E; return 0; } static int EigMatSetEig(Eigen* A,int row, double eigv, double v[], int n){ double *an=A->an; A->eigval[row]=eigv; memcpy((void*)(an+n*row),(void*)v,n*sizeof(double)); return 0; } static int EigMatGetEig(Eigen* A,int row, double *eigenvalue, double eigenvector[], int n){ double* an=A->an; *eigenvalue=A->eigval[row]; memcpy((void*)eigenvector,(void*)(an+n*row),n*sizeof(double)); return 0; } static int DvecumatComputeEigs(dvecumat*,double[],int,double[],int,double[],int,int[],int); static int DvecumatFactor(void*AA, double dmatp[], int nn0, double dwork[], int n, double ddwork[], int n1, int iptr[], int n2){ int info; dvecumat* A=(dvecumat*)AA; if (A->Eig) return 0; info=DvecumatComputeEigs(A,dmatp,nn0,dwork,n,ddwork,n1,iptr,n2);DSDPCHKERR(info); return 0; } static int DvecumatGetRank(void *AA,int *rank, int n){ dvecumat* A=(dvecumat*)AA; if (A->Eig){ *rank=A->Eig->neigs; } else { DSDPSETERR(1,"Vecu Matrix not factored yet\n"); } return 0; } static int DvecumatGetEig(void* AA, int rank, double *eigenvalue, double vv[], int n, int indz[], int *nind){ dvecumat* A=(dvecumat*)AA; int i,info; if (A->Eig){ info=EigMatGetEig(A->Eig,rank,eigenvalue,vv,n);DSDPCHKERR(info); *nind=n; for (i=0;iEig){ an=A->Eig->an; neigs=A->Eig->neigs; eigval=A->Eig->eigval; for (rank=0;rankmatvecvec=DvecumatVecVec; sops->matdot=DvecumatDot; sops->mataddrowmultiple=DvecumatGetRowAdd; sops->mataddallmultiple=DvecumatAddMultiple; sops->matview=DvecumatView; sops->matdestroy=DvecumatDestroy; sops->matfactor2=DvecumatFactor; sops->matgetrank=DvecumatGetRank; sops->matgeteig=DvecumatGetEig; sops->matrownz=DvecumatGetRowNnz; sops->matfnorm2=DvecumatFNorm2; sops->matnnz=DvecumatCountNonzeros; sops->id=1; sops->matname=datamatname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPGetDUmat" int DSDPGetDUMat(int n,double *val, struct DSDPDataMat_Ops**sops, void**smat){ int info,k; double dtmp; dvecumat* A; DSDPFunctionBegin; for (k=0;kEig=0; info=DvecumatOpsInitialize(&dvecumatops); DSDPCHKERR(info); if (sops){*sops=&dvecumatops;} if (smat){*smat=(void*)A;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DvecumatComputeEigs" static int DvecumatComputeEigs(dvecumat* AA,double DD[], int nn0, double W[], int n, double WORK[], int n1, int iiptr[], int n2){ int i,neigs,info; long int *i2darray=(long int*)DD; int ownarray1=0,ownarray2=0,ownarray3=0; double *val=AA->AA->val; double *dmatarray=0,*dworkarray=0,eps=1.0e-12; int nn1=0,nn2=0; /* create a dense array in which to put numbers */ if (n*n>nn1){ DSDPCALLOC2(&dmatarray,double,(n*n),&info); DSDPCHKERR(info); ownarray1=1; } memcpy((void*)dmatarray,(void*)val,n*n*sizeof(double)); if (n*n>nn2){ DSDPCALLOC2(&dworkarray,double,(n*n),&info); DSDPCHKERR(info); ownarray2=1; } if (n*n*sizeof(long int)>nn0*sizeof(double)){ DSDPCALLOC2(&i2darray,long int,(n*n),&info); DSDPCHKERR(info); ownarray3=1; } /* Call LAPACK to compute the eigenvalues */ info=DSDPGetEigs(dmatarray,n,dworkarray,n*n,i2darray,n*n, W,n,WORK,n1,iiptr,n2); if (info){ memcpy((void*)dmatarray,(void*)val,n*n*sizeof(double)); info=DSDPGetEigs2(dmatarray,n,dworkarray,n*n,i2darray,n*n, W,n,WORK,n1,iiptr+3*n,n2-3*n); DSDPCHKERR(info); } /* Count the nonzero eigenvalues */ for (neigs=0,i=0;i eps ){ neigs++;} } info=CreateEigenLocker(&AA->Eig,neigs,n);DSDPCHKERR(info); /* Copy into structure */ for (neigs=0,i=0; i eps){ info=EigMatSetEig(AA->Eig,neigs,W[i],dmatarray+n*i,n);DSDPCHKERR(info); neigs++; } } if (ownarray1){ DSDPFREE(&dmatarray,&info);DSDPCHKERR(info);} if (ownarray2){ DSDPFREE(&dworkarray,&info);DSDPCHKERR(info);} if (ownarray3){ DSDPFREE(&i2darray,&info);DSDPCHKERR(info);} return 0; } DSDP5.8/src/vecmat/rmmat.c0000644000175000017500000002176710326241003015337 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file rmmat.c \brief DSDPDataMat object of rank one outer product. */ typedef struct { double ev; const double *spval; const int *spai; int nnz; int n; int ishift; char UPLQ; } r1mat; static int R1MatDestroy(void*); static int R1MatView(void*); static int R1MatVecVec(void*, double[], int, double *); static int R1MatDotP(void*, double[],int,int,double *); static int R1MatDotU(void*, double[],int,int,double *); static int R1MatGetRank(void*, int*, int); static int R1MatFactor(void*); static int R1MatGetEig(void*, int, double*, double[], int,int[],int*); static int R1MatRowNnz(void*, int, int[], int*, int); static int R1MatAddRowMultiple(void*, int, double, double[], int); static int R1MatAddMultipleP(void*, double, double[], int,int); static int R1MatAddMultipleU(void*, double, double[], int,int); static struct DSDPDataMat_Ops r1matopsP; static struct DSDPDataMat_Ops r1matopsU; static int R1MatOpsInitializeP(struct DSDPDataMat_Ops*); static int R1MatOpsInitializeU(struct DSDPDataMat_Ops*); #undef __FUNCT__ #define __FUNCT__ "DSDPGetR1Mat" int DSDPGetR1Mat(int n, double ev, int ishift, const int spai[], const double spval[], int nnz, char UPLQ, void**mmat){ int i; r1mat*AA; DSDPFunctionBegin; for (i=0;i=n){ printf("Invalid entry: Entry %d . Is %d <= %d < %d?\n",i,ishift,spai[i],n+ishift); return 1; } } AA=(r1mat*) malloc(1*sizeof(r1mat)); if (AA==NULL) return 1; AA->n=n; AA->UPLQ=UPLQ; AA->spval=spval; AA->spai=spai; AA->nnz=nnz; AA->ev=ev; AA->ishift=ishift; if (mmat){*mmat=(void*)AA;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetR1PMat" /*! int DSDPGetR1PMat(int n, double ev, int ishift, const int spai[], const double spval[], int nnz, struct DSDPDataMat_Ops**mops, void**mmat) \brief Create a rank one matrix usuable by DSDP in packed symmetric format. \param n number of rows and columns of the matrix \param ev multiple of the outer product. \param ishift index of first element in vector. \param spai array of indices for vector. \param spval array of vector values. \param nnz size of arrays. \param mops address of a pointer to a table of function pointers \param mmat address of a pointer to an opaque data type. */ int DSDPGetR1PMat(int n, double ev, int ishift, const int spai[], const double spval[], int nnz, struct DSDPDataMat_Ops**mops, void**mmat){ int info; DSDPFunctionBegin; info=DSDPGetR1Mat(n,ev,ishift,spai,spval,nnz,'P',mmat); info=R1MatOpsInitializeP(&r1matopsP); if(info){return 1;} if (mops){*mops=&r1matopsP;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPGetR1UMat" /*! int DSDPGetR1UMat(int n, double ev, int ishift, const int spai[], const double spval[], int nnz, struct DSDPDataMat_Ops**mops, void**mmat) \brief Create a rank one matrix usuable by DSDP in full symmetric format. \param n number of rows and columns of the matrix \param ev multiple of the outer product. \param ishift index of first element in vector. \param spai array of indices for vector. \param spval array of vector values. \param nnz size of arrays. \param mops address of a pointer to a table of function pointers \param mmat address of a pointer to an opaque data type. */ int DSDPGetR1UMat(int n, double ev, int ishift, const int spai[], const double spval[], int nnz, struct DSDPDataMat_Ops**mops, void**mmat){ int info; DSDPFunctionBegin; info=DSDPGetR1Mat(n,ev,ishift,spai,spval,nnz,'U',mmat); info=R1MatOpsInitializeU(&r1matopsU); if(info){return 1;} if (mops){*mops=&r1matopsU;} DSDPFunctionReturn(0); } static int R1MatDotP(void* A, double x[], int nn, int n, double *v){ r1mat* AA = (r1mat*)A; int i,i2,i3,j,j2; int nnz=AA->nnz,ishift=AA->ishift; const int *ai=AA->spai; double dtmp=0.0,d3; const double *val=AA->spval; for (i=0;iev; return 0; } static int R1MatDotU(void* A, double x[], int nn, int n, double *v){ r1mat* AA = (r1mat*)A; int i,i2,i3,j,j2; int nnz=AA->nnz,ishift=AA->ishift; const int *ai=AA->spai; const double *val=AA->spval; double dtmp=0.0,d3; for (i=0;iev; return 0; } static int R1MatVecVec(void* A, double x[], int n, double *v){ r1mat* AA = (r1mat*)A; double dtmp=0.0; const double *val=AA->spval; int i,ishift=AA->ishift,nnz=AA->nnz; const int *ai=AA->spai; for (i=0; iev; return 0; } static int R1MatAddMultipleP(void*A, double dd, double vv[], int nn, int n){ r1mat* AA = (r1mat*)A; int i,i2,i3,j,j2; int nnz=AA->nnz,ishift=AA->ishift; const int *ai=AA->spai; const double *val=AA->spval; double d3,ddd=dd*AA->ev; for (i=0;innz,ishift=AA->ishift; const int *ai=AA->spai; const double *val=AA->spval; double d3,ddd=dd*AA->ev; for (i=0;innz,ishift=AA->ishift; const int *ai=AA->spai; const double *val=AA->spval; double ddd=dd*AA->ev; int i,j; for (i=0;iishift,nnz=AA->nnz; const int *ai=AA->spai; const double *val=AA->spval; for (i=0;iev; *nind=AA->nnz; } return 0; } static int R1MatRowNnz(void*A, int row, int nz[], int *rnnz, int n){ r1mat* AA = (r1mat*)A; int i,j; int nnz=AA->nnz,ishift=AA->ishift; const int *ai=AA->spai; *rnnz=0; for (i=0;ispval; int i,nnz=AA->nnz; for (i=0;iev*AA->ev; return 0; } static int R1MatCountNonzeros(void*A, int *nnz, int n){ r1mat* AA = (r1mat*)A; *nnz=AA->nnz*AA->nnz; return 0; } static int R1MatView(void* A){ int i; r1mat* AA = (r1mat*)A; printf("This matrix is %4.8e times the outer product of \n",AA->ev); for (i=0;innz;i++){ printf("%d %4.8e \n",AA->spai[i],AA->spval[i]); } return 0; } static int R1MatDestroy(void* A){ if (A) free(A); return 0; } static const char *datamatname="RANK 1 Outer Product"; static int R1MatOpsInitializeP(struct DSDPDataMat_Ops* r1matops){ int info; if (r1matops==NULL) return 0; info=DSDPDataMatOpsInitialize(r1matops); DSDPCHKERR(info); r1matops->matfactor1=R1MatFactor; r1matops->matgetrank=R1MatGetRank; r1matops->matgeteig=R1MatGetEig; r1matops->matvecvec=R1MatVecVec; r1matops->matdot=R1MatDotP; r1matops->mataddrowmultiple=R1MatAddRowMultiple; r1matops->mataddallmultiple=R1MatAddMultipleP; r1matops->matdestroy=R1MatDestroy; r1matops->matview=R1MatView; r1matops->matrownz=R1MatRowNnz; r1matops->matfnorm2=R1MatFNorm2; r1matops->matnnz=R1MatCountNonzeros; r1matops->id=15; r1matops->matname=datamatname; return 0; } static int R1MatOpsInitializeU(struct DSDPDataMat_Ops* r1matops){ int info; if (r1matops==NULL) return 0; info=DSDPDataMatOpsInitialize(r1matops); DSDPCHKERR(info); r1matops->matfactor1=R1MatFactor; r1matops->matgetrank=R1MatGetRank; r1matops->matgeteig=R1MatGetEig; r1matops->matvecvec=R1MatVecVec; r1matops->matdot=R1MatDotU; r1matops->mataddrowmultiple=R1MatAddRowMultiple; r1matops->mataddallmultiple=R1MatAddMultipleU; r1matops->matdestroy=R1MatDestroy; r1matops->matview=R1MatView; r1matops->matrownz=R1MatRowNnz; r1matops->matfnorm2=R1MatFNorm2; r1matops->matnnz=R1MatCountNonzeros; r1matops->id=15; r1matops->matname=datamatname; return 0; } DSDP5.8/src/vecmat/vechu.c0000644000175000017500000003663310326241003015327 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file vechu.c \brief DSDPDataMat for sparse matrices in upper full symmetric format */ typedef struct { int neigs; double *eigval; double *an; int *cols,*nnz; } Eigen; typedef struct { int nnzeros; const int *ind; const double *val; int ishift; double alpha; Eigen *Eig; int factored; int owndata; int n; } vechmat; #define GETI(a,b) (int)((int)a/(int)b) #define GETJ(a,b) (int)((int)a%(int)b) static void getij(int k, int n, int *i,int *j){ *i=GETI(k,n); *j=GETJ(k,n); return; } #undef __FUNCT__ #define __FUNCT__ "CreateVechMatWData" static int CreateVechMatWdata(int n, int ishift, double alpha, const int *ind, const double *vals, int nnz, vechmat **A){ int info; vechmat* V; DSDPCALLOC1(&V,vechmat,&info);DSDPCHKERR(info); V->n=n; V->ishift=ishift, V->ind=ind; V->val=vals;V->nnzeros=nnz; V->alpha=alpha; V->owndata=0; *A=V; return 0; } static int VechMatAddMultiple(void* AA, double scl, double r[], int nn, int n){ vechmat* A=(vechmat*)AA; int k; const int *ind=A->ind,nnz=A->nnzeros; const double *val=A->val; double *rr=r-A->ishift; scl*=A->alpha; for (k=0; knnzeros; const int *ind=A->ind; double vv=0,*xx=x-A->ishift; const double *val=A->val; for (k=0;kalpha; return 0; } static int EigMatVecVec(Eigen*, double[], int, double*); static int VechMatGetRank(void*,int*,int); static int VechMatVecVec(void* AA, double x[], int n, double *v){ vechmat* A=(vechmat*)AA; int info,rank=n,i=0,j,k,kk; const int *ind=A->ind,ishift=A->ishift,nnz=A->nnzeros; double vv=0,dd; const double *val=A->val; if (A->factored==3){ info=VechMatGetRank(AA,&rank,n); if (nnz>3 && rankEig,x,n,&vv); *v=vv*A->alpha; return 0; } } for (k=0; kalpha; return 0; } static int VechMatGetRowNnz(void* AA, int trow, int nz[], int *nnzz,int nn){ vechmat* A=(vechmat*)AA; int i=0,j,k,t; const int *ind=A->ind, ishift=A->ishift,nnz=A->nnzeros; *nnzz=0; for (k=0; kind,ishift=A->ishift,nnz=A->nnzeros; double fn2=0; const double *val=A->val; for (k=0; kalpha*A->alpha; return 0; } static int VechMatAddRowMultiple(void* AA, int trow, double scl, double r[], int m){ vechmat* A=(vechmat*)AA; int i=0,j,k,t,ishift=A->ishift,nnz=A->nnzeros; const int *ind=A->ind; const double *val=A->val; scl*=A->alpha; for (k=0; knnzeros; return 0; } #undef __FUNCT__ #define __FUNCT__ "VechMatDestroy" static int VechMatDestroy(void* AA){ vechmat* A=(vechmat*)AA; int info; if (A->owndata){ /* if (A->ind){ DSDPFREE(&A->ind,&info);DSDPCHKERR(info);} if (A->val){ DSDPFREE(&A->val,&info);DSDPCHKERR(info);} */ return 1; } if (A->Eig){ DSDPFREE(&A->Eig->eigval,&info);DSDPCHKERR(info); DSDPFREE(&A->Eig->an,&info);DSDPCHKERR(info); if (A->Eig->cols){DSDPFREE(&A->Eig->cols,&info);DSDPCHKERR(info);} if (A->Eig->nnz){DSDPFREE(&A->Eig->nnz,&info);DSDPCHKERR(info);} DSDPFREE(&A->Eig,&info);DSDPCHKERR(info); } DSDPFREE(&A,&info);DSDPCHKERR(info); return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateVechMatEigs" static int CreateEigenLocker(Eigen **EE,int iptr[], int neigs, int n){ int i,k,info; Eigen *E; for (k=0,i=0;in*neigs/4){ DSDPCALLOC1(&E,Eigen,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,n*neigs,&info);DSDPCHKERR(info); E->neigs=neigs; E->cols=0; E->nnz=0; } else { DSDPCALLOC1(&E,Eigen,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->eigval,double,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->nnz,int,neigs,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->an,double,k,&info);DSDPCHKERR(info); DSDPCALLOC2(&E->cols,int,k,&info);DSDPCHKERR(info); E->neigs=neigs; if (neigs>0) E->nnz[0]=iptr[0]; for (i=1;innz[i]=E->nnz[i-1]+iptr[i];} } *EE=E; return 0; } static int EigMatSetEig(Eigen* A,int row, double eigv, int idxn[], double v[], int nsub,int n){ int j,k,*cols=A->cols; double *an=A->an; A->eigval[row]=eigv; if (cols){ k=0; if (row>0){ k=A->nnz[row-1];} cols+=k; an+=k; for (k=0,j=0; jcols,bb,ee; double* an=A->an; *eigenvalue=A->eigval[row]; *nind=0; if (cols){ memset((void*)eigenvector,0,n*sizeof(double)); if (row==0){ bb=0;} else {bb=A->nnz[row-1];} ee=A->nnz[row]; for (i=bb;icols,neigs=A->neigs,*nnz=A->nnz,bb,ee; double* an=A->an,*eigval=A->eigval,dd,ddd=0; if (cols){ for (rank=0;rankind,ishift=A->ishift,nonzeros=A->nnzeros; double *ss1=0,*ss2=0; int nn1=0,nn2=0; if (A->factored) return 0; memset((void*)iptr,0,3*n*sizeof(int)); /* Find number of nonzeros in each row */ for (isdiag=1,k=0; kfactored=1; return 0;} /* Find most nonzeros per row */ for (j=0,i=0; ij) j=iptr[i]; } if (j<2){ A->factored=2; return 0; } info=VechMatComputeEigs(A,dmatp,nn0,dwork,n,ddwork,n1,iptr,n2,ss1,nn1,ss2,nn2);DSDPCHKERR(info); A->factored=3; return 0; } static int VechMatGetRank(void *AA,int *rank,int n){ vechmat* A=(vechmat*)AA; switch (A->factored){ case 1: *rank=A->nnzeros; break; case 2: *rank=2*A->nnzeros; break; case 3: *rank=A->Eig->neigs; break; default: DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static int VechMatGetEig(void* AA, int rank, double *eigenvalue, double vv[], int n, int indx[], int *nind){ vechmat* A=(vechmat*)AA; const double *val=A->val,tt=sqrt(0.5); int info,i,j,k,t; const int *ind=A->ind,ishift=A->ishift; *nind=0; switch (A->factored){ case 1: memset(vv,0,n*sizeof(double)); t=ind[rank]-ishift; i=GETI(t,n); j=GETJ(t,n); vv[i]=1.0; *eigenvalue=val[rank]*A->alpha; *nind=1; indx[0]=i; break; case 2: memset(vv,0,n*sizeof(double)); k=rank/2; getij(ind[k]-ishift,n,&i,&j); if (i==j){ if (k*2==rank){ vv[i]=1.0; *eigenvalue=val[k]*A->alpha; *nind=1; indx[0]=i; } else { *eigenvalue=0; } } else { if (k*2==rank){ vv[i]=tt; vv[j]=tt; *eigenvalue=val[k]*A->alpha; *nind=2; indx[0]=i; indx[1]=j; } else { vv[i]=-tt; vv[j]=tt; *eigenvalue=-val[k]*A->alpha; *nind=2; indx[0]=i; indx[1]=j; } } break; case 3: info=EigMatGetEig(A->Eig,rank,eigenvalue,vv,n,indx,nind);DSDPCHKERR(info); *eigenvalue=*eigenvalue*A->alpha; break; default: DSDPSETERR(1,"Vech Matrix not factored yet\n"); } return 0; } static int VechMatView(void* AA){ vechmat* A=(vechmat*)AA; int info,i=0,j,k,rank=0,ishift=A->ishift,n=A->n,nnz=A->nnzeros; const int *ind=A->ind; const double *val=A->val; for (k=0; kalpha*val[k]); } if (A->factored>0){ info=VechMatGetRank(AA,&rank,n);DSDPCHKERR(info); printf("Detected Rank: %d\n",rank); } return 0; } static struct DSDPDataMat_Ops vechmatops; static const char *datamatname="STANDARD VECH MATRIX"; static int VechMatOpsInitialize(struct DSDPDataMat_Ops *sops){ int info; if (sops==NULL) return 0; info=DSDPDataMatOpsInitialize(sops); DSDPCHKERR(info); sops->matvecvec=VechMatVecVec; sops->matdot=VechMatDot; sops->matfnorm2=VechMatFNorm2; sops->mataddrowmultiple=VechMatAddRowMultiple; sops->mataddallmultiple=VechMatAddMultiple; sops->matview=VechMatView; sops->matdestroy=VechMatDestroy; sops->matfactor2=VechMatFactor; sops->matgetrank=VechMatGetRank; sops->matgeteig=VechMatGetEig; sops->matrownz=VechMatGetRowNnz; sops->matnnz=VechMatCountNonzeros; sops->id=3; sops->matname=datamatname; return 0; } /*! \fn int DSDPGetVecUMat(int n,int ishift,double alpha, const int ind[], const double val[],int nnz, struct DSDPDataMat_Ops**sops, void**smat) \brief Given data in full symmetric format, create a sparse matrix usuable by DSDP. \param n number of rows and columns of the matrix \param ishift the index of the first element in the matrix (usually 0) \param alpha the multiple of these matrix. \param ind array of matrix indices. \param val array of matrix values. \param nnz number of elements in array. \param sops address of a pointer to a table of function pointers \param smat address of a pointer to an opaque data type. */ #undef __FUNCT__ #define __FUNCT__ "DSDPGetVecUMat" int DSDPGetVecUMat(int n,int ishift,double alpha,const int ind[], const double val[],int nnz, struct DSDPDataMat_Ops**sops, void**smat){ int info,i,j,k,itmp,nn=n*n; double dtmp; vechmat* AA; DSDPFunctionBegin; for (k=0;k=nn){ getij(itmp,n,&i,&j); /* DSDPSETERR(2,"Illegal index value: Element %d in array has row %d (>0) or column %d (>0) is greater than %d. \n",k+1,i+1,j+1,n); */ DSDPSETERR3(2,"Illegal index value: Element %d in array has index %d greater than or equal to %d. \n",k,itmp,nn); } else if (itmp<0){ DSDPSETERR1(2,"Illegal index value: %d. Must be >= 0\n",itmp); } } for (k=0;kfactored=0; AA->Eig=0; info=VechMatOpsInitialize(&vechmatops); DSDPCHKERR(info); if (sops){*sops=&vechmatops;} if (smat){*smat=(void*)AA;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VechMatComputeEigs" static int VechMatComputeEigs(vechmat* AA,double DD[], int nn0, double W[], int n, double WORK[], int n1, int iiptr[], int n2, double ss1[],int nn1, double ss2[], int nn2){ int i,j,k,nsub,neigs,info,*iptr,*perm,*invp; long int *i2darray=(long int*)DD; int ownarray1=0,ownarray2=0,ownarray3=0; int ishift=AA->ishift,nonzeros=AA->nnzeros; const int *ind=AA->ind; const double *val=AA->val; double *dmatarray=ss1,*dworkarray=ss2,maxeig,eps=1.0e-12,eps2=1.0e-12; iptr=iiptr; perm=iptr+n; invp=perm+n; /* These operations were done before calling this routine * / / * Integer arrays corresponding to rows with nonzeros and inverse map * / memset((void*)iiptr,0,3*n*sizeof(int)); / * Find number of nonzeros in each row * / for (i=0,k=0; k0){ invp[nsub]=i; perm[i]=nsub; nsub++;} } /* create a dense array in which to put numbers */ if (nsub*nsub>nn1){ DSDPCALLOC2(&dmatarray,double,(nsub*nsub),&info); DSDPCHKERR(info); ownarray1=1; } memset((void*)dmatarray,0,nsub*nsub*sizeof(double)); if (nsub*nsub>nn2){ DSDPCALLOC2(&dworkarray,double,(nsub*nsub),&info); DSDPCHKERR(info); ownarray2=1; } if (nsub*nsub*sizeof(long int)>nn0*sizeof(double)){ DSDPCALLOC2(&i2darray,long int,(nsub*nsub),&info); DSDPCHKERR(info); ownarray3=1; } for (i=0,k=0; kmaxeig){ maxeig=fabs(W[i]); } } memset((void*)iptr,0,nsub*sizeof(int)); /* Compute sparsity pattern for eigenvalue and eigenvector structures */ /* Count the nonzero eigenvalues */ for (neigs=0,k=0; k eps){ for (j=0;j= eps2){iptr[neigs]++; } else { dmatarray[nsub*k+j]=0.0;} } neigs++; /* } else if (fabs(W[k])>1.0e-100){ printf("SKIPPING EIGENVALUE: %4.4e, max is : %4.4e\n",W[k],maxeig); */ } } info=CreateEigenLocker(&AA->Eig,iptr,neigs,n);DSDPCHKERR(info); DSDPLogInfo(0,49," Data Mat has %d eigenvectors.",neigs); /* Copy into structure */ for (neigs=0,i=0; i eps){ info=EigMatSetEig(AA->Eig,neigs,W[i],invp,dmatarray+nsub*i,nsub,n);DSDPCHKERR(info); neigs++; } } if (ownarray1){ DSDPFREE(&dmatarray,&info);DSDPCHKERR(info);} if (ownarray2){ DSDPFREE(&dworkarray,&info);DSDPCHKERR(info);} if (ownarray3){ DSDPFREE(&i2darray,&info);DSDPCHKERR(info);} return 0; } DSDP5.8/src/vecmat/drowcol.c0000644000175000017500000001177010326241003015661 0ustar twernertwerner typedef struct { int rc; const double *val; int n; double x,y; } rcmat; #include "dsdpdatamat_impl.h" #include "dsdpsys.h" /*! \file drowcol.c \brief DSDPDataMat object such that A(i,j) is nonzero only if i or j equals some integer k. Not completed. */ static int RCMatDestroy(void*); static int RCMatView(void*); static int RCMatVecVec(void*, double[], int, double *); static int RCMatDot(void*, double[], int, int, double *); static int RCMatGetRank(void*, int*, int); static int RCMatFactor(void*); static int RCMatGetEig(void*, int, double*, double[], int, int[], int*); static int RCMatAddRowMultiple(void*, int, double, double[], int); static int RCMatAddMultiple(void*, double, double[], int, int); static int RCMatGetRowNnz(void*, int, int[], int*, int); static int RCMatCreate(int n,int rowcol, const double v[], rcmat**M){ rcmat *M16; M16=(rcmat*) malloc(1*sizeof(rcmat)); M16->val=v; M16->rc=rowcol; M16->n=n; *M=M16; return 0; } static int RCMatDestroy(void* AA){ free(AA); return 0; } static int RCMatVecVec(void* A, double x[], int n, double *v){ rcmat*RC=(rcmat*)A; int i; double vv=0; const double *val=RC->val; for (i=0;irc]; return 0; } static int RCMatDot(void* A, double x[], int nn, int n1, double *v){ rcmat*RC=(rcmat*)A; int i,k=0,rc=RC->rc,n=RC->n; double vv=0; const double *val=RC->val; k=rc*(rc+1)/2; for (i=0;i<=rc;i++,k++){ vv+=v[k]*val[i]; } for (i=rc+1;irc); for (i=0;in;i++){ printf("%4.4e ",RC->val[i]); } printf("\n"); return 0; } static int RCMatFactor(void* A){ /* Must compute x,y such that eigs are orthogonal */ rcmat*RC=(rcmat*)A; int i,rc=RC->rc; double vnorm2=0; const double *val=RC->val; for (i=0;in;i++){ vnorm2+=val[i]*val[i];} vnorm2=sqrt(vnorm2); if (val[rc]>=0){ RC->y=-sqrt(vnorm2); RC->x=sqrt(2*val[rc]+RC->y*RC->y); } else { RC->x=sqrt(vnorm2); RC->y=-sqrt(-2*val[rc]+RC->x*RC->x); } return 0; } static int RCMatGetRank(void *A, int*rank, int n){ *rank=2; return 0; } static int RCMatGetEig(void*A, int neig, double *eig, double v[], int n,int spind[], int *nind){ rcmat*RC=(rcmat*)A; int i,rc=RC->rc; double x=RC->x,y=RC->y,xmy=x-y; const double *val=RC->val; if (neig==0){ for (i=0;ix; *nind=n; *eig=1.0; } else if (neig==1){ for (i=0;iy; *nind=n; *eig=-1.0; } else { *eig=0;*nind=0;} return 0; } static int RCMatGetRowNnz(void*A, int nrow, int nz[], int *nnzz, int n){ rcmat*RC=(rcmat*)A; int i; *nnzz=1; if (nrow==RC->rc){for (i=0;irc){ for (i=0;ival[i];} } rrow[nrow]+=dd*RC->val[nrow]; return 0; } static int RCMatAddMultiple(void*A, double dd, double vv[], int nn, int n1){ rcmat*RC=(rcmat*)A; int i,rc=RC->rc,k=rc*(rc+1)/2,n=RC->n; const double *val=RC->val; for (i=0;i<=rc;i++,k++){ vv[k]+=dd*val[i]; } for (i=rc+1;irc; double ff=0; const double *val=RC->val; for (i=0;imatfactor1=RCMatFactor; rcmatoperator->matgetrank=RCMatGetRank; rcmatoperator->matgeteig=RCMatGetEig; rcmatoperator->matvecvec=RCMatVecVec; rcmatoperator->matrownz=RCMatGetRowNnz; rcmatoperator->matdot=RCMatDot; rcmatoperator->matfnorm2=RCMatFNorm; rcmatoperator->matnnz=RCMatCountNonzeros; rcmatoperator->mataddrowmultiple=RCMatAddRowMultiple; rcmatoperator->mataddallmultiple=RCMatAddMultiple; rcmatoperator->matdestroy=RCMatDestroy; rcmatoperator->matview=RCMatView; rcmatoperator->matname=datamatname; rcmatoperator->id=27; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPGetRCMat" int DSDPGetRCMat(int n,const double val[],int rowcol, struct DSDPDataMat_Ops**sops, void**smat){ rcmat *AA; int info; DSDPFunctionBegin; info=RCMatCreate(n,rowcol,val,&AA);DSDPCHKERR(info); info=RCMatOperationsInitialize(&rcmatops); DSDPCHKERR(info); if (sops){*sops=&rcmatops;} if (smat){*smat=(void*)AA;} DSDPFunctionReturn(0); } DSDP5.8/src/vecmat/dtrsm2.c0000644000175000017500000001467010326241003015425 0ustar twernertwerner#include "dsdplapack.h" typedef long int integer; typedef long int logical; #define max(a,b) ((a) >= (b) ? (a) : (b)) #define dmax(a,b) (double)max(a,b) static int lsame2(const char c1[], const char c2[]){ if (c1[0]==c2[0]) return 1; else return 0; } /* Subroutine */ int dtrsm2(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, double *alpha, double *a, integer * lda, double *b, integer *ldb) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, i1, i2, i3; /* Local variables */ static integer info; static double temp,alpha2,aref; static integer i, j, k; static logical lside; static integer nrowa; static logical upper; static logical nounit; #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1] #define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1] a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; /* Function Body */ lside = lsame2(side, "L"); if (lside) { nrowa = *m; } else { nrowa = *n; } nounit = lsame2(diag, "N"); upper = lsame2(uplo, "U"); info = 0; if (! lside && ! lsame2(side, "R")) { info = 1; } else if (! upper && ! lsame2(uplo, "L")) { info = 2; } else if (! lsame2(transa, "N") && ! lsame2(transa, "T") && ! lsame2(transa, "C")) { info = 3; } else if (! lsame2(diag, "U") && ! lsame2(diag, "N")) { info = 4; } else if (*m < 0) { info = 5; } else if (*n < 0) { info = 6; } else if (*lda < max(1,nrowa)) { info = 9; } else if (*ldb < max(1,*m)) { info = 11; } if (info != 0) { return info; } /* Quick return if possible. */ if (*n == 0) { return 0; } /* And when alpha.eq.zero. */ if (*alpha == 0.) { i1 = *n; for (j = 1; j <= i1; ++j) { i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, j) = 0.; /* L10: */ } /* L20: */ } return 0; } /* Start the operations. */ if (lside) { if (lsame2(transa, "N")) { /* Form B := alpha*inv( A )*B. */ if (upper) { i1 = *n; for (j = 1; j <= i1; ++j) { if (*alpha != 1.) { i2 = *m; alpha2=*alpha; for (i = 1; i <= i2; ++i) { b_ref(i, j) *= alpha2; /* L30: */ } } for (k = *m; k >= 1; --k) { if (b_ref(k, j) != 0.) { if (nounit) { b_ref(k, j) /= a_ref(k, k); } i2 = k - 1; aref=-b_ref(k, j); for (i = 1; i <= i2; ++i) { b_ref(i, j) += aref * a_ref(i, k); /* L40: */ } } /* L50: */ } /* L60: */ } } else { i1 = *n; for (j = 1; j <= i1; ++j) { if (*alpha != 1.) { i2 = *m; alpha2=*alpha; for (i = 1; i <= i2; ++i) { b_ref(i, j) *= alpha2; /* L70: */ } } i2 = *m; for (k = 1; k <= i2; ++k) { if (b_ref(k, j) != 0.) { if (nounit) { b_ref(k, j) /= a_ref(k, k); } i3 = *m; aref= -b_ref(k, j); for (i = k + 1; i <= i3; ++i) { b_ref(i, j) += aref * a_ref(i, k); /* L80: */ } } /* L90: */ } /* L100: */ } } } else { /* Form B := alpha*inv( A' )*B. */ if (upper) { i1 = *n; for (j = 1; j <= i1; ++j) { i2 = *m; alpha2=*alpha; for (i = 1; i <= i2; ++i) { temp = alpha2 * b_ref(i, j); i3 = i - 1; for (k = 1; k <= i3; ++k) { temp -= a_ref(k, i) * b_ref(k, j); /* L110: */ } if (nounit) { temp /= a_ref(i, i); } b_ref(i, j) = temp; /* L120: */ } /* L130: */ } } else { i1 = *n; for (j = 1; j <= i1; ++j) { for (i = *m; i >= 1; --i) { temp = alpha2 * b_ref(i, j); i2 = *m; for (k = i + 1; k <= i2; ++k) { temp -= a_ref(k, i) * b_ref(k, j); /* L140: */ } if (nounit) { temp /= a_ref(i, i); } b_ref(i, j) = temp; /* L150: */ } /* L160: */ } } } } else { if (lsame2(transa, "N")) { /* Form B := alpha*B*inv( A ). */ if (upper) { i1 = *n; for (j = 1; j <= i1; ++j) { if (*alpha != 1.) { i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, j) *= alpha2; /* L170: */ } } i2 = j - 1; for (k = 1; k <= i2; ++k) { if (a_ref(k, j) != 0.) { i3 = *m; aref=-a_ref(k, j); for (i = 1; i <= i3; ++i) { b_ref(i, j) += aref * b_ref(i, k); /* L180: */ } } /* L190: */ } if (nounit) { temp = 1. / a_ref(j, j); i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, j) *= temp; /* L200: */ } } /* L210: */ } } else { for (j = *n; j >= 1; --j) { if (*alpha != 1.) { i1 = *m; for (i = 1; i <= i1; ++i) { b_ref(i, j) *= alpha2; /* L220: */ } } i1 = *n; for (k = j + 1; k <= i1; ++k) { if (a_ref(k, j) != 0.) { i2 = *m; aref=-a_ref(k, j); for (i = 1; i <= i2; ++i) { b_ref(i, j) += aref * b_ref(i, k); /* L230: */ } } /* L240: */ } if (nounit) { temp = 1. / a_ref(j, j); i1 = *m; for (i = 1; i <= i1; ++i) { b_ref(i, j) *= temp; /* L250: */ } } /* L260: */ } } } else { /* Form B := alpha*B*inv( A' ). */ if (upper) { for (k = *n; k >= 1; --k) { if (nounit) { temp = 1. / a_ref(k, k); i1 = *m; for (i = 1; i <= i1; ++i) { b_ref(i, k) *= temp; /* L270: */ } } i1 = k - 1; for (j = 1; j <= i1; ++j) { if (a_ref(j, k) != 0.) { temp = a_ref(j, k); i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, j) -= temp * b_ref(i, k); /* L280: */ } } /* L290: */ } if (*alpha != 1.) { i1 = *m; for (i = 1; i <= i1; ++i) { b_ref(i, k) *= alpha2; /* L300: */ } } /* L310: */ } } else { i1 = *n; for (k = 1; k <= i1; ++k) { if (nounit) { temp = 1. / a_ref(k, k); i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, k) *= temp; /* L320: */ } } i2 = *n; for (j = k + 1; j <= i2; ++j) { if (a_ref(j, k) != 0.) { temp = a_ref(j, k); i3 = *m; for (i = 1; i <= i3; ++i) { b_ref(i, j) -= temp * b_ref(i, k); /* L330: */ } } /* L340: */ } if (*alpha != 1.) { i2 = *m; for (i = 1; i <= i2; ++i) { b_ref(i, k) *= alpha2; /* L350: */ } } /* L360: */ } } } } return 0; /* End of DTRSM . */ } /* dtrsm_ */ #undef b_ref #undef a_ref DSDP5.8/src/Makefile0000644000175000017500000000070310326241002014216 0ustar twernertwerner D1 = solver D2 = sdp D3 = lp D4 = vecmat D5 = sys D7 = bounds dsdplib: cd ${D1}; make dsdplib; cd ${D2}; make dsdplib; cd ${D3}; make dsdplib; cd ${D4}; make dsdplib; cd ${D5}; make dsdplib; cd ${D7}; make dsdplib; clean: cd ${D1}; make clean; cd ${D2}; make clean; cd ${D3}; make clean; cd ${D4}; make clean; cd ${D5}; make clean; cd ${D7}; make clean; all: dsdplib default: make dsdplib; DSDP5.8/src/bounds/0000755000175000017500000000000010326241002014050 5ustar twernertwernerDSDP5.8/src/bounds/allbounds.c0000644000175000017500000004205310326241002016203 0ustar twernertwerner#include "dsdpcone_impl.h" #include "dsdpsys.h" #include "dsdp5.h" /*! \file allbounds.c \brief Bound all the variables y in (D) and implement DSDPCone operations. */ #define COMPUTELBS(a,b,c) ( (a)+(b)-(c)) #define COMPUTEUBS(a,b,c) (-(a)-(b)-(c)) struct LUBounds_C{ double r,muscale,minx; int invisible; int keyid; int setup,iter; double lbound,ubound; double maxratio; DSDPVec YD,YP,DYD; DSDP dsdp; DSDPTruth skipit; double pobj,pax,sumx,xdots; }; typedef struct LUBounds_C* LUBounds; #define LUKEY 5432 #define LUConeValid(a) {if (!(a)||((a)->keyid!=LUKEY)){ DSDPSETERR(101,"DSDPERROR: Invalid LUCone object\n");}} static int LUBoundsS(void* dcone,DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *psdefinite); #undef __FUNCT__ #define __FUNCT__ "LUBoundsSetUp" static int LUBoundsSetup(void *dcone,DSDPVec y){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsSetUp2" static int LUBoundsSetup2(void *dcone, DSDPVec Y, DSDPSchurMat M){ int info; LUBounds lucone=(LUBounds)dcone; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->setup==0){ info=DSDPVecDuplicate(Y,&lucone->DYD);DSDPCHKERR(info); info=DSDPVecDuplicate(Y,&lucone->YD);DSDPCHKERR(info); info=DSDPVecDuplicate(Y,&lucone->YP);DSDPCHKERR(info); info=DSDPVecSet(lucone->lbound,lucone->YD);DSDPCHKERR(info); info=DSDPVecSetR(lucone->YD,-1e30);DSDPCHKERR(info); info=DSDPVecSetC(lucone->YD,-1e30);DSDPCHKERR(info); info=DSDPVecPointwiseMax(lucone->YD,Y,Y);DSDPCHKERR(info); info=DSDPVecSet(lucone->ubound,lucone->YD);DSDPCHKERR(info); info=DSDPVecSetR(lucone->YD,1e30);DSDPCHKERR(info); info=DSDPVecSetC(lucone->YD,1e30);DSDPCHKERR(info); info=DSDPVecPointwiseMin(lucone->YD,Y,Y);DSDPCHKERR(info); lucone->setup=1; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsDestroy" static int LUBoundsDestroy(void *dcone){ int info; LUBounds lucone=(LUBounds)dcone; DSDPFunctionBegin; LUConeValid(lucone); info=DSDPVecDestroy(&lucone->DYD);DSDPCHKERR(info); info=DSDPVecDestroy(&lucone->YD);DSDPCHKERR(info); info=DSDPVecDestroy(&lucone->YP);DSDPCHKERR(info); DSDPFREE(&dcone,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsSize" static int LUBoundsSize(void *dcone, double *n){ int nn,info; LUBounds lucone=(LUBounds)dcone; DSDPFunctionBegin; LUConeValid(lucone); *n=0; if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} info=DSDPVecGetSize(lucone->YD,&nn);DSDPCHKERR(info); *n=(2*(nn-2)*lucone->muscale); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsHessian" static int LUBoundsHessian(void* dcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ int info,i,m; LUBounds lucone=(LUBounds)dcone; double assa,as,asrs=0,sl,su; double dd,yy,rs=0,srrs=0; double cc,rr,r,r0=lucone->r; double lbound, ubound; DSDPVec DScale=lucone->YP,Y=lucone->YD; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} mu*=lucone->muscale; info=DSDPSchurMatDiagonalScaling(M,DScale);DSDPCHKERR(info); info=DSDPVecGetSize(DScale,&m);DSDPCHKERR(info); info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); lbound=cc*lucone->lbound; ubound=cc*lucone->ubound; r=rr*lucone->r; info=DSDPVecSetC(DScale,0);DSDPCHKERR(info); info=DSDPVecSetR(DScale,0);DSDPCHKERR(info); for (i=1;ir; double lbound=lucone->lbound, ubound=lucone->ubound; DSDPVec Y=lucone->YD; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} mu*=lucone->muscale; info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); r=r*rr; lbound*=cc; ubound*=cc; info=DSDPVecGetSize(vin,&m);DSDPCHKERR(info); for (i=1;iskipit==DSDP_TRUE){DSDPFunctionReturn(0);} info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); info=DSDPVecGetC(Y,&cr);DSDPCHKERR(info); info=DSDPVecGetR(DY,&drr);DSDPCHKERR(info); r=rr*lucone->r; dr=drr*lucone->r; lbound=cr*lucone->lbound; ubound=cr*lucone->ubound; mu*=lucone->muscale; for (i=1;iskipit==DSDP_TRUE){DSDPFunctionReturn(0);} if (lucone->setup==0){ info=LUBoundsSetup2(dcone,Y,M);DSDPCHKERR(info); } info=DSDPVecGetC(Y,&cr);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); lbound=cr*lucone->lbound; ubound=cr*lucone->ubound; r=rr*lucone->r; *psdefinite=DSDP_TRUE; if (flag==DUAL_FACTOR){ info=DSDPVecCopy(Y,lucone->YD);DSDPCHKERR(info); } else { info=DSDPVecCopy(Y,lucone->YP);DSDPCHKERR(info); } info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); for (i=1;iYP);DSDPCHKERR(info); info=DSDPVecCopy(DY,lucone->DYD);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsX" static int LUBoundsX(void* dcone,double mu, DSDPVec Y,DSDPVec DY, DSDPVec AX , double *tracexs){ LUBounds lucone=(LUBounds)dcone; int info,invisible=lucone->invisible; DSDPFunctionBegin; LUConeValid(lucone); info=LUBoundsSetX(dcone,mu,Y,DY);DSDPCHKERR(info); if (!invisible){ info=BoundYConeAddX(lucone,mu,Y,DY,AX,tracexs);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsComputeMaxStepLength" static int LUBoundsComputeMaxStepLength(void* dcone, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){ int i,m,info; double mstep=1.0e200; LUBounds lucone=(LUBounds)dcone; double lbound=lucone->lbound, ubound=lucone->ubound; double cc,rr,ddr,r,dsl,dsu,sl,su,yy,dy,dr; DSDPVec Y; DSDPFunctionBegin; LUConeValid(lucone); *maxsteplength=mstep; if (flag==PRIMAL_FACTOR){ info=DSDPVecCopy(DY,lucone->DYD);DSDPCHKERR(info); } if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} info=DSDPVecGetR(DY,&ddr);DSDPCHKERR(info); dr=ddr*lucone->r; if (flag==DUAL_FACTOR){ Y=lucone->YD; } else { Y=lucone->YP; } info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); lbound*=cc; ubound*=cc; r=rr*lucone->r; info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); for (i=1;ilbound, ubound=lucone->ubound; DSDPVec Y=lucone->YD; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); lbound*=cc; ubound*=cc; r=rr*lucone->r; info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); for (i=1;imuscale*sumlog; *logobj=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsSparsity" static int LUBoundsSparsity(void *dcone,int row, int *tnnz, int rnnz[], int m){ LUBounds lucone=(LUBounds)dcone; DSDPFunctionBegin; if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} *tnnz=1;rnnz[row]++; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPANorm2" static int LPANorm2( void *dcone, DSDPVec ANorm){ LUBounds lucone=(LUBounds)dcone; double yy,cnorm2; int i,m,info; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->invisible){DSDPFunctionReturn(0);} info=DSDPVecGetSize(ANorm,&m);DSDPCHKERR(info); for (i=1;ilbound*lucone->lbound + m*lucone->ubound*lucone->ubound; cnorm2=m+1.0; info=DSDPVecAddC(ANorm,cnorm2);DSDPCHKERR(info); info=DSDPVecAddR(ANorm,2*lucone->r);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsView" int LUBoundsView(LUBounds lucone){ double lbound=lucone->lbound, ubound=lucone->ubound; DSDPFunctionBegin; LUConeValid(lucone); if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} printf("Lower Bounds for all y variables: %4.8e\n",lbound); printf("Upper Bounds for all y variables: %4.8e\n",ubound); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsRHS" static int LUBoundsRHS( void *dcone, double mu, DSDPVec vrow, DSDPVec vrhs1, DSDPVec vrhs2){ int info,i,m; LUBounds lucone=(LUBounds)dcone; double as,sl,su; double dd,yy,rs=0; double cc,rr,r,r0=lucone->r; double lbound, ubound; DSDPVec Y=lucone->YD; DSDPFunctionBegin; if (lucone->skipit==DSDP_TRUE){DSDPFunctionReturn(0);} LUConeValid(lucone); mu*=lucone->muscale; info=DSDPVecGetSize(vrow,&m);DSDPCHKERR(info); info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); lbound=cc*lucone->lbound; ubound=cc*lucone->ubound; r=rr*lucone->r; for (i=1;iconehessian=LUBoundsHessian; coneops->conesetup=LUBoundsSetup; coneops->conesetup2=LUBoundsSetup2; coneops->conedestroy=LUBoundsDestroy; coneops->conemonitor=LUBoundsMonitor; coneops->conecomputes=LUBoundsS; coneops->coneinverts=LUInvertS; coneops->conecomputex=LUBoundsX; coneops->conesetxmaker=LUBoundsSetX; coneops->conemaxsteplength=LUBoundsComputeMaxStepLength; coneops->conerhs=LUBoundsRHS; coneops->conelogpotential=LUBoundsPotential; coneops->conesize=LUBoundsSize; coneops->conesparsity=LUBoundsSparsity; coneops->conehmultiplyadd=LUBoundsMultiply; coneops->coneanorm2=LPANorm2; coneops->id=12; coneops->name=luconename; return 0; } #undef __FUNCT__ #define __FUNCT__ "BoundYConeSetBounds" /*! \fn int BoundYConeSetBounds(LUBounds lucone, double lb, double ub); \brief Set bounds on the variables \param lucone cone of bounds. \param lb lower bound on variables. \param ub upper bound */ int BoundYConeSetBounds(LUBounds lucone, double lb, double ub){ DSDPFunctionBegin; LUConeValid(lucone); lucone->lbound=lb; lucone->ubound=ub; if (lb==0 && ub==0){lucone->skipit=DSDP_TRUE;} else { lucone->skipit=DSDP_FALSE;} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BoundYConeGetBounds" /*! \fn int BoundYConeGetBounds(LUBounds lucone, double *lb, double *ub); \brief Get bounds on the variables \param lucone cone of bounds. \param lb lower bound on variables. \param ub upper bound */ int BoundYConeGetBounds(LUBounds lucone, double *lb, double *ub){ DSDPFunctionBegin; LUConeValid(lucone); *lb=lucone->lbound; *ub=lucone->ubound; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPAddLUBounds" /*! \fn int DSDPAddLUBounds(DSDP dsdp,LUBounds lucone); \brief Set the constraints to the solver. \param lucone cone of bounds. \param dsdp the solver */ int DSDPAddLUBounds(DSDP dsdp,LUBounds lucone){ int info; DSDPFunctionBegin; LUConeValid(lucone); info=LUBoundsOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)lucone); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateLUBoundsCone" /*! \fn int DSDPCreateLUBoundsCone(DSDP dsdp, LUBounds *dspcone); \brief Create bounds cone. \param dsdp the solver \param dspcone cone of bounds. */ int DSDPCreateLUBoundsCone(DSDP dsdp, LUBounds *dspcone){ int m,info; struct LUBounds_C *lucone; DSDPFunctionBegin; if (!dsdp){DSDPFunctionReturn(1);} DSDPCALLOC1(&lucone,struct LUBounds_C,&info);DSDPCHKERR(info); *dspcone=lucone; lucone->keyid=LUKEY; info=DSDPAddLUBounds(dsdp,lucone);DSDPCHKERR(info); info=DSDPGetNumberOfVariables(dsdp,&m);DSDPCHKERR(info); lucone->muscale=1.0; lucone->r=0.0; lucone->skipit=DSDP_FALSE; lucone->pobj=0; lucone->pax=0; lucone->sumx=0; lucone->xdots=0; info=BoundYConeSetBounds(lucone,-1000000,1000000);DSDPCHKERR(info); lucone->invisible=1; lucone->setup=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LUBoundsScaleBarrier" int LUBoundsScaleBarrier(LUBounds lucone,double muscale){ DSDPFunctionBegin; LUConeValid(lucone); if (muscale>0){ lucone->muscale=muscale; } DSDPFunctionReturn(0); } DSDP5.8/src/bounds/dbounds.c0000644000175000017500000004212310326241002015654 0ustar twernertwerner#include "dsdpcone_impl.h" #include "dsdpsys.h" #include "dsdp5.h" #define COMPUTEUBS(a,b,c) (-(a)-(b)-(c)) /*! \file dbounds.c \brief Individually bound variables y. */ /*! struct BCone_C Internal Structure of bounds on variables. */ struct BCone_C{ int keyid; int nn,nnmax; int *ib; double *u,*au,*us,*uss,*ux,*uds; double r,muscale; int m; double *xuout; DSDPVec WY,WY2; }; #define BKEY 5432 #define BConeValid(a) {if (!(a)||((a)->keyid!=BKEY)){ DSDPSETERR(101,"DSDPERROR: Invalid Bcone object\n");}} #undef __FUNCT__ #define __FUNCT__ "BConeSetUp" static int BConeSetup(void *dcone,DSDPVec y){ BCone bcone=(BCone)dcone; int nn=bcone->nn; int info; DSDPFunctionBegin; if (bcone->nn<1) return 0; DSDPCALLOC2(&bcone->us,double,nn,&info);DSDPCHKERR(info); DSDPCALLOC2(&bcone->uss,double,nn,&info);DSDPCHKERR(info); DSDPCALLOC2(&bcone->ux,double,nn,&info);DSDPCHKERR(info); DSDPCALLOC2(&bcone->uds,double,nn,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetUp2" static int BConeSetup2(void *dcone, DSDPVec Y, DSDPSchurMat M){ int info; BCone bcone=(BCone)dcone; DSDPFunctionBegin; info=DSDPVecDuplicate(Y,&bcone->WY);DSDPCHKERR(info); info=DSDPVecDuplicate(Y,&bcone->WY2);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeDestroy" static int BConeDestroy(void *dcone){ int info; BCone bcone=(BCone)dcone; DSDPFunctionBegin; DSDPFREE(&bcone->ib,&info);DSDPCHKERR(info); DSDPFREE(&bcone->u,&info);DSDPCHKERR(info); DSDPFREE(&bcone->au,&info);DSDPCHKERR(info); DSDPFREE(&bcone->us,&info);DSDPCHKERR(info); DSDPFREE(&bcone->uss,&info);DSDPCHKERR(info); DSDPFREE(&bcone->uds,&info);DSDPCHKERR(info); DSDPFREE(&bcone->ux,&info);DSDPCHKERR(info); info=DSDPVecDestroy(&bcone->WY);DSDPCHKERR(info); info=DSDPVecDestroy(&bcone->WY2);DSDPCHKERR(info); DSDPFREE(&dcone,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSize" static int BConeSize(void *dcone, double *n){ BCone bcone=(BCone)dcone; DSDPFunctionBegin; *n=(double)(bcone->nn); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeComputeS" static int BConeComputeS(BCone bcone,DSDPVec Y,double ss[], int n){ int i,ii,info; int *ib=bcone->ib, nn=bcone->nn; double cr,rr,r,yy,*au=bcone->au,*u=bcone->u; DSDPFunctionBegin; info=DSDPVecGetC(Y,&cr); info=DSDPVecGetR(Y,&rr); r=rr*bcone->r; for (i=0;iib, nn=bcone->nn; double *us=bcone->us; double *au=bcone->au,*u=bcone->u; double dd,cc,rr,cs,as,rs; double r=bcone->r; DSDPVec DD=bcone->WY,MScale=bcone->WY2; DSDPFunctionBegin; if (bcone->nn<1) return 0; mu*=bcone->muscale; info=DSDPVecZero(DD);DSDPCHKERR(info); info=DSDPSchurMatDiagonalScaling(M,MScale);DSDPCHKERR(info); info=DSDPVecGetC(MScale,&cc);DSDPCHKERR(info); info=DSDPVecGetR(MScale,&rr);DSDPCHKERR(info); for (i=0;iib, nn=bcone->nn; double *us=bcone->us, *au=bcone->au,*u=bcone->u; double dd,cc,rr,cs,as,rs; double r=bcone->r; DSDPFunctionBegin; mu*=bcone->muscale; info=DSDPVecGetC(vrow,&cc);DSDPCHKERR(info); info=DSDPVecGetR(vrow,&rr);DSDPCHKERR(info); for (i=0;iib, nn=bcone->nn; double *au=bcone->au,*us=bcone->us; double assa,dd,vv; DSDPFunctionBegin; mu*=bcone->muscale; for (i=0;inn; double *us; DSDPFunctionBegin; if (flag==DUAL_FACTOR){ us=bcone->us; } else { us=bcone->uss; } info=BConeComputeS(bcone,Y,us,nn);DSDPCHKERR(info); *psdefinite=DSDP_TRUE; for (i=0;iib, nn=bcone->nn; double *au=bcone->au, *us=bcone->uss, *ux=bcone->ux, *uds=bcone->uds, *u=bcone->u; double *xuout=bcone->xuout; double ds,dus,dau,xx,cr,rr; double pobj1=0,xdots1=0; DSDPTruth psdefinite; DSDPFunctionBegin; info=BConeS(dcone,Y,PRIMAL_FACTOR,&psdefinite); DSDPCHKERR(info); info=BConeComputeS(bcone,DY,uds,nn);DSDPCHKERR(info); info=DSDPVecGetC(Y,&cr);DSDPCHKERR(info); info=DSDPVecGetR(Y,&rr);DSDPCHKERR(info); mu*=bcone->muscale; for (i=0;inn; double *us,*uds=bcone->uds; DSDPFunctionBegin; if (bcone->nn<1) return 0; if (flag==DUAL_FACTOR){ us=bcone->us; } else { us=bcone->uss; } info=BConeComputeS(bcone,DY,uds,nn);DSDPCHKERR(info); for (i=0;imuscale; int nn=bcone->nn; double *us=bcone->us; DSDPFunctionBegin; if (bcone->nn<1) return 0; for (i=0;iib, nn=bcone->nn; double *u=bcone->u; double yy=1.0,cnorm2=0; int i,ii,info; DSDPFunctionBegin; for (i=0;ir*bcone->nn); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeView" int BConeView(BCone bcone){ int i,ii; int *ib=bcone->ib, nn=bcone->nn; double *au=bcone->au,*u=bcone->u; DSDPFunctionBegin; BConeValid(bcone); ib=bcone->ib; nn=bcone->nn; au=bcone->au; u=bcone->u; for (i=0;i0){ printf("Upper Bound. Var %d: %4.8e\n",ii,u[i]); } else { printf("Lower Bound. Var %d: %4.8e\n",ii,u[i]); } } DSDPFunctionReturn(0); } static struct DSDPCone_Ops kops; static const char *bconename="VariableBounds Cone"; #undef __FUNCT__ #define __FUNCT__ "BConeOperationsInitialize" static int BConeOperationsInitialize(struct DSDPCone_Ops* coneops){ int info; if (coneops==NULL) return 0; info=DSDPConeOpsInitialize(coneops); DSDPCHKERR(info); coneops->conehessian=BConeHessian; coneops->conerhs=BConeRHS; coneops->conesetup=BConeSetup; coneops->conesetup2=BConeSetup2; coneops->conedestroy=BConeDestroy; coneops->conecomputes=BConeS; coneops->coneinverts=BConeSInvert; coneops->conecomputex=BConeX; coneops->conesetxmaker=BConeSetX; coneops->conemaxsteplength=BConeComputeMaxStepLength; coneops->conelogpotential=BConePotential; coneops->conesize=BConeSize; coneops->conemonitor=BConeMonitor; coneops->conesparsity=BConeSparsity; coneops->conehmultiplyadd=BConeMultiply; coneops->coneanorm2=LPANorm2; coneops->id=2; coneops->name=bconename; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPAddBounds" int DSDPAddBounds(DSDP dsdp,BCone bcone){ int info; DSDPFunctionBegin; BConeValid(bcone); info=BConeOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)bcone); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateBCone" /*! \fn int DSDPCreateBCone(DSDP dsdp, BCone *dspcone); \brief Create a new cone that represents bounds on the y variables \ingroup Bounds \param dsdp the solver \param dspcone new cone For example, to bound the first of three y variables below by 0 and 10, \code DSDP dsdp; BCone bcone; int xl[3],xu[3]; DSDPCreate(3,&dsdp); DSDPCreateBCone(dsdp,&bcone); BConeSetLowerBound(bcone,1,0.0); BConeSetLowerBound(bcone,1,10.0); ... DSDPComputeX(dsdp); BConeCopyX(bcone,xl,xu,3); printf("The sensitivity of the solution to lower bound is %4.4f\n",xl[0]); \endcode */ int DSDPCreateBCone(DSDP dsdp, BCone *dspcone){ int m,info; struct BCone_C *bcone; DSDPFunctionBegin; if (!dsdp){DSDPFunctionReturn(1);} DSDPCALLOC1(&bcone,struct BCone_C,&info);DSDPCHKERR(info); bcone->keyid=BKEY; *dspcone=bcone; /* info=DSDPAddBounds(dsdp,bcone);DSDPCHKERR(info); */ info=BConeOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)bcone); DSDPCHKERR(info); info=DSDPGetNumberOfVariables(dsdp,&m);DSDPCHKERR(info); bcone->nn=0; bcone->m=m; bcone->muscale=1.0; bcone->r=1.0; bcone->nnmax=0; bcone->xuout=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeScaleBarrier" int BConeScaleBarrier(BCone bcone,double muscale){ DSDPFunctionBegin; BConeValid(bcone); if (muscale>0){ bcone->muscale=muscale; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeCopyX" /*! \fn int BConeCopyX(BCone bcone,double xl[], double xu[], int m); \brief Copy the variables into arrays \param bcone Bounds \param xl array \param xu array \param m length of the arrays \ingroup Bounds \sa DSDPComputeX() This routine will set the values of this array to the value of the corresponding variable. When no bound is present, the variable will equal zero. */ int BConeCopyX(BCone bcone,double xl[], double xu[], int m){ int i,ii,*ib,nn; double *xx,*au; DSDPFunctionBegin; BConeValid(bcone); if (m!=bcone->m){ DSDPSETERR1(6,"Invalid Array Length.\n",bcone->m);} xx=bcone->ux; au=bcone->au; nn=bcone->nn; ib=bcone->ib; for (i=0;ibcone->m){ DSDPSETERR2(6,"Invalid Variable number 1 <= %d <= %d.\n",vari,bcone->m);} if (bcone->nn>=bcone->nnmax){ DSDPLogInfo(0,19,"REALLOCATING SPACE FOR BOUNDS! %d \n",bcone->nnmax); info=BConeAllocateBounds(bcone,2*bcone->nn+4);DSDPCHKERR(info); } spot=bcone->nn; bcone->u[spot]=bound; bcone->au[spot]=ai; bcone->ib[spot]=vari; bcone->nn++; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetLowerBound" /*! \fn int BConeSetLowerBound(BCone bcone,int vari, double lbound); \brief Set a lower bound on a variable y. \ingroup Bounds \param bcone bounds \param vari y variable number \param lbound lower bound */ int BConeSetLowerBound(BCone bcone,int vari, double lbound){ int info; DSDPFunctionBegin; info=BConeSetBound(bcone,vari,-1.0,-lbound);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetUpperBound" /*! \fn int BConeSetUpperBound(BCone bcone,int vari, double ubound); \brief Set an upper bound on a variable y. \ingroup Bounds \param bcone bounds \param vari y variable number \param ubound upper bound */ int BConeSetUpperBound(BCone bcone,int vari, double ubound){ int info; DSDPFunctionBegin; info=BConeSetBound(bcone,vari,1.0,ubound);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetPSlackVariable" /*! \fn int BConeSetPSlackVariable(BCone bcone,int vari); \brief Set a slack variable to a constraint in (P). \ingroup Bounds \param bcone bounds \param vari y variable number \sa BConeSetUpperBound() \sa BConeSetPSurplusVariable() When a constraint in (P) is best expressed with an inequality constraint, a slack variable may be added. This command is equivalent to setting an upper bound on variable $y_i$ to zero. */ int BConeSetPSlackVariable(BCone bcone,int vari){ int info; DSDPFunctionBegin; info=BConeSetUpperBound(bcone,vari,0);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetPSurplusVariable" /*! \fn int BConeSetPSurplusVariable(BCone bcone,int vari); \brief Set a surplus variable in constraint in (P). \ingroup Bounds \param bcone bounds \param vari y variable number \sa BConeSetLowerBound() */ int BConeSetPSurplusVariable(BCone bcone,int vari){ int info; DSDPFunctionBegin; info=BConeSetLowerBound(bcone,vari,0);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeAllocateBounds" /*! \fn int BConeAllocateBounds(BCone bcone,int nnz); \brief Set a surplus variable in constraint in (P). \ingroup Bounds \param bcone bounds \param nnz number of bounds that will be set. This optional routine allows for efficient allocation of memory for this object. \sa BConeSetLowerBound() \sa BConeSetUpperBound() */ int BConeAllocateBounds(BCone bcone, int nnz){ int j,info,*uindex; double *uu,*au; DSDPFunctionBegin; BConeValid(bcone); if (nnz<=bcone->nnmax){DSDPFunctionReturn(0);} DSDPCALLOC2(&uu,double,(nnz),&info); DSDPCHKERR(info); DSDPCALLOC2(&au,double,(nnz),&info); DSDPCHKERR(info); DSDPCALLOC2(&uindex,int,(nnz),&info); DSDPCHKERR(info); for (j=0;jnnmax>0){ for (j=0;jnn;j++){uu[j]=bcone->u[j];} for (j=0;jnn;j++){uindex[j]=bcone->ib[j];} for (j=0;jnn;j++){au[j]=bcone->au[j];} DSDPFREE(&bcone->u,&info);DSDPCHKERR(info); DSDPFREE(&bcone->au,&info);DSDPCHKERR(info); DSDPFREE(&bcone->ib,&info);DSDPCHKERR(info); } else { bcone->nn=0; } bcone->nnmax=nnz; bcone->u=uu; bcone->au=au; bcone->ib=uindex; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BConeSetXArray" int BConeSetXArray(BCone bcone,double *xuout, int n){ DSDPFunctionBegin; BConeValid(bcone); if (n==bcone->nn) bcone->xuout=xuout; DSDPFunctionReturn(0); } DSDP5.8/src/bounds/Makefile0000644000175000017500000000021310326241002015504 0ustar twernertwernerDSDPOBJ = dbounds.o allbounds.o DCFLAGS = -I${PP}solver include ../../make.include default: make dsdplib; clean: ${RM} ${DSDPOBJ} DSDP5.8/src/sys/0000755000175000017500000000000010326241002013374 5ustar twernertwernerDSDP5.8/src/sys/dsdperror.c0000644000175000017500000000621210326241003015546 0ustar twernertwerner#include "dsdpsys.h" /*! \file dsdperror.c \brief Error codes returned for most subroutines */ #include #include #define DSDP_NULL 0 #define DSDP_MAX_PATH_LEN 200 static FILE *DSDPLogInfoFile = DSDP_NULL; static FILE *dsdp_history=0; typedef void* DSDPObject; int DSDPFError(void *vobj, const char functionname[], int linen, const char filename[], const char message[], ...) { va_list Argp; int urank; size_t len; char string[8*1024]; DSDPFunctionBegin; DSDPLogInfoFile = stdout; /* if (DSDPLogPrintInfo == DSDP_FALSE) DSDPFunctionReturn(0); if ((DSDPLogPrintInfoNull == DSDP_FALSE) && !vobj) DSDPFunctionReturn(0); */ urank = 0; va_start(Argp, message); sprintf(string, "[%d] DSDP: %s(): Line %d in file %s ", urank,functionname,linen,filename); len = strlen(string); #if defined(DSDP_HAVE_VPRINTF_CHAR) vsprintf(string+len, message, (char *) Argp); #else vsprintf(string+len, message, Argp); #endif fprintf(DSDPLogInfoFile, "%s", string); fflush(DSDPLogInfoFile); if (dsdp_history) { #if defined(DSDP_HAVE_VPRINTF_CHAR) vfprintf(dsdp_history, message, (char *) Argp); #else vfprintf(dsdp_history, message, Argp); #endif } va_end(Argp); DSDPFunctionReturn(0); } void DSDPError(const char * functionname, int linen, const char filename[]){ DSDPErrorPrintf("DSDP Error in function: %s , line %d of file %s \n",functionname, linen,filename); return; } typedef struct{ void *mem; char fname[20]; size_t size; int freed; } DSDPMemory; #define DSDPMEMMAX 1 static DSDPMemory DSDPMemoryTable[DSDPMEMMAX]; static long int mmmem=0; #undef __FUNCT__ #define __FUNCT__ "DSDPMMalloc" int DSDPMMalloc(const char* fname, size_t size, void** mmem){ void*tt=0; DSDPFunctionBegin; if (size>0){ #ifdef DSDPMATLAB tt=(void*)mxMalloc(size); #else tt=(void*)malloc(size); #endif if (tt==NULL){ *mmem=0; DSDPSETERR3(100,"Memory Error in routine '%s'. Cannot allocate %d bytes, %d MB\n",fname,size,(int)(size/1000000)); } memset(tt,0,size); *mmem=tt; if (mmmem0 && DSDPMemoryTable[j].freed==0){ printf("%d, MEMORY Not FREED: %s, %d \n",j,DSDPMemoryTable[j].fname,(int)DSDPMemoryTable[j].size); } } DSDPLogInfo(0,2," MEMORY MALLOC NOT FREED: %ld\n",mmmem); return; } DSDP5.8/src/sys/dsdplog.c0000644000175000017500000000721210326241003015177 0ustar twernertwerner#include "dsdpsys.h" #include #include #define DSDP_MAX_EVENT_NAME_LENGTH 50 #define DSDP_MAX_EVENTS 30 /*! \file dsdplog.c \brief Profile the performance of DSDP */ FILE *dsdpoutputfile; typedef struct { int counter; double begintime; double totaltime; char ename[DSDP_MAX_EVENT_NAME_LENGTH]; } EventInfo; typedef struct{ EventInfo event[DSDP_MAX_EVENTS]; int nevents; int neventsmax; double time0; } EventLog; static EventLog eventlog; #undef __FUNCT__ #define __FUNCT__ "DSDPEventLogBegin" int DSDPEventLogBegin(int eventid){ double tt; DSDPTime(&tt); if (eventid<=0){return 0;} if (eventlog.event[eventid].begintime!=0 && eventid!=DSDP_MAX_EVENTS-1){ DSDPPrintf("Timing error: id: %d %s. Call begin without calling end.%4.4e\n",eventid,eventlog.event[eventid].ename,eventlog.event[eventid].begintime); }; eventlog.event[eventid].begintime=tt; eventlog.event[eventid].counter++; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPEventLogEnd" int DSDPEventLogEnd(int eventid){ double tt; DSDPTime(&tt); if (eventid<=0){return 0;} tt=tt-eventlog.event[eventid].begintime; eventlog.event[eventid].totaltime+=tt; eventlog.event[eventid].begintime=0; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPEventLogRegister" int DSDPEventLogRegister(const char *ename, int *eventid){ int id; id=eventlog.nevents; if (id<0 || id>=DSDP_MAX_EVENTS){ *eventid=DSDP_MAX_EVENTS-1;return 0;} eventlog.event[id].begintime=0; eventlog.event[id].totaltime=0; eventlog.event[id].counter=0; strncpy(eventlog.event[id].ename,ename,DSDP_MAX_EVENT_NAME_LENGTH-1); eventlog.nevents++; *eventid=id; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPEventLogInitialize" int DSDPEventLogInitialize(void){ int i; double t0; DSDPTime(&t0); eventlog.time0=t0; for (i=0;i #include #include #include #include "dsdpsys.h" #include "dsdpbasictypes.h" #define DSDP_NULL 0 #define DSDP_MAX_PATH_LEN 200 /*! \file dsdploginfo.c \brief Print the progress of the DSDP solver. */ typedef void* DSDPObject; /* extern FILE *dsdp_history; */ static FILE *dsdp_history=0; /* The next three variables determine which, if any, DSDPLogInfo() calls are used. If DSDPLogPrintInfo is zero, no info messages are printed. If DSDPLogPrintInfoNull is zero, no info messages associated with a null object are printed. If DSDPLogInfoFlags[OBJECT_COOKIE - DSDP_COOKIE] is zero, no messages related to that object are printed. OBJECT_COOKIE is, for example, MAT_COOKIE. */ static int DSDPLogPrintInfo = 0; static int DSDPLogPrintInfoNull = 0; static FILE *DSDPLogInfoFile = DSDP_NULL; static int rank=0; void DSDPSetRank(int rrank){ rank=rrank; return; } #undef __FUNCT__ #define __FUNCT__ "DSDPLogInfoAllow" /*@C DSDPLogInfoAllow - Causes DSDPLogInfo() messages to be printed to standard output. Not Collective, each processor may call this seperately, but printing is only turned on if the lowest processor number associated with the DSDPObject associated with the call to DSDPLogInfo() has called this routine. Input Parameter: + flag - DSDP_TRUE or DSDP_FALSE - filename - optional name of file to write output to (defaults to stdout) Options Database Key: . -log_info [optional filename] - Activates DSDPLogInfoAllow() Level: advanced Concepts: debugging^detailed runtime information Concepts: dumping detailed runtime information .seealso: DSDPLogInfo() @*/ int DSDPLogInfoAllow(int flag, char *filename) { char fname[DSDP_MAX_PATH_LEN], tname[5]; int prank=0; char* ierr; DSDPFunctionBegin; if (flag && filename) { sprintf(tname, ".%d", prank); ierr = strcat(fname, tname); } else if (flag) { DSDPLogInfoFile = stdout; } DSDPLogPrintInfo = flag; DSDPLogPrintInfoNull = flag; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLogInfo" /*@C DSDPLogInfo - Logs informative data, which is printed to standard output or a file when the option -log_info is specified. Collective over DSDPObject argument Input Parameter: + vobj - object most closely associated with the logging statement - message - logging message, using standard "printf" format Options Database Key: $ -log_info : activates printing of DSDPLogInfo() messages Level: intermediate Example of Usage: $ $ double alpha $ DSDPLogInfo(0,"Matrix uses parameter alpha=%g\n",alpha); $ Concepts: runtime information .seealso: DSDPLogInfoAllow() @*/ void DSDPLogFInfo(void *vobj, int outlevel, const char message[], ...) { va_list Argp; int urank; size_t len; char string[8*1024]; DSDPFunctionBegin; DSDPLogInfoFile = stdout; if (DSDPLogPrintInfo < outlevel) return; if ((DSDPLogPrintInfoNull < outlevel) && !vobj) return; urank = 0; if (rank>0) return; va_start(Argp, message); sprintf(string, "[%d][%2d] DSDP: ", rank,outlevel); len = strlen(string); #if defined(DSDP_HAVE_VPRINTF_CHAR) vsprintf(string+len, message, (char *) Argp); #else vsprintf(string+len, message, Argp); #endif fprintf(DSDPLogInfoFile, "%s", string); fflush(DSDPLogInfoFile); if (dsdp_history) { #if defined(DSDP_HAVE_VPRINTF_CHAR) vfprintf(dsdp_history, message, (char *) Argp); #else vfprintf(dsdp_history, message, Argp); #endif } va_end(Argp); return; /* DSDPFunctionReturn(0); */ } DSDP5.8/src/sys/dsdptime.c0000644000175000017500000000132110326241003015347 0ustar twernertwerner/* DSDPTime could return 0 and still work */ /*! \file dsdptime.c \brief Timing routines for GNU and Microsoft compilers. */ /* #define DSDP_TIME */ #include "dsdpsys.h" #ifdef DSDP_MS_TIME #include #include void DSDPTime(double * ttime) { /* MICROSOFT COMPILER */ clock_t t=clock(); double tscale=0.001; (*ttime)=((double)t) * tscale; } #else #ifdef DSDP_TIME #include void DSDPTime(double * ttime) { /* USED IN LINUX */ static struct timeval _tp; *ttime=0; gettimeofday(&_tp,(struct timezone *)0); (*ttime)=((double)_tp.tv_sec)+(1.0e-6)*(_tp.tv_usec); } #else void DSDPTime(double * ttime) { *ttime=0; return; } /* NO TIME */ #endif #endif /* for Microsoft */ /* */ DSDP5.8/src/sys/Makefile0000644000175000017500000000025110326241003015033 0ustar twernertwerner DSDPOBJ = dsdperror.o dsdploginfo.o dsdplog.o dsdptime.o DCFLAGS = -D${DSDPTIMER} include ../../make.include default: make dsdplib; clean: ${RM} ${DSDPOBJ} DSDP5.8/src/sdp/0000755000175000017500000000000010326241002013344 5ustar twernertwernerDSDP5.8/src/sdp/dsdpadddata.c0000644000175000017500000005605010326241002015753 0ustar twernertwerner#include "dsdpsdp.h" #include "dsdpsys.h" /*! \file dsdpadddata.c \brief Set block sizes, sparsity, format, and data matrices */ #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckI" /*! \fn int SDPConeCheckI(SDPCone sdpcone, int vari); \brief Check validity of parameter. \param sdpcone SDP cone \param vari variable i from 0 through m */ int SDPConeCheckI(SDPCone sdpcone,int vari){ DSDPFunctionBegin; SDPConeValid(sdpcone); if (vari<0 || vari>sdpcone->m) { DSDPSETERR2(1,"Bad Data Matrix: variable: %d (Max: %d)\n",vari,sdpcone->m+1);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckJ" /*! \fn int SDPConeCheckJ(SDPCone sdpcone, int blockj); \brief Check validity of parameter. \param sdpcone SDP cone \param blockj from 0 to nblocks */ int SDPConeCheckJ(SDPCone sdpcone,int blockj){ DSDPFunctionBegin; SDPConeValid(sdpcone); if (blockj<0 || blockj>= sdpcone->nblocks) { DSDPSETERR2(2,"Bad Data Matrix: Block: %d (Max: %d)\n",blockj,sdpcone->nblocks-1);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckN" /*! \fn int SDPConeCheckN(SDPCone sdpcone, int blockj, int n); \brief Check validity of parameter. \param sdpcone SDP cone \param blockj block number \param n dimension of block. */ int SDPConeCheckN(SDPCone sdpcone,int blockj, int n){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); if (sdpcone->blk[blockj].n==0 && n>0){info=SDPConeSetBlockSize(sdpcone,blockj,n);DSDPCHKERR(info);} if (sdpcone->blk[blockj].n != n){ DSDPSETERR3(3,"Check Dimension of Data Matrix: Block: %d, %d -- expecting %d\n", blockj,n,sdpcone->blk[blockj].n); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckM" /*! \fn int SDPConeCheckM(SDPCone sdpcone, int m); \brief Check validity of parameter. \param sdpcone SDP cone \param m number of y variables */ int SDPConeCheckM(SDPCone sdpcone,int m){ DSDPFunctionBegin; SDPConeValid(sdpcone); if (m!=sdpcone->m){ DSDPSETERR1(4,"Check dimension of array. This problem has %d variables\n",sdpcone->m);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeValidStorageFormat" /*! \fn int SDPConeValidStorageFormat(SDPCone sdpcone, char format); \brief Check validity of parameter. \param sdpcone SDP cone \param format such as packed symmetric or upper full symmetric */ int SDPConeValidStorageFormat(SDPCone sdpcone, char format){ DSDPFunctionBegin; if (format!='P' && format != 'U'){ DSDPSETERR1(4,"Check format of Block: %c is not supported! Use P or U. \n",format); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckStorageFormat" /*! \fn int SDPConeCheckStorageFormat(SDPCone sdpcone,int blockj, char format); \brief Check validity of parameters. \param sdpcone SDP cone \param blockj block number \param format such as packed symmetric or upper full symmetric */ int SDPConeCheckStorageFormat(SDPCone sdpcone,int blockj, char format){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=SDPConeValidStorageFormat(sdpcone,format);DSDPCHKERR(info); if (sdpcone->blk[blockj].format=='N'){ sdpcone->blk[blockj].format = format; } if (sdpcone->blk[blockj].format != format){ DSDPSETERR3(4,"Check format of Data Matrix: Block: %d, %c -- expecting %c\n", blockj,format,sdpcone->blk[blockj].format); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeRemoveDataMatrix" /*! \fn int SDPConeRemoveDataMatrix(SDPCone sdpcone,int blockj, int vari); \brief Remove the data matrix \f$A_{i,j}\f$ from the cone \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \sa SDPConeView() */ int SDPConeRemoveDataMatrix(SDPCone sdpcone,int blockj, int vari){ int info; DSDPFunctionBegin; info=SDPConeCheckI(sdpcone,vari);DSDPCHKERR(info); info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPBlockRemoveDataMatrix(&sdpcone->blk[blockj].ADATA,vari);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddDataMatrix" /*! \fn int SDPConeAddDataMatrix(SDPCone sdpcone,int blockj, int vari, int n, char format,struct DSDPDataMat_Ops* dsdpdataops, void* data); \brief Add a data matrix \f$A_{i,j}\f$ \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param format storage format 'P' (default) or 'U' \param data address of a structure ( cast to \c void* ) with matrix data. \param dsdpdataops address of a structure of function pointers that operate on the matrix data \sa SDPConeSetASparseVecMat() \sa SDPConeSetStorageFormat() \sa SDPConeSetBlockSize() \sa SDPConeCheckData() */ int SDPConeAddDataMatrix(SDPCone sdpcone,int blockj, int vari, int n, char format, struct DSDPDataMat_Ops* dsdpdataops, void* data){ int info; DSDPFunctionBegin; info=SDPConeCheckI(sdpcone,vari);DSDPCHKERR(info); info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKERR(info); info=SDPConeCheckStorageFormat(sdpcone,blockj,format);DSDPCHKERR(info); info=DSDPBlockAddDataMatrix(&sdpcone->blk[blockj].ADATA,vari,dsdpdataops,data);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetRMatrix" /*! \fn int SDPConeSetRMatrix(SDPCone sdpcone,int blockj, int n, char format,struct DSDPDataMat_Ops* dsdpdataops, void* data); \brief Add identity to dual matrix. \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param n dimension of the matrix \param format storage format 'P' (default) or 'U' \param data address of a structure ( cast to \c void* ) with matrix data. \param dsdpdataops address of a structure of function pointers that operate on the matrix data \sa SDPConeSetASparseVecMat() \sa SDPConeSetStorageFormat() \sa SDPConeSetBlockSize() \sa SDPConeCheckData() */ int SDPConeSetRMatrix(SDPCone sdpcone,int blockj, int n, char format, struct DSDPDataMat_Ops* dsdpdataops, void* data){ int info; int vari=sdpcone->m+1; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKERR(info); info=SDPConeCheckStorageFormat(sdpcone,blockj,format);DSDPCHKERR(info); info=DSDPBlockRemoveDataMatrix(&sdpcone->blk[blockj].ADATA,vari);DSDPCHKERR(info); info=DSDPBlockSetDataMatrix(&sdpcone->blk[blockj].ADATA,vari,dsdpdataops,data);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeViewDataMatrix" /*! \fn int SDPConeViewDataMatrix(SDPCone sdpcone,int blockj, int vari); \ingroup SDPBasic \brief Print a data matrix to the screen \param sdpcone semidefinite cone object \param blockj block number \param vari variable number from 0 through m \sa SDPConeView() */ int SDPConeViewDataMatrix(SDPCone sdpcone,int blockj, int vari){ int info,ii,vari2,nnzmats; DSDPDataMat AA; DSDPFunctionBegin; info=SDPConeCheckI(sdpcone,vari);DSDPCHKERR(info); info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPBlockCountNonzeroMatrices(&sdpcone->blk[blockj].ADATA,&nnzmats);DSDPCHKERR(info); for (ii=0;iiblk[blockj].ADATA,ii,&vari2,0,&AA);DSDPCHKVARERR(vari,info); if (vari2==vari){ info = DSDPDataMatView(AA);DSDPCHKERR(info);} } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeClearVMatrix" /*! \fn int SDPConeClearVMatrix(SDPCone sdpcone,int blockj, int n); \brief Free V matrix. \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param n dimension of the matrix */ int SDPConeClearVMatrix(SDPCone sdpcone,int blockj, int n){ int info; DSDPFunctionBegin; SDPConeValid(sdpcone); info=DSDPVMatDestroy(&sdpcone->blk[blockj].T);DSDPCHKERR(info); info=DSDPVMatInitialize(&sdpcone->blk[blockj].T);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetXMat" /*! \fn int SDPConeSetXMat(SDPCone sdpcone,int blockj, int n); \brief Create X matrix. \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param n dimension of the matrix */ int SDPConeSetXMat(SDPCone sdpcone,int blockj, int n){ int info; char UPLQ; DSDPVMat T; DSDPFunctionBegin; SDPConeValid(sdpcone); info=SDPConeClearVMatrix(sdpcone,blockj,n);DSDPCHKERR(info); DSDPLogInfo(0,10,"Create block X Mat: Block: %d, size: %d.\n",blockj,n); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); info=DSDPMakeVMat(UPLQ,n,&T);DSDPCHKERR(info); sdpcone->blk[blockj].T=T; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetXArray" /*! \fn int SDPConeSetXArray(SDPCone sdpcone,int blockj, int n, double xx[], int nn); \ingroup SDPRoutines \brief Provide an array for the SDPCone object can use to store dense matrices. \param sdpcone semidefinite cone object \param blockj block number \param n dimension of the block \param xx array for dense matrices \param nn length of array This routine elimates the need to copy the solution X into a separate array. \sa SDPConeGetXArray() */ int SDPConeSetXArray(SDPCone sdpcone,int blockj, int n, double xx[], int nn){ int info; char UPLQ; DSDPVMat T; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKERR(info); info=SDPConeClearVMatrix(sdpcone,blockj,n);DSDPCHKERR(info); DSDPLogInfo(0,10,"Set block X array: Block: %d, size: %d.\n",blockj,n); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); info=DSDPMakeVMatWithArray(UPLQ,xx,nn,n,&T);DSDPCHKERR(info); sdpcone->blk[blockj].T=T; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeGetXArray" /*! \fn int SDPConeGetXArray(SDPCone sdpcone,int blockj, double* xx[], int *nn); \ingroup SDPBasic \brief After applying the solver, set a pointer to the array in the object with the solution X. \param sdpcone semidefinite cone object \param blockj block number \param xx address of an array for dense matrices \param *nn the length of the array \sa DSDPSolve() \sa DSDPComputeX() \sa SDPConeViewX() \code DSDP dsdp; SDPCone sdpcone; double *xx; int nn; DSDPSolve(dsdp); DSDPComputeX(dsdp); SDPConeGetXArray(sdpcone,0,&xx,&nn); SDPConeViewX(sdpcone,0,xx,nn); SDPConeRestoreXArray(sdpcone,0,&xx,&nn); \endcode DSDP uses a single dense array to add data matrices, compute the matrix X, and take the inner product of X with the data matrices. Therefore, the ordering of elements in this array must also be used in the data matrices. */ int SDPConeGetXArray(SDPCone sdpcone,int blockj, double* xx[], int *nn){ int info,flag; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPVMatExist(sdpcone->blk[blockj].T,&flag);DSDPCHKERR(info); if (flag==0){ DSDPSETERR(6,"No X Array available, Call DSDPSetup() or SDPConeSetXArray.\n");} info=DSDPVMatGetArray(sdpcone->blk[blockj].T,xx,nn);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeRestoreXArray" /*! \fn int SDPConeRestoreXArray(SDPCone sdpcone,int blockj, double* xx[], int *nn); \ingroup SDPRoutines \brief Restore the dense array and set these pointers to null. \param sdpcone semidefinite cone object \param blockj block number \param xx address of an array for dense matrices \param *nn the length of the array \sa SDPConeGetXArray() */ int SDPConeRestoreXArray(SDPCone sdpcone,int blockj, double* xx[], int *nn){ int info,flag; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPVMatExist(sdpcone->blk[blockj].T,&flag);DSDPCHKERR(info); if (flag==0){ DSDPSETERR(6,"No X Array available, Call DSDPSetup() or SDPConeSetXArray.\n");} info=DSDPVMatRestoreArray(sdpcone->blk[blockj].T,xx,nn);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeMatrixView" /*! \fn int SDPConeMatrixView(SDPCone sdpcone,int blockj); \ingroup SDPRoutines \brief Print the dense array to the screen. \param sdpcone semidefinite cone object \param blockj block number \sa SDPConeGetXArray() */ int SDPConeMatrixView(SDPCone sdpcone, int blockj){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPVMatView(sdpcone->blk[blockj].T);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeUseFullSymmetricFormat" /*! \fn int SDPConeUseFullSymmetricFormat(SDPCone sdpcone,int blockj); \ingroup SDPData \brief Use full symmetric format for the dense array. \param sdpcone semidefinite cone object \param blockj block number \sa SDPConeGetXArray() \sa SDPConeSetASparseVecMat() \sa SDPConeSetADenseVecMat() \sa SDPConeSetStorageFormat() \sa SDPConeUsePackedFormat() \sa SDPConeCheckData() In this format, an \f$n \times n\f$ symmetric matrix is represented by an array of length \f$ n^2 \f$. Each element of the array corresponds to an element of the matrix and the mapping is given below. \f[ \begin{array}{lllllllllll} [ a_{1,1} & \ldots & a_{1,n} & a_{2,1} & \ldots & a_{2,n} & \ldots & a_{n,1} & \ldots & a_{n,n} ] \\ \end{array} \f] but elements \f$a_{i,j}, iblk[blockj].format=format; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeGetStorageFormat" /*! \fn int SDPConeGetStorageFormat(SDPCone sdpcone,int blockj, char *format); \ingroup SDPData \brief Get the storage format for the block. \param sdpcone semidefinite cone object \param blockj block number \param format format the block \sa SDPConeSetStorageFormat() \sa SDPConeGetXArray() \sa SDPConeSetASparseVecMat() \sa SDPConeSetADenseVecMat() The default format is 'P' (packed symmetric format). */ int SDPConeGetStorageFormat(SDPCone sdpcone, int blockj, char *format){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); *format=sdpcone->blk[blockj].format; if (*format=='N') *format='P'; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeScaleBarrier" int SDPConeScaleBarrier(SDPCone sdpcone,int blockj, double ggamma){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); sdpcone->blk[blockj].gammamu=ggamma; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetBlockSize" /*! \fn int SDPConeSetBlockSize(SDPCone sdpcone,int blockj, int n); \ingroup SDPRoutines \brief Set the dimension of one block in the semidefinite cone \param sdpcone semidefinite cone object \param blockj block number \param n dimension of the block \note This routine is optional, but its use can help the object detect input errors. */ int SDPConeSetBlockSize(SDPCone sdpcone, int blockj, int n){ int info,n0; DSDPFunctionBegin; DSDPLogInfo(0,10,"Set block size: Block: %d, size: %d.\n",blockj,n); info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); n0=sdpcone->blk[blockj].n; if (n0==n){DSDPFunctionReturn(0);} if (n0!=0 &&n0!=n){ DSDPSETERR2(5,"Block %d Size previously set to %d \n",blockj,n0); } sdpcone->blk[blockj].n=n; sdpcone->nn+=n-n0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeGetBlockSize" /*! \fn int SDPConeGetBlockSize(SDPCone sdpcone,int blockj, int *n); \ingroup SDPRoutines \brief Get the dimension of one block in the semidefinite cone \param sdpcone semidefinite cone object \param blockj block number \param *n set to the dimension of the block \sa SDPConeSetBlockSize() */ int SDPConeGetBlockSize(SDPCone sdpcone, int blockj, int *n){ int info; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); *n=sdpcone->blk[blockj].n; DSDPFunctionReturn(0); } /*! \fn int SDPConeGetNumberOfBlocks(SDPCone sdpcone, int *nblocks); \ingroup SDPRoutines \brief Get the number of blocks in the semidefinite cone \param sdpcone semidefinite cone object \param *nblocks set to the dimension of the block \sa DSDPCreateSDPCone() */ #undef __FUNCT__ #define __FUNCT__ "SDPConeGetNumberOfBlocks" int SDPConeGetNumberOfBlocks(SDPCone sdpcone, int *nblocks){ DSDPFunctionBegin; SDPConeValid(sdpcone); *nblocks=sdpcone->nblocks; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetSparsity" /*! \fn int SDPConeSetSparsity(SDPCone sdpcone,int blockj, int nnz); \ingroup SDPRoutines \brief Set the number of nonzero matrices in a block of the semidefinite cone. \param sdpcone semidefinite cone object \param blockj block number \param nnz number of nonzero matrices in the block \note This routine is optional, but its use can improve the memory allocation within the SDPCone object. */ int SDPConeSetSparsity(SDPCone sdpcone, int blockj, int nnz){ int info; DSDPFunctionBegin; DSDPLogInfo(0,10,"Set block nonzeros: Block: %d, Nonzero Matrices: %d.\n",blockj,nnz); info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); if (nnz>sdpcone->m) nnz=sdpcone->m; info=DSDPBlockDataAllocate(&sdpcone->blk[blockj].ADATA,nnz+2); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeView" /*! \fn int SDPConeView(SDPCone sdpcone); \brief Print the SDPCone to the screen; \param sdpcone the cone \sa SDPConeViewDataMatrix() \sa SDPConeView2() \sa SDPConeView2() \ingroup SDPBasics */ int SDPConeView(SDPCone sdpcone){ int blockj,info; DSDPFunctionBegin; for (blockj=0; blockjnblocks; blockj++){ printf("Block: %d, Dimension: %d\n",blockj,sdpcone->blk[blockj].n); info=DSDPBlockView(&sdpcone->blk[blockj].ADATA);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeView2" /*! \fn int SDPConeView2(SDPCone sdpcone); \brief Print the SDP cone to the screen in a second way \param sdpcone the cone \sa SDPConeViewDataMatrix() \sa SDPConeView() \sa SDPConeView3() \ingroup SDPData */ int SDPConeView2(SDPCone sdpcone){ int blockj,info; DSDPFunctionBegin; for (blockj=0; blockjnblocks; blockj++){ printf("Block: %d, Dimension: %d\n",blockj,sdpcone->blk[blockj].n); info=DSDPBlockView2(&sdpcone->blk[blockj].ADATA);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeView3" /*! \fn int SDPConeView3(SDPCone sdpcone); \brief Print the SDP cone to the screen in a third way \param sdpcone the cone \sa SDPConeViewDataMatrix() \sa SDPConeView() \sa SDPConeView2() \ingroup SDPData */ int SDPConeView3(SDPCone sdpcone){ int blockj,id,n,info,nnzmats; DSDPFunctionBegin; for (blockj=0; blockjnblocks; blockj++){ n=sdpcone->blk[blockj].n; printf("Block: %d \n",blockj); printf(" Dimension: %d\n",n); info=DSDPDSMatGetType(sdpcone->blk[blockj].DS,&id); if (id==1){ printf(" DS Matrix Type: Dense, Using LAPACK\n"); } else { printf(" DS Matrix Type: %d\n",id); } info=DSDPDualMatGetType(sdpcone->blk[blockj].S,&id); if (id==1){ printf(" Dual Matrix Type: Dense, Using LAPACK\n"); } else { printf(" Dual Matrix Type: %d\n",id); } info=DSDPBlockCountNonzeroMatrices(&sdpcone->blk[blockj].ADATA,&nnzmats);DSDPCHKERR(info); printf(" Number of Data Matrices: %d of %d\n",nnzmats-1,sdpcone->m+1); printf(" Number of Data Nonzeros: %d\n",sdpcone->blk[blockj].nnz); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeCheckData" /*! \fn int SDPConeCheckData(SDPCone sdpcone); \brief Check the matrix operations on a data matrix; \param sdpcone the cone \ingroup SDPData \sa SDPConeView */ int SDPConeCheckData(SDPCone sdpcone){ int i,ii,blockj,nnzmats,info; double scl=0; DSDPDataMat AA; DSDPIndex IS; DSDPVMat T; DSDPDSMat DS; DSDPDualMat S1,S2; SDPConeVec W,W2; DSDPFunctionBegin; for (blockj=0; blockjnblocks; blockj++){ T=sdpcone->blk[blockj].T;DS=sdpcone->blk[blockj].DS; W=sdpcone->blk[blockj].W;W2=sdpcone->blk[blockj].W2; S1=sdpcone->blk[blockj].S;S2=sdpcone->blk[blockj].SS; IS=sdpcone->blk[blockj].IS; printf("Block: %d\n",blockj); info=DSDPVMatCheck(T,W,W2);DSDPCHKERR(info); info=DSDPDSMatCheck(DS,W,W2,T);DSDPCHKERR(info); info=DSDPDualMatCheck(S1,W,W2,IS,T);DSDPCHKERR(info); info=DSDPDualMatCheck(S2,W,W2,IS,T);DSDPCHKERR(info); info=DSDPBlockCountNonzeroMatrices(&sdpcone->blk[blockj].ADATA,&nnzmats);DSDPCHKERR(info); for (ii=0;iiblk[blockj].ADATA,ii,&i,&scl,&AA);DSDPCHKERR(info); if (i==0) continue; printf(" Variable: %d, \n",i); info=DSDPDataMatCheck(AA,W,IS,T);DSDPCHKERR(info); } } DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpadddatamat.c0000644000175000017500000004515510326241002016461 0ustar twernertwerner#include "dsdpdatamat.h" #include "dsdpsys.h" #include "dsdp5.h" /*! \file dsdpadddatamat.c \brief Set sparse or dense matrices into the cone. */ extern int DSDPGetZeroDataMatOps(struct DSDPDataMat_Ops**); extern int DSDPGetConstantMat(int,double,char,struct DSDPDataMat_Ops**,void**); extern int DSDPGetVechMat(int,int,double,const int[], const double[],int, struct DSDPDataMat_Ops**,void**); extern int DSDPGetVecUMat(int,int,double,const int[], const double[],int, struct DSDPDataMat_Ops**,void**); extern int DSDPGetIdentityDataMatP(int,double,struct DSDPDataMat_Ops**,void**); extern int DSDPGetIdentityDataMatF(int,double,struct DSDPDataMat_Ops**,void**); extern int DSDPGetDMat(int,double,double[],struct DSDPDataMat_Ops**,void**); extern int DSDPGetR1PMat(int,double,int,const int[],const double[],int,struct DSDPDataMat_Ops**,void**); extern int DSDPGetR1UMat(int,double,int,const int[],const double[],int,struct DSDPDataMat_Ops**,void**); extern int SDPConeAddDataMatrix(SDPCone,int, int, int, char, struct DSDPDataMat_Ops*, void*); extern int SDPConeSetRMatrix(SDPCone,int,int,char,struct DSDPDataMat_Ops*,void*); #undef __FUNCT__ #define __FUNCT__ "SDPConeAddASparseVecMat" /*! \fn int SDPConeAddASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift, const int ind[], const double val[], int nnz); \brief Add data matrix \f$A_{i,j}\f$ in a sparse format \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param ishift index of first element (usually 0) \param alpha multiple of the data (usually 1) \param val array of elements in the matrix \param ind array of indices representing the location of the elements \param nnz length of the previous two arrays \note DSDP will use the two arrays throughout in many routines, but it will not modify or delete them until finished with DSDP. \sa DSDPCreateSDPCone() \sa SDPConeGetStorageFormat() \sa SDPConeViewDataMatrix() \sa SDPConeSetBlockSize() */ int SDPConeAddASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift, const int ind[], const double val[], int nnz){ int info; char UPLQ; void* dmat=0; struct DSDPDataMat_Ops* dmatops=0; DSDPFunctionBegin; info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); DSDPLogInfo(0,20,"Set sparse matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz); switch (UPLQ){ case 'P': info=DSDPGetVechMat(n,ishift,alpha,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info); break; case 'U': info=DSDPGetVecUMat(n,ishift,alpha,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info); break; } info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddSparseVecMat" /* Needed for backward compatibility */ int SDPConeAddSparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, int ishift,const int ind[], const double val[], int nnz){ int info; DSDPFunctionBegin; info= SDPConeAddASparseVecMat(sdpcone,blockj,vari,n, 1.0,ishift,ind,val,nnz);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetASparseVecMat" /*! \fn int SDPConeSetASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift, const int ind[], const double val[], int nnz); \brief Set data matrix \f$A_{i,j}\f$ in a sparse format \ingroup SDPBasic \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param ishift index of \f$ a_{1,1} \f$ (usually 0) \param alpha multiple of the data (usually 1) \param val array of elements in the matrix \param ind array of indices representing the location of the elements \param nnz length of the previous two arrays For example, the matrix \image html img208.gif can be inserted into the cone in packed symmetric format in several ways. Using the ordering of the packed symmetric format, we can index each element of the matrix with an integer between 0 and n(n+1)/2-1 (inclusive). If the first element in the \c val array is \f$a_{1,1}\f$, the first element in the \c ind array should be 0 . If the second element in the \c val array is \f$a_{2,1}\f$, then the second element in \c ind array should be 1 (the second element in dense representation). If the third element in the \c val array is \f$a_{3,2}\f$, then the third element in \c ind array should be 4. Explicitly, \code double val1[]={3,2,6}; int ind1[]={0,1,4}; SDPConeSetASparseVecMat(sdpcone,j,i,3,1.0,0,ind1,val1,3); \endcode If we index the elements from 1 through n(n+1)/2, we can use \code double val2[]={3,2,6}; int ind2[]={1,2,5}; SDPConeSetASparseVecMat(sdpcone,j,i,3,1.0,1,ind2,val2,3); \endcode The ordering of the elements in the array can be changed and zero elements can be included. \code double val3[]={6,3,0,2}; int ind3[]={4,0,2,1}; SDPConeSetASparseVecMat(sdpcone,j,i,3,1.0,0,ind3,val3,4); \endcode The elements can also be scaled. \code double val1[]={6,4,12}; int ind1[]={0,1,4}; SDPConeSetASparseVecMat(sdpcone,j,i,3,0.5,0,ind1,val1,3); \endcode \note DSDP will use the two arrays throughout in many routines, but it will not modify or delete them until finished with DSDP. \sa DSDPCreateSDPCone() \sa DSDPSetDualObjective() \sa SDPConeViewDataMatrix() */ int SDPConeSetASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha,int ishift, const int ind[], const double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddASparseVecMat(sdpcone,blockj,vari,n,alpha,ishift,ind,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetSparseVecMat" /* Needed for backward compatibility */ int SDPConeSetSparseVecMat(SDPCone sdpcone,int blockj, int vari, int n, int ishift,const int ind[], const double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeSetASparseVecMat(sdpcone,blockj,vari,n,1.0,ishift,ind,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddADenseVecMat" /*! \fn int SDPConeAddADenseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, double val[], int nnz); \brief Add a matrix \f$A_{i,j}\f$ in a dense format. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param alpha multiple of data (usually 1.0) \param val array of elements in the matrix \param nnz length of the previous two arrays \note DSDP will use the \c val array in many routines, but it will not modify or delete it until finished with DSDP. The matrix \image html img208.gif can be inserted into the cone in symmetric packed format as follows \code double val[]={3,2,0,0,6,0}; SDPConeAddADenseVecMat(sdpcone,j,i,3,1.0,val,6); \endcode \sa SDPConeViewDataMatrix() \sa SDPConeSetASparseVecMat() \sa SDPConeSetADenseVecMat() */ int SDPConeAddADenseVecMat(SDPCone sdpcone,int blockj, int vari,int n, double alpha,double val[], int nnz){ int info; char UPLQ; void* dmat=0; struct DSDPDataMat_Ops* dmatops=0; DSDPFunctionBegin; info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); DSDPLogInfo(0,20,"Set dense matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz); switch (UPLQ){ case 'P': info=DSDPGetDMat(n,alpha,val,&dmatops,&dmat); DSDPCHKERR(info); break; case 'U': DSDPSETERR(1,"Dense U Mat type does not exist.\n"); break; } info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddDenseVecMat" /* Needed for backward compatibility */ int SDPConeAddDenseVecMat(SDPCone sdpcone,int blockj, int vari,int n, double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeAddADenseVecMat(sdpcone,blockj,vari,n,1.0,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetADenseVecMat" /*! \fn int SDPConeSetADenseVecMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, double val[], int nnz); \brief Set a matrix \f$A_{i,j}\f$ in a dense format. \ingroup SDPBasic \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param alpha multiple of the data (usually 1.0) \param val array of elements in the matrix \param nnz length of the array For example, the matrix \image html img208.gif can be inserted into the cone in packed symmetric format as follows \code double val[]={3,2,0,0,6,0}; SDPConeSetDenseAVecMat(sdpcone,j,i,3,1.0,val,6); \endcode \note DSDP will use the \c val array in many routines, but it will not modify or delete it. \sa SDPConeViewDataMatrix() \sa SDPConeSetASparseVecMat() */ int SDPConeSetADenseVecMat(SDPCone sdpcone,int blockj, int vari,int n, double alpha,double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddADenseVecMat(sdpcone,blockj,vari,n,alpha,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetDenseVecMat" /* Needed for backward compatibility */ int SDPConeSetDenseVecMat(SDPCone sdpcone,int blockj, int vari,int n, double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeSetADenseVecMat(sdpcone,blockj,vari,n,1.0,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddIdentity" /*! \fn int SDPConeAddIdentity(SDPCone sdpcone,int blockj, int vari, int n, double val); \brief Add a matrix \f$A_{i,j}\f$ that is a multiple of the identity matrix. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param val multiple of identity matrix \sa SDPConeAddASparseVecMat() */ int SDPConeAddIdentity(SDPCone sdpcone, int blockj,int vari, int n, double val){ int info; char UPLQ; struct DSDPDataMat_Ops* identitymatops=0; void* imat=0; DSDPFunctionBegin; DSDPLogInfo(0,20,"Set identity matrix: Block: %d, Variable %d, size: %d, Multiple: %4.4e .\n",blockj,vari,n,val); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); switch (UPLQ){ case 'P': info=DSDPGetIdentityDataMatP(n,val,&identitymatops,&imat);DSDPCHKERR(info); break; case 'U': info=DSDPGetIdentityDataMatF(n,val,&identitymatops,&imat);DSDPCHKERR(info); break; } info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,identitymatops,imat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetIdentity" /*! \fn int SDPConeSetIdentity(SDPCone sdpcone,int blockj, int vari, int n, double val); \brief Set a matrix \f$A_{i,j}\f$ to be a multiple of the identity matrix. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param val multiple of identity matrix \sa SDPConeAddASparseVecMat() */ int SDPConeSetIdentity(SDPCone sdpcone, int blockj, int vari, int n, double val){ int info; DSDPFunctionBegin; info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddIdentity(sdpcone,blockj,vari,n,val); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddConstantMat" /*! \fn int SDPConeAddConstantMat(SDPCone sdpcone,int blockj, int vari, int n, double value); \brief Add a matrix \f$A_{i,j}\f$ whose elements are all the same. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param value the value of each element in the matrix \sa SDPConeAddADenseVecMat() */ int SDPConeAddConstantMat(SDPCone sdpcone,int blockj, int vari, int n, double value){ int info; char UPLQ; struct DSDPDataMat_Ops* constantmatops=0; void* smat=0; DSDPFunctionBegin; DSDPLogInfo(0,20,"Add allsame matrix: Block: %d, Variable %d, size: %d, Elements: %4.4e .\n",blockj,vari,n,value); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); switch (UPLQ){ case 'P': info=DSDPGetConstantMat(n,value,UPLQ,&constantmatops,&smat);DSDPCHKERR(info); break; case 'U': info=DSDPGetConstantMat(n,value,UPLQ,&constantmatops,&smat);DSDPCHKERR(info); break; } info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,constantmatops,smat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetConstantMat" /*! \fn int SDPConeSetConstantMat(SDPCone sdpcone,int blockj, int vari, int n, double value); \brief Set a matrix \f$A_{i,j}\f$ whose elements are all the same. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param value the value of each element in the matrix \sa SDPConeSetADenseVecMat() */ int SDPConeSetConstantMat(SDPCone sdpcone,int blockj, int vari, int n, double value){ int info; DSDPFunctionBegin; info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddConstantMat(sdpcone,blockj,vari,n,value); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetZeroMat" /*! \fn int SDPConeSetZeroMat(SDPCone sdpcone,int blockj, int vari, int n); \brief Set a matrix \f$A_{i,j}\f$ whose elements are all equal zero. \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \sa SDPConeSetASparseVecMat() \sa SDPConeSetConstantMat() */ int SDPConeSetZeroMat(SDPCone sdpcone,int blockj, int vari, int n){ int info; char UPLQ; struct DSDPDataMat_Ops* zeromatops=0; DSDPFunctionBegin; DSDPLogInfo(0,20,"Add zero matrix: Block: %d, Variable %d, size: %d .\n",blockj,vari,n); info=DSDPGetZeroDataMatOps(&zeromatops); DSDPCHKERR(info); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,zeromatops,0); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetRIdentity" /*! \fn int SDPConeSetRIdentity(SDPCone sdpcone,int blockj, int n, double rr); \brief Add identify matrix to dual matrix. \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param n dimension of the matrix \param rr multiple of identity matrix. */ int SDPConeSetRIdentity(SDPCone sdpcone,int blockj, int n, double rr){ int info; char UPLQ; struct DSDPDataMat_Ops* identitymatops=0; void* imat=0; DSDPFunctionBegin; info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); switch (UPLQ){ case 'P': info=DSDPGetIdentityDataMatP(n,rr,&identitymatops,&imat);DSDPCHKERR(info); break; case 'U': info=DSDPGetIdentityDataMatF(n,rr,&identitymatops,&imat);DSDPCHKERR(info); break; default: break; } info=SDPConeSetRMatrix(sdpcone,blockj,n,UPLQ,identitymatops,imat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddARankOneMat" /*! \fn int SDPConeAddARankOneMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift, const int ind[], const double val[], int nnz); \brief Add data matrix \f$A_{i,j}= alpha * v * v^T \f$ where v is a sparse vector \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param alpha multiple of the outer product \param ishift index of first element in a dense vector (usually 0) \param val array of elements in the vector \param ind array of indices representing the location of the nonzeros \param nnz length of the previous two arrays \note DSDP will use the two arrays throughout in many routines, but it will not modify or delete them. \sa DSDPCreateSDPCone() \sa SDPConeViewDataMatrix() \sa SDPConeAddASparseVecMat() */ int SDPConeAddARankOneMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift,const int ind[], const double val[], int nnz){ int info; char UPLQ; void* dmat=0; struct DSDPDataMat_Ops* dmatops=0; DSDPFunctionBegin; info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info); DSDPLogInfo(0,20,"Set sparse matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz); switch (UPLQ){ case 'P': info=DSDPGetR1PMat(n,alpha,ishift,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info); break; case 'U': info=DSDPGetR1UMat(n,alpha,ishift,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info); break; } info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetARankOneMat" /*! \fn int SDPConeSetARankOneMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift, const int ind[], const double val[], int nnz); \brief Set data matrix \f$A_{i,j}= alpha * v * v^T \f$ where v is a sparse vector \ingroup SDPData \param sdpcone SDP cone \param blockj block number j from 0 to nblocks \param vari variable i from 0 through m \param n dimension of the matrix \param alpha multiple of the outer product \param ishift index of first element in a dense vector (usually 0) \param val array of elements in the vector \param ind array of indices representing the location of the nonzeros \param nnz length of the previous two arrays \note DSDP will use the two arrays throughout in many routines, but it will not modify or delete them. \sa SDPConeViewDataMatrix() \sa SDPConeAddARankOneMat() */ int SDPConeSetARankOneMat(SDPCone sdpcone,int blockj, int vari, int n, double alpha, int ishift,const int ind[], const double val[], int nnz){ int info; DSDPFunctionBegin; info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info); info=SDPConeAddARankOneMat(sdpcone,blockj,vari,n,alpha,ishift,ind,val,nnz); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetDataMatZero" /*! \fn int DSDPSetDataMatZero(DSDPDataMat *A); \brief Make a data matrix a zero matrix. \param A data matrix. */ int DSDPSetDataMatZero(DSDPDataMat *A){ int info; struct DSDPDataMat_Ops* zeromatops=0; DSDPFunctionBegin; info=DSDPGetZeroDataMatOps(&zeromatops); DSDPCHKERR(info); info=DSDPDataMatSetData(A,zeromatops,0);DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpblock.c0000644000175000017500000004040110326241002015454 0ustar twernertwerner#include "dsdpsdp.h" #include "dsdpsys.h" static int sdpvecvecevent=0,sdpdotevent=0; /*! \file dsdpblock.c \brief Operations on a single SDP block. */ #undef __FUNCT__ #define __FUNCT__ "DSDPBlockASum" /*! \fn int DSDPBlockASum(DSDPBlockData *ADATA, double aa, DSDPVec Yk, DSDPVMat XX){ \brief Sum the data matrices. \param ADATA block of data. \param aa scalar \param Yk scalar. \param XX equals aa * sum ( YK[i]* A[i] ) */ int DSDPBlockASum(DSDPBlockData *ADATA, double aa, DSDPVec Yk, DSDPVMat XX){ double *xx,ytmp,scl=ADATA->scl; int ii,vari,n,nn,info; DSDPFunctionBegin; info=DSDPVMatGetSize(XX, &n); DSDPCHKERR(info); info=DSDPVMatGetArray(XX, &xx, &nn); DSDPCHKERR(info); for (ii=0;iinnzmats;ii++){ vari=ADATA->nzmat[ii]; info=DSDPVecGetElement(Yk,vari,&ytmp);DSDPCHKVARERR(vari,info); if (ytmp==0) continue; info = DSDPDataMatAddMultiple(ADATA->A[ii], -aa*scl*ytmp, xx,nn,n); DSDPCHKVARERR(vari,info); } info=DSDPVMatRestoreArray(XX, &xx, &nn); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockADot" /*! \fn int DSDPBlockADot(DSDPBlockData *ADATA, double aa, DSDPVec Alpha, DSDPVMat X, DSDPVec AX){ \brief Compute inner product of XX with data matrices. \param ADATA block of data. \param aa scalar \param Alpha scalar. \param X Dense symmetric matrix \param AX Set AX[i] to aa * Alpha[i] * Dot( A[i] * X) */ int DSDPBlockADot(DSDPBlockData *ADATA, double aa, DSDPVec Alpha, DSDPVMat X, DSDPVec AX){ int ii,vari,n,nn,info; double *x,sum=0,aalpha=0,scl=ADATA->scl; DSDPFunctionBegin; DSDPEventLogBegin(sdpdotevent); info=DSDPVMatScaleDiagonal(X,0.5); DSDPCHKERR(info); info=DSDPVMatGetSize(X, &n); DSDPCHKERR(info); info=DSDPVMatGetArray(X, &x, &nn); DSDPCHKERR(info); for (ii=0;iinnzmats; ii++){ /* Matrix Entries */ vari=ADATA->nzmat[ii]; info=DSDPVecGetElement(Alpha,vari,&aalpha);DSDPCHKVARERR(vari,info); if (aalpha==0.0) continue; info=DSDPDataMatDot(ADATA->A[ii],x,nn,n,&sum);DSDPCHKVARERR(vari,info); info=DSDPVecAddElement(AX,vari,aa*aalpha*sum*scl);DSDPCHKVARERR(vari,info); } info=DSDPVMatRestoreArray(X, &x, &nn); DSDPCHKERR(info); info=DSDPVMatScaleDiagonal(X,2.0); DSDPCHKERR(info); DSDPEventLogEnd(sdpdotevent); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockvAv" /*! \fn int int DSDPBlockvAv(DSDPBlockData *ADATA, double aa, DSDPVec Alpha, SDPConeVec V, DSDPVec VAV){ \brief Set VAV[i] to aa * Alpha[i] * V' A[i] V \param ADATA block of data. \param aa scalar \param Alpha scalar. \param V vecotr \param VAV the product */ int DSDPBlockvAv(DSDPBlockData *ADATA, double aa, DSDPVec Alpha, SDPConeVec V, DSDPVec VAV){ int ii,vari,info; double sum=0,aalpha=0,scl=ADATA->scl; DSDPFunctionBegin; DSDPEventLogBegin(sdpvecvecevent); if (aa==0){DSDPFunctionReturn(0);} for (ii=0;iinnzmats; ii++){ /* Matrix Entries */ vari=ADATA->nzmat[ii]; info=DSDPVecGetElement(Alpha,vari,&aalpha);DSDPCHKVARERR(vari,info); if (aalpha==0.0) continue; info=DSDPDataMatVecVec(ADATA->A[ii],V,&sum);DSDPCHKVARERR(vari,info); info=DSDPVecAddElement(VAV,vari,aa*aalpha*sum*scl);DSDPCHKVARERR(vari,info); } DSDPEventLogEnd(sdpvecvecevent); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockFactorData" /*! \fn int DSDPBlockFactorData(DSDPBlockData *ADATA, DSDPVMat X, SDPConeVec W){ \brief Factor the data matrices \param ADATA block of data. \param X work array \param W Work vector */ int DSDPBlockFactorData(DSDPBlockData *ADATA, DSDPVMat X, SDPConeVec W){ int ii,vari,n,nn,info,*iwork3n,i13,n26; double *x,*dwork3n; DSDPDataMat AA; DSDPFunctionBegin; info=DSDPVMatGetSize(X, &n); DSDPCHKERR(info); i13=13*n+1;n26=26*n+1; DSDPCALLOC2(&dwork3n,double,n26,&info);DSDPCHKERR(info); DSDPCALLOC2(&iwork3n,int,i13,&info);DSDPCHKERR(info); info=DSDPVMatGetArray(X, &x, &nn); DSDPCHKERR(info); for (ii=0;iinnzmats; ii++){ /* Matrix Entries */ info=DSDPBlockGetMatrix(ADATA,ii,&vari,0,&AA);DSDPCHKVARERR(vari,info); DSDPLogInfo(0,39,"SDP Data Mat Setup: %d\n",vari); if (vari==0) continue; info=DSDPDataMatFactor(AA,W,x,nn,dwork3n,n26,iwork3n,i13); DSDPCHKVARERR(vari,info); } info=DSDPVMatRestoreArray(X, &x, &nn); DSDPCHKERR(info); DSDPFREE(&dwork3n,&info);DSDPCHKERR(info); DSDPFREE(&iwork3n,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockEventZero" int DSDPBlockEventZero(void){ DSDPFunctionBegin; sdpvecvecevent=0;sdpdotevent=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockEventInitialize" int DSDPBlockEventInitialize(void){ DSDPFunctionBegin; if (sdpvecvecevent==0){DSDPEventLogRegister("SDP VecMatVec",&sdpvecvecevent);} if (sdpdotevent==0){DSDPEventLogRegister("SDP Dot",&sdpdotevent);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataInitialize" /*! \fn int DSDPBlockDataInitialize(DSDPBlockData *ADATA){ \brief Set pointers to null. \param ADATA block of data. */ int DSDPBlockDataInitialize(DSDPBlockData *ADATA){ DSDPFunctionBegin; ADATA->nnzmats=0; ADATA->maxnnzmats=0; ADATA->nzmat=0; ADATA->A=0; ADATA->r=1.0; ADATA->scl=1.0; /* ADATA->n=0; */ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockTakeDownData" /*! \fn int DSDPBlockTakeDownData(DSDPBlockData *ADATA){ \brief Free structures in block of data. \param ADATA block of data. */ int DSDPBlockTakeDownData(DSDPBlockData *ADATA){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataDestroy" /*! \fn int DSDPBlockDataDestroy(DSDPBlockData *ADATA); \brief Free the data matrices \param ADATA block of data. */ int DSDPBlockDataDestroy(DSDPBlockData *ADATA){ int ii,vari,info; DSDPFunctionBegin; if (!ADATA){DSDPFunctionReturn(0);} DSDPLogInfo(0,18,"Destroying All Existing Data Matrices \n"); for (ii=0; iinnzmats; ii++){ vari=ADATA->nzmat[ii]; info = DSDPDataMatDestroy(&ADATA->A[ii]);DSDPCHKVARERR(vari,info); ADATA->nzmat[ii]=0; } ADATA->nnzmats=0; info=DSDPBlockTakeDownData(ADATA);DSDPCHKERR(info); DSDPFREE(&ADATA->nzmat,&info);DSDPCHKERR(info); DSDPFREE(&ADATA->A,&info);DSDPCHKERR(info); info=DSDPBlockDataInitialize(ADATA);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataAllocate" /*! \fn int DSDPBlockDataAllocate(DSDPBlockData *ADATA, int nnz); \brief Allocate some structures. \param ADATA block of data. \param nnz number of data matrices to allocate space */ int DSDPBlockDataAllocate(DSDPBlockData *ADATA, int nnz){ int j,info,*nzmat; DSDPDataMat *A; DSDPFunctionBegin; if (!ADATA){DSDPFunctionReturn(0);} if (nnz<=ADATA->maxnnzmats){DSDPFunctionReturn(0);} DSDPLogInfo(0,18,"REALLOCATING SPACE FOR %d SDP BLOCK MATRICES! Previously allocated: %d \n",nnz,ADATA->maxnnzmats); DSDPCALLOC2(&A,struct DSDPDataMat_C,nnz,&info);DSDPCHKERR(info); DSDPCALLOC2(&nzmat,int,nnz,&info);DSDPCHKERR(info); for (j=0;jmaxnnzmats>0){ for (j=0;jnnzmats;j++){nzmat[j]=ADATA->nzmat[j];} for (j=0;jnnzmats;j++){A[j]=ADATA->A[j];} DSDPFREE(&ADATA->A,&info);DSDPCHKERR(info); DSDPFREE(&ADATA->nzmat,&info);DSDPCHKERR(info); } else { ADATA->nnzmats=0; } ADATA->maxnnzmats=nnz; ADATA->nzmat=nzmat; ADATA->A=A; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataMarkNonzeroMatrices" /*! \fn int DSDPBlockDataMarkNonzeroMatrices(DSDPBlockData *ADATA, int *annz){ \brief Mark which variable in block have a data matrix. \param ADATA block of data. \param annz array of integers to mark. */ int DSDPBlockDataMarkNonzeroMatrices(DSDPBlockData *ADATA,int*annz){ int i; DSDPFunctionBegin; for (i=0; innzmats; i++){ annz[ADATA->nzmat[i]]++; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockCountNonzerosMatrices" /*! \fn int DSDPBlockCountNonzeroMatrices(DSDPBlockData *ADATA,int*nzmats); \brief Count how many data matrices are in a block of data. \param ADATA block of data. \param nzmats set to number of nonzero matrices. Numbers from 0 to this number can be used as a matrix id in DSDPBlockGetMatrix() */ int DSDPBlockCountNonzeroMatrices(DSDPBlockData *ADATA,int*nzmats){ DSDPFunctionBegin; *nzmats=ADATA->nnzmats; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataRank" int DSDPBlockDataRank(DSDPBlockData *ADATA, int *trank, int n){ int ii,vari,info,ri,r2=0; DSDPDataMat AA; DSDPFunctionBegin; for (ii=0;iinnzmats;ii++){ info=DSDPBlockGetMatrix(ADATA,ii,&vari,0,&AA);DSDPCHKVARERR(vari,info); if (vari==0) continue; info=DSDPDataMatGetRank(AA,&ri,n); DSDPCHKVARERR(vari,info); r2+=ri; } *trank=r2; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockGetMatrix" /*! \fn int DSDPBlockGetMatrix(DSDPBlockData *ADATA,int id, int *vari, double *scl, DSDPDataMat *A); \brief Get a data matrix from a block of data. \param ADATA block of data. \param id identfier of the matrices, numbered consecutively from 0. \param vari set to variable number corresponding to A. \param scl scaling \param A data matrix. */ int DSDPBlockGetMatrix(DSDPBlockData *ADATA,int id, int *vari, double *scl, DSDPDataMat *A){ DSDPFunctionBegin; if (id>=0 && id < ADATA->nnzmats){ if (vari) *vari=ADATA->nzmat[id]; if (scl) *scl=ADATA->scl; if (A) *A=ADATA->A[id]; } else { DSDPSETERR2(2,"Invalid Matrix request. 0 <= %d < %d\n",id,ADATA->nnzmats); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockDataRowSparsity" /*! \fn int DSDPBlockDataRowSparsity(DSDPBlockData *ADATA,int row, int ai[], int rnnz[],int n); \brief Determine sparsity pattern of data. \param ADATA block of data. \param row from 0 to n. \param ai (input) array of ones and zeros that identify which data matrices to check. \param rnnz (output) array of length m where nonzeros indicate nonzero data. \param n dimension of block. */ int DSDPBlockDataRowSparsity(DSDPBlockData *ADATA,int row, int ai[], int rnnz[],int n){ int info,i,vari,rn; DSDPFunctionBegin; if (ai){ for (i=0; innzmats; i++){ vari=ADATA->nzmat[i]; if (ai[vari]==0){continue;} info=DSDPDataMatGetRowNonzeros(ADATA->A[i],row, n, rnnz, &rn); DSDPCHKVARERR(vari,info); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockRemoveDataMatrix" /*! \fn int DSDPBlockRemoveDataMatrix(DSDPBlockData *ADATA, int vari); \brief Remove a data matrix. \param ADATA block of data. \param vari variable corresponding the matrix. */ int DSDPBlockRemoveDataMatrix(DSDPBlockData *ADATA,int vari){ int info,ii,k; DSDPFunctionBegin; for (ii=0;iinnzmats;ii++){ if (ADATA->nzmat[ii]==vari){ info=DSDPDataMatDestroy(&ADATA->A[ii]);DSDPCHKVARERR(vari,info); info=DSDPSetDataMatZero(&ADATA->A[ii]);DSDPCHKVARERR(vari,info); for (k=ii;knnzmats;k++){ ADATA->A[k]=ADATA->A[k+1]; ADATA->nzmat[k]=ADATA->nzmat[k+1]; } ADATA->nnzmats--; info=DSDPSetDataMatZero(&ADATA->A[ADATA->nnzmats]);DSDPCHKERR(info); DSDPFunctionReturn(0); } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockAddDataMatrix" /*! \fn int DSDPBlockAddDataMatrix(DSDPBlockData *ADATA,int vari, struct DSDPDataMat_Ops* dsdpdataops, void* data){ \brief Add data matrix into SDP block \param ADATA block of data. \param vari the variable to which the matrix corresponds. \param dsdpdataops function pointers \param data opaque pointer to matrix. */ int DSDPBlockAddDataMatrix(DSDPBlockData *ADATA,int vari, struct DSDPDataMat_Ops* dsdpdataops, void* data){ int info,ii; DSDPFunctionBegin; if (ADATA->nnzmats>=ADATA->maxnnzmats){ info=DSDPBlockDataAllocate(ADATA,2*ADATA->maxnnzmats+7);DSDPCHKERR(info); } ii=ADATA->nnzmats; info=DSDPDataMatDestroy(&ADATA->A[ii]);DSDPCHKERR(info); info=DSDPDataMatSetData(&ADATA->A[ii], dsdpdataops, data);DSDPCHKVARERR(vari,info); ADATA->nzmat[ii]=vari; ADATA->nnzmats++; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockSetDataMatrix" /*! \fn int DSDPBlockSetDataMatrix(DSDPBlockData *ADATA,int vari, struct DSDPDataMat_Ops* dsdpdataops, void* data){ \brief Set data matrix into SDP block \param ADATA block of data. \param vari the variable to which the matrix corresponds. \param dsdpdataops function pointers \param data opaque pointer to matrix. */ int DSDPBlockSetDataMatrix(DSDPBlockData *ADATA,int vari, struct DSDPDataMat_Ops* dsdpdataops, void* data){ int info; DSDPFunctionBegin; info=DSDPBlockRemoveDataMatrix(ADATA,vari);DSDPCHKERR(info); info=DSDPBlockAddDataMatrix(ADATA,vari,dsdpdataops,data);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockNorm2" int DSDPBlockNorm2(DSDPBlockData *ADATA, int n){ double fn2,tt=0; int ii,info; DSDPFunctionBegin; for (ii=0;iinnzmats;ii++){ info=DSDPDataMatFNorm2(ADATA->A[ii],n,&fn2); DSDPCHKERR(info); tt+=fn2; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockANorm2" int DSDPBlockANorm2(DSDPBlockData *ADATA, DSDPVec ANorm2, int n){ double fn2,scl=ADATA->scl; int ii,vari,info; DSDPFunctionBegin; info=DSDPBlockNorm2(ADATA,n);DSDPCHKERR(info); scl=ADATA->scl; for (ii=0;iinnzmats;ii++){ vari=ADATA->nzmat[ii]; info=DSDPDataMatFNorm2(ADATA->A[ii],n,&fn2); DSDPCHKVARERR(vari,info); info=DSDPVecAddElement(ANorm2,vari,fn2*scl);DSDPCHKVARERR(vari,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockView" /*! \fn int DSDPBlockView(DSDPBlockData *ADATA); \brief Print the structure of the block. \param ADATA block of data. */ int DSDPBlockView(DSDPBlockData *ADATA){ int ii,kk; DSDPFunctionBegin; for (ii=0;iinnzmats;ii++){ kk=ADATA->nzmat[ii]; if (kk==0){ printf("+ C\n");} else { printf(" - A[%d] y%d\n",kk,kk);} } printf(" = S >= 0\n"); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockView2" /*! \fn int DSDPBlockView2(DSDPBlockData *ADATA); \brief Print the data \param ADATA block of data. */ int DSDPBlockView2(DSDPBlockData *ADATA){ int ii,vari,info; DSDPFunctionBegin; for (ii=0;iinnzmats;ii++){ vari=ADATA->nzmat[ii]; printf("A[%d] y%d \n",vari,vari); info=DSDPDataMatView(ADATA->A[ii]); DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatCheck" /*! \fn int DSDPDataMatCheck(DSDPDataMat AA, SDPConeVec W, DSDPIndex IS, DSDPVMat XX); \brief Check correctness of operations on the data. \param AA data matrix. \param W work vector \param IS work array \param XX work array */ int DSDPDataMatCheck(DSDPDataMat AA, SDPConeVec W, DSDPIndex IS, DSDPVMat XX){ double *xx,ack,vAv=0,esum=0,sum,eignorm,fnorm22,dnorm,scl=1; int k,n,nn,rank,info; DSDPFunctionBegin; info=SDPConeVecGetSize(W,&n);DSDPCHKERR(info); info=DSDPVMatZeroEntries(XX);DSDPCHKERR(info); info=DSDPDataMatGetRank(AA,&rank,n);DSDPCHKERR(info); for (k=0; k1) printf("Check Add or eigs\n"); if (fabs(esum-vAv) > 1.0) printf("Check vAv \n"); if (fabs(fnorm22-vAv) > 1.0) printf("Check fnorm22\n"); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpdatamat.c0000644000175000017500000003021410326241002015776 0ustar twernertwerner#include "dsdpdatamat_impl.h" #include "dsdpdatamat.h" #include "dsdpsys.h" /*! \file dsdpdatamat.c \brief Call an implementation of the data matrix operations. */ #define DSDPNoOperationError(a); { DSDPSETERR1(1,"Data natrix type: %s, Operation not defined\n",(a).dsdpops->matname); } #define DSDPChkDataError(a,b); { if (b){ DSDPSETERR1(b,"Data natrix type: %s,\n",(a).dsdpops->matname);} } static struct DSDPDataMat_Ops dsdpdatamatdefault; #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatSetData" /*! \fn int DSDPDataMatSetData(DSDPDataMat *A, struct DSDPDataMat_Ops* ops, void*data); \brief Set the opaque pointer and function pointers to the matrix. \param A symmetric data matrix \param ops pointer to a structure of function pointers \param data pointer to a matrix structure */ int DSDPDataMatSetData(DSDPDataMat *A, struct DSDPDataMat_Ops* ops, void*data){ int info; DSDPFunctionBegin; (*A).dsdpops=ops; (*A).matdata=data; if (ops==NULL){ (*A).dsdpops=&dsdpdatamatdefault; } info = DSDPDataMatOpsInitialize(&dsdpdatamatdefault); DSDPCHKERR(info); info=DSDPDataMatTest(*A);DSDPCHKERR(info); DSDPFunctionReturn(0); } static char datamatnoname[20]="MATRIX NOT SET"; #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatOpsInitialize" /*! \fn int DSDPDataMatOpsInitialize(struct DSDPDataMat_Ops* dops); \brief Initialize the table of function pointers for SDP Data matrices. \param dops pointer to a structure of function pointers. */ int DSDPDataMatOpsInitialize(struct DSDPDataMat_Ops* dops){ DSDPFunctionBegin; if (dops==NULL) return 0; dops->matfactor1=0; dops->matfactor2=0; dops->matgetrank=0; dops->matgeteig=0; dops->matvecvec=0; dops->matdot=0; dops->mataddrowmultiple=0; dops->mataddallmultiple=0; dops->matdestroy=0; dops->matview=0; dops->matrownz=0; dops->matnnz=0; dops->matfnorm2=0; dops->id=0; dops->matname=datamatnoname; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatInitialize" /*! \fn int DSDPDataMatInitialize(DSDPDataMat *A); \brief Set pointers to NULL; \param A symmetric data matrix */ int DSDPDataMatInitialize(DSDPDataMat *A){ int info; DSDPFunctionBegin; info = DSDPDataMatOpsInitialize(&dsdpdatamatdefault); DSDPCHKERR(info); info = DSDPDataMatSetData(A, &dsdpdatamatdefault,0); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatTest" /*! \fn int DSDPDataMatTest(DSDPDataMat A); \brief Test validity of matrix \param A symmetric data matrix */ int DSDPDataMatTest(DSDPDataMat A){ int info; DSDPFunctionBegin; if (A.dsdpops==0 || A.dsdpops==&dsdpdatamatdefault){ } else if (A.dsdpops->mattest){ info=(A.dsdpops->mattest)(A.matdata); DSDPChkDataError(A,info); } else { /* DSDPNoOperationError(A); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatGetType" int DSDPDataMatGetType(DSDPDataMat A, int *id){ DSDPFunctionBegin; *id=A.dsdpops->id; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatGetRank" /*! \fn int DSDPDataMatGetRank(DSDPDataMat A, int *rank, int n); \brief Get the number of nonzero eigenvalues/eigenvectors for the matrix \param A symmetric data matrix \param rank number of nonzero eigenvalues and vectors. \param n rows and columns in matrix. */ int DSDPDataMatGetRank(DSDPDataMat A, int *rank, int n){ int info; DSDPFunctionBegin; if (A.dsdpops->matgetrank){ info=(A.dsdpops->matgetrank)(A.matdata,rank,n); DSDPChkDataError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatCountNonzeros" /*! \fn int DSDPDataMatCountNonzeros(DSDPDataMat A, int *nnz, int n); \brief Compute the square of the Frobenius norm \param A symmetric data matrix. \param n dimension of the matrix. \param *nnz nonzeros in matrix. Used to identify which of a few strategies to compute Hessian. */ int DSDPDataMatCountNonzeros(DSDPDataMat A, int *nnz, int n){ int info; DSDPFunctionBegin; if (A.dsdpops->matnnz){ info=(A.dsdpops->matnnz)(A.matdata,nnz,n); DSDPChkDataError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatFNorm2" /*! \fn int DSDPDataMatFNorm2(DSDPDataMat A, int n, double *fnorm2); \brief Compute the square of the Frobenius norm \param A symmetric data matrix. \param n dimension of the matrix. \param fnorm2 square of norm. Used to scale the problem */ int DSDPDataMatFNorm2(DSDPDataMat A, int n, double *fnorm2){ int info; DSDPFunctionBegin; if (A.dsdpops->matfnorm2){ *fnorm2=0.0; info=(A.dsdpops->matfnorm2)(A.matdata,n,fnorm2); DSDPChkDataError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatGetEig" /*! \fn int DSDPDataMatGetEig(DSDPDataMat A, int rr, SDPConeVec V, DSDPIndex S, double *eigenvalue); \brief Get an eigenvalue/vector pair. \param A symmetric data matrix \param rr identifies which pair of eigs, (0 <= rr < rank) \param V Eigenvector \param S Indentifies sparsity pattern in V. \param eigenvalue the scalar associated with the vector. These pairs do not have to be eigenvalues and eigenvectors. What matters is that the matrix is a sum of the outer products of these vectors. That is, A = sum (rr * V *V') \sa DSDPDataMatGetRank() */ int DSDPDataMatGetEig(DSDPDataMat A, int rr, SDPConeVec V, DSDPIndex S, double *eigenvalue){ int info,n; double *vv; DSDPFunctionBegin; if (A.dsdpops->matgeteig){ info=SDPConeVecGetArray(V,&vv); DSDPCHKERR(info); info=SDPConeVecGetSize(V,&n); DSDPCHKERR(info); info=(A.dsdpops->matgeteig)(A.matdata,rr, eigenvalue, vv,n,S.indx+1,S.indx); DSDPChkDataError(A,info); info=SDPConeVecRestoreArray(V,&vv); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatFactor" /*! \fn int DSDPDataMatFactor(DSDPDataMat A, SDPConeVec W, double*dworknn, int nn0, double *dwork3n, int nd, int* iwork, int ni){ \brief Do eigenvalue/vector or other factorization. \param A symmetric data matrix \param W work vector \param dworknn work array \param nn0 length of dworknn array. \param dwork3n work array \param nd length of work array \param iwork work array \param ni length of iwork array This routine is called once during the DSDPSetUp routine. \sa DSDPDataMatGetRank() \sa DSDPDataMatGetEig() */ int DSDPDataMatFactor(DSDPDataMat A, SDPConeVec W, double*dworknn, int nn0, double *dwork3n, int nd, int* iwork, int ni){ int info,n; double *dvecwork; DSDPFunctionBegin; if (A.dsdpops->matfactor1){ info=(A.dsdpops->matfactor1)(A.matdata); DSDPChkDataError(A,info); } else if (A.dsdpops->matfactor2){ info=SDPConeVecGetSize(W,&n); info=SDPConeVecGetArray(W,&dvecwork); info=(A.dsdpops->matfactor2)(A.matdata,dworknn,nn0,dvecwork,n,dwork3n,nd,iwork,ni); DSDPChkDataError(A,info); info=SDPConeVecRestoreArray(W,&dvecwork); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatDot" /*! \fn int DSDPDataMatDot(DSDPDataMat A, double x[], int nn, int n, double *v); \brief Compute inner product of data with a dense matrix \param A symmetric data matrix \param x dense array matrix \param nn length of array \param n dimension of matrix. \param v the inner product \sa SDPConeSetStorageFormat() \sa DSDPVMatGetArray() */ int DSDPDataMatDot(DSDPDataMat A, double x[], int nn, int n, double *v){ int info; DSDPFunctionBegin; if (A.dsdpops->matdot){ info=(A.dsdpops->matdot)(A.matdata,x,nn,n,v); DSDPChkDataError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatVecVec" /*! \fn int DSDPDataMatVecVec(DSDPDataMat A, SDPConeVec W, double *v); \brief Compute w' A w \param A symmetric data matrix \param W vector \param v the inner product */ int DSDPDataMatVecVec(DSDPDataMat A, SDPConeVec W, double *v){ int info,n; double *x; DSDPFunctionBegin; if (A.dsdpops->matvecvec){ info=SDPConeVecGetSize(W,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(W,&x); DSDPCHKERR(info); info=(A.dsdpops->matvecvec)(A.matdata,x,n,v); DSDPChkDataError(A,info); info=SDPConeVecRestoreArray(W,&x); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatMultiply" /* \fn int DSDPDataMatMultiply(DSDPDataMat A, SDPConeVec V1, SDPConeVec V2); \brief Compute V2 = A*V1; \param A symmetric data matrix \param V1 in vector \param V2 the product Not needed. */ int DSDPDataMatMultiply(DSDPDataMat A, SDPConeVec V1, SDPConeVec V2){ int info,n; double *vv1,*vv2; DSDPFunctionBegin; if (A.dsdpops->matmultiply){ info=SDPConeVecGetSize(V1,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(V1,&vv1); DSDPCHKERR(info); info=SDPConeVecGetArray(V2,&vv2); DSDPCHKERR(info); info=(A.dsdpops->matmultiply)(A.matdata,vv1,vv2,n); DSDPChkDataError(A,info); info=SDPConeVecRestoreArray(V1,&vv1); DSDPCHKERR(info); info=SDPConeVecRestoreArray(V2,&vv2); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatGetRowNonzeros" /*! \fn int DSDPDataMatGetRowNonzeros(DSDPDataMat A, int nrow, int nmax, int *nz, int *nnz); \brief Get sparsity pattern of a row of the matrix. \param A symmetric data matrix. \param nrow number >=0 and < n. \param nmax dimension of the matrix. \param nz array used to mark nonzeros. \param nnz number of nonzeros in row. Used to create sparse data structure for S and Delta S. */ int DSDPDataMatGetRowNonzeros(DSDPDataMat A, int nrow, int nmax, int *nz, int *nnz){ int i,info; DSDPFunctionBegin; if (A.dsdpops->matrownz){ info=(A.dsdpops->matrownz)(A.matdata,nrow,nz,nnz,nmax); DSDPChkDataError(A,info); } else { *nnz=nmax; for (i=0;imataddrowmultiple){ info=SDPConeVecGetArray(R,&vv);DSDPCHKERR(info); info=SDPConeVecGetSize(R,&n);DSDPCHKERR(info); info=(A.dsdpops->mataddrowmultiple)(A.matdata,nrow,ytmp,vv,n); DSDPChkDataError(A,info); info=SDPConeVecRestoreArray(R,&vv);DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatAddMultiple" /*! \fn int DSDPDataMatAddMultiple(DSDPDataMat A, double ytmp, double *v, int nn, int n); \brief Add a multiple the data matrix to the array. \param A symmetric data matrix \param ytmp scalar multiple \param v dense array matrix \param nn dimension of array \param n dimension of matrix \sa SDPConeSetStorageFormat() \sa DSDPVMatGetArray() */ int DSDPDataMatAddMultiple(DSDPDataMat A, double ytmp, double *v, int nn, int n){ int info; DSDPFunctionBegin; if (A.dsdpops->mataddallmultiple){ info=(A.dsdpops->mataddallmultiple)(A.matdata,ytmp,v,nn,n); DSDPChkDataError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatView" /*! \fn int DSDPDataMatView(DSDPDataMat A); \brief Print matrix \param A symmetric data matrix */ int DSDPDataMatView(DSDPDataMat A){ int info; DSDPFunctionBegin; if (A.dsdpops->matview){ info=(A.dsdpops->matview)(A.matdata); DSDPChkDataError(A,info); } else { printf("No matrix view available for matrix type %s.\n",A.dsdpops->matname); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatDestroy" /*! \fn int DSDPDataMatDestroy(DSDPDataMat *A); \brief Free the data structures \param A symmetric data matrix */ int DSDPDataMatDestroy(DSDPDataMat* A){ int info; DSDPFunctionBegin; if ( (*A).dsdpops->matdestroy){ info=((*A).dsdpops->matdestroy)((*A).matdata); DSDPChkDataError(*A,info); } else { /* DSDPNoOperationError(*A); */ } info=DSDPDataMatInitialize(A); DSDPCHKERR(info); /* info=DSDPZeroMatCreate(0,A); DSDPCHKERR(info); */ DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpdatamat.h0000644000175000017500000000334610326241002016011 0ustar twernertwerner#if !defined(__DSDP_DATAMATRIXOPS_H) #define __DSDP_DATAMATRIXOPS_H #include "sdpconevec.h" /*! \file dsdpdatamat.h \brief The interface between the SDPCone and the data matrices */ /*! struct DSDPDataMat_C { void* matdata; struct DSDPDataMat_Ops* dsdpops; }; \brief Symmetric data matrix for one block in the semidefinite cone. \sa DSDPDataMat */ struct DSDPDataMat_C{ void* matdata; struct DSDPDataMat_Ops* dsdpops; }; /*! \typedef struct DSDPDataMat DSDPDataMat; \brief Represents a single symmetric data matrix for one block in this semidefinite cone. */ typedef struct DSDPDataMat_C DSDPDataMat; #ifdef __cplusplus extern "C" { #endif extern int DSDPDataMatSetData(DSDPDataMat*, struct DSDPDataMat_Ops*, void*); extern int DSDPDataMatInitialize(DSDPDataMat*); extern int DSDPDataMatGetType(DSDPDataMat, int *); extern int DSDPDataMatTest(DSDPDataMat); extern int DSDPDataMatVecVec(DSDPDataMat,SDPConeVec,double*); extern int DSDPDataMatDot(DSDPDataMat,double[], int,int,double*); extern int DSDPDataMatGetRowNonzeros(DSDPDataMat, int, int, int*, int*); extern int DSDPDataMatCountNonzeros(DSDPDataMat,int*,int); extern int DSDPDataMatFNorm2(DSDPDataMat,int,double*); extern int DSDPDataMatMultiply(DSDPDataMat,SDPConeVec,SDPConeVec); extern int DSDPDataMatView(DSDPDataMat); extern int DSDPDataMatDestroy(DSDPDataMat*); extern int DSDPDataMatGetRank(DSDPDataMat, int*,int); extern int DSDPDataMatGetEig(DSDPDataMat, int, SDPConeVec, DSDPIndex, double *); extern int DSDPDataMatFactor(DSDPDataMat,SDPConeVec, double[],int,double[],int,int[],int); extern int DSDPDataMatAddMultiple(DSDPDataMat, double, double[],int,int); extern int DSDPDataMatAddRowMultipleToVector(DSDPDataMat, int, double, SDPConeVec); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpdatamat_impl.h0000644000175000017500000000300410326241002017021 0ustar twernertwerner#if !defined(__DSDP_DATAMATRIX_H) #define __DSDP_DATAMATRIX_H /*! \file dsdpdatamat_impl.h \brief Structure of function pointers that each SDP data matrix type (sparse, dense, constant, identity, ...) must implement. */ /* DSDP Data Matrices have particular operations, and several implementations */ /*! struct DSDPDataMat_Ops \brief Table of function pointers that operate on the data matrix. */ struct DSDPDataMat_Ops{ int id; int (*mataddallmultiple)(void*,double,double[],int,int); int (*matdot)(void*, double[], int, int, double *); int (*matgetrank)(void*,int*,int); int (*matgeteig)(void*,int,double*,double[],int,int[],int*); int (*matvecvec)(void*, double[], int,double*); int (*mataddrowmultiple)(void*,int,double,double[],int); /* NEEDED? */ int (*matmultiply)(void*,double[],double[],int); int (*matfactor1)(void*); int (*matfactor2)(void*,double[],int,double[],int,double[],int,int[],int); int (*matfnorm2)(void*,int,double*); int (*matrownz)(void*,int,int[],int*,int); int (*matnnz)(void*,int*,int); int (*mattest)(void*); int (*matdestroy)(void*); int (*matview)(void*); const char *matname; }; #ifdef __cplusplus extern "C" { #endif extern int DSDPGetEigs(double[],int,double[],int,long int[],int, double[],int,double[],int,int[],int); extern int DSDPGetEigs2(double[],int,double[],int,long int[],int, double[],int,double[],int,int[],int); int DSDPDataMatOpsInitialize(struct DSDPDataMat_Ops*); #ifdef __cplusplus } #endif /* #include "dsdpdatamat.h" */ #endif DSDP5.8/src/sdp/dsdpdsmat.c0000644000175000017500000001503010326241002015472 0ustar twernertwerner#include "dsdpdsmat_impl.h" #include "dsdpdsmat.h" #include "dsdpsys.h" /*! \file dsdpdsmat.c \brief Call an implmentation of the Delta S matrix operation */ #define DSDPNoOperationError(a); { DSDPSETERR1(1,"Delta S Matrix type: %s, Operation not defined\n",(a).dsdpops->matname); } #define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Delta S Matrix type: %s,\n",(a).dsdpops->matname); } } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatGetType" int DSDPDSMatGetType(DSDPDSMat A, int *id){ DSDPFunctionBegin; *id=A.dsdpops->id; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatSetData" /*! \fn int DSDPDSMatSetData(DSDPDSMat *M, struct DSDPDSMat_Ops* ops, void*data); \brief Set the opaque pointer and function pointers to the matrix. \param M symmetric DS matrix \param ops pointer to a structure of function pointers \param data pointer to a matrix structure */ int DSDPDSMatSetData(DSDPDSMat *M, struct DSDPDSMat_Ops* ops, void*data){ int info; DSDPFunctionBegin; (*M).dsdpops=ops; (*M).matdata=data; info=DSDPDSMatTest(*M); DSDPChkMatError(*M,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatGetSize" /*! \fn int DSDPDSMatGetSize(DSDPDSMat A,int *n); \brief Set the opaque pointer and function pointers to the matrix. \param A symmetric DS matrix \param n dimension */ int DSDPDSMatGetSize(DSDPDSMat A,int*n){ int info; DSDPFunctionBegin; if (A.dsdpops->matgetsize){ info=(A.dsdpops->matgetsize)(A.matdata,n); DSDPChkMatError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatDestroy" /*! \fn int DSDPDSMatDestroy(DSDPDSMat *A); \brief Free the data structure. \param A symmetric DS matrix */ int DSDPDSMatDestroy(DSDPDSMat *A){ int info; DSDPFunctionBegin; if (!(*A).dsdpops){ return 0;} if ((*A).dsdpops->matdestroy){ info=((*A).dsdpops->matdestroy)((*A).matdata); DSDPChkMatError(*A,info); } else { /* DSDPNoOperationError(1); */ } info=DSDPDSMatInitialize(A); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatView" /*! \fn int DSDPDSMatView(DSDPDSMat A); \brief Print the matrix \param A symmetric DS matrix */ int DSDPDSMatView(DSDPDSMat A){ int info; if (A.dsdpops->matview){ info=(A.dsdpops->matview)(A.matdata); DSDPChkMatError(A,info); } else { printf("No viewer available for matrix type: %s",A.dsdpops->matname); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatZeroEntries" /*! \fn int DSDPDSMatZeroEntries(DSDPDSMat A); \brief Zero the entries in the matrix. \param A symmetric DS matrix */ int DSDPDSMatZeroEntries(DSDPDSMat A){ int info; DSDPFunctionBegin; if (A.dsdpops->matzeroentries){ info=(A.dsdpops->matzeroentries)(A.matdata); DSDPChkMatError(A,info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatSetArray" /*! \fn int DSDPDSMatSetArray(DSDPDSMat A, DSDPVMat T); \brief Set values into the matrix. \param A symmetric DS matrix \param T Source of entries in dense format \sa DSDPSetFormatType() */ int DSDPDSMatSetArray(DSDPDSMat A, DSDPVMat T){ int info,n,nn; double *ds; DSDPFunctionBegin; if (A.dsdpops->matseturmat){ info=DSDPVMatGetSize(T,&n);DSDPCHKERR(info); info=DSDPVMatGetArray(T, &ds, &nn); DSDPCHKERR(info); info=(A.dsdpops->matseturmat)(A.matdata,ds,nn,n); DSDPChkMatError(A,info); info=DSDPVMatRestoreArray(T, &ds, &nn); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatMult" /*! \fn int DSDPDSMatMult(DSDPDSMat A, SDPConeVec X, SDPConeVec Y); \brief Set values into the matrix. \param A symmetric DS matrix \param X in vector \param Y product of A and X */ int DSDPDSMatMult(DSDPDSMat A, SDPConeVec X, SDPConeVec Y){ int n,info; double *x,*y; DSDPFunctionBegin; if (A.dsdpops->matmult){ info=SDPConeVecGetArray(X,&x); DSDPCHKERR(info); info=SDPConeVecGetArray(Y,&y); DSDPCHKERR(info); info=SDPConeVecGetSize(Y,&n); DSDPCHKERR(info); info=(A.dsdpops->matmult)(A.matdata,x,y,n); DSDPChkMatError(A,info); info=SDPConeVecRestoreArray(X,&x); DSDPCHKERR(info); info=SDPConeVecRestoreArray(Y,&y); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSVecVec" /*! \fn int DSDPDSMatVecVec(DSDPDSMat A, SDPConeVec X, double *vAv); \brief Compute the product x' A x. \param A symmetric DS matrix \param X vector \param vAv the product */ int DSDPDSMatVecVec(DSDPDSMat A, SDPConeVec X, double *vAv){ int n,info; double *x; DSDPFunctionBegin; if (A.dsdpops->matvecvec){ info=SDPConeVecGetArray(X,&x); DSDPCHKERR(info); info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info); info=(A.dsdpops->matvecvec)(A.matdata,x,n,vAv); DSDPChkMatError(A,info); info=SDPConeVecRestoreArray(X,&x); DSDPCHKERR(info); } else { DSDPNoOperationError(A); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatCheck" int DSDPDSMatCheck(DSDPDSMat DS,SDPConeVec W1,SDPConeVec W2,DSDPVMat T){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static struct DSDPDSMat_Ops dsdpmatops2; static const char* dsmatname="NOT SET YET"; #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatOpsInitialize" /*! \fn int DSDPDSMatOpsInitialize(struct DSDPDSMat_Ops*aops); \brief Set pointers to null. \param aops pointer to table. */ int DSDPDSMatOpsInitialize(struct DSDPDSMat_Ops*aops){ aops->matseturmat=0; aops->matview=0; aops->matdestroy=0; aops->matgetsize=0; aops->matzeroentries=0; aops->matmult=0; aops->mattest=0; aops->matvecvec=0; aops->id=0; aops->matname=dsmatname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatTest" int DSDPDSMatTest(DSDPDSMat A){ int info; DSDPFunctionBegin; if (A.dsdpops==0 || A.dsdpops==&dsdpmatops2){ } else if (A.dsdpops->mattest){ DSDPLogInfo(0,120,"Start to set DS Matrix\n"); info=(A.dsdpops->mattest)(A.matdata); DSDPChkMatError(A,info); DSDPLogInfo(0,120,"Done set DS Matrix\n"); } else { /* DSDPNoOperationError(A); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDSMatInitialize" /*! \fn int DSDPDSMatInitialize(DSDPDSMat *B); \brief Set pointers to null. \param B pointer to matrix. */ int DSDPDSMatInitialize(DSDPDSMat *B){ int info; DSDPFunctionBegin; info=DSDPDSMatOpsInitialize(&dsdpmatops2); DSDPCHKERR(info); info=DSDPDSMatSetData(B, &dsdpmatops2, 0); DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpdsmat.h0000644000175000017500000000277710326241002015515 0ustar twernertwerner#if !defined(__DSDP_DSMATRIX_H) #define __DSDP_DSMATRIX_H #include "sdpconevec.h" #include "dsdpxmat.h" /*! \file dsdpdsmat.h \brief The interface between the SDPCone and the Delta S matrix */ /* DSDPDSMat objects are not used for much: DS, X, eigenvalue stuff */ /* These objects are good basically for assembling a matrix, accessing the data, and applying the operator to a vector */ /* DSDP Matrix Structure */ /*! struct DSDPDSMat_C { void* matdata; struct DSDPDSMat_Ops* dsdpops; }; \brief Symmetric Delta S matrix for one block in the semidefinite cone. \sa DSDPDSMat */ struct DSDPDSMat_C{ void *matdata; struct DSDPDSMat_Ops* dsdpops; }; /*! typedef struct DSDPDSMat_C DSDPDSMat; \brief A symmetric Delta S matrix for one block in the semidefinite cone. */ typedef struct DSDPDSMat_C DSDPDSMat; #ifdef __cplusplus extern "C" { #endif extern int DSDPDSMatGetType(DSDPDSMat, int *); extern int DSDPDSMatSetData(DSDPDSMat *, struct DSDPDSMat_Ops*, void*); extern int DSDPDSMatInitialize(DSDPDSMat*); extern int DSDPDSMatZeroEntries(DSDPDSMat); extern int DSDPDSMatSetArray(DSDPDSMat,DSDPVMat); extern int DSDPDSMatMult(DSDPDSMat, SDPConeVec, SDPConeVec); extern int DSDPDSMatVecVec(DSDPDSMat, SDPConeVec, double*); extern int DSDPDSMatTest(DSDPDSMat); extern int DSDPDSMatGetSize(DSDPDSMat,int*); extern int DSDPDSMatView(DSDPDSMat); extern int DSDPDSMatDestroy(DSDPDSMat*); extern int DSDPDSMatCheck(DSDPDSMat,SDPConeVec,SDPConeVec,DSDPVMat); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpdsmat_impl.h0000644000175000017500000000155210326241002016524 0ustar twernertwerner#if !defined(__DSDP_DSMATRIXOPS_H) #define __DSDP_DSMATRIXOPS_H /*! \file dsdpdsmat_impl.h \brief Structure of function pointers that each SDP Delta S matrix type (sparse, dense, diagonal, ...) must implement. */ /*! struct DSDPDSMat_Ops \brief Symmetric Delta S matrix for one block in the semidefinite cone. */ struct DSDPDSMat_Ops{ int id; int (*matzeroentries)(void*); int (*matmult)(void*,double[],double[], int); /* Multiply by a vector */ int (*matgetsize)(void*,int*); int (*matseturmat)(void*,double[],int,int); /* Set values from array */ int (*matvecvec)(void*,double[],int,double*); /* v' * DS * v */ int (*mattest)(void*); int (*matview)(void*); int (*matdestroy)(void*); const char *matname; }; #ifdef __cplusplus extern "C" { #endif extern int DSDPDSMatOpsInitialize(struct DSDPDSMat_Ops*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpdualmat.c0000644000175000017500000003235410326241002016021 0ustar twernertwerner#include "dsdpdualmat_impl.h" #include "dsdpdualmat.h" #include "dsdpsys.h" /*! \file dsdpdualmat.c \brief Call an implementation of the S matrix operations. */ #define DSDPNoOperationError(a); { DSDPSETERR1(1,"Dual natrix type: %s, Operation not defined\n",(a).dsdpops->matname);} #define DSDPChkDMatError(a,b); { if (b){ DSDPSETERR1(b,"Dual natrix type: %s,\n",(a).dsdpops->matname);} } static int sdpdualsolve=0,sdpdualinvert=0; #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatEventZero" int DSDPDualMatEventZero(void){ DSDPFunctionBegin; sdpdualinvert=0;sdpdualsolve=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatEventInitialize" int DSDPDualMatEventInitialize(void){ DSDPFunctionBegin; if (sdpdualsolve==0){DSDPEventLogRegister("SDP SSolve",&sdpdualsolve);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatGetType" int DSDPDualMatGetType(DSDPDualMat S, int *id){ DSDPFunctionBegin; *id=S.dsdpops->id; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatSetData" /*! \fn int DSDPDualMatSetData(DSDPDualMat *S, struct DSDPDualMat_Ops* ops, void*data); \brief Set the opaque pointer and function pointers to the matrix. \param S dual matrix \param ops pointer to a structure of function pointers \param data pointer to a matrix structure */ int DSDPDualMatSetData(DSDPDualMat *S, struct DSDPDualMat_Ops* ops, void*data){ int info; DSDPFunctionBegin; (*S).dsdpops=ops; (*S).matdata=data; info=DSDPDualMatTest(*S);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatDestroy" /*! \fn int DSDPDualMatDestroy(DSDPDualMat *S); \brief Free the matrix structure \param S dual matrix */ int DSDPDualMatDestroy(DSDPDualMat *S){ int info; DSDPFunctionBegin; if ( S && (*S).dsdpops && (*S).dsdpops->matdestroy){ info=((*S).dsdpops->matdestroy)((*S).matdata); DSDPChkDMatError(*S,info); } else { /* DSDPNoOperationError(*S); */ } info=DSDPDualMatSetData(S,0,0); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatGetSize" /*! \fn int DSDPDualMatGetSize(DSDPDualMat S, int *n); \brief Free the matrix structure \param S dual matrix \param n dimension */ int DSDPDualMatGetSize(DSDPDualMat S,int*n){ int info; DSDPFunctionBegin; if (S.dsdpops->matgetsize){ info=(S.dsdpops->matgetsize)(S.matdata,n); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatGetArray" int DSDPDualMatGetArray(DSDPDualMat S, double **v, int *n){ int info; DSDPFunctionBegin; if (S.dsdpops->matgetarray){ info=(S.dsdpops->matgetarray)(S.matdata,v,n); DSDPChkDMatError(S,info); } else { *v=0; *n=0; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatLogDeterminant" /*! \fn int DSDPDualMatLogDeterminant(DSDPDualMat S, double *logdet); \brief Free the matrix structure \param S dual matrix \param logdet logarithm of the determinant Assumes Cholesky factorization was successful. */ int DSDPDualMatLogDeterminant(DSDPDualMat S,double *logdet){ int info; DSDPFunctionBegin; if (S.dsdpops->matlogdet){ info=(S.dsdpops->matlogdet)(S.matdata,logdet); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatView" /*! \fn int DSDPDualMatView(DSDPDualMat S); \brief Print the matrix. \param S dual matrix */ int DSDPDualMatView(DSDPDualMat S){ int info; DSDPFunctionBegin; if (S.dsdpops->matview){ info=(S.dsdpops->matview)(S.matdata); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatSetArray" /*! \fn int DSDPDualMatSetArray(DSDPDualMat S, DSDPVMat T); \brief Print the matrix. \param S dual matrix \param T Dense array matrix. */ int DSDPDualMatSetArray(DSDPDualMat S, DSDPVMat T){ double *ss; int info,n,nn; DSDPFunctionBegin; if (S.dsdpops->matseturmat){ info=DSDPVMatGetSize(T,&n); DSDPCHKERR(info); info=DSDPVMatGetArray(T,&ss,&nn); DSDPCHKERR(info); info=(S.dsdpops->matseturmat)(S.matdata,ss,nn,n); DSDPChkDMatError(S,info); info=DSDPVMatRestoreArray(T,&ss,&nn); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatInvert" /*! \fn int DSDPDualMatInvert(DSDPDualMat S); \brief Invert the matrix. \param S dual matrix Assumes Cholesky factorization was successful. This routine may not actually invert the matrix. It give the matrix the opportunity to invert it. */ int DSDPDualMatInvert(DSDPDualMat S){ int info; DSDPFunctionBegin; /* DSDPEventLogBegin(sdpdualinvert); */ if (S.dsdpops->matinvert){ info=(S.dsdpops->matinvert)(S.matdata); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } /* DSDPEventLogEnd(sdpdualinvert); */ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatInverseAdd" /*! \fn int DSDPDualMatInverseAdd(DSDPDualMat S, double alpha, DSDPVMat T); \brief Add a multiple of the inverse to T. \param S dual matrix \param alpha scalar \param T destination. Assumes matrix already inverted. */ int DSDPDualMatInverseAdd(DSDPDualMat S, double alpha, DSDPVMat T){ int info,n,nn; double *ss; DSDPFunctionBegin; if (S.dsdpops->matinverseadd){ info=DSDPVMatGetSize(T,&n); DSDPCHKERR(info); info=DSDPVMatGetArray(T,&ss,&nn); DSDPCHKERR(info); info=(S.dsdpops->matinverseadd)(S.matdata,alpha,ss,nn,n); DSDPChkDMatError(S,info); info=DSDPVMatRestoreArray(T,&ss,&nn); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatInverseMultiply" /*! \fn int DSDPDualMatInverseMultiply(DSDPDualMat S, DSDPIndex IS, SDPConeVec B, SDPConeVec X); \brief Multiply the inverse by a vector or solve the system of equations. \param S dual matrix \param IS Sparsity pattern of B \param B Right-hand side of linear system \param X product, or solution to linear system. Assumes matrix already inverted. */ int DSDPDualMatInverseMultiply(DSDPDualMat S, DSDPIndex IS, SDPConeVec B, SDPConeVec X){ int info,n; double *bb,*xx; DSDPFunctionBegin; DSDPEventLogBegin(sdpdualsolve); if (S.dsdpops->matinversemultiply){ info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info); info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info); info=(S.dsdpops->matinversemultiply)(S.matdata,IS.indx+1,IS.indx[0],bb,xx,n); DSDPChkDMatError(S,info); info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info); info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPEventLogEnd(sdpdualsolve); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatCholeskySolveForward" /*! \fn int DSDPDualMatCholeskySolveForward(DSDPDualMat S, SDPConeVec B, SDPConeVec X); \brief Forward triangular solve. \param S dual matrix \param B Right-hand side of triangular system \param X Solution to triangular system. Assumes Cholesky factorization successful. */ int DSDPDualMatCholeskySolveForward(DSDPDualMat S, SDPConeVec B, SDPConeVec X){ int info,n; double *bb,*xx; DSDPFunctionBegin; if (S.dsdpops->matsolveforward){ info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info); info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info); info=(S.dsdpops->matsolveforward)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info); info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info); info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatDualMatCholeskySolveBackward" /*! \fn int DSDPDualMatCholeskySolveBackward(DSDPDualMat S, SDPConeVec B, SDPConeVec X); \brief Backward triangular solve. \param S dual matrix \param B Right-hand side of triangular system \param X Solution to triangular system. Assumes Cholesky factorization successful. */ int DSDPDualMatCholeskySolveBackward(DSDPDualMat S, SDPConeVec B, SDPConeVec X){ int info,n; double *bb,*xx; DSDPFunctionBegin; if (S.dsdpops->matsolvebackward){ info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info); info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info); info=(S.dsdpops->matsolvebackward)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info); info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info); info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatCholeskyFactor" /*! \fn int DSDPDualMatCholeskyFactor(DSDPDualMat S, DSDPTruth *psdefinite); \brief Factor the matrix \param S dual matrix \param psdefinite true if S is positive definite and factorization successful. */ int DSDPDualMatCholeskyFactor(DSDPDualMat S,DSDPTruth *psdefinite){ int info; int flag; DSDPFunctionBegin; if (S.dsdpops->matcholesky){ info=(S.dsdpops->matcholesky)(S.matdata,&flag); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } if (flag) *psdefinite=DSDP_FALSE; else *psdefinite=DSDP_TRUE; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatCholeskyForwardMultiply" /*! \fn int DSDPDualMatCholeskyForwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X); \brief Multiply by triangular matrix. \param S dual matrix \param B in vector \param X product Assumes Cholesky factorization successful. */ int DSDPDualMatCholeskyForwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X){ int info,n; double *bb,*xx; DSDPFunctionBegin; if (S.dsdpops->matforwardmultiply){ info=SDPConeVecGetSize(B,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info); info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info); info=(S.dsdpops->matforwardmultiply)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info); info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info); info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatCholeskyBackwardMultiply" /*! \fn int DSDPDualMatCholeskyBackwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X); \brief Multiply by triangular matrix. \param S dual matrix \param B in vector \param X product Assumes Cholesky factorization successful. */ int DSDPDualMatCholeskyBackwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X){ int info,n; double *bb,*xx; DSDPFunctionBegin; if (S.dsdpops->matbackwardmultiply){ info=SDPConeVecGetSize(B,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info); info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info); info=(S.dsdpops->matbackwardmultiply)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info); info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info); info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info); } else { DSDPNoOperationError(S); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatIsFull" /*! \fn int DSDPDualMatIsFull(DSDPDualMat S, DSDPTruth *full); \brief Factor the matrix \param S dual matrix \param full true if S is a dense structure. */ int DSDPDualMatIsFull(DSDPDualMat S, DSDPTruth *full){ int info,flag=0; DSDPFunctionBegin; *full=DSDP_FALSE; if (S.dsdpops->matfull){ info=(S.dsdpops->matfull)(S.matdata,&flag); DSDPChkDMatError(S,info); } else { DSDPNoOperationError(S); } if (flag) *full=DSDP_TRUE; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataMatCheck" int DSDPDualMatCheck(DSDPDualMat SS, SDPConeVec W1, SDPConeVec W2, DSDPIndex IS, DSDPVMat XX){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static const char* dualmatname="NOT SET YET"; /*! \fn int DSDPDualMatOpsInitialize(struct DSDPDualMat_Ops* sops){ \brief Set pointers to null. \param sops function pointers */ int DSDPDualMatOpsInitialize(struct DSDPDualMat_Ops* sops){ if (sops==NULL) return 0; sops->matseturmat=0; sops->matgetarray=0; sops->matcholesky=0; sops->matsolveforward=0; sops->matsolvebackward=0; sops->matinvert=0; sops->matinverseadd=0; sops->matinversemultiply=0; sops->matforwardmultiply=0; sops->matbackwardmultiply=0; sops->matfull=0; sops->matdestroy=0; sops->matgetsize=0; sops->matview=0; sops->matlogdet=0; sops->matname=dualmatname; return 0; } static struct DSDPDualMat_Ops dsdpdualmatopsdefault; #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatTest" int DSDPDualMatTest(DSDPDualMat S){ int info; DSDPFunctionBegin; if (S.dsdpops==0 || S.dsdpops==&dsdpdualmatopsdefault){ } else if (S.dsdpops->mattest){ info=(S.dsdpops->mattest)(S.matdata); DSDPChkDMatError(S,info); } else { /* DSDPNoOperationError(S); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDualMatInitialize" /*! \fn int DSDPDualMatInitialize(DSDPDualMat *S); \brief Set pointers to null. \param S dual matrix */ int DSDPDualMatInitialize(DSDPDualMat *S){ int info; DSDPFunctionBegin; info=DSDPDualMatOpsInitialize(&dsdpdualmatopsdefault);DSDPCHKERR(info); info=DSDPDualMatSetData(S,&dsdpdualmatopsdefault,0); DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpdualmat.h0000644000175000017500000000366310326241002016027 0ustar twernertwerner#if !defined(__DSDP_DUALMATRIX_H) #define __DSDP_DUALMATRIX_H #include "sdpconevec.h" #include "dsdpbasictypes.h" #include "dsdpxmat.h" /*! \file dsdpdualmat.h \brief The interface between the SDPCone and the matrix S. */ /*! struct DSDPDualMat_C { void* matdata; struct DSDPDualMat_Ops* dsdpops; }; \brief Represents an S matrix for one block in the semidefinite cone. \sa DSDPDualMat */ struct DSDPDualMat_C{ void* matdata; struct DSDPDualMat_Ops* dsdpops; }; /*! \typedef struct DSDPDualMat_C DSDPDualMat; \brief Represents an S matrix for one block in the semidefinite cone. */ typedef struct DSDPDualMat_C DSDPDualMat; #ifdef __cplusplus extern "C" { #endif extern int DSDPDualMatInitialize(DSDPDualMat*); extern int DSDPDualMatSetData(DSDPDualMat*,struct DSDPDualMat_Ops*,void*); extern int DSDPDualMatGetType(DSDPDualMat, int *); extern int DSDPDualMatGetSize(DSDPDualMat, int*); extern int DSDPDualMatTest(DSDPDualMat); extern int DSDPDualMatDestroy(DSDPDualMat *); extern int DSDPDualMatView(DSDPDualMat); extern int DSDPDualMatCholeskyFactor(DSDPDualMat,DSDPTruth *); extern int DSDPDualMatInvert(DSDPDualMat); extern int DSDPDualMatInverseAdd(DSDPDualMat,double,DSDPVMat); extern int DSDPDualMatInverseMultiply(DSDPDualMat, DSDPIndex, SDPConeVec, SDPConeVec); extern int DSDPDualMatCholeskySolveForward(DSDPDualMat, SDPConeVec, SDPConeVec); extern int DSDPDualMatCholeskySolveBackward(DSDPDualMat, SDPConeVec, SDPConeVec); extern int DSDPDualMatCholeskyForwardMultiply(DSDPDualMat, SDPConeVec, SDPConeVec); extern int DSDPDualMatCholeskyBackwardMultiply(DSDPDualMat, SDPConeVec, SDPConeVec); extern int DSDPDualMatLogDeterminant(DSDPDualMat, double*); extern int DSDPDualMatIsFull(DSDPDualMat,DSDPTruth*); extern int DSDPDualMatSetArray(DSDPDualMat,DSDPVMat); extern int DSDPDualMatCheck(DSDPDualMat,SDPConeVec,SDPConeVec,DSDPIndex,DSDPVMat); extern int DSDPDualMatGetArray(DSDPDualMat,double*[],int*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpdualmat_impl.h0000644000175000017500000000314210326241002017040 0ustar twernertwerner#if !defined(__DSDP_DUALMATRIXOPS_H) #define __DSDP_DUALMATRIXOPS_H /*! \file dsdpdualmat_impl.h \brief Structure of function pointers that each symmetric positive definite matrix type (dense, sparse) must implement. */ /*! struct DSDPDualMat_Ops \brief Table of function pointers that operate on the S matrix. */ struct DSDPDualMat_Ops{ int id; int (*matseturmat)(void*,double[],int,int); /* Set full array of values into matrix */ int (*matgetarray)(void*,double*[],int*); /* Set pointers to a dense array and its dimension */ int (*matcholesky)(void*,int*); /* Cholesky second argument is 0 for success, 1 otherwise */ int (*matsolveforward)(void*,double[],double[],int); /* Called after Cholesky */ int (*matsolvebackward)(void*,double[],double[],int); /* Called after Cholesky */ int (*matinvert)(void*); /* Called after Cholesky factorization */ int (*matinverseadd)(void*,double,double[],int,int); /* Add multiple of the inverse to array */ int (*matinversemultiply)(void*,int[],int,double[],double[],int); /* Called after invert */ int (*matforwardmultiply)(void*,double[],double[],int); /* Called after invert */ int (*matbackwardmultiply)(void*,double[],double[],int); /* Called after invert */ int (*matlogdet)(void*,double*); /* Called after Cholesky */ int (*matfull)(void*,int*); /* Is fully dense or not? */ int (*mattest)(void*); int (*matgetsize)(void*,int*); int (*matdestroy)(void*); int (*matview)(void*); const char *matname; }; #ifdef __cplusplus extern "C" { #endif extern int DSDPDualMatOpsInitialize(struct DSDPDualMat_Ops*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdplanczos.h0000644000175000017500000000230410326241002016040 0ustar twernertwerner#ifndef __TAO_DSDPSTEP_H #define __TAO_DSDPSTEP_H #include "sdpconevec.h" /*! \file dsdplanczos.h \brief Lanczos procedure determines the maximum step length */ /*! typedef struct DSDPLanczosStepLength \brief Apply Lanczos prodedure to find distance to boundary. */ typedef struct { int lanczosm; int maxlanczosm; double *darray; /* For SLOW BUT ROBUST METHOD ONLY */ SDPConeVec *Q; /* Size 2 for FAST, Size lanczosm for SLOW */ SDPConeVec Tv; /* For SLOW BUT ROBUST METHOD ONLY */ double *dwork4n; int *iwork10n; int lwork,liwork; int n; int type; } DSDPLanczosStepLength; #ifdef __cplusplus extern "C" { #endif extern int DSDPLanczosInitialize(DSDPLanczosStepLength*); extern int DSDPSetMaximumLanczosIterations( DSDPLanczosStepLength *LZ, int); extern int DSDPFastLanczosSetup(DSDPLanczosStepLength*,SDPConeVec); extern int DSDPRobustLanczosSetup(DSDPLanczosStepLength*,SDPConeVec); extern int DSDPLanczosStepSize( DSDPLanczosStepLength*, SDPConeVec, SDPConeVec, DSDPDualMat, DSDPDSMat, double *); extern int DSDPLanczosDestroy( DSDPLanczosStepLength*); extern int DSDPLanczosMinXEig( DSDPLanczosStepLength*, DSDPVMat, SDPConeVec, SDPConeVec, double *); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpsdp.h0000644000175000017500000001333510326241002015163 0ustar twernertwerner#ifndef __TAO_DSDPSDP_H #define __TAO_DSDPSDP_H /*! \file dsdpsdp.h \brief Internal SDPCone data structures and routines */ #include "dsdpschurmat.h" #include "dsdpbasictypes.h" #include "dsdpvec.h" #include "sdpconevec.h" #include "dsdpdatamat.h" #include "dsdpdualmat.h" #include "dsdpxmat.h" #include "dsdpdsmat.h" #include "dsdplanczos.h" typedef enum { SDPCONEEXIST=1, SDPCONESETUP1=2 } SDPConeStatus; /*! struct DSDPDataTranspose \brief Internal structure for transpose of data. */ typedef struct{ int m; int *nnzblocks; int **nzblocks; int *ttnzmat; int **nnzmats; int **idA; int *idAP; } DSDPDataTranspose; /*! struct SDPBlockData \brief Internal structure for data in one block of semidefintie. */ typedef struct{ int maxnnzmats; int nnzmats; int *nzmat; DSDPDataMat *A; double r; /* Multiple of Identity added to S to make it psd */ double scl; } DSDPBlockData; /*! struct SDPBlk \brief Internal structure for block of semidefinite cone. */ typedef struct{ DSDPBlockData ADATA; DSDPLanczosStepLength Lanczos; /* For Lanczos steplength routine */ int n; /* Dimensions */ double gammamu; /* Scale Barrier, used only by user option */ double bmu; /* For LMI, not used */ char format; /* Packed Symmetric, Full Symmetric, Lower,Upper */ int nnz; SDPConeStatus status; SDPConeVec W; SDPConeVec W2; DSDPIndex IS; DSDPDualMat S; /* Dual variable matrices */ DSDPDualMat SS; /* Compute primal variable matrices */ DSDPDSMat DS; /* Dual variable step matrices */ DSDPVMat T; /* Work Array and Primal variable matrice X */ } SDPblk; /*! struct SDPCone_C \brief Internal structure for semidefinite cone. \sa SDPCone */ struct SDPCone_C { int keyid; /* Dimensions */ int m, nn; /* Data in block format */ int nblocks; SDPblk *blk; /* Transpose of Data */ DSDPDataTranspose ATR; /* Work space */ DSDPVec Work, Work2; /* Current Solution */ DSDPVec YY,YX,DYX; double xmakermu; int optype; DSDP dsdp; }; #define SDPCONEKEY 5438 #define SDPConeValid(a) {if (!(a)||((a)->keyid!=SDPCONEKEY)){ DSDPSETERR(101,"DSDPERROR: Invalid SDPCone object\n");}} #define DSDPCHKBLOCKERR(a,b); { if (b){ DSDPSETERR1(b,"Block Number: %d,\n",a);} } #define DSDPCHKVARERR(a,b); { if (b){ DSDPSETERR1(b,"Variable Number: %d,\n",a);} } extern int DSDPSetDataMatZero(DSDPDataMat*); #include "dsdp5.h" #ifdef __cplusplus extern "C" { #endif /* Operations on the Data */ extern int DSDPBlockDataInitialize(DSDPBlockData*); extern int DSDPBlockDataAllocate(DSDPBlockData*, int); extern int DSDPBlockAddDataMatrix(DSDPBlockData*,int, struct DSDPDataMat_Ops*, void*); extern int DSDPBlockSetDataMatrix(DSDPBlockData*,int, struct DSDPDataMat_Ops*, void*); extern int DSDPBlockRemoveDataMatrix(DSDPBlockData*,int); extern int DSDPBlockDataMarkNonzeroMatrices(DSDPBlockData*,int*); extern int DSDPBlockDataRowSparsity(DSDPBlockData*,int,int[],int[],int); extern int DSDPBlockASum(DSDPBlockData*,double,DSDPVec,DSDPVMat); extern int DSDPBlockADot(DSDPBlockData*,double,DSDPVec,DSDPVMat,DSDPVec); extern int DSDPBlockvAv(DSDPBlockData*,double,DSDPVec,SDPConeVec,DSDPVec); extern int DSDPBlockDataDestroy(DSDPBlockData*); extern int DSDPBlockCheck(DSDPBlockData*,SDPConeVec,DSDPVMat); extern int DSDPBlockANorm2(DSDPBlockData*, DSDPVec, int); extern int DSDPBlockView(DSDPBlockData*); extern int DSDPBlockView2(DSDPBlockData*); extern int DSDPBlockCountNonzeroMatrices(DSDPBlockData *,int*); extern int DSDPBlockGetMatrix(DSDPBlockData*,int,int*,double*,DSDPDataMat*); extern int DSDPBlockFactorData(DSDPBlockData*,DSDPVMat,SDPConeVec); extern int DSDPBlockTakeDownData(DSDPBlockData*); extern int DSDPBlockDataRank(DSDPBlockData*,int*,int); extern int DSDPBlockTakeDown(SDPblk*); extern int DSDPBlockInitialize(SDPblk*); extern int DSDPBlockEventInitialize(void); extern int DSDPBlockEventZero(void); extern int DSDPDataMatCheck(DSDPDataMat,SDPConeVec,DSDPIndex,DSDPVMat); /* Operations on the Transpose of the Data */ extern int DSDPDataTransposeInitialize(DSDPDataTranspose*); extern int DSDPDataTransposeTakeDown(DSDPDataTranspose*); extern int DSDPDataTransposeSetup(DSDPDataTranspose*,SDPblk*,int,int); extern int DSDPUseDefaultDualMatrix(SDPCone); extern int SDPConeSetup(SDPCone,DSDPVec); extern int SDPConeSetup2(SDPCone,DSDPVec,DSDPSchurMat); extern int SDPConeComputeHessian(SDPCone,double,DSDPSchurMat,DSDPVec,DSDPVec); extern int SDPConeMultiply(SDPCone,int,double,DSDPVec,DSDPVec,DSDPVec); extern int SDPConeComputeRHS(SDPCone, int, double, DSDPVec, DSDPVec,DSDPVec); extern int SDPConeComputeXX(SDPCone,int,DSDPVec,double,DSDPDualMat, DSDPVMat); extern int SDPConeDestroy(SDPCone); extern int SDPConeCheckJ(SDPCone,int); extern int SDPConeCheckN(SDPCone,int, int); extern int SDPConeCheckM(SDPCone,int); extern int SDPConeCheckStorageFormat(SDPCone,int, char); extern int SDPConeComputeSS(SDPCone, int, DSDPVec, DSDPVMat); extern int SDPConeComputeXDot(SDPCone,int,DSDPVec,DSDPVMat,DSDPVec,double*,double*, double *); extern int SDPConeComputeX3(SDPCone,int,double,DSDPVec,DSDPVec,DSDPVMat); /* extern int DSDPPrintSDPA(TAO_DSDP *); */ extern int DSDPMakeVMat(char, int, DSDPVMat*); extern int DSDPMakeVMatWithArray(char, double[], int, int, DSDPVMat*); extern int DSDPSetDualMatrix(SDPCone sdpcone,int (*createdualmatrix)(DSDPBlockData*,DSDPVec,DSDPVMat,DSDPVec,DSDPVec,DSDPDualMat*,DSDPDualMat*,DSDPDSMat*,void*),void*); extern int DSDPAddSDP(DSDP,SDPCone); #ifdef __cplusplus } #endif extern int SDPConeSetRIdentity(SDPCone,int,int,double); extern int DSDPDualMatEventInitialize(void); extern int DSDPVMatEventInitialize(void); extern int DSDPDualMatEventZero(void); extern int DSDPVMatEventZero(void); #endif DSDP5.8/src/sdp/dsdpxmat_impl.h0000644000175000017500000000200610326241002016360 0ustar twernertwerner#if !defined(__DSDP_VMATRIXOPS_H) #define __DSDP_VMATRIXOPS_H /*! \file dsdpxmat_impl.h \brief Structure of function pointers that each dense matrix array type (upper full, packed symmetric, ...) must implement. */ /*! struct DSDPVMat_Ops \brief Table of function pointers that operate on the dense matrix. */ struct DSDPVMat_Ops{ int id; int (*matgetsize)(void*,int*); int (*mataddouterproduct)(void*,double,double[],int); int (*matmult)(void*,double[],double[],int); int (*matscalediagonal)(void*,double); int (*matshiftdiagonal)(void*,double); int (*matfnorm2)(void*,int,double*); int (*matzeroentries)(void*); int (*matgeturarray)(void*,double*[],int*); int (*matrestoreurarray)(void*,double*[],int*); int (*matmineig)(void*,double[],double[],int,double*); int (*mattest)(void*); int (*matdestroy)(void*); int (*matview)(void*); const char *matname; }; #ifdef __cplusplus extern "C" { #endif extern int DSDPVMatOpsInitialize(struct DSDPVMat_Ops*); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/dsdpstep.c0000644000175000017500000003445610326241002015352 0ustar twernertwerner#include "dsdpdualmat.h" #include "dsdpdsmat.h" #include "dsdpxmat.h" #include "dsdpsys.h" #include "dsdplanczos.h" #include "dsdplapack.h" /*! \file dsdpstep.c \brief Lanczos procedure determines the maximum step length */ typedef struct _P_Mat3* Mat3; static int MatMult3(Mat3 A, SDPConeVec x, SDPConeVec y); static int ComputeStepROBUST(Mat3 A, SDPConeVec *Q, int m, SDPConeVec W, SDPConeVec R,double*, SDPConeVec QAQTv, double *dwork, double *maxstep, double *mineig); static int ComputeStepFAST(Mat3 A, SDPConeVec *Q, int m, SDPConeVec W, double *dwork, int*iwork,double *maxstep, double *mineig); extern int DSDPGetEigsSTEP(double[],int,double[],int,long int[],int, double[],int,double[],int,int[],int); int DSDPGetTriDiagonalEigs(int n,double *D,double *E, double*WORK2N,int*); struct _P_Mat3{ int type; DSDPDualMat ss; DSDPDSMat ds; SDPConeVec V; DSDPVMat x; }; int DSDPGetTriDiagonalEigs(int N,double D[],double E[], double WORK[],int IIWORK[]){ ffinteger LDZ=DSDPMax(1,N),INFO,NN=N; ffinteger M,IL=N-1,IU=N,*ISUPPZ=0; ffinteger *IWORK=(ffinteger*)IIWORK,LIWORK,LWORK; double WW[2],VL=-1e10,VU=1e10,*Z=0,ABSTOL=0; char JOBZ='N', RANGE='I'; if (N<50){ dstev(&JOBZ,&NN,D,E,Z,&LDZ,WORK,&INFO); } else { if (N<=1) IL=1; if (N<=1) IU=1; LWORK=20*N+1; LIWORK=10*N+1; dstevr(&JOBZ,&RANGE,&NN,D,E,&VL,&VU,&IL,&IU,&ABSTOL,&M,WW,Z,&LDZ,ISUPPZ,WORK,&LWORK,IWORK,&LIWORK,&INFO); if (N==1){ D[0]=WW[0]; } else if (N>=2){ D[N-2]=WW[0]; D[N-1]=WW[1]; } } return INFO; } /* static int id1=0, id2=0; */ #undef __FUNCT__ #define __FUNCT__ "MatMult3" static int MatMult3(Mat3 A, SDPConeVec X, SDPConeVec Y){ int info=0; double minus_one=-1.0; DSDPFunctionBegin; /* DSDPEventLogBegin(id2); */ if (A->type==2){ info=DSDPVMatMult(A->x,X,Y);DSDPCHKERR(info); } else { info=DSDPDualMatCholeskySolveBackward(A->ss,X,Y); DSDPCHKERR(info); info=DSDPDSMatMult(A->ds,Y,A->V); DSDPCHKERR(info); info=DSDPDualMatCholeskySolveForward(A->ss,A->V,Y); DSDPCHKERR(info); info=SDPConeVecScale(minus_one,Y); DSDPCHKERR(info); } /* DSDPEventLogEnd(id2);*/ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLanczosInitialize" /*! \fn int DSDPLanczosInitialize( DSDPLanczosStepLength *LZ ); \brief Initialize Lanczos structure. \param LZ structure. */ int DSDPLanczosInitialize( DSDPLanczosStepLength *LZ ){ DSDPFunctionBegin; /* Build Lanczos structures */ LZ->n=0; LZ->lanczosm=0; LZ->maxlanczosm=20; LZ->type=0; LZ->dwork4n=0; LZ->Q=0; LZ->darray=0; /* if (id1==0 && id2==0){ DSDPEventLogRegister("STEP EIGS",&id1); printf("ID1: %d\n",id1); DSDPEventLogRegister("STEP MULT",&id2); printf("ID2: %d\n",id2); } */ DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPSetMaximumLanczosIterations" /*! \fn int DSDPSetMaximumLanczosIterations( DSDPLanczosStepLength *LZ, int maxlanczos ); \brief Set parameter. \param LZ structure. \param maxlanczos a parameter. */ int DSDPSetMaximumLanczosIterations( DSDPLanczosStepLength *LZ, int maxlanczos ){ DSDPFunctionBegin; if (maxlanczos>0) LZ->lanczosm=maxlanczos; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPFastLanczosSetup" /*! \fn int DSDPFastLanczosSetup( DSDPLanczosStepLength *LZ, SDPConeVec V ); \brief Use Lanczos procedure. Assume off tridiagonal entries are zero. \param LZ structure. \param V work vector. */ int DSDPFastLanczosSetup( DSDPLanczosStepLength *LZ, SDPConeVec V ){ int i,n,info; DSDPFunctionBegin; /* Build Lanczos structures */ info=SDPConeVecGetSize(V,&n);DSDPCHKERR(info); LZ->lanczosm=DSDPMin(LZ->maxlanczosm,n); LZ->type=1; LZ->n=n; if (LZ->lanczosm<50){ DSDPCALLOC2(&LZ->dwork4n,double,4*(LZ->lanczosm)+2,&info); DSDPCHKERR(info); DSDPCALLOC2(&LZ->iwork10n,int,1,&info); DSDPCHKERR(info); } else { DSDPCALLOC2(&LZ->dwork4n,double,23*(LZ->lanczosm)+2,&info); DSDPCHKERR(info); DSDPCALLOC2(&LZ->iwork10n,int,10*(LZ->lanczosm),&info); DSDPCHKERR(info); } DSDPCALLOC2(&LZ->Q,SDPConeVec,2,&info);DSDPCHKERR(info); for (i=0;i<2;i++){ info = SDPConeVecDuplicate(V,&LZ->Q[i]);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPRobustLanczosSetup" /*! \fn int DSDPRobustLanczosSetup( DSDPLanczosStepLength *LZ, SDPConeVec V ); \brief Use slowerer but more robust method. \param LZ structure. \param V work vector. */ int DSDPRobustLanczosSetup( DSDPLanczosStepLength *LZ, SDPConeVec V ){ int i,n,leig,info; DSDPFunctionBegin; /* Build Lanczos structures */ info=SDPConeVecGetSize(V,&n);DSDPCHKERR(info); leig=DSDPMin(LZ->maxlanczosm,n); LZ->n=n; LZ->lanczosm=leig; LZ->type=2; DSDPCALLOC2(&LZ->dwork4n,double,3*(LZ->lanczosm)+1,&info); DSDPCHKERR(info); DSDPCALLOC2(&LZ->darray,double,(leig*leig),&info); DSDPCHKERR(info); DSDPCALLOC2(&LZ->Q,SDPConeVec,(leig+1),&info);DSDPCHKERR(info); for (i=0;i<=leig;i++){ info = SDPConeVecDuplicate(V,&LZ->Q[i]);DSDPCHKERR(info); } info = SDPConeVecCreate(leig,&LZ->Tv);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLanczosDestroy" /*! \fn int DSDPLanczosDestroy( DSDPLanczosStepLength *LZ); \brief Free data structure. \param LZ structure. */ int DSDPLanczosDestroy( DSDPLanczosStepLength *LZ){ int i,info; DSDPFunctionBegin; if (LZ->type==2){ for (i=0;i<=LZ->lanczosm;i++){ info = SDPConeVecDestroy(&LZ->Q[i]);DSDPCHKERR(info); } info=SDPConeVecDestroy(&LZ->Tv);DSDPCHKERR(info); DSDPFREE(&LZ->darray,&info);DSDPCHKERR(info); } else if (LZ->type==1){ info = SDPConeVecDestroy(&LZ->Q[1]);DSDPCHKERR(info); info = SDPConeVecDestroy(&LZ->Q[0]);DSDPCHKERR(info); DSDPFREE(&LZ->iwork10n,&info);DSDPCHKERR(info); } DSDPFREE(&LZ->Q,&info);DSDPCHKERR(info); DSDPFREE(&LZ->dwork4n,&info);DSDPCHKERR(info); info=DSDPLanczosInitialize(LZ);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLanczosMinXEig" int DSDPLanczosMinXEig( DSDPLanczosStepLength *LZ, DSDPVMat X, SDPConeVec W1, SDPConeVec W2, double *mineig ){ int info,m; double smaxstep; struct _P_Mat3 PP; Mat3 A=&PP; DSDPFunctionBegin; A->type=2; A->x=X; A->V=W2; m=LZ->lanczosm; if (LZ->type==1){ info = ComputeStepFAST(A,LZ->Q,m,W1,LZ->dwork4n,LZ->iwork10n,&smaxstep,mineig);DSDPCHKERR(info); } else if (LZ->type==2){ info = ComputeStepROBUST(A,LZ->Q,m,LZ->Q[m],W1,LZ->darray/*LZ->TT*/,LZ->Tv,LZ->dwork4n,&smaxstep,mineig);DSDPCHKERR(info); } else { DSDPSETERR1(1,"Lanczos Step Length Has not been SetUp. Type: %d\n",LZ->type); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLanczosStepSize" /*! \fn int DSDPLanczosStepSize( DSDPLanczosStepLength *LZ, SDPConeVec W1, SDPConeVec W2, DSDPDualMat S, DSDPDSMat DS, double *maxstep ); \brief Compute distance to boundary \param LZ structure. \param W1 work vector \param W2 work vector \param S Current point in factored form. \param DS Step direction. \param maxstep output is distance to boundary. */ int DSDPLanczosStepSize( DSDPLanczosStepLength *LZ, SDPConeVec W1, SDPConeVec W2, DSDPDualMat S, DSDPDSMat DS, double *maxstep ){ int info,m; double smaxstep,mineig; struct _P_Mat3 PP; Mat3 A=&PP; DSDPFunctionBegin; A->ss=S; A->ds=DS; A->V=W2; A->type=1; m=LZ->lanczosm; if (LZ->type==1){ info = ComputeStepFAST(A,LZ->Q,m,W1,LZ->dwork4n,LZ->iwork10n,&smaxstep,&mineig);DSDPCHKERR(info); *maxstep=smaxstep; } else if (LZ->type==2){ info = ComputeStepROBUST(A,LZ->Q,m,LZ->Q[m],W1,LZ->darray/*LZ->TT*/,LZ->Tv,LZ->dwork4n,&smaxstep,&mineig);DSDPCHKERR(info); *maxstep=smaxstep; } else { DSDPSETERR1(1,"Lanczos Step Length Has not been SetUp. Type: %d\n",LZ->type); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ComputeStepROBUST" static int ComputeStepROBUST(Mat3 A, SDPConeVec *Q, int m, SDPConeVec W, SDPConeVec R, double*darray, SDPConeVec QAQTv, double *dwork, double *maxstep , double *mineig){ int i,j,n,info; double tt,wnorm, phi; double lambda1=0,lambda2=0,delta=0; double res1,res2,beta; double one=1.0; double *eigvec; int N, LDA, LWORK; DSDPFunctionBegin; memset((void*)darray,0,m*m*sizeof(double)); if (A->type==1){ for (i=0; i0){ tt=-darray[i*m+i-1]; info = SDPConeVecAXPY(tt,Q[i-1],W);DSDPCHKERR(info); } info = SDPConeVecDot(W,Q[i],&tt);DSDPCHKERR(info); darray[i*m+i]=tt; tt*=-1.0; info = SDPConeVecAXPY(tt,Q[i],W);DSDPCHKERR(info); info = SDPConeVecNorm2(W,&wnorm);DSDPCHKERR(info); if (wnorm <= 0.8 * phi){ for (j=0;j<=i;j++){ info = SDPConeVecDot(W,Q[j],&tt);DSDPCHKERR(info); if (tt==tt){tt*=-1.0;} else {tt=0;} info = SDPConeVecAXPY(tt,Q[j],W);DSDPCHKERR(info); darray[j*m+i]-=tt; if (i!=j){ darray[i*m+j]-=tt; } } } info = SDPConeVecNorm2(W,&wnorm);DSDPCHKERR(info); if (i1){ info=SDPConeVecGetArray(QAQTv,&eigvec);DSDPCHKERR(info); *mineig=eigvec[0]; lambda1=-eigvec[N-1]; lambda2=-eigvec[N-2]; info=SDPConeVecRestoreArray(QAQTv,&eigvec);DSDPCHKERR(info); info = SDPConeVecZero(W);DSDPCHKERR(info); for (i=0;i0) beta=tt; else beta=1.0e-20; delta = DSDPMin(res1,sqrt(res1)/beta); } if (delta-lambda1>0) *maxstep = 1.0/(delta-lambda1); else *maxstep = 1.0e+30; info=SDPConeVecGetSize(W,&n);DSDPCHKERR(info); DSDPLogInfo(0,19,"Robust Lanczos StepLength: Iterates %d, Max: %d, BlockSize: %d, Lambda1: %4.2e, Res1: %4.2e, Lambda2: %4.2e, Res2: %4.2e, Delta: %4.2e, MaxStep: %4.2e\n",i,m,n,lambda1,res1*res1,lambda2,res2*res2,delta,*maxstep); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ComputeStepFAST" static int ComputeStepFAST(Mat3 A, SDPConeVec *Q, int m, SDPConeVec W, double *dwork, int *iwork,double *maxstep ,double *mineig){ int i,j,n,info; double tt,wnorm, phi; double lambda1=0,lambda2=0,delta=0; double res1,res2,beta; double one=1.0; int N=m; double *diag,*subdiag,*ddwork; DSDPFunctionBegin; diag=dwork; subdiag=dwork+m; ddwork=dwork+2*m; if (A->type==1){ for (i=0; i0){ tt=-subdiag[i-1]; info = SDPConeVecAXPY(tt,Q[1],W);DSDPCHKERR(info); } info = SDPConeVecDot(W,Q[0],&tt);DSDPCHKERR(info); diag[i]=tt; tt*=-1.0; info = SDPConeVecAXPY(tt,Q[0],W);DSDPCHKERR(info); info = SDPConeVecNorm2(W,&wnorm);DSDPCHKERR(info); if (wnorm <= 1.0 * phi){ for (j=0;j<=i;j++){ if (j==i-1){ info = SDPConeVecDot(W,Q[1],&tt);DSDPCHKERR(info); if (tt==tt){tt*=-1.0;} else {tt=0;} info = SDPConeVecAXPY(tt,Q[1],W);DSDPCHKERR(info); subdiag[i-1]-=tt; } else if (j==i){ info = SDPConeVecDot(W,Q[0],&tt);DSDPCHKERR(info); if (tt==tt){tt*=-1.0;} else {tt=0;} info = SDPConeVecAXPY(tt,Q[0],W);DSDPCHKERR(info); diag[i]-=tt; } } } info = SDPConeVecNorm2(W,&wnorm);DSDPCHKERR(info); /* printf("PHI: %4.4e, VNORM: %4.2e Diag: %4.2e\n",phi,wnorm,diag[i]); */ if (i1){ lambda1=-diag[N-1]; lambda2=-diag[N-2]; res1=1.0e-8; res2=1.0e-8; tt = -lambda1 + lambda2 - res2; if (tt>0) beta=tt; else beta=1.0e-20; delta = DSDPMin(res1,sqrt(res1)/beta); *mineig=diag[0]; } if (delta-lambda1>0) *maxstep = 1.0/(delta-lambda1); else *maxstep = 1.0e+30; info=SDPConeVecGetSize(W,&n);DSDPCHKERR(info); DSDPLogInfo(0,19,"Step Length: Fast Lanczos Iterates: %2d, Max: %d, Block Size: %d, VNorm: %3.1e, Lambda1: %4.4e, Lambda2: %4.4e, Delta: %4.2e, Maxstep: %4.2e\n", i,m,n,wnorm,lambda1,lambda2,delta,*maxstep); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpxmat.h0000644000175000017500000000311410326241002015340 0ustar twernertwerner#if !defined(__DSDP_VSYMMETRICMATRIX_H) #define __DSDP_VSYMMETRICMATRIX_H /*! \file dsdpxmat.h \brief The interface between the SDPCone and the dense matrix array. */ #include "sdpconevec.h" /* DSDP V Matrix Structure */ /*! struct DSDPVMat_C { void* matdata; struct DSDPVMat_Ops* dsdpops; }; \brief Dense symmetric matrix for one block in the semidefinite cone. \sa DSDPVMat */ struct DSDPVMat_C{ void *matdata; struct DSDPVMat_Ops* dsdpops; }; /*! \typedef struct DSDPVMat_C DSDPVMat; \brief Represents a dense symmetric matrix for one block in the semidefinite cone. */ typedef struct DSDPVMat_C DSDPVMat; #ifdef __cplusplus extern "C" { #endif extern int DSDPVMatGetType(DSDPVMat, int *); extern int DSDPVMatSetData(DSDPVMat *, struct DSDPVMat_Ops*, void*); extern int DSDPVMatInitialize(DSDPVMat*); extern int DSDPVMatTest(DSDPVMat); extern int DSDPVMatGetSize(DSDPVMat,int*); extern int DSDPVMatView(DSDPVMat); extern int DSDPVMatDestroy(DSDPVMat*); extern int DSDPVMatExist(DSDPVMat,int*); extern int DSDPVMatZeroEntries(DSDPVMat); extern int DSDPVMatAddOuterProduct(DSDPVMat, double, SDPConeVec); extern int DSDPVMatMult(DSDPVMat,SDPConeVec,SDPConeVec); extern int DSDPVMatScaleDiagonal(DSDPVMat,double); extern int DSDPVMatShiftDiagonal(DSDPVMat,double); extern int DSDPVMatNormF2(DSDPVMat, double*); extern int DSDPVMatGetArray(DSDPVMat,double**,int*); extern int DSDPVMatRestoreArray(DSDPVMat,double**,int*); extern int DSDPVMatMinEigenvalue(DSDPVMat,SDPConeVec,SDPConeVec,double*); extern int DSDPVMatCheck(DSDPVMat, SDPConeVec, SDPConeVec); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/printsdpa.c0000644000175000017500000001502710326241002015521 0ustar twernertwerner#include "dsdp5.h" /*! \file printsdpa.c \brief Print data or solution in SDPA format */ static void DprintfD(FILE*fp, double d1){ int i1=(int)d1,i2=(int)(d1*100),i3=(int)(d1*10000),i4=(int)(d1*10000000); if ( d1==(double)i1){ fprintf(fp,"%2.0f ",d1); } else if (d1==(double)i2/100.0){ fprintf(fp,"%4.2f ",d1); } else if (d1==(double)i3/10000.0){ fprintf(fp,"%6.4f ",d1); } else if (d1==(double)i4/1000000.0){ fprintf(fp,"%8.6f ",d1); } else { fprintf(fp,"%22.22e ",d1); } return; } static void Dprintf(FILE*fp, int i1, int i2, int i3, int i4, double d1){ if (fabs(d1)<1e-30){return;} fprintf(fp,"%d %d %d %d ",i1,i2,i3+1,i4+1); if (i1==0) DprintfD(fp,-d1); else DprintfD(fp,d1); fprintf(fp,"\n"); return; } #undef __FUNCT__ #define __FUNCT__ "DPrintUpperRightMatrix" static void DPrintUpperRightMatrix(int constraint, int block, double amat[], int n, FILE*fp){ int col,row; for (row=0;row1.0e-20){ Dprintf(fp,constraint,block,col,row,amat[col]); } } amat+=(row+1); } return; } #undef __FUNCT__ #define __FUNCT__ "DPrintUpperFullMatrix" static void DPrintUpperFullMatrix(int constraint, int block, double amat[], int n, FILE*fp){ int col,row; for (row=0;row1.0e-20){ Dprintf(fp,constraint,block,col,row,amat[col]); } } amat+=n; } return; } #undef __FUNCT__ #define __FUNCT__ "DPrintMatrix" static void DPrintMatrix(char UPLQ, int constraint, int block, double amat[], int n, FILE*fp){ if (UPLQ=='P'){ DPrintUpperRightMatrix(constraint,block,amat,n,fp); } else if (UPLQ=='U'){ DPrintUpperFullMatrix(constraint,block,amat,n,fp); } return; } #undef __FUNCT__ #define __FUNCT__ "DPrintLPArray" static int DPrintLPArray(int cc, int block, double *vv, int n, FILE *fp ){ int i; for (i=0;i 0){ Dprintf(fp,cc,block,i,i,vv[i]); } } return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPPrintSolution" /*! \fn int DSDPPrintSolution(FILE *fp,DSDP dsdp,SDPCone sdpcone, LPCone lpcone); \brief Print solution in SDPA format \param fp file pointer \param dsdp the solver \param sdpcone semidefinite cone \param lpcone LP cone \ingroup Examples */ int DSDPPrintSolution(FILE *fp,DSDP dsdp,SDPCone sdpcone, LPCone lpcone){ int i,kk,info,n,nn,lpn=0,nblocks,nvars; double *ss,*xx,*y,*lparray; char UPLQ; info=DSDPGetNumberOfVariables(dsdp,&nvars);DSDPCHKERR(info); DSDPCALLOC2(&y,double,(nvars+2),&info);DSDPCHKERR(info); info=SDPConeGetNumberOfBlocks(sdpcone,&nblocks);DSDPCHKERR(info); if (lpcone){info=LPConeGetXArray(lpcone,&xx,&lpn);DSDPCHKERR(info);nblocks--;} DSDPCALLOC2(&lparray,double,(lpn+1),&info);DSDPCHKERR(info); /* Deleted at Borcher's request. fprintf(fp,"%d \n%d \n",nvars,nblocks); for (i=0;i0){ info=LPConeGetDimension(lpcone,&lpn);DSDPCHKERR(info); for (i=0;i<=nvars;i++){ info=LPConeGetData(lpcone,i,vv,lpn);DSDPCHKERR(info); info=DPrintLPArray(i,nblocks+1,vv,lpn,fp);DSDPCHKERR(info); } } DSDPFREE(&y,&info); if (vv){ DSDPFREE(&vv,&info); } fclose(fp); return 0; } DSDP5.8/src/sdp/sdpcone.c0000644000175000017500000003226210326241002015150 0ustar twernertwerner#include "dsdpsdp.h" #include "dsdpsys.h" /*! \file sdpcone.c \brief Implement operations on the SDPCone object. */ #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeSS" /*! \fn int SDPConeComputeSS(SDPCone sdpcone, int blockj, DSDPVec Y, DSDPVMat SS); \brief Sum the data matrices. \param sdpcone semidefinite cone object \param blockj block number \param Y scalar multiples of A matrices. \param SS destination array. */ int SDPConeComputeSS(SDPCone sdpcone, int blockj, DSDPVec Y, DSDPVMat SS){ int info; DSDPFunctionBegin; info=DSDPVMatZeroEntries(SS); DSDPCHKBLOCKERR(blockj,info); info=DSDPBlockASum(&sdpcone->blk[blockj].ADATA,1,Y,SS); DSDPCHKBLOCKERR(blockj,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeS" /*! \fn int SDPConeComputeS(SDPCone sdpcone, int blockj, double cc,double y[], int nvars, double r, int n, double s[], int nn); \ingroup SDPRoutines \brief Compute the dual matrix S \param sdpcone semidefinite cone object \param blockj block number \param cc the multiple of the matrix C (or A_0) \param y an array of containing the variables y \param nvars the length of the array and the number of variables y \param r the multiple of the identity matrix to add \param n the dimension of the block \param s array to where the matrix S will be copied. \param nn length of the array s */ int SDPConeComputeS(SDPCone sdpcone, int blockj, double cc,double y[], int nvars, double r, int n, double s[], int nn){ int i,info; char UPLQ; DSDPVMat T; DSDPVec Y=sdpcone->Work; DSDPFunctionBegin; info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKBLOCKERR(blockj,info); info=SDPConeCheckM(sdpcone,nvars);DSDPCHKERR(info); if (n<1){DSDPFunctionReturn(0);} info=DSDPVecSetC(Y,-1.0*cc); info=DSDPVecSetR(Y,-r); for (i=0;iblk; double scl=blk[blockj].ADATA.scl; DSDPVec ADOTX,YW2; DSDPVMat T; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=SDPConeCheckM(sdpcone,m-2);DSDPCHKERR(info); YW2=sdpcone->Work2; info=DSDPVecSet(alpha,YW2);DSDPCHKBLOCKERR(blockj,info); info=SDPConeGetBlockSize(sdpcone,blockj,&n);DSDPCHKBLOCKERR(blockj,info); if (n<1){DSDPFunctionReturn(0);} info=DSDPVecCreateWArray(&ADOTX,adotx,m); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ);DSDPCHKBLOCKERR(blockj,info); info=DSDPMakeVMatWithArray(UPLQ,x,nn,n,&T);DSDPCHKBLOCKERR(blockj,info); info=DSDPBlockADot(&blk[blockj].ADATA,1.0/scl,YW2,T,ADOTX);DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatDestroy(&T);DSDPCHKBLOCKERR(blockj,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeXDot" /*! \fn int SDPConeComputeXDot(SDPCone sdpcone, int blockj, DSDPVec Y,DSDPVMat X, DSDPVec AX, double* xtrace,double *xnorm, double *tracexs); \brief Compute inner product of X with the Data, S, and norm of X. \param sdpcone semidefinite cone \param blockj block number \param Y dual solution \param X dense array matrix \param AX inner products \param xtrace trace of X \param xnorm norm of X \param tracexs inner product of X and S */ int SDPConeComputeXDot(SDPCone sdpcone, int blockj, DSDPVec Y,DSDPVMat X, DSDPVec AX, double* xtrace,double *xnorm, double *tracexs){ int info; SDPblk *blk=sdpcone->blk; DSDPVec YW2=sdpcone->Work2; double one=1.0,scl=blk[blockj].ADATA.scl; DSDPFunctionBegin; info=DSDPVecZero(YW2);DSDPCHKBLOCKERR(blockj,info); info=DSDPBlockADot(&blk[blockj].ADATA,-1.0/scl,Y,X,YW2);DSDPCHKBLOCKERR(blockj,info); info=DSDPVecGetR(YW2,xtrace);DSDPCHKBLOCKERR(blockj,info); info=DSDPVecSum(YW2,tracexs);DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatNormF2(X,xnorm);DSDPCHKBLOCKERR(blockj,info); info=DSDPVecSet(one,YW2);DSDPCHKBLOCKERR(blockj,info); info=DSDPBlockADot(&blk[blockj].ADATA,1.0/scl,YW2,X,AX);DSDPCHKBLOCKERR(blockj,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeX3" /*! \fn int SDPConeComputeX3(SDPCone sdpcone, int blockj, double mu, DSDPVec Y,DSDPVec DY,DSDPVMat X); \brief Compute the matrix X with the given information. \param sdpcone semidefinite cone \param blockj block number \param mu barrier parameter \param Y dual solution \param DY Newton direction \param X destination \sa DSDPComputeX() */ int SDPConeComputeX3(SDPCone sdpcone, int blockj, double mu, DSDPVec Y,DSDPVec DY,DSDPVMat X){ int info; double xshift=1e-12,xscale=1e-12; SDPblk *blk=sdpcone->blk; DSDPTruth psdefinite1=DSDP_FALSE,psdefinite2=DSDP_FALSE,full; DSDPDualMat SS; DSDPFunctionBegin; SS=blk[blockj].SS; info=SDPConeComputeSS(sdpcone,blockj,Y,X);DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatSetArray(SS,X); DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatCholeskyFactor(SS,&psdefinite1); DSDPCHKBLOCKERR(blockj,info); if (psdefinite1 == DSDP_FALSE){ DSDPLogInfo(0,2,"Primal SDP Block %2.0f not PSD\n",blockj); } info=DSDPDualMatInvert(SS);DSDPCHKBLOCKERR(blockj,info); info=SDPConeComputeXX(sdpcone,blockj,DY,mu,SS,X);DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatIsFull(SS,&full);DSDPCHKBLOCKERR(blockj,info); psdefinite2=DSDP_FALSE; while (full==DSDP_TRUE && psdefinite2==DSDP_FALSE && xscale<2e-1){ info=DSDPVMatShiftDiagonal(X,xshift); DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatScaleDiagonal(X,1.0+xscale); DSDPCHKBLOCKERR(blockj,info); DSDPLogInfo(0,10,"VMat: shift diagonal: %4.2e, scale diagonal: %4.2e.\n",xshift,1+xscale); info=DSDPDualMatSetArray(SS,X); DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatCholeskyFactor(SS,&psdefinite2); DSDPCHKBLOCKERR(blockj,info); xshift*=10;xscale*=10; } if (full==DSDP_FALSE){ xshift=1e-12,xscale=1e-10; info=DSDPVMatShiftDiagonal(X,xshift); DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatScaleDiagonal(X,1.0+xscale); DSDPCHKBLOCKERR(blockj,info); DSDPLogInfo(0,10,"XMat: shift diagonal: %4.2e, scale diagonal: %4.2e.\n",xshift,1+xscale); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeX" /*! \fn int SDPConeComputeX(SDPCone sdpcone, int blockj, int n, double x[], int nn); \brief Compute the matrix X \ingroup SDPRoutines \param sdpcone semidefinite cone \param n di \param blockj block number \param n the dimension of the block \param x array to where the matrix X will be copied. \param nn length of the array x \sa DSDPComputeX() */ int SDPConeComputeX(SDPCone sdpcone, int blockj, int n, double x[], int nn){ int info; double mu=sdpcone->xmakermu; double xnorm,xtrace,trxs; char UPLQ; DSDPVec DY=sdpcone->DYX,Y=sdpcone->YX,AX=sdpcone->Work; DSDPVMat T; DSDPFunctionBegin; info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKBLOCKERR(blockj,info); if (n<1){DSDPFunctionReturn(0);} info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ);DSDPCHKBLOCKERR(blockj,info); info=DSDPMakeVMatWithArray(UPLQ,x,nn,n,&T);DSDPCHKBLOCKERR(blockj,info); info=SDPConeComputeX3(sdpcone,blockj,mu,Y,DY,T);DSDPCHKBLOCKERR(blockj,info); info=SDPConeComputeXDot(sdpcone,blockj,Y,T,AX,&xtrace,&xnorm,&trxs);DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatDestroy(&T);DSDPCHKBLOCKERR(blockj,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeViewX" /*! \fn int SDPConeViewX(SDPCone sdpcone, int blockj, int n, double x[], int nn); \brief Print a dense array X to the screen \ingroup SDPBasic \param sdpcone semidefinite cone \param blockj block number \param n the dimension of the block \param x dense matrix array. \param nn length of the array x \sa SDPConeGetXArray() */ int SDPConeViewX(SDPCone sdpcone, int blockj, int n, double x[], int nn){ int info; char UPLQ; DSDPVMat T; DSDPFunctionBegin; info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKBLOCKERR(blockj,info); info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ);DSDPCHKBLOCKERR(blockj,info); info=DSDPMakeVMatWithArray(UPLQ,x,nn,n,&T);DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatView(T);DSDPCHKBLOCKERR(blockj,info); info=DSDPVMatDestroy(&T);DSDPCHKBLOCKERR(blockj,info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeXVMultiply" /*! \fn int SDPConeXVMultiply(SDPCone sdpcone, int blockj, double vin[], double vout[], int n); \brief Multiply an array by a factor V such that \f$ V V^T= X \f$. \ingroup SDPRoutines \param sdpcone the SDP cone \param blockj block number \param vin input array \param vout the product V vin \param n dimension of the block and the length of the two arrays. \sa SDPConeComputeXV() \sa SDPConeAddXVAV() */ int SDPConeXVMultiply(SDPCone sdpcone, int blockj, double vin[], double vout[], int n){ int info; SDPblk *blk=sdpcone->blk; SDPConeVec V1,V2,V3,V4; DSDPDualMat S,SS; DSDPFunctionBegin; info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKBLOCKERR(blockj,info); if (sdpcone->blk[blockj].n>1){ S=blk[blockj].S; SS=blk[blockj].SS; V2=blk[blockj].W; V3=blk[blockj].W2; info=SDPConeVecCreateWArray(&V1,vin,n); info=SDPConeVecCreateWArray(&V4,vout,n); if (0){ info=DSDPDualMatCholeskySolveForward(S,V1,V3);DSDPCHKERR(info); info=SDPConeVecScale(sqrt(sdpcone->xmakermu),V3);DSDPCHKERR(info); info=DSDPDualMatCholeskySolveBackward(S,V3,V2);DSDPCHKERR(info); info=DSDPDualMatCholeskyBackwardMultiply(SS,V2,V1);DSDPCHKERR(info); } info=DSDPDualMatCholeskyForwardMultiply(SS,V1,V2);DSDPCHKERR(info); info=DSDPDualMatCholeskySolveForward(S,V2,V3);DSDPCHKERR(info); info=SDPConeVecScale(sqrt(sdpcone->xmakermu),V3);DSDPCHKERR(info); info=DSDPDualMatCholeskySolveBackward(S,V3,V4);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeAddXVAV" /*! \fn int SDPConeAddXVAV(SDPCone sdpcone, int blockj, double vin[], int n, double sum[], int mm); \brief Compute \f$ v^T A_{i,j} v \f$ for i = 0 through m. \ingroup SDPRoutines \param sdpcone the SDP cone \param blockj block number \param vin array \param n dimension of the block and the length of the two arrays. \param sum input array \param mm the number of variables plus 2 \sa SDPConeAddADotX() */ int SDPConeAddXVAV(SDPCone sdpcone, int blockj, double vin[], int n, double sum[], int mm){ int info; SDPblk *blk=sdpcone->blk; SDPConeVec V2; DSDPVec W,Wout; DSDPFunctionBegin; info=SDPConeCheckN(sdpcone,blockj,n);DSDPCHKBLOCKERR(blockj,info); W=sdpcone->Work; info=DSDPVecSet(1.0,sdpcone->Work);DSDPCHKBLOCKERR(blockj,info); if (sdpcone->blk[blockj].n>1){ info=SDPConeVecCreateWArray(&V2,vin,n);DSDPCHKERR(info); info=DSDPVecCreateWArray(&Wout,sum,mm);DSDPCHKERR(info); info=DSDPBlockvAv(&blk[blockj].ADATA,1.0,sdpcone->Work,V2,Wout);DSDPCHKBLOCKERR(blockj,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeXV" /*! \fn int SDPConeComputeXV(SDPCone sdpcone, int blockj, int *derror); \ingroup SDPRoutines \brief Compute a factor V such that \f$ V V^T= X \f$. \param sdpcone the SDP cone \param blockj block number \param derror nonzero if no such factor could be computed. \sa SDPConeXVMultiply() This routine is helpful in semidefinite relaxations of combinatorial problems. */ int SDPConeComputeXV(SDPCone sdpcone, int blockj, int *derror){ int info; double rr; DSDPVec Y,DY,W; SDPblk *blk=sdpcone->blk; DSDPTruth psdefinite1=DSDP_FALSE,psdefinite2=DSDP_FALSE; DSDPDualMat S,SS; DSDPVMat T; DSDPFunctionBegin; *derror=0; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKBLOCKERR(blockj,info); if (sdpcone->blk[blockj].n>1){ Y=sdpcone->YX; DY=sdpcone->DYX; W=sdpcone->Work; T=blk[blockj].T; S=blk[blockj].S; SS=blk[blockj].SS; info=DSDPVecWAXPY(W,-1.0,DY,Y);DSDPCHKBLOCKERR(blockj,info); while (psdefinite1==DSDP_FALSE){ info=DSDPVecGetR(W,&rr); info=DSDPVecSetR(W,10*rr-1e-12); info=SDPConeComputeSS(sdpcone,blockj,W,T);DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatSetArray(SS,T); DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatCholeskyFactor(SS,&psdefinite1); DSDPCHKBLOCKERR(blockj,info); } while (psdefinite2==DSDP_FALSE){ info=SDPConeComputeSS(sdpcone,blockj,Y,T);DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatSetArray(S,T); DSDPCHKBLOCKERR(blockj,info); info=DSDPDualMatCholeskyFactor(S,&psdefinite2); DSDPCHKBLOCKERR(blockj,info); if (psdefinite2==DSDP_FALSE){ info=DSDPVecGetR(Y,&rr); info=DSDPVecSetR(Y,10*rr-1e-15); } } if (psdefinite1==DSDP_FALSE || psdefinite2==DSDP_FALSE) *derror=1; } DSDPFunctionReturn(0); } DSDP5.8/src/sdp/Makefile0000644000175000017500000000050710326241002015006 0ustar twernertwerner DSDPOBJ = dsdpstep.o printsdpa.o sdpconevec.o \ sdpsss.o dsdpadddata.o dsdpadddatamat.o dsdpblock.o \ sdpcone.o sdpkcone.o sdpcompute.o sdpconesetup.o \ dsdpdsmat.o dsdpdatamat.o dsdpdualmat.o dsdpxmat.o DCFLAGS = -I${PP}solver include ../../make.include default: make dsdplib; clean: ${RM} ${DSDPOBJ} DSDP5.8/src/sdp/sdpcompute.c0000644000175000017500000002146410326241002015702 0ustar twernertwerner#include "dsdpsdp.h" #include "dsdpsys.h" /*! \file sdpcompute.c \brief Compute the gradient vector and Hessian matrix. Also compute X matrices */ /* static int tt1=0,tt2=0; DSDPEventLogBegin(tt1); DSDPEventLogBegin(tt2); DSDPEventLogEnd(tt2); DSDPEventLogEnd(tt1); if (tt1==0){DSDPEventLogRegister("SDP T1 Event",&tt1);} if (tt2==0){DSDPEventLogRegister("SDP T2 Event",&tt2);} */ #undef __FUNCT__ #define __FUNCT__ "SDPConeComputeHessian" /*! \fn int SDPConeComputeHessian( SDPCone sdpcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2); \brief Compute the Hessian to the barrier term. \param sdpcone cone \param mu barrier parameter \param M Schur matrix to insert elements. \param vrhs1 dual objectvive gradient. \param vrhs2 barrier gradient */ int SDPConeComputeHessian( SDPCone sdpcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ int i,k,kt,kk,m,n,rank,info; int ncols,ii,idA; double rtemp,ack,ggamma,bmu,scl; double rhs1i,rhs2i; DSDPTruth method1; SDPConeVec W,W2; DSDPVec MRowI=sdpcone->Work, Select=sdpcone->Work2; DSDPDataMat AA; DSDPDualMat S; DSDPVMat T; DSDPDataTranspose ATranspose=sdpcone->ATR; SDPblk *blk=sdpcone->blk; DSDPIndex IS; /* Evaluate M */ DSDPFunctionBegin; SDPConeValid(sdpcone); info=DSDPVecGetSize(vrhs1,&m);DSDPCHKERR(info); for (i=0; iblk[blockj]; SDPConeVec W=sdp->W,W2=sdp->W2; DSDPDataMat AA; DSDPVMat T=sdp->T; DSDPDualMat S=sdp->S; DSDPTruth method1; DSDPIndex IS=sdp->IS; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); method1=DSDP_TRUE; method1=DSDP_FALSE; if (method1==DSDP_TRUE){ info=DSDPBlockCountNonzeroMatrices(&sdp->ADATA,&nnzmats);DSDPCHKERR(info); for (i=0;iADATA,i,&ii,&scl,&AA);DSDPCHKERR(info); info=DSDPVecGetElement(vrow,ii,&dyiscale);DSDPCHKVARERR(ii,info); if (dyiscale==0) continue; info=DSDPDataMatGetRank(AA,&rank,sdp->n);DSDPCHKVARERR(ii,info); for (k=0; kADATA,1.0,vrow,T,vrhs2);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeMultiply" /*! \fn int SDPConeMultiply( SDPCone sdpcone, int blockj, double mu, DSDPVec vrow, DSDPVec vin, DSDPVec vout); \brief Compute the gradient to the barrier term. \param sdpcone semidefinite cone \param blockj block of cone \param mu barrier parameter \param vrow scalar to multiply each element of the product \param vin in vector. \param vout product */ int SDPConeMultiply(SDPCone sdpcone, int blockj, double mu, DSDPVec vrow, DSDPVec vin, DSDPVec vout){ int info,i,ii,k,rank,nnzmats; double dd2,dtmp,dyiscale,ack,scl,vv; SDPblk *sdp=&sdpcone->blk[blockj]; SDPConeVec W=sdp->W,W2=sdp->W2; DSDPDataMat AA; DSDPVMat T=sdp->T; DSDPDSMat DS=sdp->DS; DSDPIndex IS=sdp->IS; DSDPDualMat S=sdp->S; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); info=DSDPVMatZeroEntries(T); DSDPCHKERR(info); info=DSDPBlockASum(&sdp->ADATA,-1.0,vin,T); DSDPCHKERR(info); info=DSDPDSMatSetArray(DS,T); DSDPCHKERR(info); info=DSDPBlockCountNonzeroMatrices(&sdp->ADATA,&nnzmats);DSDPCHKERR(info); for (i=0;iADATA,i,&ii,&scl,&AA);DSDPCHKERR(info); info=DSDPVecGetElement(vrow,ii,&dyiscale);DSDPCHKVARERR(ii,info); if (dyiscale==0) continue; info=DSDPDataMatGetRank(AA,&rank,sdp->n);DSDPCHKVARERR(ii,info); for (dd2=0,k=0; kblk[blockj]; SDPConeVec W=sdp->W,W2=sdp->W2; DSDPDataMat AA; DSDPIndex IS=sdp->IS; DSDPFunctionBegin; info=SDPConeCheckJ(sdpcone,blockj);DSDPCHKERR(info); mu=mu*sdp->gammamu; n=sdp->n; info=DSDPVMatZeroEntries(X);DSDPCHKERR(info); info=DSDPBlockCountNonzeroMatrices(&sdp->ADATA,&nnzmats);DSDPCHKERR(info); for (i=0;iADATA,i,&ii,&scl,&AA);DSDPCHKVARERR(ii,info); info=DSDPVecGetElement(DY,ii,&dyiscale);DSDPCHKVARERR(ii,info); if (dyiscale==0) continue; info=DSDPDataMatGetRank(AA,&rank,n);DSDPCHKVARERR(ii,info); for (k=0; knnzblocks=0; ATranspose->nzblocks=0; ATranspose->idA=0; ATranspose->idAP=0; ATranspose->ttnzmat=0; ATranspose->nnzblocks=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataTransposeSetup" /*! \fn int DSDPDataTransposeSetup(DSDPDataTranspose *ATranspose, SDPblk *blk, int nblocks, int m); \brief Set up transpose structure for data. \param ATranspose transpose structure for data. \param blk semidefinite blocks \param nblocks number of blocks \param m dimension of Y vector. */ int DSDPDataTransposeSetup(DSDPDataTranspose *ATranspose, SDPblk *blk, int nblocks, int m){ int i,ii,kk,vvar,info; int nnzmats,tnzmats=0; DSDPFunctionBegin; info=DSDPDataTransposeTakeDown(ATranspose);DSDPCHKERR(info); /* Determine sparsity pattern of SDP Data Matrices */ DSDPCALLOC2(&ATranspose->nnzblocks,int,(m),&info);DSDPCHKERR(info); DSDPCALLOC2(&ATranspose->nzblocks,int*,(m),&info);DSDPCHKERR(info); DSDPCALLOC2(&ATranspose->idA,int*,(m),&info);DSDPCHKERR(info); ATranspose->m=m; for (i=0;innzblocks[i]=0; } for (kk=0; kknnzblocks);DSDPCHKERR(info); } for (tnzmats=0,i=0;innzblocks[i];} DSDPCALLOC2(&ATranspose->ttnzmat,int,tnzmats,&info);DSDPCHKERR(info); ATranspose->nzblocks[0]=ATranspose->ttnzmat; for (i=1;inzblocks[i]=ATranspose->nzblocks[i-1]+ATranspose->nnzblocks[i-1]; } DSDPCALLOC2(&ATranspose->idAP,int,tnzmats,&info);DSDPCHKERR(info); ATranspose->idA[0]=ATranspose->idAP; for (i=1;iidA[i]=ATranspose->idA[i-1]+ATranspose->nnzblocks[i-1]; } for (i=0;innzblocks[i]=0;} for (kk=0; kknnzblocks[ii]; ATranspose->nzblocks[ii][vvar]=kk; ATranspose->idA[ii][vvar]=i; ATranspose->nnzblocks[ii]++; } } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPDataTransposeTakeDown" /*! \fn int DSDPDataTransposeTakeDown(DSDPDataTranspose *ATranspose); \brief Free transpose structure for data. \param ATranspose transpose structure for data. */ int DSDPDataTransposeTakeDown(DSDPDataTranspose *ATranspose){ int info; DSDPFunctionBegin; DSDPFREE(&ATranspose->ttnzmat,&info);DSDPCHKERR(info); DSDPFREE(&ATranspose->idAP,&info);DSDPCHKERR(info); DSDPFREE(&ATranspose->nzblocks,&info);DSDPCHKERR(info); DSDPFREE(&ATranspose->nnzblocks,&info);DSDPCHKERR(info); DSDPFREE(&ATranspose->idA,&info);DSDPCHKERR(info); info=DSDPDataTransposeInitialize(ATranspose);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateSDPCone" /*! \fn int DSDPCreateSDPCone(DSDP dsdp, in nblocks, SDPCone *sdpcone); \brief Create a semidefinite matrix cone with one or more blocks. \ingroup SDPBasic \param dsdp the solver \param nblocks number of blocks \param sdpcone the new semidefinite cone with multiple blocks \sa DSDPCreate() \sa SDPConeSetASparseVecMat() */ int DSDPCreateSDPCone(DSDP dsdp, int blocks, SDPCone* dspcone){ int i,info; SDPCone sdpcone; DSDPFunctionBegin; DSDPCALLOC1(&sdpcone,struct SDPCone_C,&info);DSDPCHKERR(info); *dspcone=sdpcone; sdpcone->keyid=SDPCONEKEY; info=DSDPAddSDP(dsdp,sdpcone);DSDPCHKERR(info); info=DSDPGetNumberOfVariables(dsdp,&sdpcone->m);DSDPCHKERR(info); DSDPCALLOC2(&sdpcone->blk,SDPblk,blocks,&info); DSDPCHKERR(info); for (i=0;iblk[i]); DSDPCHKBLOCKERR(i,info); } sdpcone->nblocks=blocks; sdpcone->optype=3; info=DSDPUseDefaultDualMatrix(sdpcone); DSDPCHKERR(info); sdpcone->nn=0; sdpcone->dsdp=dsdp; info=DSDPDataTransposeInitialize(&sdpcone->ATR); DSDPCHKERR(info); info=DSDPBlockEventZero();DSDPCHKERR(info); info=DSDPDualMatEventZero();DSDPCHKERR(info); info=DSDPVMatEventZero();DSDPCHKERR(info); DSDPFunctionReturn(0); } int DSDPCreateS(DSDPBlockData*,char,int,DSDPVec,DSDPVMat,SDPConeVec,SDPConeVec,DSDPDualMat*, DSDPDualMat*, DSDPDSMat*, void*); #undef __FUNCT__ #define __FUNCT__ "DSDPBlockSetup" /*! \fn int DSDPBlockSetup(SDPblk *blk, int blockj, DSDPVec WY); \brief Allocate data structures of one block the cone. \param blk block in semidefinite cone \param blockj block number \param WY sample variable vector. */ int DSDPBlockSetup(SDPblk *blk, int blockj, DSDPVec WY){ int n,info,trank,flag; DSDPFunctionBegin; /* info=DSDPBlockTakeDown(blk);DSDPCHKERR(info); */ n=blk->n; info=DSDPVMatExist(blk->T,&flag);DSDPCHKERR(info); if (flag==0){ info=DSDPMakeVMat(blk->format,n,&blk->T);DSDPCHKERR(info); } info = DSDPIndexCreate(blk->n,&blk->IS);DSDPCHKERR(info); info = SDPConeVecCreate(blk->n,&blk->W);DSDPCHKERR(info); info = SDPConeVecDuplicate(blk->W,&blk->W2);DSDPCHKERR(info); /* Build Lanczos structures */ info=DSDPSetMaximumLanczosIterations(&blk->Lanczos,20); DSDPCHKERR(info); if (n>30){info=DSDPSetMaximumLanczosIterations(&blk->Lanczos,20); DSDPCHKERR(info);} if (n>300){info=DSDPSetMaximumLanczosIterations(&blk->Lanczos,40); DSDPCHKERR(info);} if (n>1000){info=DSDPSetMaximumLanczosIterations(&blk->Lanczos,50); DSDPCHKERR(info);} if (1){ info=DSDPFastLanczosSetup(&blk->Lanczos,blk->W);DSDPCHKERR(info); DSDPLogInfo(0,19,"SDP Block %d using Fast Lanczos\n",blockj); } else { info=DSDPRobustLanczosSetup(&blk->Lanczos,blk->W);DSDPCHKERR(info); DSDPLogInfo(0,19,"SDP Block %d using Full Lanczos\n",blockj); } /* Eigenvalues and Eigenvectors */ info=DSDPBlockFactorData(&blk->ADATA,blk->T,blk->W);DSDPCHKERR(info); info=DSDPBlockDataRank(&blk->ADATA,&trank,n);DSDPCHKERR(info); info=DSDPCreateS(&blk->ADATA,blk->format,trank,WY,blk->T,blk->W,blk->W2,&blk->S,&blk->SS,&blk->DS,0);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeBlockNNZ" int SDPConeBlockNNZ(SDPblk *blk,int m){ int i,ii,n,info,nnz,nnzmats,tnnzmats,tnnz=0; double scl; DSDPDataMat AA; DSDPFunctionBegin; nnzmats=blk->ADATA.nnzmats;tnnzmats=nnzmats; n=blk->n; for (i=0;iADATA,i,&ii,&scl,&AA);DSDPCHKERR(info); if (ii==0){tnnzmats--; continue;} if (ii==m-1){continue;} info = DSDPDataMatCountNonzeros(AA,&nnz,n); DSDPCHKERR(info); tnnz+= (nnz*(tnnzmats-i)); } if (tnnzmats>1){ tnnz=tnnz/((tnnzmats)*(tnnzmats+1)/2); } if (tnnz<1) tnnz = 1; blk->nnz=tnnz; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetup2" /*! \fn int SDPConeSetup2(SDPCone sdpcone, DSDPVec yy0, DSDPSchurMat M); \brief Allocate data structure of the cone. \param sdpcone semidefinite cone \param yy0 variable vector \param M Schur matrix. */ int SDPConeSetup2(SDPCone sdpcone, DSDPVec yy0, DSDPSchurMat M){ int kk,n,m,info; double nn=0; SDPblk *blk; DSDPFunctionBegin; info=DSDPVecGetSize(yy0,&m);DSDPCHKERR(info); for (kk=0; kknblocks; kk++){ blk=&sdpcone->blk[kk]; n=blk->n; info=SDPConeBlockNNZ(blk,m);DSDPCHKERR(info); info=DSDPBlockSetup(blk,kk,sdpcone->Work);DSDPCHKERR(info); nn+=n*blk->gammamu; } sdpcone->nn=(int)nn; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeSetup" /*! \fn int SDPConeSetup(SDPCone sdpcone, DSDPVec yy0); \brief Allocate data structure of the cone. \param sdpcone semidefinite cone \param yy0 variable vector */ int SDPConeSetup(SDPCone sdpcone, DSDPVec yy0){ int kk,n,m,info; DSDPFunctionBegin; info = DSDPVecGetSize(yy0,&m);DSDPCHKERR(info); if (m!=sdpcone->m+2){DSDPSETERR(8,"CHECK DIMENSION\n");} info = DSDPVecDuplicate(yy0,&sdpcone->Work);DSDPCHKERR(info); info = DSDPVecDuplicate(yy0,&sdpcone->Work2);DSDPCHKERR(info); info = DSDPVecDuplicate(yy0,&sdpcone->YY);DSDPCHKERR(info); info = DSDPVecDuplicate(yy0,&sdpcone->YX);DSDPCHKERR(info); info = DSDPVecDuplicate(yy0,&sdpcone->DYX);DSDPCHKERR(info); for (kk=0; kknblocks; kk++){ n=sdpcone->blk[kk].n; info=SDPConeSetRIdentity(sdpcone,kk,n,1.0);DSDPCHKERR(info); } info=DSDPDataTransposeSetup(&sdpcone->ATR,sdpcone->blk,sdpcone->nblocks,m); DSDPCHKERR(info); info=DSDPBlockEventInitialize();DSDPCHKERR(info); info=DSDPDualMatEventInitialize();DSDPCHKERR(info); info=DSDPVMatEventInitialize();DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockInitialize" /*! \fn int DSDPBlockInitialize(SDPblk *blk); \brief Initialize data structures in one block of the cone. \param blk block of semidefinite cone */ int DSDPBlockInitialize(SDPblk *blk){ int info; DSDPFunctionBegin; blk->n=0; blk->format='N'; blk->gammamu=1.0; blk->bmu=0.0; blk->nnz=10000000; info = DSDPDualMatInitialize(&blk->S); DSDPCHKERR(info); info = DSDPDualMatInitialize(&blk->SS); DSDPCHKERR(info); info = DSDPDSMatInitialize(&blk->DS); DSDPCHKERR(info); info = DSDPVMatInitialize(&blk->T); DSDPCHKERR(info); info = DSDPLanczosInitialize(&blk->Lanczos); DSDPCHKERR(info); info = DSDPBlockDataInitialize(&blk->ADATA); DSDPCHKERR(info); info = DSDPIndexInitialize(&blk->IS); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPBlockTakeDown" /*! \fn int DSDPBlockTakeDown(SDPblk *blk); \brief Free data structures in one block of the cone. \param blk block of semidefinite cone */ int DSDPBlockTakeDown(SDPblk *blk){ int info; DSDPFunctionBegin; if (!blk){DSDPFunctionReturn(0);} info=DSDPBlockTakeDownData(&blk->ADATA);DSDPCHKERR(info); info=SDPConeVecDestroy(&blk->W);DSDPCHKERR(info); info=SDPConeVecDestroy(&blk->W2);DSDPCHKERR(info); info=DSDPIndexDestroy(&blk->IS);DSDPCHKERR(info); info=DSDPLanczosDestroy(&blk->Lanczos);DSDPCHKERR(info); info=DSDPDualMatDestroy(&blk->SS);DSDPCHKERR(info); info=DSDPDualMatDestroy(&blk->S);DSDPCHKERR(info); info=DSDPDSMatDestroy(&blk->DS);DSDPCHKERR(info); info=DSDPVMatDestroy(&blk->T);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPConeTakeDown" /*! \fn int DSDPConeTakeDown(SDPCone); \brief Free data structure of the cone. \param sdpcone semidefinite cone */ int DSDPConeTakeDown(SDPCone sdpcone){ int blockj,info; DSDPFunctionBegin; for (blockj=0; blockjnblocks; blockj++){ info=DSDPBlockTakeDown(&sdpcone->blk[blockj]);DSDPCHKERR(info); } info=DSDPVecDestroy(&sdpcone->Work);DSDPCHKERR(info); info=DSDPVecDestroy(&sdpcone->Work2);DSDPCHKERR(info); info=DSDPVecDestroy(&sdpcone->YY);DSDPCHKERR(info); info=DSDPVecDestroy(&sdpcone->YX);DSDPCHKERR(info); info=DSDPVecDestroy(&sdpcone->DYX);DSDPCHKERR(info); info=DSDPDataTransposeTakeDown(&sdpcone->ATR);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SDPConeDestroy" /*! \fn int SDPConeDestroy(SDPCone sdpcone); \brief Free data structure of the cone. \param sdpcone semidefinite cone */ int SDPConeDestroy(SDPCone sdpcone){ int blockj,info; DSDPFunctionBegin; info=DSDPConeTakeDown(sdpcone);DSDPCHKERR(info); for (blockj=0; blockjnblocks; blockj++){ info=DSDPBlockDataDestroy(&sdpcone->blk[blockj].ADATA);DSDPCHKERR(info); } DSDPFREE(&sdpcone->blk,&info);DSDPCHKERR(info); DSDPFREE(&sdpcone,&info);DSDPCHKERR(info); info=DSDPBlockEventZero();DSDPCHKERR(info); info=DSDPDualMatEventZero();DSDPCHKERR(info); info=DSDPVMatEventZero();DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/dsdpxmat.c0000644000175000017500000002776110326241002015351 0ustar twernertwerner#include "dsdpxmat_impl.h" #include "dsdpxmat.h" #include "dsdpsys.h" /*! \file dsdpxmat.c \brief Call an implementation of the basic dense matrix array operations. */ #define DSDPNoOperationError(a); { DSDPSETERR1(1,"X Matrix type: %s, Operation not defined. Perhaps no X matrix has been set.\n",(a).dsdpops->matname); } #define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"X Matrix type: %s,\n",(a).dsdpops->matname);} } static int sdpxmatevent=0; #undef __FUNCT__ #define __FUNCT__ "DSDPVMatEventZero" int DSDPVMatEventZero(void){ DSDPFunctionBegin; sdpxmatevent=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatEventInitialize" int DSDPVMatEventInitialize(void){ DSDPFunctionBegin; if (sdpxmatevent==0){DSDPEventLogRegister("SDP X+vv'",&sdpxmatevent);} DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatSetData" /*! \fn int DSDPVMatSetData(DSDPVMat *X, struct DSDPVMat_Ops* ops, void*data); \brief Set opaque pointer an function pointers \param X dense symmetric matrix \param ops function pointers \param data pointer to a matrix structure. */ int DSDPVMatSetData(DSDPVMat *X, struct DSDPVMat_Ops* ops, void*data){ int info; DSDPFunctionBegin; (*X).dsdpops=ops; (*X).matdata=data; info=DSDPVMatTest(*X);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatGetType" int DSDPVMatGetType(DSDPVMat X, int *id){ DSDPFunctionBegin; *id=X.dsdpops->id; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatGetSize" /*! \fn int DSDPVMatGetSize(DSDPVMat X, int *n); \brief Get number of rows and columns. \param X dense symmetric matrix \param n number of rows and columns */ int DSDPVMatGetSize(DSDPVMat X,int*n){ int info; DSDPFunctionBegin; if (X.dsdpops->matgetsize){ info=(X.dsdpops->matgetsize)(X.matdata,n); DSDPChkMatError(X,info); } else { /* DSDPNoOperationError(X); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatDestroy" /*! \fn int DSDPVMatDestroy(DSDPVMat *X); \brief Deallocate matrix. \param X dense symmetric matrix */ int DSDPVMatDestroy(DSDPVMat *X){ int info; DSDPFunctionBegin; if (!(*X).dsdpops){ return 0;} if ((*X).dsdpops->matdestroy){ info=((*X).dsdpops->matdestroy)((*X).matdata); DSDPChkMatError(*X,info); } else { /* DSDPNoOperationError(*X); */ } info=DSDPVMatInitialize(X); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatView" /*! \fn int DSDPVMatView(DSDPVMat X); \brief Print matrix. \param X dense symmetric matrix */ int DSDPVMatView(DSDPVMat X){ int info; if (X.dsdpops->matview){ info=(X.dsdpops->matview)(X.matdata); DSDPChkMatError(X,info); } else { printf("No viewer available for matrix type: %d",X.dsdpops->id); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatZeroEntries" /*! \fn int DSDPVMatZeroEntries(DSDPVMat X); \brief Zero matrix. \param X dense symmetric matrix */ int DSDPVMatZeroEntries(DSDPVMat X){ int info; DSDPFunctionBegin; if (X.dsdpops->matzeroentries){ info=(X.dsdpops->matzeroentries)(X.matdata); DSDPChkMatError(X,info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatScaleDiagonal" /*! \fn int DSDPVMatScaleDiagonal(DSDPVMat X, double dscale); \brief Scaling diagonal is useful for inner products and norms \param X dense symmetric matrix \param dscale Semidefinite blocks scale the diagonal by half before taking the dot product with the data matrices. */ int DSDPVMatScaleDiagonal(DSDPVMat X, double dscale){ int info; DSDPFunctionBegin; if (X.dsdpops->matscalediagonal){ info=(X.dsdpops->matscalediagonal)(X.matdata,dscale); DSDPChkMatError(X,info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatShiftDiagonal" /*! \fn int DSDPVMatShiftDiagonal(DSDPVMat X, double dadd); \brief Add something to diagonal elements. \param X dense symmetric matrix \param dadd */ int DSDPVMatShiftDiagonal(DSDPVMat X, double dadd){ int info; DSDPFunctionBegin; if (X.dsdpops->matshiftdiagonal){ info=(X.dsdpops->matshiftdiagonal)(X.matdata,dadd); DSDPChkMatError(X,info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatNormF2" /*! \fn int DSDPVMatNormF2(DSDPVMat X, double* normf2); \brief Compute square of Frobenius norm of matrix. \param X dense symmetric matrix \param normf2 square of Frobenious norm. */ int DSDPVMatNormF2(DSDPVMat X, double*normf2){ int info,n; double *dd; DSDPFunctionBegin; if (X.dsdpops->matfnorm2){ info=DSDPVMatGetArray(X,&dd,&n); DSDPCHKERR(info); info=(X.dsdpops->matfnorm2)(X.matdata,n,normf2); DSDPChkMatError(X,info); info=DSDPVMatRestoreArray(X,&dd,&n); DSDPCHKERR(info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatGetArray" /*! \fn int DSDPVMatGetArray(DSDPVMat X, double **v, int *nn); \brief Get the array that stores the matrix. \param X dense symmetric matrix \param v array representing the matrix. \param nn length of the array \sa SDPConeSetStorageFormat() */ int DSDPVMatGetArray(DSDPVMat X, double **v, int *nn){ int info; DSDPFunctionBegin; if (X.dsdpops->matgeturarray){ info=(X.dsdpops->matgeturarray)(X.matdata,v,nn); DSDPChkMatError(X,info); } else { *v=0; *nn=0; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatRestoreArray" /*! \fn int DSDPVMatRestoreArray(DSDPVMat X, double **v, int *nn); \brief Restore the array that stores the matrix. \param X dense symmetric matrix \param v array representing the matrix. \param nn length of the array \sa SDPConeSetStorageFormat() */ int DSDPVMatRestoreArray(DSDPVMat X, double **v, int *nn){ int info; DSDPFunctionBegin; if (X.dsdpops->matrestoreurarray){ info=(X.dsdpops->matrestoreurarray)(X.matdata,v,nn); DSDPChkMatError(X,info); } else { *v=0; *nn=0; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatMinEigenvalue" int DSDPVMatMinEigenvalue(DSDPVMat X, SDPConeVec W1, SDPConeVec W2, double *mineig){ int n,info; double *w,*iwork; DSDPFunctionBegin; if (X.dsdpops->matmineig){ info=SDPConeVecGetSize(W1,&n); DSDPCHKERR(info); info=SDPConeVecGetArray(W1,&w); DSDPCHKERR(info); info=SDPConeVecGetArray(W2,&iwork); DSDPCHKERR(info); info=(X.dsdpops->matmineig)(X.matdata,w,iwork,n,mineig); DSDPChkMatError(X,info); info=SDPConeVecRestoreArray(W1,&w); DSDPCHKERR(info); info=SDPConeVecRestoreArray(W2,&iwork); DSDPCHKERR(info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatAddOuterProduct" /*! \fn int DSDPVMatAddOuterProduct(DSDPVMat X, double alpha, SDPConeVec V); \brief Add outer product of a vector to the matrix. \param X dense symmetric matrix \param alpha scalar multiple of outer product \param V vector. */ int DSDPVMatAddOuterProduct(DSDPVMat X, double alpha, SDPConeVec V){ int info,n; double *v; DSDPFunctionBegin; DSDPEventLogBegin(sdpxmatevent); info=SDPConeVecGetSize(V,&n); DSDPCHKERR(info); if (X.dsdpops->mataddouterproduct){ info=SDPConeVecGetArray(V,&v); DSDPCHKERR(info); info=(X.dsdpops->mataddouterproduct)(X.matdata,alpha,v,n); DSDPChkMatError(X,info); info=SDPConeVecRestoreArray(V,&v); DSDPCHKERR(info); } else { DSDPNoOperationError(X); } DSDPEventLogEnd(sdpxmatevent); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatMult" /*! \fn int DSDPVMatMult(DSDPVMat X, SDPConeVec Z, SDPConeVec Y); \brief Multiply X by a vector. \param X dense symmetric matrix \param Z input vector \param Y equals X * Z */ int DSDPVMatMult(DSDPVMat X, SDPConeVec Z, SDPConeVec Y){ int info,n; double *z,*y; DSDPFunctionBegin; info=SDPConeVecGetSize(Y,&n); DSDPCHKERR(info); if (X.dsdpops->matmult){ info=SDPConeVecGetArray(Z,&z); DSDPCHKERR(info); info=SDPConeVecGetArray(Y,&y); DSDPCHKERR(info); info=(X.dsdpops->matmult)(X.matdata,z,y,n); DSDPChkMatError(X,info); info=SDPConeVecRestoreArray(Z,&z); DSDPCHKERR(info); info=SDPConeVecRestoreArray(Y,&y); DSDPCHKERR(info); } else { DSDPNoOperationError(X); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatCheck" /*! \fn int DSDPVMatCheck(DSDPVMat X, SDPConeVec W1, SDPConeVec W2); \brief Test correctness of operations. \param X dense symmetric matrix \param W1 work vector \param W2 work vector */ int DSDPVMatCheck(DSDPVMat X, SDPConeVec W1, SDPConeVec W2){ int info,i,n,nn; double *xx,eig,eps=1e-13,one=1.0; double fnorm0,fnorm1,fnorm2,fnorm3,fnorm4; DSDPFunctionBegin; info=DSDPVMatGetSize(X,&n);DSDPCHKERR(info); info=SDPConeVecSet(one,W1);DSDPCHKERR(info); info=DSDPVMatAddOuterProduct(X,1.23456,W1);DSDPCHKERR(info); info=DSDPVMatZeroEntries(X);DSDPCHKERR(info); info=DSDPVMatNormF2(X,&fnorm0);DSDPCHKERR(info); if (fabs(fnorm0)>eps){ printf("Check DSDPVMatZero of DSDPVMatNorm\n");} info=SDPConeVecSet(one,W1);DSDPCHKERR(info); info=DSDPVMatAddOuterProduct(X,1.0,W1);DSDPCHKERR(info); info=DSDPVMatNormF2(X,&fnorm1);DSDPCHKERR(info); if (fabs(fnorm1-n*n)>eps) printf("Check DSDPVMatZero()\n"); info=DSDPVMatGetArray(X,&xx,&nn);DSDPCHKERR(info); for (i=0;ieps) printf("Check DSDPXGetArray()\n"); info=DSDPVMatAddOuterProduct(X,-1.0,W1);DSDPCHKERR(info); info=DSDPVMatNormF2(X,&fnorm3);DSDPCHKERR(info); info=DSDPVMatZeroEntries(X);DSDPCHKERR(info); info=DSDPVMatAddOuterProduct(X,1.0,W1);DSDPCHKERR(info); info=DSDPVMatScaleDiagonal(X,2.0);DSDPCHKERR(info); info=DSDPVMatZeroEntries(X);DSDPCHKERR(info); info=DSDPVMatAddOuterProduct(X,1.0,W1);DSDPCHKERR(info); info=DSDPVMatShiftDiagonal(X,1.0);DSDPCHKERR(info); info=DSDPVMatNormF2(X,&fnorm4);DSDPCHKERR(info); info=DSDPVMatMult(X,W1,W2);DSDPCHKERR(info); info=DSDPVMatMinEigenvalue(X,W1,W2,&eig);DSDPCHKERR(info); if (fabs(fnorm0)>eps) printf("Check DSDPVMatZero()\n"); DSDPFunctionReturn(0); } static struct DSDPVMat_Ops dsdpmatops2; static const char *urmatname="NOT SET YET"; #undef __FUNCT__ #define __FUNCT__ "DSDPVMatOpsInitialize" /*! \fn int DSDPVMatOpsInitialize(struct DSDPVMat_Ops*aops); \brief Set function pointers to null \param aops pointer to a structure of function pointers. */ int DSDPVMatOpsInitialize(struct DSDPVMat_Ops*aops){ aops->matgetsize=0; aops->matzeroentries=0; aops->matfnorm2=0; aops->mataddouterproduct=0; aops->matmult=0; aops->matgeturarray=0; aops->matrestoreurarray=0; aops->matview=0; aops->matdestroy=0; aops->matmineig=0; aops->matshiftdiagonal=0; aops->matscalediagonal=0; aops->id=0; aops->matname=urmatname; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatTest" /*! \fn int DSDPVMatTest(DSDPVMat X); \brief Test validity of matrix \param X dense symmetric matrix */ int DSDPVMatTest(DSDPVMat X){ int info; DSDPFunctionBegin; if (X.dsdpops==0 || X.dsdpops==&dsdpmatops2){ } else if (X.dsdpops->mattest){ info=(X.dsdpops->mattest)(X.matdata); DSDPChkMatError(X,info); } else { /* DSDPNoOperationError(X); */ } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatInitialize" /*! \fn int DSDPVMatInitialize(DSDPVMat *B); \brief Set pointers to null \param B dense symmetric matrix */ int DSDPVMatInitialize(DSDPVMat *B){ int info; DSDPFunctionBegin; info=DSDPVMatOpsInitialize(&dsdpmatops2); DSDPCHKERR(info); info=DSDPVMatSetData(B, &dsdpmatops2, 0); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPVMatExist" /*! \fn int DSDPVMatExist(DSDPVMat X, int *flag); \brief Answer whether the array has been allocated or not. \param X dense symmetric matrix \param flag true if the array has been allocated */ int DSDPVMatExist(DSDPVMat X,int *flag){ DSDPFunctionBegin; if (X.dsdpops && X.dsdpops!=&dsdpmatops2) *flag=1; else *flag=0; DSDPFunctionReturn(0); } DSDP5.8/src/sdp/sdpsss.c0000644000175000017500000003521310326241002015033 0ustar twernertwerner#include "dsdpsdp.h" #include "dsdpsys.h" /*! \file sdpsss.c \brief Determine the sparsity of each block, and choose suitable dual, Delta S, and X matrix structures. */ int DSDPCreateS(DSDPBlockData*,char,int,DSDPVec,DSDPVMat,SDPConeVec, SDPConeVec,DSDPDualMat*, DSDPDualMat*, DSDPDSMat*, void*); static int DSDPCreateDS(DSDPBlockData*, DSDPVMat,int*,int,int,int,int*,int*,DSDPDSMat*); static int DSDPCreateDS2(DSDPBlockData*, DSDPVMat,int*,int,int,int,int*,int*,DSDPDSMat*); static int DSDPCreateS1(DSDPBlockData*,int,DSDPVec,DSDPVMat,SDPConeVec, SDPConeVec,DSDPDualMat*, DSDPDualMat*, DSDPDSMat*, void*); static int DSDPCreateS2(DSDPBlockData*,int,DSDPVec,DSDPVMat,SDPConeVec, SDPConeVec,DSDPDualMat*, DSDPDualMat*, DSDPDSMat*, void*); extern int DSDPXMatPCreate(int,struct DSDPVMat_Ops**,void**); extern int DSDPXMatPCreateWithData(int,double[],int,struct DSDPVMat_Ops**,void**); extern int DSDPXMatUCreate(int,struct DSDPVMat_Ops**,void**); extern int DSDPXMatUCreateWithData(int,double[],int,struct DSDPVMat_Ops**,void**); extern int DSDPLAPACKSUDualMatCreate2(int,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPLAPACKSUDualMatCreate2P(int,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPLAPACKPUDualMatCreate2(int,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPDiagDualMatCreateP(int,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPDiagDualMatCreateU(int,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPDenseDualMatCreate(int, char,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPSparseDualMatCreate(int, int*, int*, int,char,int*,struct DSDPDualMat_Ops**,void**, struct DSDPDualMat_Ops**,void**); extern int DSDPSparseMatCreatePattern2P(int,int[],int[],int,struct DSDPDSMat_Ops**,void**); extern int DSDPSparseMatCreatePattern2U(int,int[],int[],int,struct DSDPDSMat_Ops**,void**); extern int DSDPCreateDiagDSMatP(int,struct DSDPDSMat_Ops**,void**); extern int DSDPCreateDiagDSMatU(int,struct DSDPDSMat_Ops**,void**); extern int DSDPCreateDSMatWithArray(int,double[],int,struct DSDPDSMat_Ops**,void**); extern int DSDPCreateDSMatWithArray2(int,double[],int, struct DSDPDSMat_Ops**,void**); extern int DSDPCreateURDSMat(int,struct DSDPDSMat_Ops**,void**); /* #undef __FUNCT__ #define __FUNCT__ "DSDPSetDualMatrix" int DSDPSetDualMatrix(SDPCone sdpcone,int (*createdualmatrix)(DSDPBlockData*,DSDPVec,DSDPVMat,SDPConeVec,SDPConeVec,DSDPDualMat*, DSDPDualMat*, DSDPDSMat*, void*),void*ctx){ DSDPFunctionBegin; sdpcone->createdualmatrix=createdualmatrix; sdpcone->dualmatctx=ctx; DSDPFunctionReturn(0); } */ #undef __FUNCT__ #define __FUNCT__ "CountNonzeros" static int CountNonzeros(DSDPBlockData *ADATA,int m, int rnnz[], int innz[],int n,int *nnz1, int *nnz2) { int i,j,info,totalnnz1=0,totalnnz2=0; for (i=0;i0) totalnnz1++;} /* Adjacency pattern for S also requires the objective matrix C */ for (j=0;j0) totalnnz2++;} } *nnz1=totalnnz1; *nnz2=totalnnz2; return 0; } #undef __FUNCT__ #define __FUNCT__ "CreateS1b" static int CreateS1b(DSDPBlockData *ADATA, int innz[], int m, int n, int tnnz[], int rnnz[], int snnz[]) { int i,j,info; if (ADATA->nnzmats<=0){return 0;}; memset(rnnz,0,n*sizeof(int)); for (i=0;i0){ *snnz=j; snnz++; rnnz[i]++;} } } return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDS" int DSDPCreateDS(DSDPBlockData *ADATA, DSDPVMat T, int iworkm[], int m, int n, int nnz, int rnnz[], int tnnz[], DSDPDSMat *B){ int i,n1,*cols,allnnz,info; double *ss; void *dsmat; struct DSDPDSMat_Ops* dsops; DSDPFunctionBegin; DSDPLogInfo(0,19,"DS Matrix has %d nonzeros of %d\n",nnz,n*(n-1)/2); if (nnz==0){ info=DSDPCreateDiagDSMatP(n,&dsops,&dsmat); DSDPCHKERR(info); DSDPLogInfo(0,19,"Using Diagonal Delta S matrix\n"); } else if (2*nnz +n < n*n/5){ info=DSDPVMatGetArray(T,&ss,&n1); DSDPCHKERR(info); cols=(int*)ss; info = CreateS1b(ADATA, iworkm, m, n, tnnz, rnnz, cols); DSDPCHKERR(info); for (allnnz=0,i=0;i0){ *snnz=j; snnz++; rnnz[i]++;} } } return 0; } static int dsdpuselapack=1; #undef __FUNCT__ #define __FUNCT__ "SDPConeUseLAPACKForDualMatrix" int SDPConeUseLAPACKForDualMatrix(SDPCone sdpcone,int flag){ DSDPFunctionBegin; dsdpuselapack = flag; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateS" static int DSDPCreateS1(DSDPBlockData *ADATA, int trank, DSDPVec WY, DSDPVMat T, SDPConeVec W1, SDPConeVec W2, DSDPDualMat *S, DSDPDualMat *SS, DSDPDSMat *DS, void*ctx){ int nnz,n,n1,*cols,*rnnz,*tnnz,*iworkm,m,info; int dsnnz,snnz,sfnnz; double *pss; void *smat1,*smat2; struct DSDPDualMat_Ops *sops1,*sops2; DSDPFunctionBegin; info=DSDPVecGetSize(WY,&m);DSDPCHKERR(info); info=DSDPVecGetArray(WY,&pss);DSDPCHKERR(info); iworkm=(int*)pss; info=SDPConeVecGetSize(W1,&n);DSDPCHKERR(info); info=SDPConeVecGetArray(W1,&pss);DSDPCHKERR(info); tnnz=(int*)pss; info=SDPConeVecGetArray(W2,&pss);DSDPCHKERR(info); rnnz=(int*)pss; DSDPLogInfo(0,19,"Compute Sparsity\n"); info = CountNonzeros(ADATA, m, rnnz, iworkm, n, &dsnnz,&snnz); DSDPCHKERR(info); nnz=snnz; /* printf("Nonzeros: %d %d of %d\n",dsnnz,snnz,n*(n-1)/2); */ /* TT and DS could share memory */ info=DSDPCreateDS(ADATA,T,iworkm,m,n,dsnnz,rnnz,tnnz,DS);DSDPCHKERR(info); if (nnz==0){ info=DSDPDiagDualMatCreateP(n,&sops1,&smat1,&sops2,&smat2); DSDPCHKERR(info); DSDPLogInfo(0,19,"Using Diagonal S matrix\n"); } else if (2*snnz+n+220 && dsdpuselapack){ info=DSDPLAPACKSUDualMatCreate2P(n,&sops1,&smat1,&sops2,&smat2); DSDPCHKERR(info); DSDPLogInfo(0,19,"Count %d of %d nonzeros: Using Full Dense LAPACK S matrix\n",nnz,n*(n-1)/2); } else if (dsdpuselapack){ info=DSDPLAPACKPUDualMatCreate2(n,&sops1,&smat1,&sops2,&smat2); DSDPCHKERR(info); DSDPLogInfo(0,19,"Count %d of %d nonzeros: Using Packed Dense LAPACK S matrix\n",nnz,n*(n-1)/2); } else { info=DSDPDenseDualMatCreate(n,'P',&sops1,&smat1,&sops2,&smat2); DSDPCHKERR(info); DSDPLogInfo(0,19,"Count %d of %d nonzeros: Using Dense S matrix\n",nnz,n*(n-1)/2); } info=DSDPDualMatSetData(S,sops1,smat1); DSDPCHKERR(info); info=DSDPDualMatSetData(SS,sops2,smat2); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateDS2" int DSDPCreateDS2(DSDPBlockData *ADATA, DSDPVMat T, int iworkm[], int m, int n, int nnz, int rnnz[], int tnnz[], DSDPDSMat *B){ int i,n1,*cols,allnnz,info; double *ss; void *dsmat; struct DSDPDSMat_Ops* dsops; DSDPFunctionBegin; DSDPLogInfo(0,19,"DS Matrix has %d nonzeros of %d\n",nnz,n*(n-1)/2); if (nnz==0){ info=DSDPCreateDiagDSMatU(n,&dsops,&dsmat); DSDPCHKERR(info); DSDPLogInfo(0,19,"Using Diagonal Delta S matrix\n"); } else if (2*nnz +n < n*n/4){ info=DSDPVMatGetArray(T,&ss,&n1); DSDPCHKERR(info); cols=(int*)ss; info = CreateS1b(ADATA, iworkm, m, n, tnnz, rnnz, cols); DSDPCHKERR(info); for (allnnz=0,i=0;inblocks; kk++){ info=SDPConeMultiply(sdpcone,kk,mu,vrow,vin,vout);DSDPCHKBLOCKERR(kk,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KDPConeRHS " static int KSDPConeRHS( void *K, double mu, DSDPVec vrow, DSDPVec vrhs1, DSDPVec vrhs2){ int kk,info; SDPCone sdpcone=(SDPCone)K; DSDPFunctionBegin; SDPConeValid(sdpcone); for (kk=0; kknblocks; kk++){ if (sdpcone->blk[kk].n<1) continue; info=SDPConeComputeRHS(sdpcone,kk,mu,vrow,vrhs1,vrhs2); DSDPCHKBLOCKERR(kk,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeSetup" static int KSDPConeSetup(void* K, DSDPVec y){ int info; SDPCone sdpcone=(SDPCone)K; DSDPFunctionBegin; SDPConeValid(sdpcone); info=SDPConeSetup(sdpcone,y);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeSetup2" static int KSDPConeSetup2(void* K, DSDPVec y, DSDPSchurMat M){ int info; SDPCone sdpcone=(SDPCone)K; DSDPFunctionBegin; info=SDPConeSetup2(sdpcone,y,M); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeDestroy" static int KSDPConeDestroy(void* K){ int info; SDPCone sdpcone=(SDPCone)K; DSDPFunctionBegin; SDPConeValid(sdpcone); info=SDPConeDestroy(sdpcone);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeSize" static int KSDPConeSize(void* K,double *n){ SDPCone sdpcone=(SDPCone)K; DSDPFunctionBegin; SDPConeValid(sdpcone); *n=sdpcone->nn; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeSparsity" static int KSDPConeSparsity(void *K,int row, int *tnnz, int rnnz[], int m){ SDPCone sdpcone=(SDPCone)K; SDPblk *blk=sdpcone->blk; int info,j,kk; int nnzblocks=sdpcone->ATR.nnzblocks[row],*nzblocks=sdpcone->ATR.nzblocks[row]; DSDPFunctionBegin; SDPConeValid(sdpcone); for (j=0; jblk; DSDPTruth psdefinite; DSDPDualMat SS; DSDPFunctionBegin; psdefinite = DSDP_TRUE; for (kk=sdpcone->nblocks-1; kk>=0 && psdefinite == DSDP_TRUE; kk--){ if (blk[kk].n<1) continue; if (flag==DUAL_FACTOR) SS=blk[kk].S; else SS=blk[kk].SS; switch (sdpcone->optype){ default: info=SDPConeComputeSS(sdpcone,kk,Y,blk[kk].T);DSDPCHKBLOCKERR(kk,info); info=DSDPDualMatSetArray(SS,blk[kk].T); DSDPCHKBLOCKERR(kk,info); info=DSDPDualMatCholeskyFactor(SS,&psdefinite); DSDPCHKBLOCKERR(kk,info); if (psdefinite == DSDP_FALSE){ if (flag==DUAL_FACTOR){ DSDPLogInfo(0,2,"Dual SDP Block %2.0f not PSD\n",kk); } else { DSDPLogInfo(0,2,"Primal SDP Block %2.0f not PSD\n",kk); } } break; } } *ispsdefinite=psdefinite; if (flag==DUAL_FACTOR && psdefinite==DSDP_TRUE){ info=DSDPVecCopy(Y,sdpcone->YY);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeInvertSS" static int KSDPConeInvertSS(void *K){ int kk,info; SDPCone sdpcone=(SDPCone)K; DSDPDualMat SS; DSDPFunctionBegin; SDPConeValid(sdpcone); for (kk=0;kknblocks;kk++){ if (sdpcone->blk[kk].n<1) continue; SS=sdpcone->blk[kk].S; info=DSDPDualMatInvert(SS);DSDPCHKBLOCKERR(kk,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeComputeMaxStepLength" static int KSDPConeComputeMaxStepLength(void *K, DSDPVec DY, DSDPDualFactorMatrix flag, double *maxsteplength){ int kk,info; double smaxstep,maxmaxstep=1.0e20; SDPCone sdpcone=(SDPCone)K; DSDPDualMat SS; SDPblk *blk=sdpcone->blk; DSDPDSMat DS; DSDPVMat T; DSDPFunctionBegin; SDPConeValid(sdpcone); for (kk=0; kknblocks; kk++){ if (blk[kk].n<1) continue; if (flag==DUAL_FACTOR) SS=blk[kk].S; else SS=blk[kk].SS; DS=blk[kk].DS; T=blk[kk].T; info=SDPConeComputeSS(sdpcone,kk,DY,T);DSDPCHKBLOCKERR(kk,info); info=DSDPDSMatSetArray(DS,T); DSDPCHKBLOCKERR(kk,info); info=DSDPLanczosStepSize( &blk[kk].Lanczos,blk[kk].W,blk[kk].W2,SS,DS,&smaxstep );DSDPCHKBLOCKERR(kk,info); DSDPLogInfo(0,12,"Block %d, PD %d, maxstepsize: %4.4e\n",kk,flag,smaxstep); maxmaxstep=DSDPMin(smaxstep,maxmaxstep); } *maxsteplength=maxmaxstep; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeAddANorm2" static int KSDPConeAddANorm2(void *K, DSDPVec ANorm2){ int kk,info; SDPCone sdpcone=(SDPCone)K; SDPblk *blk=sdpcone->blk; DSDPFunctionBegin; SDPConeValid(sdpcone); for (kk=0; kknblocks; kk++){ if (blk[kk].n<1) continue; info=DSDPBlockANorm2( &blk[kk].ADATA,ANorm2,blk[kk].n); DSDPCHKBLOCKERR(kk,info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeSetX" static int KSDPConeSetX(void *K, double mu, DSDPVec Y,DSDPVec DY){ SDPCone sdpcone=(SDPCone)K; int info; DSDPFunctionBegin; SDPConeValid(sdpcone); info=DSDPVecCopy(Y,sdpcone->YX);DSDPCHKERR(info); info=DSDPVecCopy(DY,sdpcone->DYX);DSDPCHKERR(info); sdpcone->xmakermu=mu; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeComputeXX" static int KSDPConeComputeXX(void *K, double mu, DSDPVec Y,DSDPVec DY,DSDPVec AX,double* tracexs){ SDPCone sdpcone=(SDPCone)K; int info,kk; double xnorm,trxs,xtrace; DSDPVMat X; DSDPFunctionBegin; SDPConeValid(sdpcone); info=KSDPConeSetX(K,mu,Y,DY);DSDPCHKERR(info); for (kk=0; kknblocks; kk++){ if (sdpcone->blk[kk].n<1) continue; X=sdpcone->blk[kk].T; info=SDPConeComputeX3(sdpcone,kk,mu,Y,DY,X);DSDPCHKBLOCKERR(kk,info); info=SDPConeComputeXDot(sdpcone,kk,Y,X,AX,&xtrace,&xnorm,&trxs);DSDPCHKBLOCKERR(kk,info); *tracexs+=trxs; DSDPLogInfo(0,10,"SDP Block %d: norm(X): %4.2e, trace(X): %4.2e, trace(XS): %4.2e.\n",kk,xnorm,xtrace,trxs); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeComputeLogSDeterminant" static int KSDPConeComputeLogSDeterminant(void *K, double *logdetobj, double *logdet){ int kk,info; double dlogdet=0,dlogdet2=0,dd; SDPCone sdpcone=(SDPCone)K; SDPblk *blk=sdpcone->blk; DSDPFunctionBegin; SDPConeValid(sdpcone); for (kk=0; kknblocks; kk++){ if (blk[kk].n<1) continue; info=DSDPDualMatLogDeterminant(blk[kk].S,&dd);DSDPCHKBLOCKERR(kk,info); dlogdet+=dd*blk[kk].gammamu; dlogdet2+=dd*blk[kk].bmu; } *logdet=dlogdet; *logdetobj=dlogdet2; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "KSDPConeMonitor" int KSDPConeMonitor(void *K, int tag){ DSDPFunctionBegin; DSDPFunctionReturn(0); } static struct DSDPCone_Ops kops; static const char *sdpconename ="SDP Cone"; #undef __FUNCT__ #define __FUNCT__ "SDPConeOperationsInitialize" static int SDPConeOperationsInitialize(struct DSDPCone_Ops* coneops){ int info; if (coneops==NULL) return 0; info=DSDPConeOpsInitialize(coneops); DSDPCHKERR(info); coneops->conehessian=KSDPConeComputeHessian; coneops->conerhs=KSDPConeRHS; coneops->conesetup=KSDPConeSetup; coneops->conesetup2=KSDPConeSetup2; coneops->conedestroy=KSDPConeDestroy; coneops->conecomputes=KSDPConeComputeSS; coneops->coneinverts=KSDPConeInvertSS; coneops->conesetxmaker=KSDPConeSetX; coneops->conecomputex=KSDPConeComputeXX; coneops->conemaxsteplength=KSDPConeComputeMaxStepLength; coneops->conelogpotential=KSDPConeComputeLogSDeterminant; coneops->conesize=KSDPConeSize; coneops->conesparsity=KSDPConeSparsity; coneops->conehmultiplyadd=KSDPConeMultiply; coneops->coneanorm2=KSDPConeAddANorm2; coneops->conemonitor=KSDPConeMonitor; coneops->id=1; coneops->name=sdpconename; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPAddSDP" /*! \fn int DSDPAddSDP(DSDP dsdp, SDPCone sdpcone); \brief Pass a semidefinite cone to the solver. \param dsdp solver \param sdpcone semidefinite cone */ int DSDPAddSDP(DSDP dsdp,SDPCone sdpcone){ int info; DSDPFunctionBegin; SDPConeValid(sdpcone); info=SDPConeOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)sdpcone); DSDPCHKERR(info); DSDPFunctionReturn(0); } DSDP5.8/src/sdp/sdpconevec.h0000644000175000017500000000342410326241002015651 0ustar twernertwerner#if !defined(__SDPCONE_VECTORS_H) #define __SDPCONE_VECTORS_H /*! \file sdpconevec.h \brief Each block of the SDPCone has two vectors of appropriate size. */ #include /*! struct SDPConeVec_C \brief Vector whose length corresponds to dimension of a block in a cone. \sa SDPConeVec */ struct SDPConeVec_C{ int dim; double *val; }; typedef struct { int *indx; } DSDPIndex; /*! \typedef struct SDPConeVec_C SDPConeVec; \brief SDPConeVec is a vector with the dimension of the block in the SDP cone. */ typedef struct SDPConeVec_C SDPConeVec; #ifdef __cplusplus extern "C" { #endif extern int SDPConeVecCreate(int,SDPConeVec *); extern int SDPConeVecDuplicate(SDPConeVec,SDPConeVec *); extern int SDPConeVecDot(SDPConeVec, SDPConeVec, double *); extern int SDPConeVecView( SDPConeVec); extern int SDPConeVecDestroy(SDPConeVec*); #define SDPConeVecCreateWArray(a,b,c) 0;{ (*(a)).val=(b); (*(a)).dim=(c);} extern int SDPConeVecSet(double, SDPConeVec ); extern int SDPConeVecZero(SDPConeVec ); extern int SDPConeVecNormalize(SDPConeVec ); extern int SDPConeVecAXPY(double, SDPConeVec, SDPConeVec); extern int SDPConeVecNorm2( SDPConeVec, double *); extern int SDPConeVecCopy( SDPConeVec, SDPConeVec); extern int SDPConeVecScale(double, SDPConeVec); #define SDPConeVecGetArray(a,b) 0;{ *(b)=((a).val); } #define SDPConeVecRestoreArray(a,b) 0;{ *(b)=0;} #define SDPConeVecGetSize(a,b) 0;{ *(b)=((a).dim); } /*! typedef struct { int *indx; } DSDPIndex; \brief Identifies sparsity in SDPConeVec. */ extern int DSDPIndexInitialize(DSDPIndex*); extern int DSDPIndexDestroy(DSDPIndex*); extern int DSDPIndexSetBasis(DSDPIndex, int); extern int DSDPIndexCreate(int,DSDPIndex*); extern int DSDPIndexView(DSDPIndex); #ifdef __cplusplus } #endif #endif DSDP5.8/src/sdp/sdpconevec.c0000644000175000017500000001325010326241002015642 0ustar twernertwerner#include "dsdpsys.h" #include "sdpconevec.h" #include "dsdplapack.h" /*! \file sdpconevec.c \brief Implementation of the SDPCone vector operations. */ #define SDPConeVecCheck(a,b) {if (a.dim != b.dim) return 1; if (a.dim>0 && (a.val==NULL || b.val==NULL) ) return 2;} static int nvecs=0; #undef __FUNCT__ #define __FUNCT__ "SDPConeVecCreate" int SDPConeVecCreate(int n ,SDPConeVec *V){ int info; V->dim=n; if (n>0){ nvecs++; DSDPCALLOC2(&(V->val),double,n,&info);DSDPCHKERR(info); } else { V->val=NULL; } return 0; } #undef __FUNCT__ #define __FUNCT__ "SDPConeVecDestroy" int SDPConeVecDestroy(SDPConeVec *V){ int info; if ((*V).val){ DSDPFREE(&(*V).val,&info);DSDPCHKERR(info); nvecs--; } (*V).dim=0; (*V).val=0; return 0; } #undef __FUNCT__ #define __FUNCT__ "SDPConeVecView" /*! \fn int SDPConeVecView(SDPConeVec V) \brief Print the elements of the vector \param V the vector */ int SDPConeVecView(SDPConeVec V){ int i; for (i=0; iindx=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPIndexCreate" /*! \fn int DSDPIndexCreate(int n, DSDPIndex *IS); \brief Allocate array for indices \param n dimension of block or vector associated with it. \param IS indices */ int DSDPIndexCreate(int n,DSDPIndex *IS){ int info,*is; DSDPFunctionBegin; DSDPCALLOC2(&is,int,n+1,&info); IS->indx=is;is[0]=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPIndexDestroy" /*! \fn int DSDPIndexDestroy(DSDPIndex *IS); \brief Deallocate memory \param IS indices */ int DSDPIndexDestroy(DSDPIndex *IS){ int info; DSDPFunctionBegin; DSDPFREE(&IS->indx,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPIndexView" /*! \fn int DSDPIndexView(DSDPIndex IS); \brief Print indices \param IS indices */ int DSDPIndexView(DSDPIndex IS){ int i; DSDPFunctionBegin; printf("Index Set with %d indices.\n",IS.indx[0]); for (i=0;i #include #include #include /*! \file dsdplp.c \brief Set linear inequalities in (D) and implement the DSDPCone operations */ typedef struct { int nrow; int ncol; int owndata; const double *an; const int *col; const int *nnz; int *nzrows; int nnzrows; } smatx; /*! struct LPCone_C ; Internal Structure of LP variables. */ struct LPCone_C{ smatx *A,*AT; DSDPVec C; DSDPVec PS,DS,X; double sscale; double r; double muscale; DSDPVec Y,WY,WY2,WX,WX2; double *xout; int n,m; }; static int CreateSpRowMatWdata(int,int,const double[], const int[], const int[],smatx **); static int SpRowMatMult(smatx*,const double[], int , double[], int); static int SpRowMatMultTrans(smatx *, const double[],int, double[],int); static int SpRowMatGetRowVector(smatx*, int, double*,int); static int SpRowMatGetScaledRowVector(smatx*, int, const double[], double*, int); static int SpRowMatDestroy(smatx*); static int SpRowMatView(smatx*); /* static int SpRowMatGetSize(smatx *, int *, int *); static int SpRowMatZero(smatx*); static int SpRowMatAddRowMultiple(smatx*, int, double, double[], int); */ static int SpRowIMultAdd(smatx*,int*,int,int *,int); static int SpRowMatRowNnz(smatx*, int, int*,int); static int SpRowMatNorm2(smatx*, int, double*); #undef __FUNCT__ #define __FUNCT__ "LPConeSetUp" static int LPConeSetup(void *dcone,DSDPVec y){ int m,info; LPCone lpcone=(LPCone)dcone; DSDPFunctionBegin; if (lpcone->n<1) return 0; m=lpcone->m; info=DSDPVecCreateSeq(m+2,&lpcone->WY);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->WY,&lpcone->WY2);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->WY,&lpcone->Y);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->WX);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->WX2);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->PS);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->DS);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->X);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSetUp2" static int LPConeSetup2(void *dcone, DSDPVec Y, DSDPSchurMat M){ LPCone lpcone=(LPCone)dcone; DSDPFunctionBegin; DSDPLogInfo(0,19,"Setup LP Cone of dimension: %d\n",lpcone->n); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeDestroy" static int LPConeDestroy(void *dcone){ int info; LPCone lpcone=(LPCone)dcone; DSDPFunctionBegin; if (lpcone->n<1) return 0; info=DSDPVecDestroy(&lpcone->DS);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->PS);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->C);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->X);DSDPCHKERR(info); info=SpRowMatDestroy(lpcone->A);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->WX2);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->WY2);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->WY);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->Y);DSDPCHKERR(info); info=DSDPVecDestroy(&lpcone->WX);DSDPCHKERR(info); DSDPFREE(&lpcone,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSize" static int LPConeSize(void *dcone, double *n){ LPCone lpcone=(LPCone)dcone; DSDPFunctionBegin; *n=lpcone->muscale*lpcone->n; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPComputeAX" static int LPComputeAX( LPCone lpcone,DSDPVec X, DSDPVec Y){ int info,m=lpcone->m,n=lpcone->n; double *x,*y,ppobj; smatx *A=lpcone->A; DSDPFunctionBegin; if (lpcone->n<1) return 0; info=DSDPVecGetSize(X,&n);DSDPCHKERR(info); info=DSDPVecDot(lpcone->C,X,&ppobj);DSDPCHKERR(info); info=DSDPVecSetC(Y,ppobj); info=DSDPVecSum(X,&ppobj);DSDPCHKERR(info); info=DSDPVecSetR(Y,ppobj*lpcone->r);DSDPCHKERR(info); info=DSDPVecGetArray(Y,&y);DSDPCHKERR(info); info=DSDPVecGetArray(X,&x);DSDPCHKERR(info); info=SpRowMatMult(A,x,n,y+1,m); info=DSDPVecRestoreArray(X,&x);DSDPCHKERR(info); info=DSDPVecRestoreArray(Y,&y);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPComputeATY" static int LPComputeATY(LPCone lpcone,DSDPVec Y, DSDPVec S){ int info,m=lpcone->m,n=lpcone->n; double cc,r,*s,*y; DSDPVec C=lpcone->C; smatx *A=lpcone->A; DSDPFunctionBegin; if (lpcone->n<1) return 0; info=DSDPVecGetC(Y,&cc);DSDPCHKERR(info); info=DSDPVecGetR(Y,&r);DSDPCHKERR(info); info=DSDPVecGetSize(S,&n);DSDPCHKERR(info); info=DSDPVecGetArray(S,&s);DSDPCHKERR(info); info=DSDPVecGetArray(Y,&y);DSDPCHKERR(info); info=SpRowMatMultTrans(A,y+1,m,s,n); DSDPCHKERR(info); info=DSDPVecRestoreArray(S,&s);DSDPCHKERR(info); info=DSDPVecRestoreArray(Y,&y);DSDPCHKERR(info); info=DSDPVecAXPY(cc,C,S);DSDPCHKERR(info); info=DSDPVecShift(r*lpcone->r,S);DSDPCHKERR(info); info=DSDPVecScale(-1.0,S);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeHessian" static int LPConeHessian(void* dcone, double mu, DSDPSchurMat M, DSDPVec vrhs1, DSDPVec vrhs2){ int info,i,m,n,ncols; double r=1.0,*wx,*wx2; LPCone lpcone=(LPCone)dcone; DSDPVec WX=lpcone->WX,WX2=lpcone->WX2,WY=lpcone->WY,WY2=lpcone->WY2,S=lpcone->DS; smatx *A=lpcone->A; DSDPFunctionBegin; if (lpcone->n<1) return 0; mu*=lpcone->muscale; info=DSDPVecGetSize(vrhs1,&m);DSDPCHKERR(info); info=DSDPVecGetSize(WX,&n);DSDPCHKERR(info); info=DSDPVecSet(mu,WX2);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX2,S,WX2);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX2,S,WX2);DSDPCHKERR(info); for (i=0;iC,WX2,WX); DSDPCHKERR(info); } else if (i==m-1){ info=DSDPVecScaleCopy(WX2,r,WX); DSDPCHKERR(info); } else { info=DSDPVecGetArray(WX,&wx); info=DSDPVecGetArray(WX2,&wx2);DSDPCHKERR(info); info=SpRowMatGetScaledRowVector(A,i-1,wx2,wx,n); info=DSDPVecRestoreArray(WX,&wx); info=DSDPVecRestoreArray(WX2,&wx2); } info=LPComputeAX(lpcone,WX,WY);DSDPCHKERR(info); info=DSDPVecPointwiseMult(WY2,WY,WY);DSDPCHKERR(info); info=DSDPSchurMatAddRow(M,i,1.0,WY);DSDPCHKERR(info); } /* Compute AS^{-1} */ info=DSDPVecSet(mu,WX);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX,S,WX);DSDPCHKERR(info); info=LPComputeAX(lpcone,WX,WY);DSDPCHKERR(info); info=DSDPSchurMatDiagonalScaling(M, WY2);DSDPCHKERR(info); info=DSDPVecPointwiseMult(WY2,WY,WY);DSDPCHKERR(info); info=DSDPVecAXPY(1.0,WY,vrhs2);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeHessian" static int LPConeRHS(void* dcone, double mu, DSDPVec vrow, DSDPVec vrhs1, DSDPVec vrhs2){ int info; LPCone lpcone=(LPCone)dcone; DSDPVec WX=lpcone->WX,WY=lpcone->WY,S=lpcone->DS; DSDPFunctionBegin; if (lpcone->n<1) return 0; mu*=lpcone->muscale; /* Compute AS^{-1} */ info=DSDPVecSet(mu,WX);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX,S,WX);DSDPCHKERR(info); info=LPComputeAX(lpcone,WX,WY);DSDPCHKERR(info); info=DSDPVecPointwiseMult(vrow,WY,WY);DSDPCHKERR(info); info=DSDPVecAXPY(1.0,WY,vrhs2);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeMultiply" static int LPConeMultiply(void* dcone, double mu, DSDPVec vrow, DSDPVec vin, DSDPVec vout){ int info; LPCone lpcone=(LPCone)dcone; DSDPVec WX=lpcone->WX,S=lpcone->DS,WY=lpcone->WY; DSDPFunctionBegin; if (lpcone->n<1) return 0; mu*=lpcone->muscale; info=LPComputeATY(lpcone,vin,WX);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX,S,WX);DSDPCHKERR(info); info=DSDPVecScale(mu,WX);DSDPCHKERR(info); info=DSDPVecPointwiseDivide(WX,S,WX);DSDPCHKERR(info); info=LPComputeAX(lpcone,WX,WY);DSDPCHKERR(info); info=DSDPVecPointwiseMult(WY,vrow,WY);DSDPCHKERR(info); info=DSDPVecAXPY(1.0,WY,vout);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSetX" static int LPConeSetX(void* dcone,double mu, DSDPVec Y,DSDPVec DY){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeX" static int LPConeX(void* dcone,double mu, DSDPVec Y,DSDPVec DY, DSDPVec AX , double *tracexs){ int info; double dtracexs; LPCone lpcone=(LPCone)dcone; DSDPVec S=lpcone->PS,WX=lpcone->WX,X=lpcone->X,DS=lpcone->DS,WY=lpcone->WY; double *xx,*xout=lpcone->xout; DSDPFunctionBegin; if (lpcone->n<1) return 0; mu*=lpcone->muscale; info=LPComputeATY(lpcone,Y,S);DSDPCHKERR(info); info=DSDPVecSet(1.0,WX); info=DSDPVecPointwiseDivide(WX,S,WX);DSDPCHKERR(info); info=LPComputeATY(lpcone,DY,DS);DSDPCHKERR(info); info=DSDPVecPointwiseMult(WX,DS,X);DSDPCHKERR(info); info=DSDPVecScale(-mu,WX);DSDPCHKERR(info); info=DSDPVecPointwiseMult(WX,X,X);DSDPCHKERR(info); info=DSDPVecAXPY(-1.0,WX,X);DSDPCHKERR(info); info=DSDPVecGetArray(X,&xx);DSDPCHKERR(info); for (info=0;infon;info++){ if (xx[info]<0) xx[info]=0; } info=DSDPVecRestoreArray(X,&xx);DSDPCHKERR(info); info=LPComputeAX(lpcone,X,WY);DSDPCHKERR(info); info=DSDPVecAXPY(1.0,WY,AX);DSDPCHKERR(info); info=DSDPVecDot(S,X,&dtracexs);DSDPCHKERR(info); *tracexs+=dtracexs; info=DSDPVecGetArray(X,&xx);DSDPCHKERR(info); if (xout){ for (info=0;infon;info++){ if (xout){ xout[info]=xx[info]; } } } info=DSDPVecRestoreArray(X,&xx);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeS" static int LPConeS(void* dcone, DSDPVec Y, DSDPDualFactorMatrix flag, DSDPTruth *psdefinite){ int i,n,info; double *s; LPCone lpcone=(LPCone)dcone; DSDPVec S; DSDPFunctionBegin; if (lpcone->n<1) return 0; if (flag==DUAL_FACTOR){ S=lpcone->DS; } else { S=lpcone->PS; } info=DSDPVecCopy(Y,lpcone->Y);DSDPCHKERR(info); info=LPComputeATY(lpcone,Y,S);DSDPCHKERR(info); info=DSDPVecGetC(Y,&lpcone->sscale); info=DSDPVecGetSize(S,&n);DSDPCHKERR(info); info=DSDPVecGetArray(S,&s);DSDPCHKERR(info); *psdefinite=DSDP_TRUE; for (i=0;iWX; DSDPFunctionBegin; if (lpcone->n<1) return 0; if (flag==DUAL_FACTOR){ S=lpcone->DS; } else { S=lpcone->PS; } info=LPComputeATY(lpcone,DY,DS);DSDPCHKERR(info); info=DSDPVecGetSize(DS,&n);DSDPCHKERR(info); info=DSDPVecGetArray(S,&s);DSDPCHKERR(info); info=DSDPVecGetArray(DS,&ds);DSDPCHKERR(info); for (i=0;in<1) return 0; mu=lpcone->muscale; info=DSDPVecGetArray(lpcone->DS,&s);DSDPCHKERR(info); info=DSDPVecGetSize(lpcone->DS,&n);DSDPCHKERR(info); for (i=0;iDS,&s);DSDPCHKERR(info); *logdet=sumlog; *logobj=0; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSparsity" static int LPConeSparsity(void *dcone,int row, int *tnnz, int rnnz[], int m){ int info,*wi,n; double *wd; LPCone lpcone=(LPCone)dcone; DSDPVec W=lpcone->WX; DSDPFunctionBegin; if (lpcone->n<1) return 0; if (row==0) return 0; if (row==m-1){ return 0; } info=DSDPVecGetSize(W,&n);DSDPCHKERR(info); info=DSDPVecGetArray(W,&wd);DSDPCHKERR(info); wi=(int*)wd; info=SpRowMatRowNnz(lpcone->A,row-1,wi,n);DSDPCHKERR(info); info=SpRowIMultAdd(lpcone->A,wi,n,rnnz+1,m-2);DSDPCHKERR(info); info=DSDPVecRestoreArray(W,&wd);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeMonitor" static int LPConeMonitor( void *dcone, int tag){ DSDPFunctionBegin; DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPANorm2" static int LPANorm2( void *dcone, DSDPVec ANorm){ int i,info; double dd; LPCone lpcone=(LPCone)dcone; DSDPFunctionBegin; if (lpcone->n<1) return 0; info=DSDPVecNorm22(lpcone->C,&dd);DSDPCHKERR(info); info=DSDPVecAddC(ANorm,dd);DSDPCHKERR(info); for (i=0;im;i++){ info=SpRowMatNorm2(lpcone->A,i,&dd);DSDPCHKERR(info); info=DSDPVecAddElement(ANorm,i+1,dd);DSDPCHKERR(info); } info=DSDPVecAddR(ANorm,1.0);DSDPCHKERR(info); DSDPFunctionReturn(0); } static struct DSDPCone_Ops kops; static const char *lpconename="LP Cone"; #undef __FUNCT__ #define __FUNCT__ "LPConeOperationsInitialize" static int LPConeOperationsInitialize(struct DSDPCone_Ops* coneops){ int info; if (coneops==NULL) return 0; info=DSDPConeOpsInitialize(coneops); DSDPCHKERR(info); coneops->conehessian=LPConeHessian; coneops->conerhs=LPConeRHS; coneops->conesetup=LPConeSetup; coneops->conesetup2=LPConeSetup2; coneops->conedestroy=LPConeDestroy; coneops->conecomputes=LPConeS; coneops->coneinverts=LPConeInvertS; coneops->conesetxmaker=LPConeSetX; coneops->conecomputex=LPConeX; coneops->conemaxsteplength=LPConeComputeMaxStepLength; coneops->conelogpotential=LPConePotential; coneops->conesize=LPConeSize; coneops->conesparsity=LPConeSparsity; coneops->conehmultiplyadd=LPConeMultiply; coneops->conemonitor=LPConeMonitor; coneops->coneanorm2=LPANorm2; coneops->id=2; coneops->name=lpconename; return 0; } #undef __FUNCT__ #define __FUNCT__ "DSDPAddLP" int DSDPAddLP(DSDP dsdp,LPCone lpcone){ int info; DSDPFunctionBegin; info=LPConeOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)lpcone); DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPCreateLPCone" /*! \fn int DSDPCreateLPCone(DSDP dsdp, LPCone *dspcone){ \brief Create a new object for linear programs and scalar inequalities. \ingroup LPRoutines \param dsdp the solver \param *dspcone new LP Cone object \note LP data can be specified using one or more LPCone objects. Although the use multiple cones is allowed, efficiency is best when all LP data is set in the same cone. \code DSDP dsdp; LPCone lpcone; DSDPCreate(3,&dsdp); DSDPCreateLPCone(dsdp,&lpcone); \endcode \sa DSDPCreate() */ int DSDPCreateLPCone(DSDP dsdp, LPCone *dspcone){ int m,info; struct LPCone_C *lpcone; DSDPFunctionBegin; DSDPCALLOC1(&lpcone,struct LPCone_C,&info);DSDPCHKERR(info); *dspcone=lpcone; /* info=DSDPAddLP(dsdp,lpcone);DSDPCHKERR(info); */ info=LPConeOperationsInitialize(&kops); DSDPCHKERR(info); info=DSDPAddCone(dsdp,&kops,(void*)lpcone); DSDPCHKERR(info); info=DSDPGetNumberOfVariables(dsdp,&m);DSDPCHKERR(info); lpcone->m=m; lpcone->muscale=1.0; lpcone->n=0; lpcone->xout=0; lpcone->r=1.0; info=DSDPVecCreateSeq(0,&lpcone->C);DSDPCHKERR(info); info=DSDPVecCreateSeq(0,&lpcone->WY);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->WX);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->WX2);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->PS);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->DS);DSDPCHKERR(info); info=DSDPVecDuplicate(lpcone->C,&lpcone->X);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeGetXArray" /*! \fn int LPConeGetXArray(LPCone lpcone, double *x[],int *n); \brief Get the array used to store the x variables \ingroup LPRoutines \param lpcone LP Cone \param x array of variables \param n the dimension of the cone and length of the array \sa DSDPCreateLPCone() For example, after calling DSDPComputeX(), \code int i,n; double *x; LPConeGetXArray(lpcone,&x,&n); for (i=0;iX,x);DSDPCHKERR(info); info=DSDPVecGetSize(lpcone->X,n);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeGetSArray" /* \fn int LPConeGetSArray(LPCone lpcone, double *s[], int *n); \brief Get the array used to store the s variables \ingroup LPRoutines \param lpcone LP Cone \param s array of variables \param n the dimension of the cone and length of the array \sa DSDPCreateLPCone() */ int LPConeGetSArray(LPCone lpcone,double *s[], int *n){ int info; DSDPFunctionBegin; info=DSDPVecGetArray(lpcone->DS,s);DSDPCHKERR(info); info=DSDPVecGetSize(lpcone->DS,n);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeCopyS" /*! \fn int LPConeCopyS(LPCone lpcone, double s[],int n); \brief Copy the variables s into the spedified array. \ingroup LPRoutines \param lpcone LP Cone \param s array \param n the conic dimension and length of the array \sa DSDPCreateLPCone() \sa LPConeGetDimension() */ int LPConeCopyS(LPCone lpcone,double s[], int n){ int i,info; double *ss,sscale=lpcone->sscale; DSDPTruth psdefinite; DSDPFunctionBegin; info=LPConeS((void*)lpcone,lpcone->Y,DUAL_FACTOR ,&psdefinite);DSDPCHKERR(info); info=DSDPVecGetArray(lpcone->DS,&ss);DSDPCHKERR(info); for (i=0;in*lpcone->muscale); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeScaleBarrier" int LPConeScaleBarrier(LPCone lpcone,double muscale){ DSDPFunctionBegin; if (muscale>0){ lpcone->muscale=muscale; } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSetData" /*! \fn LPConeSetData(LPCone lpcone, int n, const int ik[],const int cols[],const double vals[]) \brief Set data into the LP cone. \param lpcone the LP cone \param n the number of inequalities \param ik the number of nonzeros in each column of the matrix \param cols array of column numbers \param vals array of LP data \ingroup LPRoutines \sa DSDPSetDualObjective() For example, consider the following problem in the form of (D): \f[ \begin{array}{llllll} \mbox{Maximize} & & y_1 & + & y_2 \\ \mbox{Subject to} & & 4 y_1 & + & 2 y_2 & \leq 6 \\ & & 3 y_1 & + & 7 y_2 & \leq 10 \\ & & & & - y_2 & \leq 12 \\ \end{array} \f] In this example, there three inequalities, so the dimension of the x vector would be 3 and n=3. The input arrays would be as follows: \code int ik[]={0,3,5,7}; int row[]={0,1,2,0,1,0,1,2}; double vals[]={6.0,10.0,12.0,4.0,3.0,1.0,7.0,-1.0}; LPConeSetData(lpcone,3,ik,row,vals); DSDPSetDualObjective(dsdp,1,1); DSDPSetDualObjective(dsdp,2,1); \endcode */ int LPConeSetData(LPCone lpcone,int n, const int ik[],const int cols[],const double vals[]){ int info,i,spot,m=lpcone->m; DSDPVec C; DSDPFunctionBegin; lpcone->n=n; info=DSDPVecCreateSeq(n,&C);DSDPCHKERR(info); lpcone->C=C; info=DSDPVecZero(C);DSDPCHKERR(info); lpcone->muscale=1.0; if (n<100) lpcone->muscale=1.0; if (n<10) lpcone->muscale=1.0; for (i=ik[0];iA);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSetData2" /*! \fn LPConeSetData2(LPCone lpcone, int n, const int ik[],const int cols[],const double vals[]) \brief Set data A and into the LP cone. \param lpcone the LP cone \param n the number of inequalities \param ik the number of nonzeros in each column of the matrix \f$A^T\f$ \param cols array of column numbers in A \param vals array of nonzeros in A and c \ingroup LPRoutines \sa DSDPSetDualObjective() For example, consider the following problem in the form of (D): \f[ \begin{array}{llllll} \mbox{Maximize} & & y_1 & + & y_2 \\ \mbox{Subject to} & & 4 y_1 & + & 2 y_2 & \leq 6 \\ & & 3 y_1 & + & 7 y_2 & \leq 10 \\ & & & & - y_2 & \leq 12 \\ \end{array} \f] \code int ik[]={0,2,5,7}; int row[]={0,1,0,1,2,0,1,2}; double vals[]={4.0,3.0,2.0,7.0,-1.0,6.0,10.0,12.0}; LPConeSetData2(lpcone,3,ik,row,vals); DSDPSetDualObjective(dsdp,1,1); DSDPSetDualObjective(dsdp,2,1); \endcode */ int LPConeSetData2(LPCone lpcone,int n, const int ik[],const int cols[],const double vals[]){ int info,i,spot,m=lpcone->m; DSDPVec C; DSDPFunctionBegin; lpcone->n=n; info=DSDPVecCreateSeq(n,&C);DSDPCHKERR(info); lpcone->C=C; info=DSDPVecZero(C);DSDPCHKERR(info); lpcone->muscale=1.0; if (n<100) lpcone->muscale=1.0; if (n<10) lpcone->muscale=1.0; for (i=ik[m];iA);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeView2" /*! \fn LPConeView2(LPCone lpcone) \brief Print the data in the LP cone to the screen. \param lpcone the LP cone \ingroup LPRoutines */ int LPConeView2(LPCone lpcone){ int info; DSDPFunctionBegin; printf("LPCone Constraint Matrix\n"); info=SpRowMatView(lpcone->A);DSDPCHKERR(info); printf("LPCone Objective C vector\n"); info=DSDPVecView(lpcone->C);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeGetConstraint" int LPConeGetConstraint(LPCone lpcone,int column,DSDPVec W){ int n,info; double *w; DSDPFunctionBegin; if (column==0){ info=DSDPVecCopy(lpcone->C,W);DSDPCHKERR(info); } else { info=DSDPVecGetSize(W,&n);DSDPCHKERR(info); info=DSDPVecGetArray(W,&w);DSDPCHKERR(info); info=SpRowMatGetRowVector(lpcone->A,column-1,w,n);info=0;DSDPCHKERR(info); info=DSDPVecRestoreArray(W,&w);DSDPCHKERR(info); } DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeGetData" /*! \fn int LPConeGetData(LPCone lpcone, int vari, double vv[], int n); \brief Get one column (or row) of the LP data. \param lpcone LP cone \param vari column of data in (D) or row of data in (P). \param vv array of data \param n length of array and conic dimension */ int LPConeGetData(LPCone lpcone,int vari,double vv[], int n){ int info; DSDPVec W; DSDPFunctionBegin; info=DSDPVecCreateWArray(&W,vv,n);DSDPCHKERR(info); info=LPConeGetConstraint(lpcone,vari,W);DSDPCHKERR(info); DSDPFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "LPConeSetXVec" int LPConeSetXVec(LPCone lpcone,double *xout, int n){ DSDPFunctionBegin; if (n==lpcone->n) lpcone->xout=xout; DSDPFunctionReturn(0); } static int vsdot(const int*,const double *,int,const double *, int, double *); static int checkvsparse(smatx *); static int CreateSpRowMatWdata(int m,int n,const double vals[], const int cols[], const int ik[], smatx **A){ smatx *V; V=(smatx*) malloc(1*sizeof(smatx)); if (V==NULL) return 1; V->nrow=m; V->ncol=n; V->owndata=0; V->an=vals; V->col=cols; V->nnz=ik; *A=V; checkvsparse(V); return 0; } static int vsdot(const int ja[], const double an[], int nn0, const double vv[], int n, double *vdot){ int i; double tmp=0.0; for (i=0; inrow,tnnz=0; const int *nnz=A->nnz; for (i=0;i0){ tnnz++; } } if (tnnz < m/2){ A->nzrows =(int*)malloc((tnnz)*sizeof(int)); A->nnzrows=tnnz; for (i=0;i0){ A->nzrows[k]=i; k++; } } } else { A->nzrows = 0; A->nnzrows = m; } return 0; } #undef __FUNCT__ #define __FUNCT__ "SpRowMatMult" static int SpRowMatMult(smatx* A, const double x[], int n, double y[], int m){ int i,k1,k2,nrow=A->nrow; const int *nnz=A->nnz,*col=A->col; const double *an=A->an; if (A->ncol != n) return 1; if (A->nrow != m) return 2; if (x==0 && n>0) return 3; if (y==0 && m>0) return 3; if (m>0){ memset((void*)y,0,m*sizeof(double)); for (i=0; inrow; const int *col=A->col,*nnz=A->nnz; const double *an=A->an; if (A->ncol != n) return 1; if (A->nrow != m) return 2; if (x==0 && m>0) return 3; if (y==0 && n>0) return 3; memset((void*)y,0,n*sizeof(double)); for (i=0; icol; DSDPFunctionBegin; memset((void*)wi,0,n*sizeof(double)); k1=A->nnz[row]; k2=A->nnz[row+1]; for (i=k1; inrow; const int *nnz=A->nnz,*col=A->col; DSDPFunctionBegin; for (i=0; icol, *nnz=A->nnz; double *an=A->an; for (k=nnz[nrow]; knnz; double tt=0; const double *an=A->an; for (k=nnz[nrow]; kcol; const double *an=M->an; /* if (M->ncol != m) return 1; if (row<0 || row>= M->nrow) return 2; if (r==0) return 3; */ memset((void*)r,0,m*sizeof(double)); k1=M->nnz[row]; k2=M->nnz[row+1]; for (i=k1; icol; const double *an=M->an; /* if (M->ncol != m) return 1; if (row<0 || row>= M->nrow) return 2; if (r==0) return 3; */ memset((void*)r,0,m*sizeof(double)); k1=M->nnz[row]; k2=M->nnz[row+1]; for (i=k1; innz[M->nrow]; memset(M->an,0,(nnz)*sizeof(double)); return 0; } #undef __FUNCT__ #define __FUNCT__ "SpRowGetSize" static int SpRowMatGetSize(smatx *M, int *m, int *n){ *m=M->nrow; *n=M->ncol; return 0; } */ #undef __FUNCT__ #define __FUNCT__ "SpRowMatDestroy" static int SpRowMatDestroy(smatx* A){ if (A->owndata){ printf("Can't free array"); return 1; /* if (A->an) free(A->an); if (A->col) free(A->col); if (A->nnz) free(A->nnz); */ } if (A->nzrows) free(A->nzrows); free(A); return 0; } #undef __FUNCT__ #define __FUNCT__ "SpRowMatView" static int SpRowMatView(smatx* M){ int i,j,k1,k2; for (i=0; inrow; i++){ k1=M->nnz[i]; k2=M->nnz[i+1]; if (k2-k1 >0){ printf("Row %d, (Variable y%d) : ",i,i+1); for (j=k1; jan[j],M->col[j]); printf("= dobj%d \n",i+1); } } return 0; } #undef __FUNCT__ #define __FUNCT__ "LPConeView" /*! \fn LPConeView(LPCone lpcone) \brief Print the data in the LP cone to the screen \param lpcone the LP cone \ingroup LPRoutines */ int LPConeView(LPCone lpcone){ smatx* A=lpcone->A; int i,j,jj,info; const int *row=A->col,*nnz=A->nnz; int n=A->ncol,m=A->nrow; const double *an=A->an; double cc; DSDPVec C=lpcone->C; DSDPFunctionBegin; printf("LPCone Constraint Matrix\n"); printf("Number y variables 1 through %d\n",m); for (i=0; i truss1.tmp 2>&1; \ if ( ${DIFF} truss1.tmp output.truss1 ) then echo " No error: truss1 "; \ else echo " Possible Error (truss1): Differences between this output and reference output:"; fi; \ ${RM} truss1.tmp mcp100test: -@${D}dsdp5 mcp100.dat-s -dlogsummary 0 -print 1 > mcp100.tmp 2>&1; \ if ( ${DIFF} mcp100.tmp output.mcp100 ) then echo " No error: mcp100 "; \ else echo " Possible Error (mcp100): Differences between this output and reference output:"; fi; \ ${RM} mcp100.tmp maxcuttest: -@${D}maxcut graph1 > maxcut.tmp 2>&1; \ if ( ${DIFF} maxcut.tmp output.maxcut ) then echo " No error: Maxcut "; \ else echo " Possible Error (maxcut): Differences between this output and reference output:"; fi; \ ${RM} maxcut.tmp thetatest: -@${D}theta graph1 > theta.tmp 2>&1; \ if ( ${DIFF} theta.tmp output.theta ) then echo " No Error: Theta "; \ else echo " Possible Error (theta): Differences between this output and reference output:"; fi; \ ${RM} theta.tmp output: ${RM} output.truss1 output.mcp100 output.maxcut output.theta; ${D}dsdp5 truss1.dat-s -dlogsummary 0 -print 1 > output.truss1; ${D}dsdp5 mcp100.dat-s -dlogsummary 0 -print 1 > output.mcp100; ${D}maxcut graph1 > output.maxcut; ${D}theta graph1 > output.theta; test: -make truss1test -make mcp100test -make maxcuttest -make thetatest all: make test clean: ${RM} theta maxcut color stable dsdp5 DSDP5.8/bin/output.mcp1000000644000175000017500000000356210326241002015027 0ustar twernertwernermcp100.dat-s -dlogsummary 0 -print 1 Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm --------------------------------------------------------------------------------------- 0 3.00000000e+04 -3.00000000e+04 1.1e+01 0.0e+00 4.0e+01 0.00 0.00 0.00 1 7.86528973e+03 -1.74610487e+03 1.3e-09 0.0e+00 2.5e+01 1.00 0.09 108.31 2 4.91327406e+03 -4.27068853e+02 1.3e-11 0.0e+00 4.4e+00 1.00 0.31 26.26 3 7.50577324e+02 -2.51478598e+02 4.8e-13 0.0e+00 7.9e-01 1.00 0.24 26.03 4 -1.54298219e+01 -2.31868758e+02 7.1e-14 0.0e+00 1.6e-01 1.00 0.09 32.54 5 -1.54298219e+01 -2.29239790e+02 7.1e-14 0.0e+00 3.0e-01 0.75 1.00 1.92 6 -1.40416840e+02 -2.26888902e+02 2.7e-14 0.0e+00 8.1e-02 1.00 0.23 9.28 7 -2.02626096e+02 -2.26437537e+02 7.5e-15 0.0e+00 6.2e-02 1.00 1.00 2.07 8 -2.08102611e+02 -2.26227605e+02 5.7e-15 0.0e+00 2.5e-02 1.00 0.81 2.54 9 -2.18763024e+02 -2.26212118e+02 2.4e-15 0.0e+00 7.3e-03 1.00 0.24 2.35 10 -2.24005840e+02 -2.26167410e+02 6.8e-16 0.0e+00 4.5e-03 1.00 0.57 3.36 11 -2.24836054e+02 -2.26161318e+02 4.2e-16 0.0e+00 8.9e-04 1.00 0.34 3.84 12 -2.25895674e+02 -2.26158475e+02 8.3e-17 0.0e+00 2.2e-04 1.00 0.23 6.50 13 -2.26091696e+02 -2.26157715e+02 2.1e-17 0.0e+00 4.6e-05 1.00 0.14 9.84 14 -2.26143777e+02 -2.26157433e+02 4.3e-18 0.0e+00 1.4e-05 1.00 0.15 10.73 15 -2.26153258e+02 -2.26157380e+02 1.3e-18 0.0e+00 2.8e-06 1.00 0.10 13.06 16 -2.26156531e+02 -2.26157360e+02 2.6e-19 0.0e+00 1.1e-06 1.00 0.14 10.50 17 -2.26157033e+02 -2.26157354e+02 1.0e-19 0.0e+00 2.8e-07 1.00 0.12 12.25 18 -2.26157268e+02 -2.26157352e+02 2.6e-20 0.0e+00 5.8e-08 1.00 0.08 17.56 DSDP5.8/bin/output.maxcut0000644000175000017500000000224010326241002015320 0ustar twernertwernerIter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm --------------------------------------------------------------------------------------- 0 1.05500000e+02 -1.04500000e+02 3.4e+00 0.0e+00 2.3e+00 0.00 0.00 0.00 1 2.37364847e+01 -2.75634174e+01 8.0e-12 0.0e+00 1.4e+00 1.00 0.06 27.94 2 1.15870185e+01 -1.24895677e+01 3.8e-13 0.0e+00 4.4e-01 1.00 0.07 20.83 3 -2.02921832e+00 -9.64375742e+00 2.1e-14 0.0e+00 1.2e-01 1.00 0.06 18.93 4 -2.02921832e+00 -9.53814691e+00 2.1e-14 0.0e+00 1.4e-01 0.90 0.19 1.82 5 -6.95650274e+00 -9.27307276e+00 6.7e-15 0.0e+00 7.6e-02 1.00 0.40 2.63 6 -7.96544804e+00 -9.25630506e+00 3.6e-15 0.0e+00 1.5e-02 1.00 1.00 1.07 7 -9.00332379e+00 -9.25452212e+00 6.9e-16 0.0e+00 2.8e-03 1.00 0.23 1.26 8 -9.20224572e+00 -9.25022651e+00 1.3e-16 0.0e+00 5.8e-04 1.00 0.14 6.78 9 -9.24012606e+00 -9.25016199e+00 2.8e-17 0.0e+00 5.6e-04 1.00 0.28 1.02 10 -9.24052190e+00 -9.25007901e+00 2.6e-17 0.0e+00 1.1e-04 1.00 1.00 0.51 Best integer solution: -9.25 DSDP5.8/bin/output.theta0000644000175000017500000000115510326241002015130 0ustar twernertwernerIter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm --------------------------------------------------------------------------------------- 0 7.00000000e+00 -6.10000000e+01 2.0e+00 0.0e+00 5.7e-01 0.00 0.00 0.00 1 9.12357666e+00 -3.28146887e+00 1.1e-11 0.0e+00 1.1e-01 1.00 1.00 38.54 2 -5.73487482e-01 -3.00190367e+00 7.3e-15 0.0e+00 8.7e-04 1.00 1.00 38.36 3 -2.98087134e+00 -3.00001522e+00 5.2e-17 0.0e+00 7.7e-06 1.00 1.00 31.89 4 -2.99983133e+00 -3.00000012e+00 4.6e-19 0.0e+00 5.6e-08 1.00 1.00 33.02 DSDP5.8/bin/vibra1.dat-s0000644000175000017500000004247010326241002014664 0ustar twernertwerner 36 3 24 25 -36 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0 1 21 21 0.0100000000 0 1 22 22 0.0100000000 0 2 1 1 -0.5000000000 0 2 1 2 0.0000000000 0 2 1 3 0.0000000000 0 2 1 4 0.0000000000 0 2 1 5 0.0000000000 0 2 1 6 0.0000000000 0 2 1 7 0.0000000000 0 2 1 8 0.0000000000 0 2 1 9 0.0000000000 0 2 1 10 0.0000000000 0 2 1 11 0.0000000000 0 2 1 12 0.0000000000 0 2 1 13 0.0000000000 0 2 1 14 0.0000000000 0 2 1 15 0.0000000000 0 2 1 16 0.0000000000 0 2 1 17 0.0000000000 0 2 1 18 0.0000000000 0 2 1 19 0.0000000000 0 2 1 20 0.0000000000 0 2 1 21 0.0000000000 0 2 1 22 -1.0000000000 0 2 1 23 0.0000000000 0 2 1 24 0.0000000000 0 2 1 25 0.0000000000 1 1 1 1 0.9975000000 1 1 2 2 -0.0025000000 1 2 2 2 1.0000000000 1 3 1 1 1.0000000000 2 1 3 3 0.6375000000 2 1 3 4 0.3200000000 2 1 4 4 0.1575000000 2 2 4 4 0.6400000000 2 2 4 5 0.3200000000 2 2 5 5 0.1600000000 2 3 2 2 1.0000000000 3 1 1 1 -0.0025000000 3 1 2 2 3.9975000000 3 1 3 3 -0.0025000000 3 1 2 4 -4.0000000000 3 1 4 4 3.9975000000 3 2 3 3 4.0000000000 3 2 3 5 -4.0000000000 3 2 5 5 4.0000000000 3 3 3 3 1.0000000000 4 1 1 1 0.6375000000 4 1 1 2 -0.3200000000 4 1 2 2 0.1575000000 4 2 2 2 0.6400000000 4 2 2 3 -0.3200000000 4 2 3 3 0.1600000000 4 3 4 4 1.0000000000 5 1 3 3 0.9975000000 5 1 4 4 -0.0025000000 5 2 4 4 1.0000000000 5 3 5 5 1.0000000000 6 1 5 5 0.6375000000 6 1 5 6 0.3200000000 6 1 6 6 0.1575000000 6 2 6 6 0.6400000000 6 2 6 7 0.3200000000 6 2 7 7 0.1600000000 6 3 6 6 1.0000000000 7 1 3 3 -0.0025000000 7 1 4 4 3.9975000000 7 1 5 5 -0.0025000000 7 1 4 6 -4.0000000000 7 1 6 6 3.9975000000 7 2 5 5 4.0000000000 7 2 5 7 -4.0000000000 7 2 7 7 4.0000000000 7 3 7 7 1.0000000000 8 1 3 3 0.6375000000 8 1 3 4 -0.3200000000 8 1 4 4 0.1575000000 8 2 4 4 0.6400000000 8 2 4 5 -0.3200000000 8 2 5 5 0.1600000000 8 3 8 8 1.0000000000 9 1 1 1 0.9975000000 9 1 2 2 -0.0025000000 9 1 1 7 -1.0000000000 9 1 7 7 0.9975000000 9 1 8 8 -0.0025000000 9 2 2 2 1.0000000000 9 2 2 8 -1.0000000000 9 2 8 8 1.0000000000 9 3 9 9 1.0000000000 10 1 1 1 0.6375000000 10 1 1 2 0.3200000000 10 1 2 2 0.1575000000 10 1 1 9 -0.6400000000 10 1 2 9 -0.3200000000 10 1 9 9 0.6375000000 10 1 1 10 -0.3200000000 10 1 2 10 -0.1600000000 10 1 9 10 0.3200000000 10 1 10 10 0.1575000000 10 2 2 2 0.6400000000 10 2 2 3 0.3200000000 10 2 3 3 0.1600000000 10 2 2 10 -0.6400000000 10 2 3 10 -0.3200000000 10 2 10 10 0.6400000000 10 2 2 11 -0.3200000000 10 2 3 11 -0.1600000000 10 2 10 11 0.3200000000 10 2 11 11 0.1600000000 10 3 10 10 1.0000000000 11 1 7 7 -0.0025000000 11 1 8 8 3.9975000000 11 1 9 9 -0.0025000000 11 1 8 10 -4.0000000000 11 1 10 10 3.9975000000 11 2 9 9 4.0000000000 11 2 9 11 -4.0000000000 11 2 11 11 4.0000000000 11 3 11 11 1.0000000000 12 1 3 3 0.6375000000 12 1 3 4 -0.3200000000 12 1 4 4 0.1575000000 12 1 3 7 -0.6400000000 12 1 4 7 0.3200000000 12 1 7 7 0.6375000000 12 1 3 8 0.3200000000 12 1 4 8 -0.1600000000 12 1 7 8 -0.3200000000 12 1 8 8 0.1575000000 12 2 4 4 0.6400000000 12 2 4 5 -0.3200000000 12 2 5 5 0.1600000000 12 2 4 8 -0.6400000000 12 2 5 8 0.3200000000 12 2 8 8 0.6400000000 12 2 4 9 0.3200000000 12 2 5 9 -0.1600000000 12 2 8 9 -0.3200000000 12 2 9 9 0.1600000000 12 3 12 12 1.0000000000 13 1 3 3 0.9975000000 13 1 4 4 -0.0025000000 13 1 3 9 -1.0000000000 13 1 9 9 0.9975000000 13 1 10 10 -0.0025000000 13 2 4 4 1.0000000000 13 2 4 10 -1.0000000000 13 2 10 10 1.0000000000 13 3 13 13 1.0000000000 14 1 3 3 0.6375000000 14 1 3 4 0.3200000000 14 1 4 4 0.1575000000 14 1 3 11 -0.6400000000 14 1 4 11 -0.3200000000 14 1 11 11 0.6375000000 14 1 3 12 -0.3200000000 14 1 4 12 -0.1600000000 14 1 11 12 0.3200000000 14 1 12 12 0.1575000000 14 2 4 4 0.6400000000 14 2 4 5 0.3200000000 14 2 5 5 0.1600000000 14 2 4 12 -0.6400000000 14 2 5 12 -0.3200000000 14 2 12 12 0.6400000000 14 2 4 13 -0.3200000000 14 2 5 13 -0.1600000000 14 2 12 13 0.3200000000 14 2 13 13 0.1600000000 14 3 14 14 1.0000000000 15 1 9 9 -0.0025000000 15 1 10 10 3.9975000000 15 1 11 11 -0.0025000000 15 1 10 12 -4.0000000000 15 1 12 12 3.9975000000 15 2 11 11 4.0000000000 15 2 11 13 -4.0000000000 15 2 13 13 4.0000000000 15 3 15 15 1.0000000000 16 1 5 5 0.6375000000 16 1 5 6 -0.3200000000 16 1 6 6 0.1575000000 16 1 5 9 -0.6400000000 16 1 6 9 0.3200000000 16 1 9 9 0.6375000000 16 1 5 10 0.3200000000 16 1 6 10 -0.1600000000 16 1 9 10 -0.3200000000 16 1 10 10 0.1575000000 16 2 6 6 0.6400000000 16 2 6 7 -0.3200000000 16 2 7 7 0.1600000000 16 2 6 10 -0.6400000000 16 2 7 10 0.3200000000 16 2 10 10 0.6400000000 16 2 6 11 0.3200000000 16 2 7 11 -0.1600000000 16 2 10 11 -0.3200000000 16 2 11 11 0.1600000000 16 3 16 16 1.0000000000 17 1 7 7 0.9975000000 17 1 8 8 -0.0025000000 17 1 7 13 -1.0000000000 17 1 13 13 0.9975000000 17 1 14 14 -0.0025000000 17 2 8 8 1.0000000000 17 2 8 14 -1.0000000000 17 2 14 14 1.0000000000 17 3 17 17 1.0000000000 18 1 7 7 0.6375000000 18 1 7 8 0.3200000000 18 1 8 8 0.1575000000 18 1 7 15 -0.6400000000 18 1 8 15 -0.3200000000 18 1 15 15 0.6375000000 18 1 7 16 -0.3200000000 18 1 8 16 -0.1600000000 18 1 15 16 0.3200000000 18 1 16 16 0.1575000000 18 2 8 8 0.6400000000 18 2 8 9 0.3200000000 18 2 9 9 0.1600000000 18 2 8 16 -0.6400000000 18 2 9 16 -0.3200000000 18 2 16 16 0.6400000000 18 2 8 17 -0.3200000000 18 2 9 17 -0.1600000000 18 2 16 17 0.3200000000 18 2 17 17 0.1600000000 18 3 18 18 1.0000000000 19 1 13 13 -0.0025000000 19 1 14 14 3.9975000000 19 1 15 15 -0.0025000000 19 1 14 16 -4.0000000000 19 1 16 16 3.9975000000 19 2 15 15 4.0000000000 19 2 15 17 -4.0000000000 19 2 17 17 4.0000000000 19 3 19 19 1.0000000000 20 1 9 9 0.6375000000 20 1 9 10 -0.3200000000 20 1 10 10 0.1575000000 20 1 9 13 -0.6400000000 20 1 10 13 0.3200000000 20 1 13 13 0.6375000000 20 1 9 14 0.3200000000 20 1 10 14 -0.1600000000 20 1 13 14 -0.3200000000 20 1 14 14 0.1575000000 20 2 10 10 0.6400000000 20 2 10 11 -0.3200000000 20 2 11 11 0.1600000000 20 2 10 14 -0.6400000000 20 2 11 14 0.3200000000 20 2 14 14 0.6400000000 20 2 10 15 0.3200000000 20 2 11 15 -0.1600000000 20 2 14 15 -0.3200000000 20 2 15 15 0.1600000000 20 3 20 20 1.0000000000 21 1 9 9 0.9975000000 21 1 10 10 -0.0025000000 21 1 9 15 -1.0000000000 21 1 15 15 0.9975000000 21 1 16 16 -0.0025000000 21 2 10 10 1.0000000000 21 2 10 16 -1.0000000000 21 2 16 16 1.0000000000 21 3 21 21 1.0000000000 22 1 9 9 0.6375000000 22 1 9 10 0.3200000000 22 1 10 10 0.1575000000 22 1 9 17 -0.6400000000 22 1 10 17 -0.3200000000 22 1 17 17 0.6375000000 22 1 9 18 -0.3200000000 22 1 10 18 -0.1600000000 22 1 17 18 0.3200000000 22 1 18 18 0.1575000000 22 2 10 10 0.6400000000 22 2 10 11 0.3200000000 22 2 11 11 0.1600000000 22 2 10 18 -0.6400000000 22 2 11 18 -0.3200000000 22 2 18 18 0.6400000000 22 2 10 19 -0.3200000000 22 2 11 19 -0.1600000000 22 2 18 19 0.3200000000 22 2 19 19 0.1600000000 22 3 22 22 1.0000000000 23 1 15 15 -0.0025000000 23 1 16 16 3.9975000000 23 1 17 17 -0.0025000000 23 1 16 18 -4.0000000000 23 1 18 18 3.9975000000 23 2 17 17 4.0000000000 23 2 17 19 -4.0000000000 23 2 19 19 4.0000000000 23 3 23 23 1.0000000000 24 1 11 11 0.6375000000 24 1 11 12 -0.3200000000 24 1 12 12 0.1575000000 24 1 11 15 -0.6400000000 24 1 12 15 0.3200000000 24 1 15 15 0.6375000000 24 1 11 16 0.3200000000 24 1 12 16 -0.1600000000 24 1 15 16 -0.3200000000 24 1 16 16 0.1575000000 24 2 12 12 0.6400000000 24 2 12 13 -0.3200000000 24 2 13 13 0.1600000000 24 2 12 16 -0.6400000000 24 2 13 16 0.3200000000 24 2 16 16 0.6400000000 24 2 12 17 0.3200000000 24 2 13 17 -0.1600000000 24 2 16 17 -0.3200000000 24 2 17 17 0.1600000000 24 3 24 24 1.0000000000 25 1 13 13 0.9975000000 25 1 14 14 -0.0025000000 25 1 13 19 -1.0000000000 25 1 19 19 0.9975000000 25 1 20 20 -0.0025000000 25 2 14 14 1.0000000000 25 2 14 20 -1.0000000000 25 2 20 20 1.0000000000 25 3 25 25 1.0000000000 26 1 13 13 0.6375000000 26 1 13 14 0.3200000000 26 1 14 14 0.1575000000 26 1 13 21 -0.6400000000 26 1 14 21 -0.3200000000 26 1 21 21 0.6375000000 26 1 13 22 -0.3200000000 26 1 14 22 -0.1600000000 26 1 21 22 0.3200000000 26 1 22 22 0.1575000000 26 2 14 14 0.6400000000 26 2 14 15 0.3200000000 26 2 15 15 0.1600000000 26 2 14 22 -0.6400000000 26 2 15 22 -0.3200000000 26 2 22 22 0.6400000000 26 2 14 23 -0.3200000000 26 2 15 23 -0.1600000000 26 2 22 23 0.3200000000 26 2 23 23 0.1600000000 26 3 26 26 1.0000000000 27 1 19 19 -0.0025000000 27 1 20 20 3.9975000000 27 1 21 21 -0.0025000000 27 1 20 22 -4.0000000000 27 1 22 22 3.9975000000 27 2 21 21 4.0000000000 27 2 21 23 -4.0000000000 27 2 23 23 4.0000000000 27 3 27 27 1.0000000000 28 1 15 15 0.6375000000 28 1 15 16 -0.3200000000 28 1 16 16 0.1575000000 28 1 15 19 -0.6400000000 28 1 16 19 0.3200000000 28 1 19 19 0.6375000000 28 1 15 20 0.3200000000 28 1 16 20 -0.1600000000 28 1 19 20 -0.3200000000 28 1 20 20 0.1575000000 28 2 16 16 0.6400000000 28 2 16 17 -0.3200000000 28 2 17 17 0.1600000000 28 2 16 20 -0.6400000000 28 2 17 20 0.3200000000 28 2 20 20 0.6400000000 28 2 16 21 0.3200000000 28 2 17 21 -0.1600000000 28 2 20 21 -0.3200000000 28 2 21 21 0.1600000000 28 3 28 28 1.0000000000 29 1 15 15 0.9975000000 29 1 16 16 -0.0025000000 29 1 15 21 -1.0000000000 29 1 21 21 0.9975000000 29 1 22 22 -0.0025000000 29 2 16 16 1.0000000000 29 2 16 22 -1.0000000000 29 2 22 22 1.0000000000 29 3 29 29 1.0000000000 30 1 15 15 0.6375000000 30 1 15 16 0.3200000000 30 1 16 16 0.1575000000 30 1 15 23 -0.6400000000 30 1 16 23 -0.3200000000 30 1 23 23 0.6375000000 30 1 15 24 -0.3200000000 30 1 16 24 -0.1600000000 30 1 23 24 0.3200000000 30 1 24 24 0.1575000000 30 2 16 16 0.6400000000 30 2 16 17 0.3200000000 30 2 17 17 0.1600000000 30 2 16 24 -0.6400000000 30 2 17 24 -0.3200000000 30 2 24 24 0.6400000000 30 2 16 25 -0.3200000000 30 2 17 25 -0.1600000000 30 2 24 25 0.3200000000 30 2 25 25 0.1600000000 30 3 30 30 1.0000000000 31 1 21 21 -0.0025000000 31 1 22 22 3.9975000000 31 1 23 23 -0.0025000000 31 1 22 24 -4.0000000000 31 1 24 24 3.9975000000 31 2 23 23 4.0000000000 31 2 23 25 -4.0000000000 31 2 25 25 4.0000000000 31 3 31 31 1.0000000000 32 1 17 17 0.6375000000 32 1 17 18 -0.3200000000 32 1 18 18 0.1575000000 32 1 17 21 -0.6400000000 32 1 18 21 0.3200000000 32 1 21 21 0.6375000000 32 1 17 22 0.3200000000 32 1 18 22 -0.1600000000 32 1 21 22 -0.3200000000 32 1 22 22 0.1575000000 32 2 18 18 0.6400000000 32 2 18 19 -0.3200000000 32 2 19 19 0.1600000000 32 2 18 22 -0.6400000000 32 2 19 22 0.3200000000 32 2 22 22 0.6400000000 32 2 18 23 0.3200000000 32 2 19 23 -0.1600000000 32 2 22 23 -0.3200000000 32 2 23 23 0.1600000000 32 3 32 32 1.0000000000 33 1 5 5 0.9975000000 33 1 6 6 -0.0025000000 33 2 6 6 1.0000000000 33 3 33 33 1.0000000000 34 1 5 5 0.9975000000 34 1 6 6 -0.0025000000 34 1 5 11 -1.0000000000 34 1 11 11 0.9975000000 34 1 12 12 -0.0025000000 34 2 6 6 1.0000000000 34 2 6 12 -1.0000000000 34 2 12 12 1.0000000000 34 3 34 34 1.0000000000 35 1 11 11 0.9975000000 35 1 12 12 -0.0025000000 35 1 11 17 -1.0000000000 35 1 17 17 0.9975000000 35 1 18 18 -0.0025000000 35 2 12 12 1.0000000000 35 2 12 18 -1.0000000000 35 2 18 18 1.0000000000 35 3 35 35 1.0000000000 36 1 17 17 0.9975000000 36 1 18 18 -0.0025000000 36 1 17 23 -1.0000000000 36 1 23 23 0.9975000000 36 1 24 24 -0.0025000000 36 2 18 18 1.0000000000 36 2 18 24 -1.0000000000 36 2 24 24 1.0000000000 36 3 36 36 1.0000000000 DSDP5.8/docs/0000755000175000017500000000000010656407142012736 5ustar twernertwernerDSDP5.8/docs/dsdp.bib0000644000175000017500000000234410326241002014332 0ustar twernertwerner@TechReport{dsdp5, author = "Steven J. Benson and Yinyu Ye", title = "{DSDP5}: Software For Semidefinite Programming", year = "2005", month = sep, institution = "Mathematics and Computer Science Division, Argonne National Laboratory", address = "Argonne, IL", number = "ANL/MCS-P1289-0905", url = "http://www.mcs.anl.gov/~benson/dsdp", note = "Submitted to ACM Transactions on Mathematical Software", } @unpublished{dsdp-user-guide, Author ="Steven J. Benson and Yinyu Ye", Title ="{DSDP5} User Guide --- Software for Semidefinite Programming", institution = "Mathematics and Computer Science Division, Argonne National Laboratory", address = "Argonne, IL", number = "ANL/MCS-TM-277", month = "July", year = 2004, note = "\url{http://www.mcs.anl.gov/~benson/dsdp}", } @Article{dsdp1, author = "Steven J. Benson and Yinyu Ye and Xiong Zhang", title = "Solving Large-Scale Sparse Semidefinite Programs for Combinatorial Optimization", year = "2000", journal = "SIAM Journal on Optimization", volume = "10", number = 2, pages = "443--461", } DSDP5.8/docs/Makefile0000644000175000017500000000011710326241002014356 0ustar twernertwernerinclude ../make.include htmlzip: zip -r DSDP5-api-html.zip dox ${RM} -R dox DSDP5.8/docs/dox/0000755000175000017500000000000010656407142013530 5ustar twernertwernerDSDP5.8/docs/dox/Doxyfile0000644000175000017500000014146110322013646015235 0ustar twernertwerner# Doxyfile 1.4.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = "DSDP" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = YES # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = ../.. # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = YES # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = YES # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = YES # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the progam writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = docwarnings #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = "../../src" "../../include" "../../examples" "./" # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm FILE_PATTERNS = *.h *.c *.dox # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = images # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 3 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 1 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = YES # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = letter # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = NO # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = "../../include" "../../src/solver" # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = NO # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO DSDP5.8/docs/dox/docwarnings0000644000175000017500000000000010326240533015750 0ustar twernertwernerDSDP5.8/docs/dox/license.dox0000644000175000017500000000457410247464474015707 0ustar twernertwerner/*! \page License License \verbatim (C) COPYRIGHT 2004 UNIVERSITY OF CHICAGO This program discloses material protectable under copyright laws of the United States. Permission to copy and modify this software and its documentation is hereby granted, provided that this notice is retained thereon and on all copies or modifications. The University of Chicago makes no representations as to the suitability and operability of this software for any purpose. It is provided "as is"; without express or implied warranty. Permission is hereby granted to use, reproduce, prepare derivative works, and to redistribute to others, so long as this original copyright notice is retained. Any publication resulting from research that made use of this software should cite this document. This software was authored by: Steven J. Benson Mathematics and Computer Science Division Argonne National Laboratory Argonne IL 60439 Yinyu Ye Department of Management Science and Engineering Stanford University Stanford, CA U.S.A Any questions or comments on the software may be directed to benson@mcs.anl.gov or yinyu-ye@stanford.edu Argonne National Laboratory with facilities in the states of Illinois and Idaho, is owned by The United States Government, and operated by the University of Chicago under provision of a contract with the Department of Energy. DISCLAIMER THIS PROGRAM WAS PREPARED AS AN ACCOUNT OF WORK SPONSORED BY AN AGENCY OF THE UNITED STATES GOVERNMENT. NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. REFERENCE HEREIN TO ANY SPECIFIC COMMERCIAL PRODUCT, PROCESS, OR SERVICE BY TRADE NAME, TRADEMARK, MANUFACTURER, OR OTHERWISE, DOES NOT NECESSARILY CONSTITUTE OR IMPLY ITS ENDORSEMENT, RECOMMENDATION, OR FAVORING BY THE UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF. THE VIEW AND OPINIONS OF AUTHORS EXPRESSED HEREIN DO NOT NECESSARILY STATE OR REFLECT THOSE OF THE UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF. \endverbatim */ DSDP5.8/docs/dox/howtocite.dox0000644000175000017500000000256310321603052016242 0ustar twernertwerner/*! \page pageHowToCite How To Cite DSDP Please cite DSDP in any reports or publications that used it to generate results. \verbatim @TechReport{dsdp5, author = "Steven J. Benson and Yinyu Ye", title = "{DSDP5}: Software For Semidefinite Programming", year = "2005", month = sep, institution = "Mathematics and Computer Science Division, Argonne National Laboratory", address = "Argonne, IL", number = "ANL/MCS-P1289-0905", url = "http://www.mcs.anl.gov/~benson/dsdp", note = "Submitted to ACM Transactions on Mathematical Software", } @unpublished{dsdp-user-guide, Author ="Steven J. Benson and Yinyu Ye", Title ="{DSDP5} User Guide --- Software for Semidefinite Programming", institution = "Mathematics and Computer Science Division, Argonne National Laboratory", address = "Argonne, IL", number = "ANL/MCS-TM-277", month = "July", year = 2004, note = "\url{http://www.mcs.anl.gov/~benson/dsdp}", } @Article{dsdp1, author = "S. J. Benson and Y. Ye and X. Zhang", title = "Solving Large-Scale Sparse Semidefinite Programs for Combinatorial Optimization", year = "2000", journal = "SIAM Journal on Optimization", volume = "10", number = 2, pages = "443--461", } \endverbatim */ DSDP5.8/docs/dox/doxygen.dox0000644000175000017500000000102110247464474015722 0ustar twernertwerner/*! \page pageDoxygen Creating the Documentation DSDP uses Doxygen for documentation. The DSDP documentation is available online at http://www.mcs.anl.gov/~benson/dsdp/. To generate a local copy of the documentation,
  1. Make sure you have Doxygen, version 1.3.8 or later, installed.
  2. Change directory to \p DSDPROOT/dox .
  3. Type \c doxygen.
  4. Point your browser to \p DSDPROOT/dox/html/index.html .
*/ DSDP5.8/docs/dox/modules.dox0000644000175000017500000001526310323230726015714 0ustar twernertwerner/*! \defgroup DSDPBasic DSDP Basics DSDP can be used within a C application through a set of subroutines. The subroutines listed below use DSDP to solve problems in \ref PDForm "DSDP Standard Form". Several examples of applications that use the DSDP application program interface are included in the distribution. Each of these applications includes the header \code #include dsdp5.h \endcode and link to the DSDP library. \retval 0 if successful The documentation of DSDP subroutines in this chapter will not show the return integer, but we highly recommend that applications check for errors after each subroutine. */ /*! \defgroup DSDPConverge DSDP Convergence The subroutines listed below define convergence and termination criteria for the solver and problems in \ref PDForm "DSDP Standard Form". \code #include dsdp5.h \endcode \retval 0 if successful */ /*! \defgroup DSDPSolution DSDP Statistics for Data and Current Solution DSDP can provide information about the problem and its current solution in \ref PDForm "DSDP Standard Form". \code #include dsdp5.h \endcode \retval 0 if successful */ /*! \defgroup DSDPSolver DSDP Tuning Options Improve performance of DSDP and customize the solver for problems in \ref PDForm "DSDP Standard Form". \code #include dsdp5.h \endcode \retval 0 if successful */ /*! \defgroup SDPBasic Semidefinite Blocks (Basics) Routines that create the SDPCone object, set the data, and get the solution for problems. \code #include dsdp5.h \endcode In \ref PDForm "DSDP Standard Form", a semidefinite program is given by the pair of problems \f[ \begin{array}{llllllllll} (P) \ \ \ & \mbox{minimize} & {\displaystyle \sum_{j=0}^{n_b-1} C_j \bullet X_j } &\mbox{subject to}& {\displaystyle \sum_{j=0}^{n_b-1} A_{i,j} \bullet X_{j} = b_i } ,& i=1,\ldots, m, & & X_j \succeq 0, \\ \end{array} \f] \f[ \begin{array}{lllllllll} (D) \ \ \ & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i } &\mbox{subject to}&{\displaystyle \sum_{i=1}^m A_{i,j}y_i + S_{j} } = C_{j}, & j=0, \ldots, n_b-1, & S_j \succeq 0 \\ \end{array} \f] where the data \f$A_{i,j}\f$ and \f$C_j\f$ are symmetric matrices of the same dimension and the inner product of two \f$n \times n\f$ matrices \f$C=(c_{k,l})\f$ and \f$X=(x_{k,l})\f$ is defined by \f$ C \bullet X := trace (C^T X) = \sum_{k,l}c_{k,l} x_{k,l} \f$. Blocks are labelled from 0 to \e nblocks, where \e nblocks is the total number of blocks in the SDPCone object. Variables y are numbered 1 through m. Variable 0 designates the C matrices, which are also denoted \f$ A_{0,j}\f$. By default, this cone represents symmetric \f$ n \times n\f$ matrices in packed symmetric format. This format uses an array of length \f$ n(n+1)/2 \f$ and orders the the elements of the matrix as follows: \f[ \begin{array}{llllllll} [ a_{1,1} & a_{2,1} & a_{2,2} & a_{3,1} & a_{3,2} & a_{3,3} & \ldots & a_{n,n} ] \\ \end{array}. \f] \retval 0 if successful */ /*! \defgroup SDPRoutines Semidefinite Blocks (Operational Routines) Additional routines that operate on the data. \code #include dsdp5.h \endcode In \ref PDForm "DSDP Standard Form" a semidefinite program is given by the pair of problems \f[ \begin{array}{llllllllll} (P) \ \ \ & \mbox{minimize} & {\displaystyle \sum_{j=0}^{n_b-1} C_j \bullet X_j } &\mbox{subject to}& {\displaystyle \sum_{j=0}^{n_b-1} A_{i,j} \bullet X_{j} = b_i } ,& i=1,\ldots, m, & & X_j \succeq 0, \\ \end{array} \f] \f[ \begin{array}{lllllllll} (D) \ \ \ & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i } &\mbox{subject to}&{\displaystyle \sum_{i=1}^m A_{i,j}y_i + S_{j} } = C_{j}, & j=0, \ldots, n_b-1, & S_j \succeq 0 \\ \end{array} \f] where the data \f$A_{i,j}\f$ and \f$C_j\f$ are symmetric matrices of the same dimension and the inner product of two \f$n \times n\f$ matrices \f$C=(c_{k,l})\f$ and \f$X=(x_{k,l})\f$ is defined by \f$ C \bullet X := trace (C^T X) = \sum_{k,l}c_{k,l} x_{k,l} \f$. Blocks are labelled from 0 to \e nblocks, where \e nblocks is the total number of blocks in the SDPCone object. Variables y are numbered 1 through m. Variable 0 designates the C matrices, which are also denoted \f$ A_{0,j}\f$. \retval 0 if successful */ /*! \defgroup SDPData Semidefinite Blocks (Advanced Data) Less frequently used routines to set data into the SDPCone object and operate on the variables. \code #include dsdp5.h \endcode In \ref PDForm "DSDP Standard Form", a semidefinite program is given by the pair of problems \f[ \begin{array}{llllllllll} (P) \ \ \ & \mbox{minimize} & {\displaystyle \sum_{j=0}^{n_b-1} C_j \bullet X_j } &\mbox{subject to}& {\displaystyle \sum_{j=0}^{n_b-1} A_{i,j} \bullet X_{j} = b_i } ,& i=1,\ldots, m, & & X_j \succeq 0, \\ \end{array} \f] \f[ \begin{array}{lllllllll} (D) \ \ \ & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i } &\mbox{subject to}&{\displaystyle \sum_{i=1}^m A_{i,j}y_i + S_{j} } = C_{j}, & j=0, \ldots, n_b-1, & S_j \succeq 0 \\ \end{array} \f] where the data \f$A_{i,j}\f$ and \f$C_j\f$ are symmetric matrices of the same dimension and the inner product of two \f$n \times n\f$ matrices \f$C=(c_{k,l})\f$ and \f$X=(x_{k,l})\f$ is defined by \f$ C \bullet X := trace (C^T X) = \sum_{k,l}c_{k,l} x_{k,l} \f$. Blocks are labelled from 0 to \e nblocks, where \e nblocks is the total number of blocks in the SDPCone object. Variables y are numbered 1 through m. Variable 0 designates the C matrices, which are also denoted \f$ A_{0,j}\f$. \retval 0 if successful */ /*! \defgroup LPRoutines Linear Programming Routines that create the LP cone object for linear inequalites, set the data, and provide access to the solutions. \code #include dsdp5.h \endcode In \ref PDForm "DSDP Standard Form" a pure linear program is given by the following pair of problems. \f[ \begin{array}{lllllllll} \mbox{Maximize} & b^T y & & \mbox{such that} & A^T y & \leq c \\ \mbox{Minimize} & c^T x & & \mbox{such that} & A x & = b, & x \geq 0 \\ \end{array} \f] Slack variables \f$ s:= c - A^Ty \f$ must be positive. Variables \f$ x,s \in \Re^n\f$. LP data may be used in conjuction with semidefinite data. \retval 0 if successful */ /*! \defgroup Bounds Bounds Bounds on the variables y are a special type of semidefinite and LP cone. Corresponding to lower and upper bounds on the y variables are surplus and slack variables in (P) with an a cost. Variables y are numbered 1 through m. \code #include dsdp5.h \endcode \retval 0 if successful */ /*! \defgroup Examples Examples Examples that formulate problems in \ref PDForm "DSDP Standard Form". and solve them using DSDP. \note These routines are examples! They not part of the subroutine library. */ DSDP5.8/docs/dox/installation.dox0000644000175000017500000001435410307714335016752 0ustar twernertwerner/*! \page Installation Installation Instructions. The compressed files \p DSDP5.X.tar.gz and \p DSDP5.X.zip contain an implementation of the dual-scaling algorithm for conic programming optimization problems. Create the \p DSDP5.X directory structure and enter it. For example, \verbatim gunzip DSDP5.X.tar.gz tar -xvf DSDP5.X.tar \endverbatim or \verbatim unzip DSDP5.X.zip \endverbatim Several executables may have been provided. If not, it will have to be compiled. DSDP is written in the C programming language. It has been tested using several different compilers and architectures. In particular, it has been tested using gcc-2.96 and gcc-3.2 (C and C++), Intel-6.0, Intel-7.1, Intel-8.0, and Microsoft Visual Studio 2003. It has been compiled on 32 bit and 64 bit architectures. \section Compile Compiling DSDP \subsection Make Using Make DSDP was developed using Make -- which is available on Linux and most Unix systems. To compile DSDP using Make - Go to the DSDP directory and edit the file \p make.include - Go to the DSDP directory \verbatim > cd DSDP5.X \endverbatim - Define the \p DSDPROOT variable as the full directory name. For example, \verbatim DSDPROOT = /home/benson/DSDP5.X \endverbatim For those using the GCC compilers, the default values for the remaining variables may suffice. - Edit the compiler flags \p CC and \p OPTFLAGS. For example, \verbatim CC = gcc \endverbatim - Edit the compiler optimization flag \verbatim OPTFLAGS = -O3 \endverbatim - Add timing flag. By default, timing routines are not implemented due to portability issues among architectures. However, DSDP can provide time profiles for several important operations by defining one of the following variables. \verbatim DSDPTIMER = NONE \endverbatim Users of the Microsoft compiler will probably need the flags \verbatim DSDPTIMER = DSDP_MS_TIME \endverbatim Users of the GCC and many other compilers should consider defining \verbatim DSDPTIMER = DSDP_TIME \endverbatim The routines that call these two timing utilities can be found in the file \p dsdptime.c and edited. - Add additional compiler flags. See the next section for more information about specific compiler flags. - If the Matlab interface is required, also check and edit the \p MEX flag. For example, \verbatim MEX = mex -O \endverbatim - In the same file, edit the location of the BLAS and LAPACK libraries and include any other libraries required to link to them such as \p -lg2c or \p -lm. For example, \verbatim LAPACKBLAS = -llapack -lblas -lg2c -lm \endverbatim Linking to a fast implementations of these libraries, such as ATLAS or Intel, will significantly improve performance. - Compile the source code to create the DSDP library and drivers. \verbatim > make all \endverbatim Alternatively, to compile just the DSDP Matlab routine: \verbatim > make dsdpmatlab \endverbatim Alternatively, to compile just the DSDP library and C examples: \verbatim > make dsdpapi \endverbatim If the DSDP Matlab mex function does not link with the library, try the next method of compilation. If problems persist, please send a copy of the compilation log to the developers. \subsection NoMake Without Make DSDP can also be compiled by copying all of the source and header files into another directory, compiled, and linked with a driver routine (such as one of the files in \p DSDPROOT/examples/ ). This process is demonstrated in the \p dsdpagain target in \p DSDPROOT/examples/Makefile. This method neglects the directory structure of the source code and the Makefile system, but it works fine. \section Flags Compiler Flags \subsection blas BLAS and LAPACK DSDP uses BLAS and LAPACK for many of the underlying operations and it must be linked to these libraries. Two of the eigenvalue routines require LAPACK version 3 or later. The routines in BLAS and LAPACK are called from the C programming language under the assumption that the routine names are lower case and end with an underscore. The most common linking problem occurs when these assumptions are not true. Several compiler flags can be defined to change these assumptions. Define - Define \p NOUNDERBLAS if no underscore is appended to the end of routine names. This flag was used to link DSDP to the reference BLAS available in Matlab using the Microsoft Compiler. - Define \p CAPSBLAS if the names of BLAS and LAPACK routine names use all capital letters. - Define \p __DSDP_NONAMEMANGLING if a C++ compiler is being used and the BLAS and LAPACK routine names should not be changed. See the makefiles in the distribution for examples of use of these terms. Those compiling in the Microsoft Windows Operating System usually need to define the \p NOUNDERBLAS flag. DSDP also assumes that the \p integer type in Fortran is the same size as a \p long \p int in C, and a \p double \p precision variable in Fortran is the same size as a \p double in C. If problems persist, the macros and type definitions in the file \p dsdplapack.h will have to be edited. \subsection matlab Matlab If the Matlab interface is be generated, one other flag may be of interest. - \p DSDPMATLAB enables the use of the memory allocation and additional print statements available from Matlab. The standard memory allocation and print statements will be used if this flag is not defined. \section testing Testing - Run the executables by switching to directory \p DSDPROOT/exec and test the examples. \verbatim > dsdp5 truss1.dat-s > maxcut graph1 > theta graph1 \endverbatim Compare the output with the files \p output.truss1 , \p output.maxcut , and \p output.theta . If the output from any of the tests differs significantly from the files, please report it to the developers. - DSDP can be called from Matlab version 6.0 and higher. Run the sample problems by starting Matlab in the \p DSDPROOT/matlab directory and test the solver \verbatim > check; \endverbatim Compare the output with the output in \p check.out . For help using the package, type \verbatim > help dsdp; \endverbatim Several example Matlab files have been provided in \p DSDPROOT/matlab that create example problems, read data files, and verify solutions. \section Help For help with installation, please send a copy of the compilation log to the developers. */ DSDP5.8/docs/dox/authors.dox0000644000175000017500000000210510247464474015736 0ustar twernertwerner/*! \page Authors Authors and Acknowledgments This version of DSDP was developed by We thank Xiong Zhang and Cris Choi for their help in developing this code. Xiong Zhang made an enormous contribution in the initial version of DSDP. We also thank Johan Lofberg and Stefan Ratschan for suggesting many improvements to the software and Hans Mittelmann for his efforts in testing and benchmarking it. Finally, we thank all of the users who have commented on previous releases. Their contributions have made DSDP a more reliable, robust, and efficient package. This work was supported by the Mathematical, Information, and Computational Sciences Division subprogram of the Office of Advanced Scientific Computing Research, Office of Science, U.S. Department of Energy, under Contract W-31-109-ENG-38. Please notify the authors of DSDP of your experiences with it. Your feedback helps our research and futher improves the package. */ DSDP5.8/docs/dox/Makefile0000644000175000017500000000007110247464474015175 0ustar twernertwernerinclude ../make.include clean: ${RM} html/* latex/* *~ DSDP5.8/docs/dox/mainpage.dox0000644000175000017500000001101310322015632016006 0ustar twernertwerner/*! \mainpage Interior Point Solver for Semidefinite Programming and Linear Matrix Inequalities The %DSDP package uses a dual-scaling algorithm to solve conic optimization problems of the form \f[ \begin{array}{llllllllll} (P) \ \ \ & \mbox{minimize} & {\displaystyle \sum_{j=1}^{n_b} \langle C_j, X_j \rangle } &\mbox{subject to}& {\displaystyle \sum_{j=1}^{n_b} \langle A_{i,j}, X_{j} \rangle } = b_i ,& i=1,\ldots, m, & & X_j \in K_j,\\ \end{array} \f] \f[ \begin{array}{lllllllll} (D) \ \ \ & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i } &\mbox{subject to}&{\displaystyle \sum_{i=1}^m A_{i,j}y_i + S_{j} } = C_{j}, & j=1, \ldots, n_b, & S_j \in K_j, \\ \end{array} \f] where \f$K_j\f$ is a cone, \f$\langle \cdot , \cdot \rangle\f$ is the associated inner product, and \f$b_i\f$, \f$y_i\f$ are scalars. For semidefinite programming each cone \f$K_j\f$ is a set of symmetric positive definite matrices, the data \f$A_{i,j}\f$ and \f$C_j\f$ are symmetric matrices of the same dimension, and the inner product of two \f$n \times n\f$ matrices \f$C=(c_{k,l})\f$ and \f$X=(x_{k,l})\f$ is defined by \f$\langle C , X \rangle := trace (C^T X) = \sum_{k,l}c_{k,l} x_{k,l} \f$. In linear programming the cone \f$K_j\f$ is the nonnegative orthant \f$(\Re_{+}^n)\f$, the data \f$A_{i}\f$ and \f$C\f$ are vectors of the same dimension, and the inner product \f$\langle C , X \rangle\f$ is the usual vector inner product. Formulation (P) will be referred to as the \e primal problem, and formulation (D) will be referred to as the \e dual problem. %DSDP is an implementation of the interior-point dual-scaling algorithm for conic programming. The source code, written entirely in ANSI C, is freely available. The solver can be used as a subroutine library, as a function within the MATLAB environment, or as an executable that reads and writes to files. Initiated in 1997, DSDP has developed into an efficient and robust general purpose solver for semidefinite programming. Although the solver is written with semidefinite programming in mind, it can also be used for linear programming and other constraint cones. The features of DSDP include: - a robust algorithm with a convergence proof and polynomially bounded complexity under mild assumptions on the data, - primal and dual solutions, - feasible solutions when they exist or approximate certificates of infeasibity, - initial points that can be feasible or infeasible, - relatively low memory requirements for an interior-point method, - sparse and low-rank data structures, - extensibility that allows applications to customize the solver and improve its performance, - a subroutine library that enables it to be linked to larger applications, - scalable performance for large problems on parallel architectures, and - a well documented interface and examples of its use. The package has been used in many applications and tested for efficiency, robustness, and ease of use. Some of the most popular applications of semidefinite programming and linear matrix inequalities are model control, truss topology design, and semidefinite relaxations of combinatorial and global optimization problems. We welcome and encourage further use under the terms of the license included in the distribution.

\section Download Download Download the most recent version of DSDP from the DSDP Homepage. \section authors Authors DSDP was developed by Steve Benson, Yinyu Ye, and Xiong Zhang. Please notify the authors of DSDP of your experiences with it. Your feedback helps us promote our research and futher improve the package. \section References A complete description of the algorithm and a proof of convergence can be found in Solving Large-Scale Sparse Semidefinite Programs for Combinatorial Optimization, SIAM Journal on Optimization, 10(2), 2000, pp. 443-461.

For implementation details, see a publication submitted to ACM Transactions on Mathematical Software: DSDP5: Software For Semidefinite Programming, Preprint ANL/MCS-P1289-0905, Mathematics and Computer Science Division, Argonne National Laboratory, Argonne, IL, September, 2005.

For specific use of the software, consult: DSDP5 User Guide --- Software for Semidefinite Programming, Technical Report ANL/MCS-TM-277, Mathematics and Computer Science Division, Argonne National Laboratory, Argonne, IL, September, 2005.

*/ DSDP5.8/docs/dox/history.dox0000644000175000017500000000340410247464474015755 0ustar twernertwerner/*! \page History A Brief History DSDP began as a specialized solver for combinatorial optimization problems. Over the years, improvements in efficiency and design have enabled its use in many applications. Below is a brief history of DSDP. - [1997] At the University of Iowa the authors release the initial version of DSDP. It solved the semidefinite relaxations of the maximum cut, minimum bisection, s-t cut, and bound constrained quadratic problems. - [1999] DSDP version 2 increased functionality to address semidefinite cones with rank-one constraint matrices and LP constraints. It was used specifically for combinatorial problems such as graph coloring, stable sets, and satisfiability problems. - [2000] DSDP version 3 was a preliminary implementation of a general purpose SDP solver that addressed applications from the Seventh DIMACS Implementation Challenge on Semidefinite and Related Optimization Problems. DSDP 3 also featured the initial release of PDSDP, the first parallel solver for semidefinite programming. - [2002] DSDP version 4 added new sparse data structures and linked to BLAS and LAPACK to improve efficiency and precision. A Lanczos based line search and efficient iterative solver were added. It solved all problems in the SDPLIB collection that includes examples from control theory, truss topology design, and relaxations of combinatorial problems. - [2004] DSDP version 5 features a new efficient interface for semidefinite constraints, and extensibility to structured applications in conic programming. Existence of the central path was ensured by bounding the variables. New applications from in computational chemistry, global optimization, and sensor network location motivated the improvements in efficiency in robustness. */ DSDP5.8/docs/dox/dstandardform.dox0000644000175000017500000000702210247464474017104 0ustar twernertwerner/*! \page PDForm Standard Form The %DSDP package uses a dual-scaling algorithm to solve conic optimization problems of the form \f[ \begin{array}{llllllllll} (P) \ \ \ & \mbox{minimize} & {\displaystyle \sum_{j=1}^{n_b} \langle C_j, X_j \rangle } &\mbox{subject to}& {\displaystyle \sum_{j=1}^{n_b} \langle A_{i,j}, X_{j} \rangle } = b_i ,& i=1,\ldots, m, & & X_j \in K_j,\\ \end{array} \f] \f[ \begin{array}{lllllllll} (D) \ \ \ & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i } &\mbox{subject to}&{\displaystyle \sum_{i=1}^m A_{i,j}y_i + S_{j} } = C_{j}, & j=1, \ldots, n_b, & S_j \in K_j, \\ \end{array} \f] where \f$K_j\f$ is a cone, \f$\langle \cdot , \cdot \rangle\f$ is the associated inner product, and \f$b_i\f$, \f$y_i\f$ are scalars. For semidefinite programming each cone \f$K_j\f$ is a set of symmetric positive definite matrices, the data \f$A_{i,j}\f$ and \f$C_j\f$ are symmetric matrices of the same dimension, and the inner product of two \f$n \times n\f$ matrices \f$C=(c_{k,l})\f$ and \f$X=(x_{k,l})\f$ is defined by \f$\langle C , X \rangle := trace (C^T X) = \sum_{k,l}c_{k,l} x_{k,l} \f$. In linear programming the cone \f$K_j\f$ is the nonnegative orthant \f$(\Re_{+}^n)\f$, the data \f$A_{i}\f$ and \f$C\f$ are vectors of the same dimension, and the inner product \f$\langle C , X \rangle\f$ is the usual vector inner product. The convergence of the algorithm assumes that both (P) and (D) have an interior feasible region and the current solutions are elements of the interior. To satisfy these assumptions, DSDP bounds the variables \f$y\f$ such that \f$l \leq y \leq u\f$ where \f$l,u \in \Re^m\f$. Furthermore, DSDP bounds the trace of \f$X\f$ by a penalty parameter \f$\Gamma\f$. By adding these auxiliary variables and parameters, DSDP solves following pair of problems: \f[ \begin{array}{llccccll} \vspace{0.25cm} (PP) & \mbox{minimize} & {\displaystyle \sum_{j=1}^{n_b} \langle C_j, X_j \rangle } & + & u^T x^u - l^T x^l \\ &\mbox{subject to}& {\displaystyle \sum_{j=1}^{n_b} \langle A_{i,j}, X_{j} \rangle} & + & x^u_i - x^l_i & = & b_i ,& i=1,\ldots, m, \\ & & {\displaystyle \sum_{j=1}^{n_b} \langle I_j , X_{j} \rangle } & & & \leq & \Gamma, \\ & & X_j \in K_j, & & x^u, x^l & \geq & 0, \\ \end{array} \f] \f[ \begin{array}{llrcll} \vspace{0.25cm} (DD) & \mbox{maximize} & {\displaystyle \sum_{i=1}^m b_i \ y_i - \Gamma r} \\ & \mbox{subject to}&{\displaystyle C_{j} - \sum_{i=1}^m A_{i,j}y_i + r I_j } & = & S_{j} \in K_j, & j=1, \ldots, n_b, \\ & & l_i \leq y_i \leq u_i, & & & i=1,\ldots, m, \\ & & r \geq 0, \\ \end{array} \f] where \f$I_j\f$ is the identity element of \f$K_j\f$, and \f$x^l, x^u \in \Re^m \f$ . The variables \f$x^l\f$ and \f$x^u\f$ correspond to the Lagrangian multipliers of the bounds \f$l\f$ and \f$u\f$. The difference of these variables can be interpreted as the infeasibility in the solution of (P). The positive variable \f$r\f$ augments the variable \f$S_{j}\f$ so that it is a element of \f$K_{j}\f$. The parameters \f$\Gamma\f$, \f$l\f$, and \f$u\f$ bound these auxiliary variables and penalize infeasibility in (D) and (P). By default, the bounds and the penalty parameter \f$\Gamma\f$ are very large to force \f$r\f$, \f$x^l\f$, and \f$x^u\f$ to be near zero at the solution. Unbounded and infeasible solutions to either (P) or (D) are determined through examination of the solutions to (PP) and (DD). Note that the reformulation (PP) and (DD) is bounded and feasible, and it can be expressed in the form of (P) and (D). */ DSDP5.8/matlab/0000755000175000017500000000000010326241002013227 5ustar twernertwernerDSDP5.8/matlab/check.m0000644000175000017500000000201410326241002014457 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual-Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2004 by % S. J. Benson, Y. Ye % Last modified: 20 October 2004 %***************************************************************************** % check; % % This script tests the DSDP solver using the examples. Compare the output % to the file check.out % diary on; ntrials=2; BB=cell(1); for trials = [1:ntrials]; N = 10; B = zeros(N); for i=1:N, for j=1:N, B(i,j)=mod(i+j,trials+1); end; end; fprintf('MAXCUT \n'); [y,X,obj] = maxcut(B); fprintf('GPP \n'); [y,X,obj] = gpp(B,1); fprintf('ETP \n'); [obj,d]=etp(B*B'+speye(N)'); fprintf('THETA\n'); [obj,X]=thetaproblem(B); end; %[X,y] = randdinf([10 4 3], 20); OPTIONS=doptions; OPTIONS.print=10; fprintf('CONTROL1\n'); [AC,b] = readsdpa('control1.dat-s'); [STAT,y,X]=dsdp(b,AC,OPTIONS); fprintf('ARCH0\n'); [AC,b] = readsdpa('arch0.dat-s'); [STAT,y,X]=dsdp(b,AC,OPTIONS); diary off; DSDP5.8/matlab/readsdpt3.m0000644000175000017500000000174510326241002015305 0ustar twernertwerner%%******************************************************************* %% Convert problem from SDPT3 format to DSDP format %% %% [AC,b] = readsdpt3(blk,A,C,b) %% %% Input: blk, A, C, b = data in SDPT3 format. %% %% %% DSDP: version 5.0 %% Copyright (c) 2004 by %% S. Benson Y. Ye %% Last modified: 2 Jan 04 %%****************************************************************** function [AC,b]=readsdpt3(blk,A,C,b) AC=blk; [p,m]=size(blk); for bb=1:p conetype=blk{bb,1}; if conetype=='s', [pp,mm]=size(A{bb}); scl=ones(pp,1)/sqrt(2.0); dim=blk{bb,2}; k=0;na=0; cc=sparse([]); for blki=1:length(dim) n=dim(blki); nb=na+n; for j=1:n, k=k+j; scl(k)=1.0; end; cc=[cc;dvec(C{bb}(na+1:nb,na+1:nb))]; na=nb; end; scl=spdiags(scl,0,k,k); AC{bb,3}=[scl*A{bb} cc]; AC{bb,1}='SDP'; elseif conetype=='l', AC{bb,3}=[A{bb} C{bb} ]; AC{bb,1}='LP'; elseif conetype=='q', error("Cannot do SOCP Constraints"); end end; DSDP5.8/matlab/derror.m0000644000175000017500000000574410326241002014714 0ustar twernertwerner%%************************************************************************* %% Verify solution of DSDP solver by computing objective values and errors %% %% [pobj,dobj,err] = derror(STAT,y,X,b,AC) %% %% Input: AC = DSDP Constraint data %% b = DSDP objective %% X = DSDP solution matrices %% y = DSDP solution vector %% STAT = DSDP solver status %% %% Output: objective values and errors %% err(1): || A * X - b ||_2 / (1+||b||_1) %% err(2): 0 if X is PSD, else -smallest eigevalue /(1+||b||_1) %% err(3): || C - A'y - S||_F / (1+||C||_1) %% err(4): 0 if S is PSD, else -smallest eigevalue /(1+||c||_1) %% err(5): duality gap/(1+abs(primal obj)+abs(dual obj)) %% err(6): tr(XS)/(1+abs(primal obj)+abs(dual obj)) %% %% DSDP5.0 %% Copyright (c) 2003 by %% S. Benson and Y. Ye %% Last modified: December 2003 %%****************************************************************** function [pobj,dobj,err]=derror(STAT,y,X,b,AC); [ncones,p]=size(AC); m=length(b); if (p~=3) error('Dimension of first cell array not correct.'); end; berr=[-b;0]; seigerr=0; xeigerr=0; tracexs=0; for k=1:ncones, name=AC{k,1}; if (length(name)==3 & name=='SDP'), pp=length(AC{k,2}); tnz=0; for jj=1:pp, j=AC{k,2}(jj); k1=tnz+1; k2=tnz+j*(j+1)/2; AACC=AC{k,3}(k1:k2,:); XX=X{k}(k1:k2); berr=berr+dadotx(AACC,XX); svec=AACC*[-y;1]; s=dmat(svec); seigmin=min(eig(s)); seigerr=min(seigerr,seigmin); c=dmat(AACC(:,m+1)); cnorm=norm(full(c)); x=dmat(XX); xeigmin=min(eig(x)); xeigerr=min(xeigerr,xeigmin); tracexs=tracexs+sum(sum(x.*s)); tnz=tnz+j*(j+1)/2; end; elseif (length(name)==2 & name=='LP'), berr=berr+AC{k,3}'*X{k}; svec=AC{k,3}*[-y; 1]; seigmin=min(svec); seigerr=min(seigerr,seigmin); xeigmin=min(X{k}); xeigerr=min(xeigerr,xeigmin); tracexs=tracexs+dot(X{k},svec); elseif (length(name)==2 & name=='LB'), l=[AC{k,3}]; xl=[X{k}]; berr=berr - [xl; dot(l,xl)]; tracexs=tracexs+dot(y-l,xl); xeigerr=min(xeigerr,min(xl)); seigerr=min(xeigerr,min(y-l)); elseif (length(name)==2 & name=='UB'), u=[AC{k,3}]; xu=[X{k}]; berr=berr + [xu; dot(u,xu)]; tracexs=tracexs+dot(u-y,xu); xeigerr=min(xeigerr,min(xu)); seigerr=min(xeigerr,min(u-y)); else error('Cone type not recognized: %s \n',name); end; end; dobj=dot(b,y); pobj=berr(m+1); berr(m+1)=0; derr1 = norm(berr)/(1+norm(b,'inf')); tracexs=tracexs/(1+abs(pobj)+abs(dobj)); dualitygap=(pobj-dobj)/(1+abs(pobj)+abs(dobj)); err=[derr1,xeigerr,0,seigerr,dualitygap,tracexs]; if (strcmp(STAT.stype,'Unbounded')) normS=seigerr; err(3)=normS/dobj; err(4)=err4/dobj; err(5)=0; err(6)=0; end; if (strcmp(STAT.stype,'Infeasible')) err(1)=norm(berr)/(abs(pobj)+1); err(2)=xeigmin/(abs(pobj)+1); err(5)=0; err(6)=0; end; DSDP5.8/matlab/dsdp2.m0000644000175000017500000000362210326241002014424 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2002 by % S. J. Benson, Y. Ye % Last modified: 20 January 2004 %***************************************************************************** % % Converts data from DSDP2 format to DSDP5 format and calls solver. % % % > DSDP(C,A,b) attempts to solve the positive semidefinite program % MINIMIZE trace(C*X) SUCH THAT A(:,i)'*X*A(:,i) = b_i, i=1,...,m and X >= 0 % using a dual scaling algorithm. The first argument is an n x n symmetric % matrix. The second argument is an n x m matrix, and the third % argument b is a dense column vector of length m. % % > DSDP(C,A,b,y0) specifies an initial dual vector y0. % % > DSDP(C,A,b,CC,AA) adds additional linear constraints to the dual problem. % % > DSDP(C,A,b,CC,AA,y0) specifies an initial dual vector y0. % % > [Y] = DSDP() returns the dual solution vector. % % > [Y,X] = DSDP() returns the primal and dual solution % % > [Y,X,V] = DSDP() returns the rank reduction vector. % % %***************************************************************************** function [Y,DY,K,V] = dsdp2(C,A,b,CC,AA,y0); m=length(b); AC=cell(2,3); n=size(C,1); nn=n*(n+1)/2; m=length(b); AAC=sparse(nn,m+1); for i=1:m, ai=A(:,i); AAC=[AAC dvec(ai*ai')]; end; AAC=[AAC dvec(C)]; AC{1,1}='SDP'; AC{1,2}=size(C,1); AC{2,1}='LP'; AC{2,2}=0; if nrhs>4 [n1,n2]=size(C{j}); if (n1==1 | n2==1) AAC=sparse([]); for i=1:m, AAC=[AAC sparse(AA(:,i)]; end; AAC=[AAC sparse(CC)']; AC{2,1}='LP'; AC{2,2}=length(CC); AC{2,3}=AAC; end; end; [STAT,y,X]=dsdp(b,AC,OPTIONS,y0); XX=cell(p,1); for j=1:p, [n1,n2]=size(C{j}) if (n1==1 | n2==1) XX{j}=X{j}; else XX{j}=dmat(X{j}); end; end; return; DSDP5.8/matlab/dsdp4.m0000644000175000017500000000375210326241002014432 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2002 by % S. J. Benson, Y. Ye % Last modified: 20 January 2004 %***************************************************************************** % % Converts data from DSDP4 format to DSDP5 format, calls solver, and % and converts solution to DSDP4 format. % % % > DSDP(A,C,b) attempts to solve the positive semidefinite program % MINIMIZE trace(C*X) SUCH THAT trace(A_i*X) = b_i, i=1,...,m and X >= 0 % using a dual scaling algorithm. For a problem with p blocks and m % constraints, A is a p x m cell array and C is a p x 1 cell array. % One block may contain LP variables, and the cells corresponding to % this block should be a one dimensional array. All other cells % must contain a square, symmetric, real valued matrix. The third % argument b is a dense column vector of length m. % % > DSDP(A,C,b,OPTIONS,y0) specifies an initial dual vector y0. % % > [STAT,y,X] = DSDP() returns a structure containing relevant statistics, % and approximate dual and primal solutions. % %***************************************************************************** function [STAT,y,XX] = dsdp4(A,C,b,OPTIONS,y0); p=length(C); m=length(b); AC=cell(p,3); for j=1:p, [n1,n2]=size(C{j}); if (n1==1 | n2==1) AAC=sparse(n1*n2,m+1); for i=1:m, AAC=[AAC sparse(A{j,i})']; end; AAC=[AAC sparse(C{j})']; AC{j,1}='LP'; AC{j,2}=length(C{j}); AC{j,3}=AAC; else AAC=sparse(n1*(n1+1)/2,m+1); for i=1:m, AAC=[AAC dvec(A{j,i})]; end; AAC=[AAC dvec(C{j})]; AC{j,1}='SDP'; AC{j,2}=size(C{j},1); AC{j,3}=AAC; end; end; [STAT,y,X]=dsdp(b,AC,OPTIONS,y0); XX=cell(p,1); for j=1:p, [n1,n2]=size(C{j}) if (n1==1 | n2==1) XX{j}=X{j}; else XX{j}=dmat(X{j}); end; end; return; DSDP5.8/matlab/dmat.m0000644000175000017500000000156610326241002014342 0ustar twernertwerner%%******************************************************************* %% Convert a vector matrix used by DSDP to a square symmetric matrix. %% %% [A] = dmat(V) %% %% Input: V = column vector representing upper triangle of a symmetric matrix. %% %% Output: A = square symmetric matrix %% %% See also: DVEC (its inverse operator) %% %% DSDP5.0 %% Copyright (c) 2003 by %% S. Benson and Y. Ye %% Last modified: December 2003 %%****************************************************************** function [A]=dmat(V); [m,m1]=size(V); if (m1~=1) error('Not a column vector.'); end; n=floor(sqrt(2*m)); if (n*(n+1)/2 ~= m) error('Impossible Dimension. Cannot convert to square matrix.'); end; nzV=nnz(V); if (issparse(V) | nzV < n*(n+1)/2) A=sparse(n,n); else A=zeros(n,n); end; for i=1:n, k1=i*(i-1)/2+1; k2=i*(i+1)/2; A(1:i,i)= V(k1:k2); end; A=A+triu(A,1)'; DSDP5.8/matlab/dsdp.m0000644000175000017500000001154110326241002014341 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual-Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2004 by % S. J. Benson, Y. Ye % Last modified: 20 August 2004 %***************************************************************************** % % > DSDP(b,AC) attempts to solve the positive semidefinite programs % % (P) MINIMIZE trace(C*X) SUCH THAT trace(A_i*X) = b_i, i=1,...,m and X >= 0 % (D) MAXIMIZE dot(b,y) SUCH THAT C - SUM A_i*y_i >= 0. % % using a dual-scaling interior-point algorithm. % % The first argument b is a dense column vector of length m. % % The second argument specifies the data A and C. Since this data usually % has a block structure, this argument is a p x 3 cell array, where p % is the number of blocks. Each row of the cell array specifies the % type, dimension, and data of one block. % % Semidefinite Cone: % Let A_j1 .. A_jm and C_j be the parts of the full operators associated % a semidefinite block. This data can be inserted into row j of a DSDP % formatted cell array by following the example below: % > ACj = [ dvec(A_j1) ... dvec(A_jm) dvec(C_j)]; % > AC{j,1}='SDP'; AC{j,2}=size(C_j,1); AC{j,3}=ACj; % The first cell element identifies this block as a semidefinite block. % The second cell element identifies n, the dimension of the block, and % the third cell contains the data. Each column in the third element % contains one constraint matrix A_j1, .., A_jm, or C_j in sparse vector % form ( See DVEC() ). % The number of columns in ACj is LENGTH(b)+1, and the number of rows is % n*(n+1)/2 where n is the number of rows and columns in C_j. % % Multiple Semidefinite Cones: % Each semidefinite cone can be specified on a row of the cell array. % However, these blocks can also be grouped together. To group % these blocks together, the second cell entry must be an array % of integers representing the number of blocks and dimension of each % block. The data from the blocks should be concatenated such that % the number of rows increases while the number of columns remains constant. % For instance of AC1 and AC2 represent the semidefinite blocks with % dimension 4 and 7, respectively, then % > AC{j,1}='SDP'; AC{j,2}=[4 7]; AC{j,3}=[AC1; AC2]; % % Fixed Variables: % Fixed variables are constraints where a variable y is directly % set to a value. They can be eliminated from the problem or % identified to the solver. % If a set of variables [yi1 ... yil] is fixed to values [fi ... fl], % Pass the data into a separate row of the cell array. i.e. % > AC{j,1}='FIXED'; AC{j,2}=[i1 ... il ]; AC{j,3}=[f1 .. fl]; % % LP Cone: % Scalar inequalities, or matrix inequalities of dimension 1, can be % grouped together in a block. Consider dual linear constraints of % the form A'*y <= c. They can be specified by % > AC{j,1}='LP'; AC{j,2}=length(c); AC{j,3}=[A' c]; % The string 'LP' represents scalar inequalities. The % second column in the cell array represents the number of scalar % inequalities in the block, and the third element provides % the data. % % > DSDP(b,AC,OPTIONS) specifies some options for the solver % See DOPTIONS; % % > DSDP(b,AC,OPTIONS,y0) specifies an initial solution y0 in (D). % % % > [STAT,y] = DSDP() returns a structure STAT with relevant information % concerning the performance of the solver and an approximate % solution y . See DSTAT for more description of statistics. % % > [STAT,y,X] = DSDP() returns a structure containing relevant statistics, % and approximate solutions to (D) and (P). The solution % X is a cell array with the same number of columns as the % cell array AC and has the same block structure as AC. Each % element of the cell array X is a vector. % For semidefinite blocks, the DMAT() operator may convert % the solution X into a matrix. % % OUTPUT has columns: % Iter PP Objective DD Objective PInfeas DInfeas Mu StepLength Pnrm % -------------------------------------------------------------------------------------- % that represent the iteration number, objective values to (PP) and (DD), % infeasiblity to (P) and (D), barrier parameter, % steplength for (P) and (D), and a norm representing proximity to % the target on the central path. % % % See also: DVEC, DMAT, DSPARSE, DOPTIONS, DSTAT, DERROR % % Examples: MAXCUT, GPP, THETAPROBLEM, CONTROL, ETP, READSDPA, READSEDUMI % % DSDP5.0 % Copyright (c) 2004 by % S. Benson and Y. Ye % Last modified: August 2004 %***************************************************************************** DSDP5.8/matlab/dvec.m0000644000175000017500000000156210326241002014332 0ustar twernertwerner%%******************************************************************* %% Convert a square symmetric matrix to a vector %% representation used by DSDP %% %% [V] = dvec(A) %% %% Input: A = square symmetric matrix. Lower triangular entries %% are ignored. %% %% Output: V = column vector representing half of a symmetric matrix. %% If A has n rows and columns, V is a column vector with %% n*(n+1)/2 rows. %% %% See also: DSPARSE, DMAT (its inverse operator) %% %% DSDP5.0 %% Copyright (c) 2003 by %% S. Benson and Y. Ye %% Last modified: December 2003 %%****************************************************************** function [V]=dvec(A); [n,n1]=size(A); if (n~=n1) error('Matrix not square.'); end; nn=n*(n+1)/2; V=zeros(nn,1); for i=1:n, k1=i*(i-1)/2+1; k2=i*(i+1)/2; V(k1:k2,1) = A(1:i,i); end; V=sparse(V); DSDP5.8/matlab/maxcut.m0000644000175000017500000000234210326241002014707 0ustar twernertwerner%%******************************************************* %% maxcut: MAXCUT problem. %% %% (P) min Tr C*X %% s.t. diag(X) = e; %% %% C = -(diag(B*e)-B)/4. %% %% (dual problem) max e'*y %% s.t. diag(y) + S = C. %%------------------------------------------------------- %% %% [X,y,objval] = maxcut(B); %% %% B: weighted adjacency matrix of a graph. %% %% DSDP5.0 %% Copyright (c) 2004 by %% S. Benson, Y. Ye %% Last modified: Jan 2004 %%******************************************************* function [X,y,objval] = maxcut(B); if ~isreal(B); error('only real B allowed'); end; n = length(B); e = ones(n,1); CC = -(spdiags(B*e,0,n,n)-B)/4.0; b = e; AC = cell(1,3); AC{1,1}='SDP'; AC{1,2}=n; nn=n*(n+1)/2; AAC=sparse(nn,n); for k = 1:n; AAC(:,k) = dsparse(k,k,1,n,n); end; AAC=[AAC sparse(dvec(CC))]; AC{1,3}=AAC; y0 = -1.1*abs(CC)*e; OPTIONS=doptions; OPTIONS.gaptol=0.0001; OPTIONS.r0=0; OPTIONS.print=1; OPTIONS.rho=5; OPTIONS.zbar=norm(B,1); [STAT,y,Xv] = dsdp(b,AC,OPTIONS,y0); [objval,dobj,err] = derror(STAT,y,Xv,b,AC); X=dmat(Xv{1}); return; %%======================================================= DSDP5.8/matlab/arch0.dat-s0000644000175000017500000021572010326241002015165 0ustar twernertwerner174 2 161 -174 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 2.236068 0 1 2 2 1.0 0 1 3 3 1.0 0 1 5 5 1.0 0 1 6 6 1.0 0 1 8 8 1.0 0 1 9 9 1.0 0 1 11 11 1.0 0 1 12 12 1.0 0 1 14 14 1.0 0 1 15 15 1.0 0 1 17 17 1.0 0 1 18 18 1.0 0 1 20 20 1.0 0 1 21 21 1.0 0 1 23 23 1.0 0 1 24 24 1.0 0 1 26 26 1.0 0 1 27 27 1.0 0 2 1 1 0.000001 0 2 2 2 0.000001 0 2 3 3 0.000001 0 2 4 4 0.000001 0 2 5 5 0.000001 0 2 6 6 0.000001 0 2 7 7 0.000001 0 2 8 8 0.000001 0 2 9 9 0.000001 0 2 10 10 0.000001 0 2 11 11 0.000001 0 2 12 12 0.000001 0 2 13 13 0.000001 0 2 14 14 0.000001 0 2 15 15 0.000001 0 2 16 16 0.000001 0 2 17 17 0.000001 0 2 18 18 0.000001 0 2 19 19 0.000001 0 2 20 20 0.000001 0 2 21 21 0.000001 0 2 22 22 0.000001 0 2 23 23 0.000001 0 2 24 24 0.000001 0 2 25 25 0.000001 0 2 26 26 0.000001 0 2 27 27 0.000001 0 2 28 28 0.000001 0 2 29 29 0.000001 0 2 30 30 0.000001 0 2 31 31 0.000001 0 2 32 32 0.000001 0 2 33 33 0.000001 0 2 34 34 0.000001 0 2 35 35 0.000001 0 2 36 36 0.000001 0 2 37 37 0.000001 0 2 38 38 0.000001 0 2 39 39 0.000001 0 2 40 40 0.000001 0 2 41 41 0.000001 0 2 42 42 0.000001 0 2 43 43 0.000001 0 2 44 44 0.000001 0 2 45 45 0.000001 0 2 46 46 0.000001 0 2 47 47 0.000001 0 2 48 48 0.000001 0 2 49 49 0.000001 0 2 50 50 0.000001 0 2 51 51 0.000001 0 2 52 52 0.000001 0 2 53 53 0.000001 0 2 54 54 0.000001 0 2 55 55 0.000001 0 2 56 56 0.000001 0 2 57 57 0.000001 0 2 58 58 0.000001 0 2 59 59 0.000001 0 2 60 60 0.000001 0 2 61 61 0.000001 0 2 62 62 0.000001 0 2 63 63 0.000001 0 2 64 64 0.000001 0 2 65 65 0.000001 0 2 66 66 0.000001 0 2 67 67 0.000001 0 2 68 68 0.000001 0 2 69 69 0.000001 0 2 70 70 0.000001 0 2 71 71 0.000001 0 2 72 72 0.000001 0 2 73 73 0.000001 0 2 74 74 0.000001 0 2 75 75 0.000001 0 2 76 76 0.000001 0 2 77 77 0.000001 0 2 78 78 0.000001 0 2 79 79 0.000001 0 2 80 80 0.000001 0 2 81 81 0.000001 0 2 82 82 0.000001 0 2 83 83 0.000001 0 2 84 84 0.000001 0 2 85 85 0.000001 0 2 86 86 0.000001 0 2 87 87 0.000001 0 2 88 88 0.000001 0 2 89 89 0.000001 0 2 90 90 0.000001 0 2 91 91 0.000001 0 2 92 92 0.000001 0 2 93 93 0.000001 0 2 94 94 0.000001 0 2 95 95 0.000001 0 2 96 96 0.000001 0 2 97 97 0.000001 0 2 98 98 0.000001 0 2 99 99 0.000001 0 2 100 100 0.000001 0 2 101 101 0.000001 0 2 102 102 0.000001 0 2 103 103 0.000001 0 2 104 104 0.000001 0 2 105 105 0.000001 0 2 106 106 0.000001 0 2 107 107 0.000001 0 2 108 108 0.000001 0 2 109 109 0.000001 0 2 110 110 0.000001 0 2 111 111 0.000001 0 2 112 112 0.000001 0 2 113 113 0.000001 0 2 114 114 0.000001 0 2 115 115 0.000001 0 2 116 116 0.000001 0 2 117 117 0.000001 0 2 118 118 0.000001 0 2 119 119 0.000001 0 2 120 120 0.000001 0 2 121 121 0.000001 0 2 122 122 0.000001 0 2 123 123 0.000001 0 2 124 124 0.000001 0 2 125 125 0.000001 0 2 126 126 0.000001 0 2 127 127 0.000001 0 2 128 128 0.000001 0 2 129 129 0.000001 0 2 130 130 0.000001 0 2 131 131 0.000001 0 2 132 132 0.000001 0 2 133 133 0.000001 0 2 134 134 0.000001 0 2 135 135 0.000001 0 2 136 136 0.000001 0 2 137 137 0.000001 0 2 138 138 0.000001 0 2 139 139 0.000001 0 2 140 140 0.000001 0 2 141 141 0.000001 0 2 142 142 0.000001 0 2 143 143 0.000001 0 2 144 144 0.000001 0 2 145 145 0.000001 0 2 146 146 0.000001 0 2 147 147 0.000001 0 2 148 148 0.000001 0 2 149 149 0.000001 0 2 150 150 0.000001 0 2 151 151 0.000001 0 2 152 152 0.000001 0 2 153 153 0.000001 0 2 154 154 0.000001 0 2 155 155 0.000001 0 2 156 156 0.000001 0 2 157 157 0.000001 0 2 158 158 0.000001 0 2 159 159 0.000001 0 2 160 160 0.000001 0 2 161 161 0.000001 0 2 162 162 0.000001 0 2 163 163 0.000001 0 2 164 164 0.000001 0 2 165 165 0.000001 0 2 166 166 0.000001 0 2 167 167 0.000001 0 2 168 168 0.000001 0 2 169 169 0.000001 0 2 170 170 0.000001 0 2 171 171 0.000001 0 2 172 172 0.000001 0 2 173 173 0.000001 0 2 174 174 0.000001 1 1 1 1 12.221733 1 1 1 3 -9.233433 1 1 1 4 6.146200 1 1 2 2 4899.752667 1 1 3 3 8.911900 1 1 3 4 -9.109767 1 1 4 4 12.221733 1 2 1 1 1.0 2 1 2 2 4899.752667 2 1 2 5 -4900.123667 2 1 3 3 8.911900 2 1 3 4 9.109767 2 1 3 6 -9.282900 2 1 3 7 9.233433 2 1 4 4 12.221733 2 1 4 6 -9.233433 2 1 4 7 6.146200 2 1 5 5 4899.752667 2 1 6 6 8.911900 2 1 6 7 -9.109767 2 1 7 7 12.221733 2 2 2 2 1.0 3 1 5 5 4899.752667 3 1 5 8 -4900.123667 3 1 6 6 8.911900 3 1 6 7 9.109767 3 1 6 9 -9.282900 3 1 6 10 9.233433 3 1 7 7 12.221733 3 1 7 9 -9.233433 3 1 7 10 6.146200 3 1 8 8 4899.752667 3 1 9 9 8.911900 3 1 9 10 -9.109767 3 1 10 10 12.221733 3 2 3 3 1.0 4 1 8 8 4899.752667 4 1 8 11 -4900.123667 4 1 9 9 8.911900 4 1 9 10 9.109767 4 1 9 12 -9.282900 4 1 9 13 9.233433 4 1 10 10 12.221733 4 1 10 12 -9.233433 4 1 10 13 6.146200 4 1 11 11 4899.752667 4 1 12 12 8.911900 4 1 12 13 -9.109767 4 1 13 13 12.221733 4 2 4 4 1.0 5 1 11 11 4899.752667 5 1 11 14 -4900.123667 5 1 12 12 8.911900 5 1 12 13 9.109767 5 1 12 15 -9.282900 5 1 12 16 9.233433 5 1 13 13 12.221733 5 1 13 15 -9.233433 5 1 13 16 6.146200 5 1 14 14 4899.752667 5 1 15 15 8.911900 5 1 15 16 -9.109767 5 1 16 16 12.221733 5 2 5 5 1.0 6 1 14 14 4899.752667 6 1 14 17 -4900.123667 6 1 15 15 8.911900 6 1 15 16 9.109767 6 1 15 18 -9.282900 6 1 15 19 9.233433 6 1 16 16 12.221733 6 1 16 18 -9.233433 6 1 16 19 6.146200 6 1 17 17 4899.752667 6 1 18 18 8.911900 6 1 18 19 -9.109767 6 1 19 19 12.221733 6 2 6 6 1.0 7 1 17 17 4899.752667 7 1 17 20 -4900.123667 7 1 18 18 8.911900 7 1 18 19 9.109767 7 1 18 21 -9.282900 7 1 18 22 9.233433 7 1 19 19 12.221733 7 1 19 21 -9.233433 7 1 19 22 6.146200 7 1 20 20 4899.752667 7 1 21 21 8.911900 7 1 21 22 -9.109767 7 1 22 22 12.221733 7 2 7 7 1.0 8 1 20 20 4899.752667 8 1 20 23 -4900.123667 8 1 21 21 8.911900 8 1 21 22 9.109767 8 1 21 24 -9.282900 8 1 21 25 9.233433 8 1 22 22 12.221733 8 1 22 24 -9.233433 8 1 22 25 6.146200 8 1 23 23 4899.752667 8 1 24 24 8.911900 8 1 24 25 -9.109767 8 1 25 25 12.221733 8 2 8 8 1.0 9 1 23 23 4899.752667 9 1 23 26 -4900.123667 9 1 24 24 8.911900 9 1 24 25 9.109767 9 1 24 27 -9.282900 9 1 24 28 9.233433 9 1 25 25 12.221733 9 1 25 27 -9.233433 9 1 25 28 6.146200 9 1 26 26 4899.752667 9 1 27 27 8.911900 9 1 27 28 -9.109767 9 1 28 28 12.221733 9 2 9 9 1.0 10 1 26 26 4899.752667 10 1 27 27 8.911900 10 1 27 28 9.109767 10 1 27 29 9.233433 10 1 28 28 12.221733 10 1 28 29 6.146200 10 1 29 29 12.221733 10 2 10 10 1.0 11 1 30 30 4899.752667 11 1 30 33 -4900.123667 11 1 31 31 8.911900 11 1 31 32 9.109767 11 1 31 34 -9.282900 11 1 31 35 9.233433 11 1 32 32 12.221733 11 1 32 34 -9.233433 11 1 32 35 6.146200 11 1 33 33 4899.752667 11 1 34 34 8.911900 11 1 34 35 -9.109767 11 1 35 35 12.221733 11 2 11 11 1.0 12 1 33 33 4899.752667 12 1 33 36 -4900.123667 12 1 34 34 8.911900 12 1 34 35 9.109767 12 1 34 37 -9.282900 12 1 34 38 9.233433 12 1 35 35 12.221733 12 1 35 37 -9.233433 12 1 35 38 6.146200 12 1 36 36 4899.752667 12 1 37 37 8.911900 12 1 37 38 -9.109767 12 1 38 38 12.221733 12 2 12 12 1.0 13 1 36 36 4899.752667 13 1 36 39 -4900.123667 13 1 37 37 8.911900 13 1 37 38 9.109767 13 1 37 40 -9.282900 13 1 37 41 9.233433 13 1 38 38 12.221733 13 1 38 40 -9.233433 13 1 38 41 6.146200 13 1 39 39 4899.752667 13 1 40 40 8.911900 13 1 40 41 -9.109767 13 1 41 41 12.221733 13 2 13 13 1.0 14 1 39 39 4899.752667 14 1 39 42 -4900.123667 14 1 40 40 8.911900 14 1 40 41 9.109767 14 1 40 43 -9.282900 14 1 40 44 9.233433 14 1 41 41 12.221733 14 1 41 43 -9.233433 14 1 41 44 6.146200 14 1 42 42 4899.752667 14 1 43 43 8.911900 14 1 43 44 -9.109767 14 1 44 44 12.221733 14 2 14 14 1.0 15 1 42 42 4899.752667 15 1 42 45 -4900.123667 15 1 43 43 8.911900 15 1 43 44 9.109767 15 1 43 46 -9.282900 15 1 43 47 9.233433 15 1 44 44 12.221733 15 1 44 46 -9.233433 15 1 44 47 6.146200 15 1 45 45 4899.752667 15 1 46 46 8.911900 15 1 46 47 -9.109767 15 1 47 47 12.221733 15 2 15 15 1.0 16 1 45 45 4899.752667 16 1 45 48 -4900.123667 16 1 46 46 8.911900 16 1 46 47 9.109767 16 1 46 49 -9.282900 16 1 46 50 9.233433 16 1 47 47 12.221733 16 1 47 49 -9.233433 16 1 47 50 6.146200 16 1 48 48 4899.752667 16 1 49 49 8.911900 16 1 49 50 -9.109767 16 1 50 50 12.221733 16 2 16 16 1.0 17 1 48 48 4899.752667 17 1 48 51 -4900.123667 17 1 49 49 8.911900 17 1 49 50 9.109767 17 1 49 52 -9.282900 17 1 49 53 9.233433 17 1 50 50 12.221733 17 1 50 52 -9.233433 17 1 50 53 6.146200 17 1 51 51 4899.752667 17 1 52 52 8.911900 17 1 52 53 -9.109767 17 1 53 53 12.221733 17 2 17 17 1.0 18 1 51 51 4899.752667 18 1 51 54 -4900.123667 18 1 52 52 8.911900 18 1 52 53 9.109767 18 1 52 55 -9.282900 18 1 52 56 9.233433 18 1 53 53 12.221733 18 1 53 55 -9.233433 18 1 53 56 6.146200 18 1 54 54 4899.752667 18 1 55 55 8.911900 18 1 55 56 -9.109767 18 1 56 56 12.221733 18 2 18 18 1.0 19 1 54 54 4899.752667 19 1 54 57 -4900.123667 19 1 55 55 8.911900 19 1 55 56 9.109767 19 1 55 58 -9.282900 19 1 55 59 9.233433 19 1 56 56 12.221733 19 1 56 58 -9.233433 19 1 56 59 6.146200 19 1 57 57 4899.752667 19 1 58 58 8.911900 19 1 58 59 -9.109767 19 1 59 59 12.221733 19 2 19 19 1.0 20 1 57 57 4899.752667 20 1 57 60 -4900.123667 20 1 58 58 8.911900 20 1 58 59 9.109767 20 1 58 61 -9.282900 20 1 58 62 9.233433 20 1 59 59 12.221733 20 1 59 61 -9.233433 20 1 59 62 6.146200 20 1 60 60 4899.752667 20 1 61 61 8.911900 20 1 61 62 -9.109767 20 1 62 62 12.221733 20 2 20 20 1.0 21 1 63 63 4899.752667 21 1 63 66 -4900.123667 21 1 64 64 8.911900 21 1 64 65 9.109767 21 1 64 67 -9.282900 21 1 64 68 9.233433 21 1 65 65 12.221733 21 1 65 67 -9.233433 21 1 65 68 6.146200 21 1 66 66 4899.752667 21 1 67 67 8.911900 21 1 67 68 -9.109767 21 1 68 68 12.221733 21 2 21 21 1.0 22 1 66 66 4899.752667 22 1 66 69 -4900.123667 22 1 67 67 8.911900 22 1 67 68 9.109767 22 1 67 70 -9.282900 22 1 67 71 9.233433 22 1 68 68 12.221733 22 1 68 70 -9.233433 22 1 68 71 6.146200 22 1 69 69 4899.752667 22 1 70 70 8.911900 22 1 70 71 -9.109767 22 1 71 71 12.221733 22 2 22 22 1.0 23 1 69 69 4899.752667 23 1 69 72 -4900.123667 23 1 70 70 8.911900 23 1 70 71 9.109767 23 1 70 73 -9.282900 23 1 70 74 9.233433 23 1 71 71 12.221733 23 1 71 73 -9.233433 23 1 71 74 6.146200 23 1 72 72 4899.752667 23 1 73 73 8.911900 23 1 73 74 -9.109767 23 1 74 74 12.221733 23 2 23 23 1.0 24 1 72 72 4899.752667 24 1 72 75 -4900.123667 24 1 73 73 8.911900 24 1 73 74 9.109767 24 1 73 76 -9.282900 24 1 73 77 9.233433 24 1 74 74 12.221733 24 1 74 76 -9.233433 24 1 74 77 6.146200 24 1 75 75 4899.752667 24 1 76 76 8.911900 24 1 76 77 -9.109767 24 1 77 77 12.221733 24 2 24 24 1.0 25 1 75 75 4899.752667 25 1 75 78 -4900.123667 25 1 76 76 8.911900 25 1 76 77 9.109767 25 1 76 79 -9.282900 25 1 76 80 9.233433 25 1 77 77 12.221733 25 1 77 79 -9.233433 25 1 77 80 6.146200 25 1 78 78 4899.752667 25 1 79 79 8.911900 25 1 79 80 -9.109767 25 1 80 80 12.221733 25 2 25 25 1.0 26 1 78 78 4899.752667 26 1 78 81 -4900.123667 26 1 79 79 8.911900 26 1 79 80 9.109767 26 1 79 82 -9.282900 26 1 79 83 9.233433 26 1 80 80 12.221733 26 1 80 82 -9.233433 26 1 80 83 6.146200 26 1 81 81 4899.752667 26 1 82 82 8.911900 26 1 82 83 -9.109767 26 1 83 83 12.221733 26 2 26 26 1.0 27 1 81 81 4899.752667 27 1 81 84 -4900.123667 27 1 82 82 8.911900 27 1 82 83 9.109767 27 1 82 85 -9.282900 27 1 82 86 9.233433 27 1 83 83 12.221733 27 1 83 85 -9.233433 27 1 83 86 6.146200 27 1 84 84 4899.752667 27 1 85 85 8.911900 27 1 85 86 -9.109767 27 1 86 86 12.221733 27 2 27 27 1.0 28 1 84 84 4899.752667 28 1 84 87 -4900.123667 28 1 85 85 8.911900 28 1 85 86 9.109767 28 1 85 88 -9.282900 28 1 85 89 9.233433 28 1 86 86 12.221733 28 1 86 88 -9.233433 28 1 86 89 6.146200 28 1 87 87 4899.752667 28 1 88 88 8.911900 28 1 88 89 -9.109767 28 1 89 89 12.221733 28 2 28 28 1.0 29 1 87 87 4899.752667 29 1 87 90 -4900.123667 29 1 88 88 8.911900 29 1 88 89 9.109767 29 1 88 91 -9.282900 29 1 88 92 9.233433 29 1 89 89 12.221733 29 1 89 91 -9.233433 29 1 89 92 6.146200 29 1 90 90 4899.752667 29 1 91 91 8.911900 29 1 91 92 -9.109767 29 1 92 92 12.221733 29 2 29 29 1.0 30 1 90 90 4899.752667 30 1 90 93 -4900.123667 30 1 91 91 8.911900 30 1 91 92 9.109767 30 1 91 94 -9.282900 30 1 91 95 9.233433 30 1 92 92 12.221733 30 1 92 94 -9.233433 30 1 92 95 6.146200 30 1 93 93 4899.752667 30 1 94 94 8.911900 30 1 94 95 -9.109767 30 1 95 95 12.221733 30 2 30 30 1.0 31 1 96 96 4899.752667 31 1 96 99 -4900.123667 31 1 97 97 8.911900 31 1 97 98 9.109767 31 1 97 100 -9.282900 31 1 97 101 9.233433 31 1 98 98 12.221733 31 1 98 100 -9.233433 31 1 98 101 6.146200 31 1 99 99 4899.752667 31 1 100 100 8.911900 31 1 100 101 -9.109767 31 1 101 101 12.221733 31 2 31 31 1.0 32 1 99 99 4899.752667 32 1 99 102 -4900.123667 32 1 100 100 8.911900 32 1 100 101 9.109767 32 1 100 103 -9.282900 32 1 100 104 9.233433 32 1 101 101 12.221733 32 1 101 103 -9.233433 32 1 101 104 6.146200 32 1 102 102 4899.752667 32 1 103 103 8.911900 32 1 103 104 -9.109767 32 1 104 104 12.221733 32 2 32 32 1.0 33 1 102 102 4899.752667 33 1 102 105 -4900.123667 33 1 103 103 8.911900 33 1 103 104 9.109767 33 1 103 106 -9.282900 33 1 103 107 9.233433 33 1 104 104 12.221733 33 1 104 106 -9.233433 33 1 104 107 6.146200 33 1 105 105 4899.752667 33 1 106 106 8.911900 33 1 106 107 -9.109767 33 1 107 107 12.221733 33 2 33 33 1.0 34 1 105 105 4899.752667 34 1 105 108 -4900.123667 34 1 106 106 8.911900 34 1 106 107 9.109767 34 1 106 109 -9.282900 34 1 106 110 9.233433 34 1 107 107 12.221733 34 1 107 109 -9.233433 34 1 107 110 6.146200 34 1 108 108 4899.752667 34 1 109 109 8.911900 34 1 109 110 -9.109767 34 1 110 110 12.221733 34 2 34 34 1.0 35 1 108 108 4899.752667 35 1 108 111 -4900.123667 35 1 109 109 8.911900 35 1 109 110 9.109767 35 1 109 112 -9.282900 35 1 109 113 9.233433 35 1 110 110 12.221733 35 1 110 112 -9.233433 35 1 110 113 6.146200 35 1 111 111 4899.752667 35 1 112 112 8.911900 35 1 112 113 -9.109767 35 1 113 113 12.221733 35 2 35 35 1.0 36 1 111 111 4899.752667 36 1 111 114 -4900.123667 36 1 112 112 8.911900 36 1 112 113 9.109767 36 1 112 115 -9.282900 36 1 112 116 9.233433 36 1 113 113 12.221733 36 1 113 115 -9.233433 36 1 113 116 6.146200 36 1 114 114 4899.752667 36 1 115 115 8.911900 36 1 115 116 -9.109767 36 1 116 116 12.221733 36 2 36 36 1.0 37 1 114 114 4899.752667 37 1 114 117 -4900.123667 37 1 115 115 8.911900 37 1 115 116 9.109767 37 1 115 118 -9.282900 37 1 115 119 9.233433 37 1 116 116 12.221733 37 1 116 118 -9.233433 37 1 116 119 6.146200 37 1 117 117 4899.752667 37 1 118 118 8.911900 37 1 118 119 -9.109767 37 1 119 119 12.221733 37 2 37 37 1.0 38 1 117 117 4899.752667 38 1 117 120 -4900.123667 38 1 118 118 8.911900 38 1 118 119 9.109767 38 1 118 121 -9.282900 38 1 118 122 9.233433 38 1 119 119 12.221733 38 1 119 121 -9.233433 38 1 119 122 6.146200 38 1 120 120 4899.752667 38 1 121 121 8.911900 38 1 121 122 -9.109767 38 1 122 122 12.221733 38 2 38 38 1.0 39 1 120 120 4899.752667 39 1 120 123 -4900.123667 39 1 121 121 8.911900 39 1 121 122 9.109767 39 1 121 124 -9.282900 39 1 121 125 9.233433 39 1 122 122 12.221733 39 1 122 124 -9.233433 39 1 122 125 6.146200 39 1 123 123 4899.752667 39 1 124 124 8.911900 39 1 124 125 -9.109767 39 1 125 125 12.221733 39 2 39 39 1.0 40 1 123 123 4899.752667 40 1 123 126 -4900.123667 40 1 124 124 8.911900 40 1 124 125 9.109767 40 1 124 127 -9.282900 40 1 124 128 9.233433 40 1 125 125 12.221733 40 1 125 127 -9.233433 40 1 125 128 6.146200 40 1 126 126 4899.752667 40 1 127 127 8.911900 40 1 127 128 -9.109767 40 1 128 128 12.221733 40 2 40 40 1.0 41 1 129 129 4899.752667 41 1 129 132 -4900.123667 41 1 130 130 8.911900 41 1 130 131 9.109767 41 1 130 133 -9.282900 41 1 130 134 9.233433 41 1 131 131 12.221733 41 1 131 133 -9.233433 41 1 131 134 6.146200 41 1 132 132 4899.752667 41 1 133 133 8.911900 41 1 133 134 -9.109767 41 1 134 134 12.221733 41 2 41 41 1.0 42 1 132 132 4899.752667 42 1 132 135 -4900.123667 42 1 133 133 8.911900 42 1 133 134 9.109767 42 1 133 136 -9.282900 42 1 133 137 9.233433 42 1 134 134 12.221733 42 1 134 136 -9.233433 42 1 134 137 6.146200 42 1 135 135 4899.752667 42 1 136 136 8.911900 42 1 136 137 -9.109767 42 1 137 137 12.221733 42 2 42 42 1.0 43 1 135 135 4899.752667 43 1 135 138 -4900.123667 43 1 136 136 8.911900 43 1 136 137 9.109767 43 1 136 139 -9.282900 43 1 136 140 9.233433 43 1 137 137 12.221733 43 1 137 139 -9.233433 43 1 137 140 6.146200 43 1 138 138 4899.752667 43 1 139 139 8.911900 43 1 139 140 -9.109767 43 1 140 140 12.221733 43 2 43 43 1.0 44 1 138 138 4899.752667 44 1 138 141 -4900.123667 44 1 139 139 8.911900 44 1 139 140 9.109767 44 1 139 142 -9.282900 44 1 139 143 9.233433 44 1 140 140 12.221733 44 1 140 142 -9.233433 44 1 140 143 6.146200 44 1 141 141 4899.752667 44 1 142 142 8.911900 44 1 142 143 -9.109767 44 1 143 143 12.221733 44 2 44 44 1.0 45 1 141 141 4899.752667 45 1 141 144 -4900.123667 45 1 142 142 8.911900 45 1 142 143 9.109767 45 1 142 145 -9.282900 45 1 142 146 9.233433 45 1 143 143 12.221733 45 1 143 145 -9.233433 45 1 143 146 6.146200 45 1 144 144 4899.752667 45 1 145 145 8.911900 45 1 145 146 -9.109767 45 1 146 146 12.221733 45 2 45 45 1.0 46 1 144 144 4899.752667 46 1 144 147 -4900.123667 46 1 145 145 8.911900 46 1 145 146 9.109767 46 1 145 148 -9.282900 46 1 145 149 9.233433 46 1 146 146 12.221733 46 1 146 148 -9.233433 46 1 146 149 6.146200 46 1 147 147 4899.752667 46 1 148 148 8.911900 46 1 148 149 -9.109767 46 1 149 149 12.221733 46 2 46 46 1.0 47 1 147 147 4899.752667 47 1 147 150 -4900.123667 47 1 148 148 8.911900 47 1 148 149 9.109767 47 1 148 151 -9.282900 47 1 148 152 9.233433 47 1 149 149 12.221733 47 1 149 151 -9.233433 47 1 149 152 6.146200 47 1 150 150 4899.752667 47 1 151 151 8.911900 47 1 151 152 -9.109767 47 1 152 152 12.221733 47 2 47 47 1.0 48 1 150 150 4899.752667 48 1 150 153 -4900.123667 48 1 151 151 8.911900 48 1 151 152 9.109767 48 1 151 154 -9.282900 48 1 151 155 9.233433 48 1 152 152 12.221733 48 1 152 154 -9.233433 48 1 152 155 6.146200 48 1 153 153 4899.752667 48 1 154 154 8.911900 48 1 154 155 -9.109767 48 1 155 155 12.221733 48 2 48 48 1.0 49 1 153 153 4899.752667 49 1 153 156 -4900.123667 49 1 154 154 8.911900 49 1 154 155 9.109767 49 1 154 157 -9.282900 49 1 154 158 9.233433 49 1 155 155 12.221733 49 1 155 157 -9.233433 49 1 155 158 6.146200 49 1 156 156 4899.752667 49 1 157 157 8.911900 49 1 157 158 -9.109767 49 1 158 158 12.221733 49 2 49 49 1.0 50 1 156 156 4899.752667 50 1 156 159 -4900.123667 50 1 157 157 8.911900 50 1 157 158 9.109767 50 1 157 160 -9.282900 50 1 157 161 9.233433 50 1 158 158 12.221733 50 1 158 160 -9.233433 50 1 158 161 6.146200 50 1 159 159 4899.752667 50 1 160 160 8.911900 50 1 160 161 -9.109767 50 1 161 161 12.221733 50 2 50 50 1.0 51 1 1 1 24.496467 51 1 1 30 36.761483 51 1 1 32 12.252650 51 1 30 30 73.362200 51 1 30 32 36.730567 51 1 31 31 9799.876333 51 1 32 32 24.496467 51 2 51 51 1.0 52 1 2 2 73.362200 52 1 2 4 -36.730567 52 1 2 33 -73.547700 52 1 2 35 -36.761483 52 1 3 3 9799.876333 52 1 3 34 -9800.061833 52 1 4 4 24.496467 52 1 4 33 36.761483 52 1 4 35 12.252650 52 1 33 33 73.362200 52 1 33 35 36.730567 52 1 34 34 9799.876333 52 1 35 35 24.496467 52 2 52 52 1.0 53 1 5 5 73.362200 53 1 5 7 -36.730567 53 1 5 36 -73.547700 53 1 5 38 -36.761483 53 1 6 6 9799.876333 53 1 6 37 -9800.061833 53 1 7 7 24.496467 53 1 7 36 36.761483 53 1 7 38 12.252650 53 1 36 36 73.362200 53 1 36 38 36.730567 53 1 37 37 9799.876333 53 1 38 38 24.496467 53 2 53 53 1.0 54 1 8 8 73.362200 54 1 8 10 -36.730567 54 1 8 39 -73.547700 54 1 8 41 -36.761483 54 1 9 9 9799.876333 54 1 9 40 -9800.061833 54 1 10 10 24.496467 54 1 10 39 36.761483 54 1 10 41 12.252650 54 1 39 39 73.362200 54 1 39 41 36.730567 54 1 40 40 9799.876333 54 1 41 41 24.496467 54 2 54 54 1.0 55 1 11 11 73.362200 55 1 11 13 -36.730567 55 1 11 42 -73.547700 55 1 11 44 -36.761483 55 1 12 12 9799.876333 55 1 12 43 -9800.061833 55 1 13 13 24.496467 55 1 13 42 36.761483 55 1 13 44 12.252650 55 1 42 42 73.362200 55 1 42 44 36.730567 55 1 43 43 9799.876333 55 1 44 44 24.496467 55 2 55 55 1.0 56 1 14 14 73.362200 56 1 14 16 -36.730567 56 1 14 45 -73.547700 56 1 14 47 -36.761483 56 1 15 15 9799.876333 56 1 15 46 -9800.061833 56 1 16 16 24.496467 56 1 16 45 36.761483 56 1 16 47 12.252650 56 1 45 45 73.362200 56 1 45 47 36.730567 56 1 46 46 9799.876333 56 1 47 47 24.496467 56 2 56 56 1.0 57 1 17 17 73.362200 57 1 17 19 -36.730567 57 1 17 48 -73.547700 57 1 17 50 -36.761483 57 1 18 18 9799.876333 57 1 18 49 -9800.061833 57 1 19 19 24.496467 57 1 19 48 36.761483 57 1 19 50 12.252650 57 1 48 48 73.362200 57 1 48 50 36.730567 57 1 49 49 9799.876333 57 1 50 50 24.496467 57 2 57 57 1.0 58 1 20 20 73.362200 58 1 20 22 -36.730567 58 1 20 51 -73.547700 58 1 20 53 -36.761483 58 1 21 21 9799.876333 58 1 21 52 -9800.061833 58 1 22 22 24.496467 58 1 22 51 36.761483 58 1 22 53 12.252650 58 1 51 51 73.362200 58 1 51 53 36.730567 58 1 52 52 9799.876333 58 1 53 53 24.496467 58 2 58 58 1.0 59 1 23 23 73.362200 59 1 23 25 -36.730567 59 1 23 54 -73.547700 59 1 23 56 -36.761483 59 1 24 24 9799.876333 59 1 24 55 -9800.061833 59 1 25 25 24.496467 59 1 25 54 36.761483 59 1 25 56 12.252650 59 1 54 54 73.362200 59 1 54 56 36.730567 59 1 55 55 9799.876333 59 1 56 56 24.496467 59 2 59 59 1.0 60 1 26 26 73.362200 60 1 26 28 -36.730567 60 1 26 57 -73.547700 60 1 26 59 -36.761483 60 1 27 27 9799.876333 60 1 27 58 -9800.061833 60 1 28 28 24.496467 60 1 28 57 36.761483 60 1 28 59 12.252650 60 1 57 57 73.362200 60 1 57 59 36.730567 60 1 58 58 9799.876333 60 1 59 59 24.496467 60 2 60 60 1.0 61 1 29 29 24.496467 61 1 29 60 36.761483 61 1 29 62 12.252650 61 1 60 60 73.362200 61 1 60 62 36.730567 61 1 61 61 9799.876333 61 1 62 62 24.496467 61 2 61 61 1.0 62 1 30 30 73.362200 62 1 30 32 -36.730567 62 1 30 63 -73.547700 62 1 30 65 -36.761483 62 1 31 31 9799.876333 62 1 31 64 -9800.061833 62 1 32 32 24.496467 62 1 32 63 36.761483 62 1 32 65 12.252650 62 1 63 63 73.362200 62 1 63 65 36.730567 62 1 64 64 9799.876333 62 1 65 65 24.496467 62 2 62 62 1.0 63 1 33 33 73.362200 63 1 33 35 -36.730567 63 1 33 66 -73.547700 63 1 33 68 -36.761483 63 1 34 34 9799.876333 63 1 34 67 -9800.061833 63 1 35 35 24.496467 63 1 35 66 36.761483 63 1 35 68 12.252650 63 1 66 66 73.362200 63 1 66 68 36.730567 63 1 67 67 9799.876333 63 1 68 68 24.496467 63 2 63 63 1.0 64 1 36 36 73.362200 64 1 36 38 -36.730567 64 1 36 69 -73.547700 64 1 36 71 -36.761483 64 1 37 37 9799.876333 64 1 37 70 -9800.061833 64 1 38 38 24.496467 64 1 38 69 36.761483 64 1 38 71 12.252650 64 1 69 69 73.362200 64 1 69 71 36.730567 64 1 70 70 9799.876333 64 1 71 71 24.496467 64 2 64 64 1.0 65 1 39 39 73.362200 65 1 39 41 -36.730567 65 1 39 72 -73.547700 65 1 39 74 -36.761483 65 1 40 40 9799.876333 65 1 40 73 -9800.061833 65 1 41 41 24.496467 65 1 41 72 36.761483 65 1 41 74 12.252650 65 1 72 72 73.362200 65 1 72 74 36.730567 65 1 73 73 9799.876333 65 1 74 74 24.496467 65 2 65 65 1.0 66 1 42 42 73.362200 66 1 42 44 -36.730567 66 1 42 75 -73.547700 66 1 42 77 -36.761483 66 1 43 43 9799.876333 66 1 43 76 -9800.061833 66 1 44 44 24.496467 66 1 44 75 36.761483 66 1 44 77 12.252650 66 1 75 75 73.362200 66 1 75 77 36.730567 66 1 76 76 9799.876333 66 1 77 77 24.496467 66 2 66 66 1.0 67 1 45 45 73.362200 67 1 45 47 -36.730567 67 1 45 78 -73.547700 67 1 45 80 -36.761483 67 1 46 46 9799.876333 67 1 46 79 -9800.061833 67 1 47 47 24.496467 67 1 47 78 36.761483 67 1 47 80 12.252650 67 1 78 78 73.362200 67 1 78 80 36.730567 67 1 79 79 9799.876333 67 1 80 80 24.496467 67 2 67 67 1.0 68 1 48 48 73.362200 68 1 48 50 -36.730567 68 1 48 81 -73.547700 68 1 48 83 -36.761483 68 1 49 49 9799.876333 68 1 49 82 -9800.061833 68 1 50 50 24.496467 68 1 50 81 36.761483 68 1 50 83 12.252650 68 1 81 81 73.362200 68 1 81 83 36.730567 68 1 82 82 9799.876333 68 1 83 83 24.496467 68 2 68 68 1.0 69 1 51 51 73.362200 69 1 51 53 -36.730567 69 1 51 84 -73.547700 69 1 51 86 -36.761483 69 1 52 52 9799.876333 69 1 52 85 -9800.061833 69 1 53 53 24.496467 69 1 53 84 36.761483 69 1 53 86 12.252650 69 1 84 84 73.362200 69 1 84 86 36.730567 69 1 85 85 9799.876333 69 1 86 86 24.496467 69 2 69 69 1.0 70 1 54 54 73.362200 70 1 54 56 -36.730567 70 1 54 87 -73.547700 70 1 54 89 -36.761483 70 1 55 55 9799.876333 70 1 55 88 -9800.061833 70 1 56 56 24.496467 70 1 56 87 36.761483 70 1 56 89 12.252650 70 1 87 87 73.362200 70 1 87 89 36.730567 70 1 88 88 9799.876333 70 1 89 89 24.496467 70 2 70 70 1.0 71 1 57 57 73.362200 71 1 57 59 -36.730567 71 1 57 90 -73.547700 71 1 57 92 -36.761483 71 1 58 58 9799.876333 71 1 58 91 -9800.061833 71 1 59 59 24.496467 71 1 59 90 36.761483 71 1 59 92 12.252650 71 1 90 90 73.362200 71 1 90 92 36.730567 71 1 91 91 9799.876333 71 1 92 92 24.496467 71 2 71 71 1.0 72 1 60 60 73.362200 72 1 60 62 -36.730567 72 1 60 93 -73.547700 72 1 60 95 -36.761483 72 1 61 61 9799.876333 72 1 61 94 -9800.061833 72 1 62 62 24.496467 72 1 62 93 36.761483 72 1 62 95 12.252650 72 1 93 93 73.362200 72 1 93 95 36.730567 72 1 94 94 9799.876333 72 1 95 95 24.496467 72 2 72 72 1.0 73 1 63 63 73.362200 73 1 63 65 -36.730567 73 1 63 96 -73.547700 73 1 63 98 -36.761483 73 1 64 64 9799.876333 73 1 64 97 -9800.061833 73 1 65 65 24.496467 73 1 65 96 36.761483 73 1 65 98 12.252650 73 1 96 96 73.362200 73 1 96 98 36.730567 73 1 97 97 9799.876333 73 1 98 98 24.496467 73 2 73 73 1.0 74 1 66 66 73.362200 74 1 66 68 -36.730567 74 1 66 99 -73.547700 74 1 66 101 -36.761483 74 1 67 67 9799.876333 74 1 67 100 -9800.061833 74 1 68 68 24.496467 74 1 68 99 36.761483 74 1 68 101 12.252650 74 1 99 99 73.362200 74 1 99 101 36.730567 74 1 100 100 9799.876333 74 1 101 101 24.496467 74 2 74 74 1.0 75 1 69 69 73.362200 75 1 69 71 -36.730567 75 1 69 102 -73.547700 75 1 69 104 -36.761483 75 1 70 70 9799.876333 75 1 70 103 -9800.061833 75 1 71 71 24.496467 75 1 71 102 36.761483 75 1 71 104 12.252650 75 1 102 102 73.362200 75 1 102 104 36.730567 75 1 103 103 9799.876333 75 1 104 104 24.496467 75 2 75 75 1.0 76 1 72 72 73.362200 76 1 72 74 -36.730567 76 1 72 105 -73.547700 76 1 72 107 -36.761483 76 1 73 73 9799.876333 76 1 73 106 -9800.061833 76 1 74 74 24.496467 76 1 74 105 36.761483 76 1 74 107 12.252650 76 1 105 105 73.362200 76 1 105 107 36.730567 76 1 106 106 9799.876333 76 1 107 107 24.496467 76 2 76 76 1.0 77 1 75 75 73.362200 77 1 75 77 -36.730567 77 1 75 108 -73.547700 77 1 75 110 -36.761483 77 1 76 76 9799.876333 77 1 76 109 -9800.061833 77 1 77 77 24.496467 77 1 77 108 36.761483 77 1 77 110 12.252650 77 1 108 108 73.362200 77 1 108 110 36.730567 77 1 109 109 9799.876333 77 1 110 110 24.496467 77 2 77 77 1.0 78 1 78 78 73.362200 78 1 78 80 -36.730567 78 1 78 111 -73.547700 78 1 78 113 -36.761483 78 1 79 79 9799.876333 78 1 79 112 -9800.061833 78 1 80 80 24.496467 78 1 80 111 36.761483 78 1 80 113 12.252650 78 1 111 111 73.362200 78 1 111 113 36.730567 78 1 112 112 9799.876333 78 1 113 113 24.496467 78 2 78 78 1.0 79 1 81 81 73.362200 79 1 81 83 -36.730567 79 1 81 114 -73.547700 79 1 81 116 -36.761483 79 1 82 82 9799.876333 79 1 82 115 -9800.061833 79 1 83 83 24.496467 79 1 83 114 36.761483 79 1 83 116 12.252650 79 1 114 114 73.362200 79 1 114 116 36.730567 79 1 115 115 9799.876333 79 1 116 116 24.496467 79 2 79 79 1.0 80 1 84 84 73.362200 80 1 84 86 -36.730567 80 1 84 117 -73.547700 80 1 84 119 -36.761483 80 1 85 85 9799.876333 80 1 85 118 -9800.061833 80 1 86 86 24.496467 80 1 86 117 36.761483 80 1 86 119 12.252650 80 1 117 117 73.362200 80 1 117 119 36.730567 80 1 118 118 9799.876333 80 1 119 119 24.496467 80 2 80 80 1.0 81 1 87 87 73.362200 81 1 87 89 -36.730567 81 1 87 120 -73.547700 81 1 87 122 -36.761483 81 1 88 88 9799.876333 81 1 88 121 -9800.061833 81 1 89 89 24.496467 81 1 89 120 36.761483 81 1 89 122 12.252650 81 1 120 120 73.362200 81 1 120 122 36.730567 81 1 121 121 9799.876333 81 1 122 122 24.496467 81 2 81 81 1.0 82 1 90 90 73.362200 82 1 90 92 -36.730567 82 1 90 123 -73.547700 82 1 90 125 -36.761483 82 1 91 91 9799.876333 82 1 91 124 -9800.061833 82 1 92 92 24.496467 82 1 92 123 36.761483 82 1 92 125 12.252650 82 1 123 123 73.362200 82 1 123 125 36.730567 82 1 124 124 9799.876333 82 1 125 125 24.496467 82 2 82 82 1.0 83 1 93 93 73.362200 83 1 93 95 -36.730567 83 1 93 126 -73.547700 83 1 93 128 -36.761483 83 1 94 94 9799.876333 83 1 94 127 -9800.061833 83 1 95 95 24.496467 83 1 95 126 36.761483 83 1 95 128 12.252650 83 1 126 126 73.362200 83 1 126 128 36.730567 83 1 127 127 9799.876333 83 1 128 128 24.496467 83 2 83 83 1.0 84 1 96 96 73.362200 84 1 96 98 -36.730567 84 1 96 129 -73.547700 84 1 96 131 -36.761483 84 1 97 97 9799.876333 84 1 97 130 -9800.061833 84 1 98 98 24.496467 84 1 98 129 36.761483 84 1 98 131 12.252650 84 1 129 129 73.362200 84 1 129 131 36.730567 84 1 130 130 9799.876333 84 1 131 131 24.496467 84 2 84 84 1.0 85 1 99 99 73.362200 85 1 99 101 -36.730567 85 1 99 132 -73.547700 85 1 99 134 -36.761483 85 1 100 100 9799.876333 85 1 100 133 -9800.061833 85 1 101 101 24.496467 85 1 101 132 36.761483 85 1 101 134 12.252650 85 1 132 132 73.362200 85 1 132 134 36.730567 85 1 133 133 9799.876333 85 1 134 134 24.496467 85 2 85 85 1.0 86 1 102 102 73.362200 86 1 102 104 -36.730567 86 1 102 135 -73.547700 86 1 102 137 -36.761483 86 1 103 103 9799.876333 86 1 103 136 -9800.061833 86 1 104 104 24.496467 86 1 104 135 36.761483 86 1 104 137 12.252650 86 1 135 135 73.362200 86 1 135 137 36.730567 86 1 136 136 9799.876333 86 1 137 137 24.496467 86 2 86 86 1.0 87 1 105 105 73.362200 87 1 105 107 -36.730567 87 1 105 138 -73.547700 87 1 105 140 -36.761483 87 1 106 106 9799.876333 87 1 106 139 -9800.061833 87 1 107 107 24.496467 87 1 107 138 36.761483 87 1 107 140 12.252650 87 1 138 138 73.362200 87 1 138 140 36.730567 87 1 139 139 9799.876333 87 1 140 140 24.496467 87 2 87 87 1.0 88 1 108 108 73.362200 88 1 108 110 -36.730567 88 1 108 141 -73.547700 88 1 108 143 -36.761483 88 1 109 109 9799.876333 88 1 109 142 -9800.061833 88 1 110 110 24.496467 88 1 110 141 36.761483 88 1 110 143 12.252650 88 1 141 141 73.362200 88 1 141 143 36.730567 88 1 142 142 9799.876333 88 1 143 143 24.496467 88 2 88 88 1.0 89 1 111 111 73.362200 89 1 111 113 -36.730567 89 1 111 144 -73.547700 89 1 111 146 -36.761483 89 1 112 112 9799.876333 89 1 112 145 -9800.061833 89 1 113 113 24.496467 89 1 113 144 36.761483 89 1 113 146 12.252650 89 1 144 144 73.362200 89 1 144 146 36.730567 89 1 145 145 9799.876333 89 1 146 146 24.496467 89 2 89 89 1.0 90 1 114 114 73.362200 90 1 114 116 -36.730567 90 1 114 147 -73.547700 90 1 114 149 -36.761483 90 1 115 115 9799.876333 90 1 115 148 -9800.061833 90 1 116 116 24.496467 90 1 116 147 36.761483 90 1 116 149 12.252650 90 1 147 147 73.362200 90 1 147 149 36.730567 90 1 148 148 9799.876333 90 1 149 149 24.496467 90 2 90 90 1.0 91 1 117 117 73.362200 91 1 117 119 -36.730567 91 1 117 150 -73.547700 91 1 117 152 -36.761483 91 1 118 118 9799.876333 91 1 118 151 -9800.061833 91 1 119 119 24.496467 91 1 119 150 36.761483 91 1 119 152 12.252650 91 1 150 150 73.362200 91 1 150 152 36.730567 91 1 151 151 9799.876333 91 1 152 152 24.496467 91 2 91 91 1.0 92 1 120 120 73.362200 92 1 120 122 -36.730567 92 1 120 153 -73.547700 92 1 120 155 -36.761483 92 1 121 121 9799.876333 92 1 121 154 -9800.061833 92 1 122 122 24.496467 92 1 122 153 36.761483 92 1 122 155 12.252650 92 1 153 153 73.362200 92 1 153 155 36.730567 92 1 154 154 9799.876333 92 1 155 155 24.496467 92 2 92 92 1.0 93 1 123 123 73.362200 93 1 123 125 -36.730567 93 1 123 156 -73.547700 93 1 123 158 -36.761483 93 1 124 124 9799.876333 93 1 124 157 -9800.061833 93 1 125 125 24.496467 93 1 125 156 36.761483 93 1 125 158 12.252650 93 1 156 156 73.362200 93 1 156 158 36.730567 93 1 157 157 9799.876333 93 1 158 158 24.496467 93 2 93 93 1.0 94 1 126 126 73.362200 94 1 126 128 -36.730567 94 1 126 159 -73.547700 94 1 126 161 -36.761483 94 1 127 127 9799.876333 94 1 127 160 -9800.061833 94 1 128 128 24.496467 94 1 128 159 36.761483 94 1 128 161 12.252650 94 1 159 159 73.362200 94 1 159 161 36.730567 94 1 160 160 9799.876333 94 1 161 161 24.496467 94 2 94 94 1.0 95 1 1 1 10.917229 95 1 1 33 3.312697 95 1 1 34 -6.625395 95 1 1 35 5.507994 95 1 33 33 3507.186549 95 1 33 34 1750.460320 95 1 33 35 3.243566 95 1 34 34 881.496070 95 1 34 35 -6.487131 95 1 35 35 10.917229 95 2 95 95 1.0 96 1 2 2 3507.186549 96 1 2 3 1750.460320 96 1 2 4 -3.243566 96 1 2 36 -3507.601340 96 1 2 37 -1750.460320 96 1 2 38 -3.312697 96 1 3 3 881.496070 96 1 3 4 6.487131 96 1 3 36 -1750.460320 96 1 3 37 -881.910860 96 1 3 38 6.625395 96 1 4 4 10.917229 96 1 4 36 3.312697 96 1 4 37 -6.625395 96 1 4 38 5.507994 96 1 36 36 3507.186549 96 1 36 37 1750.460320 96 1 36 38 3.243566 96 1 37 37 881.496070 96 1 37 38 -6.487131 96 1 38 38 10.917229 96 2 96 96 1.0 97 1 5 5 3507.186549 97 1 5 6 1750.460320 97 1 5 7 -3.243566 97 1 5 39 -3507.601340 97 1 5 40 -1750.460320 97 1 5 41 -3.312697 97 1 6 6 881.496070 97 1 6 7 6.487131 97 1 6 39 -1750.460320 97 1 6 40 -881.910860 97 1 6 41 6.625395 97 1 7 7 10.917229 97 1 7 39 3.312697 97 1 7 40 -6.625395 97 1 7 41 5.507994 97 1 39 39 3507.186549 97 1 39 40 1750.460320 97 1 39 41 3.243566 97 1 40 40 881.496070 97 1 40 41 -6.487131 97 1 41 41 10.917229 97 2 97 97 1.0 98 1 8 8 3507.186549 98 1 8 9 1750.460320 98 1 8 10 -3.243566 98 1 8 42 -3507.601340 98 1 8 43 -1750.460320 98 1 8 44 -3.312697 98 1 9 9 881.496070 98 1 9 10 6.487131 98 1 9 42 -1750.460320 98 1 9 43 -881.910860 98 1 9 44 6.625395 98 1 10 10 10.917229 98 1 10 42 3.312697 98 1 10 43 -6.625395 98 1 10 44 5.507994 98 1 42 42 3507.186549 98 1 42 43 1750.460320 98 1 42 44 3.243566 98 1 43 43 881.496070 98 1 43 44 -6.487131 98 1 44 44 10.917229 98 2 98 98 1.0 99 1 11 11 3507.186549 99 1 11 12 1750.460320 99 1 11 13 -3.243566 99 1 11 45 -3507.601340 99 1 11 46 -1750.460320 99 1 11 47 -3.312697 99 1 12 12 881.496070 99 1 12 13 6.487131 99 1 12 45 -1750.460320 99 1 12 46 -881.910860 99 1 12 47 6.625395 99 1 13 13 10.917229 99 1 13 45 3.312697 99 1 13 46 -6.625395 99 1 13 47 5.507994 99 1 45 45 3507.186549 99 1 45 46 1750.460320 99 1 45 47 3.243566 99 1 46 46 881.496070 99 1 46 47 -6.487131 99 1 47 47 10.917229 99 2 99 99 1.0 100 1 14 14 3507.186549 100 1 14 15 1750.460320 100 1 14 16 -3.243566 100 1 14 48 -3507.601340 100 1 14 49 -1750.460320 100 1 14 50 -3.312697 100 1 15 15 881.496070 100 1 15 16 6.487131 100 1 15 48 -1750.460320 100 1 15 49 -881.910860 100 1 15 50 6.625395 100 1 16 16 10.917229 100 1 16 48 3.312697 100 1 16 49 -6.625395 100 1 16 50 5.507994 100 1 48 48 3507.186549 100 1 48 49 1750.460320 100 1 48 50 3.243566 100 1 49 49 881.496070 100 1 49 50 -6.487131 100 1 50 50 10.917229 100 2 100 100 1.0 101 1 17 17 3507.186549 101 1 17 18 1750.460320 101 1 17 19 -3.243566 101 1 17 51 -3507.601340 101 1 17 52 -1750.460320 101 1 17 53 -3.312697 101 1 18 18 881.496070 101 1 18 19 6.487131 101 1 18 51 -1750.460320 101 1 18 52 -881.910860 101 1 18 53 6.625395 101 1 19 19 10.917229 101 1 19 51 3.312697 101 1 19 52 -6.625395 101 1 19 53 5.507994 101 1 51 51 3507.186549 101 1 51 52 1750.460320 101 1 51 53 3.243566 101 1 52 52 881.496070 101 1 52 53 -6.487131 101 1 53 53 10.917229 101 2 101 101 1.0 102 1 20 20 3507.186549 102 1 20 21 1750.460320 102 1 20 22 -3.243566 102 1 20 54 -3507.601340 102 1 20 55 -1750.460320 102 1 20 56 -3.312697 102 1 21 21 881.496070 102 1 21 22 6.487131 102 1 21 54 -1750.460320 102 1 21 55 -881.910860 102 1 21 56 6.625395 102 1 22 22 10.917229 102 1 22 54 3.312697 102 1 22 55 -6.625395 102 1 22 56 5.507994 102 1 54 54 3507.186549 102 1 54 55 1750.460320 102 1 54 56 3.243566 102 1 55 55 881.496070 102 1 55 56 -6.487131 102 1 56 56 10.917229 102 2 102 102 1.0 103 1 23 23 3507.186549 103 1 23 24 1750.460320 103 1 23 25 -3.243566 103 1 23 57 -3507.601340 103 1 23 58 -1750.460320 103 1 23 59 -3.312697 103 1 24 24 881.496070 103 1 24 25 6.487131 103 1 24 57 -1750.460320 103 1 24 58 -881.910860 103 1 24 59 6.625395 103 1 25 25 10.917229 103 1 25 57 3.312697 103 1 25 58 -6.625395 103 1 25 59 5.507994 103 1 57 57 3507.186549 103 1 57 58 1750.460320 103 1 57 59 3.243566 103 1 58 58 881.496070 103 1 58 59 -6.487131 103 1 59 59 10.917229 103 2 103 103 1.0 104 1 26 26 3507.186549 104 1 26 27 1750.460320 104 1 26 28 -3.243566 104 1 26 60 -3507.601340 104 1 26 61 -1750.460320 104 1 26 62 -3.312697 104 1 27 27 881.496070 104 1 27 28 6.487131 104 1 27 60 -1750.460320 104 1 27 61 -881.910860 104 1 27 62 6.625395 104 1 28 28 10.917229 104 1 28 60 3.312697 104 1 28 61 -6.625395 104 1 28 62 5.507994 104 1 60 60 3507.186549 104 1 60 61 1750.460320 104 1 60 62 3.243566 104 1 61 61 881.496070 104 1 61 62 -6.487131 104 1 62 62 10.917229 104 2 104 104 1.0 105 1 30 30 3507.186549 105 1 30 31 1750.460320 105 1 30 32 -3.243566 105 1 30 66 -3507.601340 105 1 30 67 -1750.460320 105 1 30 68 -3.312697 105 1 31 31 881.496070 105 1 31 32 6.487131 105 1 31 66 -1750.460320 105 1 31 67 -881.910860 105 1 31 68 6.625395 105 1 32 32 10.917229 105 1 32 66 3.312697 105 1 32 67 -6.625395 105 1 32 68 5.507994 105 1 66 66 3507.186549 105 1 66 67 1750.460320 105 1 66 68 3.243566 105 1 67 67 881.496070 105 1 67 68 -6.487131 105 1 68 68 10.917229 105 2 105 105 1.0 106 1 33 33 3507.186549 106 1 33 34 1750.460320 106 1 33 35 -3.243566 106 1 33 69 -3507.601340 106 1 33 70 -1750.460320 106 1 33 71 -3.312697 106 1 34 34 881.496070 106 1 34 35 6.487131 106 1 34 69 -1750.460320 106 1 34 70 -881.910860 106 1 34 71 6.625395 106 1 35 35 10.917229 106 1 35 69 3.312697 106 1 35 70 -6.625395 106 1 35 71 5.507994 106 1 69 69 3507.186549 106 1 69 70 1750.460320 106 1 69 71 3.243566 106 1 70 70 881.496070 106 1 70 71 -6.487131 106 1 71 71 10.917229 106 2 106 106 1.0 107 1 36 36 3507.186549 107 1 36 37 1750.460320 107 1 36 38 -3.243566 107 1 36 72 -3507.601340 107 1 36 73 -1750.460320 107 1 36 74 -3.312697 107 1 37 37 881.496070 107 1 37 38 6.487131 107 1 37 72 -1750.460320 107 1 37 73 -881.910860 107 1 37 74 6.625395 107 1 38 38 10.917229 107 1 38 72 3.312697 107 1 38 73 -6.625395 107 1 38 74 5.507994 107 1 72 72 3507.186549 107 1 72 73 1750.460320 107 1 72 74 3.243566 107 1 73 73 881.496070 107 1 73 74 -6.487131 107 1 74 74 10.917229 107 2 107 107 1.0 108 1 39 39 3507.186549 108 1 39 40 1750.460320 108 1 39 41 -3.243566 108 1 39 75 -3507.601340 108 1 39 76 -1750.460320 108 1 39 77 -3.312697 108 1 40 40 881.496070 108 1 40 41 6.487131 108 1 40 75 -1750.460320 108 1 40 76 -881.910860 108 1 40 77 6.625395 108 1 41 41 10.917229 108 1 41 75 3.312697 108 1 41 76 -6.625395 108 1 41 77 5.507994 108 1 75 75 3507.186549 108 1 75 76 1750.460320 108 1 75 77 3.243566 108 1 76 76 881.496070 108 1 76 77 -6.487131 108 1 77 77 10.917229 108 2 108 108 1.0 109 1 42 42 3507.186549 109 1 42 43 1750.460320 109 1 42 44 -3.243566 109 1 42 78 -3507.601340 109 1 42 79 -1750.460320 109 1 42 80 -3.312697 109 1 43 43 881.496070 109 1 43 44 6.487131 109 1 43 78 -1750.460320 109 1 43 79 -881.910860 109 1 43 80 6.625395 109 1 44 44 10.917229 109 1 44 78 3.312697 109 1 44 79 -6.625395 109 1 44 80 5.507994 109 1 78 78 3507.186549 109 1 78 79 1750.460320 109 1 78 80 3.243566 109 1 79 79 881.496070 109 1 79 80 -6.487131 109 1 80 80 10.917229 109 2 109 109 1.0 110 1 45 45 3507.186549 110 1 45 46 1750.460320 110 1 45 47 -3.243566 110 1 45 81 -3507.601340 110 1 45 82 -1750.460320 110 1 45 83 -3.312697 110 1 46 46 881.496070 110 1 46 47 6.487131 110 1 46 81 -1750.460320 110 1 46 82 -881.910860 110 1 46 83 6.625395 110 1 47 47 10.917229 110 1 47 81 3.312697 110 1 47 82 -6.625395 110 1 47 83 5.507994 110 1 81 81 3507.186549 110 1 81 82 1750.460320 110 1 81 83 3.243566 110 1 82 82 881.496070 110 1 82 83 -6.487131 110 1 83 83 10.917229 110 2 110 110 1.0 111 1 48 48 3507.186549 111 1 48 49 1750.460320 111 1 48 50 -3.243566 111 1 48 84 -3507.601340 111 1 48 85 -1750.460320 111 1 48 86 -3.312697 111 1 49 49 881.496070 111 1 49 50 6.487131 111 1 49 84 -1750.460320 111 1 49 85 -881.910860 111 1 49 86 6.625395 111 1 50 50 10.917229 111 1 50 84 3.312697 111 1 50 85 -6.625395 111 1 50 86 5.507994 111 1 84 84 3507.186549 111 1 84 85 1750.460320 111 1 84 86 3.243566 111 1 85 85 881.496070 111 1 85 86 -6.487131 111 1 86 86 10.917229 111 2 111 111 1.0 112 1 51 51 3507.186549 112 1 51 52 1750.460320 112 1 51 53 -3.243566 112 1 51 87 -3507.601340 112 1 51 88 -1750.460320 112 1 51 89 -3.312697 112 1 52 52 881.496070 112 1 52 53 6.487131 112 1 52 87 -1750.460320 112 1 52 88 -881.910860 112 1 52 89 6.625395 112 1 53 53 10.917229 112 1 53 87 3.312697 112 1 53 88 -6.625395 112 1 53 89 5.507994 112 1 87 87 3507.186549 112 1 87 88 1750.460320 112 1 87 89 3.243566 112 1 88 88 881.496070 112 1 88 89 -6.487131 112 1 89 89 10.917229 112 2 112 112 1.0 113 1 54 54 3507.186549 113 1 54 55 1750.460320 113 1 54 56 -3.243566 113 1 54 90 -3507.601340 113 1 54 91 -1750.460320 113 1 54 92 -3.312697 113 1 55 55 881.496070 113 1 55 56 6.487131 113 1 55 90 -1750.460320 113 1 55 91 -881.910860 113 1 55 92 6.625395 113 1 56 56 10.917229 113 1 56 90 3.312697 113 1 56 91 -6.625395 113 1 56 92 5.507994 113 1 90 90 3507.186549 113 1 90 91 1750.460320 113 1 90 92 3.243566 113 1 91 91 881.496070 113 1 91 92 -6.487131 113 1 92 92 10.917229 113 2 113 113 1.0 114 1 57 57 3507.186549 114 1 57 58 1750.460320 114 1 57 59 -3.243566 114 1 57 93 -3507.601340 114 1 57 94 -1750.460320 114 1 57 95 -3.312697 114 1 58 58 881.496070 114 1 58 59 6.487131 114 1 58 93 -1750.460320 114 1 58 94 -881.910860 114 1 58 95 6.625395 114 1 59 59 10.917229 114 1 59 93 3.312697 114 1 59 94 -6.625395 114 1 59 95 5.507994 114 1 93 93 3507.186549 114 1 93 94 1750.460320 114 1 93 95 3.243566 114 1 94 94 881.496070 114 1 94 95 -6.487131 114 1 95 95 10.917229 114 2 114 114 1.0 115 1 63 63 3507.186549 115 1 63 64 1750.460320 115 1 63 65 -3.243566 115 1 63 99 -3507.601340 115 1 63 100 -1750.460320 115 1 63 101 -3.312697 115 1 64 64 881.496070 115 1 64 65 6.487131 115 1 64 99 -1750.460320 115 1 64 100 -881.910860 115 1 64 101 6.625395 115 1 65 65 10.917229 115 1 65 99 3.312697 115 1 65 100 -6.625395 115 1 65 101 5.507994 115 1 99 99 3507.186549 115 1 99 100 1750.460320 115 1 99 101 3.243566 115 1 100 100 881.496070 115 1 100 101 -6.487131 115 1 101 101 10.917229 115 2 115 115 1.0 116 1 66 66 3507.186549 116 1 66 67 1750.460320 116 1 66 68 -3.243566 116 1 66 102 -3507.601340 116 1 66 103 -1750.460320 116 1 66 104 -3.312697 116 1 67 67 881.496070 116 1 67 68 6.487131 116 1 67 102 -1750.460320 116 1 67 103 -881.910860 116 1 67 104 6.625395 116 1 68 68 10.917229 116 1 68 102 3.312697 116 1 68 103 -6.625395 116 1 68 104 5.507994 116 1 102 102 3507.186549 116 1 102 103 1750.460320 116 1 102 104 3.243566 116 1 103 103 881.496070 116 1 103 104 -6.487131 116 1 104 104 10.917229 116 2 116 116 1.0 117 1 69 69 3507.186549 117 1 69 70 1750.460320 117 1 69 71 -3.243566 117 1 69 105 -3507.601340 117 1 69 106 -1750.460320 117 1 69 107 -3.312697 117 1 70 70 881.496070 117 1 70 71 6.487131 117 1 70 105 -1750.460320 117 1 70 106 -881.910860 117 1 70 107 6.625395 117 1 71 71 10.917229 117 1 71 105 3.312697 117 1 71 106 -6.625395 117 1 71 107 5.507994 117 1 105 105 3507.186549 117 1 105 106 1750.460320 117 1 105 107 3.243566 117 1 106 106 881.496070 117 1 106 107 -6.487131 117 1 107 107 10.917229 117 2 117 117 1.0 118 1 72 72 3507.186549 118 1 72 73 1750.460320 118 1 72 74 -3.243566 118 1 72 108 -3507.601340 118 1 72 109 -1750.460320 118 1 72 110 -3.312697 118 1 73 73 881.496070 118 1 73 74 6.487131 118 1 73 108 -1750.460320 118 1 73 109 -881.910860 118 1 73 110 6.625395 118 1 74 74 10.917229 118 1 74 108 3.312697 118 1 74 109 -6.625395 118 1 74 110 5.507994 118 1 108 108 3507.186549 118 1 108 109 1750.460320 118 1 108 110 3.243566 118 1 109 109 881.496070 118 1 109 110 -6.487131 118 1 110 110 10.917229 118 2 118 118 1.0 119 1 75 75 3507.186549 119 1 75 76 1750.460320 119 1 75 77 -3.243566 119 1 75 111 -3507.601340 119 1 75 112 -1750.460320 119 1 75 113 -3.312697 119 1 76 76 881.496070 119 1 76 77 6.487131 119 1 76 111 -1750.460320 119 1 76 112 -881.910860 119 1 76 113 6.625395 119 1 77 77 10.917229 119 1 77 111 3.312697 119 1 77 112 -6.625395 119 1 77 113 5.507994 119 1 111 111 3507.186549 119 1 111 112 1750.460320 119 1 111 113 3.243566 119 1 112 112 881.496070 119 1 112 113 -6.487131 119 1 113 113 10.917229 119 2 119 119 1.0 120 1 78 78 3507.186549 120 1 78 79 1750.460320 120 1 78 80 -3.243566 120 1 78 114 -3507.601340 120 1 78 115 -1750.460320 120 1 78 116 -3.312697 120 1 79 79 881.496070 120 1 79 80 6.487131 120 1 79 114 -1750.460320 120 1 79 115 -881.910860 120 1 79 116 6.625395 120 1 80 80 10.917229 120 1 80 114 3.312697 120 1 80 115 -6.625395 120 1 80 116 5.507994 120 1 114 114 3507.186549 120 1 114 115 1750.460320 120 1 114 116 3.243566 120 1 115 115 881.496070 120 1 115 116 -6.487131 120 1 116 116 10.917229 120 2 120 120 1.0 121 1 81 81 3507.186549 121 1 81 82 1750.460320 121 1 81 83 -3.243566 121 1 81 117 -3507.601340 121 1 81 118 -1750.460320 121 1 81 119 -3.312697 121 1 82 82 881.496070 121 1 82 83 6.487131 121 1 82 117 -1750.460320 121 1 82 118 -881.910860 121 1 82 119 6.625395 121 1 83 83 10.917229 121 1 83 117 3.312697 121 1 83 118 -6.625395 121 1 83 119 5.507994 121 1 117 117 3507.186549 121 1 117 118 1750.460320 121 1 117 119 3.243566 121 1 118 118 881.496070 121 1 118 119 -6.487131 121 1 119 119 10.917229 121 2 121 121 1.0 122 1 84 84 3507.186549 122 1 84 85 1750.460320 122 1 84 86 -3.243566 122 1 84 120 -3507.601340 122 1 84 121 -1750.460320 122 1 84 122 -3.312697 122 1 85 85 881.496070 122 1 85 86 6.487131 122 1 85 120 -1750.460320 122 1 85 121 -881.910860 122 1 85 122 6.625395 122 1 86 86 10.917229 122 1 86 120 3.312697 122 1 86 121 -6.625395 122 1 86 122 5.507994 122 1 120 120 3507.186549 122 1 120 121 1750.460320 122 1 120 122 3.243566 122 1 121 121 881.496070 122 1 121 122 -6.487131 122 1 122 122 10.917229 122 2 122 122 1.0 123 1 87 87 3507.186549 123 1 87 88 1750.460320 123 1 87 89 -3.243566 123 1 87 123 -3507.601340 123 1 87 124 -1750.460320 123 1 87 125 -3.312697 123 1 88 88 881.496070 123 1 88 89 6.487131 123 1 88 123 -1750.460320 123 1 88 124 -881.910860 123 1 88 125 6.625395 123 1 89 89 10.917229 123 1 89 123 3.312697 123 1 89 124 -6.625395 123 1 89 125 5.507994 123 1 123 123 3507.186549 123 1 123 124 1750.460320 123 1 123 125 3.243566 123 1 124 124 881.496070 123 1 124 125 -6.487131 123 1 125 125 10.917229 123 2 123 123 1.0 124 1 90 90 3507.186549 124 1 90 91 1750.460320 124 1 90 92 -3.243566 124 1 90 126 -3507.601340 124 1 90 127 -1750.460320 124 1 90 128 -3.312697 124 1 91 91 881.496070 124 1 91 92 6.487131 124 1 91 126 -1750.460320 124 1 91 127 -881.910860 124 1 91 128 6.625395 124 1 92 92 10.917229 124 1 92 126 3.312697 124 1 92 127 -6.625395 124 1 92 128 5.507994 124 1 126 126 3507.186549 124 1 126 127 1750.460320 124 1 126 128 3.243566 124 1 127 127 881.496070 124 1 127 128 -6.487131 124 1 128 128 10.917229 124 2 124 124 1.0 125 1 96 96 3507.186549 125 1 96 97 1750.460320 125 1 96 98 -3.243566 125 1 96 132 -3507.601340 125 1 96 133 -1750.460320 125 1 96 134 -3.312697 125 1 97 97 881.496070 125 1 97 98 6.487131 125 1 97 132 -1750.460320 125 1 97 133 -881.910860 125 1 97 134 6.625395 125 1 98 98 10.917229 125 1 98 132 3.312697 125 1 98 133 -6.625395 125 1 98 134 5.507994 125 1 132 132 3507.186549 125 1 132 133 1750.460320 125 1 132 134 3.243566 125 1 133 133 881.496070 125 1 133 134 -6.487131 125 1 134 134 10.917229 125 2 125 125 1.0 126 1 99 99 3507.186549 126 1 99 100 1750.460320 126 1 99 101 -3.243566 126 1 99 135 -3507.601340 126 1 99 136 -1750.460320 126 1 99 137 -3.312697 126 1 100 100 881.496070 126 1 100 101 6.487131 126 1 100 135 -1750.460320 126 1 100 136 -881.910860 126 1 100 137 6.625395 126 1 101 101 10.917229 126 1 101 135 3.312697 126 1 101 136 -6.625395 126 1 101 137 5.507994 126 1 135 135 3507.186549 126 1 135 136 1750.460320 126 1 135 137 3.243566 126 1 136 136 881.496070 126 1 136 137 -6.487131 126 1 137 137 10.917229 126 2 126 126 1.0 127 1 102 102 3507.186549 127 1 102 103 1750.460320 127 1 102 104 -3.243566 127 1 102 138 -3507.601340 127 1 102 139 -1750.460320 127 1 102 140 -3.312697 127 1 103 103 881.496070 127 1 103 104 6.487131 127 1 103 138 -1750.460320 127 1 103 139 -881.910860 127 1 103 140 6.625395 127 1 104 104 10.917229 127 1 104 138 3.312697 127 1 104 139 -6.625395 127 1 104 140 5.507994 127 1 138 138 3507.186549 127 1 138 139 1750.460320 127 1 138 140 3.243566 127 1 139 139 881.496070 127 1 139 140 -6.487131 127 1 140 140 10.917229 127 2 127 127 1.0 128 1 105 105 3507.186549 128 1 105 106 1750.460320 128 1 105 107 -3.243566 128 1 105 141 -3507.601340 128 1 105 142 -1750.460320 128 1 105 143 -3.312697 128 1 106 106 881.496070 128 1 106 107 6.487131 128 1 106 141 -1750.460320 128 1 106 142 -881.910860 128 1 106 143 6.625395 128 1 107 107 10.917229 128 1 107 141 3.312697 128 1 107 142 -6.625395 128 1 107 143 5.507994 128 1 141 141 3507.186549 128 1 141 142 1750.460320 128 1 141 143 3.243566 128 1 142 142 881.496070 128 1 142 143 -6.487131 128 1 143 143 10.917229 128 2 128 128 1.0 129 1 108 108 3507.186549 129 1 108 109 1750.460320 129 1 108 110 -3.243566 129 1 108 144 -3507.601340 129 1 108 145 -1750.460320 129 1 108 146 -3.312697 129 1 109 109 881.496070 129 1 109 110 6.487131 129 1 109 144 -1750.460320 129 1 109 145 -881.910860 129 1 109 146 6.625395 129 1 110 110 10.917229 129 1 110 144 3.312697 129 1 110 145 -6.625395 129 1 110 146 5.507994 129 1 144 144 3507.186549 129 1 144 145 1750.460320 129 1 144 146 3.243566 129 1 145 145 881.496070 129 1 145 146 -6.487131 129 1 146 146 10.917229 129 2 129 129 1.0 130 1 111 111 3507.186549 130 1 111 112 1750.460320 130 1 111 113 -3.243566 130 1 111 147 -3507.601340 130 1 111 148 -1750.460320 130 1 111 149 -3.312697 130 1 112 112 881.496070 130 1 112 113 6.487131 130 1 112 147 -1750.460320 130 1 112 148 -881.910860 130 1 112 149 6.625395 130 1 113 113 10.917229 130 1 113 147 3.312697 130 1 113 148 -6.625395 130 1 113 149 5.507994 130 1 147 147 3507.186549 130 1 147 148 1750.460320 130 1 147 149 3.243566 130 1 148 148 881.496070 130 1 148 149 -6.487131 130 1 149 149 10.917229 130 2 130 130 1.0 131 1 114 114 3507.186549 131 1 114 115 1750.460320 131 1 114 116 -3.243566 131 1 114 150 -3507.601340 131 1 114 151 -1750.460320 131 1 114 152 -3.312697 131 1 115 115 881.496070 131 1 115 116 6.487131 131 1 115 150 -1750.460320 131 1 115 151 -881.910860 131 1 115 152 6.625395 131 1 116 116 10.917229 131 1 116 150 3.312697 131 1 116 151 -6.625395 131 1 116 152 5.507994 131 1 150 150 3507.186549 131 1 150 151 1750.460320 131 1 150 152 3.243566 131 1 151 151 881.496070 131 1 151 152 -6.487131 131 1 152 152 10.917229 131 2 131 131 1.0 132 1 117 117 3507.186549 132 1 117 118 1750.460320 132 1 117 119 -3.243566 132 1 117 153 -3507.601340 132 1 117 154 -1750.460320 132 1 117 155 -3.312697 132 1 118 118 881.496070 132 1 118 119 6.487131 132 1 118 153 -1750.460320 132 1 118 154 -881.910860 132 1 118 155 6.625395 132 1 119 119 10.917229 132 1 119 153 3.312697 132 1 119 154 -6.625395 132 1 119 155 5.507994 132 1 153 153 3507.186549 132 1 153 154 1750.460320 132 1 153 155 3.243566 132 1 154 154 881.496070 132 1 154 155 -6.487131 132 1 155 155 10.917229 132 2 132 132 1.0 133 1 120 120 3507.186549 133 1 120 121 1750.460320 133 1 120 122 -3.243566 133 1 120 156 -3507.601340 133 1 120 157 -1750.460320 133 1 120 158 -3.312697 133 1 121 121 881.496070 133 1 121 122 6.487131 133 1 121 156 -1750.460320 133 1 121 157 -881.910860 133 1 121 158 6.625395 133 1 122 122 10.917229 133 1 122 156 3.312697 133 1 122 157 -6.625395 133 1 122 158 5.507994 133 1 156 156 3507.186549 133 1 156 157 1750.460320 133 1 156 158 3.243566 133 1 157 157 881.496070 133 1 157 158 -6.487131 133 1 158 158 10.917229 133 2 133 133 1.0 134 1 123 123 3507.186549 134 1 123 124 1750.460320 134 1 123 125 -3.243566 134 1 123 159 -3507.601340 134 1 123 160 -1750.460320 134 1 123 161 -3.312697 134 1 124 124 881.496070 134 1 124 125 6.487131 134 1 124 159 -1750.460320 134 1 124 160 -881.910860 134 1 124 161 6.625395 134 1 125 125 10.917229 134 1 125 159 3.312697 134 1 125 160 -6.625395 134 1 125 161 5.507994 134 1 159 159 3507.186549 134 1 159 160 1750.460320 134 1 159 161 3.243566 134 1 160 160 881.496070 134 1 160 161 -6.487131 134 1 161 161 10.917229 134 2 134 134 1.0 135 1 2 2 3507.186549 135 1 2 3 -1750.460320 135 1 2 4 -3.243566 135 1 2 30 -3507.601340 135 1 2 31 1750.460320 135 1 2 32 -3.312697 135 1 3 3 881.496070 135 1 3 4 -6.487131 135 1 3 30 1750.460320 135 1 3 31 -881.910860 135 1 3 32 -6.625395 135 1 4 4 10.917229 135 1 4 30 3.312697 135 1 4 31 6.625395 135 1 4 32 5.507994 135 1 30 30 3507.186549 135 1 30 31 -1750.460320 135 1 30 32 3.243566 135 1 31 31 881.496070 135 1 31 32 6.487131 135 1 32 32 10.917229 135 2 135 135 1.0 136 1 5 5 3507.186549 136 1 5 6 -1750.460320 136 1 5 7 -3.243566 136 1 5 33 -3507.601340 136 1 5 34 1750.460320 136 1 5 35 -3.312697 136 1 6 6 881.496070 136 1 6 7 -6.487131 136 1 6 33 1750.460320 136 1 6 34 -881.910860 136 1 6 35 -6.625395 136 1 7 7 10.917229 136 1 7 33 3.312697 136 1 7 34 6.625395 136 1 7 35 5.507994 136 1 33 33 3507.186549 136 1 33 34 -1750.460320 136 1 33 35 3.243566 136 1 34 34 881.496070 136 1 34 35 6.487131 136 1 35 35 10.917229 136 2 136 136 1.0 137 1 8 8 3507.186549 137 1 8 9 -1750.460320 137 1 8 10 -3.243566 137 1 8 36 -3507.601340 137 1 8 37 1750.460320 137 1 8 38 -3.312697 137 1 9 9 881.496070 137 1 9 10 -6.487131 137 1 9 36 1750.460320 137 1 9 37 -881.910860 137 1 9 38 -6.625395 137 1 10 10 10.917229 137 1 10 36 3.312697 137 1 10 37 6.625395 137 1 10 38 5.507994 137 1 36 36 3507.186549 137 1 36 37 -1750.460320 137 1 36 38 3.243566 137 1 37 37 881.496070 137 1 37 38 6.487131 137 1 38 38 10.917229 137 2 137 137 1.0 138 1 11 11 3507.186549 138 1 11 12 -1750.460320 138 1 11 13 -3.243566 138 1 11 39 -3507.601340 138 1 11 40 1750.460320 138 1 11 41 -3.312697 138 1 12 12 881.496070 138 1 12 13 -6.487131 138 1 12 39 1750.460320 138 1 12 40 -881.910860 138 1 12 41 -6.625395 138 1 13 13 10.917229 138 1 13 39 3.312697 138 1 13 40 6.625395 138 1 13 41 5.507994 138 1 39 39 3507.186549 138 1 39 40 -1750.460320 138 1 39 41 3.243566 138 1 40 40 881.496070 138 1 40 41 6.487131 138 1 41 41 10.917229 138 2 138 138 1.0 139 1 14 14 3507.186549 139 1 14 15 -1750.460320 139 1 14 16 -3.243566 139 1 14 42 -3507.601340 139 1 14 43 1750.460320 139 1 14 44 -3.312697 139 1 15 15 881.496070 139 1 15 16 -6.487131 139 1 15 42 1750.460320 139 1 15 43 -881.910860 139 1 15 44 -6.625395 139 1 16 16 10.917229 139 1 16 42 3.312697 139 1 16 43 6.625395 139 1 16 44 5.507994 139 1 42 42 3507.186549 139 1 42 43 -1750.460320 139 1 42 44 3.243566 139 1 43 43 881.496070 139 1 43 44 6.487131 139 1 44 44 10.917229 139 2 139 139 1.0 140 1 17 17 3507.186549 140 1 17 18 -1750.460320 140 1 17 19 -3.243566 140 1 17 45 -3507.601340 140 1 17 46 1750.460320 140 1 17 47 -3.312697 140 1 18 18 881.496070 140 1 18 19 -6.487131 140 1 18 45 1750.460320 140 1 18 46 -881.910860 140 1 18 47 -6.625395 140 1 19 19 10.917229 140 1 19 45 3.312697 140 1 19 46 6.625395 140 1 19 47 5.507994 140 1 45 45 3507.186549 140 1 45 46 -1750.460320 140 1 45 47 3.243566 140 1 46 46 881.496070 140 1 46 47 6.487131 140 1 47 47 10.917229 140 2 140 140 1.0 141 1 20 20 3507.186549 141 1 20 21 -1750.460320 141 1 20 22 -3.243566 141 1 20 48 -3507.601340 141 1 20 49 1750.460320 141 1 20 50 -3.312697 141 1 21 21 881.496070 141 1 21 22 -6.487131 141 1 21 48 1750.460320 141 1 21 49 -881.910860 141 1 21 50 -6.625395 141 1 22 22 10.917229 141 1 22 48 3.312697 141 1 22 49 6.625395 141 1 22 50 5.507994 141 1 48 48 3507.186549 141 1 48 49 -1750.460320 141 1 48 50 3.243566 141 1 49 49 881.496070 141 1 49 50 6.487131 141 1 50 50 10.917229 141 2 141 141 1.0 142 1 23 23 3507.186549 142 1 23 24 -1750.460320 142 1 23 25 -3.243566 142 1 23 51 -3507.601340 142 1 23 52 1750.460320 142 1 23 53 -3.312697 142 1 24 24 881.496070 142 1 24 25 -6.487131 142 1 24 51 1750.460320 142 1 24 52 -881.910860 142 1 24 53 -6.625395 142 1 25 25 10.917229 142 1 25 51 3.312697 142 1 25 52 6.625395 142 1 25 53 5.507994 142 1 51 51 3507.186549 142 1 51 52 -1750.460320 142 1 51 53 3.243566 142 1 52 52 881.496070 142 1 52 53 6.487131 142 1 53 53 10.917229 142 2 142 142 1.0 143 1 26 26 3507.186549 143 1 26 27 -1750.460320 143 1 26 28 -3.243566 143 1 26 54 -3507.601340 143 1 26 55 1750.460320 143 1 26 56 -3.312697 143 1 27 27 881.496070 143 1 27 28 -6.487131 143 1 27 54 1750.460320 143 1 27 55 -881.910860 143 1 27 56 -6.625395 143 1 28 28 10.917229 143 1 28 54 3.312697 143 1 28 55 6.625395 143 1 28 56 5.507994 143 1 54 54 3507.186549 143 1 54 55 -1750.460320 143 1 54 56 3.243566 143 1 55 55 881.496070 143 1 55 56 6.487131 143 1 56 56 10.917229 143 2 143 143 1.0 144 1 29 29 10.917229 144 1 29 57 3.312697 144 1 29 58 6.625395 144 1 29 59 5.507994 144 1 57 57 3507.186549 144 1 57 58 -1750.460320 144 1 57 59 3.243566 144 1 58 58 881.496070 144 1 58 59 6.487131 144 1 59 59 10.917229 144 2 144 144 1.0 145 1 33 33 3507.186549 145 1 33 34 -1750.460320 145 1 33 35 -3.243566 145 1 33 63 -3507.601340 145 1 33 64 1750.460320 145 1 33 65 -3.312697 145 1 34 34 881.496070 145 1 34 35 -6.487131 145 1 34 63 1750.460320 145 1 34 64 -881.910860 145 1 34 65 -6.625395 145 1 35 35 10.917229 145 1 35 63 3.312697 145 1 35 64 6.625395 145 1 35 65 5.507994 145 1 63 63 3507.186549 145 1 63 64 -1750.460320 145 1 63 65 3.243566 145 1 64 64 881.496070 145 1 64 65 6.487131 145 1 65 65 10.917229 145 2 145 145 1.0 146 1 36 36 3507.186549 146 1 36 37 -1750.460320 146 1 36 38 -3.243566 146 1 36 66 -3507.601340 146 1 36 67 1750.460320 146 1 36 68 -3.312697 146 1 37 37 881.496070 146 1 37 38 -6.487131 146 1 37 66 1750.460320 146 1 37 67 -881.910860 146 1 37 68 -6.625395 146 1 38 38 10.917229 146 1 38 66 3.312697 146 1 38 67 6.625395 146 1 38 68 5.507994 146 1 66 66 3507.186549 146 1 66 67 -1750.460320 146 1 66 68 3.243566 146 1 67 67 881.496070 146 1 67 68 6.487131 146 1 68 68 10.917229 146 2 146 146 1.0 147 1 39 39 3507.186549 147 1 39 40 -1750.460320 147 1 39 41 -3.243566 147 1 39 69 -3507.601340 147 1 39 70 1750.460320 147 1 39 71 -3.312697 147 1 40 40 881.496070 147 1 40 41 -6.487131 147 1 40 69 1750.460320 147 1 40 70 -881.910860 147 1 40 71 -6.625395 147 1 41 41 10.917229 147 1 41 69 3.312697 147 1 41 70 6.625395 147 1 41 71 5.507994 147 1 69 69 3507.186549 147 1 69 70 -1750.460320 147 1 69 71 3.243566 147 1 70 70 881.496070 147 1 70 71 6.487131 147 1 71 71 10.917229 147 2 147 147 1.0 148 1 42 42 3507.186549 148 1 42 43 -1750.460320 148 1 42 44 -3.243566 148 1 42 72 -3507.601340 148 1 42 73 1750.460320 148 1 42 74 -3.312697 148 1 43 43 881.496070 148 1 43 44 -6.487131 148 1 43 72 1750.460320 148 1 43 73 -881.910860 148 1 43 74 -6.625395 148 1 44 44 10.917229 148 1 44 72 3.312697 148 1 44 73 6.625395 148 1 44 74 5.507994 148 1 72 72 3507.186549 148 1 72 73 -1750.460320 148 1 72 74 3.243566 148 1 73 73 881.496070 148 1 73 74 6.487131 148 1 74 74 10.917229 148 2 148 148 1.0 149 1 45 45 3507.186549 149 1 45 46 -1750.460320 149 1 45 47 -3.243566 149 1 45 75 -3507.601340 149 1 45 76 1750.460320 149 1 45 77 -3.312697 149 1 46 46 881.496070 149 1 46 47 -6.487131 149 1 46 75 1750.460320 149 1 46 76 -881.910860 149 1 46 77 -6.625395 149 1 47 47 10.917229 149 1 47 75 3.312697 149 1 47 76 6.625395 149 1 47 77 5.507994 149 1 75 75 3507.186549 149 1 75 76 -1750.460320 149 1 75 77 3.243566 149 1 76 76 881.496070 149 1 76 77 6.487131 149 1 77 77 10.917229 149 2 149 149 1.0 150 1 48 48 3507.186549 150 1 48 49 -1750.460320 150 1 48 50 -3.243566 150 1 48 78 -3507.601340 150 1 48 79 1750.460320 150 1 48 80 -3.312697 150 1 49 49 881.496070 150 1 49 50 -6.487131 150 1 49 78 1750.460320 150 1 49 79 -881.910860 150 1 49 80 -6.625395 150 1 50 50 10.917229 150 1 50 78 3.312697 150 1 50 79 6.625395 150 1 50 80 5.507994 150 1 78 78 3507.186549 150 1 78 79 -1750.460320 150 1 78 80 3.243566 150 1 79 79 881.496070 150 1 79 80 6.487131 150 1 80 80 10.917229 150 2 150 150 1.0 151 1 51 51 3507.186549 151 1 51 52 -1750.460320 151 1 51 53 -3.243566 151 1 51 81 -3507.601340 151 1 51 82 1750.460320 151 1 51 83 -3.312697 151 1 52 52 881.496070 151 1 52 53 -6.487131 151 1 52 81 1750.460320 151 1 52 82 -881.910860 151 1 52 83 -6.625395 151 1 53 53 10.917229 151 1 53 81 3.312697 151 1 53 82 6.625395 151 1 53 83 5.507994 151 1 81 81 3507.186549 151 1 81 82 -1750.460320 151 1 81 83 3.243566 151 1 82 82 881.496070 151 1 82 83 6.487131 151 1 83 83 10.917229 151 2 151 151 1.0 152 1 54 54 3507.186549 152 1 54 55 -1750.460320 152 1 54 56 -3.243566 152 1 54 84 -3507.601340 152 1 54 85 1750.460320 152 1 54 86 -3.312697 152 1 55 55 881.496070 152 1 55 56 -6.487131 152 1 55 84 1750.460320 152 1 55 85 -881.910860 152 1 55 86 -6.625395 152 1 56 56 10.917229 152 1 56 84 3.312697 152 1 56 85 6.625395 152 1 56 86 5.507994 152 1 84 84 3507.186549 152 1 84 85 -1750.460320 152 1 84 86 3.243566 152 1 85 85 881.496070 152 1 85 86 6.487131 152 1 86 86 10.917229 152 2 152 152 1.0 153 1 57 57 3507.186549 153 1 57 58 -1750.460320 153 1 57 59 -3.243566 153 1 57 87 -3507.601340 153 1 57 88 1750.460320 153 1 57 89 -3.312697 153 1 58 58 881.496070 153 1 58 59 -6.487131 153 1 58 87 1750.460320 153 1 58 88 -881.910860 153 1 58 89 -6.625395 153 1 59 59 10.917229 153 1 59 87 3.312697 153 1 59 88 6.625395 153 1 59 89 5.507994 153 1 87 87 3507.186549 153 1 87 88 -1750.460320 153 1 87 89 3.243566 153 1 88 88 881.496070 153 1 88 89 6.487131 153 1 89 89 10.917229 153 2 153 153 1.0 154 1 60 60 3507.186549 154 1 60 61 -1750.460320 154 1 60 62 -3.243566 154 1 60 90 -3507.601340 154 1 60 91 1750.460320 154 1 60 92 -3.312697 154 1 61 61 881.496070 154 1 61 62 -6.487131 154 1 61 90 1750.460320 154 1 61 91 -881.910860 154 1 61 92 -6.625395 154 1 62 62 10.917229 154 1 62 90 3.312697 154 1 62 91 6.625395 154 1 62 92 5.507994 154 1 90 90 3507.186549 154 1 90 91 -1750.460320 154 1 90 92 3.243566 154 1 91 91 881.496070 154 1 91 92 6.487131 154 1 92 92 10.917229 154 2 154 154 1.0 155 1 66 66 3507.186549 155 1 66 67 -1750.460320 155 1 66 68 -3.243566 155 1 66 96 -3507.601340 155 1 66 97 1750.460320 155 1 66 98 -3.312697 155 1 67 67 881.496070 155 1 67 68 -6.487131 155 1 67 96 1750.460320 155 1 67 97 -881.910860 155 1 67 98 -6.625395 155 1 68 68 10.917229 155 1 68 96 3.312697 155 1 68 97 6.625395 155 1 68 98 5.507994 155 1 96 96 3507.186549 155 1 96 97 -1750.460320 155 1 96 98 3.243566 155 1 97 97 881.496070 155 1 97 98 6.487131 155 1 98 98 10.917229 155 2 155 155 1.0 156 1 69 69 3507.186549 156 1 69 70 -1750.460320 156 1 69 71 -3.243566 156 1 69 99 -3507.601340 156 1 69 100 1750.460320 156 1 69 101 -3.312697 156 1 70 70 881.496070 156 1 70 71 -6.487131 156 1 70 99 1750.460320 156 1 70 100 -881.910860 156 1 70 101 -6.625395 156 1 71 71 10.917229 156 1 71 99 3.312697 156 1 71 100 6.625395 156 1 71 101 5.507994 156 1 99 99 3507.186549 156 1 99 100 -1750.460320 156 1 99 101 3.243566 156 1 100 100 881.496070 156 1 100 101 6.487131 156 1 101 101 10.917229 156 2 156 156 1.0 157 1 72 72 3507.186549 157 1 72 73 -1750.460320 157 1 72 74 -3.243566 157 1 72 102 -3507.601340 157 1 72 103 1750.460320 157 1 72 104 -3.312697 157 1 73 73 881.496070 157 1 73 74 -6.487131 157 1 73 102 1750.460320 157 1 73 103 -881.910860 157 1 73 104 -6.625395 157 1 74 74 10.917229 157 1 74 102 3.312697 157 1 74 103 6.625395 157 1 74 104 5.507994 157 1 102 102 3507.186549 157 1 102 103 -1750.460320 157 1 102 104 3.243566 157 1 103 103 881.496070 157 1 103 104 6.487131 157 1 104 104 10.917229 157 2 157 157 1.0 158 1 75 75 3507.186549 158 1 75 76 -1750.460320 158 1 75 77 -3.243566 158 1 75 105 -3507.601340 158 1 75 106 1750.460320 158 1 75 107 -3.312697 158 1 76 76 881.496070 158 1 76 77 -6.487131 158 1 76 105 1750.460320 158 1 76 106 -881.910860 158 1 76 107 -6.625395 158 1 77 77 10.917229 158 1 77 105 3.312697 158 1 77 106 6.625395 158 1 77 107 5.507994 158 1 105 105 3507.186549 158 1 105 106 -1750.460320 158 1 105 107 3.243566 158 1 106 106 881.496070 158 1 106 107 6.487131 158 1 107 107 10.917229 158 2 158 158 1.0 159 1 78 78 3507.186549 159 1 78 79 -1750.460320 159 1 78 80 -3.243566 159 1 78 108 -3507.601340 159 1 78 109 1750.460320 159 1 78 110 -3.312697 159 1 79 79 881.496070 159 1 79 80 -6.487131 159 1 79 108 1750.460320 159 1 79 109 -881.910860 159 1 79 110 -6.625395 159 1 80 80 10.917229 159 1 80 108 3.312697 159 1 80 109 6.625395 159 1 80 110 5.507994 159 1 108 108 3507.186549 159 1 108 109 -1750.460320 159 1 108 110 3.243566 159 1 109 109 881.496070 159 1 109 110 6.487131 159 1 110 110 10.917229 159 2 159 159 1.0 160 1 81 81 3507.186549 160 1 81 82 -1750.460320 160 1 81 83 -3.243566 160 1 81 111 -3507.601340 160 1 81 112 1750.460320 160 1 81 113 -3.312697 160 1 82 82 881.496070 160 1 82 83 -6.487131 160 1 82 111 1750.460320 160 1 82 112 -881.910860 160 1 82 113 -6.625395 160 1 83 83 10.917229 160 1 83 111 3.312697 160 1 83 112 6.625395 160 1 83 113 5.507994 160 1 111 111 3507.186549 160 1 111 112 -1750.460320 160 1 111 113 3.243566 160 1 112 112 881.496070 160 1 112 113 6.487131 160 1 113 113 10.917229 160 2 160 160 1.0 161 1 84 84 3507.186549 161 1 84 85 -1750.460320 161 1 84 86 -3.243566 161 1 84 114 -3507.601340 161 1 84 115 1750.460320 161 1 84 116 -3.312697 161 1 85 85 881.496070 161 1 85 86 -6.487131 161 1 85 114 1750.460320 161 1 85 115 -881.910860 161 1 85 116 -6.625395 161 1 86 86 10.917229 161 1 86 114 3.312697 161 1 86 115 6.625395 161 1 86 116 5.507994 161 1 114 114 3507.186549 161 1 114 115 -1750.460320 161 1 114 116 3.243566 161 1 115 115 881.496070 161 1 115 116 6.487131 161 1 116 116 10.917229 161 2 161 161 1.0 162 1 87 87 3507.186549 162 1 87 88 -1750.460320 162 1 87 89 -3.243566 162 1 87 117 -3507.601340 162 1 87 118 1750.460320 162 1 87 119 -3.312697 162 1 88 88 881.496070 162 1 88 89 -6.487131 162 1 88 117 1750.460320 162 1 88 118 -881.910860 162 1 88 119 -6.625395 162 1 89 89 10.917229 162 1 89 117 3.312697 162 1 89 118 6.625395 162 1 89 119 5.507994 162 1 117 117 3507.186549 162 1 117 118 -1750.460320 162 1 117 119 3.243566 162 1 118 118 881.496070 162 1 118 119 6.487131 162 1 119 119 10.917229 162 2 162 162 1.0 163 1 90 90 3507.186549 163 1 90 91 -1750.460320 163 1 90 92 -3.243566 163 1 90 120 -3507.601340 163 1 90 121 1750.460320 163 1 90 122 -3.312697 163 1 91 91 881.496070 163 1 91 92 -6.487131 163 1 91 120 1750.460320 163 1 91 121 -881.910860 163 1 91 122 -6.625395 163 1 92 92 10.917229 163 1 92 120 3.312697 163 1 92 121 6.625395 163 1 92 122 5.507994 163 1 120 120 3507.186549 163 1 120 121 -1750.460320 163 1 120 122 3.243566 163 1 121 121 881.496070 163 1 121 122 6.487131 163 1 122 122 10.917229 163 2 163 163 1.0 164 1 93 93 3507.186549 164 1 93 94 -1750.460320 164 1 93 95 -3.243566 164 1 93 123 -3507.601340 164 1 93 124 1750.460320 164 1 93 125 -3.312697 164 1 94 94 881.496070 164 1 94 95 -6.487131 164 1 94 123 1750.460320 164 1 94 124 -881.910860 164 1 94 125 -6.625395 164 1 95 95 10.917229 164 1 95 123 3.312697 164 1 95 124 6.625395 164 1 95 125 5.507994 164 1 123 123 3507.186549 164 1 123 124 -1750.460320 164 1 123 125 3.243566 164 1 124 124 881.496070 164 1 124 125 6.487131 164 1 125 125 10.917229 164 2 164 164 1.0 165 1 99 99 3507.186549 165 1 99 100 -1750.460320 165 1 99 101 -3.243566 165 1 99 129 -3507.601340 165 1 99 130 1750.460320 165 1 99 131 -3.312697 165 1 100 100 881.496070 165 1 100 101 -6.487131 165 1 100 129 1750.460320 165 1 100 130 -881.910860 165 1 100 131 -6.625395 165 1 101 101 10.917229 165 1 101 129 3.312697 165 1 101 130 6.625395 165 1 101 131 5.507994 165 1 129 129 3507.186549 165 1 129 130 -1750.460320 165 1 129 131 3.243566 165 1 130 130 881.496070 165 1 130 131 6.487131 165 1 131 131 10.917229 165 2 165 165 1.0 166 1 102 102 3507.186549 166 1 102 103 -1750.460320 166 1 102 104 -3.243566 166 1 102 132 -3507.601340 166 1 102 133 1750.460320 166 1 102 134 -3.312697 166 1 103 103 881.496070 166 1 103 104 -6.487131 166 1 103 132 1750.460320 166 1 103 133 -881.910860 166 1 103 134 -6.625395 166 1 104 104 10.917229 166 1 104 132 3.312697 166 1 104 133 6.625395 166 1 104 134 5.507994 166 1 132 132 3507.186549 166 1 132 133 -1750.460320 166 1 132 134 3.243566 166 1 133 133 881.496070 166 1 133 134 6.487131 166 1 134 134 10.917229 166 2 166 166 1.0 167 1 105 105 3507.186549 167 1 105 106 -1750.460320 167 1 105 107 -3.243566 167 1 105 135 -3507.601340 167 1 105 136 1750.460320 167 1 105 137 -3.312697 167 1 106 106 881.496070 167 1 106 107 -6.487131 167 1 106 135 1750.460320 167 1 106 136 -881.910860 167 1 106 137 -6.625395 167 1 107 107 10.917229 167 1 107 135 3.312697 167 1 107 136 6.625395 167 1 107 137 5.507994 167 1 135 135 3507.186549 167 1 135 136 -1750.460320 167 1 135 137 3.243566 167 1 136 136 881.496070 167 1 136 137 6.487131 167 1 137 137 10.917229 167 2 167 167 1.0 168 1 108 108 3507.186549 168 1 108 109 -1750.460320 168 1 108 110 -3.243566 168 1 108 138 -3507.601340 168 1 108 139 1750.460320 168 1 108 140 -3.312697 168 1 109 109 881.496070 168 1 109 110 -6.487131 168 1 109 138 1750.460320 168 1 109 139 -881.910860 168 1 109 140 -6.625395 168 1 110 110 10.917229 168 1 110 138 3.312697 168 1 110 139 6.625395 168 1 110 140 5.507994 168 1 138 138 3507.186549 168 1 138 139 -1750.460320 168 1 138 140 3.243566 168 1 139 139 881.496070 168 1 139 140 6.487131 168 1 140 140 10.917229 168 2 168 168 1.0 169 1 111 111 3507.186549 169 1 111 112 -1750.460320 169 1 111 113 -3.243566 169 1 111 141 -3507.601340 169 1 111 142 1750.460320 169 1 111 143 -3.312697 169 1 112 112 881.496070 169 1 112 113 -6.487131 169 1 112 141 1750.460320 169 1 112 142 -881.910860 169 1 112 143 -6.625395 169 1 113 113 10.917229 169 1 113 141 3.312697 169 1 113 142 6.625395 169 1 113 143 5.507994 169 1 141 141 3507.186549 169 1 141 142 -1750.460320 169 1 141 143 3.243566 169 1 142 142 881.496070 169 1 142 143 6.487131 169 1 143 143 10.917229 169 2 169 169 1.0 170 1 114 114 3507.186549 170 1 114 115 -1750.460320 170 1 114 116 -3.243566 170 1 114 144 -3507.601340 170 1 114 145 1750.460320 170 1 114 146 -3.312697 170 1 115 115 881.496070 170 1 115 116 -6.487131 170 1 115 144 1750.460320 170 1 115 145 -881.910860 170 1 115 146 -6.625395 170 1 116 116 10.917229 170 1 116 144 3.312697 170 1 116 145 6.625395 170 1 116 146 5.507994 170 1 144 144 3507.186549 170 1 144 145 -1750.460320 170 1 144 146 3.243566 170 1 145 145 881.496070 170 1 145 146 6.487131 170 1 146 146 10.917229 170 2 170 170 1.0 171 1 117 117 3507.186549 171 1 117 118 -1750.460320 171 1 117 119 -3.243566 171 1 117 147 -3507.601340 171 1 117 148 1750.460320 171 1 117 149 -3.312697 171 1 118 118 881.496070 171 1 118 119 -6.487131 171 1 118 147 1750.460320 171 1 118 148 -881.910860 171 1 118 149 -6.625395 171 1 119 119 10.917229 171 1 119 147 3.312697 171 1 119 148 6.625395 171 1 119 149 5.507994 171 1 147 147 3507.186549 171 1 147 148 -1750.460320 171 1 147 149 3.243566 171 1 148 148 881.496070 171 1 148 149 6.487131 171 1 149 149 10.917229 171 2 171 171 1.0 172 1 120 120 3507.186549 172 1 120 121 -1750.460320 172 1 120 122 -3.243566 172 1 120 150 -3507.601340 172 1 120 151 1750.460320 172 1 120 152 -3.312697 172 1 121 121 881.496070 172 1 121 122 -6.487131 172 1 121 150 1750.460320 172 1 121 151 -881.910860 172 1 121 152 -6.625395 172 1 122 122 10.917229 172 1 122 150 3.312697 172 1 122 151 6.625395 172 1 122 152 5.507994 172 1 150 150 3507.186549 172 1 150 151 -1750.460320 172 1 150 152 3.243566 172 1 151 151 881.496070 172 1 151 152 6.487131 172 1 152 152 10.917229 172 2 172 172 1.0 173 1 123 123 3507.186549 173 1 123 124 -1750.460320 173 1 123 125 -3.243566 173 1 123 153 -3507.601340 173 1 123 154 1750.460320 173 1 123 155 -3.312697 173 1 124 124 881.496070 173 1 124 125 -6.487131 173 1 124 153 1750.460320 173 1 124 154 -881.910860 173 1 124 155 -6.625395 173 1 125 125 10.917229 173 1 125 153 3.312697 173 1 125 154 6.625395 173 1 125 155 5.507994 173 1 153 153 3507.186549 173 1 153 154 -1750.460320 173 1 153 155 3.243566 173 1 154 154 881.496070 173 1 154 155 6.487131 173 1 155 155 10.917229 173 2 173 173 1.0 174 1 126 126 3507.186549 174 1 126 127 -1750.460320 174 1 126 128 -3.243566 174 1 126 156 -3507.601340 174 1 126 157 1750.460320 174 1 126 158 -3.312697 174 1 127 127 881.496070 174 1 127 128 -6.487131 174 1 127 156 1750.460320 174 1 127 157 -881.910860 174 1 127 158 -6.625395 174 1 128 128 10.917229 174 1 128 156 3.312697 174 1 128 157 6.625395 174 1 128 158 5.507994 174 1 156 156 3507.186549 174 1 156 157 -1750.460320 174 1 156 158 3.243566 174 1 157 157 881.496070 174 1 157 158 6.487131 174 1 158 158 10.917229 174 2 174 174 1.0 DSDP5.8/matlab/dadotx.m0000644000175000017500000000174310326241002014675 0ustar twernertwerner%%******************************************************************* %% Apply the operators A to the matrix X. Each column %% of A and X is the vector representation of a square symmetric %% matrix. %% %% [v] = dadotx(A,X) %% %% Input: A = square symmetric matrices in DSDP dvec form %% Input: X = square symmetric matrix in DSDP dvec form %% %% Output: v = column vector representing the inner products %% %% See also: DVEC, DMAT %% %% DSDP5.0 %% Copyright (c) 2003 by %% S. Benson and Y. Ye %% Last modified: December 2003 %%****************************************************************** function [b]=dadotx(A,x); [m,m1]=size(x); [p,p1]=size(A); if (m1~=1) error('X Not a column vector.'); end; if (m~=p) error('Number of rows in first and second argument not equal.'); end; n=floor(sqrt(2*m)); if (n*(n+1)/2 ~= m) error('Impossible Dimension for square matrix.'); end; xx=x'; for i=1:n, k=i*(i+1)/2; xx(k) = xx(k)/2; end; b=[xx]*A; b=full(2*b'); DSDP5.8/matlab/check.out0000644000175000017500000001325210326241002015040 0ustar twernertwerner>> check MAXCUT Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 5.00000000e+00 -2.75000000e+01 4.2e+00 0.0e+00 2.2e-01 0.00 0.00 0.00 1 -1.71094527e+01 -2.50331240e+01 3.9e-15 0.0e+00 3.1e-02 1.00 1.00 11.10 2 -2.40917804e+01 -2.50010311e+01 1.6e-15 0.0e+00 8.5e-04 1.00 1.00 13.04 3 -2.49754699e+01 -2.50000321e+01 4.2e-17 0.0e+00 2.6e-05 1.00 1.00 13.03 4 -2.49992356e+01 -2.50000010e+01 1.3e-18 0.0e+00 8.2e-07 1.00 1.00 13.03 DSDP Converged. GPP Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -2.75000000e+01 4.3e+00 0.0e+00 6.3e+07 0.00 0.00 0.00 5 -2.47494769e+01 -2.47500164e+01 8.7e-19 0.0e+00 1.9e-06 1.00 1.00 9.65 DSDP Converged. ETP Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+03 -2.24843191e+10 4.2e+00 2.2e+02 2.2e+10 0.00 0.00 0.00 5 4.26671087e+07 5.54484314e+00 1.2e-08 0.0e+00 1.8e+04 1.00 1.00 0.00 10 1.01770138e+01 9.99817429e+00 1.1e-16 0.0e+00 1.9e-04 1.00 1.00 31.12 13 1.00000069e+01 9.99999989e+00 4.3e-21 0.0e+00 4.5e-08 1.00 0.20 13.72 DSDP Converged. THETA Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -2.00000000e+01 2.0e+00 0.0e+00 3.2e+07 0.00 0.00 0.00 5 -4.99814021e+00 -5.00000092e+00 3.1e-18 0.0e+00 4.5e-07 1.00 1.00 10.02 7 -4.99999954e+00 -5.00000000e+00 2.5e-12 0.0e+00 1.5e-09 1.00 0.25 5.45 DSDP Converged. MAXCUT Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.10000000e+01 -4.95000000e+01 4.2e+00 0.0e+00 4.0e-01 0.00 0.00 0.00 1 -1.94320848e+01 -3.39444776e+01 5.6e-14 0.0e+00 4.3e-03 1.00 1.00 2e+03 2 -1.94320848e+01 -3.37670494e+01 5.6e-14 0.0e+00 1.7e-01 0.06 1.00 0.40 3 -2.86706069e+01 -3.31497721e+01 1.5e-14 0.0e+00 6.3e-03 1.00 1.00 12.41 4 -3.29614620e+01 -3.31256320e+01 5.5e-16 0.0e+00 1.7e-04 1.00 1.00 11.95 5 -3.31204737e+01 -3.31250238e+01 1.5e-17 0.0e+00 5.5e-06 1.00 1.00 16.41 6 -3.31248561e+01 -3.31250006e+01 4.8e-19 0.0e+00 1.6e-07 1.00 1.00 11.79 DSDP Converged. GPP Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -4.95000000e+01 4.3e+00 0.0e+00 6.3e+07 0.00 0.00 0.00 5 -3.25540925e+01 -3.30147739e+01 1.4e-15 0.0e+00 4.0e-03 1.00 1.00 1.35 8 -3.29998553e+01 -3.30000009e+01 4.7e-19 0.0e+00 2.4e-07 1.00 1.00 7.83 DSDP Converged. ETP Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+03 -2.28969525e+10 4.2e+00 2.3e+02 2.3e+10 0.00 0.00 0.00 5 2.52254327e+06 5.87664256e+00 7.6e-10 0.0e+00 1.1e+03 1.00 1.00 0.00 10 1.01862956e+01 9.99854710e+00 1.1e-16 0.0e+00 2.3e-04 1.00 1.00 11.07 13 1.00000093e+01 9.99999987e+00 5.6e-21 0.0e+00 5.6e-08 1.00 0.23 10.68 DSDP Converged. THETA Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -2.00000000e+01 2.0e+00 0.0e+00 2.8e+07 0.00 0.00 0.00 5 -2.99772977e+00 -3.00000051e+00 1.9e-18 0.0e+00 5.4e-07 1.00 1.00 5.94 7 -2.99999936e+00 -3.00000000e+00 5.4e-22 0.0e+00 1.8e-09 1.00 0.25 3.74 DSDP Converged. CONTROL1 Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -3.42355583e+14 2.0e+00 3.4e+06 3.4e+14 0.00 0.00 0.00 10 1.60299274e+13 -9.26056093e+06 3.7e+05 0.0e+00 5.0e+09 1.00 1.00 0.00 20 -9.26060336e+00 -1.79475206e+01 5.8e-14 0.0e+00 5.3e-02 0.32 1.00 0.35 30 -1.77840611e+01 -1.77846629e+01 8.9e-12 0.0e+00 1.5e-06 0.96 1.00 1.19 32 -1.77846254e+01 -1.77846378e+01 8.9e-12 0.0e+00 6.6e-08 1.00 0.14 13.77 DSDP Converged. ARCH0 Iter PP Objective DD Objective PInfeas DInfeas Nu StepLength Pnrm ---------------------------------------------------------------------------------------- 0 1.00000000e+10 -5.04724818e+15 2.6e+01 5.0e+07 5.0e+15 0.00 0.00 0.00 10 9.57801451e+10 -2.12615944e+09 5.2e+01 0.0e+00 4.6e+07 1.00 1.00 0.09 20 1.87046384e+03 -7.98317324e+01 1.8e-12 0.0e+00 2.4e-01 1.00 1.00 22.06 30 -4.48199192e-01 -5.81142931e-01 6.2e-20 0.0e+00 1.4e-04 1.00 1.00 1.09 40 -5.66243579e-01 -5.66540629e-01 1.4e-22 0.0e+00 2.4e-07 1.00 1.00 4.98 48 -5.66515995e-01 -5.66517310e-01 6.5e-25 0.0e+00 7.0e-10 1.00 0.38 16.95 DSDP Converged. DSDP5.8/matlab/readsedumi.m0000644000175000017500000000317310326241002015533 0ustar twernertwerner%%******************************************************************* %% Convert problem from SeDuMi format to DSDP format %% %% [AC,b] = readsedumi(At,b,C,K) %% %% Input: At, b, C, K = Data in SeDuMi format. %% %% %% DSDP: version 5.0 %% Copyright (c) 2004 by %% S. Benson Y. Ye %% Last modified: 2 Jan 04 %%****************************************************************** function [AC,b]=readsedumi(At,bb,c,K); %% %% First, load the matlab file containing At, c, b, and K %% if (size(c,1) == 1), c = c'; end; if (size(bb,1) == 1), bb = bb'; end; [nn,mm] = size(At); if (max(size(c)) == 1); c = c*ones(nn,1); end; if ~isfield(K,'l'); K.l = 0; end if ~isfield(K,'q'); K.q = 0; end if ~isfield(K,'s'); K.s = 0; end if K.l == 0 | isempty(K.l); K.l = 0; end; if sum(K.q) == 0 | isempty(K.q); K.q = 0; end if sum(K.s) == 0 | isempty(K.s); K.s = 0; end %% %% %% AC=cell(1,3); block=1; top=1; m = length(bb); b = -bb; if (K.l > 0) AC{block,1} = 'LP'; AC{block,2} = K.l; A = At(top:top+n-1,:); CC = c(top:top+n-1,:); AC{block,3} = [-A(:,1:m) CC(:,1)]; block = block+1; top = top+K.l; end if (K.q > 0) error(' Cannot accept SOCP cones\n'); end if (K.s > 0) for i = 1:length(K.s) n = K.s(i); AC{block,1} = 'SDP'; AC{block,2} = n; A = At(top:top+n^2-1,:); CC = c(top:top+n^2-1,:); indicies = triu(reshape(1:n^2,n,n)); indicies = indicies(find(indicies)); AC{block,3} = [-A(indicies,1:m) CC(indicies,1)]; block = block+1; top = top+n*n; end end %% DSDP5.8/matlab/control1.dat-s0000644000175000017500000001322010326241002015720 0ustar twernertwerner21 2 10 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 2 1 1 1 0 2 2 2 1 0 2 3 3 1 0 2 4 4 1 0 2 5 5 1 1 1 1 1 124.273 1 1 1 2 -35.0023 1 1 1 3 76.6539 1 1 1 4 27.332 1 1 1 5 -61.3865 1 1 1 6 88.6774 1 1 1 7 -83.062 1 1 1 8 16.5419 1 1 1 9 -20.3089 1 1 1 10 -42.1758 1 2 1 1 1 2 1 1 1 147.335 2 1 1 2 54.4754 2 1 1 3 73.3052 2 1 1 4 -13.5079 2 1 1 5 34.4098 2 1 1 6 -53.2313 2 1 1 7 -58.1725 2 1 1 8 22.8219 2 1 1 9 -76.5774 2 1 1 10 69.1595 2 1 2 2 -70.0046 2 1 2 3 76.6539 2 1 2 4 27.332 2 1 2 5 -61.3865 2 1 2 6 88.6774 2 1 2 7 -83.062 2 1 2 8 16.5419 2 1 2 9 -20.3089 2 1 2 10 -42.1758 2 2 1 2 1 3 1 1 1 151.56 3 1 1 2 -18.6112 3 1 1 3 116.021 3 1 1 4 -87.6454 3 1 1 5 -86.8244 3 1 1 6 61.4354 3 1 1 7 97.0903 3 1 1 8 -38.5015 3 1 1 9 34.7407 3 1 1 10 -16.4176 3 1 2 3 -35.0023 3 1 3 3 153.308 3 1 3 4 27.332 3 1 3 5 -61.3865 3 1 3 6 88.6774 3 1 3 7 -83.062 3 1 3 8 16.5419 3 1 3 9 -20.3089 3 1 3 10 -42.1758 3 2 1 3 1 4 1 1 1 -111.952 4 1 1 2 -87.1461 4 1 1 3 66.374 4 1 1 4 -20.8577 4 1 1 5 21.8844 4 1 1 6 95.9083 4 1 1 7 10.5205 4 1 1 8 64.9712 4 1 1 9 49.7928 4 1 1 10 22.875 4 1 2 4 -35.0023 4 1 3 4 76.6539 4 1 4 4 54.664 4 1 4 5 -61.3865 4 1 4 6 88.6774 4 1 4 7 -83.062 4 1 4 8 16.5419 4 1 4 9 -20.3089 4 1 4 10 -42.1758 4 2 1 4 1 5 1 1 1 143.439 5 1 1 2 -70.8505 5 1 1 3 34.9854 5 1 1 4 -40.5764 5 1 1 5 134.907 5 1 1 6 78.1468 5 1 1 7 93.8168 5 1 1 8 35.729 5 1 1 9 44.5208 5 1 1 10 -89.1773 5 1 2 5 -35.0023 5 1 3 5 76.6539 5 1 4 5 27.332 5 1 5 5 -122.773 5 1 5 6 88.6774 5 1 5 7 -83.062 5 1 5 8 16.5419 5 1 5 9 -20.3089 5 1 5 10 -42.1758 5 2 1 5 1 6 1 1 2 73.6677 6 1 2 2 -15.3221 6 1 2 3 73.3052 6 1 2 4 -13.5079 6 1 2 5 34.4098 6 1 2 6 -53.2313 6 1 2 7 -58.1725 6 1 2 8 22.8219 6 1 2 9 -76.5774 6 1 2 10 69.1595 6 2 2 2 1 7 1 1 2 75.7798 7 1 1 3 73.6677 7 1 2 2 -37.2224 7 1 2 3 46.2235 7 1 2 4 -87.6454 7 1 2 5 -86.8244 7 1 2 6 61.4354 7 1 2 7 97.0903 7 1 2 8 -38.5015 7 1 2 9 34.7407 7 1 2 10 -16.4176 7 1 3 3 146.61 7 1 3 4 -13.5079 7 1 3 5 34.4098 7 1 3 6 -53.2313 7 1 3 7 -58.1725 7 1 3 8 22.8219 7 1 3 9 -76.5774 7 1 3 10 69.1595 7 2 2 3 1 8 1 1 2 -55.976 8 1 1 4 73.6677 8 1 2 2 -174.292 8 1 2 3 66.374 8 1 2 4 -90.6551 8 1 2 5 21.8844 8 1 2 6 95.9083 8 1 2 7 10.5205 8 1 2 8 64.9712 8 1 2 9 49.7928 8 1 2 10 22.875 8 1 3 4 73.3052 8 1 4 4 -27.0159 8 1 4 5 34.4098 8 1 4 6 -53.2313 8 1 4 7 -58.1725 8 1 4 8 22.8219 8 1 4 9 -76.5774 8 1 4 10 69.1595 8 2 2 4 1 9 1 1 2 71.7196 9 1 1 5 73.6677 9 1 2 2 -141.701 9 1 2 3 34.9854 9 1 2 4 -40.5764 9 1 2 5 65.1093 9 1 2 6 78.1468 9 1 2 7 93.8168 9 1 2 8 35.729 9 1 2 9 44.5208 9 1 2 10 -89.1773 9 1 3 5 73.3052 9 1 4 5 -13.5079 9 1 5 5 68.8196 9 1 5 6 -53.2313 9 1 5 7 -58.1725 9 1 5 8 22.8219 9 1 5 9 -76.5774 9 1 5 10 69.1595 9 2 2 5 1 10 1 1 3 75.7798 10 1 2 3 -18.6112 10 1 3 3 107.769 10 1 3 4 -87.6454 10 1 3 5 -86.8244 10 1 3 6 61.4354 10 1 3 7 97.0903 10 1 3 8 -38.5015 10 1 3 9 34.7407 10 1 3 10 -16.4176 10 2 3 3 1 11 1 1 3 -55.976 11 1 1 4 75.7798 11 1 2 3 -87.1461 11 1 2 4 -18.6112 11 1 3 3 132.748 11 1 3 4 -29.1096 11 1 3 5 21.8844 11 1 3 6 95.9083 11 1 3 7 10.5205 11 1 3 8 64.9712 11 1 3 9 49.7928 11 1 3 10 22.875 11 1 4 4 -175.291 11 1 4 5 -86.8244 11 1 4 6 61.4354 11 1 4 7 97.0903 11 1 4 8 -38.5015 11 1 4 9 34.7407 11 1 4 10 -16.4176 11 2 3 4 1 12 1 1 3 71.7196 12 1 1 5 75.7798 12 1 2 3 -70.8505 12 1 2 5 -18.6112 12 1 3 3 69.9708 12 1 3 4 -40.5764 12 1 3 5 126.655 12 1 3 6 78.1468 12 1 3 7 93.8168 12 1 3 8 35.729 12 1 3 9 44.5208 12 1 3 10 -89.1773 12 1 4 5 -87.6454 12 1 5 5 -173.649 12 1 5 6 61.4354 12 1 5 7 97.0903 12 1 5 8 -38.5015 12 1 5 9 34.7407 12 1 5 10 -16.4176 12 2 3 5 1 13 1 1 4 -55.976 13 1 2 4 -87.1461 13 1 3 4 66.374 13 1 4 4 -165.988 13 1 4 5 21.8844 13 1 4 6 95.9083 13 1 4 7 10.5205 13 1 4 8 64.9712 13 1 4 9 49.7928 13 1 4 10 22.875 13 2 4 4 1 14 1 1 4 71.7196 14 1 1 5 -55.976 14 1 2 4 -70.8505 14 1 2 5 -87.1461 14 1 3 4 34.9854 14 1 3 5 66.374 14 1 4 4 -81.1527 14 1 4 5 -10.2237 14 1 4 6 78.1468 14 1 4 7 93.8168 14 1 4 8 35.729 14 1 4 9 44.5208 14 1 4 10 -89.1773 14 1 5 5 43.7687 14 1 5 6 95.9083 14 1 5 7 10.5205 14 1 5 8 64.9712 14 1 5 9 49.7928 14 1 5 10 22.875 14 2 4 5 1 15 1 1 5 71.7196 15 1 2 5 -70.8505 15 1 3 5 34.9854 15 1 4 5 -40.5764 15 1 5 5 145.541 15 1 5 6 78.1468 15 1 5 7 93.8168 15 1 5 8 35.729 15 1 5 9 44.5208 15 1 5 10 -89.1773 15 2 5 5 1 16 1 1 1 -1796.63 16 1 1 2 688.377 16 1 1 3 -2544.38 16 1 1 4 3924.95 16 1 1 5 3207.15 16 1 2 2 -263.751 16 1 2 3 974.877 16 1 2 4 -1503.84 16 1 2 5 -1228.82 16 1 3 3 -3603.34 16 1 3 4 5558.5 16 1 3 5 4541.95 16 1 4 4 -8574.53 16 1 4 5 -7006.4 16 1 5 5 -5725.05 16 1 6 6 1 17 1 1 1 -7613.86 17 1 1 2 7091.95 17 1 1 3 8080.22 17 1 1 4 2555.29 17 1 1 5 -3405.89 17 1 2 2 -6605.82 17 1 2 3 -7526.35 17 1 2 4 -2380.13 17 1 2 5 3172.43 17 1 3 3 -8575.15 17 1 3 4 -2711.8 17 1 3 5 3614.51 17 1 4 4 -857.581 17 1 4 5 1143.05 17 1 5 5 -1523.55 17 1 7 7 1 18 1 1 1 -2457.55 18 1 1 2 3770.24 18 1 1 3 138.551 18 1 1 4 3631.18 18 1 1 5 4931.38 18 1 2 2 -5784.08 18 1 2 3 -212.557 18 1 2 4 -5570.75 18 1 2 5 -7565.45 18 1 3 3 -7.81115 18 1 3 4 -204.717 18 1 3 5 -278.019 18 1 4 4 -5365.29 18 1 4 5 -7286.42 18 1 5 5 -9895.43 18 1 8 8 1 19 1 1 1 -786.558 19 1 1 2 972.724 19 1 1 3 2708.26 19 1 1 4 938.206 19 1 1 5 -857.517 19 1 2 2 -1202.95 19 1 2 3 -3349.26 19 1 2 4 -1160.26 19 1 2 5 1060.48 19 1 3 3 -9325 19 1 3 4 -3230.41 19 1 3 5 2952.58 19 1 4 4 -1119.09 19 1 4 5 1022.85 19 1 5 5 -934.877 19 1 9 9 1 20 1 1 1 -394.085 20 1 1 2 582.864 20 1 1 3 1587.03 20 1 1 4 -1089.46 20 1 1 5 -413.828 20 1 2 2 -862.075 20 1 2 3 -2347.27 20 1 2 4 1611.35 20 1 2 5 612.064 20 1 3 3 -6391.16 20 1 3 4 4387.4 20 1 3 5 1666.53 20 1 4 4 -3011.86 20 1 4 5 -1144.04 20 1 5 5 -434.559 20 1 10 10 1 21 1 1 1 -1 21 1 2 2 -1 21 1 3 3 -1 21 1 4 4 -1 21 1 5 5 -1 21 1 6 6 -1 21 1 7 7 -1 21 1 8 8 -1 21 1 9 9 -1 21 1 10 10 -1 DSDP5.8/matlab/readsdpa.m0000644000175000017500000000674510326241002015204 0ustar twernertwerner%%******************************************************************* %% Read in a problem in SDPA sparse format. %% %% [AC,b] = readsdpa(fname) %% %% Input: fname = name of the file containing SDP data in %% SDPA foramt. %% %% DSDP5 %% Copyright (c) 2005 by %% S.J. Benson, Y. Ye %% Last modified: 4 Feb 05 %%****************************************************************** function [AC,b] = readsdpa(fname); %% %% Open the file for input %% compressed = 0; dblocktol=0; if exist(fname) fid = fopen(fname,'r'); elseif exist([fname,'.Z']); compressed = 1; unix(['uncompress ',fname,'.Z']); fid = fopen(fname,'r'); elseif exist([fname,'.gz']); compressed = 2; unix(['gunzip ',fname,'.gz']); fid = fopen(fname,'r'); else error('** Problem not found, please specify the correct path.'); end; %% %% Clean up special characters and comments from the file %% [tmpr,count] = fscanf(fid,'%c'); linefeeds = findstr(tmpr,char(10)); comment_chars = '*"='; cumidx = []; for i=1:length(comment_chars) idx = findstr(tmpr,comment_chars(i)); cumidx = [cumidx,idx]; end; for j=length(cumidx):-1:1 if (cumidx(j)==1) | (strcmp(tmpr(cumidx(j)-1),char(10))) tmpr(cumidx(j):linefeeds(min(find(cumidx(j) size(blksize,2); blksize = blksize'; end %% %% Get input b. %% idxstrt = 2+numblk; b = datavec(idxstrt+[1:m]); idxstrt = idxstrt+m; b = -b; %% %% Construct AC %% deblkidx = find( (blksize<0) | (blksize > dblocktol) ); denumblk = length(deblkidx); AC=cell(denumblk,3); for p = 1:length(deblkidx) n = blksize(deblkidx(p)); if (n > 0); AC{p,1}='SDP'; AC{p,2}=n; AC{p,3}=sparse(n*(n+1)/2,m+1); else AC{p,1}='LP'; AC{p,2}=abs(n); AC{p,3}=sparse(abs(n),m+1); end end %% %% Construct single blocks of A,C %% len = length(datavec); Y = reshape(datavec(idxstrt+1:len),5,(len-idxstrt)/5)'; clear datavec; Y = sortrows(Y,[1 2]); matidx = [0; find(diff(Y(:,1)) ~= 0); size(Y,1)]; %% for k = 1:length(matidx)-1 idx = [matidx(k)+1 : matidx(k+1)]; Ytmp = Y(idx,1:5); matno = Ytmp(1,1); if (matno == 0) matno=m+1; end; for p = 1:denumblk n = blksize(deblkidx(p)); idx = find( Ytmp(:,2)==deblkidx(p) ); Yp = Ytmp(idx,3:5); len = length(idx); if (n>0) AC{p,3}(:,matno)= -dsparse(Yp(:,1),Yp(:,2),Yp(:,3),n,n); else tmp = -sparse(Yp(:,1),ones(len,1),Yp(:,3),abs(n),1); AC{p,3}(:,matno)=tmp; end end end %% %% %%****************************************************************** DSDP5.8/matlab/doptions.m0000644000175000017500000000702210326241002015245 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual-Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2005 by % S. J. Benson, Y. Ye % Last modified: 05 Feb 2005 %***************************************************************************** % [OPTIONS] = doptions; % % This script sets the default options for use in DSDP. % % The OPTIONS structure may contain any of the following fields: % Problem Formulation: % r0 = multiple of the identity matrix added to the initial dual matrix. % S0 = C - A'(y0) + r0*I. If r0 < 0, a dynamic selection will % be used. Default value is usually very high(~1e12), but % smaller numbers may significantly improve performance. IMPORTANT! % [default -1 (use dynamic strategy, usually very big)]. % zbar = an upper bound for the dual solution. % penalty = penalty parameter used to enforce feasibility (>=0) % This parameter can significantly infuence performance. % It must be larger than the trace of a solution X: % See STAT.tracex % boundy = a bound for the dual variables y. IMPORTANT! % % Convergence: % gaptol = tolerance for duality gap as a fraction of the value of the % objective functions (>=0). % maxit = maximum number of iterations allowed (>=0). % steptol = tolerance for stopping due to small steps (>=0). % pnormtol = terminate only if pnorm less than this number (>0). % dual_bound = stop solver when the objective (D) of a % feasible iterate is greater than this value. % % Detecting Unboundedness and Infeasibility: % inftol = maximum infeasibility in (D) allowed at solution. % infptol = maximum infeasibility in (P) allowed at solution. % % Printing % print = k, if want to display result in each k iteration, else = 0. % logtime = 1, to profile DSDP subroutines, else = 0 % Assumes proper compilation flags. % cc = add this constant to the objective value (for display purposes only) % % Other important options: % rho = potential parameter as multiple of dimension. Larger numbers % can make the algorithm go faster: [ >1] % IMPORTANT: Try 5 or 8. % reuse = reuse Newton matrix this many times (at most) per iteration. % Applications requiring few iterations(<60) should consider % setting this paramter to 0 or 1. % mu0 = initial barrier parameter (>=0). Smaller numbers may improve % performance. [-1 implies a dynamic strategy)] % % Other less important options: % dyanamicrho = Use dynamic rho strategy to reduce barrier. % lp_barrier = scale the barrier on LP cones by this amount. % xmaker = 1 if return y and dy needed to construct X in STAT.xy, STAT.xdy, STAT.xmu % maxtrustradius = maximum trust radius (>=0). Decrease to improve robustness. % bigM = if > 0,make infeasibility a positive variable with a % cost in the objective. %***************************************************************************** function [OPTIONS] = doptions(); OPTIONS.r0=-1; OPTIONS.penalty=1e8; OPTIONS.boundy=1e7; OPTIONS.zbar=1e10; OPTIONS.maxit=300; OPTIONS.gaptol=0.000001; OPTIONS.print=10; OPTIONS.dual_bound=1e10; OPTIONS.bigM=0; OPTIONS.inftol=1.0e-10; OPTIONS.cc=0; OPTIONS.steptol=1.0e-2; OPTIONS.mu0=-1; OPTIONS.logtime=0; OPTIONS.xmaker=0; OPTIONS.dloginfo=0; OPTIONS.dynamicrho=1; DSDP5.8/matlab/dstat.m0000644000175000017500000000510310326241002014523 0ustar twernertwerner%***************************************************************************** % DSDP5: Dual-Scaling Algorithm for Positive Semidefinite Programming % Copyright (c) 2004 by % S. J. Benson, Y. Ye % Last modified: 20 August 2004 %***************************************************************************** % % > [STAT,y] = DSDP() returns a structure STAT with relevant information % concerning the performance of the solver and an approximate % dual solution y . % % The fields of STAT are: % % Objective Value: % stype = 'PDFeasible' if an feasible primal and dual solutions % were computed, 'Infeasible' if dual % infeasibility was detected, and 'Unbounded' if primal % infeasibility is detected. % obj = objective value at solution % pobj = an approximately optimal objective value to (P) % dobj = an approximately optimal objective value to (D) % stopcode = 0: convergence to prescribed accuracy, % ~0: termination for other reasons % % Characteristics of Solution % tracex = if X was returned, this is the trace of it. This number % also corresponds to the minimum penalty parameter that % could solve this problem. IMPORTANT: For improved % performance, consider using penalty parameter (see DOPTIONS) % other than the default. % penalty = the penalty parameter used by the solver, which must be % greater than the trace of the primal solution (see above). % errors = several error estimates to the solution. (See DERROR) % ynorm = the largest element of y (infinity norm). % boundy = the bounds placed on the magnitude of each variable y. % mu = final barrier parameter. % r = the multiple of the identity matrix added to % C-A'(y) in the final solution to make S positive definite. % That is, S = C - A'y + r*I. % xy, xdy, xmu = values used to compute X. % % Solver Statistics % iterates = number of iterations used by the algorithm. % pstep = final primal step size. % dstep = final dual step size. % pnorm = final norm of distance to central path. % gaphist = a history of the duality gap. % infhist = a history of the dual infeasibility. % datanorm = the Frobenius norm of C, A and b, % % See also: DSDP % % DSDP5 % Copyright (c) 2004 by % S. Benson and Y. Ye % Last modified: October 2004 %***************************************************************************** DSDP5.8/matlab/control.m0000644000175000017500000000476510326241002015101 0ustar twernertwerner%%****************************************************** %% control: a SDP problem from control theory. %% %% (D) max t %% s.t Bk'*P + P*Bk <= 0, k = 1:L %% P <= I, %% P >= t*I, P = P'. %% %%------------------------------------------------------ %% %% [objval,P] = control(B), %% %% where B{k} = Bk, k = 1:L. %% %% For example, B1 = [-0.2 2.2 0.5; %% -2.3 -1.0 2.5; %% -2.1 1.2 -3.0]; %% %% B2 = [-1.5 0.6 2.2; %% -1.2 -2.1 3.3; %% 1.9 -3.2 2.9]; %% %% DSDP: version 5.6 %% Copyright (c) 2005 by %% S.J. Benson, Y. Ye %% Last modified: 2 Feb 05 %%****************************************************** function [objval,P] = control(B); if ~iscell(B); error('B must be a cell array such that B{k} = Bk'); end; L = length(B); N = length(B{1}); nn=N*(N+1)/2; b = [zeros(nn,1); 1]; AC = cell(L+2,3); for l = 1:L+2 AC{l,1} = 'SDP'; AC{l,2} = N; AC{l,3}=sparse(nn,nn+2); end; AC{L+1,3}(:,nn+2)=dvec(speye(N)); AC{L+2,3}(:,nn+1)=dvec(speye(N)); for l = 1:L count = 1; for k = 1:N for j = k:N G = B{l}; ak = [G(k,:)']; aj = [G(j,:)']; col1 = [j*ones(N,1)]; col2 = [k*ones(N,1)]; row = [1:N]'; if j ~= k; tmp = sparse([row; row],[col1; col2],[ak; aj],N,N); elseif (j == k); tmp = sparse(row,col1,ak,N,N); end; AC{l,3}(:,count)=dvec(tmp + tmp'); count = count+1; end; end; end; count = 1; for k = 1:N for j = k:N ak = [zeros(k-1,1); 0.5 ;zeros(N-k,1)]; aj = [zeros(j-1,1); 0.5 ;zeros(N-j,1)]; col1 = [j*ones(N,1)]; col2 = [k*ones(N,1)]; row = [1:N]'; if j ~= k; tmp1 = sparse([row; row],[col1; col2],[ak; aj],N,N); tmp2 = sparse([row; row],[col1; col2],-[ak; aj],N,N); elseif (j == k); tmp1 = sparse(row,col1,ak,N,N); tmp2 = sparse(row,col1,-ak,N,N); end; AC{L+1,3}(:,count) = dvec(tmp1 + tmp1'); AC{L+2,3}(:,count) = dvec(tmp2 + tmp2'); count = count+1; end; end; [STAT,y,X]=dsdp(b,AC); P=dmat(y(1:nn)); objval=dot(b,y); %%====================================================== DSDP5.8/matlab/etp.m0000644000175000017500000000305710326241002014202 0ustar twernertwerner%%*********************************************************** %% etp: Education testing problem. %% %% (D) maximize e'*d %% subject to B - diag(d) >= 0 %% d >= 0 %% %% (P) minimize Tr B*X %% subject to X >= 0 %% diag(X) >= e %% %% Ref: M.T. Chu, J.W. Wright, IMA J. of Numerical Anal., %% 15 (1995), pp. 141--160. %%----------------------------------------------------------- %% [objval,d] = etp(B); %% %% B = nxn positive definite. %% %% DSDP5.6: version 5.6 %% Copyright (c) 2005 by %% S.J. Benson, Y. Ye %% Last modified: 2 Feb 05 %%*********************************************************** function [objval,d] = etp(B); if (~isreal(B)) error('only real B allowed'); elseif (norm(B-B','fro') > 1e-13); error(' B must be symmetric'); end; %% %% validate B %% n = length(B); d = eig(B); d = real(d); if (min(d) < 0); error('B must be positive def'); end; %% %% AC = cell(2,3); AC{1,1}='SDP'; AC{1,2}=n; AC{1,3}=sparse(n*(n+1)/2,n+1); AC{2,1}='LP'; AC{2,2}=n; AC{2,3}=sparse(n,n+1); AC{1,3}(:,n+1)=dvec(B); b = ones(n,1); A = cell(2,n); for k = 1:n AC{1,3}(:,k) = dsparse(k,k,1,n,n); AC{2,3}(:,k) = [zeros(k-1,1); -1; zeros(n-k,1)]; end; y0 = 0.9*min(d)*ones(n,1); OPTIONS=doptions; % OPTIONS.r0=0; OPTIONS.zbar=100*n; OPTIONS.print=5; [STAT,y,X] = dsdp(b,AC,OPTIONS,y0); [pobj,objval,err]=derror(STAT,y,X,b,AC); d = y; %%=========================================================== DSDP5.8/matlab/readsedumifile.m0000644000175000017500000000374610326241002016401 0ustar twernertwerner%%******************************************************************* %% Read in a problem in SeDuMi format and convert to DSDP format %% %% [AC,b] = readsedumifile(fname) %% %% Input: fname.mat = name of the file containing SDP data in %% SeDuMi format. %% %% Input: AC = DSDP formatted block structure and constraint data %% b = Dual objective vector %% %% DSDP: version 5.0 %% Copyright (c) 2004 by %% S. Benson Y. Ye %% Last modified: 12 Jan 04 %%****************************************************************** function [AC,b]=readsedumifile(fname); %% %% First, load the matlab file containing At, c, b, and K %% K.q = []; K.l = []; A = 0; At = 0; compressed = 0; if exist([fname,'.mat.gz']); compressed = 1; unix(['gunzip ', fname,'.mat.gz']); elseif exist([fname,'.gz']); compressed = 2; unix(['gunzip ', fname,'.gz']); elseif exist([fname,'.mat.Z']); compressed = 3; unix(['uncompress ', fname,'.mat.Z']); elseif exist([fname,'.Z']); compressed = 4; unix(['uncompress ', fname,'.Z']); end if exist([fname,'.mat']) | exist(fname) eval(['load ', fname]); else error('** Problem not found, please specify the correct path.'); end if (compressed == 1) unix(['gzip ', fname,'.mat']); elseif (compressed == 2) unix(['gzip ', fname]); elseif (compressed == 3) unix(['compress ', fname,'.mat']); elseif (compressed == 4) unix(['compress ', fname]); end %% if (size(c,1) == 1), c = c'; end; if (size(b,1) == 1), b = b'; end; if (At == 0), At = A'; end; clear A; [nn,mm] = size(At); if (max(size(c)) == 1); c = c*ones(nn,1); end; if ~isfield(K,'l'); K.l = 0; end if ~isfield(K,'q'); K.q = 0; end if ~isfield(K,'s'); K.s = 0; end if K.l == 0 | isempty(K.l); K.l = 0; end; if sum(K.q) == 0 | isempty(K.q); K.q = 0; end if sum(K.s) == 0 | isempty(K.s); K.s = 0; end %% %% %% %% Then convert formats [AC b]=readsedumi(At,b,c,K); return; DSDP5.8/matlab/gpp.m0000644000175000017500000000245310326241002014177 0ustar twernertwerner%%******************************************************* %% gpp: graph partitioning problem. %% %% (P) minimize Tr C*X %% subject to diag(X) = e; %% Tr (ee'*X) = gamma %% %% C = -(diag(B*e)-B)/4. %% %% (D) maximize e'*y + gamma*t %% subject to diag(y) + t*ee' + S = C. %%------------------------------------------------------- %% %% [X,y,objval] = maxcut(B,gamma); %% %% B: weighted adjacency matrix of a graph. %% %% DSDP5.0 %% Copyright (c) 2004 by %% S. Benson, Y. Ye %% Last modified: Jan 2004 %%******************************************************* function [X,y,objval] = gpp(B,gamma); if ~isreal(B); error('only real B allowed'); end; n = length(B); e = ones(n,1); CC = -(spdiags(B*e,0,n,n)-B)/4.0; b = [e; gamma]; AC = cell(1,3); AC{1,1}='SDP'; AC{1,2}=n; nn=n*(n+1)/2; AAC=sparse(nn,n); for k = 1:n; AAC(:,k) = dsparse(k,k,1,n,n); end; AAC=[AAC dvec(ones(n)) dvec(CC)]; AC{1,3}=AAC; y0 = -1.1*abs(CC)*e; y0=[y0; 0]; OPTIONS=doptions; OPTIONS.gaptol=0.0001; OPTIONS.r0=0; OPTIONS.print=5; OPTIONS.rho=5; [STAT,y,Xv] = dsdp(b,AC,OPTIONS,y0); [objval,dobj,err] = derror(STAT,y,Xv,b,AC); X=dmat(Xv{1}); return; %%======================================================= DSDP5.8/matlab/randdinf.m0000644000175000017500000000454510326241002015202 0ustar twernertwerner%%******************************************************************* %% randdinfsdp.m : creates random dual infeasible SDP problems with %% various block diagonal structures. %% %% [X,y] = randdinfsdp(blocksize,m); %% %% E.g. %% randdinfsdp([[10 5],10); %% %% blocksize : for generating dense blocks, where %% blocksize(i) is the dimension of the ith block %% %% DSDP Version 5.6 %% Copyright (c) 2005 by %% S.J. Benson and Y. Ye %% Last modified: 4 Feb 05 %%****************************************************************** function [X,y] = randinf(blocksize,m); if nargin < 2; error(' insufficient number of inputs '); end; P=length(blocksize); AC=cell(P,3); for k = 1:P n=blocksize(k); AC{k,1}='SDP'; AC{k,2}=n; AC{k,3}=sparse(n*(n+1)/2,m+1); end; %% dual infeasible %% %% generate infeasibility certificate Xi, positive definite X0, and C %% Xi = []; X0 = []; trXX=0; for k = 1:P; n = blocksize(k); tmp = randn(n); tmp = tmp*tmp'; tmp = 0.5*(tmp + tmp'); %mineig = min(real(eig(tmp))); %if (mineig < 0); tmp = tmp - 1.1*mineig*eye(n); end; Xi{k} = tmp; trXX=trXX+sum(sum(tmp.*tmp)); tmp = randn(n); tmp = tmp*tmp'; tmp = 0.5*(tmp + tmp'); %mineig = min(real(eig(tmp))); %if (mineig < 0); tmp = tmp - 1.1*mineig*eye(n); end; X0{k} = tmp; tmp = randn(n); tmp = 0.5*(tmp + tmp'); AC{k,3}(:,m+1)=dvec(tmp); end; %% %% set up the matrices A and b %% A = cell(1,m); b = ones(m,1); for k = 1:m; trAx=0;bb=0; for j = 1:P; n = blocksize(j); Aj = randn(n); Ak = (Aj + Aj')/2; trAx = trAx + sum(sum(Ak .* Xi{j})); Ak=Ak - trAx/trXX*Xi{j}; Ak=(Ak+Ak')/2; AC{j,3}(:,k)=dvec(Ak); bb=bb+ sum(sum(Ak .* X0{j})); end; b(k) = bb; end; % if (trCX>0) for j=1,P, A{j,3}(:,m+1)=-A{j,3}(:,m+1); end; %% %% Xi is a dual infeasibility certificate %% %% OPTIONS=doptions; OPTIONS.print=1; [STAT,y,Xv] = dsdp(b,AC,OPTIONS); [pobj,dobj,err] = derror(STAT,y,Xv,b,AC); %%================================================= DSDP5.8/matlab/thetaproblem.m0000644000175000017500000000242710326241002016100 0ustar twernertwerner%%******************************************************* %% theta: Lovasz theta number. %% %% (P) min Tr C*X %% s.t. X(i,j) = 0 if (i,j) is an edge of G, %% Tr(X) = 1. %% b = e1, %% C = -ones(n), %% A1 = eye(n), Ak = ei*ej' + ej*ei', if (i,j) is an edge. %%------------------------------------------------------- %% %% [objval,X] = theta(G); %% %% G: adjacency matrix of a graph. %% %% DSDP: version 5.6 %% Copyright (c) 2005 by %% S.J. Benson and Y. Ye %% Last modified: 3 Feb 05 %%******************************************************* function [objval,X] = thetaproblem(G); if ~isreal(G); error('only real G allowed'); end; n = length(G); nn=n*(n+1)/2; [idx,idy]=find(triu(G,1)); nedges=length(idx); b = [1 zeros(1,nedges)]'; AC=cell(1,3); AC{1,1} = 'SDP'; AC{1,2} = n; AC{1,3} = sparse(nn,nedges+2); AC{1,3}(:,1) = dvec(speye(n)); AC{1,3}(:,nedges+2) = -ones(nn,1); for k = 1:nedges AC{1,3}(:,k+1) = dsparse([idx(k)],[idy(k)],[1],n,n); end; y0 = -2*n*b; OPTIONS=doptions; OPTIONS.print=5; OPTIONS.r0 = 0; [STAT,y,Xv] = dsdp(b,AC,OPTIONS,y0); objval = dot(b,y); X=dmat(Xv{1}); %%======================================================= DSDP5.8/matlab/dsparse.m0000644000175000017500000000404510326241002015051 0ustar twernertwerner%%******************************************************************* %% Create a column vector representing a symmetric matrix. %% %% V = DSPARSE(i,j,s,m,n) uses the same arguments as SPARSE(i,j,s,m,n) %% %% However, this routine assumes the matrix will be symmetric, so %% that n must equal m. The rows of [i,j,s] to generate an %% n-by-n sparse matrix with space allocated for length(s) nonzeros. The %% two integer index vectors, i and j, and the real entries %% vector, s, all have the same length, which is the number of %% nonzeros in the resulting sparse matrix S . When duplicate values %% for a matrix element are provided, that last one will be used. %% %% Output: V = column vector representing half of a symmetric matrix. %% A matrix with n rows and columns, implies V is a column %% vector with n*(n+1)/2 rows. This column vector is in %% the format used by DSDP for symmetric data matrices. %% %% Given the nonzero elements (i,j,s) that are on or above the diagonal, %% this routine could be defined as: V = dvec( sparse(i,j,s,n,n) ); %% %% See also: DVEC %% %% DSDP5.6 %% Copyright (c) 2005 by %% S. Benson and Y. Ye %% Last modified: December 2005 %%****************************************************************** function [V]=dsparse(irow,jcol,nz,n1,n2); if (n1~=n2) error('Matrix not square.'); end; if (size(jcol,1)~=size(irow,1)) error('Number of Row indices do not equal the number of column indices.'); end; if (size(jcol,2)~=size(irow,2)) error('Number of Row indices do not equal the number of column indices.'); end; if (size(jcol,1)~=size(nz,1)) error('Number of Row indices do not equal the number of nonzeros.'); end; if (size(jcol,2)~=size(nz,2)) error('Number of Row indices do not equal the number of nonzeros'); end; nn=n1*(n1+1)/2; nnz=length(nz); V=sparse(nn,1); idx=zeros(nnz,1); %% idx=(irow .* irow - irow)/2 + jcol for k=1:nnz, ii=irow(k); jj=jcol(k); if (jj>ii) tt=ii;ii=jj;jj=tt; end; kk=ii*(ii-1)/2+jj; idx(k)=kk; end; V(idx)=nz; DSDP5.8/matlab/Contents0000644000175000017500000000403510326241002014751 0ustar twernertwerner% DSDP5.6 % Copyright (c) 2005 by % S. Benson and Y. Ye % Last modified: Jan 30 2005 %***************************************************************************** This directory should contain: --------- DSDP Matlab file -------- i.e. dsdp.dll, dsdp.mexglx, dsdp.mexsol, ... --------- DSDP tests -------------------- check.m -- a script to test whether the solver is working properly check.out -- output of the check.m script generated by the developers --------- DSDP Help files --------------- dsdp.m -- help file for DSDP5 solver dvec.m -- converts a symmetric matrix into the column vector format used by the DSDP solver dmat.m -- converts a symmetric matrix in the vector representation used by DSDP to a square format. doptions.m -- sets several DSDP options to the default dstat.m -- help file for the statistics structure returned by DSDP dadotx.m -- computes the inner product of a solution with the data in column vector format. derror.m -- computes six different error measures associated with the SDP and a solution -------- Examples ------------------- maxcut.m -- generate a SDP relation of the maximum-cut problems and solve it using DSDP gpp.m -- generate a SDP relaxation of the graph partitioning problem and solve it using DSDP etp.m -- generate an educational testing problem and solve it using DSDP thetaproblem.m -- generate a theta problem and solve it using DSDP. control.m -- generate a model from predictive model control and solve it using DSDP. ----------- Data files ---------------- arch0.dat-s -- data file in SDPA format. control1.dat-s -- data file in SDPA format. ---------------- Data conversion utilities -------------------- readsdpa.m -- read a file in SDPA format and put the data into DSDP5 format. dsdp2.m -- converts data from DSDP2 format to DSDP5 format dsdp4.m -- converts data from DSDP4 format to DSDP5 format readsdpt3.m -- convert data from SDPT3 format into DSDP5 format readsedumifile.m -- read a file in SeDuMi format and convert it into DSDP5 format readsedumi.m -- convert data in SeDuMi format into DSDP5 format DSDP5.8/Readme0000644000175000017500000000153410326241002013112 0ustar twernertwerner% The matlab subdirectory contains examples and help files. % To compile DSDP: 1. Edit 'make.include' to define the DSDPROOT variable. Set it equal to the location of the DSDP5.x directory (usually here). Additional variables, such as compiler flags and the location of a BLAS and LAPACK libraries, may also have to be modified. 2. Compile the solver and examples. Test them. > make all; 3. (Optional) Test Matlab function if it compiled from within Matlab. Go the matlab directory and type: > check; Compare the output to the file check.out Further HTML (Doxygen) documentation of the C language API for DSDP can be found by unzipping the file docs/DSDP5-api-html.zip. Please notify the authors of DSDP of your experiences with it. Your feedback helps us promote our research and futher improve the package. DSDP5.8/Makefile0000644000175000017500000000144410326241002013432 0ustar twernertwerner default: make all D1 = src D2 = examples D3 = matlab D4 = bin include make.include dsdplibrary: chkroot info cd ${D1}; make all ${RANLIB} ${DSDPLIB} example: cd ${D2}; make most test: cd ${D4}; make all dmatlab: cd ${D2}; make dsdp dsdpmatlab: dsdplibrary make dmatlab dsdpapi: dsdplibrary make example make test; install: make dsdplibrary make example make test make dmatlab all: make install clean: cd ${D1}; make clean cd ${D2}; make clean cd ${D4}; make clean ${RM} lib/lib* matlab/dsdp.mex* ${RM} *~ */*~ */*/*~ htmlzip: zip -r DSDP5-api-html.zip dox ${RM} -R dox oshared: -@${RM} tmp; \ mkdir tmp; \ cd tmp; \ echo "building ${DSDPLIBSO}"; \ ${AR} x ${DSDPLIB} ;\ ${SH_LD} ${DSDPLIBSO} *.o -o ${DSDPLIBSO}; \ cd ../ ; \ ${RM} tmp DSDP5.8/dsdp-license0000644000175000017500000000454110326241002014270 0ustar twernertwernerCOPYRIGHT NOTIFICATION (C) COPYRIGHT 2004 UNIVERSITY OF CHICAGO This program discloses material protectable under copyright laws of the United States. Permission to copy and modify this software and its documentation is hereby granted, provided that this notice is retained thereon and on all copies or modifications. The University of Chicago makes no representations as to the suitability and operability of this software for any purpose. It is provided "as is"; without express or implied warranty. Permission is hereby granted to use, reproduce, prepare derivative works, and to redistribute to others, so long as this original copyright notice is retained. Any publication resulting from research that made use of this software should cite this document. This software was authored by: Steven J. Benson Mathematics and Computer Science Division Argonne National Laboratory Argonne IL 60439 Yinyu Ye Department of Management Science and Engineering Stanford University Stanford, CA U.S.A Any questions or comments on the software may be directed to benson@mcs.anl.gov or yinyu-ye@stanford.edu Argonne National Laboratory with facilities in the states of Illinois and Idaho, is owned by The United States Government, and operated by the University of Chicago under provision of a contract with the Department of Energy. DISCLAIMER THIS PROGRAM WAS PREPARED AS AN ACCOUNT OF WORK SPONSORED BY AN AGENCY OF THE UNITED STATES GOVERNMENT. NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. REFERENCE HEREIN TO ANY SPECIFIC COMMERCIAL PRODUCT, PROCESS, OR SERVICE BY TRADE NAME, TRADEMARK, MANUFACTURER, OR OTHERWISE, DOES NOT NECESSARILY CONSTITUTE OR IMPLY ITS ENDORSEMENT, RECOMMENDATION, OR FAVORING BY THE UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF. THE VIEW AND OPINIONS OF AUTHORS EXPRESSED HEREIN DO NOT NECESSARILY STATE OR REFLECT THOSE OF THE UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF. DSDP5.8/make.include0000644000175000017500000001036710326241002014260 0ustar twernertwerner# STEP 1: Set DSDPROOT in this file or comment out and make it an environment variable #DSDPROOT = /home/benson/dsdp/DSDP5.8 #DSDPROOT = Y:\dsdp\DSDP5.8 # LINUX and GCC USERS can probably stop here, # the defaults below should work, although fast BLAS and LAPACK recommended. # STEP 2: Set the name of the C compiler. CC = gcc #CC = cc #CC = g++ #CC = mpicc #CC = g++ # GNU C++ #CC = icc # INTEL #CC = pgcc # Portland Group #CC = ecc -KPIC #CC = cl # CYGWIN # STEP 3: Set three compiler options. # STEP 3a: Compiler Optimization. You should probably add a -On where # n is the maximum optimization allowed by your C compiler. OPTFLAGS = -O3 #OPTFLAGS = /O2 # STEP 3b: Add timing support by uncommenting one of the following lines. # no timing is completely portable, DSDP_MS_TIME for Microsoft compiler, # and DSDP_TIME for gcc and many other Linux/Unix compilers. #DSDPTIMER = NONE DSDPTIMER = DSDP_TIME #DSDPTIMER = DSDP_MS_TIME # STEP 3c: Add other compiler flags. DSDPCFLAGS = #DSDPCFLAGS = -Wall #DSDPCFLAGS = -DDSDPMATLAB # Other flags concern BLAS and LAPACK libraries -- see next step. # -DCAPSBLAS if BLAS and LAPACK routine names are capitalized. # -DNOUNDERBLAS if BLAS and LAPACK routine names have no underscore. # -D__DSDP_NONAMEMANGLING if using C++ compiler and BLAS LAPACK names should not be mangled. This should be picked up automatically. # STEP 4. Set Linker and FLAGS: Link the DSDP library to application CFLAGS = ${OPTFLAGS} -I. -I${DSDPROOT}/include ${DSDPCFLAGS} CLINKER = ${CC} ${OPTFLAGS} #CLINKER = ${CXX} ${OPTFLAGS} -static #CLINKER = link /out:dsdp5.exe #SH_LD = ${CC} -shared -W1,-soname, # STEP 5: # Location of BLAS AND LAPACK libraries. # Not needed to compile library or matlab executable # Needed to link DSDP library to the driver ( read SDPA files, maxcut example, ...) # Also include the math library and other libraries needed to link the BLAS to the C files that call them. LAPACKBLAS = -llapack -lblas -lg2c -lm #LAPACKBLAS = -L/usr/lib/ -llapack -lblas -lg2c -lm #LAPACKBLAS = -L/home/benson/ATLAS/Linux_P4SSE2/lib -llapack -lcblas -lf77blas -latlas -lg2c -lm #LAPACKBLAS = -L/sandbox/benson/ATLAS-3.6/lib/Linux_P4SSE2 -llapack -lcblas -lf77blas -latlas -lg2c -lm #LAPACKBLAS = /soft/apps/packages/lapack-3.0/lib/lapack_LINUX.a -L/soft/apps/packages/atlas-3.6.0/lib -lcblas -lf77blas -latlas -lg2c -lm # STEP 6, MATLAB MACROS - If compiling Matlab interface, check MEX flag. MEX = mex -O #MEX = C:\Matlab\bin\mex DSDPMATLABDIR = ${DSDPROOT}/matlab # Location of the DSDP library DSDPLIB = ${DSDPROOT}/lib/libdsdp.a DSDPLIBSO = ${DSDPROOT}/lib/libdsdp.so # Link drivers to the following libraries. # EXAMPLE_LIBS = ${DSDPLIB} ${LAPACKBLAS} #Directory to put the examples after compiling them. EXECDIR = ${DSDPROOT}/bin/ # STEP 7 SET Operating system commands # Other build information, archive, remove, move, copy ARCH = ar cr RANLIB = ranlib #RANLIB = echo RM = rm -f MV = mv CP = cp DD = ./ PP = ../ dsdplib: ${DSDPOBJ} ${ARCH} ${DSDPLIB} ${DSDPOBJ} ${RANLIB} ${DSDPLIB} make clean .c.o: ${CC} ${CFLAGS} ${DCFLAGS} -c $*.c info: -@echo "==========================================" -@echo " " -@echo "Compiling DSDP5" -@echo " " -@echo "For help with installation problems, please send EVERYTHING" -@echo "printed out below to the developers" -@echo "==========================================" -@echo On `date` on `hostname` -@echo Machine characteristics: `uname -a` -@echo "-----------------------------------------" -@echo "Using C compiler: ${CC}" -@echo "Using compiler options: ${CFLAGS}" -@echo "-----------------------------------------" -@echo "Current Directory: ${PWD}" -@echo "Using DSDP directory: ${DSDPROOT}" -@echo "==========================================" -@echo " " # chkroot: @if [ ${DSDPROOT}foo = foo ] ; then \ echo "*********************** ERROR **********************" ; \ echo "Set the variable DSDPROOT " ; \ echo " to the location of the DSDP5 package" ; \ echo "Either"; \ echo " edit the file 'DSDP5.x/make.include', or "; \ echo " set it as an environment variable "; \ echo "****************************************************" ; \ false; fi DSDP5.8/include/0000755000175000017500000000000010326241002013412 5ustar twernertwernerDSDP5.8/include/dsdp5.h0000644000175000017500000002142410326241002014605 0ustar twernertwerner#if !defined(__DSDP_INTERFACE_H) #define __DSDP_INTERFACE_H /*! \file dsdp5.h \brief The API to DSDP for those applications using DSDP as a subroutine library */ #include "dsdpbasictypes.h" #include "dsdpsys.h" /*! \typedef struct SDPCone_C* SDPCone; \brief The SDPCone object points to blocks of data that specify semidefinite matrix inequalities. */ /*! \typedef struct LPCone_C* LPCone; \brief The LPCone object points to blocks of data that specify linear scalar inequality constraints. */ /*! \typedef struct BCone_C* BCone; \brief The BCone object points to lower and upper bounds on the variable y in (D). */ typedef struct SDPCone_C* SDPCone; typedef struct LPCone_C* LPCone; typedef struct BCone_C* BCone; extern FILE *dsdpoutputfile; #ifdef __cplusplus extern "C" { #endif extern int DSDPCreate(int, DSDP *); extern int DSDPSetup(DSDP); extern int DSDPSolve(DSDP); extern int DSDPComputeX(DSDP); extern int DSDPComputeAndFactorS(DSDP,DSDPTruth*); extern int DSDPDestroy(DSDP); extern int DSDPCreateBCone(DSDP, BCone*); extern int BConeAllocateBounds(BCone,int); extern int BConeSetLowerBound(BCone,int, double); extern int BConeSetUpperBound(BCone,int, double); extern int BConeSetPSlackVariable(BCone,int); extern int BConeSetPSurplusVariable(BCone,int); extern int BConeScaleBarrier(BCone,double); extern int BConeView(BCone); extern int BConeSetXArray(BCone,double[], int); extern int BConeCopyX(BCone,double[],double[],int); extern int DSDPBoundDualVariables(DSDP,double, double); extern int DSDPSetYBounds(DSDP,double,double); extern int DSDPGetYBounds(DSDP,double*,double*); extern int DSDPCreateLPCone(DSDP,LPCone*); extern int LPConeSetData(LPCone,int,const int[],const int[],const double[]); extern int LPConeSetData2(LPCone,int,const int[],const int[],const double[]); extern int LPConeGetData(LPCone,int,double[],int); extern int LPConeScaleBarrier(LPCone,double); extern int LPConeGetXArray(LPCone,double*[], int*); extern int LPConeGetSArray(LPCone,double*[], int*); extern int LPConeGetDimension(LPCone,int*); extern int LPConeView(LPCone lpcone); extern int LPConeView2(LPCone lpcone); extern int LPConeCopyS(LPCone,double[],int); extern int DSDPCreateSDPCone(DSDP, int, SDPCone*); extern int SDPConeSetBlockSize(SDPCone, int, int); extern int SDPConeGetBlockSize(SDPCone, int, int*); extern int SDPConeSetStorageFormat(SDPCone, int, char); extern int SDPConeGetStorageFormat(SDPCone, int, char*); extern int SDPConeCheckStorageFormat(SDPCone, int, char); extern int SDPConeSetSparsity(SDPCone, int, int); extern int SDPConeView(SDPCone); extern int SDPConeView2(SDPCone); extern int SDPConeView3(SDPCone); extern int SDPConeSetASparseVecMat(SDPCone,int,int,int,double,int,const int[],const double[],int); extern int SDPConeSetADenseVecMat(SDPCone,int,int,int,double,double[],int); /* extern int SDPConeSetDenseMatWSparseData(SDPCone,int, int, int, double*, int*, int*); */ extern int SDPConeSetARankOneMat(SDPCone,int,int,int,double,int,const int[],const double[],int); extern int SDPConeSetConstantMat(SDPCone,int,int,int,double); extern int SDPConeSetZeroMat(SDPCone,int,int,int); extern int SDPConeSetIdentity(SDPCone,int,int,int,double); extern int SDPConeViewDataMatrix(SDPCone,int,int); extern int SDPConeMatrixView(SDPCone,int); extern int SDPConeAddASparseVecMat(SDPCone,int,int,int,double,int,const int[],const double[],int); extern int SDPConeAddADenseVecMat(SDPCone,int,int,int,double,double[],int); extern int SDPConeAddConstantMat(SDPCone,int,int,int,double); extern int SDPConeAddIdentity(SDPCone,int,int,int,double); extern int SDPConeAddARankOneMat(SDPCone,int,int,int,double,int,const int[],const double[],int); /* For backward compatibility */ extern int SDPConeAddSparseVecMat(SDPCone,int,int,int,int,const int[],const double[],int); extern int SDPConeAddDenseVecMat(SDPCone,int,int,int,double[],int); extern int SDPConeSetSparseVecMat(SDPCone,int,int,int,int,const int[],const double[],int); extern int SDPConeSetDenseVecMat(SDPCone,int,int,int,double[],int); extern int SDPConeSetXMat(SDPCone,int,int); extern int SDPConeSetXArray(SDPCone,int,int,double[], int); extern int SDPConeGetXArray(SDPCone,int,double*[],int*); extern int SDPConeRestoreXArray(SDPCone,int,double*[],int*); extern int SDPConeCheckData(SDPCone); extern int SDPConeRemoveDataMatrix(SDPCone,int,int); extern int SDPConeGetNumberOfBlocks(SDPCone, int*); extern int SDPConeComputeS(SDPCone, int, double,double[], int, double,int,double[],int); extern int SDPConeComputeX(SDPCone,int,int,double[],int); extern int SDPConeAddADotX(SDPCone,int,double,double[],int,double[],int); extern int SDPConeViewX(SDPCone,int,int,double[],int); extern int SDPConeSetLanczosIterations(SDPCone,int); extern int SDPConeScaleBarrier(SDPCone,int,double); extern int SDPConeXVMultiply(SDPCone,int,double[],double[],int); extern int SDPConeComputeXV(SDPCone,int,int*); extern int SDPConeAddXVAV(SDPCone,int,double[],int,double[],int); extern int SDPConeUseLAPACKForDualMatrix(SDPCone,int); extern int DSDPSetDualObjective(DSDP,int,double); extern int DSDPAddObjectiveConstant(DSDP,double); extern int DSDPGetDObjective(DSDP,double*); extern int DSDPGetDDObjective(DSDP,double*); extern int DSDPGetPObjective(DSDP,double*); extern int DSDPGetPPObjective(DSDP,double*); /* extern int DSDPGetDualObjective(DSDP,double*); extern int DSDPGetPrimalObjective(DSDP,double*); */ #define DSDPGetDualObjective DSDPGetDDObj #define DSDPGetPrimalObjective DSDPGetPPObj extern int DSDPGetDualityGap(DSDP,double*); extern int DSDPGetScale(DSDP,double*); extern int DSDPSetScale(DSDP,double); extern int DSDPGetPenaltyParameter(DSDP,double*); extern int DSDPGetPenalty(DSDP,double*); extern int DSDPCopyB(DSDP,double[], int); extern int DSDPSetR0(DSDP,double); extern int DSDPGetR(DSDP, double *); extern int DSDPSetRTolerance(DSDP,double); extern int DSDPGetRTolerance(DSDP,double*); extern int DSDPSetY0(DSDP,int, double); extern int DSDPGetY(DSDP, double[], int); extern int DSDPGetYMakeX(DSDP, double[], int); extern int DSDPGetDYMakeX(DSDP, double[], int); extern int DSDPGetMuMakeX(DSDP, double*); #define DSDPSetInitialBarrierParameter DSDPSetBarrierParameter #define DSDPGetInitialBarrierParameter DSDPGetBarrierParameter extern int DSDPGetBarrierParameter(DSDP, double *); extern int DSDPSetBarrierParameter(DSDP, double); extern int DSDPReuseMatrix(DSDP,int); extern int DSDPGetReuseMatrix(DSDP,int*); extern int DSDPGetDimension(DSDP, double*); extern int DSDPSetMaxIts(DSDP,int); extern int DSDPGetMaxIts(DSDP,int*); extern int DSDPSetStepTolerance(DSDP,double); extern int DSDPGetStepTolerance(DSDP,double*); extern int DSDPSetGapTolerance(DSDP,double); extern int DSDPGetGapTolerance(DSDP,double*); extern int DSDPSetPNormTolerance(DSDP,double); extern int DSDPGetPNormTolerance(DSDP,double*); extern int DSDPSetDualBound(DSDP,double); extern int DSDPGetDualBound(DSDP,double*); extern int DSDPSetPTolerance(DSDP,double); extern int DSDPGetPTolerance(DSDP,double*); extern int DSDPGetPInfeasibility(DSDP,double*); extern int DSDPSetMaxTrustRadius(DSDP,double); extern int DSDPGetMaxTrustRadius(DSDP,double*); extern int DSDPStopReason(DSDP,DSDPTerminationReason *); extern int DSDPGetSolutionType(DSDP,DSDPSolutionType*); extern int DSDPSetPotentialParameter(DSDP, double); extern int DSDPGetPotentialParameter(DSDP, double*); extern int DSDPUseDynamicRho(DSDP, int); extern int DSDPGetPotential(DSDP,double*); extern int DSDPUseLAPACKForSchur(DSDP,int); extern int DSDPGetNumberOfVariables(DSDP,int*); extern int DSDPGetFinalErrors(DSDP,double[6]); extern int DSDPGetGapHistory(DSDP, double[], int); extern int DSDPGetRHistory(DSDP, double[], int); extern int DSDPGetIts(DSDP,int *); extern int DSDPGetPnorm(DSDP, double *); extern int DSDPGetStepLengths(DSDP, double*,double*); extern int DSDPSetMonitor(DSDP, int (*)(DSDP,void*),void*); extern int DSDPSetStandardMonitor(DSDP,int); extern int DSDPSetFileMonitor(DSDP,int); extern int DSDPSetPenaltyParameter(DSDP,double); extern int DSDPUsePenalty(DSDP,int); extern int DSDPPrintLogInfo(int); extern int DSDPComputeMinimumXEigenvalue(DSDP, double*); extern int DSDPGetTraceX(DSDP dsdp, double*); extern int DSDPSetZBar(DSDP,double); extern int DSDPSetDualLowerBound(DSDP, double); extern int DSDPGetDataNorms(DSDP, double[3]); extern int DSDPGetYMaxNorm(DSDP, double*); extern int SDPConeUseFullSymmetricFormat(SDPCone, int); extern int SDPConeUsePackedFormat(SDPCone, int); extern int DSDPSetFixedVariable(DSDP,int,double); extern int DSDPSetFixedVariables(DSDP,double[],double[],double[],int); extern int DSDPGetFixedYX(DSDP,int,double*); extern int DSDPView(DSDP); extern int DSDPPrintOptions(); extern int DSDPPrintData(DSDP,SDPCone,LPCone); extern int DSDPPrintSolution(FILE*,DSDP,SDPCone, LPCone); extern int DSDPSetOptions(DSDP,char*[], int); extern int DSDPReadOptions(DSDP, char[]); extern int DSDPSetDestroyRoutine(DSDP, int (*)(void*), void*); #ifdef __cplusplus } #endif #endif DSDP5.8/include/dsdpbasictypes.h0000644000175000017500000000440010326241002016602 0ustar twernertwerner#ifndef __DSDP_BASIC_TYPES #define __DSDP_BASIC_TYPES /*! \file dsdpbasictypes.h \brief Solver, solution types, termination codes, */ /*! \typedef struct DSDP_C* DSDP; \brief An implementation of the dual-scaling algorithm for semidefinite programming. */ typedef struct DSDP_C* DSDP; /*! \typedef enum DSDPTruth \brief Boolean variables */ typedef enum { DSDP_FALSE = 0, /*!< 0*/ DSDP_TRUE = 1/*!< 1 */} DSDPTruth; /*! \typedef enum DSDPDualFactorMatrix \brief DSDP requires two instances of the data structures S. */ typedef enum { DUAL_FACTOR = 1, /*!< First instance for dual variable S */ PRIMAL_FACTOR = 2 /*!< Second instance used to compute X */ } DSDPDualFactorMatrix; typedef enum { DSDPAlways=1, DSDPNever=2, DSDPInfeasible=0} DSDPPenalty; /*! \typedef enum DSDPSolutionType \brief Formulations (P) and (D) can be feasible and bounded, feasible and unbounded, or infeasible. \sa DSDPGetSolutionType() */ typedef enum {/* converged */ DSDP_PDUNKNOWN = 0, /*!< Not sure whether (D) or (P) is feasible, check y bounds */ DSDP_PDFEASIBLE = 1, /*!< Both (D) and (P) are feasible and bounded */ DSDP_UNBOUNDED = 3, /*!< (D) is unbounded and (P) is infeasible */ DSDP_INFEASIBLE = 4 /*!< (D) in infeasible and (P) is unbounded */ } DSDPSolutionType; /*! \typedef enum DSDPTerminationReason \brief There are many reasons to terminate the solver. \sa DSDPStopReason() */ typedef enum { DSDP_CONVERGED = 1, /*!< Good news: Solution found. */ DSDP_INFEASIBLE_START = -6, /*!< The initial points y and r imply that S is not positive*/ DSDP_SMALL_STEPS = -2, /*!< Short step lengths created by numerical difficulties prevent progress */ DSDP_INDEFINITE_SCHUR_MATRIX = -8, /*!< Theoretically this matrix is positive definite */ DSDP_MAX_IT = -3, /*!< Reached maximum number of iterations */ DSDP_NUMERICAL_ERROR = -9, /*!< Another numerical error occurred. Check solution */ DSDP_UPPERBOUND = 5, /*!< Objective (DD) big enough to stop */ DSDP_USER_TERMINATION = 7, /*!< DSDP didn't stop it, did you? */ CONTINUE_ITERATING = 0 /*!< Don't Stop */ } DSDPTerminationReason; extern int DSDPSetConvergenceFlag(DSDP,DSDPTerminationReason); #endif DSDP5.8/include/dsdpsys.h0000644000175000017500000000435310326241002015261 0ustar twernertwerner#if !defined(__DSDP_KERNAL_H) #define __DSDP_KERNAL_H /*! \file dsdpsys.h \brief Error handling, printing, and profiling */ #include #include #include #include #include /* Define some macros for error checking */ #ifdef __FUNCT__ #undef __FUNCT__ #endif #define __FUNCT__ "DSDPUnknownFunction" /* #ifdef __cplusplus #define DSDPBEGINCROUTINES extern "C" { #define DSDPENDCROUTINES } #else #define DSDPBEGINCROUTINES { #define DSDPENDCROUTINES } #endif */ #ifdef __cplusplus extern "C" { #endif extern void DSDPTime(double*); extern int DSDPLogInfoAllow(int, char*); extern void DSDPError(const char*, int, const char*); extern void DSDPLogFInfo(void *vobj, int outlevel, const char message[], ...); extern int DSDPFError(void *vobj, const char *func, int linen,const char *filef, const char message[], ...); extern void DSDPMemoryLog(void); extern int DSDPEventLogBegin(int); extern int DSDPEventLogEnd(int); extern int DSDPEventLogRegister(const char*, int*); extern int DSDPEventLogInitialize(void); extern int DSDPEventLogSummary(void); extern int DSDPEventLogInitialize(void); #ifdef __cplusplus } #endif #ifndef DSDPCHKERR #define DSDPCHKERR(a) { if (a){ DSDPError(__FUNCT__,__LINE__,__FILE__); return a; } } #endif #ifdef DSDPFunctionReturn #undef DSDPFunctionReturn #endif #define DSDPFunctionReturn return #ifdef DSDPFunctionBegin #undef DSDPFunctionBegin #endif #define DSDPFunctionBegin { } #ifdef DSDPMATLAB #include "mex.h" #define DSDPPrintf mexPrintf #define DSDPErrorPrintf mexPrintf #endif #include "dsdpmem.h" #ifndef DSDPPrintf #define DSDPPrintf printf #endif #ifndef DSDPErrorPrintf #define DSDPErrorPrintf printf #endif #define DSDPLogInfo DSDPLogFInfo /*#define DSDPLogInfo if(0)DSDPLogFInfo */ #define DSDPSETERR(a,b) {DSDPFError(0,__FUNCT__,__LINE__,__FILE__,b); return (a); } #define DSDPSETERR1(a,b,c) {DSDPFError(0,__FUNCT__,__LINE__,__FILE__,b,c); return (a); } #define DSDPSETERR2(a,b,c,d) {DSDPFError(0,__FUNCT__,__LINE__,__FILE__,b,c,d); return (a); } #define DSDPSETERR3(a,b,c,d,e) {DSDPFError(0,__FUNCT__,__LINE__,__FILE__,b,c,d,e); return (a); } /* */ #define DSDPMin(a,b) ((a <= b)? (a) : (b)) #define DSDPMax(a,b) ((a >= b)? (a) : (b)) #endif DSDP5.8/include/dsdplapack.h0000644000175000017500000001466710326241002015707 0ustar twernertwerner#if !defined(DSDPLAPACK) #define DSDPLAPACK /*! \file dsdplapack.h \brief DSDP uses BLAS and LAPACK for many of its operations. */ typedef long int ffinteger; /* typedef int ffinteger; */ /* #define __DSDP_NONAMEMANGLING #undef __DSDP_NONAMEMANGLING */ #ifdef __cplusplus #define __DSDP_NONAMEMANGLING #endif #ifdef __DSDP_NONAMEMANGLING #define EXTERN_C_BEGIN extern "C" { #define EXTERN_C_END } #else #define EXTERN_C_BEGIN #define EXTERN_C_END #endif /* #define NOUNDERBLAS #define CAPSBLAS */ #ifdef NOUNDERBLAS #ifdef CAPSBLAS #define dstev DSTEV #define dpotrf DPOTRF #define dtrsm DTRSM #define dsyev DSYEV #define dpotrs DPOTRS #define daxpy DAXPY #define dgemv DGEMV #define dscal DSCAL #define dger DGER #define dsymv DSYMV #define dasum DASUM #define ddot DDOT #define dnrm2 DNRM2 #define dspmv DSPMV #define dspr DSPR #define dpptrf DPPTRF #define dpptrs DPPTRS #define dtpsv DTPSV #define dspevd DSPEVD #define dtrsv DTRSV #define dsyr DSYR #define dtrmv DTRMV #define dpotri DPOTRI #define dpptri DPPTRI #define dsyevx DSYEVX #define dsyevd DSYEVD #define dspevx DSPEVX #define dsyevr DSYEVR #define dstevr DSTEVR #endif #endif #ifndef NOUNDERBLAS #ifdef CAPSBLAS #define dstev DSTEV_ #define dpotrf DPOTRF_ #define dtrsm DTRSM_ #define dsyev DSYEV_ #define dpotrs DPOTRS_ #define daxpy DAXPY_ #define dgemv DGEMV_ #define dscal DSCAL_ #define dger DGER_ #define dsymv DSYMV_ #define ddot DDOT_ #define dnrm2 DNRM2_ #define dasum DASUM_ #define dspmv DSPMV_ #define dspr DSPR_ #define dpptrf DPPTRF_ #define dpptrs DPPTRS_ #define dtpsv DTPSV_ #define dspevd DSPEVD_ #define dtrsv DTRSV_ #define dsyr DSYR_ #define dtrmv DTRMV_ #define dpotri DPOTRI_ #define dpptri DPPTRI_ #define dsyevx DSYEVX_ #define dsyevd DSYEVD_ #define dspevx DSPEVX_ #define dsyevr DSYEVR_ #define dstevr DSTEVR_ #endif #endif #ifdef NOUNDERBLAS #ifndef CAPSBLAS #define dstev dstev #define dpotrf dpotrf #define dtrsm dtrsm #define dsyev dsyev #define dpotrs dpotrs #define daxpy daxpy #define dgemv dgemv #define dscal dscal #define dger dger #define dsymv dsymv #define dasum dasum #define ddot ddot #define dnrm2 dnrm2 #define dspmv dspmv #define dspr dspr #define dpptrf dpptrf #define dpptrs dpptrs #define dtpsv dtpsv #define dspevd dspevd #define dtrsv dtrsv #define dsyr dsyr #define dtrmv dtrmv #define dpotri dpotri #define dpptri dpptri #define dsyevx dsyevx #define dsyevd dsyevd #define dspevx dspevx #define dsyevr dsyevr #define dstevr dstevr #endif #endif #ifndef NOUNDERBLAS #ifndef CAPSBLAS #define dstev dstev_ #define dpotrf dpotrf_ #define dtrsm dtrsm_ #define dsyev dsyev_ #define dpotrs dpotrs_ #define daxpy daxpy_ #define dgemv dgemv_ #define dscal dscal_ #define dger dger_ #define dsymv dsymv_ #define dasum dasum_ #define ddot ddot_ #define dnrm2 dnrm2_ #define dspmv dspmv_ #define dspr dspr_ #define dpptrf dpptrf_ #define dpptrs dpptrs_ #define dtpsv dtpsv_ #define dspevd dspevd_ #define dtrsv dtrsv_ #define dsyr dsyr_ #define dtrmv dtrmv_ #define dpotri dpotri_ #define dpptri dpptri_ #define dsyevx dsyevx_ #define dsyevd dsyevd_ #define dspevx dspevx_ #define dsyevr dsyevr_ #define dstevr dstevr_ #endif #endif EXTERN_C_BEGIN void dpotrs(char*,ffinteger*,ffinteger*,double*,ffinteger*,double*,ffinteger*,ffinteger*); /* Cholesky Solve */ void dpotrf(char*,ffinteger*,double*,ffinteger*,ffinteger*); /* Cholesky Factor */ void dtrsm(char*,char*,char*,char*,ffinteger*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*); /* Cholesky trianglular solve */ void dsyev(char*,char*,ffinteger*,double*,ffinteger*,double*,double*,ffinteger*,ffinteger*); /* Compute eigenvalues/vectors */ void dstev(char*,ffinteger*,double*,double*,double*,ffinteger*,double*,ffinteger*); /* Compute eigenvalues/vectors */ void dgemv(char*,ffinteger*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*,double*,double*,ffinteger*); void dspmv(char*,ffinteger*,double*,double*,double*,ffinteger*,double*,double*,ffinteger*); void dspr(char*,ffinteger*,double*,double*,ffinteger*,double*); void dpptrs(char*,ffinteger*,ffinteger*,double*,double*,ffinteger*,ffinteger*); void dpptrf(char*,ffinteger*,double*,ffinteger*); void dtrsv(char*,char*,char*,ffinteger*,double*,ffinteger*,double*,ffinteger*); void dsyr(char*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*); void dtrmv(char*,char*,char*,ffinteger*,double*,ffinteger*,double*,ffinteger*); void dtpsv(char*,char*,char*,ffinteger*,double*,double*,ffinteger*); void dger(ffinteger*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*,double*,ffinteger*); void dsymv(char*,ffinteger*,double*,double*,ffinteger*,double*,ffinteger*, double*,double*,ffinteger*); void dspevd(char*,char*,ffinteger*,double*,double*,double*,ffinteger*,double*,ffinteger*,ffinteger*,ffinteger*,ffinteger*); double dasum(ffinteger*,double*,ffinteger*); void dscal(ffinteger*,double*,double*,ffinteger*); void daxpy(ffinteger*,double*,double*,ffinteger*,double*,ffinteger*); double ddot(ffinteger*,double*,ffinteger*,double*,ffinteger*); double dnrm2(ffinteger*,double*,ffinteger*); void dpotri(char*,ffinteger*,double*,ffinteger*,ffinteger*); void dpptri(char*,ffinteger*,double*,ffinteger*); void dsyevx(char*, char*, char*, ffinteger*,double*, ffinteger*, double*, double*, ffinteger*, ffinteger*, double*, ffinteger*, double *,double*, ffinteger *, double *, ffinteger*, ffinteger*, ffinteger*, ffinteger*); void dspevx(char*, char*, char*, ffinteger*,double*, double*, double*, ffinteger*, ffinteger*, double*, ffinteger*, double *,double*, ffinteger *, double *, ffinteger*, ffinteger*, ffinteger*); void dsdevx(char*, char*, char*, ffinteger*,double*, double*, double*, ffinteger*, ffinteger*, double*, ffinteger*, double *,double*, ffinteger *, double *, ffinteger*, ffinteger*, ffinteger*, ffinteger*); void dsyevr(char*, char*, char*, ffinteger*, double*, ffinteger*, double*, double*, ffinteger*, ffinteger*,double*, ffinteger*, double*, double*, ffinteger*, ffinteger*, double*, ffinteger*, ffinteger*, ffinteger*, ffinteger*); void dstevr(char*, char*, ffinteger*, double*, double*, double*, double*, ffinteger*, ffinteger*,double*, ffinteger*, double*, double*, ffinteger*, ffinteger*, double*, ffinteger*, ffinteger*, ffinteger*, ffinteger*); EXTERN_C_END #endif DSDP5.8/include/dsdpmem.h0000644000175000017500000000430010326241002015211 0ustar twernertwerner #if !defined(__DSDP_MEM_H) #define __DSDP_MEM_H /*! \file dsdpmem.h \brief Memory allocation in DSDP */ #include #include #include #include #include extern int DSDPMMalloc(const char*, size_t, void**); extern int DSDPFFree(void**); /* Define some macros for memory management */ /* #define DSDPFree(a) 0;printf("FREE: %s\n",__FUNCT__); free((*a)) #define DSDPMalloc(a,b) 0;printf("Malloc: %s\n",__FUNCT__); if (b){*(b)=malloc((a)); } */ #ifdef DSDPMATLAB #define DSDPCALLOC1(VAR,TYPE,MERR) { \ *(VAR) = (TYPE*)mxMalloc(sizeof(TYPE)); \ *MERR=0; \ if ( *(VAR)==0){*(MERR)=1;} \ else {memset(*(VAR),0,sizeof(TYPE));} } #define DSDPCALLOC2(VAR,TYPE,SIZE,MERR) { \ *MERR=0; \ *VAR=0; \ if (SIZE>0){ \ *(VAR) = (TYPE*)mxMalloc((SIZE)*sizeof(TYPE)); \ if (*(VAR)==0){ *(MERR)=1;} \ else {memset(*(VAR),0,(SIZE)*sizeof(TYPE));} \ } \ } #define DSDPFREE(VAR,MERR) {if (*(VAR)){mxFree(*(VAR));}*(VAR)=0;*(MERR)=0;} #endif /* #ifndef DSDPCALLOC1 #define DSDPCALLOC1(VAR,TYPE,MERR) { (*MERR)=DSDPMMalloc(__FUNCT__,sizeof(TYPE),(void**)(VAR));} #endif #ifndef DSDPCALLOC2 #define DSDPCALLOC2(VAR,TYPE,SIZE,MERR) { (*MERR)=DSDPMMalloc(__FUNCT__,(SIZE)*sizeof(TYPE),(void**)(VAR));} #endif #ifndef DSDPFREE #define DSDPFREE(a,b) {*(b)=DSDPFFree((void**)(a));} #endif */ #ifndef DSDPCALLOC1 #define DSDPCALLOC1(VAR,TYPE,MERR) { \ *(VAR) = (TYPE*)calloc(1, sizeof(TYPE)); \ *MERR=0; \ if ( *(VAR)==0){*(MERR)=1;} \ else { memset(*(VAR),0,sizeof(TYPE)); } \ } #endif #ifndef DSDPCALLOC2 #define DSDPCALLOC2(VAR,TYPE,SIZE,MERR) { \ *MERR=0; \ *VAR=0; \ if (SIZE>0){ \ *(VAR) = (TYPE*)calloc(SIZE, sizeof(TYPE)); \ if (*(VAR)==0){ *(MERR)=1;} \ else { memset(*(VAR),0,(SIZE)*sizeof(TYPE)); } \ } \ } #endif #ifndef DSDPFREE #define DSDPFREE(VAR,MERR) {if (*(VAR)){free(*(VAR));}*(VAR)=0;*(MERR)=0;} #endif /* #ifndef DSDPCALLOC1 #define DSDPCALLOC1(VAR,TYPE,SIZE,MERR) {*(VAR) = new TYPE;*MERR=0;} #endif #ifndef DSDPCALLOC2 #define DSDPCALLOC2(VAR,TYPE,SIZE,MERR) {*(VAR) = new TYPE[SIZE];*MERR=0;} #endif #ifndef DSDPFREE #define DSDPFREE(a,b) {delete(*(a));*(a)=0;*(b)=0;} #endif */ #endif DSDP5.8/lib/0000755000175000017500000000000010326241002012535 5ustar twernertwernerDSDP5.8/examples/0000755000175000017500000000000010326241002013605 5ustar twernertwernerDSDP5.8/examples/maxcut.c0000644000175000017500000002051610326241002015256 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include /*! \file maxcut.c \brief Most Basic Example: read graph from file, formulate the SDP relaxation of maximum cut problem, solve using DSDP, and apply randomized algorithm to generate approximate solutions. */ char help[]="\ DSDP Usage: maxcut \n\ -gaptol \n\ -maxit \n"; static int ReadGraph(char*,int *, int *,int**, int **, double **); static int TCheckArgs(DSDP,int,char **); static int ParseGraphline(char*,int*,int*,double*,int*); int MaxCutRandomized(SDPCone,int); int MaxCut(int,int, int[], int[], double[]); int main(int argc,char *argv[]){ int info; int *node1,*node2,nedges,nnodes; double *weight; if (argc<2){ printf("%s",help); return(1); } info = ReadGraph(argv[1],&nnodes,&nedges,&node1,&node2,&weight); if (info){ printf("Problem reading file\n"); return 1; } MaxCut(nnodes,nedges,node1,node2,weight); free(node1);free(node2);free(weight); return 0; } /*! \fn int MaxCut(int nnodes,int nedged, int node1[], int node2[], double weight[]); \brief Formulate and solve the SDP relaxation of the Maximum Cut problem \ingroup Examples \param nnodes number of nodes in graph \param nedges number of edges in graph \param node1 first node of each edge \param node2 second node of each edge \param weight weight of each edge \note This routine is an example! It is not part of the solver library. */ int MaxCut(int nnodes,int nedges, int node1[], int node2[], double weight[]){ int i,info; int *indd,*iptr; double *yy,*val,*diag,tval=0; DSDPTerminationReason reason; SDPCone sdpcone; DSDP dsdp; info = DSDPCreate(nnodes,&dsdp); info = DSDPCreateSDPCone(dsdp,1,&sdpcone); if (info){ printf("Out of memory\n"); return 1; } info = SDPConeSetBlockSize(sdpcone,0,nnodes); /* Formulate the problem from the data */ /* Diagonal elements equal 1.0 Create Constraint matrix A_i for i=1, ..., nnodes. that has a single nonzero element. */ diag=(double*)malloc(nnodes*sizeof(double)); iptr=(int*)malloc(nnodes*sizeof(int)); for (i=0;i=0 */ yy=(double*)malloc(nnodes*sizeof(double)); for (i=0;i0 && coltmp>0) *gotem=3; else if (temp==2 && rtmp>0 && coltmp>0){ *value = 1.0; *gotem=3;} else *gotem=0; *row=rtmp-1; *col=coltmp-1; return(0); } #undef __FUNCT__ #define __FUNCT__ "ReadGraph" int ReadGraph(char* filename,int *nnodes, int *nedges, int**n1, int ** n2, double **wght){ FILE*fp; char thisline[BUFFERSIZ]="*"; int i,k=0,line=0,nodes,edges,gotone=3; int *node1,*node2; double *weight; int info,row,col; double value; fp=fopen(filename,"r"); if (!fp){printf("Cannot open file %s !",filename);return(1);} while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } if (sscanf(thisline,"%d %d",&nodes, &edges)!=2){ printf("First line must contain the number of nodes and number of edges\n"); return 1; } node1=(int*)malloc(edges*sizeof(int)); node2=(int*)malloc(edges*sizeof(int)); weight=(double*)malloc(edges*sizeof(double)); for (i=0; i= 0 && row >= 0){ if (row=edges) { printf("To many edges in file.\nLine %d, %s\n",line,thisline); return 1; } else if (gotone&&(col >= nodes || row >= nodes || col < 0 || row < 0)){ printf("Invalid node number.\nLine %d, %s\n",line,thisline); return 1; } } *nnodes=nodes; *nedges=edges; *n1=node1; *n2=node2; *wght=weight; return 0; } DSDP5.8/examples/theta.c0000644000175000017500000003722510326241002015067 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include /*! \file theta.c \brief Read graph complement from file, formulate the Lovasz theta problem, and solve using DSDP. */ char help[]="\n\ Compute the Lovasz theta number for a graph. This number is an upper bound for \n\ the maximum clique of a graph, a lower bound for the mimimal graph coloring, and serves \n\ as a bound for several other combitorial graph problems. The number is the solution to \n\ a semidfinite program. \n\n\ The file should be the complement of the graph \n\ This file also demonstrates the use of customized data matrices in DSDP.\n\n\ DSDP Usage: theta \n"; typedef struct { int v1,v2; } EdgeMat; #include "../src/sdp/dsdpdatamat_impl.h" extern int SDPConeAddDataMatrix(SDPCone,int, int, int, char, struct DSDPDataMat_Ops*, void*); /* These variables and routines are for customized SDP Data Matrices */ static struct DSDPDataMat_Ops edgematop; static int EdgeMatOperationsInitialize(struct DSDPDataMat_Ops*); static struct DSDPDataMat_Ops onematops; static int OneMatOpsInitialize(struct DSDPDataMat_Ops*); static struct DSDPDataMat_Ops identitymatops; static int IdentitymatOperationsInitialize(struct DSDPDataMat_Ops*); static int ReadGraphFromFile(char*,int*, int*, EdgeMat*[]); int SetThetaData(DSDP, SDPCone, int, int, EdgeMat[]); int LovaszTheta(int argc,char *argv[]); int main(int argc,char *argv[]){ int info; info=LovaszTheta(argc,argv); return 0; } /*! \fn int LovaszTheta(int argc,char *argv[]); \param argc number of command line arguments \param argv command line arguments \brief Formulate and solve the Lovasz theta problem. \ingroup Examples \sa SetThetaData() */ int LovaszTheta(int argc,char *argv[]){ int info,kk,nedges,nnodes; EdgeMat *Edges; DSDP dsdp; SDPCone sdpcone; if (argc<2){ printf("%s",help); return(1); } info = ReadGraphFromFile(argv[1],&nnodes,&nedges,&Edges); if (info){ printf("Problem reading file\n"); return 1; } info = DSDPCreate(nedges+1,&dsdp); info = DSDPCreateSDPCone(dsdp,1,&sdpcone); info = SDPConeSetBlockSize(sdpcone,0,nnodes); info = SDPConeUsePackedFormat(sdpcone,0); info = SDPConeSetSparsity(sdpcone,0,nedges+1); if (info){ printf("Out of memory\n"); return 1; } info = SetThetaData(dsdp, sdpcone, nnodes, nedges, Edges); if (info){ printf("Out of memory\n"); return 1; } info = DSDPSetGapTolerance(dsdp,0.001); info = DSDPSetZBar(dsdp,nnodes+1); info = DSDPReuseMatrix(dsdp,10); for (kk=1; kk0 && coltmp>0) *gotem=3; else if (temp==2 && rtmp>0 && coltmp>0){ *value = 1.0; *gotem=3;} else *gotem=0; *row=rtmp-1; *col=coltmp-1; if (*gotem && (*col < 0 || *row < 0)){ printf("Node Number must be positive.\n, %s\n",thisline); } return(0); } #undef __FUNCT__ #define __FUNCT__ "ReadGraphFromFile" static int ReadGraphFromFile(char* filename,int *nnodes, int *nedges, EdgeMat**EE){ FILE*fp; char thisline[BUFFERSIZ]="*"; int i,k=0,line=0,nodes,edges,gotone=3; int info,row,col; double value; EdgeMat *E; fp=fopen(filename,"r"); if (!fp){ printf("Cannot open file %s !",filename); return(1); } while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } if (sscanf(thisline,"%d %d",&nodes, &edges)!=2){ printf("First line must contain the number of nodes and number of edges\n"); return 1; } E=(EdgeMat*)malloc(edges*sizeof(EdgeMat)); *EE=E; for (i=0; i= 0 && row >= 0){ if (row > col){i=row;row=col;col=i;} if (row == col){} else { E[k].v1=row; E[k].v2=col; k++;} } else if (gotone && k>=edges) { printf("To many edges in file.\nLine %d, %s\n",line,thisline); return 1; } else if (gotone&&(col >= nodes || row >= nodes || col < 0 || row < 0)){ printf("Invalid node number.\nLine %d, %s\n",line,thisline); return 1; } } *nnodes=nodes; *nedges=k; return 0; } /* SPecial Matrix where each edge represents a constraint matrix */ static int EdgeMatDestroy(void*); static int EdgeMatView(void*); static int EdgeMatVecVec(void*, double[], int, double *); static int EdgeMatDot(void*, double[], int, int, double *); static int EdgeMatGetRank(void*, int*, int); static int EdgeMatFactor(void*); static int EdgeMatGetEig(void*, int, double*, double[], int, int[], int*); static int EdgeMatAddRowMultiple(void*, int, double, double[], int); static int EdgeMatAddMultiple(void*, double, double[], int, int); static int EdgeMatGetRowNnz(void*, int, int[], int*, int); static int EdgeMatDestroy(void* AA){ return 0; } static int EdgeMatVecVec(void* A, double x[], int n, double *v){ EdgeMat*E=(EdgeMat*)A; *v=2*x[E->v1]*x[E->v2]; return 0; } static int EdgeMatDot(void* A, double x[], int nn, int n, double *v){ EdgeMat*E=(EdgeMat*)A; int k=E->v2*(E->v2+1)/2 + E->v1; *v=2*x[k]; return 0; } static int EdgeMatView(void* A){ EdgeMat*E=(EdgeMat*)A; printf(" Row: %d, Column: %d\n",E->v1,E->v2); printf(" Row: %d, Column: %d\n",E->v2,E->v1); return 0; } static int EdgeMatFactor(void* A){ return 0; } static int EdgeMatGetRank(void *A, int*rank, int n){ *rank=2; return 0; } static int EdgeMatGetEig(void*A, int neig, double *eig, double v[], int n,int spind[], int *nind){ EdgeMat*E=(EdgeMat*)A; double tt=1.0/sqrt(2.0); memset((void*)v,0,(n)*sizeof(double)); memset((void*)spind,0,(n)*sizeof(int)); if (neig==0){ v[E->v1]=tt;v[E->v2]=tt;*eig=1; spind[0]=E->v1;spind[1]=E->v2; *nind=2; } else if (neig==1){ v[E->v1]=-tt;v[E->v2]=tt;*eig=-1; spind[0]=E->v1;spind[1]=E->v2; *nind=2; } else { *eig=0;*nind=0;} return 0; } static int EdgeMatGetRowNnz(void*A, int nrow, int nz[], int *nnzz, int n){ EdgeMat*E=(EdgeMat*)A; if (nrow==E->v1){ nz[E->v2]++; *nnzz=1;} else if (nrow==E->v2){nz[E->v1]++; *nnzz=1;} else {*nnzz=0;} return 0; } static int EdgeMatAddRowMultiple(void*A, int nrow, double dd, double rrow[], int n){ EdgeMat*E=(EdgeMat*)A; if (nrow==E->v1){ rrow[E->v2]+=dd;} else if (nrow==E->v2){rrow[E->v1]+=dd;} return 0; } static int EdgeMatAddMultiple(void*A, double dd, double vv[], int nn, int n){ EdgeMat*E=(EdgeMat*)A; int k=E->v2*(E->v2+1)/2 + E->v1; vv[k]+=dd; return 0; } static int EdgeMatFNorm(void*A, int n, double *fnorm){ *fnorm=2.0; return 0; } static int EdgeMatCountNonzeros(void*A, int *nnz, int n){ *nnz=1; return 0; } static const char *datamatname="THETA EDGE MATRIX"; static int EdgeMatOperationsInitialize(struct DSDPDataMat_Ops* edgematoperator){ int info; if (edgematoperator==NULL) return 0; info=DSDPDataMatOpsInitialize(edgematoperator); if (info){ return info;} edgematoperator->matfactor1=EdgeMatFactor; edgematoperator->matgetrank=EdgeMatGetRank; edgematoperator->matgeteig=EdgeMatGetEig; edgematoperator->matvecvec=EdgeMatVecVec; edgematoperator->matrownz=EdgeMatGetRowNnz; edgematoperator->matdot=EdgeMatDot; edgematoperator->matfnorm2=EdgeMatFNorm; edgematoperator->matnnz=EdgeMatCountNonzeros; edgematoperator->mataddrowmultiple=EdgeMatAddRowMultiple; edgematoperator->mataddallmultiple=EdgeMatAddMultiple; edgematoperator->matdestroy=EdgeMatDestroy; edgematoperator->matview=EdgeMatView; edgematoperator->matname=datamatname; edgematoperator->id=25; return 0; } /* SPecial Matrix where all elements equal negative one */ static int OneMatDestroy(void*); static int OneMatView(void*); static int OneMatVecVec(void*, double[], int, double *); static int OneMatDot(void*, double[], int, int, double *); static int OneMatGetRank(void*, int*, int); static int OneMatFactor(void*); static int OneMatGetEig(void*, int, double*, double[], int, int[], int*); static int OneMatRowNnz(void*, int, int[], int*, int); static int OneMatAddRowMultiple(void*, int, double, double[], int); static int OneMatAddMultiple(void*, double, double[], int,int); static int OneMatFactor(void*A){return 0;} static int OneMatGetRank(void *A, int *rank, int n){*rank=1;return 0;} static int OneMatFNorm2(void*AA, int n, double *fnorm2){*fnorm2=1.0*n*n;return 0;} static int OneMatCountNonzeros(void*AA, int *nnz, int n){*nnz=n*n;return 0;} static int OneMatDot(void* A, double x[], int nn, int n, double *v){ double dtmp=0.0; int i,j; for (i=0;imatfactor1=OneMatFactor; mat1ops->matgetrank=OneMatGetRank; mat1ops->matgeteig=OneMatGetEig; mat1ops->matvecvec=OneMatVecVec; mat1ops->matdot=OneMatDot; mat1ops->mataddrowmultiple=OneMatAddRowMultiple; mat1ops->mataddallmultiple=OneMatAddMultiple; mat1ops->matdestroy=OneMatDestroy; mat1ops->matview=OneMatView; mat1ops->matrownz=OneMatRowNnz; mat1ops->matfnorm2=OneMatFNorm2; mat1ops->matnnz=OneMatCountNonzeros; mat1ops->id=18; mat1ops->matname=mat1name; return 0; } /* Special Matrix for the Identity */ static int IdentityMatDestroy(void*); static int IdentityMatView(void*); static int IdentityMatVecVec(void*, double[], int, double *); static int IdentityMatDot(void*, double[], int, int, double *); static int IdentityMatGetRank(void*, int*,int); static int IdentityMatFactor(void*); static int IdentityMatGetEig(void*, int, double*, double[], int, int[], int*); static int IdentityMatAddRowMultiple(void*, int, double, double[], int); static int IdentityMatAddMultiple(void*, double, double[], int, int); static int IdentityMatGetRowNnz(void*, int, int[], int*, int); static int IdentityMatDestroy(void* AA){return 0;} static int IdentityMatFNorm2(void* AA, int n, double *v){*v=1.0*n;return 0;} static int IdentityMatGetRank(void *AA, int*rank, int n){*rank=n;return 0;} static int IdentityMatFactor(void*A){return 0;} static int IdentityMatCountNonzeros(void*A, int *nnz, int n){*nnz=n;return 0;} static int IdentityMatVecVec(void* AA, double x[], int n, double *v){ int i; *v=0; for (i=0;i=n){ *eig=0; return 0;} memset((void*)v,0,(n)*sizeof(double)); *eig=1.0; v[neig]=1.0; spind[0]=neig; *nind=1; return 0; } static int IdentityMatGetRowNnz(void*A, int nrow, int nz[], int *nnzz, int n){ if (nrow>=0 && nrow < n){ *nnzz=1; nz[nrow]++; } else { *nnzz=0; } return 0; } static int IdentityMatAddRowMultiple(void*A, int nrow, double dd, double rrow[], int n){ rrow[nrow] += dd;return 0; } static int IdentityMatAddMultiple(void*A, double dd, double vv[], int nn, int n){ int i; for (i=0;imatfactor1=IdentityMatFactor; imatops->matgetrank=IdentityMatGetRank; imatops->matgeteig=IdentityMatGetEig; imatops->matvecvec=IdentityMatVecVec; imatops->matrownz=IdentityMatGetRowNnz; imatops->matdot=IdentityMatDot; imatops->matfnorm2=IdentityMatFNorm2; imatops->matnnz=IdentityMatCountNonzeros; imatops->mataddrowmultiple=IdentityMatAddRowMultiple; imatops->mataddallmultiple=IdentityMatAddMultiple; imatops->matdestroy=IdentityMatDestroy; imatops->matview=IdentityMatView; imatops->id=12; imatops->matname=eyematname; return 0; } DSDP5.8/examples/dsdp.c0000644000175000017500000007447110326241002014720 0ustar twernertwerner#include "mex.h" #include "dsdp5.h" #include /* #define K_IN prhs[0] */ #define CA_IN prhs[1] #define B_IN prhs[0] #define PARS_IN prhs[2] #define Y_IN prhs[3] #define STAT_OUT plhs[0] #define Y_OUT plhs[1] #define X_OUT plhs[2] static int DSDPPrintStats2(DSDP, void*); static int CountNonzeroMatrices(double*,int,int,int,int*,int*,int*); static int CheckForConstantMat(double*,int,int); static int printlevel=10; #define CHKERR(a) { if (a){mexWarnMsgTxt("DSDP Numerical Error"); } } #define mexErrMsgTxt(a); mexPrintf("Error: "); mexWarnMsgTxt(a); return; /*! \file dsdp.c \brief Call DSDP from the Matlab environment */ /*! \fn void mexFunction(int nlhs,mxArray *plhs[],int nrhs, const mxArray *prhs[]){ \brief Call DSDP from the Matlab environment. \param nlhs is the number of output arguments \param plhs are the output arguments \param nrhs is the number of input arguments \param prhs are the input arguments \ingroup Examples \note Must be called from Matlab */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ mxArray *CA_cell_pr,*X_cell_pr; const mxArray *OPTIONS_FIELD; mxArray *STAT_FIELD; int i,j,k,ii,itmp,index,info; int *air, *ajc, *air2, *ajc2, *str,*iptr; int nvars,nb,mC,nC,m1,n1,m2,n2; int nsubs=2, subs[2]; int iscellCA; int its,reuse=4,print_info=1,printsummary=0; int ijnnz,spot,n,nn=0,nzmats,vecn; int it1,it2; int nsdpblocks=0,sdpblockj=0,sdpnmax=1,lpnmax=1,stat1=1,xmaker=0; int sspot,nsubblocks,blockj; int jj,tnnz,tnnz2; int maxit=1000,fastblas=1,rpos=0,drho=1,iloginfo=0,aggressive=0; double penalty=1e8,rho=4,zbar=1e10,cc=0,r0=-1,mu0=-1,ylow,yhigh,gaptol=1e-6,pnormtol=1e30; double maxtrust=1e30,steptol=0.01,inftol=1e-8,lpb=1.0,dbound=1e20,infptol=1e-4; double dtmp,pstep,dstep,pnorm,mu; double *blockn,datanorm[3]; double *aval,*aval2,*bval,*yout,*y0=0,*xout,*stat; double pobj,dobj,dinf; DSDP dsdp; SDPCone sdpcone=0; DSDPTerminationReason reason; DSDPSolutionType pdfeasible; LPCone lpcone=0; BCone bcone=0; char conetype[30]; int nfields=25; const char *fnames[25]={"stype","obj","pobj","dobj","stopcode","termcode","iterates","r","mu", "pstep","dstep","pnorm","gaphist","infeashist","errors", "datanorm","ynorm","boundy","penalty","tracex","reuse","rho","xy","xdy","xmu"}; if (nrhs < 2){ mexErrMsgTxt("Two input arguments required. See help for details. ");} if (nrhs > 4){ mexErrMsgTxt("Fewer input arguments required. See help for details. ");} if (nlhs < 2){ mexErrMsgTxt("Two output arguments required. See help for details. ");} if (nlhs > 3){ mexErrMsgTxt("Fewer output arguments required. See help for details. ");} if (!mxIsDouble(B_IN) || mxIsSparse(B_IN)){ mexErrMsgTxt("DSDP: 1ST input must be a dense vector of doubles"); } nvars = mxGetM(B_IN); nb = mxGetN(B_IN); if (nb > 1){ mexErrMsgTxt("DESP: 1ST input must be a column vector"); } iscellCA = mxIsCell(CA_IN); if (!iscellCA){ mexErrMsgTxt("DSDP: 2ND input must be a cell array"); } mC = mxGetM(CA_IN); nC = mxGetN(CA_IN); if (nC != 3){ mexErrMsgTxt("DSDP: dimension of 2ND cell array is p x 3");} if (nrhs >2){ if(!mxIsStruct(PARS_IN)){ mexErrMsgTxt("3RD input `OPTIONS' should be a structure."); } } if (nrhs>3){ if (!mxIsDouble(Y_IN) || mxIsSparse(Y_IN)){ mexErrMsgTxt("DSDP: 4TH input must be a dense vector of doubles"); } m1 = mxGetM(Y_IN); n1 = mxGetN(Y_IN); if (m1 != nvars || n1 != nb){ mexErrMsgTxt("DSDP: dimensions of 1ST and 4TH input not compatible");} y0=mxGetPr(Y_IN); if (!y0){ mexErrMsgTxt("DSDP: Cannot read 4TH argument");} } else y0=0; /* Check data */ for (j=0; j2){ if (X_OUT != NULL) mxDestroyArray(X_OUT) ; X_OUT = mxCreateCellMatrix(mC,1); } if (Y_OUT != NULL) mxDestroyArray(Y_OUT) ; Y_OUT = mxCreateDoubleMatrix(nvars, 1, mxREAL) ; /* Create the Solver */ info = DSDPCreate(nvars,&dsdp); CHKERR(info); info = DSDPCreateSDPCone(dsdp,nsdpblocks,&sdpcone); CHKERR(info); /* Set Dual Objective Vector */ bval=mxGetPr(B_IN); if (!bval){ mexErrMsgTxt("DSDP: Problems with 1ST argument");} for (i=0;i2){ subs[0] = j; subs[1] = 0; index = mxCalcSingleSubscript(X_OUT,nsubs,subs); X_cell_pr = mxCreateDoubleMatrix(tnnz,1,mxREAL); mxSetCell(X_OUT,index,X_cell_pr); xout=mxGetPr(X_cell_pr); if (tnnz>0 && !xout){ mexErrMsgTxt("DSDP: Cannot create array. Out of Memory");} } for (ii=0; ii<=nvars; ii++){ /* Begin Variable matrix constraints */ i=ii+1; if (i==nvars+1) i=0; tnnz=0; spot=ajc[ii]; blockj=sdpblockj; for (jj=0;jj2){info=SDPConeSetXArray(sdpcone,blockj,n,xout+tnnz,(n*n+n)/2); CHKERR(info);} info=CountNonzeroMatrices(blockn,nsubblocks,jj,nvars, air, ajc, &nzmats); CHKERR(info); info=SDPConeSetSparsity(sdpcone,blockj,nzmats); CHKERR(info); if (stat12){ subs[0] = j; subs[1] = 0; index = mxCalcSingleSubscript(X_OUT,nsubs,subs); X_cell_pr = mxCreateDoubleMatrix(nvars,1,mxREAL); mxSetCell(X_OUT,index,X_cell_pr); aval2=mxGetPr(X_cell_pr); info=BConeSetXArray(bcone,aval2,nvars); CHKERR(info); } } else if (strcmp(conetype,"LP")==0){ subs[0] = j; subs[1] = 2; index = mxCalcSingleSubscript(CA_IN,nsubs,subs); CA_cell_pr = mxGetCell(CA_IN,index); n = mxGetM(CA_cell_pr); if (lpnmax2){ subs[0] = j; subs[1] = 0; index = mxCalcSingleSubscript(X_OUT,nsubs,subs); X_cell_pr = mxCreateDoubleMatrix(n,1,mxREAL); mxSetCell(X_OUT,index,X_cell_pr); xout=mxGetPr(X_cell_pr); if (n>0 && !xout){ mexErrMsgTxt("DSDP: Cannot create array. Out of Memory");} info=LPConeSetXVec(lpcone,xout,n); CHKERR(info); } } else if (strcmp(conetype,"FIXED")==0){ int vari; subs[0] = j; subs[1] = 1; index = mxCalcSingleSubscript(CA_IN,nsubs,subs); CA_cell_pr = mxGetCell(CA_IN,index); aval=mxGetPr(CA_cell_pr); it1 = mxGetM(CA_cell_pr); it2 = mxGetN(CA_cell_pr); subs[0] = j; subs[1] = 2; index = mxCalcSingleSubscript(CA_IN,nsubs,subs); CA_cell_pr = mxGetCell(CA_IN,index); aval2=mxGetPr(CA_cell_pr); if (nlhs>2){ subs[0] = j; subs[1] = 0; index = mxCalcSingleSubscript(X_OUT,nsubs,subs); X_cell_pr = mxCreateDoubleMatrix(it1*it2,1,mxREAL); mxSetCell(X_OUT,index,X_cell_pr); xout=mxGetPr(X_cell_pr); if (it1*it2>0 && !xout){ mexErrMsgTxt("DSDP: Cannot create array. Out of Memory");} } else {xout=0;} info=DSDPSetFixedVariables(dsdp,aval,aval2,xout,it1*it2); CHKERR(info); for (i=0;i=1) reuse++; reuse=reuse*reuse; if (nvars<2000 && reuse>10) reuse=10; if (reuse>12) reuse=12; info=DSDPReuseMatrix(dsdp,reuse); CHKERR(info); info=DSDPGetPPObjective(dsdp,&zbar); CHKERR(info); info=DSDPGetR(dsdp,&r0); CHKERR(info); info=DSDPGetMaxIts(dsdp,&maxit); CHKERR(info); info=DSDPGetPenaltyParameter(dsdp,&penalty); CHKERR(info); info=DSDPGetPotentialParameter(dsdp,&rho); CHKERR(info); info=DSDPGetDualBound(dsdp,&dbound); CHKERR(info); info=DSDPGetGapTolerance(dsdp,&gaptol); CHKERR(info); info=DSDPGetRTolerance(dsdp,&inftol); CHKERR(info); info=DSDPGetBarrierParameter(dsdp,&mu0); CHKERR(info); info=DSDPGetMaxTrustRadius(dsdp,&maxtrust); CHKERR(info); info=DSDPGetStepTolerance(dsdp,&steptol); CHKERR(info); info=DSDPGetPTolerance(dsdp,&infptol); CHKERR(info); info=DSDPGetDataNorms(dsdp, datanorm); CHKERR(info); info=DSDPGetYBounds(dsdp,&ylow,&yhigh); CHKERR(info); if (datanorm[0]==0){info=DSDPSetYBounds(dsdp,-1.0,1.0);CHKERR(info);} if (nrhs >2){ if(!mxIsStruct(PARS_IN)){ mexErrMsgTxt("Fifth Parameter `OPTIONS' should be a structure.");} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"maxit") ){ maxit=(int) mxGetScalar(OPTIONS_FIELD); info=DSDPSetMaxIts(dsdp,maxit); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"fastblas") ){ fastblas= (int) mxGetScalar(OPTIONS_FIELD);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"print") ){ print_info= (int) mxGetScalar(OPTIONS_FIELD); printlevel=print_info; } if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"bigM") ){ rpos=(int)mxGetScalar(OPTIONS_FIELD); info=DSDPUsePenalty(dsdp,rpos); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"penalty") ){ penalty=mxGetScalar(OPTIONS_FIELD); info=DSDPSetPenaltyParameter(dsdp,penalty); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"rho") ){ rho= mxGetScalar(OPTIONS_FIELD); info=DSDPSetPotentialParameter(dsdp,rho); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"dynamicrho") ){ drho= (int)mxGetScalar(OPTIONS_FIELD); info=DSDPUseDynamicRho(dsdp,drho); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"zbar") ){ zbar= mxGetScalar(OPTIONS_FIELD); info=DSDPSetZBar(dsdp,zbar); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"dual_bound") ){ dbound= mxGetScalar(OPTIONS_FIELD); info=DSDPSetDualBound(dsdp,dbound); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"reuse") ){ reuse= (int)mxGetScalar(OPTIONS_FIELD); info=DSDPReuseMatrix(dsdp,reuse); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"gaptol") ){ gaptol= mxGetScalar(OPTIONS_FIELD); info=DSDPSetGapTolerance(dsdp,gaptol);CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"lp_barrier") ){ lpb= mxGetScalar(OPTIONS_FIELD); if (lpb<0.1) lpb=0.1; if (lpcone){info=LPConeScaleBarrier(lpcone,lpb); CHKERR(info);}} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"lpb") ){ lpb= mxGetScalar(OPTIONS_FIELD); if (lpb<0.1) lpb=0.1; if (lpcone){info=LPConeScaleBarrier(lpcone,lpb); CHKERR(info);}} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"cc") ){ cc= mxGetScalar(OPTIONS_FIELD); info=DSDPAddObjectiveConstant(dsdp,cc); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"inftol") ){ inftol= mxGetScalar(OPTIONS_FIELD); info=DSDPSetRTolerance(dsdp,inftol); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"infptol") ){ infptol= mxGetScalar(OPTIONS_FIELD); info=DSDPSetPTolerance(dsdp,infptol);CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"pnormtol") ){ pnormtol= mxGetScalar(OPTIONS_FIELD); info=DSDPSetPNormTolerance(dsdp,pnormtol);CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"boundy") ){ yhigh= fabs(mxGetScalar(OPTIONS_FIELD)); ylow=-yhigh; info=DSDPSetYBounds(dsdp,ylow,yhigh);CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"r0") ){ r0= mxGetScalar(OPTIONS_FIELD); info=DSDPSetR0(dsdp,r0); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"mu0") ){ mu0=mxGetScalar(OPTIONS_FIELD); info=DSDPSetBarrierParameter(dsdp,mu0);CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"maxtrustradius")){ maxtrust= mxGetScalar(OPTIONS_FIELD); info=DSDPSetMaxTrustRadius(dsdp,maxtrust); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"steptol") ){ steptol = mxGetScalar(OPTIONS_FIELD); info=DSDPSetStepTolerance(dsdp,steptol); CHKERR(info);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"dobjmin") ){ dtmp= mxGetScalar(OPTIONS_FIELD); info = DSDPSetDualLowerBound(dsdp,dtmp);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"dloginfo") ){ iloginfo= (int) mxGetScalar(OPTIONS_FIELD); info=DSDPLogInfoAllow(iloginfo,0);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"logtime") ){ printsummary= (int) mxGetScalar(OPTIONS_FIELD);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"printproblem") ){ info=DSDPPrintData(dsdp,sdpcone,lpcone);} if ( OPTIONS_FIELD = mxGetField(PARS_IN,0,"xmaker") ){ xmaker = (int) mxGetScalar(OPTIONS_FIELD);} /* if( OPTIONS_FIELD = mxGetField(PARS_IN,0,"maxlanczos") ){ itmp= (int) mxGetScalar(OPTIONS_FIELD); info=DSDPSetLanczosIterations(dsdp,itmp);} */ } info = DSDPSetMonitor(dsdp,DSDPPrintStats2,0); CHKERR(info); info = DSDPSetup(dsdp); if (info){ mexErrMsgTxt("DSDP: Setup Error, Probably out of memory");} info = DSDPSolve(dsdp); CHKERR(info); info = DSDPStopReason(dsdp,&reason); if (reason!=DSDP_INFEASIBLE_START){ info=DSDPComputeX(dsdp);CHKERR(info); } info = DSDPGetSolutionType(dsdp,&pdfeasible); CHKERR(info); if (printsummary){ DSDPEventLogSummary();} if (info){ mexErrMsgTxt("DSDP: Numerical error");} if ( reason == DSDP_INFEASIBLE_START){ mexErrMsgTxt("DSDP Terminated Due to Infeasible Starting Point\n"); } else if (print_info){ if (reason == DSDP_CONVERGED) mexPrintf("DSDP Converged. \n"); else if ( reason == DSDP_UPPERBOUND ) mexPrintf("DSDP Converged: Dual Objective exceeds its bound\n"); else if ( reason == DSDP_SMALL_STEPS ) mexPrintf("DSDP Terminated Due to Small Steps\n"); else if ( reason == DSDP_MAX_IT) mexPrintf("DSDP Terminated Due Maximum Number of Iterations\n"); else if ( reason == DSDP_USER_TERMINATION) mexPrintf("DSDP Terminated By User\n"); else if ( reason == DSDP_INFEASIBLE_START) mexPrintf("DSDP Terminated Due to Infeasible Starting Point\n"); else mexPrintf("DSDP Finished.\n"); } if (pdfeasible==DSDP_UNBOUNDED){ mexPrintf("DSDP: Dual Unbounded, Primal Infeasible\n"); } else if (pdfeasible==DSDP_INFEASIBLE){ mexPrintf("DSDP: Primal Unbounded, Dual Infeasible\n"); } /* Set the dual solution */ yout=mxGetPr(Y_OUT); info = DSDPGetY(dsdp,yout,nvars); CHKERR(info); if (info){ mexErrMsgTxt("DSDP: Numerical error");} /* Output statistics */ if (STAT_OUT != NULL) mxDestroyArray(STAT_OUT) ; subs[0] = 1; subs[1] = 1; STAT_OUT = mxCreateStructArray(2,subs,nfields,fnames); info= DSDPGetDObjective(dsdp,&dobj); CHKERR(info); info= DSDPGetPObjective(dsdp,&pobj); CHKERR(info); info= DSDPGetR(dsdp,&dinf); CHKERR(info); info= DSDPStopReason(dsdp,&reason); CHKERR(info); info= DSDPGetIts(dsdp,&its); CHKERR(info); info= DSDPGetBarrierParameter(dsdp,&mu); CHKERR(info); info= DSDPGetStepLengths(dsdp,&pstep,&dstep); CHKERR(info); info= DSDPGetPnorm(dsdp,&pnorm); CHKERR(info); info= DSDPGetBarrierParameter(dsdp,&mu); CHKERR(info); info= DSDPGetYBounds(dsdp,&ylow,&yhigh); CHKERR(info); if (pdfeasible==DSDP_UNBOUNDED){ STAT_FIELD = mxCreateString("Unbounded"); mxSetField(STAT_OUT,0,fnames[0],STAT_FIELD); } else if (pdfeasible==DSDP_INFEASIBLE){ STAT_FIELD = mxCreateString("Infeasible"); mxSetField(STAT_OUT,0,fnames[0],STAT_FIELD); } else { STAT_FIELD = mxCreateString("PDFeasible"); mxSetField(STAT_OUT,0,fnames[0],STAT_FIELD); } STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=dobj; mxSetField(STAT_OUT,0,fnames[1],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=pobj; mxSetField(STAT_OUT,0,fnames[2],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=dobj; mxSetField(STAT_OUT,0,fnames[3],STAT_FIELD); if (reason==DSDP_CONVERGED){ STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=0; mxSetField(STAT_OUT,0,fnames[4],STAT_FIELD); } else { STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=(double)reason; if (stat[0]==0) stat[0]=-1; mxSetField(STAT_OUT,0,fnames[4],STAT_FIELD); } if (reason==DSDP_CONVERGED){ /* For YALMIP */ STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=0; if (pdfeasible==DSDP_UNBOUNDED){ stat[0]=1;} if (pdfeasible==DSDP_INFEASIBLE){ stat[0]=2;} mxSetField(STAT_OUT,0,fnames[5],STAT_FIELD); } else { STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=-1; if (reason==DSDP_INFEASIBLE_START)stat[0]=-6; if (reason==DSDP_UPPERBOUND)stat[0]=-5; if (reason==DSDP_MAX_IT)stat[0]=-3; mxSetField(STAT_OUT,0,fnames[5],STAT_FIELD); } STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=(double) its; mxSetField(STAT_OUT,0,fnames[6],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=dinf; mxSetField(STAT_OUT,0,fnames[7],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=mu; mxSetField(STAT_OUT,0,fnames[8],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=pstep; mxSetField(STAT_OUT,0,fnames[9],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=dstep; mxSetField(STAT_OUT,0,fnames[10],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=pnorm; mxSetField(STAT_OUT,0,fnames[11],STAT_FIELD); itmp=100; if (its < itmp) itmp=its; STAT_FIELD = mxCreateDoubleMatrix(itmp, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info= DSDPGetGapHistory(dsdp,stat,itmp); CHKERR(info); mxSetField(STAT_OUT,0,fnames[12],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(itmp, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info= DSDPGetRHistory(dsdp,stat,itmp); CHKERR(info); mxSetField(STAT_OUT,0,fnames[13],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(6, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetFinalErrors(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[14],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(3, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetDataNorms(dsdp,stat); CHKERR(info); dtmp=stat[0];stat[0]=stat[1];stat[1]=dtmp; mxSetField(STAT_OUT,0,fnames[15],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetYMaxNorm(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[16],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); stat[0]=yhigh; mxSetField(STAT_OUT,0,fnames[17],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetPenaltyParameter(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[18],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetTraceX(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[19],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; info = DSDPGetReuseMatrix(dsdp,&its); CHKERR(info); stat=mxGetPr(STAT_FIELD); stat[0]=(double) its; mxSetField(STAT_OUT,0,fnames[20],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetPotentialParameter(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[21],STAT_FIELD); if (xmaker){ STAT_FIELD = mxCreateDoubleMatrix(nvars+1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetYMakeX(dsdp,stat,nvars+1); CHKERR(info); mxSetField(STAT_OUT,0,fnames[22],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(nvars+1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetDYMakeX(dsdp,stat,nvars+1); CHKERR(info); mxSetField(STAT_OUT,0,fnames[23],STAT_FIELD); STAT_FIELD = mxCreateDoubleMatrix(1, 1, mxREAL) ; stat=mxGetPr(STAT_FIELD); info = DSDPGetMuMakeX(dsdp,stat); CHKERR(info); mxSetField(STAT_OUT,0,fnames[24],STAT_FIELD); } /* Free internal data structure */ info = DSDPDestroy(dsdp); CHKERR(info); return; } /* main */ #undef __FUNCT__ #define __FUNCT__ "CheckForConstantMat" static int CheckForConstantMat(double*v,int nnz, int n){ int i;double vv; if (n<=1){ return 0; } if (nnz!=(n*n+n)/2){ return 0; } for (vv=v[0],i=1;i1.0e3){ mexPrintf(" %1.0e \n",pnorm); } else { mexPrintf(" %5.2f \n",pnorm); } fflush(NULL); } return(0); } DSDP5.8/examples/readsdpa.c0000644000175000017500000007376710326241002015560 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include /*! \file readsdpa.c \brief Read SDPA data files, pass data into DSDP solver, and print solution. */ static char help[]="\ DSDP Usage: dsdp5 filename \n\ -print <10> - print information at each k iteration\n\ -save \n\ -fout to print standard monitor to a file\n\ -y0 \n\ -benchmark \n\ -directory \n\ -suffix \n\ -dloginfo <0> - print more information for higher numbers \n\ -dlogsummary <1> - print timing information \n\ -help for this help message\n"; static int qusort(int[],int[],int[],double[],int,int); static int partition(int[],int[],int[],double[],int, int); static int Parseline(char *,int *,int *,int *,int *,double *, int *); static int ReadInitialPoint(char*, int, double[]); static int TCheckArgs0(DSDP,SDPCone,int,int,char *[]); static int TCheckArgs(DSDP,SDPCone,int,int,char *[]); static int CheckForConstantMat(double[],int, int); static int CountNonzeroMatrices(int, int[],int[], int*); typedef struct{ char sformat; int blocksize; } DBlock; typedef struct{ int *block,*constraint,*matind; double*nnz; char *sformat; int totalnonzeros; double *dobj,*y0; char *conetypes; int *blocksizes; int m; int n; int nblocks; int lpn,lpspot,lpblock,lpnnz; int *lpi,*lui,*cmap; double cnorm; double fixedvari; double fixedvard,xout; } DSDPData; static int ReadSDPA2(char*,DSDPData*); static int GetMarkers(int, int, int*, int*, int*); static int ComputeY0(DSDP,DSDPData); static int rank=0; int ReadSDPAFile(int argc,char *argv[]); #define CHKDATA(a,b,c) { if (c){ printf("Possible problem in variable %d, block %d. \n",a+1,b+1);} } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char *argv[]){ int info; info=ReadSDPAFile(argc,argv); return info; } #undef __FUNCT__ #define __FUNCT__ "ReadSDPAFile" /*! \fn int ReadSDPAFile(int argc,char *argv[]); \brief Read SDPA formatted file and solve the semidefinite program. \param argc number of command line arguments \param argv command line arguments \ingroup Examples */ int ReadSDPAFile(int argc,char *argv[]){ int i,j,m,n,np,its,info; int spot,ijnnz,nzmats,sdpnmax,sdpn,stat1,printsummary=1; int runbenchmark=0,saveit=0,justone=1,fileout=0; double t1,t2,t3,t4,t5,dd,yhigh; double derr[6],dnorm[3]; double ddobj,ppobj,scl,dpot; char problemname[100],thisline[100], filename[300],savefile[100]; char directory[100]="/home/benson/sdpexamples/sdplib/"; char outputfile[50]="",suffix[20]=".dat-s", tablename[20]="results-dsdp-5.8"; char success='s',sformat; FILE *fp1=0,*fp2=0,*fout; DSDPData dddd; DSDP dsdp; DSDPTerminationReason reason; DSDPSolutionType pdfeasible; SDPCone sdpcone=0; LPCone lpcone=0; int *ittt,sspot,ione=1; if (argc<2){ printf("%s",help); DSDPPrintOptions(); return(0); } for (i=0; i2){ fp2=fopen(tablename,"a"); for (i=1; i 0.0) dddd.y0[i]=-0.0; else dddd.y0[i]=0.0; for (i=0; i=1) its++; its=its*its; if (m<2000 && its>10) its=10; if (its>12) its=12; info=DSDPReuseMatrix(dsdp,its); DSDPFREE(&dddd.blocksizes,&info); DSDPFREE(&dddd.sformat,&info); DSDPFREE(&dddd.dobj,&info); DSDPFREE(&dddd.y0,&info); DSDPFREE(&dddd.conetypes,&info); DSDPFREE(&dddd.constraint,&info); DSDPFREE(&dddd.block,&info); info=DSDPGetDataNorms(dsdp, dnorm); if (dnorm[0]==0){ info=DSDPSetR0(dsdp,np); info=DSDPSetGapTolerance(dsdp,1e-3); info=DSDPSetYBounds(dsdp,-1.0,1.0); } else { } info = TCheckArgs0(dsdp,sdpcone,dddd.m,argc,argv); info = TCheckArgs(dsdp,sdpcone,dddd.m,argc,argv); info = DSDPSetup(dsdp); if (info){ printf("\nProblem Setting problem. Likely insufficient memory\n"); return 1;} if (0==1){info=SDPConeCheckData(sdpcone);} DSDPTime(&t4); info=DSDPGetScale(dsdp,&scl); info=DSDPGetPotentialParameter(dsdp,&dpot); info=DSDPGetReuseMatrix(dsdp,&its); if (printsummary && rank==0){ printf("DSDP Process Data: %4.3e seconds\n\n",t4-t3); printf("Data Norms: C: %4.2e, A: %4.2e, b: %4.2e\n",dnorm[0],dnorm[1],dnorm[2]); printf("Scale C: %4.2e\n\n",scl); printf("Potential Parameter: %4.2f\n",dpot); printf("Reapply Schur matrix: %d\n\n",its); } if (0==1){info=DSDPPrintData(dsdp,sdpcone,lpcone);} info = DSDPSolve(dsdp); if (info){ printf("\nNumerical errors encountered in DSDPSolve(). \n");} info=DSDPStopReason(dsdp,&reason); if (reason!=DSDP_INFEASIBLE_START){ info=DSDPComputeX(dsdp);DSDPCHKERR(info); } info=DSDPStopReason(dsdp,&reason); info=DSDPGetSolutionType(dsdp,&pdfeasible); DSDPTime(&t5); info=DSDPGetDObjective(dsdp,&ddobj); info=DSDPGetPObjective(dsdp,&ppobj); info=DSDPGetFinalErrors(dsdp,derr); info=DSDPGetIts(dsdp,&its); success='s'; if (printsummary && rank==0){ if (reason == DSDP_CONVERGED){ printf("DSDP Converged. \n"); success='s'; } else if ( reason == DSDP_UPPERBOUND ){ printf("DSDP Terminated Because Dual Objective Exceeded its Bound\n"); success='c'; } else if ( reason == DSDP_SMALL_STEPS ){ printf("DSDP Terminated Due to Small Steps\n"); success='c'; } else if ( reason == DSDP_MAX_IT){ printf("DSDP Terminated Due Maximum Number of Iterations\n"); success='c'; } else if ( reason == DSDP_INFEASIBLE_START){ printf("DSDP Terminated Due to Infeasible Starting Point\n"); success='c'; } else if ( reason == DSDP_INDEFINITE_SCHUR_MATRIX){ printf("DSDP Terminated Due to Indefinite Schur Complement\n"); success='c'; } else { printf("DSDP Finished\n"); success='c'; } if (pdfeasible == DSDP_UNBOUNDED ){ printf("DSDP Dual Unbounded, Primal Infeasible\n"); } else if ( pdfeasible == DSDP_INFEASIBLE ){ printf("DSDP Primal Unbounded, Dual Infeasible\n"); } printf("\nP Objective : %16.8e \n",ppobj); printf("DSDP Solution: %16.8e \n\n",ddobj); printf("DSDP Solve Time: %4.3e seconds\n",t5-t4); printf("DSDP Preparation and Solve Time: %4.3e seconds\n\n",t5-t3); } else { if (reason == DSDP_CONVERGED){success='s';} else {success='c';} } if (rank==0){ fp2=fopen(tablename,"a"); if (pdfeasible==DSDP_UNBOUNDED){ fprintf(fp2," %-18s & %4d & %4d & infeasible & unbounded & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else if (pdfeasible==DSDP_INFEASIBLE){ fprintf(fp2," %-18s & %4d & %4d & unbounded & infeasible & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else { fprintf(fp2," %-18s & %4d & %4d & %13.7f & %13.7f & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,-ppobj,-ddobj,derr[0],success,its,t5-t3); } fclose(fp2); } if (printsummary && rank==0){ /* info=DSDPComputeMinimumXEigenvalue(dsdp,&derr[1]); */ printf("\nP Infeasible: %8.2e \n",derr[0]); printf("D Infeasible: %8.2e \n",derr[2]); printf("Minimal P Eigenvalue: %6.2e \n",derr[1]); printf("Minimal D Eigenvalue: 0.00 \n"); printf("Relative P - D Objective values: %4.2e \n",derr[4]); printf("Relative X Dot S: %4.2e \n",derr[5]); info=DSDPGetYBounds(dsdp,&dd,&yhigh); info=DSDPGetYMaxNorm(dsdp,&dd); printf("\nMax Y: %10.8e, Bounded by %6.1e\n",dd,yhigh); info=DSDPGetTraceX(dsdp,&dd); printf("Trace X: %4.8e, ",dd); info=DSDPGetPenaltyParameter(dsdp,&dd); printf("Bounded by Penalty Parameter: %4.1e \n\n",dd); if (printsummary){ DSDPEventLogSummary();} printf("--- DSDP Finished ---\n\n"); } if (rank==0){ if (saveit){ fout=fopen(savefile,"w"); /* fprintf(fout,"** %s \n",filename); Deleted */ info= DSDPPrintSolution(fout,dsdp,sdpcone,lpcone); if (dddd.fixedvari){ sspot=dddd.nblocks+1,dd=dddd.xout; fprintf(fout,"1 %d 1 1 1.0e-11\n1 %d 2 2 1.0e-11\n",sspot,sspot); fprintf(fout,"2 %d 1 1 %12.8e\n",sspot,DSDPMax(1.0e-10,dd)); fprintf(fout,"2 %d 2 2 %12.8e\n",sspot,DSDPMax(1e-10,-dd)); } fclose(fout); } } for (i=0; ilpn=0;ddd->lpspot=0;ddd->lpblock=0;ddd->cnorm=0; /* Read block sizes */ DSDPCALLOC2(&ddd->sformat,char, (nblocks+1),&info); DSDPCALLOC2(&ddd->blocksizes,int, (nblocks+1),&info); DSDPCALLOC2(&ddd->conetypes,char, (nblocks+1),&info ); line++; for (i=0;i0) { ddd->blocksizes[i]=col; np+=col; ddd->conetypes[i]='S'; } else if (col>0){ddd->blocksizes[i]=-col; np+=-col; ddd->conetypes[i]='S'; } else if (col<0){ddd->blocksizes[i]=-col; np += -col; ddd->conetypes[i]='L';ddd->lpn=-col;ddd->lpblock=i; } else { ddd->blocksizes[i]=0; ddd->conetypes[i]='N';} if (ddd->blocksizes[i]<10){ddd->sformat[i]='U';} else {ddd->sformat[i]='P';} } else{ printf("Error block sizes, line %d",line); return(1);} } if (ddd->blocksizes[nblocks-1]==0) nblocks--; fgets(thisline,BUFFERSIZ,fp); /* Read objective vector */ DSDPCALLOC2(&ddd->y0,double,m,&info); DSDPCALLOC2(&ddd->dobj,double,m,&info); line++; for (i=0;idobj[i]=val; } fgets(thisline,BUFFERSIZ,fp); tline=line; fseek(fp,0,SEEK_SET); line=0; for (i=0;i0){ printf("Error: line %d \n%s\n",line,thisline);return 1;} if (nargs==5 && val!=0.0){ nonzero++; i1=row*(row+1)/2 + col; if (row >= ddd->blocksizes[nblk-1] || col >= ddd->blocksizes[nblk-1] ) { printf("Data Error in line: %d. Row %d or col %d > blocksize %d\n%s",line,row+1,col+1,ddd->blocksizes[nblk-1],thisline); return 1; } if (row<0 || col<0){ printf("Data Error in line: %d. Row %d or col %d <= 0 \n%s",line,row+1,col+1,thisline); return 1; } if (nmat>m || nmat<0){ printf("Data Error in line: %d. Is Var 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } if (nblk>nblocks || nblk<0){ printf("Data Error in line: %d. Is Block 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } } else if (nargs==5 && val==0.0){ } else if (nargs<5 && nargs>0){ printf("Too few numbers. \n"); printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); } } /* Allocate memory for the data */ nonzero++; DSDPCALLOC2(&ddd->matind,int,nonzero,&info); DSDPCALLOC2(&ddd->nnz,double,nonzero,&info); DSDPCALLOC2(&ddd->block,int,nonzero,&info); DSDPCALLOC2(&ddd->constraint,int,nonzero,&info); nonzero--; fseek(fp,0,SEEK_SET); line=0; for (i=0;i=nonzero && !feof(fp) ){ */ printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } if (nargs==5 && val!=0.0){ if (row>col){ printf("Warning: Line: %d Row < Column. %s \n",line,thisline); } i=row;row=col;col=i; n=ddd->blocksizes[nblk-1]; if (nmat==0) {val=-val;} if (ddd->conetypes[nblk-1]=='S'){ /* if (row==col) val/=2; */ ddd->matind[k]=row*(row+1)/2 + col; if (ddd->sformat[nblk-1]=='U'){ddd->matind[k]=row*n + col;} } else { ddd->matind[k]=col; } ddd->block[k]=nblk; ddd->constraint[k]=nmat; ddd->nnz[k]=val; k++; } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } } ddd->block[k]=nblocks+1; ddd->constraint[k]=m+2; ddd->matind[k]=10000000; ddd->nnz[k]=0.0; qusort(ddd->block,ddd->constraint,ddd->matind,ddd->nnz,0,nonzero-1); for (i=0;imatind[i]==ddd->matind[i+1] && ddd->constraint[i]==ddd->constraint[i+1] && ddd->block[i]==ddd->block[i+1] ){ printf("DSDPError: Reading Input File:\n"); printf("Possible problem with data input file: Double Entry: \n"); printf(" %d %d %d %2.10e\n", ddd->constraint[i],ddd->block[i],ddd->matind[i]+1,ddd->nnz[i]); printf(" %d %d %d %2.10e\n\n", ddd->constraint[i+1],ddd->block[i+1],ddd->matind[i+1]+1,ddd->nnz[i+1]); for (k=i+1;kconstraint[k]=ddd->constraint[k+1]; ddd->block[k]=ddd->block[k+1]; ddd->matind[k]=ddd->matind[k+1];ddd->nnz[k]=ddd->nnz[k+1]; } ddd->constraint[nonzero-1]=bigint;ddd->nnz[nonzero-1]=0; nonzero--; } } ddd->fixedvari=0;ddd->fixedvard=0; if (ddd->lpblock>0){ int spot; if (ddd->blocksizes[ddd->lpblock]==2){ i=0;k=0; while (ddd->block[i]<=ddd->lpblock && iblock[i]==ddd->lpblock+1 && iconstraint[spot]==ddd->constraint[spot+1] && ddd->constraint[spot+2]==ddd->constraint[spot+3] && ddd->matind[spot]==ddd->matind[spot+2] && ddd->matind[spot+1]==ddd->matind[spot+3] && fabs(ddd->nnz[spot+2])==1.0 && fabs(ddd->nnz[spot+3])==1.0 && fabs(ddd->nnz[spot] + ddd->nnz[spot+1]) <=1e-6 ){ ddd->fixedvari=ddd->constraint[spot+2]; ddd->fixedvard=ddd->nnz[spot]/ddd->nnz[spot+2]; nblocks--;ddd->lpblock=0; } } } } ddd->totalnonzeros=nonzero; for (ddd->n=0,i=0;in += ddd->blocksizes[i]; ddd->m=m; ddd->nblocks=nblocks; fclose(fp); return 0; } #undef __FUNCT__ #define __FUNCT__ "Parseline" static int Parseline(char thisline[],int *nmat,int *nblk,int *row, int *col,double *value, int *nargs){ int temp; int rtmp,coltmp; *nargs=0; *nmat=-1;*nblk=-1;rtmp=-1;coltmp=-1;*value=0.0; temp=sscanf(thisline,"%d %d %d %d %lg",nmat,nblk,&rtmp,&coltmp,value); if (temp==5) *nargs=5; else if (temp>0 && temp<5) *nargs=temp; *row=rtmp-1; *col=coltmp-1; return(0); } static int partition(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int k=lend; int pivot1=list1[k],pivot2=list2[k],pivot3=list3[k]; double pivot5 = list5[k]; int bottom = lstart-1, top = lend; int done = 0; int ordered=1; while (!done){ while (!done) { bottom = bottom+1; if (bottom == top){ done = 1; break; } if ( list1[bottom] > pivot1 || (list1[bottom] == pivot1 && list2[bottom] > pivot2) || (list1[bottom] == pivot1 && list2[bottom] == pivot2 && list3[bottom] > pivot3) ){ list1[top] = list1[bottom]; list2[top] = list2[bottom]; list3[top] = list3[bottom]; list5[top] = list5[bottom]; ordered=0; break; } } while (!done){ top = top-1; if (top == bottom){ done = 1; break; } if ( list1[top] < pivot1 || (list1[top] == pivot1 && list2[top] < pivot2) || (list1[top] == pivot1 && list2[top] == pivot2 && list3[top] < pivot3)){ list1[bottom] = list1[top]; list2[bottom] = list2[top]; list3[bottom] = list3[top]; list5[bottom] = list5[top]; ordered=0; break; } } } list1[top] = pivot1; list2[top] = pivot2; list3[top] = pivot3; list5[top] = pivot5; ordered=0; if (bottom==lend){ ordered=1; for (k=lstart;k list1[k+1]) || (list1[k] == list1[k+1] && list2[k] > list2[k+1]) || (list1[k] == list1[k+1] && list2[k] == list2[k+1] && list3[k] > list3[k+1]) ){ ordered=0; break; } } } if (ordered && lend-lstart>2){ top=(lend+lstart)/2; } return top; } static int qusort(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int split; if (lstart < lend){ split = partition(list1, list2, list3, list5,lstart, lend); qusort(list1, list2, list3, list5, lstart, split-1); qusort(list1, list2, list3, list5, split+1, lend); } else { return 0; } return 0; } #undef __FUNCT__ #define __FUNCT__ "GetMarkers" static int GetMarkers(int block, int constraint, int blockn[], int constraintn[], int*m3){ int i=0; while (blockn[i]==block && constraintn[i]==constraint){ i++;} *m3=i; return 0; } #undef __FUNCT__ #define __FUNCT__ "CountNonzeroMatrices" static int CountNonzeroMatrices(int block, int blockn[], int constraintn[], int*m3){ int i=0,cvar=-1,nnzmats=0; while (blockn[i]==block){ if (constraintn[i]>cvar){ cvar=constraintn[i];nnzmats++;} i++; } *m3=nnzmats; return 0; } #undef __FUNCT__ #define __FUNCT__ "CheckForConstantMat" static int CheckForConstantMat(double v[],int nnz, int n){ int i; double vv; if (n<=1){ return 0; } if (nnz!=(n*n+n)/2){ return 0; } for (vv=v[0],i=1;i1) return 0; if (dddd.fixedvari) return 0; info=GetMarkers(1,0,dddd.block+spot,dddd.constraint+spot,&ijnnz); for (i=0;i #include #include #include /*! \file stable.c \brief Read graph from file, formulate the Maximum Stable Set problem, and solve using DSDP. */ char help[]="\n\ Compute the stable set for a graph. \n\n\ DSDP Usage: stable \n"; typedef struct { double v[3]; int indd[3]; } EdgeMat; static int ReadGraphFromFile(char*,int*, int*, EdgeMat*[]); int SetStableSetData(DSDP, SDPCone, int, int, EdgeMat[]); int StableSet(int argc,char *argv[]); int StableRandomized(SDPCone,int, int, EdgeMat[]); #define CHKERR(a) { if (a){printf("DSDP Numerical Error or Memory Problem"); return 2;} } int main(int argc,char *argv[]){ int info; info=StableSet(argc,argv); return 0; } /*! \fn int StableSet(int argc,char *argv[]); \param argc number of command line arguments \param argv command line arguments \brief Formulate and solve the maximum Stable Set problem. \ingroup Examples \sa SetStableSetData() */ int StableSet(int argc,char *argv[]){ int info,kk,nedges,nnodes; EdgeMat *Edges; DSDP dsdp; SDPCone sdpcone; if (argc<2){ printf("%s",help); return(1); } info = ReadGraphFromFile(argv[1],&nnodes,&nedges,&Edges); if (info){ printf("Problem reading file\n"); return 1; } info = DSDPCreate(nedges+nnodes+1,&dsdp);CHKERR(info); info = DSDPCreateSDPCone(dsdp,1,&sdpcone);CHKERR(info); info = SDPConeSetBlockSize(sdpcone,0,nnodes+1);CHKERR(info); info = SDPConeUsePackedFormat(sdpcone,0);CHKERR(info); info = SDPConeSetSparsity(sdpcone,0,nedges+nnodes+1);CHKERR(info); info = SetStableSetData(dsdp, sdpcone, nnodes, nedges, Edges); if (info){ printf("Problem setting data\n"); return 1; } info = DSDPSetGapTolerance(dsdp,0.0001);CHKERR(info); info = DSDPSetZBar(dsdp,1e10*nnodes+1);CHKERR(info); info = DSDPReuseMatrix(dsdp,10);CHKERR(info); for (kk=1; kk 0 && tt[e1]*tt[e2] >0){ if ( fabs(tt[e0]-tt[e2]) > fabs(tt[e1]-tt[e2]) ){ tt[e0]*=-1; } else { tt[e1]*=-1; } } } for (j=0;j0 && coltmp>0) *gotem=3; else if (temp==2 && rtmp>0 && coltmp>0){ *value = 1.0; *gotem=3;} else *gotem=0; *row=rtmp-1; *col=coltmp-1; if (*gotem && (*col < 0 || *row < 0)){ printf("Node Number must be positive.\n, %s\n",thisline); } return(0); } #undef __FUNCT__ #define __FUNCT__ "ReadGraphFromFile" static int ReadGraphFromFile(char* filename,int *nnodes, int *nedges, EdgeMat**EE){ FILE*fp; char thisline[BUFFERSIZ]="*"; int i,k=0,line=0,nodes,edges,gotone=3; int info,row,col; double value; EdgeMat *E; fp=fopen(filename,"r"); if (!fp){ printf("Cannot open file %s !",filename); return(1); } while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } if (sscanf(thisline,"%d %d",&nodes, &edges)!=2){ printf("First line must contain the number of nodes and number of edges\n"); return 1; } E=(EdgeMat*)malloc(edges*sizeof(EdgeMat)); *EE=E; for (i=0; i= 0 && row >= 0){ if (row > col){i=row;row=col;col=i;} if (row == col){} else { E[k].indd[0]=row; E[k].indd[1]=col; E[k].indd[2]=nodes; E[k].v[0]=1.0; E[k].v[1]=1.0; E[k].v[2]=1.0; k++; } } else if (gotone && k>=edges) { printf("To many edges in file.\nLine %d, %s\n",line,thisline); return 1; } else if (gotone&&(col >= nodes || row >= nodes || col < 0 || row < 0)){ printf("Invalid node number.\nLine %d, %s\n",line,thisline); return 1; } } *nnodes=nodes; *nedges=k; return 0; } DSDP5.8/examples/color.c0000644000175000017500000002160110326241002015067 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include /*! \file color.c \brief Second Basic Example: Read graph from file, formulate the SDP relaxation of k-coloring problem, solve using DSDP, and apply randomized algorithm to generate approximate solutions. */ char help2[]="\nA positive semidefinite relaxation of the\n\ graph k coloring problem can be rewritten as\n\n\ Find X>=0 \n\ such that X_ij <= 1 - 1/(k-1) for all edges (i,j).\n\ "; char help[]="DSDP Usage: color "; static int ReadGraph(char*,int *, int *,int**, int **, double **); static int ParseGraphline(char*,int*,int*,double*,int*); static int RandomizedColor(DSDP, SDPCone, int, int[], int[], int); int MinColoring(int argc,char *argv[]); int main(int argc,char *argv[]){ int info; info=MinColoring(argc,argv); return 0; } /*! \fn int MinColoring(int argc,char *argv[]); \param argc number of command line arguments \param argv command line arguments \ingroup Examples \brief SDP relaxation of k-coloring problem */ int MinColoring(int argc,char *argv[]){ int i,kk,vari,info; int *node1,*node2,nedges,nnodes; int *iptr1,*iptr2; double *weight,*yy1,*yy2,bb; DSDPTerminationReason reason; SDPCone sdpcone; BCone bcone; DSDP dsdp; if (argc<2){ printf("%s\n%s",help2,help); return(1); } info = ReadGraph(argv[1],&nnodes,&nedges,&node1,&node2,&weight); if (info){ printf("Problem reading file\n"); return 1; } info = DSDPCreate(nnodes+nedges,&dsdp); info = DSDPCreateSDPCone(dsdp,1,&sdpcone); info = SDPConeSetBlockSize(sdpcone,0,nnodes); info = SDPConeSetSparsity(sdpcone,0,nnodes+nedges+1); info = DSDPCreateBCone(dsdp,&bcone); if (info){ printf("Out of memory\n"); return 1; } /* Formulate the problem from the data */ /* Create data matrices */ /* Diagonal elements of X(i,i) must equal 1.0 */ iptr1=(int*)malloc(nnodes*sizeof(int)); yy1=(double*)malloc(nnodes*sizeof(double)); for (i=0;ival, d2=((orderVec*)e2)->val; if (d1d2) return (-1); return(0); } static int RemoveNode(int node, int node1[], int node2[], int *nedges){ int i,nnedges=*nedges; for (i=0;imaxdegree){nmax=i; maxdegree=iwork[i];} } return nmax; } static int First(int coloring[], int nnodes){ int i,nmax=nnodes; for (i=0;i0){ coloring++; maxvertex=First(color,nnodes); maxvertex=HighDegree(node1,node2,tnedges,degree,nnodes); cgroup[0]=maxvertex;ngsize=1; info=GetXRow(xptr,xrow,maxvertex,nnodes); for (i=0;i0 && coltmp>0) *gotem=3; else if (temp==2 && rtmp>0 && coltmp>0){ *value = 1.0; *gotem=3;} else *gotem=0; *row=rtmp-1; *col=coltmp-1; return(0); } #undef __FUNCT__ #define __FUNCT__ "ReadGraph" int ReadGraph(char* filename,int *nnodes, int *nedges, int**n1, int ** n2, double **wght){ FILE*fp; char thisline[BUFFERSIZ]="*"; int i,k=0,line=0,nodes,edges,gotone=3; int *node1,*node2; double *weight; int info,row,col; double value; fp=fopen(filename,"r"); if (!fp){printf("Cannot open file %s !",filename);return(1);} while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } if (sscanf(thisline,"%d %d",&nodes, &edges)!=2){ printf("First line must contain the number of nodes and number of edges\n"); return 1; } node1=(int*)malloc(edges*sizeof(int)); node2=(int*)malloc(edges*sizeof(int)); weight=(double*)malloc(edges*sizeof(double)); for (i=0; i= 0 && row >= 0){ if (row=edges) { printf("To many edges in file.\nLine %d, %s\n",line,thisline); return 1; } else if (gotone&&(col >= nodes || row >= nodes || col < 0 || row < 0)){ printf("Invalid node number.\nLine %d, %s\n",line,thisline); return 1; } } *nnodes=nodes; *nedges=edges; *n1=node1; *n2=node2; *wght=weight; return 0; } DSDP5.8/examples/Contents0000644000175000017500000000161710326241002015332 0ustar twernertwerner% DSDP5 % Copyright (c) 2005 by % S. Benson and Y. Ye % Last modified: Jan 30 2005 %***************************************************************************** This directory should contain: dsdp.c -- a mex function that connects the DSDP solver to Matlab readsdpa.c -- a driver routine that reads SDPA formatted files and calls the DSDP solver maxcut.c -- reads a graph, formulates the SDP relaxation of the maximum cut problem, calls the DSDP solver, and applies a randomized algorithm for integer solutions. theta.c -- reads a graph, formulates the Lovasz theta problem, defines several new matrix structures that are convenient and efficient, and calls the DSDP solver. color.c -- reads a graph, formulates an SDP relaxation of the k-coloring problem that includes SDP cones and a LP Bounds Cone, and calls the DSDP solver. DSDP5.8/pdsdp/0000755000175000017500000000000010326241002013101 5ustar twernertwernerDSDP5.8/pdsdp/PLAPPACK/0000755000175000017500000000000010326241002014274 5ustar twernertwernerDSDP5.8/pdsdp/PLAPPACK/Makefile0000644000175000017500000000135410326241002015737 0ustar twernertwerner PLAPACK_ROOT = /home/benson/soft/PLAPACKR30 default: all include ../../make.include include ${PLAPACK_ROOT}/Make.include LINKER = mpicc DCFLAGS = -I${DSDPROOT}/include -I${DSDPROOT}/ OBJS = readsdpa.o pdsdpplapack.o LIBLAPACK = /usr/lib/liblapack.a -lblas -lg2c -lm dsdpsdpa: ${OBJS} ${LINKER} -o pdsdp5 ${OBJS} ${DSDPLIB} ${PLAPACKLIB} ${LIBLAPACK} ${RM} ${OBJS} info2: -@echo "======================================================" -@echo "Compiling PDSDP using PLAPACK parallel linear solver." -@echo " Check ../../make.include to set compiler." -@echo " the mpicc compiler may produce faster DSDP libraries" -@echo "======================================================" clean: ${RM} ${OBJS} all: info info2 dsdpsdpa DSDP5.8/pdsdp/PLAPPACK/pdsdpplapack.c0000644000175000017500000003452010326241002017112 0ustar twernertwerner#include "pdsdp5plapack.h" #include "src/solver/dsdpschurmat_impl.h" static int printtimes=0; static int printmore=0; static void PPDSDPPrintTime(int rank, char* label, double itertime, double cumtime){ if (printtimes==0) return; if (rank==0){ printf(" %10s: This iteration: %4.4e, Cumulative Time %4.4e \n",label,itertime,cumtime); } return; } static void PPDSDPPrint(char *label, double dd){ int rank; if (printmore==0) return; MPI_Comm_rank(MPI_COMM_WORLD,&rank); if (rank==0){ printf(" %d: %s %4.4e\n",rank,label,dd); } return; } #include static void wallclock(double * ttime) { /* Linux/Unix */ static struct timeval _tp; gettimeofday(&_tp,(struct timezone *)0); (*ttime)=((double)_tp.tv_sec)+(1.0e-6)*(_tp.tv_usec); } /* PDSDP simply provides a different implementation of the Schur operations. */ typedef struct { MPI_Comm mpi_comm, plapack_comm; PLA_Obj AMat, vVec, wVec; PLA_Obj one,zero,dxerror; PLA_Template templ; int global_size; int nb_distr; int rank,nprocs; int rowrank,numrownodes; int colrank,numcolnodes; double ratio; double t0,t1,t2,thessian,tsolve; DSDP dsdp; } plapackM; static struct DSDPSchurMat_Ops plapackdsdpops; static int DSDPPlapackOpsInit(struct DSDPSchurMat_Ops*); extern int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*,void*); #undef __FUNCT__ #define __FUNCT__ "PDSDPUsePLAPACKLinearSolver" int PDSDPUsePLAPACKLinearSolver(DSDP dsdp, MPI_Comm comm, double ratio, int nb_distr){ int info; plapackM* ctx; DSDPFunctionBegin; DSDPCALLOC1(&ctx,plapackM,&info);DSDPCHKERR(info); info=DSDPPlapackOpsInit(&plapackdsdpops);DSDPCHKERR(info); info=DSDPSetSchurMatOps(dsdp,&plapackdsdpops,(void*)ctx);DSDPCHKERR(info); ctx->dsdp=dsdp; ctx->ratio=ratio; ctx->nb_distr=nb_distr; ctx->mpi_comm=comm; ctx->AMat=NULL; ctx->vVec=NULL; ctx->wVec=NULL; ctx->zero=NULL; ctx->one=NULL; ctx->dxerror=NULL; ctx->templ=NULL; DSDPFunctionReturn(0); } static int onrow(plapackM* ctx,int row){ int block,it1,it2,it3; block=ctx->nb_distr; it1= row / block; /* Which block */ it2= (it1) % ctx->numcolnodes; /* Which colrank does this block belong to */ it3= (row%block) + block*(it1 / ctx->numcolnodes) ; /* Of all col */ if (it2 == ctx->colrank && it3%ctx->numrownodes == ctx->rowrank ){ return 1; } return 0; } #undef __FUNCT__ #define __FUNCT__ "pmatsetup" int pmatsetup(void *MM, int m){ plapackM* ctx=(plapackM*)MM; MPI_Comm rowcomm,colcomm; int itmp,nprocs,info; DSDPFunctionBegin; ctx->global_size=m; info = MPI_Comm_size(ctx->mpi_comm,&nprocs); DSDPCHKERR(info); itmp=(m-nprocs+1)/nprocs; itmp=DSDPMax(2,itmp); ctx->nb_distr=DSDPMin(ctx->nb_distr,itmp); info = PLA_Comm_1D_to_2D_ratio(ctx->mpi_comm,ctx->ratio,&ctx->plapack_comm); DSDPCHKERR(info); info = PLA_Init(ctx->plapack_comm); DSDPCHKERR(info); info = PLA_Temp_create(ctx->nb_distr, 0, &ctx->templ); DSDPCHKERR(info); info=PLA_Matrix_create(MPI_DOUBLE, m, m, ctx->templ, PLA_ALIGN_FIRST, PLA_ALIGN_FIRST, &ctx->AMat);DSDPCHKERR(info); info=PLA_Mvector_create(MPI_DOUBLE, m, 1, ctx->templ, PLA_ALIGN_FIRST, &ctx->vVec);DSDPCHKERR(info); info=PLA_Mvector_create(MPI_DOUBLE, m, 1, ctx->templ, PLA_ALIGN_FIRST, &ctx->wVec);DSDPCHKERR(info); info=PLA_Mscalar_create( MPI_DOUBLE, PLA_ALL_ROWS, PLA_ALL_COLS, 1, 1, ctx->templ, &ctx->dxerror );DSDPCHKERR(info); info=PLA_Mscalar_create( MPI_DOUBLE, PLA_ALL_ROWS, PLA_ALL_COLS, 1, 1, ctx->templ, &ctx->one );DSDPCHKERR(info); info=PLA_Mscalar_create( MPI_DOUBLE, PLA_ALL_ROWS, PLA_ALL_COLS, 1, 1, ctx->templ, &ctx->zero );DSDPCHKERR(info); info=PLA_Obj_set_to_one(ctx->one);DSDPCHKERR(info); info=PLA_Obj_set_to_zero(ctx->zero);DSDPCHKERR(info); info = MPI_Comm_rank(ctx->plapack_comm,&ctx->rank); DSDPCHKERR(info); info = MPI_Comm_size(ctx->plapack_comm,&ctx->nprocs); DSDPCHKERR(info); info = PLA_Temp_comm_col_info(ctx->templ, &rowcomm, &ctx->rowrank, &ctx->numrownodes); DSDPCHKERR(info); info = PLA_Temp_comm_row_info(ctx->templ, &colcomm, &ctx->colrank, &ctx->numcolnodes); DSDPCHKERR(info); ctx->t0=0;ctx->t1=0;ctx->t2=0; ctx->thessian=0;ctx->tsolve=0; wallclock(&ctx->t0); DSDPFunctionReturn(0); } static int pmatzero(void*MM){ plapackM* ctx=(plapackM*)MM; DSDPFunctionBegin; wallclock(&ctx->t1); PLA_Obj_set_to_zero(ctx->AMat); PLA_API_begin(); PLA_Obj_API_open(ctx->AMat); DSDPFunctionReturn(0); } static int pmatonprocessor( void* MM,int row ,int*yesorno){ plapackM* ctx=(plapackM*)MM; if (onrow(ctx,row)){ *yesorno=1; } else { *yesorno=0; } return 0; } static int pmatlocalvariables( void* MM,double vars[] ,int m){ plapackM* ctx=(plapackM*)MM; int row; for (row=0;rownprocs; int i,info; DSDPFunctionBegin; info=PLA_Obj_set_to_zero(ctx->vVec);DSDPCHKERR(info); info=PLA_Obj_set_to_zero(ctx->wVec);DSDPCHKERR(info); info=PLA_API_begin();DSDPCHKERR(info); info=PLA_Obj_API_open(ctx->vVec);DSDPCHKERR(info); info=PLA_API_axpy_vector_to_global(n, &d_one, x, 1, ctx->vVec, 0); DSDPCHKERR(info); /* Copy solution from PLAPACK vector to DSDPVector */ info=PLA_Obj_API_close(ctx->vVec); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); PLA_Symv( PLA_LOWER_TRIANGULAR, ctx->one, ctx->AMat, ctx->vVec, ctx->zero, ctx->wVec ); /* Copy solution from PLAPACK vector to DSDPVector */ memset((void*)y,0,n*sizeof(double)); info=PLA_API_begin(); info=PLA_Obj_API_open(ctx->wVec); info=PLA_API_axpy_global_to_vector(n, &d_one, ctx->wVec, 0, y, 1); DSDPCHKERR(info); info=PLA_Obj_API_close(ctx->wVec); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); for (i=0;iglobal_size; double d_one=1.0,shift2; DSDPFunctionBegin; if (shift==0) return 0; info=PLA_API_begin();DSDPCHKERR(info); info=PLA_Obj_API_open(ctx->AMat);DSDPCHKERR(info); for (row=0;rowglobal_size, ctx->AMat, row, row); DSDPCHKERR(info); } } info=PLA_Obj_API_close(ctx->AMat); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int pmataddelement(void* MM,int row, double shift){ plapackM* ctx=(plapackM*)MM; int info; double d_one=1.0; DSDPFunctionBegin; if (onrow(ctx,row)){ info = PLA_API_axpy_matrix_to_global(1,1,&d_one,&shift, ctx->global_size, ctx->AMat, row, row); DSDPCHKERR(info); } DSDPFunctionReturn(0); } static int pmatadddiagonal(void*MM, double val[],int n){ plapackM* ctx=(plapackM*)MM; int row,info,m=ctx->global_size; double d_one=1.0; DSDPFunctionBegin; for (row=0;rowglobal_size, ctx->AMat, row, row); DSDPCHKERR(info); } } DSDPFunctionReturn(0); } /* Should I cache some lines before inserting them into the matrix ? */ static int pmataddline(void*MM, int row, double dd, double vals[], int m){ plapackM* ctx=(plapackM*)MM; int info; double d_one=1.0*dd; DSDPFunctionBegin; vals[row]+=1.0e-11; /* vals[row]*=dd*(1.0 + 1.0e-10); */ info = PLA_API_axpy_matrix_to_global(m-row,1,&d_one, vals+row, m, ctx->AMat, row, row); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int pmatassemble(void*MM){ plapackM* ctx=(plapackM*)MM; int info; DSDPFunctionBegin; /* info=pmatshiftdiagonal(MM,1.0e-13); */ info=PLA_Obj_API_close(ctx->AMat);DSDPCHKERR(info); info=PLA_API_end();DSDPCHKERR(info); wallclock(&ctx->t2); ctx->thessian+=ctx->t2-ctx->t1; PPDSDPPrintTime(ctx->rank,"Compute M",ctx->t2-ctx->t1,ctx->thessian); DSDPFunctionReturn(0); } static int pmatdistributed(void*MM, int*flag){ DSDPFunctionBegin; *flag=1; DSDPFunctionReturn(0); } static int pmatfactor(void*MM, int *flag){ plapackM* ctx=(plapackM*)MM; int info,dummy; double ddxerror; DSDPFunctionBegin; wallclock(&ctx->t1); info=PLA_Obj_set_to_one(ctx->wVec);DSDPCHKERR(info); info=PLA_Obj_set_to_zero(ctx->vVec);DSDPCHKERR(info); info=PLA_Symv( PLA_LOWER_TRIANGULAR, ctx->one, ctx->AMat, ctx->wVec, ctx->zero, ctx->vVec ); DSDPCHKERR(info); *flag=0; info = PLA_Chol(PLA_LOWER_TRIANGULAR, ctx->AMat); DSDPCHKERR(info); if (info!=0) { *flag=1; printf("PLAPACK WARNING: Non positive-definite Matrix M : Row: %d\n",info); } info = PLA_Trsv(PLA_LOWER_TRIANGULAR, PLA_NO_TRANSPOSE, PLA_NONUNIT_DIAG, ctx->AMat, ctx->vVec);DSDPCHKERR(info); info = PLA_Trsv(PLA_LOWER_TRIANGULAR, PLA_TRANSPOSE, PLA_NONUNIT_DIAG, ctx->AMat,ctx->vVec); DSDPCHKERR(info); info=PLA_Obj_set_to_minus_one(ctx->wVec);DSDPCHKERR(info); info=PLA_Axpy( ctx->one, ctx->vVec, ctx->wVec );DSDPCHKERR(info); info=PLA_Nrm2( ctx->wVec, ctx->dxerror );DSDPCHKERR(info); PLA_Obj_get_local_contents( ctx->dxerror, PLA_NO_TRANS, &dummy, &dummy, &ddxerror, 1, 1 ); if (ddxerror/sqrt(1.0*ctx->global_size) > 0.1){ *flag=1; if (ctx->rank==-1){ printf("PDSDPPLAPACK: Non positive-definite Matrix. %4.2e\n",ddxerror); } } wallclock(&ctx->t2); ctx->tsolve+=ctx->t2-ctx->t1; PPDSDPPrintTime(ctx->rank,"PLAPACK: Factor M",ctx->t2-ctx->t1,ctx->tsolve); PPDSDPPrintTime(ctx->rank,"Subtotal Time",0,ctx->t2-ctx->t1); DSDPFunctionReturn(0); } static int pmatreduce(void*MM,double *v, int m){ plapackM* ctx=(plapackM*)MM; double d_one=1.0; int info; int i; DSDPFunctionBegin; /* Copy vec from DSDPVector to PLAPACK vector. This assumes the entries in the local DSDP Vectors are not duplicated on multiple processors. It adds the first element of each vector together, second element, ... */ info=PLA_Obj_set_to_zero(ctx->vVec);DSDPCHKERR(info); info=PLA_API_begin();DSDPCHKERR(info); info=PLA_Obj_API_open(ctx->vVec);DSDPCHKERR(info); info=PLA_API_axpy_vector_to_global(m, &d_one, v , 1, ctx->vVec, 0); DSDPCHKERR(info); info=PLA_Obj_API_close(ctx->vVec); DSDPCHKERR(info); /* Copy solution from PLAPACK vector to DSDPVector */ memset((void*)v,0,m*sizeof(double)); info=PLA_Obj_API_open(ctx->vVec);DSDPCHKERR(info); info=PLA_API_axpy_global_to_vector(m, &d_one, ctx->vVec, 0, v, 1); DSDPCHKERR(info); info=PLA_Obj_API_close(ctx->vVec); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); DSDPFunctionReturn(0); } static int pmatsolve(void* MM, double bb[], double xx[], int n){ plapackM* ctx=(plapackM*)MM; double d_one=1.0,drank=1.0/ctx->nprocs; int i,info; DSDPFunctionBegin; wallclock(&ctx->t1); /* Copy RHS from DSDPVector to PLAPACK vector. This assumes the entries in the local DSDP Vectors are not duplicated on multiple processors. It adds the first element of each vector together, second element, ... */ info=PLA_Obj_set_to_zero(ctx->vVec);DSDPCHKERR(info); info=PLA_API_begin();DSDPCHKERR(info); info=PLA_Obj_API_open(ctx->vVec);DSDPCHKERR(info); info=PLA_API_axpy_vector_to_global(n, &d_one, bb , 1, ctx->vVec, 0); DSDPCHKERR(info); info=PLA_Obj_API_close(ctx->vVec); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); /* Assuming the matrix is already factored, solve the equations. */ info = PLA_Trsv(PLA_LOWER_TRIANGULAR, PLA_NO_TRANSPOSE, PLA_NONUNIT_DIAG, ctx->AMat, ctx->vVec);DSDPCHKERR(info); info = PLA_Trsv(PLA_LOWER_TRIANGULAR, PLA_TRANSPOSE, PLA_NONUNIT_DIAG, ctx->AMat,ctx->vVec); DSDPCHKERR(info); /* Copy solution from PLAPACK vector to DSDPVector */ memset((void*)xx,0,n*sizeof(double)); info=PLA_API_begin(); info=PLA_Obj_API_open(ctx->vVec); info=PLA_API_axpy_global_to_vector(n, &d_one, ctx->vVec, 0, xx, 1); DSDPCHKERR(info); info=PLA_Obj_API_close(ctx->vVec); DSDPCHKERR(info); info=PLA_API_end(); DSDPCHKERR(info); for (i=0;it2); ctx->tsolve+=ctx->t2-ctx->t1; /* PPDSDPPrintTime(ctx->rank,"Solve M",ctx->t2-ctx->t1,ctx->tsolve);*/ DSDPFunctionReturn(0); } static int pmatdestroy(void*MM){ plapackM* ctx=(plapackM*)MM; int info; DSDPFunctionBegin; PPDSDPPrint("PDSDP: Compute M: %5.5e \n",ctx->thessian); PPDSDPPrint("PDSDP: Solve M %4.5e seconds\n ",ctx->tsolve); info=PLA_Obj_free(&ctx->AMat); DSDPCHKERR(info); info=PLA_Obj_free(&ctx->vVec); DSDPCHKERR(info); info=PLA_Obj_free(&ctx->wVec); DSDPCHKERR(info); info=PLA_Obj_free(&ctx->one); DSDPCHKERR(info); info=PLA_Obj_free(&ctx->zero); DSDPCHKERR(info); info=PLA_Obj_free(&ctx->dxerror); DSDPCHKERR(info); info=PLA_Temp_free(&ctx->templ); DSDPCHKERR(info); info=PLA_Finalize(); DSDPCHKERR(info); DSDPFREE(&ctx,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } static const char *plapackmatname="PLAPACK matrix"; static int DSDPPlapackOpsInit(struct DSDPSchurMat_Ops* sops){ int info; if (!sops) return 0; info=DSDPSchurMatOpsInitialize(sops); DSDPCHKERR(info); sops->matzero=pmatzero; sops->matrownonzeros=pmatrowcolumns; sops->mataddrow=pmataddline; sops->matadddiagonal=pmatadddiagonal; sops->mataddelement=pmataddelement ; sops->matshiftdiagonal=pmatshiftdiagonal; sops->matassemble=pmatassemble; sops->matscaledmultiply=0; sops->matfactor=pmatfactor; sops->matsolve=pmatsolve; sops->pmatwhichdiag=0; sops->matscaledmultiply=pmatmult; sops->pmatonprocessor=pmatonprocessor; sops->pmatlocalvariables=pmatlocalvariables; sops->pmatdistributed=pmatdistributed; sops->pmatreduction=pmatreduce; sops->matsetup=pmatsetup; sops->matdestroy=pmatdestroy; sops->id=25; sops->matname=plapackmatname; return 0; } DSDP5.8/pdsdp/PLAPPACK/readsdpa.c0000644000175000017500000007323410326241002016234 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include #include "pdsdp5plapack.h" /*! \file readsdpa.c \brief Read SDPA data files, pass data into DSDP solver, and print solution. */ /* static char help[]="\n"; */ static char help[]="\ DSDP Usage: dsdp5 filename \n\ -print <10> - print information at each k iteration\n\ -save \n\ -fout to print standard monitor to a file\n\ -y0 \n\ -benchmark \n\ -directory \n\ -suffix \n\ -dloginfo <0> - print more information for higher numbers \n\ -dlogsummary <1> - print timing information \n\ -help for this help message\n"; static int qusort(int[],int[],int[],double[],int,int); static int partition(int[],int[],int[],double[],int, int); static int Parseline(char *,int *,int *,int *,int *,double *, int *); static int ReadInitialPoint(char*, int, double[]); static int TCheckArgs0(DSDP,SDPCone,int,int,char *[]); static int TCheckArgs(DSDP,SDPCone,int,int,char *[]); static int CheckForConstantMat(double[],int, int); static int CountNonzeroMatrices(int, int[],int[], int*); typedef struct{ char sformat; int blocksize; } DBlock; typedef struct{ int *block,*constraint,*matind; double*nnz; char *sformat; int totalnonzeros; double *dobj,*y0; char *conetypes; int *blocksizes; int m; int n; int nblocks; int lpn,lpspot,lpblock,lpnnz; int *lpi,*lui,*cmap; double cnorm; double fixedvari; double fixedvard,xout; } DSDPData; static int ReadSDPA2(char*,DSDPData*); static int GetMarkers(int, int, int*, int*, int*); static int ComputeY0(DSDP,DSDPData); static int rank=0; int ReadSDPAFile(int argc,char *argv[]); #define CHKDATA(a,b,c) { if (c){ printf("Possible problem in variable %d, block %d. \n",a+1,b+1);} } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char *argv[]){ int info; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&rank); DSDPSetRank(rank); info=ReadSDPAFile(argc,argv); MPI_Finalize( ); return info; } #undef __FUNCT__ #define __FUNCT__ "ReadSDPAFile" /*! \fn int ReadSDPAFile(int argc,char *argv[]); \brief Read SDPA formatted file and solve the semidefinite program. \param argc number of command line arguments \param argv command line arguments \ingroup Examples */ int ReadSDPAFile(int argc,char *argv[]){ int i,j,m,n,np,its,info; int spot,ijnnz,nzmats,sdpnmax,sdpn,stat1,printsummary=1; int runbenchmark=0,saveit=0,justone=1,fileout=0; double t1,t2,t3,t4,t5,dd,yhigh; double derr[6],dnorm[3]; double ddobj,ppobj; char problemname[100],thisline[100], filename[300],savefile[100]; char directory[100]="/home/benson/sdpexamples/sdplib/"; char outputfile[50]="",suffix[20]=".dat-s", tablename[20]="results-dsdp-5.7"; char success='f',sformat; FILE *fp1=0,*fp2=0,*fout; DSDPData dddd; DSDP dsdp; DSDPTerminationReason reason; DSDPSolutionType pdfeasible; SDPCone sdpcone=0; LPCone lpcone=0; int *ittt,sspot; if (argc<2){ printf("%s",help); DSDPPrintOptions(); return(0); } for (i=0; i 0.0) dddd.y0[i]=-0.0; else dddd.y0[i]=0.0; for (i=0; i=m && its==0) its=1; if (its>=1) its++; its=its*its; if (m<2000 && its>10) its=10; if (its>12) its=12; info=DSDPReuseMatrix(dsdp,its); DSDPFREE(&dddd.blocksizes,&info); DSDPFREE(&dddd.sformat,&info); DSDPFREE(&dddd.dobj,&info); DSDPFREE(&dddd.y0,&info); DSDPFREE(&dddd.conetypes,&info); DSDPFREE(&dddd.constraint,&info); DSDPFREE(&dddd.block,&info); info=DSDPGetDataNorms(dsdp, dnorm); if (dnorm[0]==0){ info=DSDPSetR0(dsdp,np); info=DSDPSetGapTolerance(dsdp,1e-3); info=DSDPSetYBounds(dsdp,-1.0,1.0); } else { } info = TCheckArgs0(dsdp,sdpcone,dddd.m,argc,argv); info = TCheckArgs(dsdp,sdpcone,dddd.m,argc,argv); { int nb_distr=64,psize; double ratio=1/8.0; MPI_Comm_size(MPI_COMM_WORLD,&psize); if (psize>16){ ratio=1.0/2.0;} if (m/psize< 128){ nb_distr=16;} info=PDSDPUsePLAPACKLinearSolver(dsdp,MPI_COMM_WORLD,ratio,nb_distr); if (info){return 1;} } info = DSDPSetup(dsdp); if (info){ printf("\nProblem Setting problem. Likely insufficient memory\n"); return 1;} if (0==1){info=SDPConeCheckData(sdpcone);} DSDPTime(&t4); if (rank==0){ printf("DSDP Process Data: %4.3e seconds\n\n",t4-t3); printf("Data Norms: C: %4.2e, A: %4.2e, b: %4.2e\n",dnorm[0],dnorm[1],dnorm[2]); info=DSDPGetScale(dsdp,&ddobj); printf("Scale C: %4.2e\n\n",ddobj); info=DSDPGetPotentialParameter(dsdp,&ddobj); printf("Potential Parameter: %4.2f\n",ddobj); info=DSDPGetReuseMatrix(dsdp,&its); printf("Reapply Schur matrix: %d\n\n",its); } if (0==1){info=DSDPPrintData(dsdp,sdpcone,lpcone);} info = DSDPSolve(dsdp); if (info){ printf("\nNumerical errors encountered in DSDPSolve(). \n");} info=DSDPStopReason(dsdp,&reason); if (reason!=DSDP_INFEASIBLE_START){ info=DSDPComputeX(dsdp);DSDPCHKERR(info); } info=DSDPStopReason(dsdp,&reason); info=DSDPGetSolutionType(dsdp,&pdfeasible); DSDPTime(&t5); if (rank==0){ if (reason == DSDP_CONVERGED){ printf("DSDP Converged. \n"); success='s'; } else if ( reason == DSDP_UPPERBOUND ){ printf("DSDP Terminated Because Dual Objective Exceeded its Bound\n"); success='s'; } else if ( reason == DSDP_SMALL_STEPS ){ printf("DSDP Terminated Due to Small Steps\n"); success='f'; } else if ( reason == DSDP_MAX_IT){ printf("DSDP Terminated Due Maximum Number of Iterations\n"); success='f'; } else if ( reason == DSDP_INFEASIBLE_START){ printf("DSDP Terminated Due to Infeasible Starting Point\n"); success='f'; } else if ( reason == DSDP_INDEFINITE_SCHUR_MATRIX){ printf("DSDP Terminated Due to Indefinite Schur Complement\n"); success='f'; } else { printf("DSDP Finished\n"); success='f'; } if (pdfeasible == DSDP_UNBOUNDED ){ printf("DSDP Dual Unbounded, Primal Infeasible\n"); } else if ( pdfeasible == DSDP_INFEASIBLE ){ printf("DSDP Primal Unbounded, Dual Infeasible\n"); } info=DSDPGetDObjective(dsdp,&ddobj); info=DSDPGetPObjective(dsdp,&ppobj); printf("\nP Objective : %16.8e \n",ppobj); printf("DSDP Solution: %16.8e \n\n",ddobj); printf("DSDP Solve Time: %4.3e seconds\n",t5-t4); printf("DSDP Preparation and Solve Time: %4.3e seconds\n\n",t5-t3); info=DSDPGetFinalErrors(dsdp,derr); info=DSDPGetIts(dsdp,&its); if (1 || runbenchmark){ fp2=fopen(tablename,"a"); if (pdfeasible==DSDP_UNBOUNDED){ fprintf(fp2," %-18s & %4d & %4d & infeasible & unbounded & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else if (pdfeasible==DSDP_INFEASIBLE){ fprintf(fp2," %-18s & %4d & %4d & unbounded & infeasible & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else { fprintf(fp2," %-18s & %4d & %4d & %13.7f & %13.7f & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,-ppobj,-ddobj,derr[0],success,its,t5-t3); } fclose(fp2); } /* info=DSDPComputeMinimumXEigenvalue(dsdp,&derr[1]); */ printf("\nP Infeasible: %8.2e \n",derr[0]); printf("D Infeasible: %8.2e \n",derr[2]); printf("Minimal P Eigenvalue: %6.2e \n",derr[1]); printf("Minimal D Eigenvalue: 0.00 \n"); printf("Relative P - D Objective values: %4.2e \n",derr[4]); printf("Relative X Dot S: %4.2e \n",derr[5]); info=DSDPGetYBounds(dsdp,&dd,&yhigh); info=DSDPGetYMaxNorm(dsdp,&dd); printf("\nMax Y: %10.8e, Bounded by %6.1e\n",dd,yhigh); info=DSDPGetTraceX(dsdp,&dd); printf("Trace X: %4.8e, ",dd); info=DSDPGetPenaltyParameter(dsdp,&dd); printf("Bounded by Penalty Parameter: %4.1e \n\n",dd); if (printsummary){ DSDPEventLogSummary();} printf("--- DSDP Finished ---\n\n"); if (saveit){ fout=fopen(savefile,"w"); /* fprintf(fout,"** %s \n",filename); Deleted */ info= DSDPPrintSolution(fout,dsdp,sdpcone,lpcone); if (dddd.fixedvari){ sspot=dddd.nblocks+1,dd=dddd.xout; fprintf(fout,"1 %d 1 1 1.0e-11\n1 %d 2 2 1.0e-11\n",sspot,sspot); fprintf(fout,"2 %d 1 1 %12.8e\n",sspot,DSDPMax(1.0e-10,dd)); fprintf(fout,"2 %d 2 2 %12.8e\n",sspot,DSDPMax(1e-10,-dd)); } fclose(fout); } } info = DSDPDestroy(dsdp); DSDPFREE(&dddd.matind,&info); DSDPFREE(&dddd.nnz,&info); if (fileout){fclose(dsdpoutputfile);} if (0){ DSDPMemoryLog();} } if (runbenchmark){ fclose(fp1);} return 0; } /* main */ #define BUFFERSIZ 4000 #undef __FUNCT__ #define __FUNCT__ "ReadSDPA2" static int ReadSDPA2(char *filename, DSDPData*ddd){ FILE*fp; char ctmp,refline[BUFFERSIZ]="*",thisline[BUFFERSIZ]="*"; int info,tline,line=0; int i,k,m,n; /* int spot,nzmark, */ int bigint=1000000; int i1,nblk,nmat,col,row; int np=0,nblocks; int nargs,nonzero; double val; fp=fopen(filename,"r"); if (!fp){ printf("Cannot open file %s !",filename); return(1); } /* Read comments */ while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } /* Read number of constraints */ if (sscanf(thisline,"%d",&m)<1){ printf("Error: line %d. Number of constraints not given.\n",line); return(1); } /* Read number of blocks */ fgets(thisline,BUFFERSIZ,fp); line++; if (sscanf(thisline,"%d",&nblocks)!=1){ printf("Error: line %d. Number of blocks not given.\n",line); return(1); } ddd->lpn=0;ddd->lpspot=0;ddd->lpblock=0;ddd->cnorm=0; /* Read block sizes */ DSDPCALLOC2(&ddd->sformat,char, (nblocks+1),&info); DSDPCALLOC2(&ddd->blocksizes,int, (nblocks+1),&info); DSDPCALLOC2(&ddd->conetypes,char, (nblocks+1),&info ); line++; for (i=0;i0) { ddd->blocksizes[i]=col; np+=col; ddd->conetypes[i]='S'; } else if (col>0){ddd->blocksizes[i]=-col; np+=-col; ddd->conetypes[i]='S'; } else if (col<0){ddd->blocksizes[i]=-col; np += -col; ddd->conetypes[i]='L';ddd->lpn=-col;ddd->lpblock=i; } else { ddd->blocksizes[i]=0; ddd->conetypes[i]='N';} if (ddd->blocksizes[i]<10){ddd->sformat[i]='U';} else {ddd->sformat[i]='P';} } else{ printf("Error block sizes, line %d",line); return(1);} } if (ddd->blocksizes[nblocks-1]==0) nblocks--; fgets(thisline,BUFFERSIZ,fp); /* Read objective vector */ DSDPCALLOC2(&ddd->y0,double,m,&info); DSDPCALLOC2(&ddd->dobj,double,m,&info); line++; for (i=0;idobj[i]=val; } fgets(thisline,BUFFERSIZ,fp); tline=line; nargs=5; nonzero=0; while(!feof(fp)){ thisline[0]='\0'; nmat=-1; nblk=-1; row=-1; col=-1; val=0.0; fgets(thisline,BUFFERSIZ,fp); line++; info = Parseline(thisline,&nmat,&nblk,&row,&col,&val,&nargs); if (!feof(fp)&&nargs!=5&&nargs>0){ printf("Error: line %d \n%s\n",line,thisline);return 1;} if (nargs==5 && val!=0.0){ nonzero++; i1=row*(row+1)/2 + col; if (row >= ddd->blocksizes[nblk-1] || col >= ddd->blocksizes[nblk-1] ) { printf("Data Error in line: %d. Row %d or col %d > blocksize %d\n%s",line,row+1,col+1,ddd->blocksizes[nblk-1],thisline); return 1; } if (row<0 || col<0){ printf("Data Error in line: %d. Row %d or col %d <= 0 \n%s",line,row+1,col+1,thisline); return 1; } if (nmat>m || nmat<0){ printf("Data Error in line: %d. Is Var 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } if (nblk>nblocks || nblk<0){ printf("Data Error in line: %d. Is Block 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); } } /* Allocate memory for the data */ nonzero++; DSDPCALLOC2(&ddd->matind,int,nonzero,&info); DSDPCALLOC2(&ddd->nnz,double,nonzero,&info); DSDPCALLOC2(&ddd->block,int,nonzero,&info); DSDPCALLOC2(&ddd->constraint,int,nonzero,&info); nonzero--; fseek(fp,0,SEEK_SET); line=0; for (i=0;i=nonzero && !feof(fp) ){ */ printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } if (nargs==5 && val!=0.0){ if (row>col){ printf("Warning: Line: %d Row < Column. %s \n",line,thisline); } i=row;row=col;col=i; n=ddd->blocksizes[nblk-1]; if (nmat==0) {val=-val;} if (ddd->conetypes[nblk-1]=='S'){ /* if (row==col) val/=2; */ ddd->matind[k]=row*(row+1)/2 + col; if (ddd->sformat[nblk-1]=='U'){ddd->matind[k]=row*n + col;} } else { ddd->matind[k]=col; } ddd->block[k]=nblk; ddd->constraint[k]=nmat; ddd->nnz[k]=val; k++; } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } } ddd->block[k]=nblocks+1; ddd->constraint[k]=m+2; ddd->matind[k]=10000000; ddd->nnz[k]=0.0; qusort(ddd->block,ddd->constraint,ddd->matind,ddd->nnz,0,nonzero-1); for (i=0;imatind[i]==ddd->matind[i+1] && ddd->constraint[i]==ddd->constraint[i+1] && ddd->block[i]==ddd->block[i+1] ){ printf("DSDPError: Reading Input File:\n"); printf("Possible problem with data input file: Double Entry: \n"); printf(" %d %d %d %2.10e\n", ddd->constraint[i],ddd->block[i],ddd->matind[i]+1,ddd->nnz[i]); printf(" %d %d %d %2.10e\n\n", ddd->constraint[i+1],ddd->block[i+1],ddd->matind[i+1]+1,ddd->nnz[i+1]); for (k=i+1;kconstraint[k]=ddd->constraint[k+1]; ddd->block[k]=ddd->block[k+1]; ddd->matind[k]=ddd->matind[k+1];ddd->nnz[k]=ddd->nnz[k+1]; } ddd->constraint[nonzero-1]=bigint;ddd->nnz[nonzero-1]=0; nonzero--; } } ddd->fixedvari=0;ddd->fixedvard=0; if (ddd->lpblock>0){ int spot; if (ddd->blocksizes[ddd->lpblock]==2){ i=0;k=0; while (ddd->block[i]<=ddd->lpblock && iblock[i]==ddd->lpblock+1 && iconstraint[spot]==ddd->constraint[spot+1] && ddd->constraint[spot+2]==ddd->constraint[spot+3] && ddd->matind[spot]==ddd->matind[spot+2] && ddd->matind[spot+1]==ddd->matind[spot+3] && fabs(ddd->nnz[spot+2])==1.0 && fabs(ddd->nnz[spot+3])==1.0 && fabs(ddd->nnz[spot] + ddd->nnz[spot+1]) <=1e-6 ){ ddd->fixedvari=ddd->constraint[spot+2]; ddd->fixedvard=ddd->nnz[spot]/ddd->nnz[spot+2]; nblocks--;ddd->lpblock=0; } } } } ddd->totalnonzeros=nonzero; for (ddd->n=0,i=0;in += ddd->blocksizes[i]; ddd->m=m; ddd->nblocks=nblocks; fclose(fp); return 0; } #undef __FUNCT__ #define __FUNCT__ "Parseline" static int Parseline(char thisline[],int *nmat,int *nblk,int *row, int *col,double *value, int *nargs){ int temp; int rtmp,coltmp; *nmat=-1;*nblk=-1;rtmp=-1;coltmp=-1;*value=0.0; temp=sscanf(thisline,"%d %d %d %d %lg",nmat,nblk,&rtmp,&coltmp,value); if (temp==5) *nargs=5; else *nargs=0; *row=rtmp-1; *col=coltmp-1; return(0); } static int partition(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int k=lend; int pivot1=list1[k],pivot2=list2[k],pivot3=list3[k]; double pivot5 = list5[k]; int bottom = lstart-1, top = lend; int done = 0; int ordered=1; while (!done){ while (!done) { bottom = bottom+1; if (bottom == top){ done = 1; break; } if ( list1[bottom] > pivot1 || (list1[bottom] == pivot1 && list2[bottom] > pivot2) || (list1[bottom] == pivot1 && list2[bottom] == pivot2 && list3[bottom] > pivot3) ){ list1[top] = list1[bottom]; list2[top] = list2[bottom]; list3[top] = list3[bottom]; list5[top] = list5[bottom]; ordered=0; break; } } while (!done){ top = top-1; if (top == bottom){ done = 1; break; } if ( list1[top] < pivot1 || (list1[top] == pivot1 && list2[top] < pivot2) || (list1[top] == pivot1 && list2[top] == pivot2 && list3[top] < pivot3)){ list1[bottom] = list1[top]; list2[bottom] = list2[top]; list3[bottom] = list3[top]; list5[bottom] = list5[top]; ordered=0; break; } } } list1[top] = pivot1; list2[top] = pivot2; list3[top] = pivot3; list5[top] = pivot5; ordered=0; if (bottom==lend){ ordered=1; for (k=lstart;k list1[k+1]) || (list1[k] == list1[k+1] && list2[k] > list2[k+1]) || (list1[k] == list1[k+1] && list2[k] == list2[k+1] && list3[k] > list3[k+1]) ){ ordered=0; break; } } } if (ordered && lend-lstart>2){ top=(lend+lstart)/2; } return top; } static int qusort(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int split; if (lstart < lend){ split = partition(list1, list2, list3, list5,lstart, lend); qusort(list1, list2, list3, list5, lstart, split-1); qusort(list1, list2, list3, list5, split+1, lend); } else { return 0; } return 0; } #undef __FUNCT__ #define __FUNCT__ "GetMarkers" static int GetMarkers(int block, int constraint, int blockn[], int constraintn[], int*m3){ int i=0; while (blockn[i]==block && constraintn[i]==constraint){ i++;} *m3=i; return 0; } #undef __FUNCT__ #define __FUNCT__ "CountNonzeroMatrices" static int CountNonzeroMatrices(int block, int blockn[], int constraintn[], int*m3){ int i=0,cvar=-1,nnzmats=0; while (blockn[i]==block){ if (constraintn[i]>cvar){ cvar=constraintn[i];nnzmats++;} i++; } *m3=nnzmats; return 0; } #undef __FUNCT__ #define __FUNCT__ "CheckForConstantMat" static int CheckForConstantMat(double v[],int nnz, int n){ int i; double vv; if (n<=1){ return 0; } if (nnz!=(n*n+n)/2){ return 0; } for (vv=v[0],i=1;i1) return 0; if (dddd.fixedvari) return 0; info=GetMarkers(1,0,dddd.block+spot,dddd.constraint+spot,&ijnnz); for (i=0;i #include #include #include #include "pdsdp5petsc.h" /*! \file readsdpa.c \brief Read SDPA data files, pass data into DSDP solver, and print solution. */ /* static char help[]="\n"; */ static char help[]="\ DSDP Usage: dsdp5 filename \n\ -print <10> - print information at each k iteration\n\ -save \n\ -fout to print standard monitor to a file\n\ -y0 \n\ -benchmark \n\ -directory \n\ -suffix \n\ -dloginfo <0> - print more information for higher numbers \n\ -dlogsummary <1> - print timing information \n\ -help for this help message\n"; static int qusort(int[],int[],int[],double[],int,int); static int partition(int[],int[],int[],double[],int, int); static int Parseline(char *,int *,int *,int *,int *,double *, int *); static int ReadInitialPoint(char*, int, double[]); static int TCheckArgs0(DSDP,SDPCone,int,int,char *[]); static int TCheckArgs(DSDP,SDPCone,int,int,char *[]); static int CheckForConstantMat(double[],int, int); static int CountNonzeroMatrices(int, int[],int[], int*); typedef struct{ char sformat; int blocksize; } DBlock; typedef struct{ int *block,*constraint,*matind; double*nnz; char *sformat; int totalnonzeros; double *dobj,*y0; char *conetypes; int *blocksizes; int m; int n; int nblocks; int lpn,lpspot,lpblock,lpnnz; int *lpi,*lui,*cmap; double cnorm; double fixedvari; double fixedvard,xout; } DSDPData; static int ReadSDPA2(char*,DSDPData*); static int GetMarkers(int, int, int*, int*, int*); static int ComputeY0(DSDP,DSDPData); static int rank=0; int ReadSDPAFile(int argc,char *argv[]); #define CHKDATA(a,b,c) { if (c){ printf("Possible problem in variable %d, block %d. \n",a+1,b+1);} } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char *argv[]){ int info; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&rank); DSDPSetRank(rank); info=ReadSDPAFile(argc,argv); MPI_Finalize( ); return info; } #undef __FUNCT__ #define __FUNCT__ "ReadSDPAFile" /*! \fn int ReadSDPAFile(int argc,char *argv[]); \brief Read SDPA formatted file and solve the semidefinite program. \param argc number of command line arguments \param argv command line arguments \ingroup Examples */ int ReadSDPAFile(int argc,char *argv[]){ int i,j,m,n,np,its,info; int spot,ijnnz,nzmats,sdpnmax,sdpn,stat1,printsummary=1; int runbenchmark=0,saveit=0,justone=1,fileout=0; double t1,t2,t3,t4,t5,dd,yhigh; double derr[6],dnorm[3]; double ddobj,ppobj; char problemname[100],thisline[100], filename[300],savefile[100]; char directory[100]="/home/benson/sdpexamples/sdplib/"; char outputfile[50]="",suffix[20]=".dat-s", tablename[20]="results-dsdp-5.7"; char success='f',sformat; FILE *fp1=0,*fp2=0,*fout; DSDPData dddd; DSDP dsdp; DSDPTerminationReason reason; DSDPSolutionType pdfeasible; SDPCone sdpcone=0; LPCone lpcone=0; int *ittt,sspot; if (argc<2){ printf("%s",help); DSDPPrintOptions(); return(0); } for (i=0; i 0.0) dddd.y0[i]=-0.0; else dddd.y0[i]=0.0; for (i=0; i=m && its==0) its=1; if (its>=1) its++; its=its*its; if (m<2000 && its>10) its=10; if (its>12) its=12; info=DSDPReuseMatrix(dsdp,its); DSDPFREE(&dddd.blocksizes,&info); DSDPFREE(&dddd.sformat,&info); DSDPFREE(&dddd.dobj,&info); DSDPFREE(&dddd.y0,&info); DSDPFREE(&dddd.conetypes,&info); DSDPFREE(&dddd.constraint,&info); DSDPFREE(&dddd.block,&info); info=DSDPGetDataNorms(dsdp, dnorm); if (dnorm[0]==0){ info=DSDPSetR0(dsdp,np); info=DSDPSetGapTolerance(dsdp,1e-3); info=DSDPSetYBounds(dsdp,-1.0,1.0); } else { } info = TCheckArgs0(dsdp,sdpcone,dddd.m,argc,argv); info = TCheckArgs(dsdp,sdpcone,dddd.m,argc,argv); info = DSDPSetup(dsdp); if (info){ printf("\nProblem Setting problem. Likely insufficient memory\n"); return 1;} if (0==1){info=SDPConeCheckData(sdpcone);} DSDPTime(&t4); if (rank==0){ printf("DSDP Process Data: %4.3e seconds\n\n",t4-t3); printf("Data Norms: C: %4.2e, A: %4.2e, b: %4.2e\n",dnorm[0],dnorm[1],dnorm[2]); info=DSDPGetScale(dsdp,&ddobj); printf("Scale C: %4.2e\n\n",ddobj); info=DSDPGetPotentialParameter(dsdp,&ddobj); printf("Potential Parameter: %4.2f\n",ddobj); info=DSDPGetReuseMatrix(dsdp,&its); printf("Reapply Schur matrix: %d\n\n",its); } if (0==1){info=DSDPPrintData(dsdp,sdpcone,lpcone);} info = DSDPSolve(dsdp); if (info){ printf("\nNumerical errors encountered in DSDPSolve(). \n");} info=DSDPStopReason(dsdp,&reason); if (reason!=DSDP_INFEASIBLE_START){ info=DSDPComputeX(dsdp);DSDPCHKERR(info); } info=DSDPStopReason(dsdp,&reason); info=DSDPGetSolutionType(dsdp,&pdfeasible); DSDPTime(&t5); if (rank==0){ if (reason == DSDP_CONVERGED){ printf("DSDP Converged. \n"); success='s'; } else if ( reason == DSDP_UPPERBOUND ){ printf("DSDP Terminated Because Dual Objective Exceeded its Bound\n"); success='s'; } else if ( reason == DSDP_SMALL_STEPS ){ printf("DSDP Terminated Due to Small Steps\n"); success='f'; } else if ( reason == DSDP_MAX_IT){ printf("DSDP Terminated Due Maximum Number of Iterations\n"); success='f'; } else if ( reason == DSDP_INFEASIBLE_START){ printf("DSDP Terminated Due to Infeasible Starting Point\n"); success='f'; } else if ( reason == DSDP_INDEFINITE_SCHUR_MATRIX){ printf("DSDP Terminated Due to Indefinite Schur Complement\n"); success='f'; } else { printf("DSDP Finished\n"); success='f'; } if (pdfeasible == DSDP_UNBOUNDED ){ printf("DSDP Dual Unbounded, Primal Infeasible\n"); } else if ( pdfeasible == DSDP_INFEASIBLE ){ printf("DSDP Primal Unbounded, Dual Infeasible\n"); } info=DSDPGetDObjective(dsdp,&ddobj); info=DSDPGetPObjective(dsdp,&ppobj); printf("\nP Objective : %16.8e \n",ppobj); printf("DSDP Solution: %16.8e \n\n",ddobj); printf("DSDP Solve Time: %4.3e seconds\n",t5-t4); printf("DSDP Preparation and Solve Time: %4.3e seconds\n\n",t5-t3); info=DSDPGetFinalErrors(dsdp,derr); info=DSDPGetIts(dsdp,&its); if (1 || runbenchmark){ fp2=fopen(tablename,"a"); if (pdfeasible==DSDP_UNBOUNDED){ fprintf(fp2," %-18s & %4d & %4d & infeasible & unbounded & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else if (pdfeasible==DSDP_INFEASIBLE){ fprintf(fp2," %-18s & %4d & %4d & unbounded & infeasible & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else { fprintf(fp2," %-18s & %4d & %4d & %13.7f & %13.7f & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,-ppobj,-ddobj,derr[0],success,its,t5-t3); } fclose(fp2); } /* info=DSDPComputeMinimumXEigenvalue(dsdp,&derr[1]); */ printf("\nP Infeasible: %8.2e \n",derr[0]); printf("D Infeasible: %8.2e \n",derr[2]); printf("Minimal P Eigenvalue: %6.2e \n",derr[1]); printf("Minimal D Eigenvalue: 0.00 \n"); printf("Relative P - D Objective values: %4.2e \n",derr[4]); printf("Relative X Dot S: %4.2e \n",derr[5]); info=DSDPGetYBounds(dsdp,&dd,&yhigh); info=DSDPGetYMaxNorm(dsdp,&dd); printf("\nMax Y: %10.8e, Bounded by %6.1e\n",dd,yhigh); info=DSDPGetTraceX(dsdp,&dd); printf("Trace X: %4.8e, ",dd); info=DSDPGetPenaltyParameter(dsdp,&dd); printf("Bounded by Penalty Parameter: %4.1e \n\n",dd); if (printsummary){ DSDPEventLogSummary();} printf("--- DSDP Finished ---\n\n"); if (saveit){ fout=fopen(savefile,"w"); /* fprintf(fout,"** %s \n",filename); Deleted */ info= DSDPPrintSolution(fout,dsdp,sdpcone,lpcone); if (dddd.fixedvari){ sspot=dddd.nblocks+1,dd=dddd.xout; fprintf(fout,"1 %d 1 1 1.0e-11\n1 %d 2 2 1.0e-11\n",sspot,sspot); fprintf(fout,"2 %d 1 1 %12.8e\n",sspot,DSDPMax(1.0e-10,dd)); fprintf(fout,"2 %d 2 2 %12.8e\n",sspot,DSDPMax(1e-10,-dd)); } fclose(fout); } } info = DSDPDestroy(dsdp); DSDPFREE(&dddd.matind,&info); DSDPFREE(&dddd.nnz,&info); if (fileout){fclose(dsdpoutputfile);} if (0){ DSDPMemoryLog();} } if (runbenchmark){ fclose(fp1);} return 0; } /* main */ #define BUFFERSIZ 4000 #undef __FUNCT__ #define __FUNCT__ "ReadSDPA2" static int ReadSDPA2(char *filename, DSDPData*ddd){ FILE*fp; char ctmp,refline[BUFFERSIZ]="*",thisline[BUFFERSIZ]="*"; int info,tline,line=0; int i,k,m,n; /* int spot,nzmark, */ int bigint=1000000; int i1,nblk,nmat,col,row; int np=0,nblocks; int nargs,nonzero; double val; fp=fopen(filename,"r"); if (!fp){ printf("Cannot open file %s !",filename); return(1); } /* Read comments */ while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } /* Read number of constraints */ if (sscanf(thisline,"%d",&m)<1){ printf("Error: line %d. Number of constraints not given.\n",line); return(1); } /* Read number of blocks */ fgets(thisline,BUFFERSIZ,fp); line++; if (sscanf(thisline,"%d",&nblocks)!=1){ printf("Error: line %d. Number of blocks not given.\n",line); return(1); } ddd->lpn=0;ddd->lpspot=0;ddd->lpblock=0;ddd->cnorm=0; /* Read block sizes */ DSDPCALLOC2(&ddd->sformat,char, (nblocks+1),&info); DSDPCALLOC2(&ddd->blocksizes,int, (nblocks+1),&info); DSDPCALLOC2(&ddd->conetypes,char, (nblocks+1),&info ); line++; for (i=0;i0) { ddd->blocksizes[i]=col; np+=col; ddd->conetypes[i]='S'; } else if (col>0){ddd->blocksizes[i]=-col; np+=-col; ddd->conetypes[i]='S'; } else if (col<0){ddd->blocksizes[i]=-col; np += -col; ddd->conetypes[i]='L';ddd->lpn=-col;ddd->lpblock=i; } else { ddd->blocksizes[i]=0; ddd->conetypes[i]='N';} if (ddd->blocksizes[i]<10){ddd->sformat[i]='U';} else {ddd->sformat[i]='P';} } else{ printf("Error block sizes, line %d",line); return(1);} } if (ddd->blocksizes[nblocks-1]==0) nblocks--; fgets(thisline,BUFFERSIZ,fp); /* Read objective vector */ DSDPCALLOC2(&ddd->y0,double,m,&info); DSDPCALLOC2(&ddd->dobj,double,m,&info); line++; for (i=0;idobj[i]=val; } fgets(thisline,BUFFERSIZ,fp); tline=line; nargs=5; nonzero=0; while(!feof(fp)){ thisline[0]='\0'; nmat=-1; nblk=-1; row=-1; col=-1; val=0.0; fgets(thisline,BUFFERSIZ,fp); line++; info = Parseline(thisline,&nmat,&nblk,&row,&col,&val,&nargs); if (!feof(fp)&&nargs!=5&&nargs>0){ printf("Error: line %d \n%s\n",line,thisline);return 1;} if (nargs==5 && val!=0.0){ nonzero++; i1=row*(row+1)/2 + col; if (row >= ddd->blocksizes[nblk-1] || col >= ddd->blocksizes[nblk-1] ) { printf("Data Error in line: %d. Row %d or col %d > blocksize %d\n%s",line,row+1,col+1,ddd->blocksizes[nblk-1],thisline); return 1; } if (row<0 || col<0){ printf("Data Error in line: %d. Row %d or col %d <= 0 \n%s",line,row+1,col+1,thisline); return 1; } if (nmat>m || nmat<0){ printf("Data Error in line: %d. Is Var 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } if (nblk>nblocks || nblk<0){ printf("Data Error in line: %d. Is Block 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); } } /* Allocate memory for the data */ nonzero++; DSDPCALLOC2(&ddd->matind,int,nonzero,&info); DSDPCALLOC2(&ddd->nnz,double,nonzero,&info); DSDPCALLOC2(&ddd->block,int,nonzero,&info); DSDPCALLOC2(&ddd->constraint,int,nonzero,&info); nonzero--; fseek(fp,0,SEEK_SET); line=0; for (i=0;i=nonzero && !feof(fp) ){ */ printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } if (nargs==5 && val!=0.0){ if (row>col){ printf("Warning: Line: %d Row < Column. %s \n",line,thisline); } i=row;row=col;col=i; n=ddd->blocksizes[nblk-1]; if (nmat==0) {val=-val;} if (ddd->conetypes[nblk-1]=='S'){ /* if (row==col) val/=2; */ ddd->matind[k]=row*(row+1)/2 + col; if (ddd->sformat[nblk-1]=='U'){ddd->matind[k]=row*n + col;} } else { ddd->matind[k]=col; } ddd->block[k]=nblk; ddd->constraint[k]=nmat; ddd->nnz[k]=val; k++; } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } } ddd->block[k]=nblocks+1; ddd->constraint[k]=m+2; ddd->matind[k]=10000000; ddd->nnz[k]=0.0; qusort(ddd->block,ddd->constraint,ddd->matind,ddd->nnz,0,nonzero-1); for (i=0;imatind[i]==ddd->matind[i+1] && ddd->constraint[i]==ddd->constraint[i+1] && ddd->block[i]==ddd->block[i+1] ){ printf("DSDPError: Reading Input File:\n"); printf("Possible problem with data input file: Double Entry: \n"); printf(" %d %d %d %2.10e\n", ddd->constraint[i],ddd->block[i],ddd->matind[i]+1,ddd->nnz[i]); printf(" %d %d %d %2.10e\n\n", ddd->constraint[i+1],ddd->block[i+1],ddd->matind[i+1]+1,ddd->nnz[i+1]); for (k=i+1;kconstraint[k]=ddd->constraint[k+1]; ddd->block[k]=ddd->block[k+1]; ddd->matind[k]=ddd->matind[k+1];ddd->nnz[k]=ddd->nnz[k+1]; } ddd->constraint[nonzero-1]=bigint;ddd->nnz[nonzero-1]=0; nonzero--; } } ddd->fixedvari=0;ddd->fixedvard=0; if (ddd->lpblock>0){ int spot; if (ddd->blocksizes[ddd->lpblock]==2){ i=0;k=0; while (ddd->block[i]<=ddd->lpblock && iblock[i]==ddd->lpblock+1 && iconstraint[spot]==ddd->constraint[spot+1] && ddd->constraint[spot+2]==ddd->constraint[spot+3] && ddd->matind[spot]==ddd->matind[spot+2] && ddd->matind[spot+1]==ddd->matind[spot+3] && fabs(ddd->nnz[spot+2])==1.0 && fabs(ddd->nnz[spot+3])==1.0 && fabs(ddd->nnz[spot] + ddd->nnz[spot+1]) <=1e-6 ){ ddd->fixedvari=ddd->constraint[spot+2]; ddd->fixedvard=ddd->nnz[spot]/ddd->nnz[spot+2]; nblocks--;ddd->lpblock=0; } } } } ddd->totalnonzeros=nonzero; for (ddd->n=0,i=0;in += ddd->blocksizes[i]; ddd->m=m; ddd->nblocks=nblocks; fclose(fp); return 0; } #undef __FUNCT__ #define __FUNCT__ "Parseline" static int Parseline(char thisline[],int *nmat,int *nblk,int *row, int *col,double *value, int *nargs){ int temp; int rtmp,coltmp; *nmat=-1;*nblk=-1;rtmp=-1;coltmp=-1;*value=0.0; temp=sscanf(thisline,"%d %d %d %d %lg",nmat,nblk,&rtmp,&coltmp,value); if (temp==5) *nargs=5; else *nargs=0; *row=rtmp-1; *col=coltmp-1; return(0); } static int partition(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int k=lend; int pivot1=list1[k],pivot2=list2[k],pivot3=list3[k]; double pivot5 = list5[k]; int bottom = lstart-1, top = lend; int done = 0; int ordered=1; while (!done){ while (!done) { bottom = bottom+1; if (bottom == top){ done = 1; break; } if ( list1[bottom] > pivot1 || (list1[bottom] == pivot1 && list2[bottom] > pivot2) || (list1[bottom] == pivot1 && list2[bottom] == pivot2 && list3[bottom] > pivot3) ){ list1[top] = list1[bottom]; list2[top] = list2[bottom]; list3[top] = list3[bottom]; list5[top] = list5[bottom]; ordered=0; break; } } while (!done){ top = top-1; if (top == bottom){ done = 1; break; } if ( list1[top] < pivot1 || (list1[top] == pivot1 && list2[top] < pivot2) || (list1[top] == pivot1 && list2[top] == pivot2 && list3[top] < pivot3)){ list1[bottom] = list1[top]; list2[bottom] = list2[top]; list3[bottom] = list3[top]; list5[bottom] = list5[top]; ordered=0; break; } } } list1[top] = pivot1; list2[top] = pivot2; list3[top] = pivot3; list5[top] = pivot5; ordered=0; if (bottom==lend){ ordered=1; for (k=lstart;k list1[k+1]) || (list1[k] == list1[k+1] && list2[k] > list2[k+1]) || (list1[k] == list1[k+1] && list2[k] == list2[k+1] && list3[k] > list3[k+1]) ){ ordered=0; break; } } } if (ordered && lend-lstart>2){ top=(lend+lstart)/2; } return top; } static int qusort(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int split; if (lstart < lend){ split = partition(list1, list2, list3, list5,lstart, lend); qusort(list1, list2, list3, list5, lstart, split-1); qusort(list1, list2, list3, list5, split+1, lend); } else { return 0; } return 0; } #undef __FUNCT__ #define __FUNCT__ "GetMarkers" static int GetMarkers(int block, int constraint, int blockn[], int constraintn[], int*m3){ int i=0; while (blockn[i]==block && constraintn[i]==constraint){ i++;} *m3=i; return 0; } #undef __FUNCT__ #define __FUNCT__ "CountNonzeroMatrices" static int CountNonzeroMatrices(int block, int blockn[], int constraintn[], int*m3){ int i=0,cvar=-1,nnzmats=0; while (blockn[i]==block){ if (constraintn[i]>cvar){ cvar=constraintn[i];nnzmats++;} i++; } *m3=nnzmats; return 0; } #undef __FUNCT__ #define __FUNCT__ "CheckForConstantMat" static int CheckForConstantMat(double v[],int nnz, int n){ int i; double vv; if (n<=1){ return 0; } if (nnz!=(n*n+n)/2){ return 0; } for (vv=v[0],i=1;i1) return 0; if (dddd.fixedvari) return 0; info=GetMarkers(1,0,dddd.block+spot,dddd.constraint+spot,&ijnnz); for (i=0;iM; int i,m=MC->m,info; PetscFunctionBegin; info = PetscGetTime(&MC->t1); info=PetscLogEventBegin(MC->hevent,0,0,0,0); info=MatZeroEntries(M);CHKERRQ(info); for (i=0;iiptr[i]=i; PetscFunctionReturn(0); } static int onrow(petscM* MC,int row){ if (MC->low<= row && row < MC->high){ return 1; } return 0; } static int pmatlocalvariables( void* MM,double vars[] ,int m){ petscM* MC=(petscM*)MM; int row; for (row=0;rowlow<= row && row < MC->high){ switch (MC->hmethod){ case 2: *ncols = m; for (i=0;ihmethod){ case 2: info=MatSetValues(MC->M,1,&row,m,MC->iptr,vals,ADD_VALUES);CHKERRQ(info); break; case 3: info=MatSetValues(MC->M,1,&row,m,MC->iptr,vals,ADD_VALUES);CHKERRQ(info); vals[row]=0; info=MatSetValues(MC->M,m,MC->iptr,1,&row,vals,ADD_VALUES);CHKERRQ(info); break; default: info=MatSetValues(MC->M,1,&row,m-row,MC->iptr+row,vals+row,ADD_VALUES);CHKERRQ(info); info=MatSetValues(MC->M,m-row-1,MC->iptr+row+1,1,&row,vals+row+1,ADD_VALUES);CHKERRQ(info); } PetscFunctionReturn(0); } static int pmatassemble(void*MM){ petscM* MC=(petscM*)MM; Mat M= MC->M; PetscLogDouble t2; int info; PetscFunctionBegin; info=MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);CHKERRQ(info); info=MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);CHKERRQ(info); info=PetscLogEventEnd(MC->hevent,0,0,0,0); info = PetscGetTime(&t2); MC->thessian+=(t2-MC->t1); PetscLogInfo((M,"Compute Hessian: %10.6e, Total: %10.6e\n",t2-MC->t1,MC->thessian)); PetscFunctionReturn(0); } static int pmatfactor(void*MM,int*flag){ petscM* MC=(petscM*)MM; int info; PetscFunctionBegin; info=KSPSetOperators(MC->ksp,MC->M,MC->M,SAME_NONZERO_PATTERN);CHKERRQ(info); *flag=0; PetscFunctionReturn(0); } static int pmatreduce(void*MM,double *v, int m){ petscM* MC=(petscM*)MM; Vec VP=MC->RHS,Vall=MC->Vall; int i,info; double *vv, zero=0.0; PetscFunctionBegin; info=VecGetArray(Vall,&vv);CHKERRQ(info); for (i=0;iscatter);CHKERRQ(info); info = VecScatterEnd(Vall,VP,ADD_VALUES,SCATTER_REVERSE,MC->scatter);CHKERRQ(info); /* Copy PETSc Vector into DSDP vector */ info = VecSet(Vall,zero);CHKERRQ(info); info = VecScatterBegin(VP,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); info = VecScatterEnd(VP,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); /* info=VecView(Vall,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(info); */ info=VecGetArray(Vall,&vv);CHKERRQ(info); for (i=0;iX,PRHS=MC->RHS, Vall=MC->Vall; int i,its,info,low,high; double *vv; double zero=0.0; KSP ksp=MC->ksp; KSPConvergedReason reason; PetscReal rnorm,rnorm2,rtol=1.0e-6,aatol=1.0e-12; PetscLogDouble t0,t1; PetscFunctionBegin; info = PetscGetTime(&t0); info=VecSet(PRHS,zero);CHKERRQ(info); info=VecGetOwnershipRange(PRHS,&low,&high);CHKERRQ(info); info=VecGetArray(PRHS,&vv);CHKERRQ(info); for (i=low;iM,"DSDP : First Try Linear iterations: %d, ",its)); PetscLogInfo((MC->M,"DSDP : Residual Norm: %4.2e, ",rnorm)); PetscLogInfo((MC->M,"DSDP : Termination Reason: %d\n",reason)); if (reason!=2 && reason!=3){ info=KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); CHKERRQ(info); info = KSPSetTolerances(ksp,rtol/rnorm,aatol,1e+25,m/3+20);CHKERRQ(info); info = KSPSolve(ksp,PRHS,DX);CHKERRQ(info); info = KSPGetIterationNumber(ksp, &its); CHKERRQ(info); info=KSPGetConvergedReason(ksp,&reason); CHKERRQ(info); info = KSPGetResidualNorm(ksp,&rnorm2); CHKERRQ(info); PetscLogInfo((MC->M,"DSDP : More Linear iterations: %d, ",its)); PetscLogInfo((MC->M,"DSDP : Residual Norm: %4.2e, ",rnorm2)); PetscLogInfo((MC->M,"DSDP : Termination Reason: %d\n",reason)); if (reason!=2 && reason!=3 && rnorm2M,"DSDP : STill More Linear iterations: %d, ",its)); PetscLogInfo((MC->M,"DSDP : Residual Norm: %4.2e, ",rnorm)); PetscLogInfo((MC->M,"DSDP : Termination Reason: %d\n",reason)); } } /* Copy PETSc Vector into DSDP vector */ info = VecSet(Vall,zero);CHKERRQ(info); info = VecScatterBegin(DX,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); info = VecScatterEnd(DX,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); /* info=VecView(Vall,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(info); */ info=VecGetArray(Vall,&vv);CHKERRQ(info); for (i=0;itsolve+=(t1-t0); PetscLogInfo((MC->M,"DSDP : Solve Linear system: %10.6e, Total: %10.6e\n",t1-t0,MC->tsolve)); PetscFunctionReturn(0); } static int pmatdestroy(void*MM){ petscM* MC=(petscM*)MM; int info; PetscLogDouble tf; PetscFunctionBegin; info = PetscGetTime(&tf); PetscLogInfo((MC->M,"DSDP : DSDP Total: %10.6e\n",tf-MC->t0)); info=MatDestroy(MC->M);CHKERRQ(info); info=VecScatterDestroy(MC->scatter);CHKERRQ(info); info=VecDestroy(MC->Vall);CHKERRQ(info); info=VecDestroy(MC->X);CHKERRQ(info); info=VecDestroy(MC->RHS);CHKERRQ(info); info=KSPDestroy(MC->ksp);CHKERRQ(info); info=PetscLogEventEnd(MC->dsdpevent,0,0,0,0); PetscFree(MC->iptr); /* PetscFinalize(); */ PetscFunctionReturn(0);CHKERRQ(info); } static int pmatview(void*MM){ petscM* MC=(petscM*)MM; int info; PetscFunctionBegin; info=KSPView(MC->ksp,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(info); info=MatView(MC->M,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(info); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDPLinearSolverCreate" static int DSDPPetscLinearSolverCreate(void *MM, int m){ int i,info,mlocal; PC pc; IS ISLocal,ISGlobal; petscM* MC=(petscM*)MM; PetscFunctionBegin; info = VecCreateSeq(PETSC_COMM_SELF,m,&MC->Vall);CHKERRQ(info); info = VecCreateMPI(MC->comm,MC->mlocal,m,&MC->X);CHKERRQ(info); info = VecDuplicate(MC->X,&MC->RHS);CHKERRQ(info); /* Create the parallel matrix */ info = VecGetOwnershipRange(MC->X,&MC->low,&MC->high);CHKERRQ(info); info = VecGetLocalSize(MC->X,&mlocal);CHKERRQ(info); info = MatCreateMPIDense(MC->comm,mlocal,mlocal,m,m,0,&MC->M);CHKERRQ(info); info = MatSetOption(MC->M,MAT_COLUMNS_SORTED); CHKERRQ(info); info = MatSetOption(MC->M,MAT_ROWS_SORTED); CHKERRQ(info); MC->m=m; MC->mlocal=mlocal; /* Create the scatter between local and parallel vectors */ info = ISCreateStride(PETSC_COMM_SELF,m,0,1,&ISLocal);CHKERRQ(info); info = ISCreateStride(MC->comm,m,0,1,&ISGlobal); CHKERRQ(info); info = VecScatterCreate(MC->X,ISGlobal,MC->Vall,ISLocal,&MC->scatter); CHKERRQ(info); info = ISDestroy(ISLocal);CHKERRQ(info); info = ISDestroy(ISGlobal);CHKERRQ(info); info = PetscMalloc(m*sizeof(int),&MC->iptr); for (i=0;iiptr[i]=i; /* Create the Linear Solver */ info = KSPCreate(MC->comm,&MC->ksp);CHKERRQ(info); info = KSPSetTolerances(MC->ksp,1.0e-8,1.0e-13,1e+25,1000);CHKERRQ(info); info = KSPGetPC(MC->ksp,&pc); CHKERRQ(info); info = KSPSetType(MC->ksp,KSPCG); CHKERRQ(info); info = PCSetType(pc,PCJACOBI); CHKERRQ(info); info = KSPSetFromOptions(MC->ksp); CHKERRQ(info); MC->hmethod=3; MC->t0=0; MC->t1=0; MC->thessian=0; MC->tsolve=0; info=PetscLogEventRegister(&MC->dsdpevent,"DSDPSolve",KSP_COOKIE); info=PetscLogEventRegister(&MC->hevent,"DSPPComputeM",KSP_COOKIE); info=PetscLogEventBegin(MC->dsdpevent,0,0,0,0); info = PetscGetTime(&MC->t0); PetscFunctionReturn(0); } static int TTTMatMult(void*MM,double xx[],double yy[],int m){ petscM* MC=(petscM*)MM; Vec X=MC->X,Y=MC->RHS, Vall=MC->Vall; double *x,*y,*vv,zero=0.0; int i,info,low,high; PetscFunctionBegin; info=VecSet(X,zero);CHKERRQ(info); info=VecGetOwnershipRange(X,&low,&high);CHKERRQ(info); info=VecGetArray(X,&vv);CHKERRQ(info); for (i=low;iM,X,Y);CHKERRQ(info); info = VecScatterBegin(Y,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); info = VecScatterEnd(Y,Vall,INSERT_VALUES,SCATTER_FORWARD,MC->scatter);CHKERRQ(info); info=VecGetArray(Vall,&y);CHKERRQ(info); for (i=0;iM,d);CHKERRQ(info); PetscFunctionReturn(0); } static int TTTMatAddDiagonal(void *MM, double diag[], int m){ petscM* MC=(petscM*)MM; Vec D=MC->X; int i,info; double *d, zero=0.0; PetscFunctionBegin; info=VecSet(D,zero);CHKERRQ(info); info=VecGetArray(D,&d);CHKERRQ(info); for (i=MC->low;ihigh;i++) d[i-MC->low]=diag[i]; info=VecRestoreArray(D,&d);CHKERRQ(info); info=MatDiagonalSet(MC->M,D,ADD_VALUES);CHKERRQ(info); PetscFunctionReturn(0); } static int pmataddelement(void* MM,int row, double shift){ petscM* MC=(petscM*)MM; int info; PetscFunctionBegin; if (onrow(MC,row)){ info=MatSetValues(MC->M,1,&row,1,&row,&shift,ADD_VALUES);CHKERRQ(info); } PetscFunctionReturn(0); } static int pmatdistributed(void*MM, int*flag){ PetscFunctionBegin; *flag=1; PetscFunctionReturn(0); } static struct DSDPSchurMat_Ops petscdsdpops; static const char* tmatname="PETSc"; static int DSDPPetscOpsInit(struct DSDPSchurMat_Ops* sops){ int info; if (!sops) return 0; info=DSDPSchurMatOpsInitialize(sops); CHKERRQ(info); sops->matzero=pmatzero; sops->mataddrow=pmataddline; sops->matdestroy=pmatdestroy; sops->matfactor=pmatfactor; sops->matsolve=pmatsolve; sops->matrownonzeros=pmatidcolumns; sops->matassemble=pmatassemble; sops->matsetup=DSDPPetscLinearSolverCreate; sops->matadddiagonal=TTTMatAddDiagonal; sops->matshiftdiagonal=TTTMatShiftDiagonal; sops->matscaledmultiply=TTTMatMult; sops->matview=pmatview; sops->mataddelement=pmataddelement; sops->pmatwhichdiag=0; sops->pmatonprocessor=pmatonprocessor; sops->pmatlocalvariables=pmatlocalvariables; sops->pmatdistributed=pmatdistributed; sops->pmatreduction=pmatreduce; sops->id=22; sops->matname=tmatname; return 0; } int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*,void*); #undef __FUNCT__ #define __FUNCT__ "PDSDPUsePETScLinearSolver" int PDSDPUsePETScLinearSolver(DSDP dsdp, MPI_Comm comm, int mlocal){ int info; petscM* MM; PetscFunctionBegin; /* PetscInitialize(0,0,0,0); */ info=PetscMalloc(sizeof(petscM),&MM); MM->dsdp=dsdp; MM->comm=comm; MM->mlocal=mlocal; MPI_Comm_rank(comm,&MM->rank); info=DSDPPetscOpsInit(&petscdsdpops);CHKERRQ(info); info=DSDPSetSchurMatOps(dsdp,&petscdsdpops,(void*)MM);CHKERRQ(info); PetscFunctionReturn(0); } DSDP5.8/pdsdp/PETSc/Makefile0000644000175000017500000000050310326241002015455 0ustar twernertwerner BOPT=O include ../../make.include include ${PETSC_DIR}/bmake/common/base ALLLIBS = ${DSDPLIB} ${LAPACKBLAS} # Check compiler flags so PETSc and DSDP use the same compiler! g++ ? dsdpsdpa: readsdpa.o pdsdppetsc.o chkopts $(CLINKER) -o pdsdp5 readsdpa.o pdsdppetsc.o $(DSDPLIB) $(PETSC_KSP_LIB) rm *.o all: dsdpsdpa DSDP5.8/pdsdp/PETSc/theta1.dat-s0000644000175000017500000005253110326241002016145 0ustar twernertwerner104 1 50 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 1 1 1 1.0 0 1 1 2 1.0 0 1 1 3 1.0 0 1 1 4 1.0 0 1 1 5 1.0 0 1 1 6 1.0 0 1 1 7 1.0 0 1 1 8 1.0 0 1 1 9 1.0 0 1 1 10 1.0 0 1 1 11 1.0 0 1 1 12 1.0 0 1 1 13 1.0 0 1 1 14 1.0 0 1 1 15 1.0 0 1 1 16 1.0 0 1 1 17 1.0 0 1 1 18 1.0 0 1 1 19 1.0 0 1 1 20 1.0 0 1 1 21 1.0 0 1 1 22 1.0 0 1 1 23 1.0 0 1 1 24 1.0 0 1 1 25 1.0 0 1 1 26 1.0 0 1 1 27 1.0 0 1 1 28 1.0 0 1 1 29 1.0 0 1 1 30 1.0 0 1 1 31 1.0 0 1 1 32 1.0 0 1 1 33 1.0 0 1 1 34 1.0 0 1 1 35 1.0 0 1 1 36 1.0 0 1 1 37 1.0 0 1 1 38 1.0 0 1 1 39 1.0 0 1 1 40 1.0 0 1 1 41 1.0 0 1 1 42 1.0 0 1 1 43 1.0 0 1 1 44 1.0 0 1 1 45 1.0 0 1 1 46 1.0 0 1 1 47 1.0 0 1 1 48 1.0 0 1 1 49 1.0 0 1 1 50 1.0 0 1 2 2 1.0 0 1 2 3 1.0 0 1 2 4 1.0 0 1 2 5 1.0 0 1 2 6 1.0 0 1 2 7 1.0 0 1 2 8 1.0 0 1 2 9 1.0 0 1 2 10 1.0 0 1 2 11 1.0 0 1 2 12 1.0 0 1 2 13 1.0 0 1 2 14 1.0 0 1 2 15 1.0 0 1 2 16 1.0 0 1 2 17 1.0 0 1 2 18 1.0 0 1 2 19 1.0 0 1 2 20 1.0 0 1 2 21 1.0 0 1 2 22 1.0 0 1 2 23 1.0 0 1 2 24 1.0 0 1 2 25 1.0 0 1 2 26 1.0 0 1 2 27 1.0 0 1 2 28 1.0 0 1 2 29 1.0 0 1 2 30 1.0 0 1 2 31 1.0 0 1 2 32 1.0 0 1 2 33 1.0 0 1 2 34 1.0 0 1 2 35 1.0 0 1 2 36 1.0 0 1 2 37 1.0 0 1 2 38 1.0 0 1 2 39 1.0 0 1 2 40 1.0 0 1 2 41 1.0 0 1 2 42 1.0 0 1 2 43 1.0 0 1 2 44 1.0 0 1 2 45 1.0 0 1 2 46 1.0 0 1 2 47 1.0 0 1 2 48 1.0 0 1 2 49 1.0 0 1 2 50 1.0 0 1 3 3 1.0 0 1 3 4 1.0 0 1 3 5 1.0 0 1 3 6 1.0 0 1 3 7 1.0 0 1 3 8 1.0 0 1 3 9 1.0 0 1 3 10 1.0 0 1 3 11 1.0 0 1 3 12 1.0 0 1 3 13 1.0 0 1 3 14 1.0 0 1 3 15 1.0 0 1 3 16 1.0 0 1 3 17 1.0 0 1 3 18 1.0 0 1 3 19 1.0 0 1 3 20 1.0 0 1 3 21 1.0 0 1 3 22 1.0 0 1 3 23 1.0 0 1 3 24 1.0 0 1 3 25 1.0 0 1 3 26 1.0 0 1 3 27 1.0 0 1 3 28 1.0 0 1 3 29 1.0 0 1 3 30 1.0 0 1 3 31 1.0 0 1 3 32 1.0 0 1 3 33 1.0 0 1 3 34 1.0 0 1 3 35 1.0 0 1 3 36 1.0 0 1 3 37 1.0 0 1 3 38 1.0 0 1 3 39 1.0 0 1 3 40 1.0 0 1 3 41 1.0 0 1 3 42 1.0 0 1 3 43 1.0 0 1 3 44 1.0 0 1 3 45 1.0 0 1 3 46 1.0 0 1 3 47 1.0 0 1 3 48 1.0 0 1 3 49 1.0 0 1 3 50 1.0 0 1 4 4 1.0 0 1 4 5 1.0 0 1 4 6 1.0 0 1 4 7 1.0 0 1 4 8 1.0 0 1 4 9 1.0 0 1 4 10 1.0 0 1 4 11 1.0 0 1 4 12 1.0 0 1 4 13 1.0 0 1 4 14 1.0 0 1 4 15 1.0 0 1 4 16 1.0 0 1 4 17 1.0 0 1 4 18 1.0 0 1 4 19 1.0 0 1 4 20 1.0 0 1 4 21 1.0 0 1 4 22 1.0 0 1 4 23 1.0 0 1 4 24 1.0 0 1 4 25 1.0 0 1 4 26 1.0 0 1 4 27 1.0 0 1 4 28 1.0 0 1 4 29 1.0 0 1 4 30 1.0 0 1 4 31 1.0 0 1 4 32 1.0 0 1 4 33 1.0 0 1 4 34 1.0 0 1 4 35 1.0 0 1 4 36 1.0 0 1 4 37 1.0 0 1 4 38 1.0 0 1 4 39 1.0 0 1 4 40 1.0 0 1 4 41 1.0 0 1 4 42 1.0 0 1 4 43 1.0 0 1 4 44 1.0 0 1 4 45 1.0 0 1 4 46 1.0 0 1 4 47 1.0 0 1 4 48 1.0 0 1 4 49 1.0 0 1 4 50 1.0 0 1 5 5 1.0 0 1 5 6 1.0 0 1 5 7 1.0 0 1 5 8 1.0 0 1 5 9 1.0 0 1 5 10 1.0 0 1 5 11 1.0 0 1 5 12 1.0 0 1 5 13 1.0 0 1 5 14 1.0 0 1 5 15 1.0 0 1 5 16 1.0 0 1 5 17 1.0 0 1 5 18 1.0 0 1 5 19 1.0 0 1 5 20 1.0 0 1 5 21 1.0 0 1 5 22 1.0 0 1 5 23 1.0 0 1 5 24 1.0 0 1 5 25 1.0 0 1 5 26 1.0 0 1 5 27 1.0 0 1 5 28 1.0 0 1 5 29 1.0 0 1 5 30 1.0 0 1 5 31 1.0 0 1 5 32 1.0 0 1 5 33 1.0 0 1 5 34 1.0 0 1 5 35 1.0 0 1 5 36 1.0 0 1 5 37 1.0 0 1 5 38 1.0 0 1 5 39 1.0 0 1 5 40 1.0 0 1 5 41 1.0 0 1 5 42 1.0 0 1 5 43 1.0 0 1 5 44 1.0 0 1 5 45 1.0 0 1 5 46 1.0 0 1 5 47 1.0 0 1 5 48 1.0 0 1 5 49 1.0 0 1 5 50 1.0 0 1 6 6 1.0 0 1 6 7 1.0 0 1 6 8 1.0 0 1 6 9 1.0 0 1 6 10 1.0 0 1 6 11 1.0 0 1 6 12 1.0 0 1 6 13 1.0 0 1 6 14 1.0 0 1 6 15 1.0 0 1 6 16 1.0 0 1 6 17 1.0 0 1 6 18 1.0 0 1 6 19 1.0 0 1 6 20 1.0 0 1 6 21 1.0 0 1 6 22 1.0 0 1 6 23 1.0 0 1 6 24 1.0 0 1 6 25 1.0 0 1 6 26 1.0 0 1 6 27 1.0 0 1 6 28 1.0 0 1 6 29 1.0 0 1 6 30 1.0 0 1 6 31 1.0 0 1 6 32 1.0 0 1 6 33 1.0 0 1 6 34 1.0 0 1 6 35 1.0 0 1 6 36 1.0 0 1 6 37 1.0 0 1 6 38 1.0 0 1 6 39 1.0 0 1 6 40 1.0 0 1 6 41 1.0 0 1 6 42 1.0 0 1 6 43 1.0 0 1 6 44 1.0 0 1 6 45 1.0 0 1 6 46 1.0 0 1 6 47 1.0 0 1 6 48 1.0 0 1 6 49 1.0 0 1 6 50 1.0 0 1 7 7 1.0 0 1 7 8 1.0 0 1 7 9 1.0 0 1 7 10 1.0 0 1 7 11 1.0 0 1 7 12 1.0 0 1 7 13 1.0 0 1 7 14 1.0 0 1 7 15 1.0 0 1 7 16 1.0 0 1 7 17 1.0 0 1 7 18 1.0 0 1 7 19 1.0 0 1 7 20 1.0 0 1 7 21 1.0 0 1 7 22 1.0 0 1 7 23 1.0 0 1 7 24 1.0 0 1 7 25 1.0 0 1 7 26 1.0 0 1 7 27 1.0 0 1 7 28 1.0 0 1 7 29 1.0 0 1 7 30 1.0 0 1 7 31 1.0 0 1 7 32 1.0 0 1 7 33 1.0 0 1 7 34 1.0 0 1 7 35 1.0 0 1 7 36 1.0 0 1 7 37 1.0 0 1 7 38 1.0 0 1 7 39 1.0 0 1 7 40 1.0 0 1 7 41 1.0 0 1 7 42 1.0 0 1 7 43 1.0 0 1 7 44 1.0 0 1 7 45 1.0 0 1 7 46 1.0 0 1 7 47 1.0 0 1 7 48 1.0 0 1 7 49 1.0 0 1 7 50 1.0 0 1 8 8 1.0 0 1 8 9 1.0 0 1 8 10 1.0 0 1 8 11 1.0 0 1 8 12 1.0 0 1 8 13 1.0 0 1 8 14 1.0 0 1 8 15 1.0 0 1 8 16 1.0 0 1 8 17 1.0 0 1 8 18 1.0 0 1 8 19 1.0 0 1 8 20 1.0 0 1 8 21 1.0 0 1 8 22 1.0 0 1 8 23 1.0 0 1 8 24 1.0 0 1 8 25 1.0 0 1 8 26 1.0 0 1 8 27 1.0 0 1 8 28 1.0 0 1 8 29 1.0 0 1 8 30 1.0 0 1 8 31 1.0 0 1 8 32 1.0 0 1 8 33 1.0 0 1 8 34 1.0 0 1 8 35 1.0 0 1 8 36 1.0 0 1 8 37 1.0 0 1 8 38 1.0 0 1 8 39 1.0 0 1 8 40 1.0 0 1 8 41 1.0 0 1 8 42 1.0 0 1 8 43 1.0 0 1 8 44 1.0 0 1 8 45 1.0 0 1 8 46 1.0 0 1 8 47 1.0 0 1 8 48 1.0 0 1 8 49 1.0 0 1 8 50 1.0 0 1 9 9 1.0 0 1 9 10 1.0 0 1 9 11 1.0 0 1 9 12 1.0 0 1 9 13 1.0 0 1 9 14 1.0 0 1 9 15 1.0 0 1 9 16 1.0 0 1 9 17 1.0 0 1 9 18 1.0 0 1 9 19 1.0 0 1 9 20 1.0 0 1 9 21 1.0 0 1 9 22 1.0 0 1 9 23 1.0 0 1 9 24 1.0 0 1 9 25 1.0 0 1 9 26 1.0 0 1 9 27 1.0 0 1 9 28 1.0 0 1 9 29 1.0 0 1 9 30 1.0 0 1 9 31 1.0 0 1 9 32 1.0 0 1 9 33 1.0 0 1 9 34 1.0 0 1 9 35 1.0 0 1 9 36 1.0 0 1 9 37 1.0 0 1 9 38 1.0 0 1 9 39 1.0 0 1 9 40 1.0 0 1 9 41 1.0 0 1 9 42 1.0 0 1 9 43 1.0 0 1 9 44 1.0 0 1 9 45 1.0 0 1 9 46 1.0 0 1 9 47 1.0 0 1 9 48 1.0 0 1 9 49 1.0 0 1 9 50 1.0 0 1 10 10 1.0 0 1 10 11 1.0 0 1 10 12 1.0 0 1 10 13 1.0 0 1 10 14 1.0 0 1 10 15 1.0 0 1 10 16 1.0 0 1 10 17 1.0 0 1 10 18 1.0 0 1 10 19 1.0 0 1 10 20 1.0 0 1 10 21 1.0 0 1 10 22 1.0 0 1 10 23 1.0 0 1 10 24 1.0 0 1 10 25 1.0 0 1 10 26 1.0 0 1 10 27 1.0 0 1 10 28 1.0 0 1 10 29 1.0 0 1 10 30 1.0 0 1 10 31 1.0 0 1 10 32 1.0 0 1 10 33 1.0 0 1 10 34 1.0 0 1 10 35 1.0 0 1 10 36 1.0 0 1 10 37 1.0 0 1 10 38 1.0 0 1 10 39 1.0 0 1 10 40 1.0 0 1 10 41 1.0 0 1 10 42 1.0 0 1 10 43 1.0 0 1 10 44 1.0 0 1 10 45 1.0 0 1 10 46 1.0 0 1 10 47 1.0 0 1 10 48 1.0 0 1 10 49 1.0 0 1 10 50 1.0 0 1 11 11 1.0 0 1 11 12 1.0 0 1 11 13 1.0 0 1 11 14 1.0 0 1 11 15 1.0 0 1 11 16 1.0 0 1 11 17 1.0 0 1 11 18 1.0 0 1 11 19 1.0 0 1 11 20 1.0 0 1 11 21 1.0 0 1 11 22 1.0 0 1 11 23 1.0 0 1 11 24 1.0 0 1 11 25 1.0 0 1 11 26 1.0 0 1 11 27 1.0 0 1 11 28 1.0 0 1 11 29 1.0 0 1 11 30 1.0 0 1 11 31 1.0 0 1 11 32 1.0 0 1 11 33 1.0 0 1 11 34 1.0 0 1 11 35 1.0 0 1 11 36 1.0 0 1 11 37 1.0 0 1 11 38 1.0 0 1 11 39 1.0 0 1 11 40 1.0 0 1 11 41 1.0 0 1 11 42 1.0 0 1 11 43 1.0 0 1 11 44 1.0 0 1 11 45 1.0 0 1 11 46 1.0 0 1 11 47 1.0 0 1 11 48 1.0 0 1 11 49 1.0 0 1 11 50 1.0 0 1 12 12 1.0 0 1 12 13 1.0 0 1 12 14 1.0 0 1 12 15 1.0 0 1 12 16 1.0 0 1 12 17 1.0 0 1 12 18 1.0 0 1 12 19 1.0 0 1 12 20 1.0 0 1 12 21 1.0 0 1 12 22 1.0 0 1 12 23 1.0 0 1 12 24 1.0 0 1 12 25 1.0 0 1 12 26 1.0 0 1 12 27 1.0 0 1 12 28 1.0 0 1 12 29 1.0 0 1 12 30 1.0 0 1 12 31 1.0 0 1 12 32 1.0 0 1 12 33 1.0 0 1 12 34 1.0 0 1 12 35 1.0 0 1 12 36 1.0 0 1 12 37 1.0 0 1 12 38 1.0 0 1 12 39 1.0 0 1 12 40 1.0 0 1 12 41 1.0 0 1 12 42 1.0 0 1 12 43 1.0 0 1 12 44 1.0 0 1 12 45 1.0 0 1 12 46 1.0 0 1 12 47 1.0 0 1 12 48 1.0 0 1 12 49 1.0 0 1 12 50 1.0 0 1 13 13 1.0 0 1 13 14 1.0 0 1 13 15 1.0 0 1 13 16 1.0 0 1 13 17 1.0 0 1 13 18 1.0 0 1 13 19 1.0 0 1 13 20 1.0 0 1 13 21 1.0 0 1 13 22 1.0 0 1 13 23 1.0 0 1 13 24 1.0 0 1 13 25 1.0 0 1 13 26 1.0 0 1 13 27 1.0 0 1 13 28 1.0 0 1 13 29 1.0 0 1 13 30 1.0 0 1 13 31 1.0 0 1 13 32 1.0 0 1 13 33 1.0 0 1 13 34 1.0 0 1 13 35 1.0 0 1 13 36 1.0 0 1 13 37 1.0 0 1 13 38 1.0 0 1 13 39 1.0 0 1 13 40 1.0 0 1 13 41 1.0 0 1 13 42 1.0 0 1 13 43 1.0 0 1 13 44 1.0 0 1 13 45 1.0 0 1 13 46 1.0 0 1 13 47 1.0 0 1 13 48 1.0 0 1 13 49 1.0 0 1 13 50 1.0 0 1 14 14 1.0 0 1 14 15 1.0 0 1 14 16 1.0 0 1 14 17 1.0 0 1 14 18 1.0 0 1 14 19 1.0 0 1 14 20 1.0 0 1 14 21 1.0 0 1 14 22 1.0 0 1 14 23 1.0 0 1 14 24 1.0 0 1 14 25 1.0 0 1 14 26 1.0 0 1 14 27 1.0 0 1 14 28 1.0 0 1 14 29 1.0 0 1 14 30 1.0 0 1 14 31 1.0 0 1 14 32 1.0 0 1 14 33 1.0 0 1 14 34 1.0 0 1 14 35 1.0 0 1 14 36 1.0 0 1 14 37 1.0 0 1 14 38 1.0 0 1 14 39 1.0 0 1 14 40 1.0 0 1 14 41 1.0 0 1 14 42 1.0 0 1 14 43 1.0 0 1 14 44 1.0 0 1 14 45 1.0 0 1 14 46 1.0 0 1 14 47 1.0 0 1 14 48 1.0 0 1 14 49 1.0 0 1 14 50 1.0 0 1 15 15 1.0 0 1 15 16 1.0 0 1 15 17 1.0 0 1 15 18 1.0 0 1 15 19 1.0 0 1 15 20 1.0 0 1 15 21 1.0 0 1 15 22 1.0 0 1 15 23 1.0 0 1 15 24 1.0 0 1 15 25 1.0 0 1 15 26 1.0 0 1 15 27 1.0 0 1 15 28 1.0 0 1 15 29 1.0 0 1 15 30 1.0 0 1 15 31 1.0 0 1 15 32 1.0 0 1 15 33 1.0 0 1 15 34 1.0 0 1 15 35 1.0 0 1 15 36 1.0 0 1 15 37 1.0 0 1 15 38 1.0 0 1 15 39 1.0 0 1 15 40 1.0 0 1 15 41 1.0 0 1 15 42 1.0 0 1 15 43 1.0 0 1 15 44 1.0 0 1 15 45 1.0 0 1 15 46 1.0 0 1 15 47 1.0 0 1 15 48 1.0 0 1 15 49 1.0 0 1 15 50 1.0 0 1 16 16 1.0 0 1 16 17 1.0 0 1 16 18 1.0 0 1 16 19 1.0 0 1 16 20 1.0 0 1 16 21 1.0 0 1 16 22 1.0 0 1 16 23 1.0 0 1 16 24 1.0 0 1 16 25 1.0 0 1 16 26 1.0 0 1 16 27 1.0 0 1 16 28 1.0 0 1 16 29 1.0 0 1 16 30 1.0 0 1 16 31 1.0 0 1 16 32 1.0 0 1 16 33 1.0 0 1 16 34 1.0 0 1 16 35 1.0 0 1 16 36 1.0 0 1 16 37 1.0 0 1 16 38 1.0 0 1 16 39 1.0 0 1 16 40 1.0 0 1 16 41 1.0 0 1 16 42 1.0 0 1 16 43 1.0 0 1 16 44 1.0 0 1 16 45 1.0 0 1 16 46 1.0 0 1 16 47 1.0 0 1 16 48 1.0 0 1 16 49 1.0 0 1 16 50 1.0 0 1 17 17 1.0 0 1 17 18 1.0 0 1 17 19 1.0 0 1 17 20 1.0 0 1 17 21 1.0 0 1 17 22 1.0 0 1 17 23 1.0 0 1 17 24 1.0 0 1 17 25 1.0 0 1 17 26 1.0 0 1 17 27 1.0 0 1 17 28 1.0 0 1 17 29 1.0 0 1 17 30 1.0 0 1 17 31 1.0 0 1 17 32 1.0 0 1 17 33 1.0 0 1 17 34 1.0 0 1 17 35 1.0 0 1 17 36 1.0 0 1 17 37 1.0 0 1 17 38 1.0 0 1 17 39 1.0 0 1 17 40 1.0 0 1 17 41 1.0 0 1 17 42 1.0 0 1 17 43 1.0 0 1 17 44 1.0 0 1 17 45 1.0 0 1 17 46 1.0 0 1 17 47 1.0 0 1 17 48 1.0 0 1 17 49 1.0 0 1 17 50 1.0 0 1 18 18 1.0 0 1 18 19 1.0 0 1 18 20 1.0 0 1 18 21 1.0 0 1 18 22 1.0 0 1 18 23 1.0 0 1 18 24 1.0 0 1 18 25 1.0 0 1 18 26 1.0 0 1 18 27 1.0 0 1 18 28 1.0 0 1 18 29 1.0 0 1 18 30 1.0 0 1 18 31 1.0 0 1 18 32 1.0 0 1 18 33 1.0 0 1 18 34 1.0 0 1 18 35 1.0 0 1 18 36 1.0 0 1 18 37 1.0 0 1 18 38 1.0 0 1 18 39 1.0 0 1 18 40 1.0 0 1 18 41 1.0 0 1 18 42 1.0 0 1 18 43 1.0 0 1 18 44 1.0 0 1 18 45 1.0 0 1 18 46 1.0 0 1 18 47 1.0 0 1 18 48 1.0 0 1 18 49 1.0 0 1 18 50 1.0 0 1 19 19 1.0 0 1 19 20 1.0 0 1 19 21 1.0 0 1 19 22 1.0 0 1 19 23 1.0 0 1 19 24 1.0 0 1 19 25 1.0 0 1 19 26 1.0 0 1 19 27 1.0 0 1 19 28 1.0 0 1 19 29 1.0 0 1 19 30 1.0 0 1 19 31 1.0 0 1 19 32 1.0 0 1 19 33 1.0 0 1 19 34 1.0 0 1 19 35 1.0 0 1 19 36 1.0 0 1 19 37 1.0 0 1 19 38 1.0 0 1 19 39 1.0 0 1 19 40 1.0 0 1 19 41 1.0 0 1 19 42 1.0 0 1 19 43 1.0 0 1 19 44 1.0 0 1 19 45 1.0 0 1 19 46 1.0 0 1 19 47 1.0 0 1 19 48 1.0 0 1 19 49 1.0 0 1 19 50 1.0 0 1 20 20 1.0 0 1 20 21 1.0 0 1 20 22 1.0 0 1 20 23 1.0 0 1 20 24 1.0 0 1 20 25 1.0 0 1 20 26 1.0 0 1 20 27 1.0 0 1 20 28 1.0 0 1 20 29 1.0 0 1 20 30 1.0 0 1 20 31 1.0 0 1 20 32 1.0 0 1 20 33 1.0 0 1 20 34 1.0 0 1 20 35 1.0 0 1 20 36 1.0 0 1 20 37 1.0 0 1 20 38 1.0 0 1 20 39 1.0 0 1 20 40 1.0 0 1 20 41 1.0 0 1 20 42 1.0 0 1 20 43 1.0 0 1 20 44 1.0 0 1 20 45 1.0 0 1 20 46 1.0 0 1 20 47 1.0 0 1 20 48 1.0 0 1 20 49 1.0 0 1 20 50 1.0 0 1 21 21 1.0 0 1 21 22 1.0 0 1 21 23 1.0 0 1 21 24 1.0 0 1 21 25 1.0 0 1 21 26 1.0 0 1 21 27 1.0 0 1 21 28 1.0 0 1 21 29 1.0 0 1 21 30 1.0 0 1 21 31 1.0 0 1 21 32 1.0 0 1 21 33 1.0 0 1 21 34 1.0 0 1 21 35 1.0 0 1 21 36 1.0 0 1 21 37 1.0 0 1 21 38 1.0 0 1 21 39 1.0 0 1 21 40 1.0 0 1 21 41 1.0 0 1 21 42 1.0 0 1 21 43 1.0 0 1 21 44 1.0 0 1 21 45 1.0 0 1 21 46 1.0 0 1 21 47 1.0 0 1 21 48 1.0 0 1 21 49 1.0 0 1 21 50 1.0 0 1 22 22 1.0 0 1 22 23 1.0 0 1 22 24 1.0 0 1 22 25 1.0 0 1 22 26 1.0 0 1 22 27 1.0 0 1 22 28 1.0 0 1 22 29 1.0 0 1 22 30 1.0 0 1 22 31 1.0 0 1 22 32 1.0 0 1 22 33 1.0 0 1 22 34 1.0 0 1 22 35 1.0 0 1 22 36 1.0 0 1 22 37 1.0 0 1 22 38 1.0 0 1 22 39 1.0 0 1 22 40 1.0 0 1 22 41 1.0 0 1 22 42 1.0 0 1 22 43 1.0 0 1 22 44 1.0 0 1 22 45 1.0 0 1 22 46 1.0 0 1 22 47 1.0 0 1 22 48 1.0 0 1 22 49 1.0 0 1 22 50 1.0 0 1 23 23 1.0 0 1 23 24 1.0 0 1 23 25 1.0 0 1 23 26 1.0 0 1 23 27 1.0 0 1 23 28 1.0 0 1 23 29 1.0 0 1 23 30 1.0 0 1 23 31 1.0 0 1 23 32 1.0 0 1 23 33 1.0 0 1 23 34 1.0 0 1 23 35 1.0 0 1 23 36 1.0 0 1 23 37 1.0 0 1 23 38 1.0 0 1 23 39 1.0 0 1 23 40 1.0 0 1 23 41 1.0 0 1 23 42 1.0 0 1 23 43 1.0 0 1 23 44 1.0 0 1 23 45 1.0 0 1 23 46 1.0 0 1 23 47 1.0 0 1 23 48 1.0 0 1 23 49 1.0 0 1 23 50 1.0 0 1 24 24 1.0 0 1 24 25 1.0 0 1 24 26 1.0 0 1 24 27 1.0 0 1 24 28 1.0 0 1 24 29 1.0 0 1 24 30 1.0 0 1 24 31 1.0 0 1 24 32 1.0 0 1 24 33 1.0 0 1 24 34 1.0 0 1 24 35 1.0 0 1 24 36 1.0 0 1 24 37 1.0 0 1 24 38 1.0 0 1 24 39 1.0 0 1 24 40 1.0 0 1 24 41 1.0 0 1 24 42 1.0 0 1 24 43 1.0 0 1 24 44 1.0 0 1 24 45 1.0 0 1 24 46 1.0 0 1 24 47 1.0 0 1 24 48 1.0 0 1 24 49 1.0 0 1 24 50 1.0 0 1 25 25 1.0 0 1 25 26 1.0 0 1 25 27 1.0 0 1 25 28 1.0 0 1 25 29 1.0 0 1 25 30 1.0 0 1 25 31 1.0 0 1 25 32 1.0 0 1 25 33 1.0 0 1 25 34 1.0 0 1 25 35 1.0 0 1 25 36 1.0 0 1 25 37 1.0 0 1 25 38 1.0 0 1 25 39 1.0 0 1 25 40 1.0 0 1 25 41 1.0 0 1 25 42 1.0 0 1 25 43 1.0 0 1 25 44 1.0 0 1 25 45 1.0 0 1 25 46 1.0 0 1 25 47 1.0 0 1 25 48 1.0 0 1 25 49 1.0 0 1 25 50 1.0 0 1 26 26 1.0 0 1 26 27 1.0 0 1 26 28 1.0 0 1 26 29 1.0 0 1 26 30 1.0 0 1 26 31 1.0 0 1 26 32 1.0 0 1 26 33 1.0 0 1 26 34 1.0 0 1 26 35 1.0 0 1 26 36 1.0 0 1 26 37 1.0 0 1 26 38 1.0 0 1 26 39 1.0 0 1 26 40 1.0 0 1 26 41 1.0 0 1 26 42 1.0 0 1 26 43 1.0 0 1 26 44 1.0 0 1 26 45 1.0 0 1 26 46 1.0 0 1 26 47 1.0 0 1 26 48 1.0 0 1 26 49 1.0 0 1 26 50 1.0 0 1 27 27 1.0 0 1 27 28 1.0 0 1 27 29 1.0 0 1 27 30 1.0 0 1 27 31 1.0 0 1 27 32 1.0 0 1 27 33 1.0 0 1 27 34 1.0 0 1 27 35 1.0 0 1 27 36 1.0 0 1 27 37 1.0 0 1 27 38 1.0 0 1 27 39 1.0 0 1 27 40 1.0 0 1 27 41 1.0 0 1 27 42 1.0 0 1 27 43 1.0 0 1 27 44 1.0 0 1 27 45 1.0 0 1 27 46 1.0 0 1 27 47 1.0 0 1 27 48 1.0 0 1 27 49 1.0 0 1 27 50 1.0 0 1 28 28 1.0 0 1 28 29 1.0 0 1 28 30 1.0 0 1 28 31 1.0 0 1 28 32 1.0 0 1 28 33 1.0 0 1 28 34 1.0 0 1 28 35 1.0 0 1 28 36 1.0 0 1 28 37 1.0 0 1 28 38 1.0 0 1 28 39 1.0 0 1 28 40 1.0 0 1 28 41 1.0 0 1 28 42 1.0 0 1 28 43 1.0 0 1 28 44 1.0 0 1 28 45 1.0 0 1 28 46 1.0 0 1 28 47 1.0 0 1 28 48 1.0 0 1 28 49 1.0 0 1 28 50 1.0 0 1 29 29 1.0 0 1 29 30 1.0 0 1 29 31 1.0 0 1 29 32 1.0 0 1 29 33 1.0 0 1 29 34 1.0 0 1 29 35 1.0 0 1 29 36 1.0 0 1 29 37 1.0 0 1 29 38 1.0 0 1 29 39 1.0 0 1 29 40 1.0 0 1 29 41 1.0 0 1 29 42 1.0 0 1 29 43 1.0 0 1 29 44 1.0 0 1 29 45 1.0 0 1 29 46 1.0 0 1 29 47 1.0 0 1 29 48 1.0 0 1 29 49 1.0 0 1 29 50 1.0 0 1 30 30 1.0 0 1 30 31 1.0 0 1 30 32 1.0 0 1 30 33 1.0 0 1 30 34 1.0 0 1 30 35 1.0 0 1 30 36 1.0 0 1 30 37 1.0 0 1 30 38 1.0 0 1 30 39 1.0 0 1 30 40 1.0 0 1 30 41 1.0 0 1 30 42 1.0 0 1 30 43 1.0 0 1 30 44 1.0 0 1 30 45 1.0 0 1 30 46 1.0 0 1 30 47 1.0 0 1 30 48 1.0 0 1 30 49 1.0 0 1 30 50 1.0 0 1 31 31 1.0 0 1 31 32 1.0 0 1 31 33 1.0 0 1 31 34 1.0 0 1 31 35 1.0 0 1 31 36 1.0 0 1 31 37 1.0 0 1 31 38 1.0 0 1 31 39 1.0 0 1 31 40 1.0 0 1 31 41 1.0 0 1 31 42 1.0 0 1 31 43 1.0 0 1 31 44 1.0 0 1 31 45 1.0 0 1 31 46 1.0 0 1 31 47 1.0 0 1 31 48 1.0 0 1 31 49 1.0 0 1 31 50 1.0 0 1 32 32 1.0 0 1 32 33 1.0 0 1 32 34 1.0 0 1 32 35 1.0 0 1 32 36 1.0 0 1 32 37 1.0 0 1 32 38 1.0 0 1 32 39 1.0 0 1 32 40 1.0 0 1 32 41 1.0 0 1 32 42 1.0 0 1 32 43 1.0 0 1 32 44 1.0 0 1 32 45 1.0 0 1 32 46 1.0 0 1 32 47 1.0 0 1 32 48 1.0 0 1 32 49 1.0 0 1 32 50 1.0 0 1 33 33 1.0 0 1 33 34 1.0 0 1 33 35 1.0 0 1 33 36 1.0 0 1 33 37 1.0 0 1 33 38 1.0 0 1 33 39 1.0 0 1 33 40 1.0 0 1 33 41 1.0 0 1 33 42 1.0 0 1 33 43 1.0 0 1 33 44 1.0 0 1 33 45 1.0 0 1 33 46 1.0 0 1 33 47 1.0 0 1 33 48 1.0 0 1 33 49 1.0 0 1 33 50 1.0 0 1 34 34 1.0 0 1 34 35 1.0 0 1 34 36 1.0 0 1 34 37 1.0 0 1 34 38 1.0 0 1 34 39 1.0 0 1 34 40 1.0 0 1 34 41 1.0 0 1 34 42 1.0 0 1 34 43 1.0 0 1 34 44 1.0 0 1 34 45 1.0 0 1 34 46 1.0 0 1 34 47 1.0 0 1 34 48 1.0 0 1 34 49 1.0 0 1 34 50 1.0 0 1 35 35 1.0 0 1 35 36 1.0 0 1 35 37 1.0 0 1 35 38 1.0 0 1 35 39 1.0 0 1 35 40 1.0 0 1 35 41 1.0 0 1 35 42 1.0 0 1 35 43 1.0 0 1 35 44 1.0 0 1 35 45 1.0 0 1 35 46 1.0 0 1 35 47 1.0 0 1 35 48 1.0 0 1 35 49 1.0 0 1 35 50 1.0 0 1 36 36 1.0 0 1 36 37 1.0 0 1 36 38 1.0 0 1 36 39 1.0 0 1 36 40 1.0 0 1 36 41 1.0 0 1 36 42 1.0 0 1 36 43 1.0 0 1 36 44 1.0 0 1 36 45 1.0 0 1 36 46 1.0 0 1 36 47 1.0 0 1 36 48 1.0 0 1 36 49 1.0 0 1 36 50 1.0 0 1 37 37 1.0 0 1 37 38 1.0 0 1 37 39 1.0 0 1 37 40 1.0 0 1 37 41 1.0 0 1 37 42 1.0 0 1 37 43 1.0 0 1 37 44 1.0 0 1 37 45 1.0 0 1 37 46 1.0 0 1 37 47 1.0 0 1 37 48 1.0 0 1 37 49 1.0 0 1 37 50 1.0 0 1 38 38 1.0 0 1 38 39 1.0 0 1 38 40 1.0 0 1 38 41 1.0 0 1 38 42 1.0 0 1 38 43 1.0 0 1 38 44 1.0 0 1 38 45 1.0 0 1 38 46 1.0 0 1 38 47 1.0 0 1 38 48 1.0 0 1 38 49 1.0 0 1 38 50 1.0 0 1 39 39 1.0 0 1 39 40 1.0 0 1 39 41 1.0 0 1 39 42 1.0 0 1 39 43 1.0 0 1 39 44 1.0 0 1 39 45 1.0 0 1 39 46 1.0 0 1 39 47 1.0 0 1 39 48 1.0 0 1 39 49 1.0 0 1 39 50 1.0 0 1 40 40 1.0 0 1 40 41 1.0 0 1 40 42 1.0 0 1 40 43 1.0 0 1 40 44 1.0 0 1 40 45 1.0 0 1 40 46 1.0 0 1 40 47 1.0 0 1 40 48 1.0 0 1 40 49 1.0 0 1 40 50 1.0 0 1 41 41 1.0 0 1 41 42 1.0 0 1 41 43 1.0 0 1 41 44 1.0 0 1 41 45 1.0 0 1 41 46 1.0 0 1 41 47 1.0 0 1 41 48 1.0 0 1 41 49 1.0 0 1 41 50 1.0 0 1 42 42 1.0 0 1 42 43 1.0 0 1 42 44 1.0 0 1 42 45 1.0 0 1 42 46 1.0 0 1 42 47 1.0 0 1 42 48 1.0 0 1 42 49 1.0 0 1 42 50 1.0 0 1 43 43 1.0 0 1 43 44 1.0 0 1 43 45 1.0 0 1 43 46 1.0 0 1 43 47 1.0 0 1 43 48 1.0 0 1 43 49 1.0 0 1 43 50 1.0 0 1 44 44 1.0 0 1 44 45 1.0 0 1 44 46 1.0 0 1 44 47 1.0 0 1 44 48 1.0 0 1 44 49 1.0 0 1 44 50 1.0 0 1 45 45 1.0 0 1 45 46 1.0 0 1 45 47 1.0 0 1 45 48 1.0 0 1 45 49 1.0 0 1 45 50 1.0 0 1 46 46 1.0 0 1 46 47 1.0 0 1 46 48 1.0 0 1 46 49 1.0 0 1 46 50 1.0 0 1 47 47 1.0 0 1 47 48 1.0 0 1 47 49 1.0 0 1 47 50 1.0 0 1 48 48 1.0 0 1 48 49 1.0 0 1 48 50 1.0 0 1 49 49 1.0 0 1 49 50 1.0 0 1 50 50 1.0 1 1 1 1 1.0 1 1 2 2 1.0 1 1 3 3 1.0 1 1 4 4 1.0 1 1 5 5 1.0 1 1 6 6 1.0 1 1 7 7 1.0 1 1 8 8 1.0 1 1 9 9 1.0 1 1 10 10 1.0 1 1 11 11 1.0 1 1 12 12 1.0 1 1 13 13 1.0 1 1 14 14 1.0 1 1 15 15 1.0 1 1 16 16 1.0 1 1 17 17 1.0 1 1 18 18 1.0 1 1 19 19 1.0 1 1 20 20 1.0 1 1 21 21 1.0 1 1 22 22 1.0 1 1 23 23 1.0 1 1 24 24 1.0 1 1 25 25 1.0 1 1 26 26 1.0 1 1 27 27 1.0 1 1 28 28 1.0 1 1 29 29 1.0 1 1 30 30 1.0 1 1 31 31 1.0 1 1 32 32 1.0 1 1 33 33 1.0 1 1 34 34 1.0 1 1 35 35 1.0 1 1 36 36 1.0 1 1 37 37 1.0 1 1 38 38 1.0 1 1 39 39 1.0 1 1 40 40 1.0 1 1 41 41 1.0 1 1 42 42 1.0 1 1 43 43 1.0 1 1 44 44 1.0 1 1 45 45 1.0 1 1 46 46 1.0 1 1 47 47 1.0 1 1 48 48 1.0 1 1 49 49 1.0 1 1 50 50 1.0 2 1 1 2 5.0e-01 3 1 1 28 5.0e-01 4 1 1 50 5.0e-01 5 1 2 21 5.0e-01 6 1 2 22 5.0e-01 7 1 2 36 5.0e-01 8 1 2 49 5.0e-01 9 1 3 10 5.0e-01 10 1 3 30 5.0e-01 11 1 3 34 5.0e-01 12 1 3 35 5.0e-01 13 1 3 49 5.0e-01 14 1 4 11 5.0e-01 15 1 4 12 5.0e-01 16 1 4 17 5.0e-01 17 1 4 34 5.0e-01 18 1 5 18 5.0e-01 19 1 5 19 5.0e-01 20 1 5 34 5.0e-01 21 1 5 46 5.0e-01 22 1 6 19 5.0e-01 23 1 6 21 5.0e-01 24 1 6 30 5.0e-01 25 1 6 38 5.0e-01 26 1 7 9 5.0e-01 27 1 7 22 5.0e-01 28 1 7 23 5.0e-01 29 1 7 44 5.0e-01 30 1 7 45 5.0e-01 31 1 8 29 5.0e-01 32 1 8 31 5.0e-01 33 1 8 34 5.0e-01 34 1 9 20 5.0e-01 35 1 9 33 5.0e-01 36 1 10 23 5.0e-01 37 1 10 38 5.0e-01 38 1 10 49 5.0e-01 39 1 11 22 5.0e-01 40 1 11 34 5.0e-01 41 1 11 35 5.0e-01 42 1 11 46 5.0e-01 43 1 12 14 5.0e-01 44 1 13 17 5.0e-01 45 1 13 47 5.0e-01 46 1 14 15 5.0e-01 47 1 14 34 5.0e-01 48 1 14 38 5.0e-01 49 1 14 39 5.0e-01 50 1 14 49 5.0e-01 51 1 15 16 5.0e-01 52 1 15 28 5.0e-01 53 1 15 35 5.0e-01 54 1 15 46 5.0e-01 55 1 15 48 5.0e-01 56 1 16 28 5.0e-01 57 1 16 30 5.0e-01 58 1 16 43 5.0e-01 59 1 17 30 5.0e-01 60 1 18 37 5.0e-01 61 1 18 38 5.0e-01 62 1 19 21 5.0e-01 63 1 19 25 5.0e-01 64 1 19 39 5.0e-01 65 1 19 41 5.0e-01 66 1 20 30 5.0e-01 67 1 20 34 5.0e-01 68 1 21 33 5.0e-01 69 1 21 46 5.0e-01 70 1 22 37 5.0e-01 71 1 22 40 5.0e-01 72 1 23 30 5.0e-01 73 1 23 37 5.0e-01 74 1 23 39 5.0e-01 75 1 23 43 5.0e-01 76 1 23 46 5.0e-01 77 1 24 25 5.0e-01 78 1 25 33 5.0e-01 79 1 25 38 5.0e-01 80 1 26 39 5.0e-01 81 1 26 46 5.0e-01 82 1 27 29 5.0e-01 83 1 30 31 5.0e-01 84 1 30 36 5.0e-01 85 1 32 33 5.0e-01 86 1 32 43 5.0e-01 87 1 32 46 5.0e-01 88 1 33 41 5.0e-01 89 1 33 46 5.0e-01 90 1 33 48 5.0e-01 91 1 35 40 5.0e-01 92 1 35 48 5.0e-01 93 1 36 46 5.0e-01 94 1 37 39 5.0e-01 95 1 37 42 5.0e-01 96 1 37 43 5.0e-01 97 1 37 48 5.0e-01 98 1 38 42 5.0e-01 99 1 39 45 5.0e-01 100 1 39 46 5.0e-01 101 1 40 41 5.0e-01 102 1 40 47 5.0e-01 103 1 41 43 5.0e-01 104 1 43 48 5.0e-01 DSDP5.8/pdsdp/PETSc/pdsdp5petsc.h0000644000175000017500000000020310326241002016421 0ustar twernertwerner#include "../../include/dsdp5.h" #include "petscksp.h" int PDSDPUsePETScLinearSolver(DSDP, MPI_Comm, int); void DSDPSetRank(int); DSDP5.8/pdsdp/README0000644000175000017500000000044010326241002013757 0ustar twernertwernerDSDP can be run in parallel using parallel either the parallel Cholesky solver from ScaLAPACK or the parallel preconditioned Conjugate Gradient method from PETSc. For most problems, the Cholesky solver is recommended. It has proven to be more robust, and it is faster on most problems. DSDP5.8/pdsdp/ScaLAPACK/0000755000175000017500000000000010326241002014463 5ustar twernertwernerDSDP5.8/pdsdp/ScaLAPACK/Makefile0000644000175000017500000000305710326241002016130 0ustar twernertwerner default: all include ../../make.include SCALAPACKDIR=/home/benson/soft/SCALAPACK BLACSDIR=/home/benson/soft/BLACS/LIB #MPIHOME = /home/benson/petsc-2.3.0/externalpackages/mpich2-1.0.1/linux-gnu-O MPIHOME = /home/petsc/soft/linux-debian_sarge-gcc-pgf90/mpich-1.2.6 #MPIHOME = /home/petsc/soft/linux-2/mpich-1.2.5 DCFLAGS = -I${SCALAPACKDIR}/PBLAS/SRC -I${MPIHOME}/include/ SCALAPACKLIB = -L${SCALAPACKDIR} -lscalapack COMMPLAT=MPI-LINUX-0 #BLACSLIB = ${BLACSDIR}/blacsCinit_${COMMPLAT}.a ${BLACSDIR}/blacsF77init_${COMMPLAT}.a ${BLACSDIR}/blacs_${COMMPLAT}.a BLACSLIB = -L${BLACSDIR}/ -lblacsCinit_${COMMPLAT} -lblacsF77init_${COMMPLAT} -lblacs_${COMMPLAT} #MPI = -L${MPIHOME}/lib -lfmpich -lmpich MPI = -L${MPIHOME}/lib -lmpich #MPI = -L${MPIHOME}/lib -lfmpich -lmpich -lmpichf90 -lmpichf90nc -lmpichfsup #MPI = ${MPIHOME}/lib/*.a LAPACKBLAS = /usr/lib/liblapack.a -lblas -lf2c -lm ALLLIBS = ${DSDPLIB} ${SCALAPACKLIB} ${BLACSLIB} ${MPI} ${LAPACKBLAS} FLINKER = mpicc OBJS = readsdpa.o pdsdpscalapack.o dsdpsdpa: ${OBJS} ${FLINKER} -o pdsdp5 ${OBJS} ${ALLLIBS} ${RM} ${OBJS} OBJS2 = maxcut.o pdsdpscalapack.o maxcut: ${OBJS2} ${CLINKER} -o pmaxcut ${OBJS2} ${ALLLIBS} ${RM} ${OBJS2} info2: -@echo "======================================================" -@echo "Compiling PDSDP using SCLAPACK parallel linear solver." -@echo " Check ../../make.include to set compiler." -@echo " the mpicc compiler may produce faster DSDP libraries" -@echo "======================================================" clean: ${RM} ${OBJS} all: info info2 dsdpsdpa DSDP5.8/pdsdp/ScaLAPACK/pdsdp5scalapack.h0000644000175000017500000000041010326241002017671 0ustar twernertwerner#include "dsdp5.h" #include "mpi.h" int PDSDPUseSCALAPACKLinearSolver(DSDP); void DSDPSetRank(int); /* To use PDSDP, 1. Get a problem working using DSDP. 2. Add the routines: -- MPI_Initialize() -- MPI_Finalize() -- PDSDPUseSCALAPACKLinearSolver() */ DSDP5.8/pdsdp/ScaLAPACK/readsdpa.o0000644000175000017500000007320410326241002016434 0ustar twernertwernerELF ]4( U]U$M L$\$$[ $U T$U$؋]]Í'UW1V11S ($= 5 =1Cit$$D$d $5h=fL$5HON 1,=1҉(11}048f9ƅ;}u19}} 4WC;]|;]"$ ]KKU ]v>j#t+1u7>rK!$:$1d\$D<$T$t$(L$<$kZZ\$|$H$$Z(T$L$t$|$$($u11ɉ=4$$D$.@b $1;}&t&E G4oC;|ދL$4$T$$1ۉ|$;@V|$󥋍 $(݅ٞyغ11ۉ011ɉ489׉,}:'$|$$ËT$ t$L$݅zu $:݅ $L$@ݝH D$ D$݅Hrh\$ @t$$|$݅Hٞr,\$ QT$$L$Ji݅tܭ`D$8@|$ (\$$EL$t$T$ \$|$$݅@tܭ`D$8@t$ (\$$EL$|$T$ \$t$$$$ $`$$$ ƅs$bs!L$D$$~؁Ĝ[^_]$`݅$xܭ\$E$\$E\$ E\$\$$݅x$\$\$t<$݅x$\$\$4$$tL$$ vۅ8$\$\$4$1ɉL$\$ T$<$$n$K$($$$$݅ܭ$`\$\$4$|$PT$ $@418< ~$L$=1;@#v'C;@~1;@Gt&'\$4T$ljL$ |$ $TC4;@~;@&<|C;@~t$ ϋT$4$$st$D$֋;mD$\$<\$L$T$ |$4$|4D<\$\$D$ |$$uJP>|$<ډL$T$ D$$t$$T$뚾st$L$ss؉ٽF F݅$f fD\$٭D\$٭F݅$\$ ݅\$t$ L$T$|$$t&C\$\$$;@|1;@hv'vWC;@}1;@{މ|$$\$;@|맋M 11Dt$ T$|$$$1ɉL$Z$T$$t$$\$$ |$݅ܭ$ \$$+jh(T$4$$E|$L$"$u144$} Zt$(_\$$E ZL$P4$T$$-hT$O4$L$Z1 y1ɉD$ t$L$<$((|$p$t$ 7HT$x $|$>UZ(T$p $t$7ZT$x $|$>ZT$IH<$L$<$t$1ɉ$5E C$KL$;]|$DD$U1҉WJVSuT$ $D$fHf1|$D$$4$1҉tIT$|t&'|$u8<*t<"u)|\$4$|$t붍O\$t$ $|\$4$|$tOL$T$<$Ht&$`tD$ļ[^_]Ëu BF4F8F<^PF~7$T$Ft$1ɉL$Ft$] BC$~B$T$} ‰G$t$1D$ L$] BC ~7$|$C t$1ۉ\$AL$t1p9p? E p$|uJ|\$$|$M A~>$L$u ‰Ft$1D$\$] C~9$T$Ct$1|$t$t1ɉp9p|R\$$H" t$|TT$$Hto|X|$L$$ u$[|$t$$pt\$L$7݅] pspp; |\$ $|$t1҉lx|<$ƅt$|ݝ|$4$\$T$L$tT$ L$\$4$ <$t:t-$tL$D$݅zl] s$D99xzxv9Ax=;zT$ tt$D$T$$ T$ t|$D$\$$`$JtL$ sD$t$T$릍|$|t$K|$z|$ L$t$뽃݅ut$t$xD$&Dlu lF~9lD$$Ft$l1t$L$l] C ~>lt$$‹E ҉P t$l1ɉL$|$lu ~8lL$$t$l1t$|$l] C~tEM1[[^_]ËM9~EB9D$ \$NEȋE$UMDt۞]Ȁ}U}Pt#؋MMOEE;Mq]O]}t E΋tDuz]Ouz΍GU}H9u눋]]KtEltDuz݋Muz΋]ԋE9u1 $MED$u 1ۉ\$1L$ t$;}EUUEUE1;}}뱋E 4DE99uuD9~뎋u uU99MUu94>Eu U44uΐt&1I9 ;U|!uE 4Eu9|9uϋuE9}ĉEU ȋ44u؋1҅DSDP Usage: dsdp5 filename -print <10> - print information at each k iteration -save -fout to print standard monitor to a file -y0 -benchmark -directory -suffix -dloginfo <0> - print more information for higher numbers -dlogsummary <1> - print timing information -help for this help message /home/benson/sdpexamples/sdplib/.dat-sresults-dsdp-5.7*-help-benchmark-directory-table-suffix-save-dlogsummary-fout%s-dloginfoDSDP Finished P Objective : %16.8e DSDP Solution: %16.8e a P Infeasible: %8.2e D Infeasible: %8.2e Minimal P Eigenvalue: %6.2e Minimal D Eigenvalue: 0.00 Relative X Dot S: %4.2e Trace X: %4.8e, --- DSDP Finished --- w2 %d 1 1 %12.8e 2 %d 2 2 %12.8e DSDP Converged. readsdpa.cReadSDPAFileScale C: %4.2e Potential Parameter: %4.2f Reapply Schur matrix: %d Fixed: %2.0f %4.2f ? Variables %d Matrix Blocks: %d, Nonzeros in Constraints: %d Problem reading SDPA file%s r%s %d,%lg%cConstraints: %d, Blocks: %d Error: line %d %s Please check data file %d %d %d %2.10e %d %d %d %2.10e {(Error block sizes, line %dCannot open file %s !%d %d %d %d %lg-params-print%lfDSDP Solve Time: %4.3e seconds DSDP Preparation and Solve Time: %4.3e seconds %-18s & %4d & %4d & %13.7f & %13.7f & %4.0e & %c & %3d & %6.2f \\ Relative P - D Objective values: %4.2e Max Y: %10.8e, Bounded by %6.1e Bounded by Penalty Parameter: %4.1e 1 %d 1 1 1.0e-11 1 %d 2 2 1.0e-11 %-18s & %4d & %4d & unbounded & infeasible & %4.0e & %c & %3d & %6.2f \\ %-18s & %4d & %4d & infeasible & unbounded & %4.0e & %c & %3d & %6.2f \\ DSDP Primal Unbounded, Dual InfeasibleDSDP Dual Unbounded, Primal InfeasibleDSDP Terminated Due to Indefinite Schur ComplementDSDP Terminated Due to Infeasible Starting PointDSDP Terminated Due Maximum Number of IterationsDSDP Terminated Due to Small StepsDSDP Terminated Because Dual Objective Exceeded its Bound Numerical errors encountered in DSDPSolve(). DSDP Process Data: %4.3e seconds Data Norms: C: %4.2e, A: %4.2e, b: %4.2e Problem Setting problem. Likely insufficient memoryDSDP Set Data: %4.3e seconds Possible problem in variable %d, block %d. Total Number of Constraints: %d Read Data File into Buffer: %4.3e seconds Error: line %d. Number of blocks not given. Error reading objective, line %d, i=%d Problem Reading SDPA file at line %d: %s Data Error in line: %d. Is Block 0 <= %d <= %d %sData Error in line: %d. Is Var 0 <= %d <= %d %sData Error in line: %d. Row %d or col %d <= 0 %sData Error in line: %d. Row %d or col %d > blocksize %d %sProblem could be earlier in file The first recorded matix nonzero in the file occured at line %d: %sWarning: Line: %d Row < Column. %s DSDPError: Reading Input File:Possible problem with data input file: Double Entry: Error: line %d. Number of constraints not given. Warning: reading initial y vector: Expecting %d entries but read only %d entries Cannot open file containing initial dual solution %sB$tI PGMbP?|=|۽ư>GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13).symtab.strtab.shstrtab.rel.text.data.bss.rodata.rodata.str1.1.rodata.str1.32.rodata.cst4.rodata.cst8.note.GNU-stack.comment@; lj %`; +>0 >^ 82~N%G2Qw W8\dP\ qp\p\&\x_0 e  7 0.*666A -MLp-Ha-pu+p,p98  cp0#,7IYj #*9IWo{(@GUi|*/@GMglxreadsdpa.chelprankReadSDPA2ComputeY0TCheckArgs0TCheckArgsGetMarkersCountNonzeroMatricesCheckForConstantMatParselinequsortpartitionReadInitialPointmainMPI_InitMPI_Comm_rankDSDPSetRankReadSDPAFileMPI_FinalizememsetputcharfgetssscanfstrncpystrncatputsdsdpoutputfileDSDPTimeDSDPCreateDSDPCreateSDPConeDSDPReuseMatrixDSDPGetDataNormsPDSDPUseSCALAPACKLinearSolverDSDPSetupDSDPSolveDSDPStopReasonDSDPComputeXDSDPGetSolutionTypeDSDPGetDObjectiveDSDPGetPObjectiveprintfDSDPGetFinalErrorsDSDPGetItsfopenfprintffcloseDSDPGetYBoundsDSDPGetYMaxNormDSDPGetTraceXDSDPGetPenaltyParameterDSDPDestroyfreeDSDPPrintSolutionDSDPEventLogSummaryDSDPErrorDSDPGetScaleDSDPGetPotentialParameterDSDPGetReuseMatrixDSDPSetR0DSDPSetGapToleranceDSDPSetYBoundsDSDPCreateLPConeSDPConeSetStorageFormatcallocLPConeSetDataSDPConeSetBlockSizeSDPConeSetSparsitySDPConeSetASparseVecMatSDPConeSetADenseVecMatSDPConeSetConstantMatSDPConeSetXArrayDSDPSetY0DSDPSetFixedVariablesDSDPSetDualObjective__strtol_internalDSDPLogInfoAllowfeofDSDPPrintOptionsfscanffseekDSDPSetPotentialParametersqrtDSDPSetZBarDSDPSetOptionsDSDPSetStandardMonitorDSDPSetFileMonitorDSDPReadOptions/5=OV6=P\lsF 5!"#$$&%,H&\''( )'*b+,-' ".B/Y0{/1'%+ 2I 3V _ 4l u 4  4  4 5 6  7  u 8 9  4  4  4  %  4  4 : ;)  < 4N <[ d 4v =  4  % > & 9 ? ?" . 7V @q 9  8   8    8, A<  8   %     + 7 <%OVjoB % 4 4C4D&48E?N4Z _%F GH?????? ?8 A4dIJKL 40:MNJvO 4P.QwR 4S&94bTU SXVfWr44 44 4 7"&'8K9t##X# V8#z###$#57js44Y 7:Xn!"!" 4RKrKK c!KK!3ZKWZe{Z4 4!JX! X/  H 4  4! ! Z! u!4!"K*"U"K|""K""K#9#[{##Z#X#!U$X$ $4$ $%$ $4$$%% %48& W&4^& c&%&#}' '%' '%''4( (4#)9* w**Z**Z**Z**Z++ +,7,"/ 0\0**0]V2 2 2S2F2 2^2\2* 3]3]5S)5F85 L5^c5\:6X6W6V 7Kv7S7_77`77a8?8*8=8p8V8b8878X89Z9909 59%<9 O94\9 a94DSDP5.8/pdsdp/ScaLAPACK/readsdpa.c0000644000175000017500000007265510326241002016431 0ustar twernertwerner#include "dsdp5.h" #include #include #include #include #include "pdsdp5scalapack.h" /*! \file readsdpa.c \brief Read SDPA data files, pass data into DSDP solver, and print solution. */ /* static char help[]="\n"; */ static char help[]="\ DSDP Usage: dsdp5 filename \n\ -print <10> - print information at each k iteration\n\ -save \n\ -fout to print standard monitor to a file\n\ -y0 \n\ -benchmark \n\ -directory \n\ -suffix \n\ -dloginfo <0> - print more information for higher numbers \n\ -dlogsummary <1> - print timing information \n\ -help for this help message\n"; static int qusort(int[],int[],int[],double[],int,int); static int partition(int[],int[],int[],double[],int, int); static int Parseline(char *,int *,int *,int *,int *,double *, int *); static int ReadInitialPoint(char*, int, double[]); static int TCheckArgs0(DSDP,SDPCone,int,int,char *[]); static int TCheckArgs(DSDP,SDPCone,int,int,char *[]); static int CheckForConstantMat(double[],int, int); static int CountNonzeroMatrices(int, int[],int[], int*); typedef struct{ char sformat; int blocksize; } DBlock; typedef struct{ int *block,*constraint,*matind; double*nnz; char *sformat; int totalnonzeros; double *dobj,*y0; char *conetypes; int *blocksizes; int m; int n; int nblocks; int lpn,lpspot,lpblock,lpnnz; int *lpi,*lui,*cmap; double cnorm; double fixedvari; double fixedvard,xout; } DSDPData; static int ReadSDPA2(char*,DSDPData*); static int GetMarkers(int, int, int*, int*, int*); static int ComputeY0(DSDP,DSDPData); static int rank=0; int ReadSDPAFile(int argc,char *argv[]); #define CHKDATA(a,b,c) { if (c){ printf("Possible problem in variable %d, block %d. \n",a+1,b+1);} } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char *argv[]){ int info; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&rank); DSDPSetRank(rank); info=ReadSDPAFile(argc,argv); MPI_Finalize( ); return info; } #undef __FUNCT__ #define __FUNCT__ "ReadSDPAFile" /*! \fn int ReadSDPAFile(int argc,char *argv[]); \brief Read SDPA formatted file and solve the semidefinite program. \param argc number of command line arguments \param argv command line arguments \ingroup Examples */ int ReadSDPAFile(int argc,char *argv[]){ int i,j,m,n,np,its,info; int spot,ijnnz,nzmats,sdpnmax,sdpn,stat1,printsummary=1; int runbenchmark=0,saveit=0,justone=1,fileout=0; double t1,t2,t3,t4,t5,dd,yhigh; double derr[6],dnorm[3]; double ddobj,ppobj; char problemname[100],thisline[100], filename[300],savefile[100]; char directory[100]="/home/benson/sdpexamples/sdplib/"; char outputfile[50]="",suffix[20]=".dat-s", tablename[20]="results-dsdp-5.7"; char success='f',sformat; FILE *fp1=0,*fp2=0,*fout; DSDPData dddd; DSDP dsdp; DSDPTerminationReason reason; DSDPSolutionType pdfeasible; SDPCone sdpcone=0; LPCone lpcone=0; int *ittt,sspot; if (argc<2){ printf("%s",help); DSDPPrintOptions(); return(0); } for (i=0; i 0.0) dddd.y0[i]=-0.0; else dddd.y0[i]=0.0; for (i=0; i=m && its==0) its=1; if (its>=1) its++; its=its*its; if (m<2000 && its>10) its=10; if (its>12) its=12; info=DSDPReuseMatrix(dsdp,its); DSDPFREE(&dddd.blocksizes,&info); DSDPFREE(&dddd.sformat,&info); DSDPFREE(&dddd.dobj,&info); DSDPFREE(&dddd.y0,&info); DSDPFREE(&dddd.conetypes,&info); DSDPFREE(&dddd.constraint,&info); DSDPFREE(&dddd.block,&info); info=DSDPGetDataNorms(dsdp, dnorm); if (dnorm[0]==0){ info=DSDPSetR0(dsdp,np); info=DSDPSetGapTolerance(dsdp,1e-3); info=DSDPSetYBounds(dsdp,-1.0,1.0); } else { } info = TCheckArgs0(dsdp,sdpcone,dddd.m,argc,argv); info = TCheckArgs(dsdp,sdpcone,dddd.m,argc,argv); info=PDSDPUseSCALAPACKLinearSolver(dsdp); info = DSDPSetup(dsdp); if (info){ printf("\nProblem Setting problem. Likely insufficient memory\n"); return 1;} if (0==1){info=SDPConeCheckData(sdpcone);} DSDPTime(&t4); if (rank==0){ printf("DSDP Process Data: %4.3e seconds\n\n",t4-t3); printf("Data Norms: C: %4.2e, A: %4.2e, b: %4.2e\n",dnorm[0],dnorm[1],dnorm[2]); info=DSDPGetScale(dsdp,&ddobj); printf("Scale C: %4.2e\n\n",ddobj); info=DSDPGetPotentialParameter(dsdp,&ddobj); printf("Potential Parameter: %4.2f\n",ddobj); info=DSDPGetReuseMatrix(dsdp,&its); printf("Reapply Schur matrix: %d\n\n",its); } if (0==1){info=DSDPPrintData(dsdp,sdpcone,lpcone);} info = DSDPSolve(dsdp); if (info){ printf("\nNumerical errors encountered in DSDPSolve(). \n");} info=DSDPStopReason(dsdp,&reason); if (reason!=DSDP_INFEASIBLE_START){ info=DSDPComputeX(dsdp);DSDPCHKERR(info); } info=DSDPStopReason(dsdp,&reason); info=DSDPGetSolutionType(dsdp,&pdfeasible); DSDPTime(&t5); if (rank==0){ if (reason == DSDP_CONVERGED){ printf("DSDP Converged. \n"); success='s'; } else if ( reason == DSDP_UPPERBOUND ){ printf("DSDP Terminated Because Dual Objective Exceeded its Bound\n"); success='s'; } else if ( reason == DSDP_SMALL_STEPS ){ printf("DSDP Terminated Due to Small Steps\n"); success='f'; } else if ( reason == DSDP_MAX_IT){ printf("DSDP Terminated Due Maximum Number of Iterations\n"); success='f'; } else if ( reason == DSDP_INFEASIBLE_START){ printf("DSDP Terminated Due to Infeasible Starting Point\n"); success='f'; } else if ( reason == DSDP_INDEFINITE_SCHUR_MATRIX){ printf("DSDP Terminated Due to Indefinite Schur Complement\n"); success='f'; } else { printf("DSDP Finished\n"); success='f'; } if (pdfeasible == DSDP_UNBOUNDED ){ printf("DSDP Dual Unbounded, Primal Infeasible\n"); } else if ( pdfeasible == DSDP_INFEASIBLE ){ printf("DSDP Primal Unbounded, Dual Infeasible\n"); } info=DSDPGetDObjective(dsdp,&ddobj); info=DSDPGetPObjective(dsdp,&ppobj); printf("\nP Objective : %16.8e \n",ppobj); printf("DSDP Solution: %16.8e \n\n",ddobj); printf("DSDP Solve Time: %4.3e seconds\n",t5-t4); printf("DSDP Preparation and Solve Time: %4.3e seconds\n\n",t5-t3); info=DSDPGetFinalErrors(dsdp,derr); info=DSDPGetIts(dsdp,&its); if (1 || runbenchmark){ fp2=fopen(tablename,"a"); if (pdfeasible==DSDP_UNBOUNDED){ fprintf(fp2," %-18s & %4d & %4d & infeasible & unbounded & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else if (pdfeasible==DSDP_INFEASIBLE){ fprintf(fp2," %-18s & %4d & %4d & unbounded & infeasible & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,derr[0],success,its,t5-t3); } else { fprintf(fp2," %-18s & %4d & %4d & %13.7f & %13.7f & %4.0e & %c & %3d & %6.2f \\\\\n",problemname,m,np,-ppobj,-ddobj,derr[0],success,its,t5-t3); } fclose(fp2); } /* info=DSDPComputeMinimumXEigenvalue(dsdp,&derr[1]); */ printf("\nP Infeasible: %8.2e \n",derr[0]); printf("D Infeasible: %8.2e \n",derr[2]); printf("Minimal P Eigenvalue: %6.2e \n",derr[1]); printf("Minimal D Eigenvalue: 0.00 \n"); printf("Relative P - D Objective values: %4.2e \n",derr[4]); printf("Relative X Dot S: %4.2e \n",derr[5]); info=DSDPGetYBounds(dsdp,&dd,&yhigh); info=DSDPGetYMaxNorm(dsdp,&dd); printf("\nMax Y: %10.8e, Bounded by %6.1e\n",dd,yhigh); info=DSDPGetTraceX(dsdp,&dd); printf("Trace X: %4.8e, ",dd); info=DSDPGetPenaltyParameter(dsdp,&dd); printf("Bounded by Penalty Parameter: %4.1e \n\n",dd); if (printsummary){ DSDPEventLogSummary();} printf("--- DSDP Finished ---\n\n"); if (saveit){ fout=fopen(savefile,"w"); /* fprintf(fout,"** %s \n",filename); Deleted */ info= DSDPPrintSolution(fout,dsdp,sdpcone,lpcone); if (dddd.fixedvari){ sspot=dddd.nblocks+1,dd=dddd.xout; fprintf(fout,"1 %d 1 1 1.0e-11\n1 %d 2 2 1.0e-11\n",sspot,sspot); fprintf(fout,"2 %d 1 1 %12.8e\n",sspot,DSDPMax(1.0e-10,dd)); fprintf(fout,"2 %d 2 2 %12.8e\n",sspot,DSDPMax(1e-10,-dd)); } fclose(fout); } } info = DSDPDestroy(dsdp); DSDPFREE(&dddd.matind,&info); DSDPFREE(&dddd.nnz,&info); if (fileout){fclose(dsdpoutputfile);} if (0){ DSDPMemoryLog();} } if (runbenchmark){ fclose(fp1);} return 0; } /* main */ #define BUFFERSIZ 4000 #undef __FUNCT__ #define __FUNCT__ "ReadSDPA2" static int ReadSDPA2(char *filename, DSDPData*ddd){ FILE*fp; char ctmp,refline[BUFFERSIZ]="*",thisline[BUFFERSIZ]="*"; int info,tline,line=0; int i,k,m,n; /* int spot,nzmark, */ int bigint=1000000; int i1,nblk,nmat,col,row; int np=0,nblocks; int nargs,nonzero; double val; fp=fopen(filename,"r"); if (!fp){ printf("Cannot open file %s !",filename); return(1); } /* Read comments */ while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } /* Read number of constraints */ if (sscanf(thisline,"%d",&m)<1){ printf("Error: line %d. Number of constraints not given.\n",line); return(1); } /* Read number of blocks */ fgets(thisline,BUFFERSIZ,fp); line++; if (sscanf(thisline,"%d",&nblocks)!=1){ printf("Error: line %d. Number of blocks not given.\n",line); return(1); } ddd->lpn=0;ddd->lpspot=0;ddd->lpblock=0;ddd->cnorm=0; /* Read block sizes */ DSDPCALLOC2(&ddd->sformat,char, (nblocks+1),&info); DSDPCALLOC2(&ddd->blocksizes,int, (nblocks+1),&info); DSDPCALLOC2(&ddd->conetypes,char, (nblocks+1),&info ); line++; for (i=0;i0) { ddd->blocksizes[i]=col; np+=col; ddd->conetypes[i]='S'; } else if (col>0){ddd->blocksizes[i]=-col; np+=-col; ddd->conetypes[i]='S'; } else if (col<0){ddd->blocksizes[i]=-col; np += -col; ddd->conetypes[i]='L';ddd->lpn=-col;ddd->lpblock=i; } else { ddd->blocksizes[i]=0; ddd->conetypes[i]='N';} if (ddd->blocksizes[i]<10){ddd->sformat[i]='U';} else {ddd->sformat[i]='P';} } else{ printf("Error block sizes, line %d",line); return(1);} } if (ddd->blocksizes[nblocks-1]==0) nblocks--; fgets(thisline,BUFFERSIZ,fp); /* Read objective vector */ DSDPCALLOC2(&ddd->y0,double,m,&info); DSDPCALLOC2(&ddd->dobj,double,m,&info); line++; for (i=0;idobj[i]=val; } fgets(thisline,BUFFERSIZ,fp); tline=line; nargs=5; nonzero=0; while(!feof(fp)){ thisline[0]='\0'; nmat=-1; nblk=-1; row=-1; col=-1; val=0.0; fgets(thisline,BUFFERSIZ,fp); line++; info = Parseline(thisline,&nmat,&nblk,&row,&col,&val,&nargs); if (!feof(fp)&&nargs!=5&&nargs>0){ printf("Error: line %d \n%s\n",line,thisline);return 1;} if (nargs==5 && val!=0.0){ nonzero++; i1=row*(row+1)/2 + col; if (row >= ddd->blocksizes[nblk-1] || col >= ddd->blocksizes[nblk-1] ) { printf("Data Error in line: %d. Row %d or col %d > blocksize %d\n%s",line,row+1,col+1,ddd->blocksizes[nblk-1],thisline); return 1; } if (row<0 || col<0){ printf("Data Error in line: %d. Row %d or col %d <= 0 \n%s",line,row+1,col+1,thisline); return 1; } if (nmat>m || nmat<0){ printf("Data Error in line: %d. Is Var 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } if (nblk>nblocks || nblk<0){ printf("Data Error in line: %d. Is Block 0 <= %d <= %d \n%s",line,nmat,m,thisline); return 1; } } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); } } /* Allocate memory for the data */ nonzero++; DSDPCALLOC2(&ddd->matind,int,nonzero,&info); DSDPCALLOC2(&ddd->nnz,double,nonzero,&info); DSDPCALLOC2(&ddd->block,int,nonzero,&info); DSDPCALLOC2(&ddd->constraint,int,nonzero,&info); nonzero--; fseek(fp,0,SEEK_SET); line=0; for (i=0;i=nonzero && !feof(fp) ){ */ printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } if (nargs==5 && val!=0.0){ if (row>col){ printf("Warning: Line: %d Row < Column. %s \n",line,thisline); } i=row;row=col;col=i; n=ddd->blocksizes[nblk-1]; if (nmat==0) {val=-val;} if (ddd->conetypes[nblk-1]=='S'){ /* if (row==col) val/=2; */ ddd->matind[k]=row*(row+1)/2 + col; if (ddd->sformat[nblk-1]=='U'){ddd->matind[k]=row*n + col;} } else { ddd->matind[k]=col; } ddd->block[k]=nblk; ddd->constraint[k]=nmat; ddd->nnz[k]=val; k++; } else if (nargs==5 && val==0.0){ } else if (nargs==0){ } else { printf("Problem Reading SDPA file at line %d: %s\n",line, thisline); printf("Problem could be earlier in file \n"); printf("The first recorded matix nonzero in the file occured at line %d: \n %s",tline,refline); printf(" Please check data file\n"); return 1; } } ddd->block[k]=nblocks+1; ddd->constraint[k]=m+2; ddd->matind[k]=10000000; ddd->nnz[k]=0.0; qusort(ddd->block,ddd->constraint,ddd->matind,ddd->nnz,0,nonzero-1); for (i=0;imatind[i]==ddd->matind[i+1] && ddd->constraint[i]==ddd->constraint[i+1] && ddd->block[i]==ddd->block[i+1] ){ printf("DSDPError: Reading Input File:\n"); printf("Possible problem with data input file: Double Entry: \n"); printf(" %d %d %d %2.10e\n", ddd->constraint[i],ddd->block[i],ddd->matind[i]+1,ddd->nnz[i]); printf(" %d %d %d %2.10e\n\n", ddd->constraint[i+1],ddd->block[i+1],ddd->matind[i+1]+1,ddd->nnz[i+1]); for (k=i+1;kconstraint[k]=ddd->constraint[k+1]; ddd->block[k]=ddd->block[k+1]; ddd->matind[k]=ddd->matind[k+1];ddd->nnz[k]=ddd->nnz[k+1]; } ddd->constraint[nonzero-1]=bigint;ddd->nnz[nonzero-1]=0; nonzero--; } } ddd->fixedvari=0;ddd->fixedvard=0; if (ddd->lpblock>0){ int spot; if (ddd->blocksizes[ddd->lpblock]==2){ i=0;k=0; while (ddd->block[i]<=ddd->lpblock && iblock[i]==ddd->lpblock+1 && iconstraint[spot]==ddd->constraint[spot+1] && ddd->constraint[spot+2]==ddd->constraint[spot+3] && ddd->matind[spot]==ddd->matind[spot+2] && ddd->matind[spot+1]==ddd->matind[spot+3] && fabs(ddd->nnz[spot+2])==1.0 && fabs(ddd->nnz[spot+3])==1.0 && fabs(ddd->nnz[spot] + ddd->nnz[spot+1]) <=1e-6 ){ ddd->fixedvari=ddd->constraint[spot+2]; ddd->fixedvard=ddd->nnz[spot]/ddd->nnz[spot+2]; nblocks--;ddd->lpblock=0; } } } } ddd->totalnonzeros=nonzero; for (ddd->n=0,i=0;in += ddd->blocksizes[i]; ddd->m=m; ddd->nblocks=nblocks; fclose(fp); return 0; } #undef __FUNCT__ #define __FUNCT__ "Parseline" static int Parseline(char thisline[],int *nmat,int *nblk,int *row, int *col,double *value, int *nargs){ int temp; int rtmp,coltmp; *nmat=-1;*nblk=-1;rtmp=-1;coltmp=-1;*value=0.0; temp=sscanf(thisline,"%d %d %d %d %lg",nmat,nblk,&rtmp,&coltmp,value); if (temp==5) *nargs=5; else *nargs=0; *row=rtmp-1; *col=coltmp-1; return(0); } static int partition(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int k=lend; int pivot1=list1[k],pivot2=list2[k],pivot3=list3[k]; double pivot5 = list5[k]; int bottom = lstart-1, top = lend; int done = 0; int ordered=1; while (!done){ while (!done) { bottom = bottom+1; if (bottom == top){ done = 1; break; } if ( list1[bottom] > pivot1 || (list1[bottom] == pivot1 && list2[bottom] > pivot2) || (list1[bottom] == pivot1 && list2[bottom] == pivot2 && list3[bottom] > pivot3) ){ list1[top] = list1[bottom]; list2[top] = list2[bottom]; list3[top] = list3[bottom]; list5[top] = list5[bottom]; ordered=0; break; } } while (!done){ top = top-1; if (top == bottom){ done = 1; break; } if ( list1[top] < pivot1 || (list1[top] == pivot1 && list2[top] < pivot2) || (list1[top] == pivot1 && list2[top] == pivot2 && list3[top] < pivot3)){ list1[bottom] = list1[top]; list2[bottom] = list2[top]; list3[bottom] = list3[top]; list5[bottom] = list5[top]; ordered=0; break; } } } list1[top] = pivot1; list2[top] = pivot2; list3[top] = pivot3; list5[top] = pivot5; ordered=0; if (bottom==lend){ ordered=1; for (k=lstart;k list1[k+1]) || (list1[k] == list1[k+1] && list2[k] > list2[k+1]) || (list1[k] == list1[k+1] && list2[k] == list2[k+1] && list3[k] > list3[k+1]) ){ ordered=0; break; } } } if (ordered && lend-lstart>2){ top=(lend+lstart)/2; } return top; } static int qusort(int list1[], int list2[], int list3[], double list5[], int lstart, int lend){ int split; if (lstart < lend){ split = partition(list1, list2, list3, list5,lstart, lend); qusort(list1, list2, list3, list5, lstart, split-1); qusort(list1, list2, list3, list5, split+1, lend); } else { return 0; } return 0; } #undef __FUNCT__ #define __FUNCT__ "GetMarkers" static int GetMarkers(int block, int constraint, int blockn[], int constraintn[], int*m3){ int i=0; while (blockn[i]==block && constraintn[i]==constraint){ i++;} *m3=i; return 0; } #undef __FUNCT__ #define __FUNCT__ "CountNonzeroMatrices" static int CountNonzeroMatrices(int block, int blockn[], int constraintn[], int*m3){ int i=0,cvar=-1,nnzmats=0; while (blockn[i]==block){ if (constraintn[i]>cvar){ cvar=constraintn[i];nnzmats++;} i++; } *m3=nnzmats; return 0; } #undef __FUNCT__ #define __FUNCT__ "CheckForConstantMat" static int CheckForConstantMat(double v[],int nnz, int n){ int i; double vv; if (n<=1){ return 0; } if (nnz!=(n*n+n)/2){ return 0; } for (vv=v[0],i=1;i1) return 0; if (dddd.fixedvari) return 0; info=GetMarkers(1,0,dddd.block+spot,dddd.constraint+spot,&ijnnz); for (i=0;i #include #include #include /*! \file maxcut.c \brief Most Basic Example: read graph from file, formulate the SDP relaxation of maximum cut problem, solve using DSDP, and apply randomized algorithm to generate approximate solutions. */ char help[]="\ DSDP Usage: maxcut \n\ -gaptol \n\ -maxit \n"; static int ReadGraph(char*,int *, int *,int**, int **, double **); static int TCheckArgs(DSDP,int,char **); static int ParseGraphline(char*,int*,int*,double*,int*); int MaxCutRandomized(SDPCone,int); int MaxCut(int,int, int[], int[], double[]); int main(int argc,char *argv[]){ int info; int *node1,*node2,nedges,nnodes; double *weight; if (argc<2){ printf("%s",help); return(1); } MPI_Init(&argc,&argv); info = ReadGraph(argv[1],&nnodes,&nedges,&node1,&node2,&weight); if (info){ printf("Problem reading file\n"); return 1; } MaxCut(nnodes,nedges,node1,node2,weight); free(node1);free(node2);free(weight); MPI_Finalize( ); return 0; } /*! \fn int MaxCut(int nnodes,int nedged, int node1[], int node2[], double weight[]); \brief Formulate and solve the SDP relaxation of the Maximum Cut problem \ingroup Examples \param nnodes number of nodes in graph \param nedges number of edges in graph \param node1 first node of each edge \param node2 second node of each edge \param weight weight of each edge \note This routine is an example! It is not part of the solver library. */ int MaxCut(int nnodes,int nedges, int node1[], int node2[], double weight[]){ int i,info; int *indd,*iptr; double *yy,*val,*diag,tval=0; DSDPTerminationReason reason; SDPCone sdpcone; DSDP dsdp; info = DSDPCreate(nnodes,&dsdp); info = DSDPCreateSDPCone(dsdp,1,&sdpcone); if (info){ printf("Out of memory\n"); return 1; } info = SDPConeSetBlockSize(sdpcone,0,nnodes); /* Formulate the problem from the data */ /* Diagonal elements equal 1.0 Create Constraint matrix A_i for i=1, ..., nnodes. that has a single nonzero element. */ diag=(double*)malloc(nnodes*sizeof(double)); iptr=(int*)malloc(nnodes*sizeof(int)); for (i=0;i=0 */ yy=(double*)malloc(nnodes*sizeof(double)); for (i=0;i0 && coltmp>0) *gotem=3; else if (temp==2 && rtmp>0 && coltmp>0){ *value = 1.0; *gotem=3;} else *gotem=0; *row=rtmp-1; *col=coltmp-1; return(0); } #undef __FUNCT__ #define __FUNCT__ "ReadGraph" int ReadGraph(char* filename,int *nnodes, int *nedges, int**n1, int ** n2, double **wght){ FILE*fp; char thisline[BUFFERSIZ]="*"; int i,k=0,line=0,nodes,edges,gotone=3; int *node1,*node2; double *weight; int info,row,col; double value; fp=fopen(filename,"r"); if (!fp){printf("Cannot open file %s !",filename);return(1);} while(!feof(fp) && (thisline[0] == '*' || thisline[0] == '"') ){ fgets(thisline,BUFFERSIZ,fp); line++; } if (sscanf(thisline,"%d %d",&nodes, &edges)!=2){ printf("First line must contain the number of nodes and number of edges\n"); return 1; } node1=(int*)malloc(edges*sizeof(int)); node2=(int*)malloc(edges*sizeof(int)); weight=(double*)malloc(edges*sizeof(double)); for (i=0; i= 0 && row >= 0){ if (row=edges) { printf("To many edges in file.\nLine %d, %s\n",line,thisline); return 1; } else if (gotone&&(col >= nodes || row >= nodes || col < 0 || row < 0)){ printf("Invalid node number.\nLine %d, %s\n",line,thisline); return 1; } } *nnodes=nodes; *nedges=edges; *n1=node1; *n2=node2; *wght=weight; return 0; } DSDP5.8/pdsdp/ScaLAPACK/control7-2.pbs0000644000175000017500000000042010326241002017073 0ustar twernertwerner#!/bin/sh #PBS -l walltime=10:00 #PBS -l nodes=2 cat $PBS_NODEFILE PDSDPDIR=/home/benson/dual/DSDP5.7 PDSDPEXE=${PDSDPDIR}/pdsdp/SCALAPACK/pdsdp5 EXAMPLEDIR=/home/benson/sdpexamples EX=control7.dat-s mpirun -np 2 -machinefile $PBS_NODEFILE ${PDSDPEXE} ${EXAMPLEDIR}/${EX} DSDP5.8/pdsdp/ScaLAPACK/theta4-2.pbs0000644000175000017500000000041610326241002016522 0ustar twernertwerner#!/bin/sh #PBS -l walltime=10:00 #PBS -l nodes=2 cat $PBS_NODEFILE PDSDPDIR=/home/benson/dual/DSDP5.7 PDSDPEXE=${PDSDPDIR}/pdsdp/SCALAPACK/pdsdp5 EXAMPLEDIR=/home/benson/sdpexamples EX=theta4.dat-s mpirun -np 2 -machinefile $PBS_NODEFILE ${PDSDPEXE} ${EXAMPLEDIR}/${EX} DSDP5.8/pdsdp/ScaLAPACK/pdsdpscalapack.o0000644000175000017500000002425410326241002017627 0ustar twernertwernerELF4( UXT$]u$øXD$1D$$$ :uT\$M t$ $u6C1C\Ct(ƃTUCCD]u]$UWVSl}EU EwD_t$$_H\$1ɉL$$WDD$t$wXT$ $_Tt$WLOPT$ L$\$OH $$1W`D$T$GD}Mf fMm]mދ_DM؉ؙOlGp9tv'I9uGpOl_pw`uЉ\$ Ol_hT$4$L$\$WpGdT$OlD$ L$w`]̍]UĉEȉM4$wT\$ G\M t$_L\$ED$ $HUE]\$ U wXt$_P\$D$$EHUȍ]M\$ u _tT$L$\$4$HUu̍ML$ UčE \$t$T$$HbGxMEԋUԉDHUPLE~F$L$GxUԋM$1ɉL$UT$Oxu EvUEEG|~:$T$G|M$L$1ɉL$O|uEMEE1҉ƅ~C$T$M$L$1ɉL$uEu$E1E~@$1T$Mt$$L$uEuE1E ~@$1T$M t$$L$uEuufE1E ~@$1T$M t$$L$uEut"'$(l[^_]ÍE WHD$ Eut$$Mu UT$L$L$D$t$ t$t$$Mt$6E뙉t$EUT$$MUD$EL$ MT$T$L$L$D$ $Mt $F뢉\$EЍUT$MuL$ M T$t$$ΉL$L$D$\$ $Mt $VL\$ EUD$$MEЉT$T$UT$T$L$ D$t$$]t $fUuM L$ EM t$]t$ \$$T$D$L$ D$L$4$]t $vwWWW$W,W4_<4$1\$u̍ML$ UčE $t$T$s\$UML$ uȍE $T$t$t$MED$ u \$L$4$Et$MuL$ E \$t$$Y$l&U1S$]UM 9}M@9|؉\$[D$fD$ D$ L$$$1[]ËŐt&U1]]u$CP 1C C pCC C CC(`C,C4C C8 C<0 CDPC@C0CH`SP]u]Ív$UWVS }DOHLދP $Wx\$1$\$1t$D$ $19}萍&B9|؃ 1[^_]ÍU$E ]t$M{X;SPt$1t$]덶U1ɉWVS}E9}#XXpPș9tU A9|Z1[^_]ɋE t&UWVSUE}] TE2]MBx ur|1҉EEuL$T$EEEEEE]؉$u19}'<@9|UrH\$ ]t$(ցƴL$\$Ӂ L$t$$\$L$ D$<$L$\$@MEL$D]M\$8U]ԉt$(u\$,]ƐT$C@PH]2` m}&  !m' T8MkXiP r |pwl L T`]  :0 L P`N (  8V]dwY!)2;JZ_pdsdpscalapack.cprinttimesprintmorescalapackdsdpopsDSDPScalapackOpsInitpvecreducescalapackmatnamepmatzeropmatrowcolumnspmataddlinepmatadddiagonalpmataddelementpmatshiftdiagonalpmatassemblepmatfactorpmatsolvepmatmultpmatonprocessorpmatlocalvariablespmatdistributedpmatdestroypmatgetdiagonalPDSDPUseSCALAPACKLinearSolvercallocmemsetDSDPSetSchurMatOpsDSDPErrorpmatsetupCblacs_pinfoCblacs_getCblacs_gridinitCblacs_gridinfonumroc_putsdescinit_printfDSDPTimesqrtMPI_AllreduceDSDPSchurMatOpsInitializeCpdgemr2dpdsymv_pdpotrf_pdpotrs_Cblacs_barrierCblacs_gridexitfreeMPI_Comm_rank!6"=T`#$&'(>)W'()C*y***7!["!"!"a!}"!"!;"ch+,-,&k,y,,$H.s****/g01     %& C H $ . " " " 2$ 3  $ ": .7<$+2.W4|-.---$9.2C52.(-+;@$OT-b{6767e8v8888889--'93?J-T]-r9~--f/ot$DSDP5.8/pdsdp/ScaLAPACK/pdsdpscalapack.c0000644000175000017500000004063710326241002017616 0ustar twernertwerner#include "pdsdp5scalapack.h" #include "dsdpsys.h" #include "src/solver/dsdpschurmat_impl.h" #include "pblas.h" #include "PBpblas.h" #include "PBtools.h" #include "PBblas.h" #include "PBblacs.h" typedef long int ftnlen; /* External Scalapack and BLACS routines from Fortran routines */ extern int pdpotrf_(char *uplo, int *n, double *a, int *ia, int *ja, int *desca, int *info, ftnlen uplo_len); extern int pdpotrs_(char *uplo, int *n, int *nrhs, double *a, int *ia, int *ja, int *desca, double *b, int *ib, int *jb, int *descb, int *info, ftnlen uplo_len); extern int numroc_(int *n, int *nb, int *iproc, int *isrcproc, int *nprocs); extern int descinit_(int *desc, int *m, int *n, int *mb, int *nb, int *irsrc, int *icsrc, int *ictxt, int *lld, int *info); extern void Cpdgemr2d(int m, int n, double* ptrmyblock, int ia, int ja, int* desca, double* ptrmynewblock, int ib, int jb, int* descb, int globcontext); extern void Cpdtrmr2d(char* uplo, char* diag,int m, int n, double* ptrmyblock, int ia, int ja, int* desca,double* ptrmynewblock, int ib, int jb, int* descb, int globcontext); extern int pdlaprnt_(int *m, int *n, double *a, int *ia, int *ja, int *desca, int *irprnt, int *icprnt, char *cmatnm, int *nout, double *work, ftnlen cmatnm_len); static int pvecreduce(void*,double *, int); static int printtimes=0; static int printmore=1; static void PPDSDPPrintTime(int rank, char* label, double itertime, double cumtime){ if (printtimes==0) return; if (rank==0){ printf(" %10s: This iteration: %4.4e, Cumulative Time %4.4e \n",label,itertime,cumtime); } return; } static void PPDSDPPrint(char *label, double dd){ int rank=0; if (printmore==0) return; MPI_Comm_rank(MPI_COMM_WORLD,&rank); if (rank==0){ printf(" %d: ",rank); printf(label,dd); } return; } /* PDSDP simply provides a different implementation of the Schur operations. */ typedef struct { int m; int rank; double ratio; int fflag; double t0,t1,t2,thessian,tfactor,tsolve; /* mb defines how many continuous rows are processed by one processor. mb2 defines block size of two cyclic distribution of ScaLAPACK */ int nprocs; int ictxt; int myrow; int mycol; int nprow; int npcol; int mb; int ictxt2; int myrow2; int mycol2; int nprow2; int npcol2; int mb2; double* pB; double* pg; double* pB2; double* pg2; double* rr; double *diag; int descB[DLEN1_]; int descg[DLEN1_]; int descB2[DLEN1_]; int descg2[DLEN1_]; int descDy[DLEN1_]; int maxmp; int maxnp; int maxmp2; int maxnp2; char UPLQ; } scalapackM; static struct DSDPSchurMat_Ops scalapackdsdpops; static int DSDPScalapackOpsInit(struct DSDPSchurMat_Ops*); extern int DSDPSetSchurMatOps(DSDP,struct DSDPSchurMat_Ops*,void*); #undef __FUNCT__ #define __FUNCT__ "PDSDPUseSCALAPACKLinearSolver" int PDSDPUseSCALAPACKLinearSolver(DSDP dsdp){ int info; scalapackM* ctx; DSDPFunctionBegin; DSDPCALLOC1(&ctx,scalapackM,&info); info=DSDPScalapackOpsInit(&scalapackdsdpops);DSDPCHKERR(info); info=DSDPSetSchurMatOps(dsdp,&scalapackdsdpops,(void*)ctx);DSDPCHKERR(info); ctx->fflag=0; ctx->mb=1; ctx->mb2=1; ctx->mb2=40; ctx->UPLQ='U'; ctx->rank=0; ctx->nprocs=0; DSDPFunctionReturn(0); } static int rowonp(scalapackM* ctx,int row,int *mrow){ if (row % ctx->npcol==ctx->mycol){ if (mrow) *mrow=(row/ctx->npcol)*ctx->maxmp; return 1; } else { if (mrow) *mrow=-1; return 0; } } #undef __FUNCT__ #define __FUNCT__ "pmatsetup" int pmatsetup(void *MM, int m){ scalapackM* ctx=(scalapackM*)MM; int maxmp,maxnp,maxmp2,maxnp2; int info; int IZERO = 0, IONE = 1; DSDPFunctionBegin; ctx->m=m; /* ctx->nprow=1; ctx->npcol=1; sl_init__(&ctx->ictxt,&ctx->nprow,&ctx->npcol); */ Cblacs_pinfo(&ctx->rank, &ctx->nprocs); Cblacs_get(-1,0,&ctx->ictxt); Cblacs_gridinit(&ctx->ictxt,"Row-major",1,ctx->nprocs); Cblacs_gridinfo(ctx->ictxt,&ctx->nprow,&ctx->npcol,&ctx->myrow,&ctx->mycol); Cblacs_get(-1,0,&ctx->ictxt2); ctx->nprow2 = (int) sqrt((double)ctx->nprocs); ctx->npcol2 = ctx->nprocs/ctx->nprow2; while (ctx->nprow2*ctx->npcol2 != ctx->nprocs) { ctx->nprow2--; ctx->npcol2 = ctx->nprocs/ctx->nprow2; } Cblacs_gridinit(&ctx->ictxt2,"Row-major",ctx->nprow2,ctx->npcol2); Cblacs_gridinfo(ctx->ictxt2,&ctx->nprow2,&ctx->npcol2,&ctx->myrow2,&ctx->mycol2); maxmp = DSDPMax(1,numroc_(&m,&ctx->mb,&ctx->myrow,&IZERO,&ctx->nprow)); maxnp = DSDPMax(1,numroc_(&m,&ctx->mb,&ctx->mycol,&IZERO,&ctx->npcol)); maxmp2 = DSDPMax(1,numroc_(&m,&ctx->mb2,&ctx->myrow2,&IZERO,&ctx->nprow2)); maxnp2 = DSDPMax(1,numroc_(&m,&ctx->mb2,&ctx->mycol2,&IZERO,&ctx->npcol2)); ctx->maxmp=maxmp; ctx->maxnp=maxnp; ctx->maxmp2=maxmp2; ctx->maxnp2=maxnp2; if (0){ printf("RANK: %-3d, NPROCS: %-3d, M: %-3d\n",ctx->rank,ctx->nprocs,m); printf("RANK: %-3d, ICTXT : %-3d,MYROW: %-3d of NPROW: %-3d, MYCOL: %-3d, NPCOL: %-3d\n", ctx->rank,ctx->ictxt,ctx->myrow,ctx->nprow,ctx->mycol,ctx->npcol); printf("RANK: %-3d, ICTXT2: %-3d,MYROW: %-3d of NPROW: %-3d, MYCOL: %-3d, NPCOL: %-3d\n", ctx->rank,ctx->ictxt2,ctx->myrow2,ctx->nprow2,ctx->mycol2,ctx->npcol2); printf("RANK: %-3d, block : %-3d, maxmp : %-3d, maxnp : %-3d\n",ctx->rank,ctx->mb,maxmp,maxnp); printf("RANK: %-3d, block2: %-3d, maxmp2: %-3d, maxnp2: %-3d\n",ctx->rank,ctx->mb2,maxmp2,maxnp2); } DSDPCALLOC2(&ctx->pB,double,maxnp*maxmp,&info); if (info){printf("OUT of Memory\n"); return 1;} DSDPCALLOC2(&ctx->pg,double,maxmp,&info); if (info){printf("OUT of Memory\n"); return 1;} DSDPCALLOC2(&ctx->pB2,double,maxmp2*maxnp2,&info); if (info){printf("OUT of Memory\n"); return 1;} DSDPCALLOC2(&ctx->pg2,double,maxmp2,&info); if (info){printf("OUT of Memory\n"); return 1;} DSDPCALLOC2(&ctx->rr,double,m,&info); if (info){printf("OUT of Memory\n"); return 1;} DSDPCALLOC2(&ctx->diag,double,m,&info); if (info){printf("OUT of Memory\n"); return 1;} descinit_(ctx->descB,&m,&m,&m,&ctx->mb,&IZERO,&IZERO, &ctx->ictxt,&m,&info); if (info!=0) { printf("DESCINIT ERROR1"); return info; } descinit_(ctx->descg,&m,&IONE,&ctx->mb,&IONE,&IZERO,&IZERO, &ctx->ictxt,&maxmp,&info); if (info!=0) { printf("DESCINIT ERROR2"); return info; } descinit_(ctx->descB2,&m,&m,&ctx->mb2,&ctx->mb2,&IZERO,&IZERO, &ctx->ictxt2,&maxmp2,&info); if (info!=0) { printf("DESCINIT ERROR3"); return info; } descinit_(ctx->descg2,&m,&IONE,&ctx->mb2,&IONE,&IZERO,&IZERO, &ctx->ictxt2,&maxmp2,&info); if (info!=0) {printf("DESCINIT ERROR4"); return info;} descinit_(ctx->descDy,&m,&IONE,&m,&IONE,&IZERO,&IZERO, &ctx->ictxt,&m,&info); if (info!=0) { printf("DESCINIT ERROR5"); return info;} ctx->t0=0;ctx->t1=0;ctx->t2=0; ctx->thessian=0;ctx->tfactor=0;ctx->tsolve=0; DSDPTime(&ctx->t0); DSDPFunctionReturn(0); } static void pvecscalem(double v1[], double v2[], double v3[], int n){ int i; for (i=0;imaxmp*ctx->maxnp, nn2=ctx->maxmp2*ctx->maxnp2; DSDPFunctionBegin; DSDPTime(&ctx->t1); memset((void*)ctx->pB,0,nn1*sizeof(double)); memset((void*)ctx->pB2,0,nn2*sizeof(double)); for (i=0;im;i++){ctx->diag[i]=1.0;} DSDPFunctionReturn(0); } static int pmatonprocessor( void* MM,int row ,int*yesorno){ scalapackM* ctx=(scalapackM*)MM; if (rowonp(ctx,row,0)){ *yesorno=1; } else { *yesorno=0; } return 0; } static int pmatlocalvariables( void* MM,double vars[] ,int m){ scalapackM* ctx=(scalapackM*)MM; int row; for (row=0;rowm; char UPLQ=ctx->UPLQ; double *A=ctx->pB; double ALPHA=1.0,BETA=0.0; double *X=ctx->pg,*Y=y; DSDPFunctionBegin; memset((void*)y,0,m*sizeof(double)); pvecscaled(x,ctx->diag,ctx->rr,m); Cpdgemr2d(m,1,ctx->rr,1,1,ctx->descDy,X,1,1,ctx->descg,ctx->ictxt); pdsymv_(&UPLQ,&N,&ALPHA,A,&IA,&JA,ctx->descB,X,&IX,&JX,ctx->descg,&INCX,&BETA,Y,&IY,&JY,ctx->descDy,&INCY); info=pvecreduce(MM,y,m);DSDPCHKERR(info); pvecscaled(y,ctx->diag,y,m); DSDPFunctionReturn(0); } static int pmatrowcolumns(void* MM,int row ,double cols[],int*ncols, int nrows){ scalapackM* ctx=(scalapackM*)MM; int i; DSDPFunctionBegin; memset((void*)cols,0,nrows*sizeof(int)); if (rowonp(ctx,row,0)){ *ncols=row+1; for (i=0;i<=row;i++){ cols[i]=1.0;} } else { *ncols=0; } DSDPFunctionReturn(0); } static int pmatshiftdiagonal(void* MM,double shift){ scalapackM* ctx=(scalapackM*)MM; int mrow,row,m=ctx->m; DSDPFunctionBegin; if (shift==0) return 0; for (row=0;rowpB[mrow+row]+=10*shift; } } DSDPFunctionReturn(0); } static int pmataddelement(void* MM,int row, double shift){ scalapackM* ctx=(scalapackM*)MM; int mrow; DSDPFunctionBegin; if (rowonp(ctx,row,&mrow)){ ctx->pB[mrow+row]+=shift; } DSDPFunctionReturn(0); } static int pmatadddiagonal(void*MM, double val[],int n){ scalapackM* ctx=(scalapackM*)MM; int mrow,row; DSDPFunctionBegin; for (row=0;rowpB[mrow+row]+=val[row]; } } DSDPFunctionReturn(0); } static int pmatgetdiagonal(void*MM, double val[],int n){ scalapackM* ctx=(scalapackM*)MM; int info,mrow,row; DSDPFunctionBegin; for (row=0;rowpB[mrow+row]); if (val[row]==0) val[row]=1.0; } else { val[row]=0; } } info=pvecreduce(MM,val,n);DSDPCHKERR(info); for (row=0;rowm; DSDPFunctionBegin; for (row=0;rowpB[mrow+i]=ctx->pB[mrow+i]*ctx->diag[row]*ctx->diag[i]; if (i!=row && fabs(ctx->pB[mrow+i])>1.0){printf("BAD ELEMENT: %d, %d, %4.10e\n",row,i,ctx->pB[mrow+i]);} } } } DSDPFunctionReturn(0); } /* Cache lines before inserting them into the matrix */ static int pmataddline(void*MM, int row, double dd, double vals[], int m){ scalapackM* ctx=(scalapackM*)MM; int i,mrow; DSDPFunctionBegin; if (rowonp(ctx,row,&mrow)){ for (i=0;i<=row;i++){ ctx->pB[mrow+i]+=dd*vals[i]; } } DSDPFunctionReturn(0); } static int pmatassemble(void*MM){ scalapackM* ctx=(scalapackM*)MM; int info; DSDPFunctionBegin; DSDPTime(&ctx->t2); ctx->thessian+=ctx->t2-ctx->t1; info=pmatshiftdiagonal(MM,1.0e-12);DSDPCHKERR(info); DSDPFunctionReturn(0); } static int pmatdistributed(void*MM, int*flag){ DSDPFunctionBegin; *flag=1; DSDPFunctionReturn(0); } static int pmatfactor(void*MM, int *flag){ scalapackM* ctx=(scalapackM*)MM; int info=0,info2=0; int N=ctx->m,m=ctx->m; int IA=1,JA=1; double *A=ctx->pB2; char UPLQ=ctx->UPLQ; DSDPFunctionBegin; info=pmatgetdiagonal(MM,ctx->diag,ctx->m);DSDPCHKERR(info); info=pmatscale(MM);DSDPCHKERR(info); info=pmatshiftdiagonal(MM,1.0e-11);DSDPCHKERR(info); Cpdgemr2d(m,m,ctx->pB,1,1,ctx->descB,ctx->pB2,1,1,ctx->descB2,ctx->ictxt); PPDSDPPrintTime(ctx->rank,"Compute M",ctx->t2-ctx->t1,ctx->thessian); if (0){ int IONE=1,IZERO=0; int ISTDOUT = 6; double tmpwork[100]; pdlaprnt_(&m,&m,ctx->pB,&IONE,&IONE,ctx->descB,&IZERO,&IZERO, "B0 = ", &ISTDOUT,tmpwork,5); pdlaprnt_(&m,&m,ctx->pB2,&IONE,&IONE,ctx->descB2,&IZERO,&IZERO, "B2 = ", &ISTDOUT,tmpwork,5); } DSDPTime(&ctx->t1); *flag=0; info=pdpotrf_(&UPLQ,&N,A,&IA,&JA,ctx->descB2,&info2,1); if (info2!=0) {*flag=1;} if (info2!=0) {ctx->fflag=1;} if (info2!=0) {printf("BAD FACTOR : %d\n",info2); } DSDPTime(&ctx->t2); ctx->tfactor+=ctx->t2-ctx->t1; PPDSDPPrintTime(ctx->rank,"SCALAPACK: Factor M",ctx->t2-ctx->t1,ctx->tfactor); DSDPFunctionReturn(0); } static int pvecreduce(void*MM,double *v, int m){ scalapackM* ctx=(scalapackM*)MM; int i; DSDPFunctionBegin; for (i=0;irr[i]=v[i]; v[i]=0;} MPI_Allreduce((void*)ctx->rr,(void*)v,m,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); /* char top; void Cdgsum2d(int ConTxt, char *scope, char *top, int m, int n, double *A, int lda, int rdest, int cdest); top = *PB_Ctop(ctx->ictxt,"COMBINE","All", TOP_GET ); Cdgsum2d(ctx->ictxt,"All",&top,m,1,v,m,-1,-1); */ DSDPFunctionReturn(0); } static int pmatsolve(void* MM, double bb[], double xx[], int n){ scalapackM* ctx=(scalapackM*)MM; int info=0,info2=0,m=ctx->m; int N=ctx->m, NRHS=1; int IA=1,JA=1,IB=1,JB=1; double *A=ctx->pB2; char UPLQ=ctx->UPLQ; int i; DSDPFunctionBegin; DSDPTime(&ctx->t1); /* Copy RHS from DSDPVector to SCALAPACK vector. This assumes the entries in the local DSDP Vectors are not duplicated on multiple processors. It adds the first element of each vector together, second element, ... */ pvecscalem(bb,ctx->diag,ctx->rr,m); Cpdgemr2d(m,1,ctx->rr,1,1,ctx->descDy,ctx->pg2,1,1,ctx->descg2,ctx->ictxt2); if (0){ int IONE=1,IZERO=0; int ISTDOUT = 6; double tmpwork[100]; pdlaprnt_(&m,&IONE,ctx->pg2,&IONE,&IONE,ctx->descg2,&IZERO,&IZERO, "rhs = ", &ISTDOUT,tmpwork,5); } info=pdpotrs_(&UPLQ,&N,&NRHS,A,&IA,&JA,ctx->descB2,ctx->pg2,&IB,&JB,ctx->descg2,&info2,1); if (info2!=0){ printf("CHOLESKY SOLVE INFO: %d\n",info2);return 10;} if (0){ int IONE=1,IZERO=0; int ISTDOUT = 6; double tmpwork[100]; pdlaprnt_(&m,&IONE,ctx->pg2,&IONE,&IONE,ctx->descg2,&IZERO,&IZERO, "dy = ", &ISTDOUT,tmpwork,5); } Cpdgemr2d(m,1,ctx->pg2,1,1,ctx->descg2,xx,1,1,ctx->descDy,ctx->ictxt2); info=pvecreduce(MM,xx,m);DSDPCHKERR(info); if (xx[0]!=xx[0]){ printf("BAD CHOLESKY SOLVE.\n");return 10;} pvecscalem(xx,ctx->diag,xx,m); if (0){ int IONE=1,IZERO=0; int ISTDOUT = 6; double tmpwork[100]; pdlaprnt_(&m,&IONE,xx,&IONE,&IONE,ctx->descDy,&IZERO,&IZERO, "dy1 = ", &ISTDOUT,tmpwork,5); } if (0){ double derr=0,dd3,*rr3; rr3=(double*)malloc(n*sizeof(double)); info=pmatmult(MM,xx,rr3,n);DSDPCHKERR(info); for (i=0;i<-m;i++){ printf("RANK:%d %d RHS1: %4.4e, RHS2: %4.4e, SCL: %4.4e\n",ctx->rank,i,bb[i],rr3[i],ctx->diag[i]);} for (i=0;irank,sqrt(derr)); } DSDPTime(&ctx->t2); ctx->tsolve+=ctx->t2-ctx->t1; /* PPDSDPPrintTime(ctx->rank,"Solve M",ctx->t2-ctx->t1,ctx->tsolve);*/ DSDPFunctionReturn(0); } static int pmatdestroy(void*MM){ scalapackM* ctx=(scalapackM*)MM; int info; DSDPFunctionBegin; Cblacs_barrier(ctx->ictxt,"All"); Cblacs_gridexit(ctx->ictxt); Cblacs_barrier(ctx->ictxt2,"All"); Cblacs_gridexit(ctx->ictxt2); /* pbfreebuf(); */ /* Cblacs_exit(0); */ PPDSDPPrint("PDSDP: Compute M: %5.5e \n",ctx->thessian); PPDSDPPrint("PDSDP: Factor M %4.5e seconds \n",ctx->tfactor); PPDSDPPrint("PDSDP: Solve M %4.5e seconds \n",ctx->tsolve); DSDPFREE(&ctx->pB,&info);DSDPCHKERR(info); DSDPFREE(&ctx->pB2,&info);DSDPCHKERR(info); DSDPFREE(&ctx->pg,&info);DSDPCHKERR(info); DSDPFREE(&ctx->pg2,&info);DSDPCHKERR(info); DSDPFREE(&ctx->rr,&info);DSDPCHKERR(info); DSDPFREE(&ctx->diag,&info);DSDPCHKERR(info); DSDPFREE(&ctx,&info);DSDPCHKERR(info); DSDPFunctionReturn(0); } static const char *scalapackmatname="SCALAPACK matrix"; static int DSDPScalapackOpsInit(struct DSDPSchurMat_Ops* sops){ int info; if (!sops) return 0; info=DSDPSchurMatOpsInitialize(sops); DSDPCHKERR(info); sops->matzero=pmatzero; sops->matrownonzeros=pmatrowcolumns; sops->mataddrow=pmataddline; sops->matadddiagonal=pmatadddiagonal; sops->mataddelement=pmataddelement ; sops->matshiftdiagonal=pmatshiftdiagonal; sops->matassemble=pmatassemble; sops->matscaledmultiply=0; sops->matfactor=pmatfactor; sops->matsolve=pmatsolve; sops->pmatwhichdiag=0; sops->matscaledmultiply=pmatmult; sops->pmatonprocessor=pmatonprocessor; sops->pmatlocalvariables=pmatlocalvariables; sops->pmatdistributed=pmatdistributed; sops->pmatreduction=pvecreduce; sops->matsetup=pmatsetup; sops->matdestroy=pmatdestroy; sops->id=25; sops->matname=scalapackmatname; return 0; } DSDP5.8/pdsdp/pdsdp.bib0000644000175000017500000000057210326241002014675 0ustar twernertwerner@TechReport{pdsdp, author = "S. J. Benson", title = "Parallel Computing on Semidefinite Programs", institution = "Mathematics and Computer Science Division, Argonne National Laboratory", number= "ANL/MCS-P939-0302", month = "March", year = "2003", location ="ftp://info.mcs.anl.gov/pub/tech_reports/reports/P939.pdf", note="Submitted to Parallel Computing", }