symbolic_algebra.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 
34 #include <acado_toolkit.hpp>
35 
36 using namespace std;
37 
39 
40 void output(const char* name, const Expression& e)
41 {
42  Function f;
43  f << e;
44 
45  ofstream stream( name );
46  stream << f;
47  stream.close();
48 }
49 
50 int main( ){
51 
53  IntermediateState y1=y0*2+1;
54  output("sym1.txt",y1);
55  y0=4;
56  output("sym2.txt",y1);
57  y0=2;
58  output("sym3.txt",y1);
59 
60  Expression E;
61  IntermediateState e1(1,3);e1(0)=1;e1(1)=2;e1(2)=3;
62  IntermediateState e2(1,3);e2(0)=-1;e2(1)=-2;e2(2)=-3;
63  // Thus doesn't work with DifferentialState e1(3);
64  E.appendRows(e1);
65  printf("Shape %d x %d\n",E.getNumRows(),E.getNumCols());
66  E.appendRows(e2);
67 
68  output("sym4.txt",E);
69 
70  return 0;
71 }
72 
73 
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
#define USING_NAMESPACE_ACADO
uint getNumCols() const
uint getNumRows() const
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
int main()
#define E
Expression & appendRows(const Expression &arg)
Definition: expression.cpp:141
USING_NAMESPACE_ACADO void output(const char *name, const Expression &e)


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