Example #1
0
int DSDPZeroFixedVariables( DSDPSchurMat M, DSDPVec dy){
  int i,info; 
  FixedVariables *fv=&M.schur->fv;
  DSDPFunctionBegin;
  for (i=0;i<fv->nvars;i++){
    info=DSDPVecSetElement(dy,fv->var[i],0.0);DSDPCHKERR(info);
  }
  DSDPFunctionReturn(0);
}
Example #2
0
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;i<fv->nvars;i++){
    vv=fv->fval[i]*fabs(scl);
    jj=fv->var[i];
    info=DSDPVecSetElement(y,jj,vv);DSDPCHKERR(info);
  }
  DSDPFunctionReturn(0);
}
Example #3
0
int DSDPComputeFixedYX( DSDPSchurMat M, DSDPVec berr){
  int i,jj,info;
  double vv;
  FixedVariables *fv=&M.schur->fv;
  DSDPFunctionBegin;
  for (i=0;i<fv->nvars;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);
}
Example #4
0
/*!
\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];i<ik[m+1];i++){
    info=DSDPVecSetElement(C,cols[i],vals[i]);
  }
  spot=ik[0];
  info=CreateSpRowMatWdata(m,n,vals+spot,cols+spot,ik,&lpcone->A);DSDPCHKERR(info);
  DSDPFunctionReturn(0); 
}
Example #5
0
/*!
\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;i<nvars;i++){info=DSDPVecSetElement(Y,i+1,y[i]);}
  info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ);DSDPCHKBLOCKERR(blockj,info);
  info=DSDPMakeVMatWithArray(UPLQ,s,nn,n,&T);DSDPCHKBLOCKERR(blockj,info);
  info=SDPConeComputeSS(sdpcone,blockj,Y,T);DSDPCHKBLOCKERR(blockj,info);
  info=DSDPVMatDestroy(&T);DSDPCHKBLOCKERR(blockj,info);
  DSDPFunctionReturn(0); 
}