36 #include <qpOASES/QProblem.hpp> 52 int nOutputs, mxArray* plhs[]
63 returnvalue = QP.
init( H,g,A,lb,ub,lbA,ubA, nWSRin,0 );
65 returnvalue = QP.
init( H,g,A,lb,ub,lbA,ubA, nWSRin,0, x0,0,0,0 );
76 for (
int k=0; k<nP; ++k )
81 g_current = &(g[k*nV]);
83 lb_current = &(lb[k*nV]);
85 ub_current = &(ub[k*nV]);
87 lbA_current = &(lbA[k*nC]);
89 ubA_current = &(ubA[k*nC]);
91 returnvalue = QP.
hotstart( g_current,lb_current,ub_current,lbA_current,ubA_current, nWSRin,0 );
96 nOutputs,plhs,nV,nC );
110 int nOutputs, mxArray* plhs[]
121 returnvalue = QP.
init( H,g,lb,ub, nWSRin,0 );
123 returnvalue = QP.
init( H,g,lb,ub, nWSRin,0, x0,0,0 );
132 for (
int k=0; k<nP; ++k )
137 g_current = &(g[k*nV]);
139 lb_current = &(lb[k*nV]);
141 ub_current = &(ub[k*nV]);
143 returnvalue = QP.
hotstart( g_current,lb_current,ub_current, nWSRin,0 );
159 void mexFunction(
int nlhs, mxArray* plhs[],
int nrhs,
const mxArray* prhs[] )
165 int H_idx, g_idx, A_idx, lb_idx, ub_idx, lbA_idx, ubA_idx, x0_idx=-1, options_idx=-1;
172 #ifdef __SUPPRESSANYOUTPUT__ 177 unsigned int nV=0, nC=0, nP=0;
184 if ( ( nrhs < 4 ) || ( nrhs > 9 ) )
185 mexErrMsgTxt(
"ERROR (qpOASES): Invalid number of input arguments!\n Type 'help qpOASES' for further information." );
189 mexErrMsgTxt(
"ERROR (qpOASES): At most five output arguments are allowed: \n [obj,x,y,status,nWSRout]!" );
191 mexErrMsgTxt(
"ERROR (qpOASES): At least one output argument is required: [obj,...]!" );
199 nV = mxGetM( prhs[ H_idx ] );
200 nP = mxGetN( prhs[ g_idx ] );
203 if ( ( !mxIsEmpty( prhs[nrhs-1] ) ) && ( mxIsStruct( prhs[nrhs-1] ) ) )
204 options_idx = nrhs-1;
207 if ( ( ( nrhs >= 4 ) && ( nrhs <= 5 ) ) ||
208 ( ( options_idx > 0 ) && ( nrhs == 6 ) ) )
223 if ( mxIsEmpty( prhs[ A_idx ] ) )
245 nC = mxGetM( prhs[ A_idx ] );
251 int nWSRin = 5*(nV+nC);
252 if ( options_idx > 0 )
256 if ( ( mxIsDouble( prhs[ H_idx ] ) == 0 ) ||
257 ( mxIsDouble( prhs[ g_idx ] ) == 0 ) )
258 mexErrMsgTxt(
"ERROR (qpOASES): All data has to be provided in double precision!" );
261 if ( mxGetN( prhs[ H_idx ] ) != nV )
264 snprintf(msg, 199,
"ERROR (qpOASES): Hessian matrix input dimension mismatch (%ld != %d)!",
265 (
long int)mxGetN(prhs[H_idx]), nV);
266 fprintf(stderr,
"%s\n", msg);
271 if ( mxIsSparse( prhs[ H_idx ] ) != 0 )
273 long *ir = (
long *)mxGetIr(prhs[H_idx]);
274 long *jc = (
long *)mxGetJc(prhs[H_idx]);
306 if ( mxIsDouble( prhs[ A_idx ] ) == 0 )
307 mexErrMsgTxt(
"ERROR (qpOASES): All data has to be provided in real_t precision!" );
310 if ( mxGetN( prhs[ A_idx ] ) != nV )
313 snprintf(msg, 199,
"ERROR (qpOASES): Constraint matrix input dimension mismatch (%ld != %d)!",
314 (
long int)mxGetN(prhs[A_idx]), nV);
315 fprintf(stderr,
"%s\n", msg);
319 A_for = (
real_t*) mxGetPr( prhs[ A_idx ] );
328 if ( mxIsSparse( prhs[ A_idx ] ) != 0 )
330 long *ir = (
long *)mxGetIr(prhs[A_idx]);
331 long *jc = (
long *)mxGetJc(prhs[A_idx]);
339 A_mem =
new real_t[nC*nV];
359 if (Hdiag)
delete[] Hdiag;
374 if (Hdiag)
delete[] Hdiag;
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 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.
returnValue smartDimensionCheck(real_t **input, unsigned int m, unsigned int n, BooleanType emptyAllowed, const mxArray *prhs[], int idx)
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 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)
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.
void allocateOutputs(int nlhs, mxArray *plhs[], int nV, int nC=0, int nP=1)
Interfaces matrix-vector operations tailored to general sparse matrices.
Provides a generic way to set and pass user-specified options.
void qpOASESmex_bounds(int nV, int nP, SymmetricMatrix *H, real_t *g, real_t *lb, real_t *ub, int nWSRin, real_t *x0, Options *options, int nOutputs, mxArray *plhs[])
Abstract base class for interfacing tailored matrix-vector operations.
void obtainOutputs(int k, QProblemB *qp, returnValue returnvalue, int nWSRin, int nlhs, mxArray *plhs[], int nV, int nC=0)
void qpOASESmex_constraints(int nV, int nC, int nP, SymmetricMatrix *H, real_t *g, Matrix *A, real_t *lb, real_t *ub, real_t *lbA, real_t *ubA, int nWSRin, real_t *x0, Options *options, int nOutputs, mxArray *plhs[])
Implements the online active set strategy for QPs with general constraints.
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...