[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Interrupting GLPK on demand

From: Heinrich Schuchardt
Subject: Re: [Help-glpk] Interrupting GLPK on demand
Date: Mon, 14 Oct 2019 19:11:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hello Szabolcs,

you can create a terminal hook function (see glp_term_hook()). In this
hook function you can trigger an abort using glp_error(). Use a error
hook function (see glp_error_hook()) to catch the error and longjmp() to
return to the setjmp() in the calling program.

An example in Java is available as:

An example for an error hook function in C is available as:

Best regards


On 10/14/19 2:45 PM, Szabolcs Horvát wrote:

Is there a way to interrupt GLPK without killing the entire process?

I am interested in terminating glp_intopt(). In principle, this is
possible by calling glp_ios_terminate() from the callback function
passed to glp_intopt(). However, glp_intopt() will internally call
glp_simplex(), which may take a very long time. Thus in practice this
does not work. I could not find any way to interrupt glp_simplex() on
demand.  It is possible to set a time limit (tm_lim in glp_smcp), but
this is not what I need. I would like to have the ability to
interactively interrupt the computation.

For example, glp_simplex() could periodically call a user-supplied
function. If this function returns "true", the computation should be
interrupted gracefully.

I do not need a partial result to be returned. I simply need a clean
interruption, with the resources used by the function properly cleaned
up (e.g. no unreleased memory). I assume that this is possible, since
a time limit is already implemented. In principle, I could even look
up the part of the code that checks the time, and add an additional
interruption check. I am wondering why this wasn't implemented
already, and whether simply doing this would cause any problems. Some
old messages posted to this mailing list seem to suggest that
implementing interruption may not be easy, which seems to be in
contradiction with the fact that a time limit is already implemented.


  - Is there a way to interrupt glp_intopt() cleanly and reliably?
  - If not, consider this a feature request. Please add this functionality.
  - Would there be an issue with extending the time-limit check to also
call a user-supplied interruption-check function?

Use case:

I am not very familiar with ILP solvers. I am actually using graph
theory code that relies on GLPK. I am using this code from a
high-level language that is typically used interactively (think Python
in a Jupyter notebook). Given the nature of the problems that GLPK
solves, it is very hard to predict how long a computation would take.
It could be seconds or days. Therefore, it is important to be able to
interrupt computations gracefully, without needing to kill the entire

In particular, this problem came up while working on the igraph

Best regards,

Help-glpk mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]