log_record.hpp
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 
26 
32 #ifndef ACADO_TOOLKIT_LOG_RECORD_HPP
33 #define ACADO_TOOLKIT_LOG_RECORD_HPP
34 
39 
40 #include <map>
41 #include <iterator>
42 
44 
45 class Logging;
46 
72 class LogRecord
73 {
74  friend class Logging;
75 
76  //
77  // PUBLIC MEMBER FUNCTIONS:
78  //
79  public:
80 
88  PrintScheme _printScheme = PS_DEFAULT
89  );
90 
92  ~LogRecord( );
93 
104  );
105 
115  returnValue operator<<( const Expression& _name
116  );
117 
127  returnValue addItem( LogName _name,
128  const char* const _label = DEFAULT_LABEL
129  );
130 
140  returnValue addItem( const Expression& _name,
141  const char* const _label = DEFAULT_LABEL
142  );
143 
155  inline returnValue getAll( LogName _name,
156  MatrixVariablesGrid& values
157  ) const;
158 
170  inline returnValue getAll( const Expression& _name,
171  MatrixVariablesGrid& values
172  ) const;
173 
174 
186  inline returnValue getFirst( LogName _name,
187  DMatrix& firstValue
188  ) const;
189 
201  inline returnValue getFirst( const Expression& _name,
202  DMatrix& firstValue
203  ) const;
204 
216  inline returnValue getFirst( LogName _name,
217  VariablesGrid& firstValue
218  ) const;
219 
231  inline returnValue getFirst( const Expression& _name,
232  VariablesGrid& firstValue
233  ) const;
234 
235 
247  inline returnValue getLast( LogName _name,
248  DMatrix& lastValue
249  ) const;
250 
262  inline returnValue getLast( const Expression& _name,
263  DMatrix& lastValue
264  ) const;
265 
277  inline returnValue getLast( LogName _name,
278  VariablesGrid& lastValue
279  ) const;
280 
292  inline returnValue getLast( const Expression& _name,
293  VariablesGrid& lastValue
294  ) const;
295 
296 
308  inline returnValue setAll( LogName _name,
309  const MatrixVariablesGrid& values
310  );
311 
323  inline returnValue setAll( const Expression& _name,
324  const MatrixVariablesGrid& values
325  );
326 
327 
340  inline returnValue setLast( LogName _name,
341  const DMatrix& value,
342  double time = -INFTY
343  );
344 
357  inline returnValue setLast( const Expression& _name,
358  const DMatrix& value,
359  double time = -INFTY
360  );
361 
374  inline returnValue setLast( LogName _name,
375  VariablesGrid& value,
376  double time = -INFTY
377  );
378 
391  inline returnValue setLast( const Expression& _name,
392  VariablesGrid& value,
393  double time = -INFTY
394  );
395 
406  returnValue print( std::ostream& _stream = std::cout,
408  ) const;
409 
414  returnValue printInfo( ) const;
415 
423  uint getMaxNumMatrices( ) const;
424 
429  inline uint getNumItems( ) const;
430 
436  inline BooleanType isEmpty( ) const;
437 
443  inline LogFrequency getLogFrequency( ) const;
444 
449  inline PrintScheme getPrintScheme( ) const;
450 
458  inline returnValue setLogFrequency( LogFrequency _frequency
459  );
460 
467  inline returnValue setPrintScheme( PrintScheme _printScheme
468  );
469 
478  inline BooleanType hasItem( LogName _name
479  ) const;
480 
489  inline BooleanType hasItem( const Expression& _name
490  ) const;
491 
499  inline BooleanType hasNonEmptyItem( LogName _name
500  ) const;
501 
509  inline BooleanType hasNonEmptyItem( const Expression& _name
510  ) const;
511 
512 
513  inline uint getNumDoubles( ) const;
514 
527  returnValue getAll( uint _name,
528  LogRecordItemType _type,
529  MatrixVariablesGrid& values
530  ) const;
531 
544  returnValue getFirst( uint _name,
545  LogRecordItemType _type,
546  DMatrix& firstValue
547  ) const;
548 
561  returnValue getLast( uint _name,
562  LogRecordItemType _type,
563  DMatrix& lastValue
564  ) const;
565 
578  returnValue setAll( uint _name,
579  LogRecordItemType _type,
580  const MatrixVariablesGrid& values
581  );
582 
596  returnValue setLast( uint _name,
597  LogRecordItemType _type,
598  const DMatrix& value,
599  double time = -INFTY
600  );
601 
602 
612  inline BooleanType hasItem( uint _name,
613  LogRecordItemType _type
614  ) const;
615 
624 
632  inline returnValue enableWriteProtection(const Expression& _name);
633 
642 
650  inline returnValue disableWriteProtection(const Expression& _name);
651 
654  ) const;
655 
656  //
657  // DATA MEMBERS:
658  //
659  protected:
661  int aliasIdx;
666 
669  {
671  : label( DEFAULT_LABEL ), writeProtection( false )
672  {}
673 
674  LogRecordData( const std::string& _label
675  )
676  : label( _label ), writeProtection( false )
677  {}
678 
680  const std::string& _label,
681  bool _writeProtection
682  )
683  : values( _values ), label( _label ), writeProtection( _writeProtection )
684  {}
685 
687  std::string label;
689  };
690 
692  typedef std::map<std::pair<int, LogRecordItemType>, LogRecordData> LogRecordItems;
694  LogRecordItems items;
695 };
696 
698 
699 #include <acado/user_interaction/log_record.ipp>
700 
701 #endif // ACADO_TOOLKIT_LOG_RECORD_HPP
702 
703 /*
704  * end of file
705  */
returnValue addItem(LogName _name, const char *const _label=DEFAULT_LABEL)
Definition: log_record.cpp:70
LogFrequency getLogFrequency() const
BooleanType hasItem(LogName _name) const
const double INFTY
returnValue operator<<(LogName _name)
Definition: log_record.cpp:57
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
returnValue setAll(LogName _name, const MatrixVariablesGrid &values)
uint getNumItems() const
LogFrequency frequency
Definition: log_record.hpp:663
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
returnValue disableWriteProtection(LogName _name)
BooleanType isEmpty() const
BooleanType hasNonEmptyItem(LogName _name) const
std::map< std::pair< int, LogRecordItemType >, LogRecordData > LogRecordItems
Definition: log_record.hpp:692
uint getMaxNumMatrices() const
Definition: log_record.cpp:188
Provides a generic way to store algorithmic information during runtime.
Definition: logging.hpp:55
LogRecordItems items
Definition: log_record.hpp:694
#define CLOSE_NAMESPACE_ACADO
returnValue getLast(LogName _name, DMatrix &lastValue) const
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
PrintScheme getPrintScheme() const
LogPrintMode
returnValue printInfo() const
Definition: log_record.cpp:174
Provides a time grid consisting of matrix-valued optimization variables at each grid point...
LogRecordItemType
PrintScheme
PrintScheme printScheme
Definition: log_record.hpp:665
LogName
LogFrequency
MatrixVariablesGrid values
Definition: log_record.hpp:686
LogRecord(LogFrequency _frequency=LOG_AT_EACH_ITERATION, PrintScheme _printScheme=PS_DEFAULT)
Definition: log_record.cpp:44
LogRecordData(const std::string &_label)
Definition: log_record.hpp:674
returnValue setPrintScheme(PrintScheme _printScheme)
LogRecordData(const MatrixVariablesGrid &_values, const std::string &_label, bool _writeProtection)
Definition: log_record.hpp:679
Allows to setup and store user-specified log records of algorithmic information.
Definition: log_record.hpp:72
#define BEGIN_NAMESPACE_ACADO
returnValue print(std::ostream &_stream=std::cout, LogPrintMode _mode=PRINT_ITEM_BY_ITEM) const
Definition: log_record.cpp:95
returnValue setLast(LogName _name, const DMatrix &value, double time=-INFTY)
returnValue getAll(LogName _name, MatrixVariablesGrid &values) const
returnValue setLogFrequency(LogFrequency _frequency)
const char DEFAULT_LABEL[1]
returnValue enableWriteProtection(LogName _name)
uint getNumDoubles() const
returnValue getFirst(LogName _name, DMatrix &firstValue) const
returnValue updateLogRecord(LogRecord &_record) const
Definition: log_record.cpp:338


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