put_abortfunc

Sets an abort routine.

void put_abortfunc(lprec *lp, lphandle_intfunc newctrlc, void *ctrlchandle);

Return Value

put_abortfunc 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

newctrlc

The abort routine.

typedef int (__WINAPI lphandle_intfunc)(lprec *lp, void *userhandle);

Note the __WINAPI attribute. This is important under Windows. It ensures __stdcall calling convention which is required.

ctrlchandle

A parameter that will be provided to the abort routine.

Remarks

The put_abortfunc function sets an abort routine.
When set, the abort routine is called regularly. The user can do whatever he wants in this routine. For example check if the user pressed abort. The return value of this routine must be FALSE (0) or TRUE (1). If TRUE (1), then lp_solve aborts the solver and returns with an appropriate code. The abort routine can be cleared by specifying NULL as abort routine.
The default is no abort routine (NULL).

Example

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

int __WINAPI abortfunction(lprec *lp, void *userhandle)
{
 int doabort = FALSE;

 /* do something */

 return(doabort);
}

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_abortfunc(lp, abortfunction, NULL);

  solve(lp);

  delete_lp(lp);
  return(0);
}

lp_solve API reference

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