50 double*
lb,
double*
ub,
52 int nWSRin,
real_t maxCpuTimeIn,
54 int nOutputs, mxArray* plhs[],
55 const double*
const guessedBounds,
const double*
const guessedConstraints,
56 const double*
const _R
65 real_t *g_current, *lb_current, *ub_current, *lbA_current, *ubA_current;
79 if (guessedBounds != 0) {
80 for (i = 0; i < nV; i++) {
89 "ERROR (qpOASES_e): Only {-1, 0, 1} allowed for status of bounds!");
96 if (guessedConstraints != 0) {
97 for (i = 0; i < nC; i++) {
106 "ERROR (qpOASES_e): Only {-1, 0, 1} allowed for status of constraints!");
114 maxCpuTimeOut = (maxCpuTimeIn >= 0.0) ? maxCpuTimeIn :
QPOASES_INFTY;
117 &nWSRout,&maxCpuTimeOut,
119 (guessedBounds != 0) ? &bounds : 0, (guessedConstraints != 0) ? &constraints : 0,
132 for ( k=0; k<nP; ++k )
137 g_current = &(g[k*nV]);
139 lb_current = &(lb[k*nV]);
141 ub_current = &(ub[k*nV]);
143 lbA_current = &(lbA[k*nC]);
145 ubA_current = &(ubA[k*nC]);
148 maxCpuTimeOut = (maxCpuTimeIn >= 0.0) ? maxCpuTimeIn :
QPOASES_INFTY;
149 returnvalue =
QProblem_hotstart( &QP,g_current,lb_current,ub_current,lbA_current,ubA_current, &nWSRout,&maxCpuTimeOut );
154 nOutputs,plhs,nV,nC,-1 );
169 double*
lb,
double*
ub,
170 int nWSRin,
real_t maxCpuTimeIn,
172 int nOutputs, mxArray* plhs[],
173 const double*
const guessedBounds,
174 const double*
const _R
183 real_t *g_current, *lb_current, *ub_current;
194 if (guessedBounds != 0) {
195 for (i = 0; i < nV; i++) {
204 "ERROR (qpOASES_e): Only {-1, 0, 1} allowed for status of bounds!");
212 maxCpuTimeOut = (maxCpuTimeIn >= 0.0) ? maxCpuTimeIn :
QPOASES_INFTY;
215 &nWSRout,&maxCpuTimeOut,
217 (guessedBounds != 0) ? &bounds : 0,
228 for ( k=0; k<nP; ++k )
233 g_current = &(g[k*nV]);
235 lb_current = &(lb[k*nV]);
237 ub_current = &(ub[k*nV]);
240 maxCpuTimeOut = (maxCpuTimeIn >= 0.0) ? maxCpuTimeIn :
QPOASES_INFTY;
241 returnvalue =
QProblemB_hotstart( &QP,g_current,lb_current,ub_current, &nWSRout,&maxCpuTimeOut );
246 nOutputs,plhs,nV,-1 );
257 void mexFunction(
int nlhs, mxArray* plhs[],
int nrhs,
const mxArray* prhs[] )
265 double *x0=0, *R_for=0;
267 double *guessedBounds=0, *guessedConstraints=0;
269 int H_idx=-1, g_idx=-1, A_idx=-1, lb_idx=-1, ub_idx=-1, lbA_idx=-1, ubA_idx=-1;
270 int options_idx=-1, x0_idx=-1, auxInput_idx=-1;
273 unsigned int nV=0, nC=0, nP=0;
288 #ifdef __SUPPRESSANYOUTPUT__ 295 if ( ( nrhs < 4 ) || ( nrhs > 9 ) )
297 myMexErrMsgTxt(
"ERROR (qpOASES_e): Invalid number of input arguments!\nType 'help qpOASES' for further information." );
304 myMexErrMsgTxt(
"ERROR (qpOASES_e): At most six output arguments are allowed: \n [x,fval,exitflag,iter,lambda,auxOutput]!" );
309 myMexErrMsgTxt(
"ERROR (qpOASES_e): At least one output argument is required: [x,...]!" );
319 if ( mxIsEmpty(prhs[0]) == 1 )
322 nV = (int)mxGetM( prhs[ g_idx ] );
327 nV = (int)mxGetM( prhs[ H_idx ] );
330 nP = (int)mxGetN( prhs[ g_idx ] );
339 if ( isSimplyBoundedQp ==
BT_TRUE )
341 if ( ( nrhs >= 5 ) && ( !mxIsEmpty(prhs[4]) ) && ( mxIsStruct(prhs[4]) ) )
347 if ( ( !mxIsEmpty(prhs[4]) ) && ( mxIsStruct(prhs[4]) ) )
349 myMexErrMsgTxt(
"ERROR (qpOASES_e): Fifth input argument must not be a struct when solving QP with general constraints!\nType 'help qpOASES' for further information." );
353 if ( ( nrhs >= 8 ) && ( !mxIsEmpty(prhs[7]) ) && ( mxIsStruct(prhs[7]) ) )
358 numberOfColumns = (int)mxGetN(prhs[2]);
361 if ( ( isSimplyBoundedQp ==
BT_TRUE ) ||
362 ( ( numberOfColumns == 1 ) && ( nV != 1 ) ) )
367 if ( ( nrhs >= 6 ) && ( !mxIsEmpty(prhs[5]) ) )
370 if ( mxIsStruct(prhs[5]) )
392 if ( mxIsEmpty( prhs[ A_idx ] ) )
406 nC = (int)mxGetM( prhs[ A_idx ] );
409 if ( ( nrhs >= 9 ) && ( !mxIsEmpty(prhs[8]) ) )
412 if ( mxIsStruct(prhs[8]) )
432 if ( ( ( H_idx >= 0 ) && ( mxIsDouble( prhs[ H_idx ] ) == 0 ) ) ||
433 ( mxIsDouble( prhs[ g_idx ] ) == 0 ) )
435 myMexErrMsgTxt(
"ERROR (qpOASES_e): All data has to be provided in double precision!" );
453 if ( ( H_idx >= 0 ) && ( ( mxGetN( prhs[ H_idx ] ) != nV ) || ( mxGetM( prhs[ H_idx ] ) != nV ) ) )
456 (
long int)mxGetN(prhs[H_idx]), nV);
464 if ( mxIsDouble( prhs[ A_idx ] ) == 0 )
466 myMexErrMsgTxt(
"ERROR (qpOASES_e): All data has to be provided in real_t precision!" );
471 if ( mxGetN( prhs[ A_idx ] ) != nV )
474 (
long int)mxGetN(prhs[A_idx]), nV);
511 if ( auxInput_idx >= 0 )
512 setupAuxiliaryInputs( prhs[auxInput_idx],nV,nC, &hessianType,&x0,&guessedBounds,&guessedConstraints,&R_for );
524 if ( options_idx > 0 )
525 setupOptions( &options,prhs[options_idx],&nWSRin,&maxCpuTimeIn );
532 if ( ( nC > 0 ) && ( A_idx >= 0 ) )
541 ( H_idx >= 0 ) ? &H : 0, g,
547 ( R_for != 0 ) ? R : 0
555 ( H_idx >= 0 ) ? &H : 0, g, ( ( nC > 0 ) && ( A_idx >= 0 ) ) ? &A : 0,
560 guessedBounds,guessedConstraints,
561 ( R_for != 0 ) ? R : 0
void QProblemBCON(QProblemB *_THIS, int _nV, HessianType _hessianType)
returnValue Bounds_setupBound(Bounds *_THIS, int number, SubjectToStatus _status)
#define USING_NAMESPACE_QPOASES
USING_NAMESPACE_QPOASES int QProblem_qpOASES(int nV, int nC, HessianType hessianType, int nP, DenseMatrix *H, double *g, DenseMatrix *A, double *lb, double *ub, double *lbA, double *ubA, int nWSRin, real_t maxCpuTimeIn, const double *const x0, Options *options, int nOutputs, mxArray *plhs[], const double *const guessedBounds, const double *const guessedConstraints, const double *const _R)
BooleanType containsNaNorInf(const mxArray *prhs[], int_t rhs_index, bool mayContainInf)
static BooleanType qpOASES_isEqual(real_t x, real_t y, real_t TOL)
Manages working sets of constraints.
returnValue setupHessianMatrix(const mxArray *prhsH, int_t nV, SymmetricMatrix **H, sparse_int_t **Hir, sparse_int_t **Hjc, real_t **Hv)
Implements the online active set strategy for box-constrained QPs.
returnValue setupOptions(Options *options, const mxArray *optionsPtr, int &nWSRin)
Allows to pass back messages to the calling function.
returnValue QProblem_initMW(QProblem *_THIS, DenseMatrix *_H, const real_t *const _g, DenseMatrix *_A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int *nWSR, real_t *const cputime, const real_t *const xOpt, const real_t *const yOpt, Bounds *const guessedBounds, Constraints *const guessedConstraints, const real_t *const _R)
returnValue smartDimensionCheck(real_t **input, unsigned int m, unsigned int n, BooleanType emptyAllowed, const mxArray *prhs[], int idx)
returnValue Constraints_setupConstraint(Constraints *_THIS, int number, SubjectToStatus _status)
returnValue convertFortranToC(const real_t *const A_for, int nV, int nC, real_t *const A)
returnValue obtainOutputsSB(int k, QProblemB *qp, returnValue returnvalue, int _nWSRout, double _cpuTime, int nlhs, mxArray *plhs[], int nV, int handle)
int QProblemB_qpOASES(int nV, HessianType hessianType, int nP, DenseMatrix *H, double *g, double *lb, double *ub, int nWSRin, real_t maxCpuTimeIn, const double *const x0, Options *options, int nOutputs, mxArray *plhs[], const double *const guessedBounds, const double *const _R)
Interfaces matrix-vector operations tailored to general dense matrices.
void allocateOutputs(int nlhs, mxArray *plhs[], int nV, int nC=0, int nP=1)
returnValue setupAuxiliaryInputs(const mxArray *auxInput, uint_t nV, uint_t nC, HessianType *hessianType, double **x0, double **guessedBounds, double **guessedConstraints, double **R)
int_t QProblemB_hotstart(const real_t *const g, const real_t *const lb, const real_t *const ub, int_t *const nWSR, real_t *const cputime, real_t *const x, real_t *const y, real_t *const obj, int_t *const status)
Provides a generic way to set and pass user-specified options.
static returnValue QProblemB_setOptions(QProblemB *_THIS, Options _options)
static const real_t QPOASES_INFTY
void obtainOutputs(int k, QProblemB *qp, returnValue returnvalue, int nWSRin, int nlhs, mxArray *plhs[], int nV, int nC=0)
returnValue Options_setToDefault(Options *_THIS)
returnValue setupConstraintMatrix(const mxArray *prhsA, int_t nV, int_t nC, Matrix **A, sparse_int_t **Air, sparse_int_t **Ajc, real_t **Av)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
#define QPOASES_MAX_STRING_LENGTH
Manages working sets of bounds (= box constraints).
int_t QProblem_hotstart(const real_t *const g, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, int_t *const nWSR, real_t *const cputime, real_t *const x, real_t *const y, real_t *const obj, int_t *const status)
Implements the online active set strategy for QPs with general constraints.
void QProblemCON(QProblem *_THIS, int _nV, int _nC, HessianType _hessianType)
static const real_t QPOASES_TOL
void ConstraintsCON(Constraints *_THIS, int _n)
returnValue QProblemB_initMW(QProblemB *_THIS, DenseMatrix *_H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub, int *nWSR, real_t *const cputime, const real_t *const xOpt, const real_t *const yOpt, Bounds *const guessedBounds, const real_t *const _R)
static returnValue QProblem_setOptions(QProblem *_THIS, Options _options)
void BoundsCON(Bounds *_THIS, int _n)