model_container.cpp
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 
34 
35 
37 
38 
39 
40 //
41 // PUBLIC MEMBER FUNCTIONS:
42 //
43 
44 
46  NU = 0;
47  NP = 0;
48  NOD = 0;
49 }
50 
51 
52 returnValue ModelContainer::setDimensions( uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NDX3, uint _NXA, uint _NXA3, uint _NU, uint _NOD, uint _NP ) {
53  return modelData.setDimensions( _NX1, _NX2, _NX3, _NDX, _NDX3, _NXA, _NXA3, _NU, _NOD, _NP );
54 }
55 
56 
57 returnValue ModelContainer::setDimensions( uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NXA, uint _NU, uint _NOD, uint _NP ) {
58  return setDimensions( _NX1, _NX2, _NX3, _NDX, 0, _NXA, 0, _NU, _NOD, _NP );
59 }
60 
61 
62 returnValue ModelContainer::setDimensions( uint _NX, uint _NDX, uint _NXA, uint _NU, uint _NOD, uint _NP ) {
63  return setDimensions( 0, _NX, 0, _NDX, _NXA, _NU, _NOD, _NP );
64 }
65 
66 
68  return setDimensions( _NX, 0, 0, _NU, _NOD, _NP );
69 }
70 
72  return modelData.setModel( _f );
73 }
74 
75 
76 returnValue ModelContainer::setNARXmodel( const uint _delay, const DMatrix& _parms ) {
77  return modelData.setNARXmodel( _delay, _parms );
78 }
79 
80 
81 returnValue ModelContainer::setModel( const std::string& fileName, const std::string& _rhs_ODE, const std::string& _diffs_rhs_ODE ) {
82  return modelData.setModel( fileName, _rhs_ODE, _diffs_rhs_ODE );
83 }
84 
85 
86 returnValue ModelContainer::setLinearInput( const DMatrix& M1_, const DMatrix& A1_, const DMatrix& B1_ )
87 {
88  return modelData.setLinearInput( M1_, A1_, B1_ );
89 }
90 
91 
93 {
94  DMatrix M1_ = eye<double>(A1_.getNumRows());
95  return modelData.setLinearInput( M1_, A1_, B1_ );
96 }
97 
98 
99 returnValue ModelContainer::setLinearOutput( const DMatrix& M3_, const DMatrix& A3_, const OutputFcn& rhs3_ )
100 {
101  return modelData.setLinearOutput( M3_, A3_, rhs3_ );
102 }
103 
104 
106 {
107  DMatrix M3_ = eye<double>(A3_.getNumRows());
108  return modelData.setLinearOutput( M3_, A3_, rhs3_ );
109 }
110 
111 
112 returnValue ModelContainer::setLinearOutput( const DMatrix& M3_, const DMatrix& A3_, const std::string& rhs3_, const std::string& diffs_rhs3_ )
113 {
114  return modelData.setLinearOutput( M3_, A3_, rhs3_, diffs_rhs3_ );
115 }
116 
117 
118 returnValue ModelContainer::setLinearOutput( const DMatrix& A3_, const std::string& rhs3_, const std::string& diffs_rhs3_ )
119 {
120  DMatrix M3_ = eye<double>(A3_.getNumRows());
121  return modelData.setLinearOutput( M3_, A3_, rhs3_, diffs_rhs3_ );
122 }
123 
124 
126 {
127  return modelData.setNonlinearFeedback( C_, feedb_ );
128 }
129 
130 
131 uint ModelContainer::addOutput( const OutputFcn& outputEquation_, const DVector& measurements ) {
132  DVector newMeas(measurements);
133  newMeas.append( 1.0 );
134  Grid grid( newMeas );
135  return modelData.addOutput( outputEquation_, grid );
136 }
137 
138 
139 uint ModelContainer::addOutput( const OutputFcn& outputEquation_, const uint numberMeasurements ) {
140  Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
141  return modelData.addOutput( outputEquation_, grid );
142 }
143 
144 
145 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim, const DVector& measurements ) {
146  DVector newMeas(measurements);
147  newMeas.append( 1.0 );
148  Grid grid( newMeas );
149  return modelData.addOutput( output, diffs_output, dim, grid );
150 }
151 
152 
153 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim, const uint numberMeasurements ) {
154  Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
155  return modelData.addOutput( output, diffs_output, dim, grid );
156 }
157 
158 
159 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim,
160  const DVector& measurements, const std::string& colInd, const std::string& rowPtr ) {
161  DVector newMeas(measurements);
162  newMeas.append( 1.0 );
163  Grid grid( newMeas );
164  return modelData.addOutput( output, diffs_output, dim, grid, colInd, rowPtr );
165 }
166 
167 
168 uint ModelContainer::addOutput( const std::string& output, const std::string& diffs_output, const uint dim,
169  const uint numberMeasurements, const std::string& colInd, const std::string& rowPtr ) {
170  Grid grid( 0.0, 1.0, (int)numberMeasurements + 1 );
171  return modelData.addOutput( output, diffs_output, dim, grid, colInd, rowPtr );
172 }
173 
174 
176  return modelData.getIntegrationGrid( _grid );
177 }
178 
179 
180 returnValue ModelContainer::setIntegrationGrid( const Grid& _ocpGrid, const uint _numSteps ) {
181  return modelData.setIntegrationGrid( _ocpGrid, _numSteps );
182 }
183 
184 
186 
187  modelData.getModel(differentialEquation_);
188  return SUCCESSFUL_RETURN;
189 }
190 
191 
193 
194  std::vector<Expression> outputExpressions_;
195  modelData.getOutputExpressions(outputExpressions_);
196  if( outputExpressions_.size() == 0 ) return BT_FALSE;
197  return BT_TRUE;
198 }
199 
200 
202 
203  DifferentialEquation differentialEquation_;
204  modelData.getModel(differentialEquation_);
205  if( differentialEquation_.getDim() == 0 ) return BT_FALSE;
206  return BT_TRUE;
207 }
208 
209 
211 
212  return modelData.modelDimensionsSet();
213 }
214 
215 
217 
219 }
220 
221 
223 
224  return modelData.exportRhs();
225 }
226 
227 
229 {
230  return modelData.getNX();
231 }
232 
233 
235 {
236  return modelData.getNDX();
237 }
238 
239 
241 {
242  return modelData.getNXA();
243 }
244 
245 
247 {
248  if( NU > 0 ) return NU;
249  return modelData.getNU();
250 }
251 
252 
254 {
255  if( NP > 0 ) return NP;
256  return modelData.getNP();
257 }
258 
260 {
261  if( NOD > 0 ) return NOD;
262  return modelData.getNOD();
263 }
264 
265 
267 {
268  return modelData.getN();
269 }
270 
271 
273 {
274  modelData.setN( N_ );
275  return SUCCESSFUL_RETURN;
276 }
277 
279 {
280  NU = NU_;
281  modelData.setNU( NU );
282  return SUCCESSFUL_RETURN;
283 }
284 
286 {
287  NP = NP_;
288  modelData.setNP( NP );
289  return SUCCESSFUL_RETURN;
290 }
291 
293 {
294  NOD = NOD_;
295  modelData.setNOD( NOD );
296  return SUCCESSFUL_RETURN;
297 }
298 
299 
301 {
302  return modelData.getDimOutputs();
303 }
304 
305 
307 {
308  return modelData.getNumMeas();
309 }
310 
311 
312 const std::string ModelContainer::getFileNameModel( ) const
313 {
314  return modelData.getFileNameModel();
315 }
316 
317 
319  return modelData;
320 }
321 
322 
324  modelData = data;
325  return SUCCESSFUL_RETURN;
326 }
327 
328 
329 // PROTECTED:
330 
331 
332 
334 
335 // end of file.
returnValue setLinearInput(const DMatrix &A1_, const DMatrix &B1_)
BooleanType exportRhs() const
uint getN() const
returnValue setIntegrationGrid(const Grid &_ocpGrid, const uint _numSteps)
Definition: model_data.cpp:396
uint addOutput(const OutputFcn &outputEquation_, const DVector &measurements)
Allows to setup and evaluate output functions based on SymbolicExpressions.
Definition: output_fcn.hpp:55
returnValue setNP(const uint NP_)
Definition: model_data.cpp:577
returnValue setLinearOutput(const DMatrix &A3_, const OutputFcn &rhs_)
DVector getNumMeas() const
Definition: model_data.cpp:614
BooleanType modelDimensionsSet() const
Definition: model_data.cpp:459
DVector getDimOutputs() const
Definition: model_data.cpp:591
returnValue getOutputExpressions(std::vector< Expression > &outputExpressions_) const
Definition: model_data.cpp:166
uint getNOD() const
BooleanType hasEquidistantControlGrid() const
Definition: model_data.cpp:439
returnValue setNonlinearFeedback(const DMatrix &C_, const OutputFcn &feedb_)
Definition: model_data.cpp:340
Allows to pass back messages to the calling function.
BooleanType modelDimensionsSet() const
returnValue setNU(const uint NU_)
Definition: model_data.cpp:570
returnValue getModel(DifferentialEquation &_f) const
Definition: model_data.cpp:203
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
uint getNU() const
DVector getDimOutputs() const
uint getNP() const
returnValue setModelData(const ModelData &data)
returnValue setLinearInput(const DMatrix &M1_, const DMatrix &A1_, const DMatrix &B1_)
Definition: model_data.cpp:309
#define CLOSE_NAMESPACE_ACADO
uint getNXA() const
Data class for defining models and everything that is related, to be passed to the integrator...
Definition: model_data.hpp:52
const std::string getFileNameModel() const
Definition: model_data.cpp:624
returnValue setModel(const DifferentialEquation &_f)
returnValue getModel(DifferentialEquation &_f) const
returnValue setN(const uint N_)
returnValue setNARXmodel(const uint _delay, const DMatrix &_parms)
uint addOutput(const OutputFcn &outputEquation_, const Grid &measurements)
Definition: model_data.cpp:80
uint getN() const
Definition: model_data.cpp:557
returnValue setLinearOutput(const DMatrix &M3_, const DMatrix &A3_, const OutputFcn &rhs_)
Definition: model_data.cpp:322
uint getNDX() const
Definition: model_data.cpp:507
returnValue setModel(const DifferentialEquation &_f)
Definition: model_data.cpp:253
returnValue getIntegrationGrid(Grid &integrationGrid_) const
Definition: model_data.cpp:389
BooleanType hasEquidistantControlGrid() const
returnValue setNOD(const uint NOD_)
Definition: model_data.cpp:584
int getDim() const
uint getNU() const
Definition: model_data.cpp:540
BooleanType hasOutputs() const
returnValue setIntegrationGrid(const Grid &_ocpGrid, const uint _numSteps)
returnValue setDimensions(uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NDX3, uint _NXA, uint _NXA3, uint _NU, uint _NOD, uint _NP)
returnValue setNARXmodel(const uint _delay, const DMatrix &_parms)
Definition: model_data.cpp:280
returnValue getIntegrationGrid(Grid &_grid) const
unsigned getNumRows() const
Definition: matrix.hpp:185
#define BT_TRUE
Definition: acado_types.hpp:47
GenericVector & append(const GenericVector &_arg)
Definition: vector.cpp:42
uint getNXA() const
Definition: model_data.cpp:525
uint getNDX() const
DVector getNumMeas() const
uint getNX() const
Definition: model_data.cpp:478
#define BEGIN_NAMESPACE_ACADO
returnValue setDimensions(uint _NX1, uint _NX2, uint _NX3, uint _NDX, uint _NDX3, uint _NXA, uint _NXA3, uint _NU, uint _NOD, uint _NP)
Definition: model_data.cpp:63
#define BT_FALSE
Definition: acado_types.hpp:49
USING_NAMESPACE_ACADO void output(const char *name, const Expression &e)
uint getNOD() const
Definition: model_data.cpp:551
returnValue setNOD(const uint NOD_)
uint getNP() const
Definition: model_data.cpp:546
ModelData & getModelData()
BooleanType exportRhs() const
Definition: model_data.cpp:465
returnValue setN(const uint N_)
Definition: model_data.cpp:563
const std::string getFileNameModel() const
returnValue setNonlinearFeedback(const DMatrix &C_, const OutputFcn &feedb_)
BooleanType hasDifferentialEquation() const
returnValue setNP(const uint NP_)
returnValue setNU(const uint NU_)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
uint getNX() const


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