put_abortfunc

Sets a abort routine.

void put_abortfunc(lprec *lp, ctrlcfunc 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, read_lp, read_LP, read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

newctrlc

The abort routine.
typedef int ctrlcfunc(lprec *lp, void *userhandle);

ctrlchandle

A parameter that will be provided to the abort routine.

Remarks

The put_abortfunc function sets a 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 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, read_lp, read_LP, read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, put_logfunc