CONOPT
Loading...
Searching...
No Matches

General messaging callback and optional error reporting callback.

The Message and ErrMsg callback routines defined in this section must both be provided by the modeler. They use a vector of CHARACTER*132 variables (MSGV) or a CHARACTER*80 variable (MSG) as well as a message length information (LEN and MSGLEN) plus various control information.

If you implement your routines in another language than Fortran then you should be aware that there is no standard way of communicating character variables. Check your systems documentation, and make sure you re-check it if you move to another compiler or computer. We have included the C translation in the header file coiheader.h and in the following text.

Note
There will never be a new-line character or a null-character in a message.
All argument values except USRMEM are defined by CONOPT and they must not be changed.

The Progress and TriOrd callback routines described at the end of this section are both optional.


Message – General Message Routine

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 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.

Integer Function Message( SMSG, DMSG, NMSG, LLEN, &
USRMEM, MSGV )
INTEGER, Intent(IN) :: NMSG, SMSG
INTEGER, Dimension(*), Intent(IN) :: LLEN
CHARACTER*132, Dimension(*), Intent(IN) :: MSGV
REAL*8, Intent(IN OUT) :: USRMEM(*)

where:


ErrMsg – Error message for a Row, Column, or Jacobian element

Attention
Mandatory callback routine.

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.

Note
The messages sent via ErrMsg are intended both for the Status file and the Documentation file.

The Fortran definition of ErrMsg is:

Integer Function ErrMsg( ROWNO, COLNO, POSNO, MSGLEN, &
USRMEM, MSG )
INTEGER, Intent(IN) :: ROWNO, COLNO, POSNO, MSGLEN
CHARACTER*80, Intent(IN) :: MSG
REAL*8, Intent(IN OUT) :: USRMEM(*)

where:

There are some special cases for the three first arguments and the message should be interpreted accordingly. The special values depend on the Base. For Base = 1, i.e. Fortran conventions, the special cases are:

For Base = 0, i.e. C conventions, the special cases are:

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.


Progress – Algorithmic Progress

If the optional Progress routine has been registered, CONOPT will call it at the end of each iteration. The modeler may use the information in the arguments for displaying progress information or for monitoring individual variables.

The Fortran definition of Progress is:

Integer Function Progress( LEN_INT, INT, LEN_RL, RL, &
X, USRMEM )
INTEGER, Intent(IN) :: LEN_INT, LEN_RL
INTEGER, Intent(IN), Dimension(LEN_INT) :: INT
REAL*8, Intent(IN), Dimension(LEN_RL) :: RL
REAL*8, Intent(IN) :: X(*)
REAL*8, Intent(IN OUT) :: USRMEM(*)

where:

The user may tell CONOPT that the optimization should be stopped as soon as possible by letting Progress return a nonzero value. CONOPT will in this case call Status with SOLSTA = 8, user interrupt, and it will call Solution before returning. In an attempt to create a complete solution CONOPT may call FDEval for some post-triangular equations after Progress has returned a nonzero value. A zero return value means that CONOPT should continue the optimization.


TriOrd – Triangular Order information

When CONOPT solves a model, it tries to detect any part of the model that can be solved and removed before the optimization is started such as fixed variables and recursive or triangular equations. The variables and equations identified in this way can be solved independent of the optimization, and they can therefore be removed from the iterative optimization process.

If the optional callback routine TriOrd has been registered CONOPT will call TriOrd to report on the fixed variables and recursive equations. There are two types of calls distinguished with a MODE parameter. MODE = 1 (detection mode) is used during the actual solution process and it reports on all fixed variables, recursive equations and variables, implied bounds, etc as they are identified and solved. If the triangular solution process determines that the model is infeasible then CONOPT identifies the minimum set of equations and variables that cause this infeasibility, the so called critical equations and variables, and TriOrd is called again with MODE = 2 (critical reporting mode) for this subset of equations and variables in solution order. The first call in each sequence is called with negative MODE value (-1 and -2, respectively). This sign-feature can be used to write headers to the solution information.

If you are not interested in this information, do not register TriOrd. Otherwise, you may implement and register a routine that prints an appropriate message, possibly controlled by the value of MODE. Note that the number of times the routine will be called cannot be determined a priori; the calls will just stop when there are no recursive equations left or when the model is determined to be infeasible.

The Fortran definition of TriOrd is:

Integer Function TriOrd( MODE, TYPE, STATUS, ROWNO, COLNO,
INF, VALUE, RESID, USRMEM )
INTEGER, Intent(IN) :: MODE, TYPE, STATUS ROWNO, COLNO, INF
REAL*8, Intent(IN) :: VALUE, RESID
REAL*8, Intent(IN OUT) :: USRMEM(*)

where:

Comments: The terminology “Variable COLNO is the only variable appearing in equation or inequality ROWNO” means that the variable is the only variable left after previously reported variables have been removed.

The ROWNO argument identifies the number of the equation that is being solved. ROWNO equal to Base-1 (0 for Fortran and -1 for C) means that there is no equation which means that the variable COLNO is fixed through identical lower and upper bounds. Otherwise ROWNO is between 1 and NumCon for Fortran and between 0 and NumCon-1 for C calls. COLNO is usually the number of the variable that is being solved for and it has a value between 1 and NumVar for Fortran and between 0 and NumCon-1 for C. If the equation is solved for the slack variable, for example in case of inequalities, then COLNO will be Base-1 (0 for Fortran and -1 for C). VALUE is the final value of the variable or the slack and for structural variables it will always be between the bounds. RESID will usually be zero indicating that the equation was solved. In some special cases, COLNO, VALUE, and RESID may have to be interpreted differently:

CONOPT will stop searching for triangular equations when the model has been determined to be infeasible. If MODE = 1, CONOPT will start with a sequence of TriOrd calls with MODE = 2 for the critical subsequence of equations and variables, and if MODE = 2 then this will be the last call. CONOPT will also call the Message callback routine explaining the reason it stops just after the last call of TriOrd.