export_split_qpdunes_interface.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
33 #include <acado/code_generation/templates/templates.hpp>
34 
35 using namespace std;
36 
38 
40  const std::string& _commonHeaderName,
41  const std::string& _realString,
42  const std::string& _intString,
43  int _precision,
44  const std::string& _commentString
45  ) : ExportTemplatedFile(QPDUNES_SPLIT_TEMPLATE, _fileName, _commonHeaderName, _realString, _intString, _precision, _commentString)
46 {}
47 
49  const unsigned _printLevel,
50  const std::string& _HH,
51  const std::string& _g,
52  const std::string& _gN,
53  const std::string& _CC,
54  const std::string& _c,
55  const std::string& _DD,
56  const std::string& _lb0,
57  const std::string& _ub0,
58  const std::string& _lb,
59  const std::string& _ub,
60  const std::string& _lbA,
61  const std::string& _ubA,
62  const std::string& _primal,
63  const std::string& _lambda,
64  const std::string& _mu,
65  const std::vector< unsigned >& conDim,
66  const std::string& _initialStateFixed,
67  const std::string& _diagH,
68  const std::string& _diagHN,
69  const unsigned _NI,
70  const unsigned _NX,
71  const unsigned _NU
72 )
73 {
74  stringstream ss;
75 
76  // Configure the dictionary
77  dictionary[ "@MODULE_NAME@" ] = ExportStatement::fcnPrefix;
78  dictionary[ "@MODULE_PREFIX@" ] = ExportStatement::varPrefix;
79 
80  ss << _maxIter;
81  dictionary[ "@MAX_ITER@" ] = ss.str();
82 
83  ss.str( string() );
84  ss << _printLevel;
85  dictionary[ "@PRINT_LEVEL@" ] = ss.str();
86 
87  ss.str( string() );
88  ss << _NI;
89  dictionary[ "@ACADO_N@" ] = ss.str();
90 
91  ss.str( string() );
92  ss << _NX;
93  dictionary[ "@ACADO_NX@" ] = ss.str();
94 
95  ss.str( string() );
96  ss << _NU;
97  dictionary[ "@ACADO_NU@" ] = ss.str();
98 
99  dictionary[ "@QP_H@" ] = _HH;
100  dictionary[ "@QP_G@" ] = _g;
101  dictionary[ "@QP_G_N@" ] = _gN;
102  dictionary[ "@QP_C@" ] = _CC;
103  dictionary[ "@QP_c@" ] = _c;
104 
105  dictionary[ "@QP_LB@" ] = _lb;
106  dictionary[ "@QP_UB@" ] = _ub;
107 
108  dictionary[ "@QP_LB_0@" ] = _lb0;
109  dictionary[ "@QP_UB_0@" ] = _ub0;
110 
111  if (conDim.size() > 0)
112  {
113  dictionary[ "@QP_D@" ] = _DD;
114  dictionary[ "@QP_LBA@" ] = _lbA;
115  dictionary[ "@QP_UBA@" ] = _ubA;
116 
117  ss.str( string() );
118  ss << "unsigned int nD[";
119  ss << _NI;
120  ss << " + 1] = {";
121  for (unsigned i = 0; i < conDim.size(); ++i)
122  {
123  ss << conDim[ i ];
124  if (i < conDim.size() - 1)
125  ss << ", ";
126  }
127  ss << "};";
128  dictionary[ "@QP_ND_ARRAY@" ] = ss.str();
129  }
130  else
131  {
132  dictionary[ "@QP_D@" ] = dictionary[ "@QP_LBA@" ] = dictionary[ "@QP_UBA@" ] = "0";
133  ss.str( string() );
134  ss << "unsigned int nD[";
135  ss << _NI;
136  ss << " + 1]; for (kk = 0; kk < ";
137  ss << _NI;
138  ss << " + 1; nD[ kk++ ] = 0);";
139  dictionary[ "@QP_ND_ARRAY@" ] = ss.str();
140  }
141 
142  dictionary[ "@QP_PRIMAL@" ] = _primal;
143  dictionary[ "@QP_LAMBDA@" ] = _lambda;
144  dictionary[ "@QP_MU@" ] = _mu;
145 
146  dictionary[ "@INITIAL_STATE_FIXED@" ] = _initialStateFixed;
147 
148  dictionary[ "@DIAG_H@" ] = _diagH;
149  dictionary[ "@DIAG_HN@" ] = _diagHN;
150 
151  // And then fill a template file
152  fillTemplate();
153 
154  return SUCCESSFUL_RETURN;
155 }
156 
std::map< std::string, std::string > dictionary
ExportSplitQpDunesInterface(const std::string &_fileName, const std::string &_commonHeaderName="", const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16, const std::string &_commentString=std::string())
Allows to pass back messages to the calling function.
#define CLOSE_NAMESPACE_ACADO
Allows export of template files.
static std::string fcnPrefix
#define BEGIN_NAMESPACE_ACADO
virtual returnValue configure()
static std::string varPrefix


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:34