/* * g e t K k t V i o l a t i o n S B */ returnValue qpOASES_getKktViolationSB( int nV, const real_t* const H, const real_t* const g, const real_t* const lb, const real_t* const ub, const real_t* const x, const real_t* const y, real_t* const _stat, real_t* const feas, real_t* const cmpl ) { return qpOASES_getKktViolation( nV,0, H,g,0,lb,ub,0,0, x,y, _stat,feas,cmpl ); }
/* * s o l v e O Q P b e n c h m a r k */ returnValue solveOQPbenchmark( int nQP, int nV, int nC, int nEC, real_t* _H, const real_t* const g, real_t* _A, const real_t* const lb, const real_t* const ub, const real_t* const lbA, const real_t* const ubA, BooleanType isSparse, BooleanType useHotstarts, const Options* options, int maxAllowedNWSR, real_t* maxNWSR, real_t* avgNWSR, real_t* maxCPUtime, real_t* avgCPUtime, real_t* maxStationarity, real_t* maxFeasibility, real_t* maxComplementarity ) { int k; myStatic QProblem qp; returnValue returnvalue; /* I) SETUP AUXILIARY VARIABLES: */ /* 1) Keep nWSR and store current and maximum number of * working set recalculations in temporary variables */ int nWSRcur; real_t CPUtimeLimit = *maxCPUtime; real_t CPUtimeCur = CPUtimeLimit; real_t stat, feas, cmpl; /* 2) Pointers to data of current QP ... */ const real_t* gCur; const real_t* lbCur; const real_t* ubCur; const real_t* lbACur; const real_t* ubACur; /* 3) Vectors for solution obtained by qpOASES. */ myStatic real_t x[NVMAX]; myStatic real_t y[NVMAX+NCMAX]; /* 4) Prepare matrix objects */ DenseMatrix *H, *A; myStatic DenseMatrix HH, AA; DenseMatrixCON( &HH, nV, nV, nV, _H ); DenseMatrixCON( &AA, nC, nV, nV, _A ); H = &HH; A = &AA; *maxNWSR = 0; *avgNWSR = 0; *maxCPUtime = 0.0; *avgCPUtime = 0.0; *maxStationarity = 0.0; *maxFeasibility = 0.0; *maxComplementarity = 0.0; /*DenseMatrix_print( H );*/ /* II) SETUP QPROBLEM OBJECT */ QProblemCON( &qp,nV,nC,HST_UNKNOWN ); QProblem_setOptions( &qp,*options ); /*QProblem_setPrintLevel( &qp,PL_LOW );*/ /* QProblem_printOptions( &qp ); */ /* III) RUN BENCHMARK SEQUENCE: */ for( k=0; k<nQP; ++k ) { /* 1) Update pointers to current QP data. */ gCur = &( g[k*nV] ); lbCur = &( lb[k*nV] ); ubCur = &( ub[k*nV] ); lbACur = &( lbA[k*nC] ); ubACur = &( ubA[k*nC] ); /* 2) Set nWSR and maximum CPU time. */ nWSRcur = maxAllowedNWSR; CPUtimeCur = CPUtimeLimit; /* 3) Solve current QP. */ if ( ( k == 0 ) || ( useHotstarts == BT_FALSE ) ) { /* initialise */ returnvalue = QProblem_initM( &qp, H,gCur,A,lbCur,ubCur,lbACur,ubACur, &nWSRcur,&CPUtimeCur ); if ( ( returnvalue != SUCCESSFUL_RETURN ) && ( returnvalue != RET_MAX_NWSR_REACHED ) ) return THROWERROR( returnvalue ); } else { /* hotstart */ returnvalue = QProblem_hotstart( &qp, gCur,lbCur,ubCur,lbACur,ubACur, &nWSRcur,&CPUtimeCur ); if ( ( returnvalue != SUCCESSFUL_RETURN ) && ( returnvalue != RET_MAX_NWSR_REACHED ) ) return THROWERROR( returnvalue ); } /* 4) Obtain solution vectors and objective function value */ QProblem_getPrimalSolution( &qp,x ); QProblem_getDualSolution( &qp,y ); /* 5) Compute KKT residuals */ qpOASES_getKktViolation( nV,nC, _H,gCur,_A,lbCur,ubCur,lbACur,ubACur, x,y, &stat,&feas,&cmpl ); /* 6) Update maximum values. */ if ( nWSRcur > *maxNWSR ) *maxNWSR = nWSRcur; if (stat > *maxStationarity) *maxStationarity = stat; if (feas > *maxFeasibility) *maxFeasibility = feas; if (cmpl > *maxComplementarity) *maxComplementarity = cmpl; if ( CPUtimeCur > *maxCPUtime ) *maxCPUtime = CPUtimeCur; *avgNWSR += nWSRcur; *avgCPUtime += CPUtimeCur; } *avgNWSR /= nQP; *avgCPUtime /= ((double)nQP); return SUCCESSFUL_RETURN; }