examples/integration_algorithm/simple_dae.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_gnuplot.hpp>
37 
38 using namespace std;
39 
41 
42 /* >>> start tutorial code >>> */
43 int main( )
44 {
45  // DEFINE A RIGHT-HAND-SIDE:
46  // -------------------------
49  Parameter p,q;
50 
52 
53  f << dot(x) == -p*x*x*z ;
54  f << 0 == q*q - z*z + 0.1*x;
55 
56 
57  // DEFINE INITIAL VALUES:
58  // ----------------------
59 
60  DVector xStart( 1 );
61  xStart(0) = 1.0;
62 
63  DVector zStart( 1 );
64  zStart(0) = 1.0;
65 
66  DVector pp( 2 );
67  pp(0) = 1.0;
68  pp(1) = 1.0;
69 
70  double t0 = 0.0 ;
71  double tend = 1.0 ;
72 
73  Grid timeHorizon( t0,tend );
74 
75 
76  // DEFINE AN INTEGRATOR:
77  // ---------------------
78 
79  IntegrationAlgorithm intAlg;
80 
81  intAlg.addStage( f, timeHorizon );
82 
83  intAlg.set( INTEGRATOR_PRINTLEVEL, HIGH );
84 
85 
86  // START THE INTEGRATION:
87  // ----------------------
88 
89  //integrator.freezeAll();
90  intAlg.integrate( timeHorizon, xStart, zStart, pp );
91 
92 
93  // GET THE RESULTS
94  // ---------------
95 
96  VariablesGrid differentialStates;
97  VariablesGrid algebraicStates ;
98 
99 // intAlg.getX ( differentialStates );
100  intAlg.getLast( LOG_DIFFERENTIAL_STATES,differentialStates );
101  intAlg.getXA( algebraicStates );
102 
103  cout << "x = " << endl << differentialStates << endl;
104  cout << "z = " << endl << algebraicStates << endl;
105 
106  return 0;
107 }
108 /* <<< end tutorial code <<< */
109 
110 
#define USING_NAMESPACE_ACADO
Provides a time grid consisting of vector-valued optimization variables at each grid point...
USING_NAMESPACE_ACADO int main()
returnValue getXA(DVector &xaEnd) const
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)
returnValue set(OptionsName name, int value)
Definition: options.cpp:126
returnValue getLast(LogName _name, DMatrix &lastValue) const
User-interface to integrate a DynamicSystem, possibly over multiple stages.
Expression dot(const Expression &arg)
virtual returnValue addStage(const DynamicSystem &dynamicSystem_, const Grid &stageIntervals, const IntegratorType &integratorType_=INT_UNKNOWN)
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:04