35 #if defined(__WIN32__) || defined(WIN32) 37 #elif defined(LINUX) || defined(__LINUX__) 50 #ifdef __NO_SNPRINTF__ 51 #if (!defined(_MSC_VER)) || defined(__DSPACE__) || defined(__XPCTARGET__) 53 int snprintf(
char* s,
size_t n,
const char* format, ... )
74 #ifndef __SUPPRESSANYOUTPUT__ 97 const int*
const V_idx
100 #ifndef __SUPPRESSANYOUTPUT__ 127 #ifndef __SUPPRESSANYOUTPUT__ 152 #ifndef __SUPPRESSANYOUTPUT__ 157 for( i=0; i<nrow; ++i )
171 const int*
const ROW_idx,
const int*
const COL_idx
174 #ifndef __SUPPRESSANYOUTPUT__ 179 for( i=0; i<nrow; ++i )
196 #ifndef __SUPPRESSANYOUTPUT__ 221 #ifndef __SUPPRESSANYOUTPUT__ 248 #ifndef __SUPPRESSANYOUTPUT__ 271 #ifndef __SUPPRESSANYOUTPUT__ 282 if ( outputfile == 0 )
284 fprintf( outputfile,
"%s", s );
298 #ifndef __SUPPRESSANYOUTPUT__ 299 #ifndef __XPCTARGET__ 301 #ifndef __NO_COPYRIGHT__ 302 qpOASES_myPrintf(
"\nqpOASES_embedded -- An Embedded Implementation of the Online Active Set Strategy.\nCopyright (C) 2007-2015 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" );
315 const char* datafilename
318 #ifndef __SUPPRESSANYOUTPUT__ 326 if ( ( datafile = fopen( datafilename,
"r" ) ) == 0 )
333 for( i=0; i<nrow; ++i )
335 for( j=0; j<ncol; ++j )
337 #ifdef __USE_SINGLE_PRECISION__ 338 if ( fscanf( datafile,
"%f ", &float_data ) == 0 )
340 if ( fscanf( datafile,
"%lf ", &float_data ) == 0 )
347 data[i*ncol + j] = ( (
real_t) float_data );
368 const char* datafilename
380 const char* datafilename
383 #ifndef __SUPPRESSANYOUTPUT__ 390 if ( ( datafile = fopen( datafilename,
"r" ) ) == 0 )
399 if ( fscanf( datafile,
"%d\n", &(data[i]) ) == 0 )
427 #ifndef __SUPPRESSANYOUTPUT__ 437 if ( ( datafile = fopen( datafilename,
"a" ) ) == 0 )
446 if ( ( datafile = fopen( datafilename,
"w" ) ) == 0 )
454 for( i=0; i<nrow; ++i )
456 for( j=0; j<ncol; ++j )
457 fprintf( datafile,
"%.16e ", data[i*ncol+j] );
459 fprintf( datafile,
"\n" );
493 #ifndef __SUPPRESSANYOUTPUT__ 504 if ( ( datafile = fopen( datafilename,
"a" ) ) == 0 )
513 if ( ( datafile = fopen( datafilename,
"w" ) ) == 0 )
522 fprintf( datafile,
"%d\n", integer[i] );
541 const double*
const data,
int nRows,
int nCols,
const char*
name 547 #ifndef __SUPPRESSANYOUTPUT__ 552 if ( ( matFile == 0 ) || ( data == 0 ) || ( nRows < 0 ) || ( nCols < 0 ) || ( name == 0 ) )
566 if ( fwrite( name,
sizeof(
char),(
unsigned long)(var.
nCharName), matFile ) < 1 )
569 for ( ii=0; ii<nCols; ++ii )
570 for ( jj=0; jj<nRows; ++jj )
571 if ( fwrite( &(data[jj*nCols+ii]),
sizeof(
double),1, matFile ) < 1 )
588 const int*
const data,
int nRows,
int nCols,
const char*
name 595 for ( ii=0; ii<nRows; ++ii )
596 for ( jj=0; jj<nCols; ++jj )
597 realData[ ii*nCols+jj ] = (
real_t) data[ ii*nCols+jj ];
608 real_t current_time = -1.0;
610 #if defined(__WIN32__) || defined(WIN32) 611 LARGE_INTEGER
counter, frequency;
612 QueryPerformanceFrequency(&frequency);
613 QueryPerformanceCounter(&counter);
614 current_time = ((
real_t) counter.QuadPart) / ((
real_t) frequency.QuadPart);
615 #elif defined(LINUX) || defined(__LINUX__) 616 struct timeval theclock;
617 gettimeofday( &theclock,0 );
618 current_time = 1.0*theclock.tv_sec + 1.0e-6*theclock.tv_usec;
673 *_stat = *feas = *cmpl = 0.0;
676 for (i = 0; i < nV; i++)
686 for (j = 0; j < nV; j++) sum += H[i*nV+j] * x[j];
690 for (j = 0; j < nC; j++) sum -= A[j*nV+i] * y[nV+j];
699 for (i = 0; i < nV; i++)
703 if (lb[i] - x[i] > *feas)
704 *feas = lb[i] - x[i];
707 if (x[i] - ub[i] > *feas)
708 *feas = x[i] - ub[i];
714 if (y[i] > dualActiveTolerance)
715 prod = (x[i] - lb[i]) * y[i];
718 if (y[i] < -dualActiveTolerance)
719 prod = (x[i] - ub[i]) * y[i];
725 for (i = 0; i < nC; i++)
731 for (j = 0; j < nV; j++)
732 sum += A[i*nV+j] * x[j];
736 if (lbA[i] - sum > *feas)
737 *feas = lbA[i] - sum;
739 if (sum - ubA[i] > *feas)
740 *feas = sum - ubA[i];
746 if (y[nV+i] > dualActiveTolerance)
747 prod = (sum - lbA[i]) * y[nV+i];
750 if (y[nV+i] < -dualActiveTolerance)
751 prod = (sum - ubA[i]) * y[nV+i];
784 #ifndef __SUPPRESSANYOUTPUT__ 786 snprintf(
string,20,
"BT_FALSE" );
788 snprintf(
string,20,
"BT_TRUE" );
800 #ifndef __SUPPRESSANYOUTPUT__ 804 snprintf(
string,20,
"ST_INACTIVE" );
808 snprintf(
string,20,
"ST_LOWER" );
812 snprintf(
string,20,
"ST_UPPER" );
816 snprintf(
string,20,
"ST_UNDEFINED" );
820 snprintf(
string,20,
"ST_INFEASIBLE_LOWER" );
824 snprintf(
string,20,
"ST_INFEASIBLE_UPPER" );
828 snprintf(
string,20,
"<invalid value>" );
842 #ifndef __SUPPRESSANYOUTPUT__ 846 snprintf(
string,20,
"PL_NONE" );
850 snprintf(
string,20,
"PL_LOW" );
854 snprintf(
string,20,
"PL_MEDIUM" );
858 snprintf(
string,20,
"PL_HIGH" );
862 snprintf(
string,20,
"PL_TABULAR" );
866 snprintf(
string,20,
"PL_DEBUG_ITER" );
870 snprintf(
string,20,
"<invalid value>" );
887 int simpleStatus = -1;
890 switch ( returnvalue )
915 if ( doPrintStatus ==
BT_TRUE )
942 if ( ( nV <= 0 ) || ( nC <= 0 ) || ( A == 0 ) )
945 for( ii=0; ii<nC; ++ii )
953 for( jj=0; jj<nV; ++jj )
954 A[ii*nV + jj] /= curNorm;
956 if ( lbA != 0 ) lbA[ii] /= curNorm;
957 if ( ubA != 0 ) ubA[ii] /= curNorm;
964 for( jj=0; jj<nV; ++jj )
965 A[ii*nV + jj] = 1.0 / ((
real_t)nV);
970 for( jj=0; jj<nV; ++jj )
987 void gdb_printmat(
const char *fname,
real_t *
M,
int n,
int m,
int ldim )
989 #ifdef __SUPPRESSANYOUTPUT__ 994 fid = fopen(fname,
"wt");
997 perror(
"Error opening file: ");
1001 for (i = 0; i < n; i++)
1003 for (j = 0; j < m; j++)
1004 fprintf(fid,
" %23.16e", M[j*ldim+i]);
1014 #if defined(__DSPACE__) || defined(__XPCTARGET__) 1018 void __cxa_pure_virtual(
void )
returnValue qpOASES_printNI(const int *const _index, int n, const char *name)
returnValue qpOASES_printM(const real_t *const M, int nrow, int ncol)
returnValue qpOASES_convertPrintLevelToString(PrintLevel value, char *const string)
static returnValue MessageHandling_setErrorCount(MessageHandling *_THIS, int _errorCount)
returnValue qpOASES_printCopyrightNotice()
returnValue qpOASES_convertBooleanTypeToString(BooleanType value, char *const string)
returnValue qpOASES_writeIntoFileI(const int *const integer, int n, const char *datafilename, BooleanType append)
returnValue qpOASES_writeIntoFileM(const real_t *const data, int nrow, int ncol, const char *datafilename, BooleanType append)
#define THROWINFO(retval)
returnValue qpOASES_printPV(const real_t *const v, int n, const int *const V_idx)
#define ST_INFEASIBLE_UPPER
Allows to pass back messages to the calling function.
returnValue qpOASES_writeIntoMatFile(FILE *const matFile, const double *const data, int nRows, int nCols, const char *name)
static FILE * MessageHandling_getOutputFile(MessageHandling *_THIS)
returnValue qpOASES_writeIntoMatFileI(FILE *const matFile, const int *const data, int nRows, int nCols, const char *name)
#define THROWERROR(retval)
#define ST_INFEASIBLE_LOWER
returnValue qpOASES_printI(const int *const _index, int n)
returnValue qpOASES_printPM(const real_t *const M, int nrow, int ncol, const int *const ROW_idx, const int *const COL_idx)
static void MessageHandling_setInfoVisibilityStatus(MessageHandling *_THIS, VisibilityStatus _infoVisibility)
static real_t qpOASES_getAbs(real_t x)
static VisibilityStatus MessageHandling_getInfoVisibilityStatus(MessageHandling *_THIS)
returnValue qpOASES_readFromFileI(int *data, int n, const char *datafilename)
returnValue qpOASES_printNM(const real_t *const M, int nrow, int ncol, const char *name)
returnValue qpOASES_convertSubjectToStatusToString(SubjectToStatus value, char *const string)
returnValue normaliseConstraints(int nV, int nC, real_t *A, real_t *lbA, real_t *ubA, int type)
real_t qpOASES_getCPUtime()
returnValue qpOASES_writeIntoFileV(const real_t *const data, int n, const char *datafilename, BooleanType append)
static real_t qpOASES_getSqrt(real_t x)
returnValue MessageHandling_throwError(MessageHandling *_THIS, returnValue Enumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
static const real_t QPOASES_INFTY
returnValue qpOASES_readFromFileM(real_t *data, int nrow, int ncol, const char *datafilename)
#define END_NAMESPACE_QPOASES
MessageHandling * qpOASES_getGlobalMessageHandler()
returnValue qpOASES_getKktViolation(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 *const _stat, real_t *const feas, real_t *const cmpl)
returnValue qpOASES_readFromFileV(real_t *data, int n, const char *datafilename)
static const real_t QPOASES_EPS
#define QPOASES_MAX_STRING_LENGTH
real_t qpOASES_getNorm(const real_t *const v, int n, int type)
returnValue qpOASES_printNV(const real_t *const v, int n, const char *name)
#define BEGIN_NAMESPACE_QPOASES
returnValue qpOASES_getKktViolationSB(int nV, const real_t *const H, const real_t *const g, const real_t *const lb, const real_t *const ub, const real_t *const x, const real_t *const y, real_t *const _stat, real_t *const feas, real_t *const cmpl)
BEGIN_NAMESPACE_QPOASES returnValue qpOASES_printV(const real_t *const v, int n)
int qpOASES_getSimpleStatus(returnValue returnvalue, BooleanType doPrintStatus)
returnValue qpOASES_myPrintf(const char *s)