catalyst_mixing_ennc.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 
00045 // IMPLEMENTATION:
00046 // ---------------
00047 
00048 #include <acado_optimal_control.hpp>
00049 #include <acado_gnuplot.hpp>
00050 
00051 
00052 /* >>> start tutorial code >>> */
00053 int main( ){
00054 
00055     USING_NAMESPACE_ACADO
00056 
00057     // INTRODUCE THE VARIABLES:
00058     // -------------------------
00059     DifferentialState     x1,x2,x3;
00060     Control               u;
00061 
00062     DifferentialEquation  f(0.0,1.0);
00063 
00064 
00065     // DEFINE A DIFFERENTIAL EQUATION:
00066     // -------------------------------
00067     f << dot(x1) == -u*(x1-10.0*x2);
00068     f << dot(x2) ==  u*(x1-10.0*x2)-(1.0-u)*x2;
00069     f << dot(x3) ==  u/10.0;
00070 
00071 
00072     // DEFINE AN OPTIMAL CONTROL PROBLEM:
00073     // ----------------------------------
00074     OCP ocp(0.0,1.0,25);
00075     ocp.minimizeMayerTerm( 0, -(1.0-x1-x2));
00076     ocp.minimizeMayerTerm( 1, x3          );
00077 
00078     ocp.subjectTo( f );
00079 
00080     ocp.subjectTo( AT_START, x1 == 1.0  );
00081     ocp.subjectTo( AT_START, x2 == 0.0  );
00082     ocp.subjectTo( AT_START, x3 == 0.0  );
00083 
00084     ocp.subjectTo(  0.0 <= x1 <= 1.0  );
00085     ocp.subjectTo(  0.0 <= x2 <= 1.0  );
00086     ocp.subjectTo(  0.0 <= x3 <= 1.0  );
00087     ocp.subjectTo(  0.0 <= u  <= 1.0  );
00088 
00089 
00090     // DEFINE A MULTI-OBJECTIVE ALGORITHM AND SOLVE THE OCP:
00091     // -----------------------------------------------------
00092     MultiObjectiveAlgorithm algorithm(ocp);
00093 
00094     algorithm.set( PARETO_FRONT_GENERATION    , PFG_ENHANCED_NORMALIZED_NORMAL_CONSTRAINT );
00095     algorithm.set( PARETO_FRONT_DISCRETIZATION, 11               );
00096     algorithm.set( HESSIAN_APPROXIMATION, EXACT_HESSIAN );
00097     //algorithm.set( PARETO_FRONT_HOTSTART, BT_FALSE        );
00098     //algorithm.set( DISCRETIZATION_TYPE, SINGLE_SHOOTING   );
00099     
00100     // Minimize individual objective function
00101     algorithm.solveSingleObjective(0);
00102 
00103     // Minimize individual objective function
00104     algorithm.solveSingleObjective(1);
00105 
00106     // Generate Pareto set
00107     algorithm.solve();
00108 
00109     algorithm.getWeights("catatlyst_mixing_ennc_weights.txt");
00110     algorithm.getAllDifferentialStates("catalyst_mixing_ennc_states.txt");
00111     algorithm.getAllControls("catalyst_mixing_ennc_controls.txt");
00112 
00113     // GET THE RESULT FOR THE PARETO FRONT AND PLOT IT:
00114     // ------------------------------------------------
00115     VariablesGrid paretoFront;
00116     algorithm.getParetoFront( paretoFront );
00117 
00118     GnuplotWindow window1;
00119     window1.addSubplot( paretoFront, "Pareto Front", "Conversion","Catalyst", PM_POINTS );
00120     window1.plot( );
00121 
00122 
00123     // PRINT INFORMATION ABOUT THE ALGORITHM:
00124     // --------------------------------------
00125     algorithm.printInfo();
00126 
00127 
00128     // SAVE INFORMATION:
00129     // -----------------
00130     paretoFront.print( "catalyst_mixing_ennc_pareto.txt" );
00131 
00132     return 0;
00133 }
00134 /* <<< end tutorial code <<< */
00135 


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