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
00044 #include "acado_optimal_control.hpp"
00045 #include <acado_gnuplot.hpp>
00046
00047
00048 int main( ){
00049
00050 USING_NAMESPACE_ACADO
00051
00052
00053
00054 #define v 0.1
00055 #define L 1.0
00056 #define Beta 0.2
00057 #define Delta 0.25
00058 #define E 11250.0
00059 #define k0 1E+06
00060 #define R 1.986
00061 #define K1 250000.0
00062 #define Cin 0.02
00063 #define Tin 340.0
00064
00065
00066
00067
00068 DifferentialState x1,x2;
00069 Control u ;
00070 DifferentialEquation f( 0.0, L );
00071
00072
00073
00074
00075 double Alpha, Gamma;
00076 Alpha = k0*exp(-E/(R*Tin));
00077 Gamma = E/(R*Tin);
00078
00079 f << dot(x1) == Alpha /v * (1.0-x1) * exp((Gamma*x2)/(1.0+x2));
00080 f << dot(x2) == (Alpha*Delta)/v * (1.0-x1) * exp((Gamma*x2)/(1.0+x2)) + Beta/v * (u-x2);
00081
00082
00083
00084
00085 OCP ocp( 0.0, L, 50 );
00086 ocp.minimizeMayerTerm( 0, Cin*(1.0-x1) );
00087 ocp.minimizeMayerTerm( 1, (pow((Tin*x2),2.0)/K1) + 0.005*Cin*(1.0-x1) );
00088
00089
00090 ocp.subjectTo( f );
00091
00092 ocp.subjectTo( AT_START, x1 == 0.0 );
00093 ocp.subjectTo( AT_START, x2 == 0.0 );
00094
00095 ocp.subjectTo( 0.0 <= x1 <= 1.0 );
00096 ocp.subjectTo( (280.0-Tin)/Tin <= x2 <= (400.0-Tin)/Tin );
00097 ocp.subjectTo( (280.0-Tin)/Tin <= u <= (400.0-Tin)/Tin );
00098
00099
00100
00101
00102 MultiObjectiveAlgorithm algorithm(ocp);
00103
00104 algorithm.set( INTEGRATOR_TYPE, INT_BDF );
00105 algorithm.set( KKT_TOLERANCE, 1e-7 );
00106
00107 algorithm.set( PARETO_FRONT_GENERATION , PFG_NORMALIZED_NORMAL_CONSTRAINT );
00108 algorithm.set( PARETO_FRONT_DISCRETIZATION, 11 );
00109
00110
00111 algorithm.solveSingleObjective(0);
00112
00113
00114 algorithm.solveSingleObjective(1);
00115
00116
00117 algorithm.solve();
00118
00119 algorithm.getWeights("plug_flow_reactor_nnc_weights.txt");
00120 algorithm.getAllDifferentialStates("plug_flow_reactor_nnc_states.txt");
00121 algorithm.getAllControls("plug_flow_reactor_nnc_controls.txt");
00122
00123
00124
00125
00126 VariablesGrid paretoFront;
00127 algorithm.getParetoFront( paretoFront );
00128
00129 GnuplotWindow window1;
00130 window1.addSubplot( paretoFront, "Pareto Front (conversion versus energy)", "OUTLET CONCENTRATION", "ENERGY", PM_POINTS );
00131 window1.plot( );
00132
00133
00134
00135
00136 algorithm.printInfo();
00137
00138
00139
00140
00141 paretoFront.print();
00142
00143 return 0;
00144 }
00145
00146
00147