MAiNGO
maingo::Logger Class Reference

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...
 
Loggeroperator= (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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Logger() [1/2]

maingo::Logger::Logger ( )
inline

Default constructor.

◆ Logger() [2/2]

maingo::Logger::Logger ( const Logger )
default

Default copy constructor.

◆ ~Logger()

maingo::Logger::~Logger ( )
inline

Default destructor.

Member Function Documentation

◆ clear()

void Logger::clear ( )

Clears all logging information.

◆ create_csv_files()

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.

Parameters
[in]pureMultistarttells whether the run was only a multistart
[in]printEveryLocalSearchtells whether the user wants to list every local search
[in]maxLocalSearchesis the number of performed local searches
[in]objectivesAtRootholds all objectives attained at the root node
[in]feasibleAtRootholds whether search i was feasible

◆ create_log_file()

void Logger::create_log_file ( bool  writeLog,
OUTSTREAM_VERB  givenOutstreamVerbosity 
)

Function used for creating the log file.

Parameters
[in]writeLogsays whether to write log
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ operator=()

Logger& maingo::Logger::operator= ( const Logger )
default

Default copy assignment.

◆ print_message()

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.

Parameters
[in]messageis the message to be printed or written
[in]writeLogsays whether to write log
[in]verbosityGivenis the verbosity given by, e.g., settings
[in]verbosityNeededis the least verbosity needed for the message to be printed/written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ print_message_to_stream_only()

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.

Parameters
[in]messageis the message to be printed or written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ print_settings()

void Logger::print_settings ( bool  writeLog,
VERB  verbosityGiven,
VERB  verbosityNeeded,
OUTSTREAM_VERB  givenOutstreamVerbosity 
)

Function for printing and writing user-set settings.

Parameters
[in]writeLogsays whether to write log
[in]verbosityGivenis the verbosity given by, e.g., settings
[in]verbosityNeededis the least verbosity needed for the message to be printed/written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ save_setting()

void Logger::save_setting ( SETTING_NAMES  settingName,
const std::string &  str 
)

Function used for saving the user-set settings.

Parameters
[in]settingNameis the changed setting
[in]stris the corresponding string

◆ save_settings_file_name()

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.

Parameters
[in]fileNameit the name of the file set by the user
[in]fileFoundtells whether the wanted file has been found

◆ set_output_stream()

void Logger::set_output_stream ( std::ostream *  outputStream)

Sets output stream.

Parameters
[in,out]outputStreamis the new output stream to be used by MAiNGO.

◆ write_all_iterations_to_csv()

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.

Parameters
[in]errmsgis a possible additional error message

◆ write_all_lines_to_log()

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.

Parameters
[in]errmsgis a possible additional error message

Member Data Documentation

◆ _nSettingFiles

unsigned int maingo::Logger::_nSettingFiles = 0
private

number of setting files from which the user has read, default is set to 0

◆ _outStream

std::ostream* maingo::Logger::_outStream = &std::cout
private

default MAiNGO output stream is set to std::cout

◆ _userSetSettings

std::map<int, std::string> maingo::Logger::_userSetSettings
private

map holding settings set by the user

◆ babLine

std::queue<std::string> maingo::Logger::babLine

queue for storing lines of B&B output

◆ babLineCsv

std::queue<std::string> maingo::Logger::babLineCsv

queue for storing lines of B&B output for CSV file

◆ csvGeneralName

std::string maingo::Logger::csvGeneralName

string storing name of the csv general file

◆ csvIterationsName

std::string maingo::Logger::csvIterationsName

string storing name of the csv iterations file

◆ logFileName

std::string maingo::Logger::logFileName

string storing name of the log file

◆ reachedMinNodeSize

bool maingo::Logger::reachedMinNodeSize

bool for saving information if minimum node size has been reached within B&B

◆ resFileName

std::string maingo::Logger::resFileName

string storing name of the res file


The documentation for this class was generated from the following files: