plug_flow_reactor2_nbi.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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     // INTRODUCE FIXED PARAMETERS:
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  K3         30.0
00062     #define  Cin        0.02
00063     #define  Tin        340.0
00064 
00065 
00066     // INTRODUCE THE VARIABLES:
00067     // -------------------------
00068     DifferentialState     x1,x2,x3;
00069     Control               u    ;
00070     DifferentialEquation  f( 0.0, L );
00071 
00072 
00073     // DEFINE A DIFFERENTIAL EQUATION:
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     f << dot(x3) == 1.0/K3*Beta/L*(u-x2);
00082 
00083 
00084     // DEFINE AN OPTIMAL CONTROL PROBLEM:
00085     // ----------------------------------
00086     OCP ocp( 0.0, L, 50 );
00087     ocp.minimizeMayerTerm( 0, Cin*(1.0-x1)   ); // Solve conversion optimal problem
00088     ocp.minimizeMayerTerm( 1, x3             ); // Solve energy optimal problem
00089 
00090     ocp.subjectTo( f );
00091 
00092     ocp.subjectTo( AT_START, x1 ==  0.0 );
00093     ocp.subjectTo( AT_START, x2 ==  0.0 );
00094     ocp.subjectTo( AT_START, x3 ==  0.0 );
00095 
00096     ocp.subjectTo(  0.0            <= x1 <=  1.0             );
00097     ocp.subjectTo( (280.0-Tin)/Tin <= x2 <= (400.0-Tin)/Tin  );
00098     ocp.subjectTo( (280.0-Tin)/Tin <= u  <= (400.0-Tin)/Tin  );
00099 
00100 
00101     // DEFINE A MULTI-OBJECTIVE ALGORITHM AND SOLVE THE OCP:
00102     // -----------------------------------------------------
00103     MultiObjectiveAlgorithm algorithm(ocp);
00104 
00105     algorithm.set( INTEGRATOR_TYPE, INT_BDF );
00106     algorithm.set( KKT_TOLERANCE, 1e-8 );
00107 
00108     algorithm.set( PARETO_FRONT_GENERATION    , PFG_NORMAL_BOUNDARY_INTERSECTION );
00109     algorithm.set( PARETO_FRONT_DISCRETIZATION, 11               );
00110 
00111 
00112     // Minimize individual objective function
00113     algorithm.solveSingleObjective(0);
00114 
00115     algorithm.getDifferentialStates("pfr_nominal_states0.txt");
00116     algorithm.getControls("pfr_nominal_controls0.txt");
00117 
00118 
00119 
00120     // Minimize individual objective function
00121     algorithm.solveSingleObjective(1);
00122 
00123     // Generate Pareto set   
00124     algorithm.solve();
00125 
00126 //     algorithm.getWeights("plug_flow_reactor2_nbi_weights.txt");
00127 //     algorithm.getAllDifferentialStates("plug_flow_reactor2_nbi_states.txt");
00128 //     algorithm.getAllControls("plug_flow_reactor2_nbi_controls.txt");
00129 
00130 
00131 
00132     // VISUALIZE THE RESULTS IN A GNUPLOT WINDOW:
00133     // ------------------------------------------
00134     VariablesGrid paretoFront;
00135     algorithm.getParetoFront( paretoFront );
00136 
00137     GnuplotWindow window1;
00138     window1.addSubplot( paretoFront, "Pareto Front (conversion versus energy)", "OUTLET CONCENTRATION","ENERGY", PM_POINTS );
00139     window1.plot( );
00140 
00141 
00142     // PRINT INFORMATION ABOUT THE ALGORITHM:
00143     // --------------------------------------
00144     algorithm.printInfo();
00145 
00146 
00147     // SAVE INFORMATION:
00148     // ----------------
00149     paretoFront.print();
00150 
00151     return 0;
00152 }
00153 
00154 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:49