38 #include <qpOASES/QProblem.hpp> 86 if ( globalQP_H != 0 )
92 if ( globalQP_A != 0 )
115 int nOutputs, mxArray* plhs[]
125 returnvalue = globalQP->
init( H,g,A,lb,ub,lbA,ubA, nWSR,0 );
127 returnvalue = globalQP->
init( H,g,A,lb,ub,lbA,ubA, nWSR,0, x0,0,0,0 );
144 int nOutputs, mxArray* plhs[]
162 void mexFunction(
int nlhs, mxArray* plhs[],
int nrhs,
const mxArray* prhs[] )
168 real_t *H_for=0, *H_mem=0, *
g=0, *A_for=0, *A_mem=0, *
lb=0, *
ub=0, *
lbA=0, *
ubA=0, *x0=0;
175 #ifdef __SUPPRESSANYOUTPUT__ 180 unsigned int nV=0, nC=0;
185 if ( ( nrhs < 6 ) || ( nrhs > 10 ) )
187 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of input arguments!\nType 'help qpOASES_sequence' for further information." );
190 if ( mxIsChar( prhs[0] ) != 1 )
191 mexErrMsgTxt(
"ERROR (qpOASES): First input argument must be a string!" );
193 typeString = (
char*) mxGetPr( prhs[0] );
196 if ( ( strcmp( typeString,
"i" ) != 0 ) && ( strcmp( typeString,
"I" ) != 0 ) &&
197 ( strcmp( typeString,
"h" ) != 0 ) && ( strcmp( typeString,
"H" ) != 0 ) &&
198 ( strcmp( typeString,
"c" ) != 0 ) && ( strcmp( typeString,
"C" ) != 0 ) )
200 mexErrMsgTxt(
"ERROR (qpOASES): Undefined first input argument!\nType 'help qpOASES_sequence' for further information." );
206 if ( ( strcmp( typeString,
"i" ) == 0 ) || ( strcmp( typeString,
"I" ) == 0 ) )
209 if ( ( nlhs < 1 ) || ( nlhs > 5 ) )
210 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of output arguments!\nType 'help qpOASES_sequence' for further information." );
212 if ( ( nrhs < 8 ) || ( nrhs > 10 ) )
213 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of input arguments!\nType 'help qpOASES_sequence' for further information." );
216 if ( ( mxIsDouble( prhs[1] ) == 0 ) ||
217 ( mxIsDouble( prhs[2] ) == 0 ) ||
218 ( mxIsDouble( prhs[3] ) == 0 ) )
219 mexErrMsgTxt(
"ERROR (qpOASES): All data has to be provided in real_t precision!" );
227 nV = mxGetM( prhs[1] );
228 nC = mxGetM( prhs[3] );
230 if ( ( mxGetN( prhs[1] ) != nV ) || ( ( mxGetN( prhs[3] ) != 0 ) && ( mxGetN( prhs[3] ) != nV ) ) )
231 mexErrMsgTxt(
"ERROR (qpOASES): Input dimension mismatch!" );
250 int nWSRin = 5*(nV+nC);
260 if ( ( !mxIsEmpty( prhs[9] ) ) && ( mxIsStruct( prhs[9] ) ) )
268 if ( mxIsSparse( prhs[1] ) != 0 )
270 long *ir = (
long *)mxGetIr(prhs[1]);
271 long *jc = (
long *)mxGetJc(prhs[1]);
285 H_for = (
real_t*) mxGetPr( prhs[1] );
286 H_mem =
new real_t[nV*nV];
287 for(
int i=0; i<nV*nV; ++i )
298 if ( mxIsSparse( prhs[3] ) != 0 )
300 long *ir = (
long *)mxGetIr(prhs[3]);
301 long *jc = (
long *)mxGetJc(prhs[3]);
310 A_for = (
real_t*) mxGetPr( prhs[3] );
311 A_mem =
new real_t[nC*nV];
323 globalQP_H,
g,globalQP_A,
333 if ( ( strcmp( typeString,
"h" ) == 0 ) || ( strcmp( typeString,
"H" ) == 0 ) )
336 if ( ( nlhs < 1 ) || ( nlhs > 5 ) )
337 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of output arguments!\nType 'help qpOASES_sequence' for further information." );
339 if ( ( nrhs < 6 ) || ( nrhs > 7 ) )
340 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of input arguments!\nType 'help qpOASES_sequence' for further information." );
344 mexErrMsgTxt(
"ERROR (qpOASES): QP sequence needs to be initialised first!" );
348 nV = globalQP->
getNV( );
349 nC = globalQP->
getNC( );
367 int nWSRin = 5*(nV+nC);
371 if ( ( !mxIsEmpty( prhs[6] ) ) && ( mxIsStruct( prhs[6] ) ) )
388 if ( ( strcmp( typeString,
"c" ) == 0 ) || ( strcmp( typeString,
"C" ) == 0 ) )
392 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of output arguments!\nType 'help qpOASES_sequence' for further information." );
395 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of input arguments!\nType 'help qpOASES_sequence' for further information." );
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)
returnValue setupOptions(Options *options, const mxArray *optionsPtr, int &nWSRin)
Allows to pass back messages to the calling function.
Interfaces matrix-vector operations tailored to symmetric dense matrices.
void allocateGlobalQProblemInstance(int nV, int nC, Options *options)
void deleteGlobalQProblemInstance()
returnValue smartDimensionCheck(real_t **input, unsigned int m, unsigned int n, BooleanType emptyAllowed, const mxArray *prhs[], int idx)
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 convertFortranToC(const real_t *const A_for, int nV, int nC, real_t *const A)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
returnValue setOptions(const Options &_options)
static long * globalQP_Hdiag
Interfaces matrix-vector operations tailored to general dense matrices.
void allocateOutputs(int nlhs, mxArray *plhs[], int nV, int nC=0, int nP=1)
Interfaces matrix-vector operations tailored to general sparse matrices.
static QProblem * globalQP
Provides a generic way to set and pass user-specified options.
Abstract base class for interfacing tailored matrix-vector operations.
void deleteGlobalQProblemMatrices()
void 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 nWSR, Options *options, int nOutputs, mxArray *plhs[])
void obtainOutputs(int k, QProblemB *qp, returnValue returnvalue, int nWSRin, int nlhs, mxArray *plhs[], int nV, int nC=0)
Implements the online active set strategy for QPs with general constraints.
static Matrix * globalQP_A
void init(int nV, int nC, SymmetricMatrix *H, real_t *g, Matrix *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 x0, Options *options, int nOutputs, mxArray *plhs[])
static SymmetricMatrix * globalQP_H
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...