Go to the documentation of this file.00001
00035 #include <acado_toolkit.hpp>
00036 #include <acado/utils/matlab_acado_utils.hpp>
00037
00038 USING_NAMESPACE_ACADO
00039
00040 void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
00041 {
00042 clearAllStaticCounters( );
00043
00044
00045
00046 DifferentialState s,v,m ;
00047 Control u ;
00048 Parameter T ;
00049 DifferentialEquation f( 0.0, T );
00050
00051
00052 OCP ocp( 0.0, T );
00053 ocp.minimizeMayerTerm( T );
00054
00055 f << dot(s) == v;
00056 f << dot(v) == (u-0.2*v*v)/m;
00057 f << dot(m) == -0.01*u*u;
00058
00059 ocp.subjectTo( f );
00060 ocp.subjectTo( AT_START, s == 0.0 );
00061 ocp.subjectTo( AT_START, v == 0.0 );
00062 ocp.subjectTo( AT_START, m == 1.0 );
00063
00064 ocp.subjectTo( AT_END , s == 10.0 );
00065 ocp.subjectTo( AT_END , v == 0.0 );
00066
00067 ocp.subjectTo( -0.1 <= v <= 1.7 );
00068 ocp.subjectTo( -1.1 <= u <= 1.1 );
00069 ocp.subjectTo( 5.0 <= T <= 15.0 );
00070
00071
00072 OptimizationAlgorithm algorithm(ocp);
00073 algorithm.solve();
00074
00075
00076
00077
00078 VariablesGrid states_out;
00079 algorithm.getDifferentialStates ( states_out );
00080 acadoPlot(states_out);
00081
00082 VariablesGrid controls_out;
00083 algorithm.getControls ( controls_out );
00084 acadoPlot(controls_out);
00085
00086
00087 clearAllStaticCounters( );
00088 }
00089