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
00046
00047
00048
00049 #include <acado_optimal_control.hpp>
00050 #include <acado_gnuplot.hpp>
00051
00052
00053
00054 int main( ){
00055
00056 USING_NAMESPACE_ACADO
00057
00058
00059
00060 DifferentialState x1,x2;
00061 Control u ;
00062 Parameter t1 ;
00063 DifferentialEquation f(0.0,t1);
00064
00065
00066
00067
00068 f << dot(x1) == x2;
00069 f << dot(x2) == u;
00070
00071
00072
00073
00074 OCP ocp(0.0,t1,25);
00075 ocp.minimizeMayerTerm( 0, x2 );
00076 ocp.minimizeMayerTerm( 1, 2.0*t1/20.0);
00077
00078 ocp.subjectTo( f );
00079
00080 ocp.subjectTo( AT_START, x1 == 0.0 );
00081 ocp.subjectTo( AT_START, x2 == 0.0 );
00082 ocp.subjectTo( AT_END , x1 == 200.0 );
00083
00084 ocp.subjectTo( 0.0 <= x1 <= 200.0001 );
00085 ocp.subjectTo( 0.0 <= x2 <= 40.0 );
00086 ocp.subjectTo( 0.0 <= u <= 5.0 );
00087 ocp.subjectTo( 0.1 <= t1 <= 50.0 );
00088
00089
00090
00091
00092 MultiObjectiveAlgorithm algorithm(ocp);
00093
00094 algorithm.set( PARETO_FRONT_GENERATION, PFG_NORMALIZED_NORMAL_CONSTRAINT );
00095 algorithm.set( PARETO_FRONT_DISCRETIZATION, 11 );
00096 algorithm.set( KKT_TOLERANCE, 1e-8 );
00097
00098
00099 algorithm.solveSingleObjective(0);
00100
00101
00102 algorithm.solveSingleObjective(1);
00103
00104
00105 algorithm.solve();
00106
00107 algorithm.getWeights("car_nnc_weights.txt");
00108 algorithm.getAllDifferentialStates("car_nnc_states.txt");
00109 algorithm.getAllControls("car_nnc_controls.txt");
00110 algorithm.getAllParameters("car_nnc_parameters.txt");
00111
00112
00113
00114
00115 VariablesGrid paretoFront;
00116 algorithm.getParetoFront( paretoFront );
00117
00118 GnuplotWindow window1;
00119 window1.addSubplot( paretoFront, "Pareto Front (time versus energy)", "ENERGY","TIME", PM_POINTS );
00120 window1.plot( );
00121
00122 printf("\n\n");
00123 printf("-------------------------------------------\n\n");
00124 printf("Pay off matrix: \n");
00125 (algorithm.getPayOffMatrix()).print();
00126 printf("\n\n");
00127 printf("Utopia vector: \n");
00128 (algorithm.getUtopiaVector()).print();
00129 printf("\n\n");
00130 printf("-------------------------------------------\n\n");
00131
00132
00133
00134
00135 algorithm.printInfo();
00136
00137
00138
00139
00140 paretoFront.print( "car_nnc_pareto.txt" );
00141
00142 return 0;
00143 }
00144
00145