linopy
linopy copied to clipboard
Wish to add model.interrupt()/terminate() to api
In some cases, when solving a certain MIP problem, the solver may become slow. If the solver is called through an API request, it is not possible to directly stop the process using Ctrl+C. Instead, the interrupt feature of the solver itself needs to be used. Time Limit can be used to terminate models. However, if the solution time of the model ranges from 20 seconds to 1 hour, and the length of the solution time is not known in advance, it is difficult to control it through time limit.
Gurobi https://www.gurobi.com/documentation/current/refman/py_model_terminate.html COPT https://guide.coap.online/copt/zh-doc/pyapiref.html#model-interrupt Cplex https://www.ibm.com/docs/en/icos/22.1.0?topic=users-example-complex-termination-criteria-in-callback
Thanks for raising this @loongmxbt. What do you have in mind as a command? If the model is being solved, the python shell cannot be accessed. So it would not make sense to have a model.interrrupt() call, right? Perhaps a ctrl+c call would be more suitable?
Thanks for your reply, I have now bypassed this problem through other methods. I think this may be a feature for C/S application. If the client side send a calculation task, the server side consumes the task and begin the calculation. Thus the client side cannot terminate the task directly, the client side may send another api call to terminate cplex/gurobi and the task it self. We know sometimes the calculation may stuck at some point. Pretty much like the repo here: https://github.com/AlexKressner/OptiDeploy