symbolic_differentiation1.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00032 #include <acado/utils/acado_utils.hpp>
00033 #include <acado/user_interaction/user_interaction.hpp>
00034 #include <acado/symbolic_expression/symbolic_expression.hpp>
00035 #include <acado/function/function.hpp>
00036 
00037 using namespace std;
00038 
00039 USING_NAMESPACE_ACADO
00040 
00041 /* >>> start tutorial code >>> */
00042 int main()
00043 {
00044         // DEFINE VALRIABLES:
00045         // ---------------------------
00046         DifferentialState x;
00047         IntermediateState y;
00048         IntermediateState z;
00049 
00050         Function f;
00051 
00052         // DEFINE A TEST FUNCTION:
00053         // -----------------------
00054         y = x * x;
00055 
00056         f << cos(x);
00057         f << sin(x);
00058         f << forwardDerivative(sin(x), x);
00059         f << forwardDerivative(cos(x), x);
00060         f << forwardDerivative(x * x, x);
00061         f << forwardDerivative(y, x);
00062         f << forwardDerivative(y + x * y, x);
00063         f << x + forwardDerivative(x + y * y, x);
00064         f << forwardDerivative(y * y + 1.0 / y, x);
00065         f << forwardDerivative(sqrt(x), x);
00066         f << forwardDerivative(log(x), x);
00067 
00068         f << laplace(x * y, x);
00069 
00070 //      DifferentialState z(2);
00071 //
00072 //      f << forwardDerivative(sin(z), z);
00073 //      f << backwardDerivative(z(0) * z(0) + z(1) * z(1) * 3.0, z);
00074 
00075         f << backwardDerivative(cos(y) + sin(y), x);
00076 
00077         ofstream stream( "symbolic_differentiation1_output.txt" );
00078         stream << f;
00079         stream.close();
00080 
00081 //      // TEST THE FUNCTION f:
00082 //      // --------------------
00083 //      double xx[3] = { 1.0, 1.0, 1.0 };
00084 //      double *result = new double[f.getDim()];
00085 //
00086 //      // EVALUATE f AT THE POINT  (tt,xx):
00087 //      // ---------------------------------
00088 //      f.evaluate(0.0, xx, result, MEDIUM);
00089 //
00090 //      delete[] result;
00091 
00092         return 0;
00093 }
00094 /* <<< end tutorial code <<< */
00095 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 12:01:10