qpOASES  3.0.1
Functions
include/qpOASES/Utils.hpp File Reference
#include <qpOASES/MessageHandling.hpp>
#include <qpOASES/Utils.ipp>
Include dependency graph for Utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BEGIN_NAMESPACE_QPOASES returnValue print (const real_t *const v, int n, const char *name=0)
returnValue print (const real_t *const v, int n, const int *const V_idx, const char *name=0)
returnValue print (const real_t *const M, int nrow, int ncol, const char *name=0)
returnValue print (const real_t *const M, int nrow, int ncol, const int *const ROW_idx, const int *const COL_idx, const char *name=0)
returnValue print (const int *const index, int n, const char *name=0)
returnValue myPrintf (const char *s)
returnValue printCopyrightNotice ()
returnValue readFromFile (real_t *data, int nrow, int ncol, const char *datafilename)
returnValue readFromFile (real_t *data, int n, const char *datafilename)
returnValue readFromFile (int *data, int n, const char *datafilename)
returnValue writeIntoFile (const real_t *const data, int nrow, int ncol, const char *datafilename, BooleanType append=BT_FALSE)
returnValue writeIntoFile (const real_t *const data, int n, const char *datafilename, BooleanType append=BT_FALSE)
returnValue writeIntoFile (const int *const integer, int n, const char *datafilename, BooleanType append=BT_FALSE)
returnValue writeIntoMatFile (FILE *const matFile, const real_t *const data, int nRows, int nCols, const char *name)
returnValue writeIntoMatFile (FILE *const matFile, const int *const data, int nRows, int nCols, const char *name)
real_t getCPUtime ()
real_t getNorm (const real_t *const v, int n, int type=2)
BooleanType isEqual (real_t x, real_t y, real_t TOL=ZERO)
BooleanType isZero (real_t x, real_t TOL=ZERO)
real_t getSign (real_t arg)
int getMax (int x, int y)
int getMin (int x, int y)
real_t getMax (real_t x, real_t y)
real_t getMin (real_t x, real_t y)
real_t getAbs (real_t x)
real_t getSqrt (real_t x)
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)
void getKKTResidual (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 &stat, real_t &feas, real_t &cmpl)
returnValue convertBooleanTypeToString (BooleanType value, char *const string)
returnValue convertSubjectToStatusToString (SubjectToStatus value, char *const string)
returnValue convertPrintLevelToString (PrintLevel value, char *const string)
int getSimpleStatus (returnValue returnvalue, BooleanType doPrintStatus=BT_FALSE)
returnValue normaliseConstraints (int nV, int nC, real_t *A, real_t *lbA, real_t *ubA, int type=1)

Detailed Description

Author:
Hans Joachim Ferreau, Andreas Potschka, Christian Kirches
Version:
3.0
Date:
2007-2014

Declaration of some utility functions for working with qpOASES.


Function Documentation

returnValue convertBooleanTypeToString ( BooleanType  value,
char *const  string 
)

Writes a value of BooleanType into a string.

Returns:
SUCCESSFUL_RETURN
Parameters:
valueValue to be written.
stringInput: String of sufficient size,
Output: String containing value.

References BT_FALSE, and SUCCESSFUL_RETURN.

Referenced by Options::print().

returnValue convertPrintLevelToString ( PrintLevel  value,
char *const  string 
)

Writes a value of PrintLevel into a string.

Returns:
SUCCESSFUL_RETURN
Parameters:
valueValue to be written.
stringInput: String of sufficient size,
Output: String containing value.

References PL_DEBUG_ITER, PL_HIGH, PL_LOW, PL_MEDIUM, PL_NONE, PL_TABULAR, and SUCCESSFUL_RETURN.

Referenced by Options::print().

returnValue convertSubjectToStatusToString ( SubjectToStatus  value,
char *const  string 
)

Writes a value of SubjectToStatus into a string.

Returns:
SUCCESSFUL_RETURN
Parameters:
valueValue to be written.
stringInput: String of sufficient size,
Output: String containing value.

References ST_INACTIVE, ST_INFEASIBLE_LOWER, ST_INFEASIBLE_UPPER, ST_LOWER, ST_UNDEFINED, ST_UPPER, and SUCCESSFUL_RETURN.

Referenced by Options::print().

real_t getAbs ( real_t  x) [inline]
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 
)

Computes "residual" of KKT system.

Parameters:
nVNumber of variables.
nCNumber of constraints.
HHessian matrix.
gSequence of gradient vectors.
AConstraint matrix.
lbSequence of lower bound vectors (on variables).
ubSequence of upper bound vectors (on variables).
lbASequence of lower constraints' bound vectors.
ubASequence of upper constraints' bound vectors.
xSequence of primal trial vectors.
ySequence of dual trial vectors.
statMaximum value of stationarity condition residual.
feasMaximum value of primal feasibility violation.
cmplMaximum value of complementarity residual.

References EPS, getAbs(), and real_t.

Referenced by getKKTResidual(), and solveOQPbenchmark().

void getKKTResidual ( 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 stat,
real_t feas,
real_t cmpl 
)

Computes "residual" of KKT system (for simply bounded QPs).

Parameters:
nVNumber of variables.
HHessian matrix.
gSequence of gradient vectors.
lbSequence of lower bound vectors (on variables).
ubSequence of upper bound vectors (on variables).
xSequence of primal trial vectors.
ySequence of dual trial vectors.
statMaximum value of stationarity condition residual.
feasMaximum value of primal feasibility violation.
cmplMaximum value of complementarity residual.

References getKKTResidual().

int getMax ( int  x,
int  y 
) [inline]
real_t getMax ( real_t  x,
real_t  y 
) [inline]

Returns maximum of two reals.

Returns:
Maximum of two reals
Parameters:
xFirst real number.
ySecond real number.
int getMin ( int  x,
int  y 
) [inline]

Returns minimum of two integers.

Returns:
Minimum of two integers
Parameters:
xFirst integer.
ySecond integer.

Referenced by QProblemB::computeCholesky(), QProblem::computeProjectedCholesky(), QProblem::performDriftCorrection(), QProblemB::performDriftCorrection(), QProblem::QProblem(), QProblemB::updateFarBounds(), and QProblem::updateFarBounds().

real_t getMin ( real_t  x,
real_t  y 
) [inline]

Returns minimum of two reals.

Returns:
Minimum of two reals
Parameters:
xFirst real number.
ySecond real number.
real_t getNorm ( const real_t *const  v,
int  n,
int  type = 2 
)

Returns the N-norm of a vector.

Returns:
>= 0.0: successful
Parameters:
vVector.
nVector's dimension.
typeNorm type, 1: one-norm, 2: Euclidean norm.

References getAbs(), getSqrt(), INFTY, real_t, RET_INVALID_ARGUMENTS, and THROWERROR.

Referenced by normaliseConstraints(), and QProblemB::regulariseHessian().

real_t getSign ( real_t  arg) [inline]

Returns sign of a real-valued argument.

Returns:
1.0: argument is non-negative
-1.0: argument is negative
Parameters:
argreal-valued argument whose sign is to be determined.
int getSimpleStatus ( returnValue  returnvalue,
BooleanType  doPrintStatus = BT_FALSE 
)

Converts a returnValue from an (S)QProblem(B) object into a more simple status flag.

Returns:
0: QP problem solved 1: QP could not be solved within given number of iterations -1: QP could not be solved due to an internal error -2: QP is infeasible (and thus could not be solved) -3: QP is unbounded (and thus could not be solved)
Parameters:
returnvalueReturnValue to be analysed.
doPrintStatusFlag indicating whether simple status shall be printed to screen.

References BT_TRUE, getGlobalMessageHandler(), MessageHandling::getInfoVisibilityStatus(), RET_HOTSTART_STOPPED_INFEASIBILITY, RET_HOTSTART_STOPPED_UNBOUNDEDNESS, RET_INIT_FAILED_INFEASIBILITY, RET_INIT_FAILED_UNBOUNDEDNESS, RET_MAX_NWSR_REACHED, RET_SIMPLE_STATUS_P0, MessageHandling::setErrorCount(), MessageHandling::setInfoVisibilityStatus(), SUCCESSFUL_RETURN, THROWINFO, and VS_VISIBLE.

real_t getSqrt ( real_t  x) [inline]
BooleanType isEqual ( real_t  x,
real_t  y,
real_t  TOL = ZERO 
) [inline]

Tests whether two real_t-valued arguments are (numerically) equal.

Returns:
BT_TRUE: arguments differ not more than TOL
BT_FALSE: arguments differ more than TOL
Parameters:
xFirst real number.
ySecond real number.
TOLTolerance for comparison.

References BT_FALSE, BT_TRUE, and getAbs().

Referenced by dgemm_(), DenseMatrix::getCol(), SparseMatrix::getCol(), SparseMatrixRow::getCol(), DenseMatrix::getRow(), SparseMatrix::getRow(), SparseMatrixRow::getRow(), sgemm_(), DenseMatrix::times(), SparseMatrix::times(), SparseMatrixRow::times(), DenseMatrix::transTimes(), SparseMatrix::transTimes(), and SparseMatrixRow::transTimes().

BooleanType isZero ( real_t  x,
real_t  TOL = ZERO 
) [inline]

Tests whether a real-valued argument is (numerically) zero.

Returns:
BT_TRUE: argument differs from 0.0 not more than TOL
BT_FALSE: argument differs from 0.0 more than TOL
Parameters:
xReal number.
TOLTolerance for comparison.

References BT_FALSE, BT_TRUE, and getAbs().

Referenced by SparseMatrix::addToDiag(), SparseMatrixRow::addToDiag(), QProblemB::computeGivens(), QProblemB::determineHessianType(), dgemm_(), QProblem::setA(), sgemm_(), SparseMatrix::SparseMatrix(), SparseMatrixRow::SparseMatrixRow(), DenseMatrix::times(), SparseMatrix::times(), SparseMatrixRow::times(), DenseMatrix::transTimes(), SparseMatrix::transTimes(), and SparseMatrixRow::transTimes().

returnValue myPrintf ( const char *  s)
returnValue normaliseConstraints ( int  nV,
int  nC,
real_t A,
real_t lbA,
real_t ubA,
int  type = 1 
)

Normalises QP constraints.

Returns:
SUCCESSFUL_RETURN
RET_INVALID_ARGUMENTS
Parameters:
nVNumber of variables.
nCNumber of constraints.
AInput: Constraint matrix,
Output: Normalised constraint matrix.
lbAInput: Constraints' lower bound vector,
Output: Normalised constraints' lower bound vector.
ubAInput: Constraints' upper bound vector,
Output: Normalised constraints' upper bound vector.
typeNorm type, 1: one-norm, 2: Euclidean norm.

References EPS, getNorm(), getSqrt(), INFTY, real_t, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, and THROWERROR.

BEGIN_NAMESPACE_QPOASES returnValue print ( const real_t *const  v,
int  n,
const char *  name = 0 
)

Prints a (possibly named) vector.

Returns:
SUCCESSFUL_RETURN
Parameters:
vVector to be printed.
nLength of vector.
nameName of vector.

References MAX_STRING_LENGTH, myPrintf(), and SUCCESSFUL_RETURN.

Referenced by print().

returnValue print ( const real_t *const  v,
int  n,
const int *const  V_idx,
const char *  name = 0 
)

Prints a (possibly named) permuted vector.

Returns:
SUCCESSFUL_RETURN
Parameters:
vVector to be printed.
nLength of vector.
V_idxPemutation vector.
nameName of vector.

References MAX_STRING_LENGTH, myPrintf(), and SUCCESSFUL_RETURN.

returnValue print ( const real_t *const  M,
int  nrow,
int  ncol,
const char *  name = 0 
)

Prints a (possibly named) matrix.

Returns:
SUCCESSFUL_RETURN
Parameters:
MMatrix to be printed.
nrowRow number of matrix.
ncolColumn number of matrix.
nameName of matrix.

References MAX_STRING_LENGTH, myPrintf(), print(), and SUCCESSFUL_RETURN.

returnValue print ( const real_t *const  M,
int  nrow,
int  ncol,
const int *const  ROW_idx,
const int *const  COL_idx,
const char *  name = 0 
)

Prints a (possibly named) permuted matrix.

Returns:
SUCCESSFUL_RETURN
Parameters:
MMatrix to be printed.
nrowRow number of matrix.
ncolColumn number of matrix.
ROW_idxRow pemutation vector.
COL_idxColumn pemutation vector.
nameName of matrix.

References MAX_STRING_LENGTH, myPrintf(), print(), and SUCCESSFUL_RETURN.

returnValue print ( const int *const  index,
int  n,
const char *  name = 0 
)

Prints a (possibly named) index array.

Returns:
SUCCESSFUL_RETURN
Parameters:
indexIndex array to be printed.
nLength of index array.
nameName of index array.

References MAX_STRING_LENGTH, myPrintf(), and SUCCESSFUL_RETURN.

Prints qpOASES copyright notice.

Returns:
SUCCESSFUL_RETURN

References myPrintf(), and SUCCESSFUL_RETURN.

Referenced by QProblemB::QProblemB().

returnValue readFromFile ( real_t data,
int  nrow,
int  ncol,
const char *  datafilename 
)

Reads a real_t matrix from file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
RET_UNABLE_TO_READ_FILE
Parameters:
dataMatrix to be read from file.
nrowRow number of matrix.
ncolColumn number of matrix.
datafilenameData file name.

References __FILE__, __FUNCTION__, __LINE__, getGlobalMessageHandler(), MAX_STRING_LENGTH, real_t, RET_NOT_YET_IMPLEMENTED, RET_UNABLE_TO_OPEN_FILE, RET_UNABLE_TO_READ_FILE, SUCCESSFUL_RETURN, MessageHandling::throwError(), and VS_VISIBLE.

Referenced by SQProblem::hotstart(), QProblemB::loadQPvectorsFromFile(), QProblem::loadQPvectorsFromFile(), readFromFile(), readOQPdata(), readOQPdimensions(), QProblemB::setupQPdataFromFile(), and QProblem::setupQPdataFromFile().

returnValue readFromFile ( real_t data,
int  n,
const char *  datafilename 
)

Reads a real_t vector from file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
RET_UNABLE_TO_READ_FILE
Parameters:
dataVector to be read from file.
nLength of vector.
datafilenameData file name.

References readFromFile().

returnValue readFromFile ( int *  data,
int  n,
const char *  datafilename 
)

Reads an integer (column) vector from file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
RET_UNABLE_TO_READ_FILE
Parameters:
dataVector to be read from file.
nLength of vector.
datafilenameData file name.

References __FILE__, __FUNCTION__, __LINE__, getGlobalMessageHandler(), MAX_STRING_LENGTH, RET_NOT_YET_IMPLEMENTED, RET_UNABLE_TO_OPEN_FILE, RET_UNABLE_TO_READ_FILE, SUCCESSFUL_RETURN, MessageHandling::throwError(), and VS_VISIBLE.

returnValue writeIntoFile ( const real_t *const  data,
int  nrow,
int  ncol,
const char *  datafilename,
BooleanType  append = BT_FALSE 
)

Writes a real_t matrix into a file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
Parameters:
dataMatrix to be written into file.
nrowRow number of matrix.
ncolColumn number of matrix.
datafilenameData file name.
appendIndicates if data shall be appended if the file already exists (otherwise it is overwritten).

References __FILE__, __FUNCTION__, __LINE__, BT_TRUE, getGlobalMessageHandler(), MAX_STRING_LENGTH, RET_NOT_YET_IMPLEMENTED, RET_UNABLE_TO_OPEN_FILE, SUCCESSFUL_RETURN, MessageHandling::throwError(), and VS_VISIBLE.

Referenced by writeIntoFile().

returnValue writeIntoFile ( const real_t *const  data,
int  n,
const char *  datafilename,
BooleanType  append = BT_FALSE 
)

Writes a real_t vector into a file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
Parameters:
dataVector to be written into file.
nLength of vector.
datafilenameData file name.
appendIndicates if data shall be appended if the file already exists (otherwise it is overwritten).

References writeIntoFile().

returnValue writeIntoFile ( const int *const  integer,
int  n,
const char *  datafilename,
BooleanType  append = BT_FALSE 
)

Writes an integer (column) vector into a file.

Returns:
SUCCESSFUL_RETURN
RET_UNABLE_TO_OPEN_FILE
Parameters:
integerInteger vector to be written into file.
nLength of vector.
datafilenameData file name.
appendIndicates if integer shall be appended if the file already exists (otherwise it is overwritten).

References __FILE__, __FUNCTION__, __LINE__, BT_TRUE, getGlobalMessageHandler(), MAX_STRING_LENGTH, RET_NOT_YET_IMPLEMENTED, RET_UNABLE_TO_OPEN_FILE, SUCCESSFUL_RETURN, MessageHandling::throwError(), and VS_VISIBLE.

returnValue writeIntoMatFile ( FILE *const  matFile,
const real_t *const  data,
int  nRows,
int  nCols,
const char *  name 
)

Writes a real_t matrix/vector into a Matlab binary file.

Returns:
SUCCESSFUL_RETURN
RET_INVALID_ARGUMENTS RET_UNABLE_TO_WRITE_FILE
Parameters:
matFilePointer to Matlab binary file.
dataData to be written into file.
nRowsRow number of matrix.
nColsColumn number of matrix.
nameMatlab name of matrix/vector to be stored.

References MatMatrixHeader::imaginaryPart, MatMatrixHeader::nCharName, MatMatrixHeader::nCols, MatMatrixHeader::nRows, MatMatrixHeader::numericFormat, real_t, RET_INVALID_ARGUMENTS, RET_NOT_YET_IMPLEMENTED, RET_UNABLE_TO_WRITE_FILE, and SUCCESSFUL_RETURN.

Referenced by writeIntoMatFile(), QProblem::writeQpDataIntoMatFile(), and QProblem::writeQpWorkspaceIntoMatFile().

returnValue writeIntoMatFile ( FILE *const  matFile,
const int *const  data,
int  nRows,
int  nCols,
const char *  name 
)

Writes in integer matrix/vector into a Matlab binary file.

Returns:
SUCCESSFUL_RETURN
RET_INVALID_ARGUMENTS RET_UNABLE_TO_WRITE_FILE
Parameters:
matFilePointer to Matlab binary file.
dataData to be written into file.
nRowsRow number of matrix.
nColsColumn number of matrix.
nameMatlab name of matrix/vector to be stored.

References real_t, and writeIntoMatFile().