examples/integrator/transition.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  Transition j;
51  TIME t;
52 
53  f << dot(x) == -x - 1.0;
54  j << x == x*x;
55 
56  // Define an integrator:
57  // ---------------------
58  IntegratorRK45 integrator;
59 
60  integrator.init( f, j );
61 
62 
63  // Define an initial value:
64  // ------------------------
65 
66  double x_start[1] = { 0.0 };
67 
68  double t_start = 0.0;
69  double t_end = 1.0;
70 
71 
72  // START THE INTEGRATION
73  // ----------------------
74  integrator.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
75  integrator.set( INTEGRATOR_TOLERANCE, 1.0e-6 );
76 
77  integrator.freezeAll();
78  integrator.integrate( t_start, t_end, x_start );
79 
80  DVector xEnd;
81  integrator.getX(xEnd);
82 
83  xEnd.print();
84 
85 
86  DVector seed(1);
87  seed(0) = 1.0;
88 
89  integrator.setBackwardSeed( 1, seed );
90 
91  integrator.integrateSensitivities();
92 
93  DVector dX(1), dP, dU, dW;
94 
95  integrator.getBackwardSensitivities( dX, dP, dU, dW, 1 );
96 
97  dX.print("dX ");
98 
99 
100  return 0;
101 }
102 /* <<< end tutorial code <<< */
returnValue getX(DVector &xEnd) const
virtual returnValue init(const DifferentialEquation &rhs_)
returnValue set(OptionsName name, int value)
#define USING_NAMESPACE_ACADO
virtual returnValue print(std::ostream &stream=std::cout, const std::string &name=DEFAULT_LABEL, const std::string &startString=DEFAULT_START_STRING, const std::string &endString=DEFAULT_END_STRING, uint width=DEFAULT_WIDTH, uint precision=DEFAULT_PRECISION, const std::string &colSeparator=DEFAULT_COL_SEPARATOR, const std::string &rowSeparator=DEFAULT_ROW_SEPARATOR) const
Definition: vector.cpp:97
virtual returnValue freezeAll()
Expression dot(const Expression &arg)
returnValue getBackwardSensitivities(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, int order) const
Definition: integrator.cpp:424
Implements the Runge-Kutta-45 scheme for integrating ODEs.
const double t_end
Allows to setup and evaluate transition functions based on SymbolicExpressions.
Definition: transition.hpp:53
const double t_start
returnValue integrateSensitivities()
Definition: integrator.cpp:357
returnValue setBackwardSeed(const int &order, const DVector &seed)
Definition: integrator.cpp:338
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:35:13