![]() |
MAiNGO
|
This class contains all logging and output information. More...
#include <logger.h>
Public Member Functions | |
Logger () | |
Default constructor. More... | |
Logger (const Logger &)=default | |
Default copy constructor. More... | |
Logger & | operator= (const Logger &)=default |
Default copy assignment. More... | |
~Logger () | |
Default destructor. More... | |
void | print_message (const std::string &message, bool writeLog, VERB verbosityGiven, VERB verbosityNeeded, OUTSTREAM_VERB givenOutstreamVerbosity) |
The main function used for printing a given message and storing it in log and/or csv. More... | |
void | print_message_to_stream_only (const std::string &message, OUTSTREAM_VERB givenOutstreamVerbosity) |
The main function used for printing a given message and storing it in log and/or csv. More... | |
void | set_output_stream (std::ostream *outputStream) |
Sets output stream. More... | |
void | create_log_file (bool writeLog, OUTSTREAM_VERB givenOutstreamVerbosity) |
Function used for creating the log file. More... | |
void | create_csv_files (bool pureMultistart, bool printEveryLocalSearch, unsigned int maxLocalSearches, const std::vector< double > &objectivesAtRoot, const std::vector< SUBSOLVER_RETCODE > &feasibleAtRoot) |
Function used for creating the csv files. More... | |
void | write_all_lines_to_log (const std::string &errmsg="") |
Function used for writing all lines stored in queue babLine to log with name logFileName. More... | |
void | write_all_iterations_to_csv (const std::string &errmsg="") |
Function used for writing all lines stored in queue babCsv to csv file with name csvIterationsName. More... | |
void | save_settings_file_name (const std::string &fileName, bool fileFound) |
Function used for saving the names of setting files set by the user. More... | |
void | save_setting (SETTING_NAMES settingName, const std::string &str) |
Function used for saving the user-set settings. More... | |
void | print_settings (bool writeLog, VERB verbosityGiven, VERB verbosityNeeded, OUTSTREAM_VERB givenOutstreamVerbosity) |
Function for printing and writing user-set settings. More... | |
void | clear () |
Clears all logging information. More... | |
Public Attributes | |
Auxiliary public variables for storing output and logging information | |
std::queue< std::string > | babLine |
std::queue< std::string > | babLineCsv |
std::string | logFileName |
std::string | resFileName |
std::string | csvIterationsName |
std::string | csvGeneralName |
bool | reachedMinNodeSize |
Private Attributes | |
Private variable storing the output | |
std::ostream * | _outStream = &std::cout |
unsigned int | _nSettingFiles = 0 |
std::map< int, std::string > | _userSetSettings |
This class contains all logging and output information.
This class is used by the MAiNGO, BranchAndBound, LowerBoundingSolver and UpperBoundingSolver classes for a central and proper storing of output and logging information.
|
inline |
Default constructor.
|
default |
Default copy constructor.
|
inline |
Default destructor.
void Logger::clear | ( | ) |
Clears all logging information.
void Logger::create_csv_files | ( | bool | pureMultistart, |
bool | printEveryLocalSearch, | ||
unsigned int | maxLocalSearches, | ||
const std::vector< double > & | objectivesAtRoot, | ||
const std::vector< SUBSOLVER_RETCODE > & | feasibleAtRoot | ||
) |
Function used for creating the csv files.
[in] | pureMultistart | tells whether the run was only a multistart |
[in] | printEveryLocalSearch | tells whether the user wants to list every local search |
[in] | maxLocalSearches | is the number of performed local searches |
[in] | objectivesAtRoot | holds all objectives attained at the root node |
[in] | feasibleAtRoot | holds whether search i was feasible |
void Logger::create_log_file | ( | bool | writeLog, |
OUTSTREAM_VERB | givenOutstreamVerbosity | ||
) |
Function used for creating the log file.
[in] | writeLog | says whether to write log |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_message | ( | const std::string & | message, |
bool | writeLog, | ||
VERB | verbosityGiven, | ||
VERB | verbosityNeeded, | ||
OUTSTREAM_VERB | givenOutstreamVerbosity | ||
) |
The main function used for printing a given message and storing it in log and/or csv.
[in] | message | is the message to be printed or written |
[in] | writeLog | says whether to write log |
[in] | verbosityGiven | is the verbosity given by, e.g., settings |
[in] | verbosityNeeded | is the least verbosity needed for the message to be printed/written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_message_to_stream_only | ( | const std::string & | message, |
OUTSTREAM_VERB | givenOutstreamVerbosity | ||
) |
The main function used for printing a given message and storing it in log and/or csv.
[in] | message | is the message to be printed or written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_settings | ( | bool | writeLog, |
VERB | verbosityGiven, | ||
VERB | verbosityNeeded, | ||
OUTSTREAM_VERB | givenOutstreamVerbosity | ||
) |
Function for printing and writing user-set settings.
[in] | writeLog | says whether to write log |
[in] | verbosityGiven | is the verbosity given by, e.g., settings |
[in] | verbosityNeeded | is the least verbosity needed for the message to be printed/written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::save_setting | ( | SETTING_NAMES | settingName, |
const std::string & | str | ||
) |
Function used for saving the user-set settings.
[in] | settingName | is the changed setting |
[in] | str | is the corresponding string |
void Logger::save_settings_file_name | ( | const std::string & | fileName, |
bool | fileFound | ||
) |
Function used for saving the names of setting files set by the user.
[in] | fileName | it the name of the file set by the user |
[in] | fileFound | tells whether the wanted file has been found |
void Logger::set_output_stream | ( | std::ostream * | outputStream | ) |
Sets output stream.
[in,out] | outputStream | is the new output stream to be used by MAiNGO. |
void Logger::write_all_iterations_to_csv | ( | const std::string & | errmsg = "" | ) |
Function used for writing all lines stored in queue babCsv to csv file with name csvIterationsName.
[in] | errmsg | is a possible additional error message |
void Logger::write_all_lines_to_log | ( | const std::string & | errmsg = "" | ) |
Function used for writing all lines stored in queue babLine to log with name logFileName.
[in] | errmsg | is a possible additional error message |
|
private |
number of setting files from which the user has read, default is set to 0
|
private |
default MAiNGO output stream is set to std::cout
|
private |
map holding settings set by the user
std::queue<std::string> maingo::Logger::babLine |
queue for storing lines of B&B output
std::queue<std::string> maingo::Logger::babLineCsv |
queue for storing lines of B&B output for CSV file
std::string maingo::Logger::csvGeneralName |
string storing name of the csv general file
std::string maingo::Logger::csvIterationsName |
string storing name of the csv iterations file
std::string maingo::Logger::logFileName |
string storing name of the log file
bool maingo::Logger::reachedMinNodeSize |
bool for saving information if minimum node size has been reached within B&B
std::string maingo::Logger::resFileName |
string storing name of the res file