40 #include <scilab/stack-c.h> 41 #include <scilab/machine.h> 42 #include <scilab/sciprint.h> 68 int *nV,
int* nC,
int*
nWSR,
69 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 72 void init(
double*
H,
double*
g,
double*
A,
double*
lb,
double*
ub,
double*
lbA,
double*
ubA,
73 int *nV,
int* nC,
int*
nWSR,
74 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 76 void initSB(
double*
H,
double*
g,
double*
lb,
double*
ub,
78 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 80 void initVM(
double*
H,
double*
g,
double*
A,
double*
lb,
double*
ub,
double*
lbA,
double*
ubA,
81 int *nV,
int* nC,
int*
nWSR,
82 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 87 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 91 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 95 double* x,
double* obj,
int* status,
int* nWSRout,
double*
y 117 static int H, H_rows, H_cols;
118 static int A, A_rows, A_cols;
119 static int g, g_rows, g_cols;
120 static int lb, lb_rows, lb_cols;
121 static int ub, ub_rows, ub_cols;
122 static int lbA, lbA_rows, lbA_cols;
123 static int ubA, ubA_rows, ubA_cols;
124 static int nWSR, nWSR_rows, nWSR_cols;
126 static int obj, x,
y, status, nWSRout;
129 static int minlhs = 1, maxlhs = 5, minrhs = 8, maxrhs = 8, one = 1, y_size;
131 CheckRhs( minrhs,maxrhs );
132 CheckLhs( minlhs,maxlhs );
136 GetRhsVar( 1,
"d", &H_rows,&H_cols,&H );
137 if ( ( H_rows != H_cols ) || ( H_rows < 1 ) )
139 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
144 GetRhsVar( 2,
"d", &g_rows,&g_cols,&g );
145 if ( !( ( ( g_rows == H_rows ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols == H_rows ) ) ) )
147 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
152 GetRhsVar( 3,
"d", &A_rows,&A_cols,&A );
153 if ( ( A_cols != H_rows ) || ( A_rows < 1 ) )
155 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
160 GetRhsVar( 4,
"d", &lb_rows,&lb_cols,&lb);
161 if ( !( ( ( lb_rows == H_rows ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
163 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
168 GetRhsVar( 5,
"d", &ub_rows,&ub_cols,&ub);
169 if ( !( ( ( ub_rows == H_rows ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
171 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
176 GetRhsVar( 6,
"d", &lbA_rows,&lbA_cols,&lbA);
177 if ( ( lbA_rows != A_rows ) || ( lbA_cols != 1 ) )
179 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
184 GetRhsVar( 7,
"d", &ubA_rows,&ubA_cols,&ubA);
185 if ( ( ubA_rows != A_rows ) || ( ubA_cols != 1 ) )
187 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
192 GetRhsVar( 8,
"i", &nWSR_rows,&nWSR_cols,&nWSR);
193 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
195 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
201 y_size = H_rows + A_rows;
203 CreateVar( 9,
"d", &H_rows,&one,&x );
204 CreateVar( 10,
"d", &one,&one,&obj );
205 CreateVar( 11,
"i", &one,&one,&status );
206 CreateVar( 12,
"i", &one,&one,&nWSRout );
207 CreateVar( 13,
"d", &y_size,&one,&y );
211 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
213 qpoases( stk(H),stk(g),stk(A),stk(lb),stk(ub),stk(lbA),stk(ubA),
214 &H_rows,&A_rows,istk(nWSR),
215 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
218 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
220 qpoases( stk(H),stk(g),stk(A),0,stk(ub),stk(lbA),stk(ubA),
221 &H_rows,&A_rows,istk(nWSR),
222 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
225 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
227 qpoases( stk(H),stk(g),stk(A),stk(lb),0,stk(lbA),stk(ubA),
228 &H_rows,&A_rows,istk(nWSR),
229 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
234 qpoases( stk(H),stk(g),stk(A),0,0,stk(lbA),stk(ubA),
235 &H_rows,&A_rows,istk(nWSR),
236 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
255 static int H, H_rows, H_cols;
256 static int A, A_rows, A_cols;
257 static int g, g_rows, g_cols;
258 static int lb, lb_rows, lb_cols;
259 static int ub, ub_rows, ub_cols;
260 static int lbA, lbA_rows, lbA_cols;
261 static int ubA, ubA_rows, ubA_cols;
262 static int nWSR, nWSR_rows, nWSR_cols;
264 static int obj, x,
y, status, nWSRout;
267 static int minlhs = 1, maxlhs = 5, minrhs = 8, maxrhs = 8, one = 1, y_size;
269 CheckRhs( minrhs,maxrhs );
270 CheckLhs( minlhs,maxlhs );
274 GetRhsVar( 1,
"d", &H_rows,&H_cols,&H );
275 if ( ( H_rows != H_cols ) || ( H_rows < 1 ) )
277 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
282 GetRhsVar( 2,
"d", &g_rows,&g_cols,&g );
283 if ( !( ( ( g_rows == H_rows ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols == H_rows ) ) ) )
285 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
290 GetRhsVar( 3,
"d", &A_rows,&A_cols,&A );
291 if ( ( A_cols != H_rows ) || ( A_rows < 1 ) )
293 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
298 GetRhsVar( 4,
"d", &lb_rows,&lb_cols,&lb);
299 if ( !( ( ( lb_rows == H_rows ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
301 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
306 GetRhsVar( 5,
"d", &ub_rows,&ub_cols,&ub);
307 if ( !( ( ( ub_rows == H_rows ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
309 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
314 GetRhsVar( 6,
"d", &lbA_rows,&lbA_cols,&lbA);
315 if ( ( lbA_rows != A_rows ) || ( lbA_cols != 1 ) )
317 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
322 GetRhsVar( 7,
"d", &ubA_rows,&ubA_cols,&ubA);
323 if ( ( ubA_rows != A_rows ) || ( ubA_cols != 1 ) )
325 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
330 GetRhsVar( 8,
"i", &nWSR_rows,&nWSR_cols,&nWSR);
331 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
333 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
339 y_size = H_rows + A_rows;
341 CreateVar( 9,
"d", &H_rows,&one,&x );
342 CreateVar( 10,
"d", &one,&one,&obj );
343 CreateVar( 11,
"i", &one,&one,&status );
344 CreateVar( 12,
"i", &one,&one,&nWSRout );
345 CreateVar( 13,
"d", &y_size,&one,&y );
353 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
355 init( stk(H),stk(g),stk(A),stk(lb),stk(ub),stk(lbA),stk(ubA),
356 &H_rows,&A_rows,istk(nWSR),
357 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
360 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
362 init( stk(H),stk(g),stk(A),0,stk(ub),stk(lbA),stk(ubA),
363 &H_rows,&A_rows,istk(nWSR),
364 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
367 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
369 init( stk(H),stk(g),stk(A),stk(lb),0,stk(lbA),stk(ubA),
370 &H_rows,&A_rows,istk(nWSR),
371 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
376 init( stk(H),stk(g),stk(A),0,0,stk(lbA),stk(ubA),
377 &H_rows,&A_rows,istk(nWSR),
378 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
397 static int H, H_rows, H_cols;
398 static int g, g_rows, g_cols;
399 static int lb, lb_rows, lb_cols;
400 static int ub, ub_rows, ub_cols;
401 static int nWSR, nWSR_rows, nWSR_cols;
403 static int obj, x,
y, status, nWSRout;
406 static int minlhs = 1, maxlhs = 5, minrhs = 5, maxrhs = 5, one = 1;
408 CheckRhs( minrhs,maxrhs );
409 CheckLhs( minlhs,maxlhs );
413 GetRhsVar( 1,
"d", &H_rows,&H_cols,&H );
414 if ( ( H_rows != H_cols ) || ( H_rows < 1 ) )
416 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
421 GetRhsVar( 2,
"d", &g_rows,&g_cols,&g );
422 if ( !( ( ( g_rows == H_rows ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols == H_rows ) ) ) )
424 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
429 GetRhsVar( 3,
"d", &lb_rows,&lb_cols,&lb);
430 if ( !( ( ( lb_rows == H_rows ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
432 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
437 GetRhsVar( 4,
"d", &ub_rows,&ub_cols,&ub);
438 if ( !( ( ( ub_rows == H_rows ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
440 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
445 GetRhsVar( 5,
"i", &nWSR_rows,&nWSR_cols,&nWSR);
446 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
448 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
454 CreateVar( 9,
"d", &H_rows,&one,&x );
455 CreateVar( 10,
"d", &one,&one,&obj );
456 CreateVar( 11,
"i", &one,&one,&status );
457 CreateVar( 12,
"i", &one,&one,&nWSRout );
458 CreateVar( 13,
"d", &H_rows,&one,&y );
465 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
467 initSB( stk(H),stk(g),stk(lb),stk(ub),
469 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
472 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
474 initSB( stk(H),stk(g),0,stk(ub),
476 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
479 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
481 initSB( stk(H),stk(g),stk(lb),0,
483 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
488 initSB( stk(H),stk(g),0,0,
490 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
509 static int H, H_rows, H_cols;
510 static int A, A_rows, A_cols;
511 static int g, g_rows, g_cols;
512 static int lb, lb_rows, lb_cols;
513 static int ub, ub_rows, ub_cols;
514 static int lbA, lbA_rows, lbA_cols;
515 static int ubA, ubA_rows, ubA_cols;
516 static int nWSR, nWSR_rows, nWSR_cols;
518 static int obj, x,
y, status, nWSRout;
521 static int minlhs = 1, maxlhs = 5, minrhs = 8, maxrhs = 8, one = 1, y_size;
523 CheckRhs( minrhs,maxrhs );
524 CheckLhs( minlhs,maxlhs );
528 GetRhsVar( 1,
"d", &H_rows,&H_cols,&H );
529 if ( ( H_rows != H_cols ) || ( H_rows < 1 ) )
531 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
536 GetRhsVar( 2,
"d", &g_rows,&g_cols,&g );
537 if ( !( ( ( g_rows == H_rows ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols == H_rows ) ) ) )
539 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
544 GetRhsVar( 3,
"d", &A_rows,&A_cols,&A );
545 if ( ( A_cols != H_rows ) || ( A_rows < 1 ) )
547 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
552 GetRhsVar( 4,
"d", &lb_rows,&lb_cols,&lb );
553 if ( !( ( ( lb_rows == H_rows ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
555 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
560 GetRhsVar( 5,
"d", &ub_rows,&ub_cols,&ub );
561 if ( !( ( ( ub_rows == H_rows ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
563 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
568 GetRhsVar( 6,
"d", &lbA_rows,&lbA_cols,&lbA );
569 if ( ( lbA_rows != A_rows ) || ( lbA_cols != 1 ) )
571 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
576 GetRhsVar( 7,
"d", &ubA_rows,&ubA_cols,&ubA );
577 if ( ( ubA_rows != A_rows ) || ( ubA_cols != 1 ) )
579 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
584 GetRhsVar( 8,
"i", &nWSR_rows,&nWSR_cols,&nWSR) ;
585 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
587 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
593 y_size = H_rows + A_rows;
595 CreateVar( 9,
"d", &H_rows,&one,&x );
596 CreateVar( 10,
"d", &one,&one,&obj );
597 CreateVar( 11,
"i", &one,&one,&status );
598 CreateVar( 12,
"i", &one,&one,&nWSRout );
599 CreateVar( 13,
"d", &y_size,&one,&y );
607 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
609 initVM( stk(H),stk(g),stk(A),stk(lb),stk(ub),stk(lbA),stk(ubA),
610 &H_rows,&A_rows,istk(nWSR),
611 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
614 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
616 initVM( stk(H),stk(g),stk(A),0,stk(ub),stk(lbA),stk(ubA),
617 &H_rows,&A_rows,istk(nWSR),
618 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
621 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
623 initVM( stk(H),stk(g),stk(A),stk(lb),0,stk(lbA),stk(ubA),
624 &H_rows,&A_rows,istk(nWSR),
625 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
630 initVM( stk(H),stk(g),stk(A),0,0,stk(lbA),stk(ubA),
631 &H_rows,&A_rows,istk(nWSR),
632 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
651 static int g, g_rows, g_cols;
652 static int lb, lb_rows, lb_cols;
653 static int ub, ub_rows, ub_cols;
654 static int lbA, lbA_rows, lbA_cols;
655 static int ubA, ubA_rows, ubA_cols;
656 static int nWSR, nWSR_rows, nWSR_cols;
658 static int obj, x,
y, status, nWSRout;
661 static int minlhs = 1, maxlhs = 5, minrhs = 6, maxrhs = 6, one = 1, y_size;
663 CheckRhs( minrhs,maxrhs );
664 CheckLhs( minlhs,maxlhs );
669 sciprint(
"ERROR (qpOASES): QP not initialised!\n" );
675 GetRhsVar( 1,
"d", &g_rows,&g_cols,&g );
676 if ( !( ( ( g_rows ==
qp_rowsH ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols ==
qp_rowsH ) ) ) )
678 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
683 GetRhsVar( 2,
"d", &lb_rows,&lb_cols,&lb );
684 if ( !( ( ( lb_rows ==
qp_rowsH ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
686 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
691 GetRhsVar( 3,
"d", &ub_rows,&ub_cols,&ub );
692 if ( !( ( ( ub_rows ==
qp_rowsH ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
694 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
699 GetRhsVar( 4,
"d", &lbA_rows,&lbA_cols,&lbA );
700 if ( ( lbA_rows !=
qp_rowsA ) || ( lbA_cols != 1 ) )
702 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
707 GetRhsVar( 5,
"d", &ubA_rows,&ubA_cols,&ubA );
708 if ( ( ubA_rows !=
qp_rowsA ) || ( ubA_cols != 1 ) )
710 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
715 GetRhsVar( 6,
"i", &nWSR_rows,&nWSR_cols,&nWSR );
716 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
718 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
726 CreateVar( 7,
"d", &
qp_rowsH,&one,&x );
727 CreateVar( 8,
"d", &one,&one,&obj );
728 CreateVar( 9,
"i", &one,&one,&status );
729 CreateVar( 10,
"i", &one,&one,&nWSRout );
730 CreateVar( 11,
"d", &y_size,&one,&y );
734 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
736 hotstart( stk(g),stk(lb),stk(ub),stk(lbA),stk(ubA),
738 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
741 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
743 hotstart( stk(g),0,stk(ub),stk(lbA),stk(ubA),
745 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
748 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
750 hotstart( stk(g),stk(lb),0,stk(lbA),stk(ubA),
752 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
757 hotstart( stk(g),0,0,stk(lbA),stk(ubA),
759 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
779 static int g, g_rows, g_cols;
780 static int lb, lb_rows, lb_cols;
781 static int ub, ub_rows, ub_cols;
782 static int nWSR, nWSR_rows, nWSR_cols;
784 static int obj, x,
y, status, nWSRout;
787 static int minlhs = 1, maxlhs = 5, minrhs = 4, maxrhs = 4, one = 1;
789 CheckRhs( minrhs,maxrhs );
790 CheckLhs( minlhs,maxlhs );
795 sciprint(
"ERROR (qpOASES): QP not initialised!\n" );
801 GetRhsVar( 1,
"d", &g_rows,&g_cols,&g );
802 if ( !( ( ( g_rows ==
qpb_rowsH ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols ==
qpb_rowsH ) ) ) )
804 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
809 GetRhsVar( 2,
"d", &lb_rows,&lb_cols,&lb );
810 if ( !( ( ( lb_rows ==
qpb_rowsH ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
812 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
817 GetRhsVar( 3,
"d", &ub_rows,&ub_cols,&ub );
818 if ( !( ( ( ub_rows ==
qpb_rowsH ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
820 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
825 GetRhsVar( 4,
"i", &nWSR_rows,&nWSR_cols,&nWSR );
826 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
828 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
835 CreateVar( 6,
"d", &one,&one,&obj );
836 CreateVar( 7,
"i", &one,&one,&status );
837 CreateVar( 8,
"i", &one,&one,&nWSRout );
842 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
846 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
849 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
853 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
856 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
860 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
867 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
887 static int H, H_rows, H_cols;
888 static int A, A_rows, A_cols;
889 static int g, g_rows, g_cols;
890 static int lb, lb_rows, lb_cols;
891 static int ub, ub_rows, ub_cols;
892 static int lbA, lbA_rows, lbA_cols;
893 static int ubA, ubA_rows, ubA_cols;
894 static int nWSR, nWSR_rows, nWSR_cols;
896 static int obj, x,
y, status, nWSRout;
899 static int minlhs = 1, maxlhs = 5, minrhs = 8, maxrhs = 8, one = 1, y_size;
901 CheckRhs( minrhs,maxrhs );
902 CheckLhs( minlhs,maxlhs );
907 sciprint(
"ERROR (qpOASES): QP not initialised!\n" );
913 GetRhsVar( 1,
"d", &H_rows,&H_cols,&H );
914 if ( ( H_rows != H_cols ) || ( H_rows < 1 ) )
916 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
921 GetRhsVar( 2,
"d", &g_rows,&g_cols,&g );
922 if ( !( ( ( g_rows == H_rows ) && ( g_cols == 1 ) ) || ( ( g_rows == 1 ) && ( g_cols == H_rows ) ) ) )
924 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
929 GetRhsVar( 3,
"d", &A_rows,&A_cols,&A );
930 if ( ( A_cols != H_rows ) || ( A_rows < 1 ) )
932 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
937 GetRhsVar( 4,
"d", &lb_rows,&lb_cols,&lb);
938 if ( !( ( ( lb_rows == H_rows ) && ( lb_cols == 1 ) ) || ( ( lb_rows == 0 ) && ( lb_cols == 0 ) ) ) )
940 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
945 GetRhsVar( 5,
"d", &ub_rows,&ub_cols,&ub);
946 if ( !( ( ( ub_rows == H_rows ) && ( ub_cols == 1 ) ) || ( ( ub_rows == 0 ) && ( ub_cols == 0 ) ) ) )
948 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
953 GetRhsVar( 6,
"d", &lbA_rows,&lbA_cols,&lbA);
954 if ( ( lbA_rows != A_rows ) || ( lbA_cols != 1 ) )
956 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
961 GetRhsVar( 7,
"d", &ubA_rows,&ubA_cols,&ubA);
962 if ( ( ubA_rows != A_rows ) || ( ubA_cols != 1 ) )
964 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
969 GetRhsVar( 8,
"i", &nWSR_rows,&nWSR_cols,&nWSR);
970 if ( ( nWSR_rows != nWSR_cols ) || ( nWSR_cols != 1 ) )
972 sciprint(
"ERROR (qpOASES): Dimension mismatch!\n" );
980 sciprint(
"ERROR (qpOASES): Incompatible matrix dimensions!\n" );
986 y_size = H_rows + A_rows;
988 CreateVar( 9,
"d", &H_rows,&one,&x );
989 CreateVar( 10,
"d", &one,&one,&obj );
990 CreateVar( 11,
"i", &one,&one,&status );
991 CreateVar( 12,
"i", &one,&one,&nWSRout );
992 CreateVar( 13,
"d", &y_size,&one,&y );
996 if ( ( lb_rows != 0 ) && ( ub_rows != 0 ) )
998 hotstartVM( stk(H),stk(g),stk(A),stk(lb),stk(ub),stk(lbA),stk(ubA),
1000 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
1003 else if ( ( lb_rows == 0 ) && ( ub_rows != 0 ) )
1005 hotstartVM( stk(H),stk(g),stk(A),0,stk(ub),stk(lbA),stk(ubA),
1007 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
1010 else if ( ( lb_rows != 0 ) && ( ub_rows == 0 ) )
1012 hotstartVM( stk(H),stk(g),stk(A),stk(lb),0,stk(lbA),stk(ubA),
1014 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
1019 hotstartVM( stk(H),stk(g),stk(A),0,0,stk(lbA),stk(ubA),
1021 stk(x),stk(obj),istk(status),istk(nWSRout),stk(y)
1041 const int minlhs = 1, maxlhs = 1, minrhs = 0, maxrhs = 0;
1043 CheckRhs( minrhs,maxrhs );
1044 CheckLhs( minlhs,maxlhs );
1059 const int minlhs = 1, maxlhs = 1, minrhs = 0, maxrhs = 0;
1061 CheckRhs( minrhs,maxrhs );
1062 CheckLhs( minlhs,maxlhs );
1076 const int minlhs = 1, maxlhs = 1, minrhs = 0, maxrhs = 0;
1078 CheckRhs( minrhs,maxrhs );
1079 CheckLhs( minlhs,maxlhs );
1099 char*
name[] = {
"qpOASES",
1100 "qpOASES_init",
"qpOASES_initSB",
"qpOASES_initVM",
1101 "qpOASES_hotstart",
"qpOASES_hotstartSB",
"qpOASES_hotstartVM",
1102 "qpOASES_cleanup",
"qpOASES_cleanupSB",
"qpOASES_cleanupVM" int(* gate_function)(char *)
int int_qpOASES(char *fname)
int sci_gateway(char *name, gate_function f)
int int_solveSB(char *fname)
def Error(filename, linenum, category, confidence, message)
void hotstartSB(double *g, double *lb, double *ub, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
int int_initVM(char *fname)
int int_hotstartSB(char *fname)
int int_hotstartVM(char *fname)
int int_cleanupSB(char *fname)
void hotstart(double *g, double *lb, double *ub, double *lbA, double *ubA, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
int int_solveVM(char *fname)
int C2F() qpOASESgateway()
int int_solve(char *fname)
int int_cleanupVM(char *fname)
void hotstartVM(double *H, double *g, double *A, double *lb, double *ub, double *lbA, double *ubA, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
void init(double *H, double *g, double *A, double *lb, double *ub, double *lbA, double *ubA, int *nV, int *nC, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
int int_init(char *fname)
int int_hotstart(char *fname)
void initVM(double *H, double *g, double *A, double *lb, double *ub, double *lbA, double *ubA, int *nV, int *nC, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
int int_cleanup(char *fname)
void qpoases(double *H, double *g, double *A, double *lb, double *ub, double *lbA, double *ubA, int *nV, int *nC, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)
int int_initSB(char *fname)
void initSB(double *H, double *g, double *lb, double *ub, int *nV, int *nWSR, double *x, double *obj, int *status, int *nWSRout, double *y)