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
00034 #include <acado_optimal_control.hpp>
00035 #include <acado_gnuplot.hpp>
00036
00037
00038
00039 int main( ){
00040
00041 USING_NAMESPACE_ACADO
00042
00043
00044
00045
00046 DifferentialState x , dx ;
00047 DifferentialState L , dL ;
00048 DifferentialState phi, dphi;
00049 DifferentialState P0,P1,P2 ;
00050
00051 Control ddx, ddL ;
00052 Parameter T ;
00053 Parameter gamma ;
00054
00055 double const g = 9.81;
00056 double const m = 10.0;
00057 double const b = 0.1 ;
00058
00059 DifferentialEquation f(0.0,T);
00060
00061 const double F2 = 50.0;
00062
00063
00064
00065
00066 f << dot(x ) == dx + 0.000001*gamma;
00067 f << dot(dx ) == ddx ;
00068 f << dot(L ) == dL ;
00069 f << dot(dL ) == ddL ;
00070 f << dot(phi ) == dphi;
00071 f << dot(dphi) == -(g/L)*phi - ( b + 2.0*dL/L )*dphi - ddx/L;
00072
00073 f << dot(P0) == 2.0*P1;
00074 f << dot(P1) == -(g/L)*P0 - ( b + 2.0*dL/L )*P1 + P2;
00075 f << dot(P2) == -2.0*(g/L)*P1 - 2.0*( b + 2.0*dL/L )*P2 + F2/(m*m*L*L);
00076
00077
00078
00079
00080 OCP ocp( 0.0, T, 20 );
00081 ocp.minimizeMayerTerm( 0, T );
00082 ocp.minimizeMayerTerm( 1, -gamma );
00083
00084 ocp.subjectTo( f );
00085
00086 ocp.subjectTo( AT_START, x == 0.0 );
00087 ocp.subjectTo( AT_START, dx == 0.0 );
00088 ocp.subjectTo( AT_START, L == 70.0 );
00089 ocp.subjectTo( AT_START, dL == 0.0 );
00090 ocp.subjectTo( AT_START, phi == 0.0 );
00091 ocp.subjectTo( AT_START, dphi == 0.0 );
00092
00093 ocp.subjectTo( AT_START, P0 == 0.0 );
00094 ocp.subjectTo( AT_START, P1 == 0.0 );
00095 ocp.subjectTo( AT_START, P2 == 0.0 );
00096
00097 ocp.subjectTo( AT_END , x == 10.0 );
00098 ocp.subjectTo( AT_END , dx == 0.0 );
00099 ocp.subjectTo( AT_END , L == 70.0 );
00100 ocp.subjectTo( AT_END , dL == 0.0 );
00101
00102 ocp.subjectTo( AT_END , -0.075 <= phi - gamma*sqrt(P0) );
00103 ocp.subjectTo( AT_END , phi + gamma*sqrt(P0) <= 0.075 );
00104
00105 ocp.subjectTo( gamma >= 0.0 );
00106
00107 ocp.subjectTo( 5.0 <= T <= 17.0 );
00108
00109 ocp.subjectTo( -0.3 <= ddx <= 0.3 );
00110 ocp.subjectTo( -1.0 <= ddL <= 1.0 );
00111
00112 ocp.subjectTo( -10.0 <= x <= 50.0 );
00113 ocp.subjectTo( -20.0 <= dx <= 20.0 );
00114 ocp.subjectTo( 30.0 <= L <= 75.0 );
00115 ocp.subjectTo( -20.0 <= dL <= 20.0 );
00116
00117
00118
00119
00120 MultiObjectiveAlgorithm algorithm(ocp);
00121
00122 algorithm.set( PARETO_FRONT_DISCRETIZATION, 31 );
00123 algorithm.set( PARETO_FRONT_GENERATION, PFG_NORMAL_BOUNDARY_INTERSECTION );
00124
00125
00126
00127 algorithm.solveSingleObjective(0);
00128
00129
00130 algorithm.solveSingleObjective(1);
00131
00132
00133
00134 algorithm.solve();
00135
00136 algorithm.getWeights("crane_nbi_weights.txt");
00137 algorithm.getAllDifferentialStates("crane_nbi_states.txt");
00138 algorithm.getAllControls("crane_nbi_controls.txt");
00139 algorithm.getAllParameters("crane_nbi_parameters.txt");
00140
00141
00142
00143
00144 VariablesGrid paretoFront;
00145 algorithm.getParetoFront( paretoFront );
00146
00147 GnuplotWindow window1;
00148 window1.addSubplot( paretoFront, "Pareto Front (robustness versus time)", "TIME","ROBUSTNESS", PM_POINTS );
00149 window1.plot( );
00150
00151
00152
00153
00154 algorithm.printInfo();
00155
00156
00157
00158
00159 paretoFront.print( "crane_nbi_pareto.txt" );
00160
00161 return 0;
00162 }
00163
00164