model_container.cpp
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 #include <acado/ocp/model_container.hpp>
00034 
00035 
00036 BEGIN_NAMESPACE_ACADO
00037 
00038 
00039 
00040 //
00041 // PUBLIC MEMBER FUNCTIONS:
00042 //
00043 
00044 
00045 ModelContainer::ModelContainer() {
00046 }
00047 
00048 
00049 returnValue ModelContainer::setDimensions( uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NDX3, uint _NXA, uint _NXA3, uint _NU, uint _NOD, uint _NP ) {
00050         return modelData.setDimensions( _NX1, _NX2, _NX3, _NDX, _NDX3, _NXA, _NXA3, _NU, _NOD, _NP );
00051 }
00052 
00053 
00054 returnValue ModelContainer::setDimensions( uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NXA, uint _NU, uint _NOD, uint _NP ) {
00055         return setDimensions( _NX1, _NX2, _NX3, _NDX, 0, _NXA, 0, _NU, _NOD, _NP );
00056 }
00057 
00058 
00059 returnValue ModelContainer::setDimensions( uint _NX, uint _NDX, uint _NXA, uint _NU, uint _NOD, uint _NP ) {
00060         return setDimensions( 0, _NX, 0, _NDX, _NXA, _NU, _NOD, _NP );
00061 }
00062 
00063 
00064 returnValue ModelContainer::setDimensions( uint _NX, uint _NU, uint _NOD, uint _NP ) {
00065         return setDimensions( _NX, 0, 0, _NU, _NOD, _NP );
00066 }
00067 
00068 returnValue ModelContainer::setModel( const DifferentialEquation& _f ) {
00069         return modelData.setModel( _f );
00070 }
00071 
00072 
00073 returnValue ModelContainer::setNARXmodel( const uint _delay, const DMatrix& _parms ) {
00074         return modelData.setNARXmodel( _delay, _parms );
00075 }
00076 
00077 
00078 returnValue ModelContainer::setModel(   const std::string& fileName, const std::string& _rhs_ODE, const std::string& _diffs_rhs_ODE ) {
00079         return modelData.setModel( fileName, _rhs_ODE, _diffs_rhs_ODE );
00080 }
00081 
00082 
00083 returnValue ModelContainer::setLinearInput( const DMatrix& M1_, const DMatrix& A1_, const DMatrix& B1_ )
00084 {
00085         return modelData.setLinearInput( M1_, A1_, B1_ );
00086 }
00087 
00088 
00089 returnValue ModelContainer::setLinearInput( const DMatrix& A1_, const DMatrix& B1_ )
00090 {
00091         DMatrix M1_ = eye<double>(A1_.getNumRows());
00092         return modelData.setLinearInput( M1_, A1_, B1_ );
00093 }
00094 
00095 
00096 returnValue ModelContainer::setLinearOutput( const DMatrix& M3_, const DMatrix& A3_, const OutputFcn& rhs3_ )
00097 {
00098         return modelData.setLinearOutput( M3_, A3_, rhs3_ );
00099 }
00100 
00101 
00102 returnValue ModelContainer::setLinearOutput( const DMatrix& A3_, const OutputFcn& rhs3_ )
00103 {
00104         DMatrix M3_ = eye<double>(A3_.getNumRows());
00105         return modelData.setLinearOutput( M3_, A3_, rhs3_ );
00106 }
00107 
00108 
00109 returnValue ModelContainer::setLinearOutput( const DMatrix& M3_, const DMatrix& A3_, const std::string& rhs3_, const std::string& diffs_rhs3_ )
00110 {
00111         return modelData.setLinearOutput( M3_, A3_, rhs3_, diffs_rhs3_ );
00112 }
00113 
00114 
00115 returnValue ModelContainer::setLinearOutput( const DMatrix& A3_, const std::string& rhs3_, const std::string& diffs_rhs3_ )
00116 {
00117         DMatrix M3_ = eye<double>(A3_.getNumRows());
00118         return modelData.setLinearOutput( M3_, A3_, rhs3_, diffs_rhs3_ );
00119 }
00120 
00121 
00122 uint ModelContainer::addOutput( const OutputFcn& outputEquation_, const DVector& measurements ) {
00123         DVector newMeas(measurements);
00124         newMeas.append( 1.0 );
00125         Grid grid( newMeas );
00126         return modelData.addOutput( outputEquation_, grid );
00127 }
00128 
00129 
00130 uint ModelContainer::addOutput( const OutputFcn& outputEquation_, const uint numberMeasurements ) {
00131         Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
00132         return modelData.addOutput( outputEquation_, grid );
00133 }
00134 
00135 
00136 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim, const DVector& measurements ) {
00137         DVector newMeas(measurements);
00138         newMeas.append( 1.0 );
00139         Grid grid( newMeas );
00140         return modelData.addOutput( output, diffs_output, dim, grid );
00141 }
00142 
00143 
00144 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim, const uint numberMeasurements ) {
00145         Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
00146         return modelData.addOutput( output, diffs_output, dim, grid );
00147 }
00148 
00149 
00150 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim,
00151                                                                 const DVector& measurements, const std::string& colInd, const std::string& rowPtr       ) {
00152         DVector newMeas(measurements);
00153         newMeas.append( 1.0 );
00154         Grid grid( newMeas );
00155         return modelData.addOutput( output, diffs_output, dim, grid, colInd, rowPtr );
00156 }
00157 
00158 
00159 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim,
00160                                                                 const uint numberMeasurements, const std::string& colInd, const std::string& rowPtr     ) {
00161         Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
00162         return modelData.addOutput( output, diffs_output, dim, grid, colInd, rowPtr );
00163 }
00164 
00165 
00166 returnValue ModelContainer::setIntegrationGrid( const Grid& _ocpGrid, const uint _numSteps ) {
00167         return modelData.setIntegrationGrid( _ocpGrid, _numSteps );
00168 }
00169 
00170 
00171 returnValue ModelContainer::getModel( DifferentialEquation &differentialEquation_ ) const {
00172 
00173     modelData.getModel(differentialEquation_);
00174     return SUCCESSFUL_RETURN;
00175 }
00176 
00177 
00178 BooleanType ModelContainer::hasOutputs() const {
00179 
00180         std::vector<Expression> outputExpressions_;
00181         modelData.getOutputExpressions(outputExpressions_);
00182     if( outputExpressions_.size() == 0 ) return BT_FALSE;
00183     return BT_TRUE;
00184 }
00185 
00186 
00187 BooleanType ModelContainer::hasDifferentialEquation() const {
00188 
00189         DifferentialEquation differentialEquation_;
00190         modelData.getModel(differentialEquation_);
00191     if( differentialEquation_.getDim() == 0 ) return BT_FALSE;
00192     return BT_TRUE;
00193 }
00194 
00195 
00196 BooleanType ModelContainer::modelDimensionsSet() const {
00197 
00198     return modelData.modelDimensionsSet();
00199 }
00200 
00201 
00202 BooleanType ModelContainer::hasEquidistantControlGrid() const {
00203 
00204     return modelData.hasEquidistantControlGrid();
00205 }
00206 
00207 
00208 BooleanType ModelContainer::exportRhs() const {
00209 
00210     return modelData.exportRhs();
00211 }
00212 
00213 
00214 uint ModelContainer::getNX( ) const
00215 {
00216         return modelData.getNX();
00217 }
00218 
00219 
00220 uint ModelContainer::getNDX( ) const
00221 {
00222         return modelData.getNDX();
00223 }
00224 
00225 
00226 uint ModelContainer::getNXA( ) const
00227 {
00228         return modelData.getNXA();
00229 }
00230 
00231 
00232 uint ModelContainer::getNU( ) const
00233 {
00234         return modelData.getNU();
00235 }
00236 
00237 
00238 uint ModelContainer::getNP( ) const
00239 {
00240         return modelData.getNP();
00241 }
00242 
00243 uint ModelContainer::getNOD( ) const
00244 {
00245         return modelData.getNOD();
00246 }
00247 
00248 
00249 uint ModelContainer::getN( ) const
00250 {
00251         return modelData.getN();
00252 }
00253 
00254 
00255 returnValue ModelContainer::setN( const uint N_ )
00256 {
00257         modelData.setN( N_ );
00258         return SUCCESSFUL_RETURN;
00259 }
00260 
00261 
00262 DVector ModelContainer::getDimOutputs( ) const
00263 {
00264         return modelData.getDimOutputs();
00265 }
00266 
00267 
00268 DVector ModelContainer::getNumMeas( ) const
00269 {
00270         return modelData.getNumMeas();
00271 }
00272 
00273 
00274 const std::string ModelContainer::getFileNameModel( ) const
00275 {
00276         return modelData.getFileNameModel();
00277 }
00278 
00279 
00280 ModelData& ModelContainer::getModelData( ) {
00281         return modelData;
00282 }
00283 
00284 
00285 returnValue ModelContainer::setModelData( const ModelData& data ) {
00286         modelData = data;
00287         return SUCCESSFUL_RETURN;
00288 }
00289 
00290 
00291 // PROTECTED:
00292 
00293 
00294 
00295 CLOSE_NAMESPACE_ACADO
00296 
00297 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:22