export_qpdunes_interface.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 
00032 #include <acado/code_generation/export_qpdunes_interface.hpp>
00033 #include <acado/code_generation/templates/templates.hpp>
00034 
00035 using namespace std;
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 ExportQpDunesInterface::ExportQpDunesInterface( const std::string& _fileName,
00040                                                                                                 const std::string& _commonHeaderName,
00041                                                                                                 const std::string& _realString,
00042                                                                                                 const std::string& _intString,
00043                                                                                                 int _precision,
00044                                                                                                 const std::string& _commentString
00045                                                 ) : ExportTemplatedFile(QPDUNES_TEMPLATE, _fileName, _commonHeaderName, _realString, _intString, _precision, _commentString)
00046 {}
00047 
00048 returnValue ExportQpDunesInterface::configure(  const unsigned _maxIter,
00049                                                                                                 const unsigned _printLevel,
00050                                                                                                 const std::string& _HH,
00051                                                                                                 const std::string& _g,
00052                                                                                                 const std::string& _gN,
00053                                                                                                 const std::string& _CC,
00054                                                                                                 const std::string& _c,
00055                                                                                                 const std::string& _DD,
00056                                                                                                 const std::string& _lb0,
00057                                                                                                 const std::string& _ub0,
00058                                                                                                 const std::string& _lb,
00059                                                                                                 const std::string& _ub,
00060                                                                                                 const std::string& _lbA,
00061                                                                                                 const std::string& _ubA,
00062                                                                                                 const std::string& _primal,
00063                                                                                                 const std::string& _lambda,
00064                                                                                                 const std::string& _mu,
00065                                                                                                 const std::vector< unsigned >& conDim,
00066                                                                                                 const std::string& _initialStateFixed,
00067                                                                                                 const std::string& _diagH,
00068                                                                                                 const std::string& _diagHN
00069 )
00070 {
00071         stringstream ss;
00072 
00073         // Configure the dictionary
00074 
00075         ss << _maxIter;
00076         dictionary[ "@MAX_ITER@" ] =  ss.str();
00077 
00078         ss.str( string() );
00079         ss << _printLevel;
00080         dictionary[ "@PRINT_LEVEL@" ] =  ss.str();
00081 
00082         dictionary[ "@QP_H@" ] =  _HH;
00083         dictionary[ "@QP_G@" ] =  _g;
00084         dictionary[ "@QP_G_N@" ] =  _gN;
00085         dictionary[ "@QP_C@" ] =  _CC;
00086         dictionary[ "@QP_c@" ] =  _c;
00087 
00088         dictionary[ "@QP_LB@" ] =  _lb;
00089         dictionary[ "@QP_UB@" ] =  _ub;
00090 
00091         dictionary[ "@QP_LB_0@" ] =  _lb0;
00092         dictionary[ "@QP_UB_0@" ] =  _ub0;
00093 
00094         if (conDim.size() > 0)
00095         {
00096                 dictionary[ "@QP_D@" ]   =  _DD;
00097                 dictionary[ "@QP_LBA@" ] =  _lbA;
00098                 dictionary[ "@QP_UBA@" ] =  _ubA;
00099 
00100                 ss.str( string() );
00101                 ss << "const unsigned int nD[ACADO_N + 1] = {";
00102                 for (unsigned i = 0; i < conDim.size(); ++i)
00103                 {
00104                         ss << conDim[ i ];
00105                         if (i < conDim.size() - 1)
00106                                 ss << ", ";
00107                 }
00108                 ss << "};";
00109                 dictionary[ "@QP_ND_ARRAY@" ] = ss.str();
00110         }
00111         else
00112         {
00113                 dictionary[ "@QP_D@" ] = dictionary[ "@QP_LBA@" ] = dictionary[ "@QP_UBA@" ] = "0";
00114                 dictionary[ "@QP_ND_ARRAY@" ] = "unsigned int nD[ACADO_N + 1]; for (kk = 0; kk < ACADO_N + 1; nD[ kk++ ] = 0);";
00115         }
00116 
00117         dictionary[ "@QP_PRIMAL@" ] =  _primal;
00118         dictionary[ "@QP_LAMBDA@" ] =  _lambda;
00119         dictionary[ "@QP_MU@" ] =  _mu;
00120 
00121         dictionary[ "@INITIAL_STATE_FIXED@" ] = _initialStateFixed;
00122 
00123         dictionary[ "@DIAG_H@" ] = _diagH;
00124         dictionary[ "@DIAG_HN@" ] = _diagHN;
00125 
00126         // And then fill a template file
00127         fillTemplate();
00128 
00129         return SUCCESSFUL_RETURN;
00130 }
00131 
00132 CLOSE_NAMESPACE_ACADO


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:37:01