aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
logger.hpp
Go to the documentation of this file.
1
3#pragma once
4
5#include <string_view>
6#include <vector>
7#include <boost/unordered_map.hpp>
8
9namespace aligator {
10using uint = unsigned int;
11
12constexpr std::string_view int_format = "{: >{}d} ";
13constexpr std::string_view sci_format = "{: >{}.3e} ";
14constexpr std::string_view dbl_format = "{: >{}.3g} ";
15struct LogColumn {
16 std::string_view name;
17 std::string_view format;
19};
20
21// log columns names and widths
22static const LogColumn BASIC_KEYS[12] = {
23 {"iter", int_format, 5U}, {"alpha", sci_format, 10U},
24 {"inner_crit", sci_format, 11U}, {"prim_err", sci_format, 10U},
25 {"dual_err", sci_format, 10U}, {"preg", sci_format, 10U},
26 {"cost", sci_format, 10U}, {"dphi0", sci_format, 11U},
27 {"merit", sci_format, 10U}, {"ΔM", sci_format, 11U},
28 {"aliter", int_format, 7U}, {"mu", dbl_format, 7U}};
29
31struct Logger {
32 bool active = true;
33
35
37 void log();
38 void finish(bool conv);
39 void reset();
40
41 void addColumn(std::string_view name, uint width, std::string_view format);
42 void addColumn(LogColumn col) { addColumn(col.name, col.width, col.format); }
43
44 void addEntry(std::string_view name, double val);
45 void addEntry(std::string_view name, size_t val);
46
47protected:
48 // sizes and formats
49 std::vector<std::string_view> m_colNames;
50 boost::unordered_map<std::string_view, std::pair<uint, std::string>>
52 boost::unordered_map<std::string_view, std::string> m_currentLine;
53};
54
55} // namespace aligator
Main package namespace.
constexpr std::string_view sci_format
Definition logger.hpp:13
unsigned int uint
Definition logger.hpp:10
static const LogColumn BASIC_KEYS[12]
Definition logger.hpp:22
constexpr std::string_view dbl_format
Definition logger.hpp:14
constexpr std::string_view int_format
Definition logger.hpp:12
std::string_view format
Definition logger.hpp:17
std::string_view name
Definition logger.hpp:16
A table logging utility to log the trace of the numerical solvers.
Definition logger.hpp:31
std::vector< std::string_view > m_colNames
Definition logger.hpp:49
void addEntry(std::string_view name, double val)
void addEntry(std::string_view name, size_t val)
void addColumn(std::string_view name, uint width, std::string_view format)
boost::unordered_map< std::string_view, std::string > m_currentLine
Definition logger.hpp:52
boost::unordered_map< std::string_view, std::pair< uint, std::string > > m_colSpecs
Definition logger.hpp:51
void finish(bool conv)
void addColumn(LogColumn col)
Definition logger.hpp:42