46 myMexErrMsgTxt(
"ERROR (qpOASES_e): Too many primal variables (try increasing QPOASES_NVMAX)!" );
52 myMexErrMsgTxt(
"ERROR (qpOASES_e): Too many constraints (try increasing QPOASES_NCMAX)!" );
94 if ( ( mxGetM(pm) == 1 ) && ( mxGetN(pm) == 1 ) )
145 const mxArray* prhs[],
int idx
158 if ( mxIsEmpty( prhs[ idx ] ) )
161 if ( ( emptyAllowed ==
BT_TRUE ) || ( idx == 0 ) )
177 if ( mxIsSparse( prhs[ idx ] ) == 0 )
179 if ( ( mxGetM( prhs[ idx ] ) == m ) && ( mxGetN( prhs[ idx ] ) == n ) )
181 *input = (
real_t*) mxGetPr( prhs[ idx ] );
187 snprintf(msg,
QPOASES_MAX_STRING_LENGTH,
"ERROR (qpOASES_e): Input dimension mismatch for argument %d ([%ld,%ld] ~= [%d,%d]).",
188 idx+1, (
long int)mxGetM(prhs[idx]), (
long int)mxGetN(prhs[idx]), m, n);
190 snprintf(msg,
QPOASES_MAX_STRING_LENGTH,
"ERROR (qpOASES_e): Input dimension mismatch for some auxInput entry ([%ld,%ld] ~= [%d,%d]).",
191 (
long int)mxGetM(prhs[idx]), (
long int)mxGetN(prhs[idx]), m, n);
222 for ( i = 0; i < dim; ++i )
223 if ( mxIsNaN(data[i]) == 1 )
240 for ( i = 0; i < dim; ++i )
241 if ( mxIsInf(data[i]) == 1 )
262 if (mxIsSparse(prhs[rhs_index]) == 1)
263 dim = (
unsigned int)mxGetNzmax(prhs[rhs_index]);
265 dim = mxGetM(prhs[rhs_index]) * mxGetN(prhs[rhs_index]);
269 "ERROR (qpOASES_e): Argument %d contains 'NaN' !", rhs_index + 1);
277 "ERROR (qpOASES_e): Argument %d contains 'Inf' !",
295 if ( ( M_for == 0 ) || ( M == 0 ) )
298 if ( ( nV < 0 ) || ( nC < 0 ) )
301 for ( i=0; i<nC; ++i )
302 for ( j=0; j<nV; ++j )
303 M[i*nV + j] = M_for[j*nC + i];
314 mxArray* optionName = mxGetField( optionsPtr,0,optionString );
316 if ( optionName == 0 )
319 snprintf(msg,
QPOASES_MAX_STRING_LENGTH,
"Option struct does not contain entry '%s', using default value instead!", optionString );
320 mexWarnMsgTxt( msg );
324 if ( ( mxIsEmpty(optionName) ==
false ) && (
mxIsScalar( optionName ) ==
true ) )
326 *optionValue = mxGetPr( optionName );
333 mexWarnMsgTxt( msg );
349 if ( mxGetNumberOfFields(optionsPtr) != 31 )
350 mexWarnMsgTxt(
"Options might be set incorrectly as struct has wrong number of entries!\n Type 'help qpOASES_options' for further information." );
354 if ( *optionValue >= 0.0 )
355 *nWSRin = (int)*optionValue;
358 if ( *optionValue >= 0.0 )
359 *maxCpuTime = *optionValue;
363 #ifdef __SUPPRESSANYOUTPUT__ 366 optionValueInt = (int)*optionValue;
377 optionValueInt = (int)*optionValue;
383 optionValueInt = (int)*optionValue;
389 optionValueInt = (int)*optionValue;
395 optionValueInt = (int)*optionValue;
401 optionValueInt = (int)*optionValue;
407 optionValueInt = (int)*optionValue;
419 optionValueInt = (int)*optionValue;
434 options->
epsNum = *optionValue;
437 options->
epsDen = *optionValue;
460 optionValueInt = (int)*optionValue;
461 if ( optionValueInt < -1 )
463 if ( optionValueInt > 1 )
498 HessianType* hessianType,
double** x0,
double** guessedBounds,
double** guessedConstraints,
double**
R 501 mxArray* curField = 0;
502 double* hessianTypeTmp;
506 curField = mxGetField( auxInput,0,
"hessianType" );
507 if ( curField == NULL )
508 mexWarnMsgTxt(
"auxInput struct does not contain entry 'hessianType'!\n Type 'help qpOASES_auxInput' for further information." );
511 if ( mxIsEmpty(curField) ==
true )
520 hessianTypeTmp = mxGetPr(curField);
521 hessianTypeInt = (int)*hessianTypeTmp;
522 if ( hessianTypeInt < 0 )
524 if ( hessianTypeInt > 5 )
531 curField = mxGetField( auxInput,0,
"x0" );
532 if ( curField == NULL )
533 mexWarnMsgTxt(
"auxInput struct does not contain entry 'x0'!\n Type 'help qpOASES_auxInput' for further information." );
536 *x0 = mxGetPr(curField);
542 curField = mxGetField( auxInput,0,
"guessedWorkingSetB" );
543 if ( curField == NULL )
544 mexWarnMsgTxt(
"auxInput struct does not contain entry 'guessedWorkingSetB'!\n Type 'help qpOASES_auxInput' for further information." );
547 *guessedBounds = mxGetPr(curField);
553 curField = mxGetField( auxInput,0,
"guessedWorkingSetC" );
554 if ( curField == NULL )
555 mexWarnMsgTxt(
"auxInput struct does not contain entry 'guessedWorkingSetC'!\n Type 'help qpOASES_auxInput' for further information." );
558 *guessedConstraints = mxGetPr(curField);
564 curField = mxGetField( auxInput,0,
"R" );
565 if ( curField == NULL )
566 mexWarnMsgTxt(
"auxInput struct does not contain entry 'R'!\n Type 'help qpOASES_auxInput' for further information." );
569 *R = mxGetPr(curField);
590 plhs[curIdx++] = mxCreateDoubleMatrix( 1, 1, mxREAL );
593 plhs[curIdx++] = mxCreateDoubleMatrix( nV, nP, mxREAL );
598 plhs[curIdx++] = mxCreateDoubleMatrix( 1, nP, mxREAL );
603 plhs[curIdx++] = mxCreateDoubleMatrix( 1, nP, mxREAL );
608 plhs[curIdx++] = mxCreateDoubleMatrix( 1, nP, mxREAL );
613 plhs[curIdx++] = mxCreateDoubleMatrix( nV+nC, nP, mxREAL );
618 mxArray* auxOutput = mxCreateStructMatrix( 1,1,0,0 );
622 curFieldNum = mxAddField( auxOutput,
"workingSetB" );
623 if ( curFieldNum >= 0 )
624 mxSetFieldByNumber( auxOutput,0,curFieldNum,mxCreateDoubleMatrix( nV, nP, mxREAL ) );
626 curFieldNum = mxAddField( auxOutput,
"workingSetC" );
627 if ( curFieldNum >= 0 )
628 mxSetFieldByNumber( auxOutput,0,curFieldNum,mxCreateDoubleMatrix( nC, nP, mxREAL ) );
630 curFieldNum = mxAddField( auxOutput,
"cpuTime" );
631 if ( curFieldNum >= 0 )
632 mxSetFieldByNumber( auxOutput,0,curFieldNum,mxCreateDoubleMatrix( 1, nP, mxREAL ) );
634 plhs[curIdx] = auxOutput;
649 int nlhs, mxArray* plhs[],
int nV,
int nC,
int handle
652 double *x=0, *obj=0, *status=0, *nWSRout=0, *
y=0, *workingSetB=0, *workingSetC=0, *cpuTime;
653 mxArray *auxOutput=0, *curField=0;
660 plhs[curIdx++] = mxCreateDoubleScalar( handle );
663 x = mxGetPr( plhs[curIdx++] );
669 obj = mxGetPr( plhs[curIdx++] );
675 status = mxGetPr( plhs[curIdx++] );
681 nWSRout = mxGetPr( plhs[curIdx++] );
682 nWSRout[k] = (double) _nWSRout;
687 y = mxGetPr( plhs[curIdx++] );
693 auxOutput = plhs[curIdx];
699 curField = mxGetField( auxOutput,0,
"workingSetB" );
700 workingSetB = mxGetPr(curField);
707 curField = mxGetField( auxOutput,0,
"workingSetC" );
708 workingSetC = mxGetPr(curField);
713 curField = mxGetField( auxOutput,0,
"cpuTime" );
714 cpuTime = mxGetPr(curField);
715 cpuTime[0] = (double) _cpuTime;
730 int nlhs, mxArray* plhs[],
int nV,
int handle
733 double *x=0, *obj=0, *status=0, *nWSRout=0, *
y=0, *workingSetB=0, *workingSetC=0, *cpuTime;
734 mxArray *auxOutput=0, *curField=0;
741 plhs[curIdx++] = mxCreateDoubleScalar( handle );
744 x = mxGetPr( plhs[curIdx++] );
750 obj = mxGetPr( plhs[curIdx++] );
756 status = mxGetPr( plhs[curIdx++] );
762 nWSRout = mxGetPr( plhs[curIdx++] );
763 nWSRout[k] = (double) _nWSRout;
768 y = mxGetPr( plhs[curIdx++] );
774 auxOutput = plhs[curIdx];
780 curField = mxGetField( auxOutput,0,
"workingSetB" );
781 workingSetB = mxGetPr(curField);
786 curField = mxGetField( auxOutput,0,
"cpuTime" );
787 cpuTime = mxGetPr(curField);
788 cpuTime[0] = (double) _cpuTime;
813 if ( mxIsSparse( prhsH ) != 0 )
815 myMexErrMsgTxt(
"ERROR (qpOASES_e): Cannot handle sparse matrices!" );
821 H_for = (
real_t*) mxGetPr( prhsH );
844 if ( mxIsSparse( prhsA ) != 0 )
846 myMexErrMsgTxt(
"ERROR (qpOASES_e): Cannot handle sparse matrices!" );
852 A_for = (
real_t*) mxGetPr( prhsA );
void QProblemBCON(QProblemB *_THIS, int _nV, HessianType _hessianType)
returnValue QProblem_getPrimalSolution(QProblem *_THIS, real_t *const xOpt)
returnValue QProblemB_getWorkingSetBounds(QProblemB *_THIS, real_t *workingSetB)
static int QProblemB_getNV(QProblemB *_THIS)
int allocateQPInstance(int nV, int nC, HessianType hessianType, BooleanType isSimplyBounded, const Options *options)
QPInstance * getQPInstance(int handle)
BooleanType containsNaN(const real_t *const data, unsigned int dim)
int QPInstance_getNV(QPInstance *_THIS)
Implements the online active set strategy for box-constrained QPs.
returnValue QProblemB_getDualSolution(QProblemB *_THIS, real_t *const yOpt)
BooleanType enableFarBounds
returnValue setupHessianMatrix(const mxArray *prhsH, int nV, DenseMatrix *H)
BooleanType isSimplyBounded
int qpOASES_getSimpleStatus(returnValue returnvalue, BooleanType doPrintStatus)
static QPInstance QPInstances[MAX_NUM_QPINSTANCES]
Allows to pass back messages to the calling function.
returnValue setupOptions(Options *options, const mxArray *optionsPtr, int *nWSRin, real_t *maxCpuTime)
int QPInstance_getNC(QPInstance *_THIS)
real_t QProblemB_getObjVal(QProblemB *_THIS)
BooleanType enableFullLITests
BooleanType enableEqualities
BooleanType enableRamping
BooleanType containsInf(const real_t *const data, unsigned int dim)
returnValue obtainOutputsSB(int k, QProblemB *qp, returnValue returnvalue, int _nWSRout, double _cpuTime, int nlhs, mxArray *plhs[], int nV, int handle)
BooleanType enableFlippingBounds
static int QProblem_getNV(QProblem *_THIS)
void DenseMatrixCON(DenseMatrix *_THIS, int m, int n, int lD, real_t *v)
returnValue setupConstraintMatrix(const mxArray *prhsA, int nV, int nC, DenseMatrix *A)
Interfaces matrix-vector operations tailored to general dense matrices.
bool mxIsScalar(const mxArray *pm)
Provides a generic way to set and pass user-specified options.
real_t QProblem_getObjVal(QProblem *_THIS)
returnValue obtainOutputs(int k, QProblem *qp, returnValue returnvalue, int _nWSRout, double _cpuTime, int nlhs, mxArray *plhs[], int nV, int nC, int handle)
int enableDriftCorrection
returnValue allocateOutputs(int nlhs, mxArray *plhs[], int nV, int nC, int nP, int handle)
BooleanType hasOptionsValue(const mxArray *optionsPtr, const char *const optionString, double **optionValue)
BooleanType enableRegularisation
static returnValue QProblemB_setOptions(QProblemB *_THIS, Options _options)
static int QProblem_getNC(QProblem *_THIS)
returnValue QProblemB_getPrimalSolution(QProblemB *_THIS, real_t *const xOpt)
returnValue QProblem_getDualSolution(QProblem *_THIS, real_t *const yOpt)
real_t terminationTolerance
returnValue QProblem_getWorkingSetConstraints(QProblem *_THIS, real_t *workingSetC)
void QPInstanceCON(QPInstance *_THIS, int _nV, int _nC, HessianType _hessianType, BooleanType _isSimplyBounded)
returnValue setupAuxiliaryInputs(const mxArray *auxInput, unsigned int nV, unsigned int nC, HessianType *hessianType, double **x0, double **guessedBounds, double **guessedConstraints, double **R)
int numRegularisationSteps
int enableCholeskyRefactorisation
BooleanType enableNZCTests
returnValue convertFortranToC(const real_t *const M_for, int nV, int nC, real_t *const M)
#define QPOASES_MAX_STRING_LENGTH
Implements the online active set strategy for QPs with general constraints.
static int QPInstance_nexthandle
void QProblemCON(QProblem *_THIS, int _nV, int _nC, HessianType _hessianType)
#define MAX_NUM_QPINSTANCES
SubjectToStatus initialStatusBounds
static returnValue QProblem_setOptions(QProblem *_THIS, Options _options)
BooleanType containsNaNorInf(const mxArray *prhs[], int rhs_index, BooleanType mayContainInf)
#define REFER_NAMESPACE_QPOASES
returnValue smartDimensionCheck(real_t **input, unsigned int m, unsigned int n, BooleanType emptyAllowed, const mxArray *prhs[], int idx)
returnValue QProblem_getWorkingSetBounds(QProblem *_THIS, real_t *workingSetB)