38 #include <qpOASES/extras/OQPinterface.hpp> 39 #include <qpOASES/QProblem.hpp> 49 int& nQP,
int& nV,
int& nC,
int& nEC
54 snprintf( filename,160,
"%sdims.oqp",path );
68 if ( ( nQP <= 0 ) || ( nV <= 0 ) || ( nC < 0 ) || ( nEC < 0 ) )
79 int& nQP,
int& nV,
int& nC,
int& nEC,
87 if ( ( H == 0 ) || ( g == 0 ) || ( lb == 0 ) || ( ub == 0 ) )
97 if ( ( nC > 0 ) && ( ( A == 0 ) || ( lbA == 0 ) || ( ubA == 0 ) ) )
104 snprintf( filename,160,
"%sH.oqp",path );
113 snprintf( filename,160,
"%sg.oqp",path );
116 delete[] *
g;
delete[] *
H;
122 snprintf( filename,160,
"%slb.oqp",path );
125 delete[] *
lb;
delete[] *
g;
delete[] *
H;
131 snprintf( filename,160,
"%sub.oqp",path );
134 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
142 snprintf( filename,160,
"%sA.oqp",path );
146 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
151 *lbA =
new real_t[nQP*nC];
152 snprintf( filename,160,
"%slbA.oqp",path );
155 delete[] *
lbA;
delete[] *
A;
156 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
161 *ubA =
new real_t[nQP*nC];
162 snprintf( filename,160,
"%subA.oqp",path );
165 delete[] *
ubA;
delete[] *
lbA;
delete[] *
A;
166 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
180 *xOpt =
new real_t[nQP*nV];
181 snprintf( filename,160,
"%sx_opt.oqp",path );
185 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
186 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
194 *yOpt =
new real_t[nQP*(nV+nC)];
195 snprintf( filename,160,
"%sy_opt.oqp",path );
199 if ( xOpt != 0 ) {
delete[]
xOpt; };
200 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
201 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
209 *objOpt =
new real_t[nQP];
210 snprintf( filename,160,
"%sobj_opt.oqp",path );
214 if ( yOpt != 0 ) {
delete[] yOpt; };
215 if ( xOpt != 0 ) {
delete[]
xOpt; };
216 if ( nC > 0 ) {
delete[] *
ubA;
delete[] *
lbA;
delete[] *
A; };
217 delete[] *
ub;
delete[] *
lb;
delete[] *
g;
delete[] *
H;
246 real_t CPUtimeLimit = maxCPUtime;
247 real_t CPUtimeCur = CPUtimeLimit;
249 maxStationarity = 0.0;
250 maxFeasibility = 0.0;
251 maxComplementarity = 0.0;
277 H =
new SymDenseMat(nV, nV, nV, const_cast<real_t *>(_H));
278 A =
new DenseMatrix(nC, nV, nV, const_cast<real_t *>(_A));
290 for( k=0; k<nQP; ++k )
294 lbCur = &( lb[k*nV] );
295 ubCur = &( ub[k*nV] );
296 lbACur = &( lbA[k*nC] );
297 ubACur = &( ubA[k*nC] );
301 CPUtimeCur = CPUtimeLimit;
307 returnvalue = qp.
init( H,gCur,A,lbCur,ubCur,lbACur,ubACur, nWSRcur,&CPUtimeCur );
310 delete A;
delete H;
delete[]
y;
delete[] x;
317 returnvalue = qp.
hotstart( gCur,lbCur,ubCur,lbACur,ubACur, nWSRcur,&CPUtimeCur );
320 delete A;
delete H;
delete[]
y;
delete[] x;
330 getKKTResidual( nV, nC, _H,gCur,_A,lbCur,ubCur,lbACur,ubACur, x, y, stat, feas, cmpl );
333 if ( nWSRcur > maxNWSR )
335 if (stat > maxStationarity) maxStationarity = stat;
336 if (feas > maxFeasibility) maxFeasibility = feas;
337 if (cmpl > maxComplementarity) maxComplementarity = cmpl;
339 if ( CPUtimeCur > maxCPUtime )
340 maxCPUtime = CPUtimeCur;
344 delete A;
delete H;
delete[]
y;
delete[] x;
369 real_t CPUtimeLimit = maxCPUtime;
370 real_t CPUtimeCur = CPUtimeLimit;
373 maxStationarity = 0.0;
374 maxFeasibility = 0.0;
375 maxComplementarity = 0.0;
396 H =
new SymDenseMat(nV, nV, nV, const_cast<real_t *>(_H));
408 for( k=0; k<nQP; ++k )
412 lbCur = &( lb[k*nV] );
413 ubCur = &( ub[k*nV] );
417 CPUtimeCur = CPUtimeLimit;
423 returnvalue = qp.
init( H,gCur,lbCur,ubCur, nWSRcur,&CPUtimeCur );
426 delete H;
delete[]
y;
delete[] x;
433 returnvalue = qp.
hotstart( gCur,lbCur,ubCur, nWSRcur,&CPUtimeCur );
436 delete H;
delete[]
y;
delete[] x;
446 getKKTResidual( nV,0, _H,gCur,0,lbCur,ubCur,0,0, x,y, stat,feas,cmpl );
449 if ( nWSRcur > maxNWSR )
451 if (stat > maxStationarity) maxStationarity = stat;
452 if (feas > maxFeasibility) maxFeasibility = feas;
453 if (cmpl > maxComplementarity) maxComplementarity = cmpl;
455 if ( CPUtimeCur > maxCPUtime )
456 maxCPUtime = CPUtimeCur;
459 delete H;
delete[]
y;
delete[] x;
473 int nQP=0, nV=0, nC=0, nEC=0;
503 maxStationarity,maxFeasibility,maxComplementarity
508 delete[]
H;
delete[]
A;
509 delete[]
ubA;
delete[]
lbA;
delete[]
ub;
delete[]
lb;
delete[]
g;
519 maxStationarity,maxFeasibility,maxComplementarity
524 delete[]
H;
delete[]
A;
525 delete[]
ub;
delete[]
lb;
delete[]
g;
530 delete[]
H;
delete[]
A;
531 delete[]
ubA;
delete[]
lbA;
delete[]
ub;
delete[]
lb;
delete[]
g;
returnValue getPrimalSolution(real_t *const xOpt) const
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.
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)
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
Interfaces matrix-vector operations tailored to general sparse matrices.
Provides a generic way to set and pass user-specified options.
Abstract base class for interfacing tailored matrix-vector operations.
#define END_NAMESPACE_QPOASES
#define BEGIN_NAMESPACE_QPOASES
Implements the online active set strategy for QPs with general constraints.
returnValue setPrintLevel(PrintLevel _printlevel)
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...
void getKKTResidual(int nV, int 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)
returnValue getDualSolution(real_t *const yOpt) const