> I am currently modifying the GLPKMEX interface to GLPK (Matlab > interface) and wish to be able to terminate a call to GLPK if a user > was to say push Ctrl-C, and return the current best solution. I have > read through the documentation and have tried glp_error() however this > also causes Matlab to crash (not sure if I have done something wrong), > but wondered if there was a cleaner way? > > I am imagining an event handler which could be passed to GLPK before > glp_simplex() or another solver is called, which is then called by the > solver each iteration (with perhaps some runtime information), and a > return code passed back to indicate whether to continue or stop. > > I apologize if this already exists in GLPK however I have been unable > to find it! >
No, such feature does not exist in glpk, and it would be problematic to implement it in a way which you wish. Currently only glp_intopt allows correct asynchronous termination. To implement that you need to pass to glp_intopt your own callback, which checks a termination flag every time it is called from glp_intopt, and if that flag is set (by your signal handler when it catches the SIGTERM signal), it should return a non-zero to tell glp_intopt to terminate with return code GLP_ESTOP, in which case the best solution will be correctly stored in the problem object. Other solvers (glp_simplex and glp_interior) do not provide such feature, so the only way to terminate them is to catch SIGTERM, call longjmp, and then call glp_free_env to free all resources used by glpk routines (e.g. memory allocated by glp_simplex) before return to a Matlab control program. _______________________________________________ Help-glpk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-glpk
