CONOPT
Loading...
Searching...
No Matches
ConoptMessageHandler Class

Data Structures

class  ConoptMessageHandler
 The message handler class. More...
 

Enumerations

enum class  ConoptVerbosityLevel {
  ConoptVerbosityLevel::VerbLevelMin = 0 , ConoptVerbosityLevel::None , ConoptVerbosityLevel::Normal , ConoptVerbosityLevel::Error ,
  ConoptVerbosityLevel::Debug , ConoptVerbosityLevel::VerbLevelMax
}
 the verbosity level of the message handler More...
 

Functions

 ConoptMessageHandler::ConoptMessageHandler ()
 Constructor.
 
virtual ConoptMessageHandler::~ConoptMessageHandler ()
 Destructor.
 
virtual int ConoptMessageHandler::message (int smsg, int dmsg, int nmsg, const std::vector< std::string > &msgv)
 virtual method for handling the messages.
 
virtual int ConoptMessageHandler::errorMessage (int rowno, int colno, int posno, const std::string &msg)
 virtual method for handling error messages.
 
int ConoptMessageHandler::sendMessage (std::string msg)
 sends a message to the message handler
 
void ConoptMessageHandler::setVerbosityLevel (ConoptVerbosityLevel verblevel)
 sets the verbosity level for messaging.
 

Detailed Description

An optional class for providing a custom message handler.

Enumeration Type Documentation

◆ ConoptVerbosityLevel

enum class ConoptVerbosityLevel
strong

the verbosity level of the message handler

This is used for the default message handler ConoptMessageHandler.

Enumerator
VerbLevelMin 
None 

turn off all output

Normal 

normal output, iteration log to stdout and error to stderr

Error 

more detailed iteration log to stdout, error to stdout and stderr

Debug 

extensive iteration log, error to stdout and stderr

VerbLevelMax 

Definition at line 70 of file defines.h.

Function Documentation

◆ ConoptMessageHandler()

ConoptMessageHandler::ConoptMessageHandler ( )

Constructor.

◆ ~ConoptMessageHandler()

virtual ConoptMessageHandler::~ConoptMessageHandler ( )
virtual

Destructor.

◆ message()

virtual int ConoptMessageHandler::message ( int smsg,
int dmsg,
int nmsg,
const std::vector< std::string > & msgv )
virtual

virtual method for handling the messages.

This can be redefined by the user for alternative message handling

Attention
Mandatory callback routine. (Fortran and C API only. A default implementation is available in the other languages.)

General messages can be information for the iteration log, error messages, termination messages, and other generally useful information. The messages can be more than one line long and each line can be up to 132 characters long. There may be blank lines identified by LLEN(I) = 1 and MSGV(I)(1:1) = " " used to space the messages nicely, and some of the lines may be indented with leading blanks.

Messages are sent to three simultaneous streams or files and parts of the messages can be intended for one or more streams. These streams/files are:

  • The Screen file: These messages are intended for immediate display, showing the modeler the progress as it happens. The file has a small number of small messages plus an iteration log with lines for a subset of the iterations. The first SMSG lines are intended for this file.
  • The Status file: A summary file that after the model has been solved can be used to determine the status of the solution and whether there were any problems during the solution process. Error messages are more detailed than in the Screen file, but there is no iteration log. The file is intended to be saved with the solution. The first NMSG lines are intended for this file.
  • The Documentation file: A detailed description of the iteration process with one line per iteration plus detailed versions of all error and termination messages. The file is intended for experimentation and debugging. The first DMSG lines are intended for this file.

The modeler may implement all three streams or a subset of them. Note that SMSG, NMSG, or DMSG can be zero indicating that there are only messages for a subset for the files. Also note that the status file always will be a subset of the documentation file, i.e. NMSG will be less than or equal to DMSG. All messages start with the first line in MSGV.

Parameters
smsgThe number of lines in the message that should go to the Screen file. Between 0 and 30.
dmsgThe number of lines in the message that should go to the Status file. Between 0 and 30.
nmsgThe number of lines in the message that should go to the Documentation file. Between 0 and 30.
msgvVector with the actual message lines.

Reimplemented in Tut_MessageHandler.

◆ errorMessage()

virtual int ConoptMessageHandler::errorMessage ( int rowno,
int colno,
int posno,
const std::string & msg )
virtual

virtual method for handling error messages.

This can be redefined by the user for alternative message handling

Messages about particular parts of a model are all one line long. The messages can be related to an error or it can be a general informative message related to a row or column or Jacobian element. The modeler is responsible for combining the row and column identification and the message text and for displaying the overall message.

There are some special cases for the three first arguments and the message should be interpreted accordingly. The special cases are:

  • COLNO = -1: The message is about a row and ROWNO will be between 0 and NumCon-1.
  • ROWNO = -1: The message is about a column and COLNO will be between 0 and NumVar-1.
  • ROWNO and COLNO both non-negative: The message is about a position in the Jacobian if POSNO is non-negative and about a (row,column)-pair if POSNO is -1.

Examples of message texts are "Inconsistent lower and upper bounds." and "The variable has reached 'infinity.'" for a column, "The slack has reached 'infinity.'" for a row and "Initial Jacobian element was not defined." for a Jacobian element.

Parameters
rownoThe number of a row in the matrix.
colnoThe number of a column in the matrix.
posnoThe number of a Jacobian element in the matrix.
msgThe actual message.

Reimplemented in Tut_MessageHandler.

◆ sendMessage()

int ConoptMessageHandler::sendMessage ( std::string msg)

sends a message to the message handler

◆ setVerbosityLevel()

void ConoptMessageHandler::setVerbosityLevel ( ConoptVerbosityLevel verblevel)

sets the verbosity level for messaging.

The effect of this will depend on how the user implements the custom message handler