Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00033 #ifndef ACADO_TOOLKIT_OPTIMIZATION_ALGORITHM_BASE_HPP
00034 #define ACADO_TOOLKIT_OPTIMIZATION_ALGORITHM_BASE_HPP
00035
00036 #include <acado/matrix_vector/matrix_vector.hpp>
00037 #include <acado/variables_grid/variables_grid.hpp>
00038
00039 #include <acado/nlp_solver/nlp_solver.hpp>
00040 #include <acado/nlp_solver/scp_method.hpp>
00041
00042
00043 BEGIN_NAMESPACE_ACADO
00044
00045 class OCP;
00046
00047
00065 class OptimizationAlgorithmBase
00066 {
00067
00068
00069
00070 public:
00071
00073 OptimizationAlgorithmBase();
00074
00076 OptimizationAlgorithmBase( const OCP& ocp_ );
00077
00079 OptimizationAlgorithmBase( const OptimizationAlgorithmBase& arg );
00080
00082 virtual ~OptimizationAlgorithmBase( );
00083
00085 OptimizationAlgorithmBase& operator=( const OptimizationAlgorithmBase& arg );
00086
00087
00089 returnValue initializeDifferentialStates( const char* fileName , BooleanType autoinit=BT_FALSE);
00090 returnValue initializeAlgebraicStates ( const char* fileName , BooleanType autoinit=BT_FALSE);
00091 returnValue initializeParameters ( const char* fileName);
00092 returnValue initializeControls ( const char* fileName);
00093 returnValue initializeDisturbances ( const char* fileName);
00094
00095 returnValue initializeDifferentialStates( const VariablesGrid &xd_init_ , BooleanType autoinit=BT_FALSE);
00096 returnValue initializeAlgebraicStates ( const VariablesGrid &xa_init_ , BooleanType autoinit=BT_FALSE);
00097 returnValue initializeParameters ( const VariablesGrid &u_init_);
00098 returnValue initializeControls ( const VariablesGrid &p_init_);
00099 returnValue initializeDisturbances ( const VariablesGrid &w_init_);
00100
00105 returnValue simulateStatesForInitialization();
00106
00107 returnValue getDifferentialStates( VariablesGrid &xd_ ) const;
00108 returnValue getAlgebraicStates ( VariablesGrid &xa_ ) const;
00109 returnValue getParameters ( VariablesGrid &u_ ) const;
00110 returnValue getParameters ( DVector &u_ ) const;
00111 returnValue getControls ( VariablesGrid &p_ ) const;
00112 returnValue getDisturbances ( VariablesGrid &w_ ) const;
00113
00114 returnValue getDifferentialStates( const char* fileName ) const;
00115 returnValue getAlgebraicStates ( const char* fileName ) const;
00116 returnValue getParameters ( const char* fileName ) const;
00117 returnValue getControls ( const char* fileName ) const;
00118 returnValue getDisturbances ( const char* fileName ) const;
00119
00120 double getObjectiveValue ( const char* fileName ) const;
00121 double getObjectiveValue () const;
00122
00123
00124 returnValue getSensitivitiesX( BlockMatrix& _sens
00125 ) const;
00126
00127 returnValue getSensitivitiesXA( BlockMatrix& _sens
00128 ) const;
00129
00130 returnValue getSensitivitiesP( BlockMatrix& _sens
00131 ) const;
00132
00133 returnValue getSensitivitiesU( BlockMatrix& _sens
00134 ) const;
00135
00136 returnValue getSensitivitiesW( BlockMatrix& _sens
00137 ) const;
00138
00139
00142 virtual uint getNX( ) const;
00143
00146 virtual uint getNXA( ) const;
00147
00150 virtual uint getNP( ) const;
00151
00154 virtual uint getNU( ) const;
00155
00158 virtual uint getNW( ) const;
00159
00160
00161 double getStartTime ( ) const;
00162
00163 double getEndTime( ) const;
00164
00165
00166
00167
00168
00169 protected:
00170
00171 returnValue clear( );
00172
00174 returnValue init( UserInteraction* _userIteraction
00175 );
00176
00177 BooleanType isLinearQuadratic( Objective *F,
00178 DynamicDiscretization *G,
00179 Constraint *H
00180 ) const;
00181
00182 virtual returnValue allocateNlpSolver( Objective *F,
00183 DynamicDiscretization *G,
00184 Constraint *H
00185 ) = 0;
00186
00187 virtual returnValue initializeNlpSolver( const OCPiterate& _userInit
00188 ) = 0;
00189
00190 virtual returnValue initializeObjective( Objective* F
00191 ) = 0;
00192
00193
00194 virtual returnValue extractOCPdata( Objective** objective,
00195 DifferentialEquation*** differentialEquation,
00196 Constraint** constraint,
00197 Grid& unionGrid
00198 );
00199
00200 virtual returnValue setupObjective( Objective* objective,
00201 DifferentialEquation** differentialEquation,
00202 Constraint* constraint,
00203 Grid unionGrid
00204 );
00205
00206 virtual returnValue setupDifferentialEquation( Objective* objective,
00207 DifferentialEquation** differentialEquation,
00208 Constraint* constraint,
00209 Grid unionGrid
00210 );
00211
00212 virtual returnValue setupDynamicDiscretization( UserInteraction* _userIteraction,
00213 Objective* objective,
00214 DifferentialEquation** differentialEquation,
00215 Constraint* constraint,
00216 Grid unionGrid,
00217 DynamicDiscretization** dynamicDiscretization
00218 );
00219
00220 virtual returnValue determineDimensions( Objective* const _objective,
00221 DifferentialEquation** const _differentialEquation,
00222 Constraint* const _constraint,
00223 uint& _nx,
00224 uint& _nxa,
00225 uint& _np,
00226 uint& _nu,
00227 uint& _nw
00228 ) const;
00229
00230 virtual returnValue initializeOCPiterate( Constraint* const _constraint,
00231 const Grid& _unionGrid,
00232 uint nx,
00233 uint nxa,
00234 uint np,
00235 uint nu,
00236 uint nw
00237 );
00238
00239
00240
00241
00242 protected:
00243
00244 NLPsolver *nlpSolver ;
00245 OCP *ocp ;
00246
00247 OCPiterate iter;
00248 OCPiterate userInit;
00249 };
00250
00251 CLOSE_NAMESPACE_ACADO
00252
00253 #endif // ACADO_TOOLKIT_OPTIMIZATION_ALGORITHM_BASE_HPP
00254
00255
00256
00257