39 #include <qpOASES/extras/OQPinterface.hpp> 40 #include <qpOASES/QProblem.hpp> 69 if ( ( nQP <= 0 ) || ( nV <= 0 ) || ( nC < 0 ) || ( nEC < 0 ) )
88 if ( ( H == 0 ) || ( g == 0 ) || ( lb == 0 ) || ( ub == 0 ) )
98 if ( ( nC > 0 ) && ( ( A == 0 ) || ( lbA == 0 ) || ( ubA == 0 ) ) )
117 delete[] *
g;
delete[] *
H;
126 delete[] *
lb;
delete[] *
g;
delete[] *
H;
135 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
147 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
152 *lbA =
new real_t[nQP*nC];
156 delete[] *
lbA;
delete[] *
A;
157 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
162 *ubA =
new real_t[nQP*nC];
166 delete[] *
ubA;
delete[] *
lbA;
delete[] *
A;
167 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
181 *xOpt =
new real_t[nQP*nV];
186 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
187 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
195 *yOpt =
new real_t[nQP*(nV+nC)];
200 if ( xOpt != 0 ) {
delete[]
xOpt; };
201 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
202 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
210 *objOpt =
new real_t[nQP];
215 if ( yOpt != 0 ) {
delete[] yOpt; };
216 if ( xOpt != 0 ) {
delete[]
xOpt; };
217 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
218 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
244 _H,g,_A,lb,ub,lbA,ubA,
247 maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
248 maxStationarity,maxFeasibility,maxComplementarity
250 nWSR = (
int_t)maxNWSR;
277 real_t CPUtimeLimit = maxCPUtime;
278 real_t CPUtimeCur = CPUtimeLimit;
283 maxStationarity = 0.0;
284 maxFeasibility = 0.0;
285 maxComplementarity = 0.0;
315 delete[] A_cpy;
delete[] H_cpy;
319 H =
new SymDenseMat(nV, nV, nV, const_cast<real_t *>(H_cpy));
320 A =
new DenseMatrix(nC, nV, nV, const_cast<real_t *>(A_cpy));
336 for( k=0; k<nQP; ++k )
343 lbCur = &( lb[k*nV] );
344 ubCur = &( ub[k*nV] );
345 lbACur = &( lbA[k*nC] );
346 ubACur = &( ubA[k*nC] );
349 nWSRcur = maxAllowedNWSR;
350 CPUtimeCur = CPUtimeLimit;
353 if ( ( k == 0 ) || ( useHotstarts ==
BT_FALSE ) )
356 returnvalue = qp.
init( H,gCur,A,lbCur,ubCur,lbACur,ubACur, nWSRcur,&CPUtimeCur );
359 delete A;
delete H;
delete[]
y;
delete[] x;
366 returnvalue = qp.
hotstart( gCur,lbCur,ubCur,lbACur,ubACur, nWSRcur,&CPUtimeCur );
369 delete A;
delete H;
delete[]
y;
delete[] x;
380 getKktViolation( nV,nC, _H,gCur,_A,lbCur,ubCur,lbACur,ubACur, x,y, stat,feas,cmpl );
383 if ( ((
double)nWSRcur) > maxNWSR )
384 maxNWSR = ((double)nWSRcur);
385 if (stat > maxStationarity) maxStationarity = stat;
386 if (feas > maxFeasibility) maxFeasibility = feas;
387 if (cmpl > maxComplementarity) maxComplementarity = cmpl;
389 if ( CPUtimeCur > maxCPUtime )
390 maxCPUtime = CPUtimeCur;
392 avgNWSR += ((double)nWSRcur);
393 avgCPUtime += CPUtimeCur;
395 avgNWSR /= ((double)nQP);
396 avgCPUtime /= ((double)nQP);
398 delete A;
delete H;
delete[]
y;
delete[] x;
423 maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
424 maxStationarity,maxFeasibility,maxComplementarity
426 nWSR = (
int_t)maxNWSR;
451 real_t CPUtimeLimit = maxCPUtime;
452 real_t CPUtimeCur = CPUtimeLimit;
458 maxStationarity = 0.0;
459 maxFeasibility = 0.0;
460 maxComplementarity = 0.0;
486 H =
new SymDenseMat(nV, nV, nV, const_cast<real_t *>(H_cpy));
500 for( k=0; k<nQP; ++k )
507 lbCur = &( lb[k*nV] );
508 ubCur = &( ub[k*nV] );
511 nWSRcur = maxAllowedNWSR;
512 CPUtimeCur = CPUtimeLimit;
515 if ( ( k == 0 ) || ( useHotstarts ==
BT_FALSE ) )
518 returnvalue = qp.
init( H,gCur,lbCur,ubCur, nWSRcur,&CPUtimeCur );
521 delete H;
delete[]
y;
delete[] x;
528 returnvalue = qp.
hotstart( gCur,lbCur,ubCur, nWSRcur,&CPUtimeCur );
531 delete H;
delete[]
y;
delete[] x;
545 if ( nWSRcur > maxNWSR )
547 if (stat > maxStationarity) maxStationarity = stat;
548 if (feas > maxFeasibility) maxFeasibility = feas;
549 if (cmpl > maxComplementarity) maxComplementarity = cmpl;
551 if ( CPUtimeCur > maxCPUtime )
552 maxCPUtime = CPUtimeCur;
555 avgCPUtime += CPUtimeCur;
558 avgCPUtime /= ((double)nQP);
560 delete H;
delete[]
y;
delete[] x;
580 maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
581 maxStationarity,maxFeasibility,maxComplementarity
583 nWSR = (
int_t)maxNWSR;
598 int_t nQP=0, nV=0, nC=0, nEC=0;
627 isSparse,useHotstarts,
628 options,maxAllowedNWSR,
629 maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
630 maxStationarity,maxFeasibility,maxComplementarity
635 if ( H != 0 )
delete[]
H;
636 if (
g != 0 )
delete[]
g;
637 if (
A != 0 )
delete[]
A;
638 if (
lb != 0 )
delete[]
lb;
639 if (
ub != 0 )
delete[]
ub;
640 if (
lbA != 0 )
delete[]
lbA;
641 if (
ubA != 0 )
delete[]
ubA;
649 isSparse,useHotstarts,
650 options,maxAllowedNWSR,
651 maxNWSR,avgNWSR,maxCPUtime,avgCPUtime,
652 maxStationarity,maxFeasibility,maxComplementarity
657 if ( H != 0 )
delete[]
H;
658 if (
g != 0 )
delete[]
g;
659 if (
A != 0 )
delete[]
A;
660 if (
lb != 0 )
delete[]
lb;
661 if (
ub != 0 )
delete[]
ub;
666 if ( H != 0 )
delete[]
H;
667 if (
g != 0 )
delete[]
g;
668 if (
A != 0 )
delete[]
A;
669 if (
lb != 0 )
delete[]
lb;
670 if (
ub != 0 )
delete[]
ub;
671 if (
lbA != 0 )
delete[]
lbA;
672 if (
ubA != 0 )
delete[]
ubA;
returnValue getPrimalSolution(real_t *const xOpt) const
BEGIN_NAMESPACE_QPOASES returnValue readOqpDimensions(const char *path, int_t &nQP, int_t &nV, int_t &nC, int_t &nEC)
Interfaces matrix-vector operations tailored to symmetric sparse matrices.
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
Implements the online active set strategy for box-constrained QPs.
returnValue getKktViolation(int_t nV, int_t nC, const real_t *const H, const real_t *const g, const real_t *const A, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, const real_t *const x, const real_t *const y, real_t &stat, real_t &feas, real_t &cmpl, const real_t *const workingSetB=0, const real_t *const workingSetC=0, BooleanType hasIdentityHessian=BT_FALSE)
Allows to pass back messages to the calling function.
Interfaces matrix-vector operations tailored to symmetric dense matrices.
#define THROWERROR(retval)
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
returnValue hotstart(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new, int &nWSR, real_t *const cputime)
returnValue readFromFile(real_t *data, int nrow, int ncol, const char *datafilename)
Interfaces matrix-vector operations tailored to general sparse matrices.
returnValue setOptions(const Options &_options)
returnValue hotstart(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, int &nWSR, real_t *const cputime)
Interfaces matrix-vector operations tailored to general dense matrices.
returnValue getDualSolution(real_t *const yOpt) const
Provides a generic way to set and pass user-specified options.
Abstract base class for interfacing tailored matrix-vector operations.
#define END_NAMESPACE_QPOASES
returnValue runOqpBenchmark(const char *path, BooleanType isSparse, const Options &options, int_t &nWSR, real_t &maxCPUtime, real_t &maxStationarity, real_t &maxFeasibility, real_t &maxComplementarity)
const uint_t MAX_STRING_LENGTH
returnValue solveOqpBenchmark(int_t nQP, int_t nV, int_t nC, int_t nEC, const real_t *const _H, const real_t *const g, const real_t *const _A, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, BooleanType isSparse, const Options &options, int_t &nWSR, real_t &maxCPUtime, real_t &maxStationarity, real_t &maxFeasibility, real_t &maxComplementarity)
#define BEGIN_NAMESPACE_QPOASES
Implements the online active set strategy for QPs with general constraints.
returnValue readOqpData(const char *path, int_t &nQP, int_t &nV, int_t &nC, int_t &nEC, real_t **H, real_t **g, real_t **A, real_t **lb, real_t **ub, real_t **lbA, real_t **ubA, real_t **xOpt, real_t **yOpt, real_t **objOpt)
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...
returnValue getDualSolution(real_t *const yOpt) const