getting_started_discretized.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 
00026 
00027 
00034 #include <acado_optimal_control.hpp>
00035 
00036 /* >>> start tutorial code >>> */
00037 int main( ){
00038 
00039     USING_NAMESPACE_ACADO
00040 
00041     DifferentialState   x;
00042     Control             u;
00043 
00044     const double h = 0.01;
00045     DiscretizedDifferentialEquation f(h);
00046 
00047     const double tStart =  0.0;
00048     const double tEnd   =  1.0;
00049 
00050         Grid timeHorizon( tStart,tEnd );
00051 
00052 
00053     // DEFINE A DIFFERENTIAL EQUATION:
00054     // -------------------------------
00055     f << next(x) == x - h*x + h*u*u;
00056 
00057 
00058     // Define an integrator:
00059     // ---------------------
00060         IntegrationAlgorithm intAlg;
00061         
00062         intAlg.addStage( f, timeHorizon );
00063 
00064     intAlg.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
00065 
00066 
00067     // Define an initial value:
00068     // ------------------------
00069 
00070     DVector xStart( 1 );
00071         xStart(0) = 1.0;
00072     
00073         DVector uStart( 1 );
00074         uStart(0) = 1.0;
00075 
00076         DVector xaStart, pStart;
00077 
00078 
00079     // START THE INTEGRATION
00080     // ----------------------
00081 
00082     intAlg.integrate( timeHorizon, xStart, xaStart, pStart, uStart );
00083 
00084     // ----------------------
00085 //     DVector seed(1);
00086 //     seed(0) = 1.0;
00087 // 
00088 //     integrator.setForwardSeed( 1, emptyVector, emptyVector, seed );
00089 //     integrator.integrateSensitivities();
00090 // 
00091 //     integrator.setForwardSeed( 2, emptyVector, emptyVector, seed );
00092 //     integrator.integrateSensitivities();
00093 // 
00094 // 
00095 //     // GET THE RESULTS
00096 //     // ---------------
00097 // 
00098 //      VariablesGrid differentialStates;
00099 //      integrator.getX( differentialStates );
00100 // 
00101 //      DVector Dx( 1 );
00102 //      integrator.getForwardSensitivities( Dx,1 );
00103 //      
00104 //      differentialStates.print( "x" );
00105 //      Dx.print( "Dx" );
00106 
00107 
00108     return 0;
00109 }
00110 /* <<< end tutorial code <<< */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:24