matrix_variables_grid.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00033 #ifndef ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
00034 #define ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
00035 
00036 #include <acado/variables_grid/grid.hpp>
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 const Grid emptyGrid;
00041 const Grid trivialGrid( 1 );
00042 
00043 class VariablesGrid;
00044 class MatrixVariable;
00045 
00060 class MatrixVariablesGrid : public Grid
00061 {
00062     //
00063     // PUBLIC MEMBER FUNCTIONS:
00064     //
00065     public:
00066 
00069         MatrixVariablesGrid( );
00070 
00086         MatrixVariablesGrid(    uint _nRows,
00087                                                                 uint _nCols,
00088                                                                 const Grid& _grid,
00089                                                                 VariableType _type = VT_UNKNOWN,
00090                                                                 const char** const _names = 0,
00091                                                                 const char** const _units = 0,
00092                                                                 const DVector* const _scaling = 0,
00093                                                                 const DVector* const _lb = 0,
00094                                                                 const DVector* const _ub = 0,
00095                                                                 const BooleanType* const _autoInit = 0
00096                                                                 );
00097 
00113         MatrixVariablesGrid(    uint _nRows,
00114                                                                 uint _nCols,
00115                                                                 uint _nPoints,
00116                                                                 VariableType _type = VT_UNKNOWN,
00117                                                                 const char** const _names = 0,
00118                                                                 const char** const _units = 0,
00119                                                                 const DVector* const _scaling = 0,
00120                                                                 const DVector* const _lb = 0,
00121                                                                 const DVector* const _ub = 0,
00122                                                                 const BooleanType* const _autoInit = 0
00123                                                                 );
00124 
00144                 MatrixVariablesGrid(    uint _nRows,
00145                                                                 uint _nCols,
00146                                                                 double _firstTime,
00147                                                                 double _lastTime,
00148                                                                 uint _nPoints,
00149                                                                 VariableType _type = VT_UNKNOWN,
00150                                                                 const char** const _names = 0,
00151                                                                 const char** const _units = 0,
00152                                                                 const DVector* const _scaling = 0,
00153                                                                 const DVector* const _lb = 0,
00154                                                                 const DVector* const _ub = 0,
00155                                                                 const BooleanType* const _autoInit = 0
00156                                                                 );
00157 
00165         MatrixVariablesGrid(    const DMatrix& arg,
00166                                                                 const Grid& _grid = trivialGrid,
00167                                                                 VariableType _type = VT_UNKNOWN
00168                                                                 );
00169 
00174         MatrixVariablesGrid(    const MatrixVariablesGrid& rhs
00175                                                                 );
00176 
00179         virtual ~MatrixVariablesGrid( );
00180 
00185         MatrixVariablesGrid& operator=( const MatrixVariablesGrid& rhs
00186                                                                                 );
00187 
00188 
00189 
00190 
00202                 MatrixVariablesGrid& operator=( const DMatrix& rhs
00203                                                                                 );
00204 
00205 
00215         double& operator()(     uint pointIdx,
00216                                                                         uint rowIdx,
00217                                                                         uint colIdx
00218                                                                         );
00219 
00229         double operator()(      uint pointIdx,
00230                                                                         uint rowIdx,
00231                                                                         uint colIdx
00232                                                                         ) const;
00233 
00240         MatrixVariablesGrid operator()( const uint rowIdx
00241                                                                                                 ) const;
00242 
00250         MatrixVariablesGrid operator[]( const uint pointIdx
00251                                                                                                 ) const;
00252 
00253 
00260                 MatrixVariablesGrid operator+(  const MatrixVariablesGrid& arg
00261                                                                                                 ) const;
00262 
00269                 MatrixVariablesGrid& operator+=(        const MatrixVariablesGrid& arg
00270                                                                                                 );
00271 
00272 
00280                 MatrixVariablesGrid operator-(  const MatrixVariablesGrid& arg
00281                                                                                                 ) const;
00282 
00289                 MatrixVariablesGrid& operator-=(        const MatrixVariablesGrid& arg
00290                                                                                                 );
00291 
00292 
00297         returnValue init( );
00298 
00315         returnValue init(       uint _nRows,
00316                                                         uint _nCols,
00317                                                         const Grid& _grid,
00318                                                         VariableType _type = VT_UNKNOWN,
00319                                                         const char** const _names = 0,
00320                                                         const char** const _units = 0,
00321                                                         const DVector* const _scaling = 0,
00322                                                         const DVector* const _lb = 0,
00323                                                         const DVector* const _ub = 0,
00324                                                         const BooleanType* const _autoInit = 0
00325                                                         );
00326 
00344         returnValue init(       uint _nRows,
00345                                                         uint _nCols,
00346                                                         uint _nPoints,
00347                                                         VariableType _type = VT_UNKNOWN,
00348                                                         const char** const _names = 0,
00349                                                         const char** const _units = 0,
00350                                                         const DVector* const _scaling = 0,
00351                                                         const DVector* const _lb = 0,
00352                                                         const DVector* const _ub = 0,
00353                                                         const BooleanType* const _autoInit = 0
00354                                                         );
00355 
00377         returnValue init(       uint _nRows,
00378                                                         uint _nCols,
00379                                                         double _firstTime,
00380                                                         double _lastTime,
00381                                                         uint _nPoints,
00382                                                         VariableType _type = VT_UNKNOWN,
00383                                                         const char** const _names = 0,
00384                                                         const char** const _units = 0,
00385                                                         const DVector* const _scaling = 0,
00386                                                         const DVector* const _lb = 0,
00387                                                         const DVector* const _ub = 0,
00388                                                         const BooleanType* const _autoInit = 0
00389                                                         );
00390 
00400                 returnValue init(       const DMatrix& arg,
00401                                                         const Grid& _grid = trivialGrid,
00402                                                         VariableType _type = VT_UNKNOWN
00403                                                         );
00404 
00413                 returnValue addMatrix(  const DMatrix& newMatrix,
00414                                                                 double newTime = -INFTY
00415                                                                 );
00416 
00425                 returnValue setMatrix(  uint pointIdx,
00426                                                                 const DMatrix& _value
00427                                                                 ) const;
00428 
00436                 returnValue setAllMatrices(     const DMatrix& _values
00437                                                                         );
00438 
00439 
00446                 DMatrix getMatrix(      uint pointIdx
00447                                                         ) const;
00448 
00453                 DMatrix getFirstMatrix( ) const;
00454 
00459                 DMatrix getLastMatrix( ) const;
00460 
00461 
00467                 uint getDim( ) const;
00468 
00469 
00474                 uint getNumRows( ) const;
00475 
00480                 uint getNumCols( ) const;
00481 
00486                 uint getNumValues( ) const;
00487 
00488 
00495                 uint getNumRows(        uint pointIdx
00496                                                                 ) const;
00497 
00504                 uint getNumCols(        uint pointIdx
00505                                                                 ) const;
00506 
00513                 uint getNumValues(      uint pointIdx
00514                                                                         ) const;
00515 
00516 
00521         VariableType getType( ) const;
00522 
00529         returnValue setType(    VariableType _type
00530                                                                         );
00531 
00538                 VariableType getType(   uint pointIdx
00539                                                                                 ) const;
00540 
00549         returnValue setType(    uint pointIdx,
00550                                                                         VariableType _type
00551                                                                         );
00552 
00563                 returnValue getName(    uint pointIdx,
00564                                                                         uint idx,
00565                                                                         char* const _name
00566                                                                         ) const;
00567 
00578                 returnValue setName(    uint pointIdx,
00579                                                                         uint idx,
00580                                                                         const char* const _name
00581                                                                         );
00582 
00583 
00594                 returnValue getUnit(    uint pointIdx,
00595                                                                         uint idx,
00596                                                                         char* const _unit
00597                                                                         ) const;
00598 
00609                 returnValue setUnit(    uint pointIdx,
00610                                                                         uint idx,
00611                                                                         const char* const _unit
00612                                                                         );
00613 
00620                 DVector getScaling(     uint pointIdx
00621                                                                                                 ) const;
00622 
00632                 returnValue setScaling( uint pointIdx,
00633                                                                                 const DVector& _scaling
00634                                                                                 );
00635 
00645                 double getScaling(      uint pointIdx,
00646                                                                         uint valueIdx
00647                                                                         ) const;
00648 
00660                 returnValue setScaling( uint pointIdx,
00661                                                                                 uint valueIdx,
00662                                                                                 double _scaling
00663                                                                                 );
00664 
00671                 DVector getLowerBounds( uint pointIdx
00672                                                                                                         ) const;
00673 
00682                 returnValue setLowerBounds(     uint pointIdx,
00683                                                                                         const DVector& _lb
00684                                                                                         );
00685 
00695                 double getLowerBound(   uint pointIdx,
00696                                                                                 uint valueIdx
00697                                                                                 ) const;
00698 
00709                 returnValue setLowerBound(      uint pointIdx,
00710                                                                                         uint valueIdx,
00711                                                                                         double _lb
00712                                                                                         );
00713 
00720                 DVector getUpperBounds( uint pointIdx
00721                                                                                                         ) const;
00722 
00731                 returnValue setUpperBounds(     uint pointIdx,
00732                                                                                         const DVector& _ub
00733                                                                                         );
00734 
00744                 double getUpperBound(   uint pointIdx,
00745                                                                                 uint valueIdx
00746                                                                                 ) const;
00747 
00758                 returnValue setUpperBound(      uint pointIdx,
00759                                                                                         uint valueIdx,
00760                                                                                         double _ub
00761                                                                                         );
00762 
00763 
00772                 BooleanType getAutoInit(        uint pointIdx
00773                                                                                 ) const;
00774 
00784                 returnValue setAutoInit(        uint pointIdx,
00785                                                                                 BooleanType _autoInit
00786                                                                                 );
00787 
00792                 returnValue disableAutoInit( );
00793 
00798                 returnValue enableAutoInit( );
00799 
00800 
00807                 BooleanType hasNames( ) const;
00808 
00815                 BooleanType hasUnits( ) const;
00816 
00822                 BooleanType hasScaling( ) const;
00823 
00830                 BooleanType hasLowerBounds( ) const;
00831 
00838                 BooleanType hasUpperBounds( ) const;
00839 
00840 
00845                 double getMax( ) const;
00846 
00851                 double getMin( ) const;
00852 
00857                 double getMean( ) const;
00858 
00863                 returnValue setZero( );
00864 
00871                 returnValue setAll(     double _value
00872                                                                         );
00873 
00883                 returnValue appendTimes(        const MatrixVariablesGrid& arg,
00884                                                                         MergeMethod _mergeMethod = MM_DUPLICATE
00885                                                                         );
00886 
00895                 returnValue appendValues(       const MatrixVariablesGrid& arg
00896                                                                         );
00897 
00911                 returnValue merge(      const MatrixVariablesGrid& arg,
00912                                                         MergeMethod _mergeMethod = MM_DUPLICATE,
00913                                                         BooleanType keepOverlap = BT_TRUE
00914                                                         );
00915 
00922         returnValue getGrid(    Grid& _grid
00923                                                                         ) const;
00924 
00933                 Grid getTimePoints( ) const;
00934 
00943         MatrixVariablesGrid getTimeSubGrid(     uint startIdx,
00944                                                                                         uint endIdx
00945                                                                                         ) const;
00946 
00959         MatrixVariablesGrid getValuesSubGrid(   uint startIdx,
00960                                                                                                 uint endIdx
00961                                                                                                 ) const;
00962 
00974                 returnValue refineGrid( const Grid& arg,
00975                                                                 InterpolationMode mode = IM_CONSTANT
00976                                                                 );
00977 
00987                 returnValue coarsenGrid(        const Grid& arg
00988                                                                         );
00989 
01000                 MatrixVariablesGrid getRefinedGrid(     const Grid& arg,
01001                                                                                         InterpolationMode mode = IM_CONSTANT
01002                                                                                         ) const;
01003 
01012                 MatrixVariablesGrid getCoarsenedGrid(   const Grid& arg
01013                                                                                                 ) const;
01014 
01021                 MatrixVariablesGrid& shiftTimes(        double timeShift
01022                                                                                         );
01023 
01030                 MatrixVariablesGrid& shiftBackwards( DMatrix lastValue = emptyMatrix );
01031 
01044                 DVector linearInterpolation(    double time
01045                                                                         ) const;
01046 
01062                 returnValue print(      std::ostream& stream           = std::cout,
01063                                                         const char* const name         = DEFAULT_LABEL,
01064                                                         const char* const startString  = DEFAULT_START_STRING,
01065                                                         const char* const endString    = DEFAULT_END_STRING,
01066                                                         uint width                     = DEFAULT_WIDTH,
01067                                                         uint precision                 = DEFAULT_PRECISION,
01068                                                         const char* const colSeparator = DEFAULT_COL_SEPARATOR,
01069                                                         const char* const rowSeparator = DEFAULT_ROW_SEPARATOR
01070                                                         ) const;
01071 
01087                 returnValue print(      const char* const filename,
01088                                                         const char* const name         = DEFAULT_LABEL,
01089                                                         const char* const startString  = DEFAULT_START_STRING,
01090                                                         const char* const endString    = DEFAULT_END_STRING,
01091                                                         uint width                     = DEFAULT_WIDTH,
01092                                                         uint precision                 = DEFAULT_PRECISION,
01093                                                         const char* const colSeparator = DEFAULT_COL_SEPARATOR,
01094                                                         const char* const rowSeparator = DEFAULT_ROW_SEPARATOR
01095                                                         ) const;
01096 
01108                 returnValue print(      const char* const filename,
01109                                                         const char* const name,
01110                                                         PrintScheme printScheme
01111                                                         ) const;
01112 
01124                 returnValue print(      std::ostream& stream,
01125                                                         const char* const name,
01126                                                         PrintScheme printScheme
01127                                                         ) const;
01128 
01143                 returnValue read(       std::istream& stream
01144                                                         );
01145 
01160                 returnValue read(       const char* const filename
01161                                                         );
01162 
01164                 friend std::ostream& operator<<(        std::ostream& stream,
01165                                                                                         const MatrixVariablesGrid& arg
01166                                                                                         );
01167 
01169                 friend std::istream& operator>>(        std::istream& stream,
01170                                                                                 MatrixVariablesGrid& arg
01171                                                                                 );
01172 
01174                 returnValue sprint(     std::ostream& stream
01175                                                         );
01176 
01177     //
01178     // PROTECTED MEMBER FUNCTIONS:
01179     //
01180     protected:
01181 
01187                 returnValue clearValues( );
01188 
01189 
01205                 returnValue initMatrixVariables(        uint _nRows,
01206                                                                                         uint _nCols,
01207                                                                                         VariableType _type = VT_UNKNOWN,
01208                                                                                         const char** const _names = 0,
01209                                                                                         const char** const _units = 0,
01210                                                                                         const DVector* const _scaling = 0,
01211                                                                                         const DVector* const _lb = 0,
01212                                                                                         const DVector* const _ub = 0,
01213                                                                                         const BooleanType* const _autoInit = 0
01214                                                                                         );
01215 
01224                 returnValue addMatrix(  const MatrixVariable& newMatrix,
01225                                                                 double newTime = -INFTY
01226                                                                 );
01227 
01228     //
01229     // DATA MEMBERS:
01230     //
01231     protected:
01232 
01234                 MatrixVariable** values;
01235 };
01236 
01237 CLOSE_NAMESPACE_ACADO
01238 
01239 #endif  // ACADO_TOOLKIT_MATRIX_VARIABLES_GRID_HPP
01240 
01241 /*
01242  *      end of file
01243  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:03