dynamic_discretization.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 
27 
36 
37 
38 
40 
41 
42 
43 
44 //
45 // PUBLIC MEMBER FUNCTIONS:
46 //
47 
49  :AlgorithmicBase( ){
50 
51  setupOptions( );
52  setupLogging( );
53 
55 }
56 
57 
58 
60  :AlgorithmicBase( _userInteraction ){
61 
62  // setup options and loggings for stand-alone instances
63  if ( _userInteraction == 0 ){
64 
65  setupOptions( );
66  setupLogging( );
67  }
69 }
70 
71 
73  : AlgorithmicBase( arg ){
74 
76 }
77 
78 
80 
81 
83 
84  if ( this != &arg ){
87  }
88  return *this;
89 }
90 
91 
93  const BlockMatrix &pSeed_,
94  const BlockMatrix &uSeed_,
95  const BlockMatrix &wSeed_ ){
96 
97  xSeed = xSeed_;
98  pSeed = pSeed_;
99  uSeed = uSeed_;
100  wSeed = wSeed_;
101 
102  return SUCCESSFUL_RETURN;
103 }
104 
105 
107 
108  BlockMatrix xSeed_( N, 1 );
109  BlockMatrix pSeed_( N, 1 );
110  BlockMatrix uSeed_( N, 1 );
111  BlockMatrix wSeed_( N, 1 );
112 
113  int run1;
114  for( run1 = 0; run1 < N; run1++ ){
115  xSeed_.setIdentity( run1, 0, nx );
116  pSeed_.setIdentity( run1, 0, np );
117  uSeed_.setIdentity( run1, 0, nu );
118  wSeed_.setIdentity( run1, 0, nw );
119  }
120  return setForwardSeed( xSeed_, pSeed_, uSeed_, wSeed_ );
121 }
122 
123 
124 
126 
127  bSeed = seed;
128  return SUCCESSFUL_RETURN;
129 }
130 
131 
133 
134  BlockMatrix seed( 1, N );
135  int run1;
136  for( run1 = 0; run1 < N; run1++ )
137  seed.setIdentity( 0, run1, nx );
138 
139  return setBackwardSeed( seed );
140 }
141 
142 
143 
145 
146  int run1;
147  uint run2;
148 
149  residuum_.init( N, 1 );
150 
151  for( run1 = 0; run1 < N; run1++ ){
152  DMatrix tmp( residuum.getNumValues(), 1 );
153  for( run2 = 0; run2 < residuum.getNumValues(); run2++ )
154  tmp( run2, 0 ) = residuum(run1,run2);
155  residuum_.setDense(run1,0,tmp);
156  }
157 
158  return SUCCESSFUL_RETURN;
159 }
160 
161 
163 
164  D = dForward;
165  return SUCCESSFUL_RETURN;
166 }
167 
168 
170 
171  D = dBackward;
172  return SUCCESSFUL_RETURN;
173 }
174 
175 
177 
178  BlockMatrix empty;
179  setBackwardSeed( empty );
180  setForwardSeed( empty, empty, empty, empty );
181  return SUCCESSFUL_RETURN;
182 }
183 
184 
185 
186 //
187 // PROTECTED MEMBER FUNCTIONS:
188 //
189 
191 
192  // add integration options
196 
197  // add integrator options
210 
211  return SUCCESSFUL_RETURN;
212 }
213 
214 
216 {
217  LogRecord tmp( LOG_AT_END );
218 
221  tmp.addItem( LOG_PARAMETERS );
222  tmp.addItem( LOG_CONTROLS );
223  tmp.addItem( LOG_DISTURBANCES );
225 
228 
230 
231  return SUCCESSFUL_RETURN;
232 }
233 
235 
236  N = 0 ;
237  printLevel = LOW ;
238 
239  nx = 0 ;
240  na = 0 ;
241  np = 0 ;
242  nu = 0 ;
243  nw = 0 ;
244 }
245 
247 
248  N = arg.N ;
249  nx = arg.nx;
250  na = arg.na;
251  np = arg.np;
252  nu = arg.nu;
253  nw = arg.nw;
254 
255  unionGrid = arg.unionGrid ;
256  printLevel = arg.printLevel;
257  residuum = arg.residuum ;
258 
259  xSeed = arg.xSeed ;
260  pSeed = arg.pSeed ;
261  uSeed = arg.uSeed ;
262  wSeed = arg.wSeed ;
263 
264  bSeed = arg.bSeed ;
265 
266  dForward = arg.dForward ;
267  dBackward = arg.dBackward;
268 }
269 
270 
272 
273  uint nEvaluationPoints = 0;
274  uint nShoot = unionGrid.getNumIntervals();
275 
276  int plotResolution;
277  get( PLOT_RESOLUTION,plotResolution );
278 
279  switch ( (PrintLevel) plotResolution ) {
280 
281  case LOW : nEvaluationPoints = (uint)(10.0 / sqrt((double)nShoot) + 2.0); break;
282  case MEDIUM: nEvaluationPoints = (uint)(30.0 / sqrt((double)nShoot) + 2.0); break;
283  case HIGH : nEvaluationPoints = (uint)(100.0 / sqrt((double)nShoot) + 2.0); break;
284  default : nEvaluationPoints = (uint)(10.0 / sqrt((double)nShoot) + 2.0); break;
285  }
286  return nEvaluationPoints;
287 }
288 
289 
290 
292 
293 // end of file.
virtual returnValue getForwardSensitivities(BlockMatrix &D) const
Implements a very rudimentary block sparse matrix class.
const int defaultFeasibilityCheck
returnValue addItem(LogName _name, const char *const _label=DEFAULT_LABEL)
Definition: log_record.cpp:70
IntermediateState sqrt(const Expression &arg)
virtual returnValue getResiduum(BlockMatrix &residuum_) const
const double defaultRelaxationParameter
const double defaultMaxStepsize
returnValue setDense(uint rowIdx, uint colIdx, const DMatrix &value)
const int defaultFreezeIntegrator
Allows to pass back messages to the calling function.
AlgorithmicBase & operator=(const AlgorithmicBase &rhs)
Base class for all algorithmic modules within the ACADO Toolkit providing some basic functionality...
virtual returnValue setBackwardSeed(const BlockMatrix &seed)
const double defaultStepsizeTuning
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
const double defaultMinStepsize
DynamicDiscretization & operator=(const DynamicDiscretization &rhs)
const int defaultMaxNumSteps
virtual returnValue deleteAllSeeds()
#define CLOSE_NAMESPACE_ACADO
Base class for discretizing a DifferentialEquation for use in optimal control algorithms.
const double defaultIntegratorTolerance
const int defaultIntegratorPrintlevel
virtual returnValue setUnitForwardSeed()
virtual returnValue setupOptions()
returnValue init(uint _nRows, uint _nCols)
const double defaultCorrectorTolerance
Encapsulates all user interaction for setting options, logging data and plotting results.
PrintLevel
const double defaultInitialStepsize
const int defaultAlgebraicRelaxation
uint getNumIntervals() const
virtual returnValue setForwardSeed(const BlockMatrix &xSeed_, const BlockMatrix &pSeed_, const BlockMatrix &uSeed_, const BlockMatrix &wSeed_)
Allows to setup and store user-specified log records of algorithmic information.
Definition: log_record.hpp:72
#define BEGIN_NAMESPACE_ACADO
int addLogRecord(LogRecord &_record)
const int defaultPlotResoltion
const int defaultLinearAlgebraSolver
virtual returnValue getBackwardSensitivities(BlockMatrix &D) const
virtual returnValue setUnitBackwardSeed()
returnValue addOption(OptionsName name, int value)
returnValue setIdentity(uint rowIdx, uint colIdx, uint dim)
virtual returnValue setupLogging()
const double defaultAbsoluteTolerance
void copy(const DynamicDiscretization &rhs)


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