export_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 
39 ExportQpDunesInterface::ExportQpDunesInterface( const std::string& _fileName,
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_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 
78  ss << _maxIter;
79  dictionary[ "@MAX_ITER@" ] = ss.str();
80 
81  ss.str( string() );
82  ss << _printLevel;
83  dictionary[ "@PRINT_LEVEL@" ] = ss.str();
84 
85  ss.str( string() );
86  ss << _NI;
87  dictionary[ "@ACADO_N@" ] = ss.str();
88 
89  ss.str( string() );
90  ss << _NX;
91  dictionary[ "@ACADO_NX@" ] = ss.str();
92 
93  ss.str( string() );
94  ss << _NU;
95  dictionary[ "@ACADO_NU@" ] = ss.str();
96 
97  dictionary[ "@QP_H@" ] = _HH;
98  dictionary[ "@QP_G@" ] = _g;
99  dictionary[ "@QP_G_N@" ] = _gN;
100  dictionary[ "@QP_C@" ] = _CC;
101  dictionary[ "@QP_c@" ] = _c;
102 
103  dictionary[ "@QP_LB@" ] = _lb;
104  dictionary[ "@QP_UB@" ] = _ub;
105 
106  dictionary[ "@QP_LB_0@" ] = _lb0;
107  dictionary[ "@QP_UB_0@" ] = _ub0;
108 
109  if (conDim.size() > 0)
110  {
111  dictionary[ "@QP_D@" ] = _DD;
112  dictionary[ "@QP_LBA@" ] = _lbA;
113  dictionary[ "@QP_UBA@" ] = _ubA;
114 
115  ss.str( string() );
116  ss << "unsigned int nD[";
117  ss << _NI;
118  ss << " + 1] = {";
119  for (unsigned i = 0; i < conDim.size(); ++i)
120  {
121  ss << conDim[ i ];
122  if (i < conDim.size() - 1)
123  ss << ", ";
124  }
125  ss << "};";
126  dictionary[ "@QP_ND_ARRAY@" ] = ss.str();
127  }
128  else
129  {
130  dictionary[ "@QP_D@" ] = dictionary[ "@QP_LBA@" ] = dictionary[ "@QP_UBA@" ] = "0";
131  ss.str( string() );
132  ss << "unsigned int nD[";
133  ss << _NI;
134  ss << " + 1]; for (kk = 0; kk < ";
135  ss << _NI;
136  ss << " + 1; nD[ kk++ ] = 0);";
137  dictionary[ "@QP_ND_ARRAY@" ] = ss.str();
138  }
139 
140  dictionary[ "@QP_PRIMAL@" ] = _primal;
141  dictionary[ "@QP_LAMBDA@" ] = _lambda;
142  dictionary[ "@QP_MU@" ] = _mu;
143 
144  dictionary[ "@INITIAL_STATE_FIXED@" ] = _initialStateFixed;
145 
146  dictionary[ "@DIAG_H@" ] = _diagH;
147  dictionary[ "@DIAG_HN@" ] = _diagHN;
148 
149  // And then fill a template file
150  fillTemplate();
151 
152  return SUCCESSFUL_RETURN;
153 }
154 
std::map< std::string, std::string > dictionary
Allows to pass back messages to the calling function.
#define CLOSE_NAMESPACE_ACADO
Allows export of template files.
ExportQpDunesInterface(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())
#define BEGIN_NAMESPACE_ACADO
virtual returnValue configure()


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