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
00061 DifferentialState x1,x2;
00062 Control u ;
00063 Parameter t1 ;
00064
00065 DifferentialEquation f(0.0,t1);
00066
00067
00068
00069
00070 f << dot(x1) == x2;
00071 f << dot(x2) == u;
00072
00073
00074
00075
00076 OCP ocp(0.0,t1,25);
00077 ocp.minimizeMayerTerm( 0, x2 );
00078 ocp.minimizeMayerTerm( 1, 2.0*t1/20.0);
00079
00080 ocp.subjectTo( f );
00081
00082 ocp.subjectTo( AT_START, x1 == 0.0 );
00083 ocp.subjectTo( AT_START, x2 == 0.0 );
00084 ocp.subjectTo( AT_END , x1 == 200.0 );
00085
00086 ocp.subjectTo( 0.0 <= x1 <= 200.0001 );
00087 ocp.subjectTo( 0.0 <= x2 <= 40.0 );
00088 ocp.subjectTo( 0.0 <= u <= 5.0 );
00089 ocp.subjectTo( 0.1 <= t1 <= 50.0 );
00090
00091
00092
00093
00094 MultiObjectiveAlgorithm algorithm(ocp);
00095
00096 algorithm.set( PARETO_FRONT_DISCRETIZATION, 11 );
00097 algorithm.set( PARETO_FRONT_GENERATION, PFG_NORMAL_BOUNDARY_INTERSECTION );
00098 algorithm.set( KKT_TOLERANCE, 1e-8 );
00099
00100
00101 algorithm.solveSingleObjective(0);
00102
00103
00104 algorithm.solveSingleObjective(1);
00105
00106
00107 algorithm.solve();
00108
00109 algorithm.getWeights("car_nbi_weights.txt");
00110 algorithm.getAllDifferentialStates("car_nbi_states.txt");
00111 algorithm.getAllControls("car_nbi_controls.txt");
00112 algorithm.getAllParameters("car_nbi_parameters.txt");
00113
00114
00115
00116
00117 VariablesGrid paretoFront;
00118 algorithm.getParetoFront( paretoFront );
00119
00120 GnuplotWindow window1;
00121 window1.addSubplot( paretoFront, "Pareto Front (time versus energy)", "ENERGY","TIME", PM_POINTS );
00122 window1.plot( );
00123
00124
00125
00126
00127 algorithm.printInfo();
00128
00129
00130
00131
00132 paretoFront.print( "car_nbi_pareto.txt" );
00133
00134 return 0;
00135 }
00136
00137