Allows to setup and store user-specified log records of algorithmic information. More...
#include <log_record.hpp>
Classes | |
struct | LogRecordData |
Protected Types | |
typedef std::map< std::pair< int, LogRecordItemType >, LogRecordData > | LogRecordItems |
Protected Attributes | |
int | aliasIdx |
LogFrequency | frequency |
LogRecordItems | items |
PrintScheme | printScheme |
Friends | |
class | Logging |
Allows to setup and store user-specified log records of algorithmic information.
The class LogRecord allows to setup and store user-specified log records of algorithmic information consisting of numerical values during runtime.
A log record comprises arbitrarily many LogRecordItems stored in a simple singly-linked list. Within these items, the actual numerical values of the algorithmic to be logged as well as settings defining their output format is stored. Several commonly-used output formats are pre-defined within so-called PrintSchemes.
Additionally, a log record stores two important settings: (i) the LogFrequency defining whether the information is stored at each iteration or only at the start or end, respectively; (ii) the file, e.g. a file or the screen, to which the whole log record including all its items can be printed.
Finally, it is interesting to know that LogRecords can be setup by the user and flushed to UserInterface classes. Internally, LogRecords are stored as basic singly-linked within a LogCollection.
Definition at line 72 of file log_record.hpp.
|
protected |
Type definition for Log record items.
Definition at line 692 of file log_record.hpp.
BEGIN_NAMESPACE_ACADO LogRecord::LogRecord | ( | LogFrequency | _frequency = LOG_AT_EACH_ITERATION , |
PrintScheme | _printScheme = PS_DEFAULT |
||
) |
Constructor which takes information in the log frequency and the general output file.
[in] | _frequency | Frequency determining at which time instants the numerical values are to be stored. |
[in] | _printScheme | Print scheme defining the output format of the information. |
Definition at line 44 of file log_record.cpp.
LogRecord::~LogRecord | ( | ) |
Destructor.
Definition at line 54 of file log_record.cpp.
returnValue LogRecord::addItem | ( | LogName | _name, |
const char *const | _label = DEFAULT_LABEL |
||
) |
Adds an item of given internal name to the singly-linked list. In addition, label of the item can be specified.
[in] | _name | Internal name of item to be added. |
[in] | _label | Label of item to be added. |
Definition at line 70 of file log_record.cpp.
returnValue LogRecord::addItem | ( | const Expression & | _name, |
const char *const | _label = DEFAULT_LABEL |
||
) |
Adds an item of given internal name to the singly-linked list. In addition, label of the item can be specified.
[in] | _name | Internal name of item to be added. |
[in] | _label | Label of item to be added. |
Definition at line 84 of file log_record.cpp.
|
inline |
Disables write protection of item with given name. As long as write protection is enabled, numerical values of this item cannot be modified.
[in] | _name | Internal name of item. |
|
inline |
Disables write protection of item with given name. As long as write protection is enabled, numerical values of this item cannot be modified.
[in] | _name | Internal name of item. |
|
inline |
Enables write protection of item with given name. As long as write protection is enabled, numerical values of this item cannot be modified.
[in] | _name | Internal name of item. |
|
inline |
Enables write protection of item with given name. As long as write protection is enabled, numerical values of this item cannot be modified.
[in] | _name | Internal name of item. |
|
inline |
Gets all numerical values at all time instants of the item with given name.
[in] | _name | Internal name of item. |
[out] | values | All numerical values at all time instants of given item. |
|
inline |
Gets all numerical values at all time instants of the item with given name.
[in] | _name | Internal name of item. |
[out] | values | All numerical values at all time instants of given item. |
returnValue LogRecord::getAll | ( | uint | _name, |
LogRecordItemType | _type, | ||
MatrixVariablesGrid & | values | ||
) | const |
Gets all numerical values at all time instants of the item with given internal name and internal type.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
[out] | values | All numerical values at all time instants of given item. |
Definition at line 208 of file log_record.cpp.
|
inline |
Gets numerical value at first time instant of the item with given name.
[in] | _name | Internal name of item. |
[out] | firstValue | Numerical value at first time instant of given item. |
|
inline |
Gets numerical value at first time instant of the item with given name.
[in] | _name | Internal name of item. |
[out] | firstValue | Numerical value at first time instant of given item. |
|
inline |
Gets numerical value at first time instant of the item with given name (converts internally used DMatrix into VariablesGrid).
[in] | _name | Internal name of item. |
[out] | firstValue | Numerical value at first time instant of given item. |
|
inline |
Gets numerical value at first time instant of the item with given name (converts internally used DMatrix into VariablesGrid).
[in] | _name | Internal name of item. |
[out] | firstValue | Numerical value at first time instant of given item. |
returnValue LogRecord::getFirst | ( | uint | _name, |
LogRecordItemType | _type, | ||
DMatrix & | firstValue | ||
) | const |
Gets numerical value at first time instant of the item with given internal name and internal type.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
[out] | firstValue | Numerical value at first time instant of given item. |
Definition at line 223 of file log_record.cpp.
|
inline |
Gets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[out] | lastValue | Numerical value at last time instant of given item. |
|
inline |
Gets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[out] | lastValue | Numerical value at last time instant of given item. |
|
inline |
Gets numerical value at last time instant of the item with given name (converts internally used DMatrix into VariablesGrid).
[in] | _name | Internal name of item. |
[out] | lastValue | Numerical value at last time instant of given item. |
|
inline |
Gets numerical value at last time instant of the item with given name (converts internally used DMatrix into VariablesGrid).
[in] | _name | Internal name of item. |
[out] | lastValue | Numerical value at last time instant of given item. |
returnValue LogRecord::getLast | ( | uint | _name, |
LogRecordItemType | _type, | ||
DMatrix & | lastValue | ||
) | const |
Gets numerical value at last time instant of the item with given internal name and internal type.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
[out] | lastValue | Numerical value at last time instant of given item. |
Definition at line 241 of file log_record.cpp.
|
inline |
Returns current log frequency determining at which time instants the numerical values are to be stored.
uint LogRecord::getMaxNumMatrices | ( | ) | const |
Returns maximum number of matrices per item. Remember that the numerical values of each item is stored in a MatrixVariablesGrid and that the number of matrices might be different from one item to the other.
Definition at line 188 of file log_record.cpp.
|
inline |
|
inline |
Returns number of items contained in the record.
|
inline |
Returns current print scheme defining the output format of the information.
|
inline |
Returns whether an (possibly empty) item with given internal name exists or not.
[in] | _name | Internal name of item. |
|
inline |
Returns whether an (possibly empty) item with given internal name exists or not.
[in] | _name | Internal name of item. |
|
inline |
Returns whether an (possibly empty) item with given internal name and internal type exists or not.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
|
inline |
Returns whether a non-empty item with given internal name exists or not.
@param[in] _name Internal name of item.
|
inline |
Returns whether a non-empty item with given internal name exists or not.
@param[in] _name Internal name of item.
|
inline |
Returns whether the record is empty (i.e. contains no items) or not.
returnValue LogRecord::operator<< | ( | LogName | _name | ) |
Adds an item of given name to the singly-linked list.
@param[in] _name Internal name of item to be added. \note This function is doing the same as the corresponding addItem member function and is introduced for syntax reasons only.
Definition at line 57 of file log_record.cpp.
returnValue LogRecord::operator<< | ( | const Expression & | _name | ) |
Adds an item of given internal name to the singly-linked list.
@param[in] _name Internal name of item to be added. \note This function is doing the same as the corresponding addItem member function and is introduced for syntax reasons only.
Definition at line 63 of file log_record.cpp.
returnValue LogRecord::print | ( | std::ostream & | _stream = std::cout , |
LogPrintMode | _mode = PRINT_ITEM_BY_ITEM |
||
) | const |
Prints whole record into a stream; all items are printed according to the output format settings.
[in] | _stream | Stream to print the record. |
[in] | _mode | Print mode: see documentation of LogPrintMode of details. |
Definition at line 95 of file log_record.cpp.
returnValue LogRecord::printInfo | ( | ) | const |
Prints information on the record and its items on screen.
Definition at line 174 of file log_record.cpp.
|
inline |
Sets all numerical values at all time instants of the item with given name.
[in] | _name | Internal name of item. |
[in] | values | All numerical values at all time instants of given item. |
|
inline |
Sets all numerical values at all time instants of the item with given name.
[in] | _name | Internal name of item. |
[in] | values | All numerical values at all time instants of given item. |
returnValue LogRecord::setAll | ( | uint | _name, |
LogRecordItemType | _type, | ||
const MatrixVariablesGrid & | values | ||
) |
Sets all numerical values at all time instants of the item with given internal name and internal type.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
[in] | values | All numerical values at all time instants of given item. |
Definition at line 260 of file log_record.cpp.
|
inline |
Sets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[in] | lastValue | Numerical value at last time instant of given item. |
[in] | time | Time label of the instant. |
|
inline |
Sets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[in] | lastValue | Numerical value at last time instant of given item. |
[in] | time | Time label of the instant. |
|
inline |
Sets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[in] | lastValue | Numerical value at last time instant of given item. |
[in] | time | Time label of the instant. |
|
inline |
Sets numerical value at last time instant of the item with given name.
[in] | _name | Internal name of item. |
[in] | lastValue | Numerical value at last time instant of given item. |
[in] | time | Time label of the instant. |
returnValue LogRecord::setLast | ( | uint | _name, |
LogRecordItemType | _type, | ||
const DMatrix & | value, | ||
double | time = -INFTY |
||
) |
Sets numerical value at last time instant of the item with given internal name and internal type.
[in] | _name | Internal name of item. |
[in] | _type | Internal type of item. |
[in] | lastValue | Numerical value at last time instant of given item. |
[in] | time | Time label of the instant. |
Definition at line 292 of file log_record.cpp.
|
inline |
Sets the log frequency determining at which time instants the numerical values are to be stored.
[in] | _frequency | New log frequency |
|
inline |
Sets the print scheme defining the output format of the information.
@param[in] _printScheme New print scheme
returnValue LogRecord::updateLogRecord | ( | LogRecord & | _record | ) | const |
Update an existing record.
Definition at line 338 of file log_record.cpp.
|
friend |
Definition at line 74 of file log_record.hpp.
|
protected |
Alias index of record (-1 = no alias record).
Definition at line 661 of file log_record.hpp.
|
protected |
Frequency determining at which time instants the numerical values are to be stored.
Definition at line 663 of file log_record.hpp.
|
protected |
Log record items.
Definition at line 694 of file log_record.hpp.
|
protected |
Print scheme defining the output format of the information.
Definition at line 665 of file log_record.hpp.