matrix_variables_grid.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
33 #ifndef ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
34 #define ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
35 
37 
39 
41 const Grid trivialGrid( 1 );
42 
43 class VariablesGrid;
44 class MatrixVariable;
45 
60 class MatrixVariablesGrid : public Grid
61 {
62  //
63  // PUBLIC MEMBER FUNCTIONS:
64  //
65  public:
66 
70 
86  MatrixVariablesGrid( uint _nRows,
87  uint _nCols,
88  const Grid& _grid,
89  VariableType _type = VT_UNKNOWN,
90  const char** const _names = 0,
91  const char** const _units = 0,
92  const DVector* const _scaling = 0,
93  const DVector* const _lb = 0,
94  const DVector* const _ub = 0,
95  const BooleanType* const _autoInit = 0
96  );
97 
113  MatrixVariablesGrid( uint _nRows,
114  uint _nCols,
115  uint _nPoints,
116  VariableType _type = VT_UNKNOWN,
117  const char** const _names = 0,
118  const char** const _units = 0,
119  const DVector* const _scaling = 0,
120  const DVector* const _lb = 0,
121  const DVector* const _ub = 0,
122  const BooleanType* const _autoInit = 0
123  );
124 
144  MatrixVariablesGrid( uint _nRows,
145  uint _nCols,
146  double _firstTime,
147  double _lastTime,
148  uint _nPoints,
149  VariableType _type = VT_UNKNOWN,
150  const char** const _names = 0,
151  const char** const _units = 0,
152  const DVector* const _scaling = 0,
153  const DVector* const _lb = 0,
154  const DVector* const _ub = 0,
155  const BooleanType* const _autoInit = 0
156  );
157 
165  MatrixVariablesGrid( const DMatrix& arg,
166  const Grid& _grid = trivialGrid,
167  VariableType _type = VT_UNKNOWN
168  );
169 
175  );
176 
179  virtual ~MatrixVariablesGrid( );
180 
186  );
187 
188 
189 
190 
203  );
204 
205 
215  double& operator()( uint pointIdx,
216  uint rowIdx,
217  uint colIdx
218  );
219 
229  double operator()( uint pointIdx,
230  uint rowIdx,
231  uint colIdx
232  ) const;
233 
240  MatrixVariablesGrid operator()( const uint rowIdx
241  ) const;
242 
250  MatrixVariablesGrid operator[]( const uint pointIdx
251  ) const;
252 
253 
261  ) const;
262 
270  );
271 
272 
281  ) const;
282 
290  );
291 
292 
297  returnValue init( );
298 
315  returnValue init( uint _nRows,
316  uint _nCols,
317  const Grid& _grid,
318  VariableType _type = VT_UNKNOWN,
319  const char** const _names = 0,
320  const char** const _units = 0,
321  const DVector* const _scaling = 0,
322  const DVector* const _lb = 0,
323  const DVector* const _ub = 0,
324  const BooleanType* const _autoInit = 0
325  );
326 
344  returnValue init( uint _nRows,
345  uint _nCols,
346  uint _nPoints,
347  VariableType _type = VT_UNKNOWN,
348  const char** const _names = 0,
349  const char** const _units = 0,
350  const DVector* const _scaling = 0,
351  const DVector* const _lb = 0,
352  const DVector* const _ub = 0,
353  const BooleanType* const _autoInit = 0
354  );
355 
377  returnValue init( uint _nRows,
378  uint _nCols,
379  double _firstTime,
380  double _lastTime,
381  uint _nPoints,
382  VariableType _type = VT_UNKNOWN,
383  const char** const _names = 0,
384  const char** const _units = 0,
385  const DVector* const _scaling = 0,
386  const DVector* const _lb = 0,
387  const DVector* const _ub = 0,
388  const BooleanType* const _autoInit = 0
389  );
390 
400  returnValue init( const DMatrix& arg,
401  const Grid& _grid = trivialGrid,
402  VariableType _type = VT_UNKNOWN
403  );
404 
413  returnValue addMatrix( const DMatrix& newMatrix,
414  double newTime = -INFTY
415  );
416 
425  returnValue setMatrix( uint pointIdx,
426  const DMatrix& _value
427  ) const;
428 
436  returnValue setAllMatrices( const DMatrix& _values
437  );
438 
439 
446  DMatrix getMatrix( uint pointIdx
447  ) const;
448 
453  DMatrix getFirstMatrix( ) const;
454 
459  DMatrix getLastMatrix( ) const;
460 
461 
467  uint getDim( ) const;
468 
469 
474  uint getNumRows( ) const;
475 
480  uint getNumCols( ) const;
481 
486  uint getNumValues( ) const;
487 
488 
495  uint getNumRows( uint pointIdx
496  ) const;
497 
504  uint getNumCols( uint pointIdx
505  ) const;
506 
513  uint getNumValues( uint pointIdx
514  ) const;
515 
516 
521  VariableType getType( ) const;
522 
530  );
531 
538  VariableType getType( uint pointIdx
539  ) const;
540 
549  returnValue setType( uint pointIdx,
550  VariableType _type
551  );
552 
563  returnValue getName( uint pointIdx,
564  uint idx,
565  char* const _name
566  ) const;
567 
578  returnValue setName( uint pointIdx,
579  uint idx,
580  const char* const _name
581  );
582 
583 
594  returnValue getUnit( uint pointIdx,
595  uint idx,
596  char* const _unit
597  ) const;
598 
609  returnValue setUnit( uint pointIdx,
610  uint idx,
611  const char* const _unit
612  );
613 
620  DVector getScaling( uint pointIdx
621  ) const;
622 
632  returnValue setScaling( uint pointIdx,
633  const DVector& _scaling
634  );
635 
645  double getScaling( uint pointIdx,
646  uint valueIdx
647  ) const;
648 
660  returnValue setScaling( uint pointIdx,
661  uint valueIdx,
662  double _scaling
663  );
664 
671  DVector getLowerBounds( uint pointIdx
672  ) const;
673 
682  returnValue setLowerBounds( uint pointIdx,
683  const DVector& _lb
684  );
685 
695  double getLowerBound( uint pointIdx,
696  uint valueIdx
697  ) const;
698 
709  returnValue setLowerBound( uint pointIdx,
710  uint valueIdx,
711  double _lb
712  );
713 
720  DVector getUpperBounds( uint pointIdx
721  ) const;
722 
731  returnValue setUpperBounds( uint pointIdx,
732  const DVector& _ub
733  );
734 
744  double getUpperBound( uint pointIdx,
745  uint valueIdx
746  ) const;
747 
758  returnValue setUpperBound( uint pointIdx,
759  uint valueIdx,
760  double _ub
761  );
762 
763 
772  BooleanType getAutoInit( uint pointIdx
773  ) const;
774 
784  returnValue setAutoInit( uint pointIdx,
785  BooleanType _autoInit
786  );
787 
793 
799 
800 
807  BooleanType hasNames( ) const;
808 
815  BooleanType hasUnits( ) const;
816 
822  BooleanType hasScaling( ) const;
823 
830  BooleanType hasLowerBounds( ) const;
831 
838  BooleanType hasUpperBounds( ) const;
839 
840 
845  double getMax( ) const;
846 
851  double getMin( ) const;
852 
857  double getMean( ) const;
858 
863  returnValue setZero( );
864 
871  returnValue setAll( double _value
872  );
873 
884  MergeMethod _mergeMethod = MM_DUPLICATE
885  );
886 
896  );
897 
912  MergeMethod _mergeMethod = MM_DUPLICATE,
913  BooleanType keepOverlap = BT_TRUE
914  );
915 
922  returnValue getGrid( Grid& _grid
923  ) const;
924 
933  Grid getTimePoints( ) const;
934 
944  uint endIdx
945  ) const;
946 
960  uint endIdx
961  ) const;
962 
974  returnValue refineGrid( const Grid& arg,
976  );
977 
987  returnValue coarsenGrid( const Grid& arg
988  );
989 
1002  ) const;
1003 
1013  ) const;
1014 
1021  MatrixVariablesGrid& shiftTimes( double timeShift
1022  );
1023 
1031 
1044  DVector linearInterpolation( double time
1045  ) const;
1046 
1062  returnValue print( std::ostream& stream = std::cout,
1063  const char* const name = DEFAULT_LABEL,
1064  const char* const startString = DEFAULT_START_STRING,
1065  const char* const endString = DEFAULT_END_STRING,
1066  uint width = DEFAULT_WIDTH,
1068  const char* const colSeparator = DEFAULT_COL_SEPARATOR,
1069  const char* const rowSeparator = DEFAULT_ROW_SEPARATOR
1070  ) const;
1071 
1087  returnValue print( const char* const filename,
1088  const char* const name = DEFAULT_LABEL,
1089  const char* const startString = DEFAULT_START_STRING,
1090  const char* const endString = DEFAULT_END_STRING,
1091  uint width = DEFAULT_WIDTH,
1093  const char* const colSeparator = DEFAULT_COL_SEPARATOR,
1094  const char* const rowSeparator = DEFAULT_ROW_SEPARATOR
1095  ) const;
1096 
1108  returnValue print( const char* const filename,
1109  const char* const name,
1110  PrintScheme printScheme
1111  ) const;
1112 
1124  returnValue print( std::ostream& stream,
1125  const char* const name,
1126  PrintScheme printScheme
1127  ) const;
1128 
1143  returnValue read( std::istream& stream
1144  );
1145 
1160  returnValue read( const char* const filename
1161  );
1162 
1164  friend std::ostream& operator<<( std::ostream& stream,
1165  const MatrixVariablesGrid& arg
1166  );
1167 
1169  friend std::istream& operator>>( std::istream& stream,
1170  MatrixVariablesGrid& arg
1171  );
1172 
1174  returnValue sprint( std::ostream& stream
1175  );
1176 
1177  //
1178  // PROTECTED MEMBER FUNCTIONS:
1179  //
1180  protected:
1181 
1188 
1189 
1206  uint _nCols,
1207  VariableType _type = VT_UNKNOWN,
1208  const char** const _names = 0,
1209  const char** const _units = 0,
1210  const DVector* const _scaling = 0,
1211  const DVector* const _lb = 0,
1212  const DVector* const _ub = 0,
1213  const BooleanType* const _autoInit = 0
1214  );
1215 
1224  returnValue addMatrix( const MatrixVariable& newMatrix,
1225  double newTime = -INFTY
1226  );
1227 
1228  //
1229  // DATA MEMBERS:
1230  //
1231  protected:
1232 
1235 };
1236 
1238 
1239 #endif // ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
1240 
1241 /*
1242  * end of file
1243  */
const char DEFAULT_END_STRING[4]
returnValue setAllMatrices(const DMatrix &_values)
returnValue setType(VariableType _type)
BooleanType getAutoInit(uint pointIdx) const
returnValue addMatrix(const DMatrix &newMatrix, double newTime=-INFTY)
DVector getScaling(uint pointIdx) const
MatrixVariablesGrid & operator+=(const MatrixVariablesGrid &arg)
const double INFTY
DMatrix getFirstMatrix() const
MatrixVariablesGrid & operator-=(const MatrixVariablesGrid &arg)
returnValue setScaling(uint pointIdx, const DVector &_scaling)
returnValue setUpperBounds(uint pointIdx, const DVector &_ub)
const uint DEFAULT_PRECISION
BooleanType hasScaling() const
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
const char DEFAULT_COL_SEPARATOR[2]
DVector getUpperBounds(uint pointIdx) const
double getLowerBound(uint pointIdx, uint valueIdx) const
BooleanType hasLowerBounds() const
MatrixVariablesGrid operator+(const MatrixVariablesGrid &arg) const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
MatrixVariablesGrid getTimeSubGrid(uint startIdx, uint endIdx) const
returnValue setLowerBound(uint pointIdx, uint valueIdx, double _lb)
#define CLOSE_NAMESPACE_ACADO
double getUpperBound(uint pointIdx, uint valueIdx) const
const char DEFAULT_START_STRING[3]
MatrixVariablesGrid getCoarsenedGrid(const Grid &arg) const
VariableType
Definition: acado_types.hpp:95
returnValue print() const
Definition: grid.cpp:700
returnValue setAll(double _value)
MatrixVariablesGrid getRefinedGrid(const Grid &arg, InterpolationMode mode=IM_CONSTANT) const
MatrixVariablesGrid & shiftBackwards(DMatrix lastValue=emptyMatrix)
returnValue setAutoInit(uint pointIdx, BooleanType _autoInit)
returnValue appendValues(const MatrixVariablesGrid &arg)
returnValue sprint(std::ostream &stream)
static DMatrix emptyMatrix
Definition: matrix.hpp:465
returnValue merge(const MatrixVariablesGrid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
VariableType getType() 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)
BEGIN_NAMESPACE_ACADO const Grid emptyGrid
Provides a time grid consisting of matrix-valued optimization variables at each grid point...
returnValue setUpperBound(uint pointIdx, uint valueIdx, double _ub)
PrintScheme
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
friend std::ostream & operator<<(std::ostream &stream, const MatrixVariablesGrid &arg)
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.
const Grid trivialGrid(1)
void rhs(const real_t *x, real_t *f)
MatrixVariablesGrid getValuesSubGrid(uint startIdx, uint endIdx) const
returnValue getName(uint pointIdx, uint idx, char *const _name) const
DMatrix getMatrix(uint pointIdx) const
returnValue read(std::istream &stream)
returnValue appendTimes(const MatrixVariablesGrid &arg, MergeMethod _mergeMethod=MM_DUPLICATE)
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue setMatrix(uint pointIdx, const DMatrix &_value) const
const uint DEFAULT_WIDTH
MatrixVariablesGrid & operator=(const MatrixVariablesGrid &rhs)
returnValue coarsenGrid(const Grid &arg)
const char DEFAULT_ROW_SEPARATOR[6]
DVector getLowerBounds(uint pointIdx) const
MatrixVariablesGrid operator-(const MatrixVariablesGrid &arg) const
returnValue setLowerBounds(uint pointIdx, const DVector &_lb)
BooleanType hasUpperBounds() const
#define BEGIN_NAMESPACE_ACADO
MergeMethod
MatrixVariablesGrid & shiftTimes(double timeShift)
returnValue setName(uint pointIdx, uint idx, const char *const _name)
const char DEFAULT_LABEL[1]
InterpolationMode


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:51