put_msgfunc
Sets a message routine.
void put_msgfunc(lprec *lp, msgfunc 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, read_lp, read_LP,
read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI
newmsg
The message routine.
typedef void msgfunc(lprec *lp, void *userhandle, int message);
msghandle
A parameter that will be provided to the message routine.
mask
Any combination of the following values:
MSG_PRESOLVE (1) |
Presolve done |
MSG_LPFEASIBLE (8) |
Feasible solution found |
MSG_LPOPTIMAL (16) |
Real optimal solution found |
MSG_MILPEQUAL (32) |
Equal MILP solution found |
MSG_MILPFEASIBLE (128) |
First MILPsolution found |
MSG_MILPBETTER (512) |
Better MILPsolution found |
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 usefull to follow the solving progress.
Example
#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"
int 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;
}
return(0);
}
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, read_lp,
read_LP, read_lpt, read_LPT,
read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, put_abortfunc
|