Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #include <acado_optimal_control.hpp>
00036 #include <acado_gnuplot.hpp>
00037
00038
00039 int main( ){
00040
00041 USING_NAMESPACE_ACADO
00042
00043
00044
00045 DifferentialState x;
00046 DifferentialState l;
00047 AlgebraicState z;
00048 Control u;
00049 DifferentialEquation f;
00050
00051 const double t_start = 0.0;
00052 const double t_end = 10.0;
00053
00054
00055
00056 f << dot(x) == -x + 0.5*x*x + u + 0.5*z;
00057 f << dot(l) == x*x + 3.0*u*u ;
00058 f << 0 == z + exp(z) - 1.0 + x ;
00059
00060
00061
00062
00063 OCP ocp( t_start, t_end, 10 );
00064 ocp.minimizeMayerTerm( l );
00065
00066 ocp.subjectTo( f );
00067 ocp.subjectTo( AT_START, x == 1.0 );
00068 ocp.subjectTo( AT_START, l == 0.0 );
00069
00070 GnuplotWindow window;
00071 window.addSubplot(x,"DIFFERENTIAL STATE x");
00072 window.addSubplot(z,"ALGEBRAIC STATE z" );
00073 window.addSubplot(u,"CONTROL u" );
00074
00075
00076
00077
00078 OptimizationAlgorithm algorithm(ocp);
00079
00080 algorithm.set( ABSOLUTE_TOLERANCE , 1.0e-7 );
00081 algorithm.set( INTEGRATOR_TOLERANCE , 1.0e-7 );
00082 algorithm.set( HESSIAN_APPROXIMATION, EXACT_HESSIAN );
00083
00084
00085 algorithm << window;
00086 algorithm.solve();
00087
00088 return 0;
00089 }
00090
00091
00092