examples/integration_algorithm/getting_started_discretized.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 
35 
36 /* >>> start tutorial code >>> */
37 int main( ){
38 
40 
42  Control u;
43 
44  const double h = 0.01;
46 
47  const double tStart = 0.0;
48  const double tEnd = 1.0;
49 
50  Grid timeHorizon( tStart,tEnd );
51 
52 
53  // DEFINE A DIFFERENTIAL EQUATION:
54  // -------------------------------
55  f << next(x) == x - h*x + h*u*u;
56 
57 
58  // Define an integrator:
59  // ---------------------
60  IntegrationAlgorithm intAlg;
61 
62  intAlg.addStage( f, timeHorizon );
63 
64  intAlg.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
65 
66 
67  // Define an initial value:
68  // ------------------------
69 
70  DVector xStart( 1 );
71  xStart(0) = 1.0;
72 
73  DVector uStart( 1 );
74  uStart(0) = 1.0;
75 
76  DVector xaStart, pStart;
77 
78 
79  // START THE INTEGRATION
80  // ----------------------
81 
82  intAlg.integrate( timeHorizon, xStart, xaStart, pStart, uStart );
83 
84  // ----------------------
85 // DVector seed(1);
86 // seed(0) = 1.0;
87 //
88 // integrator.setForwardSeed( 1, emptyVector, emptyVector, seed );
89 // integrator.integrateSensitivities();
90 //
91 // integrator.setForwardSeed( 2, emptyVector, emptyVector, seed );
92 // integrator.integrateSensitivities();
93 //
94 //
95 // // GET THE RESULTS
96 // // ---------------
97 //
98 // VariablesGrid differentialStates;
99 // integrator.getX( differentialStates );
100 //
101 // DVector Dx( 1 );
102 // integrator.getForwardSensitivities( Dx,1 );
103 //
104 // differentialStates.print( "x" );
105 // Dx.print( "Dx" );
106 
107 
108  return 0;
109 }
110 /* <<< end tutorial code <<< */
#define USING_NAMESPACE_ACADO
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
returnValue integrate(VariablesGrid *x, VariablesGrid *xa, VariablesGrid *p, VariablesGrid *u, VariablesGrid *w)
Allows to setup and evaluate discretized differential equations based on SymbolicExpressions.
returnValue set(OptionsName name, int value)
Definition: options.cpp:126
User-interface to integrate a DynamicSystem, possibly over multiple stages.
Expression next(const Expression &arg)
virtual returnValue addStage(const DynamicSystem &dynamicSystem_, const Grid &stageIntervals, const IntegratorType &integratorType_=INT_UNKNOWN)


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