58 const char**
const _names,
59 const char**
const _units,
67 init( _nRows,_nCols,_grid,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
75 const char**
const _names,
76 const char**
const _units,
84 init( _nRows,_nCols,_nPoints,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
94 const char**
const _names,
95 const char**
const _units,
103 init( _nRows,_nCols,_firstTime,_lastTime,_nPoints,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
113 init( arg,_grid,_type );
168 operator()( i,j,0 ) =
rhs( i,j+1 );
188 const char**
const _names,
189 const char**
const _units,
204 return initMatrixVariables( _nRows,_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
212 const char**
const _names,
213 const char**
const _units,
228 return initMatrixVariables( _nRows,_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
238 const char**
const _names,
239 const char**
const _units,
254 return initMatrixVariables( _nRows,_nCols,_type,_names,_units,_scaling,_lb,_ub,_autoInit );
297 *(
values[pointIdx]) = _value;
363 switch ( _mergeMethod )
454 switch ( _mergeMethod )
506 return newVariablesGrid;
508 if ( startIdx > endIdx )
509 return newVariablesGrid;
511 for(
uint i=startIdx; i<=endIdx; ++i )
514 return newVariablesGrid;
525 return newVariablesGrid;
527 if ( startIdx > endIdx )
528 return newVariablesGrid;
533 return newVariablesGrid;
584 if ( Grid::operator==( arg ) ==
BT_TRUE )
618 if ( Grid::operator==( arg ) ==
BT_TRUE )
621 if ( Grid::operator>=( arg ) ==
BT_FALSE )
684 if( fabs( t2 - t1 ) <
SQRT_EPS )
return tmp1;
696 const char*
const name,
697 const char*
const startString,
698 const char*
const endString,
701 const char*
const colSeparator,
702 const char*
const rowSeparator
705 if (name != NULL && strlen(name) > 0)
706 stream << name <<
" = ";
707 if (startString != NULL && strlen(startString) > 0)
708 stream << startString;
711 stream << setw( width ) << setprecision( precision ) << scientific;
713 stream << setw( width );
722 if (colSeparator != NULL && strlen(colSeparator) > 0)
723 stream << colSeparator;
725 values[k]->
print(stream,
"",
"",
"", width, precision, colSeparator, colSeparator);
727 if (k < (
getNumPoints() - 1) && rowSeparator != NULL && strlen(rowSeparator) > 0)
728 stream << rowSeparator;
730 if (endString != NULL && strlen(endString) > 0)
737 const char*
const name,
738 const char*
const startString,
739 const char*
const endString,
742 const char*
const colSeparator,
743 const char*
const rowSeparator
746 ofstream stream( filename );
749 if (stream.is_open() ==
true)
750 status =
print(stream, name, startString, endString, width, precision,
751 colSeparator, rowSeparator);
761 const char*
const name,
765 ofstream stream(filename);
768 if (stream.is_open())
769 status =
print(stream, name, printScheme);
779 const char*
const name,
785 switch (printScheme) {
801 char* startString = 0;
805 char* colSeparator = 0;
806 char* rowSeparator = 0;
809 &endString, width, precision, &colSeparator, &rowSeparator);
813 status =
print(stream, name, startString, endString, width, precision,
814 colSeparator, rowSeparator);
816 if (startString != 0)
817 delete[] startString;
820 if (colSeparator != 0)
821 delete[] colSeparator;
822 if (rowSeparator != 0)
823 delete[] rowSeparator;
833 vector< vector< double > > data;
836 if (data.size() == 0)
840 unsigned nc = data[ 0 ].size();
841 unsigned nr = data.size();
843 if (data[
row ].size() != nc)
852 for (
unsigned row = 0; row < nr; ++
row)
853 for (
unsigned col = 0;
col < nc - 1; ++
col)
854 operator()(
row,
col, 0) = data[ row ][col + 1];
861 ifstream stream( filename );
864 if (stream.is_open())
865 status =
read( stream );
915 const char**
const _names,
916 const char**
const _units,
923 DVector currentScaling,currentLb,currentUb;
928 currentScaling = _scaling[i];
930 currentScaling.
init( );
942 values[i] =
new MatrixVariable( _nRows,_nCols,_type,_names,_units,currentScaling,currentLb,currentUb );
968 uint run1, run2, run3;
971 double *tmp =
new double[tmpSize];
987 for (run1 = 0; run1 < nRows; run1++) {
988 for (run2 = 0; run2 < nCols; run2++) {
989 if (tmp[nCols * run1 + run2] <=
ACADO_NAN - 1.0)
990 stream << scientific << tmp[nCols * run1 + run2] <<
TEXT_SEPARATOR;
1004 #pragma warning( disable : 4390 ) 1017 return values[pointIdx]->operator()( rowIdx,colIdx );
1026 return values[pointIdx]->operator()( rowIdx,colIdx );
1047 rowGrid( run1,0,0 ) =
values[run1]->operator()( rowIdx,0 );
1079 *(tmp.values[i]) += *(arg.
values[i]);
1109 *(tmp.values[i]) -= *(arg.
values[i]);
1259 const char*
const _name
1284 const char*
const _unit
1548 double maxValue = -
INFTY;
1562 double minValue =
INFTY;
1576 double meanValue = 0.0;
returnValue getGlobalStringDefinitions(PrintScheme _printScheme, char **_startString, char **_endString, uint &_width, uint &_precision, char **_colSeparator, char **_rowSeparator)
returnValue setAllMatrices(const DMatrix &_values)
returnValue setTime(double _time)
returnValue setType(VariableType _type)
double getLowerBound(uint idx) const
returnValue appendSettings(const VariableSettings &rhs)
returnValue print(std::ostream &stream=std::cout, const char *const name=DEFAULT_LABEL, const char *const startString=DEFAULT_START_STRING, const char *const endString=DEFAULT_END_STRING, uint width=DEFAULT_WIDTH, uint precision=DEFAULT_PRECISION, const char *const colSeparator=DEFAULT_COL_SEPARATOR, const char *const rowSeparator=DEFAULT_ROW_SEPARATOR) const
returnValue disableAutoInit()
int findLastTime(double _time, uint startIdx=0) const
BooleanType getAutoInit(uint pointIdx) const
returnValue addMatrix(const DMatrix &newMatrix, double newTime=-INFTY)
double getTime(uint pointIdx) const
DVector getScaling(uint pointIdx) const
returnValue setUnit(uint idx, const char *const _unit)
MatrixVariablesGrid & operator+=(const MatrixVariablesGrid &arg)
double getFirstTime() const
BooleanType acadoIsEqual(double x, double y, double TOL)
uint getCeilIndex(double time) const
DMatrix getFirstMatrix() const
MatrixVariablesGrid & operator-=(const MatrixVariablesGrid &arg)
returnValue getUnit(uint idx, char *_unit) const
returnValue setScaling(uint pointIdx, const DVector &_scaling)
returnValue setUpperBounds(uint pointIdx, const DVector &_ub)
void init(unsigned _dim=0)
BooleanType hasScaling() const
returnValue setName(uint idx, const char *const _name)
double getUpperBound(uint idx) const
returnValue clearValues()
Allows to pass back messages to the calling function.
DVector getUpperBounds(uint pointIdx) const
double getLowerBound(uint pointIdx, uint valueIdx) const
returnValue getName(uint idx, char *_name) const
BooleanType hasLowerBounds() const
MatrixVariablesGrid operator+(const MatrixVariablesGrid &arg) const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Allows to conveniently handle (one-dimensional) grids consisting of time points.
BooleanType isEmpty() const
returnValue setScaling(const DVector &_scaling)
GenericMatrix & appendRows(const GenericMatrix &_arg)
uint getLastIndex() const
BooleanType acadoIsGreater(double x, double y, double TOL)
MatrixVariablesGrid getTimeSubGrid(uint startIdx, uint endIdx) const
const char NOT_A_NUMBER[3]
returnValue setLowerBound(uint pointIdx, uint valueIdx, double _lb)
DVector getLowerBounds() const
#define CLOSE_NAMESPACE_ACADO
double getUpperBound(uint pointIdx, uint valueIdx) const
MatrixVariablesGrid getCoarsenedGrid(const Grid &arg) const
BooleanType isInInterval(double _time) const
returnValue print() const
DVector getScaling() const
returnValue setAll(double _value)
MatrixVariablesGrid getRefinedGrid(const Grid &arg, InterpolationMode mode=IM_CONSTANT) const
BooleanType getAutoInit() const
MatrixVariablesGrid & shiftBackwards(DMatrix lastValue=emptyMatrix)
returnValue setUpperBound(uint idx, double _ub)
uint getFloorIndex(double time) const
#define ACADOFATAL(retval)
returnValue setAutoInit(uint pointIdx, BooleanType _autoInit)
returnValue appendValues(const MatrixVariablesGrid &arg)
BooleanType acadoIsStrictlySmaller(double x, double y, double TOL)
BEGIN_NAMESPACE_ACADO const char LINE_SEPARATOR
returnValue sprint(std::ostream &stream)
VariableType getType() const
static DMatrix emptyMatrix
returnValue merge(const MatrixVariablesGrid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
returnValue setAutoInit(BooleanType _autoInit)
Grid getTimePoints() const
virtual ~MatrixVariablesGrid()
VariableType getType() const
virtual returnValue print(std::ostream &_stream=std::cout, const std::string &_name=DEFAULT_LABEL, const std::string &_startString=DEFAULT_START_STRING, const std::string &_endString=DEFAULT_END_STRING, uint _width=DEFAULT_WIDTH, uint _precision=DEFAULT_PRECISION, const std::string &_colSeparator=DEFAULT_COL_SEPARATOR, const std::string &_rowSeparator=DEFAULT_ROW_SEPARATOR) const
BooleanType hasNames() const
BooleanType hasUnits() const
double & operator()(uint pointIdx, uint rowIdx, uint colIdx)
DVector linearInterpolation(double time) const
friend std::istream & operator>>(std::istream &stream, MatrixVariablesGrid &arg)
Provides a time grid consisting of matrix-valued optimization variables at each grid point...
Grid & operator=(const Grid &rhs)
const BooleanType defaultAutoInit
returnValue setUpperBound(uint pointIdx, uint valueIdx, double _ub)
DMatrix getMatrix() const
returnValue getGrid(Grid &_grid) const
DMatrix getLastMatrix() const
returnValue refineGrid(const Grid &arg, InterpolationMode mode=IM_CONSTANT)
returnValue setUnit(uint pointIdx, uint idx, const char *const _unit)
returnValue getUnit(uint pointIdx, uint idx, char *const _unit) const
returnValue setLowerBounds(const DVector &_lb)
friend std::ostream & operator<<(std::ostream &stream, const MatrixVariablesGrid &arg)
returnValue init(uint _nPoints=0, const double *const _times=0)
BooleanType isInfty(const double x)
BooleanType acadoIsSmaller(double x, double y, double TOL)
MatrixVariablesGrid operator[](const uint pointIdx) const
returnValue initMatrixVariables(uint _nRows, uint _nCols, VariableType _type=VT_UNKNOWN, const char **const _names=0, const char **const _units=0, const DVector *const _scaling=0, const DVector *const _lb=0, const DVector *const _ub=0, const BooleanType *const _autoInit=0)
Provides matrix-valued optimization variables.
void rhs(const real_t *x, real_t *f)
MatrixVariablesGrid getValuesSubGrid(uint startIdx, uint endIdx) const
DVector getUpperBounds() const
returnValue getName(uint pointIdx, uint idx, char *const _name) const
DMatrix getMatrix(uint pointIdx) const
unsigned getNumRows() const
MatrixVariable getRows(uint startIdx, uint endIdx) const
const char TEXT_SEPARATOR
returnValue read(std::istream &stream)
int acadoMin(const int x, const int y)
returnValue setLowerBound(uint idx, double _lb)
returnValue appendTimes(const MatrixVariablesGrid &arg, MergeMethod _mergeMethod=MM_DUPLICATE)
returnValue setMatrix(uint pointIdx, const DMatrix &_value) const
Grid & shiftTimes(double timeShift)
unsigned getNumCols() const
uint getNumIntervals() const
returnValue addTime(double _time)
MatrixVariablesGrid & operator=(const MatrixVariablesGrid &rhs)
returnValue coarsenGrid(const Grid &arg)
uint getNumPoints() const
returnValue setType(VariableType _type)
BooleanType hasTime(double _time) const
returnValue enableAutoInit()
double getLastTime() const
DVector getLowerBounds(uint pointIdx) const
MatrixVariablesGrid operator-(const MatrixVariablesGrid &arg) const
static DVector emptyVector
returnValue setLowerBounds(uint pointIdx, const DVector &_lb)
BooleanType hasUpperBounds() const
#define BEGIN_NAMESPACE_ACADO
MatrixVariablesGrid & shiftTimes(double timeShift)
returnValue setName(uint pointIdx, uint idx, const char *const _name)
returnValue setUpperBounds(const DVector &_ub)
BooleanType acadoIsStrictlyGreater(double x, double y, double TOL)
uint getNumValues() const
#define ACADOERROR(retval)
#define ACADOERRORTEXT(retval, text)