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 00027 00034 #ifndef ACADO_TOOLKIT_DYNAMIC_DISCRETIZATION_HPP 00035 #define ACADO_TOOLKIT_DYNAMIC_DISCRETIZATION_HPP 00036 00037 00038 #include <acado/utils/acado_utils.hpp> 00039 #include <acado/user_interaction/algorithmic_base.hpp> 00040 00041 #include <acado/dynamic_system/dynamic_system.hpp> 00042 #include <acado/variables_grid/grid.hpp> 00043 #include <acado/matrix_vector/matrix_vector.hpp> 00044 #include <acado/symbolic_expression/symbolic_expression.hpp> 00045 #include <acado/variables_grid/variables_grid.hpp> 00046 #include <acado/integrator/integrator.hpp> 00047 00048 00049 BEGIN_NAMESPACE_ACADO 00050 00051 00062 class DynamicDiscretization : public AlgorithmicBase 00063 { 00064 // 00065 // PUBLIC MEMBER FUNCTIONS: 00066 // 00067 00068 public: 00069 00071 DynamicDiscretization( ); 00072 00073 DynamicDiscretization( UserInteraction* _userInteraction 00074 ); 00075 00077 DynamicDiscretization( const DynamicDiscretization& rhs ); 00078 00080 virtual ~DynamicDiscretization( ); 00081 00083 DynamicDiscretization& operator=( const DynamicDiscretization& rhs ); 00084 00086 virtual DynamicDiscretization* clone() const = 0; 00087 00088 00089 00091 virtual returnValue addStage( const DynamicSystem &dynamicSystem_, 00092 const Grid &stageIntervals, 00093 const IntegratorType &integratorType_ = INT_UNKNOWN ) = 0; 00094 00096 virtual returnValue addTransition( const Transition& transition_ ) = 0; 00097 00098 00100 virtual returnValue clear() = 0; 00101 00102 00103 00115 virtual returnValue setForwardSeed( const BlockMatrix &xSeed_, 00116 const BlockMatrix &pSeed_, 00117 const BlockMatrix &uSeed_, 00118 const BlockMatrix &wSeed_ ); 00119 00120 00127 virtual returnValue setUnitForwardSeed(); 00128 00129 00130 00142 virtual returnValue setBackwardSeed( const BlockMatrix &seed ); 00143 00144 00145 00152 virtual returnValue setUnitBackwardSeed(); 00153 00154 00155 00161 virtual returnValue deleteAllSeeds(); 00162 00163 00164 00176 virtual returnValue evaluate( OCPiterate &iter ) = 0; 00177 00178 00179 00185 virtual returnValue evaluateSensitivities( ) = 0; 00186 00187 00188 00194 virtual returnValue evaluateSensitivities( const BlockMatrix &seed, BlockMatrix &hessian ) = 0; 00195 00196 00197 00203 virtual returnValue evaluateSensitivitiesLifted( ) = 0; 00204 00205 00206 00207 00212 virtual returnValue getResiduum( BlockMatrix &residuum_ ) const; 00213 00214 00215 00221 virtual returnValue getForwardSensitivities( BlockMatrix &D ) const; 00224 00225 00226 00232 virtual returnValue getBackwardSensitivities( BlockMatrix &D ) const; 00235 00236 00237 00239 inline int getNumberOfIntervals( ) const; 00240 00241 00242 00243 virtual BooleanType isAffine( ) const = 0; 00244 00245 00246 virtual returnValue unfreeze( ) = 0; 00247 00248 00249 // 00250 // PROTECTED MEMBER FUNCTIONS: 00251 // 00252 00253 protected: 00254 virtual returnValue setupOptions( ); 00255 virtual returnValue setupLogging( ); 00256 00257 void copy( const DynamicDiscretization& rhs ); 00258 void initializeVariables(); 00259 00260 uint getNumEvaluationPoints() const; 00261 00262 00263 // 00264 // PROTECTED MEMBERS: 00265 // 00266 00267 protected: 00268 00269 Grid unionGrid ; 00270 int N ; 00271 PrintLevel printLevel ; 00272 BooleanType freezeTraj ; 00275 // DIMENSIONS: 00276 // ----------- 00277 int nx; 00278 int na; 00279 int np; 00280 int nu; 00281 int nw; 00282 00283 00284 // INPUT STORAGE: 00285 // ------------------------ 00286 BlockMatrix xSeed ; 00287 BlockMatrix pSeed ; 00288 BlockMatrix uSeed ; 00289 BlockMatrix wSeed ; 00291 BlockMatrix bSeed ; 00294 // RESULTS: 00295 // ------------------------ 00296 VariablesGrid residuum ; 00297 BlockMatrix dForward ; 00298 BlockMatrix dBackward; 00300 }; 00301 00302 00303 CLOSE_NAMESPACE_ACADO 00304 00305 00306 00307 #include <acado/dynamic_discretization/dynamic_discretization.ipp> 00308 00309 //#include <acado/dynamic_discretization/simulation_algorithm.hpp> 00310 //#include <acado/dynamic_discretization/simulation_by_integration.hpp> 00311 //#include <acado/dynamic_discretization/simulation_by_collocation.hpp> 00312 #include <acado/dynamic_discretization/shooting_method.hpp> 00313 #include <acado/dynamic_discretization/collocation_method.hpp> 00314 00315 00316 #endif // ACADO_TOOLKIT_DYNAMIC_DISCRETIZATION_HPP 00317 00318 00319 // end of file