Reputation: 47
I am using Ilog Cplex with Visual C++ 2015 to solve my problem. How can I send a break signal to solver and make it return the best solution found so far?
Upvotes: 1
Views: 57
Reputation: 5930
I take it, you are using Concert C++. Handling Ctrl-C (or break) is not within the scope of CPLEX.
But there is the IloCplex::Aborter class. You can install a handler for Ctrl-C (see for example here). Then also install an aborter with the IloCplex
class and from the handler abort this aborter.
Of course, if your abort signal comes from a different source, you can use the same strategy: register and aborter and invoke its abort()
function to abort CPLEX.
After CPLEX has been aborted, the best solution found so far can be queried using getValues()
and getObjectiveValue()
. These functions always query the best feasible solution found so far, no matter whether it has been proven optimal or not.
Upvotes: 1