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
00043 #include "acado_optimal_control.hpp"
00044 #include <acado_gnuplot.hpp>
00045
00046
00047 int main( ){
00048
00049 USING_NAMESPACE_ACADO
00050
00051
00052
00053 #define Csin 2.8
00054
00055
00056
00057 DifferentialState x1,x2,x3,x4,x5;
00058 IntermediateState mu,sigma,pif;
00059 Control u ;
00060 Parameter tf ;
00061 DifferentialEquation f(0.0,tf) ;
00062
00063
00064
00065
00066 mu = 0.125*x2/x4;
00067 sigma = mu/0.135;
00068 pif = (-384.0*mu*mu + 134.0*mu);
00069
00070 f << dot(x1) == mu*x1;
00071 f << dot(x2) == -sigma*x1 + u*Csin;
00072 f << dot(x3) == pif*x1;
00073 f << dot(x4) == u;
00074 f << dot(x5) == 0.001*(u*u + 0.01*tf*tf);
00075
00076
00077
00078 OCP ocp( 0.0, tf, 50 );
00079 ocp.minimizeMayerTerm(0, 0.01*x5 -x3/tf );
00080 ocp.minimizeMayerTerm(1, 0.01*x5 -x3/(Csin*(x4-5.0)));
00081
00082 ocp.subjectTo( f );
00083
00084 ocp.subjectTo( AT_START, x1 == 0.1 );
00085 ocp.subjectTo( AT_START, x2 == 14.0 );
00086 ocp.subjectTo( AT_START, x3 == 0.0 );
00087 ocp.subjectTo( AT_START, x4 == 5.0 );
00088 ocp.subjectTo( AT_START, x5 == 0.0 );
00089 ocp.subjectTo( AT_END, x4 >= 5.0+20.0/Csin );
00090
00091 ocp.subjectTo( 0.0 <= x1 <= 15.0 );
00092 ocp.subjectTo( 0.0 <= x2 <= 30.0 );
00093 ocp.subjectTo( -0.1 <= x3 <= 1000.0 );
00094 ocp.subjectTo( 5.0 <= x4 <= 20.0 );
00095 ocp.subjectTo( 20.0 <= tf <= 40.0 );
00096 ocp.subjectTo( 0.0 <= u <= 2.0 );
00097
00098
00099
00100
00101 MultiObjectiveAlgorithm algorithm(ocp);
00102
00103 algorithm.set( PARETO_FRONT_DISCRETIZATION, 41 );
00104 algorithm.set( PARETO_FRONT_GENERATION , PFG_NORMALIZED_NORMAL_CONSTRAINT );
00105 algorithm.set( HESSIAN_APPROXIMATION , EXACT_HESSIAN );
00106
00107
00108 algorithm.set( KKT_TOLERANCE, 1e-8 );
00109
00110
00111 algorithm.solveSingleObjective(1);
00112
00113
00114 algorithm.solveSingleObjective(0);
00115
00116
00117 algorithm.set( KKT_TOLERANCE, 5.0e-6 );
00118 algorithm.solve();
00119
00120 algorithm.getWeights("fed_batch_bioreactor2_nnc_weights.txt");
00121 algorithm.getAllDifferentialStates("fed_batch_bioreactor2_nnc_states.txt");
00122 algorithm.getAllControls("fed_batch_bioreactor2_nnc_controls.txt");
00123 algorithm.getAllParameters("fed_batch_bioreactor2_nnc_parameters.txt");
00124
00125
00126
00127
00128 VariablesGrid paretoFront;
00129 algorithm.getParetoFront( paretoFront );
00130
00131 GnuplotWindow window1;
00132 window1.addSubplot( paretoFront, "Pareto Front (yield versus productivity)", "-PRODUCTIVTY", "-YIELD", PM_POINTS );
00133 window1.plot( );
00134
00135
00136
00137
00138 algorithm.printInfo();
00139
00140
00141
00142
00143 paretoFront.print();
00144
00145 return 0;
00146 }