export_gauss_newton_qpdunes.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 
34 
36 
37 using namespace std;
38 
40  const std::string& _commonHeaderName
41  ) : ExportNLPSolver( _userInteraction,_commonHeaderName )
42 {}
43 
45 {
46  LOG( LVL_DEBUG ) << "Solver: setup initialization... " << endl;
48 
49  //
50  // Add QP initialization call to the initialization
51  //
52  ExportFunction initializeQpDunes( "initializeQpDunes" );
54  << "ret = (int)initializeQpDunes();\n"
55  << "if ((return_t)ret != QPDUNES_OK) return ret;\n";
56 
57  cleanup.setup( "cleanupSolver" );
58  ExportFunction cleanupQpDunes( "cleanupQpDunes" );
59  cleanupQpDunes.setName( "cleanupQpDunes" );
60  cleanup.addFunctionCall( cleanupQpDunes );
61  LOG( LVL_DEBUG ) << "done!" << endl;
62 
63  LOG( LVL_DEBUG ) << "Solver: setup setupVariables... " << endl;
65  LOG( LVL_DEBUG ) << "done!" << endl;
66 
67  LOG( LVL_DEBUG ) << "Solver: setup setupSimulation... " << endl;
69  LOG( LVL_DEBUG ) << "done!" << endl;
70 
71  LOG( LVL_DEBUG ) << "Solver: setup setupObjectiveEvaluation... " << endl;
73  LOG( LVL_DEBUG ) << "done!" << endl;
74 
75  LOG( LVL_DEBUG ) << "Solver: setup setupConstraintsEvaluation... " << endl;
77  LOG( LVL_DEBUG ) << "done!" << endl;
78 
79  LOG( LVL_DEBUG ) << "Solver: setup setupEvaluation... " << endl;
81  LOG( LVL_DEBUG ) << "done!" << endl;
82 
83  LOG( LVL_DEBUG ) << "Solver: setup setupAuxiliaryFunctions... " << endl;
85  LOG( LVL_DEBUG ) << "done!" << endl;
86 
87  return SUCCESSFUL_RETURN;
88 }
89 
91  ExportStruct dataStruct
92  ) const
93 {
94  returnValue status;
95  status = ExportNLPSolver::getDataDeclarations(declarations, dataStruct);
96  if (status != SUCCESSFUL_RETURN)
97  return status;
98 
99  declarations.addDeclaration(x0, dataStruct);
100 
101  declarations.addDeclaration(qpH, dataStruct);
102  declarations.addDeclaration(qpg, dataStruct);
103  declarations.addDeclaration(qpgN, dataStruct);
104  declarations.addDeclaration(qpLb0, dataStruct);
105  declarations.addDeclaration(qpUb0, dataStruct);
106  declarations.addDeclaration(qpLb, dataStruct);
107  declarations.addDeclaration(qpUb, dataStruct);
108  declarations.addDeclaration(lbValues, dataStruct);
109  declarations.addDeclaration(ubValues, dataStruct);
110  declarations.addDeclaration(qpC, dataStruct);
111  declarations.addDeclaration(qpc, dataStruct);
112 
113  declarations.addDeclaration(qpA, dataStruct);
114  declarations.addDeclaration(qpLbA, dataStruct);
115  declarations.addDeclaration(qpUbA, dataStruct);
116 
117  declarations.addDeclaration(qpPrimal, dataStruct);
118  declarations.addDeclaration(qpLambda, dataStruct);
119  declarations.addDeclaration(qpMu, dataStruct);
120 
121  // lagrange multipliers
122  declarations.addDeclaration(mu, dataStruct);
123 
124  return SUCCESSFUL_RETURN;
125 }
126 
128  ) const
129 {
130  declarations.addDeclaration( preparation );
131  declarations.addDeclaration( feedback );
132 
133  declarations.addDeclaration( initialize );
134  declarations.addDeclaration( initializeNodes );
135  declarations.addDeclaration( shiftStates );
136  declarations.addDeclaration( shiftControls );
137  declarations.addDeclaration( getKKT );
138  declarations.addDeclaration( getObjective );
139 
140  declarations.addDeclaration( cleanup );
141  declarations.addDeclaration( shiftQpData );
142 
143  declarations.addDeclaration( evaluateStageCost );
144  declarations.addDeclaration( evaluateTerminalCost );
145 
146  return SUCCESSFUL_RETURN;
147 }
148 
150  )
151 {
153  code.addStatement( *qpInterface );
154 
155  code.addLinebreak( 2 );
156  code.addStatement( "/******************************************************************************/\n" );
157  code.addStatement( "/* */\n" );
158  code.addStatement( "/* ACADO code generation */\n" );
159  code.addStatement( "/* */\n" );
160  code.addStatement( "/******************************************************************************/\n" );
161  code.addLinebreak( 2 );
162 
163  int useOMP;
164  get(CG_USE_OPENMP, useOMP);
165  if ( useOMP )
166  {
167  code.addDeclaration( state );
168  }
169 
171 
174  code.addFunction( setObjQ1Q2 );
175  code.addFunction( setObjR1R2 );
176  code.addFunction( setObjQN1QN2 );
177  code.addFunction( setStageH );
178  code.addFunction( setStagef );
180 
182 
183  for (unsigned i = 0; i < evaluatePointConstraints.size(); ++i)
184  {
185  if (evaluatePointConstraints[ i ] == 0)
186  continue;
188  }
189 
190  code.addFunction( setStagePac );
191 
193 
194  code.addFunction( acc );
195 
196  code.addFunction( preparation );
197  code.addFunction( feedback );
198 
199  code.addFunction( initialize );
201  code.addFunction( shiftStates );
202  code.addFunction( shiftControls );
203  code.addFunction( getKKT );
204  code.addFunction( getObjective );
205 
206  code.addFunction( cleanup );
207  code.addFunction( shiftQpData );
208 
209  return SUCCESSFUL_RETURN;
210 }
211 
212 
214 {
215  return (N + 1) * NX + N * NU;
216 }
217 
218 //
219 // PROTECTED FUNCTIONS:
220 //
221 
223 {
224  if (S1.getGivenMatrix().isZero() == false)
226  "Mixed control-state terms in the objective function are not supported at the moment.");
227 
228  evaluateObjective.setup("evaluateObjective");
229 
230  int variableObjS;
231  get(CG_USE_VARIABLE_WEIGHTING_MATRIX, variableObjS);
232 
233  //
234  // A loop the evaluates objective and corresponding gradients
235  //
236  ExportIndex runObj( "runObj" );
237  ExportForLoop loopObjective(runObj, 0, N);
238 
239  evaluateObjective.addIndex( runObj );
240 
241  loopObjective.addStatement( objValueIn.getCols(0, getNX()) == x.getRow( runObj ) );
242  loopObjective.addStatement( objValueIn.getCols(NX, NX + NU) == u.getRow( runObj ) );
243  loopObjective.addStatement( objValueIn.getCols(NX + NU, NX + NU + NOD) == od.getRow( runObj ) );
244  loopObjective.addLinebreak( );
245 
246  // Evaluate the objective function
248 
249  // Stack the measurement function value
250  loopObjective.addStatement(
251  Dy.getRows(runObj * NY, (runObj + 1) * NY) == objValueOut.getTranspose().getRows(0, getNY())
252  );
253  loopObjective.addLinebreak( );
254 
255  // Optionally compute derivatives
256 
257  ExportVariable tmpObjS, tmpFx, tmpFu;
258  ExportVariable tmpFxEnd, tmpObjSEndTerm;
259 
260  tmpObjS.setup("tmpObjS", NY, NY, REAL, ACADO_LOCAL);
261  if (objS.isGiven() == true)
262  tmpObjS = objS;
263  tmpFx.setup("tmpFx", NY, NX, REAL, ACADO_LOCAL);
264  if (objEvFx.isGiven() == true)
265  tmpFx = objEvFx;
266  tmpFu.setup("tmpFu", NY, NU, REAL, ACADO_LOCAL);
267  if (objEvFu.isGiven() == true)
268  tmpFu = objEvFu;
269  tmpFxEnd.setup("tmpFx", NYN, NX, REAL, ACADO_LOCAL);
270  if (objEvFxEnd.isGiven() == true)
271  tmpFxEnd = objEvFxEnd;
272  tmpObjSEndTerm.setup("tmpObjSEndTerm", NYN, NYN, REAL, ACADO_LOCAL);
273  if (objSEndTerm.isGiven() == true)
274  tmpObjSEndTerm = objSEndTerm;
275 
276  unsigned indexX = getNY();
277  ExportArgument tmpFxCall = tmpFx;
278  if (tmpFx.isGiven() == false)
279  {
280  tmpFxCall = objValueOut.getAddress(0, indexX);
281  indexX += objEvFx.getDim();
282  }
283 
284  ExportArgument tmpFuCall = tmpFu;
285  if (tmpFu.isGiven() == false)
286  {
287  tmpFuCall = objValueOut.getAddress(0, indexX);
288  }
289 
290  ExportArgument objSCall = variableObjS == true ? objS.getAddress(runObj * NY, 0) : objS;
291 
292  //
293  // Optional computation of Q1, Q2
294  //
295  if (Q1.isGiven() == false)
296  {
297  ExportVariable tmpQ1, tmpQ2;
298  tmpQ1.setup("tmpQ1", NX, NX, REAL, ACADO_LOCAL);
299  tmpQ2.setup("tmpQ2", NX, NY, REAL, ACADO_LOCAL);
300 
301  setObjQ1Q2.setup("setObjQ1Q2", tmpFx, tmpObjS, tmpQ1, tmpQ2);
302  setObjQ1Q2.addStatement( tmpQ2 == (tmpFx ^ tmpObjS) );
303  setObjQ1Q2.addStatement( tmpQ1 == tmpQ2 * tmpFx );
304 
305  loopObjective.addFunctionCall(
306  setObjQ1Q2,
307  tmpFxCall, objSCall,
308  Q1.getAddress(runObj * NX, 0), Q2.getAddress(runObj * NX, 0)
309  );
310 
311  loopObjective.addLinebreak( );
312  }
313 
314  if (R1.isGiven() == false)
315  {
316  ExportVariable tmpR1, tmpR2;
317  tmpR1.setup("tmpR1", NU, NU, REAL, ACADO_LOCAL);
318  tmpR2.setup("tmpR2", NU, NY, REAL, ACADO_LOCAL);
319 
320  setObjR1R2.setup("setObjR1R2", tmpFu, tmpObjS, tmpR1, tmpR2);
321  setObjR1R2.addStatement( tmpR2 == (tmpFu ^ tmpObjS) );
322  setObjR1R2.addStatement( tmpR1 == tmpR2 * tmpFu );
323 
324  loopObjective.addFunctionCall(
325  setObjR1R2,
326  tmpFuCall, objSCall,
327  R1.getAddress(runObj * NU, 0), R2.getAddress(runObj * NU, 0)
328  );
329 
330  loopObjective.addLinebreak( );
331  }
332 
333  evaluateObjective.addStatement( loopObjective );
334 
335  //
336  // Evaluate the quadratic Mayer term
337  //
340 
341  // Evaluate the objective function, last node.
344 
347 
348  if (QN1.isGiven() == false)
349  {
350  ExportVariable tmpQN1, tmpQN2;
351  tmpQN1.setup("tmpQN1", NX, NX, REAL, ACADO_LOCAL);
352  tmpQN2.setup("tmpQN2", NX, NYN, REAL, ACADO_LOCAL);
353 
354  setObjQN1QN2.setup("setObjQN1QN2", tmpFxEnd, tmpObjSEndTerm, tmpQN1, tmpQN2);
355  setObjQN1QN2.addStatement( tmpQN2 == (tmpFxEnd ^ tmpObjSEndTerm) );
356  setObjQN1QN2.addStatement( tmpQN1 == tmpQN2 * tmpFxEnd );
357 
358  indexX = getNYN();
359  ExportArgument tmpFxEndCall = tmpFxEnd.isGiven() == true ? tmpFxEnd : objValueOut.getAddress(0, indexX);
360 
362  setObjQN1QN2,
363  tmpFxEndCall, objSEndTerm,
364  QN1.getAddress(0, 0), QN2.getAddress(0, 0)
365  );
366 
368  }
369 
370  //
371  // Hessian setup
372  //
373 
374  // LM regularization preparation
375 
376  ExportVariable evLmX = zeros<double>(NX, NX);
377  ExportVariable evLmU = zeros<double>(NU, NU);
378 
379  if (levenbergMarquardt > 0.0)
380  {
381  DMatrix lmX = eye<double>( NX );
382  lmX *= levenbergMarquardt;
383 
384  DMatrix lmU = eye<double>( NU );
385  lmU *= levenbergMarquardt;
386 
387  evLmX = lmX;
388  evLmU = lmU;
389  }
390 
391  // Interface variable to qpDUNES
392  qpH.setup("qpH", N * (NX + NU) * (NX + NU) + NX * NX, 1, REAL, ACADO_WORKSPACE);
393 
394  ExportVariable stageH;
395  ExportIndex index( "index" );
396  stageH.setup("stageH", NX + NU, NX + NU, REAL, ACADO_LOCAL);
397  setStageH.setup("setStageH", stageH, index);
398 
399  if (Q1.isGiven() == false)
401  stageH.getSubMatrix(0, NX, 0, NX) == Q1.getSubMatrix(index * NX, (index + 1) * NX, 0, NX) + evLmX
402  );
403  else
404  {
405  setStageH.addStatement( index == index );
407  stageH.getSubMatrix(0, NX, 0, NX) == Q1 + evLmX
408  );
409  }
411 
412  if (R1.isGiven() == false)
414  stageH.getSubMatrix(NX, NX + NU, NX, NX + NU) == R1.getSubMatrix(index * NU, (index + 1) * NU, 0, NU) + evLmU
415  );
416  else
418  stageH.getSubMatrix(NX, NX + NU, NX, NX + NU) == R1 + evLmU
419  );
420 
421  if (Q1.isGiven() == true && R1.isGiven() == true)
422  {
423  for (unsigned i = 0; i < N; ++i)
424  {
426  setStageH, qpH.getAddress(i * (NX + NU) * (NX + NU)), ExportIndex( i ));
427  }
430  qpH.getTranspose().getCols(N * (NX + NU) * (NX + NU), N * (NX + NU) * (NX + NU) + NX * NX) == QN1.makeRowVector() + evLmX.makeRowVector()
431  );
432  }
433  else
434  {
435  for (unsigned i = 0; i < N; ++i)
436  {
438  setStageH, qpH.getAddress(i * (NX + NU) * (NX + NU)), ExportIndex( i ));
439  }
442  qpH.getTranspose().getCols(N * (NX + NU) * (NX + NU), N * (NX + NU) * (NX + NU) + NX * NX) == QN1.makeRowVector() + evLmX.makeRowVector()
443  );
444  }
445 
446  //
447  // Gradient setup
448  //
449  int sensitivityProp;
450  get( DYNAMIC_SENSITIVITY, sensitivityProp );
451  bool adjoint = ((ExportSensitivityType) sensitivityProp == BACKWARD);
452 
453  // Interface variable to qpDUNES
454  qpg.setup("qpG", N * (NX + NU) + NX, 1, REAL, ACADO_WORKSPACE);
455 
456  ExportVariable stagef;
457  stagef.setup("stagef", NX + NU, 1, REAL, ACADO_LOCAL);
458  setStagef.setup("setStagef", stagef, index);
459 
460  if (Q2.isGiven() == false)
462  stagef.getRows(0, NX) == Q2.getSubMatrix(index * NX, (index + 1) * NX, 0, NY) *
463  Dy.getRows(index * NY, (index + 1) * NY)
464  );
465  else
466  {
467  setStagef.addStatement( index == index );
469  stagef.getRows(0, NX) == Q2 *
470  Dy.getRows(index * NY, (index + 1) * NY)
471  );
472  }
473  if( adjoint ) {
474  setStagef.addStatement( stagef.getRows(0, NX) += objSlx.getRows( index*NX, index*NX+NX ) );
475  }
477 
478  if (R2.isGiven() == false)
480  stagef.getRows(NX, NX + NU) == R2.getSubMatrix(index * NU, (index + 1) * NU, 0, NY) *
481  Dy.getRows(index * NY, (index + 1) * NY)
482  );
483  else
484  {
486  stagef.getRows(NX, NX + NU) == R2 *
487  Dy.getRows(index * NY, (index + 1) * NY)
488  );
489  }
490  if( adjoint ) {
491  setStagef.addStatement( stagef.getRows(NX, NX+NU) += objSlu.getRows( index*NU, index*NU+NU ) );
492  }
493 
494  // A buffer given to update the last node's gradient
495  if (initialStateFixed() == false)
496  qpgN.setup("qpgN", NX, 1, REAL, ACADO_WORKSPACE);
497 
498  return SUCCESSFUL_RETURN;
499 }
500 
502 {
504  //
505  // Setup evaluation of box constraints on states and controls
506  //
508 
509  int hardcodeConstraintValues;
510  get(CG_HARDCODE_CONSTRAINT_VALUES, hardcodeConstraintValues);
511 
512  if (initialStateFixed() == true)
513  {
514  qpLb0.setup("qpLb0", 1, NX + NU, REAL, ACADO_WORKSPACE);
515  qpUb0.setup("qpUb0", 1, NX + NU, REAL, ACADO_WORKSPACE);
516  }
517  qpLb.setup("qpLb", 1, N * (NX + NU) + NX, REAL, ACADO_WORKSPACE);
518  qpUb.setup("qpUb", 1, N * (NX + NU) + NX, REAL, ACADO_WORKSPACE);
519 
520  DVector lbTmp, ubTmp;
521  DVector lbXValues, ubXValues;
522  DVector lbUValues, ubUValues;
523 
524  DVector lbXInf( NX );
525  lbXInf.setAll( -INFTY );
526  DVector ubXInf( NX );
527  ubXInf.setAll( INFTY );
528 
529  //
530  // Stack state bounds
531  //
532  for (unsigned i = 0; i < N + 1; ++i)
533  {
534  lbTmp = xBounds.getLowerBounds( i );
535  if ( !lbTmp.getDim() )
536  lbXValues.append( lbXInf );
537  else
538  lbXValues.append( lbTmp );
539 
540  ubTmp = xBounds.getUpperBounds( i );
541  if ( !ubTmp.getDim() )
542  ubXValues.append( ubXInf );
543  else
544  ubXValues.append( ubTmp );
545  }
546 
547  ExportVariable evLbXValues("lbXValues", lbXValues, STATIC_CONST_REAL);
548  ExportVariable evUbXValues("ubXValues", ubXValues, STATIC_CONST_REAL);
549 
550  DVector lbUInf( NU );
551  lbUInf.setAll( -INFTY );
552  DVector ubUInf( NU );
553  ubUInf.setAll( INFTY );
554 
555  //
556  // Stack control constraints
557  //
558  for (unsigned i = 0; i < N; ++i)
559  {
560  lbTmp = uBounds.getLowerBounds( i );
561  if ( !lbTmp.getDim() )
562  lbUValues.append( lbUInf );
563  else
564  lbUValues.append( lbTmp );
565 
566  ubTmp = uBounds.getUpperBounds( i );
567  if ( !ubTmp.getDim() )
568  ubUValues.append( ubUInf );
569  else
570  ubUValues.append( ubTmp );
571  }
572 
573  ExportVariable evLbUValues("lbUValues", lbUValues, STATIC_CONST_REAL);
574  ExportVariable evUbUValues("ubUValues", ubUValues, STATIC_CONST_REAL);
575 
576  //
577  // Export evaluation of simple box constraints
578  //
579  evaluateConstraints.setup("evaluateConstraints");
580  if( hardcodeConstraintValues == YES ) {
581  evaluateConstraints.addVariable( evLbXValues );
582  evaluateConstraints.addVariable( evUbXValues );
583  evaluateConstraints.addVariable( evLbUValues );
584  evaluateConstraints.addVariable( evUbUValues );
585  }
586  else {
587  lbValues.setup("lbValues", 1, N * (NX + NU) + NX, REAL, ACADO_VARIABLES);
588  lbValues.setDoc( "Lower bounds values." );
589  ubValues.setup("ubValues", 1, N * (NX + NU) + NX, REAL, ACADO_VARIABLES);
590  ubValues.setDoc( "Upper bounds values." );
591 
592  for( uint i = 0; i < N; i++ ) {
593  for( uint j = 0; j < NX; j++ ) {
594  initialize.addStatement(lbValues.getCol(i * (NX + NU) + j) == lbXValues(i * NX + j));
595  initialize.addStatement(ubValues.getCol(i * (NX + NU) + j) == ubXValues(i * NX + j));
596  }
597  for( uint j = 0; j < NU; j++ ) {
598  initialize.addStatement(lbValues.getCol(i * (NX + NU) + NX + j) == lbUValues(i * NU + j));
599  initialize.addStatement(ubValues.getCol(i * (NX + NU) + NX + j) == ubUValues(i * NU + j));
600  }
601  }
602  for( uint j = 0; j < NX; j++ ) {
603  initialize.addStatement(lbValues.getCol(N * (NX + NU) + j) == lbXValues(N * NX + j));
604  initialize.addStatement(ubValues.getCol(N * (NX + NU) + j) == ubXValues(N * NX + j));
605  }
606  }
607 
608  if (initialStateFixed() == true && hardcodeConstraintValues == YES)
609  {
611  qpLb0.getCols(NX, NX + NU) == evLbUValues.getTranspose().getCols(0, NU) - u.getRow( 0 )
612  );
614  qpUb0.getCols(NX, NX + NU) == evUbUValues.getTranspose().getCols(0, NU) - u.getRow( 0 )
615  );
616  }
617  else if (initialStateFixed() == true) {
619  qpLb0.getCols(NX, NX + NU) == lbValues.getCols(NX, NX + NU) - u.getRow( 0 )
620  );
622  qpUb0.getCols(NX, NX + NU) == ubValues.getCols(NX, NX + NU) - u.getRow( 0 )
623  );
624  }
625 
626  ExportIndex ind( "ind" );
628  ExportForLoop lbLoop(ind, 0, N);
629  ExportForLoop ubLoop(ind, 0, N);
630 
631  if( hardcodeConstraintValues == YES ) {
632  lbLoop.addStatement(
633  qpLb.getCols(ind * (NX + NU), ind * (NX + NU) + NX) ==
634  evLbXValues.getTranspose().getCols(ind * NX, (ind + 1) * NX) - x.getRow( ind )
635  );
636  lbLoop.addStatement(
637  qpLb.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) ==
638  evLbUValues.getTranspose().getCols(ind * NU, (ind + 1) * NU) - u.getRow( ind )
639  );
640 
641  ubLoop.addStatement(
642  qpUb.getCols(ind * (NX + NU), ind * (NX + NU) + NX) ==
643  evUbXValues.getTranspose().getCols(ind * NX, (ind + 1) * NX) - x.getRow( ind )
644  );
645  ubLoop.addStatement(
646  qpUb.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) ==
647  evUbUValues.getTranspose().getCols(ind * NU, (ind + 1) * NU) - u.getRow( ind )
648  );
649  }
650  else {
651  lbLoop.addStatement(
652  qpLb.getCols(ind * (NX + NU), ind * (NX + NU) + NX) ==
653  lbValues.getCols(ind * (NX + NU), ind * (NX + NU) + NX) - x.getRow( ind )
654  );
655  lbLoop.addStatement(
656  qpLb.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) ==
657  lbValues.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) - u.getRow( ind )
658  );
659 
660  ubLoop.addStatement(
661  qpUb.getCols(ind * (NX + NU), ind * (NX + NU) + NX) ==
662  ubValues.getCols(ind * (NX + NU), ind * (NX + NU) + NX) - x.getRow( ind )
663  );
664  ubLoop.addStatement(
665  qpUb.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) ==
666  ubValues.getCols(ind * (NX + NU) + NX, (ind + 1) * (NX + NU)) - u.getRow( ind )
667  );
668  }
669 
673 
674  if( hardcodeConstraintValues == YES ) {
676  qpLb.getCols(N * (NX + NU), N * (NX + NU) + NX) ==
677  evLbXValues.getTranspose().getCols(N * NX, (N + 1) * NX) - x.getRow( N )
678  );
680  qpUb.getCols(N * (NX + NU), N * (NX + NU) + NX) ==
681  evUbXValues.getTranspose().getCols(N * NX, (N + 1) * NX) - x.getRow( N )
682  );
683  }
684  else {
686  qpLb.getCols(N * (NX + NU), N * (NX + NU) + NX) ==
687  lbValues.getCols(N * (NX + NU), N * (NX + NU) + NX) - x.getRow( N )
688  );
690  qpUb.getCols(N * (NX + NU), N * (NX + NU) + NX) ==
691  ubValues.getCols(N * (NX + NU), N * (NX + NU) + NX) - x.getRow( N )
692  );
693  }
695 
697  //
698  // Evaluation of the system dynamics equality constraints
699  //
701 
702  //
703  // Set QP C matrix
704  //
705 
706  qpC.setup("qpC", N * NX, NX + NU, REAL, ACADO_WORKSPACE);
707  qpc.setup("qpc", N * NX, 1, REAL, ACADO_WORKSPACE);
708 
709  ExportForLoop cLoop(ind, 0, N);
710 
711  cLoop.addStatement(
712  qpC.getSubMatrix(ind * NX, (ind + 1) * NX, 0, NX) ==
713  evGx.getSubMatrix(ind * NX, (ind + 1) * NX, 0, NX)
714  );
715  cLoop.addStatement(
716  qpC.getSubMatrix(ind * NX, (ind + 1) * NX, NX, NX + NU) ==
717  evGu.getSubMatrix(ind * NX, (ind + 1) * NX, 0, NU)
718  );
719 
722 
723  //
724  // Set QP c vector
725  //
728 
730  //
731  // Setup evaluation of path and point constraints
732  //
734 
735  if (getNumComplexConstraints() == 0)
736  return SUCCESSFUL_RETURN;
737  else if(hardcodeConstraintValues == YES)
739 
740  unsigned dimLbA = N * dimPacH;
741  unsigned dimConA = dimLbA * (NX + NU);
742 
743  qpConDim.resize(N + 1, 0);
744  for (unsigned i = 0; i < N; ++i)
745  qpConDim[ i ] += dimPacH;
746 
747  for (unsigned i = 0; i < N; ++i)
748  if (evaluatePointConstraints[ i ])
749  {
750  unsigned dim = evaluatePointConstraints[ i ]->getFunctionDim() / (1 + NX + NU);
751 
752  dimLbA += dim;
753  dimConA += dim * (NX + NU);
754 
755  qpConDim[ i ] += dim;
756  }
757 
758  if (evaluatePointConstraints[ N ])
759  {
760  unsigned dim = evaluatePointConstraints[ N ]->getFunctionDim() / (1 + NX);
761  dimLbA += dim;
762  dimConA += dim * NX;
763 
764  qpConDim[ N ] += dim;
765  }
766 
767  qpA.setup("qpA", dimConA, 1, REAL, ACADO_WORKSPACE);
768  qpLbA.setup("qpLbA", dimLbA, 1, REAL, ACADO_WORKSPACE);
769  qpUbA.setup("qpUbA", dimLbA, 1, REAL, ACADO_WORKSPACE);
770 
771  //
772  // Setup constraint values for the whole horizon.
773  //
774  DVector lbAValues;
775  DVector ubAValues;
776 
777  for (unsigned i = 0; i < N; ++i)
778  {
779  if ( dimPacH )
780  {
781  lbAValues.append( lbPathConValues.block(i * NX, 0, NX, 1) );
782  ubAValues.append( ubPathConValues.block(i * NX, 0, NX, 1) );
783  }
784  lbAValues.append( pocLbStack[ i ] );
785  ubAValues.append( pocUbStack[ i ] );
786  }
787  lbAValues.append( pocLbStack[ N ] );
788  ubAValues.append( pocUbStack[ N ] );
789 
790  ExportVariable evLbAValues("lbAValues", lbAValues, STATIC_CONST_REAL);
791  ExportVariable evUbAValues("ubAValues", ubAValues, STATIC_CONST_REAL);
792 
793  evaluateConstraints.addVariable( evLbAValues );
794  evaluateConstraints.addVariable( evUbAValues );
795 
796  //
797  // Evaluate path constraints
798  //
799 
800  if ( dimPacH )
801  {
802  ExportIndex runPac;
803  evaluateConstraints.acquire( runPac );
804  ExportForLoop loopPac(runPac, 0, N);
805 
806  loopPac.addStatement( conValueIn.getCols(0, NX) == x.getRow( runPac ) );
807  loopPac.addStatement( conValueIn.getCols(NX, NX + NU) == u.getRow( runPac ) );
808  loopPac.addStatement( conValueIn.getCols(NX + NU, NX + NU + NOD) == od.getRow( runPac ) );
810 
811  loopPac.addStatement( pacEvH.getRows( runPac * dimPacH, (runPac + 1) * dimPacH) ==
812  conValueOut.getTranspose().getRows(0, dimPacH) );
813  loopPac.addLinebreak( );
814 
815  unsigned derOffset = dimPacH;
816 
817  // Optionally store derivatives
818  if (pacEvHx.isGiven() == false)
819  {
820  loopPac.addStatement(
821  pacEvHx.makeRowVector().getCols(runPac * dimPacH * NX, (runPac + 1) * dimPacH * NX) ==
822  conValueOut.getCols(derOffset, derOffset + dimPacH * NX )
823  );
824 
825  derOffset = derOffset + dimPacH * NX;
826  }
827  if (pacEvHu.isGiven() == false )
828  {
829  loopPac.addStatement(
830  pacEvHu.makeRowVector().getCols(runPac * dimPacH * NU, (runPac + 1) * dimPacH * NU) ==
831  conValueOut.getCols(derOffset, derOffset + dimPacH * NU )
832  );
833  }
834 
835  // Add loop to the function.
837  evaluateConstraints.release( runPac );
839  }
840 
841  //
842  // Evaluate point constraints
843  //
844 
845  for (unsigned i = 0, intRowOffset = 0, dim = 0; i < N + 1; ++i)
846  {
847  if (evaluatePointConstraints[ i ] == 0)
848  continue;
849 
851  string( "Evaluating constraint on node: #" ) + toString( i )
852  );
853 
855  if (i < N)
856  {
859  }
860  else
862 
864  evaluatePointConstraints[ i ]->getName(), conValueIn, conValueOut );
866 
867  if (i < N)
868  dim = evaluatePointConstraints[ i ]->getFunctionDim() / (1 + NX + NU);
869  else
870  dim = evaluatePointConstraints[ i ]->getFunctionDim() / (1 + NX);
871 
872  // Fill pocEvH, pocEvHx, pocEvHu
874  pocEvH.getRows(intRowOffset, intRowOffset + dim) ==
875  conValueOut.getTranspose().getRows(0, dim));
877 
879  pocEvHx.makeRowVector().getCols(intRowOffset * NX, (intRowOffset + dim) * NX)
880  == conValueOut.getCols(dim, dim + dim * NX));
882 
883  if (i < N)
884  {
886  pocEvHu.makeRowVector().getCols(intRowOffset * NU, (intRowOffset + dim) * NU)
887  == conValueOut.getCols(dim + dim * NX, dim + dim * NX + dim * NU));
889  }
890 
891  intRowOffset += dim;
892  }
893 
894  //
895  // Copy data to QP solver structures
896  //
897 
898  ExportVariable tLbAValues, tUbAValues, tPacA;
899  ExportIndex offsetPac("offset"), indPac( "ind" );
900 
901  tLbAValues.setup("lbAValues", dimPacH, 1, REAL, ACADO_LOCAL);
902  tUbAValues.setup("ubAValues", dimPacH, 1, REAL, ACADO_LOCAL);
903  tPacA.setup("tPacA", dimPacH, NX + NU, REAL, ACADO_LOCAL);
904 
905  setStagePac.setup("setStagePac", offsetPac, indPac, tPacA, tLbAValues, tUbAValues);
906 
907  if (pacEvHx.isGiven() == true)
908  setStagePac << (tPacA.getSubMatrix(0, dimPacH, 0, NX) == pacEvHx);
909  else
910  setStagePac << (tPacA.getSubMatrix(0, dimPacH, 0, NX) ==
911  pacEvHx.getSubMatrix(indPac * dimPacH, indPac * dimPacH + dimPacH, 0 , NX));
912 
913  if (pacEvHu.isGiven() == true)
914  setStagePac << (tPacA.getSubMatrix(0, dimPacH, NX, NX + NU) == pacEvHu);
915  else
916  setStagePac << (tPacA.getSubMatrix(0, dimPacH, NX, NX + NU) ==
917  pacEvHu.getSubMatrix(indPac * dimPacH, indPac * dimPacH + dimPacH, 0 , NU));
918 
920  << (qpLbA.getRows(offsetPac, offsetPac + dimPacH) == tLbAValues - pacEvH.getRows(indPac * dimPacH, indPac * dimPacH + dimPacH))
921  << (qpUbA.getRows(offsetPac, offsetPac + dimPacH) == tUbAValues - pacEvH.getRows(indPac * dimPacH, indPac * dimPacH + dimPacH));
922 
923  ExportVariable tPocA;
924  tPocA.setup("tPocA", conValueOut.getDim(), NX + NU, REAL);
925  if ( dimPocH )
927 
928  unsigned offsetEval = 0;
929  unsigned offsetPoc = 0;
930  for (unsigned i = 0; i < N; ++i)
931  {
932  if ( dimPacH )
933  {
935  setStagePac,
936  ExportIndex( offsetEval ), ExportIndex( i ),
937  qpA.getAddress(offsetEval * (NX + NU)),
938  evLbAValues.getAddress( offsetEval ), evUbAValues.getAddress( offsetEval )
939  );
940 
941  offsetEval += dimPacH;
942  }
943 
944  if ( evaluatePointConstraints[ i ] )
945  {
946  unsigned dim = evaluatePointConstraints[ i ]->getFunctionDim() / (1 + NX + NU);
947 
949 
951  << (tPocA.getSubMatrix(0, dim, 0, NX) == pocEvHx.getSubMatrix(offsetPoc, offsetPoc + dim, 0, NX))
952  << (tPocA.getSubMatrix(0, dim, NX, NX + NU) == pocEvHu.getSubMatrix(offsetPoc, offsetPoc + dim, 0, NU))
953  << (qpA.getRows(offsetEval * (NX + NU), (offsetEval + dim) * (NX + NU)) == tPocA.makeColVector().getRows(0, dim * (NX + NU)))
954  << (qpLbA.getRows(offsetEval, offsetEval + dim) ==
955  evLbAValues.getRows(offsetEval, offsetEval + dim) - pocEvH.getRows(offsetPoc, offsetPoc + dim))
956  << (qpUbA.getRows(offsetEval, offsetEval + dim) ==
957  evUbAValues.getRows(offsetEval, offsetEval + dim) - pocEvH.getRows(offsetPoc, offsetPoc + dim));
958 
959  offsetEval += dim;
960  offsetPoc += dim;
961  }
962  }
963 
964  if ( evaluatePointConstraints[ N ] )
965  {
966  unsigned dim = evaluatePointConstraints[ N ]->getFunctionDim() / (1 + NX);
967 
969  << (qpA.getRows(offsetEval * (NX + NU), offsetEval * (NX + NU) + dim * NX) ==
970  pocEvHx.makeColVector().getRows(offsetPoc * (NX + NU), offsetPoc * (NX + NU) + dim * NX))
971  << (qpLbA.getRows(offsetEval, offsetEval + dim) ==
972  evLbAValues.getRows(offsetEval, offsetEval + dim) - pocEvH.getRows(offsetPoc, offsetPoc + dim))
973  << (qpUbA.getRows(offsetEval, offsetEval + dim) ==
974  evUbAValues.getRows(offsetEval, offsetEval + dim) - pocEvH.getRows(offsetPoc, offsetPoc + dim));
975  }
976 
977  return SUCCESSFUL_RETURN;
978 }
979 
981 {
982  if (initialStateFixed() == true)
983  {
984  x0.setup("x0", NX, 1, REAL, ACADO_VARIABLES);
985  x0.setDoc( (std::string)"Current state feedback vector." );
986  }
987 
988  return SUCCESSFUL_RETURN;
989 }
990 
992 {
993  return SUCCESSFUL_RETURN;
994 }
995 
997 {
998  stringstream ss;
999 
1001  //
1002  // Setup preparation phase
1003  //
1005  preparation.setup("preparationStep");
1006  preparation.doc( "Preparation step of the RTI scheme." );
1007 
1008  ExportVariable retSim("ret", 1, 1, INT, ACADO_LOCAL, true);
1009  retSim.setDoc("Status of the integration module. =0: OK, otherwise the error code.");
1010  preparation.setReturnValue(retSim, false);
1011 
1012  preparation << retSim.getFullName() << " = " << modelSimulation.getName() << "();\n";
1013 
1017 
1019  //
1020  // Setup feedback phase
1021  //
1023  ExportVariable stateFeedback("stateFeedback", NX, 1, REAL, ACADO_LOCAL);
1024  ExportVariable returnValueFeedbackPhase("retVal", 1, 1, INT, ACADO_LOCAL, true);
1025  returnValueFeedbackPhase.setDoc( "Status code of the FORCES QP solver." );
1026  feedback.setup("feedbackStep" );
1027  feedback.doc( "Feedback/estimation step of the RTI scheme." );
1028  feedback.setReturnValue( returnValueFeedbackPhase );
1029 
1030  qpPrimal.setup("qpPrimal", N * (NX + NU) + NX, 1, REAL, ACADO_WORKSPACE);
1031  qpLambda.setup("qpLambda", N * NX, 1, REAL, ACADO_WORKSPACE);
1032  qpMu.setup("qpMu", 2 * N * (NX + NU) + 2 * NX, 1, REAL, ACADO_WORKSPACE);
1033 
1034  //
1035  // Calculate objective residuals and call the QP solver
1036  //
1037  int sensitivityProp;
1038  get( DYNAMIC_SENSITIVITY, sensitivityProp );
1039  bool adjoint = ((ExportSensitivityType) sensitivityProp == BACKWARD);
1040  if( getNY() > 0 || getNYN() > 0 ) {
1041  feedback.addStatement( Dy -= y );
1043  feedback.addStatement( DyN -= yN );
1045 
1046  for (unsigned i = 0; i < N; ++i)
1048  feedback.addStatement( qpg.getRows(N * (NX + NU), N * (NX + NU) + NX) == QN2 * DyN );
1049  if( adjoint ) feedback.addStatement( qpg.getRows(N * (NX + NU), N * (NX + NU) + NX) += objSlx.getRows(N*NX,N*NX+NX) );
1051  }
1052 
1053  if (initialStateFixed() == true)
1054  {
1056  qpLb0.getTranspose().getRows(0, NX) == x0 - x.getRow( 0 ).getTranspose()
1057  );
1059  qpUb0.getCols(0, NX) == qpLb0.getCols(0, NX)
1060  );
1061  }
1062  else
1063  {
1064  feedback << (qpgN == qpg.getRows(N * (NX + NU), N * (NX + NU) + NX));
1065  }
1067 
1068  feedback << returnValueFeedbackPhase.getFullName() << " = solveQpDunes();\n";
1069 
1070  //
1071  // Here we have to accumulate the differences.
1072  //
1073 
1074  ExportVariable stageOut("stageOut", 1, NX + NU, REAL, ACADO_LOCAL);
1075  ExportIndex index( "index" );
1076  acc.setup("accumulate", stageOut, index);
1077 
1078  acc << (x.getRow( index ) += stageOut.getCols(0, NX))
1079  << (u.getRow( index ) += stageOut.getCols(NX, NX + NU));
1080 
1081  for (unsigned i = 0; i < N; ++i)
1085  x.getRow( N ) += qpPrimal.getTranspose().getCols(N * (NX + NU), N * (NX + NU) + NX)
1086  );
1088 
1089  //
1090  // Pass the multipliers of the dynamic constraints in case of exact Hessian SQP.
1091  //
1092  int hessianApproximation;
1093  get( HESSIAN_APPROXIMATION, hessianApproximation );
1094  bool secondOrder = ((HessianApproximationMode)hessianApproximation == EXACT_HESSIAN);
1095  if( secondOrder ) feedback.addStatement( mu.makeColVector() == qpLambda );
1096 
1098  //
1099  // Shifting of QP data
1100  //
1102 
1103  shiftQpData.setup( "shiftQpData" );
1104  ss.str( string() );
1105  ss << "qpDUNES_shiftLambda( &qpData );" << endl
1106  << "qpDUNES_shiftIntervals( &qpData );" << endl;
1107  shiftQpData.addStatement( ss.str().c_str() );
1108 
1110  //
1111  // Setup evaluation of the KKT tolerance
1112  //
1114  ExportVariable kkt("kkt", 1, 1, REAL, ACADO_LOCAL, true);
1115  ExportVariable prd("prd", 1, 1, REAL, ACADO_LOCAL, true);
1116  ExportIndex index2( "index2" );
1117 
1118  getKKT.setup( "getKKT" );
1119  getKKT.doc( "Get the KKT tolerance of the current iterate." );
1120  kkt.setDoc( "KKT tolerance." );
1121  getKKT.setReturnValue( kkt );
1122 // getKKT.addVariable( prd );
1123  getKKT.addIndex( index );
1124  getKKT.addIndex( index2 );
1125 
1126  getKKT.addStatement( kkt == (qpg ^ qpPrimal) );
1127  getKKT << kkt.getFullName() << " = fabs( " << kkt.getFullName() << " );\n";
1128 
1129  ExportForLoop lamLoop(index, 0, N * NX);
1130  lamLoop << kkt.getFullName() << "+= fabs( " << d.get(index, 0) << " * " << qpLambda.get(index, 0) << ");\n";
1131  getKKT.addStatement( lamLoop );
1132 
1133  /*
1134 
1135  lambda are the multipliers of the coupling constraints
1136  i.e. lambda_i for x_{i+1} = A * x_i + B * u_i + c
1137  mu correspond to the bounds
1138  in the fashion
1139  mu = mu_0 … mu_N
1140  i.e. major ordering by the stages
1141  within each stage i
1142  i.e. within mu_i
1143  we have the minor ordering( I drop the i here)
1144  lb z_0, ub z_0, lb z_1, ub z_1, … lb z_nZ, ub z_nZ
1145  where z are the stage variables in the ordering z = [x u]
1146  signs are positive if active, zero if inactive
1147 
1148  */
1149 
1150  if ( getNumComplexConstraints() )
1151  {
1153  "KKT Tolerance with affine stage constraints is under development");
1154  return SUCCESSFUL_RETURN;
1155  }
1156 
1157  if (initialStateFixed() == true)
1158  {
1159  for (unsigned el = 0; el < NX + NU; ++el)
1160  {
1161  getKKT << kkt.getFullName() << " += fabs("
1162  << qpLb0.get(0, el) << " * " << qpMu.get(2 * el + 0, 0) << ");\n";
1163  getKKT << kkt.getFullName() << " += fabs("
1164  << qpUb0.get(0, el) << " * " << qpMu.get(2 * el + 1, 0) << ");\n";
1165  }
1166  }
1167 
1168  ExportForLoop bndLoop(index, initialStateFixed() ? 1 : 0, N);
1169  ExportForLoop bndInLoop(index2, 0, NX + NU);
1170  bndInLoop << kkt.getFullName() << " += fabs("
1171  << qpLb.get(0, index * (NX + NU) + index2) << " * " << qpMu.get(index * 2 * (NX + NU) + 2 * index2 + 0, 0) << ");\n";
1172  bndInLoop << kkt.getFullName() << " += fabs("
1173  << qpUb.get(0, index * (NX + NU) + index2) << " * " << qpMu.get(index * 2 * (NX + NU) + 2 * index2 + 1, 0) << ");\n";
1174  bndLoop.addStatement( bndInLoop );
1175  getKKT.addStatement( bndLoop );
1176 
1177  for (unsigned el = 0; el < NX; ++el)
1178  {
1179  getKKT << kkt.getFullName() << " += fabs("
1180  << qpLb.get(0, N * (NX + NU) + el) << " * " << qpMu.get(N * 2 * (NX + NU) + 2 * el + 0, 0) << ");\n";
1181  getKKT << kkt.getFullName() << " += fabs("
1182  << qpUb.get(0, N * (NX + NU) + el) << " * " << qpMu.get(N * 2 * (NX + NU) + 2 * el + 1, 0) << ");\n";
1183  }
1184 
1185  return SUCCESSFUL_RETURN;
1186 }
1187 
1189 {
1190  //
1191  // Configure and export QP interface
1192  //
1193 
1194  qpInterface = std::shared_ptr< ExportQpDunesInterface >(new ExportQpDunesInterface("", commonHeaderName));
1195 
1196  int maxNumQPiterations;
1197  get(MAX_NUM_QP_ITERATIONS, maxNumQPiterations);
1198 
1199  // XXX If not specified, use default value
1200  if ( maxNumQPiterations <= 0 )
1201  maxNumQPiterations = getNumQPvars();
1202 
1203  int printLevel;
1204  get(PRINTLEVEL, printLevel);
1205 
1206  if ( (PrintLevel)printLevel >= MEDIUM )
1207  printLevel = 2;
1208  else
1209  printLevel = 0;
1210 
1211  qpInterface->configure(
1212  maxNumQPiterations,
1213  printLevel,
1214  qpH.getFullName(),
1215  qpg.getFullName(),
1216  initialStateFixed() ? "0" : qpgN.getFullName(),
1217  qpC.getFullName(),
1218  qpc.getFullName(),
1219  qpA.getFullName(),
1220  initialStateFixed() ? qpLb0.getFullName() : "0",
1221  initialStateFixed() ? qpUb0.getFullName() : "0",
1222  qpLb.getFullName(),
1223  qpUb.getFullName(),
1224  qpLbA.getFullName(),
1225  qpUbA.getFullName(),
1228  qpMu.getFullName(),
1229  qpConDim,
1230  initialStateFixed() ? "1" : "0",
1231  diagonalH ? "1" : "0",
1232  diagonalHN ? "1" : "0",
1233  N, NX, NU
1234  );
1235 
1236  return SUCCESSFUL_RETURN;
1237 }
1238 
#define LOG(level)
Just define a handy macro for getting the logger.
Lowest level, the debug level.
ExportVariable objEvFx
HessianApproximationMode
virtual returnValue getCode(ExportStatementBlock &code)
ExportVariable conValueOut
ExportVariable getRow(const ExportIndex &idx) const
ExportVariable objS
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
ExportVariable objSlu
ExportFunction shiftStates
ExportVariable pacEvHx
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
ExportFunction & setName(const std::string &_name)
const double INFTY
ExportVariable getTranspose() const
ExportVariable pocEvH
bool initialStateFixed() const
VariablesGrid xBounds
ExportVariable pocEvHx
ExportVariable & setup(const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string())
bool isGiven(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
uint getNX() const
Allows to pass back messages to the calling function.
ExportVariable conValueIn
DVector getUpperBounds(uint pointIdx) const
ExportVariable pacEvHu
std::vector< DVector > pocLbStack
returnValue addComment(const std::string &_comment)
ExportVariable objEvFxEnd
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
const DMatrix & getGivenMatrix() const
Allows to export code of a for-loop.
string toString(T const &value)
VariablesGrid uBounds
virtual returnValue setupMultiplicationRoutines()
ExportVariable objSlx
#define CLOSE_NAMESPACE_ACADO
ExportVariable DyN
ExportVariable state
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
ExportVariable evGx
virtual returnValue setupConstraintsEvaluation(void)
Defines a scalar-valued index variable to be used for exporting code.
Base class for export of NLP/OCP solvers.
ExportAcadoFunction evaluateStageCost
Defines a matrix-valued variable that can be passed as argument to exported functions.
ExportAcadoFunction evaluateTerminalCost
ExportFunction & setup(const std::string &_name="defaultFunctionName", const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
Interface generator for the qpDUNES QP solver.
#define YES
Definition: acado_types.hpp:51
virtual returnValue setDoc(const std::string &_doc)
std::shared_ptr< ExportQpDunesInterface > qpInterface
virtual returnValue setupInitialization()
std::string commonHeaderName
ExportStruct
ExportFunction modelSimulation
virtual ExportFunction & doc(const std::string &_doc)
virtual bool isDefined() const
uint getNY() const
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
ExportFunction getObjective
printLevel
Definition: example1.py:55
virtual returnValue setupObjectiveEvaluation(void)
unsigned getDim() const
Definition: vector.hpp:172
ExportVariable makeRowVector() const
ExportVariable objValueIn
ExportFunction initializeNodes
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable QN2
virtual returnValue setupSimulation(void)
ExportVariable QN1
std::vector< std::shared_ptr< ExportAcadoFunction > > evaluatePointConstraints
Encapsulates all user interaction for setting options, logging data and plotting results.
Allows to export code of an arbitrary function.
virtual uint getDim() const
ExportFunction shiftControls
returnValue addStatement(const ExportStatement &_statement)
virtual bool isGiven() const
PrintLevel
std::string getFullName() const
returnValue addLinebreak(uint num=1)
ExportAcadoFunction evaluatePathConstraints
uint getNYN() const
GenericVector & append(const GenericVector &_arg)
Definition: vector.cpp:42
#define ACADOWARNINGTEXT(retval, text)
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
virtual ExportFunction & acquire(ExportIndex &obj)
ExportFunction & addVariable(const ExportVariable &_var)
ExportGaussNewtonQpDunes(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
void setAll(const T &_value)
Definition: vector.hpp:160
ExportVariable evGu
ExportVariable objSEndTerm
std::string getName() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
returnValue addDeclaration(const ExportVariable &_data, ExportStruct _dataStruct=ACADO_ANY)
returnValue setupAuxiliaryFunctions()
virtual ExportFunction & release(const ExportIndex &obj)
unsigned getNumComplexConstraints(void)
DVector getLowerBounds(uint pointIdx) const
#define BEGIN_NAMESPACE_ACADO
returnValue addFunction(const ExportFunction &_function)
std::vector< DVector > pocUbStack
ExportVariable objEvFu
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
ExportVariable pacEvH
ExportVariable pocEvHu
Allows to export code for a block of statements.
ExportFunction initialize
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
ExportVariable objValueOut
ExportVariable getCol(const ExportIndex &idx) const
ExportFunction & addIndex(const ExportIndex &_index)
ExportFunction regularizeHessian
#define ACADOERROR(retval)
Defines a matrix-valued variable to be used for exporting code.
returnValue addFunctionCall(const std::string &_fName, const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
ExportVariable makeColVector() const


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