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