# put_msgfunc

Sets a message routine.

void put_msgfunc(lprec *lp, lphandleint_func newmsg, void *msghandle, int mask);

Return Value

put_msgfunc has no return value.

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

newmsg

The message routine.
typedef void (__WINAPI lphandleint_func)(lprec *lp, void *userhandle, int message);
Note the __WINAPI attribute. This is important under Windows. It ensures __stdcall calling convention which is required.

msghandle

A parameter that will be provided to the message routine.

mask

Any combination of the following values:

MSG_PRESOLVE (1) | Presolve done.
MSG_ITERATION (2) |
MSG_INVERT (4) |
MSG_LPFEASIBLE (8) | Feasible solution found.
MSG_LPOPTIMAL (16) | Real optimal solution found. Only fired when there are integer variables at the start of B&B
MSG_LPEQUAL (32) |
MSG_LPBETTER (64) |
MSG_MILPFEASIBLE (128) | First MILPsolution found. Only fired when there are integer variables during B&B
MSG_MILPEQUAL (256) | Equal MILP solution found. Only fired when there are integer variables during B&B
MSG_MILPBETTER (512) | Better MILPsolution found. Only fired when there are integer variables during B&B
MSG_MILPSTRATEGY (1024) |
MSG_MILPOPTIMAL (2048) |
MSG_PERFORMANCE (4096) |
MSG_INITPSEUDOCOST (8192) |

Remarks

The put_msgfunc function sets a message routine. This routine is called when a situation specified in mask occurs. Note that this routine is called while solving the model. This can be useful to follow the solving progress.

Example

    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.h"

    void __WINAPI msgfunction(lprec *lp, void *userhandle, int msg)
    {
     switch(msg) {
     case MSG_LPFEASIBLE:
      printf("Feasible solution found\n");
      break;
     case MSG_MILPFEASIBLE:
      printf("Integer feasible solution found\n");
      break;
     case MSG_MILPBETTER:
      printf("Better integer feasible solution found\n");
      break;
     }
    }

    int main(void)
    {
      lprec *lp;

      /* Create a new LP model */
      lp = make_lp(0, 0);
      if(lp == NULL) {
        fprintf(stderr, "Unable to create new LP model\n");
        return(1);
      }

      put_msgfunc(lp, msgfunction, NULL, MSG_LPFEASIBLE | MSG_MILPFEASIBLE | MSG_MILPBETTER);

      delete_lp(lp);
      return(0);
    }

lp_solve API reference

See Also make_lp, copy_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, put_abortfunc