15.9 Function Types

MSKcallbackfunc
MSKint32t  (MSKAPI * MSKcallbackfunc) (
  MSKtask_t task,
  MSKuserhandle_t usrptr,
  MSKcallbackcodee caller,
  const MSKrealt * douinf,
  const MSKint32t * intinf,
  const MSKint64t * lintinf)

The progress callback function is a user-defined function which will be called by MOSEK occasionally during the optimization process. In particular, the callback function is called at the beginning of each iteration in the interior-point optimizer. For the simplex optimizers MSK_IPAR_LOG_SIM_FREQ controls how frequently the callback is called. The callback provides an code denoting the point in the solver from which the call happened, and a set of arrays containing information items related to the current state of the solver. Typically the user-defined callback function displays information about the solution process. The callback function can also be used to terminate the optimization process by returning a non-zero value.

The user must not call any MOSEK function directly or indirectly from the callback function. The only exception is the possibility to retrieve a current best integer solution from the mixed-integer optimizer, see Section Progress and data callback.

Parameters:
  • task (MSKtask_t) – An optimization task. (input)

  • usrptr (MSKuserhandle_t) – A pointer to a user-defined structure. (input/output)

  • caller (MSKcallbackcodee) – The caller key indicating the current progress of the solver. (input)

  • douinf (MSKrealt*) – An array of double information items. The elements correspond to the definitions in MSKdinfiteme. (input)

  • intinf (MSKint32t*) – An array of integer information items. The elements correspond to the definitions in MSKiinfiteme. (input)

  • lintinf (MSKint64t*) – An array of long information items. The elements correspond to the definitions in MSKliinfiteme. (input)

Return:

(MSKint32t) – If the return value is non-zero, MOSEK terminates whatever it is doing and returns control to the calling application.

MSKexitfunc
void  (MSKAPI * MSKexitfunc) (
  MSKuserhandle_t usrptr,
  const char * file,
  MSKint32t line,
  const char * msg)

A user-defined exit function which is called in case of fatal errors to handle an error message and terminate the program. The function should never return.

Parameters:
  • usrptr (MSKuserhandle_t) – A pointer to a user-defined structure. (input/output)

  • file (char*) – The name of the file where the fatal error occurred. (input)

  • line (MSKint32t) – The line number in the file where the fatal error occurred. (input)

  • msg (char*) – A message about the error. (input)

Return:

(void)

MSKhreadfunc
size_t  (MSKAPI * MSKhreadfunc) (
  MSKuserhandle_t handle,
  void * dest,
  const size_t count)

Behaves similarly to system read function. Returns the number of bytes read.

Parameters:
  • handle (MSKuserhandle_t) – A pointer to a user-defined data structure (or a null pointer). (input/output)

  • dest (void*) – Read into this destination (output)

  • count (size_t) – Number of bytes to read. (input)

Return:

(size_t) – The function response code.

MSKhwritefunc
size_t  (MSKAPI * MSKhwritefunc) (
  MSKuserhandle_t handle,
  const void * src,
  const size_t count)

Behaves similarly to system write function. Returns the number of bytes written.

Parameters:
  • handle (MSKuserhandle_t) – A pointer to a user-defined data structure (or a null pointer). (input/output)

  • src (void*) – Write from this location (input)

  • count (size_t) – Number of bytes to write. (input)

Return:

(size_t) – The function response code.

MSKresponsefunc
MSKrescodee  (MSKAPI * MSKresponsefunc) (
  MSKuserhandle_t handle,
  MSKrescodee r,
  const char * msg)

Whenever MOSEK generates a warning or an error this function is called. The argument r contains the code of the error/warning and the argument msg contains the corresponding error/warning message. This function should always return MSK_RES_OK.

Parameters:
  • handle (MSKuserhandle_t) – A pointer to a user-defined data structure (or a null pointer). (input/output)

  • r (MSKrescodee) – The response code corresponding to the exception. (input)

  • msg (char*) – A string containing the exception message. (input)

Return:

(MSKrescodee) – The function response code.

MSKstreamfunc
void  (MSKAPI * MSKstreamfunc) (
  MSKuserhandle_t handle,
  const char * str)

The message-stream callback function is a user-defined function which can be linked to any of the MOSEK streams. Doing so, the function is called whenever MOSEK sends a message to the stream.

The user must not call any MOSEK function directly or indirectly from the callback function.

Parameters:
  • handle (MSKuserhandle_t) – A pointer to a user-defined data structure (or a null pointer). (input/output)

  • str (char*) – A string containing a message to a stream. (input)

Return:

(void)