examples/integrator/getting_started.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 #include <acado_integrators.hpp>
37 
38 
39 
40 /* >>> start tutorial code >>> */
41 int main( ){
42 
43 
45 
46  // Define a Right-Hand-Side:
47  // -------------------------
50  TIME t;
51 
52  f << dot(x) == -x + sin(0.01*t);
53 
54 
55 
56  // Define an integrator:
57  // ---------------------
58  IntegratorBDF integrator( f );
59  integrator.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
60  integrator.set( INTEGRATOR_TOLERANCE, 1.0e-3 );
61 
62 
63  // Define an initial value:
64  // ------------------------
65 
66  double x_start[1] = { 1.0 };
67 
68  double t_start = 0.0;
69  double t_end = 1000.0;
70 
71 
72  // START THE INTEGRATION
73  // ----------------------
74 
75  //integrator.freezeAll();
76  integrator.integrate( t_start, t_end, x_start );
77 
78  integrator.printRunTimeProfile();
79 
80 
81  // GET THE RESULTS
82  // ---------------
83 
84  VariablesGrid differentialStates;
85  integrator.getX( differentialStates );
86 
87  differentialStates.print( "x" );
88 
89 
90  return 0;
91 }
92 /* <<< end tutorial code <<< */
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
returnValue print(std::ostream &stream=std::cout, const char *const name=DEFAULT_LABEL, const char *const startString=DEFAULT_START_STRING, const char *const endString=DEFAULT_END_STRING, uint width=DEFAULT_WIDTH, uint precision=DEFAULT_PRECISION, const char *const colSeparator=DEFAULT_COL_SEPARATOR, const char *const rowSeparator=DEFAULT_ROW_SEPARATOR) const
returnValue getX(DVector &xEnd) const
Implements the backward-differentiation formula for integrating DAEs.
returnValue set(OptionsName name, int value)
#define USING_NAMESPACE_ACADO
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Expression dot(const Expression &arg)
const double t_end
const double t_start
virtual returnValue printRunTimeProfile() const
Definition: integrator.cpp:624
returnValue integrate(double t0, double tend, double *x0, double *xa=0, double *p=0, double *u=0, double *w=0)
Definition: integrator.cpp:207
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.


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