37 #if defined(__WIN32__) || defined(WIN32) 49 #include <qpOASES/Utils.hpp> 60 #ifndef __SUPPRESSANYOUTPUT__ 63 char myPrintfString[160];
69 snprintf( myPrintfString,160,
" %.16e\t", v[i] );
84 const int*
const V_idx
87 #ifndef __SUPPRESSANYOUTPUT__ 90 char myPrintfString[160];
96 snprintf( myPrintfString,160,
" %.16e\t", v[ V_idx[i] ] );
114 #ifndef __SUPPRESSANYOUTPUT__ 115 #ifndef __XPCTARGET__ 116 char myPrintfString[160];
119 snprintf( myPrintfString,160,
"%s = ", name );
125 return print( v, n );
133 #ifndef __SUPPRESSANYOUTPUT__ 134 #ifndef __XPCTARGET__ 138 for( i=0; i<nrow; ++i )
139 print( &(M[i*ncol]), ncol );
152 const int*
const ROW_idx,
const int*
const COL_idx
155 #ifndef __SUPPRESSANYOUTPUT__ 156 #ifndef __XPCTARGET__ 160 for( i=0; i<nrow; ++i )
161 print( &( M[ ROW_idx[i]*ncol ] ), ncol, COL_idx );
177 #ifndef __SUPPRESSANYOUTPUT__ 178 #ifndef __XPCTARGET__ 179 char myPrintfString[160];
182 snprintf( myPrintfString,160,
"%s = ", name );
188 return print( M, nrow, ncol );
197 #ifndef __SUPPRESSANYOUTPUT__ 198 #ifndef __XPCTARGET__ 200 char myPrintfString[160];
206 snprintf( myPrintfString,160,
" %d\t", index[i] );
224 #ifndef __SUPPRESSANYOUTPUT__ 225 #ifndef __XPCTARGET__ 226 char myPrintfString[160];
229 snprintf( myPrintfString,160,
"%s = ", name );
235 return print( index, n );
244 #ifndef __SUPPRESSANYOUTPUT__ 245 #ifndef __XPCTARGET__ 250 if ( outputfile == 0 )
253 fprintf( outputfile,
"%s", s );
267 #ifndef __SUPPRESSANYOUTPUT__ 268 #ifndef __XPCTARGET__ 270 #ifndef __NO_COPYRIGHT__ 271 myPrintf(
"\nqpOASES -- An Implementation of the Online Active Set Strategy.\nCopyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,\nChristian Kirches et al. All rights reserved.\n\nqpOASES is distributed under the terms of the \nGNU Lesser General Public License 2.1 in the hope that it will be \nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty \nof MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \nSee the GNU Lesser General Public License for more details.\n\n" );
284 const char* datafilename
287 #ifndef __XPCTARGET__ 293 if ( ( datafile = fopen( datafilename,
"r" ) ) == 0 )
296 snprintf( errstr,80,
"(%s)",datafilename );
301 for( i=0; i<nrow; ++i )
303 for( j=0; j<ncol; ++j )
305 #ifdef __USE_SINGLE_PRECISION__ 306 if ( fscanf( datafile,
"%f ", &float_data ) == 0 )
308 if ( fscanf( datafile,
"%lf ", &float_data ) == 0 )
313 snprintf( errstr,80,
"(%s)",datafilename );
316 data[i*ncol + j] = ( (
real_t) float_data );
336 const char* datafilename
348 const char* datafilename
351 #ifndef __XPCTARGET__ 356 if ( ( datafile = fopen( datafilename,
"r" ) ) == 0 )
359 snprintf( errstr,80,
"(%s)",datafilename );
366 if ( fscanf( datafile,
"%d\n", &(data[i]) ) == 0 )
370 snprintf( errstr,80,
"(%s)",datafilename );
394 #ifndef __XPCTARGET__ 402 if ( ( datafile = fopen( datafilename,
"a" ) ) == 0 )
405 snprintf( errstr,80,
"(%s)",datafilename );
412 if ( ( datafile = fopen( datafilename,
"w" ) ) == 0 )
415 snprintf( errstr,80,
"(%s)",datafilename );
421 for( i=0; i<nrow; ++i )
423 for( j=0; j<ncol; ++j )
424 fprintf( datafile,
"%.16e ", data[i*ncol+j] );
426 fprintf( datafile,
"\n" );
459 #ifndef __XPCTARGET__ 468 if ( ( datafile = fopen( datafilename,
"a" ) ) == 0 )
471 snprintf( errstr,80,
"(%s)",datafilename );
478 if ( ( datafile = fopen( datafilename,
"w" ) ) == 0 )
481 snprintf( errstr,80,
"(%s)",datafilename );
488 fprintf( datafile,
"%d\n", integer[i] );
507 real_t current_time = -1.0;
509 #if defined(__WIN32__) || defined(WIN32) 510 LARGE_INTEGER
counter, frequency;
511 QueryPerformanceFrequency(&frequency);
512 QueryPerformanceCounter(&counter);
513 current_time = ((
real_t) counter.QuadPart) / ((
real_t) frequency.QuadPart);
515 struct timeval theclock;
516 gettimeofday( &theclock,0 );
517 current_time = 1.0*theclock.tv_sec + 1.0e-6*theclock.tv_usec;
552 const real_t dualActiveTolerance = 1.0e3 *
EPS;
558 stat = feas = cmpl = 0.0;
564 const real_t* lbACur = lbA ? lbA : 0;
565 const real_t* ubACur = ubA ? ubA : 0;
570 for (i = 0; i < nV; i++)
573 sum = gCur[i] - yCur[i];
576 for (j = 0; j < nV; j++) sum += H[i*nV+j] * xCur[j];
578 for (j = 0; j < nC; j++) sum -= A[j*nV+i] * yCur[j+nV];
581 if (fabs(sum) > stat) stat = fabs(sum);
586 for (i = 0; i < nV; i++)
589 if (lbCur[i] - xCur[i] > feas)
590 feas = lbCur[i] - xCur[i];
591 if (xCur[i] - ubCur[i] > feas)
592 feas = xCur[i] - ubCur[i];
596 if (yCur[i] > dualActiveTolerance)
597 prod = (xCur[i] - lbCur[i]) * yCur[i];
598 if (yCur[i] < -dualActiveTolerance)
599 prod = (xCur[i] - ubCur[i]) * yCur[i];
600 if (fabs(prod) > cmpl) cmpl = fabs(prod);
603 for (i = 0; i < nC; i++)
607 for (j = 0; j < nV; j++)
608 sum += A[i*nV+j] * xCur[j];
611 if (lbACur[i] - sum > feas)
612 feas = lbACur[i] - sum;
613 if (sum - ubACur[i] > feas)
614 feas = sum - ubACur[i];
618 if (yCur[nV+i] > dualActiveTolerance)
619 prod = (sum - lbACur[i]) * yCur[nV+i];
620 if (yCur[nV+i] < -dualActiveTolerance)
621 prod = (sum - ubACur[i]) * yCur[nV+i];
622 if (fabs(prod) > cmpl) cmpl = fabs(prod);
630 snprintf(
string,20,
"BT_TRUE" );
632 snprintf(
string,20,
"BT_FALSE" );
643 snprintf(
string,20,
"ST_INACTIVE" );
647 snprintf(
string,20,
"ST_LOWER" );
651 snprintf(
string,20,
"ST_UPPER" );
655 snprintf(
string,20,
"ST_UNDEFINED" );
668 snprintf(
string,20,
"PL_NONE" );
672 snprintf(
string,20,
"PL_LOW" );
676 snprintf(
string,20,
"PL_MEDIUM" );
680 snprintf(
string,20,
"PL_HIGH" );
684 snprintf(
string,20,
"PL_TABULAR" );
694 extern "C" void gdb_printmat(
const char *fname,
real_t *
M,
int n,
int m,
int ldim)
699 fid = fopen(fname,
"wt");
702 perror(
"Error opening file: ");
706 for (i = 0; i < n; i++)
708 for (j = 0; j < m; j++)
709 fprintf(fid,
" %23.16e",
M[j*ldim+i]);
IntermediateState sqrt(const Expression &arg)
returnValue throwError(returnValue Enumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
BEGIN_NAMESPACE_ACADO const double EPS
returnValue readFromFile(real_t *data, int nrow, int ncol, const char *datafilename)
Allows to pass back messages to the calling function.
returnValue convertSubjectToStatusToString(SubjectToStatus value, char *const string)
#define THROWERROR(retval)
returnValue printCopyrightNotice()
returnValue convertPrintLevelToString(PrintLevel value, char *const string)
real_t getNorm(const real_t *const v, int n)
returnValue convertBooleanTypeToString(BooleanType value, char *const string)
#define END_NAMESPACE_QPOASES
returnValue myPrintf(const char *s)
BEGIN_NAMESPACE_QPOASES returnValue print(const real_t *const v, int n)
myFILE * getOutputFile() const
#define BEGIN_NAMESPACE_QPOASES
returnValue writeIntoFile(const real_t *const data, int nrow, int ncol, const char *datafilename, BooleanType append)
MessageHandling * getGlobalMessageHandler()
void getKKTResidual(int nV, int nC, 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, const real_t *const x, const real_t *const y, real_t &stat, real_t &feas, real_t &cmpl)